:root {
  --fg: #1a1a1a;
  --muted: #555;
  --bg: #fafafa;
  --bg-elev: #ffffff;
  --accent: #800000;
  --accent-hover: #a00000;
  --accent-soft: #fbe8e8;
  --accent-border: #e6c0c0;
  --code-bg: #f0f0f0;
  --kbd-bg: #fff;
  --kbd-border: #999;
  --kbd-fg: #1a1a1a;
  --panel: #f6f6f0;
  --tip-bg: #fff8d0;
  --tip-border: #cc0;
  --internals-bg: #eef2f8;
  --internals-border: #69b;
  --internals-fg: #246;
  --anecdote-bg: #fbf6ec;
  --anecdote-border: #a8884a;
  --anecdote-fg: #6a4a14;
  --qr-bg: #f6efef;
  --qr-fg: #4a1414;
  --buy-bg: #fff0e0;
  --buy-border: #c80;
  --example-bg: #fbf5f5;
  --example-border: #e6c0c0;
  --example-fg: #4a1414;
  --rule: #e5e5e5;
  --rule-strong: #ddd;
  --table-head: #efefef;
  --summary-bg: #fbf2f2;
  --summary-fg: #4a1414;
  --pager-hover-bg: #fbe8e8;
  --pager-hover-border: #e6c0c0;
  --broken: #a33;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --fg: #e6e6e6;
    --muted: #9aa0a6;
    --bg: #14161b;
    --bg-elev: #1c1f26;
    --accent: #e07070;
    --accent-hover: #ff8c8c;
    --accent-soft: #2a1818;
    --accent-border: #5a2828;
    --code-bg: #22262d;
    --kbd-bg: #2a2e36;
    --kbd-border: #555;
    --kbd-fg: #e6e6e6;
    --panel: #1c1f26;
    --tip-bg: #2c2a18;
    --tip-border: #b8a83a;
    --internals-bg: #18222e;
    --internals-border: #4a7aa0;
    --internals-fg: #aac6e0;
    --anecdote-bg: #2a2418;
    --anecdote-border: #a8884a;
    --anecdote-fg: #d8c08a;
    --qr-bg: #2a1818;
    --qr-fg: #d8a0a0;
    --buy-bg: #2c2418;
    --buy-border: #a87830;
    --example-bg: #1f1818;
    --example-border: #5a2828;
    --example-fg: #d8a0a0;
    --rule: #2a2e36;
    --rule-strong: #3a3e46;
    --table-head: #22262d;
    --summary-bg: #2a1818;
    --summary-fg: #e8b8b8;
    --pager-hover-bg: #2a1818;
    --pager-hover-border: #5a2828;
    --broken: #d88;
  }
}
:root[data-theme="dark"] {
  --fg: #e6e6e6;
  --muted: #9aa0a6;
  --bg: #14161b;
  --bg-elev: #1c1f26;
  --accent: #e07070;
  --accent-hover: #ff8c8c;
  --accent-soft: #2a1818;
  --accent-border: #5a2828;
  --code-bg: #22262d;
  --kbd-bg: #2a2e36;
  --kbd-border: #555;
  --kbd-fg: #e6e6e6;
  --panel: #1c1f26;
  --tip-bg: #2c2a18;
  --tip-border: #b8a83a;
  --internals-bg: #18222e;
  --internals-border: #4a7aa0;
  --internals-fg: #aac6e0;
  --anecdote-bg: #2a2418;
  --anecdote-border: #a8884a;
  --anecdote-fg: #d8c08a;
  --qr-bg: #2a1818;
  --qr-fg: #d8a0a0;
  --buy-bg: #2c2418;
  --buy-border: #a87830;
  --example-bg: #1f1818;
  --example-border: #5a2828;
  --example-fg: #d8a0a0;
  --rule: #2a2e36;
  --rule-strong: #3a3e46;
  --table-head: #22262d;
  --summary-bg: #2a1818;
  --summary-fg: #e8b8b8;
  --pager-hover-bg: #2a1818;
  --pager-hover-border: #5a2828;
  --broken: #d88;
}
button#theme-toggle {
  position: fixed; top: 10px; right: 10px; z-index: 1000;
  width: 36px; height: 36px; padding: 0;
  border: 1px solid var(--rule-strong); border-radius: 50%;
  background: var(--bg-elev); color: var(--fg);
  font-size: 1.05rem; line-height: 1; cursor: pointer;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
  transition: transform 0.15s ease, background 0.2s ease;
}
button#theme-toggle:hover {
  background: var(--accent-soft); border-color: var(--accent-border);
  transform: scale(1.05);
}
button#theme-toggle:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
* { box-sizing: border-box; }
body {
  font: 16px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--fg); background: var(--bg);
  margin: 0; padding: 0;
}
article {
  max-width: 760px; margin: 0 auto; padding: 2rem 1.25rem;
}
nav.topnav, nav.bottomnav {
  max-width: 760px; margin: 0 auto; padding: 0.75rem 1.25rem;
  font-size: 0.9rem; color: var(--muted);
}
nav a { color: var(--accent); text-decoration: none; }
nav a:hover { text-decoration: underline; }

