:root {
  --bg: #f4f1ea;
  --panel: #fffdf8;
  --ink: #26221c;
  --quiet: #6e665a;
  --line: #d9d1c2;
  --accent: #7a2e2e;
  --accent-soft: #f3e3df;
  --hidden: #8a5a00;
  --hidden-soft: #fbefd5;
  --dm: #3d4f7a;
  --dm-soft: #e4e9f5;
  --read: #2f5d46;
  --read-soft: #e5f0ea;
  --shadow: 0 1px 2px rgba(0, 0, 0, .06);
  /* one colour per type, everywhere it shows */
  --c-trap: #c0392b; --c-mob: #6b3fa0; --c-loot: #a86b00; --c-clue: #2f7d50;
  --c-npc: #2b6cb0; --c-event: #b83280; --c-fixture: #5a6474; --c-passage: #0f766e;
  --c-encounter-table: #8a5a00; --c-service: #5a6474; --c-document: #8b5e34;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17151a;
    --panel: #221f26;
    --ink: #ece7df;
    --quiet: #a39b8f;
    --line: #3a3540;
    --accent: #e08a7a;
    --accent-soft: #3a2626;
    --hidden: #e6b44f;
    --hidden-soft: #3a2f17;
    --dm: #9fb2e3;
    --dm-soft: #232b40;
    --read: #8fd1ad;
    --read-soft: #1d3127;
    --shadow: none;
    --c-trap: #f87171; --c-mob: #c4a1ff; --c-loot: #f6c453; --c-clue: #6fd3a0;
    --c-npc: #7fb4ff; --c-event: #f58ac8; --c-fixture: #a7b1c2; --c-passage: #4fd1c5;
    --c-encounter-table: #e6b44f; --c-service: #a7b1c2; --c-document: #e0b088;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
}
a { color: var(--accent); }
button.link {
  background: none; border: 0; padding: 0; font: inherit;
  color: var(--accent); cursor: pointer; text-decoration: underline; text-underline-offset: 2px; text-align: inherit;
}

/* Top bar */
.topbar {
  display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center;
  padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--panel);
}
.topbar h1 { font-size: 17px; margin: 0; flex: 1 1 auto; display: flex; align-items: center; gap: 10px; min-width: 0; }
.home-link {
  font-size: 12px; font-weight: 700; letter-spacing: .06em; text-decoration: none; color: var(--accent);
  border: 1px solid var(--line); border-radius: 6px; padding: 3px 7px; flex: none;
}
.home-link:hover { background: var(--accent-soft); }
body.no-world .home-link { display: none; }
#jump {
  flex: 0 1 260px; min-width: 0; padding: 6px 10px; border-radius: 6px;
  border: 1px solid var(--line); background: var(--bg); color: var(--ink); font: inherit;
}
.btn {
  padding: 6px 12px; border-radius: 6px; border: 1px solid var(--line);
  background: var(--bg); cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: var(--accent); }

.crumbbar {
  display: flex; align-items: center; gap: 12px;
  width: 100%; max-width: 1280px; margin: 0 auto; padding: 6px 16px 0;
}
.breadcrumb { flex: 1 1 auto; min-width: 0; color: var(--quiet); font-size: 14px; }
.turn { flex: none; display: flex; align-items: center; gap: 2px; }
.rose { flex: none; color: var(--ink); transition: transform .3s ease-in-out; }
.turn-btn {
  width: 28px; height: 28px; border-radius: 50%; border: 1px solid var(--line); background: var(--panel);
  color: var(--ink); font: 16px/1 system-ui, sans-serif; cursor: pointer;
}
.turn-btn:hover { border-color: var(--accent); color: var(--accent); }
@media (prefers-reduced-motion: reduce) { .rose { transition: none; } }
.breadcrumb .sep { margin: 0 6px; }

/* Stage: the room fills the viewport; exit icons float over it at the edges */
body { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }
.stage { position: relative; flex: 1 1 auto; min-height: 0; width: 100%; }
.stage[hidden] { display: none; }
.edge {
  position: absolute; z-index: 10; display: flex; align-items: center; justify-content: center; gap: 8px;
  pointer-events: none;
}
.edge > *, .edge .xi { pointer-events: auto; }
.edge.n  { top: 8px; left: 50%; transform: translateX(-50%); }
.edge.s  { bottom: 8px; left: 50%; transform: translateX(-50%); }
.edge.w  { left: 8px; top: 50%; transform: translateY(-50%); flex-direction: column; }
.edge.e  { right: 8px; top: 50%; transform: translateY(-50%); flex-direction: column; }
.edge.nw { top: 8px; left: 8px; }
.edge.ne { top: 8px; right: 8px; }
.edge.sw { bottom: 8px; left: 8px; }
.edge.se { bottom: 8px; right: 8px; }
.edge > div { display: flex; gap: 8px; align-items: center; }
.edge.n > div:empty, .edge.s > div:empty { display: none; }

