/* ==========================================================================
   The Agentic Development Lifecycle — reading theme
   Colour is semantic, never decorative:
     part hues encode the five parts; grade hues encode evidence strength.
   ========================================================================== */

:root {
  /* neutrals */
  --ink:        #0F172A;
  --ink-soft:   #334155;
  --muted:      #64748B;
  --faint:      #94A3B8;
  --line:       #E2E8F0;
  --line-soft:  #F1F5F9;
  --paper:      #FFFFFF;
  --wash:       #F8FAFC;
  --wash-deep:  #F1F5F9;

  /* part hues */
  --p1: #BE123C;  --p1-wash: #FFF1F2;   /* I   The Discontinuity   */
  --p2: #4338CA;  --p2-wash: #EEF2FF;   /* II  The Four Pillars    */
  --p3: #0F766E;  --p3-wash: #F0FDFA;   /* III The Lifecycle       */
  --p4: #7C3AED;  --p4-wash: #F5F3FF;   /* IV  Human Transformation*/
  --p5: #B45309;  --p5-wash: #FFFBEB;   /* V   Modes and Practice  */

  /* evidence grades */
  --gA: #047857;  --gA-wash: #ECFDF5;
  --gB: #0E7490;  --gB-wash: #ECFEFF;
  --gC: #B45309;  --gC-wash: #FFFBEB;
  --gD: #64748B;  --gD-wash: #F1F5F9;

  --accent:     var(--p2);
  --accent-wash:var(--p2-wash);

  --radius: 10px;
  --measure: 68ch;

  --mono: "SF Mono", ui-monospace, "JetBrains Mono", Menlo, Consolas,
          "DejaVu Sans Mono", monospace;
  --sans: ui-sans-serif, -apple-system, "Segoe UI", Inter, system-ui, sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia,
           "Times New Roman", serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ink:        #E2E8F0;
    --ink-soft:   #CBD5E1;
    --muted:      #94A3B8;
    --faint:      #64748B;
    --line:       #1E293B;
    --line-soft:  #172033;
    --paper:      #0B1220;
    --wash:       #0F172A;
    --wash-deep:  #131C2E;

    --p1: #FB7185;  --p1-wash: #2A1015;
    --p2: #A5B4FC;  --p2-wash: #171A33;
    --p3: #5EEAD4;  --p3-wash: #0C2622;
    --p4: #C4B5FD;  --p4-wash: #1D1533;
    --p5: #FCD34D;  --p5-wash: #2A2010;

    --gA: #6EE7B7;  --gA-wash: #0A2A1E;
    --gB: #67E8F9;  --gB-wash: #0A2530;
    --gC: #FCD34D;  --gC-wash: #2A2010;
    --gD: #94A3B8;  --gD-wash: #1B2434;
  }
}
:root[data-theme="dark"] {
  --ink:#E2E8F0; --ink-soft:#CBD5E1; --muted:#94A3B8; --faint:#64748B;
  --line:#1E293B; --line-soft:#172033; --paper:#0B1220; --wash:#0F172A;
  --wash-deep:#131C2E;
  --p1:#FB7185; --p1-wash:#2A1015; --p2:#A5B4FC; --p2-wash:#171A33;
  --p3:#5EEAD4; --p3-wash:#0C2622; --p4:#C4B5FD; --p4-wash:#1D1533;
  --p5:#FCD34D; --p5-wash:#2A2010;
  --gA:#6EE7B7; --gA-wash:#0A2A1E; --gB:#67E8F9; --gB-wash:#0A2530;
  --gC:#FCD34D; --gC-wash:#2A2010; --gD:#94A3B8; --gD-wash:#1B2434;
}

/* ---------- base ---------- */

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

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

.wrap { max-width: 1140px; margin: 0 auto; padding: 0 24px; }

/* ---------- masthead ---------- */

