/* MAZE — Solver's Desk. Dark-only "candlelit study" theme.
   Sections are append-only per module; keep order. */

/* ===== 0. fonts + tokens + reset ===== */
@font-face {
  font-family: 'Dair';
  src: url('../vendor/fonts/dair.woff2') format('woff2');
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Dair';
  src: url('../vendor/fonts/dair-italic.woff2') format('woff2');
  font-weight: 400; font-style: italic; font-display: swap;
}
@font-face {
  font-family: 'Gmuender Gravur';
  src: url('../vendor/fonts/gmuender-gravur.woff2') format('woff2');
  font-weight: 400; font-style: normal; font-display: swap;
}

:root {
  /* warm near-black: candlelit paper, not tech-blue */
  --bg-0: #0b0a08;
  --bg-1: #121110;
  --bg-2: #191713;
  --bg-3: #232019;
  --line: #2e2a22;
  --line-soft: #221f19;
  --ink: #e8e1d1;
  --ink-dim: #a89f8c;
  --ink-faint: #6e6759;
  --accent: #f2c94c;
  --accent-bright: #ffd970;
  --accent-ink: #1a1508;
  --accent-soft: rgba(242, 201, 76, .16);
  --accent-line: rgba(242, 201, 76, .75);
  --door-fill: rgba(255, 235, 59, .16);
  --door-line: rgba(255, 235, 59, .75);
  --ok: #97bd80;
  --bad: #c96f6f;
  /* room statuses */
  --st-unsolved: #b0713f;
  --st-progress: #7da7c9;
  --st-deadend: #c96f6f;
  --st-onpath: #97bd80;
  --st-solved: #f2c94c;
  --st-important: #b48ec9;
  --display: 'Gmuender Gravur', 'Dair', 'Palatino Linotype', Palatino, Georgia, serif;
  --smallcaps: 'Dair', 'Palatino Linotype', Georgia, serif;
  --serif: 'Palatino Linotype', 'Book Antiqua', Palatino, Georgia, serif;
  --sans: 'Segoe UI', system-ui, sans-serif;
  --mono: Consolas, 'Cascadia Mono', monospace;
  --rail-w: 58px;
  --panel-w: 336px;
  --text-panel-w: 564px;   /* wide enough that the book's own line rag survives */
  --shadow: 0 10px 34px rgba(0, 0, 0, .6);
  --ease: cubic-bezier(.22, .9, .28, 1);
  /* shared reading size: page text, hint list, extra (community) list.
     Change once here and all three follow. */
  --reading-size: 21px;
  --reading-lh: 1.3em;
  --reading-ls: .02em;
}
body.font-large { --reading-size: 27px; }

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg-0);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  overflow: hidden;
}
/* paper grain over everything */
body::after {
  content: '';
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 9000;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)' opacity='.05'/%3E%3C/svg%3E");
}
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; padding: 0; }
input, textarea, select { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration-color: rgba(242, 201, 76, .4); text-underline-offset: 3px; }
a:hover { color: var(--accent-bright); }
img { max-width: 100%; }
.screen { position: fixed; inset: 0; }
[hidden] { display: none !important; }

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

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 5px; border: 2px solid var(--bg-1); }
::-webkit-scrollbar-thumb:hover { background: var(--ink-faint); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* shared bits */
.btn {
  font-family: var(--smallcaps);
  font-size: 22px;
  letter-spacing: .08em;
  padding: 7px 14px 8px;
  border: 1px solid var(--line);
  background: var(--bg-2);
  border-radius: 3px;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .35), inset 0 0 0 2px rgba(232, 225, 209, .03);
  transition: border-color .18s var(--ease), color .18s var(--ease), background .18s var(--ease);
}
.btn:hover { border-color: var(--accent-line); color: var(--accent-bright); }
.btn-primary {
  background: linear-gradient(180deg, var(--accent-bright), var(--accent));
  color: var(--accent-ink);
  border-color: var(--accent);
}
.btn-primary:hover { color: #000; filter: brightness(1.06); }

.prose { font-family: var(--serif); font-size: 16.5px; line-height: 1.68; color: var(--ink); }
.prose p { margin: 0 0 .85em; }
.prose h1 { font-family: var(--display); font-weight: 400; font-size: 26px; margin: .4em 0 .5em; color: var(--accent); }
.prose ul { padding-left: 1.3em; }
.prose li { margin-bottom: .4em; }
.prose blockquote { margin: 1em 0; padding: .2em 0 .2em 1em; border-left: 2px solid var(--line); color: var(--ink-dim); }
.prose i, .prose em { font-style: italic; }
.prose.dropcap > p:first-of-type::first-letter {
  font-family: var(--display);
  font-size: 3.1em;
  line-height: .82;
  padding: 0 .09em 0 0;
  color: var(--accent);
}

/* ===== 1. app shell / menu ===== */
#screen-menu { overflow-y: auto; }
.menu-bg {
  position: fixed; inset: 0; pointer-events: none;
  background:
    radial-gradient(1200px 700px at 68% 38%, rgba(242, 201, 76, .05), transparent 60%),
    radial-gradient(1600px 1000px at 50% 120%, rgba(0, 0, 0, .5), transparent 60%);
}
.menu-wrap {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(420px, 620px) minmax(360px, 560px);
  justify-content: center;
  align-items: center;
  gap: clamp(24px, 6vw, 90px);
  padding: 48px clamp(24px, 5vw, 72px);
}
@media (max-width: 980px) {
  .menu-wrap { grid-template-columns: 1fr; max-width: 640px; margin: 0 auto; }
  .menu-right { order: -1; text-align: center; }
  .menu-cover { max-height: 42vh; }
}

.menu-kicker {
  font-family: var(--smallcaps);
  letter-spacing: .34em;
  font-size: 19px;
  color: var(--accent);
}
.menu-title.menu-title-desk { font-size: 75px; letter-spacing: .03em; color: #ebd389; }
@media (max-width: 700px) { .menu-title.menu-title-desk { font-size: clamp(44px, 10vw, 75px); } }
.menu-sub.menu-sub-desk {
  font-family: var(--sans);
  font-style: normal;
  font-size: 14px;
  line-height: 1.55;
  color: var(--ink-dim);
  max-width: 430px;
}
.menu-title {
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(84px, 11vw, 148px);
  line-height: .95;
  margin: 4px 0 2px -5px;
  letter-spacing: .045em;
  color: var(--ink);
  text-shadow: 0 0 46px rgba(242, 201, 76, .18);
}
.menu-sub {
  font-family: var(--display);
  font-style: italic;
  font-size: clamp(17px, 2vw, 21px);
  color: var(--ink-dim);
}
.menu-rule { margin: 26px 0; height: 1px; background: var(--line); position: relative; max-width: 440px; }
.menu-rule span {
  position: absolute; left: 50%; top: 50%;
  width: 7px; height: 7px;
  transform: translate(-50%, -50%) rotate(45deg);
  background: var(--bg-0);
  border: 1px solid var(--accent-line);
}

.menu-ctas { display: flex; flex-direction: column; gap: 10px; max-width: 440px; }
.menu-btn {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas: 'label arrow' 'sub arrow';
  text-align: left;
  padding: 12px 16px 13px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 3px;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .4), inset 0 0 0 2px rgba(232, 225, 209, .03);
  transition: border-color .18s var(--ease), transform .18s var(--ease), background .18s var(--ease);
}
.menu-btn:hover { border-color: var(--accent-line); transform: translateX(3px); }
.menu-btn-label {
  grid-area: label;
  font-family: var(--smallcaps);
  font-size: 19px;
  letter-spacing: .12em;
}
.menu-btn-sub { grid-area: sub; font-size: 14px; color: var(--ink-faint); font-family: var(--sans); }
.menu-btn-arrow { grid-area: arrow; align-self: center; color: var(--ink-faint); transition: color .18s, transform .18s; }
.menu-btn:hover .menu-btn-arrow { color: var(--accent); transform: translateX(3px); }
.menu-btn-primary { background: linear-gradient(180deg, #221d12, #1b1710); border-color: rgba(242, 201, 76, .5); }
.menu-btn-primary .menu-btn-label { color: var(--accent-bright); }
.menu-btn-primary:hover { box-shadow: inset 0 0 0 1px rgba(0,0,0,.4), 0 0 24px rgba(242, 201, 76, .12); }

.menu-save-label {
  margin-top: 32px;
  font-family: var(--smallcaps);
  font-size: 14px;
  letter-spacing: .28em;
  text-transform: uppercase;
  color: var(--ink-dim);
}
.menu-row2 { display: flex; gap: 8px; margin-top: 18px; flex-wrap: wrap; }
.menu-row2 .btn {
  font-family: var(--smallcaps);
  font-size: 16px;
  letter-spacing: .08em;
  padding: 12px 26px 12px;
  width: 22.8%;
}
/* Help & About lines up with the Continue button above instead of sharing the row's split */
.menu-row2 [data-menu-about] { width: 440px; max-width: 100%; }
.menu-hint { color: var(--ink-faint); font-size: 14px; margin: 14px 0 0; max-width: 440px; }
.menu-footer { color: var(--ink-faint); font-size: 14px; margin-top: 34px; line-height: 1.6; max-width: 460px; }

.menu-right { position: relative; }
.menu-cover {
  display: block;
  width: 100%;
  max-height: 72vh;
  object-fit: contain;
  border: 1px solid rgba(242, 201, 76, .35);
  outline: 1px solid rgba(0, 0, 0, .8);
  outline-offset: -4px;
  box-shadow: var(--shadow), 0 0 80px rgba(242, 201, 76, .07);
  transition: transform .5s var(--ease), box-shadow .5s var(--ease);
  cursor: pointer;
}
.menu-cover:hover { transform: scale(1.01); box-shadow: var(--shadow), 0 0 110px rgba(242, 201, 76, .12); }

/* the big retro way in */
.menu-enter {
  display: block;
  width: 100%;
  margin-top: 18px;
  padding: 17px 20px 18px;
  font-family: var(--smallcaps);
  font-size: 27px;
  letter-spacing: .24em;
  text-align: center;
  color: var(--accent-bright);
  background: linear-gradient(180deg, #2b2313, #1c1810 55%, #181510);
  border: 1px solid var(--accent-line);
  border-radius: 4px;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .55), inset 0 0 0 3px rgba(242, 201, 76, .14),
    0 8px 26px rgba(0, 0, 0, .5);
  transition: box-shadow .25s var(--ease), transform .25s var(--ease), filter .25s var(--ease);
}
.menu-enter span { display: inline-block; padding-left: .24em; /* balance letterspacing */ }
.menu-enter:hover {
  transform: translateY(-2px);
  filter: brightness(1.08);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .55), inset 0 0 0 3px rgba(242, 201, 76, .22),
    0 10px 30px rgba(0, 0, 0, .55), 0 0 44px rgba(242, 201, 76, .2);
}
.menu-danger:hover { border-color: var(--bad); color: var(--bad); }

.reveal { opacity: 0; transform: translateY(10px); animation: reveal .7s var(--ease) forwards; animation-delay: calc(var(--i, 0) * 90ms); }
@keyframes reveal { to { opacity: 1; transform: none; } }

/* ===== 2. viewer stage (step 4) ===== */
#screen-viewer { background: var(--bg-0); }
#stage {
  position: absolute; inset: 0;
  overflow: hidden;
  background: radial-gradient(1400px 900px at 50% 42%, #100f0c, var(--bg-0) 75%);
}
#world { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
#world img#room-img {
  display: block;
  user-select: none;
  -webkit-user-drag: none;
  pointer-events: none;
}
#door-layer { position: absolute; left: 0; top: 0; pointer-events: none; }
#pins-layer { position: absolute; left: 0; top: 0; width: 100%; height: 100%; pointer-events: none; }

#stage { cursor: grab; }
#stage.panning { cursor: grabbing; }
#world.interacting { will-change: transform; }
#world img#room-img { opacity: 0; transition: opacity .28s var(--ease); }
#world img#room-img.loaded { opacity: 1; }

.text-page-card {
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  width: min(620px, calc(100vw - 140px));
  max-height: 80vh;
  overflow-y: auto;
  background: linear-gradient(175deg, #17150f, #121009);
  border: 1px solid rgba(242, 201, 76, .3);
  outline: 1px solid rgba(0, 0, 0, .8);
  outline-offset: -5px;
  box-shadow: var(--shadow);
  padding: 44px 48px;
}
.text-page-title {
  font-family: var(--smallcaps);
  font-size: 26px;
  letter-spacing: .18em;
  color: var(--accent);
  text-align: center;
  margin-bottom: 22px;
}
.text-page-card::after {
  content: '';
  display: block;
  margin: 26px auto 0;
  width: 7px; height: 7px;
  transform: rotate(45deg);
  border: 1px solid var(--accent-line);
}

/* ===== 3. doors (step 5) ===== */
.door-shape {
  fill: none;
  stroke: none;
  pointer-events: fill;
  cursor: pointer;
}
.door-shape:hover, .door-shape.hot {
  fill: var(--door-fill);
  stroke: var(--door-line);
  stroke-width: 1.5;
}
#stage.placing .door-shape { pointer-events: none; }
#door-tooltip {
  position: fixed;
  z-index: 700;
  pointer-events: none;
  background: rgba(14, 12, 8, .96);
  border: 1px solid rgba(242, 201, 76, .5);
  border-radius: 3px;
  overflow: hidden;
  box-shadow: 0 4px 18px rgba(0, 0, 0, .6);
  white-space: nowrap;
}
#door-tooltip .tt-thumb {
  display: block;
  width: 158px;
  height: auto;
  border-bottom: 1px solid rgba(242, 201, 76, .35);
  filter: saturate(.92);
}
/* instant hover tips for [data-tip] controls */
.hover-tip {
  position: fixed;
  z-index: 880;
  pointer-events: none;
  max-width: 320px;
  padding: 9px 13px 10px;
  background: rgba(14, 12, 8, .97);
  border: 1px solid var(--accent-line);
  border-radius: 4px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, .65);
  font-family: var(--serif);
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
}
.hover-tip b { color: var(--accent-bright); font-weight: 600; }

