/* ==========================================================================
   The Home Server Book — presentation layer.
   Content never touches this file; this file never knows what a chapter says.
   ========================================================================== */

/* --- tokens ------------------------------------------------------------- */

:root {
  --paper:        #fbfaf7;
  --surface:      #ffffff;
  --surface-2:    #f4f2ed;
  --ink:          #1d2025;
  --ink-soft:     #3c424c;
  --muted:        #6b7280;
  --line:         #e4e0d8;
  --line-strong:  #d3cec3;

  --accent:       #17605c;
  --accent-soft:  #e6f1ef;
  --accent-ink:   #0e4a47;
  --warm:         #a4501a;
  --warm-soft:    #fbeee2;
  --warm-line:    #e8c9a8;
  --danger:       #a32f2a;
  --danger-soft:  #fbeceb;
  --danger-line:  #efc4c1;
  --caution:      #8a6410;
  --caution-soft: #fcf3dc;
  --caution-line: #e8d49a;

  --shadow-sm: 0 1px 2px rgb(28 25 20 / 0.05), 0 1px 3px rgb(28 25 20 / 0.04);
  --shadow-md: 0 2px 4px rgb(28 25 20 / 0.04), 0 8px 24px rgb(28 25 20 / 0.07);
  --shadow-lg: 0 12px 40px rgb(28 25 20 / 0.13);

  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, ui-serif, serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Mono", Menlo, Consolas, monospace;

  --measure: 45rem;
  --sidebar-w: 19rem;
  --rail-w: 14rem;
  --radius: 10px;
  --radius-lg: 16px;
}

:root[data-theme="dark"] {
  --paper:        #101216;
  --surface:      #171a1f;
  --surface-2:    #1e2228;
  --ink:          #e8eaed;
  --ink-soft:     #ccd2da;
  --muted:        #939cab;
  --line:         #272c34;
  --line-strong:  #343b45;

  --accent:       #66c4bb;
  --accent-soft:  #16302e;
  --accent-ink:   #9adcd4;
  --warm:         #e0a06a;
  --warm-soft:    #2c2118;
  --warm-line:    #4a3524;
  --danger:       #ef9a95;
  --danger-soft:  #2d1a19;
  --danger-line:  #4d2b29;
  --caution:      #e3c473;
  --caution-soft: #2a2317;
  --caution-line: #453a20;

  --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.3);
  --shadow-md: 0 2px 4px rgb(0 0 0 / 0.25), 0 8px 24px rgb(0 0 0 / 0.35);
  --shadow-lg: 0 12px 40px rgb(0 0 0 / 0.5);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper:        #101216;
    --surface:      #171a1f;
    --surface-2:    #1e2228;
    --ink:          #e8eaed;
    --ink-soft:     #ccd2da;
    --muted:        #939cab;
    --line:         #272c34;
    --line-strong:  #343b45;

    --accent:       #66c4bb;
    --accent-soft:  #16302e;
    --accent-ink:   #9adcd4;
    --warm:         #e0a06a;
    --warm-soft:    #2c2118;
    --warm-line:    #4a3524;
    --danger:       #ef9a95;
    --danger-soft:  #2d1a19;
    --danger-line:  #4d2b29;
    --caution:      #e3c473;
    --caution-soft: #2a2317;
    --caution-line: #453a20;

    --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.3);
    --shadow-md: 0 2px 4px rgb(0 0 0 / 0.25), 0 8px 24px rgb(0 0 0 / 0.35);
    --shadow-lg: 0 12px 40px rgb(0 0 0 / 0.5);
  }
}

/* --- reset -------------------------------------------------------------- */

*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img, svg { max-width: 100%; }
img { height: auto; display: block; }
button { font: inherit; color: inherit; cursor: pointer; }
a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--accent-ink); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 100;
  background: var(--accent); color: #fff; padding: 0.6rem 1rem; border-radius: 0 0 8px 0;
}
.skip-link:focus { left: 0; }

/* --- layout ------------------------------------------------------------- */

.layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100vh;
}

.content-area {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

main {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, var(--measure)) var(--rail-w);
  gap: 3.5rem;
  justify-content: center;
  padding: 3rem 3rem 5rem;
  align-items: start;
}

/* Pages without an on-page contents rail centre their single column. */
main:not(:has(.rail)) { grid-template-columns: minmax(0, var(--measure)); }

@media (max-width: 1240px) {
  main { grid-template-columns: minmax(0, var(--measure)); }
  .rail { display: none; }
}

/* --- sidebar ------------------------------------------------------------ */

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--surface-2);
  border-right: 1px solid var(--line);
}

.sidebar__brand {
  display: block;
  padding: 1.6rem 1.5rem 1.1rem;
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid var(--line);
}
.sidebar__brand-title {
  display: block;
  font-family: var(--serif);
  font-size: 1.22rem;
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.01em;
}
.sidebar__brand-sub {
  display: block;
  margin-top: 0.3rem;
  font-size: 0.79rem;
  color: var(--muted);
  line-height: 1.4;
}

