/* AWS Zero to Architect: bright, reader-first styles. Mobile first, three themes, print ready. */

:root {
  --font-ui: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-serif: Charter, "Bitstream Charter", "Sitka Text", Cambria, Georgia, "Times New Roman", serif;
  --font-read: var(--font-serif);
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "DejaVu Sans Mono", "Liberation Mono", "Courier New", monospace;
  --fs: 18px;
  --bar: 56px;
  --measure: 76rem;
  --drawer-w: 320px;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 24, 31, 0.06), 0 6px 20px rgba(20, 24, 31, 0.06);
  color-scheme: light;
}

html[data-font="sans"] { --font-read: var(--font-ui); }
html[data-width="narrow"] { --measure: 44rem; }
html[data-width="medium"] { --measure: 60rem; }
html[data-width="wide"] { --measure: 76rem; }
html[data-width="full"] { --measure: 100%; }

html[data-theme="light"] {
  --bg: #f6fbff; --surface: #ffffff; --surface-2: #eaf4ff; --text: #14213d; --muted: #4a5d7c;
  --border: #d3e4f8; --accent: #d9480f; --accent-ink: #ffffff; --accent-soft: #fff0e3; --link: #0b63ce;
  --code-bg: #eef5fd; --code-head: #dcebfb; --code-text: #14213d;
  --c-trap: #dc2626; --c-ai: #7c3aed; --c-tip: #b45309; --c-info: #0284c7; --c-note: #475569; --c-intro: #d9480f;
  --c-arch: #0d9488; --c-cost: #15803d; --c-sec: #be123c; --c-lab: #4f46e5;
}
html[data-theme="sepia"] {
  --bg: #f7edd5; --surface: #fdf5e1; --surface-2: #f0e1bf; --text: #34270f; --muted: #6d5733;
  --border: #e2d1a8; --accent: #b9400a; --accent-ink: #fff8ea; --accent-soft: #f9e2c1; --link: #8a3b00;
  --code-bg: #f1e4c6; --code-head: #e8d8b3; --code-text: #34270f;
  --c-trap: #c0270f; --c-ai: #7a2fb0; --c-tip: #9a5a00; --c-info: #1d6a9a; --c-note: #6b5a3f; --c-intro: #b9400a;
  --c-arch: #0b7a70; --c-cost: #2f7a1d; --c-sec: #a8143f; --c-lab: #4338ca;
}
html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f1424; --surface: #171d33; --surface-2: #212a47; --text: #e9eefc; --muted: #a7b4d4;
  --border: #2c3759; --accent: #ffa94d; --accent-ink: #1b1305; --accent-soft: #2e2418; --link: #79c0ff;
  --code-bg: #0b0f1d; --code-head: #151b30; --code-text: #e3e8f8;
  --c-trap: #ff7b7b; --c-ai: #c4a1ff; --c-tip: #ffd23f; --c-info: #5ec4ff; --c-note: #a7b4d4; --c-intro: #ffa94d;
  --c-arch: #2dd4bf; --c-cost: #4ade80; --c-sec: #ff7aa2; --c-lab: #9aa5ff;
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--bar) + 16px); }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: var(--font-ui); line-height: 1.5; -webkit-font-smoothing: antialiased;
}
html.drawer-open, html.drawer-open body { overflow: hidden; }
a { color: var(--link); text-underline-offset: 3px; }
img, svg { max-width: 100%; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--accent); color: var(--accent-ink); padding: 8px 14px; border-radius: 8px; z-index: 100; }
.skip:focus { left: 8px; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 40; height: var(--bar);
  display: flex; align-items: center; gap: 6px;
  padding: 0 max(10px, env(safe-area-inset-right)) 0 max(10px, env(safe-area-inset-left));
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(12px); backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--border);
}
.progress { position: absolute; left: 0; right: 0; bottom: -1px; height: 3px; background: transparent; }
.progress-bar { height: 100%; width: 0; background: var(--accent); transition: width 0.1s linear; }
.icon-btn {
  width: 44px; height: 44px; display: inline-grid; place-items: center; flex: none;
  background: transparent; border: 0; border-radius: 12px; cursor: pointer; color: var(--text);
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn.aa { font-family: var(--font-serif); font-weight: 700; font-size: 1.05rem; letter-spacing: -0.02em; }
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--text); font-weight: 700; flex: none; }
.brand-mark { display: inline-grid; place-items: center; width: 32px; height: 30px; border-radius: 9px; background: linear-gradient(135deg, #4f46e5, #db2777); color: #fff; font-size: 0.8rem; font-weight: 800; letter-spacing: 0.02em; }
.brand-text { display: none; font-size: 0.98rem; }
.topbar-title { flex: 1; min-width: 0; text-align: center; font-size: 0.85rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 0 6px; }
.topbar-actions { display: flex; gap: 2px; margin-left: auto; }
.topbar-title + .topbar-actions { margin-left: 0; }

/* ---------- settings popover ---------- */
.settings {
  position: fixed; z-index: 60; top: calc(var(--bar) + 6px); right: max(10px, env(safe-area-inset-right));
  width: min(360px, calc(100vw - 20px)); padding: 14px; border-radius: 16px;
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow);
}
.set-row { display: grid; gap: 6px; padding: 8px 0; }
.set-row + .set-row { border-top: 1px solid var(--border); }
.set-label { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); font-weight: 700; }
.seg { display: flex; gap: 6px; }
.seg button, .size button {
  flex: 1; min-height: 42px; padding: 0 10px; border-radius: 10px; cursor: pointer;
  background: var(--surface-2); border: 1px solid var(--border); font-weight: 600;
}
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.size { display: flex; align-items: center; gap: 8px; }
.size button { flex: none; width: 52px; }
.size input { flex: 1; accent-color: var(--accent); height: 32px; }

