/* MPCMRPCompanion — "Illuminated Manuscript" theme: vellum, ink, rubric red, lapis and gold leaf.
 * Cinzel capitals for labels and controls, Cormorant Garamond for names and headings, EB Garamond
 * for reading, blackletter only for ornamental initials. Mobile first.
 *
 * Layout model
 *   phones / narrow  : sticky one-row top bar · scrolling page · fixed bottom tab bar
 *   >= 900px         : the tab bar becomes a slim left rail, panes lay out in columns
 * Everything is sized from the tokens below (spacing, type, radii, tap size). The token names are
 * inherited from the platform: --void is the page (parchment), --neon the primary accent
 * (rubric red), --terminal the second accent (lapis), --bone the ink, --gold the gilt rules.
 */
:root {
  /* colour */
  --void: #f3e7c9;
  --panel: #f8efd8;
  --panel-raised: #efe0bb;
  --outline: #c9ad74;
  --neon: #a51d1d;
  --terminal: #1f3f8f;
  --gold: #c99a2e;
  --amber: #8a5a0b;
  --amber-dim: #f3dc9c;
  --rust: #b42318;
  --bone: #241a0f;
  --ash: #6b5640;
  --active: #f6e3cf;
  --ok: #2d6a2c;
  --serious: #1f3f8f;
  --silly: #c2457a;

  /* type */
  --mono: ui-monospace, "SFMono-Regular", Consolas, monospace;
  --serif: "EB Garamond", Garamond, "Times New Roman", serif;
  --display: "Cinzel", "Trajan Pro", Georgia, serif;
  --heading: "Cormorant Garamond", "EB Garamond", Georgia, serif;
  --fell: var(--heading);
  --hand: "Caveat", "Segoe Print", cursive;
  --black: "UnifrakturMaguntia", "Old English Text MT", serif;
  --fs-xs: 12px;
  --fs-sm: 13px;
  --fs-md: 15px;
  --fs-lg: 20px;
  --fs-xl: 24px;
  --fs-2xl: 42px;

  /* spacing */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 24px;

  /* shape & motion */
  --r-sm: 2px;
  --r-md: 3px;
  --r-lg: 10px;
  --r-pill: 999px;
  --speed: 120ms;
  --ease: cubic-bezier(0.2, 0, 0, 1);
  --glow: 0 0 0 2px rgba(142, 27, 23, 0.18);
  --paper-shadow: 0 1px 0 rgba(255, 250, 235, 0.7) inset, 0 1px 2px rgba(70, 45, 15, 0.18);

  /* chrome */
  --tap: 44px;
  --topbar-h: 56px;
  --tabbar-h: 64px;
  --rail-w: 88px;
  --gutter: 16px;
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
}
@media (pointer: fine) { :root { --tap: 38px; } }
@media (min-width: 900px) { :root { --gutter: 24px; } }

* { box-sizing: border-box; }
html {
  background: var(--void);
  -webkit-text-size-adjust: 100%;
  scroll-padding-top: calc(var(--topbar-h) + var(--sat) + 72px);
}
html.sheet-open, html.gs-open { overflow: hidden; }
body {
  margin: 0;
  min-height: 100dvh;
  background-color: var(--void);
  background-image: radial-gradient(ellipse at 50% 0%, rgba(251, 244, 224, 0.9), rgba(251, 244, 224, 0) 65%),
    radial-gradient(ellipse at 50% 120%, rgba(140, 95, 35, 0.26), rgba(140, 95, 35, 0) 60%);
  background-attachment: fixed;
  color: var(--bone);
  font-family: var(--serif);
  font-size: 17px;
  line-height: 1.4;
  letter-spacing: 0;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-wrap: break-word;
}
::selection { background: var(--neon); color: var(--void); }
[hidden] { display: none !important; }
* { scrollbar-width: thin; scrollbar-color: var(--outline) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--outline); border: 2px solid var(--void); border-radius: 6px; }

/* Parchment grain (cosmetic; never intercepts input). The 'scanlines' setting switches it off. */
body::after {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 9999; opacity: 0.22; mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.45 0 0 0 0 0.32 0 0 0 0 0.15 0 0 0 0.55 0'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23n)'/%3E%3C/svg%3E");
}
@media (prefers-contrast: more) { body::after { display: none; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; } }
html.no-scanlines body::after { display: none; }
html.no-glow { --glow: none; }
html.no-anim *, html.no-anim *::before, html.no-anim *::after { transition: none !important; animation: none !important; }

/* One keyboard-focus style everywhere. */
:focus-visible { outline: 2px solid var(--neon); outline-offset: 2px; }
input:focus-visible, textarea:focus-visible, select:focus-visible { outline-offset: 0; }
.modal:focus-visible { outline: none; }
.skip-link { position: absolute; left: 8px; top: -60px; z-index: 100; background: var(--neon); color: var(--void); padding: 10px 14px; border-radius: var(--r-md); }
.skip-link:focus { top: 8px; }

/* ---------- utilities ---------- */
.muted { color: var(--ash); }
.ok { color: var(--ok); }
.warn { color: var(--rust); }
.amber-t { color: var(--amber); }
.dmg { color: var(--amber); }
.tag { color: var(--amber); font-size: var(--fs-xs); letter-spacing: 1px; }
.sm { font-size: var(--fs-sm); }
.pad { padding: var(--sp-3) 0; }
.grow { flex: 1; min-width: 0; }
.mt4 { margin-top: 4px; } .mt8 { margin-top: 8px; } .mb6 { margin-bottom: 6px; }
.gap14 { gap: 4px 14px; }
.prewrap { white-space: pre-line; overflow-wrap: anywhere; }
.clamp3 { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.spacer { height: var(--sp-2); }
.row { display: flex; align-items: center; gap: var(--sp-2); }
.row.between { justify-content: space-between; }
.row.wrap { flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: var(--sp-2); }
.lbl { font-size: var(--fs-xs); letter-spacing: 1px; color: var(--ash); }
.kv { display: flex; justify-content: space-between; gap: var(--sp-3); padding: 5px 0; border-bottom: 1px solid rgba(110, 85, 50, 0.22); }
.kv:last-child { border-bottom: 0; }
.kv .k { color: var(--ash); font-size: var(--fs-xs); letter-spacing: 1px; flex: 0 0 auto; padding-top: 2px; }
.kv .v { text-align: right; min-width: 0; }

/* ---------- buttons ---------- */
button, .btn {
  font-family: var(--display);
  font-size: 15px;
  letter-spacing: 0.3px;
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: var(--tap);
  padding: 0 14px;
  border-radius: var(--r-md);
  border: 1px solid var(--outline);
  background: var(--panel-raised);
  color: var(--bone);
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: border-color var(--speed) var(--ease), background var(--speed) var(--ease), color var(--speed) var(--ease), transform var(--speed) var(--ease);
}
button:hover { border-color: var(--terminal); }
button:active { transform: translateY(1px); }
button:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }
.primary { background: var(--neon); color: var(--void); border-color: var(--neon); font-weight: 700; }
.primary:hover { box-shadow: var(--glow); }
button.amber { background: var(--amber-dim); color: var(--amber); border-color: var(--amber); }
button.danger { color: var(--rust); border-color: var(--rust); background: transparent; }
button.danger:hover { background: rgba(180, 35, 24, 0.12); }
button.ghost { background: transparent; }
button.mini { font-size: var(--fs-sm); padding: 0 10px; }
.block { display: flex; width: 100%; }
.btn-row { display: flex; gap: var(--sp-2); margin-top: 10px; }
.btn-row > * { flex: 1 1 0; min-width: 0; }
.btn-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-2); margin-top: 10px; }
.btn-grid > button { white-space: normal; text-align: center; padding-block: 6px; }
.icon-btn { position: relative; width: var(--tap); min-width: var(--tap); padding: 0; background: transparent; border-color: transparent; color: var(--bone); }
.icon-btn:hover { border-color: var(--outline); }
.icon-btn svg { width: 22px; height: 22px; }
.icon-btn.active { color: var(--neon); }
.icon-btn.sm { width: 40px; min-width: 40px; min-height: 40px; }

.stepper { display: inline-flex; align-items: center; gap: var(--sp-2); flex: 0 0 auto; }
.stepper-btn { flex: 0 0 44px; width: 44px; min-height: 44px; padding: 0; font-size: 20px; }
.stepper > .val, .stepper > span { min-width: 3ch; text-align: center; font-weight: 700; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: var(--sp-2);
  height: calc(var(--topbar-h) + var(--sat));
  padding: var(--sat) max(8px, var(--sar)) 0 max(12px, var(--sal));
  background: var(--panel);
  border-bottom: 1px solid var(--outline);
}
.tb-brand { color: var(--neon); font-weight: 700; font-size: 16px; letter-spacing: 1.5px; text-shadow: var(--glow); white-space: nowrap; }
body.authed .tb-brand { display: none; }
.tb-char {
  flex: 1 1 0; min-width: 0; max-width: 340px; justify-content: flex-start; text-align: left;
  min-height: 48px; padding: 2px 8px; background: transparent; border-color: transparent;
}
.tb-char:hover { border-color: var(--outline); }
.tb-char-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.15; }
.tb-char-label { font-size: 10px; letter-spacing: 1px; color: var(--ash); }
.tb-char-name { font-size: 16px; font-weight: 700; color: var(--terminal); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tb-char-icon { flex: 0 0 auto; color: var(--ash); }
.tb-char-icon svg { width: 18px; height: 18px; display: block; }
.tb-actions { margin-left: auto; display: flex; align-items: center; gap: 2px; }
.tb-label { display: none; }
.offline-badge { font-size: var(--fs-xs); color: var(--amber); border: 1px solid var(--amber-dim); border-radius: var(--r-pill); padding: 2px 8px; white-space: nowrap; letter-spacing: 0.5px; }
.rec-badge { display: none; position: absolute; top: 9px; right: 9px; width: 9px; height: 9px; border-radius: 50%; background: var(--rust); animation: rec-blink 1.4s steps(2, start) infinite; }
.icon-btn.rec .rec-badge { display: block; }
.icon-btn.rec { color: var(--rust); }
kbd { font-family: var(--serif); font-size: 11px; border: 1px solid var(--outline); border-radius: 3px; padding: 0 5px; color: var(--ash); }

/* ---------- tab bar (phones) / rail (wide) ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr);
  height: calc(var(--tabbar-h) + var(--sab));
  padding: 0 var(--sar) var(--sab) var(--sal);
  background: var(--panel);
  border-top: 1px solid var(--outline);
}
.tab {
  flex-direction: column; gap: 3px; min-width: 0; min-height: 0; padding: 0;
  background: transparent; border: 0; border-top: 2px solid transparent; border-radius: 0;
  color: var(--ash); font-size: var(--fs-xs); letter-spacing: 0.5px;
}
.tab:hover { color: var(--bone); }
.tab-icon svg { width: 24px; height: 24px; display: block; }
.tab.active { color: var(--neon); background: var(--active); border-top-color: var(--neon); }
.tab:focus-visible { outline-offset: -3px; }

/* ---------- page ---------- */
.content { min-width: 0; padding: var(--sp-3) max(var(--gutter), var(--sar)) var(--sp-5) max(var(--gutter), var(--sal)); }
body.authed .content { padding-bottom: calc(var(--tabbar-h) + var(--sab) + var(--sp-5)); max-width: 720px; margin-inline: auto; }
body.authed .content.route-inventory { padding-bottom: calc(var(--tabbar-h) + var(--sab) + 96px); }
body.authed .content.route-session { padding-bottom: calc(var(--tabbar-h) + var(--sab) + 80px); }

.route-head { display: flex; align-items: center; gap: var(--sp-2); margin: 0 0 var(--sp-2) -8px; }
.route-head h1 { flex: 1; margin: 0; font-size: var(--fs-lg); letter-spacing: 1px; color: var(--neon); }

/* Login */
.login-wrap { display: flex; justify-content: center; padding-top: 8vh; }
.login-card { width: 100%; max-width: 380px; }
.login-card h2 { color: var(--neon); letter-spacing: 1px; margin: 0 0 4px; }
.login-card .sub { color: var(--ash); margin-bottom: var(--sp-4); }

/* ---------- surfaces ---------- */
.card, .panel {
  background: var(--panel);
  border: 1px solid var(--outline);
  border-radius: var(--r-md);
  padding: var(--sp-3);
  margin-bottom: 10px;
}
.panel { padding: var(--sp-4); margin-bottom: var(--sp-3); }
.card.row-card { display: flex; align-items: center; gap: 10px; }
.card.clickable { cursor: pointer; }
.card.clickable:hover { border-color: var(--terminal); background: var(--panel-raised); }
.card.flash { border-color: var(--neon); box-shadow: var(--glow); }
.panel-title { color: var(--neon); font-weight: 700; letter-spacing: 1px; margin: 0 0 var(--sp-2); font-size: var(--fs-md); }
.panel-title.amber { color: var(--amber); }
.panel-title.err { color: var(--rust); }
.sec-label { display: flex; justify-content: space-between; align-items: baseline; gap: var(--sp-2); margin: var(--sp-3) 0 6px; font-size: var(--fs-xs); letter-spacing: 1px; color: var(--ash); }
.empty { text-align: center; padding: 32px var(--sp-4); border: 1px dashed var(--outline); border-radius: var(--r-md); margin-bottom: var(--sp-3); }
.empty-title { color: var(--neon); font-weight: 700; letter-spacing: 1px; margin-bottom: 6px; }
.empty .stack { margin: var(--sp-4) auto 0; max-width: 320px; }
.banner { padding: 8px 10px; border-radius: var(--r-md); margin-bottom: var(--sp-2); border: 1px solid var(--outline); }
.banner.err { color: var(--rust); border-color: var(--rust); background: rgba(180, 35, 24, 0.07); }
.banner.ok { color: var(--ok); border-color: var(--ok); background: rgba(45, 106, 44, 0.07); }
.banner.row > span { flex: 1; min-width: 0; }
.alert { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); margin: var(--sp-2) 0; padding: 8px 10px; border-radius: var(--r-md); border: 1px solid var(--outline); font-size: 13px; }
.alert.warn { color: var(--rust); border-color: var(--rust); background: rgba(180, 35, 24, 0.08); }
.alert button { flex: 0 0 auto; }

/* Viewing a crew-mate's sheet */
.viewing { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; padding: 8px 10px; border: 1px solid var(--neon); background: var(--active); border-radius: var(--r-md); }
.viewing.readonly { border-color: var(--amber); background: var(--panel); }
.viewing-text { min-width: 0; font-size: 13px; }
.viewing-label { font-size: var(--fs-xs); letter-spacing: 1px; color: var(--ash); }
.viewing button { flex: 0 0 auto; }

/* ---------- segmented control, chips, collapsibles ---------- */
.segbar { margin-bottom: 10px; }
.segctl { display: flex; gap: 3px; padding: 3px; background: var(--panel-raised); border: 1px solid var(--outline); border-radius: 10px; margin-bottom: 10px; }
.segbar .segctl { margin-bottom: 0; }
.segctl button { flex: 1 1 0; min-width: 0; border: 0; background: transparent; border-radius: 8px; color: var(--ash); font-size: 13px; font-weight: 700; letter-spacing: 1px; padding: 0 6px; }
.segctl button.on { background: var(--active); color: var(--neon); box-shadow: inset 0 0 0 1px var(--neon); }
.segctl button .coll-badge { margin-left: 6px; }