/* Exit icons */
.xi { position: relative; }
.xi-btn {
  position: relative; display: grid; place-items: center;
  width: 40px; height: 40px; border-radius: 50%;
  border: 2px solid var(--accent); background: var(--panel); color: var(--accent);
  font: 600 20px/1 system-ui, sans-serif; cursor: pointer; box-shadow: var(--shadow);
}
.xi-btn:hover, .xi:focus-within .xi-btn { background: var(--accent); color: var(--panel); }
.xi.is-hidden .xi-btn { border-style: dashed; border-color: var(--hidden); color: var(--hidden); }
.xi.is-hidden .xi-btn:hover { background: var(--hidden); color: var(--panel); }
.xi.is-hidden.is-found .xi-btn { border-style: solid; }
.xi.blocked .xi-btn { opacity: .5; }
.badge {
  position: absolute; display: grid; place-items: center;
  width: 17px; height: 17px; border-radius: 50%; font: 700 11px/1 system-ui, sans-serif;
  background: var(--panel); border: 1px solid var(--line); color: var(--ink);
}
.badge .icon { width: 11px; height: 11px; }
.badge.lock { right: -5px; bottom: -5px; }
.badge.eye { left: -5px; top: -5px; background: var(--hidden-soft); color: var(--hidden); border-color: var(--hidden); }
.xi.is-found .badge.eye { display: none; }
.badges { position: absolute; right: -8px; top: -7px; display: flex; flex-direction: row-reverse; gap: 1px; }
.badges .badge { position: static; color: var(--panel); }
.badge.mark { --c: var(--c-fixture); background: var(--c); border-color: var(--c); }
.badge.mark-trap { --c: var(--c-trap); } .badge.mark-mob { --c: var(--c-mob); } .badge.mark-loot { --c: var(--c-loot); }
.badge.mark-clue { --c: var(--c-clue); } .badge.mark-event { --c: var(--c-event); } .badge.mark-npc { --c: var(--c-npc); }

/* Hover card: the padding bridges the gap so the pointer can move into it */
.xi-card { position: absolute; z-index: 30; display: none; width: 340px; max-width: calc(100vw - 32px); }
.xi:hover .xi-card, .xi:focus-within .xi-card { display: block; }
.xi-card .exit { max-height: 60vh; overflow-y: auto; box-shadow: 0 8px 28px rgba(0, 0, 0, .25); }
.pos-below .xi-card { top: 100%; left: 50%; transform: translateX(-50%); padding-top: 8px; }
.pos-above .xi-card { bottom: 100%; left: 50%; transform: translateX(-50%); padding-bottom: 8px; }
.pos-right .xi-card { left: 100%; top: 50%; transform: translateY(-50%); padding-left: 8px; }
.pos-left .xi-card { right: 100%; top: 50%; transform: translateY(-50%); padding-right: 8px; }
.pos-below-right .xi-card { top: 100%; left: 0; padding-top: 8px; }
.pos-below-left .xi-card { top: 100%; right: 0; padding-top: 8px; }
.pos-above-right .xi-card { bottom: 100%; left: 0; padding-bottom: 8px; }
.pos-above-left .xi-card { bottom: 100%; right: 0; padding-bottom: 8px; }

/* Exit card (inside the hover card) */
.exit {
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; font-size: 14px;
}
.exit.is-hidden { border-style: dashed; border-color: var(--hidden); }
.exit-head { display: flex; gap: 8px; align-items: baseline; }
.exit .arrow { font-size: 18px; line-height: 1; color: var(--accent); flex: none; }
.exit .arrow .icon { width: 18px; height: 18px; }
.exit .meta { color: var(--quiet); font-size: 13px; }
.exit .side-desc { margin-top: 4px; }
.exit .sub { margin-top: 6px; }
.exit .sub summary { cursor: pointer; color: var(--accent); font-weight: 600; font-size: 13px; }
.exit .sub .obj { margin-top: 6px; }

