/* 国王密令 IV · 3D 地图
   Dark ruin palette: wet stone, aged bone, tarnished brass, ember and verdigris routes. */
:root {
  color-scheme: dark;
  --font-serif: "Trajan Pro", "Cinzel", "Optima", "Palatino Linotype", "Book Antiqua", Palatino,
                "Noto Serif SC", "Source Han Serif SC", "Songti SC", "STSong", "SimSun", serif;
  --font-sans: "Noto Sans SC", "PingFang SC", "Microsoft YaHei UI", "Microsoft YaHei",
               "Segoe UI", "Helvetica Neue", Arial, sans-serif;

  --void: #0b0d0a;
  --fog: #0d100d;          /* matches the WebGL clear colour */
  --crypt: #12150f;
  --stone: #191d16;
  --stone-2: #232820;
  --moss: #5f6a52;

  --bone: #ddd4b8;
  --bone-dim: #a8a088;
  --bone-faint: #7d7861;

  --brass: #b08d4c;
  --brass-hi: #d9b86c;
  --brass-lo: #5f4c2a;
  --brass-wash: rgba(176, 141, 76, .16);

  --ember: #d9532c;
  --ember-hi: #f26a3a;
  --verdigris: #52b5a3;

  --rule: rgba(176, 141, 76, .22);
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .86 0 0 0 0 .82 0 0 0 0 .7 0 0 0 .16 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  --ease: cubic-bezier(.22, .61, .36, 1);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  height: 100dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  font-family: var(--font-sans);
  font-size: 13px;
  color: var(--bone);
  background:
    radial-gradient(120% 90% at 30% 0%, #1a1f16 0%, var(--void) 62%) fixed,
    var(--void);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
h1, h2, h3, p { margin: 0; }
[hidden] { display: none !important; }
::selection { background: var(--brass); color: var(--void); }
* { scrollbar-width: thin; scrollbar-color: var(--brass-lo) transparent; }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--brass-lo); }
::-webkit-scrollbar-thumb:hover { background: var(--brass); }

button, input, select { font: inherit; color: inherit; }
button {
  border: 0; border-radius: 0; background: transparent;
  min-height: 0; padding: 0; cursor: pointer;
  transition: background .16s var(--ease), color .16s var(--ease), border-color .16s var(--ease);
}
button:disabled { opacity: .3; cursor: default; }
:focus-visible { outline: 2px solid var(--brass-hi); outline-offset: 2px; }
canvas:focus-visible { outline-offset: -4px; }

.kicker { font-family: var(--font-serif); font-size: 12px; letter-spacing: .12em; color: var(--brass); line-height: 1.4; }