.sidebar__progress { padding: 0.9rem 1.5rem; border-bottom: 1px solid var(--line); }
.sidebar__progress-bar {
  height: 5px;
  border-radius: 99px;
  background: var(--line-strong);
  overflow: hidden;
}
.sidebar__progress-bar span {
  display: block; height: 100%; width: 0%;
  background: var(--accent);
  border-radius: 99px;
  transition: width 0.4s ease;
}
.sidebar__progress-label {
  margin-top: 0.45rem;
  font-size: 0.72rem;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.sidebar__scroll { overflow-y: auto; padding: 1rem 0.75rem 3rem; flex: 1; }

.sidebar__part {
  padding: 1.1rem 0.75rem 0.4rem;
  font-size: 0.68rem;
  font-weight: 650;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
}
.sidebar__list { list-style: none; padding: 0; }

.sidebar__link {
  display: grid;
  grid-template-columns: 1.6rem 1fr auto;
  align-items: baseline;
  gap: 0.5rem;
  padding: 0.42rem 0.75rem;
  border-radius: 8px;
  color: var(--ink-soft);
  text-decoration: none;
  font-size: 0.9rem;
  line-height: 1.4;
}
.sidebar__link:hover { background: var(--surface); color: var(--ink); }
.sidebar__link.is-current {
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-weight: 600;
}
.sidebar__link.is-upcoming { color: var(--muted); opacity: 0.65; cursor: default; }
.sidebar__link--annex { grid-template-columns: 1fr; }
.sidebar__num { font-variant-numeric: tabular-nums; font-size: 0.78rem; color: var(--muted); }
.sidebar__link.is-current .sidebar__num { color: var(--accent); }

.sidebar__tick { width: 1rem; height: 1rem; align-self: center; }
.sidebar__link.is-done .sidebar__tick {
  background: var(--accent);
  mask: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M4 12.5 9 17.5 20 6.5" fill="none" stroke="black" stroke-width="2.6" stroke-linecap="round" stroke-linejoin="round"/></svg>') center / 0.9rem no-repeat;
}

.nav-toggle {
  display: none;
  position: fixed; top: 0.7rem; left: 0.7rem; z-index: 60;
  width: 2.6rem; height: 2.6rem;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  padding: 0.55rem;
}

@media (max-width: 900px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .nav-toggle { display: block; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; z-index: 70;
    width: min(20rem, 86vw);
    transform: translateX(-101%);
    transition: transform 0.25s ease;
    box-shadow: var(--shadow-lg);
  }
  .sidebar.is-open { transform: none; }
  main { padding: 4rem 1.25rem 4rem; }
  body.nav-open { overflow: hidden; }
}

/* --- topbar ------------------------------------------------------------- */

.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 0.7rem 3rem;
  background: color-mix(in srgb, var(--paper) 86%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  min-height: 3.4rem;
}
.topbar__where {
  display: flex; align-items: center; gap: 0.5rem;
  font-size: 0.8rem; color: var(--muted); min-width: 0;
}
.topbar__part { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar__title { color: var(--ink-soft); font-weight: 550; }
.topbar__actions { display: flex; align-items: center; gap: 0.5rem; flex-shrink: 0; }

@media (max-width: 900px) {
  .topbar { padding: 0.7rem 1.25rem 0.7rem 3.6rem; }
}

.prompt-btn {
  display: inline-flex; align-items: center; gap: 0.45rem;
  max-width: min(26rem, 46vw);
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--warm-line);
  border-radius: 99px;
  background: var(--warm-soft);
  color: var(--warm);
  font-size: 0.78rem;
  font-weight: 550;
  white-space: nowrap;
}
.prompt-btn:hover { border-color: var(--warm); }
.prompt-btn svg { width: 1rem; height: 1rem; flex-shrink: 0; }
.prompt-btn__label { overflow: hidden; text-overflow: ellipsis; }
.prompt-btn em { font-style: normal; font-weight: 650; }
@media (max-width: 700px) { .prompt-btn__label { display: none; } }

.theme-toggle {
  width: 2.15rem; height: 2.15rem;
  display: grid; place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
}
.theme-toggle:hover { color: var(--ink); border-color: var(--line-strong); }
.theme-toggle svg { width: 1.05rem; height: 1.05rem; }
.theme-toggle__moon { display: none; }
:root[data-theme="dark"] .theme-toggle__sun { display: none; }
:root[data-theme="dark"] .theme-toggle__moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle__sun { display: none; }
  :root:not([data-theme="light"]) .theme-toggle__moon { display: block; }
}

/* --- page header -------------------------------------------------------- */

.page { min-width: 0; }

.page__header { margin-bottom: 2rem; }
.page__eyebrow {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem;
  font-size: 0.74rem; letter-spacing: 0.07em; text-transform: uppercase;
  color: var(--muted); margin-bottom: 0.9rem;
}
.page__part { color: var(--accent); font-weight: 650; }
.page__chapter::before, .page__time::before { content: "·"; margin-right: 0.6rem; opacity: 0.6; }
.page__title {
  font-family: var(--serif);
  font-size: clamp(2.1rem, 4.4vw, 2.95rem);
  line-height: 1.1;
  letter-spacing: -0.022em;
  font-weight: 600;
}
.page__summary {
  margin-top: 0.9rem;
  font-size: 1.14rem;
  line-height: 1.55;
  color: var(--ink-soft);
  max-width: 38rem;
}

.goals {
  margin: 0 0 2.5rem;
  padding: 1.1rem 1.3rem;
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  background: var(--surface);
}
.goals__title {
  font-size: 0.74rem; letter-spacing: 0.07em; text-transform: uppercase;
  color: var(--muted); font-weight: 650; margin-bottom: 0.6rem;
}
.goals__list { margin: 0; padding-left: 1.1rem; }
.goals__list li { margin: 0.25rem 0; font-size: 0.94rem; color: var(--ink-soft); }

/* --- prose -------------------------------------------------------------- */

.prose { font-size: 1.0625rem; }
.prose > * + * { margin-top: 1.15rem; }

.prose p { color: var(--ink-soft); }
.prose strong { color: var(--ink); font-weight: 620; }

.prose h2, .prose h3, .prose h4 {
  font-family: var(--serif);
  line-height: 1.22;
  letter-spacing: -0.014em;
  color: var(--ink);
  scroll-margin-top: 5rem;
}
.prose h2 {
  margin-top: 3.2rem;
  padding-top: 1.6rem;
  border-top: 1px solid var(--line);
  font-size: 1.72rem;
  font-weight: 600;
}
.prose h2:first-child { margin-top: 0; border-top: 0; padding-top: 0; }
.prose h3 { margin-top: 2.1rem; font-size: 1.28rem; font-weight: 600; }
.prose h4 { margin-top: 1.6rem; font-size: 1.06rem; font-weight: 650; font-family: var(--sans); }

.prose .header-anchor {
  float: left;
  margin-left: -1.35rem;
  width: 1.35rem;
  color: var(--line-strong);
  text-decoration: none;
  opacity: 0;
  font-weight: 400;
  transition: opacity 0.15s;
}
.prose h2:hover .header-anchor,
.prose h3:hover .header-anchor,
.prose .header-anchor:focus { opacity: 1; }
@media (max-width: 700px) { .prose .header-anchor { display: none; } }