#door-tooltip .tt-label {
  display: block;
  padding: 5px 11px 6px;
  font-family: var(--smallcaps);
  font-size: 14px;
  letter-spacing: .09em;
  color: var(--accent-bright);
}

/* ===== 4. pins + symbols (step 6) ===== */
.pin-wrap {
  position: absolute;
  width: 0; height: 0;
  pointer-events: none;
}
.pin-glyph {
  /* counter-transform: flip leftmost, then counter-rotation, then 1/z so the
     glyph stays upright, unmirrored, constant screen size. origin = anchor. */
  position: absolute;
  left: 0; top: 0;
  transform-origin: 0 0;
  transform: scale(var(--cfx, 1), var(--cfy, 1)) rotate(var(--ck, 0deg)) scale(var(--cz, 1));
  pointer-events: auto;
}
.icon { width: 18px; height: 18px; display: inline-block; vertical-align: -4px; }

#stage.placing { cursor: crosshair; }
#pins-layer.hide-comments .pin-wrap[data-kind="comment"] { display: none; }
.pin-plate {
  position: absolute;
  left: 0; top: 0;
  transform: translate(-50%, -50%);
  width: 27px; height: 27px;
  border-radius: 50%;
  background: rgba(13, 11, 7, .93);
  border: 1px solid var(--accent-line);
  box-shadow: 0 2px 9px rgba(0, 0, 0, .65), inset 0 0 0 2.5px rgba(0, 0, 0, .5);
  display: flex; align-items: center; justify-content: center;
  color: var(--accent);
  cursor: pointer;
  transition: transform .14s var(--ease), box-shadow .14s var(--ease);
}
.pin-plate:hover { transform: translate(-50%, -50%) scale(1.14); box-shadow: 0 3px 14px rgba(0, 0, 0, .7), 0 0 12px rgba(242, 201, 76, .35); }
.pin-glyph.dragging .pin-plate { transform: translate(-50%, -50%) scale(1.2); cursor: grabbing; }
.pin-plate .pin-icon, .pin-plate .icon { width: 22px; height: 22px; vertical-align: 0; }
.pin-symbol.has-note::after {
  content: '';
  position: absolute;
  top: -1px; right: -1px;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent);
  border: 1px solid #16130e;
}
.pin-comment { border-color: rgba(232, 225, 209, .65); color: var(--ink); }
.pin-comment .pin-num {
  font-family: var(--smallcaps);
  font-size: 14px;
  line-height: 1;
  padding-top: 1px;
}
.pin-comment.pin-focus { box-shadow: 0 0 0 3px var(--accent-soft), 0 0 16px rgba(242, 201, 76, .55); border-color: var(--accent); color: var(--accent); }
.pin-x {
  position: absolute;
  left: 13px; top: -13px;
  transform: translate(-50%, -50%);
  width: 21px; height: 21px;
  border-radius: 50%;
  background: rgba(13, 11, 7, .95);
  border: 1px solid var(--bad);
  color: var(--bad);
  font-size: 14px;
  line-height: 1;
  display: flex; align-items: center; justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity .14s var(--ease);
}
.pin-glyph:hover .pin-x { opacity: 1; pointer-events: auto; }
.pin-x:hover { background: var(--bad); color: #16120c; }

.pin-popover, .symbol-palette {
  position: fixed;
  z-index: 780;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 4px;
  box-shadow: var(--shadow);
  padding: 8px;
}
.pin-popover { display: flex; align-items: center; gap: 10px; padding: 7px 10px; }
.pin-popover-label {
  font-family: var(--smallcaps);
  letter-spacing: .07em;
  display: flex; align-items: center; gap: 7px;
  color: var(--ink-dim);
}
.pin-popover-label .icon { color: var(--accent); }
.pin-popover-del { display: flex; align-items: center; gap: 6px; }
.pin-popover-del .icon { width: 15px; height: 15px; }
.pin-popover-del:hover { border-color: var(--bad); color: var(--bad); }

.symbol-palette {
  display: grid;
  grid-template-columns: repeat(5, 48px);
  gap: 5px;
  padding: 10px;
}
.palette-title {
  grid-column: 1 / -1;
  font-family: var(--smallcaps);
  letter-spacing: .14em;
  font-size: 14px;
  color: var(--accent);
  padding: 0 4px 6px;
  border-bottom: 1px solid var(--line-soft);
  margin-bottom: 4px;
}
.palette-item {
  display: flex; align-items: center; justify-content: center;
  padding: 9px 0;
  border-radius: 3px;
  border: 1px solid transparent;
}
.palette-item .icon { color: var(--accent); flex: none; width: 27px; height: 27px; }
.palette-item:hover { background: var(--bg-3); border-color: var(--accent-line); }

.text-panel-status { display: flex; align-items: center; gap: 8px; flex: 1; }
.text-panel-status label {
  font-family: var(--smallcaps);
  font-size: 14px;
  letter-spacing: .12em;
  color: var(--ink-faint);
}
.text-panel-status .tb-status-sel {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 3px;
  color: var(--ink);
  font-size: 14px;
  padding: 4px 6px;
}
.ct-mark-group { display: flex; }
.ct-mark-group .ct-btn:first-child { border-radius: 3px 0 0 3px; }
.ct-mark-caret { border-radius: 0 3px 3px 0; border-left: none; padding: 5px 7px 6px; }

/* page config popover (status + page symbols, opened from grid tiles) */
.page-config-status { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.page-config-status .btn.active { border-color: var(--accent-line); color: var(--accent-bright); }
.page-config-syms { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.page-config-sym {
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  padding: 9px 4px 7px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--bg-2);
  font-size: 14px;
  color: var(--ink-faint);
}
.page-config-sym .icon { width: 19px; height: 19px; color: var(--ink-dim); }
.page-config-sym:hover { border-color: var(--accent-line); }
.page-config-sym.on { border-color: var(--accent-line); background: #201b10; color: var(--ink); }
.page-config-sym.on .icon { color: var(--accent); }
.page-config-head {
  font-family: var(--smallcaps);
  letter-spacing: .12em;
  font-size: 14px;
  color: var(--ink-dim);
  margin: 0 0 8px;
}

/* ===== 5. rail ===== */
#rail {
  position: fixed;
  left: 0; top: 0; bottom: 0;
  width: var(--rail-w);
  z-index: 600;
  display: flex;
  flex-direction: column;
  background: linear-gradient(90deg, rgba(10, 9, 7, .96), rgba(14, 12, 9, .9));
  border-right: 1px solid var(--line-soft);
  transition: transform .28s var(--ease);
}
#rail.collapsed { transform: translateX(calc(4px - var(--rail-w))); }
#rail.collapsed .rail-inner { opacity: 0; pointer-events: none; }
.rail-inner {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 0;
  scrollbar-width: none;
  transition: opacity .2s;
}
.rail-inner::-webkit-scrollbar { display: none; }
.rail-btn {
  width: 46px; height: 46px;
  margin: 1px 0;
  display: flex; align-items: center; justify-content: center;
  border-radius: 4px;
  color: var(--ink-dim);
  border: 1px solid transparent;
  transition: color .15s, border-color .15s, background .15s;
}
.rail-btn .icon { width: 29px; height: 29px; vertical-align: 0; }
.rail-btn:hover { color: var(--ink); background: var(--bg-3); }
.rail-btn.active { color: var(--accent); border-color: rgba(242, 201, 76, .4); background: #1e190e; }
.rail-sep { width: 22px; height: 1px; background: var(--line); margin: 7px 0; flex: none; }
.rail-spacer { flex: 1; min-height: 20px; }
.rail-collapse {
  position: absolute;
  right: -14px; top: 50%;
  transform: translateY(-50%);
  width: 14px; height: 52px;
  background: var(--bg-2);
  border: 1px solid var(--line-soft);
  border-left: none;
  border-radius: 0 4px 4px 0;
  color: var(--ink-faint);
  display: flex; align-items: center; justify-content: center;
}
.rail-collapse .icon { width: 11px; height: 11px; transition: transform .3s var(--ease); }
#rail.collapsed .rail-collapse .icon { transform: rotate(180deg); }
.rail-collapse:hover { color: var(--accent); }

/* ===== 6. panels: notes / comments ===== */
.side-panel {
  position: fixed;
  top: 0; bottom: 0;
  width: var(--panel-w);
  z-index: 580;
  background: linear-gradient(180deg, #131109, #100e0a 120px, var(--bg-1));
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
}
#notes-panel { right: 0; border-left: 1px solid var(--line); }
#comments-panel { right: 0; border-left: 1px solid var(--line); }
/* the right tabs sit below the top bar, like the page text */
body.topbar-on .side-panel { top: 44px; }

.panel-tabs {
  display: flex;
  align-items: stretch;
  border-bottom: 1px solid var(--line-soft);
  background: rgba(10, 9, 7, .6);
  flex: none;
}
.panel-tab {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 8px 10px;
  font-family: var(--smallcaps);
  font-size: 16px;
  letter-spacing: .12em;
  color: var(--ink-faint);
  border-bottom: 2px solid transparent;
}
.panel-tab .icon { width: 23px; height: 23px; }
.panel-tab:hover { color: var(--ink); }
.panel-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent-line);
  background: linear-gradient(180deg, rgba(242, 201, 76, .06), transparent);
}
.panel-tabs .panel-close { align-self: center; margin: 0 8px; }
.panel-head {
  display: flex; align-items: center; gap: 9px;
  padding: 13px 14px 11px;
  border-bottom: 1px solid var(--line-soft);
  flex: none;
}
.panel-head .icon { color: var(--accent); width: 17px; height: 17px; }
.panel-head h3 {
  margin: 0;
  flex: 1;
  font-family: var(--smallcaps);
  font-weight: 400;
  font-size: 19px;
  letter-spacing: .14em;
  color: var(--ink);
}
.panel-close { color: var(--ink-faint); padding: 4px; border-radius: 3px; }
.panel-close:hover { color: var(--bad); }
.panel-close .icon { width: 13px; height: 13px; }
.panel-sub {
  font-family: var(--smallcaps);
  letter-spacing: .16em;
  font-size: 14px;
  color: var(--ink-faint);
  margin: 0 0 8px;
}

/* notes: priorities */
.priority-block { padding: 14px 14px 10px; border-bottom: 1px solid var(--line-soft); flex: none; max-height: 42%; display: flex; flex-direction: column; }
.priority-list { list-style: none; margin: 0 0 8px; padding: 0; overflow-y: auto; }
.priority-item {
  display: flex; align-items: center; gap: 7px;
  padding: 5px 2px;
  border-bottom: 1px dashed var(--line-soft);
  font-size: 14px;
}
.priority-item.drag-src { opacity: .35; }
.prio-grip { color: var(--ink-faint); cursor: grab; }
.prio-grip .icon { width: 13px; height: 13px; }
.prio-check { width: 20px; height: 20px; display: flex; align-items: center; justify-content: center; color: var(--ok); }
.prio-check .icon { width: 14px; height: 14px; }
.prio-box { width: 12px; height: 12px; border: 1px solid var(--ink-faint); border-radius: 2px; display: inline-block; }
.prio-check:hover .prio-box { border-color: var(--accent); }
.prio-text { flex: 1; line-height: 1.35; }
.priority-item.done .prio-text { text-decoration: line-through; color: var(--ink-faint); }
.prio-del { color: var(--ink-faint); opacity: 0; transition: opacity .15s; }
.prio-del .icon { width: 11px; height: 11px; }
.priority-item:hover .prio-del { opacity: 1; }
.prio-del:hover { color: var(--bad); }
.priority-empty { color: var(--ink-faint); font-size: 14px; font-style: italic; padding: 4px 2px; }
.priority-add input {
  width: 100%;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 7px 10px;
  font-size: 14px;
  color: var(--ink);
}
.priority-add input:focus { outline: none; border-color: var(--accent-line); }
.priority-add input::placeholder { color: var(--ink-faint); }

/* notes: editor fills the rest */
.notes-block { flex: 1; display: flex; flex-direction: column; padding: 12px 14px 14px; min-height: 0; }
.notes-editor { flex: 1; min-height: 0; }

/* comments */
.all-rooms-toggle {
  display: flex; align-items: center; gap: 5px;
  font-size: 14px;
  color: var(--ink-faint);
  font-family: var(--smallcaps);
  letter-spacing: .08em;
  cursor: pointer;
}
.all-rooms-toggle input { accent-color: var(--accent); }
.comments-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line-soft);
  flex: none;
}
.ct-btn {
  display: flex; align-items: center; gap: 6px;
  font-size: 14px;
  letter-spacing: .06em;
  padding: 5px 9px 6px;
}
.ct-btn .icon { width: 21px; height: 21px; color: var(--accent); }
.ct-btn.active { border-color: var(--accent-line); color: var(--accent-bright); }
.comment-blank { color: var(--ink-faint); font-style: italic; cursor: pointer; }
.comment-body { cursor: pointer; }
.comment-list { list-style: none; margin: 0; padding: 10px 12px 16px; overflow-y: auto; flex: 1; }
.comment-item {
  border: 1px solid var(--line-soft);
  border-radius: 4px;
  background: var(--bg-2);
  padding: 8px 10px;
  margin-bottom: 9px;
  transition: border-color .3s;
}
.comment-item.flash { border-color: var(--accent); box-shadow: 0 0 14px rgba(242, 201, 76, .25); }
.comment-item.editing {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft), 0 0 16px rgba(242, 201, 76, .3);
}
.mini-pin-sym .icon { width: 15px; height: 15px; color: var(--accent); }
.comment-meta { display: flex; align-items: center; gap: 8px; margin-bottom: 5px; }
.comment-pin-ref { display: flex; align-items: center; gap: 6px; }
.mini-pin {
  width: 24px; height: 24px;
  border-radius: 50%;
  background: rgba(13, 11, 7, .95);
  border: 1px solid rgba(232, 225, 209, .55);
  color: var(--ink);
  font-family: var(--smallcaps);
  font-size: 14px;
  display: flex; align-items: center; justify-content: center;
}
.comment-pin-ref:hover .mini-pin { border-color: var(--accent); color: var(--accent); }
.comment-room { font-family: var(--smallcaps); font-size: 14px; letter-spacing: .06em; color: var(--ink-dim); }
.comment-date { flex: 1; font-size: 16px; color: var(--ink-faint); font-family: var(--mono); }
.comment-tools { display: flex; gap: 2px; opacity: 0; transition: opacity .15s; }
.comment-item:hover .comment-tools { opacity: 1; }
.comment-tools button { color: var(--ink-faint); padding: 3px; border-radius: 3px; font-size: 14px; }
.comment-tools button:hover { color: var(--accent); }
.comment-tools .comment-del:hover, .comment-del.confirming { color: var(--bad); }
.comment-tools .icon { width: 13px; height: 13px; }
.comment-body { font-size: 22px; line-height: 1.128em; overflow-wrap: break-word; }
.comment-body p { margin: 0 0 .4em; }
.comment-body p:last-child { margin-bottom: 0; }
.comment-empty { color: var(--ink-faint); font-size: 14px; text-align: center; padding: 26px 8px; line-height: 2; }
.comment-empty .icon { width: 14px; height: 14px; color: var(--accent); }
.composer { padding: 12px; border-bottom: 1px solid var(--line-soft); flex: none; }
.composer-actions { display: flex; gap: 8px; margin-top: 9px; justify-content: flex-end; }

/* ===== 7. top bar / breadcrumb / drawer ===== */
#top-bar {
  position: fixed;
  top: 0;
  left: var(--rail-w); right: 0;
  z-index: 560;
  height: 44px;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 10px 0 16px;
  background: linear-gradient(180deg, rgba(10, 9, 7, .95), rgba(10, 9, 7, .82));
  border-bottom: 1px solid var(--line-soft);
  backdrop-filter: blur(4px);
  transition: transform .28s var(--ease);
}
body.rail-collapsed #top-bar { left: 4px; }
#top-bar.collapsed { transform: translateY(-100%); }
.topbar-collapse {
  position: absolute;
  bottom: -15px;
  left: 50%;
  transform: translateX(-50%);
  width: 54px;
  height: 15px;
  background: var(--bg-2);
  border: 1px solid var(--line-soft);
  border-top: none;
  border-radius: 0 0 5px 5px;
  color: var(--ink-faint);
  display: flex;
  align-items: center;
  justify-content: center;
}
.topbar-collapse:hover { color: var(--accent); }
.topbar-collapse .icon { width: 11px; height: 11px; transform: rotate(90deg); transition: transform .3s var(--ease); }
#top-bar.collapsed .topbar-collapse .icon { transform: rotate(-90deg); }

.tb-jump {
  width: 92px;
  background: #000;
  color: var(--ink);
  border: 1px solid var(--accent-line);
  border-radius: 3px;
  padding: 5px 9px;
  font-family: var(--mono);
  font-size: 14px;
}
.tb-jump:focus { outline: none; box-shadow: 0 0 0 1px var(--accent-soft); }
.tb-jump::-webkit-outer-spin-button, .tb-jump::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.tb-jump::placeholder { color: var(--ink-faint); }
.tb-btn {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 4px;
  color: var(--ink-dim);
  flex: none;
}
.tb-btn:hover { color: var(--accent); background: var(--bg-3); }
.tb-btn .icon { width: 17px; height: 17px; }
/* the page grid is the most important control — double-size icon */
.tb-grid-big { width: 44px; height: 40px; color: var(--accent); }
.tb-grid-big .icon { width: 34px; height: 34px; }
.tb-grid-big:hover { color: var(--accent-bright); box-shadow: inset 0 0 0 1px var(--accent-line); }
/* fixed width so the next-page arrow never jumps as titles change */
.tb-title {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 10px;
  margin: 0 8px;
  width: 275px;
  flex: none;
}
.tb-page {
  font-family: var(--display);
  font-size: 30px;
  letter-spacing: .12em;
  color: #ebd389;
  white-space: nowrap;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tb-folio { font-size: 14px; color: var(--ink-faint); font-family: var(--mono); white-space: nowrap; }
.tb-status { display: flex; align-items: center; gap: 7px; margin-left: 10px; }
.tb-status label {
  font-family: var(--smallcaps);
  font-size: 14px;
  letter-spacing: .12em;
  color: var(--ink-faint);
}
.tb-status-sel {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 3px;
  color: var(--ink);
  font-size: 14px;
  padding: 4px 6px;
}
.tb-status-sel:focus { outline: none; border-color: var(--accent-line); }
.tb-spacer { flex: 1; }
.tb-back {
  font-family: var(--smallcaps);
  font-size: 15px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--ink-dim);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 7px 16px 3px;   /* optical centering: the small-caps face rides high */
  margin-right: 8px;
  white-space: nowrap;
}
.tb-back:hover { color: var(--accent-bright); border-color: var(--accent-line); }
.tb-last {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px 5px;
  margin-right: 6px;
  font-family: var(--smallcaps);
  font-size: 14px;
  letter-spacing: .08em;
  color: var(--ink-dim);
  border: 1px dashed var(--line);
  border-radius: 3px;
  white-space: nowrap;
}
.tb-last .icon { width: 18px; height: 18px; color: var(--accent); }
.tb-last:hover { color: var(--accent-bright); border-color: var(--accent-line); }