/* Mini-map: a small box in the corner, a large overlay when open */
.minimap {
  position: absolute; z-index: 20; display: none;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, .18); overflow: hidden;
}
.map-mini { display: block; width: 100%; height: 100%; padding: 4px; border: 0; background: none; cursor: zoom-in; }
.map-mini .map-svg { pointer-events: none; }
.minimap.open {
  inset: 24px 64px; z-index: 40;
  display: flex; flex-direction: column; box-shadow: 0 12px 48px rgba(0, 0, 0, .35);
}
.map-head { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.map-crumbs { flex: 1 1 auto; min-width: 0; color: var(--quiet); font-size: 14px; }
.map-crumbs .sep { margin: 0 6px; }
.map-head .btn { color: var(--ink); font: inherit; }
.map-head .btn[disabled] { opacity: .4; cursor: default; }
.map-svg { display: block; width: 100%; height: 100%; flex: 1 1 auto; min-height: 0; }
.map-empty { margin: auto; color: var(--quiet); }
.map-svg .edge { stroke: var(--quiet); stroke-width: 2.5; fill: none; stroke-linejoin: round; }
.map-svg .edge.hidden, .map-svg .stub.hidden line { stroke-dasharray: 7 6; stroke: var(--hidden); }
.map-svg .stub line { stroke: var(--quiet); stroke-width: 2; stroke-dasharray: 2 5; }
.map-svg .stub text { fill: var(--quiet); font-size: 13px; }
.map-svg .stub rect { fill: var(--panel); stroke: var(--quiet); stroke-dasharray: 3 4; }
.map-svg .stub { cursor: pointer; }
.map-svg .stub:hover text { fill: var(--accent); }
.map-svg .node { cursor: pointer; }
.map-svg .node rect { fill: var(--bg); stroke: var(--ink); stroke-width: 1.5; }
.map-svg .node.shell rect { stroke-dasharray: 5 4; }
.map-svg .node.hidden rect { stroke: var(--hidden); }
.map-svg .node text { fill: var(--ink); font-size: 15px; }
.map-svg .node.here rect { fill: var(--accent); stroke: var(--accent); }
.map-svg .node.here > text { fill: var(--panel); font-weight: 700; }
.map-svg .node:hover rect { stroke: var(--accent); stroke-width: 2.5; }
.map-svg .down circle { fill: var(--panel); stroke: var(--accent); stroke-width: 1.5; }
.map-svg .down text { fill: var(--accent); font-size: 16px; font-weight: 700; }
.map-svg .down:hover circle { fill: var(--accent-soft); }

/* Room: no frame, the whole stage; padding keeps text clear of the edge icons */
.room {
  position: absolute; inset: 0; overflow-y: auto;
  padding: 60px 64px 72px;
}
.room-inner > .md, .room-inner > .notes { max-width: 80ch; }
.objects { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 10px; align-items: start; }
.room h2 { margin: 0 0 4px; font-size: 24px; }
.room h3 {
  margin: 20px 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--quiet);
}
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.chip {
  display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px;
  border: 1px solid var(--line); color: var(--quiet);
}
.chip.cond { border-color: var(--accent); color: var(--accent); }
.chip.hidden { border-color: var(--hidden); color: var(--hidden); background: var(--hidden-soft); }
.chip.dm { border-color: var(--dm); color: var(--dm); background: var(--dm-soft); }
.chip.presence { border-style: dashed; }

.md p { margin: 6px 0; }
.md blockquote {
  margin: 8px 0; padding: 8px 12px; border-left: 4px solid var(--line); background: var(--bg); border-radius: 6px;
}
.md blockquote.read { border-left-color: var(--read); background: var(--read-soft); }
.md blockquote.read::before {
  content: "Read aloud"; display: block; font-size: 11px; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: var(--read); margin-bottom: 2px;
}
.notes {
  margin-top: 10px; padding: 8px 12px; border-radius: 6px; background: var(--dm-soft); border-left: 4px solid var(--dm);
}
.notes::before {
  content: "DM notes"; display: block; font-size: 11px; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: var(--dm);
}

/* Objects */
.obj {
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; background: var(--panel);
}
.obj.is-hidden { border-style: dashed; border-color: var(--hidden); }
.obj.flash { animation: flash 1.6s ease-out; }
@keyframes flash { from { background: var(--accent-soft); } to { background: var(--panel); } }
.obj-head { display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: baseline; }
.obj-type { font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--accent); }
.obj-name { font-weight: 600; }
.obj ul { margin: 4px 0; padding-left: 20px; }
.obj .kv { color: var(--quiet); font-size: 13px; }
.obj .kv b { color: var(--ink); font-weight: 600; }
.handout {
  margin: 6px 0; padding: 10px 14px; border-radius: 6px; background: var(--bg);
  border: 1px solid var(--line); font-family: Georgia, "Times New Roman", serif;
}
.handout > :first-child { margin-top: 0; } .handout > :last-child { margin-bottom: 0; }
.show-players { margin: 4px 0; }
.handout-dialog {
  width: min(640px, calc(100vw - 32px)); max-height: calc(100vh - 48px); overflow: auto;
  border: 1px solid var(--line); border-radius: 10px; padding: 20px; background: var(--panel); color: var(--ink);
}
.handout-dialog::backdrop { background: rgba(0, 0, 0, .55); }
.handout-dialog h2 { margin: 0 0 8px; font-size: 22px; }
.handout-dialog .handout-text { font-size: 18px; line-height: 1.55; padding: 16px 20px; }
.handout-dialog form { margin-top: 14px; text-align: right; }
.obj .nested { margin-top: 8px; padding-left: 10px; border-left: 2px solid var(--line); display: flex; flex-direction: column; gap: 6px; }

.children { display: flex; flex-wrap: wrap; gap: 8px; }
.child {
  border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; background: var(--bg); text-align: left;
  font: inherit; color: var(--ink); cursor: pointer;
}
.child:hover { border-color: var(--accent); }
.child .where { display: block; font-size: 12px; color: var(--quiet); }
.backlinks li, .derived li { margin: 2px 0; }
.derived .sep { margin: 0 4px; color: var(--quiet); }
.derived .via { color: var(--quiet); font-size: 13px; }
.derived li.is-hidden .via { color: var(--hidden); }
.hub-child { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; cursor: default; }
.hub-child .entry, .hub-child .overview { font-size: 13px; }
.hub-child .overview { color: var(--quiet); }
.hub-banner {
  margin: -4px 0 10px; padding: 6px 10px; border-radius: 6px; font-size: 13px;
  background: var(--dm-soft); color: var(--dm); border-left: 4px solid var(--dm);
}