.masthead {
  border-bottom: 1px solid var(--line);
  background: var(--wash);
  position: sticky; top: 0; z-index: 50;
  backdrop-filter: saturate(140%) blur(8px);
}
.masthead .wrap {
  display: flex; align-items: center; gap: 18px;
  height: 58px;
}
.brand {
  font-weight: 680; letter-spacing: -0.015em; color: var(--ink);
  text-decoration: none; font-size: 15px; white-space: nowrap;
}
.brand .adlc {
  font-family: var(--mono); font-size: 12px; letter-spacing: 0.08em;
  color: var(--accent); border: 1px solid var(--accent);
  border-radius: 5px; padding: 2px 6px; margin-right: 9px;
}
.mast-nav { margin-left: auto; display: flex; gap: 20px; align-items: center; }
.mast-nav a {
  color: var(--muted); text-decoration: none; font-size: 14px;
  border-bottom: 1px solid transparent; padding-bottom: 2px;
}
.mast-nav a:hover { color: var(--ink); border-bottom-color: var(--accent); }
#theme-toggle {
  background: none; border: 1px solid var(--line); color: var(--muted);
  border-radius: 6px; width: 30px; height: 28px; cursor: pointer;
  font-size: 14px; line-height: 1;
}
#theme-toggle:hover { color: var(--ink); border-color: var(--accent); }

/* ---------- hero (index) ---------- */

.hero { padding: 72px 0 40px; border-bottom: 1px solid var(--line); }
.hero h1 {
  font-family: var(--serif); font-size: clamp(34px, 5.2vw, 56px);
  line-height: 1.08; letter-spacing: -0.02em; margin: 0 0 14px;
  max-width: 22ch;
}
.hero .sub {
  font-size: clamp(17px, 2.2vw, 21px); color: var(--ink-soft);
  max-width: 62ch; margin: 0 0 26px; line-height: 1.5;
}
.hero .thesis {
  border-left: 3px solid var(--accent); background: var(--accent-wash);
  padding: 16px 22px; border-radius: 0 var(--radius) var(--radius) 0;
  max-width: 74ch; font-size: 16.5px;
}
.stat-row {
  display: flex; flex-wrap: wrap; gap: 30px; margin-top: 32px;
  padding-top: 24px; border-top: 1px solid var(--line);
}
.stat b {
  display: block; font-family: var(--mono); font-size: 26px;
  color: var(--ink); font-weight: 600; letter-spacing: -0.02em;
}
.stat span { font-size: 12.5px; color: var(--muted); text-transform: uppercase;
  letter-spacing: 0.07em; }

/* ---------- sections ---------- */

section { padding: 52px 0; }
section > h2 {
  font-family: var(--serif); font-size: 30px; letter-spacing: -0.015em;
  margin: 0 0 6px;
}
section > .lede { color: var(--muted); margin: 0 0 30px; max-width: 70ch; }

/* ---------- part blocks + chapter cards ---------- */

.part { margin-bottom: 40px; }
.part-head {
  display: flex; align-items: baseline; gap: 14px;
  padding-bottom: 10px; margin-bottom: 18px;
  border-bottom: 2px solid var(--part, var(--line));
}
.part-num {
  font-family: var(--mono); font-size: 12px; letter-spacing: 0.1em;
  color: var(--part, var(--muted)); font-weight: 600;
  border: 1px solid var(--part, var(--line)); border-radius: 5px;
  padding: 3px 8px;
}
.part-head h3 { margin: 0; font-size: 21px; letter-spacing: -0.01em; }
.part-head .part-note { margin-left: auto; color: var(--muted); font-size: 13.5px;
  font-style: italic; }

.cards { display: grid; gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(min(330px, 100%), 1fr)); }

.card {
  display: block; text-decoration: none; color: inherit;
  border: 1px solid var(--line); border-left: 3px solid var(--part, var(--accent));
  border-radius: var(--radius); padding: 15px 17px; background: var(--paper);
  transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease;
}
.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 22px -10px rgba(15,23,42,.28);
  border-color: var(--part, var(--accent));
}
.card .ch-no {
  font-family: var(--mono); font-size: 11.5px; color: var(--part, var(--muted));
  letter-spacing: 0.09em; font-weight: 600;
}
.card h4 { margin: 5px 0 8px; font-size: 16.5px; line-height: 1.3;
  letter-spacing: -0.01em; }
.card p { margin: 0; font-size: 13.8px; color: var(--muted); line-height: 1.5; }
.card .meta { margin-top: 10px; font-family: var(--mono); font-size: 11px;
  color: var(--faint); }

/* ---------- reading paths ---------- */