/* ── Title bar ────────────────────────────────────────────────── */
.topbar {
  flex: none; height: 60px;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px;
  background: var(--grain), linear-gradient(#1b2017, var(--crypt));
  border-bottom: 1px solid var(--brass-lo);
  box-shadow: 0 1px 0 #000, 0 2px 0 rgba(176, 141, 76, .18);
  position: relative; z-index: 5;
}
.wordmark { display: flex; align-items: center; gap: 16px; min-width: 0; }
.mark {
  position: relative; width: 20px; height: 20px; flex: none;
  border: 1px solid var(--brass); transform: rotate(45deg);
  box-shadow: 0 0 0 3px var(--crypt), 0 0 0 4px var(--brass-lo);
}
.mark::after { content: ""; position: absolute; inset: 5px; background: var(--ember); box-shadow: 0 0 10px rgba(242, 106, 58, .7); }
.wordmark-text { display: flex; flex-direction: column; gap: 5px; }
h1 {
  font-family: var(--font-serif); font-size: 21px; font-weight: 700; line-height: 1;
  letter-spacing: .2em; white-space: nowrap; color: var(--bone);
  text-shadow: 0 1px 0 #000, 0 0 14px rgba(217, 184, 108, .22);
}
.wordmark-text p { font-size: 11px; letter-spacing: .14em; color: var(--bone-dim); white-space: nowrap; }

.views { display: flex; align-items: stretch; height: 100%; }
.views button {
  position: relative; height: 100%; padding: 0 18px;
  font-family: var(--font-serif); font-size: 13px; letter-spacing: .14em; color: var(--bone-dim);
}
.views button:hover { color: var(--bone); background: linear-gradient(transparent 40%, var(--brass-wash)); }
.views button[aria-pressed="true"] { color: var(--brass-hi); background: linear-gradient(transparent 20%, var(--brass-wash)); }
.views button[aria-pressed="true"]::after {
  content: ""; position: absolute; left: 14px; right: 14px; bottom: -1px;
  height: 2px; background: var(--brass-hi); box-shadow: 0 0 8px rgba(217, 184, 108, .6);
}
.views-rule { width: 1px; height: 18px; align-self: center; background: var(--brass-lo); margin: 0 8px; }
.views .reset { color: var(--bone); }

/* ── Stage: map window + codex ───────────────────────────────── */
.stage {
  flex: 1; min-height: 0;
  display: grid; grid-template-columns: minmax(0, 1fr) clamp(320px, 27vw, 400px);
  gap: 14px; padding: 14px;
}

.viewport {
  position: relative; min-width: 0; min-height: 0; overflow: hidden;
  background: var(--fog);
  border: 1px solid var(--brass-lo);
}
/* inner double frame (corner filigree is the .corner SVG) */
.viewport::before {
  content: ""; position: absolute; inset: 5px; z-index: 1; pointer-events: none;
  border: 1px solid rgba(176, 141, 76, .34);
  box-shadow: inset 0 0 0 3px rgba(11, 13, 10, .55), inset 0 0 0 4px rgba(176, 141, 76, .16);
}
/* vignette, so the model sinks into the dark */
.viewport::after {
  content: ""; position: absolute; inset: 0; z-index: 1; pointer-events: none;
  background: radial-gradient(ellipse at 50% 46%, transparent 52%, rgba(5, 7, 5, .62) 100%);
}
canvas {
  display: block; width: 100%; height: 100%; touch-action: none; cursor: grab;
  animation: fog-lift 1.6s var(--ease) both;
}
canvas:active { cursor: grabbing; }
.plan-map { position: absolute; inset: 0; z-index: 0; pointer-events: none; animation: none; }
.viewport.first-person canvas { cursor: crosshair; }
.crosshair {
  display: none; position: absolute; left: 50%; top: 50%; z-index: 2;
  width: 9px; height: 9px; transform: translate(-50%, -50%); pointer-events: none;
  border: 1px solid var(--bone); border-radius: 50%; box-shadow: 0 0 0 1px var(--void);
}
.viewport.first-person .crosshair { display: block; }
@keyframes fog-lift { from { opacity: 0; filter: brightness(.35) blur(6px); } to { opacity: 1; filter: none; } }

.map-caption {
  position: absolute; left: 56px; bottom: 20px; z-index: 2;
  padding: 6px 10px; pointer-events: none;
  background: rgba(11, 13, 10, .82); border: 1px solid var(--brass-lo); border-left: 2px solid var(--brass);
  font-size: 12px; letter-spacing: .04em; color: var(--bone-dim); white-space: nowrap;
}
.zoom { position: absolute; right: 22px; bottom: 56px; z-index: 3; display: grid; }
.zoom button, .move-pad button {
  width: 34px; height: 34px; display: grid; place-items: center;
  border: 1px solid var(--brass-lo); background: rgba(11, 13, 10, .86); color: var(--bone);
  font-size: 16px; line-height: 1;
}
.zoom button + button { border-top: 0; }
.zoom button:hover, .move-pad button:hover { background: var(--brass); border-color: var(--brass-hi); color: var(--void); }

.move-pad {
  position: absolute; right: 22px; bottom: 56px; z-index: 3; display: none;
  grid-template-columns: repeat(3, 42px); gap: 4px; touch-action: none;
}
.move-pad button { width: auto; min-height: 42px; }
.move-pad button:first-child { grid-column: 2; }
.move-pad button:nth-child(2) { grid-column: 1; }

.route-points { position: absolute; inset: 0; z-index: 2; pointer-events: none; }
.route-point {
  position: absolute; width: 20px; height: 20px; transform: translate(-50%, -50%); pointer-events: auto;
}
.route-point::after {
  content: ""; display: block; margin: auto; width: 8px; height: 8px; border-radius: 50%;
  background: var(--bone); border: 1px solid var(--ember); box-shadow: 0 0 0 1px var(--void);
}
.route-point.optional::after { border-color: var(--verdigris); }
.route-point:hover, .route-point:focus-visible, .route-point[aria-current="true"] { z-index: 1; }
.route-point:hover::after, .route-point:focus-visible::after, .route-point[aria-current="true"]::after {
  background: var(--ember-hi); border-color: var(--bone); transform: scale(1.35);
}

.pin {
  position: absolute; z-index: 2; transform: translate(-50%, -100%);
  padding: 4px 9px; border: 1px solid #7c2a14; border-radius: 0;
  background: var(--ember); color: #fff3e0;
  font-family: var(--font-serif); font-size: 12px; font-weight: 700; letter-spacing: .06em; white-space: nowrap;
  box-shadow: 0 0 14px rgba(242, 106, 58, .45);
}
.pin:hover { background: var(--ember-hi); }
.pin::after {
  content: ""; position: absolute; border: 5px solid transparent;
  border-top-color: var(--ember); top: 100%; left: calc(50% - 5px);
}
.landmark-pin { background: rgba(11, 13, 10, .92); color: var(--bone); border: 1px solid var(--brass); box-shadow: none; }
.landmark-pin:hover { background: var(--brass); color: var(--void); }
.landmark-pin::after { border-top-color: var(--brass); }

.detail {
  position: absolute; top: 26px; left: 56px; z-index: 4;
  width: 320px; max-width: calc(100% - 36px);
  padding: 16px 18px 17px;
  background: rgba(13, 16, 12, .92); backdrop-filter: blur(3px);
  border: 1px solid var(--brass-lo); border-top: 2px solid var(--brass);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .55), inset 0 0 0 3px var(--fog), inset 0 0 0 4px rgba(176, 141, 76, .2);
}
.detail-close {
  position: absolute; top: 10px; right: 10px;
  width: 24px; height: 24px; display: grid; place-items: center;
  border: 1px solid var(--brass-lo); font-size: 14px; line-height: 1; color: var(--bone-dim);
}
.detail-close:hover { background: var(--brass); border-color: var(--brass-hi); color: var(--void); }
#detail-area { font-family: var(--font-serif); font-size: 12px; letter-spacing: .1em; color: var(--brass-hi); }
#detail-title { font-family: var(--font-serif); font-size: 18px; font-weight: 700; line-height: 1.3; margin: 7px 0 9px; padding-right: 30px; color: var(--bone); }
#detail-note { font-size: 12.5px; line-height: 1.8; color: var(--bone-dim); }