.prose ul, .prose ol { padding-left: 1.4rem; color: var(--ink-soft); }
.prose li + li { margin-top: 0.35rem; }
.prose li > ul, .prose li > ol { margin-top: 0.35rem; }

.prose blockquote {
  padding: 0.2rem 0 0.2rem 1.2rem;
  border-left: 3px solid var(--line-strong);
  color: var(--muted);
  font-style: italic;
}

.prose hr { border: 0; border-top: 1px solid var(--line); margin: 2.5rem 0; }

.prose code {
  font-family: var(--mono);
  font-size: 0.86em;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 0.1em 0.34em;
  color: var(--ink);
  word-break: break-word;
}

.prose table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.93rem;
  display: block;
  overflow-x: auto;
}
.prose thead th {
  text-align: left;
  font-size: 0.74rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom: 1px solid var(--line-strong);
  padding: 0.5rem 0.8rem 0.5rem 0;
  white-space: nowrap;
}
.prose tbody td {
  padding: 0.55rem 0.8rem 0.55rem 0;
  border-bottom: 1px solid var(--line);
  color: var(--ink-soft);
  vertical-align: top;
}

/* --- glossary terms ----------------------------------------------------- */

.term {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px dashed var(--accent);
  cursor: help;
}
.term:hover { color: var(--accent); }

.term-pop {
  position: absolute;
  z-index: 80;
  max-width: 20rem;
  padding: 0.65rem 0.8rem;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background: var(--surface);
  box-shadow: var(--shadow-md);
  font-size: 0.84rem;
  line-height: 1.5;
  color: var(--ink-soft);
}

/* --- code blocks -------------------------------------------------------- */

.code-block {
  margin: 1.6rem 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}
.code-block__head {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 0.4rem 0.5rem 0.4rem 0.9rem;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
  min-height: 2.35rem;
}
.code-block__head--bare { justify-content: flex-end; }
.code-block__title {
  font-family: var(--mono);
  font-size: 0.76rem;
  color: var(--muted);
}
.code {
  margin: 0;
  padding: 0.95rem 1.1rem;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 0.845rem;
  line-height: 1.62;
  tab-size: 2;
}
.code code { background: none; border: 0; padding: 0; font-size: inherit; color: var(--ink); }

/* Console sessions: the command you type stands out from what comes back. */
.code--console code .gp { color: var(--accent); font-weight: 600; user-select: none; }
.code--console code .go { color: var(--muted); }

.copy-btn {
  display: inline-flex; align-items: center; gap: 0.35rem;
  padding: 0.28rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 550;
  white-space: nowrap;
}
.copy-btn:hover { color: var(--ink); border-color: var(--line-strong); }
.copy-btn svg { width: 0.85rem; height: 0.85rem; }
.copy-btn.is-copied { color: var(--accent); border-color: var(--accent); }

.snippet {
  margin: 1.6rem 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
}
.snippet__head {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 0.4rem 0.5rem 0.4rem 0.9rem;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
}
.snippet__file { font-family: var(--mono); font-size: 0.76rem; color: var(--accent); }

/* --- callouts ----------------------------------------------------------- */

.callout {
  margin: 1.7rem 0;
  padding: 0.95rem 1.15rem;
  border: 1px solid var(--line);
  border-left: 3px solid var(--muted);
  border-radius: var(--radius);
  background: var(--surface);
}
.callout__title {
  display: flex; align-items: center; gap: 0.5rem;
  font-size: 0.8rem; font-weight: 650; letter-spacing: 0.02em;
  margin-bottom: 0.45rem;
}
.callout__title .icon { width: 1.05rem; height: 1.05rem; flex-shrink: 0; }
.callout__body > * + * { margin-top: 0.7rem; }
.callout__body p, .callout__body li { font-size: 0.95rem; }
.callout__body > :last-child { margin-bottom: 0; }

.callout--note   { border-left-color: var(--accent); background: var(--accent-soft); }
.callout--note   .callout__title { color: var(--accent-ink); }
.callout--tip    { border-left-color: var(--accent); }
.callout--tip    .callout__title { color: var(--accent); }
.callout--warning { border-left-color: var(--caution); background: var(--caution-soft); border-color: var(--caution-line); }
.callout--warning .callout__title { color: var(--caution); }
.callout--danger { border-left-color: var(--danger); background: var(--danger-soft); border-color: var(--danger-line); }
.callout--danger .callout__title { color: var(--danger); }

.callout--note code, .callout--warning code, .callout--danger code { background: color-mix(in srgb, var(--surface) 70%, transparent); }

/* --- objective / recap -------------------------------------------------- */

.objective {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.9rem;
  margin: 1.8rem 0;
  padding: 1.15rem 1.3rem;
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, var(--accent-soft), var(--surface));
  border: 1px solid var(--line);
}
.objective .icon { width: 1.4rem; height: 1.4rem; color: var(--accent); margin-top: 0.15rem; }
.objective__body > * + * { margin-top: 0.6rem; }
.objective__body p { font-size: 1.02rem; color: var(--ink); }