a.practice-link {
  display: inline-block; background: var(--accent); color: #fff;
  padding: 4px 14px; border-radius: 4px; font-weight: 600;
  text-decoration: none;
}
a.practice-link:hover { background: var(--accent-hover); text-decoration: none; }
p.example-try {
  margin: 0.6rem 0 0; text-align: right; font-size: 0.92rem;
}
p.tagline {
  color: var(--muted); font-size: 1.1rem; margin: -0.4rem 0 1.6rem;
  font-style: italic;
}
section.hero {
  background: var(--accent-soft); border: 1px solid var(--accent-border);
  padding: 1rem 1.2rem; border-radius: 6px; margin: 0 0 2rem;
}
section.hero p { margin: 0.6rem 0; }
section.hero p:first-child { margin-top: 0; }
section.hero p:last-child { margin-bottom: 0; }
p.hero-cta { margin-top: 1rem !important; display: flex; align-items: center; gap: 0.8rem; flex-wrap: wrap; }
p.hero-cta .hero-aside { color: var(--muted); font-size: 0.92rem; }
h2.contents-heading { margin-top: 1.5rem; }
nav.pager {
  max-width: 760px; margin: 0.5rem auto; padding: 0.6rem 1.25rem;
  display: grid; grid-template-columns: 1fr auto 1fr;
  align-items: center; gap: 0.8rem;
  font-size: 0.92rem;
  border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule);
}
nav.pager .pager-prev { text-align: left; }
nav.pager .pager-next { text-align: right; }
nav.pager .pager-pos  { color: var(--muted); font-variant-numeric: tabular-nums; }
nav.pager .pager-link {
  display: inline-block; padding: 4px 10px; border-radius: 4px;
  text-decoration: none; color: var(--accent);
  border: 1px solid transparent;
}
nav.pager .pager-link:hover { background: var(--pager-hover-bg); border-color: var(--pager-hover-border); text-decoration: none; }
nav.pager .pager-disabled { color: var(--muted); opacity: 0.5; font-style: italic; }
nav.pager.pager-bottom { margin-top: 2rem; }

footer.site-footer {
  margin: 3rem 0 1rem;
  padding: 0.8rem 0 0;
  border-top: 1px solid var(--rule);
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
}
footer.site-footer a { color: var(--muted); }

h1 { font-size: 2rem; margin: 0.4rem 0 0.2rem; }
h2 { font-size: 1.4rem; margin: 1.8rem 0 0.6rem; border-bottom: 1px solid var(--rule-strong); padding-bottom: 0.3rem; }
h3 { font-size: 1.15rem; margin: 1.4rem 0 0.4rem; }
p.subtitle { color: var(--muted); font-size: 1.1rem; margin-top: 0; font-style: italic; }
p.meta { color: var(--muted); font-size: 0.9rem; }

a { color: var(--accent); }
a:hover { color: var(--accent-hover); }
a.broken, span.broken { color: var(--broken); text-decoration: line-through dotted; }

code {
  background: var(--code-bg); padding: 1px 5px; border-radius: 3px;
  font: 0.9em ui-monospace, "Fira Code", Consolas, monospace;
}
pre {
  background: var(--code-bg); padding: 0.7rem 0.9rem; border-radius: 5px;
  overflow-x: auto; margin: 0.8rem 0;
  border-left: 3px solid var(--rule-strong);
}
pre code { background: transparent; padding: 0; font-size: 0.9rem; }
kbd {
  background: var(--kbd-bg); border: 1px solid var(--kbd-border);
  border-bottom-width: 2px; border-radius: 4px;
  padding: 0 5px; font: 0.85em ui-monospace, Consolas, monospace;
  color: var(--kbd-fg);
  white-space: nowrap;
}
/* Keycaps that appear inside a link or heading inherit the link/heading color
   instead of the high-contrast white-on-gray default — this keeps the title
   visually unified rather than spotted with neutral chips. */
a kbd, h1 kbd, h2 kbd, h3 kbd, h4 kbd, .subtitle kbd {
  background: transparent; color: inherit;
  border-color: currentColor;
  border-bottom-width: 1px;
  text-decoration: none;
}
a kbd { display: inline-block; text-decoration: none; }
a:hover kbd { color: inherit; }

blockquote.summary {
  border-left: 3px solid var(--accent); margin: 1rem 0;
  padding: 0.6rem 1rem; background: var(--summary-bg); color: var(--summary-fg);
  font-size: 1.05rem;
}

table {
  border-collapse: collapse; width: 100%; margin: 1rem 0;
  font-size: 0.95rem;
}
th, td { border: 1px solid var(--rule-strong); padding: 0.4rem 0.6rem; text-align: left; vertical-align: top; }
thead th { background: var(--table-head); }

