/* THE HIDDEN SIGNAL — read.mmdv.dev
   A reading surface first. Paper white, warm-black ink, generous air.
   Deliberately NOT the zinc UI palette of mmdv.dev: that page is a card you
   glance at, this one is 200,000 words you sit with.

   One accent, amber, and it is reserved: it only ever renders something the
   READER made — a tick, a highlight, a saved chapter. Nothing decorative may
   use it, so colour on the page always means "you did this".

   Light is the design. Dark is a real night mode (warm dark, not inverted
   grey) because people read in bed, but every decision was made on paper. */
*,*::before,*::after{box-sizing:border-box;margin:0}
:root{
  --bg:#fdfdfb;--ink:#212124;--muted:#5f6163;--line:#e6e5e0;--faint:#f2f1ec;
  --mark:#8d660c;--mark-fill:#e8c25a;--mark-wash:rgba(246,214,120,.55);
  --sans:ui-sans-serif,system-ui,-apple-system,"Segoe UI",sans-serif;
  --serif:ui-serif,Charter,"Bitstream Charter","Iowan Old Style",Georgia,Cambria,serif;
  --mono:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;
  --measure:34rem;
}
@media(prefers-color-scheme:dark){
  :root:not([data-theme="light"]){
    --bg:#1a1a19;--ink:#e3e1da;--muted:#9a978e;--line:#302f2c;--faint:#232220;
    --mark:#dcb45c;--mark-fill:#8a6c1c;--mark-wash:rgba(180,142,50,.34);
  }
}
:root[data-theme="dark"]{
  --bg:#1a1a19;--ink:#e3e1da;--muted:#9a978e;--line:#302f2c;--faint:#232220;
  --mark:#dcb45c;--mark-fill:#8a6c1c;--mark-wash:rgba(180,142,50,.34);
}
:root[data-theme="light"]{
  --bg:#fdfdfb;--ink:#212124;--muted:#5f6163;--line:#e6e5e0;--faint:#f2f1ec;
  --mark:#8d660c;--mark-fill:#e8c25a;--mark-wash:rgba(246,214,120,.55);
}
html{-webkit-text-size-adjust:100%;scroll-behavior:smooth}
@media(prefers-reduced-motion:reduce){html{scroll-behavior:auto}
  *,*::before,*::after{animation-duration:.01ms!important;transition-duration:.01ms!important}}
body{
  background:var(--bg);color:var(--ink);font-family:var(--sans);
  font-size:16px;line-height:1.6;-webkit-font-smoothing:antialiased;
  min-height:100dvh;display:flex;flex-direction:column;
}
@media(min-width:768px){body{font-size:17px}}
::selection{background:var(--mark-wash)}
a{color:inherit}
:focus-visible{outline:2px solid var(--mark);outline-offset:2px;border-radius:1px}

/* ---------- shell ---------- */
.wrap{width:100%;max-width:46rem;margin:0 auto;padding:0 1.5rem;flex:1}
.wrap.narrow{max-width:calc(var(--measure) + 3rem)}
header.bar{border-bottom:1px solid var(--line);position:sticky;top:0;z-index:40;background:var(--bg)}
.bar-in{width:100%;max-width:46rem;margin:0 auto;padding:.7rem 1.5rem;
  display:flex;align-items:center;gap:.9rem}
.brand{font-size:.85rem;font-weight:600;letter-spacing:-.01em;text-decoration:none;white-space:nowrap;flex:none}
/* The link strip is the only thing allowed to give way on a narrow screen. It
   scrolls; search and the theme control stay pinned and reachable, which is the
   opposite of what happened when they lived inside the same scrolling nav. */
.bar .links{display:flex;gap:.9rem;align-items:center;margin-left:auto;
  overflow-x:auto;min-width:0;scrollbar-width:none;-ms-overflow-style:none}
.bar .links::-webkit-scrollbar{display:none}
.bar .links a{font-size:.82rem;color:var(--muted);text-decoration:none;white-space:nowrap}
.bar .links a:hover,.bar .links a[aria-current]{color:var(--ink)}
.acts{display:flex;flex:none;gap:.1rem}
@media(max-width:620px){
  .bar-in{gap:.6rem;padding-left:1rem;padding-right:1rem}
  .bar .links{gap:.75rem}
  .bar .links a[data-home]{display:none}   /* the brand already goes home */
}
.icon-btn{display:inline-grid;place-items:center;width:1.9rem;height:1.9rem;
  background:none;border:none;padding:0;cursor:pointer;color:var(--muted);border-radius:3px}