.chip-strip { display: flex; gap: var(--sp-2); overflow-x: auto; margin: 0 calc(-1 * var(--gutter)) var(--sp-2); padding: 3px var(--gutter) 8px; scrollbar-width: none; -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain; }
.chip-strip::-webkit-scrollbar { display: none; }
.chip { flex: 0 0 auto; white-space: nowrap; min-height: 40px; border-radius: var(--r-pill); padding: 0 14px; }
.chip.active { background: var(--active); border-color: var(--neon); color: var(--neon); }
.chip.ghost { color: var(--ash); border-style: dashed; }

.coll { background: var(--panel); border: 1px solid var(--outline); border-radius: var(--r-md); margin-bottom: 10px; }
.coll-head { display: flex; align-items: center; gap: var(--sp-2); width: 100%; min-height: 48px; padding: 0 var(--sp-3); justify-content: flex-start; text-align: left; background: transparent; border: 0; border-radius: var(--r-md); color: var(--neon); font-weight: 700; letter-spacing: 1px; }
.coll-title { flex: 1; min-width: 0; }
.coll-badge { font-size: var(--fs-xs); font-weight: 400; color: var(--amber); border: 1px solid var(--amber-dim); border-radius: var(--r-pill); padding: 1px 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 60%; letter-spacing: 0.5px; }
.coll.bad .coll-badge { color: var(--rust); border-color: var(--rust); }
.coll-chev svg { width: 20px; height: 20px; display: block; transition: transform var(--speed) var(--ease); }
.coll.open .coll-chev svg { transform: rotate(180deg); }
.coll-body { display: none; padding: 0 var(--sp-3) var(--sp-3); }
.coll.open > .coll-body { display: block; }

/* ---------- tiles & meters ---------- */
.tiles { display: flex; gap: var(--sp-2); flex-wrap: wrap; }
.tiles2, .tiles3, .tiles4 { display: grid; gap: var(--sp-2); margin: 10px 0; }
.tiles2 { grid-template-columns: 1fr 1fr; }
.tiles3 { grid-template-columns: repeat(3, 1fr); }
.tiles4 { grid-template-columns: repeat(4, 1fr); margin: 8px 0; }
.tile { flex: 1 1 0; min-width: 0; text-align: center; background: var(--panel-raised); border: 1px solid var(--outline); border-radius: var(--r-md); padding: 8px 6px; }
button.tile { display: block; min-height: 0; width: 100%; letter-spacing: 0; }
.tile .val { color: var(--neon); font-size: var(--fs-xl); font-weight: 700; line-height: 1.15; }
.tile .val.sm-val { font-size: 13px; padding-top: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile .sub { font-size: 10px; color: var(--ash); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: 0.5px; }
.tile.clickable { cursor: pointer; border-color: var(--neon); }
.tile.clickable:hover { background: var(--active); box-shadow: var(--glow); }
.tile.bad, .tile.clickable.bad { border-color: var(--rust); }
.tile.clickable .sub { color: var(--neon); }
.tile.bad .sub { color: var(--rust); }
.tiles4 .tile .val { font-size: 16px; }
.stepper-tile .stepper { justify-content: center; margin-top: 2px; }
.stepper-tile .sub { margin: 0; }
.stepper-tile .val { font-size: var(--fs-xl); }
.amber-t.val, .val.amber-t { color: var(--amber); }

.meter-card { padding: 10px var(--sp-3); }
.meter-head { display: flex; align-items: center; gap: 10px; min-height: 28px; margin-bottom: 6px; }
.meter-head > .lbl { flex: 1; }
.meter-val { font-weight: 700; font-size: 16px; }
.meter-card .meter-head > button { min-height: var(--tap); }
.seg-meter { display: flex; gap: 4px; }
.seg { flex: 1 1 0; min-width: 0; min-height: 44px; padding: 0; border-radius: var(--r-sm); background: var(--panel-raised); }
.seg.on { background: var(--neon); border-color: var(--neon); }
.seg.t-amber.on { background: var(--amber); border-color: var(--amber); }
.seg.t-low.on { background: var(--rust); border-color: var(--rust); }
.seg-meter.sm { flex: 1; max-width: 300px; }
.seg-meter.sm .seg { min-height: 40px; }

/* Engineered Lungs: the top life-support segment half-filled (left half lit); readout shows the ½ too */
.seg.half { border-color: var(--neon); background: linear-gradient(90deg, var(--neon) 50%, var(--panel-raised) 50%); }
.seg.t-low.half { border-color: var(--rust); background: linear-gradient(90deg, var(--rust) 50%, var(--panel-raised) 50%); }
.o2-half .meter-head { gap: 6px; }
.o2-half .meter-head > button { min-height: 36px; padding: 0 10px; font-size: var(--fs-sm); flex: 0 0 auto; }
.o2-half .o2-use { border-color: var(--neon); color: var(--neon); font-weight: 700; }
.o2-half .o2-add { min-width: 44px; }
.o2-note { font-size: var(--fs-xs); margin-top: 5px; line-height: 1.2; }

/* ---------- origin benefit (sheet, Stats) ---------- */
.supp-tag { display: inline-block; font-size: 9px; letter-spacing: 1px; line-height: 1; padding: 2px 5px; border: 1px dashed var(--amber); border-radius: 3px; color: var(--amber); vertical-align: middle; white-space: nowrap; }
.benefit-name { color: var(--amber); font-weight: 700; font-size: var(--fs-sm); letter-spacing: 0.5px; overflow-wrap: anywhere; }
.benefit-name.is-used { color: var(--ash); }
.benefit-origin { font-size: var(--fs-xs); color: var(--ash); letter-spacing: 1px; }
.benefit-fx { display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; width: 100%; min-height: 0; padding: 2px 0 0; margin: 2px 0 0; border: 0; background: transparent; text-align: left; font-size: 11px; line-height: 1.3; font-weight: 400; letter-spacing: 0; color: var(--ash); cursor: pointer; }
.benefit-fx.open { display: block; overflow: visible; color: var(--bone); }
.benefit-fx { position: relative; padding-right: 16px; }
.benefit-fx::after { content: '▾'; position: absolute; right: 2px; top: 2px; color: var(--amber); }
.benefit-fx.open::after { content: '▴'; }
@media (min-height: 940px) { .benefit-fx { -webkit-line-clamp: 2; } }
@media (min-width: 900px) { .benefit-fx { -webkit-line-clamp: 3; } }
.uses-pill { margin-left: auto; min-height: 28px; padding: 0 8px; border-radius: var(--r-pill); font-size: 10px; letter-spacing: 0.5px; font-weight: 700; white-space: nowrap; display: inline-flex; align-items: center; gap: 5px; position: relative; }
.uses-pill::before { content: ''; position: absolute; inset: -8px -4px; } /* 44px-ish tap area around the slim pill */
.uses-pill.avail { background: var(--active); border-color: var(--neon); color: var(--neon); }
.uses-pill.used { background: transparent; border: 1px dashed var(--ash); color: var(--ash); }
.uses-pill.used .uses-txt { text-decoration: line-through; text-decoration-thickness: 1px; }
.uses-pill:disabled { opacity: 0.85; cursor: default; }
@media (max-width: 380px) { .uses-pill .uses-txt { letter-spacing: 0; } }
.dr-src { color: var(--amber); }
.add-benefit { width: 100%; min-height: 32px; margin: 4px 0; border: 1px dashed var(--outline); color: var(--ash); background: transparent; font-size: var(--fs-sm); }
.supp-line { margin-top: 6px; }
.benefit-hint { display: block; margin-top: 3px; color: var(--amber); font-size: var(--fs-xs); letter-spacing: 0.5px; }
.benefit-hint::before { content: '◷ '; }
#f-benefit { margin-top: 6px; }

/* wizard: Alien Origins (supplement) toggle */
.wiz-alien { display: flex; flex-wrap: wrap; align-items: center; gap: 6px var(--sp-2); margin: 0 0 var(--sp-2); padding: 8px; border: 1px dashed var(--outline); border-radius: var(--r-md); }
.wiz-alien.on { border-color: var(--amber); background: rgba(176, 125, 20, 0.08); }
.wiz-alien .muted { flex: 1; min-width: 140px; }
.wiz-alien-teach { flex-basis: 100%; color: var(--bone); }
.bar { height: 10px; border: 1px solid var(--outline); border-radius: var(--r-pill); background: var(--panel-raised); overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--neon); }

/* ---------- character sheet ---------- */
.seg-panes > .pane { display: none; }
.seg-panes.seg-stats > .pane-stats,
.seg-panes.seg-mutations > .pane-mutations,
.seg-panes.seg-details > .pane-details { display: block; }
.pane > .sec-label:first-child { margin-top: 0; }

.sheet-id { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; min-height: 20px; }
.vitals { padding-bottom: var(--sp-3); }
.hp { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); margin-top: 6px; }
.hp-btn { width: 64px; min-height: 56px; padding: 0; font-size: 28px; line-height: 1; border-radius: 10px; }
.hp-read { flex: 1; text-align: center; }
.hp-num { font-size: var(--fs-2xl); font-weight: 700; line-height: 1; }
.hp-max { font-size: var(--fs-xl); font-weight: 400; color: var(--ash); }
.abilities { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--sp-2); margin-bottom: 10px; }
.ability { flex-direction: column; gap: 2px; min-height: 80px; padding: 6px 2px; background: var(--panel-raised); border: 1px solid var(--neon); border-radius: 10px; letter-spacing: 0; }
.ability:hover { background: var(--active); box-shadow: var(--glow); }
.ab-lbl { font-size: var(--fs-sm); font-weight: 700; letter-spacing: 1px; }
.ab-val { font-size: 30px; font-weight: 700; color: var(--neon); line-height: 1; }
.ab-hint { font-size: 10px; color: var(--neon); letter-spacing: 0.5px; }
.ability.advantage { border-color: var(--amber); } .ability.advantage .ab-val, .ability.advantage .ab-hint { color: var(--amber); }
.ability.disadvantage { border-color: var(--rust); } .ability.disadvantage .ab-val, .ability.disadvantage .ab-hint { color: var(--rust); }
.ability:disabled { border-color: var(--outline); opacity: 0.7; box-shadow: none; }
.badge-vital { font-size: var(--fs-xs); font-weight: 700; letter-spacing: 1px; padding: 2px 6px; border-radius: 2px; }
.badge-vital.dying, .badge-vital.dead { background: var(--rust); color: var(--void); }
.badge-vital.unconscious { background: var(--amber); color: var(--void); }
.badge-broken { background: var(--rust); color: var(--void); font-weight: 700; font-size: var(--fs-xs); padding: 2px 6px; border-radius: 2px; }

/* ---------- gear ---------- */
.slotbar { position: sticky; top: calc(var(--topbar-h) + var(--sat)); z-index: 5; margin: 0 calc(-1 * var(--gutter)) 10px; padding: 10px var(--gutter); background: var(--void); border-bottom: 1px solid var(--outline); }
.slotbar-top { display: flex; align-items: baseline; gap: 10px; margin-bottom: 6px; }
.slotbar-val { font-size: var(--fs-xl); font-weight: 700; }
.slotbar-warn { margin-left: auto; font-size: var(--fs-sm); }
.slotbar.bad .bar > span { background: var(--rust); }
.parts { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-2); margin-bottom: 10px; }
.items { display: flex; flex-direction: column; gap: var(--sp-2); margin-top: 10px; }
.item { padding: 0; margin: 0; }
.item.equipped { border-left: 3px solid var(--amber); }
.item.broken { border-color: var(--rust); }
.item-top { display: flex; align-items: stretch; }
.item-main { flex: 1; min-width: 0; flex-direction: column; align-items: flex-start; justify-content: center; gap: 4px; min-height: 60px; padding: 8px var(--sp-3); background: transparent; border: 0; text-align: left; letter-spacing: 0; }
.item-name { font-weight: 700; font-size: 15px; overflow-wrap: anywhere; }
.item-sub { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 12px; font-size: var(--fs-sm); }
.equip { position: relative; display: flex; align-items: center; width: 68px; margin: 8px 8px 8px 0; flex: 0 0 auto; cursor: pointer; }
.equip input[type="checkbox"] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; margin: 0; cursor: pointer; }
.equip input[type="checkbox"]::before, .equip input[type="checkbox"]::after { display: none; }
.equip span { display: flex; align-items: center; justify-content: center; width: 100%; min-height: var(--tap); border: 1px solid var(--outline); border-radius: var(--r-md); font-size: var(--fs-xs); letter-spacing: 0.5px; color: var(--ash); background: var(--panel-raised); }
.equip input:checked + span { color: var(--amber); border-color: var(--amber); background: rgba(176, 125, 20, 0.14); }
.equip input:focus-visible + span { outline: 2px solid var(--neon); outline-offset: 2px; }
.equip input:disabled + span { opacity: 0.5; }
.item-cond { display: flex; align-items: center; gap: 10px; padding: 0 var(--sp-3) 10px; }
.item-ammo { flex-wrap: wrap; }
.item-ammo .ammo-spacer { flex: 1; }
.item-ammo .ammo-btn { flex: 0 0 auto; min-height: 40px; padding: 0 12px; font-size: var(--fs-sm); }
.seg.t-amber.on { background: var(--amber); border-color: var(--amber); }
.item .coll-body { padding-top: 0; border-top: 1px solid var(--outline); padding-top: 10px; }
.fab { position: fixed; z-index: 35; right: max(16px, var(--sar)); bottom: calc(var(--tabbar-h) + var(--sab) + 16px); min-height: 56px; padding: 0 22px 0 16px; border-radius: 28px; background: var(--neon); color: var(--void); border: 0; font-weight: 700; letter-spacing: 1px; box-shadow: 0 4px 16px rgba(60, 38, 14, 0.28), var(--glow); }
.fab svg { width: 22px; height: 22px; }

/* ---------- ship ---------- */
.hubstat .hub-title { margin-bottom: 6px; font-size: var(--fs-lg); }
.hubstat input[type="range"] { margin: -4px 0 0; }
.mod-row { padding: 4px 0; border-bottom: 1px solid rgba(110, 85, 50, 0.22); min-height: 48px; }
.mod-row:last-of-type { border-bottom: 0; }
.add-row { display: flex; gap: var(--sp-2); margin-top: 10px; }
.add-row select { flex: 1; min-width: 0; }

