:root {
  color-scheme: dark;
  --bg: #11171b;
  --bg-deep: #0d1215;
  --surface: #182126;
  --surface-2: #1d282e;
  --line: #344148;
  --line-soft: #29353b;
  --text: #edf2ef;
  --muted: #a8b3b7;
  --quiet: #849399;
  --accent: #df645c;
  --accent-strong: #ee756d;
  --accent-soft: rgba(223, 100, 92, .12);
  --radius: 14px;
  --control-radius: 8px;
  --shell: min(1220px, calc(100% - 48px));
  --header-height: 72px;
  font-family: "Segoe UI Variable", "Segoe UI", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: var(--header-height); }
body {
  margin: 0;
  min-width: 320px;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; }
.skip-link {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 20;
  padding: 10px 14px;
  border-radius: var(--control-radius);
  background: var(--text);
  color: var(--bg-deep);
  transform: translateY(-160%);
}
.skip-link:focus { transform: translateY(0); }
.section-shell { width: var(--shell); margin-inline: auto; }

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  min-height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 0 max(24px, calc((100vw - 1220px) / 2));
  border-bottom: 1px solid rgba(255, 255, 255, .08);
  background: rgba(17, 23, 27, .94);
  backdrop-filter: blur(16px);
}
.brand { display: inline-flex; align-items: center; gap: 12px; color: var(--text); text-decoration: none; }
.brand-mark {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid var(--accent);
  border-radius: 50%;
  color: var(--accent-strong);
  font-weight: 750;
}
.brand strong, .brand small { display: block; }
.brand strong { font-size: 15px; letter-spacing: .08em; }
.brand small { margin-top: -2px; color: var(--quiet); font-size: 9px; letter-spacing: .19em; }
.primary-nav { display: flex; align-items: center; gap: 24px; white-space: nowrap; }
.primary-nav a {
  color: var(--muted);
  font-size: 13px;
  text-decoration: none;
  transition: color .2s ease, border-color .2s ease, transform .15s ease;
}
.primary-nav a:hover, .primary-nav a:focus-visible { color: var(--text); }
.primary-nav a:active { transform: translateY(1px); }
.primary-nav .nav-home { padding: 8px 12px; border: 1px solid var(--line); border-radius: var(--control-radius); }