/* Home: no world open */
.home { flex: 1 1 auto; overflow-y: auto; padding: 0 16px 48px; }
.home[hidden] { display: none; }
.home > section { max-width: 1040px; margin: 0 auto; }
.home-hero { text-align: center; padding: 56px 0 40px; border-bottom: 1px solid var(--line); }
.home-kicker { margin: 0 0 10px; font-size: 13px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--accent); }
.home-hero h2 { margin: 0 auto 14px; max-width: 760px; font: 700 clamp(28px, 5vw, 44px)/1.12 Georgia, "Iowan Old Style", serif; text-wrap: balance; }
.home-lead { margin: 0 auto 26px; max-width: 680px; font-size: 18px; color: var(--quiet); text-wrap: pretty; }
.home-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; align-items: center; }
.home-actions .btn.big { margin: 0; }
.home-btn { padding: 13px 22px; font-size: 16px; border-radius: 10px; background: var(--panel); color: var(--ink); text-decoration: none; }
.home-drop { margin: 18px 0 0; font-size: 13px; color: var(--quiet); }
body.dragging .home-hero { background: var(--accent-soft); border-radius: 14px; }
.home-section { padding: 40px 0 8px; }
.home-section h3 { margin: 0 0 18px; font: 700 24px/1.2 Georgia, "Iowan Old Style", serif; }
.home-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 14px; }
.home-card { padding: 18px 18px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); box-shadow: var(--shadow); }
.home-card h4 { display: flex; align-items: center; gap: 8px; margin: 0 0 6px; font-size: 16px; }
.home-card p { margin: 0 0 6px; color: var(--quiet); font-size: 14.5px; }
.home-plan, .home-code {
  margin: 8px 0 0; padding: 12px 14px; border-radius: 8px; background: var(--bg); border: 1px solid var(--line);
  font: 13px/1.45 ui-monospace, "SF Mono", Menlo, monospace; overflow-x: auto;
}
.home-plan { letter-spacing: .35em; width: max-content; }
.home-code .c { color: var(--quiet); }
.home-two { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 28px; align-items: start; }
.home-list { margin: 0; padding-left: 18px; }
.home-list li { margin: 0 0 8px; }
.home-links { margin: 14px 0 0; }
.home-example { border-top: 1px solid var(--line); margin-top: 32px; }
.home-example > p { max-width: 760px; }
.home-example .home-actions { justify-content: flex-start; margin: 16px 0; }
.home-fine { font-size: 13px; color: var(--quiet); }
@media (max-width: 760px) {
  .home-hero { padding-top: 32px; }
  .home-two { grid-template-columns: 1fr; }
  .home-lead { font-size: 16px; }
}
.btn.big { display: inline-block; margin: 10px 0 4px; padding: 14px 28px; font-size: 17px; font-weight: 600;
  background: var(--accent); border-color: var(--accent); color: var(--panel); border-radius: 10px; }
.btn.big:hover { filter: brightness(1.1); }
body.no-world .crumbbar, body.no-world .modes, body.no-world #jump, body.no-world .toggle, body.no-world .menu, body.no-world .topbar > label.btn { display: none; }
.menu-list hr { width: 100%; border: 0; border-top: 1px solid var(--line); margin: 2px 0; }

/* Phone */
@media (max-width: 760px) {
  .xi-btn { width: 36px; height: 36px; font-size: 18px; }
  .room { padding: 54px 50px 64px; }
  .objects { grid-template-columns: minmax(0, 1fr); }
  .minimap { right: 54px; bottom: 54px; width: 150px; height: 96px; }
  .minimap.open { inset: 8px; }
}

/* Play state */
.flags { display: inline-flex; gap: 8px; margin-left: auto; }
.flag { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--quiet); cursor: pointer; user-select: none; }
.flag input { margin: 0; accent-color: var(--accent); }
.obj.done { opacity: .55; }
.obj.done > .obj-head .obj-name { text-decoration: line-through; }
.obj.is-hidden.found { border-style: solid; }
.chip.visited { border-color: var(--read); color: var(--read); background: var(--read-soft); }
.exit .transition {
  margin: 6px 0 2px; padding: 3px 8px; border-radius: 6px; font-size: 13px; font-weight: 600;
  background: var(--dm-soft); color: var(--dm);
}
.toggle { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; cursor: pointer; user-select: none; }
.toggle input { accent-color: var(--accent); width: 16px; height: 16px; margin: 0; }
.menu { position: relative; }
.menu > summary { list-style: none; font-size: 14px; }
.menu > summary::-webkit-details-marker { display: none; }
.menu-list {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 50; display: flex; flex-direction: column; gap: 6px;
  padding: 8px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 24px rgba(0, 0, 0, .25);
}
.menu-list .btn { color: var(--ink); font: inherit; font-size: 14px; text-align: left; }
.btn { color: var(--ink); font-size: 14px; }
a.btn { text-decoration: none; display: inline-block; }

/* Map: visited state, the level itself, crossings */
.map-svg .node.unvisited rect { fill: var(--panel); stroke-opacity: .45; }
.map-svg .node.unvisited > text { fill-opacity: .55; }
.map-svg .node.visited:not(.here) rect { fill: var(--read-soft); stroke: var(--read); stroke-width: 3; }
.map-svg .node.level rect { stroke-width: 3; }
.map-svg .stub.crossing rect { stroke: var(--dm); }
.map-svg .stub text.sub { fill: var(--dm); font-size: 12px; }

