/* Mapper: a cartographer's desk. Night-ink chrome, gilt hairlines, the map on
   parchment. Cinzel for names of things, EB Garamond for reading, DM Sans for
   controls. Dark by default; no cards, no gradients. */

@font-face { font-family: 'DM Sans'; font-weight: 400; font-display: swap; src: url(fonts/dm-sans-latin-400-normal.woff2) format('woff2'); }
@font-face { font-family: 'DM Sans'; font-weight: 500; font-display: swap; src: url(fonts/dm-sans-latin-500-normal.woff2) format('woff2'); }
@font-face { font-family: 'DM Sans'; font-weight: 600; font-display: swap; src: url(fonts/dm-sans-latin-600-normal.woff2) format('woff2'); }
@font-face { font-family: 'Cinzel'; font-weight: 500; font-display: swap; src: url(fonts/cinzel-latin-500-normal.woff2) format('woff2'); }
@font-face { font-family: 'Cinzel'; font-weight: 600; font-display: swap; src: url(fonts/cinzel-latin-600-normal.woff2) format('woff2'); }
@font-face { font-family: 'EB Garamond'; font-weight: 400; font-display: swap; src: url(fonts/eb-garamond-latin-400-normal.woff2) format('woff2'); }
@font-face { font-family: 'EB Garamond'; font-weight: 500; font-display: swap; src: url(fonts/eb-garamond-latin-500-normal.woff2) format('woff2'); }
@font-face { font-family: 'EB Garamond'; font-style: italic; font-weight: 400; font-display: swap; src: url(fonts/eb-garamond-latin-400-italic.woff2) format('woff2'); }
@font-face { font-family: 'IM Fell English'; font-style: normal; font-display: swap; src: url(fonts/im-fell-english-latin-400-normal.woff2) format('woff2'); }
@font-face { font-family: 'IM Fell English'; font-style: italic; font-display: swap; src: url(fonts/im-fell-english-latin-400-italic.woff2) format('woff2'); }

*, *::before, *::after { box-sizing: border-box; }

:root {
  --bg: #14110d;
  --canvas: #0e0c09;
  --panel: #1b1712;
  --raise: #1f1a14;
  --hover: #2a241c;
  --line: #2e271d;
  --line2: #3a3125;
  --gilt: rgba(201, 162, 74, 0.42);
  --text: #ede4cf;
  --soft: #cdbf9f;
  --muted: #a8997b;
  --dim: #8f8268;
  --accent: #c9a24a;
  --accent-ink: #1a1408;
  --link: #d9b860;
  --warn: #f0c2ad;
  --ok: #b9d6a8;
  --river: #8fb6d4;
  --mountain: #d9a25e;
  --float: rgba(20, 17, 13, 0.94);
  --r-sm: 5px;
  --r-md: 7px;
  --r-lg: 10px;
  --font: 'DM Sans', system-ui, -apple-system, sans-serif;
  --serif: 'EB Garamond', Georgia, serif;
  --caps: 'Cinzel', Georgia, serif;
  color-scheme: dark;
}

html, body { height: 100%; margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 13px/1.45 var(--font);
  display: grid; grid-template-rows: auto 1fr;
  overflow: hidden; -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }

button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; border-radius: var(--r-sm); padding: 6px 10px; cursor: pointer; white-space: nowrap; color: var(--soft); }
button:hover { background: var(--hover); color: var(--text); }
button.primary { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
button.primary:hover { background: #d8b45e; color: var(--accent-ink); }
button.ghost { border: 1px solid var(--line2); color: var(--text); }
button.ghost:hover { border-color: #5a4c33; background: none; }
button.danger:hover { color: #ffb4a8; border-color: #5a3430; }
button.link { padding: 2px 0; color: var(--link); }
button.link:hover { background: none; color: #ecd08a; }
button.big { padding: 13px 22px; border-radius: var(--r-sm); min-height: 46px; font-size: 14px; }
button.caps-btn { font-family: var(--caps); letter-spacing: 0.12em; text-transform: uppercase; font-size: 12.5px; }
button:disabled { opacity: 0.35; cursor: default; background: none; }
input[type=text], input[type=number], input[type=search], select, textarea {
  background: var(--panel); border: 1px solid var(--line2); border-radius: var(--r-sm); padding: 6px 9px; width: 100%; min-width: 0;
}
input:focus-visible, select:focus-visible, button:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
input[type=range] { width: 100%; accent-color: var(--accent); }
input[type=color] { width: 40px; height: 28px; padding: 0; border: 1px solid var(--line2); border-radius: var(--r-sm); background: none; }
input[type=checkbox] { accent-color: var(--accent); margin: 0; }
hr { border: 0; border-top: 1px solid var(--line); margin: 14px 0; }

.caps { font-family: var(--caps); font-size: 11px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--accent); }
.title { font-family: var(--serif); font-weight: 500; }
.ornament { display: flex; align-items: center; gap: 10px; color: var(--accent); }
.ornament span { flex: 1; height: 1px; background: var(--line2); }
.ornament i { font-style: normal; font-size: 8px; }

/* segmented control */
.seg { display: inline-flex; flex-wrap: wrap; background: var(--panel); border: 1px solid var(--line2); border-radius: var(--r-md); padding: 2px; }
.seg button { padding: 4px 11px; border-radius: 5px; color: var(--muted); }
.seg button:hover { background: none; color: var(--text); }
.seg button.on { background: var(--hover); color: var(--text); font-weight: 500; }

/* top bar */
.top { min-height: 56px; display: flex; align-items: center; gap: 16px; padding: 0 14px 0 20px; border-bottom: 1px solid var(--line); min-width: 0; }
.mark { font-family: var(--caps); font-weight: 600; font-size: 15px; letter-spacing: 0.22em; text-transform: uppercase; text-decoration: none; color: var(--accent); }
.docname { font-family: var(--serif); font-style: italic; font-size: 16px; color: var(--soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 22ch; }
.grow { flex: 1; }
.stages { display: flex; gap: 4px; margin-left: 18px; }
.stages button {
  display: flex; align-items: baseline; gap: 7px; padding: 17px 8px 14px; border-radius: 0;
  border-bottom: 2px solid transparent; color: var(--muted);
  font-family: var(--caps); font-size: 12px; letter-spacing: 0.13em; text-transform: uppercase;
}
.stages button:hover { background: none; color: var(--text); }
.stages button.on { color: var(--text); border-bottom-color: var(--accent); }
.stages em { font-family: var(--font); font-style: normal; letter-spacing: 0; font-size: 11px; color: var(--warn); }
.menus { display: flex; gap: 2px; }
.menus details { position: relative; }
.menus summary { list-style: none; cursor: pointer; padding: 6px 9px; border-radius: var(--r-sm); color: var(--muted); }
.menus summary::-webkit-details-marker { display: none; }
.menus details[open] summary, .menus summary:hover { background: var(--hover); color: var(--text); }
.menus .drop {
  position: absolute; top: calc(100% + 6px); right: 0; z-index: 30;
  background: var(--panel); border: 1px solid var(--line2); border-radius: var(--r-lg);
  padding: 5px; min-width: 280px; display: grid; box-shadow: 0 18px 44px rgba(0,0,0,0.6);
}
.menus details:first-child .drop { left: 0; right: auto; }
.menus .drop button { text-align: left; padding: 8px 10px; color: var(--text); white-space: normal; }
.menus .drop small { display: block; color: var(--muted); font-size: 12px; }
.menus .drop .sep { height: 1px; background: var(--line2); margin: 4px 8px; }
.views button { padding: 5px 12px; }
.undo { display: flex; gap: 2px; }
button.icon { width: 34px; height: 34px; padding: 0; display: grid; place-items: center; }

/* work area */
.rail h3 { font-family: var(--caps); font-size: 11px; font-weight: 500; letter-spacing: 0.18em; text-transform: uppercase; color: var(--accent); margin: 0 8px 4px; }
.rail .about { font-family: var(--serif); font-size: 14.5px; line-height: 1.35; color: var(--muted); margin: 0 8px 12px; }

/* strategy checks and export list in the rail */
.checks, .exports { display: flex; flex-direction: column; gap: 4px; }
.rail .check-row { display: grid; grid-template-columns: 40px 1fr; gap: 8px; align-items: start; white-space: normal; padding: 9px 8px; border-radius: var(--r-md); }
.rail .export-row { display: flex; flex-direction: column; gap: 1px; white-space: normal; padding: 9px 8px; border-radius: var(--r-md); }
.check-row b { font-family: var(--serif); font-weight: 500; font-size: 21px; line-height: 1; font-variant-numeric: lining-nums; color: var(--text); }
.check-row.warn b { color: var(--warn); }
.check-row.ok b { color: var(--ok); }
.check-row > span { display: flex; flex-direction: column; }
.check-row strong, .export-row strong { font-weight: 500; color: var(--text); }
.check-row small, .export-row small { color: var(--muted); font-size: 12px; line-height: 1.35; }
.check-row.open { background: var(--hover); }
.primary-row strong { color: var(--accent); }
.check-items { display: flex; flex-direction: column; padding: 2px 0 8px 48px; }
.rail .check-items button { padding: 4px 6px; font-family: var(--serif); font-size: 14.5px; color: var(--soft); }

.stage { position: relative; min-width: 0; min-height: 0; background: var(--canvas); overflow: hidden; }
.pane { position: absolute; inset: 0; }
.pane canvas { display: block; touch-action: none; }
#pane2d canvas { cursor: crosshair; }

/* the floating tool bar */
.toolbar {
  position: absolute; top: 18px; left: 50%; transform: translateX(-50%); z-index: 5;
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; justify-content: center;
  width: max-content; max-width: calc(100% - 40px);
  background: var(--float); border: 1px solid var(--line2); border-radius: var(--r-lg);
  padding: 6px 8px 6px 14px; box-shadow: 0 8px 24px rgba(0,0,0,0.45);
}
.toolbar > b { font-family: var(--caps); font-weight: 500; font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--accent); }
.toolbar .div, .toolbar hr { width: 1px; height: 18px; background: var(--line2); border: 0; margin: 0; }
.toolbar > div { display: contents; }
.toolbar .field { display: flex; align-items: center; gap: 8px; margin: 0; }
.toolbar .field > span { color: var(--soft); white-space: nowrap; }
.toolbar .slider input[type=range] { width: 100px; }
.toolbar .slider .num { display: flex; align-items: center; gap: 3px; }
.toolbar .slider .num input { width: 56px; padding: 3px 6px; text-align: right; }
.toolbar .slider .num em { color: var(--muted); font-style: normal; font-size: 12px; }
.toolbar .field input[type=text] { width: 180px; padding: 4px 8px; }
.toolbar .field select { width: auto; padding: 4px 8px; }
.toolbar .check { display: flex; align-items: center; gap: 6px; color: var(--soft); margin: 0; cursor: pointer; white-space: nowrap; }
.toolbar .seg { padding: 2px; }
.toolbar .row { display: contents; }
.toolbar .info { color: var(--muted); white-space: nowrap; }

.hint {
  position: absolute; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 4;
  margin: 0; max-width: calc(100% - 150px); width: max-content;
  background: var(--float); border: 1px solid var(--line2); border-radius: var(--r-md); padding: 7px 14px;
  font-family: var(--serif); font-size: 15px; color: var(--soft); pointer-events: none; text-align: center;
  opacity: 0; transition: opacity 0.3s;
}
.hint.show { opacity: 1; }
.hint.live { color: #ecd08a; font-style: italic; }
.hint:empty { display: none; }
.zoom { position: absolute; right: 20px; bottom: 20px; z-index: 4; display: flex; flex-direction: column; background: var(--float); border: 1px solid var(--line2); border-radius: var(--r-md); overflow: hidden; }
.zoom button { width: 38px; height: 38px; padding: 0; border-radius: 0; font-size: 16px; }
.zoom button + button { border-top: 1px solid var(--line2); }
.zoom button[data-z=fit] { font-size: 11px; }

/* the table view */
.pane.table { overflow: auto; padding: 20px 24px 40px; background: var(--bg); display: flex; flex-direction: column; gap: 12px; }
.tablebar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.tablebar h2 { margin: 0 6px 0 0; font-size: 24px; }
.tablebar input[type=search] { width: 260px; }
.tablewrap { overflow-x: auto; }
.pane.table table { border-collapse: collapse; width: 100%; min-width: 980px; font-variant-numeric: tabular-nums; }
.pane.table th { text-align: left; font-weight: 500; color: var(--muted); padding: 8px; border-bottom: 1px solid var(--line2); white-space: nowrap; }
.pane.table td { padding: 4px 8px; border-bottom: 1px solid var(--line); }
.pane.table td input[type=text], .pane.table td select { background: transparent; border-color: transparent; padding: 5px 6px; }
.pane.table td input[type=text]:hover, .pane.table td select:hover { border-color: var(--line2); }
.pane.table td:first-child input { font-family: var(--serif); font-size: 15px; }
.pane.table .num { text-align: right; }
.pane.table .warn { color: var(--warn); font-style: italic; }
.x-river { color: var(--river); }
.x-mountains { color: var(--mountain); }
.x-land { color: var(--muted); }

/* inspector */
.sheetgrip { display: none; }
.side section { padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.side section + section { border-top: 1px solid var(--line); }
.side h2 { font-size: 13px; font-weight: 600; margin: 0; display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.side h2 small { color: var(--muted); font-weight: 400; font-variant-numeric: tabular-nums; text-align: right; }
.side h2.gap { margin-top: 6px; }
.selhead { display: flex; flex-direction: column; gap: 3px; }
.side .selhead h2.title { font-size: 26px; font-weight: 500; line-height: 1.1; display: block; }
.selhead small { color: var(--muted); font-variant-numeric: lining-nums; }
.empty { font-family: var(--serif); font-size: 15px; color: var(--muted); margin: 0; }
.field { display: grid; gap: 5px; margin: 0; }
.field > span { color: var(--muted); font-size: 12px; }
.field > span.caps { color: var(--accent); font-size: 11px; }
.side .slider { grid-template-columns: minmax(0, 1fr) auto; align-items: center; column-gap: 10px; }
.side .slider > span:first-child { grid-column: 1 / -1; }
.slider .num { display: flex; align-items: center; gap: 4px; }
.slider .num input { width: 64px; padding: 4px 6px; text-align: right; }
.slider .num em { color: var(--muted); font-style: normal; font-size: 12px; }
.check { display: flex; gap: 8px; align-items: center; margin: 0; cursor: pointer; color: var(--soft); }
.row { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.row.between { justify-content: space-between; color: var(--soft); }
.note { color: var(--muted); font-size: 12.5px; margin: 0; }
.warn { color: var(--warn); }
.ok { color: var(--ok); }
.side .seg { display: flex; }
.side .seg button { flex: 1; }
.pieces { display: grid; gap: 4px; }
.pieces > div { display: flex; align-items: center; gap: 8px; padding: 7px 9px; background: var(--raise); border-radius: var(--r-sm); }
.pieces i, .layer i { width: 9px; height: 9px; border-radius: 2px; flex-shrink: 0; }
.pieces span { flex: 1; }
.pieces em, .layer em { font-style: normal; color: var(--muted); font-variant-numeric: tabular-nums; }
.borders { display: flex; flex-direction: column; }
.borders .nb { display: grid; grid-template-columns: 1fr auto 62px; gap: 10px; align-items: baseline; text-align: left; padding: 8px 2px; border-radius: 0; border-bottom: 1px solid var(--line); }
.borders .nb span { font-family: var(--serif); font-size: 15px; color: var(--text); }
.borders .nb em { font-family: var(--serif); font-size: 14.5px; }
.borders .nb small { color: var(--muted); text-align: right; font-variant-numeric: lining-nums tabular-nums; }
.layers { display: grid; }
.layer { display: flex; align-items: center; gap: 10px; padding: 5px 0; cursor: pointer; }
.layer span { flex: 1; color: var(--soft); }
.layer.sub { padding-left: 19px; }
.layer.sub span { color: var(--muted); }
.layer i.none { background: none; }
.attrs { display: grid; grid-template-columns: 1fr 1fr auto; gap: 4px; }
.attrs button { padding: 2px 8px; }
.issues { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; font-size: 12.5px; }
.issues li[data-at] { cursor: pointer; text-decoration: underline dotted; text-underline-offset: 3px; }
.textlist { display: grid; gap: 4px; max-height: 340px; overflow-y: auto; }
.textrow { display: grid; grid-template-columns: auto 1fr auto; gap: 8px; align-items: center; }
.textrow input[type=text] { padding: 4px 7px; }

/* status */

/* start */
.welcome { overflow-y: auto; }
.welcome .wrap { max-width: 1080px; margin: 0 auto; padding: 84px 24px 64px; display: flex; flex-direction: column; gap: 56px; }
.intro { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 16px; }
.kicker { font-family: var(--caps); font-size: 12px; letter-spacing: 0.3em; text-transform: uppercase; color: var(--accent); }
.intro h1 { margin: 0; font-family: var(--caps); font-weight: 500; font-size: clamp(30px, 6vw, 58px); letter-spacing: 0.06em; line-height: 1.1; }
.intro .ornament { width: min(340px, 80%); }
.lede { margin: 0; max-width: 46ch; font-family: var(--serif); font-style: italic; font-size: 19px; color: var(--soft); }
.cta { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; margin-top: 8px; }
.small { margin: 0; color: var(--muted); font-size: 13px; }
.recent { display: flex; flex-direction: column; gap: 14px; }
.recent .label { font-family: var(--caps); font-size: 11px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--accent); }
.starts { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 24px; }
.card { display: flex; flex-direction: column; gap: 12px; text-align: left; white-space: normal; padding: 0; color: var(--text); }
.card:hover { background: none; }
.card:hover .thumb { outline-color: var(--accent); }
.card > span:nth-child(2) { display: grid; gap: 1px; padding: 0 2px; }
.card b { font-family: var(--serif); font-weight: 500; font-size: 21px; }
.card small { color: var(--muted); font-size: 13.5px; }
.card .go { display: none; }
.thumb { width: 100%; aspect-ratio: 16 / 10; border-radius: 3px; object-fit: cover; display: block; background: #b89460; outline: 1px solid var(--line2); outline-offset: 4px; }
.thumb.blank { background: none; border: 1px dashed #4a3f2c; outline: 0; }

/* modal */
dialog.modal { background: var(--panel); color: var(--text); border: 1px solid var(--line2); border-radius: 12px; padding: 22px; width: min(460px, calc(100vw - 32px)); box-shadow: 0 24px 60px rgba(0,0,0,0.6); }
dialog.modal::backdrop { background: rgba(0,0,0,0.6); }
dialog.modal h2 { font-family: var(--serif); font-size: 22px; font-weight: 500; margin: 0 0 14px; }
dialog.modal form > div { display: grid; gap: 12px; }
dialog.modal .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
dialog.modal .actions button { border: 1px solid var(--line2); }
dialog.modal .actions button.primary { border-color: var(--accent); }
dialog.modal ul { padding-left: 18px; margin: 0; }

#toast { position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%) translateY(8px); background: #ede4cf; color: #1a1408; padding: 8px 14px; border-radius: var(--r-md); font-family: var(--serif); font-size: 15px; opacity: 0; pointer-events: none; transition: opacity 0.18s, transform 0.18s; max-width: calc(100vw - 32px); z-index: 50; }
#toast.show { opacity: 1; transform: translateX(-50%); }

.card.older small { color: var(--accent); }

/* share */
.sharebox { display: flex; gap: 8px; align-items: stretch; }
.sharebox .sharelink { flex: 1; min-width: 0; font: 14px/1.2 var(--font); padding: 9px 10px; background: var(--bg); color: var(--text); border: 1px solid var(--line2); border-radius: var(--r-sm, 6px); }
.sharebox button { white-space: nowrap; }
.shareacts { display: flex; gap: 8px; flex-wrap: wrap; }
.shareacts .danger { color: #f0c2ad; }
@media (max-width: 760px) { .sharebox { flex-direction: column; } }

/* ---------- the workspace: the map gets the screen ---------- */
.savestate { color: var(--dim); font-size: 12px; white-space: nowrap; }
.top .share { display: inline-flex; align-items: center; gap: 7px; height: 34px; padding: 0 14px; border-color: var(--accent); }
.menus .mainmenu summary { display: flex; align-items: center; gap: 6px; height: 40px; padding: 0 10px; color: var(--text); }
.menus .mlabel { font-size: 13px; }
.menus .drop { right: 0; left: auto; width: 340px; max-height: calc(100dvh - 76px); overflow-y: auto; padding: 6px; }
.menus .group { display: grid; padding: 4px 0; }
.menus .group + .group { border-top: 1px solid var(--line2); margin-top: 4px; padding-top: 8px; }
.menus .gh { font-family: var(--caps); font-size: 10.5px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--accent); padding: 2px 10px 4px; }
.menus details:first-child .drop { left: auto; right: 0; }

.work { position: relative; min-height: 0; display: block; }
.stage { position: absolute; inset: 0; }

/* floating things on the map share one look */
.rail, .views, .floatbtn, .layerpop, .side, .zoom { background: var(--float); border: 1px solid var(--line2); box-shadow: 0 8px 24px rgba(0,0,0,0.4); }

/* tools: an icon palette */
.rail { position: absolute; z-index: 6; left: 16px; top: 16px; display: flex; flex-direction: column; gap: 2px; padding: 5px; border-radius: 12px; max-height: calc(100% - 96px); overflow-y: auto; }
.rail .tool { width: 42px; height: 42px; padding: 0; display: flex; align-items: center; justify-content: center; border-radius: 8px; color: var(--soft); }
.rail .tool.on { background: var(--hover); color: var(--accent); }
/* the Strategy and Export stages: a list, not tools */
.rail.panel { width: 300px; padding: 14px 10px; gap: 1px; border-radius: var(--r-lg); }

.views { position: absolute; z-index: 5; left: 16px; bottom: 16px; border-radius: 10px; padding: 3px; }
.views button { padding: 7px 13px; }
.floatbtn { position: absolute; z-index: 7; right: 16px; top: 16px; display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 14px; border-radius: 10px; color: var(--text); }
.floatbtn.on { border-color: var(--accent); }
.layerpop { position: absolute; z-index: 8; right: 16px; top: 64px; width: 320px; max-height: calc(100% - 140px); overflow-y: auto; border-radius: var(--r-lg); }
.layerpop section { padding: 16px 18px; display: flex; flex-direction: column; gap: 12px; }
.pos { position: absolute; z-index: 4; right: 76px; bottom: 22px; color: var(--muted); font-size: 12px; font-variant-numeric: lining-nums tabular-nums; pointer-events: none; text-shadow: 0 1px 2px #000; }
.zoom { right: 16px; bottom: 16px; }

/* the inspector: only when something is selected */
.side { position: absolute; z-index: 7; right: 16px; top: 64px; width: 340px; max-height: calc(100% - 140px); overflow-y: auto; border-radius: 12px; }
.side.empty { display: none; }
.side #selpanel:empty { display: none; }
.side section { padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.side section + section { border-top: 1px solid var(--line); }
.toolbar { top: 16px; }
.layerpop:not([hidden]) ~ .side { display: none; }

/* a narrower desktop */
@media (max-width: 1180px) {
  .savestate, .menus .mlabel { display: none; }
  .stages { margin-left: 4px; }
  .stages button { padding-left: 6px; padding-right: 6px; letter-spacing: 0.08em; }
}

/* phones: header, the map, the tools, the stages; nothing else until asked for */
@media (max-width: 760px) {
  .top { min-height: 0; height: 54px; padding: 0 4px 0 14px; gap: 6px; }
  .mark { font-size: 12px; letter-spacing: 0.2em; }
  .docname { max-width: 38vw; font-size: 16px; }
  .undo { display: none; }
  .top .share { border: 0; width: 44px; height: 44px; padding: 0; justify-content: center; color: var(--accent); }
  .top .share span { display: none; }
  .menus .mainmenu summary { width: 44px; height: 44px; justify-content: center; padding: 0; }
  .menus .drop {
    position: fixed; left: 0; right: 0; top: auto; bottom: 0; width: auto; z-index: 60;
    max-height: 78dvh; border-radius: 16px 16px 0 0; padding: 8px 8px calc(16px + env(safe-area-inset-bottom));
  }
  .menus .drop button { min-height: 48px; }
  .menus details[open] summary::after { content: ''; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 55; }
  #toast { top: 64px; bottom: auto; }

  .stages {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; margin: 0;
    height: calc(58px + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
    background: var(--bg); border-top: 1px solid var(--line);
    display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 0;
  }
  .stages[hidden] { display: none !important; }
  .stages button { position: relative; justify-content: center; align-items: center; padding: 0; border-bottom: 0; border-top: 2px solid transparent; font-size: 9.5px; letter-spacing: 0.08em; }
  .stages button.on { border-top-color: var(--accent); }
  .stages em { position: absolute; top: 9px; right: 12%; }
  .work { height: calc(100dvh - 54px - 58px - env(safe-area-inset-bottom)); }

  .rail { left: 8px; right: 8px; top: auto; bottom: 8px; flex-direction: row; justify-content: space-between; max-height: none; overflow-x: auto; border-radius: 14px; }
  .rail .tool { width: 46px; height: 46px; flex-shrink: 0; }
  .rail.panel { left: 8px; right: 8px; width: auto; top: 56px; bottom: 8px; flex-direction: column; justify-content: flex-start; overflow-y: auto; }
  .views { left: auto; right: 8px; top: 8px; bottom: auto; }
  .views button { padding: 7px 10px; }
  .floatbtn { right: auto; left: 8px; top: 8px; height: 40px; }
  .layerpop { position: fixed; left: 0; right: 0; top: auto; bottom: 0; width: auto; max-height: 72dvh; border-radius: 16px 16px 0 0; z-index: 60; padding-bottom: env(safe-area-inset-bottom); }
  .toolbar { top: 56px; max-width: calc(100% - 16px); }
  .hint, .pos, .zoom { display: none; }
  .side {
    position: fixed; z-index: 35; left: 0; right: 0; top: auto; width: auto; bottom: calc(58px + env(safe-area-inset-bottom));
    max-height: 76px; overflow: hidden; background: var(--bg); border: 0; border-top: 1px solid var(--line2);
    border-radius: 16px 16px 0 0; box-shadow: 0 -10px 30px rgba(0,0,0,0.5); transition: max-height 0.2s;
  }
  .side.open { max-height: 64dvh; overflow-y: auto; }
  .work:has(.side:not(.empty)) .rail:not(.panel) { bottom: 84px; }
  .sheetgrip { display: flex; justify-content: center; width: 100%; padding: 8px 0 4px; border-radius: 0; position: sticky; top: 0; background: var(--bg); z-index: 1; }
  .sheetgrip span { width: 42px; height: 4px; border-radius: 2px; background: #4a3f2c; }
  .side section { padding: 2px 18px 16px; }
  .side:not(.open) .selhead h2.title { font-size: 20px; }
  .side input[type=text], .side select { min-height: 44px; font-size: 16px; }
  .borders .nb { min-height: 44px; }
  .pane.table { padding: 56px 12px 24px; }
  .welcome .wrap { padding: 48px 18px 40px; gap: 40px; }
  .starts { grid-template-columns: 1fr; }
}
.rail.panel button { width: 100%; text-align: left; justify-content: flex-start; }
.side { max-height: calc(100% - 64px - 150px); }
@media (max-width: 760px) {
  .side { max-height: 76px; }
  .side.open { max-height: 64dvh; }
  #toast { top: auto; bottom: calc(58px + 84px + env(safe-area-inset-bottom)); }
}
.character { display: grid; gap: 4px; margin-bottom: 12px; }
.character p { margin: 0; font-family: var(--serif); font-size: 15.5px; color: var(--soft); }
.character b { color: var(--text); font-weight: 500; }
.character .res { display: flex; flex-wrap: wrap; gap: 4px; }
.tag { font-family: var(--font); font-size: 12px; padding: 2px 8px; border: 1px solid var(--line2); border-radius: 999px; color: var(--soft); }
.check-act { padding: 0 8px 10px 56px; }
.factions { display: grid; gap: 4px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.faction { display: grid; grid-template-columns: 28px minmax(0, 1fr) 28px; gap: 8px; align-items: center; padding: 0 6px; }
.faction input[type=color] { width: 26px; height: 26px; padding: 0; border: 1px solid var(--line2); border-radius: 50%; background: none; }
.faction input[type=color]::-webkit-color-swatch-wrapper { padding: 0; } .faction input[type=color]::-webkit-color-swatch { border: 0; border-radius: 50%; }
.faction input[type=text] { font-family: var(--serif); font-size: 15px; background: none; border-color: transparent; padding: 4px 6px; }
.faction input[type=text]:focus { border-color: var(--line2); }
.faction small { color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
