:root {
  color-scheme: light;
  --ink: #071b24;
  --ink-soft: #3d4f56;
  --paper: #f4f7f4;
  --surface: #ffffff;
  --surface-soft: #eaf0ec;
  --line: #cbd6d0;
  --line-strong: #9dafaa;
  --accent: #b8f34b;
  --accent-dark: #0b4d3b;
  --positive: #d86642;
  --negative: #1f7a74;
  --danger: #a83a2a;
  --shadow: 0 22px 60px rgba(7, 27, 36, 0.09);
  --radius: 1.25rem;
}

[data-theme="dark"] {
  color-scheme: dark;
  --ink: #edf5f1;
  --ink-soft: #a9bcb5;
  --paper: #061319;
  --surface: #0b2028;
  --surface-soft: #102b32;
  --line: #284249;
  --line-strong: #496269;
  --accent: #b8f34b;
  --accent-dark: #b8f34b;
  --positive: #ff8b66;
  --negative: #65c8bd;
  --danger: #ff9b83;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.28);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-width: 320px;
  background:
    linear-gradient(90deg, transparent 49.9%, color-mix(in srgb, var(--line) 25%, transparent) 50%, transparent 50.1%) 0 0 / 7rem 7rem,
    var(--paper);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 1rem;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

button, input { font: inherit; }
a, button { color: inherit; }

.skip-link {
  position: fixed;
  z-index: 100;
  top: 0.75rem;
  left: 0.75rem;
  transform: translateY(-180%);
  padding: 0.75rem 1rem;
  border-radius: 0.5rem;
  background: var(--ink);
  color: var(--paper);
}
.skip-link:focus { transform: translateY(0); }

.site-header, main, footer {
  width: min(100% - 3rem, 90rem);
  margin-inline: auto;
}

.site-header {
  min-height: 5.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.8rem;
  color: var(--ink);
  font-size: 1.02rem;
  text-decoration: none;
  letter-spacing: -0.01em;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 2.25rem;
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--ink);
  color: var(--accent);
}
.brand-mark svg { width: 1.45rem; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.8; }
.brand-mark circle { fill: currentColor; stroke: none; }

.header-actions { display: flex; align-items: center; gap: 1.1rem; }
.text-link, footer a { text-underline-offset: 0.25rem; text-decoration-thickness: 1px; }
.text-link:hover, footer a:hover { color: var(--accent-dark); }

