:root {
  color-scheme: light dark;
  --bg: #fbfaf7;
  --bg-band: #f1efe9;
  --surface: #ffffff;
  --text: #1c1f2a;
  --muted: #565c6e;
  --line: #dcd8cf;
  --accent: #3546c4;
  --accent-text: #ffffff;
  --amber: #8f5200;
  --night: #141833;
  --night-text: #eef0fa;
  --radius: 14px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1220;
    --bg-band: #151a2e;
    --surface: #1a2036;
    --text: #e8eaf3;
    --muted: #a9afc4;
    --line: #2c3450;
    --accent: #8b98ff;
    --accent-text: #0f1220;
    --amber: #f5b14c;
    --night: #0a0d1a;
    --night-text: #eef0fa;
  }
}

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

html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.6 var(--font);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-underline-offset: 3px; }
a:focus-visible, summary:focus-visible { outline: 3px solid var(--amber); outline-offset: 3px; border-radius: 4px; }
code { font-family: var(--mono); font-size: 0.88em; background: var(--bg-band); padding: 0.1em 0.35em; border-radius: 5px; white-space: nowrap; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 0.6em; }
h2 { font-size: clamp(1.6rem, 1.2rem + 1.6vw, 2.2rem); letter-spacing: -0.01em; }
h3 { font-size: 1.15rem; }
p { margin: 0 0 1em; }

.wrap { max-width: 68rem; margin: 0 auto; padding: 0 16px; }
@media (min-width: 720px) { .wrap { padding: 0 32px; } }

.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; z-index: 10; }
.skip:focus { left: 8px; }

/* Header */
.top { position: sticky; top: 0; z-index: 5; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.top-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 64px; flex-wrap: wrap; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-weight: 700; font-size: 1.15rem; }
.logo { width: 30px; height: 30px; }
.logo-moon { fill: var(--accent); }
.logo-z { fill: none; stroke: var(--amber); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
nav { display: flex; flex-wrap: wrap; gap: 4px 18px; font-size: 0.95rem; }
nav a { color: var(--muted); text-decoration: none; padding: 6px 0; }
nav a:hover { color: var(--text); }
nav .nav-cta { color: var(--accent); font-weight: 600; }
@media (max-width: 640px) { nav a:not(.nav-cta) { display: none; } }

/* Hero */
.hero { padding: clamp(48px, 9vw, 112px) 0 clamp(40px, 7vw, 88px); }
.eyebrow { color: var(--amber); font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; font-size: 0.8rem; margin-bottom: 1.2em; }
.hero h1 { font-size: clamp(2.1rem, 1.3rem + 3.6vw, 3.6rem); letter-spacing: -0.02em; max-width: 18em; }
.accent { color: var(--accent); }
.lead { font-size: clamp(1.05rem, 1rem + 0.4vw, 1.25rem); color: var(--muted); max-width: 40em; }
.actions { display: flex; flex-wrap: wrap; gap: 12px; margin: 2em 0 2.5em; }
.button { display: inline-block; background: var(--accent); color: var(--accent-text); text-decoration: none; font-weight: 600; padding: 12px 20px; border-radius: 999px; border: 2px solid var(--accent); }
.button:hover { filter: brightness(1.08); }
.button.ghost { background: transparent; color: var(--accent); }
.facts { list-style: none; padding: 0; margin: 0; display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); }
.facts li { border-top: 2px solid var(--line); padding-top: 12px; color: var(--muted); font-size: 0.95rem; }
.facts strong { display: block; color: var(--text); font-size: 1rem; }

/* Sections */
section { padding: clamp(48px, 7vw, 88px) 0; }
.band { background: var(--bg-band); }
.section-lead { color: var(--muted); max-width: 42em; margin-bottom: 2em; }
.note { color: var(--muted); font-size: 0.95rem; margin-top: 1.5em; max-width: 46em; }

.steps { list-style: none; padding: 0; margin: 0 0 2.5em; display: grid; gap: 20px; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); counter-reset: step; }
.steps li { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; counter-increment: step; }
.steps li::before { content: counter(step); display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: var(--accent); color: var(--accent-text); font-weight: 700; margin-bottom: 12px; }
.steps p { color: var(--muted); margin: 0; }

.cards { display: grid; gap: 20px; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; }
.card p { color: var(--muted); margin: 0; }

/* Diagram */
.diagram { margin: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; overflow-x: auto; }
/* Legible on phones: the figure scrolls sideways rather than shrinking the labels. */
.diagram svg { display: block; width: 100%; min-width: 540px; height: auto; max-width: 720px; margin: 0 auto; }
.d-node rect { fill: var(--bg-band); stroke: var(--line); stroke-width: 1.5; }
.d-app rect { stroke: var(--accent); }
.d-waker rect { stroke: var(--amber); }
.d-node text { fill: var(--text); font: 600 15px var(--font); text-anchor: middle; }
.d-line { fill: none; stroke: var(--muted); stroke-width: 2; }
.d-awake { stroke: var(--accent); }
.d-asleep, .d-start { stroke: var(--amber); stroke-dasharray: 6 5; }
.d-label { fill: var(--muted); font: 13px var(--font); text-anchor: middle; }

/* Table */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 14px 18px; border-bottom: 1px solid var(--line); }
tbody tr:last-child th, tbody tr:last-child td { border-bottom: 0; }
thead th { font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
tbody th { font-weight: 500; }
td { font-variant-numeric: tabular-nums; white-space: nowrap; font-weight: 600; }

/* FAQ */
.faq { display: grid; gap: 12px; max-width: 48rem; }
details { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 0 20px; }
summary { cursor: pointer; font-weight: 600; padding: 16px 0; list-style-position: outside; }
details p { color: var(--muted); }

/* Closing and footer */
.closing { background: var(--night); color: var(--night-text); text-align: center; }
.closing h2 { color: var(--night-text); }
.closing .button { background: #f5b14c; border-color: #f5b14c; color: #141833; }
.bottom { border-top: 1px solid var(--line); color: var(--muted); font-size: 0.9rem; }
.bottom-inner { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 24px; padding-top: 24px; padding-bottom: 24px; }
.bottom p { margin: 0; }

/* Error page */
.error-page { min-height: 70vh; display: grid; place-items: center; text-align: center; padding: 48px 16px; }