.recap {
  margin: 2.4rem 0 1.5rem;
  padding: 1.2rem 1.35rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.recap__title {
  display: flex; align-items: center; gap: 0.5rem;
  font-size: 0.76rem; letter-spacing: 0.07em; text-transform: uppercase;
  font-weight: 650; color: var(--muted); margin-bottom: 0.7rem;
}
.recap__title .icon { width: 1rem; height: 1rem; }
.recap__body ul { padding-left: 1.2rem; }
.recap__body li { font-size: 0.95rem; }

/* --- aside -------------------------------------------------------------- */

.aside {
  margin: 1.7rem 0;
  padding: 0.85rem 0 0.85rem 1.15rem;
  border-left: 2px solid var(--line-strong);
  font-size: 0.9rem;
  color: var(--muted);
}
.aside__title {
  font-size: 0.72rem; letter-spacing: 0.07em; text-transform: uppercase;
  font-weight: 650; color: var(--ink-soft); margin-bottom: 0.4rem;
}
.aside__body > * + * { margin-top: 0.6rem; }
.aside__body p, .aside__body li { font-size: 0.9rem; color: var(--muted); }

@media (min-width: 1500px) {
  .aside {
    float: right;
    clear: right;
    width: 15.5rem;
    margin: 0.35rem calc(-15.5rem - 2.5rem) 1.2rem 2rem;
    border-left: 0;
    border-top: 2px solid var(--line-strong);
    padding: 0.7rem 0 0;
  }
}

/* --- reveal (why / quiz) ------------------------------------------------ */

.reveal {
  margin: 1.6rem 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}
.reveal__summary {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.75rem 1rem;
  cursor: pointer;
  list-style: none;
  font-size: 0.93rem;
  font-weight: 550;
  color: var(--ink);
}
.reveal__summary::-webkit-details-marker { display: none; }
.reveal__summary:hover { background: var(--surface-2); }
.reveal__summary .icon {
  width: 1rem; height: 1rem; color: var(--accent); flex-shrink: 0;
  transition: transform 0.18s ease;
}
.reveal[open] .reveal__summary .icon { transform: rotate(90deg); }
.reveal__question { flex: 1; }
.reveal__hint {
  font-size: 0.72rem; color: var(--muted); font-weight: 500;
  border: 1px solid var(--line); border-radius: 99px; padding: 0.1rem 0.5rem;
  white-space: nowrap;
}
.reveal[open] .reveal__hint { display: none; }
.reveal__body {
  padding: 0 1rem 1rem;
  border-top: 1px solid var(--line);
  padding-top: 0.9rem;
}
.reveal__body > * + * { margin-top: 0.75rem; }
.reveal__body p, .reveal__body li { font-size: 0.95rem; }
.reveal--quiz { border-left: 3px solid var(--warm); }
.reveal--quiz .reveal__summary .icon { color: var(--warm); }

/* --- checklist ---------------------------------------------------------- */

.checklist {
  margin: 2rem 0;
  padding: 1.1rem 1.3rem;
  border: 1px solid var(--accent);
  border-radius: var(--radius-lg);
  background: var(--surface);
}
.checklist__title {
  display: flex; align-items: center; gap: 0.5rem;
  font-size: 0.76rem; letter-spacing: 0.07em; text-transform: uppercase;
  font-weight: 650; color: var(--accent); margin-bottom: 0.7rem;
}
.checklist__title .icon { width: 1rem; height: 1rem; }
.checklist__body ul { list-style: none; padding: 0; }
.checklist__body li {
  display: flex; align-items: flex-start; gap: 0.6rem;
  padding: 0.4rem 0;
  font-size: 0.95rem;
  border-bottom: 1px solid var(--line);
}
.checklist__body li:last-child { border-bottom: 0; }
.checklist__body input[type="checkbox"] {
  margin-top: 0.32rem;
  width: 1.05rem; height: 1.05rem;
  accent-color: var(--accent);
  flex-shrink: 0;
  cursor: pointer;
}
.checklist__body li:has(input:checked) { color: var(--muted); }
.checklist__body li:has(input:checked) code { opacity: 0.7; }

/* --- agent card --------------------------------------------------------- */

.agent-card {
  margin: 1.9rem 0;
  padding: 1.1rem 1.25rem;
  border: 1px solid var(--warm-line);
  border-left: 3px solid var(--warm);
  border-radius: var(--radius-lg);
  background: var(--warm-soft);
}
.agent-card__head {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: start;
  gap: 0.75rem;
}
.agent-card__head .icon { width: 1.25rem; height: 1.25rem; color: var(--warm); margin-top: 0.15rem; }
.agent-card__title { font-size: 0.99rem; font-weight: 620; color: var(--ink); line-height: 1.4; }
.agent-card__goal { margin-top: 0.2rem; font-size: 0.87rem; color: var(--warm); }
.agent-card__note {
  margin-top: 0.75rem;
  font-size: 0.83rem;
  line-height: 1.55;
  color: var(--muted);
}
.agent-card .copy-btn {
  background: var(--warm);
  border-color: var(--warm);
  color: #fff;
  padding: 0.4rem 0.75rem;
  font-size: 0.78rem;
}
.agent-card .copy-btn:hover { filter: brightness(1.08); color: #fff; }
.agent-card .copy-btn.is-copied { background: var(--accent); border-color: var(--accent); }
:root[data-theme="dark"] .agent-card .copy-btn { color: #201406; }

@media (max-width: 620px) {
  .agent-card__head { grid-template-columns: auto 1fr; }
  .agent-card__head .copy-btn { grid-column: 1 / -1; justify-self: start; margin-top: 0.5rem; }
}

/* --- diagrams ----------------------------------------------------------- */

.diagram { margin: 2.2rem 0; }
.diagram__frame {
  position: relative;
  padding: 1.5rem 1.25rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  overflow: hidden;
}
.diagram__frame svg { display: block; width: 100%; height: auto; }
.diagram__caption {
  margin-top: 0.7rem;
  font-size: 0.85rem;
  color: var(--muted);
  text-align: center;
  line-height: 1.5;
}
.diagram__replay {
  position: absolute; top: 0.6rem; right: 0.6rem;
  display: inline-flex; align-items: center; gap: 0.3rem;
  padding: 0.25rem 0.55rem;
  border: 1px solid var(--line);
  border-radius: 99px;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.72rem;
  opacity: 0;
  transition: opacity 0.15s;
}
.diagram__frame:hover .diagram__replay,
.diagram__replay:focus { opacity: 1; }
.diagram__replay svg { width: 0.8rem; height: 0.8rem; }

/* Diagram vocabulary, so every SVG in book/diagrams/ inherits the theme. */
.diagram svg { --d-line: var(--line-strong); --d-ink: var(--ink-soft); --d-accent: var(--accent); --d-warm: var(--warm); --d-muted: var(--muted); --d-surface: var(--surface-2); }
.diagram svg text { font-family: var(--sans); fill: var(--d-ink); }
.diagram svg .d-label { font-size: 12px; fill: var(--d-ink); }
.diagram svg .d-small { font-size: 10.5px; fill: var(--d-muted); }
.diagram svg .d-title { font-size: 13px; font-weight: 600; fill: var(--ink); }
.diagram svg .d-box { fill: var(--d-surface); stroke: var(--d-line); stroke-width: 1.2; }
.diagram svg .d-box-accent { fill: var(--accent-soft); stroke: var(--d-accent); stroke-width: 1.4; }
.diagram svg .d-box-warm { fill: var(--warm-soft); stroke: var(--warm-line); stroke-width: 1.2; }
.diagram svg .d-arrow { stroke: var(--d-line); stroke-width: 1.6; fill: none; }
.diagram svg .d-arrow-accent { stroke: var(--d-accent); stroke-width: 1.8; fill: none; }
.diagram svg .d-arrow-danger { stroke: var(--danger); stroke-width: 1.8; fill: none; }
.diagram svg .d-fill-accent { fill: var(--d-accent); }
.diagram svg .d-fill-line { fill: var(--d-line); }
.diagram svg .d-dashed { stroke-dasharray: 5 4; }

/* --- figures ------------------------------------------------------------ */

.figure {
  margin: 2.2rem auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--surface);
}
.figure img { width: 100%; }
.figure__caption {
  padding: 0.7rem 1rem;
  font-size: 0.84rem;
  color: var(--muted);
  border-top: 1px solid var(--line);
  line-height: 1.5;
}
.figure__credit { opacity: 0.75; font-size: 0.78rem; }

/* --- annex link --------------------------------------------------------- */

.annex-link {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.85rem;
  margin: 1.7rem 0;
  padding: 0.9rem 1.1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  text-decoration: none;
  color: inherit;
}
.annex-link:hover { border-color: var(--accent); background: var(--accent-soft); }
.annex-link .icon { width: 1.2rem; height: 1.2rem; color: var(--accent); }
.annex-link__body { display: block; min-width: 0; }
.annex-link__label {
  display: block;
  font-size: 0.68rem; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--muted); font-weight: 650;
}
.annex-link__title { display: block; font-size: 0.98rem; font-weight: 580; color: var(--ink); }
.annex-link__summary { display: block; font-size: 0.85rem; color: var(--muted); margin-top: 0.15rem; }
.annex-link > .icon:last-child { color: var(--muted); width: 1rem; }

/* --- widgets ------------------------------------------------------------ */

.widget {
  margin: 2.2rem 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  overflow: hidden;
}
.widget__fallback { padding: 1rem; font-size: 0.9rem; color: var(--muted); }

.w-head {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 0.7rem 1.1rem;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}
.w-head__title { font-size: 0.8rem; font-weight: 650; letter-spacing: 0.03em; color: var(--ink-soft); }
.w-head__hint { font-size: 0.74rem; color: var(--muted); }
.w-body { padding: 1.15rem; }

.w-btn {
  padding: 0.35rem 0.7rem;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: var(--surface);
  font-size: 0.8rem;
  color: var(--ink-soft);
}
.w-btn:hover { border-color: var(--accent); color: var(--accent); }
.w-btn.is-active { background: var(--accent); border-color: var(--accent); color: #fff; }
:root[data-theme="dark"] .w-btn.is-active { color: #10201f; }

.w-steps { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 1.1rem; }

.w-stage {
  display: grid;
  gap: 1rem;
  align-items: center;
}
@media (min-width: 820px) { .w-stage { grid-template-columns: 1.25fr 1fr; } }

.w-explain { font-size: 0.93rem; color: var(--ink-soft); }
.w-explain h4 { font-size: 1rem; margin-bottom: 0.4rem; color: var(--ink); }
.w-explain p + p { margin-top: 0.6rem; }
.w-log {
  margin-top: 0.9rem;
  padding: 0.7rem 0.85rem;
  border-radius: 8px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 0.76rem;
  color: var(--muted);
  line-height: 1.55;
  overflow-x: auto;
}

.w-field { display: grid; gap: 0.3rem; margin-bottom: 0.85rem; }
.w-field label { font-size: 0.76rem; font-weight: 620; color: var(--muted); letter-spacing: 0.02em; }
.w-field input {
  font: inherit;
  font-size: 0.9rem;
  font-family: var(--mono);
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: var(--paper);
  color: var(--ink);
  width: 100%;
}
.w-field input:focus { border-color: var(--accent); outline: none; }
.w-grid2 { display: grid; gap: 0 1rem; }
@media (min-width: 640px) { .w-grid2 { grid-template-columns: 1fr 1fr; } }
.w-note { font-size: 0.8rem; color: var(--muted); margin-top: 0.4rem; }

/* --- rail --------------------------------------------------------------- */

.rail {
  position: sticky;
  top: 5rem;
  font-size: 0.84rem;
  max-height: calc(100vh - 8rem);
  overflow-y: auto;
}
.rail__title {
  font-size: 0.68rem; letter-spacing: 0.09em; text-transform: uppercase;
  color: var(--muted); font-weight: 650; margin-bottom: 0.6rem;
}
.rail__list { list-style: none; padding: 0; border-left: 1px solid var(--line); }
.rail__item a {
  display: block;
  padding: 0.24rem 0 0.24rem 0.8rem;
  margin-left: -1px;
  border-left: 2px solid transparent;
  color: var(--muted);
  text-decoration: none;
  line-height: 1.4;
}
.rail__item a:hover { color: var(--ink); }
.rail__item.is-active a { color: var(--accent); border-left-color: var(--accent); font-weight: 550; }
.rail__item--h3 a { padding-left: 1.6rem; font-size: 0.8rem; }
.rail__hint {
  margin-top: 1.2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.5;
}

/* --- pager -------------------------------------------------------------- */

.pager {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-top: 4rem;
  padding-top: 2rem;
  border-top: 1px solid var(--line);
}
.pager__link {
  display: block;
  padding: 0.9rem 1.1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  text-decoration: none;
  color: inherit;
}
.pager__link:hover { border-color: var(--accent); }
.pager__link--next { text-align: right; }
.pager__dir {
  display: block;
  font-size: 0.68rem; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--muted); font-weight: 650; margin-bottom: 0.2rem;
}
.pager__title { display: block; font-size: 0.95rem; font-weight: 550; color: var(--ink); }

/* --- home page ---------------------------------------------------------- */

.page--home { max-width: none; }

.hero { padding: 1rem 0 2.5rem; }
.hero__eyebrow {
  font-size: 0.74rem; letter-spacing: 0.09em; text-transform: uppercase;
  color: var(--accent); font-weight: 650; margin-bottom: 1rem;
}
.hero__title {
  font-family: var(--serif);
  font-size: clamp(2.5rem, 6vw, 3.7rem);
  line-height: 1.05;
  letter-spacing: -0.028em;
  font-weight: 600;
}
.hero__subtitle {
  margin-top: 1rem;
  font-size: 1.25rem;
  line-height: 1.5;
  color: var(--ink-soft);
  max-width: 36rem;
}
.hero__intro { margin-top: 1.6rem; max-width: 36rem; }
.hero__intro p { color: var(--muted); }
.hero__intro p + p { margin-top: 0.8rem; }
.hero__cta {
  display: inline-flex; align-items: center; gap: 0.5rem;
  margin-top: 2rem;
  padding: 0.7rem 1.25rem;
  border-radius: 99px;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.95rem;
  box-shadow: var(--shadow-sm);
}
.hero__cta:hover { color: #fff; filter: brightness(1.08); }
.hero__cta svg { width: 1.05rem; height: 1.05rem; }
:root[data-theme="dark"] .hero__cta { color: #0c1d1c; }
:root[data-theme="dark"] .hero__cta:hover { color: #0c1d1c; }

.how { margin: 3rem 0; }
.how__title {
  font-family: var(--serif);
  font-size: 1.5rem; font-weight: 600; margin-bottom: 1.2rem;
}
.how__grid { display: grid; gap: 1rem; }
@media (min-width: 780px) { .how__grid { grid-template-columns: repeat(3, 1fr); } }
.how__card {
  padding: 1.1rem 1.2rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
}
.how__card--accent { border-color: var(--warm-line); background: var(--warm-soft); }
.how__num {
  display: grid; place-items: center;
  width: 1.7rem; height: 1.7rem;
  border-radius: 99px;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-size: 0.82rem; font-weight: 700;
  margin-bottom: 0.7rem;
}
.how__card--accent .how__num { background: var(--warm); color: #fff; }
:root[data-theme="dark"] .how__card--accent .how__num { color: #221507; }
.how__card h3 { font-size: 1.02rem; font-weight: 620; margin-bottom: 0.35rem; }
.how__card p { font-size: 0.9rem; color: var(--muted); line-height: 1.55; }

.toc-part { margin: 3rem 0; }
.toc-part__title {
  font-family: var(--serif);
  font-size: 1.35rem; font-weight: 600;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--line);
}
.toc-part__note { margin-top: 0.7rem; font-size: 0.9rem; color: var(--muted); }
.toc-list { list-style: none; padding: 0; margin-top: 0.5rem; }
.toc-list__item { border-bottom: 1px solid var(--line); }
.toc-list__item a {
  display: grid;
  grid-template-columns: 2.4rem 1fr;
  gap: 0.5rem;
  padding: 0.95rem 0.5rem 0.95rem 0;
  text-decoration: none;
  color: inherit;
  border-radius: 8px;
}
.toc-list--annex .toc-list__item a { grid-template-columns: 1fr; padding-left: 0.5rem; }
.toc-list__item a:hover { background: var(--surface); }
.toc-list__num {
  font-family: var(--serif);
  font-size: 1.15rem;
  color: var(--line-strong);
  font-weight: 600;
  text-align: right;
  padding-right: 0.4rem;
}
.toc-list__item a:hover .toc-list__num { color: var(--accent); }
.toc-list__body { display: block; min-width: 0; }
.toc-list__title { display: block; font-size: 1.02rem; font-weight: 580; color: var(--ink); }
.toc-list__summary { display: block; font-size: 0.9rem; color: var(--muted); margin-top: 0.2rem; line-height: 1.5; }
.toc-list__time {
  display: inline-block; margin-top: 0.4rem;
  font-size: 0.7rem; letter-spacing: 0.05em; text-transform: uppercase;
  color: var(--muted); border: 1px solid var(--line); border-radius: 99px; padding: 0.05rem 0.5rem;
}

.roadmap { margin-top: 3.5rem; padding-top: 2rem; border-top: 1px solid var(--line); }

/* --- footer, toast ------------------------------------------------------ */

.footer {
  padding: 2rem 3rem 3rem;
  border-top: 1px solid var(--line);
  font-size: 0.82rem;
  color: var(--muted);
}
@media (max-width: 900px) { .footer { padding: 2rem 1.25rem 3rem; } }

.toast {
  position: fixed;
  bottom: 1.5rem; left: 50%;
  transform: translate(-50%, 1.5rem);
  z-index: 90;
  padding: 0.6rem 1.1rem;
  border-radius: 99px;
  background: var(--ink);
  color: var(--paper);
  font-size: 0.85rem;
  font-weight: 550;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

/* --- motion ------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  .diagram__replay { display: none; }
}

/* --- print -------------------------------------------------------------- */

@media print {
  .sidebar, .topbar, .rail, .nav-toggle, .copy-btn, .prompt-btn, .diagram__replay, .pager, .toast { display: none !important; }
  .layout { grid-template-columns: 1fr; }
  main { padding: 0; grid-template-columns: 1fr; }
  body { background: #fff; }
  .reveal[open] .reveal__body, .reveal__body { display: block !important; }
}

/* --- widget internals --------------------------------------------------- */

.w-stage svg { width: 100%; height: auto; }
.w-node { fill: var(--surface-2); stroke: var(--line-strong); stroke-width: 1.2; }
.w-node--server { fill: var(--accent-soft); stroke: var(--accent); }
.w-cap { font-family: var(--sans); font-size: 11px; font-weight: 620; fill: var(--ink-soft); }
.w-tiny { font-family: var(--mono); font-size: 10px; fill: var(--muted); }
.w-stage-label { font-family: var(--sans); font-size: 10px; fill: var(--muted); letter-spacing: 0.06em; text-transform: uppercase; }
.w-flow {
  stroke: var(--accent); stroke-width: 2; fill: none; color: var(--accent);
  stroke-dasharray: 1; stroke-dashoffset: 1;
  animation: w-draw 0.65s ease forwards;
}
.w-flow--back { stroke: var(--warm); color: var(--warm); animation-delay: 0.25s; }
@keyframes w-draw { to { stroke-dashoffset: 0; } }

.w-zones { display: grid; gap: 0.55rem; margin-top: 1rem; }
.w-zone {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas: "label verdict" "sub verdict";
  gap: 0 1rem;
  align-items: center;
  padding: 0.75rem 1rem;
  border: 1px solid var(--line);
  border-left: 3px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface-2);
}
.w-zone__label { grid-area: label; font-size: 0.94rem; font-weight: 580; color: var(--ink); }
.w-zone__sub { grid-area: sub; font-size: 0.8rem; color: var(--muted); }
.w-zone__verdict {
  grid-area: verdict;
  font-size: 0.74rem; font-weight: 650; letter-spacing: 0.03em;
  padding: 0.2rem 0.6rem; border-radius: 99px; white-space: nowrap;
  border: 1px solid currentColor;
}
.w-zone.w-yes  { border-left-color: var(--accent); }
.w-zone.w-yes  .w-zone__verdict { color: var(--accent); }
.w-zone.w-auth { border-left-color: var(--caution); }
.w-zone.w-auth .w-zone__verdict { color: var(--caution); }
.w-zone.w-no   { border-left-color: var(--danger); }
.w-zone.w-no   .w-zone__verdict { color: var(--danger); }

.w-sheet-actions { display: flex; align-items: center; gap: 0.8rem; flex-wrap: wrap; margin-top: 0.4rem; }
.w-sheet-actions .w-note { margin-top: 0; }

/* Arrow colour has to reach the marker too, hence the paired `color`. */
.diagram svg .d-arrow        { color: var(--d-line); }
.diagram svg .d-arrow-accent { color: var(--d-accent); }
.diagram svg .d-arrow-warm   { stroke: var(--warm); color: var(--warm); stroke-width: 1.8; fill: none; }
.diagram svg .d-arrow-danger { color: var(--danger); }

.diagram svg .d-flow {
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  animation: d-draw 0.7s ease forwards;
}
@keyframes d-draw { to { stroke-dashoffset: 0; } }
.diagram svg .d-fade { opacity: 0; animation: d-fade-in 0.5s ease forwards; }
@keyframes d-fade-in { to { opacity: 1; } }

/* --- packet path widget ------------------------------------------------- */

.w-stops { list-style: none; padding: 0; margin: 1rem 0 0; }
.w-stop {
  display: grid;
  grid-template-columns: 1.6rem 1fr;
  gap: 0.7rem;
  padding: 0.5rem 0.7rem;
  border-left: 2px solid var(--line-strong);
  margin-left: 0.4rem;
}
.w-stop__mark {
  display: grid; place-items: center;
  width: 1.5rem; height: 1.5rem;
  margin-left: -1.45rem;
  border-radius: 99px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--muted);
}
.w-stop__body { display: block; min-width: 0; }
.w-stop__label { display: block; font-size: 0.9rem; font-weight: 560; color: var(--ink); }
.w-stop__detail { display: block; font-size: 0.82rem; color: var(--muted); line-height: 1.5; }

.w-stop--pass { border-left-color: var(--accent); }
.w-stop--pass .w-stop__mark { border-color: var(--accent); color: var(--accent); }
.w-stop--skip { opacity: 0.5; }
.w-stop--skip .w-stop__label { font-weight: 500; }
.w-stop--stop { border-left-color: var(--danger); }
.w-stop--stop .w-stop__mark { border-color: var(--danger); color: var(--danger); background: var(--danger-soft); }
.w-stop--stop .w-stop__label { color: var(--danger); }

.w-outcome {
  display: grid;
  gap: 0.25rem;
  margin-top: 1.1rem;
  padding: 0.85rem 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  border-left: 3px solid var(--line-strong);
  background: var(--surface-2);
}
.w-outcome strong { font-size: 0.98rem; }
.w-outcome span { font-size: 0.87rem; color: var(--muted); line-height: 1.5; }
.w-outcome--bad { border-left-color: var(--danger); background: var(--danger-soft); }
.w-outcome--bad strong { color: var(--danger); }
.w-outcome--good { border-left-color: var(--accent); background: var(--accent-soft); }
.w-outcome--good strong { color: var(--accent-ink); }

.w-btn code {
  font-family: var(--mono);
  font-size: 0.88em;
  background: none;
  border: 0;
  padding: 0;
  color: inherit;
}

/* --- reader values ------------------------------------------------------ */

/* A placeholder the reader can replace. Quiet in prose, quieter in code. */
.pv {
  border-bottom: 1px dotted var(--line-strong);
  cursor: help;
}
.prose .pv { color: inherit; }
/* Inside code, a background would make two adjacent values look like one
   token (admin@192.168.1.20). An underline keeps the boundary visible. */
.code .pv, .prose code .pv, .snippet .pv, .preview .pv {
  border-bottom: 1px dashed var(--accent);
  background: none;
  padding: 0;
}

.values-link {
  display: inline-flex; align-items: center; gap: 0.4rem;
  height: 2.15rem;
  padding: 0 0.6rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  text-decoration: none;
  font-size: 0.78rem;
  font-weight: 550;
  white-space: nowrap;
}
.values-link:hover { color: var(--accent); border-color: var(--accent); }
.values-link.is-current { color: var(--accent-ink); background: var(--accent-soft); border-color: var(--accent); }
.values-link svg { width: 1.05rem; height: 1.05rem; }
@media (max-width: 820px) { .values-link__label { display: none; } }

/* --- the settings card in a chapter ------------------------------------- */

.settings-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: start;
  gap: 0.85rem;
  margin: 1.8rem 0;
  padding: 1rem 1.15rem;
  border: 1px solid var(--accent);
  border-radius: var(--radius-lg);
  background: var(--accent-soft);
  text-decoration: none;
  color: inherit;
}
.settings-card:hover { filter: brightness(0.99); border-color: var(--accent-ink); }
.settings-card .icon { width: 1.2rem; height: 1.2rem; color: var(--accent); margin-top: 0.1rem; }
.settings-card > .icon:last-child { color: var(--accent); width: 1rem; align-self: center; }
.settings-card__body { display: block; min-width: 0; }
.settings-card__label {
  display: block;
  font-size: 0.72rem; letter-spacing: 0.07em; text-transform: uppercase;
  font-weight: 650; color: var(--accent-ink);
}
.settings-card__list { list-style: none; padding: 0; margin: 0.5rem 0 0; }
.settings-card__item {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.5rem;
  padding: 0.15rem 0;
  font-size: 0.9rem;
}
.settings-card__value {
  font-family: var(--mono);
  font-size: 0.84em;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 0.05em 0.4em;
  color: var(--ink);
}
.settings-card__about { color: var(--ink-soft); }
.settings-card__cta {
  display: block;
  margin-top: 0.6rem;
  font-size: 0.83rem;
  line-height: 1.5;
  color: var(--muted);
}

/* --- the settings page -------------------------------------------------- */

.settings { margin: 2rem 0 0; }
.settings__row {
  display: grid;
  gap: 0.6rem 2rem;
  padding: 1.2rem 0;
  border-top: 1px solid var(--line);
}
@media (min-width: 780px) {
  .settings__row { grid-template-columns: 1fr 17rem; align-items: start; }
}
.settings__label { display: block; font-size: 1rem; font-weight: 600; color: var(--ink); }
.settings__about { margin-top: 0.25rem; font-size: 0.92rem; color: var(--ink-soft); line-height: 1.55; }
.settings__about code, .settings__hint code {
  font-family: var(--mono); font-size: 0.85em;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 5px; padding: 0.05em 0.32em;
}
.settings__where { margin-top: 0.35rem; font-size: 0.82rem; color: var(--muted); }
.settings__field input {
  width: 100%;
  font-family: var(--mono);
  font-size: 0.92rem;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
}
.settings__field input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.settings__hint { margin-top: 0.35rem; font-size: 0.78rem; color: var(--muted); }

.settings__actions {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem;
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--line);
}
.settings__save {
  padding: 0.6rem 1.2rem;
  border: 1px solid var(--accent);
  border-radius: 99px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  font-size: 0.92rem;
}
.settings__save:hover { filter: brightness(1.08); }
:root[data-theme="dark"] .settings__save { color: #0c1d1c; }
.settings__reset {
  padding: 0.6rem 1rem;
  border: 1px solid var(--line-strong);
  border-radius: 99px;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.88rem;
}
.settings__reset:hover { color: var(--ink); border-color: var(--ink-soft); }
.settings__status { font-size: 0.85rem; color: var(--accent); font-weight: 550; }

/* --- settings live preview ---------------------------------------------- */

.preview {
  margin: 1.4rem 0 0;
  padding: 0.9rem 1.1rem 1rem;
  border: 1px solid var(--accent);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.preview__label {
  font-size: 0.7rem; letter-spacing: 0.09em; text-transform: uppercase;
  font-weight: 650; color: var(--accent); margin-bottom: 0.5rem;
}
.preview__code {
  margin: 0;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 0.82rem;
  line-height: 1.75;
  color: var(--ink);
}
.preview__prompt { color: var(--accent); user-select: none; }
.preview__note { margin-top: 0.6rem; font-size: 0.78rem; color: var(--muted); }


/* --- the values dialog -------------------------------------------------- */

.values {
  /* The global `* { margin: 0 }` reset would otherwise beat the UA's
     `margin: auto`, which is what centres a modal dialog. */
  margin: auto;
  width: min(46rem, calc(100vw - 2rem));
  max-height: min(86vh, 52rem);
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  background: var(--paper);
  color: var(--ink);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.values::backdrop {
  background: rgb(16 18 22 / 0.55);
  backdrop-filter: blur(3px);
}
.values[open] {
  display: flex;
  flex-direction: column;
  animation: values-in 0.18s ease;
}
@keyframes values-in {
  from { opacity: 0; transform: translateY(6px) scale(0.99); }
}

.values__close {
  position: absolute;
  top: 0.8rem; right: 0.8rem;
  z-index: 2;
  width: 2rem; height: 2rem;
  display: grid; place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
}
.values__close:hover { color: var(--ink); border-color: var(--line-strong); }
.values__close svg { width: 1rem; height: 1rem; }

.values__head {
  padding: 1.4rem 1.6rem 1.1rem;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}
.values__eyebrow {
  font-size: 0.7rem; letter-spacing: 0.09em; text-transform: uppercase;
  font-weight: 650; color: var(--accent); margin-bottom: 0.4rem;
}
.values__title {
  font-family: var(--serif);
  font-size: 1.7rem;
  font-weight: 600;
  letter-spacing: -0.018em;
  line-height: 1.15;
}
.values__intro {
  margin-top: 0.5rem;
  font-size: 0.94rem;
  line-height: 1.55;
  color: var(--ink-soft);
  max-width: 34rem;
}

/* flex:1 with min-height:0 is what actually lets this scroll inside the
   dialog; without the min-height it just grows and the dialog clips it. */
.values__scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 0 1.6rem 1.6rem; }

.values__storage {
  margin-top: 1.2rem;
  padding: 0.7rem 0.9rem;
  border-left: 3px solid var(--accent);
  border-radius: 0 8px 8px 0;
  background: var(--accent-soft);
  font-size: 0.85rem;
  line-height: 1.55;
  color: var(--ink-soft);
}

.values__footnote {
  margin-top: 1.4rem;
  padding-top: 1.2rem;
  border-top: 1px solid var(--line);
  font-size: 0.85rem;
  line-height: 1.6;
  color: var(--muted);
}
.values__footnote p + p { margin-top: 0.6rem; }
.values__footnote code {
  font-family: var(--mono); font-size: 0.85em;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 5px; padding: 0.05em 0.32em;
}

/* A real footer rather than a sticky element, so nothing scrolls under it.
   The submit button reaches the form by id. */
.values__actions {
  flex: 0 0 auto;
  margin: 0;
  padding: 0.9rem 1.6rem;
  border-top: 1px solid var(--line);
  background: var(--surface-2);
}

.sidebar__link--button {
  width: 100%;
  text-align: left;
  border: 0;
  background: none;
  font: inherit;
  font-size: 0.9rem;
  line-height: 1.4;
}

@media (max-width: 620px) {
  .values { width: 100vw; max-width: 100vw; max-height: 100vh; height: 100vh; border-radius: 0; border: 0; }
  .values__head, .values__scroll { padding-left: 1.1rem; padding-right: 1.1rem; }
}
