:root {
  --primary: #388e3c;
  --primary-light: #4caf50;
  --border: #81c784;
  --hover-bg: #f1f8e9;
  --text: #2c3e50;
  --text-muted: #555;
  --bg: #ffffff;
  --code-bg: #f6f8f6;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family:
    -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', Arial,
    'Hiragino Kaku Gothic ProN', 'Hiragino Sans', Meiryo, sans-serif;
  font-size: 16px;
  line-height: 1.75;
  color: var(--text);
  background: linear-gradient(180deg, #ffffff 0%, #f9fbf8 100%);
}

header.page-header {
  position: relative;
  background: linear-gradient(135deg, #388e3c 0%, #4caf50 100%);
  color: #fff;
  padding: 2.5rem 1rem 2rem;
}

header.page-header .header-actions {
  position: absolute;
  top: 0.85rem;
  right: 0.85rem;
  display: inline-flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.5rem;
}

header.page-header .header-action {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.75rem;
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 600;
  line-height: 1.2;
  transition:
    background-color 0.15s ease,
    border-color 0.15s ease;
}

header.page-header .header-action:hover {
  background: rgba(255, 255, 255, 0.22);
  border-color: #ffffff;
}

header.page-header .header-action:focus-visible {
  outline: 2px solid #ffffff;
  outline-offset: 2px;
}

header.page-header .header-action svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

/* BMC 公式ロゴは細部が密集していて 14px ではほぼ視認不可。 */
/* SupportLinks.tsx と同じ 20px に揃えてカップ部分が見えるサイズにする。 */
header.page-header .header-action img {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

header.page-header .inner {
  max-width: 880px;
  margin: 0 auto;
}

header.page-header h1 {
  margin: 0 0 0.5rem;
  font-size: clamp(1.4rem, 4vw, 2rem);
  line-height: 1.3;
}

header.page-header p {
  margin: 0;
  font-size: 0.95rem;
  opacity: 0.95;
}

.breadcrumb {
  max-width: 880px;
  margin: 1rem auto 0;
  padding: 0 1rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.breadcrumb a {
  color: var(--primary);
  text-decoration: none;
}

.breadcrumb a:hover {
  text-decoration: underline;
}

main {
  max-width: 880px;
  margin: 0 auto;
  padding: 2rem 1rem 4rem;
}

nav.toc {
  background: var(--hover-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem 1.5rem;
  margin-bottom: 2.5rem;
}

nav.toc h2 {
  margin: 0 0 0.5rem;
  font-size: 1rem;
  color: var(--primary);
}

nav.toc ol {
  margin: 0;
  padding-left: 1.5rem;
}

nav.toc li {
  margin: 0.25rem 0;
}

nav.toc a {
  color: var(--text);
  text-decoration: none;
}

nav.toc a:hover {
  color: var(--primary);
  text-decoration: underline;
}

section {
  margin-bottom: 3rem;
}

h2 {
  color: var(--primary);
  border-bottom: 2px solid var(--border);
  padding-bottom: 0.4rem;
  margin: 0 0 1rem;
  font-size: 1.5rem;
  scroll-margin-top: 1rem;
}

h3 {
  color: var(--text);
  margin: 1.75rem 0 0.75rem;
  font-size: 1.15rem;
  border-left: 4px solid var(--primary-light);
  padding-left: 0.6rem;
}

.dp-subheading {
  color: var(--text);
  margin: 1.25rem 0 0.5rem;
  font-size: 1rem;
  font-weight: 600;
}

table.dp-trace {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
}

table.dp-trace th,
table.dp-trace td {
  border: 1px solid #d4e2d2;
  padding: 0.4rem 0.6rem;
  text-align: center;
}

table.dp-trace th {
  background: var(--hover-bg);
  color: var(--primary);
  font-weight: 600;
}

table.dp-trace tbody tr.highlight {
  background: #fff8e1;
}

table.dp-trace td.label {
  background: #fafdf9;
  font-weight: 600;
  color: var(--text-muted);
}

p {
  margin: 0.75rem 0;
}

ul,
ol {
  padding-left: 1.5rem;
}

li {
  margin: 0.25rem 0;
}

code {
  background: var(--code-bg);
  border: 1px solid #e0e8df;
  border-radius: 3px;
  padding: 0.05em 0.35em;
  font-family:
    ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Monaco, Consolas, 'Liberation Mono',
    'Courier New', monospace;
  font-size: 0.9em;
}

.callout {
  background: var(--hover-bg);
  border-left: 4px solid var(--primary);
  padding: 0.75rem 1rem;
  margin: 1rem 0;
  border-radius: 0 4px 4px 0;
}

.callout strong {
  color: var(--primary);
}

table.values {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
  font-size: 0.95rem;
}

table.values th,
table.values td {
  border: 1px solid #d4e2d2;
  padding: 0.5rem 0.75rem;
  text-align: left;
}

table.values th {
  background: var(--hover-bg);
  color: var(--primary);
  font-weight: 600;
}

table.values tbody tr:nth-child(even) {
  background: #fafdf9;
}

figure.diagram {
  margin: 1.25rem 0;
  text-align: center;
}

/* SVG はファイルに切り出し <img> で読み込む。線・色は SVG 内 <style> に内包。 */
figure.diagram img.rbd-diagram {
  max-width: 100%;
  height: auto;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.75rem 1rem;
  box-sizing: border-box;
}

figure.diagram figcaption {
  margin-top: 0.5rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.formula-block {
  overflow-x: auto;
  padding: 0.5rem 0;
}

footer.page-footer {
  border-top: 1px solid var(--border);
  background: var(--hover-bg);
  padding: 1.5rem 1rem;
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-muted);
}

footer.page-footer a {
  color: var(--primary);
  text-decoration: none;
}

footer.page-footer a:hover {
  text-decoration: underline;
}

footer.page-footer .footer-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem 1rem;
  margin-top: 1rem;
  font-size: 0.85rem;
}

/* footer.page-footer a の詳細度に勝つため、同じ詳細度以上で色を指定する */
footer.page-footer a.back-to-tool {
  display: inline-block;
  margin-top: 0.75rem;
  padding: 0.5rem 1.25rem;
  background: var(--primary);
  color: #ffffff;
  border-radius: 4px;
  text-decoration: none;
  font-weight: 600;
}

footer.page-footer a.back-to-tool:hover {
  background: #2e7d32;
  color: #ffffff;
  text-decoration: none;
}

header.page-header .header-cta {
  display: inline-block;
  margin-top: 0.5rem;
  color: #ffffff;
  text-decoration: underline;
  text-underline-offset: 3px;
  font-weight: 600;
}

header.page-header .header-cta:hover {
  opacity: 0.85;
}
