/* Drawbook — the book is the page: a sign-up slip, then the open leaf as an eight-line ledger, then the circled pages
   and the margin notes. Dot-matrix display face, mono body, one yellow line of light. The CA hangs as a bookmark
   ribbon on the right edge at every width. */
:root {
  --ground: #0B0B09;
  --leafbg: #121210;
  --inkc: #E4E1D3;
  --faded: #8C887A;
  --ghost: #4D4A41;
  --rule: #2B2A24;
  --glow: #F5E400;
  --glow-soft: rgba(245, 228, 0, .12);
  --dots: "DotGothic16", "IBM Plex Mono", ui-monospace, monospace;
  --mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  --ribbon-w: 44px;
}
* { box-sizing: border-box; }
html { background: var(--ground); -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--ground); color: var(--inkc);
  font-family: var(--mono); font-size: 14px; line-height: 1.5;
  overflow-x: hidden;
}
a { color: inherit; }
code { font-family: var(--mono); }
button { font: inherit; cursor: pointer; }
[hidden] { display: none !important; }

/* ---------- the bookmark ribbon (the CA) ---------- */
.spine {
  position: fixed; right: 0; top: 50%; transform: translateY(-50%); z-index: 40;
  width: var(--ribbon-w);
  display: flex; flex-direction: column; align-items: center; gap: 9px;
  padding: 12px 0 26px;
  background: var(--glow); color: #0B0B09;
  clip-path: polygon(0 0, 100% 0, 100% 100%, 50% calc(100% - 14px), 0 100%);
  box-shadow: 0 0 22px rgba(245, 228, 0, .25);
}
.spine-cap, .spine-addr, .spine-copy { writing-mode: vertical-rl; }
.spine-cap { font-family: var(--dots); font-size: 10px; letter-spacing: .06em; }
.spine-addr {
  font-size: 10.5px; line-height: 1; font-weight: 600; letter-spacing: .01em;
  user-select: all; -webkit-user-select: all; word-break: break-all;
}
.spine-addr.is-blank { font-weight: 400; font-style: italic; opacity: .7; user-select: none; -webkit-user-select: none; }
.spine-copy {
  border: 0; border-radius: 3px; background: #0B0B09; color: var(--glow);
  padding: 9px 5px; font-family: var(--dots); font-size: 11px; letter-spacing: .06em;
}
.spine-copy[data-done="1"] { background: transparent; color: #0B0B09; outline: 1px dashed #0B0B09; }

/* ---------- the book (one column on the phone) ---------- */
.book {
  padding: 10px calc(var(--ribbon-w) + 12px) 40px 14px;
  display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px;
  grid-template-areas: "stamp" "slip" "leaf" "bygone" "scrawl" "lookup" "statute" "colophon";
}
.stamp { grid-area: stamp; display: flex; align-items: center; gap: 8px; height: 30px; color: var(--faded); font-size: 12px; }
.stamp-mark { border-radius: 4px; }
.stamp-word { font-family: var(--dots); font-size: 15px; color: var(--inkc); letter-spacing: .04em; }
.stamp-pg { font-family: var(--dots); }
.stamp-how { margin-left: auto; text-decoration: none; border-bottom: 1px dotted var(--ghost); }

/* ---------- the slip: the last circled name, the live sentence, the pen ---------- */
.slip {
  grid-area: slip; position: relative;
  padding: 14px 14px 12px; border: 1px dashed var(--ghost); background: var(--leafbg);
}
.slip::before { content: "sign-up slip"; position: absolute; top: -9px; left: 10px; padding: 0 6px; background: var(--ground); color: var(--ghost); font-size: 10.5px; letter-spacing: .1em; }
.slip-kick { margin: 0; color: var(--faded); font-size: 11.5px; letter-spacing: .04em; }
.slip-moment {
  margin: 4px 0 2px; font-family: var(--dots); font-size: 25px; line-height: 1.2; color: var(--inkc);
}
.slip-moment b { color: var(--glow); font-weight: 400; text-shadow: 0 0 14px rgba(245, 228, 0, .45); }
.slip-moment .ring { display: inline-block; min-width: 1.35em; padding: 0 .12em; border: 2px solid var(--glow); border-radius: 50%; text-align: center; color: var(--glow); box-shadow: 0 0 12px rgba(245, 228, 0, .35); }
.slip-who { margin: 0 0 8px; color: var(--faded); font-size: 12px; word-break: break-all; }
.slip-who:empty { display: none; }
.slip-live { margin: 0 0 12px; font-size: 14.5px; line-height: 1.45; }
.slip-live b { color: var(--glow); font-weight: 600; }
.slip-act { display: flex; gap: 8px; }
.slip-sign {
  flex: 1; min-height: 50px; border: 0; background: var(--glow); color: #0B0B09;
  font-family: var(--dots); font-size: 15.5px; letter-spacing: .01em; padding: 8px 10px;
}
.slip-sign:disabled { background: transparent; color: var(--faded); outline: 1px dashed var(--ghost); cursor: default; }
.slip-purse { min-height: 50px; padding: 0 12px; border: 1px solid var(--ghost); background: transparent; color: var(--inkc); font-size: 12.5px; }
.slip-purse[data-on="1"] { color: var(--glow); border-color: var(--glow); }
.slip-clock { margin: 10px 0 0; font-size: 12.5px; color: var(--inkc); }
.slip-mine { margin: 4px 0 0; font-size: 11.5px; color: var(--faded); }
.slip-out { margin-top: 10px; width: 100%; min-height: 42px; border: 1px solid var(--glow); background: var(--glow-soft); color: var(--glow); font-family: var(--dots); font-size: 15px; }

/* ---------- the leaf: eight numbered lines ---------- */
.leaf { grid-area: leaf; border-top: 2px solid var(--inkc); }
.leaf-top { display: flex; justify-content: space-between; align-items: baseline; padding: 8px 0 6px; }
.leaf-pg { font-family: var(--dots); font-size: 20px; }
.leaf-state { font-size: 12px; color: var(--faded); }
.leaf-state b { color: var(--glow); font-weight: 500; }
.leaf-cols, .ln { display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; gap: 10px; align-items: center; }
.leaf-cols { padding: 4px 0; border-bottom: 1px solid var(--rule); color: var(--ghost); font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; }
.leaf-lines { list-style: none; margin: 0; padding: 0; }
.ln { min-height: 42px; padding: 4px 0; border-bottom: 1px dotted var(--rule); }
.ln-no { font-family: var(--dots); font-size: 18px; color: var(--ghost); text-align: center; }
.ln-name { font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ln-at { font-size: 11px; color: var(--faded); text-align: right; white-space: nowrap; }
.ln.is-blank .ln-name { color: var(--ghost); letter-spacing: .32em; }
.ln.is-signed .ln-no { color: var(--inkc); }
.ln.is-mine .ln-name::after { content: "  you"; color: var(--glow); font-size: 11px; }
.ln.is-next { background: var(--glow-soft); box-shadow: inset 3px 0 0 var(--glow); cursor: pointer; }
.ln.is-next .ln-no { color: var(--glow); }
.ln.is-next .ln-name { color: var(--glow); letter-spacing: .02em; }
.ln.is-next .ln-name::before { content: ""; display: inline-block; width: 8px; height: 15px; margin-right: 6px; vertical-align: -2px; background: var(--glow); animation: caret 1s steps(1) infinite; }
.ln.is-dim { opacity: .38; }
.ln.is-circled .ln-no span { display: inline-block; width: 30px; height: 30px; line-height: 26px; border: 2px solid var(--glow); border-radius: 50%; color: var(--glow); box-shadow: 0 0 14px rgba(245, 228, 0, .4); animation: circle-in .7s ease-out both; }
.ln.is-circled .ln-name, .ln.is-circled .ln-at { color: var(--glow); }
.ln.is-fresh .ln-name { animation: ink-in .9s ease-out both; }
.leaf.is-shut .ln.is-signed { animation: scan 2.4s linear infinite; }
.leaf-sum { margin: 8px 0 0; font-size: 11.5px; color: var(--faded); }
@keyframes caret { 50% { opacity: 0; } }
@keyframes circle-in { from { transform: scale(1.8); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes ink-in { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }
@keyframes scan { 0%, 80%, 100% { background: transparent; } 10% { background: var(--glow-soft); } }

/* ---------- shared section heads ---------- */
.sect-top { display: flex; justify-content: space-between; align-items: baseline; padding-bottom: 6px; border-bottom: 1px solid var(--rule); }
.sect-name { font-family: var(--dots); font-size: 16px; }
.sect-n { font-size: 11.5px; color: var(--faded); }

/* ---------- circled pages ---------- */
.bygone { grid-area: bygone; }
.bygone-cols, .bygone-row { display: grid; grid-template-columns: 46px minmax(0, 1fr) 62px 52px; gap: 8px; align-items: baseline; }
.bygone-cols { padding: 6px 0 4px; color: var(--ghost); font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; }
.bygone-rows { list-style: none; margin: 0; padding: 0; }
.bygone-rows > li { padding: 7px 0; border-bottom: 1px dotted var(--rule); font-size: 12.5px; }
.bygone-row .dotrow { font-family: var(--mono); letter-spacing: .12em; color: var(--faded); white-space: nowrap; overflow: hidden; }
.bygone-row .dotrow em { font-style: normal; color: var(--glow); }
.bygone-row b { color: var(--glow); font-weight: 500; }
.bygone-sub { margin-top: 2px; font-size: 11px; color: var(--faded); word-break: break-all; }
.bygone-sub a { color: var(--faded); }
.bygone-rows > li.is-say { color: var(--faded); }
.bygone-rows > li.is-eg { opacity: .45; }

/* ---------- the margin: the tape ---------- */
.scrawl { grid-area: scrawl; }
.scrawl-rows { list-style: none; margin: 0; padding: 0; max-height: 360px; overflow-y: auto; }
.scrawl-rows > li { display: grid; grid-template-columns: 64px minmax(0, 1fr) 40px; gap: 8px; padding: 6px 0; border-bottom: 1px dotted var(--rule); font-size: 12.5px; }
.scrawl-rows > li.is-say { display: block; color: var(--faded); }
.scrawl-rows > li.is-eg { opacity: .45; }
.scrawl-rows > li.is-new { animation: ink-in .8s steps(12) both; }
.mk { font-family: var(--dots); color: var(--faded); }
li[data-k="drawn"] .mk, li[data-k="drawn"] b { color: var(--glow); }
.tm { color: var(--ghost); text-align: right; font-size: 11px; }

/* ---------- one name ---------- */
.lookup { grid-area: lookup; }
.lookup-body { padding-top: 8px; font-size: 12.5px; word-break: break-all; }
.lookup-body > div { padding: 4px 0; border-bottom: 1px dotted var(--rule); }

/* ---------- rules ---------- */
.statute { grid-area: statute; }
.statute-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; padding-top: 10px; }
.clause h3 { margin: 0 0 4px; font-family: var(--dots); font-weight: 400; font-size: 15px; }
.clause h3 i { font-style: normal; color: var(--glow); margin-right: 6px; }
.clause p { margin: 0; font-size: 13px; color: #C9C5B6; }
.eg { margin: 6px 0 8px; padding: 10px; overflow-x: auto; background: var(--leafbg); border: 1px dashed var(--rule); font-size: 11.5px; line-height: 1.55; color: var(--faded); }

/* ---------- colophon ---------- */
.colophon { grid-area: colophon; border-top: 2px solid var(--inkc); padding-top: 10px; font-size: 11.5px; color: var(--faded); }
.colophon-row { display: grid; grid-template-columns: minmax(0, 1fr); gap: 2px; padding: 5px 0; }
.colophon-row code { color: var(--inkc); word-break: break-all; }
.colophon-links { display: flex; flex-wrap: wrap; gap: 14px; padding: 8px 0; }
.colophon-links a.is-off { display: none; }
.colophon-end { margin: 6px 0 0; color: var(--ghost); }

/* ---------- pops ---------- */
.pops { position: fixed; left: 12px; bottom: 14px; z-index: 50; display: flex; flex-direction: column; gap: 6px; max-width: calc(100vw - 80px); }
.pop { padding: 9px 12px; background: #1B1B17; border: 1px solid var(--ghost); font-size: 12.5px; color: var(--inkc); }

/* ---------- 720–1000: one column, wider measure, bigger leaf ---------- */
@media (min-width: 720px) {
  :root { --ribbon-w: 52px; }
  body { font-size: 15px; }
  .book { padding: 18px calc(var(--ribbon-w) + 28px) 56px 32px; gap: 22px; max-width: 900px; margin: 0 auto; }
  .spine-addr { font-size: 12px; }
  .spine-cap { font-size: 11px; }
  .slip { padding: 20px 22px 16px; }
  .slip-moment { font-size: 34px; }
  .slip-live { font-size: 16px; }
  .ln { min-height: 50px; grid-template-columns: 48px minmax(0, 1fr) auto; }
  .leaf-cols { grid-template-columns: 48px minmax(0, 1fr) auto; }
  .ln-no { font-size: 22px; }
  .ln-name { font-size: 15px; }
  .ln-at { font-size: 12px; }
  .leaf-pg { font-size: 24px; }
  .statute-grid { grid-template-columns: 1fr 1fr; }
  .clause-eg { grid-column: 1 / -1; }
  .colophon-row { grid-template-columns: 110px minmax(0, 1fr); }
}

/* ---------- ≥1000: recompose — slip and leaf left, circled pages and the margin right ---------- */
@media (min-width: 1000px) {
  :root { --ribbon-w: 58px; }
  .book {
    max-width: 1240px; padding: 22px calc(var(--ribbon-w) + 40px) 64px 40px; column-gap: 40px; row-gap: 26px;
    grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
    grid-template-areas:
      "stamp stamp"
      "slip bygone"
      "slip scrawl"
      "leaf scrawl"
      "lookup scrawl"
      "statute statute"
      "colophon colophon";
    align-items: start;
  }
  .spine-addr { font-size: 13px; }
  .spine-copy { font-size: 12px; padding: 11px 6px; }
  .slip-moment { font-size: 40px; }
  .slip-sign { font-size: 19px; min-height: 56px; }
  .ln { min-height: 56px; }
  .ln-no { font-size: 24px; }
  .ln-name { font-size: 16px; }
  .scrawl-rows { max-height: 520px; }
  .statute-grid { grid-template-columns: 1fr 1fr 1fr; }
  .clause-eg { grid-column: span 2; grid-row: span 2; }
}