.icon-btn:hover{color:var(--ink)}
.icon-btn svg{width:1rem;height:1rem;display:block}
/* The control shows the mode it switches TO, so it has to track all three
   theme states, not just the explicit ones. */
.i-sun{display:none}
@media(prefers-color-scheme:dark){
  :root:not([data-theme="light"]) .i-moon{display:none}
  :root:not([data-theme="light"]) .i-sun{display:block}
}
:root[data-theme="dark"] .i-moon{display:none}
:root[data-theme="dark"] .i-sun{display:block}
:root[data-theme="light"] .i-moon{display:block}
:root[data-theme="light"] .i-sun{display:none}
footer.site{border-top:1px solid var(--line);margin-top:4rem}
footer.site .in{width:100%;max-width:46rem;margin:0 auto;padding:1.5rem;
  font-size:.78rem;color:var(--muted);display:flex;gap:1rem;flex-wrap:wrap;justify-content:space-between}
footer.site a{text-decoration:underline;text-underline-offset:3px}

/* ---------- headings / prose ---------- */
/* The rule: serif is the book's own language — titles, prose, the case, the
   mechanism, the chapter lists. Sans is the guide talking about the book —
   navigation, section labels, counters, controls. */
h1{font-family:var(--serif);font-size:1.5rem;font-weight:600;letter-spacing:-.012em;line-height:1.25}
@media(min-width:768px){h1{font-size:1.75rem}}
h2{font-size:1.05rem;font-weight:600;letter-spacing:-.012em}
.lede{font-family:var(--serif);font-size:1.05rem;line-height:1.7;color:var(--muted);
  max-width:var(--measure)}
.prose{font-family:var(--serif);max-width:var(--measure);font-size:1.0625rem;line-height:1.75}
.prose p{margin-top:1.15em}
.prose p:first-child{margin-top:0}
.prose em{font-style:italic}
.prose strong{font-weight:600}
.prose blockquote{margin:1.4em 0;padding-left:1.1rem;border-left:2px solid var(--line);
  color:var(--muted);font-style:italic}
.prose .lead::first-letter{}
mark.hl{background:var(--mark-wash);color:inherit;padding:.05em 0;border-radius:1px;cursor:pointer}

/* ---------- home: the tick roadmap ---------- */
.hero{padding:2.75rem 0 1.75rem}
.hero h1{font-size:2rem;margin-bottom:.5rem}
@media(min-width:768px){.hero h1{font-size:2.3rem}}
.hero .sub{font-family:var(--serif);font-size:1.08rem;line-height:1.65;color:var(--muted);
  max-width:32rem;margin-bottom:1.1rem}
.counts{font-size:.82rem;color:var(--muted)}
.counts b{font-weight:600;color:var(--ink);font-variant-numeric:tabular-nums}
.resume{display:flex;align-items:baseline;gap:.6rem;flex-wrap:wrap;
  border:1px solid var(--line);border-radius:4px;padding:.7rem .9rem;margin:1.4rem 0 0;
  font-size:.85rem;text-decoration:none}
.resume:hover{border-color:var(--muted)}
.resume .k{color:var(--muted);font-size:.78rem}
.resume .t{font-family:var(--serif);font-weight:600;font-size:.95rem}

.tier{margin-top:2.5rem}
.tier-h{display:flex;align-items:baseline;gap:.7rem;padding-bottom:.5rem;
  border-bottom:1px solid var(--ink)}
.tier-h h2{font-size:.95rem}
.tier-h .n{font-size:.78rem;color:var(--muted);margin-left:auto;font-variant-numeric:tabular-nums}
.prow{display:grid;grid-template-columns:1.6rem 1fr;gap:.75rem;align-items:start;
  padding:.75rem 0;border-bottom:1px solid var(--line);text-decoration:none}
.prow:hover .ptitle{color:var(--muted)}
.prow .pnum{font-family:var(--mono);font-size:.78rem;color:var(--muted);
  padding-top:.12rem;text-align:right;font-variant-numeric:tabular-nums}