/* Lists and notes */
.item-note { font-size: 12px; color: var(--quiet); }
ol.seq { margin: 4px 0; padding-left: 24px; }
ol.seq li { margin: 2px 0; }
ol.seq li .flag { margin-right: 2px; }
ol.seq li.next { font-weight: 600; }
ol.seq li.next::marker { color: var(--accent); }
ol.seq li:has(input:checked) { color: var(--quiet); text-decoration: line-through; }
.nested.summoned::before {
  content: "Then appears"; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--dm);
}

/* Type colours */
.t-trap { --c: var(--c-trap); } .t-mob { --c: var(--c-mob); } .t-loot { --c: var(--c-loot); } .t-clue { --c: var(--c-clue); }
.t-npc { --c: var(--c-npc); } .t-event { --c: var(--c-event); } .t-fixture { --c: var(--c-fixture); } .t-passage { --c: var(--c-passage); }
.t-encounter-table { --c: var(--c-encounter-table); } .t-service { --c: var(--c-service); } .t-document { --c: var(--c-document); }
.ticon { display: inline-grid; place-items: center; color: var(--c, var(--quiet)); }
.ticon .icon { width: 15px; height: 15px; }
.obj[class*="t-"] { border-left: 4px solid var(--c); }
.obj[class*="t-"] .obj-type { color: var(--c); }

/* Map view: notes on the left, the room in the middle, the hovered card on the right */
.side, .plan-area, .detail, .legend { display: none; }
.stage.planned .edge, .stage.planned .room { display: none; }
.stage.planned .side, .stage.planned .plan-area, .stage.planned .detail { display: block; }
.stage.planned .legend { display: block; }
.side, .detail { position: absolute; top: 0; bottom: 0; width: 20%; min-width: 230px; overflow-y: auto; padding: 14px 16px 60px; }
.side { left: 0; border-right: 1px solid var(--line); }
.detail { right: 0; border-left: 1px solid var(--line); }
.plan-area { position: absolute; top: 0; bottom: 0; left: max(20%, 230px); right: max(20%, 230px); overflow: hidden; }
.side h2 { margin: 0 0 4px; font-size: 21px; }
.side h3, .detail h3 { margin: 18px 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--quiet); }
.side .md, .side .notes { font-size: 14px; }
.detail-hint { color: var(--quiet); font-size: 14px; }
.detail .obj, .detail .exit { font-size: 14px; }
/* Accordions: groups by type, items that open to their card */
.grp { margin: 8px 0; }
.grp > summary { cursor: pointer; display: flex; align-items: center; gap: 6px; padding: 4px 2px; font-size: 12px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .05em; color: var(--c); border-bottom: 2px solid var(--c); list-style: none; }
.grp > summary::-webkit-details-marker { display: none; }
.grp > summary::after { content: "▾"; margin-left: 4px; color: var(--quiet); transition: transform .15s; }
.grp:not([open]) > summary::after { transform: rotate(-90deg); }
.grp .count { margin-left: auto; min-width: 20px; padding: 0 6px; border-radius: 999px; background: var(--c); color: var(--panel); text-align: center; font-size: 11px; }
.grp:has(.item.hl):not([open]) > summary { background: color-mix(in srgb, var(--c) 18%, transparent); }
.grp-body { display: flex; flex-direction: column; gap: 4px; padding-top: 4px; }
.item { border: 1px solid var(--line); border-left: 4px solid var(--c); border-radius: 7px; background: var(--panel); }
.item-head { display: flex; flex-wrap: wrap; align-items: center; }
.item-toggle { flex: 1 1 100%; min-width: 0; display: flex; align-items: center; gap: 6px; padding: 6px 8px; background: none; border: 0;
  font: inherit; font-size: 14px; color: var(--ink); text-align: left; cursor: pointer; }
.item-toggle .ticon { font: 600 15px/1 system-ui, sans-serif; }
.item-name { overflow: hidden; text-overflow: ellipsis; }
.item.open .item-name { font-weight: 600; }
.item-head .flags { margin: -4px 0 0; padding: 0 8px 6px 30px; flex-wrap: wrap; gap: 4px 10px; }
.item-name { flex: 1 1 auto; min-width: 0; }
.st { flex: none; padding: 0 6px; border-radius: 999px; font-size: 11px; white-space: nowrap; }
.st.check { color: var(--hidden); border: 1px dashed var(--hidden); background: var(--hidden-soft); }
.st.done { color: var(--quiet); border: 1px solid var(--line); }
.item.done .item-name { text-decoration: line-through; color: var(--quiet); }
.item.hl { box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 45%, transparent); }
.item.flash { animation: flash-item 1.4s ease-out; }
@keyframes flash-item { from { background: color-mix(in srgb, var(--c) 25%, var(--panel)); } to { background: var(--panel); } }
.item-body { border-top: 1px solid var(--line); }
.item-body > .obj, .item-body > .exit { border: 0; border-radius: 0 0 7px 7px; font-size: 14px; }
.item-body > .obj > .obj-head > .ticon, .item-body > .obj > .obj-head > .obj-type,
.item-body > .obj > .obj-head > .obj-name, .item-body > .obj > .obj-head > .flags { display: none; }
.item-body > .obj > .obj-head:empty { display: none; }
.mk.hl { outline: 3px solid color-mix(in srgb, var(--c) 55%, transparent); transform: translate(-50%, -50%) scale(1.2); }
.xi.on-plan.hl .xi-btn { background: var(--c-passage); color: var(--panel); }
.acc { border: 1px solid var(--line); border-left: 4px solid var(--c); border-radius: 8px; margin: 6px 0; background: var(--panel); }
.acc > summary { cursor: pointer; padding: 6px 10px; display: flex; gap: 6px; align-items: center; font-size: 14px; }
.acc > summary > span { color: var(--c); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.acc > .obj { border: 0; border-top: 1px solid var(--line); border-radius: 0 0 8px 8px; }

.scene-svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.scene-svg .c-floor { fill: var(--panel); stroke: var(--line); stroke-width: calc(var(--px) * .5px); }
.scene-svg .here-room .c-floor { fill: var(--bg); }
.scene-svg .c-solid { fill: color-mix(in srgb, var(--ink) 45%, var(--bg)); }
.scene-svg .c-wall, .map-svg .c-wall { fill: none; stroke: var(--ink); stroke-width: 3px; stroke-linecap: square; vector-effect: non-scaling-stroke; }
.scene-svg .c-door, .map-svg .c-door { fill: none; stroke: var(--c-passage); stroke-width: 3px; stroke-dasharray: 2 3; vector-effect: non-scaling-stroke; }
.scene-svg .nb { opacity: .45; cursor: pointer; }
.scene-svg .nb.unvisited { opacity: .2; }
.scene-svg .nb.visited { opacity: .7; }
.scene-svg .nb.visited .c-floor { fill: var(--read-soft); }
.scene-svg .nb.visited .c-wall, .map-svg .room-plan.visited .c-wall { stroke: var(--read); stroke-width: 4.5px; }
.scene-svg .nb.visited .nb-label { fill: var(--read); }
.scene-svg .nb:hover { opacity: .75; }
.scene-svg .nb-label { font-size: calc(var(--px) * 13px); font-weight: 600; fill: var(--ink);
  paint-order: stroke; stroke: var(--bg); stroke-width: calc(var(--px) * 4px); }
.marks { position: absolute; inset: 0; pointer-events: none; }
.marks > * { position: absolute; transform: translate(-50%, -50%); pointer-events: auto; }
.mk {
  display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; padding: 0; cursor: pointer;
  background: var(--c); color: var(--panel); border: 2px solid var(--c); box-shadow: 0 1px 4px rgba(0, 0, 0, .3);
}
.mk .icon { width: 15px; height: 15px; }
.mk.check { background: var(--panel); color: var(--c); border-style: dashed; }
.mk.check.found { background: var(--c); color: var(--panel); border-style: solid; }
.mk.done { opacity: .35; }
.mk:hover, .mk:focus-visible { outline: 3px solid color-mix(in srgb, var(--c) 40%, transparent); }
.mk.flash { animation: pulse 1.2s ease-out 2; }
@keyframes pulse { 50% { transform: translate(-50%, -50%) scale(1.35); } }
.xi.on-plan .xi-btn { width: 34px; height: 34px; font-size: 18px; border-color: var(--c-passage); color: var(--c-passage); }
.xi.on-plan .xi-btn:hover, .xi.on-plan:focus-within .xi-btn { background: var(--c-passage); color: var(--panel); }
.xi.on-plan.is-hidden .xi-btn { border-color: var(--hidden); color: var(--hidden); }

/* Legend drawer */
.legend { position: absolute; z-index: 25; left: calc(max(20%, 230px) + 10px); bottom: 10px; max-width: 330px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 4px 16px rgba(0, 0, 0, .18); font-size: 13px; }
.legend > summary { cursor: pointer; padding: 6px 12px; font-weight: 600; }
.legend-body { padding: 4px 12px 10px; }
.legend ul { list-style: none; margin: 4px 0; padding: 0; display: grid; gap: 4px; }
.legend-types { grid-template-columns: 1fr 1fr; }
.legend li { display: flex; align-items: center; gap: 8px; }
.legend .sw { width: 14px; height: 14px; border-radius: 50%; background: var(--c); flex: none; }
.mk-demo { width: 16px; height: 16px; border-radius: 50%; background: var(--c-trap); border: 2px solid var(--c-trap); flex: none; }
.mk-demo.check { background: transparent; border-style: dashed; }
.mk-demo.done { opacity: .35; }
.xi-demo { display: grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--c-passage); color: var(--c-passage); font-size: 12px; flex: none; }
.xi-demo.hidden { border-style: dashed; border-color: var(--hidden); color: var(--hidden); }
.wall-demo { width: 18px; border-top: 3px solid var(--ink); flex: none; }
.door-demo { width: 18px; border-top: 3px dashed var(--c-passage); flex: none; }
.legend-scale { margin: 6px 0 0; color: var(--quiet); }

/* Mini-map on demand */
.map-btn[aria-expanded="true"] { border-color: var(--accent); color: var(--accent); }
.map-key { margin: 0; padding: 6px 12px; font-size: 12px; color: var(--quiet); display: flex; gap: 8px; align-items: center; border-top: 1px solid var(--line); }
.map-key .sw { width: 12px; height: 12px; border-radius: 3px; border: 1px solid var(--line); }
.map-key .sw.visited { background: var(--read-soft); border: 2px solid var(--read); color: var(--read); font-size: 9px; font-weight: 700; display: inline-grid; place-items: center; }
.map-hint { margin-left: auto; font-style: italic; }
.vis-demo { display: inline-grid; place-items: center; width: 18px; height: 14px; border: 2px solid var(--read); background: var(--read-soft); color: var(--read); font-size: 10px; font-weight: 700; border-radius: 3px; flex: none; }
.xi-demo .icon { width: 13px; height: 13px; }
.map-key .sw.unvisited { background: var(--panel); opacity: .5; }
.map-svg.is-plan .room-plan .c-floor { fill: var(--bg); stroke: none; }
.map-svg.is-plan .room-plan.unvisited { opacity: .3; }
.map-svg .plan-label.visited text { fill: var(--read); }
.map-svg .plan-label.unvisited { opacity: .45; }
.map-svg.is-plan .room-plan.visited .c-floor { fill: var(--read-soft); }
.map-svg.is-plan .room-plan.here .c-floor { fill: var(--accent-soft); }
.map-svg.is-plan .room-plan.here { opacity: 1; }
.map-svg.is-plan .room-plan:hover .c-floor { fill: var(--dm-soft); }
.map-svg.is-plan .room-plan { cursor: pointer; }
.map-svg .c-solid { fill: color-mix(in srgb, var(--ink) 45%, var(--bg)); }
.map-svg .plan-label { pointer-events: none; }
.map-svg .plan-label text { font-size: 13px; font-weight: 600; fill: var(--ink); paint-order: stroke; stroke: var(--panel); stroke-width: 4px; stroke-linejoin: round; }
.map-svg .node.unvisited { opacity: .35; }

/* Map / scenario switch */
.modes { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; flex: none; }
.modes button { border: 0; background: var(--bg); padding: 6px 14px; font: inherit; font-size: 14px; color: var(--ink); cursor: pointer; }
.modes button + button { border-left: 1px solid var(--line); }
.modes button[aria-pressed="true"] { background: var(--accent); color: var(--panel); font-weight: 600; }
.modes button:not([aria-pressed="true"]):hover { background: var(--accent-soft); }
body[data-view="scenario"] .crumbbar { display: none; }

/* Scenario: quests on the left, the scene graph in the middle, the card on the right */
.scenario { flex: 1 1 auto; min-height: 0; display: grid; grid-template-columns: minmax(230px, 19%) minmax(0, 1fr) minmax(300px, 27%); }
.scenario[hidden] { display: none; }
.sc-side, .sc-detail { overflow-y: auto; padding: 14px 16px 48px; min-height: 0; }
.sc-side { border-right: 1px solid var(--line); }
.sc-detail { border-left: 1px solid var(--line); }
.sc-side h2 { margin: 0 0 10px; font-size: 21px; }
.sc-side h3, .sc-card h3 { display: flex; align-items: center; gap: 6px; margin: 18px 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--quiet); }
.sc-q { display: flex; align-items: center; gap: 6px; width: 100%; padding: 5px 8px; border: 1px solid transparent; border-radius: 7px;
  background: none; font: inherit; font-size: 14px; color: var(--ink); text-align: left; cursor: pointer; }