.hero {
  min-height: calc(100dvh - var(--header-height));
  display: grid;
  place-items: center;
  padding-block: 56px;
}
.hero-copy { width: min(760px, 100%); text-align: center; }
.eyebrow {
  margin: 0 0 16px;
  color: var(--accent-strong);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: .2em;
}
.hero h1 {
  margin: 0;
  font-size: clamp(44px, 6.2vw, 78px);
  line-height: 1.06;
  letter-spacing: -.055em;
}
.hero-lead { max-width: 36em; margin: 22px auto 32px; color: var(--muted); font-size: 17px; }
.search-form { width: min(650px, 100%); margin-inline: auto; text-align: left; }
.search-form label { display: block; margin-bottom: 8px; color: var(--text); font-size: 13px; font-weight: 650; }
.search-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; }
.search-row input {
  min-width: 0;
  min-height: 52px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: var(--control-radius);
  outline: none;
  background: var(--surface);
  color: var(--text);
}
.search-row input::placeholder { color: #89969b; }
.search-row input:focus-visible { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(223, 100, 92, .18); }
.button {
  min-height: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 20px;
  border-radius: var(--control-radius);
  font-weight: 750;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  transition: transform .15s ease, border-color .2s ease, background .2s ease;
}
.button:active { transform: translateY(1px); }
.button-primary { border: 1px solid var(--accent); background: var(--accent); color: #11171b; }
.button-primary:hover { background: var(--accent-strong); }
.button-secondary { border: 1px solid var(--line); background: var(--surface-2); color: var(--text); }
.button-secondary:hover { border-color: var(--accent); }
.field-hint, .form-message { margin: 8px 0 0; font-size: 12px; }
.field-hint { color: var(--quiet); }
.form-message { min-height: 1.4em; color: #f0a59f; }

.result-section {
  min-height: calc(100dvh - var(--header-height));
  padding-block: 52px 36px;
  border-top: 1px solid var(--line-soft);
  background: var(--bg-deep);
}
.result-shell { display: grid; gap: 26px; }
.result-overview {
  display: grid;
  grid-template-columns: minmax(220px, .75fr) minmax(0, 2.25fr);
  gap: 64px;
  align-items: end;
}
.classification {
  width: fit-content;
  padding: 5px 9px;
  border: 1px solid var(--line);
  border-radius: var(--control-radius);
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
}
.molecule-heading h2 { margin: 15px 0 0; font-size: clamp(50px, 6vw, 76px); line-height: 1; letter-spacing: -.055em; }
.molecule-heading p { margin: 8px 0 0; color: var(--accent-strong); font-size: 15px; }
.result-meta { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px 46px; margin: 0; }
.result-meta dt { color: var(--quiet); font-size: 11px; }
.result-meta dd { margin: 6px 0 0; color: var(--text); font-size: 14px; }
.result-callout { max-width: 900px; padding: 18px 22px; border-left: 3px solid var(--accent); background: var(--accent-soft); }
.result-callout strong { color: var(--accent-strong); font-size: 11px; }
.result-callout p { margin: 5px 0 0; font-size: clamp(16px, 2vw, 20px); }

.chart-block { min-width: 0; padding-top: 4px; }
.chart-heading { display: flex; align-items: end; justify-content: space-between; gap: 30px; margin-bottom: 12px; }
.chart-heading h3 { margin: 0; font-size: 21px; }
.chart-heading p { margin: 4px 0 0; color: var(--quiet); font-size: 11px; }
.chart-legend { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px 18px; }
.chart-legend span { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 11px; }
.legend-line { width: 28px; height: 0; display: inline-block; border-top: 2px solid currentColor; }
.legend-line.model { color: var(--accent-strong); }
.legend-line.human { color: #dce3e0; }
.legend-line.removal { color: var(--accent); border-top-style: dashed; }
.chart-frame {
  position: relative;
  min-height: 360px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.chart-loading, .chart-error {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 14px;
  color: var(--muted);
  text-align: center;
}
.chart-loading::before {
  content: "";
  width: 220px;
  height: 2px;
  margin-inline: auto;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  animation: loading-sweep 1.2s ease-in-out infinite;
}
.chart-error strong { color: var(--text); }
.chart-error .button { margin-inline: auto; }
#fentanylChart { width: 100%; height: auto; min-height: 360px; display: block; }
.grid-line { stroke: #2e3a40; stroke-width: 1; vector-effect: non-scaling-stroke; }
.axis-line { stroke: #607078; stroke-width: 1; vector-effect: non-scaling-stroke; }
.axis-label { fill: #91a0a6; font-size: 12px; font-family: "Cascadia Mono", Consolas, monospace; }
.axis-title { fill: #a8b3b7; font-size: 12px; }
.data-path { fill: none; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.model-path { stroke: var(--accent-strong); stroke-width: 3; }
.human-path { stroke: #dce3e0; stroke-width: 2; }
.human-point { fill: #dce3e0; stroke: var(--surface); stroke-width: 2; vector-effect: non-scaling-stroke; }
.removal-line { stroke: var(--accent); stroke-width: 1.5; stroke-dasharray: 7 6; opacity: .75; vector-effect: non-scaling-stroke; }
.removal-label { fill: var(--accent-strong); font-size: 11px; }
.time-cursor { stroke: #74858c; stroke-width: 1; stroke-dasharray: 3 6; opacity: .65; vector-effect: non-scaling-stroke; }
.cursor-point { vector-effect: non-scaling-stroke; }
.model-cursor { fill: var(--surface); stroke: var(--accent-strong); stroke-width: 3; }
.human-cursor { fill: var(--surface); stroke: #dce3e0; stroke-width: 3; }
.time-readout {
  position: absolute;
  top: 14px;
  right: 16px;
  min-width: 60px;
  padding: 5px 9px;
  border: 1px solid var(--line);
  border-radius: var(--control-radius);
  background: rgba(13, 18, 21, .86);
  color: var(--text);
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 11px;
  text-align: center;
}
.chart-notes { display: grid; grid-template-columns: auto auto 1fr; gap: 12px 28px; align-items: start; margin-top: 12px; }
.chart-notes p { margin: 0; color: var(--muted); font-size: 11px; }
.chart-notes strong { color: var(--text); }
.chart-notes .model-disclaimer { color: var(--quiet); text-align: right; }

@keyframes loading-sweep {
  0%, 100% { opacity: .3; transform: scaleX(.35); }
  50% { opacity: 1; transform: scaleX(1); }
}

@media (max-width: 820px) {
  :root { --shell: min(100% - 32px, 720px); }
  .site-header { padding-inline: 16px; }
  .primary-nav { gap: 12px; }
  .primary-nav > a:first-child { display: none; }
  .hero { padding-block: 44px; }
  .hero h1 { font-size: clamp(43px, 12vw, 64px); }
  .result-section { padding-block: 42px 34px; }
  .result-overview { grid-template-columns: 1fr; gap: 28px; align-items: start; }
  .molecule-heading h2 { font-size: 54px; }
  .chart-heading { display: block; }
  .chart-legend { justify-content: flex-start; margin-top: 12px; }
  .chart-notes { grid-template-columns: 1fr 1fr; }
  .chart-notes .model-disclaimer { grid-column: 1 / -1; text-align: left; }
}

@media (max-width: 560px) {
  :root { --header-height: 64px; }
  .site-header { min-height: var(--header-height); }
  .brand-mark { width: 31px; height: 31px; }
  .nav-home { font-size: 11px !important; }
  .hero { min-height: calc(100dvh - var(--header-height)); padding-block: 36px; }
  .hero h1 { font-size: 43px; }
  .hero-lead { margin-block: 18px 26px; font-size: 15px; }
  .search-row { grid-template-columns: 1fr; }
  .search-row .button { width: 100%; }
  .result-meta { grid-template-columns: 1fr; gap: 16px; }
  .result-callout { padding: 16px 18px; }
  .chart-frame { min-height: 300px; margin-inline: -8px; }
  #fentanylChart { min-height: 300px; }
  .chart-legend { display: grid; grid-template-columns: 1fr 1fr; }
  .chart-notes { grid-template-columns: 1fr; }
  .chart-notes .model-disclaimer { grid-column: auto; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}


[hidden] {
  display: none !important;
}