.ptitle{font-family:var(--serif);font-size:1rem;font-weight:600;letter-spacing:0}
.pfocus{font-size:.8rem;color:var(--muted);margin-top:.15rem;line-height:1.5;
  display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}
/* A tally, not a progress skeleton. Thirty unread chapters render as a row of
   short baseline strokes; a chapter you have read grows to full height in the
   accent. Twelve rows of identical grey blocks read as a page still loading,
   which is exactly the wrong first impression for an empty guide. */
.ticks{display:none;grid-template-columns:repeat(30,1fr);margin-top:.55rem;max-width:15rem;
  height:14px;align-items:end}
.ticks i{display:block;width:2px;height:5px;background:var(--line);justify-self:center;
  transition:height .18s ease,background .18s ease}
.ticks i.on{height:14px;background:var(--mark-fill)}
@media(min-width:600px){.ticks{display:grid}}
.pmeta{font-size:.75rem;color:var(--muted);margin-top:.4rem;font-variant-numeric:tabular-nums}
.pbar{height:3px;background:var(--faint);border-radius:2px;margin-top:.45rem;max-width:15rem;overflow:hidden}
.pbar span{display:block;height:100%;background:var(--mark-fill);width:0}
@media(min-width:600px){.pbar{display:none}}

/* ---------- three doors ---------- */
.doors{display:grid;gap:0;margin-top:3rem;border-top:1px solid var(--ink)}
@media(min-width:640px){.doors{grid-template-columns:repeat(3,1fr);gap:1.5rem}}
.door{padding:.95rem 0;border-bottom:1px solid var(--line);text-decoration:none;display:block}
.door h3{font-family:var(--serif);font-size:1rem;font-weight:600;margin-bottom:.2rem}
.door p{font-size:.8rem;color:var(--muted);line-height:1.55}
.door:hover h3{color:var(--muted)}

/* ---------- chapter ---------- */
.ch-top{display:flex;align-items:center;gap:.6rem;padding:1.5rem 0 .4rem;font-size:.8rem;color:var(--muted)}
.ch-top a{text-decoration:none}
.ch-top a:hover{color:var(--ink)}
.ch-tools{margin-left:auto;display:flex;gap:.15rem}
.tool{display:inline-flex;align-items:center;gap:.35rem;background:none;border:1px solid transparent;
  border-radius:4px;padding:.28rem .5rem;cursor:pointer;color:var(--muted);font:inherit;font-size:.78rem}
.tool:hover{color:var(--ink);border-color:var(--line)}
.tool[aria-pressed="true"]{color:var(--mark);border-color:var(--line)}
.tool svg{width:.95rem;height:.95rem}
.ch-num{font-family:var(--mono);font-size:.78rem;color:var(--muted);font-variant-numeric:tabular-nums}
.ch-head{padding-bottom:1.5rem}
.ch-head h1{margin:.35rem 0 0}
.ch-body{padding-bottom:1rem}
.apparatus{border-top:1px solid var(--ink);margin-top:2.75rem;padding-top:1.5rem;max-width:var(--measure)}
.ap{margin-bottom:1.75rem}
.ap h2{font-size:.82rem;font-weight:600;color:var(--muted);margin-bottom:.4rem}
.ap .t{font-family:var(--serif);font-size:.98rem;line-height:1.7}
ol.beats{list-style:none;counter-reset:b;font-size:.92rem}
ol.beats li{counter-increment:b;display:grid;grid-template-columns:1.4rem 1fr;gap:.5rem;
  padding:.4rem 0;border-bottom:1px solid var(--line);line-height:1.55;font-family:var(--serif)}
ol.beats li::before{content:counter(b);font-family:var(--mono);font-size:.75rem;color:var(--muted);
  padding-top:.18rem}
ol.beats li:last-child{border-bottom:0}
ol.srcs{list-style:none;counter-reset:s;font-size:.82rem}
ol.srcs li{counter-increment:s;display:grid;grid-template-columns:1.4rem 1fr;gap:.5rem;padding:.3rem 0}
ol.srcs li::before{content:counter(s);font-family:var(--mono);font-size:.72rem;color:var(--muted);padding-top:.15rem}
ol.srcs a{color:var(--muted);text-decoration:none;overflow-wrap:anywhere;font-family:var(--mono);font-size:.76rem}
ol.srcs .host{color:var(--ink);font-weight:500}
ol.srcs a:hover{color:var(--ink);text-decoration:underline;text-underline-offset:2px}
.xref{font-size:.85rem;color:var(--muted);margin-top:.5rem}
.xref a{color:var(--ink);text-decoration:underline;text-underline-offset:3px;text-decoration-color:var(--line)}
.xref a:hover{text-decoration-color:var(--muted)}