.sc-q:hover { border-color: var(--line); background: var(--panel); }
.sc-q.on { border-color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.sc-q-name { flex: 1 1 auto; min-width: 0; }
.count { flex: none; min-width: 20px; padding: 0 6px; border-radius: 999px; background: var(--line); color: var(--ink); text-align: center; font-size: 11px; font-weight: 600; }
.count.short { background: var(--c-trap); color: var(--panel); }
.st.warn { color: var(--c-trap); border: 1px solid var(--c-trap); }
.sc-tree, .sc-tree ul { list-style: none; margin: 2px 0; padding: 0; }
.sc-tree ul { padding-left: 14px; border-left: 2px solid var(--line); margin-left: 10px; }
.sc-key { list-style: none; margin: 4px 0; padding: 0; display: grid; gap: 6px; font-size: 13px; color: var(--quiet); }
.sc-key li { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.pill-demo { padding: 0 7px; border-radius: 999px; font-size: 11px; font-weight: 600; background: var(--line); color: var(--ink); }
.pill-demo.start { background: var(--read); color: var(--panel); } .pill-demo.end { background: var(--ink); color: var(--panel); }
.pill-demo.proactive { background: var(--c-event); color: var(--panel); } .pill-demo.short { background: var(--c-trap); color: var(--panel); }
.edge-demo { width: 26px; border-top: 2.5px solid var(--c-clue); flex: none; }
.edge-demo.unfound { border-top-style: dashed; opacity: .5; }
.node-demo { display: inline-grid; place-items: center; width: 22px; height: 14px; border-radius: 4px; border: 1.5px solid var(--ink); font-size: 10px; font-weight: 700; flex: none; }
.node-demo.ghost { border-style: dashed; opacity: .55; }
.node-demo.reached { border: 2px solid var(--read); background: var(--read-soft); color: var(--read); }
.sc-side .map-hint { margin: 12px 0 0; font-size: 13px; color: var(--quiet); }

.sc-mid { position: relative; min-height: 0; min-width: 0; display: grid; }
.sc-zoom { position: absolute; z-index: 5; top: 10px; right: 18px; display: flex; gap: 4px; }
.sc-zoom .btn { padding: 3px 10px; box-shadow: var(--shadow); }
.sc-graph { overflow: auto; min-height: 0; display: grid; }
.sc-svg { margin: auto; display: block; }
.sc-empty { margin: auto; padding: 24px; color: var(--quiet); text-align: center; }
.sc-band rect { fill: color-mix(in srgb, var(--panel) 60%, transparent); stroke: var(--line); }
.sc-band text { font-size: 13px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; fill: var(--quiet); cursor: pointer; }
.sc-band text:hover { fill: var(--accent); }
.sc-node { cursor: pointer; outline: none; }
.sc-node > rect { fill: var(--panel); stroke: var(--ink); stroke-width: 1.5; }
.sc-node > text { fill: var(--ink); font-size: 14px; font-weight: 600; }
.sc-node > text.sub { fill: var(--quiet); font-size: 11.5px; font-weight: 400; font-style: italic; }
.sc-node:hover > rect, .sc-node:focus-visible > rect { stroke: var(--accent); stroke-width: 2.5; }
.sc-node.selected > rect { fill: var(--accent-soft); stroke: var(--accent); stroke-width: 3; }
.sc-node.ghost > rect { stroke-dasharray: 5 4; fill: var(--bg); }
.sc-node.ghost { opacity: .7; }
.sc-node.reached > rect { fill: var(--read-soft); stroke: var(--read); stroke-width: 3; }
.sc-node.reached.selected > rect { stroke: var(--accent); }
.sc-node.unreached:not(.selected) { opacity: .55; }
.pill rect { fill: var(--line); }
.pill text { font-size: 10.5px; font-weight: 700; fill: var(--ink); }
.pill.start rect { fill: var(--read); } .pill.end rect { fill: var(--ink); } .pill.proactive rect { fill: var(--c-event); }
.pill.start text, .pill.end text, .pill.proactive text, .pill.short text { fill: var(--panel); }
.pill.short rect { fill: var(--c-trap); }
.sc-edge { cursor: pointer; }
.sc-edge .hit { fill: none; stroke: transparent; stroke-width: 14; }
.sc-edge .line { fill: none; stroke: var(--c-clue); stroke-width: 2.2; }
.sc-edge.loop .line { stroke-dasharray: 9 3; }
.sc-edge.unfound .line { stroke-dasharray: 4 5; opacity: .45; }
.sc-edge:hover .line, .sc-edge.selected .line { stroke: var(--accent); stroke-width: 3.5; opacity: 1; }
.sc-edge circle { fill: var(--panel); stroke: var(--c-clue); stroke-width: 1.5; }
.sc-edge text { font-size: 11px; font-weight: 700; fill: var(--c-clue); }
.sc-arrow path { fill: var(--c-clue); }

.sc-card h2 { margin: 2px 0 6px; font-size: 21px; }
.sc-crumb { font-size: 12px; color: var(--quiet); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.sc-card .md, .sc-card .notes { font-size: 14px; }
.sc-card .children .child { font-size: 14px; }
.chip.k-start { border-color: var(--read); color: var(--read); background: var(--read-soft); }
.chip.k-end { border-color: var(--ink); color: var(--ink); }
.chip.k-proactive { border-color: var(--c-event); color: var(--c-event); }
.sc-card .chips .flags { margin-left: 0; }
.sc-warn { margin: 4px 0 8px; padding: 6px 10px; border-radius: 6px; font-size: 13px; color: var(--c-trap); background: color-mix(in srgb, var(--c-trap) 10%, var(--panel)); border-left: 4px solid var(--c-trap); }
.acc > summary > .acc-name { flex: 1 1 auto; min-width: 0; font-size: 14px; font-weight: 600; color: var(--ink); text-transform: none; letter-spacing: 0; }
.acc > summary > .acc-lead { flex: none; max-width: 50%; color: var(--quiet); font-size: 12px; font-weight: 400; text-transform: none; letter-spacing: 0; text-align: right; }
.acc.found > summary > .acc-name { color: var(--read); }
.acc-where { padding: 0 12px 8px; font-size: 13px; color: var(--quiet); }
.sc-card .objects { grid-template-columns: minmax(0, 1fr); }
.scenes-here { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 6px 0; }
.scene-chip { padding: 2px 10px; border-radius: 999px; border: 1px solid var(--accent); background: var(--accent-soft); color: var(--accent);
  font: inherit; font-size: 13px; cursor: pointer; }
.scene-chip:hover { background: var(--accent); color: var(--panel); }
.scene-chip.reached { border-color: var(--read); background: var(--read-soft); color: var(--read); }
.obj .sc-line .link { font-size: 13px; }

@media (max-width: 900px) {
  .scenario { display: block; overflow-y: auto; }
  .sc-side, .sc-detail { border: 0; overflow: visible; }
  .sc-graph { height: 60vh; border-block: 1px solid var(--line); }
}

@media (max-width: 900px) {
  .side, .detail { position: static; width: auto; min-width: 0; border: 0; }
  .stage.planned { overflow-y: auto; }
  .stage.planned .plan-area { position: relative; left: 0; right: 0; height: 60vh; }
  .legend { left: 10px; }
}