.api-status {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--ink-soft);
  font-size: 0.82rem;
}
.status-dot { width: 0.5rem; height: 0.5rem; border-radius: 50%; background: #e3a72f; box-shadow: 0 0 0 4px color-mix(in srgb, #e3a72f 16%, transparent); }
.api-status.online .status-dot { background: #39a46c; box-shadow: 0 0 0 4px color-mix(in srgb, #39a46c 16%, transparent); }
.api-status.demo .status-dot { background: #d5b53d; box-shadow: 0 0 0 4px color-mix(in srgb, #d5b53d 16%, transparent); }
.api-status.offline .status-dot { background: var(--danger); box-shadow: 0 0 0 4px color-mix(in srgb, var(--danger) 16%, transparent); }

.icon-button {
  width: 2.5rem;
  height: 2.5rem;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
}
.icon-button:hover { background: var(--surface-soft); }
.icon-button svg { width: 1.1rem; fill: none; stroke: currentColor; stroke-linecap: round; stroke-width: 1.8; }
.moon-icon { display: none; }
[data-theme="dark"] .sun-icon { display: none; }
[data-theme="dark"] .moon-icon { display: block; }

main { padding-block: clamp(2.5rem, 6vw, 5.5rem); }

.demo-banner {
  display: flex;
  gap: 0.7rem;
  align-items: baseline;
  margin: calc(clamp(2.5rem, 6vw, 5.5rem) * -0.45) 0 2.5rem;
  padding: 0.8rem 1rem;
  border: 1px solid color-mix(in srgb, #d5b53d 55%, var(--line));
  border-radius: 0.7rem;
  background: color-mix(in srgb, #d5b53d 12%, var(--surface));
  color: var(--ink-soft);
  font-size: 0.82rem;
}
.demo-banner[hidden] { display: none; }
.demo-banner strong { flex: 0 0 auto; color: var(--ink); }

.intro {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(18rem, 0.7fr);
  gap: clamp(2rem, 8vw, 8rem);
  align-items: end;
  margin-bottom: clamp(2.5rem, 5vw, 4.5rem);
}

.eyebrow {
  margin: 0 0 0.5rem;
  color: var(--accent-dark);
  font-size: 0.75rem;
  font-weight: 750;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h1, h2, h3, p { overflow-wrap: anywhere; }
h1 {
  margin: 0;
  max-width: 15ch;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(3rem, 6.2vw, 6.2rem);
  font-weight: 400;
  letter-spacing: -0.055em;
  line-height: 0.94;
}
.intro-copy { margin: 0 0 0.35rem; max-width: 38rem; color: var(--ink-soft); font-size: clamp(1rem, 1.3vw, 1.2rem); }

.analysis-grid { display: grid; grid-template-columns: minmax(18rem, 0.68fr) minmax(0, 1.6fr); gap: 1rem; align-items: start; }
.panel { border: 1px solid var(--line); border-radius: var(--radius); background: color-mix(in srgb, var(--surface) 96%, transparent); box-shadow: var(--shadow); }
.query-card { position: sticky; top: 1rem; padding: clamp(1.4rem, 3vw, 2rem); }
.panel-heading { display: flex; gap: 1rem; align-items: flex-start; padding-bottom: 1.5rem; border-bottom: 1px solid var(--line); }
.panel-heading h2, .result-header h2, .section-heading h3, .report-section h3 { margin: 0; letter-spacing: -0.03em; line-height: 1.15; }
.panel-heading h2 { font-size: 1.4rem; }
.step-number { display: grid; place-items: center; width: 2rem; height: 2rem; border-radius: 50%; background: var(--accent); color: #071b24; font-size: 0.73rem; font-weight: 800; }

form { padding-top: 1.5rem; }
label { display: block; margin-bottom: 0.55rem; font-size: 0.88rem; font-weight: 700; }
.search-control { position: relative; }
.search-control svg { position: absolute; top: 50%; left: 1rem; width: 1.2rem; transform: translateY(-50%); fill: none; stroke: var(--ink-soft); stroke-width: 1.8; }
input {
  width: 100%;
  height: 3.25rem;
  padding: 0 1rem 0 2.9rem;
  border: 1px solid var(--line-strong);
  border-radius: 0.7rem;
  outline: none;
  background: var(--surface);
  color: var(--ink);
}
input:focus { border-color: var(--accent-dark); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-dark) 18%, transparent); }
.field-help { margin: 0.55rem 0 1rem; color: var(--ink-soft); font-size: 0.78rem; }

.primary-button, .secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  min-height: 3rem;
  border: 0;
  border-radius: 0.7rem;
  font-weight: 760;
  cursor: pointer;
}
.primary-button { width: 100%; padding: 0.8rem 1rem; background: var(--ink); color: var(--paper); }
.primary-button svg { width: 1.1rem; fill: none; stroke: currentColor; stroke-width: 2; transition: transform 160ms ease; }
.primary-button:hover svg { transform: translateX(0.2rem); }
.primary-button:disabled, .secondary-button:disabled { cursor: wait; opacity: 0.65; }
/* Disabled for the whole session, not mid-request — 'wait' would promise a result. */
.secondary-button.unavailable, .secondary-button.unavailable:hover { cursor: not-allowed; border-color: var(--line); background: transparent; }

.quick-searches { margin-top: 1.7rem; }
.quick-searches > span { display: block; margin-bottom: 0.65rem; color: var(--ink-soft); font-size: 0.78rem; }
.quick-searches div { display: flex; flex-wrap: wrap; gap: 0.45rem; }
.quick-searches button { padding: 0.45rem 0.7rem; border: 1px solid var(--line); border-radius: 99rem; background: transparent; font-size: 0.78rem; cursor: pointer; }
.quick-searches button:hover { border-color: var(--accent-dark); background: var(--surface-soft); }

.boundary-note { display: flex; gap: 0.8rem; margin-top: 1.7rem; padding-top: 1.35rem; border-top: 1px solid var(--line); color: var(--ink-soft); }
.boundary-note svg { flex: 0 0 auto; width: 1.25rem; fill: none; stroke: var(--accent-dark); stroke-width: 1.8; }
.boundary-note p { margin: 0; font-size: 0.82rem; }
.boundary-note strong { color: var(--ink); }

.results-panel { min-height: 39rem; padding: clamp(1.5rem, 4vw, 3rem); }
.result-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 1.5rem; padding-bottom: 2rem; border-bottom: 1px solid var(--line); }
.result-header h2 { max-width: 24ch; font-family: Georgia, "Times New Roman", serif; font-size: clamp(1.8rem, 3vw, 2.75rem); font-weight: 400; }
.metadata { display: flex; flex-wrap: wrap; gap: 0.45rem; margin-top: 0.85rem; }
.metadata span { padding: 0.35rem 0.65rem; border: 1px solid var(--line); border-radius: 99rem; color: var(--ink-soft); font-size: 0.78rem; }
.snapshot-id { margin: 0; color: var(--ink-soft); font-size: 0.75rem; line-height: 1.4; text-align: right; text-transform: uppercase; letter-spacing: 0.08em; }
.snapshot-id strong { color: var(--ink); font-size: 0.85rem; letter-spacing: 0; text-transform: none; }

.score-section { display: grid; grid-template-columns: 0.65fr 1.35fr; gap: clamp(2rem, 5vw, 5rem); align-items: end; padding: 2.4rem 0; border-bottom: 1px solid var(--line); }
.metric-label { margin: 0; color: var(--ink-soft); font-size: 0.83rem; }
.score-value { display: flex; align-items: baseline; gap: 0.55rem; margin: 0.1rem 0 0; font-family: Georgia, "Times New Roman", serif; font-size: clamp(3.5rem, 7vw, 6rem); line-height: 1; letter-spacing: -0.06em; }
.score-value small { font-family: Inter, ui-sans-serif, system-ui, sans-serif; color: var(--ink-soft); font-size: 0.8rem; letter-spacing: 0; }
.percentile-copy { margin: 0.55rem 0 0; color: var(--ink-soft); font-size: 0.82rem; }
.range-track { position: relative; height: 0.55rem; border-radius: 99rem; background: linear-gradient(90deg, var(--negative), #d5b53d 58%, var(--positive)); }
.range-track span { position: absolute; top: 50%; left: 50%; width: 1.15rem; height: 1.15rem; transform: translate(-50%, -50%); border: 3px solid var(--surface); border-radius: 50%; background: var(--ink); box-shadow: 0 0 0 1px var(--ink), 0 4px 12px rgba(0,0,0,.18); transition: left 500ms cubic-bezier(.2,.8,.2,1); }
.range-labels { display: grid; grid-template-columns: 1fr 2fr 1fr; margin-top: 0.65rem; color: var(--ink-soft); font-size: 0.72rem; }
.range-labels span:nth-child(2) { text-align: center; }
.range-labels span:last-child { text-align: right; }
.range-labels strong { color: var(--ink); }

.drivers-section { padding: 2.4rem 0; }
.section-heading { display: flex; justify-content: space-between; gap: 1rem; align-items: end; }
.section-heading h3, .report-section h3 { font-size: 1.25rem; }
.legend { display: flex; flex-wrap: wrap; gap: 0.8rem; color: var(--ink-soft); font-size: 0.72rem; }
.legend span { display: inline-flex; align-items: center; gap: 0.35rem; }
.legend-dot { width: 0.55rem; height: 0.55rem; border-radius: 50%; }
.legend-dot.up { background: var(--positive); }
.legend-dot.down { background: var(--negative); }
.driver-chart { margin-top: 1.5rem; }
.driver-row { display: grid; grid-template-columns: minmax(7rem, 0.8fr) minmax(10rem, 2fr) 4.5rem; gap: 0.8rem; align-items: center; min-height: 2.45rem; }
.driver-name { font-size: 0.82rem; font-weight: 680; }
.driver-bar-track { position: relative; height: 0.55rem; border-radius: 99rem; background: var(--surface-soft); overflow: hidden; }
.driver-bar-track::after { content: ""; position: absolute; top: 0; bottom: 0; left: 50%; width: 1px; background: var(--line-strong); }
.driver-bar { position: absolute; top: 0; bottom: 0; width: 0; transition: width 450ms cubic-bezier(.2,.8,.2,1); }
.driver-bar.positive { left: 50%; border-radius: 0 99rem 99rem 0; background: var(--positive); }
.driver-bar.negative { right: 50%; border-radius: 99rem 0 0 99rem; background: var(--negative); }
.driver-number { color: var(--ink-soft); font-variant-numeric: tabular-nums; font-size: 0.78rem; text-align: right; }

.scope-note { display: grid; grid-template-columns: 5rem 1fr; gap: 1rem; padding: 1rem 1.1rem; border-left: 3px solid var(--accent); background: var(--surface-soft); }
.scope-note span { color: var(--accent-dark); font-size: 0.7rem; font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase; }
.scope-note p { margin: 0; color: var(--ink-soft); font-size: 0.8rem; }

.report-section { display: flex; align-items: center; justify-content: space-between; gap: 1.5rem; margin-top: 1.7rem; }
.report-section p:not(.eyebrow) { margin: 0.35rem 0 0; color: var(--ink-soft); font-size: 0.82rem; }
.secondary-button { flex: 0 0 auto; padding: 0.65rem 1rem; border: 1px solid var(--line-strong); background: transparent; }
.secondary-button:hover { border-color: var(--accent-dark); background: var(--surface-soft); }
.report-output { margin-top: 1.25rem; padding: 1.25rem; border: 1px solid var(--line); border-radius: 0.8rem; background: var(--surface-soft); white-space: pre-wrap; font-family: Georgia, "Times New Roman", serif; font-size: 1rem; }
.report-output.error { border-color: color-mix(in srgb, var(--danger) 50%, var(--line)); color: var(--danger); font-family: inherit; font-size: 0.85rem; }

.result-loading { padding-top: 0.5rem; }
.skeleton { border-radius: 0.5rem; background: linear-gradient(90deg, var(--surface-soft) 25%, color-mix(in srgb, var(--surface-soft) 55%, var(--surface)) 50%, var(--surface-soft) 75%); background-size: 200% 100%; animation: shimmer 1.4s infinite; }
.skeleton-title { width: 55%; height: 2.5rem; }
.skeleton-score { width: 32%; height: 6rem; margin-top: 4rem; }
.skeleton-line { width: 100%; height: 1rem; margin-top: 3rem; }
.skeleton-line.short { width: 72%; margin-top: 1rem; }
.result-error { min-height: 31rem; display: flex; justify-content: center; align-items: center; gap: 1rem; }
.result-error[hidden] { display: none; }
.result-error h2 { margin: 0; font-size: 1.3rem; }
.result-error p { margin: 0.35rem 0 0; max-width: 32rem; color: var(--ink-soft); }
.error-icon { display: grid; place-items: center; flex: 0 0 auto; width: 2.3rem; height: 2.3rem; border: 1px solid var(--danger); border-radius: 50%; color: var(--danger); font-weight: 800; }

.method-strip { display: grid; grid-template-columns: 0.7fr 1.5fr; gap: clamp(2rem, 7vw, 7rem); margin-top: clamp(4rem, 8vw, 8rem); padding-top: clamp(2rem, 4vw, 3rem); border-top: 1px solid var(--line); }
.method-strip h2 { margin: 0; max-width: 14ch; font-family: Georgia, "Times New Roman", serif; font-size: clamp(2rem, 3.5vw, 3.5rem); font-weight: 400; line-height: 1.05; letter-spacing: -0.045em; }
.method-strip ol { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.25rem; margin: 0; padding: 0; list-style: none; }
.method-strip li { padding-top: 1rem; border-top: 3px solid var(--ink); }
.method-strip li > span { color: var(--accent-dark); font-size: 0.72rem; font-weight: 800; }
.method-strip li p { margin: 1.4rem 0 0; color: var(--ink-soft); font-size: 0.85rem; }
.method-strip li strong { display: block; margin-bottom: 0.35rem; color: var(--ink); font-size: 1rem; }

footer { display: flex; justify-content: space-between; gap: 1rem; padding: 1.7rem 0 2.4rem; border-top: 1px solid var(--line); color: var(--ink-soft); font-size: 0.78rem; }
footer p { margin: 0; }
footer div { display: flex; gap: 1rem; }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
button:focus-visible, a:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent-dark) 45%, transparent); outline-offset: 3px; }

@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

@media (max-width: 900px) {
  .intro { grid-template-columns: 1fr; gap: 1.5rem; }
  .analysis-grid { grid-template-columns: 1fr; }
  .query-card { position: static; }
  .method-strip { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .site-header, main, footer { width: min(100% - 2rem, 90rem); }
  .site-header { min-height: 4.5rem; }
  .brand span:last-child { font-size: 0.9rem; }
  .api-status, .text-link { display: none; }
  main { padding-top: 2.6rem; }
  .demo-banner { align-items: flex-start; flex-direction: column; }
  h1 { font-size: clamp(2.8rem, 14vw, 4.1rem); }
  .results-panel { padding: 1.25rem; }
  .result-header, .section-heading, .report-section { align-items: flex-start; flex-direction: column; }
  .snapshot-id { text-align: left; }
  .score-section { grid-template-columns: 1fr; gap: 1.8rem; }
  .driver-row { grid-template-columns: 6.7rem minmax(7rem, 1fr) 3.6rem; gap: 0.5rem; }
  .driver-name { font-size: 0.75rem; }
  .scope-note { grid-template-columns: 1fr; gap: 0.3rem; }
  .method-strip ol { grid-template-columns: 1fr; }
  .method-strip li p { margin-top: 0.8rem; }
  footer { flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