/* ---------- crew ---------- */
.crew-name { font-size: var(--fs-xl); font-weight: 700; }
.crew-head button.rec { border-color: var(--rust); }
.roster { display: grid; gap: 10px; grid-template-columns: 1fr; margin-bottom: 10px; }
.crew-head { display: flex; flex-direction: column; gap: 8px; }
.crew-head .row { margin-bottom: 2px; }
.roster-card { margin: 0; }
.roster-name { font-size: 17px; font-weight: 700; }
.forms2 { display: grid; gap: 10px; grid-template-columns: 1fr; margin-bottom: 10px; }
.forms2 .card { margin: 0; }
.badge-role { font-size: var(--fs-xs); font-weight: 700; letter-spacing: 1px; padding: 2px 6px; border-radius: 2px; border: 1px solid var(--outline); color: var(--ash); }
.badge-role.gm { background: var(--amber); border-color: var(--amber); color: var(--void); }
.invite-code { font-size: 26px; font-weight: 700; letter-spacing: 6px; color: var(--neon); background: var(--panel-raised); border: 1px dashed var(--neon); border-radius: var(--r-md); padding: 8px 12px; margin-top: 4px; text-align: center; user-select: all; word-break: break-all; }
.member-row { padding: 6px 0; border-bottom: 1px solid var(--outline); gap: var(--sp-2); }
.member-row:last-of-type { border-bottom: 0; }
@media (max-width: 420px) { .invite-code { font-size: 22px; letter-spacing: 4px; } }

/* ---------- forms ---------- */
input[type="text"], input[type="number"], input[type="search"], textarea, select {
  font-family: var(--mono);
  font-size: 16px; /* >=16px stops iOS zooming into a focused field */
  background: var(--panel-raised);
  color: var(--bone);
  border: 1px solid var(--outline);
  border-radius: var(--r-md);
  padding: 0 10px;
  min-height: var(--tap);
  width: 100%;
  -webkit-appearance: none; appearance: none;
}
textarea { padding: 10px; min-height: 0; resize: vertical; }
select { padding-right: 28px; background-image: linear-gradient(45deg, transparent 50%, var(--ash) 50%), linear-gradient(135deg, var(--ash) 50%, transparent 50%); background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
input:focus, textarea:focus, select:focus { border-color: var(--neon); }
input[type="search"]::-webkit-search-cancel-button { -webkit-appearance: none; }
label.field { display: block; margin-bottom: var(--sp-2); }
label.field .field-label, div.field-label { display: block; color: var(--ash); font-size: var(--fs-xs); letter-spacing: 1px; margin-bottom: 3px; }
label.field .field-hint { display: block; color: var(--terminal); font-size: var(--fs-xs); margin-bottom: 4px; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: var(--sp-2); }
input[type="range"] { width: 100%; height: var(--tap); accent-color: var(--neon); background: transparent; }
input[type="range"].low { accent-color: var(--rust); }
/* Checkboxes render as 52x44 switches so they are easy to hit. */
input[type="checkbox"] { -webkit-appearance: none; appearance: none; position: relative; flex: 0 0 auto; width: 52px; height: var(--tap); margin: 0; border: 0; background: transparent; cursor: pointer; }
input[type="checkbox"]::before { content: ""; position: absolute; left: 0; top: 50%; width: 52px; height: 26px; margin-top: -13px; border-radius: 13px; background: var(--panel-raised); border: 1px solid var(--outline); transition: background var(--speed) var(--ease); }
input[type="checkbox"]::after { content: ""; position: absolute; left: 5px; top: 50%; width: 16px; height: 16px; margin-top: -8px; border-radius: 50%; background: var(--ash); transition: transform var(--speed) var(--ease), background var(--speed) var(--ease); }
input[type="checkbox"]:checked::before { background: var(--active); border-color: var(--neon); }
input[type="checkbox"]:checked::after { transform: translateX(26px); background: var(--neon); }
input[type="checkbox"]:disabled { opacity: 0.5; }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4); padding: var(--sp-3) 0; border-bottom: 1px solid var(--outline); min-height: 56px; cursor: pointer; }
.setting-row:last-child { border-bottom: 0; }
.setting-text { min-width: 0; }
.setting-name { display: block; }
.setting-desc { display: block; font-size: var(--fs-xs); margin-top: 3px; line-height: 1.4; }

/* ---------- session log ---------- */
.rec-dot { color: var(--rust); font-weight: 700; letter-spacing: 1px; font-size: var(--fs-sm); animation: rec-blink 1.4s steps(2, start) infinite; }
.no-anim .rec-dot, .no-anim .rec-badge { animation: none; }
@keyframes rec-blink { 50% { opacity: 0.25; } }
.session-card { display: flex; align-items: center; gap: var(--sp-3); }
.log-row { display: grid; grid-template-columns: 24px 1fr auto; gap: var(--sp-2); align-items: start; padding: 8px 0; border-bottom: 1px solid var(--outline); }
.log-row:last-child { border-bottom: 0; }
.log-icon { text-align: center; }
.log-icon.neon { color: var(--neon); } .log-icon.amber { color: var(--amber); } .log-icon.rust { color: var(--rust); }
.log-body { overflow-wrap: anywhere; }
.log-time { font-size: var(--fs-sm); white-space: nowrap; }
.log-author { color: var(--terminal); font-weight: 700; }
.log-author::after { content: " ›"; color: var(--ash); font-weight: 400; }
.past-head { flex-direction: column; align-items: flex-start; gap: 2px; width: 100%; padding: 4px 0; background: transparent; border: 0; text-align: left; letter-spacing: 0; justify-content: center; }
.compose { position: fixed; z-index: 34; left: 0; right: 0; bottom: calc(var(--tabbar-h) + var(--sab)); display: flex; gap: var(--sp-2); padding: 8px max(12px, var(--sar)) 8px max(12px, var(--sal)); background: var(--panel); border-top: 1px solid var(--outline); }
.compose input { flex: 1; min-width: 0; }

/* ---------- rules ---------- */
.rules-search { position: sticky; top: calc(var(--topbar-h) + var(--sat)); z-index: 5; display: flex; gap: var(--sp-2); margin: 0 calc(-1 * var(--gutter)) var(--sp-2); padding: 8px var(--gutter); background: var(--void); }
.rules-search input { flex: 1; min-width: 0; }
.rules-search button { flex: 0 0 auto; }
.rule-heading { font-weight: 700; margin: 2px 0; }

/* ---------- switcher ---------- */
.picks { display: flex; flex-direction: column; gap: var(--sp-2); margin-bottom: 10px; }
.pick { justify-content: flex-start; gap: var(--sp-2); width: 100%; min-height: 52px; text-align: left; letter-spacing: 0; }
.pick.on { border-color: var(--neon); background: var(--active); }
.pick.retired { border-style: dashed; color: var(--ash); }

/* ---------- modal / bottom sheet ---------- */
#modal-root:empty { display: none; }
.modal-backdrop { position: fixed; inset: 0; z-index: 60; display: flex; align-items: flex-end; justify-content: center; background: rgba(42, 26, 10, 0.55); backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px); animation: fade-in var(--speed) var(--ease); }
.modal { position: relative; width: 100%; max-width: 680px; max-height: calc(100dvh - 24px - var(--sat)); overflow-y: auto; overscroll-behavior: contain; padding: 0 var(--sp-4); background: var(--panel); border: 1px solid var(--outline); border-bottom: 0; border-radius: var(--r-lg) var(--r-lg) 0 0; box-shadow: 0 -8px 32px rgba(60, 38, 14, 0.28); animation: sheet-up 180ms var(--ease); }
.sheet-grab { position: sticky; top: 0; z-index: 3; display: flex; justify-content: center; height: 22px; margin: 0 calc(-1 * var(--sp-4)); padding-top: 9px; background: var(--panel); touch-action: none; cursor: grab; }
.sheet-grab::before { content: ""; width: 44px; height: 4px; border-radius: 2px; background: var(--outline); }
.sheet-x { position: absolute; top: 4px; right: 4px; z-index: 4; width: 44px; min-width: 44px; padding: 0; background: transparent; border-color: transparent; }
.sheet-x svg { width: 20px; height: 20px; }
.modal h2 { margin: 0 0 var(--sp-3); padding-right: 44px; color: var(--neon); font-size: var(--fs-lg); letter-spacing: 1px; }
.modal-actions { position: sticky; bottom: 0; z-index: 3; display: flex; flex-wrap: wrap; gap: var(--sp-2); margin: var(--sp-4) calc(-1 * var(--sp-4)) 0; padding: var(--sp-3) var(--sp-4) calc(var(--sp-3) + var(--sab)); background: var(--panel); border-top: 1px solid var(--outline); }
.modal-actions > button { flex: 1 1 0; min-width: 110px; }
.modal mark, .gs-panel mark, .rules-hit mark { background: rgba(142, 27, 23, 0.16); color: var(--neon); padding: 0 1px; border-radius: 2px; }
.roll-big { text-align: center; }
.roll-big .total { font-size: 56px; font-weight: 700; line-height: 1.1; }
.roll-instruction { font-size: 24px; font-weight: 700; color: var(--neon); letter-spacing: 0.5px; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes sheet-up { from { transform: translateY(40px); opacity: 0.4; } to { transform: none; opacity: 1; } }

/* Creation wizard: a full-screen flow on phones. */
.modal.full { display: flex; flex-direction: column; height: 100dvh; max-height: none; max-width: none; padding: var(--sat) max(var(--sp-4), var(--sar)) 0 max(var(--sp-4), var(--sal)); border: 0; border-radius: 0; overflow: hidden; }
.modal.full .modal-actions { position: static; flex: 0 0 auto; margin: 0 calc(-1 * var(--sp-4)); }
.wiz-head { display: flex; align-items: center; justify-content: space-between; padding-top: var(--sp-2); }
.wiz-head h2 { margin: 0; padding: 0; }
.wiz-head button { width: 44px; padding: 0; border-color: transparent; font-size: 18px; }
.wiz-toggle { margin: 4px 0 var(--sp-2); gap: var(--sp-2); flex-wrap: wrap; }
.wiz-toggle .muted { flex: 1; min-width: 140px; }
.wiz-stepbar { display: flex; flex-direction: column; gap: 5px; margin-bottom: var(--sp-2); }
.wiz-stepbar-text { font-size: var(--fs-xs); letter-spacing: 1px; color: var(--terminal); }
.wiz-stepbar-track { display: block; height: 5px; border-radius: 3px; background: var(--panel-raised); overflow: hidden; }
.wiz-stepbar-track > span { display: block; height: 100%; background: var(--neon); }
.wiz-steps { display: none; flex-wrap: wrap; gap: 6px; margin-bottom: var(--sp-3); }
.wiz-step { font-size: var(--fs-xs); letter-spacing: 0.5px; color: var(--ash); border: 1px solid var(--outline); border-radius: 12px; padding: 3px 9px; }
.wiz-step.done { color: var(--terminal); }
.wiz-step.active { color: var(--neon); border-color: var(--neon); background: var(--active); }
.wiz-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 2px 2px var(--sp-3); }
.card.wiz-sel { border-color: var(--neon); background: var(--active); }
.wiz-benefits { margin-top: 10px; display: flex; flex-direction: column; gap: 6px; }
.wiz-radio { display: flex; gap: var(--sp-2); align-items: center; cursor: pointer; border: 1px solid var(--outline); border-radius: var(--r-md); padding: 8px; min-height: var(--tap); }
.wiz-radio.on { border-color: var(--amber); background: var(--panel-raised); }
.wiz-radio input { width: 24px; height: 24px; margin: 0; flex: 0 0 auto; }
.wiz-intro { color: var(--ash); font-size: 13px; margin: 0 0 10px; }
.wiz-teach { border: 1px solid var(--amber); border-left-width: 3px; background: rgba(176, 125, 20, 0.1); border-radius: var(--r-md); padding: 10px 12px; margin: 0 0 var(--sp-3); font-size: 13px; line-height: 1.45; }
.wiz-teach .teach-title { color: var(--amber); font-weight: 700; letter-spacing: 1px; font-size: var(--fs-sm); margin-bottom: 6px; }
.wiz-teach p { margin: 0 0 6px; } .wiz-teach p:last-child { margin-bottom: 0; }
.wiz-teach b { color: var(--neon); } .wiz-teach i { color: var(--terminal); }

/* ---------- global search overlay ---------- */
.gs-overlay { position: fixed; inset: 0; z-index: 70; background: var(--void); }
.gs-sheet { display: flex; flex-direction: column; height: 100%; }
.gs-bar { display: flex; align-items: center; gap: var(--sp-2); padding: calc(var(--sat) + 8px) max(12px, var(--sar)) 8px max(12px, var(--sal)); border-bottom: 1px solid var(--outline); }
.gs-input { flex: 1; min-width: 0; border-color: var(--neon); }
.gs-panel { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding-bottom: calc(var(--sab) + var(--sp-4)); }
.gs-group { color: var(--amber); font-size: var(--fs-xs); letter-spacing: 1px; padding: 8px 14px 4px; background: var(--panel-raised); position: sticky; top: 0; }
.gs-item { padding: 12px 14px; border-bottom: 1px solid var(--outline); cursor: pointer; min-height: var(--tap); }
.gs-item.sel, .gs-item:hover { background: var(--active); }
.gs-title { font-weight: 700; }
.gs-badge { color: var(--amber); border: 1px solid var(--amber-dim); border-radius: var(--r-pill); font-size: 10px; letter-spacing: 1px; padding: 1px 8px; white-space: nowrap; }
.gs-snippet { font-size: var(--fs-sm); margin-top: 3px; overflow-wrap: anywhere; }
.gs-note { padding: 14px; }

/* ---------- toasts: above the tab bar (top of screen while a sheet is open) ---------- */
.toast-root { position: fixed; left: 0; right: 0; bottom: calc(var(--tabbar-h) + var(--sab) + 12px); z-index: 80; display: flex; flex-direction: column; align-items: center; gap: var(--sp-2); padding: 0 var(--sp-4); pointer-events: none; }
html.sheet-open .toast-root { bottom: auto; top: calc(var(--sat) + 12px); }
.toast { max-width: 480px; padding: 10px 14px; border-radius: var(--r-md); background: var(--panel-raised); border: 1px solid var(--neon); color: var(--neon); box-shadow: 0 4px 16px rgba(60, 38, 14, 0.28); animation: sheet-up 160ms var(--ease); }
.toast.err { border-color: var(--rust); color: var(--rust); }

@media (display-mode: standalone) { html, body { overscroll-behavior-y: none; } }

/* Very narrow (320px) phones: tighten gutters so seven life-support segments stay >= 40px wide. */
@media (max-width: 359px) { :root { --gutter: 8px; } .meter-card { padding: 8px 6px; } .seg-meter { gap: 1px; } .tb-char-label { display: none; } }