.error {
  position: absolute; inset: 36% 12% auto; z-index: 4;
  padding: 16px 18px; text-align: center;
  background: rgba(13, 16, 12, .95); border: 1px solid var(--ember);
  font-size: 13px; line-height: 1.7; color: var(--bone);
}

/* ── Codex panel ──────────────────────────────────────────────── */
.codex {
  position: relative; min-width: 0; min-height: 0; display: flex; flex-direction: column;
  background: var(--grain), linear-gradient(#1b2017, var(--crypt) 55%);
  border: 1px solid var(--brass-lo);
  box-shadow: inset 0 0 0 4px var(--crypt), inset 0 0 0 5px rgba(176, 141, 76, .26);
}

.chapter-band {
  flex: none;
  display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; column-gap: 16px; row-gap: 12px;
  padding: 22px 22px 16px;
}
.chapter-index {
  font-family: var(--font-serif); font-size: 54px; font-weight: 700; line-height: .9;
  font-variant-numeric: lining-nums tabular-nums; color: var(--brass-hi);
  text-shadow: 0 2px 0 #000, 0 0 18px rgba(217, 184, 108, .25);
  min-width: 1.7em; text-align: center; padding: 12px 10px 10px;
  background: radial-gradient(circle at 50% 30%, rgba(176, 141, 76, .16), rgba(0, 0, 0, .35));
  border: 1px solid var(--brass);
  box-shadow: inset 0 0 0 3px var(--crypt), inset 0 0 0 4px rgba(176, 141, 76, .45), 0 2px 8px rgba(0, 0, 0, .5);
}
.chapter-text { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.chapter-text h2 {
  font-family: var(--font-serif); font-size: 19px; font-weight: 700; line-height: 1.35; letter-spacing: .03em; color: var(--bone);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.legend { grid-column: 1 / -1; display: flex; align-items: center; gap: 22px; }
.legend span { display: inline-flex; align-items: center; gap: 8px; font-size: 12px; color: var(--bone-dim); white-space: nowrap; }
.legend i { display: inline-block; width: 24px; height: 0; border-top: 3px solid var(--ember-hi); box-shadow: 0 0 8px rgba(242, 106, 58, .5); }
.legend i.dashed { border-top: 3px dashed var(--verdigris); box-shadow: none; }

.controls { flex: none; }
.control-group { display: flex; align-items: center; gap: 10px; min-height: 46px; padding: 7px 22px; position: relative; }
.control-label { flex: none; width: 34px; font-family: var(--font-serif); font-size: 12px; letter-spacing: .1em; color: var(--brass); white-space: nowrap; }

.chapter-controls select {
  flex: 1; min-width: 0; height: 32px;
  border: 1px solid var(--brass-lo); border-radius: 0;
  background-color: rgba(0, 0, 0, .35); color: var(--bone);
  font-size: 13px; padding: 0 28px 0 10px;
  appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23d9b86c' stroke-width='1.3'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
  cursor: pointer; text-overflow: ellipsis;
}
.chapter-controls select:hover, .chapter-controls select:focus { border-color: var(--brass); }
.chapter-controls select option { background: var(--crypt); color: var(--bone); }
.chapter-controls button {
  flex: none; width: 32px; height: 32px; display: grid; place-items: center;
  border: 1px solid var(--brass-lo); color: var(--bone); font-size: 17px; line-height: 1;
}
.chapter-controls button:hover:not(:disabled) { background: var(--brass); border-color: var(--brass-hi); color: var(--void); }

.check { display: inline-flex; align-items: center; gap: 8px; color: var(--bone); cursor: pointer; user-select: none; font-size: 13px; }
.layers { gap: 14px; flex-wrap: wrap; }
.layers .control-label { margin-right: -8px; }
.check.compact { font-size: 12px; color: var(--bone-dim); }
input[type="checkbox"] {
  appearance: none; -webkit-appearance: none;
  width: 15px; height: 15px; margin: 0; flex: none;
  display: inline-grid; place-content: center;
  border: 1px solid var(--brass); border-radius: 0; background: rgba(0, 0, 0, .35);
  cursor: pointer;
}
input[type="checkbox"]::before {
  content: ""; width: 8px; height: 4px; margin-top: -2px;
  border-left: 2px solid var(--void); border-bottom: 2px solid var(--void);
  transform: rotate(-45deg) scale(0); transition: transform .14s var(--ease);
}
input[type="checkbox"]:checked { background: var(--brass-hi); border-color: var(--brass-hi); }
input[type="checkbox"]:checked::before { transform: rotate(-45deg) scale(1); }

.cutaway input[type="range"] { flex: 1; min-width: 0; }
.cutaway output { flex: none; min-width: 40px; text-align: right; font-size: 12px; font-variant-numeric: tabular-nums; color: var(--bone); }
input[type="range"] { appearance: none; -webkit-appearance: none; height: 20px; background: transparent; cursor: pointer; }
input[type="range"]::-webkit-slider-runnable-track { height: 2px; background: var(--brass-lo); }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 11px; height: 11px; margin-top: -4.5px;
  border: 1px solid var(--void); border-radius: 0; background: var(--brass-hi); transform: rotate(45deg);
}
input[type="range"]::-moz-range-track { height: 2px; background: var(--brass-lo); }
input[type="range"]::-moz-range-thumb { width: 10px; height: 10px; border: 1px solid var(--void); border-radius: 0; background: var(--brass-hi); transform: rotate(45deg); }

.search-group input[type="search"] {
  flex: 1; min-width: 0; height: 32px; padding: 0 10px;
  border: 1px solid var(--brass-lo); border-radius: 0; background: rgba(0, 0, 0, .35);
  font-size: 13px; color: var(--bone);
}
.search-group input[type="search"]::placeholder { color: var(--bone-faint); }
.search-group input[type="search"]:focus { outline: none; border-color: var(--brass-hi); background: rgba(0, 0, 0, .5); }
.search-group input[type="search"]::-webkit-search-cancel-button { filter: sepia(1) brightness(1.2); cursor: pointer; }

/* ── Route list: a game-menu column with a diamond cursor ───── */
.steps-wrap { flex: 1; min-height: 0; display: flex; flex-direction: column; position: relative; }
.steps-head { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 22px 8px; }
.step-list { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; padding: 0 12px 14px; }
.step {
  position: relative; width: 100%;
  display: block; padding: 9px 12px 9px 32px;
  border-left: 2px solid transparent; border-bottom: 1px solid rgba(221, 212, 184, .06);
  color: var(--bone); text-align: left;
}
.step:hover { background: rgba(176, 141, 76, .09); }
.step[aria-current="true"] {
  background: linear-gradient(90deg, rgba(176, 141, 76, .26), rgba(176, 141, 76, .04));
  border-left-color: var(--brass-hi);
}
.step > span:first-child { position: absolute; left: 12px; top: 50%; width: 10px; height: 10px; margin-top: -5px; font-size: 0; }
.step > span:first-child::before {
  content: ""; display: block; width: 8px; height: 8px; margin: 1px;
  border: 1px solid var(--bone-faint); transform: rotate(45deg) scale(.7);
}
.step.landmark > span:first-child::before { border-color: var(--brass); transform: rotate(45deg); }
.step.optional > span:first-child::before { border-color: var(--verdigris); }
.step[aria-current="true"] > span:first-child::before { background: var(--ember-hi); border-color: var(--ember-hi); box-shadow: 0 0 9px rgba(242, 106, 58, .8); transform: rotate(45deg); }
.step > span:nth-child(2) { display: block; min-width: 0; }
.step strong {
  display: block; font-size: 13.5px; font-weight: 500; line-height: 1.4; color: var(--bone-dim);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-right: 44px;
}
.step.landmark strong { color: var(--bone); font-weight: 600; }
.step[aria-current="true"] strong { color: var(--brass-hi); }
.step small { display: block; margin-top: 2px; font-size: 11.5px; line-height: 1.4; color: var(--bone-faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.step[aria-current="true"] small { color: var(--bone-dim); }
.step.optional::after {
  content: "支线"; position: absolute; top: 10px; right: 10px;
  padding: 0 5px; font-size: 11px; line-height: 17px; color: var(--verdigris); border: 1px solid rgba(82, 181, 163, .5);
}
.empty { padding: 18px 12px; font-size: 12.5px; line-height: 1.7; color: var(--bone-dim); }

/* ── Ornament layer ───────────────────────────────────────────── */
.defs { position: absolute; width: 0; height: 0; overflow: hidden; }
.corner {
  position: absolute; z-index: 2; width: 44px; height: 44px; pointer-events: none;
  color: var(--brass-hi); fill: none; stroke: currentColor; stroke-linecap: round;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, .8));
}
.corner.tl { top: 3px; left: 3px; }
.corner.tr { top: 3px; right: 3px; transform: scaleX(-1); }
.corner.bl { bottom: 3px; left: 3px; transform: scaleY(-1); }
.corner.br { bottom: 3px; right: 3px; transform: scale(-1, -1); }
.codex .corner { width: 28px; height: 28px; color: var(--brass); z-index: 3; }
.codex .corner.tl, .codex .corner.tr { top: 2px; } .codex .corner.bl, .codex .corner.br { bottom: 2px; }
.codex .corner.tl, .codex .corner.bl { left: 2px; } .codex .corner.tr, .codex .corner.br { right: 2px; }

/* graduated rules along the map frame */
.ruler { position: absolute; z-index: 1; pointer-events: none; opacity: .5; }
.ruler.x { left: 64px; right: 64px; height: 7px; }
.ruler.y { top: 64px; bottom: 64px; width: 7px; }
.ruler.x.top { top: 8px; background:
  repeating-linear-gradient(90deg, var(--brass) 0 1px, transparent 1px 10px) top / 100% 3px no-repeat,
  repeating-linear-gradient(90deg, var(--brass-hi) 0 1px, transparent 1px 50px) top / 100% 7px no-repeat; }
.ruler.x.bottom { bottom: 8px; background:
  repeating-linear-gradient(90deg, var(--brass) 0 1px, transparent 1px 10px) bottom / 100% 3px no-repeat,
  repeating-linear-gradient(90deg, var(--brass-hi) 0 1px, transparent 1px 50px) bottom / 100% 7px no-repeat; }
.ruler.y.left { left: 8px; background:
  repeating-linear-gradient(180deg, var(--brass) 0 1px, transparent 1px 10px) left / 3px 100% no-repeat,
  repeating-linear-gradient(180deg, var(--brass-hi) 0 1px, transparent 1px 50px) left / 7px 100% no-repeat; }
.ruler.y.right { right: 8px; background:
  repeating-linear-gradient(180deg, var(--brass) 0 1px, transparent 1px 10px) right / 3px 100% no-repeat,
  repeating-linear-gradient(180deg, var(--brass-hi) 0 1px, transparent 1px 50px) right / 7px 100% no-repeat; }

/* compass: needle follows the camera heading (set from viewer.js) */
.compass { position: absolute; top: 36px; right: 42px; z-index: 2; width: 84px; display: grid; justify-items: center; gap: 3px; pointer-events: none; }
.compass svg { width: 84px; height: 84px; filter: drop-shadow(0 3px 8px rgba(0, 0, 0, .65)); }
.compass span { font-family: var(--font-serif); font-size: 11px; letter-spacing: .14em; color: var(--brass); text-shadow: 0 1px 2px #000; }
.compass .needle { transform-origin: 40px 40px; transform: rotate(var(--rot, 0deg)); }

/* header flourish and panel foot */
.ornament {
  background:
    url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='72' height='11' viewBox='0 0 72 11'%3E%3Cpath d='M36 .5l5 5-5 5-5-5z' fill='%23d9b86c'/%3E%3Cpath d='M36 3l2.5 2.5L36 8l-2.5-2.5z' fill='%230b0d0a'/%3E%3Cpath d='M20 5.5l3-3 3 3-3 3zM46 5.5l3-3 3 3-3 3z' fill='none' stroke='%23b08d4c'/%3E%3Cpath d='M2 5.5h14M56 5.5h14' stroke='%23b08d4c'/%3E%3C/svg%3E") center / 72px 11px no-repeat,
    linear-gradient(90deg, transparent, var(--brass-lo) 30%, var(--brass-lo)) left center / calc(50% - 36px) 1px no-repeat,
    linear-gradient(270deg, transparent, var(--brass-lo) 30%, var(--brass-lo)) right center / calc(50% - 36px) 1px no-repeat;
}
.flourish { flex: 1; height: 11px; margin: 0 32px; min-width: 60px; }
.ornament.foot { flex: none; height: 22px; margin: 0 18px; opacity: .85; }

/* engraved dividers between control rows */
.control-group::before, .steps-wrap::before {
  content: ""; position: absolute; top: 0; left: 18px; right: 18px; height: 1px;
  background: linear-gradient(90deg, transparent, var(--brass-lo) 14%, var(--brass-lo) 86%, transparent);
}
.control-group::after, .steps-wrap::after {
  content: ""; position: absolute; top: -3px; left: calc(50% - 3px); width: 6px; height: 6px;
  background: var(--crypt); border: 1px solid var(--brass); transform: rotate(45deg);
}
.control-group:first-child::before, .control-group:first-child::after { display: none; }

/* chapter jump pips */
.pips { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 2px; margin: 0 -3px; }
.pips button { position: relative; width: 14px; height: 14px; }
.pips button::before {
  content: ""; position: absolute; inset: 3px; transform: rotate(45deg);
  border: 1px solid var(--brass-lo); background: rgba(0, 0, 0, .3);
}
.pips button:hover::before { border-color: var(--brass-hi); background: var(--brass-wash); }
.pips button[aria-current="true"]::before { background: var(--ember-hi); border-color: var(--ember-hi); box-shadow: 0 0 9px rgba(242, 106, 58, .85); inset: 2px; }

/* bevelled buttons, recessed fields */
.chapter-controls button, .zoom button, .move-pad button, .detail-close {
  background: linear-gradient(rgba(217, 184, 108, .13), rgba(0, 0, 0, .35));
  box-shadow: inset 0 1px 0 rgba(217, 184, 108, .28), inset 0 -1px 0 rgba(0, 0, 0, .6);
}
.chapter-controls select, .search-group input[type="search"] {
  box-shadow: inset 0 2px 5px rgba(0, 0, 0, .7), 0 1px 0 rgba(217, 184, 108, .14);
}
input[type="checkbox"] { box-shadow: inset 0 1px 3px rgba(0, 0, 0, .7); }
.cutaway output {
  padding: 3px 6px; background: rgba(0, 0, 0, .4); border: 1px solid var(--brass-lo);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, .7);
}
.views button + button::before {
  content: ""; position: absolute; left: -2px; top: 50%; width: 3px; height: 3px; margin-top: -1.5px;
  background: var(--brass-lo); transform: rotate(45deg);
}
.views .views-rule + button::before { display: none; }

/* route list: a rail the waypoints hang from */
.steps-head { gap: 10px; }
.steps-head .kicker { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; }
.steps-head .kicker::before { content: ""; width: 7px; height: 7px; flex: none; background: var(--brass); transform: rotate(45deg) scale(.8); }
.steps-head .count { font-size: 12px; color: var(--bone-faint); font-variant-numeric: tabular-nums; white-space: nowrap; }
.step::before {
  content: ""; position: absolute; left: 16px; top: 0; bottom: -1px; width: 1px;
  background: linear-gradient(var(--brass-lo), var(--brass-lo));
}
.step:first-of-type::before { top: 50%; }
.step:last-of-type::before { bottom: 50%; }
.step > span:first-child::before { background: #161a13; }
.step[aria-current="true"] > span:first-child::before { background: var(--ember-hi); }

/* detail window */
.detail::before, .detail::after {
  content: ""; position: absolute; width: 7px; height: 7px; background: var(--brass-hi); transform: rotate(45deg);
  top: -4px; box-shadow: 0 0 0 2px var(--fog);
}
.detail::before { left: 14px; } .detail::after { right: 14px; }
#detail-title { margin-bottom: 0; }
#detail-title::after {
  content: ""; display: block; height: 1px; margin-top: 10px;
  background: linear-gradient(90deg, var(--brass), var(--brass-lo) 55%, transparent);
}
#detail-note { margin-top: 10px; }

/* ── Responsive ───────────────────────────────────────────────── */
@media (any-pointer: coarse) { .move-pad { display: grid; } }

@media (max-width: 1100px) {
  .stage { grid-template-columns: minmax(0, 1fr) 320px; padding: 10px; gap: 10px; }
  .topbar { padding: 0 18px; }
  .views button { padding: 0 12px; }
  .control-group { padding: 7px 16px; }
  .chapter-band { padding: 18px 16px 14px; }
  .steps-head { padding: 12px 16px 8px; }
}
@media (max-width: 860px) {
  .flourish { display: none; }
  .ruler { display: none; }
  .compass { top: 30px; right: 30px; width: 64px; }
  .compass svg { width: 64px; height: 64px; }
  body { display: block; height: auto; overflow: visible; }
  .topbar { height: auto; flex-wrap: wrap; padding: 0 14px; }
  .wordmark { padding: 12px 0; }
  .views { width: 100%; height: 42px; border-top: 1px solid var(--rule); }
  .views button { flex: 1; height: 42px; padding: 0 6px; font-size: 12.5px; letter-spacing: .08em; }
  .views button[aria-pressed="true"]::after { left: 8px; right: 8px; }
  .views-rule { display: none; }
  .stage { display: block; padding: 10px; }
  .viewport { height: 58dvh; min-height: 330px; }
  .codex { margin-top: 10px; }
  .step-list { max-height: 340px; flex: none; }
  .steps-wrap { flex: none; }
  .map-caption { left: 46px; bottom: 14px; white-space: normal; max-width: calc(100% - 110px); }
  .zoom, .move-pad { right: 14px; bottom: 50px; }
  .detail { top: 22px; left: 22px; max-width: calc(100% - 44px); }
  .chapter-index { font-size: 46px; }
}
@media (max-width: 420px) {
  .wordmark-text p { display: none; }
  h1 { font-size: 18px; letter-spacing: .14em; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