figure.keys, figure.lesson-embed { margin: 1rem 0; }
figure.keys figcaption, figure.lesson-embed figcaption {
  font-style: italic; color: var(--muted); font-size: 0.9rem; margin-bottom: 0.4rem;
}
figure.lesson-embed iframe.lesson-iframe {
  width: 100%; aspect-ratio: 1/1; max-width: 480px; border: 0; border-radius: 6px;
  background: #000; display: block;
}
figure.lesson-embed .placeholder {
  background: #222; color: #fff; padding: 2rem; text-align: center;
  border-radius: 6px; font-size: 1.1rem;
}

aside.tip {
  background: var(--tip-bg); border-left: 4px solid var(--tip-border);
  padding: 0.7rem 1rem; margin: 1rem 0; border-radius: 4px;
}
aside.internals {
  background: var(--internals-bg); border-left: 4px solid var(--internals-border);
  padding: 0.7rem 1rem; margin: 1.2rem 0; border-radius: 4px;
}
aside.internals header {
  font-weight: 600; margin-bottom: 0.4rem; color: var(--internals-fg);
}
aside.internals p { margin: 0.5rem 0; }
aside.internals ul { margin: 0.5rem 0; padding-left: 1.4rem; }
aside.anecdote {
  background: var(--anecdote-bg); border-left: 4px solid var(--anecdote-border);
  padding: 0.7rem 1rem; margin: 1.2rem 0; border-radius: 4px;
  font-style: italic;
}
aside.anecdote header {
  font-weight: 600; margin-bottom: 0.4rem; color: var(--anecdote-fg);
  font-style: normal;
}
aside.anecdote p { margin: 0.5rem 0; }
aside.qr {
  background: var(--qr-bg); padding: 0.4rem 0.8rem; margin: 1rem 0;
  border-radius: 4px; font-size: 0.9rem; color: var(--qr-fg);
  display: flex; align-items: center; gap: 0.8rem;
}
aside.qr img.qr-img { background: #fff; padding: 4px; border-radius: 4px; }
section.watch { margin: 2rem 0; padding-top: 1rem; border-top: 1px solid var(--rule-strong); }
section.watch h2 { margin-top: 0; }
ul.lesson-grid {
  list-style: none; padding: 0; display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1.2rem;
}
ul.lesson-grid li { display: flex; flex-direction: column; gap: 0.4rem; }
ul.lesson-grid iframe.lesson-iframe {
  width: 100%; aspect-ratio: 1/1; border: 0; border-radius: 6px;
  background: #000; display: block;
}
ul.lesson-grid .lesson-meta { font-size: 0.85rem; color: var(--muted); }
ul.lesson-grid .lesson-pending .placeholder {
  background: var(--code-bg); color: var(--muted); padding: 1.5rem 1rem;
  text-align: center; border-radius: 6px; aspect-ratio: 1/1;
  display: flex; align-items: center; justify-content: center;
}
aside.buy-prompt {
  background: var(--buy-bg); border: 1px dashed var(--buy-border);
  padding: 0.6rem 1rem; margin: 1.5rem 0; border-radius: 4px;
  text-align: center; font-style: italic;
}

section.example {
  margin: 1.6rem 0; padding: 1rem 1.2rem;
  background: var(--example-bg); border: 1px solid var(--example-border); border-radius: 6px;
}
section.example h3.example-title {
  margin: 0 0 0.4rem; font-size: 1.05rem; color: var(--example-fg);
  text-transform: uppercase; letter-spacing: 0.04em;
}
section.example p.example-summary {
  margin: 0 0 1rem; color: var(--example-fg); font-style: italic; opacity: 0.85;
}
figure.example-step {
  margin: 0.8rem 0; padding: 0.6rem; background: var(--bg-elev);
  border-radius: 4px; border: 1px solid var(--example-border);
}
figure.example-step figcaption {
  font-size: 0.95rem; color: var(--fg); margin-bottom: 0.5rem;
}
figure.example-step .step-n {
  display: inline-block; font-weight: 600; color: var(--accent);
  margin-right: 0.5rem;
}
figure.example-step .step-cap { color: var(--fg); }
figure.example-step .screenshot {
  background: #000; border-radius: 4px; padding: 4px;
  display: flex; justify-content: flex-start;
}
figure.example-step .screenshot img {
  width: 100%; max-width: 380px; height: auto; display: block;
}
figure.example-step .screenshot.missing {
  background: var(--accent-soft); color: var(--broken); padding: 1rem; text-align: center;
  font-family: monospace; font-size: 0.9rem;
}
figure.example-step p.narration {
  margin: 0.6rem 0 0; color: var(--muted); font-size: 0.95rem;
}

p.see-also {
  margin-top: 2rem; padding-top: 0.8rem; border-top: 1px solid var(--rule-strong);
  font-size: 0.95rem;
}
ol.topic-list { padding-left: 1.5rem; }
ol.topic-list li { margin: 0.4rem 0; }
.sub { color: var(--muted); }
