:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --ink: #17202a;
  --muted: #5d6b78;
  --line: #d9e0e7;
  --blue: #2f6fed;
  --green: #138a63;
  --amber: #d89112;
  --red: #c44747;
  --shadow: 0 18px 50px rgba(23, 32, 42, 0.09);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family:
    "Noto Sans TC",
    "Microsoft JhengHei",
    system-ui,
    sans-serif;
  line-height: 1.65;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 18px clamp(18px, 4vw, 56px);
  background: rgba(246, 247, 249, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}

.topbar h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.2;
}

.eyebrow,
.section-label {
  margin: 0 0 6px;
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

nav a {
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
  font-weight: 700;
  padding: 8px 10px;
  border-radius: 6px;
}

nav a:hover {
  color: var(--ink);
  background: #e9edf3;
}

main {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 34px 0 64px;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.8fr);
  gap: 28px;
  align-items: stretch;
  margin-bottom: 28px;
}

.hero-copy,
.hero-panel,
.architecture,
.definitions,
.calculator,
.benchmark-notes {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.hero-copy {
  padding: clamp(24px, 5vw, 44px);
}

.hero-copy h2,
.calculator h2,
.benchmark-notes h2 {
  margin: 0 0 12px;
  font-size: clamp(28px, 4vw, 46px);
  line-height: 1.16;
}

.hero-copy p,
.calculator p,
.benchmark-notes p {
  margin: 0;
  color: var(--muted);
}

.hero-panel {
  display: grid;
  align-items: center;
  padding: 28px;
}

.flow {
  display: grid;
  gap: 8px;
}

.flow span {
  display: block;
  padding: 14px 16px;
  color: #10335d;
  font-weight: 800;
  background: #edf4ff;
  border: 1px solid #c7dcff;
  border-radius: 8px;
}

.flow i {
  display: grid;
  place-items: center;
  height: 18px;
  color: var(--blue);
  font-style: normal;
  font-size: 18px;
  font-weight: 900;
  line-height: 1;
}

.architecture {
  margin-bottom: 28px;
  padding: clamp(22px, 4vw, 36px);
}

.definitions {
  margin-bottom: 28px;
  padding: clamp(22px, 4vw, 36px);
}

.section-heading {
  max-width: 920px;
  margin-bottom: 22px;
}

.section-heading h2 {
  margin: 0 0 12px;
  font-size: clamp(26px, 3.4vw, 40px);
  line-height: 1.18;
}

.section-heading p:last-child {
  margin: 0;
  color: var(--muted);
}

.architecture-grid {
  display: block;
  margin-top: 22px;
}

.paper-figure {
  margin: 0 0 22px;
  padding: 14px;
  background: #fbfcfe;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.paper-figure img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 6px;
  background: #fff;
}

.paper-figure figcaption {
  margin-top: 10px;
  color: var(--muted);
  font-size: 14px;
}

.architecture-diagram {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 28px minmax(180px, 1fr) 28px minmax(180px, 1fr) 28px minmax(150px, 0.8fr);
  gap: 10px;
  align-items: center;
  overflow-x: auto;
  padding: 18px;
  background: #fbfcfe;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.arch-block {
  min-width: 180px;
  padding: 14px;
  border: 1px dashed #aebdcc;
  border-radius: 8px;
  background: #ffffff;
}

.arch-block h3 {
  margin: 0 0 10px;
  font-size: 15px;
  color: #123967;
}

.arch-flow {
  display: grid;
  gap: 8px;
}

.arch-flow span {
  display: block;
  padding: 9px 10px;
  border-radius: 7px;
  background: #eef4fb;
  border: 1px solid #d3e0ee;
  font-size: 13px;
  font-weight: 800;
}

.exploration .arch-flow span {
  background: #f1f7ff;
}

.inference .arch-flow span {
  background: #f6f1ff;
  border-color: #dfd0fb;
}

.aggregation .arch-flow span {
  background: #f0faf5;
  border-color: #c7ead9;
}

.tests .arch-flow span {
  background: #fff7e8;
  border-color: #efd6a8;
}

.arch-arrow {
  color: var(--blue);
  font-size: 24px;
  font-weight: 900;
  text-align: center;
}

.architecture-steps {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin: 0 0 22px;
}

.architecture-steps article {
  padding: 14px 16px;
  background: #fbfcfe;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.architecture-steps strong {
  display: block;
  margin-bottom: 4px;
  color: #123967;
}

.architecture-steps p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.definition-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.definition-card {
  padding: 20px;
  background: #fbfcfe;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.definition-card > h3 {
  margin: 0 0 10px;
  font-size: 24px;
}

.definition-card > p {
  margin: 0 0 16px;
  color: var(--muted);
}

.definition-subcard {
  margin-top: 14px;
  padding: 16px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.definition-subcard h4 {
  margin: 0 0 8px;
  font-size: 17px;
}

.definition-subcard p {
  margin: 0 0 10px;
  color: var(--muted);
}

.definition-subcard ol,
.definition-subcard ul {
  margin: 0;
}

.definition-subcard li {
  margin-bottom: 8px;
}

.formula-box.compact {
  margin: 10px 0 12px;
  padding: 10px 12px;
  font-size: 16px;
}

.layout {
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.formula-nav {
  position: sticky;
  top: 94px;
  display: grid;
  gap: 10px;
}

.nav-item {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  color: var(--ink);
  background: var(--surface);
  font: inherit;
  font-weight: 800;
  text-align: left;
  cursor: pointer;
}

.nav-item span {
  display: block;
  margin-bottom: 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.nav-item.active {
  color: #0f3d7a;
  border-color: #a9c7ff;
  background: #edf4ff;
}

.formula-stage {
  min-height: 490px;
}

.formula-card {
  display: none;
  min-height: 490px;
  padding: clamp(22px, 4vw, 36px);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.formula-card.active {
  display: block;
}

.formula-card h2 {
  margin: 0 0 18px;
  font-size: clamp(24px, 3vw, 36px);
  line-height: 1.2;
}

.formula-box {
  overflow-x: auto;
  margin: 18px 0 24px;
  padding: 18px;
  color: #10243d;
  background: #f1f5fb;
  border: 1px solid #cfdbea;
  border-radius: 8px;
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: clamp(15px, 2vw, 20px);
  line-height: 1.7;
}

.deep-dive {
  margin-top: 20px;
  border: 1px solid #cfdbea;
  border-radius: 8px;
  background: #f7faff;
}

.deep-dive summary {
  padding: 15px 18px;
  color: #123967;
  font-weight: 900;
  cursor: pointer;
  list-style-position: inside;
}

.deep-dive[open] summary {
  border-bottom: 1px solid #dce7f5;
}

.deep-content {
  padding: 18px;
}

.deep-content h3 {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid #e0e8f2;
}

.deep-content h3:first-child {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

.deep-content p {
  margin: 0 0 12px;
}

.plain-formula {
  overflow-x: auto;
  margin: 12px 0 16px;
  padding: 12px 14px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.takeaway {
  margin-top: 16px !important;
  padding: 14px 16px;
  color: #0d4b36;
  background: #edf8f3;
  border: 1px solid #bfe7d6;
  border-radius: 8px;
  font-weight: 800;
}

.explain-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.explain-grid > div,
.callout {
  padding: 18px;
  background: #fbfcfe;
  border: 1px solid var(--line);
  border-radius: 8px;
}

h3 {
  margin: 0 0 8px;
  font-size: 18px;
}

ul {
  margin: 0;
  padding-left: 20px;
}

.demo-chain {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 22px 0;
}

.chain-step {
  min-height: 64px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #fff;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.chain-step.active {
  color: #fff;
  background: var(--green);
  border-color: var(--green);
}

.mini-control label {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  font-weight: 800;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--blue);
}

.score-bars {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.score-row {
  display: grid;
  grid-template-columns: 72px 1fr 70px;
  gap: 10px;
  align-items: center;
  font-size: 13px;
  color: var(--muted);
}

.score-bar {
  height: 12px;
  overflow: hidden;
  background: #e7ecf3;
  border-radius: 999px;
}

.score-bar span {
  display: block;
  height: 100%;
  background: var(--blue);
}

.calculator {
  margin-top: 28px;
  padding: clamp(22px, 4vw, 36px);
}

.coverage-demo {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr) 240px;
  gap: 18px;
  margin-top: 22px;
}

.feature-list,
.test-matrix,
.result-panel {
  padding: 16px;
  background: #fbfcfe;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.feature-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  padding: 10px;
  border-radius: 8px;
  background: #fff;
  border: 1px solid var(--line);
}

.feature-dot {
  width: 12px;
  height: 12px;
  flex: 0 0 12px;
  border-radius: 50%;
  background: #bac5d0;
}

.feature-pill.covered .feature-dot {
  background: var(--green);
}

.test-row {
  display: grid;
  grid-template-columns: 86px repeat(5, minmax(58px, 1fr));
  gap: 8px;
  align-items: center;
  margin-bottom: 10px;
}

.test-row strong {
  font-size: 14px;
}

.test-row label {
  display: grid;
  place-items: center;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
}

.test-row input {
  width: 18px;
  height: 18px;
  accent-color: var(--green);
}

.result-panel {
  display: grid;
  align-content: center;
}

.result-panel p {
  margin: 0;
}

.result-panel strong {
  display: block;
  margin: 6px 0 12px;
  font-size: 28px;
}

.meter {
  height: 14px;
  overflow: hidden;
  background: #e5eaf0;
  border-radius: 999px;
}

.meter span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--green);
  transition: width 0.2s ease;
}

#coverageResult {
  margin-top: 14px;
  font-size: 34px;
}

.benchmark-notes {
  margin-top: 28px;
  padding: clamp(22px, 4vw, 36px);
}

.note-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-top: 18px;
}

.note-grid article {
  padding: 16px;
  background: #fbfcfe;
  border: 1px solid var(--line);
  border-radius: 8px;
}

@media (max-width: 900px) {
  .topbar,
  .hero,
  .layout,
  .coverage-demo,
  .definition-grid,
  .explain-grid,
  .note-grid {
    grid-template-columns: 1fr;
  }

  .architecture-steps {
    grid-template-columns: 1fr;
  }

  .architecture-diagram {
    grid-template-columns: 1fr;
  }

  .arch-arrow {
    transform: rotate(90deg);
  }

  .topbar {
    position: static;
    align-items: flex-start;
  }

  .formula-nav {
    position: static;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .demo-chain {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 560px) {
  main {
    width: min(100% - 20px, 1180px);
  }

  .formula-nav,
  .demo-chain {
    grid-template-columns: 1fr;
  }

  .test-row {
    grid-template-columns: 72px repeat(5, minmax(38px, 1fr));
    gap: 6px;
  }

  .test-row label {
    min-height: 38px;
  }
}