.paths { display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.path {
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; background: var(--wash);
}
.path h4 { margin: 0 0 8px; font-size: 15px; }
.path .seq { font-family: var(--mono); font-size: 13px; color: var(--accent);
  margin-bottom: 8px; font-weight: 600; }
.path p { margin: 0; font-size: 13.5px; color: var(--muted); }

/* ---------- figure / diagram ---------- */

figure.diagram {
  margin: 36px 0; padding: 20px; background: var(--wash);
  border: 1px solid var(--line); border-radius: var(--radius);
}
figure.diagram svg { width: 100%; height: auto; display: block; }
figure.diagram figcaption {
  margin-top: 14px; font-size: 13.5px; color: var(--muted);
  text-align: center; font-style: italic;
}

/* ---------- article ---------- */

.layout { display: grid; grid-template-columns: 1fr; gap: 40px; }
@media (min-width: 1040px) {
  .layout { grid-template-columns: 232px minmax(0,1fr); }
}

.toc {
  position: sticky; top: 82px; align-self: start; max-height: calc(100vh - 110px);
  overflow-y: auto; font-size: 13.3px; padding-right: 8px;
}
.toc-title { font-family: var(--mono); font-size: 10.5px; letter-spacing: .12em;
  text-transform: uppercase; color: var(--faint); margin-bottom: 10px; }
.toc a { display: block; color: var(--muted); text-decoration: none;
  padding: 4px 0 4px 11px; border-left: 2px solid var(--line); line-height: 1.4; }
.toc a:hover { color: var(--ink); border-left-color: var(--part, var(--accent)); }
.toc a.h3 { padding-left: 22px; font-size: 12.6px; }
@media (max-width: 1039px) { .toc { display: none; } }

article { max-width: var(--measure); min-width: 0; }

.ch-header { margin-bottom: 34px; padding-bottom: 22px;
  border-bottom: 2px solid var(--part, var(--line)); }
.ch-eyebrow {
  font-family: var(--mono); font-size: 11.5px; letter-spacing: .1em;
  color: var(--part, var(--muted)); text-transform: uppercase; font-weight: 600;
}
.ch-header h1 {
  font-family: var(--serif); font-size: clamp(29px, 4.4vw, 42px);
  line-height: 1.12; letter-spacing: -0.02em; margin: 9px 0 0;
}

article h2 {
  font-size: 23px; letter-spacing: -0.015em; margin: 46px 0 14px;
  padding-top: 8px; scroll-margin-top: 78px;
}
article h3 { font-size: 18.5px; margin: 32px 0 10px; scroll-margin-top: 78px; }
article p { margin: 0 0 18px; }
article a { color: var(--accent); text-decoration: none;
  border-bottom: 1px solid color-mix(in srgb, var(--accent) 35%, transparent); }
article a:hover { border-bottom-color: var(--accent); }
article strong { font-weight: 660; color: var(--ink); }
article hr { border: 0; border-top: 1px solid var(--line); margin: 40px 0; }

article ul, article ol { margin: 0 0 18px; padding-left: 22px; }
article li { margin-bottom: 7px; }

/* epigraph — the leading blockquote of each chapter */
article blockquote {
  margin: 0 0 26px; padding: 16px 22px;
  border-left: 3px solid var(--part, var(--accent));
  background: var(--part-wash, var(--wash));
  border-radius: 0 var(--radius) var(--radius) 0;
  font-family: var(--serif); font-size: 18px; line-height: 1.5;
  color: var(--ink-soft);
}
article blockquote p { margin: 0 0 10px; }
article blockquote p:last-child { margin: 0; }

/* ---------- ASCII diagrams: the book's signature element ---------- */

article pre {
  background: var(--wash-deep);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  overflow-x: auto;
  margin: 0 0 24px;
  line-height: 1.42;
  tab-size: 4;
}
article pre code {
  font-family: var(--mono); font-size: 12.6px;
  font-variant-ligatures: none; white-space: pre;
  color: var(--ink-soft); background: none; padding: 0; border: 0;
}
/* ascii figures get a touch more presence */
article pre.ascii {
  background: var(--paper);
  border-left: 3px solid var(--part, var(--accent));
}
article pre.ascii code { color: var(--ink); font-size: 12.4px; }

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

figure.diagram {
  margin: 30px 0 30px;
  padding: 22px 24px 16px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-left: 3px solid var(--part, var(--accent));
  border-radius: var(--radius);
  overflow-x: auto;
}
figure.diagram svg {
  display: block;
  width: 100%;
  min-width: 620px;
  height: auto;
  overflow: visible;
}
figure.diagram figcaption {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--line-soft);
  font-size: 13.6px;
  line-height: 1.55;
  color: var(--muted);
}
figure.diagram figcaption b {
  color: var(--part, var(--accent));
  font-weight: 640;
  letter-spacing: .01em;
}
@media (max-width: 700px) {
  figure.diagram { padding: 16px 14px 12px; }
}