.pager{display:grid;gap:1px;border-top:1px solid var(--line);margin-top:3rem;background:var(--line)}
@media(min-width:640px){.pager{grid-template-columns:1fr 1fr}}
.pg{background:var(--bg);padding:1rem 0;text-decoration:none;display:block}
@media(min-width:640px){.pg.next{text-align:right;padding-left:1.5rem}.pg.prev{padding-right:1.5rem}}
.pg .k{font-size:.75rem;color:var(--muted);display:block;margin-bottom:.15rem}
.pg .t{font-family:var(--serif);font-size:.95rem;font-weight:500;line-height:1.4}
.pg:hover .t{color:var(--muted)}

/* ---------- chapter list (part page) ---------- */
.clist{border-top:1px solid var(--ink)}
.crow{display:grid;grid-template-columns:1.9rem 1fr auto;gap:.75rem;align-items:start;
  padding:.7rem 0;border-bottom:1px solid var(--line)}
.crow .cn{font-family:var(--mono);font-size:.78rem;color:var(--muted);padding-top:.15rem;
  text-align:right;font-variant-numeric:tabular-nums}
.crow a{font-family:var(--serif);text-decoration:none;font-size:1rem;font-weight:500;display:block;line-height:1.4}
.crow a:hover{color:var(--muted)}
.crow .cs{font-size:.8rem;color:var(--muted);margin-top:.1rem;line-height:1.5;
  display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}
.crow.done .cn{color:var(--mark)}
.dot{width:.85rem;height:.85rem;border:1px solid var(--line);border-radius:2px;
  background:none;cursor:pointer;padding:0;margin-top:.28rem;flex:none}
.dot[aria-pressed="true"]{background:var(--mark-fill);border-color:var(--mark-fill)}
.dot:hover{border-color:var(--muted)}

/* ---------- search overlay ---------- */
dialog.search{border:none;padding:0;background:none;max-width:none;max-height:none;width:100%;height:100%}
dialog.search::backdrop{background:rgba(0,0,0,.35)}
.sbox{width:100%;max-width:38rem;margin:8vh auto 0;background:var(--bg);
  border:1px solid var(--line);border-radius:6px;overflow:hidden;
  box-shadow:0 12px 40px rgba(0,0,0,.18)}
.sbox input{width:100%;border:none;border-bottom:1px solid var(--line);background:none;
  padding:.9rem 1rem;font:inherit;font-size:1rem;color:var(--ink);outline:none}
.sres{max-height:60vh;overflow-y:auto}
.sres a{display:block;padding:.6rem 1rem;text-decoration:none;border-bottom:1px solid var(--faint)}
.sres a[data-sel]{background:var(--faint)}
.sres .st{font-family:var(--serif);font-size:.98rem;font-weight:500;line-height:1.35}
.sres .sm{font-size:.75rem;color:var(--muted);margin-top:.1rem}
.sres .empty{padding:1rem;font-size:.85rem;color:var(--muted)}

/* ---------- popover for highlighting ---------- */
.hlpop{position:absolute;z-index:60;background:var(--bg);border:1px solid var(--line);
  border-radius:4px;box-shadow:0 6px 20px rgba(0,0,0,.15);display:none}
.hlpop button{background:none;border:none;font:inherit;font-size:.8rem;color:var(--ink);
  padding:.4rem .7rem;cursor:pointer}
.hlpop button:hover{background:var(--faint)}

/* ---------- generic list pages ---------- */
.page-h{padding:2.25rem 0 1.5rem}
.page-h h1{margin-bottom:.5rem}
.rule-top{border-top:1px solid var(--ink)}
.stack{display:block}
.stack .item{padding:1rem 0;border-bottom:1px solid var(--line);text-decoration:none;display:block}
.stack .item h3{font-family:var(--serif);font-size:1.05rem;font-weight:600;margin-bottom:.2rem}
.stack .item p{font-size:.85rem;color:var(--muted);line-height:1.55;max-width:var(--measure)}
.stack .item .m{font-size:.75rem;color:var(--muted);font-variant-numeric:tabular-nums;margin-top:.3rem}
.stack .item:hover h3{color:var(--muted)}