/* ============ tablets & up ============ */
@media (min-width: 720px) {
  .roster { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
  .crew-head button.block { width: auto; align-self: flex-start; padding: 0 20px; }
  .forms2 { grid-template-columns: 1fr 1fr; }
  .modal-backdrop { align-items: center; padding: var(--sp-4); }
  .modal { max-height: 90dvh; border-bottom: 1px solid var(--outline); border-radius: var(--r-lg); padding-bottom: 0; }
  .sheet-grab { display: none; }
  .modal h2 { margin-top: var(--sp-4); }
  .modal-actions { margin-bottom: 0; padding-bottom: var(--sp-3); }
  .modal.full { height: min(90dvh, 880px); max-width: 720px; border: 1px solid var(--outline); border-radius: var(--r-lg); padding-top: 0; }
  .wiz-stepbar { display: none; }
  .wiz-steps { display: flex; }
  .gs-overlay { display: flex; justify-content: center; align-items: flex-start; padding: 8vh var(--sp-4) 0; background: rgba(60, 38, 14, 0.28); }
  .gs-sheet { height: auto; width: min(640px, 100%); max-height: 78dvh; background: var(--panel); border: 1px solid var(--neon); border-radius: var(--r-lg); box-shadow: var(--glow); overflow: hidden; }
  .gs-bar { padding-top: 8px; }
}

/* ============ wide: left rail + columns ============ */
@media (min-width: 900px) {
  .topbar { padding-left: max(16px, var(--sal)); padding-right: max(16px, var(--sar)); gap: var(--sp-3); }
  body.authed .tb-brand { display: block; text-shadow: none; font-size: 14px; white-space: nowrap; letter-spacing: 1px; margin-right: var(--sp-3); }
  .tb-char { flex: 0 1 340px; }
  .tb-label { display: inline; font-size: var(--fs-xs); letter-spacing: 1px; }
  .icon-btn.gs-toggle { width: auto; min-width: 280px; padding: 0 12px; gap: 8px; justify-content: flex-start; border-color: var(--outline); color: var(--ash); margin-right: var(--sp-2); }
  .gs-label { flex: 1; text-align: left; display: flex; justify-content: space-between; font-size: 13px; letter-spacing: 0.3px; }
  #tb-log, #tb-rules { width: auto; padding: 0 12px; gap: 6px; }
  #tb-log .rec-badge { top: 7px; right: auto; left: 22px; }

  .tabbar { top: calc(var(--topbar-h) + var(--sat)); right: auto; bottom: 0; width: var(--rail-w); height: auto; grid-auto-flow: row; grid-template-columns: 1fr; grid-auto-rows: 76px; align-content: start; padding: var(--sp-2) 0 0 var(--sal); border-top: 0; border-right: 1px solid var(--outline); }
  .tab { border-top: 0; border-left: 3px solid transparent; }
  .tab.active { border-top-color: transparent; border-left-color: var(--neon); }
  body.authed .content { max-width: none; margin: 0; padding: var(--sp-5) var(--gutter) var(--sp-5) calc(var(--rail-w) + var(--gutter)); }
  body.authed .content > * { max-width: 1280px; }
  body.authed .content.route-inventory { padding-bottom: 96px; }
  body.authed .content.route-session { padding-bottom: 96px; }
  .content.route-session > * { max-width: 860px; }
  .compose { left: var(--rail-w); bottom: 0; padding: 12px var(--gutter); }
  .compose > * { max-width: 800px; }
  .fab { bottom: 24px; right: 32px; }
  .toast-root { left: var(--rail-w); bottom: 24px; }

  .slotbar, .rules-search { margin-left: 0; margin-right: 0; padding-left: 0; padding-right: 0; }
  .chip-strip { margin-left: 0; margin-right: 0; padding-left: 2px; padding-right: 2px; flex-wrap: wrap; overflow: visible; }

  /* Sheet: all three segments side by side. */
  .segbar { display: none; }
  .seg-panes { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: var(--sp-4) var(--sp-5); align-items: start; }
  .seg-panes > .pane { display: block; }
  .seg-panes > .pane-stats { grid-column: span 1; }
  .items { display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); align-items: start; }
  .parts { max-width: 560px; }
  .route-hub { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 0 var(--sp-5); align-items: start; }
  .route-hub > .chip-strip, .route-hub > .banner, .route-hub > .empty { grid-column: 1 / -1; }
  .route-hub > .hubstat { grid-column: 1; grid-row: span 3; }
  .route-hub > .coll { grid-column: 2; }
}
@media (min-width: 1200px) {
  .seg-panes { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* ============ Story board ============ */
/* list */
.board-head { margin-bottom: var(--sp-2); }
.board-h1 { margin: 0; font-size: var(--fs-lg); letter-spacing: 1px; color: var(--neon); }
.board-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); }
.board-card { padding: 0; margin: 0; overflow: hidden; }
.board-card.last { border-color: var(--neon); }
.bl-main { display: flex; gap: 12px; align-items: center; width: 100%; padding: 10px; min-height: 88px; justify-content: flex-start; text-align: left; background: transparent; border: 0; border-radius: 0; }
.bl-main:hover { background: var(--panel-raised); }
.bl-thumb { flex: 0 0 84px; width: 84px; height: 64px; border: 1px solid var(--outline); border-radius: var(--r-md); background: var(--panel-raised); display: flex; align-items: center; justify-content: center; overflow: hidden; color: var(--ash); font-size: 26px; }
.bl-thumb-img { width: 100%; height: 100%; object-fit: cover; display: block; }
.bl-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; flex: 1; }
.bl-title { font-weight: 700; color: var(--terminal); font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bl-badges { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.bl-actions { display: flex; gap: var(--sp-2); padding: 0 10px 10px; flex-wrap: wrap; }
.bd-loading { padding: 24px var(--gutter); }
.pin-results { max-height: 220px; overflow-y: auto; overscroll-behavior: contain; border: 1px solid var(--outline); border-radius: var(--r-md); }
.pin-res { display: flex; width: 100%; justify-content: space-between; gap: 8px; text-align: left; border: 0; border-bottom: 1px solid var(--outline); border-radius: 0; background: transparent; min-height: 44px; }
.pin-res:hover { background: var(--active); }
.pin-target { margin-bottom: var(--sp-2); }

/* the canvas fills the page area between the app bars */
html.board-open, body.board-open { overflow: hidden; overscroll-behavior: none; }
body.board-open::after { display: none; }
body.authed .content.route-board-open { position: fixed; top: calc(var(--topbar-h) + var(--sat)); left: 0; right: 0; bottom: calc(var(--tabbar-h) + var(--sab)); padding: 0; margin: 0; max-width: none; min-height: 0; }
body.authed .content.route-board-open > * { max-width: none; }
@media (min-width: 900px) { body.authed .content.route-board-open { left: var(--rail-w); bottom: 0; padding: 0; } }
body.board-focus .topbar, body.board-focus .tabbar { display: none; }
body.board-focus.authed .content.route-board-open { top: 0; left: 0; bottom: 0; }
body.board-open .toast-root { bottom: calc(var(--tabbar-h) + var(--sab) + 84px); }
@media (min-width: 900px) { body.board-open .toast-root { bottom: 24px; left: calc(var(--rail-w) + 80px); } }
body.board-focus .toast-root { bottom: 84px; left: 0; }

.bd { --bd-top: 8px; position: absolute; inset: 0; overflow: hidden; background: var(--void); touch-action: none; overscroll-behavior: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; }
body.board-focus .bd { --bd-top: max(8px, var(--sat)); }
.bd-canvas { position: absolute; left: 0; top: 0; display: block; touch-action: none; cursor: crosshair; outline: none; -webkit-user-select: none; user-select: none; }
.bd[data-active="select"] .bd-canvas { cursor: default; }
.bd[data-active="text"] .bd-canvas { cursor: text; }
.bd[data-active="pin"] .bd-canvas { cursor: copy; }
.bd[data-active="eraser"] .bd-canvas { cursor: none; }
.bd-canvas.panning-ready { cursor: grab; }
.bd-canvas.panning { cursor: grabbing; }
.bd-bar { position: absolute; z-index: 3; background: rgba(248, 240, 218, 0.96); border: 1px solid var(--outline); border-radius: 12px; box-shadow: 0 4px 16px rgba(0, 0, 0, 0.45); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
.bd-bar[hidden], .bd-pop[hidden] { display: none; }
.bd-btn { flex: 0 0 auto; width: 44px; min-width: 44px; min-height: 44px; padding: 0; background: transparent; border-color: transparent; color: var(--bone); }
.bd-btn svg { width: 22px; height: 22px; display: block; }
.bd-btn:hover { border-color: var(--outline); }
.bd-btn.on, .bd-btn[aria-pressed="true"] { color: var(--neon); background: var(--active); border-color: var(--neon); }
.bd-btn:disabled { opacity: 0.32; }
.bd-btn.danger { color: var(--rust); }
.bd-btn.bd-txt { width: auto; padding: 0 12px; gap: 6px; font-weight: 700; }
.bd-btn.bd-txt svg { width: 18px; height: 18px; }
.bd-btn.primary { background: var(--neon); color: var(--void); border-color: var(--neon); }

.bd-top { top: var(--bd-top); left: max(8px, var(--sal)); right: max(8px, var(--sar)); display: flex; align-items: center; gap: 2px; padding: 2px; min-height: 50px; }
.bd-title { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; line-height: 1.15; padding: 0 6px; }
.bd-title-text { font-weight: 700; color: var(--terminal); font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bd-sub { font-size: 10px; letter-spacing: 1px; color: var(--ash); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bd-status { flex: 0 0 auto; display: inline-flex; align-items: center; gap: 5px; font-size: 10px; letter-spacing: 0.8px; padding: 0 6px; color: var(--ash); white-space: nowrap; }
.bd-status i { width: 9px; height: 9px; border-radius: 50%; background: var(--neon); box-shadow: 0 0 6px rgba(142, 27, 23, 0.35); }
.bd-status[data-state="saving"] i { background: var(--amber); box-shadow: none; animation: rec-blink 1s steps(2, start) infinite; }
.bd-status[data-state="unsaved"] i, .bd-status[data-state="offline"] i { background: var(--amber); box-shadow: none; }
.bd-status[data-state="unsaved"], .bd-status[data-state="offline"], .bd-status[data-state="saving"] { color: var(--amber); }
@media (max-width: 460px) { .bd-status[data-state="saved"] b { display: none; } }
@media (max-width: 359px) { .bd-status b { max-width: 70px; overflow: hidden; text-overflow: ellipsis; } .bd-sub { display: none; } }
.bd-wide { display: none; }
.bd-zoom-grp { display: none; align-items: center; }
.bd-zlabel { width: 58px; min-width: 58px; font-size: 12px; }

.bd-dock { left: max(8px, var(--sal)); right: max(8px, var(--sar)); bottom: 8px; display: flex; padding: 2px; }
body.board-focus .bd-dock { bottom: max(8px, var(--sab)); }
.bd-dock .bd-btn { flex: 1 1 0; min-width: 0; width: auto; min-height: 48px; position: relative; }
.bd-dot { position: absolute; right: calc(50% - 17px); bottom: 7px; width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--panel); box-shadow: 0 0 0 1px var(--outline); }
.bd-dot[hidden] { display: none; }
.bd-caret { display: none; position: absolute; top: 3px; right: 5px; width: 0; height: 0; border-left: 4px solid transparent; border-right: 4px solid transparent; border-bottom: 5px solid currentColor; opacity: 0.8; }
.bd-tool.on .bd-caret { display: block; }
.bd-acts { right: max(8px, var(--sar)); top: calc(var(--bd-top) + 58px); display: flex; flex-direction: column; padding: 2px; }

.bd-pop { background: var(--panel); z-index: 5; left: max(8px, var(--sal)); right: max(8px, var(--sar)); bottom: 72px; margin: 0 auto; width: min(340px, calc(100% - 16px)); max-height: calc(100% - 140px); overflow-y: auto; overscroll-behavior: contain; padding: 10px 12px 12px; touch-action: pan-y; }
.bd-pop[data-pop="menu"] { top: calc(var(--bd-top) + 58px); bottom: auto; left: auto; right: max(8px, var(--sar)); margin: 0; width: min(280px, calc(100% - 16px)); }
.bd-pop[data-pop="photo"] { top: calc(var(--bd-top) + 58px); bottom: auto; left: auto; right: calc(max(8px, var(--sar)) + 52px); margin: 0; width: min(280px, calc(100% - 76px)); }
.bd.editing .bd-pop { top: calc(var(--bd-top) + 58px); bottom: auto; }
.bd-pop-title { color: var(--neon); font-size: var(--fs-sm); letter-spacing: 1.5px; font-weight: 700; margin-bottom: 8px; }
.bd-pop .muted { margin-top: 8px; }
.bd-swatches { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 10px; }
.bd-sw { min-height: 44px; padding: 0; background: var(--c); border: 2px solid var(--outline); border-radius: 10px; }
.bd-sw.on { border-color: var(--neon); box-shadow: 0 0 0 2px var(--void) inset, 0 0 0 1px var(--neon); }
.bd-widths { display: flex; gap: 8px; margin-bottom: 4px; }
.bd-wd { flex: 1 1 0; min-width: 0; min-height: 44px; padding: 0; }
.bd-wd i { display: block; border-radius: 50%; }
.bd-wd.on { border-color: var(--neon); background: var(--active); }
.bd-seg { margin-bottom: 10px; }
.bd-row { display: flex; gap: 8px; align-items: flex-start; margin-bottom: 0; }
.bd-row .bd-seg { flex: 1 1 0; min-width: 0; margin-bottom: 10px; }
.bd-row .bd-seg button { min-height: 44px; }
.bd-align { display: flex; flex: 0 0 auto; gap: 2px; }
.bd-row .bd-align { margin-bottom: 10px; }
.bd-menu { display: flex; flex-direction: column; gap: 2px; }
.bd-menu button { justify-content: flex-start; width: 100%; background: transparent; border-color: transparent; min-height: 44px; }
.bd-menu button:hover { background: var(--panel-raised); border-color: var(--outline); }
.bd-menu svg { width: 20px; height: 20px; flex: 0 0 auto; }

.bd-selbar { z-index: 4; left: 0; top: 0; padding: 6px 6px 4px; display: flex; flex-direction: column; gap: 2px; max-width: calc(100% - 16px); will-change: transform; }
.bd-sel-info { display: flex; gap: 6px; align-items: baseline; padding: 0 4px; font-size: var(--fs-sm); white-space: nowrap; }
.bd-sel-label { padding: 0 4px; font-weight: 700; color: var(--terminal); max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bd-sel-btns { display: flex; gap: 2px; flex-wrap: wrap; }
.bd-sel-rows { display: flex; flex-wrap: wrap; column-gap: 2px; row-gap: 0; }
.bd-sel-rows .bd-sel-btns { flex-wrap: nowrap; }
.bd-sel-hint { padding: 0 4px; font-size: 12px; color: var(--ash); }
.bd-locktag { color: var(--amber); display: inline-flex; align-items: center; gap: 3px; }
.bd-locktag svg { width: 12px; height: 12px; }
.bd-btn[aria-disabled="true"] { opacity: 0.32; }
.bd-btn.bd-txt.on svg { color: var(--neon); }
.bd-sel-sw { display: grid; grid-template-columns: repeat(4, 44px); gap: 6px; padding: 4px 4px 2px; }
.bd-sel-sw .bd-sw { width: 44px; min-height: 44px; }
.bd-connect { z-index: 4; top: calc(var(--bd-top) + 58px); left: max(8px, var(--sal)); right: calc(max(8px, var(--sar)) + 56px); margin: 0 auto; width: fit-content; max-width: calc(100% - 72px); display: flex; align-items: center; gap: 6px; padding: 4px 4px 4px 12px; border-color: var(--amber); }
.bd-connect[hidden] { display: none; }
.bd-connect-txt { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.bd-connect-txt b { color: var(--amber); font-size: var(--fs-sm); letter-spacing: 0.5px; }
.bd-connect-txt span { color: var(--ash); font-size: 12px; }
.bd.connecting .bd-canvas { cursor: crosshair; }

.bd-empty { position: absolute; inset: 0; z-index: 1; display: flex; align-items: center; justify-content: center; padding: 70px 16px 84px; pointer-events: none; }
.bd-empty-card { pointer-events: auto; max-width: 360px; text-align: center; padding: 18px 16px; background: rgba(248, 240, 218, 0.95); border: 1px dashed var(--outline); border-radius: var(--r-lg); }
.bd-empty-card p { margin: 0 0 12px; color: var(--bone); }
.bd-empty-card .btn-row { margin-top: 0; flex-wrap: wrap; }
.bd-empty-card svg { width: 18px; height: 18px; }
.bd-editor { position: absolute; left: 0; top: 0; z-index: 6; margin: 0; border: 2px dashed var(--neon); border-radius: 6px; resize: none; overflow: hidden; min-height: 40px; outline: none; box-sizing: border-box; font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; user-select: text; -webkit-user-select: text; touch-action: auto; letter-spacing: 0; }
.bd-editor:focus { border-color: var(--neon); }
.bd-drop { position: absolute; inset: 8px; z-index: 7; display: flex; align-items: center; justify-content: center; border: 3px dashed var(--neon); border-radius: var(--r-lg); background: rgba(12, 14, 11, 0.75); color: var(--neon); font-weight: 700; letter-spacing: 2px; pointer-events: none; }
.bd-drop[hidden] { display: none; }

/* tablets / desktop: vertical tool dock on the left, zoom controls in the top bar */
@media (min-width: 700px) and (min-height: 560px) {
  .bd-dock { top: calc(var(--bd-top) + 58px); bottom: auto; right: auto; flex-direction: column; width: 56px; }
  .bd-dock .bd-btn { flex: 0 0 auto; width: 100%; min-height: 50px; }
  .bd-dot { right: 6px; bottom: 6px; }
  .bd-caret { top: 5px; right: 5px; }
  .bd-acts { left: max(8px, var(--sal)); right: auto; top: auto; bottom: 12px; width: 56px; }
  .bd-acts .bd-btn { width: 100%; min-height: 50px; }
  .bd-pop { left: calc(max(8px, var(--sal)) + 64px); right: auto; margin: 0; top: calc(var(--bd-top) + 58px); bottom: auto; width: 320px; max-height: calc(100% - 80px); }
  .bd-pop[data-pop="photo"] { left: calc(max(8px, var(--sal)) + 64px); right: auto; top: auto; bottom: 12px; width: 300px; }
  .bd-pop[data-pop="menu"] { left: auto; right: max(8px, var(--sar)); top: calc(var(--bd-top) + 58px); }
  .bd.editing .bd-pop { top: calc(var(--bd-top) + 58px); }
  .bd-connect { left: calc(max(8px, var(--sal)) + 64px); right: calc(max(8px, var(--sar)) + 8px); max-width: calc(100% - 140px); }
}
@media (min-width: 700px) { .bd-wide { display: inline-flex; } .bd-zoom-grp.bd-wide { display: inline-flex; } .bd-top { left: max(8px, var(--sal)); } }
@media (max-height: 559px) and (min-width: 560px) { .bd-acts { flex-direction: row; top: calc(var(--bd-top) + 58px); } }

/* ============ Handouts ============ */
.crew-head-btns { flex-wrap: wrap; }
.crew-head-btns > * { flex: 1 1 148px; }
.crew-head-btns button.has-new { border-color: var(--neon); color: var(--neon); }
.chip.has-new::after { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--neon); margin-left: 7px; box-shadow: var(--glow); }
.tab-icon { position: relative; display: inline-block; }
.tab-badge { position: absolute; top: -5px; right: -10px; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px; background: var(--neon); color: var(--void); font-size: 10px; font-weight: 700; line-height: 17px; text-align: center; box-shadow: var(--glow); letter-spacing: 0; }
.ho-new-pill { display: inline-block; background: var(--neon); color: var(--void); font-size: 10px; font-weight: 700; letter-spacing: 1px; padding: 1px 7px; border-radius: var(--r-pill); vertical-align: middle; margin-left: 4px; }
.ho-newtxt { color: var(--neon); font-weight: 700; }
.ho-section { border-color: var(--outline); }
.ho-section.dropping { border-color: var(--neon); box-shadow: var(--glow); outline: 2px dashed var(--neon); outline-offset: 3px; }
.ho-section.dropping .coll-body::before { content: "DROP IMAGES TO UPLOAD AS HIDDEN DRAFTS"; display: block; text-align: center; padding: 14px; margin-bottom: 8px; border: 1px dashed var(--neon); color: var(--neon); letter-spacing: 1px; font-size: var(--fs-sm); }

.ho-bar { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.ho-bar > button { flex: 1 1 120px; }
.ho-bar > .primary { flex: 1 1 100%; }
.ho-bar svg, .ho-acts svg, .ho-sec svg, .ho-chip svg, .ho-flag svg, .hov-actions svg { width: 16px; height: 16px; flex: 0 0 auto; }
.ho-hint { margin: 8px 0 var(--sp-2); }
.ho-uploads:empty { display: none; }
.ho-up { border: 1px solid var(--outline); border-radius: var(--r-md); padding: 6px 8px; margin-bottom: 6px; background: var(--panel-raised); }
.ho-up.failed { border-color: var(--rust); }
.ho-up-top { display: flex; align-items: center; gap: 6px; min-height: 30px; }
.ho-up-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--fs-sm); }
.ho-up-state { font-size: 10px; letter-spacing: 1px; color: var(--amber); white-space: nowrap; }
.ho-up.done .ho-up-state { color: var(--neon); }
.ho-up.failed .ho-up-state { color: var(--rust); }
.ho-up button.mini { min-height: 36px; }
.ho-up button.icon { width: 36px; padding: 0; }
.ho-up-err { color: var(--rust); font-size: var(--fs-sm); padding-bottom: 2px; }
.ho-prog { height: 4px; background: var(--outline); border-radius: 2px; overflow: hidden; margin: 4px 0 2px; }
.ho-prog i { display: block; height: 100%; background: var(--neon); transition: width 120ms linear; }
.ho-up.queued .ho-prog i, .ho-up.preparing .ho-prog i { width: 35% !important; background: var(--amber); animation: ho-slide 1.1s ease-in-out infinite alternate; }
@keyframes ho-slide { from { margin-left: 0; } to { margin-left: 65%; } }
.ho-filter { display: block; width: 100%; margin: 6px 0 2px; }
.ho-sec { margin-top: var(--sp-4); }
.ho-sec > span { display: inline-flex; align-items: center; gap: 6px; }
.ho-sec button.mini { min-height: 36px; }
.ho-sec.draft { color: var(--amber); }
.ho-empty { margin: var(--sp-3) 0 0; }

.ho-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(136px, 1fr)); }
.ho-card { position: relative; display: flex; flex-direction: column; min-width: 0; background: var(--panel-raised); border: 1px solid var(--outline); border-radius: var(--r-md); overflow: hidden; }
.ho-card.given { border-top: 2px solid var(--ok); }
.ho-card.draft { border: 1px dashed var(--amber); background: repeating-linear-gradient(135deg, rgba(176, 125, 20, 0.12) 0 7px, transparent 7px 14px), var(--panel-raised); }
.ho-card.draft .ho-img { opacity: 0.62; filter: grayscale(0.55); }
.ho-card.draft .ho-img.loaded { opacity: 0.62; }
.ho-card.unseen { border-color: var(--neon); box-shadow: var(--glow); }
.ho-card.sel { outline: 3px solid var(--neon); outline-offset: -3px; }
.ho-thumb { position: relative; display: block; width: 100%; aspect-ratio: 4 / 3; padding: 0; border: 0; border-radius: 0; background: var(--panel-raised); overflow: hidden; min-height: 0; }
.ho-thumb:hover { border-color: transparent; }
.ho-img { display: block; width: 100%; height: 100%; object-fit: contain; opacity: 0; transition: opacity 160ms var(--ease); }
.ho-img.loaded { opacity: 1; }
.ho-flag { position: absolute; display: inline-flex; align-items: center; gap: 4px; font-size: 10px; font-weight: 700; letter-spacing: 1px; padding: 3px 7px; border-radius: 3px; line-height: 1.2; }
.ho-flag.draft { top: 6px; left: 6px; background: var(--amber); color: var(--void); }
.ho-flag.new { top: 6px; left: 6px; background: var(--neon); color: var(--void); box-shadow: var(--glow); }
.ho-flag.priv { bottom: 6px; left: 6px; background: rgba(248, 240, 218, 0.94); color: var(--amber); border: 1px solid var(--amber); }
.ho-check { position: absolute; top: 6px; right: 6px; width: 30px; height: 30px; border-radius: 50%; border: 2px solid var(--bone); background: rgba(60, 38, 14, 0.28); display: flex; align-items: center; justify-content: center; font-weight: 700; color: var(--void); }
.ho-check.on { background: var(--neon); border-color: var(--neon); }
.ho-info { display: flex; flex-direction: column; gap: 4px; padding: 6px 8px 8px; min-width: 0; }
.ho-main { display: flex; flex-direction: column; align-items: stretch; justify-content: flex-start; width: 100%; padding: 0; text-align: left; background: transparent; border: 0; border-radius: 0; min-height: 0; gap: 0; }
.ho-main:hover { background: rgba(110, 85, 50, 0.06); }
.ho-main .ho-thumb { display: block; }
.ho-main .ho-info { display: flex; padding: 8px; }
.ho-title { display: flex; align-items: center; justify-content: flex-start; width: 100%; min-height: var(--tap); padding: 0; background: transparent; border: 0; border-radius: var(--r-sm); text-align: left; color: var(--terminal); font-weight: 700; font-size: 14px; letter-spacing: 0.2px; }
.ho-title:hover { color: var(--neon); }
.ho-title span { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.ho-title-static { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; font-weight: 700; color: var(--terminal); font-size: 14px; }
.ho-rename { width: 100%; min-height: var(--tap); padding: 0 8px; }
.ho-cap { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; font-size: var(--fs-sm); color: var(--ash); }
.ho-note { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; font-size: 11px; color: var(--amber); }
.ho-note::before { content: "GM · "; letter-spacing: 1px; opacity: 0.7; }
.ho-chips { display: flex; flex-wrap: wrap; gap: 4px; min-width: 0; }
.ho-chip { display: inline-flex; align-items: center; gap: 3px; max-width: 100%; font-size: 10px; letter-spacing: 0.5px; padding: 2px 7px; border-radius: var(--r-pill); border: 1px solid var(--outline); color: var(--bone); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ho-chip svg { width: 11px; height: 11px; }
.ho-chip.draft { color: var(--amber); border-color: var(--amber-dim); background: rgba(176, 125, 20, 0.12); }
.ho-chip.crew { color: var(--neon); border-color: var(--outline); }
.ho-chip.user { color: var(--terminal); border-color: var(--outline); }
.ho-chip.user.priv { color: var(--amber); border-color: var(--amber); }
.ho-chip.dim { opacity: 0.55; }
.ho-acts { display: flex; gap: 6px; margin-top: 2px; }
.ho-acts .mini { flex: 1 1 0; min-width: 0; min-height: var(--tap); }
.ho-acts .ho-more { flex: 0 0 var(--tap); padding: 0; }
.ho-selbar { position: fixed; left: max(8px, var(--sal)); right: max(8px, var(--sar)); bottom: calc(var(--tabbar-h) + var(--sab) + 8px); z-index: 45; display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); padding: 8px; background: var(--panel-raised); border: 1px solid var(--neon); border-radius: var(--r-md); box-shadow: 0 4px 24px rgba(60, 38, 14, 0.28), var(--glow); }
.ho-selbar b { flex: 1 1 100px; color: var(--neon); letter-spacing: 1px; font-size: var(--fs-sm); }
.ho-selbar button { flex: 0 1 auto; }
@media (min-width: 900px) { .ho-selbar { left: calc(var(--rail-w) + 16px); right: 16px; bottom: 16px; max-width: 640px; } }

/* sheets */
.ho-big { min-height: 60px; font-size: 16px; letter-spacing: 1px; margin: 4px 0 2px; }
.ho-picks { display: flex; flex-direction: column; }
.ho-pick { display: flex; align-items: center; gap: 10px; min-height: 52px; padding: 0 4px; border-bottom: 1px solid rgba(110, 85, 50, 0.3); cursor: pointer; }
.ho-pick-name { flex: 1; min-width: 0; display: inline-flex; align-items: center; gap: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; }
.ho-pick-name svg { width: 14px; height: 14px; color: var(--amber); flex: 0 0 auto; }
.ho-bsum { display: flex; align-items: center; gap: 10px; margin: 0 0 12px; min-width: 0; }
.ho-bsum > span:last-child { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.ho-bsum-t { display: flex; font-weight: 400; }
.ho-minis { display: flex; gap: 4px; align-items: center; flex: 0 1 auto; }
.ho-mini { display: block; width: 56px; height: 42px; flex: 0 0 auto; border-radius: 4px; overflow: hidden; background: var(--panel-raised); border: 1px solid var(--outline); }
.ho-more-n { font-size: var(--fs-sm); color: var(--ash); padding-left: 4px; }
.ho-rrow { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 56px; border-bottom: 1px solid rgba(110, 85, 50, 0.3); }
.ho-rname { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; min-width: 0; overflow-wrap: anywhere; }
.ho-rname svg { width: 14px; height: 14px; color: var(--amber); }
.ho-more-list button { justify-content: flex-start; min-height: 48px; }
.ho-blist { display: flex; flex-direction: column; gap: 6px; }
.ho-brow { flex-direction: column; align-items: flex-start; justify-content: center; gap: 2px; width: 100%; min-height: 52px; padding: 8px 12px; text-align: left; }
.ho-bt { font-weight: 700; color: var(--terminal); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ho-pickgrid { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); }
.ho-pickcell { display: flex; flex-direction: column; align-items: stretch; justify-content: flex-start; padding: 0; overflow: hidden; text-align: left; min-height: 0; gap: 0; }
.ho-pickcell .ho-title-static { padding: 5px 6px 6px; font-size: 12px; min-height: 40px; }

/* toast with an action */
.toast { display: flex; align-items: center; gap: 12px; }
.toast.act { pointer-events: auto; }
.toast-text { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.toast-btn { flex: 0 0 auto; min-height: 44px; background: var(--neon); color: var(--void); border-color: var(--neon); font-weight: 700; }
html.ho-viewing .toast-root { bottom: auto; top: calc(var(--sat) + 70px); }

/* viewer */
html.ho-viewing, html.ho-viewing body { overflow: hidden; }
.hov { position: fixed; inset: 0; z-index: 50; background: #050605; color: var(--bone); overscroll-behavior: contain; touch-action: none; }
.hov:focus-visible { outline: none; }
.hov-stage { position: absolute; inset: 0; overflow: hidden; touch-action: none; cursor: grab; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.hov-stage.grabbing { cursor: grabbing; }
.hov-stage img { position: absolute; left: 0; top: 0; max-width: none; transform-origin: 0 0; will-change: transform; user-select: none; -webkit-user-drag: none; }
.hov-stage img.settle { transition: transform 200ms var(--ease); }
.hov-load { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--ash); letter-spacing: 2px; pointer-events: none; }
.hov-top { position: absolute; top: 0; left: 0; right: 0; z-index: 2; display: flex; align-items: center; gap: 4px; padding: calc(var(--sat) + 6px) max(8px, var(--sar)) 6px max(8px, var(--sal)); background: linear-gradient(to bottom, rgba(5, 6, 5, 0.92), rgba(5, 6, 5, 0.55)); }
.hov-btn { width: 44px; min-width: 44px; min-height: 44px; padding: 0; background: rgba(20, 23, 18, 0.72); }
.hov-btn svg { width: 22px; height: 22px; }
.hov-btn[aria-pressed="true"] { color: var(--neon); border-color: var(--neon); }
.hov-title { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.2; padding: 0 4px; }
.hov-title b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--terminal); }
.hov-title span { font-size: var(--fs-xs); letter-spacing: 1px; }
.hov-zoomgrp { display: none; gap: 4px; }
@media (min-width: 560px) { .hov-zoomgrp { display: inline-flex; } }
.hov-nav { position: absolute; top: 50%; transform: translateY(-50%); z-index: 2; width: 44px; min-width: 44px; min-height: 72px; padding: 0; background: rgba(20, 23, 18, 0.55); }
.hov-nav svg { width: 24px; height: 24px; }
.hov-nav.prev { left: max(6px, var(--sal)); }
.hov-nav.next { right: max(6px, var(--sar)); }
.hov-panel { position: absolute; left: 0; right: 0; bottom: 0; z-index: 2; max-height: 46dvh; overflow-y: auto; overscroll-behavior: contain; background: rgba(12, 14, 11, 0.95); border-top: 1px solid var(--outline); padding: 10px max(var(--gutter), var(--sar)) calc(10px + var(--sab)) max(var(--gutter), var(--sal)); touch-action: pan-y; }
.hov-meta { display: flex; flex-direction: column; gap: 6px; }
.hov-cap { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px; }
.hov-gmnote { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 13px; color: var(--amber); border: 1px dashed var(--amber-dim); border-radius: var(--r-md); padding: 6px 8px; }
.hov-gmnote .lbl { display: block; color: var(--amber); opacity: 0.8; margin-bottom: 2px; }
.hov-actions { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-top: 8px; }
.hov-actions > button { flex: 1 1 110px; min-height: 44px; }
.hov-actions > .primary { flex: 2 1 190px; }
.hov.bare .hov-top, .hov.bare .hov-panel, .hov.bare .hov-nav { display: none; }
@media (min-width: 900px) {
  .hov-panel { left: 50%; right: auto; width: min(760px, 92vw); transform: translateX(-50%); border: 1px solid var(--outline); border-bottom: 0; border-radius: var(--r-lg) var(--r-lg) 0 0; }
}

.coll-badge:has(.ho-newtxt) { border-color: var(--neon); }

.ho-root.selecting { padding-bottom: 84px; }

/* ---------- photo editor (crop / straighten / scan) ---------- */
html.pe-open, html.pe-open body { overflow: hidden; overscroll-behavior: none; }
.pe { position: fixed; inset: 0; z-index: 75; display: grid; grid-template-rows: auto minmax(0, 1fr) auto auto; background: #050605; color: var(--bone); overscroll-behavior: none; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.pe:focus-visible { outline: none; }
.pe button { touch-action: none; min-height: 44px; }
.pe-top { display: flex; align-items: center; gap: 8px; padding: calc(var(--sat) + 4px) max(8px, var(--sar)) 4px max(8px, var(--sal)); background: #0a0c09; border-bottom: 1px solid var(--outline); }
.pe-title { flex: 1; margin: 0; font-size: var(--fs-md); letter-spacing: 2px; text-align: center; color: var(--terminal); }
.pe-ico { width: 44px; min-width: 44px; padding: 0; }
.pe-ico svg, .pe-tool svg, .pe-wide svg { width: 20px; height: 20px; flex: 0 0 auto; }
.pe-skip { min-width: 64px; background: transparent; border-color: transparent; color: var(--ash); letter-spacing: 1px; }
.pe-skip:hover { color: var(--bone); }
.pe-stage { position: relative; min-height: 0; overflow: hidden; background: repeating-conic-gradient(#0b0d0a 0 25%, #0e110d 0 50%) 0 0 / 22px 22px; }
.pe-vp { position: absolute; inset: 0; overflow: hidden; touch-action: none; }
.pe-img { position: absolute; left: 0; top: 0; transform-origin: 0 0; max-width: none; image-rendering: auto; box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.12), 0 6px 30px rgba(0, 0, 0, 0.7); will-change: transform; pointer-events: none; }
.pe-svg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.pe-dim { fill: rgba(5, 6, 5, 0.58); }
.pe-grid line { stroke: rgba(255, 255, 255, 0.32); stroke-width: 1; }
.pe-line0 { fill: none; stroke: rgba(0, 0, 0, 0.75); stroke-width: 4.5; stroke-linejoin: round; }
.pe-line1 { fill: none; stroke: var(--neon); stroke-width: 2; stroke-linejoin: round; }
.pe[data-mode="crop"] .pe-line1 { stroke: #ffffff; }
.pe-h { position: absolute; left: -24px; top: -24px; width: 48px; height: 48px; min-height: 48px; min-width: 48px; padding: 0; border: 0; background: transparent; border-radius: 50%; cursor: grab; will-change: transform; z-index: 2; }
.pe-h:hover { border: 0; }
.pe-h:active { transform: none; }
.pe-h i { position: absolute; left: 50%; top: 50%; width: 20px; height: 20px; margin: -10px 0 0 -10px; border-radius: 50%; background: rgba(5, 6, 5, 0.35); border: 2.5px solid var(--neon); box-shadow: 0 0 0 1.5px rgba(0, 0, 0, 0.75), 0 0 10px rgba(57, 255, 20, 0.45); transition: transform var(--speed) var(--ease); }
.pe[data-mode="crop"] .pe-h i { border-color: #fff; box-shadow: 0 0 0 1.5px rgba(0, 0, 0, 0.75); }
.pe-h.edge i { width: 30px; height: 10px; margin: -5px 0 0 -15px; border-radius: 6px; background: var(--neon); border-width: 1.5px; transform: rotate(var(--a, 0rad)); }
.pe[data-mode="crop"] .pe-h.edge i { background: #fff; }
.pe-h.drag i { transform: scale(1.25) rotate(0rad); background: rgba(57, 255, 20, 0.35); }
.pe-h.edge.drag i { transform: rotate(var(--a, 0rad)) scale(1.25); }
.pe-h:focus-visible { outline: 2px solid var(--amber); outline-offset: -4px; }
.pe-h[hidden] { display: none; }
.pe-loupe { position: absolute; left: 0; top: 0; width: 116px; height: 116px; border-radius: 50%; border: 3px solid var(--neon); box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.8), 0 8px 24px rgba(0, 0, 0, 0.7); pointer-events: none; z-index: 5; background: #000; }
.pe-loupe[hidden] { display: none; }
.pe-prev { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; padding: 14px; background: #0b0d0a; z-index: 3; }
.pe-prev[hidden] { display: none; }
.pe-prev canvas { max-width: 100%; max-height: 100%; width: auto; height: auto; object-fit: contain; background: #fff; box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.15), 0 6px 30px rgba(0, 0, 0, 0.7); }
.pe-hint { position: absolute; left: 50%; top: 8px; white-space: nowrap; transform: translateX(-50%); z-index: 6; max-width: calc(100% - 20px); display: flex; align-items: center; gap: 10px; padding: 6px 12px; border-radius: var(--r-pill); background: rgba(20, 23, 18, 0.92); border: 1px solid var(--outline); color: var(--terminal); font-size: var(--fs-sm); letter-spacing: 0.6px; text-align: center; pointer-events: none; }
.pe-hint[hidden] { display: none; }
.pe-link { min-height: 44px !important; padding: 0 10px; border-radius: var(--r-pill); font-size: var(--fs-sm); background: transparent; border-color: var(--neon); color: var(--neon); }
.pe-busy { position: absolute; inset: 0; z-index: 8; display: none; align-items: center; justify-content: center; gap: 10px; background: rgba(5, 6, 5, 0.62); color: var(--bone); letter-spacing: 1.5px; font-size: var(--fs-sm); }
.pe-busy.on { display: flex; }
.pe-spin { width: 20px; height: 20px; border-radius: 50%; border: 3px solid var(--outline); border-top-color: var(--neon); animation: pe-spin 0.8s linear infinite; }
@keyframes pe-spin { to { transform: rotate(360deg); } }
.pe-tools { display: flex; flex-direction: column; gap: 6px; padding: 8px max(10px, var(--sar)) 4px max(10px, var(--sal)); background: #0a0c09; border-top: 1px solid var(--outline); }
.pe-seg { display: grid; grid-template-columns: 1fr 1fr; border: 1px solid var(--outline); border-radius: var(--r-md); overflow: hidden; }
.pe-seg .pe-btn { border: 0; border-radius: 0; background: var(--panel); letter-spacing: 1.5px; font-weight: 700; color: var(--ash); }
.pe-seg .pe-btn[aria-pressed="true"] { background: var(--active); color: var(--neon); box-shadow: inset 0 -3px 0 var(--neon); }
.pe-row { display: flex; gap: 6px; }
.pe-tool { flex: 1 1 0; min-width: 0; flex-direction: column; gap: 1px; padding: 4px 2px; font-size: 11px; letter-spacing: 0.5px; }
.pe-tool span { line-height: 1.1; }
.pe-tool[aria-pressed="true"] { border-color: var(--neon); color: var(--neon); background: var(--active); }
.pe-bw { flex: 0 0 auto; padding: 0 12px; flex-direction: row; font-weight: 700; }
.pe-bw[hidden] { display: none; }
.pe-foot { display: flex; gap: 8px; padding: 6px max(10px, var(--sar)) calc(8px + var(--sab)) max(10px, var(--sal)); background: #0a0c09; }
.pe-wide { flex: 1 1 0; font-weight: 700; letter-spacing: 1.2px; min-height: 52px !important; }
.pe-foot .pe-primary { flex: 1.5 1 0; }
.pe[data-state="loading"] .pe-tools, .pe[data-state="loading"] .pe-foot { opacity: 0.45; pointer-events: none; }
.pe[data-state="preview"] .pe-seg, .pe[data-state="preview"] [data-pe="rot-left"], .pe[data-state="preview"] [data-pe="rot-right"], .pe[data-state="preview"] [data-pe="detect"], .pe[data-state="preview"] [data-pe="reset"] { opacity: 0.35; pointer-events: none; }
.pe.is-busy .pe-tools, .pe.is-busy .pe-foot, .pe.is-busy .pe-top { pointer-events: none; }
.pe.is-busy .pe-top .pe-ico { pointer-events: auto; }
@media (min-width: 700px) { .pe-tools { flex-direction: row; align-items: center; justify-content: center; } .pe-seg { width: 300px; } .pe-row { width: 440px; } .pe-foot { justify-content: center; } .pe-wide { max-width: 240px; } }
@media (max-height: 480px) and (orientation: landscape) {
  .pe { grid-template-columns: minmax(0, 1fr) 240px; grid-template-rows: auto minmax(0, 1fr) auto; }
  .pe-top { grid-column: 1 / -1; }
  .pe-stage { grid-row: 2 / 4; }
  .pe-tools { grid-column: 2; grid-row: 2; border-top: 0; border-left: 1px solid var(--outline); flex-direction: column; justify-content: flex-start; overflow-y: auto; }
  .pe-row { flex-wrap: wrap; width: auto; }
  .pe-tool { flex: 1 1 28%; }
  .pe-seg { width: auto; }
  .pe-foot { grid-column: 2; grid-row: 3; flex-direction: column; border-left: 1px solid var(--outline); }
  .pe-wide { max-width: none; min-height: 44px !important; }
}
@media (prefers-reduced-motion: reduce) { .pe *, .pe *::before { transition: none !important; animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; } .pe-spin { animation: none; border-top-color: var(--neon); border-right-color: var(--neon); } }

/* handout upload sheet + owner badges */
.pe-up-prev { display: flex; justify-content: center; margin: 4px 0 10px; }
.pe-up-prev img { max-width: 100%; max-height: 34dvh; border: 1px solid var(--outline); border-radius: var(--r-md); background: #fff; }
.pe-share { display: block; padding: 8px 10px; margin: 8px 0; border: 1px solid var(--amber); border-radius: var(--r-md); background: rgba(255, 176, 0, 0.08); color: var(--amber); font-size: var(--fs-sm); }
.pe-share.ok { border-color: #3b8f28; background: rgba(57, 255, 20, 0.06); color: var(--terminal); }
.pe-share svg { width: 18px; height: 18px; flex: 0 0 auto; margin-top: 1px; }
.pe-up-prog { height: 6px; margin: 8px 0 0; background: var(--outline); border-radius: 3px; overflow: hidden; }
.pe-up-prog i { display: block; height: 100%; width: 0; background: var(--neon); transition: width 120ms linear; }
.ho-by { display: block; margin-top: 2px; color: var(--ash); font-size: var(--fs-xs); letter-spacing: 0.6px; text-transform: uppercase; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ho-card > .ho-acts { padding: 0 8px 8px; }

/* --- Session notes (Logseq-style outline) ------------------------------------------------- */
.session-card { flex-wrap: wrap; }
.route-notes { padding-bottom: calc(var(--tabbar-h) + var(--sab) + 72px); }
.nb-status { font-size: var(--fs-xs); letter-spacing: 1px; color: var(--ash); }
.nb-status[data-state="unsaved"], .nb-status[data-state="saving"] { color: var(--amber); }
.nb-status[data-state="error"] { color: var(--rust); }
.nb-head { display: flex; flex-direction: column; gap: 6px; }
.nb-share-page { display: flex; align-items: center; gap: 8px; font-size: var(--fs-sm); color: var(--bone); cursor: pointer; }
.nb-outline { padding: 4px 0; }
.nb-row { display: flex; align-items: flex-start; gap: 4px; min-height: 30px; }
.nb-kids { margin-left: 11px; padding-left: 12px; border-left: 1px solid var(--outline); }
.nb-bullet { flex: none; width: 24px; height: 30px; min-height: 0; padding: 0; border: 0; background: transparent; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.nb-bullet i { display: block; width: 7px; height: 7px; border-radius: 50%; background: var(--ash); }
.nb-bullet.has-kids i { background: var(--bone); }
.nb-bullet.closed i { box-shadow: 0 0 0 4px var(--outline); }
.nb-text { flex: 1; min-width: 0; padding: 5px 4px; line-height: 1.45; color: var(--bone); white-space: normal; overflow-wrap: anywhere; cursor: text; border-radius: var(--r-sm); }
.nb-text.empty { color: var(--ash); }
.nb.ro .nb-text { cursor: default; }
.nb-input { flex: 1; min-width: 0; margin: 0; padding: 4px; line-height: 1.45; font: inherit; color: var(--bone); background: var(--panel-raised); border: 1px solid var(--neon); border-radius: var(--r-sm); resize: none; overflow: hidden; min-height: 30px; }
.nb-share { flex: none; color: var(--amber); font-size: var(--fs-sm); padding-top: 6px; }
.nb.shared > .nb-row .nb-text { box-shadow: inset 2px 0 0 var(--amber); }
.nb.flash > .nb-row .nb-text { background: var(--amber-dim); transition: background 0.4s; }
.nb-link { display: inline; min-height: 0; padding: 1px 6px; margin: 0 1px; font-size: var(--fs-sm); letter-spacing: 0; color: var(--neon); background: var(--active); border: 1px solid var(--outline); border-radius: var(--r-sm); cursor: pointer; }
.nb-add { display: block; margin: 6px 0 0 28px; min-height: 0; padding: 4px 8px; font-size: var(--fs-sm); color: var(--ash); background: transparent; border: 1px dashed var(--outline); }
.nb-crew-page { margin-bottom: 8px; }
.nb-bar { position: fixed; z-index: 34; left: 0; right: 0; bottom: calc(var(--tabbar-h) + var(--sab)); display: flex; flex-wrap: wrap; gap: 6px; padding: 8px max(12px, var(--sar)) 8px max(12px, var(--sal)); background: var(--panel); border-top: 1px solid var(--outline); }
.nb-bar[hidden] { display: none; }
.nb-bar .mini { min-width: 40px; }
@media (min-width: 900px) {
  .nb-bar { left: var(--rail-w); bottom: 0; padding: 10px var(--gutter); }
  .route-notes { padding-bottom: 80px; }
}
.segctl-wrap { flex-wrap: wrap; }
.segctl-wrap button { flex: 1 1 30%; font-size: 12px; letter-spacing: 0.5px; }
.bd-pop .stack svg { width: 20px; height: 20px; flex: 0 0 auto; }
.bd-pop .stack button { justify-content: flex-start; gap: 10px; }

/* --- What's new (changelog) ---------------------------------------------------------------- */
.cl-entry + .cl-entry { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--outline); }
.cl-head { color: var(--neon); }
.cl-title { margin: 2px 0 8px; font-weight: 700; color: var(--bone); }
.cl-sec { margin-top: 8px; }
.cl-list { margin: 4px 0 0; padding-left: 18px; color: var(--bone); line-height: 1.45; }
.cl-list li + li { margin-top: 4px; }

/* --- Text-only handouts ------------------------------------------------------------------- */
.ho-txt { display: block; width: 100%; height: 100%; padding: 10px 12px; box-sizing: border-box; overflow: hidden; text-align: left; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 11px; line-height: 1.35; letter-spacing: 0; color: #2b2a22; background: #e8e1c7; font-family: Georgia, "Times New Roman", serif; }
.ho-card.draft .ho-txt { opacity: 0.62; filter: grayscale(0.55); }
.hov-text { position: absolute; inset: 0; overflow-y: auto; touch-action: pan-y; cursor: auto; user-select: text; -webkit-user-select: text; display: flex; justify-content: center; align-items: flex-start; padding: 72px 16px 160px; box-sizing: border-box; }
.hov-text[hidden] { display: none; }
.hov-page { width: 100%; max-width: 640px; padding: 22px 22px 28px; box-sizing: border-box; border-radius: 4px; background: #e8e1c7; color: #24231c; font-family: Georgia, "Times New Roman", serif; font-size: 17px; line-height: 1.6; overflow-wrap: anywhere; box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5); }
.hov-page-title { margin-bottom: 10px; font-size: 20px; font-weight: 700; }
.hov.text .hov-zoomgrp, .hov.text [data-action="hov-fit"] { display: none; }

.notes-list-head { margin-left: 0; }
#tb-rules.active { color: var(--neon); }

/* --- MPCMRP: character creator ------------------------------------------------------------- */
.cr-mode { display: flex; gap: var(--sp-3); align-items: center; text-align: left; width: 100%; min-height: 72px; }
.cr-mode-icon { font-size: 28px; flex: 0 0 auto; }
.cr-mode-text { display: block; margin-top: 2px; letter-spacing: 0; }
.cr-sit { display: block; width: 100%; text-align: left; letter-spacing: 0; }
.cr-sit-desc { margin-top: 6px; color: var(--bone); }
.cr-muses { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 6px; }
.cr-muses button { text-align: left; white-space: normal; }
.cr-line.done { border-color: var(--terminal); }
.cr-line select, .cr-slot select { max-width: 100%; }
.cr-slot { border-top: 1px dashed var(--outline); padding-top: var(--sp-2); margin-top: var(--sp-2); }
.cr-acc { border-left: 3px solid var(--terminal); padding: 6px 8px; margin: 6px 0; background: var(--panel-raised); border-radius: var(--r-sm); display: flex; flex-direction: column; gap: 3px; }
.cr-cash { border-left: 3px solid var(--amber); padding: 6px 8px; margin: 6px 0; background: rgba(176, 125, 20, 0.1); border-radius: var(--r-sm); display: flex; flex-direction: column; gap: 6px; }
.cr-book { margin: 0 0 var(--sp-2); }
.cr-book-part { border-left: 2px solid var(--outline); padding: 4px 0 4px 10px; margin: 6px 0; font-size: 13px; }
.cr-die-row { padding: 6px 0; border-bottom: 1px solid rgba(110, 85, 50, 0.22); }
.cr-purse { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 0 var(--sp-2); }
.cr-table { width: 100%; border-collapse: collapse; margin: 8px 0; font-size: 13px; }
.cr-table td, .cr-table th { border-bottom: 1px solid var(--outline); padding: 5px 4px; vertical-align: top; text-align: left; }
.cr-table th { color: var(--ash); font-size: var(--fs-xs); letter-spacing: 1px; font-weight: 400; }
.cr-track { display: flex; gap: 3px; flex-wrap: wrap; margin: 6px 0; }
.cr-track-die { flex: 1 1 0; min-width: 52px; display: flex; flex-direction: column; align-items: center; padding: 6px 2px; border: 1px solid var(--outline); border-radius: var(--r-sm); font-size: 10px; text-align: center; }
.cr-todo { margin: 0; padding-left: 18px; color: var(--rust); font-size: 13px; }
.cr-details { margin: 6px 0; }
.cr-details summary { cursor: pointer; color: var(--terminal); padding: 4px 0; }
.die-pill { display: inline-block; min-width: 38px; text-align: center; padding: 2px 8px; border-radius: var(--r-pill); border: 1px solid var(--neon); color: var(--neon); font-weight: 700; font-size: 13px; }
.die-pill.free { border-style: dashed; color: var(--amber); border-color: var(--amber); }
.side-serious { background: rgba(35, 66, 127, 0.1); }
.side-neither { background: rgba(42, 29, 18, 0.05); }
.side-silly { background: rgba(180, 35, 24, 0.08); }

/* --- MPCMRP: character sheet ----------------------------------------------------------------- */
.tokens { display: flex; gap: var(--sp-3); flex-wrap: wrap; margin-top: var(--sp-2); }
.token { flex: 1 1 140px; text-align: center; background: var(--panel-raised); border: 1px solid var(--outline); border-radius: var(--r-md); padding: 6px; }
.token .lbl { font-size: var(--fs-xs); color: var(--ash); letter-spacing: 1px; }
.token .stepper { justify-content: center; font-size: var(--fs-lg); }
.line-card { display: flex; flex-direction: column; gap: 6px; }
.line-card.empty-line { border-style: dashed; }
.die-track { display: grid; grid-template-columns: repeat(9, 1fr); gap: 3px; }
.die-cell { min-height: 36px; padding: 0; font-size: 11px; letter-spacing: 0; border-radius: var(--r-sm); color: var(--ash); }
.die-cell.on { border-color: var(--neon); color: var(--neon); box-shadow: inset 0 0 0 1px var(--neon); font-weight: 700; }
.acc-row { display: flex; gap: 6px; flex-wrap: wrap; }
.acc-chip { min-height: 32px; font-size: 12px; letter-spacing: 0; padding: 2px 10px; border-radius: var(--r-pill); white-space: normal; text-align: left; }
.acc-chip.dead { border-style: dashed; color: var(--rust); }
.status-track { display: grid; grid-template-columns: repeat(6, 1fr); gap: 3px; margin-top: 6px; }
.status-cell { min-height: 44px; padding: 2px; font-size: 10px; letter-spacing: 0; line-height: 1.15; white-space: normal; border-radius: var(--r-sm); color: var(--ash); }
.status-cell.on { border-color: var(--amber); color: var(--amber); box-shadow: inset 0 0 0 1px var(--amber); font-weight: 700; }
.status-cell.on.end { border-color: var(--rust); color: var(--rust); box-shadow: inset 0 0 0 1px var(--rust); }
.status-cell.locked { opacity: 0.45; }

/* =========================================================================================
 * ILLUMINATED MANUSCRIPT
 * Vellum, gilt rules, rubric red and lapis. Cinzel capitals for labels and controls, Cormorant
 * Garamond for names and headings, EB Garamond for reading, blackletter only for initials.
 * ========================================================================================= */

/* ---- type ---- */
.tab, .tb-char-label, .kv .k, .lbl, .field-label, .tag, .badge-role, .chip, .segctl button, .wiz-stepbar-text, .wiz-step,
.teach-title, .status-cell, .token .lbl, .coll-badge, .gs-badge, .offline-badge, .sec-label, .coll-head {
  font-family: var(--display); font-weight: 600; letter-spacing: 0.6px;
}
.die-pill, .die-cell, .cr-track-die, .stepper, .tile .val, .roll-big .total, .tab-badge, .ho-new-pill {
  font-family: var(--serif); font-variant-numeric: lining-nums; letter-spacing: 0;
}
input[type], textarea, select { font-family: var(--serif); font-size: 17px; letter-spacing: 0; }
h1, h2, h3 { font-weight: 700; }
.panel-title, .empty-title, .modal h2, .route-head h1, .rule-heading, .roster-name, .crew-name {
  font-family: var(--heading); font-weight: 700; letter-spacing: 0; color: var(--neon);
}
.panel-title { font-size: 21px; }
.empty-title { font-size: 24px; }
.modal h2 { font-size: 27px; line-height: 1.1; border-bottom: 2px solid var(--gold); box-shadow: 0 3px 0 -1px var(--panel), 0 4px 0 -1px var(--gold); padding-bottom: 8px; margin-bottom: 14px; }
.route-head h1 { font-size: 28px; }
/* Ornamental initials: blackletter for the first letter only (readable everywhere else). */
.modal h2::first-letter, .route-head h1::first-letter, .empty-title::first-letter { font-family: var(--black); font-weight: 400; font-size: 1.22em; color: var(--neon); }
.panel-title::first-letter { color: var(--terminal); }
.sec-label { color: var(--neon); font-size: var(--fs-sm); border-bottom: 1px solid var(--outline); padding-bottom: 3px; }
.tag { color: var(--amber); font-size: 12px; }
.kv { border-bottom-style: dotted; }
.muted { color: var(--ash); }

/* ---- surfaces ---- */
.card, .panel, .coll, .tile, .token { background: var(--panel); border-color: var(--outline); border-radius: 0; box-shadow: none; }
.panel { border: 1px solid var(--outline); box-shadow: inset 0 0 0 3px var(--panel), inset 0 0 0 4px rgba(201, 154, 46, 0.55); }
.empty { border: 1px solid var(--gold); background: rgba(248, 239, 216, 0.75); box-shadow: inset 0 0 0 3px #f3e7c9, inset 0 0 0 4px rgba(165, 29, 29, 0.5); border-radius: 0; }
.coll-head { color: var(--neon); font-size: 14px; }
.card.clickable:hover, .tile.clickable:hover { border-color: var(--neon); background: #fbf4e2; }
.card.wiz-sel { border: 2px solid var(--neon); background: #fbf4e2; box-shadow: inset 0 0 0 3px #f3e2b3; }
.banner { border-radius: 0; }

/* ---- buttons ---- */
button, .btn { font-family: var(--display); font-weight: 600; font-size: 14px; letter-spacing: 0.6px; background: var(--panel); border: 1px solid #b89a5e; color: var(--bone); border-radius: 0; box-shadow: none; }
button:hover { border-color: var(--neon); }
.primary, button.primary, .btn.primary { background: var(--neon); color: #fbecc8; border: 2px solid var(--gold); box-shadow: inset 0 0 0 2px #7a1212, 0 3px 0 #6b0f0f; }
.primary:hover, button.primary:hover { background: #b52424; box-shadow: inset 0 0 0 2px #7a1212, 0 3px 0 #6b0f0f; }
button.amber { background: var(--amber-dim); color: #5a3a05; border-color: var(--gold); }
button.danger { background: transparent; color: var(--rust); border-color: var(--rust); }
button.ghost, .icon-btn, .tab, .tb-char, .coll-head, .sheet-x { background: transparent; box-shadow: none; border-color: transparent; }
.stepper-btn { border-radius: 50%; }
.chip { border-radius: 0; }
.chip.active { background: #fbf4e2; border-color: var(--neon); color: var(--neon); }
.segctl, .segctl button { border-radius: 0; }
.segctl button.on { background: #fbf4e2; color: var(--neon); box-shadow: inset 0 0 0 1px var(--neon); }

/* ---- top bar: a vellum header under a double gilt rule ---- */
.topbar { background: linear-gradient(#f8efd8, #f1e3c2); color: var(--bone); border-bottom: 2px solid var(--gold); box-shadow: 0 3px 0 -1px var(--void), 0 4px 0 -1px var(--gold); }
.topbar .icon-btn { color: var(--bone); }
.topbar .icon-btn:hover, .topbar .tb-char:hover { border-color: var(--outline); }
.topbar .icon-btn.active, .topbar #tb-rules.active, .topbar #tb-log.active, .topbar #tb-account.active { color: var(--neon); background: #fbf4e2; border-color: var(--outline); }
.topbar .icon-btn.gs-toggle { color: var(--ash); border-color: var(--outline); background: #fbf4e2; }
.tb-brand { font-family: var(--black); font-weight: 400; color: var(--neon); font-size: 24px; letter-spacing: 0; text-shadow: none; }
.tb-char { gap: 10px; }
.tb-mono { flex: 0 0 40px; height: 40px; box-sizing: border-box; border: 2px solid var(--gold); background: var(--terminal); box-shadow: inset 0 0 0 2px #f3e7c9, inset 0 0 0 3px var(--neon); display: flex; align-items: center; justify-content: center; font-family: var(--black); font-size: 28px; line-height: 1; color: #f7e3a3; }
.tb-char-label { color: var(--neon); font-size: 10px; letter-spacing: 1.4px; }
.tb-char-name { font-family: var(--heading); font-weight: 700; font-size: 22px; color: var(--bone); }
.tb-char-icon { color: var(--bone); }
kbd { color: var(--ash); border-color: var(--outline); }

/* ---- tab bar / rail: a red ribbon bookmark marks the active tab ---- */
.tabbar { background: var(--panel-raised); border-top: 2px solid var(--gold); }
.tab { color: #5b4630; font-size: 11px; position: relative; }
.tab.active { color: var(--neon); background: transparent; border-top-color: transparent; }
.tab.active::before { content: ""; position: absolute; top: -2px; left: 50%; width: 20px; height: 14px; margin-left: -10px; background: var(--neon); clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 70%, 0 100%); }
.tab-badge { background: var(--neon); color: #fbecc8; }
@media (min-width: 900px) {
  .tab.active::before { top: 50%; left: -2px; width: 14px; height: 20px; margin: -10px 0 0; clip-path: polygon(0 0, 100% 0, 70% 50%, 100% 100%, 0 100%); }
}

/* ---- doodles: faint marginal drawings, always behind the content ---- */
.content, .modal { isolation: isolate; }
.content { position: relative; }
.doodle { position: absolute; z-index: -1; pointer-events: none; opacity: 0.2; display: block; }
.doodle svg { display: block; width: 100%; height: 100%; }
.doodle-rabbit { width: 170px; height: 156px; right: -12px; bottom: 60px; transform: rotate(-6deg); }
.doodle-cow { width: 150px; height: 120px; left: 6px; top: 8px; transform: rotate(-14deg); opacity: 0.28; }
.doodle-swallow { width: 170px; height: 128px; right: 4px; bottom: 90px; transform: rotate(6deg); opacity: 0.26; }
.doodle-shrubbery { width: 84px; height: 78px; right: 58px; top: 4px; transform: rotate(-4deg); opacity: 0.15; }
.doodle-coconuts { width: 70px; height: 38px; right: 150px; top: 16px; transform: rotate(10deg); opacity: 0.16; }
.doodle-grail { width: 70px; height: 84px; right: 60px; top: 2px; opacity: 0.18; }

/* ---- login: a proclamation in a gilt frame ---- */
.login-wrap { position: relative; padding-top: 4vh; min-height: calc(100dvh - var(--topbar-h) - 40px); }
.login-card { position: relative; text-align: center; padding: 34px 24px 28px; max-width: 380px; background: transparent; border: 0; box-shadow: none; outline: none; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.login-card::before { content: ""; position: absolute; inset: 0; border: 2px solid var(--gold); box-shadow: inset 0 0 0 4px var(--void), inset 0 0 0 5px var(--neon); pointer-events: none; }
.login-kicker { font-family: var(--display); font-weight: 600; font-size: 13px; letter-spacing: 3px; color: var(--neon); }
.login-crest { position: relative; width: 190px; height: 160px; display: flex; align-items: center; justify-content: center; }
.login-crest .rays { position: absolute; inset: 0; width: 100%; height: 100%; }
.login-crest img { position: relative; width: 112px; height: 112px; }
.login-card h2 { font-family: var(--heading); font-weight: 700; font-size: 42px; line-height: 1; color: var(--bone); margin: 0; border: 0; box-shadow: none; padding: 0; }
.login-card h2::first-letter { font-size: 1em; }
.login-card h2 .init { font-family: var(--black); font-weight: 400; font-size: 50px; color: var(--neon); }
.login-card h2 .init.lapis { color: var(--terminal); }
.login-card .sub { font-style: italic; font-size: 17px; color: #3d2d1c; max-width: 280px; margin: 0; }
.login-rule { display: flex; align-items: center; gap: 10px; width: 220px; color: var(--neon); }
.login-rule::before, .login-rule::after { content: ""; flex: 1; height: 1px; background: var(--gold); }
.login-card .btn.primary { width: 100%; max-width: 290px; min-height: 52px; font-size: 17px; }
.login-card .tiny { font-style: italic; font-size: 14px; color: var(--ash); max-width: 260px; }

/* ---- teaching notes: the professor's hand in the margin ---- */
.wiz-teach { position: relative; border: 1px solid var(--gold); border-left-width: 1px; border-radius: 0; background: #fbf1d3; transform: rotate(-0.4deg); padding: 10px 12px 10px 14px; }
.wiz-teach .teach-title { color: var(--neon); }
.wiz-teach p { font-family: var(--hand); font-weight: 600; font-size: 20px; line-height: 1.2; color: var(--terminal); }
.wiz-teach b { color: var(--neon); font-weight: 700; }
.wiz-teach i { color: var(--terminal); }

/* ---- character creator ---- */
.wiz-head h2 { border: 0; box-shadow: none; margin: 0; padding: 0; }
.cr-kicker { font-family: var(--display); font-weight: 600; font-size: 12px; letter-spacing: 1.5px; color: var(--neon); }
.cr-title { font-family: var(--heading); font-weight: 700; font-size: 32px; line-height: 1.05; color: var(--bone); margin: 2px 0 8px; }
.cr-title .init { font-family: var(--black); font-weight: 400; font-size: 40px; color: var(--neon); }
.cr-progress { display: grid; grid-template-columns: repeat(var(--n, 7), minmax(0, 1fr)); gap: 6px; margin-bottom: 10px; }
.cr-progress span { height: 8px; border: 1px solid var(--outline); }
.cr-progress span.done { background: var(--neon); border-color: var(--gold); }
.cr-progress span.now { background: var(--gold); border-color: var(--neon); }
.cr-sit { display: flex; gap: 10px; align-items: flex-start; text-align: left; width: 100%; padding: 10px; font-family: var(--serif); font-weight: 400; font-size: 15px; letter-spacing: 0; line-height: 1.3; }
.cr-sit-cap { flex: 0 0 42px; height: 42px; display: flex; align-items: center; justify-content: center; background: var(--cap, #5b4630); border: 2px solid var(--gold); font-family: var(--black); font-size: 30px; color: #f7e3a3; }
.cr-sit-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.cr-sit-name { font-family: var(--display); font-weight: 600; font-size: 16px; letter-spacing: 0.5px; color: var(--bone); }
.cr-sit .tag { font-family: var(--display); }
.cr-mode, .cr-muses button, .card.clickable { font-family: var(--serif); font-weight: 400; font-size: 16px; letter-spacing: 0; text-transform: none; line-height: 1.35; }
.cr-mode b, .cr-muses button { font-family: var(--display); font-weight: 600; }
.cr-muses button .muted { font-family: var(--serif); font-weight: 400; }
.cr-mode-icon { width: 46px; height: 46px; flex: 0 0 46px; display: flex; align-items: center; justify-content: center; border: 2px solid var(--gold); background: var(--terminal); color: #f7e3a3; font-family: var(--black); font-size: 30px; }
.cr-acc { border-left: 0; border: 1px solid var(--outline); background: #fbf4e2; border-radius: 0; }
.cr-cash { border-left: 0; border: 1px solid var(--gold); background: #fbf1d3; border-radius: 0; }
.cr-book-part { border-left-color: var(--neon); }
.cr-table td, .cr-table th { border-bottom: 1px dotted var(--outline); }
.die-pill { border-radius: 0; border-color: var(--gold); color: var(--bone); background: #fbf4e2; font-weight: 600; }
.die-pill.free { border-color: var(--amber); color: var(--amber); border-style: dashed; }

/* ---- character sheet ---- */
.ms-head { display: flex; flex-direction: column; gap: 10px; }
.ms-sub { font-style: italic; font-size: 16px; color: #5b4630; }
.ms-seals { display: flex; gap: 10px; }
.ms-seal-box { flex: 1 1 0; min-width: 0; display: flex; align-items: center; gap: 10px; padding: 6px 8px; border: 1px solid var(--outline); background: var(--panel); }
.ms-seal-ctl { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.ms-seal-btns { display: flex; gap: 6px; }
.ms-seal { flex: 0 0 38px; height: 38px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-family: var(--heading); font-weight: 700; font-size: 20px; color: #fbe9c8; background: var(--neon); box-shadow: inset 0 0 0 3px #c43a2c, 0 1px 2px rgba(60, 30, 10, 0.4); }
.ms-seal.dark { background: #3b2a1a; box-shadow: inset 0 0 0 3px #5a4330, 0 1px 2px rgba(60, 30, 10, 0.4); color: #f3e7c9; }
.ms-seal-label { flex: 1; font-family: var(--display); font-weight: 600; font-size: 13px; letter-spacing: 0.5px; }
.ms-seal-box .stepper-btn { flex: 0 0 36px; width: 36px; min-height: 36px; font-size: 18px; }
.ms-section { display: flex; align-items: baseline; gap: 8px; border-bottom: 1px solid var(--outline); padding-bottom: 3px; margin: 14px 0 4px; }
.ms-section > b { font-family: var(--display); font-weight: 600; font-size: 14px; letter-spacing: 0.6px; color: var(--neon); }
.ms-section > span { font-style: italic; font-size: 14px; color: var(--ash); }
.ms-line { display: flex; flex-direction: column; gap: 5px; padding: 8px 0 9px; border-bottom: 1px dotted var(--outline); }
.ms-line-head { display: flex; align-items: baseline; gap: 6px; }
.ms-name { font-family: var(--heading); font-weight: 700; font-size: 21px; line-height: 1.1; }
.ms-name .init { color: var(--neon); font-size: 1.12em; }
.ms-line:nth-of-type(even) .ms-name .init { color: var(--terminal); }
.ms-side { flex: 1; min-width: 0; font-style: italic; font-size: 15px; color: var(--ash); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ms-die { font-family: var(--heading); font-weight: 700; font-size: 20px; }
.ms-mod { font-weight: 600; font-size: 16px; color: var(--neon); min-width: 2ch; text-align: right; }
.ms-mod.minus { color: var(--rust); }
.ms-accs { display: flex; flex-wrap: wrap; gap: 2px 12px; }
.ms-acc { min-height: 32px; padding: 0; border: 0; background: transparent; font-family: var(--serif); font-weight: 400; font-style: italic; font-size: 16px; letter-spacing: 0; color: #3d2d1c; text-align: left; }
.ms-acc::before { content: "❧ "; color: var(--gold); font-style: normal; }
.ms-acc:hover { color: var(--neon); }
.ms-acc.dead { color: var(--rust); text-decoration: line-through dotted; }
.ms-retainer .ms-name { font-family: var(--display); font-weight: 600; font-size: 16px; letter-spacing: 0.5px; }
.ms-retainer .ms-side { white-space: normal; }
.ms-indiff { font-style: italic; font-size: 15px; padding: 8px 0; border-bottom: 1px dotted var(--outline); }
.ms-empty-line { font-style: italic; color: var(--ash); padding: 8px 0; border-bottom: 1px dotted var(--outline); }
.ms-track-label { font-family: var(--display); font-weight: 600; font-size: 13px; letter-spacing: 0.6px; color: var(--neon); margin: 12px 0 4px; display: flex; justify-content: space-between; }
.ms-track-label span { font-family: var(--serif); font-weight: 400; font-style: italic; font-size: 14px; color: var(--ash); letter-spacing: 0; }

.die-track { gap: 3px; }
.die-cell { min-height: 26px; border-radius: 0; font-size: 12px; border: 1px solid #d4bd8a; box-shadow: none; }
.side-serious { background: rgba(31, 63, 143, 0.08); color: var(--serious); }
.side-neither { background: transparent; color: #5b4630; }
.side-silly { background: rgba(194, 69, 122, 0.1); color: #8c2a55; }
.die-cell.on { border-color: var(--gold); font-weight: 700; box-shadow: none; }
.die-cell.on.side-serious { background: var(--serious); color: #fbf3df; }
.die-cell.on.side-silly { background: var(--silly); color: #fff6fa; }
.die-cell.on.side-neither { background: var(--bone); color: #fbf3df; }
.status-track { gap: 2px; }
.status-cell { min-height: 44px; border-radius: 0; background: transparent; border: 1px solid var(--outline); font-family: var(--serif); font-weight: 400; font-size: 11px; letter-spacing: 0; color: var(--bone); }
.status-cell.on { background: #f7e3a3; border-color: var(--gold); color: var(--bone); font-weight: 600; box-shadow: none; }
.status-cell.end { color: var(--neon); border-color: var(--neon); }
.status-cell.on.end { background: rgba(165, 29, 29, 0.14); color: var(--neon); }
.status-cell.locked { opacity: 0.45; }

/* Photo viewers stay dark (better for photos): a candlelit palette. */
.hov, .pe {
  --void: #15110c; --panel: #1f1912; --panel-raised: #2b2319; --outline: #4d3f2c;
  --bone: #f3e6c8; --ash: #b8a582; --active: #3a1f18; --neon: #e2a03a; --terminal: #9bb7ef;
}
.hov button, .pe button { background: var(--panel-raised); color: var(--bone); box-shadow: none; border-color: var(--outline); }
.hov .primary, .pe .primary { background: var(--neon); color: #1f1912; border-color: var(--neon); }
.bd-bar, .bd-empty-card { color: var(--bone); }
/* Lining numerals everywhere (Cormorant's and Garamond's old-style 0 reads like an 'o'). */
html { font-variant-numeric: lining-nums; }
/* Mode cards (New character): buttons centre their content by default; keep icon + text left-aligned. */
.cr-mode { justify-content: flex-start; text-align: left; }
.cr-mode > span:last-child { flex: 1; min-width: 0; }
.cr-sit { justify-content: flex-start; }

/* ---- quick name generator ---- */
.ng-name { font-family: var(--heading); font-weight: 700; font-size: 30px; line-height: 1.15; color: var(--bone); text-align: center; padding: 18px 8px 14px; min-height: 2.4em; display: flex; align-items: center; justify-content: center; }
.ng-actions { display: flex; gap: 10px; margin-bottom: 12px; }
.ng-actions .primary { flex: 2; min-height: 52px; font-size: 17px; }
.ng-actions button:not(.primary) { flex: 1; min-height: 52px; }
.ng-history { display: flex; flex-direction: column; gap: 2px; margin-top: 6px; }
.ng-old { justify-content: flex-start; text-align: left; border: 0; border-bottom: 1px dotted var(--outline); background: transparent; font-family: var(--serif); font-weight: 400; font-style: italic; font-size: 16px; letter-spacing: 0; min-height: 40px; padding: 0 2px; }
.ng-old:hover { color: var(--neon); }
.modal .doodle-grail { right: 54px; top: 0; }
.ng-give { display: flex; flex-direction: column; gap: 6px; padding: 10px 0; border-top: 1px dotted var(--outline); border-bottom: 1px dotted var(--outline); margin: 4px 0 8px; }
.ng-hint { font-style: italic; }

/* ---- Tools tab ---- */
.tools-intro { font-style: italic; color: var(--ash); margin: 0 0 12px; }
.ng-panel .ng-name { font-size: 34px; padding: 22px 8px 18px; }
.ng-old::before { content: "↺ "; color: var(--gold); font-style: normal; }