article :not(pre) > code {
  font-family: var(--mono); font-size: 0.875em;
  background: var(--wash-deep); border: 1px solid var(--line);
  border-radius: 5px; padding: 1px 5px; color: var(--ink);
}

/* ---------- tables ---------- */

.table-scroll { overflow-x: auto; margin: 0 0 26px; }
article table {
  border-collapse: collapse; width: 100%; font-size: 14.6px; line-height: 1.5;
}
article th, article td {
  border-bottom: 1px solid var(--line); padding: 9px 12px;
  text-align: left; vertical-align: top;
}
article th {
  font-size: 12.4px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); font-weight: 640; border-bottom: 2px solid var(--line);
  white-space: nowrap;
}
article tbody tr:hover { background: var(--wash); }

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

.callout {
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 17px 20px; margin: 0 0 26px; background: var(--wash);
}
.callout .callout-h {
  font-family: var(--mono); font-size: 10.8px; letter-spacing: .12em;
  text-transform: uppercase; font-weight: 640; margin-bottom: 9px;
}
.callout ul { margin: 0; }
.callout p:last-child { margin-bottom: 0; }

.callout.learn { background: var(--wash); }
.callout.learn .callout-h { color: var(--muted); }

.callout.claim {
  background: var(--part-wash, var(--accent-wash));
  border-color: color-mix(in srgb, var(--part, var(--accent)) 30%, var(--line));
}
.callout.claim .callout-h { color: var(--part, var(--accent)); }

.callout.takeaway {
  background: var(--gA-wash); border-color: color-mix(in srgb, var(--gA) 32%, var(--line));
  font-size: 17px;
}
.callout.takeaway .callout-h { color: var(--gA); }

.callout.open {
  background: var(--gC-wash); border-color: color-mix(in srgb, var(--gC) 30%, var(--line));
}
.callout.open .callout-h { color: var(--gC); }

.callout.sources { background: var(--wash); font-size: 14px; }
.callout.sources .callout-h { color: var(--muted); }
.callout.sources li { margin-bottom: 9px; }

/* ---------- evidence grade pills ---------- */

.grade {
  display: inline-block; font-family: var(--mono); font-size: 11px;
  font-weight: 700; letter-spacing: .04em;
  padding: 1px 6px; border-radius: 4px; border: 1px solid;
  vertical-align: baseline; white-space: nowrap;
}
.grade.A { color: var(--gA); background: var(--gA-wash); border-color: color-mix(in srgb, var(--gA) 38%, transparent); }
.grade.B { color: var(--gB); background: var(--gB-wash); border-color: color-mix(in srgb, var(--gB) 38%, transparent); }
.grade.C { color: var(--gC); background: var(--gC-wash); border-color: color-mix(in srgb, var(--gC) 38%, transparent); }
.grade.D { color: var(--gD); background: var(--gD-wash); border-color: color-mix(in srgb, var(--gD) 38%, transparent); }

/* ---------- chapter footer nav ---------- */

.ch-nav {
  display: flex; gap: 14px; margin-top: 56px; padding-top: 26px;
  border-top: 1px solid var(--line);
}
.ch-nav a {
  flex: 1; text-decoration: none; color: inherit; border: 1px solid var(--line);
  border-radius: var(--radius); padding: 13px 16px; font-size: 14px;
  transition: border-color .12s ease;
}
.ch-nav a:hover { border-color: var(--accent); }
.ch-nav .dir { font-family: var(--mono); font-size: 10.5px; letter-spacing: .1em;
  text-transform: uppercase; color: var(--faint); display: block; margin-bottom: 4px; }
.ch-nav .next { text-align: right; }
.ch-nav .spacer { flex: 1; }

/* ---------- footer ---------- */

footer {
  border-top: 1px solid var(--line); margin-top: 70px; padding: 34px 0 60px;
  color: var(--muted); font-size: 13.5px; background: var(--wash);
}
footer a { color: var(--muted); }

@media print {
  .masthead, .toc, .ch-nav, #theme-toggle { display: none; }
  article { max-width: none; }
  article pre { break-inside: avoid; }
}

/* ═══════════════════════════════════════════════════════════════════════
   THE COVER AND READING CHROME
   The cover states the book's identity in its own vocabulary: the rings of
   control as the motif, the five part hues as a spine band, the evidence
   grades as a footer. Nothing decorative that the book does not already mean.
   ═══════════════════════════════════════════════════════════════════════ */

.cover-stage {
  position: relative;
  padding: 56px 20px 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  background:
    radial-gradient(60% 60% at 25% 12%, color-mix(in srgb, var(--p2) 9%, transparent), transparent 70%),
    radial-gradient(55% 55% at 80% 78%, color-mix(in srgb, var(--p3) 8%, transparent), transparent 70%);
}

.book {
  /* --tilt drives the whole illusion; --thick is the book's physical depth */
  --tilt: -16deg;
  --thick: 58px;
  perspective: 2100px;
  perspective-origin: 52% 42%;
  width: min(100%, 680px);
  margin-inline: auto;
}

.book-3d {
  position: relative;
  transform-style: preserve-3d;
  transform: rotateY(var(--tilt)) rotateX(2.2deg);
  transition: transform .85s cubic-bezier(.23,1,.32,1);
}
.book:hover .book-3d { transform: rotateY(-9deg) rotateX(1deg); }

/* The spine slab. Hinged at the cover's left edge and swung backwards, so it
   has real depth rather than being painted on. rotateY(90deg) sends it away
   from the viewer; the translateZ then lifts it to meet the front face. */
.book-side {
  position: absolute; top: 0; left: 0; height: 100%;
  width: var(--thick);
  transform-origin: left center;
  transform: translateZ(calc(var(--thick) / 2)) rotateY(90deg);
  backface-visibility: hidden;
  background:
    linear-gradient(90deg, #0a1120 0%, #16213a 42%, #0e1729 70%, #060a13 100%);
  border-radius: 3px 0 0 3px;
}
/* a soft highlight down the spine's outer curve */
.book-side::before {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(90deg,
    transparent 0%, rgba(255,255,255,.05) 46%, transparent 72%);
}

/* The fore-edge: the stacked pages on the right. */
.book-edge {
  position: absolute; top: 4px; right: 0; height: calc(100% - 8px);
  width: var(--thick);
  transform-origin: right center;
  transform: translateZ(calc(var(--thick) / 2)) rotateY(-90deg);
  backface-visibility: hidden;
  background:
    repeating-linear-gradient(90deg,
      #e8edf5 0 1.5px, #c8d3e2 1.5px 3px);
  border-radius: 0 2px 2px 0;
  box-shadow: inset -6px 0 12px rgba(10,17,32,.28);
}

.book-front {
  position: relative;
  transform: translateZ(calc(var(--thick) / 2));
  border-radius: 3px 10px 10px 3px;
  background: linear-gradient(168deg, #101a2d 0%, #0b1322 45%, #070c17 100%);
  box-shadow:
    0 2px 0 rgba(255,255,255,.055) inset,
    0 46px 80px rgba(2,6,18,.44),
    0 14px 30px rgba(2,6,18,.32);
  overflow: hidden;
  display: flex; flex-direction: column;
  padding: 0 0 30px;
}
/* light falling across the jacket, and the hinge shadow beside the spine */
.book-front::after {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background:
    linear-gradient(100deg, rgba(255,255,255,.055) 0%, transparent 26%),
    linear-gradient(90deg, rgba(0,0,0,.42) 0px, rgba(0,0,0,.16) 14px, transparent 42px);
}

/* the ground shadow, cast separately so it does not rotate with the book */
.book-shadow {
  position: absolute; left: 8%; right: 6%; bottom: -18px; height: 34px;
  background: radial-gradient(50% 50% at 50% 50%, rgba(2,6,18,.34), transparent 76%);
  filter: blur(14px);
  transform: translateZ(-40px);
  pointer-events: none;
}

.book-parts { display: flex; height: 5px; position: relative; z-index: 3; }
.book-parts i { flex: 1; }

.book-band {
  display: flex; justify-content: space-between; align-items: center;
  padding: 15px 30px 15px 34px;
  border-bottom: 1px solid rgba(148,175,220,.14);
  font-family: var(--mono); font-size: 10px; letter-spacing: .2em;
  color: #6f86ab;
}

.book-motif { padding: 30px 30px 8px 34px; display: flex; justify-content: center; }
.book-motif svg { width: 100%; max-width: 290px; height: auto; }

.book-title-block { padding: 8px 34px 0 38px; text-align: center; }
.book-kicker {
  font-family: var(--mono); font-size: 10px; letter-spacing: .28em;
  color: var(--p3); margin-bottom: 18px;
}
.book-title {
  margin: 0; font-family: var(--serif);
  font-size: clamp(32px, 7vw, 54px); line-height: 1.04;
  letter-spacing: -.018em; color: #f2f6fc; font-weight: 600;
}
.book-title span { display: block; }
.book-title .t3 { color: #9db4dc; }

.book-rule {
  margin: 26px 34px 20px 38px; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(157,180,220,.5), transparent);
}

.book-sub {
  margin: 0 36px 0 42px; text-align: center;
  font-family: var(--serif); font-style: italic;
  font-size: 15.5px; line-height: 1.6; color: #a9bcd9;
}

.book-foot { margin-top: 30px; padding-left: 12px; text-align: center; }
.book-grades {
  display: flex; gap: 7px; justify-content: center; margin-bottom: 18px;
  font-family: var(--mono); font-size: 10px; letter-spacing: .1em;
}
.book-grades b {
  padding: 3px 8px; border-radius: 4px; font-weight: 600;
  border: 1px solid currentColor;
}
.book-author {
  font-family: var(--mono); font-size: 11.4px; letter-spacing: .3em;
  color: #cfdcef;
}

/* ---------- the actions under the cover ---------- */

.cover-cta {
  display: flex; gap: 12px; flex-wrap: wrap; justify-content: center;
  margin: 38px 0 0;
}
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 11px 20px; border-radius: 9px;
  font-size: 14.5px; font-weight: 600; text-decoration: none;
  border: 1px solid transparent; transition: transform .15s, box-shadow .15s;
}
.btn:hover { transform: translateY(-1px); text-decoration: none; }
.btn-primary {
  background: var(--ink); color: var(--paper);
  box-shadow: 0 6px 16px rgba(2,6,18,.22);
}
.btn-primary:hover { box-shadow: 0 10px 22px rgba(2,6,18,.3); }
.btn-ghost {
  background: var(--paper); color: var(--ink); border-color: var(--line);
}
.btn-ghost:hover { border-color: var(--accent); }

.cover-note {
  margin: 20px 0 0; font-family: var(--mono);
  font-size: 11px; color: var(--faint); letter-spacing: .06em; text-align: center;
}

/* ---------- continue reading ---------- */

#continue { margin: 26px auto 0; max-width: 520px; width: 100%; }
#continue a {
  display: flex; align-items: center; gap: 14px;
  padding: 13px 16px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--paper); text-decoration: none;
}
#continue a:hover { border-color: var(--accent); text-decoration: none; }
.cont-label {
  font-family: var(--mono); font-size: 9.5px; letter-spacing: .18em;
  color: var(--faint); text-transform: uppercase;
}
.cont-title { font-weight: 600; color: var(--ink); font-size: 14.5px; }
.cont-pct { font-family: var(--mono); font-size: 11.5px; color: var(--muted); }

/* ---------- overall reading meter ---------- */

#read-meter { margin: 30px auto 0; max-width: 520px; width: 100%; }
.rm-track {
  height: 6px; border-radius: 3px; overflow: hidden;
  background: var(--wash-deep); border: 1px solid var(--line);
}
.rm-fill {
  height: 100%; width: 0;
  background: linear-gradient(90deg, var(--p1), var(--p2), var(--p3), var(--p4), var(--p5));
  transition: width .5s ease;
}
.rm-text {
  margin-top: 8px; font-family: var(--mono); font-size: 11px;
  color: var(--muted); text-align: center;
}

/* ---------- per-chapter scroll progress ---------- */