/* ---------- attack/defense pairs ---------- */
.pair{border-bottom:1px solid var(--line);padding:1.15rem 0;display:grid;gap:.9rem}
@media(min-width:720px){.pair{grid-template-columns:1fr 1fr;gap:2rem}}
.side{min-width:0}
.side .k{font-size:.73rem;color:var(--muted);margin-bottom:.3rem}
/* Attack and counter are told apart by rule style rather than by a second hue:
   colour on this site is reserved for the reader's own marks. Solid against
   dotted is unmistakable at a glance and survives greyscale printing. */
.atk{border-left:2px solid var(--ink);padding-left:.85rem}
.def{border-left:2px dotted var(--muted);padding-left:.85rem}
.side a{font-family:var(--serif);text-decoration:none;font-size:.98rem;font-weight:500;display:block;line-height:1.4;margin-bottom:.25rem}
.side a:hover{color:var(--muted)}
.side .gap{font-family:var(--serif);font-size:.9rem;line-height:1.65;color:var(--muted)}
.side .written{font-size:.72rem;color:var(--muted);margin-bottom:.3rem}

/* ---------- situation / quiz ---------- */
.q{max-width:var(--measure)}
.q .scenario{font-family:var(--serif);font-size:1.05rem;line-height:1.7;margin-bottom:1.2rem}
.opts{display:block;margin-bottom:1rem}
.opt{display:block;width:100%;text-align:left;background:none;border:1px solid var(--line);
  border-radius:4px;padding:.65rem .8rem;margin-bottom:.5rem;font:inherit;font-size:.9rem;
  color:var(--ink);cursor:pointer;line-height:1.45}
.opt:hover{border-color:var(--muted)}
.opt.right{border-color:var(--mark-fill);background:var(--mark-wash)}
.opt.wrong{border-color:var(--line);color:var(--muted);text-decoration:line-through}
.qfoot{font-size:.85rem;color:var(--muted);border-top:1px solid var(--line);padding-top:.9rem}
.qfoot a{color:var(--ink);text-decoration:underline;text-underline-offset:3px}
.qprog{font-family:var(--mono);font-size:.78rem;color:var(--muted);margin-bottom:.75rem;
  font-variant-numeric:tabular-nums}
.grp{font-size:.82rem;color:var(--muted);margin:1.3rem 0 .1rem}
.chips{display:flex;flex-wrap:wrap;gap:.4rem;margin:.6rem 0 1.2rem}
.chip{border:1px solid var(--line);border-radius:100px;padding:.32rem .7rem;background:none;
  font:inherit;font-size:.82rem;color:var(--ink);cursor:pointer}
.chip[aria-pressed="true"]{border-color:var(--mark-fill);background:var(--mark-wash)}
.chip:hover{border-color:var(--muted)}
.btn{display:inline-block;border:1px solid var(--ink);border-radius:4px;padding:.5rem .9rem;
  background:none;font:inherit;font-size:.85rem;color:var(--ink);cursor:pointer;text-decoration:none}
.btn:hover{background:var(--ink);color:var(--bg)}
.btn[disabled]{opacity:.4;cursor:default}
.btn[disabled]:hover{background:none;color:var(--ink)}

/* ---------- saved ---------- */
.hlitem{border-bottom:1px solid var(--line);padding:.9rem 0}
.hlitem .q{font-family:var(--serif);font-size:.95rem;line-height:1.65;
  border-left:2px solid var(--mark-fill);padding-left:.8rem;margin-bottom:.35rem}
.hlitem .src{font-size:.78rem;color:var(--muted)}
.hlitem .src a{text-decoration:none}
.hlitem .src a:hover{color:var(--ink)}
.hlitem .rm{background:none;border:none;color:var(--muted);font:inherit;font-size:.75rem;
  cursor:pointer;padding:0;margin-left:.6rem;text-decoration:underline}
.empty-state{font-family:var(--serif);color:var(--muted);font-size:1rem;line-height:1.7;
  max-width:var(--measure);padding:1.5rem 0}
.kbd{font-family:var(--mono);font-size:.75rem;border:1px solid var(--line);border-radius:3px;
  padding:.05rem .3rem;color:var(--muted)}