/* ---------- layout ---------- */
.layout { display: block; }
.main { padding: 22px max(18px, env(safe-area-inset-right)) 96px max(18px, env(safe-area-inset-left)); outline: none; min-width: 0; }

.drawer {
  position: fixed; z-index: 50; top: 0; bottom: 0; left: 0; width: min(88vw, var(--drawer-w));
  background: var(--surface); border-right: 1px solid var(--border);
  transform: translateX(-102%); transition: transform 0.25s ease; overflow-y: auto; overscroll-behavior: contain;
  padding-top: env(safe-area-inset-top);
}
.drawer-open .drawer { transform: none; box-shadow: var(--shadow); }
.scrim { position: fixed; inset: 0; z-index: 45; background: rgba(8, 10, 14, 0.5); opacity: 0; pointer-events: none; transition: opacity 0.25s; }
.drawer-open .scrim { opacity: 1; pointer-events: auto; }
.drawer-inner { padding: 14px 12px 40px; }
.drawer-links { display: flex; flex-wrap: wrap; gap: 6px; padding: 6px 4px 14px; }
.drawer-links a { padding: 8px 12px; border-radius: 999px; background: var(--surface-2); color: var(--text); text-decoration: none; font-size: 0.85rem; font-weight: 600; border: 1px solid var(--border); }
.drawer-links a[aria-current="page"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.group { margin: 0 0 18px; }
.group-title { margin: 0 4px 6px; font-size: 0.95rem; line-height: 1.25; }
.group-title span { display: block; font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); font-weight: 700; margin-bottom: 2px; }
.chs, .sub { list-style: none; margin: 0; padding: 0; }
.ch > a, .ch.soon {
  display: flex; align-items: baseline; gap: 10px; padding: 9px 10px; border-radius: 10px; text-decoration: none; color: var(--text); font-size: 0.9rem; line-height: 1.3;
}
.ch > a:hover { background: var(--surface-2); }
.ch.current > a { background: var(--accent-soft); font-weight: 700; }
.ch.soon { color: var(--muted); }
.num { flex: none; display: inline-grid; place-items: center; min-width: 26px; height: 26px; padding: 0 4px; border-radius: 8px; background: var(--surface-2); font-size: 0.78rem; font-weight: 700; border: 1px solid var(--border); }
.ch.current .num { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.ch .t { flex: 1; min-width: 0; }
.ck { flex: none; font-size: 0.7rem; color: var(--muted); font-weight: 700; }
.ch.done .ck { color: #15803d; }
.badge { flex: none; font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.08em; padding: 2px 7px; border-radius: 999px; border: 1px solid var(--border); color: var(--muted); font-weight: 700; }
.ch.current { position: relative; }
.ch.current > a { padding-right: 46px; }
.ch-toggle { position: absolute; top: 3px; right: 4px; width: 36px; height: 36px; display: grid; place-items: center; border: 0; border-radius: 10px; background: transparent; color: var(--text); cursor: pointer; }
.ch-toggle:hover { background: color-mix(in srgb, var(--accent) 16%, transparent); }
.ch-toggle::before { content: ""; width: 8px; height: 8px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(-135deg) translate(-1px, -1px); transition: transform 0.2s; }
.ch-toggle[aria-expanded="false"]::before { transform: rotate(45deg) translate(-1px, -1px); }
.sub { margin: 2px 0 8px 46px; border-left: 2px solid var(--border); }
.sub a { display: block; padding: 5px 10px; font-size: 0.8rem; color: var(--muted); text-decoration: none; line-height: 1.3; border-radius: 0 8px 8px 0; }
.sub a:hover, .sub a.active { color: var(--text); background: var(--surface-2); }
.sub a.active { font-weight: 700; box-shadow: inset 2px 0 0 var(--accent); }

@media (min-width: 1100px) {
  .brand-text { display: inline; }
  #btn-menu { display: none; }
  .layout { display: grid; grid-template-columns: var(--drawer-w) minmax(0, 1fr); }
  .drawer { position: sticky; top: var(--bar); height: calc(100vh - var(--bar)); width: auto; transform: none; z-index: 1; padding-top: 0; }
  .scrim { display: none; }
  html.drawer-open, html.drawer-open body { overflow: auto; }
  .main { padding: 40px 40px 120px; }
  .topbar { padding-left: 18px; }
  .topbar-title { text-align: left; padding-left: 20px; }
}
@media (min-width: 640px) and (max-width: 1099px) { .brand-text { display: inline; } }

/* ---------- chapter header ---------- */
.chapter-head, .content { max-width: var(--measure); margin-left: auto; margin-right: auto; }
.chapter-head { padding: 6px 0 18px; }
.kicker { margin: 0 0 8px; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--accent); font-weight: 800; }
.chapter-head h1 { margin: 0 0 12px; font-size: clamp(1.9rem, 6.4vw, 2.9rem); line-height: 1.12; letter-spacing: -0.02em; text-wrap: balance; }
.lede { font-family: var(--font-read); font-size: calc(var(--fs) * 1.08); color: var(--muted); margin: 0 0 12px; }
.meta { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; margin: 0; font-size: 0.85rem; color: var(--muted); }
.text-btn { background: none; border: 0; padding: 6px 8px; margin: -6px -2px; color: var(--link); cursor: pointer; font-weight: 600; text-decoration: underline; text-underline-offset: 3px; border-radius: 8px; }

/* ---------- reading content ---------- */
.content { font-family: var(--font-read); font-size: var(--fs); line-height: 1.72; overflow-wrap: break-word; hyphens: manual; }
.content > * + * { margin-top: 1.05em; }
.content p { margin: 0; }
.content strong { font-weight: 700; }
.content h1, .content h2, .content h3, .content h4 { font-family: var(--font-ui); line-height: 1.2; letter-spacing: -0.012em; position: relative; text-wrap: balance; }
.content h1 {
  font-size: 1.7em; margin-top: 2.6em; padding: 18px 18px; border-radius: var(--radius);
  background: linear-gradient(135deg, #4f46e5, #7c3aed 60%, #db2777); color: #fff;
}
.content h1 .anchor { color: inherit; }
.content h2 { font-size: 1.45em; margin-top: 2.2em; padding: 0.9em 0 0 0; border-top: 3px solid var(--border); }
.content h2::before { content: ""; position: absolute; left: 0; top: -3px; width: 64px; height: 3px; background: linear-gradient(90deg, var(--accent), #db2777); border-radius: 3px; }
.content h3 { font-size: 1.15em; margin-top: 1.8em; }
.content h4 { font-size: 1.02em; margin-top: 1.5em; color: var(--accent); text-transform: uppercase; letter-spacing: 0.04em; }
.anchor { margin-left: 0.4em; font-size: 0.7em; text-decoration: none; opacity: 0; color: var(--muted); }
.content h1:hover .anchor, .content h2:hover .anchor, .content h3:hover .anchor, .content h4:hover .anchor, .anchor:focus { opacity: 0.8; }
@media (hover: none) { .anchor { display: none; } }
.content ul, .content ol { padding-left: 1.35em; margin-top: 0.7em; margin-bottom: 0; }
.content li + li { margin-top: 0.35em; }
.content li > ul, .content li > ol { margin-top: 0.35em; }
.content hr { border: 0; border-top: 1px dashed var(--border); margin: 2.2em 0; }
.content code {
  font-family: var(--font-mono); font-size: 0.84em; background: var(--code-bg); padding: 0.12em 0.4em; border-radius: 6px; word-break: break-word;
}
.content a { font-weight: 600; }

/* tables */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.content table { border-collapse: collapse; width: 100%; font-family: var(--font-ui); font-size: 0.82em; line-height: 1.45; }
.content th, .content td { padding: 0.6em 0.8em; text-align: left; vertical-align: top; border-bottom: 1px solid var(--border); min-width: 4.5rem; }
.content th { background: var(--surface-2); font-weight: 700; vertical-align: bottom; position: sticky; top: 0; }
.content tr:last-child td { border-bottom: 0; }
.content tbody tr:nth-child(even) td { background: color-mix(in srgb, var(--surface-2) 45%, transparent); }
.content td code { font-size: 0.92em; }

.swipe-hint { margin-top: 6px !important; font: 600 0.74rem var(--font-ui); color: var(--muted); text-align: right; }

/* code and diagrams */
.codeblock { border-radius: var(--radius); overflow: hidden; background: var(--code-bg); border: 1px solid var(--border); position: relative; }
.codeblock::before {
  content: attr(data-lang); display: block; padding: 6px 12px; font: 700 0.68rem/1.6 var(--font-ui);
  text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); background: var(--code-head);
}
.codeblock pre { margin: 0; padding: 14px 16px; overflow-x: auto; -webkit-overflow-scrolling: touch; tab-size: 2; }
.codeblock code { background: none; padding: 0; font-size: 0.78em; line-height: 1.55; color: var(--code-text); white-space: pre; word-break: normal; display: block; }
.copy { position: absolute; top: 3px; right: 6px; min-height: 28px; padding: 0 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: 600 0.72rem var(--font-ui); cursor: pointer; }
.copy.ok { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

/* callouts */
.callout {
  --c: var(--c-note); position: relative; padding: 14px 16px 14px 56px; border-radius: var(--radius);
  border: 1px solid color-mix(in srgb, var(--c) 35%, var(--border));
  background: color-mix(in srgb, var(--c) 9%, var(--surface));
  font-size: 0.96em; line-height: 1.62;
}
.callout::before {
  content: "i"; position: absolute; left: 14px; top: 14px; width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center; font: 800 0.9rem/1 var(--font-ui); color: #fff; background: var(--c);
}
.callout > * + * { margin-top: 0.7em; }
.callout-trap { --c: var(--c-trap); }
.callout-trap::before { content: "!"; }
.callout-ai { --c: var(--c-ai); }
.callout-ai::before { content: "AI"; font-size: 0.68rem; letter-spacing: 0.02em; }
.callout-tip { --c: var(--c-tip); }
.callout-tip::before { content: "TIP"; font-size: 0.56rem; letter-spacing: 0.02em; }
.callout-info { --c: var(--c-info); }
.callout-intro { --c: var(--c-intro); font-size: 0.98em; background: var(--accent-soft); }
.callout-intro::before { content: "i"; }
.callout-arch { --c: var(--c-arch); }
.callout-arch::before { content: "ARC"; font-size: 0.52rem; letter-spacing: 0.02em; }
.callout-cost { --c: var(--c-cost); }
.callout-cost::before { content: "$"; font-size: 1rem; }
.callout-security { --c: var(--c-sec); }
.callout-security::before { content: "SEC"; font-size: 0.52rem; letter-spacing: 0.02em; }
.callout-lab { --c: var(--c-lab); }
.callout-lab::before { content: "LAB"; font-size: 0.52rem; letter-spacing: 0.02em; }
.callout code { background: color-mix(in srgb, var(--c) 12%, var(--surface)); }

/* collapsibles */
details { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
details > summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; gap: 10px; min-height: 52px; padding: 12px 16px;
  font-family: var(--font-ui); font-size: 0.92rem; font-weight: 650; -webkit-tap-highlight-color: transparent; user-select: none;
}
details > summary::-webkit-details-marker { display: none; }
details > summary::after {
  content: ""; margin-left: auto; flex: none; width: 9px; height: 9px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor;
  transform: rotate(45deg) translateY(-2px); transition: transform 0.2s; opacity: 0.7;
}
details[open] > summary::after { transform: rotate(-135deg) translateY(-2px); }
details[open] > summary { border-bottom: 1px solid var(--border); }
details > summary:hover { background: var(--surface-2); }
details > :not(summary) { margin-left: 16px; margin-right: 16px; }
.content details > :not(summary) { margin-left: 16px; margin-right: 16px; }
.content details > :last-child { margin-bottom: 16px; }
details > summary + * { margin-top: 14px; }
details > :last-child { margin-bottom: 16px; }
.content details > * + * { margin-top: 0.95em; }
.content details > summary + * { margin-top: 14px; }
.content details h3 { margin-top: 1.2em; }
.content details h3:first-of-type { margin-top: 0.4em; }
.tag { flex: none; font-size: 0.64rem; text-transform: uppercase; letter-spacing: 0.09em; padding: 3px 8px; border-radius: 999px; background: var(--accent); color: var(--accent-ink); font-weight: 800; }
details.deeper { border-color: color-mix(in srgb, var(--accent) 40%, var(--border)); background: color-mix(in srgb, var(--accent-soft) 55%, var(--surface)); }
details.deeper > summary b { font-weight: 650; }
details.selftest .tag { background: var(--c-info); color: #fff; }
details.answer { margin: 0.6em 0 1.4em; border-style: dashed; background: transparent; }
details.answer > summary { min-height: 44px; font-size: 0.85rem; color: var(--link); }
details.answer[open] { border-style: solid; background: color-mix(in srgb, #16a34a 8%, var(--surface)); border-color: color-mix(in srgb, #16a34a 45%, var(--border)); }
details.answer[open] > summary { color: #15803d; }
html[data-theme="dark"] details.answer[open] > summary { color: #6ee7a0; }

.content p.opts { padding: 10px 14px; border-left: 3px solid var(--border); background: color-mix(in srgb, var(--surface-2) 55%, transparent); border-radius: 0 10px 10px 0; line-height: 1.8; }

/* nested boxes (AI family tree) */
.nest { --n: var(--accent); border: 2px solid var(--n); border-radius: 16px; padding: 12px 14px 14px; background: color-mix(in srgb, var(--n) 8%, var(--surface)); }
.nest > .nest { margin-top: 12px; }
.nest-t { display: block; font: 800 1rem/1.3 var(--font-ui); color: var(--text); }
.nest-s { display: block; font: 0.86rem/1.4 var(--font-ui); color: var(--muted); }
.nest-1 { --n: #64748b; } .nest-2 { --n: #2563eb; } .nest-3 { --n: #7c3aed; } .nest-4 { --n: #ea580c; }

/* numbered step flow (lifecycle diagrams) */
.content ol.flow { list-style: none; counter-reset: flow; padding: 0; margin-left: 0; display: grid; gap: 10px; }
.flow > li { counter-increment: flow; position: relative; margin: 0 !important; padding: 12px 16px 12px 58px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.flow > li::before { content: counter(flow); position: absolute; left: 14px; top: 12px; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: var(--accent-ink); font: 800 0.9rem var(--font-ui); }
.flow > li:not(:last-child)::after { content: ""; position: absolute; left: 28px; top: 44px; bottom: -12px; width: 2px; background: var(--border); }
.flow b { display: block; font-family: var(--font-ui); font-size: 0.98em; }
.flow span { display: block; color: var(--muted); font-size: 0.9em; line-height: 1.5; }
.flow em { font-style: normal; font-family: var(--font-ui); font-size: 0.78em; font-weight: 700; color: var(--accent); }

/* pager */
.pager { max-width: var(--measure); margin: 56px auto 0; display: grid; gap: 12px; grid-template-columns: 1fr; }
.pager a, .pager .disabled {
  display: grid; gap: 4px; padding: 16px 18px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface);
  text-decoration: none; color: var(--text); box-shadow: var(--shadow); font-family: var(--font-ui);
}
.pager a:hover { border-color: var(--accent); }
.pager .disabled { opacity: 0.6; box-shadow: none; }
.pager-label { display: inline-flex; align-items: center; gap: 4px; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--accent); font-weight: 800; }
.pager-next { text-align: right; }
.pager-next .pager-label { justify-content: flex-end; }
.pager-title { font-weight: 650; line-height: 1.3; }
@media (min-width: 700px) { .pager { grid-template-columns: 1fr 1fr; } }

.site-footer { max-width: var(--measure); margin: 64px auto 0; padding-top: 20px; border-top: 1px solid var(--border); font-size: 0.78rem; color: var(--muted); line-height: 1.6; }
.site-footer p { margin: 0 0 6px; }

/* back to top */
.to-top {
  position: fixed; right: max(16px, env(safe-area-inset-right)); bottom: max(18px, env(safe-area-inset-bottom)); z-index: 30;
  width: 46px; height: 46px; border-radius: 50%; border: 1px solid var(--border); background: var(--surface); color: var(--text);
  display: grid; place-items: center; box-shadow: var(--shadow); cursor: pointer;
}

/* toast */
.toast {
  position: fixed; left: 50%; bottom: max(20px, env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 70;
  display: flex; gap: 12px; align-items: center; padding: 10px 14px; border-radius: 999px;
  background: var(--text); color: var(--bg); font: 600 0.85rem var(--font-ui); box-shadow: var(--shadow); max-width: calc(100vw - 24px);
}
.toast button { background: none; border: 0; color: inherit; text-decoration: underline; cursor: pointer; font-weight: 700; padding: 6px; }

/* search */
.search { position: fixed; inset: 0; z-index: 80; background: rgba(8, 10, 14, 0.55); display: flex; justify-content: center; align-items: flex-start; padding: max(12px, env(safe-area-inset-top)) 12px 12px; }
.search-box { width: min(680px, 100%); max-height: calc(100vh - 24px); display: flex; flex-direction: column; background: var(--surface); border-radius: 18px; border: 1px solid var(--border); box-shadow: var(--shadow); overflow: hidden; }
.search-bar { display: flex; gap: 8px; align-items: center; padding: 12px; border-bottom: 1px solid var(--border); }
.search-bar input { flex: 1; min-width: 0; height: 46px; border-radius: 12px; border: 1px solid var(--border); background: var(--bg); color: var(--text); padding: 0 14px; font: 1rem var(--font-ui); }
.results { list-style: none; margin: 0; padding: 6px; overflow-y: auto; }
.results a { display: block; padding: 11px 12px; border-radius: 12px; text-decoration: none; color: var(--text); font-family: var(--font-ui); }
.results a:hover, .results a.sel { background: var(--surface-2); }
.results .r-page { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--accent); font-weight: 800; }
.results .r-head { font-weight: 700; margin: 2px 0; }
.results .r-snip { font-size: 0.85rem; color: var(--muted); line-height: 1.45; }
.results mark { background: color-mix(in srgb, var(--accent) 30%, transparent); color: inherit; border-radius: 3px; padding: 0 1px; }
.search-hint { margin: 0; padding: 10px 16px 14px; font-size: 0.8rem; color: var(--muted); }
kbd { font: 600 0.78em var(--font-mono); padding: 1px 6px; border-radius: 6px; border: 1px solid var(--border); background: var(--surface-2); }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 48px; padding: 0 22px; border-radius: 999px; font-weight: 700; text-decoration: none; border: 1px solid var(--border); background: var(--surface); color: var(--text); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.ghost { background: transparent; }

/* ---------- home ---------- */
.home { max-width: 1040px; margin: 0 auto; }
.hero {
  position: relative; overflow: hidden; border-radius: 24px; padding: clamp(26px, 6vw, 56px);
  color: #ffffff; background:
    radial-gradient(800px 380px at 105% -10%, rgba(255, 214, 10, 0.40), transparent 60%),
    radial-gradient(700px 360px at -10% 115%, rgba(0, 224, 255, 0.40), transparent 60%),
    linear-gradient(135deg, #4f46e5, #7c3aed 55%, #db2777);
}
.hero-kicker { margin: 0 0 14px; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.14em; color: #fde68a; font-weight: 800; }
.hero h1 { margin: 0 0 16px; font-size: clamp(2.1rem, 8vw, 3.9rem); line-height: 1.04; letter-spacing: -0.03em; }
.hero-sub { margin: 0 0 24px; max-width: 40rem; font-size: clamp(1rem, 2.6vw, 1.15rem); line-height: 1.6; color: #f1f5ff; }
.hero-cta { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 22px; }
.hero .btn { border-color: rgba(255, 255, 255, 0.28); background: rgba(255, 255, 255, 0.1); color: #fff; }
.hero .btn.primary { background: #fde047; border-color: #fde047; color: #1f1700; }
.chips { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.chips li { padding: 7px 14px; border-radius: 999px; background: rgba(255, 255, 255, 0.18); border: 1px solid rgba(255, 255, 255, 0.35); font-size: 0.85rem; color: #fff; }
.chips b { color: #fff; }

.how, .map { margin-top: 44px; }
.how h2, .map h2 { margin: 0 0 14px; font-size: 1.5rem; letter-spacing: -0.015em; }
.how-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.how-grid > div { padding: 18px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); }
.how-grid h3 { margin: 10px 0 6px; font-size: 1.02rem; }
.how-grid p { margin: 0; color: var(--muted); font-size: 0.92rem; line-height: 1.55; }
.how-ic { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 10px; background: linear-gradient(135deg, #4f46e5, #db2777); color: #fff; font-weight: 800; }
.map-head p { margin: 0 0 16px; }
.dgrid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); }
.dcard { --g: var(--c-note); padding: 18px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); border-top: 5px solid var(--g); }
.dcard[data-g="p1"], .toc-group[data-g="p1"], .group[data-g="p1"] { --g: #2563eb; }
.dcard[data-g="p2"], .toc-group[data-g="p2"], .group[data-g="p2"] { --g: #7c3aed; }
.dcard[data-g="p3"], .toc-group[data-g="p3"], .group[data-g="p3"] { --g: #ea580c; }
.dcard[data-g="p4"], .toc-group[data-g="p4"], .group[data-g="p4"] { --g: #059669; }
.dcard[data-g="p5"], .toc-group[data-g="p5"], .group[data-g="p5"] { --g: #db2777; }
.dcard[data-g="p6"], .toc-group[data-g="p6"], .group[data-g="p6"] { --g: #0891b2; }
.dcard[data-g="p7"], .toc-group[data-g="p7"], .group[data-g="p7"] { --g: #ca8a04; }
.dcard[data-g="p8"], .toc-group[data-g="p8"], .group[data-g="p8"] { --g: #4f46e5; }
.dcard[data-g="p9"], .toc-group[data-g="p9"], .group[data-g="p9"] { --g: #e11d48; }
.dcard[data-g="p10"], .toc-group[data-g="p10"], .group[data-g="p10"] { --g: #0d9488; }
.dcard[data-g="p11"], .toc-group[data-g="p11"], .group[data-g="p11"] { --g: #9333ea; }
.dcard[data-g="s0"], .toc-group[data-g="s0"], .group[data-g="s0"] { --g: #f97316; }
.eyebrow { margin: 0 0 4px; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--g, var(--muted)); font-weight: 800; }
.dcard h3 { margin: 0 0 10px; font-size: 1.1rem; line-height: 1.25; }
.wbar { height: 6px; border-radius: 99px; background: var(--surface-2); margin-bottom: 12px; overflow: hidden; }
.wbar span { display: block; height: 100%; background: var(--g); border-radius: 99px; }
.dcard ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.dcard li > a, .dcard li.soon { display: flex; align-items: baseline; gap: 10px; padding: 7px 6px; border-radius: 10px; text-decoration: none; color: var(--text); font-size: 0.92rem; line-height: 1.3; }
.dcard li > a:hover { background: var(--surface-2); }
.dcard li.soon { color: var(--muted); }
.group .group-title span { color: var(--g, var(--muted)); }

/* contents page */
.toc-group { --g: var(--c-note); margin-top: 2.4em; }
.toc-group h2 { margin: 0 0 12px; font-size: 1.4em; border: 0; padding: 0; margin-top: 0; }
.toc-group .eyebrow { margin-top: 0; }
.toc-group ol { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; }
.toc-ch { padding: 14px 16px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); border-left: 5px solid var(--g); }
.toc-ch h3 { margin: 0 0 6px; font-size: 1.02rem; display: flex; gap: 10px; align-items: baseline; }
.toc-ch h3 a { text-decoration: none; display: flex; gap: 10px; align-items: baseline; color: var(--text); }
.toc-ch ul { margin: 0; padding-left: 1.2em; font-family: var(--font-ui); font-size: 0.84rem; color: var(--muted); line-height: 1.5; }
.toc-ch.soon { opacity: 0.75; }
.plain .content h2:first-child { margin-top: 0; }

/* ---------- print ---------- */
@media print {
  :root { --fs: 11pt; }
  html[data-theme] { --bg: #fff; --surface: #fff; --surface-2: #f3f3f3; --text: #000; --muted: #444; --border: #bbb; --code-bg: #f5f5f5; --code-head: #eee; --code-text: #000; --accent: #7a2f00; --accent-soft: #fff4e8; --accent-ink: #fff; --link: #000; }
  .topbar, .drawer, .scrim, .settings, .search, .to-top, .pager, .toast, .anchor, .copy, .site-footer, .meta .text-btn, .skip { display: none !important; }
  .layout { display: block; }
  .main { padding: 0; }
  .content { font-size: 11pt; line-height: 1.5; max-width: none; }
  .chapter-head { max-width: none; }
  .content h1 { break-before: page; background: none; color: #000; border-bottom: 2px solid #000; border-radius: 0; padding: 0 0 6px; }
  .content h2, .content h3 { break-after: avoid; }
  details, .callout, .codeblock, .table-wrap, tr { break-inside: avoid; }
  details > summary::after { display: none; }
  .table-wrap { overflow: visible; }
  a { text-decoration: none; }
  .content a[href^="http"]::after { content: " (" attr(href) ")"; font-size: 0.8em; color: #444; }
}

@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }
