/* F1NDX Quests.
   Colors are sampled from the Quests art: the warm black behind it, the orange of the frame and of "QUESTS",
   the parchment of "F1NDX", and the sage teal of the keyhole and star.
   Cinzel echoes the wordmark and is only used for names (page titles, quest titles, step titles).
   Atkinson Hyperlegible does all the reading work. */

@font-face { font-family: "Cinzel"; src: url("/static/fonts/cinzel.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Atkinson"; src: url("/static/fonts/atkinson-400.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Atkinson"; src: url("/static/fonts/atkinson-700.woff2") format("woff2"); font-weight: 700; font-display: swap; }

:root {
  --abyss: #0B0A09;
  --rail: #0F0D0B;
  --chart: #16130F;
  --chart-2: #1D1914;
  --chart-3: #27211A;
  --line: #2E2720;
  --line-2: #3F352A;
  --parchment: #EBDCC0;
  --dim: #ADA18D;
  --faint: #81776A;
  --brass: #C87A26;
  --brass-hi: #E8A75E;
  --brass-ink: #170F05;
  --teal: #7FAE9A;
  --verdigris: #9DB36B;
  --ember: #CF5A3E;
  --amber: #E0B457;

  --display: "Cinzel", "Trajan Pro", Georgia, serif;
  --body: "Atkinson", "Segoe UI", system-ui, sans-serif;

  /* Surfaces that are only used for one job */
  --well: #0E0C0A;          /* inside of inputs */
  --chart-sel: #251E16;     /* selected map step */
  --line-3: #54473A;        /* hovered input edge */
  --brass-top: #E09A4C;     /* lit top edge of brass buttons */
  --brass-top-hi: #F2BE7E;
  --brass-lo: #8A5318;

  /* Status: text, edge, quiet fill, solid fill (toasts sit over content so they need a solid one) */
  --ok-ink: #D5E2BC;   --ok-edge: #47552C;   --ok-fill: rgba(157, 179, 107, 0.07);   --ok-solid: #161A0E;
  --bad-ink: #F3CDBE;  --bad-edge: #6E2C1D;  --bad-fill: rgba(207, 90, 62, 0.08);  --bad-solid: #26110B;
  --warn-ink: #F1DCAA; --warn-edge: #5E4A20; --warn-fill: rgba(224, 180, 87, 0.07);

  /* Type scale: seven sizes, nothing in between */
  --t-xs: 12px;    /* stamps, map labels, fine print */
  --t-s: 13px;     /* hints, captions, table heads */
  --t-m: 14px;     /* UI text: nav, buttons, labels, rows */
  --t-body: 15px;  /* reading text, inputs, section headings */
  --t-l: 18px;     /* quest titles in lists, panel names */
  --t-xl: 24px;    /* step names, big numbers */
  --t-2xl: 32px;   /* page titles */

  /* Motion: three speeds */
  --quick: 0.15s;   /* hover and press */
  --settle: 0.25s;  /* things opening, toasts */
  --draw: 1.1s;     /* the door appearing, once */

  --pad: 24px;     /* inner padding of every panel */
  --r-s: 4px;
  --r: 6px;
  --r-l: 10px;
  /* A warm top highlight and a deep, soft drop. Panels sit on the night, they don't float in grey fog. */
  --lift: inset 0 1px 0 rgba(235, 220, 192, 0.045), 0 1px 0 rgba(0, 0, 0, 0.45), 0 18px 40px -24px rgba(0, 0, 0, 0.9);
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
}

* { box-sizing: border-box; }
html { background: var(--abyss); }
body { margin: 0; color: var(--parchment); font: var(--t-body)/1.55 var(--body); -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
a { color: var(--brass-hi); text-decoration: none; }
a:hover { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; border-radius: var(--r-s); }
::selection { background: rgba(127, 174, 154, 0.28); color: var(--parchment); }
h1, h2, .insp-title, .entry-title { font-family: var(--display); font-weight: 500; letter-spacing: 0.02em; }
h1 { font-size: var(--t-2xl); line-height: 1.15; margin: 0; }
h2 { font-size: var(--t-l); line-height: 1.3; margin: 0 0 8px; }
/* Section headings inside panels: plain bold text, the same everywhere */
.chart-bar h2, .pop h2, .sect h2, .setting-about h2, h2.panel-title { font: 700 var(--t-body)/1.3 var(--body); letter-spacing: 0; color: var(--parchment); }
.chart-bar h2 { margin: 0; }
.pop h2 { margin: 0 0 2px; }
h2.panel-title { margin: 0 0 4px; }
h3 { font: 700 var(--t-m)/1.3 var(--body); color: var(--dim); margin: 20px 0 8px; }
p { margin: 0 0 10px; }
code { font: 0.92em/1 var(--body); font-weight: 700; background: var(--chart-2); border: 1px solid var(--line); padding: 1px 5px; border-radius: var(--r-s); color: var(--brass-hi); }
kbd { font: 700 var(--t-xs)/1 var(--body); padding: 3px 5px; border-radius: var(--r-s); border: 1px solid rgba(27, 18, 5, 0.35); margin-left: 4px; opacity: 0.7; }
.muted { color: var(--dim); }
.note { font-size: var(--t-m); color: var(--dim); }
.ok-text { color: var(--verdigris); }
.warn-text { color: var(--amber); }
.hint { display: block; font-weight: 400; font-size: var(--t-s); color: var(--faint); margin: 2px 0 0; }
.lede { color: var(--dim); margin: 8px 0 0; max-width: 62ch; }
.skip { position: absolute; left: -999px; top: 8px; z-index: 50; background: var(--parchment); color: var(--abyss); padding: 8px 12px; border-radius: var(--r); }
.skip:focus { left: 8px; }
.icon { flex: none; }

/* ---------- shell ---------- */
body.app { display: grid; grid-template-columns: 224px minmax(0, 1fr); min-height: 100vh; }
.rail { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 26px; padding: 18px 14px 14px;
  background: var(--rail); border-right: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 11px; padding: 0 10px; color: var(--parchment); }
.brand:hover { text-decoration: none; }
.brand img { border-radius: var(--r-s); }
.brand-name { display: flex; flex-direction: column; font: 700 var(--t-body)/1.1 var(--body); letter-spacing: 0.16em; }
.brand-name span { font-weight: 400; letter-spacing: 0.05em; color: var(--brass-hi); font-size: var(--t-m); margin-top: 3px; }
.rail-nav { display: flex; flex-direction: column; gap: 2px; }
.rail-nav a { position: relative; display: flex; align-items: center; gap: 11px; padding: 8px 10px; border-radius: var(--r); color: var(--dim); font-weight: 700; font-size: var(--t-m); }
.rail-nav a:hover { color: var(--parchment); background: var(--chart); text-decoration: none; }
.rail-nav a[aria-current="page"] { color: var(--parchment); background: var(--chart-2); box-shadow: inset 0 1px 0 rgba(235, 220, 192, 0.05); }
.rail-nav a[aria-current="page"] .icon { color: var(--brass-hi); }
.rail-nav a[aria-current="page"]::before { content: ""; position: absolute; left: -14px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 var(--r-s) var(--r-s) 0; background: var(--brass); }
.rail-foot { margin-top: auto; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 4px 0 10px; border-top: 1px solid var(--line); }
.rail-foot form { margin: 0; }
.who { display: flex; align-items: center; gap: 10px; min-width: 0; }
.who img, .who-initial { width: 30px; height: 30px; border-radius: 50%; flex: none; }
.who-initial { display: grid; place-items: center; background: var(--chart-3); color: var(--brass-hi); font-weight: 700; font-size: var(--t-s); }
.who-name { display: flex; flex-direction: column; font-size: var(--t-m); font-weight: 700; line-height: 1.2; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who-name small { font-weight: 400; color: var(--faint); font-size: var(--t-s); }

main { width: 100%; margin: 0; padding: 30px 40px 72px; }
.crumb { display: inline-flex; align-items: center; gap: 4px; color: var(--dim); font-size: var(--t-m); margin: 0 0 14px -8px; padding: 2px 6px 2px 2px; border-radius: var(--r-s); }
.crumb:hover { color: var(--parchment); text-decoration: none; background: var(--chart); }
.crumb .icon { width: 16px; height: 16px; }

/* ---------- toast ---------- */
.toast { position: fixed; right: 24px; bottom: 24px; z-index: 40; display: flex; align-items: center; gap: 12px; max-width: 440px;
  padding: 12px 10px 12px 16px; border-radius: var(--r); border: 1px solid; box-shadow: var(--lift), 0 20px 40px -12px rgba(0, 0, 0, 0.7);
  animation: toast-in var(--settle) var(--ease) both; }
.toast.ok { background: var(--ok-solid); border-color: var(--ok-edge); color: var(--ok-ink); }
.toast.error { background: var(--bad-solid); border-color: var(--bad-edge); color: var(--bad-ink); }
.toast.leaving { opacity: 0; transform: translateY(6px); transition: opacity var(--settle), transform var(--settle); }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } }

/* ---------- buttons, forms ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; font: 700 var(--t-m)/1 var(--body); padding: 10px 15px; border-radius: var(--r);
  background: var(--chart-2); color: var(--parchment); border: 1px solid var(--line-2); cursor: pointer; white-space: nowrap;
  box-shadow: inset 0 1px 0 rgba(235, 220, 192, 0.05); transition: border-color var(--quick), background-color var(--quick), transform var(--quick); }
.btn:hover { border-color: var(--brass); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn .icon { width: 16px; height: 16px; }
/* The brass ring on the emblem, as a material: a little lighter at the top edge. */
.btn.primary { color: var(--brass-ink); border-color: var(--brass-lo);
  background: var(--brass); box-shadow: inset 0 1px 0 var(--brass-top), 0 1px 0 rgba(0, 0, 0, 0.5); }
.btn.primary:hover { background: var(--brass-hi); border-color: var(--brass); box-shadow: inset 0 1px 0 var(--brass-top-hi), 0 1px 0 rgba(0, 0, 0, 0.5); }
.btn.primary:disabled { background: var(--chart-2); color: var(--faint); border-color: var(--line); box-shadow: none; cursor: not-allowed; transform: none; }
.btn.ghost { background: transparent; box-shadow: none; }
.btn.danger, .btn.ghost.danger { color: var(--ember); border-color: var(--bad-edge); }
.btn.danger:hover { border-color: var(--ember); background: var(--bad-fill); }
.btn.wide { width: 100%; }
.icon-btn { display: inline-grid; place-items: center; width: 32px; height: 32px; padding: 0; border-radius: var(--r); background: transparent;
  border: 1px solid transparent; color: var(--dim); cursor: pointer; }
.icon-btn:hover { color: var(--parchment); background: var(--chart-2); border-color: var(--line); text-decoration: none; }
.icon-btn .icon { width: 17px; height: 17px; }
.link { background: none; border: 0; color: var(--dim); font: inherit; cursor: pointer; padding: 0; }
.link:hover { color: var(--parchment); }

label { display: block; font-weight: 700; font-size: var(--t-m); margin-bottom: 16px; }
label.gap { margin-top: 16px; }
input, textarea, select { display: block; width: 100%; margin-top: 7px; font: 400 var(--t-body)/1.45 var(--body); color: var(--parchment);
  background: var(--well); border: 1px solid var(--line-2); border-radius: var(--r); padding: 9px 11px;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.35); transition: border-color var(--quick), box-shadow var(--quick); }
textarea { resize: vertical; min-height: 44px; }
select { appearance: none; padding-right: 34px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 4.5 6 8l3.5-3.5' fill='none' stroke='%239AA7B4' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 11px center; }
input:hover, textarea:hover, select:hover { border-color: var(--line-3); }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--teal); box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.35), 0 0 0 3px rgba(127, 174, 154, 0.15); }
::placeholder { color: var(--faint); opacity: 1; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.check { display: inline-flex; align-items: center; gap: 7px; margin: 0; color: var(--dim); font-weight: 400; cursor: pointer; }
.check input, .radio input, .type-opt input { width: auto; margin: 0; accent-color: var(--brass); box-shadow: none; }

.notice { display: flex; align-items: baseline; gap: 10px; padding: 11px 16px; border-radius: var(--r); margin: 0 0 18px; border: 1px solid; font-size: var(--t-m); }
.notice::before { content: ""; flex: none; width: 8px; height: 8px; border-radius: 50%; background: currentColor; transform: translateY(-1px); }
.notice.ok { background: var(--ok-fill); border-color: var(--ok-edge); color: var(--ok-ink); }
.notice.ok::before { background: var(--verdigris); }
.notice.error { background: var(--bad-fill); border-color: var(--bad-edge); color: var(--bad-ink); }
.notice.error::before { background: var(--ember); }
.notice code { color: inherit; background: rgba(11, 10, 9, 0.5); }

/* ---------- stamps ----------
   The one place letters are set in capitals, like an ink stamp on a case file. */
.stamp { display: inline-block; font: 500 var(--t-xs)/1 var(--display); letter-spacing: 0.08em; padding: 5px 9px 4px;
  border: 1.5px solid currentColor; border-radius: var(--r-s); transform: rotate(-2.5deg); white-space: nowrap; }
.stamp.live { color: var(--verdigris); }
.stamp.draft { color: var(--faint); }
.stamp.edited { color: var(--amber); }

/* ---------- type glyphs (same marks as the map) ---------- */
.glyph { flex: none; overflow: visible; }
.mark { fill: var(--parchment); stroke: none; }
.t-choice .mark { fill: var(--brass-hi); }
.t-mcq .mark { fill: var(--teal); }
.t-flag .mark { fill: none; stroke: var(--teal); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.t-ending .mark { fill: var(--verdigris); }
.t-ending .mark.ring { fill: none; stroke: var(--verdigris); stroke-width: 1.5; }
.t-ending.tone-bad .mark { fill: var(--ember); }
.t-ending.tone-bad .mark.ring { fill: none; stroke: var(--ember); }
.t-ending.tone-neutral .mark { fill: var(--amber); }
.t-ending.tone-neutral .mark.ring { fill: none; stroke: var(--amber); }

/* ---------- page heads ---------- */
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; margin-bottom: 26px; flex-wrap: wrap; }

/* ---------- quest list: a ledger, not a wall of cards ---------- */
.new-quest { position: relative; }
.new-quest > summary { list-style: none; }
.new-quest > summary::-webkit-details-marker { display: none; }
.new-quest[open] > summary { background: var(--chart-2); color: var(--parchment); border-color: var(--line-2); box-shadow: none; }
.pop { position: absolute; right: 0; top: calc(100% + 10px); z-index: 20; width: 420px; padding: var(--pad);
  background: var(--chart); border: 1px solid var(--line-2); border-radius: var(--r-l); box-shadow: var(--lift), 0 30px 60px -20px rgba(0, 0, 0, 0.85); }

.pop .hint { margin-bottom: 16px; }

.ledger { border: 1px solid var(--line); border-radius: var(--r-l); background: var(--chart); box-shadow: var(--lift); overflow: hidden; }
.ledger-head, .entry { display: grid; grid-template-columns: minmax(0, 1fr) 110px 150px 130px 120px; gap: 20px; align-items: center; padding: 0 var(--pad); }
.ledger-head { height: 40px; font-size: var(--t-s); color: var(--faint); border-bottom: 1px solid var(--line); background: rgba(11, 10, 9, 0.35); }
.entry { min-height: 112px; padding-top: 16px; padding-bottom: 16px; color: var(--parchment); border-top: 1px solid var(--line); transition: background-color var(--quick); }
.ledger-head + .entry { border-top: 0; }
.entry:hover { background: var(--chart-2); text-decoration: none; }
.entry:hover .entry-title { color: var(--brass-hi); }
.entry-quest { display: flex; align-items: center; gap: 20px; min-width: 0; }
.thumb { flex: none; width: 128px; height: 64px; padding: 8px; border-radius: var(--r); background: var(--abyss); border: 1px solid var(--line);
  background-image: radial-gradient(circle, rgba(200, 122, 38, 0.16) 1px, transparent 1.3px); background-size: 9px 9px; }
.thumb path { fill: none; stroke: var(--brass); stroke-opacity: 0.6; stroke-width: 1; }
.thumb rect { fill: var(--line-2); }
.thumb rect.t-choice { fill: var(--brass-hi); }
.thumb rect.t-mcq, .thumb rect.t-flag { fill: var(--teal); }
.thumb rect.t-ending { fill: var(--amber); }
.thumb rect.t-ending.tone-good { fill: var(--verdigris); }
.thumb rect.t-ending.tone-bad { fill: var(--ember); }
.entry:hover .thumb { border-color: var(--line-2); }
.entry-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.entry-title { font-size: var(--t-l); line-height: 1.25; transition: color var(--quick); }
.entry-pitch { color: var(--dim); font-size: var(--t-m); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; max-width: 64ch; }
.entry-facts { display: flex; flex-wrap: wrap; gap: 4px 14px; color: var(--faint); font-size: var(--t-s); }
.needs { color: var(--amber); }
.needs::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--amber); margin-right: 6px; transform: translateY(-1px); }
.entry-access { font-size: var(--t-m); color: var(--dim); }
.entry-access.premium { color: var(--brass-hi); }
.entry-access.premium::before { content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 7px; transform: rotate(45deg) translateY(-2px); border: 1.5px solid currentColor; }
.entry-players { display: flex; flex-direction: column; gap: 4px; font-size: var(--t-m); }
.entry-players small, .entry-edit small { color: var(--faint); font-size: var(--t-s); }
.entry-players progress { margin: 0; width: 100%; max-width: 120px; }
.entry-edit { display: flex; flex-direction: column; font-size: var(--t-m); color: var(--dim); }
.empty { border: 1px dashed var(--line-2); border-radius: var(--r-l); padding: 48px 28px; text-align: center; color: var(--dim); }

/* ---------- quest page ---------- */
.quest-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; flex-wrap: wrap; margin-bottom: 18px; }
.title-row { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.quest-meta { list-style: none; display: flex; flex-wrap: wrap; gap: 6px 20px; margin: 10px 0 0; padding: 0; color: var(--dim); font-size: var(--t-m); }
.quest-meta .premium { color: var(--brass-hi); }
.quest-meta .code { color: var(--faint); }
.actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.actions form { margin: 0; }
.publish { display: flex; align-items: center; gap: 14px; }
.uptodate { display: inline-flex; align-items: center; gap: 8px; color: var(--verdigris); font-size: var(--t-m); }
.uptodate::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

.workspace { display: grid; grid-template-columns: minmax(0, 1fr) 352px; height: max(560px, calc(100vh - 236px));
  border: 1px solid var(--line); border-radius: var(--r-l); overflow: hidden; background: var(--chart); box-shadow: var(--lift); }
.chart { position: relative; min-width: 0; min-height: 0; border-right: 1px solid var(--line); display: flex; flex-direction: column; }
.chart-bar { display: flex; align-items: center; gap: 18px; padding: 10px 12px 10px var(--pad); border-bottom: 1px solid var(--line); }

.legend { margin: 0 auto 0 0; font-size: var(--t-s); color: var(--faint); display: flex; align-items: center; gap: 8px; }
.legend-line { display: inline-block; width: 30px; height: 0; border-top: 1px solid var(--brass); position: relative; opacity: 0.8; }
.legend-line::after { content: ""; position: absolute; left: 12px; right: 0; top: -2.5px; border-top: 4px solid var(--brass); }
.zoom { display: flex; align-items: center; gap: 2px; padding: 2px; border: 1px solid var(--line); border-radius: var(--r); background: var(--abyss); }
.zoom .icon-btn { width: 28px; height: 28px; }
.zoom-level { min-width: 46px; text-align: center; font-size: var(--t-s); color: var(--dim); font-variant-numeric: tabular-nums; }
.chart-scroll { flex: 1; min-height: 0; overflow: auto; display: flex; cursor: grab; overscroll-behavior: contain;
  background-color: var(--abyss);
  background-image: radial-gradient(circle, rgba(200, 122, 38, 0.17) 1px, transparent 1.4px);
  background-size: 22px 22px; scrollbar-color: var(--line-2) transparent; }
.chart-scroll:focus-visible { outline-offset: -2px; }
.storymap { display: block; flex: none; margin: auto; }
.edge { fill: none; stroke: var(--brass); }
.edge.back { stroke-dasharray: 5 5; }
.edge.sel { stroke: var(--teal); stroke-opacity: 1; }
.tip { fill: var(--brass); }
.edge-label { font: var(--t-xs) var(--body); fill: var(--dim); paint-order: stroke; stroke: var(--abyss); stroke-width: 5px; stroke-linejoin: round; }
.node { cursor: pointer; }
.node:hover { text-decoration: none; }
.node-box { fill: var(--chart); stroke: var(--line-2); stroke-width: 1; transition: stroke var(--quick); }
.node:hover .node-box { stroke: var(--brass); fill: var(--chart-2); }
.node.sel .node-box { stroke: var(--teal); stroke-width: 1.5; fill: var(--chart-sel); filter: drop-shadow(0 0 14px rgba(127, 174, 154, 0.32)); }
.node:focus-visible { outline: none; }
.node:focus-visible .node-box { stroke: var(--teal); stroke-width: 2; }
.node-kind { font: var(--t-xs) var(--body); fill: var(--dim); }
.node-title { font: 700 var(--t-m) var(--body); fill: var(--parchment); }
.node-stat { font: var(--t-xs) var(--body); fill: var(--faint); }
.node-stat.warnish { fill: var(--amber); }
.reach { fill: var(--brass); opacity: 0.75; }
.node.sel .reach { fill: var(--teal); opacity: 1; }
.start-tag { font: 500 var(--t-s) var(--display); letter-spacing: 0.08em; fill: var(--brass-hi); }
.warn-dot { fill: var(--amber); }

.inspector { padding: 20px var(--pad) var(--pad); overflow-y: auto; min-height: 0; scrollbar-color: var(--line-2) transparent; }
.insp-head { display: flex; justify-content: space-between; align-items: center; margin-top: -4px; }
.insp-kind { display: flex; align-items: center; gap: 8px; margin: 0; font-size: var(--t-m); color: var(--dim); }
.insp-title { font-size: var(--t-xl); line-height: 1.25; margin: 8px 0 10px; }
.excerpt { color: var(--dim); margin: 0 0 6px; font-size: var(--t-m); }
.leads { list-style: none; padding: 0; margin: 0; }
.leads li { display: flex; flex-direction: column; padding: 8px 0; border-top: 1px solid var(--line); font-size: var(--t-m); }
.leads li:first-child { border-top: 0; }
.leads .muted { font-size: var(--t-s); }
.problems { margin: 16px 0 0; padding: 10px 12px 10px 30px; border-left: 2px solid var(--amber); border-radius: 0 var(--r-s) var(--r-s) 0; background: var(--warn-fill); color: var(--warn-ink); font-size: var(--t-m); }
.figures { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; margin: 20px 0; }
.figures.three { grid-template-columns: repeat(3, 1fr); }
.figures div { background: var(--chart); padding: 11px 13px 10px; }
.figures dt { font-size: var(--t-s); color: var(--dim); }
.figures dd { margin: 3px 0 0; font: 500 var(--t-xl)/1.1 var(--display); color: var(--parchment); font-variant-numeric: lining-nums tabular-nums; }
.insp-actions { display: flex; gap: 10px; align-items: center; }
.insp-actions form { margin: 0; }
.bar-row { display: flex; justify-content: space-between; font-size: var(--t-m); margin-top: 6px; }
.bar-row span { color: var(--dim); font-variant-numeric: tabular-nums; }
progress { display: block; width: 100%; height: 5px; margin: 5px 0 8px; appearance: none; border: 0; border-radius: var(--r-s); background: var(--chart-3); overflow: hidden; }
progress::-webkit-progress-bar { background: var(--chart-3); }
progress::-webkit-progress-value { background: var(--amber); border-radius: var(--r-s); }
progress::-moz-progress-bar { background: var(--amber); border-radius: var(--r-s); }
progress.tone-good::-webkit-progress-value { background: var(--verdigris); }
progress.tone-good::-moz-progress-bar { background: var(--verdigris); }
progress.tone-bad::-webkit-progress-value { background: var(--ember); }
progress.tone-bad::-moz-progress-bar { background: var(--ember); }
.fold { border-top: 1px solid var(--line); padding: 12px 0 2px; margin-top: 14px; }
.fold summary { cursor: pointer; font-weight: 700; color: var(--parchment); list-style: none; display: flex; align-items: center; border-radius: var(--r-s); }
.fold summary::-webkit-details-marker { display: none; }
.fold summary::before { content: ""; width: 7px; height: 7px; margin: 0 11px 0 3px; border-right: 1.6px solid var(--brass); border-bottom: 1.6px solid var(--brass); transform: rotate(-45deg); transition: transform var(--settle) var(--ease); }
.fold[open] summary::before { transform: rotate(45deg) translate(-2px, -1px); }
.fold summary:hover { color: var(--brass-hi); }
.fold[open] summary { margin-bottom: 14px; }
.type-pick { display: grid; gap: 6px; margin-bottom: 16px; }
.type-opt { display: flex; gap: 11px; align-items: flex-start; border: 1px solid var(--line); border-radius: var(--r); padding: 9px 11px; margin: 0; font-weight: 400; cursor: pointer; transition: border-color var(--quick), background-color var(--quick); }
.type-opt:hover { border-color: var(--line-2); }
.type-opt input { position: absolute; opacity: 0; pointer-events: none; }
.type-opt .glyph { margin-top: 2px; }
.type-opt strong { font-size: var(--t-m); }
.type-opt small { display: block; color: var(--dim); font-size: var(--t-s); line-height: 1.4; }
.type-opt:has(input:checked) { border-color: var(--brass); background: rgba(200, 122, 38, 0.08); }
.type-opt:has(input:focus-visible) { outline: 2px solid var(--teal); outline-offset: 2px; }

/* ---------- step editor ---------- */
.kind-line { display: flex; align-items: center; gap: 9px; margin: 0 0 8px; color: var(--dim); font-size: var(--t-m); }
.step-id { color: var(--faint); margin-left: 6px; padding-left: 14px; border-left: 1px solid var(--line-2); }
.editor-split { display: grid; grid-template-columns: minmax(0, 760px) minmax(360px, 440px); gap: 36px; align-items: start; justify-content: start; }
.editor { background: var(--chart); border: 1px solid var(--line); border-radius: var(--r-l); box-shadow: var(--lift); }
.sect { padding: var(--pad) var(--pad) 8px; border-top: 1px solid var(--line); }
.sect:first-of-type { border-top: 0; }
.sect h2 { margin: 0 0 14px; }
.sect h2 + .hint { margin: -10px 0 14px; }
.ev { display: grid; grid-template-columns: 1fr 1.8fr; gap: 10px; margin-bottom: 10px; align-items: start; }
.ev input, .ev textarea, .opt input, .opt select { margin-top: 0; }
.opt-head { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; font-size: var(--t-s); color: var(--faint); margin-bottom: 6px; }
.opt { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 10px; align-items: center; }
.opt-head.mcq, .opt.mcq { grid-template-columns: 44px 1fr 1.4fr; }
.radio { display: grid; place-items: center; height: 40px; margin: 0; border: 1px solid var(--line); border-radius: var(--r); cursor: pointer; }
.radio:has(input:checked) { border-color: var(--verdigris); background: rgba(157, 179, 107, 0.1); }
.radio input { accent-color: var(--verdigris); }
.sealed { display: flex; gap: 10px; align-items: baseline; color: var(--ok-ink); font-size: var(--t-m); padding: 9px 12px; margin-bottom: 12px; border-radius: var(--r); background: var(--ok-fill); border: 1px solid var(--ok-edge); }
.sealed .icon { width: 16px; height: 16px; color: var(--verdigris); align-self: center; }
.savebar { position: sticky; bottom: 0; z-index: 5; display: flex; align-items: center; gap: 10px; padding: 14px var(--pad); margin-top: 10px;
  border-top: 1px solid var(--line); border-radius: 0 0 var(--r-l) var(--r-l); background: var(--chart); }
.save-state { margin-right: auto; display: inline-flex; align-items: center; gap: 8px; font-size: var(--t-m); color: var(--faint); }
.save-state::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--line-2); }
.dirty .save-state { color: var(--amber); }
.dirty .save-state::before { background: var(--amber); }
.preview-col { position: sticky; top: 24px; }
.preview-label { display: flex; justify-content: space-between; align-items: baseline; font-weight: 700; margin: 0 0 10px; }
.preview-label span { font-weight: 400; font-size: var(--t-s); color: var(--faint); }
.preview-col > .hint { margin-top: 10px; }
.danger-zone { margin-top: 26px; padding-top: 18px; border-top: 1px solid var(--line); }

/* ---------- settings ---------- */
.setting { max-width: 880px; display: grid; grid-template-columns: 280px minmax(0, 460px); gap: 40px; padding: var(--pad); border: 1px solid var(--line); border-radius: var(--r-l); background: var(--chart); box-shadow: var(--lift); }
.setting-about h2 { margin-bottom: 8px; }
.setting-about p { color: var(--dim); font-size: var(--t-m); }
.problem-line { color: var(--amber); }

/* ---------- messages (errors, access denied) ---------- */
body.bare { min-height: 100vh; }
.page-login main { max-width: none; padding: 0; }
.gate.solo { display: grid; min-height: 100vh; place-items: center; }
.gate-panel { width: min(400px, 100% - 48px); padding: 40px 0; text-align: center; }
.gate-panel h1 { margin: 0 0 4px; font-size: var(--t-2xl); }
.gate-panel > p { color: var(--dim); margin: 16px auto 28px; max-width: 34ch; }
.gate-icon { display: block; margin: 0 auto 22px; }
.btn.big { width: 100%; padding: 14px 22px; font-size: var(--t-body); gap: 10px; }

/* ---------- Discord preview: Discord's own colors, so it looks like the real thing ---------- */
.dc { background: #313338; border-radius: var(--r-l); padding: 14px 16px; color: #DBDEE1; font: 14.5px/1.4 "gg sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.4), 0 24px 48px -24px rgba(0, 0, 0, 0.9); }
.dc-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; flex-wrap: wrap; }
.dc-avatar { width: 32px; height: 32px; border-radius: 50%; background: url("/static/emblem.png") center / cover; color: transparent; overflow: hidden; }
.dc-name { font-weight: 600; color: #F2F3F5; }
.dc-app { background: #5865F2; color: #fff; font-size: 10px; font-weight: 700; padding: 1px 5px; border-radius: 4px; }
.dc-only { font-size: 12px; color: #949BA4; margin-left: auto; }
.dc-embed { background: #2B2D31; border-left: 4px solid var(--brass); border-radius: 4px; padding: 10px 14px 12px; }
.dc-embed.tone-good { border-left-color: var(--verdigris); }
.dc-embed.tone-bad { border-left-color: var(--ember); }
.dc-embed.tone-neutral { border-left-color: var(--amber); }
.dc-author { font-size: 12.5px; font-weight: 600; color: #F2F3F5; margin-bottom: 4px; }
.dc-title { font-weight: 700; color: #F2F3F5; margin-bottom: 6px; }
.dc-desc, .dc-fval { font-size: 14px; word-wrap: break-word; }
.dc code { font: 13px/1.3 Consolas, monospace; background: #1E1F22; border: 0; color: #DBDEE1; padding: 1px 4px; }
.dc pre { background: #1E1F22; border-radius: 4px; padding: 7px; margin: 6px 0 0; font-size: 12.5px; white-space: pre-wrap; }
.dc-field { margin-top: 9px; }
.dc-fname { font-weight: 700; font-size: 13.5px; color: #F2F3F5; margin-bottom: 2px; }
.dc-img { display: block; max-width: 100%; border-radius: 4px; margin-top: 10px; }
.dc-empty { color: #949BA4; font-style: italic; }
.dc-footer { font-size: 12px; color: #B5BAC1; margin-top: 10px; }
.dc-buttons { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.dc-btn { font-size: 13.5px; font-weight: 500; padding: 6px 14px; border-radius: 4px; color: #fff; background: #4E5058; }
.dc-btn.blurple { background: #5865F2; }
.dc-btn.green { background: #248046; }

.chart-scroll.panning { cursor: grabbing; user-select: none; }

/* ---------- smaller screens ---------- */
@media (max-width: 1200px) {
  .workspace { grid-template-columns: 1fr; height: auto; }
  .chart { height: 70vh; border-right: 0; border-bottom: 1px solid var(--line); }
  .editor-split { grid-template-columns: minmax(0, 1fr); }
  .preview-col { position: static; }
  .ledger-head, .entry { grid-template-columns: minmax(0, 1fr) 100px 130px 120px; }
  .ledger-head span:last-child, .entry-edit { display: none; }
}
@media (max-width: 900px) {
  body.app { display: block; }
  .rail { position: static; height: auto; flex-direction: row; align-items: center; gap: 14px; padding: 10px 14px; border-right: 0; border-bottom: 1px solid var(--line); }
  .rail-nav { flex-direction: row; }
  .rail-nav a[aria-current="page"]::before { display: none; }
  .rail-foot { margin: 0 0 0 auto; padding: 0; border: 0; }
  .who-name { display: none; }
  .brand-name span { display: none; }
  main { padding: 22px 18px 48px; }
  .ledger-head { display: none; }
  .entry { grid-template-columns: 1fr auto; row-gap: 12px; }
  .entry-quest { grid-column: 1 / -1; }
  .entry-access { display: none; }
  .setting { grid-template-columns: 1fr; gap: 16px; }
  .gate { grid-template-columns: 1fr; }
  .pop { width: min(420px, calc(100vw - 36px)); }
}
@media (max-width: 600px) {
  .thumb { display: none; }
  .row, .ev, .opt, .opt-head { grid-template-columns: 1fr; }
  .opt.mcq, .opt-head.mcq { grid-template-columns: 44px 1fr; }
  .opt.mcq input[name^="opt_feedback"] { grid-column: 2; }
  .opt-head { display: none; }
  h1 { font-size: var(--t-xl); }
  .rail-nav span { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* ---------- login: the doorway ----------
   Behind the door everything is drawn live: sheets of light (login.js) and letterpress grain. */
.door-scene { position: relative; min-height: 100vh; display: grid; place-items: center; overflow: hidden; background: var(--abyss); isolation: isolate; }
.silk { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 0; }
/* Letterpress grain, like the banner's paper. */
.grain { position: absolute; inset: 0; z-index: 2; pointer-events: none; opacity: 0.09; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 0.9 0 0 0 0 0.75 0 0 0 1 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E"); }
/* The door: the archway from the banner, cut out and set into the scene, with the sign-in beside it like the banner's lettering. */
.silk { transform: scaleX(-1); }   /* waves rise behind the door, the text side stays dark */
.entrance { position: relative; z-index: 1; display: grid; grid-template-columns: auto minmax(300px, 380px); align-items: center; gap: clamp(32px, 6vw, 88px); padding: 32px; }
.door { position: relative; height: min(74vh, 640px); aspect-ratio: 600 / 640; }
/* One entrance for the whole scene. Nothing shows until the art, fonts and first frame of the waves are ready
   (login.js adds .ready); then the waves come up out of the dark and the door and sign-in rise in together.
   If the script never runs, everything still appears after 2.5s. */
.door-scene .silk { opacity: 0; transition: opacity 0.9s var(--ease); }
.door-scene .entrance { opacity: 0; translate: 0 12px; transition: opacity 0.8s var(--ease) 0.2s, translate 0.8s var(--ease) 0.2s; }
.door-scene.ready .silk, .door-scene.ready .entrance { opacity: 1; translate: 0 0; }
.door-scene:not(.ready) .silk, .door-scene:not(.ready) .entrance { animation: show-anyway 0.6s var(--ease) 2.5s forwards; }
@keyframes show-anyway { to { opacity: 1; translate: 0 0; } }
.door img { position: relative; width: 100%; height: 100%; filter: drop-shadow(0 28px 40px rgba(0, 0, 0, 0.75)); }
/* light from the corridor spilling onto the ground in front of the door */
.door-glow { position: absolute; left: -10%; right: -10%; bottom: -14%; height: 46%; border-radius: 50%;
  background: radial-gradient(closest-side, rgba(232, 167, 94, 0.32), rgba(200, 122, 38, 0.1) 60%, transparent); filter: blur(6px); }
/* the lantern inside, flickering on the lit wall and steps */
.door-flicker { position: absolute; left: 30%; right: 18%; top: 26%; bottom: 8%; border-radius: 40% 40% 20% 20%; mix-blend-mode: screen; pointer-events: none;
  background: radial-gradient(ellipse at 62% 60%, rgba(255, 196, 120, 0.22), transparent 65%); animation: flicker 4.5s ease-in-out infinite alternate; }
@keyframes flicker { 0% { opacity: 0.55; } 30% { opacity: 1; } 55% { opacity: 0.7; } 80% { opacity: 0.95; } 100% { opacity: 0.8; } }
.door-way { display: flex; flex-direction: column; align-items: flex-start; }
.door h1, .door-way h1 { margin: 0; width: 100%; }
.door-wordmark { display: block; width: 100%; height: auto; filter: drop-shadow(0 2px 10px rgba(0, 0, 0, 0.6)); }
.door-sign { font: 500 var(--t-l)/1.2 var(--display); letter-spacing: 0.08em; color: var(--parchment); margin: 20px 0 18px; }
.door-way .gate-note { font-size: var(--t-s); color: var(--dim); margin: 14px 0 0; }
@media (max-width: 900px) {
  .entrance { grid-template-columns: 1fr; justify-items: center; gap: 8px; padding: 24px 20px 40px; }
  .door { height: min(42vh, 380px); }
  .door-way { align-items: center; text-align: center; width: min(360px, 100%); }
}
@media (max-width: 420px) { .door-sign { margin: 14px 0 12px; } .door-way .btn.big { font-size: var(--t-m); } }
@media (prefers-reduced-motion: reduce) { .door-flicker { animation: none; } .door-scene .silk, .door-scene .entrance { transition: none; } }