/* page-text panel: a left-hand page, like the book (text left, image right).
   On narrow screens it reverts to a bottom sheet (media query below). */
#text-drawer {
  --serif: 'Dair', 'Palatino Linotype', 'Book Antiqua', Palatino, Georgia, serif;
  position: fixed;
  left: var(--rail-w);
  top: 0; bottom: 0;
  width: var(--text-panel-w);
  z-index: 555;   /* below the top bar so neither hides the other */
  display: flex;
  flex-direction: column;
  background: linear-gradient(172deg, #17140d, #121009 140px, #100e0a);
  border-right: 1px solid rgba(242, 201, 76, .28);
  box-shadow: var(--shadow);
}
body.rail-collapsed #text-drawer { left: 4px; }
/* the page text starts below the top bar — the two never overlap */
body.topbar-on #text-drawer { top: 44px; }

/* sticky footer: the way to ask the house for help */
.clue-btn {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 11px;
  margin: 0;
  padding: 15px 16px;
  font-family: var(--smallcaps);
  font-size: 19px;
  letter-spacing: .16em;
  color: var(--accent-bright);
  background: linear-gradient(180deg, #241d10, #1a1610);
  border-top: 1px solid var(--accent-line);
  box-shadow: 0 -6px 18px rgba(0, 0, 0, .45);
  transition: filter .2s var(--ease);
}
.clue-btn .icon { width: 19px; height: 19px; }
.clue-btn:hover { filter: brightness(1.15); }

/* which plate sits on the stage: room art, book text page, or game art */
.plate-switch {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
}
.plate-btn {
  flex: 1;
  padding: 9px 6px 10px;
  font-family: var(--smallcaps);
  font-size: 14px;
  letter-spacing: .07em;
  color: var(--ink-dim);
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 3px;
  transition: color .18s var(--ease), border-color .18s var(--ease), background .18s var(--ease);
}
.plate-btn:hover { color: var(--accent-bright); border-color: var(--accent-line); }
/* the colour plate carries a name and a caveat, so it gets two lines */
.plate-btn-color {
  display: flex;
  flex-direction: column;
  gap: 2px;
  line-height: 1.2;
  flex: 1.5;
}
.plate-btn-label { display: block; }
.plate-sub {
  display: block;
  font-family: var(--sans);
  font-size: 12px;
  letter-spacing: 0;
  color: var(--ink-faint);
}
.plate-btn-color:hover .plate-sub, .plate-btn-color.active .plate-sub { color: var(--ink-dim); }
.plate-btn.active {
  color: var(--accent-bright);
  border-color: var(--accent-line);
  background: #221c11;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .5);
}

.text-orig-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 13px 14px;
  margin-bottom: 16px;
  font-family: var(--smallcaps);
  font-size: 16px;
  letter-spacing: .1em;
  color: var(--accent);
  background: #1f1a10;
  border: 1px solid var(--accent-line);
  border-radius: 3px;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .5), inset 0 0 0 2px rgba(242, 201, 76, .08);
  transition: filter .2s var(--ease), box-shadow .2s var(--ease);
}
.text-orig-btn .icon { width: 17px; height: 17px; }
.extra-clues-btn { margin-top: 10px; }
.text-orig-btn:hover { filter: brightness(1.12); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .5), 0 0 18px rgba(242, 201, 76, .16); }
.text-orig-btn.active { background: #2a2212; color: var(--accent-bright); }

/* the alt plate is the book's text page — artwork-space overlays hide */
#world.alt-scan #door-layer, #world.alt-scan #pins-layer { display: none !important; }

/* Hints & Solutions: a left panel over the page text, never over the art */
#hints-panel {
  --serif: 'Dair', 'Palatino Linotype', 'Book Antiqua', Palatino, Georgia, serif;
  position: fixed;
  left: var(--rail-w);
  top: 0; bottom: 0;
  width: var(--text-panel-w);
  z-index: 585;
  display: flex;
  flex-direction: column;
  background: linear-gradient(172deg, #18140c, #121009 140px, #100e0a);
  border-right: 1px solid rgba(242, 201, 76, .4);
  box-shadow: var(--shadow);
}
body.rail-collapsed #hints-panel { left: 4px; }
body.topbar-on #hints-panel { top: 44px; }
#hints-panel .panel-head h3 {
  font-size: 17px;
  letter-spacing: .1em;
  color: var(--accent);
}
.hints-panel-body { flex: 1; overflow-y: auto; padding: 14px 16px 20px; }
@media (max-width: 760px) {
  #hints-panel { left: 0; right: 0; top: auto; bottom: 0; width: auto; height: 62vh; }
}

/* a door the book hid, standing revealed */
.door-shape.door-hidden {
  stroke: var(--accent-line);
  stroke-width: 1.6;
  stroke-dasharray: 7 5;
  fill: rgba(242, 201, 76, .08);
}
.door-shape.door-hidden:hover { fill: var(--door-fill); stroke: var(--accent-bright); }
.text-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 18px 22px 26px;
}
.text-panel-body .prose { font-size: var(--reading-size); line-height: var(--reading-lh); letter-spacing: var(--reading-ls); }
.text-panel-body .prose p:last-child { margin-bottom: 0; }
.text-panel-body::after {
  content: '';
  display: block;
  margin: 26px auto 0;
  width: 7px; height: 7px;
  transform: rotate(45deg);
  border: 1px solid var(--accent-line);
}

@media (max-width: 760px) {
  #text-drawer {
    left: 0; right: 0; top: auto; bottom: 0;
    width: auto;
    height: 38vh;
    border-right: none;
    border-top: 1px solid rgba(242, 201, 76, .32);
  }
  body.rail-collapsed #text-drawer { left: 0; }
  body.text-open #notes-panel, body.rail-collapsed.text-open #notes-panel { left: var(--rail-w); }
}

/* view tools — bottom center */
#view-tools {
  position: fixed;
  left: 50%; bottom: 14px;
  transform: translateX(-50%);
  z-index: 565;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 5px 8px;
  background: rgba(14, 12, 8, .8);
  border: 1px solid var(--line);
  border-radius: 4px;
  box-shadow: var(--shadow), inset 0 0 0 1px rgba(0, 0, 0, .4);
  backdrop-filter: blur(7px);
}
.vt-grid-float {
  position: absolute;
  right: -66px;
  top: 50%;
  transform: translateY(-50%);
  width: 56px; height: 52px;
  background: rgba(14, 12, 8, .8);
  border: 1px solid var(--line);
  border-radius: 4px;
  backdrop-filter: blur(7px);
  color: var(--accent);
}
.vt-btn.vt-grid-float .icon { width: 40px; height: 40px; }
.text-panel-none {
  font-family: var(--serif);
  font-style: italic;
  font-size: 15px;
  color: var(--ink-faint);
  margin: 0;
}
/* the directions scan sits slightly crooked; nudge it straight */
#world img#room-img.tilt-fix { transform: rotate(.5deg); }
.vt-grid-float:hover { color: var(--accent-bright); box-shadow: inset 0 0 0 1px var(--accent-line); }
.vt-btn {
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 4px;
  color: var(--ink-dim);
}
.vt-btn:hover { color: var(--accent); background: var(--bg-3); }
.vt-btn .icon { width: 22px; height: 22px; }
.vt-sep { width: 1px; height: 20px; background: var(--line); margin: 0 5px; }
#view-tools { transition: transform .28s var(--ease); }
#view-tools.collapsed { transform: translateX(-50%) translateY(calc(100% + 16px)); }
.viewtools-collapse {
  position: absolute;
  top: -15px;
  left: 50%;
  transform: translateX(-50%);
  width: 54px;
  height: 15px;
  background: var(--bg-2);
  border: 1px solid var(--line-soft);
  border-bottom: none;
  border-radius: 5px 5px 0 0;
  color: var(--ink-faint);
  display: flex;
  align-items: center;
  justify-content: center;
}
.viewtools-collapse:hover { color: var(--accent); }
.viewtools-collapse .icon { width: 11px; height: 11px; transform: rotate(-90deg); transition: transform .3s var(--ease); }
#view-tools.collapsed .viewtools-collapse .icon { transform: rotate(90deg); }
@media (max-width: 760px) {
  body.text-open #view-tools { bottom: calc(38vh + 12px); }
}

/* ===== 8. page grid + modals ===== */
#modal-root { position: fixed; inset: 0; z-index: 800; }
.modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(6, 5, 3, .72);
  backdrop-filter: blur(3px);
  animation: fadein .22s var(--ease);
}
.modal-frame {
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  width: min(560px, calc(100vw - 48px));
  max-height: min(82vh, 900px);
  display: flex;
  flex-direction: column;
  background: var(--bg-1);
  border: 1px solid var(--line);
  box-shadow: var(--shadow), inset 0 0 0 1px rgba(0, 0, 0, .5), inset 0 0 0 2px rgba(232, 225, 209, .03);
  border-radius: 4px;
  animation: modalin .26s var(--ease);
}
.modal-frame.wide { width: min(780px, calc(100vw - 48px)); }
@keyframes modalin { from { opacity: 0; transform: translate(-50%, -47%) scale(.985); } }
@keyframes fadein { from { opacity: 0; } }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px 12px;
  border-bottom: 1px solid var(--line-soft);
  position: relative;
}
.modal-head::after {
  content: '';
  position: absolute; left: 50%; bottom: -4px;
  width: 7px; height: 7px;
  transform: translateX(-50%) rotate(45deg);
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-top: none; border-left: none;
}
.modal-head h2 {
  margin: 0;
  font-family: var(--smallcaps);
  font-weight: 400;
  font-size: 21px;
  letter-spacing: .1em;
  color: var(--accent);
}
.modal-close { color: var(--ink-faint); font-size: 15px; padding: 4px 8px; border-radius: 3px; }
.modal-close:hover { color: var(--bad); }
.modal-body { padding: 18px 20px; overflow-y: auto; }
.modal-actions {
  display: flex; gap: 10px; justify-content: flex-end;
  padding: 12px 18px 16px;
  border-top: 1px solid var(--line-soft);
}
.about-primary {
  margin: 4px 0 16px;
  padding: 12px 16px;
  border: 1px solid rgba(242, 201, 76, .45);
  border-radius: 3px;
  background: radial-gradient(320px 70px at 50% 0%, var(--accent-soft), transparent 75%), var(--bg-2);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .35);
  font-family: var(--smallcaps);
  font-size: 16px;
  letter-spacing: .06em;
}
.about-colophon { font-size: 14px; color: var(--ink-dim); margin-top: 14px; }
.about-credits {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--line-soft);
}
.about-credits-title {
  font-family: var(--smallcaps);
  font-size: 16px;
  letter-spacing: .12em;
  color: var(--accent);
  margin: 0 0 7px;
}
.about-credits p { font-size: 14px; line-height: 1.6; color: var(--ink-dim); margin: 0 0 .6em; }
.about-credits p:last-child { margin-bottom: 0; }
.about-credits b { color: var(--ink); font-weight: 600; }

/* settings */
.set-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 13px 2px;
  border-bottom: 1px solid var(--line-soft);
}
.set-row:last-child { border-bottom: none; }
.set-info { flex: 1; }
.set-name {
  display: block;
  font-family: var(--smallcaps);
  font-size: 17px;
  letter-spacing: .1em;
  color: var(--accent);
  margin-bottom: 3px;
}
.set-desc { display: block; font-size: 14px; line-height: 1.55; color: var(--ink-dim); max-width: 420px; }
.set-group { display: flex; gap: 6px; flex: none; }
.set-row .btn { white-space: nowrap; text-decoration: none; }
.set-row .btn.active { border-color: var(--accent-line); color: var(--accent-bright); }

/* larger reading mode: curated bumps, no compounding.
   .extra-list li and .hint-item read --reading-size directly (bumped once,
   above, via body.font-large { --reading-size }). .text-panel-body .prose
   needs its own higher-specificity rule below so the generic .prose bump
   on this line doesn't win over it and clobber the shared variable. */
body.font-large .prose { font-size: 21px; }
body.font-large .text-panel-body .prose { font-size: var(--reading-size); }
body.font-large .ql-editor { font-size: 27px; }
body.font-large .comment-body { font-size: 27px; }
body.font-large .comment-date { font-size: 19px; }
body.font-large .hint-clue-title { font-size: 27px; }
body.font-large .hint-sol-input { font-size: 19px; }
body.font-large .hints-gate-note, body.font-large .hints-progress-warning { font-size: 17px; }
body.font-large .panel-tab { font-size: 24px; }
body.font-large .btn { font-size: 27px; }
body.font-large .menu-btn-label { font-size: 24px; }
body.font-large .menu-btn-sub, body.font-large .menu-hint, body.font-large .menu-footer { font-size: 17px; }
body.font-large .set-desc { font-size: 17px; }
body.font-large .priority-item { font-size: 17px; }
body.font-large .comment-empty, body.font-large .draw-hint { font-size: 17px; }
body.font-large .tb-page { font-size: 37.5px; }
body.font-large .paths-sub { font-size: 19px; }
.about-primary-sub { display: block; margin-top: 4px; font-family: var(--sans); font-size: 14px; letter-spacing: 0; color: var(--ink-dim); }
.about-help-title {
  font-family: var(--smallcaps);
  font-size: 17px;
  letter-spacing: .14em;
  color: var(--accent);
  margin: 0 0 8px;
}
.about-help { margin-top: 0; }
.about-help li { margin-bottom: .55em; }

.contest-note {
  font-family: var(--serif);
  font-style: italic;
  color: var(--ink-dim);
  margin: 0 0 10px;
}
.contest-toggle {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 12px;
}
.contest-open-page { font-size: 14px; }
.contest-scan img {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: var(--bg-1);
  cursor: zoom-in;
}
.contest-toggle .icon { width: 14px; height: 14px; vertical-align: -2px; }

/* hints gate: titles stay face-down until asked for */
.hints-gate { text-align: center; padding: 26px 18px 20px; }
.hints-gate-lead {
  font-family: var(--serif);
  font-style: italic;
  font-size: 16px;
  color: var(--ink);
  margin: 0 0 16px;
}
.hints-gate-btn { padding: 11px 22px 12px; }
.hints-gate-note {
  max-width: 380px;
  margin: 14px auto 0;
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink-faint);
}

.grid-modal-frame { width: min(1060px, calc(100vw - 48px)) !important; }
.grid-legend {
  display: flex; flex-wrap: wrap; gap: 14px;
  margin-bottom: 14px;
  font-size: 14px;
  color: var(--ink-dim);
  font-family: var(--smallcaps);
  letter-spacing: .06em;
}
.legend-swatch {
  display: inline-block;
  width: 9px; height: 9px;
  border-radius: 50%;
  margin-right: 5px;
  background: var(--line);
}
.legend-item.st-unsolved .legend-swatch { background: var(--st-unsolved); }
.legend-item.st-progress .legend-swatch { background: var(--st-progress); }
.legend-item.st-deadend .legend-swatch { background: var(--st-deadend); }
.legend-item.st-onpath .legend-swatch { background: var(--st-onpath); }
.legend-item.st-solved .legend-swatch { background: var(--st-solved); }
.legend-item.st-important .legend-swatch { background: var(--st-important); }

.page-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 10px;
}
.page-grid.specials { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); margin-bottom: 12px; }
.grid-tile {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--bg-2);
  padding: 5px 5px 3px;
  transition: border-color .15s var(--ease), transform .15s var(--ease);
}
.grid-tile:hover { border-color: var(--accent-line); transform: translateY(-2px); }
.grid-tile.current { box-shadow: 0 0 0 2px var(--accent-soft), inset 0 0 0 1px var(--accent-line); }
.grid-tile.st-unsolved { border-color: var(--st-unsolved); }
.grid-tile.st-progress { border-color: var(--st-progress); }
.grid-tile.st-deadend { border-color: var(--st-deadend); }
.grid-tile.st-onpath { border-color: var(--st-onpath); }
.grid-tile.st-solved { border-color: var(--st-solved); }
.grid-tile.st-important { border-color: var(--st-important); }
.tile-visual { display: block; aspect-ratio: 5 / 4; overflow: hidden; background: var(--bg-1); }
.tile-visual img { width: 100%; height: 100%; object-fit: cover; filter: saturate(.9); }
.grid-tile:hover .tile-visual img { filter: none; }
.tile-text-stand {
  display: flex; align-items: center; justify-content: center;
  height: 100%;
  font-family: var(--smallcaps);
  letter-spacing: .08em;
  color: var(--ink-dim);
  font-size: 14px;
  text-align: center;
  padding: 4px;
}
.tile-label {
  display: block;
  text-align: center;
  font-family: var(--smallcaps);
  font-size: 14px;
  letter-spacing: .06em;
  padding-top: 3px;
  color: var(--ink-dim);
}
.grid-tile.visited .tile-label { color: var(--ink); }
.tile-dot {
  position: absolute; top: 8px; left: 8px;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--ink-faint);   /* visited marker, deliberately quiet */
}
.tile-sol {
  position: absolute;
  bottom: 4px; right: 5px;
  font-family: var(--mono);
  font-size: 14px;
  padding: 0 5px 1px;
  border-radius: 3px;
  background: rgba(10, 9, 6, .85);
  border: 1px solid var(--line);
}
.tile-sol.sol-some { color: #c49a6c; border-color: #6b5537; }
.tile-sol.sol-all { color: var(--accent-bright); border-color: var(--accent-line); }
.sol-count { font-family: var(--mono); font-size: 15px; padding-left: 4px; }
.sol-count.sol-none { color: var(--ink-faint); }
.sol-count.sol-some { color: #c49a6c; }
.sol-count.sol-all { color: var(--accent-bright); }
.tile-count {
  position: absolute; top: 6px; right: 6px;
  min-width: 22px; height: 22px;
  border-radius: 11px;
  background: var(--bg-0);
  border: 1px solid var(--line);
  color: var(--ink-dim);
  font-size: 14px;
  font-family: var(--mono);
  display: flex; align-items: center; justify-content: center;
  padding: 0 4px;
}
.tile-badges {
  position: absolute; bottom: 26px; left: 6px; right: 6px;
  display: flex; gap: 2px; justify-content: flex-end;
}
.tile-badges .icon { width: 14px; height: 14px; color: var(--accent); filter: drop-shadow(0 1px 2px rgba(0,0,0,.9)); }
.tile-config {
  position: absolute;
  bottom: 4px; left: 4px;
  width: 20px; height: 20px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 3px;
  color: var(--ink-faint);
  opacity: 0;
  transition: opacity .15s var(--ease), color .15s var(--ease);
}
.grid-tile:hover .tile-config { opacity: 1; }
.tile-config:hover { color: var(--accent); background: rgba(0, 0, 0, .55); }
.tile-config .icon { width: 14px; height: 14px; }
/* hover preview: the destination thumb at its natural size */
.tile-preview {
  position: fixed;
  z-index: 860;
  pointer-events: none;
  background: rgba(12, 10, 7, .97);
  border: 1px solid var(--accent-line);
  border-radius: 3px;
  overflow: hidden;
  box-shadow: 0 10px 40px rgba(0, 0, 0, .75);
}
.tile-preview img {
  display: block;
  width: auto;
  max-width: min(494px, 46vw);
  max-height: 46vh;
  height: auto;
}
.tile-preview span {
  display: block;
  padding: 4px 10px 5px;
  font-family: var(--smallcaps);
  font-size: 14px;
  letter-spacing: .1em;
  color: var(--accent);
  border-top: 1px solid var(--line-soft);
}

/* ===== 9. paths screen (step 8 — subagent section, append only) ===== */

/* ===== 10. quiz (step 9 — subagent section, append only) ===== */

/* ===== 11. quill dark skin ===== */
.ql-toolbar.ql-snow {
  border: 1px solid var(--line);
  border-radius: 3px 3px 0 0;
  background: var(--bg-2);
  padding: 5px 6px;
}
.ql-container.ql-snow {
  border: 1px solid var(--line);
  border-top: none;
  border-radius: 0 0 3px 3px;
  background: #100e0a;
  font-family: var(--serif);
  font-size: 14.5px;
  color: var(--ink);
  height: auto;
}
.notes-editor .ql-container.ql-snow { flex: 1; min-height: 120px; display: flex; flex-direction: column; }
.notes-editor .ql-editor { flex: 1; }
.composer-editor .ql-editor { min-height: 96px; max-height: 200px; }
.ql-editor { font-size: 22px; line-height: 1.128em; }
.ql-editor.ql-blank::before { color: var(--ink-faint); font-style: italic; }
.ql-snow .ql-stroke { stroke: var(--ink-dim); }
.ql-snow .ql-fill { fill: var(--ink-dim); }
.ql-snow .ql-picker { color: var(--ink-dim); }
.ql-snow.ql-toolbar button:hover .ql-stroke, .ql-snow.ql-toolbar button.ql-active .ql-stroke,
.ql-snow .ql-picker-label:hover .ql-stroke { stroke: var(--accent); }
.ql-snow.ql-toolbar button:hover .ql-fill, .ql-snow.ql-toolbar button.ql-active .ql-fill { fill: var(--accent); }
.ql-snow .ql-picker-label:hover, .ql-snow .ql-picker-label.ql-active,
.ql-snow .ql-picker-item:hover, .ql-snow .ql-picker-item.ql-selected { color: var(--accent); }
.ql-snow .ql-picker-options {
  background: var(--bg-3);
  border: 1px solid var(--line) !important;
  box-shadow: var(--shadow);
}
.ql-snow .ql-picker.ql-expanded .ql-picker-label { border-color: var(--line); }
.ql-snow .ql-tooltip {
  background: var(--bg-3);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  color: var(--ink);
}
.ql-snow .ql-tooltip input[type=text] { background: var(--bg-1); border: 1px solid var(--line); color: var(--ink); }
.ql-snow .ql-editor blockquote { border-left: 2px solid var(--accent-line); color: var(--ink-dim); }
/* app-wide 14px text floor applies to Quill sizes + chrome too */
.ql-size-small { font-size: 14px; }
.ql-snow .ql-picker, .ql-snow .ql-tooltip { font-size: 14px; }

/* ===== 12. hints ===== */
.hint-clue {
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--bg-2);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .35);
  padding: 12px 15px 13px;
  margin-bottom: 12px;
}
.hint-clue-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  padding-bottom: 7px;
  margin-bottom: 9px;
  border-bottom: 1px solid var(--line-soft);
}
.hint-clue-name {
  font-family: var(--smallcaps);
  font-size: 16px;
  letter-spacing: .12em;
  color: var(--accent);
  white-space: nowrap;
}
.hint-clue-title {
  font-family: var(--smallcaps);
  font-size: 22px;
  line-height: 1.128em;
  letter-spacing: .1em;
  color: var(--ink-dim);
  transition: filter .25s var(--ease);
}
.hint-clue-title.veiled {
  filter: blur(5px);
  user-select: none;
  pointer-events: none;
}
.hint-eye {
  width: 26px; height: 26px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 3px;
  color: var(--ink-faint);
}
.hint-eye:hover { color: var(--accent); background: var(--bg-3); }
.hint-eye .icon { width: 16px; height: 16px; }
.hint-head-spacer { flex: 1; }
.hint-conceal-one {
  font-family: var(--smallcaps);
  font-size: 14px;
  letter-spacing: .08em;
  color: var(--ink-faint);
  text-decoration: underline;
  text-underline-offset: 3px;
  white-space: nowrap;
}
.hint-conceal-one:hover { color: var(--bad); }
.hint-sol-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  padding-top: 9px;
  border-top: 1px dashed var(--line-soft);
  flex-wrap: wrap;
}
.hint-sol-input {
  flex: 1;
  min-width: 150px;
  background: #000;
  border: 1px solid var(--line);
  border-radius: 3px;
  color: var(--ink);
  font-family: var(--serif);
  font-size: 15px;
  padding: 7px 10px;
}
.hint-sol-input:focus { outline: none; border-color: var(--accent-line); }
.hint-sol-input[data-ok="1"] { border-color: var(--accent-line); }
.hint-sol-check { font-size: 14px; white-space: nowrap; }
.hint-sol-result { font-family: var(--smallcaps); font-size: 15px; letter-spacing: .06em; }
.hint-sol-result.ok { color: var(--accent-bright); }
.hint-sol-result.bad { color: var(--bad); }
.hint-sol-result i { font-family: var(--serif); font-style: italic; color: var(--ink-dim); letter-spacing: 0; }
.hint-sol-reveal { margin-top: 7px; }
.hint-show-sol {
  font-family: var(--smallcaps);
  font-size: 14px;
  letter-spacing: .09em;
  color: var(--ink-faint);
  border: 1px dashed var(--line);
  border-radius: 3px;
  padding: 4px 11px 5px;
}
.hint-show-sol:hover { color: var(--accent); border-color: var(--accent-line); }
.hint-show-sol.confirming { color: var(--bad); border-color: var(--bad); border-style: solid; }

/* community observations + red herrings, each gated */
.extra-blocks { margin-top: 4px; }
.extra-sec {
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--bg-2);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .3);
  padding: 12px 14px 13px;
  margin-bottom: 12px;
}
.extra-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 7px;
  margin-bottom: 9px;
  border-bottom: 1px solid var(--line-soft);
}
.extra-title {
  font-family: var(--smallcaps);
  font-size: 16px;
  letter-spacing: .12em;
  color: var(--accent);
}
.extra-toggle {
  font-family: var(--smallcaps);
  font-size: 14px;
  letter-spacing: .09em;
  color: var(--ink-faint);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.extra-toggle:hover { color: var(--bad); }
.extra-warn {
  font-family: var(--serif);
  font-style: italic;
  font-size: 14px;
  line-height: 1.55;
  color: var(--ink-dim);
  margin: 0 0 10px;
}
.extra-open { font-size: 14px; }
.extra-open[data-extra-show="clues"]:hover { border-color: var(--bad); color: var(--bad); }
.extra-list { margin: 0; padding-left: 22px; }
.extra-list li {
  font-family: var(--serif);
  font-size: var(--reading-size);
  line-height: var(--reading-lh);
  letter-spacing: var(--reading-ls);
  color: var(--ink);
  margin-bottom: 8px;
}
.extra-list li::marker { color: var(--accent); font-family: var(--mono); font-size: 20px; }
.extra-credit {
  font-family: var(--sans);
  font-size: 14px;
  color: var(--ink-faint);
  white-space: nowrap;
}
.extra-source { font-size: 14px; color: var(--ink-faint); margin: 0 0 12px; line-height: 1.5; }

.hints-progress { margin-bottom: 14px; }
.hints-progress-label {
  font-family: var(--smallcaps);
  font-size: 14px;
  letter-spacing: .1em;
  color: var(--ink-dim);
  margin-bottom: 6px;
}
.hints-progress-track {
  height: 8px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--bg-1);
  overflow: hidden;
}
.hints-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #8a6d1c, var(--accent));
  transition: width .4s var(--ease);
}
.hint-progress-toggle {
  align-self: flex-start;
  font-family: var(--smallcaps);
  font-size: 14px;
  letter-spacing: .09em;
  color: var(--ink-dim);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.hint-progress-toggle:hover { color: var(--accent); }
.hints-progress-warning { font-size: 14px; color: var(--ink-faint); line-height: 1.5; }
.hint-progress { font-family: var(--mono); font-size: 14px; color: var(--ink-faint); }
.hint-none { margin: 0 0 9px; font-family: var(--serif); font-style: italic; font-size: 14px; color: var(--ink-faint); }
.hint-list { margin: 0 0 10px; padding-left: 22px; }
.hint-item {
  font-family: var(--serif);
  font-size: var(--reading-size);
  line-height: var(--reading-lh);
  letter-spacing: var(--reading-ls);
  color: var(--ink);
  margin-bottom: 6px;
}
.hint-item::marker { color: var(--ink-faint); font-family: var(--mono); font-size: 20px; }
.hint-item.hint-solution {
  color: var(--accent-bright);
  border-left: 2px solid var(--accent-line);
  padding-left: 9px;
  margin-left: -11px;
  list-style: none;
}
.hint-reveal { font-size: 14px; }
.hint-reveal-solution { border-color: rgba(242, 201, 76, .45); color: var(--accent); }
.hint-reveal.confirming { border-color: var(--bad); color: var(--bad); }
.hint-doneline { font-family: var(--smallcaps); font-size: 14px; letter-spacing: .1em; color: var(--ink-faint); }
.hints-foot {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-top: 4px;
  padding-top: 10px;
  border-top: 1px solid var(--line-soft);
}
.hint-conceal {
  align-self: flex-start;
  font-family: var(--smallcaps);
  font-size: 14px;
  letter-spacing: .09em;
  color: var(--ink-faint);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.hint-conceal:hover { color: var(--bad); }
.hints-credit { font-size: 14px; color: var(--ink-faint); }

/* ===== 13. toasts ===== */
#toast-root {
  position: fixed;
  left: 50%; bottom: 26px;
  transform: translateX(-50%);
  z-index: 950;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  pointer-events: none;
}
.toast {
  font-family: var(--smallcaps);
  letter-spacing: .05em;
  font-size: 28px;
  line-height: 1.25;
  background: var(--accent);
  color: #57503e;
  border: 1px solid #b8952f;
  border-left: 4px solid #8a6d1c;
  padding: 12px 24px 14px;
  border-radius: 4px;
  box-shadow: var(--shadow);
  max-width: min(760px, calc(100vw - 40px));
  text-align: center;
  animation: toastin .3s var(--ease);
}
.toast .toast-undo-btn { color: #2c2716; border-color: #8a6d1c; }
.toast-out { opacity: 0; transition: opacity .45s; }
@keyframes toastin { from { opacity: 0; transform: translateY(8px); } }