.progress-bar {
  position: fixed; top: 0; left: 0; right: 0; height: 3px;
  background: transparent; z-index: 60; pointer-events: none;
}
.progress-fill {
  height: 100%; width: 0;
  background: var(--part, var(--accent));
  transition: width .08s linear;
}

/* ---------- cards remember what you opened ---------- */

.card { position: relative; }
.card.seen::after {
  content: '✓'; position: absolute; top: 12px; right: 13px;
  font-size: 12px; font-weight: 700; color: var(--gA);
}
.card.seen { border-color: color-mix(in srgb, var(--gA) 34%, var(--line)); }

/* ---------- search ---------- */

.icon-btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 5px 9px; border: 1px solid var(--line); border-radius: 7px;
  background: var(--paper); color: var(--muted);
  font: inherit; font-size: 12.5px; cursor: pointer;
}
.icon-btn:hover { border-color: var(--accent); color: var(--ink); }
.icon-btn kbd {
  font-family: var(--mono); font-size: 10px; color: var(--faint);
  border: 1px solid var(--line); border-radius: 4px; padding: 1px 4px;
}

#search[hidden] { display: none; }
#search {
  position: fixed; inset: 0; z-index: 200;
  background: color-mix(in srgb, var(--ink) 42%, transparent);
  backdrop-filter: blur(3px);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 10vh 20px 20px;
}
.sr-panel {
  width: min(100%, 680px); max-height: 76vh; display: flex; flex-direction: column;
  background: var(--paper); border: 1px solid var(--line);
  border-radius: 14px; box-shadow: 0 26px 60px rgba(2,6,18,.34); overflow: hidden;
}
.sr-panel input {
  width: 100%; border: 0; border-bottom: 1px solid var(--line);
  padding: 17px 20px; font: inherit; font-size: 16px;
  background: transparent; color: var(--ink); outline: none;
}
.sr-hint {
  padding: 8px 20px; font-family: var(--mono); font-size: 11px;
  color: var(--faint); border-bottom: 1px solid var(--line-soft);
}
.sr-list { overflow-y: auto; }
.sr-item {
  display: block; padding: 12px 20px; text-decoration: none;
  border-bottom: 1px solid var(--line-soft);
}
.sr-item:hover, .sr-item:focus {
  background: var(--wash); outline: none; text-decoration: none;
}
.sr-ch {
  font-family: var(--mono); font-size: 10px; letter-spacing: .13em;
  color: var(--faint); text-transform: uppercase;
}
.sr-t { font-weight: 600; color: var(--ink); margin: 2px 0 3px; font-size: 14.5px; }
.sr-x { font-size: 12.8px; color: var(--muted); line-height: 1.5; }
.sr-item mark {
  background: color-mix(in srgb, var(--p5) 30%, transparent);
  color: inherit; border-radius: 2px; padding: 0 1px;
}
.sr-foot {
  padding: 9px 20px; border-top: 1px solid var(--line-soft);
  font-family: var(--mono); font-size: 10.5px; color: var(--faint);
  display: flex; gap: 16px; flex-wrap: wrap;
}

/* ---------- reading size ---------- */

:root[data-size="s"] article { font-size: 15.4px; }
:root[data-size="l"] article { font-size: 18.6px; }

/* The masthead gained three controls; below this width the section links
   drop out — on the cover they are a scroll away, and on a chapter the
   brand still returns home. */
@media (max-width: 860px) {
  .mast-nav { gap: 10px; }
  .mast-nav a { display: none; }
  .icon-btn kbd { display: none; }
  .masthead .brand { font-size: 14px; }
}
@media (max-width: 400px) {
  #size-toggle { display: none; }
  .masthead .wrap { padding-inline: 12px; }
  .mast-nav { gap: 7px; }
}

@media (max-width: 560px) {
  /* the brand must yield rather than push the controls off-screen */
  .masthead .brand {
    min-width: 0; flex: 0 1 auto;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  .mast-nav { flex: 0 0 auto; }
}

@media (max-width: 720px) {
  .book { --thick: 34px; --tilt: -11deg; }
  .cover-stage { padding: 30px 14px 26px; overflow-x: clip; }
  .book-motif { padding: 18px 18px 2px; }
  .book-title-block { padding: 4px 18px 0; }
  .book-sub { margin: 0 20px; font-size: 13px; }
  .cover-cta .btn { width: 100%; justify-content: center; }
}
