/* Tabletop VTT. Palette is a wet-erase battle mat: off-white vinyl, cool grid lines,
   marker colors for ink, amber for whose turn it is. */
:root {
  --mat: #F2F4F1;
  --grid: rgba(70, 98, 112, 0.24);
  --ink: #1E2935;
  --ink-2: #536070;
  --ink-3: #8994A0;
  --panel: #FFFFFF;
  --panel-2: #F6F7F8;
  --line: #DCE1E5;
  --line-2: #C9D0D6;
  --accent: #2F5FD0;
  --accent-ink: #FFFFFF;
  --accent-soft: #E7EDFB;
  --turn: #E3A21A;
  --turn-soft: #FDF3DA;
  --turn-ink: #6B4A00;
  --danger: #C8382E;
  --danger-soft: #FBE7E5;
  --ok: #2E8B57;
  --font: "Atkinson Hyperlegible Next", "Atkinson Hyperlegible", "Segoe UI", system-ui, -apple-system, sans-serif;
  --r-panel: 12px;
  --r-ctl: 7px;
  --shadow: 0 1px 2px rgba(30, 41, 53, 0.08), 0 8px 28px rgba(30, 41, 53, 0.10);
  --shadow-sm: 0 1px 2px rgba(30, 41, 53, 0.10);
  --dice-w: 340px;
  --init-h: 160px;
  --gap: 12px;
}
body.dice-hidden { --dice-w: 0px; }
body.init-collapsed { --init-h: 46px; }

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.4;
  color: var(--ink);
  background: var(--mat);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
}
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
body, button, .btn, .tool { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
#board, .token-pop .tp-head { -webkit-touch-callout: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
::selection { background: var(--accent-soft); }

/* ---------- Controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 32px; padding: 0 12px;
  border: 1px solid var(--line-2); border-radius: var(--r-ctl);
  background: var(--panel); color: var(--ink);
  cursor: pointer; white-space: nowrap; font-weight: 500;
  transition: background-color .12s, border-color .12s;
}
.btn:hover { background: var(--panel-2); border-color: var(--ink-3); }
.btn:active { transform: translateY(0.5px); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 700; }
.btn.primary:hover { background: #2752BA; }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: var(--danger-soft); border-color: var(--danger); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: rgba(30, 41, 53, 0.06); border-color: transparent; }
.btn.icon { width: 32px; padding: 0; }
.btn.small { height: 26px; padding: 0 8px; font-size: 13px; }
.btn.small.icon { width: 26px; padding: 0; }
.btn.big { height: 44px; font-size: 16px; width: 100%; }
.btn svg { width: 18px; height: 18px; flex: none; }
.btn.small svg { width: 15px; height: 15px; }
.btn[aria-pressed="true"].ghost { background: var(--accent-soft); color: var(--accent); }

input[type="text"], input[type="number"], input[type="password"], input:not([type]), select, textarea {
  width: 100%; height: 32px; padding: 0 9px;
  border: 1px solid var(--line-2); border-radius: var(--r-ctl);
  background: var(--panel); color: var(--ink);
}
textarea { height: auto; padding: 8px 9px; resize: vertical; line-height: 1.45; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input[type="number"] { padding-right: 2px; }
.check { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); margin: 0; }
.check.small { font-size: 13px; color: var(--ink-2); }
.field { display: grid; gap: 5px; margin: 0; padding: 0; border: 0; min-width: 0; }
.field > .seg { justify-self: start; }
.field > span, .field > legend { font-size: 13px; font-weight: 700; color: var(--ink-2); padding: 0; }
.muted { color: var(--ink-2); }
.hint { font-size: 12.5px; color: var(--ink-2); margin: 0; }

.swatches { display: flex; flex-wrap: wrap; gap: 6px; }
.swatch {
  width: 26px; height: 26px; border-radius: 50%;
  border: 2px solid var(--panel); box-shadow: 0 0 0 1px var(--line-2);
  cursor: pointer; padding: 0;
}
.swatch[aria-checked="true"], .swatch[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--ink); }
.swatch.none {
  background: linear-gradient(135deg, transparent 45%, var(--danger) 45%, var(--danger) 55%, transparent 55%), var(--panel);
}

/* ---------- Join ---------- */
.join {
  position: fixed; inset: 0; display: grid; place-items: center; padding: 24px;
  background:
    linear-gradient(var(--grid) 1px, transparent 1px) 0 0 / 56px 56px,
    linear-gradient(90deg, var(--grid) 1px, transparent 1px) 0 0 / 56px 56px,
    var(--mat);
  overflow: auto;
}
.join-card {
  width: min(400px, 100%);
  display: grid; gap: 16px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 16px; padding: 28px; box-shadow: var(--shadow);
}
.join-mark { width: 40px; height: 40px; color: var(--turn); }
.join-card h1 { margin: -4px 0 0; font-size: 28px; line-height: 1.15; font-weight: 800; letter-spacing: -0.01em; }
.join-sub { margin: -8px 0 0; color: var(--ink-2); }
.join-error { margin: 0; color: var(--danger); font-weight: 500; min-height: 0; }
.join-error:empty { display: none; }
#gmFields { display: grid; gap: 10px; }
.returning { display: grid; gap: 8px; justify-items: center; }
.linkbtn {
  border: 0; background: none; padding: 2px 4px; color: var(--accent); font-weight: 500; cursor: pointer;
  text-decoration: underline; text-underline-offset: 3px; text-decoration-color: rgba(47, 95, 208, .35);
}
.linkbtn:hover { text-decoration-color: var(--accent); }
.return-list { width: 100%; display: grid; gap: 4px; max-height: 240px; overflow: auto; padding: 6px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel-2); }
.return-list .who-btn {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; padding: 8px 10px;
  border: 1px solid transparent; border-radius: 7px; background: var(--panel); cursor: pointer;
}
.return-list .who-btn:hover, .return-list .who-btn:focus-visible { border-color: var(--accent); outline: none; }
.return-list .dot { width: 12px; height: 12px; border-radius: 50%; flex: none; }
.return-list .meta { margin-left: auto; font-size: 12.5px; color: var(--ink-2); }
.return-list .empty { padding: 6px 8px; color: var(--ink-2); margin: 0; }
.same-name { display: grid; gap: 10px; padding: 12px; border-radius: 10px; background: var(--accent-soft); }
.same-name p { margin: 0; font-weight: 500; }
.same-name .row { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Board ---------- */
#board {
  position: fixed; inset: 0; width: 100%; height: 100%;
  display: block; touch-action: none; user-select: none; -webkit-user-select: none;
  background: var(--mat); outline: none;
}
#board.tool-hand, #board.panning { cursor: grab; }
#board.panning:active { cursor: grabbing; }
#board.tool-pen, #board.tool-rect, #board.tool-ellipse, #board.tool-line, #board.tool-arrow, #board.tool-token { cursor: crosshair; }
#board.tool-text { cursor: text; }
#board.tool-note { cursor: copy; }
#board.tool-eraser { cursor: cell; }
#board.tool-ruler { cursor: crosshair; }
#board.tool-laser { cursor: crosshair; }
.obj { }
.obj.is-hidden { opacity: 0.45; }
.obj.is-erasing { opacity: 0.2; }
.obj .hit { fill: none; stroke: transparent; pointer-events: stroke; }
.obj .hitfill { fill: transparent; pointer-events: all; }
.obj text { font-family: var(--font); }
.note-card {
  width: 100%; height: 100%; overflow: hidden;
  border-radius: 6px; padding: 12px 14px;
  font-family: var(--font); font-size: 15px; line-height: 1.45; color: var(--ink);
  border: 1px solid rgba(30, 41, 53, 0.12);
  box-shadow: 0 1px 1px rgba(30,41,53,.06), 0 4px 14px rgba(30, 41, 53, 0.08);
  word-wrap: break-word; overflow-wrap: anywhere;
  -webkit-mask-image: linear-gradient(#000 calc(100% - 18px), transparent);
          mask-image: linear-gradient(#000 calc(100% - 18px), transparent);
}
.note-card h1, .note-card h2, .note-card h3 { margin: 0 0 6px; line-height: 1.2; }
.note-card h1 { font-size: 21px; }
.note-card h2 { font-size: 18px; }
.note-card h3 { font-size: 16px; }
.note-card p { margin: 0 0 6px; }
.note-card ul { margin: 0 0 6px; padding-left: 18px; }
.note-card code { font-size: 13px; background: rgba(30,41,53,.07); padding: 0 3px; border-radius: 3px; }
.note-card .empty { color: var(--ink-3); }
.note-card hr { border: 0; border-top: 1px solid rgba(30,41,53,.18); margin: 8px 0; }

.sel-box { fill: none; stroke: var(--accent); }
.sel-box.locked { stroke: var(--ink-3); }
.sel-handle { fill: var(--panel); stroke: var(--accent); cursor: nwse-resize; }
.sel-handle[data-handle="ne"], .sel-handle[data-handle="sw"] { cursor: nesw-resize; }
.sel-handle.end { cursor: move; }
.marquee {
  position: fixed; border: 1px solid var(--accent); background: rgba(47, 95, 208, 0.08);
  pointer-events: none; z-index: 5;
}
.cursor-label { font-family: var(--font); font-size: 12px; font-weight: 700; }
.ping-hl { fill: none; animation: pingHl .8s ease-in-out 3; }
@keyframes pingHl { 0%, 100% { stroke-opacity: 1; } 50% { stroke-opacity: .2; } }
.ping-ring { fill: none; animation: ping 1.4s ease-out forwards; transform-box: fill-box; transform-origin: center; }
@keyframes ping { from { transform: scale(0.2); opacity: 1; } to { transform: scale(2.6); opacity: 0; } }

/* Inline text editor on the board */
.board-editor {
  position: fixed; z-index: 6; margin: 0; border: 0; padding: 0;
  background: transparent; outline: none; resize: none; overflow: hidden;
  font-family: var(--font); line-height: 1.25; white-space: pre; color: var(--ink);
  caret-color: var(--accent);
}
.board-editor.note {
  white-space: pre-wrap; overflow: auto; border-radius: 6px; line-height: 1.45;
  box-shadow: 0 0 0 2px var(--accent);
}

/* ---------- Floating chrome ---------- */
.topbar {
  position: fixed; top: var(--gap); left: var(--gap); z-index: 10;
  display: flex; align-items: center; gap: 10px; pointer-events: none;
}
.tablename {
  display: flex; align-items: center; gap: 10px; pointer-events: auto;
  height: 40px; padding: 0 14px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-panel);
  box-shadow: var(--shadow-sm); font-weight: 800; font-size: 15px; max-width: 30vw;
}
#tableName { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conn { font-size: 12.5px; font-weight: 500; color: var(--ink-2); display: inline-flex; align-items: center; gap: 6px; }
.conn::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); }
.conn[data-state="ok"] { font-size: 0; gap: 0; }
.conn[data-state="down"]::before { background: var(--danger); }
.conn[data-state="connecting"]::before { background: var(--turn); }

.toolbar {
  position: fixed; top: var(--gap); left: 50%; transform: translateX(calc(-50% - var(--dice-w) / 2));
  z-index: 10; display: flex; align-items: center; gap: 2px; padding: 4px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-panel);
  box-shadow: var(--shadow);
}
.toolbar .sep { width: 1px; height: 24px; background: var(--line); margin: 0 4px; }
.tool {
  position: relative; width: 36px; height: 36px; border: 0; border-radius: 8px;
  background: transparent; color: var(--ink); cursor: pointer; display: grid; place-items: center;
}
.tool svg { width: 20px; height: 20px; }
.tool:hover { background: var(--panel-2); }
.tool[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); }
.tool .key {
  position: absolute; right: 3px; bottom: 1px; font-size: 9.5px; font-weight: 700; color: var(--ink-3);
}
.tool[aria-pressed="true"] .key { color: var(--accent); }
.tool.gm-hide[aria-pressed="true"] { background: var(--turn-soft); color: var(--turn-ink); }

.stylebar {
  position: fixed; top: 66px; left: 50%; transform: translateX(calc(-50% - var(--dice-w) / 2));
  z-index: 10; display: flex; align-items: center; gap: 10px; padding: 6px 10px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-panel);
  box-shadow: var(--shadow-sm);
}
.stylebar .group { display: flex; align-items: center; gap: 5px; }
.stylebar .sep { width: 1px; height: 22px; background: var(--line); }
.stylebar .swatch { width: 22px; height: 22px; }
.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: var(--r-ctl); overflow: hidden; }
.seg button {
  height: 26px; min-width: 30px; padding: 0 7px; border: 0; background: var(--panel); cursor: pointer;
  border-right: 1px solid var(--line); font-size: 12.5px; font-weight: 700; color: var(--ink-2);
  display: grid; place-items: center;
}
.seg button:last-child { border-right: 0; }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--panel); }
.seg button svg { width: 18px; height: 18px; }

.topright {
  position: fixed; top: var(--gap); right: var(--gap); z-index: 11;
  display: flex; align-items: center; gap: 4px; height: 40px; padding: 0 4px 0 8px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-panel);
  box-shadow: var(--shadow-sm);
}
.people { display: flex; align-items: center; margin-right: 4px; }
.avatar {
  position: relative; width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center; font-size: 11.5px; font-weight: 800; color: #fff;
  border: 2px solid var(--panel); margin-left: -6px; cursor: default; flex: none;
  text-shadow: 0 1px 1px rgba(0,0,0,.25);
}
.avatar:first-child { margin-left: 0; }
.avatar.offline { filter: grayscale(1); opacity: .45; }
.avatar.gm::after {
  content: ""; position: absolute; right: -3px; bottom: -3px; width: 11px; height: 11px;
  border-radius: 50%; background: var(--turn); border: 2px solid var(--panel);
}
.avatar.more { background: var(--panel-2); color: var(--ink-2); text-shadow: none; border-color: var(--panel); box-shadow: inset 0 0 0 1px var(--line); }

/* ---------- Menus & popovers ---------- */
.menu {
  position: fixed; z-index: 40; min-width: 220px; max-width: 320px; padding: 6px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow);
}
.menu button.item {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  padding: 7px 10px; border: 0; border-radius: 6px; background: transparent; cursor: pointer;
}
.menu button.item:hover, .menu button.item:focus-visible { background: var(--panel-2); outline: none; }
.menu button.item svg { width: 17px; height: 17px; color: var(--ink-2); flex: none; }
.menu button.item.danger { color: var(--danger); }
.menu button.item.danger svg { color: var(--danger); }
.menu .menu-sep { height: 1px; background: var(--line); margin: 5px 4px; }
.menu .menu-head { padding: 6px 10px 4px; font-size: 12.5px; color: var(--ink-2); font-weight: 700; }
.menu .who { display: flex; align-items: center; gap: 8px; padding: 6px 10px; }
.menu .who .dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.menu .who .role { margin-left: auto; font-size: 12px; color: var(--ink-2); }

/* ---------- Inspector ---------- */
.inspector {
  position: fixed; top: 64px; left: var(--gap); z-index: 9; width: 300px;
  max-height: calc(100% - var(--init-h) - 64px - 44px - var(--gap) * 4);
  overflow: auto; overscroll-behavior: contain;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-panel);
  box-shadow: var(--shadow);
}
.insp-head {
  display: flex; align-items: center; gap: 8px; padding: 10px 10px 10px 14px;
  border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--panel); z-index: 1;
}
.insp-head h2 { margin: 0; font-size: 15px; font-weight: 800; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.insp-tag {
  font-size: 11.5px; font-weight: 700; padding: 2px 7px; border-radius: 999px;
  background: var(--turn-soft); color: var(--turn-ink);
}
.insp-tag.lock { background: var(--panel-2); color: var(--ink-2); }
.insp-body { padding: 12px 14px 14px; display: grid; gap: 14px; }
.insp-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.insp-actions { display: flex; flex-wrap: wrap; gap: 6px; padding-top: 12px; border-top: 1px solid var(--line); }
.insp-section { display: grid; gap: 8px; }
.insp-section > .label { font-size: 13px; font-weight: 700; color: var(--ink-2); display: flex; align-items: center; justify-content: space-between; }
.token-preview {
  width: 56px; height: 56px; border-radius: 50%; flex: none; display: grid; place-items: center;
  font-weight: 800; color: #fff; font-size: 18px; background-size: cover; background-position: center;
  box-shadow: 0 0 0 3px var(--panel), 0 0 0 5px var(--ring, var(--line-2));
}
.bar-row { display: grid; grid-template-columns: 1fr 56px 10px 56px auto; gap: 4px; align-items: center; }
.bar-row input { height: 28px; padding: 0 6px; font-size: 13px; }
.bar-row .slash { text-align: center; color: var(--ink-3); }
.bar-row .bar-tools { display: flex; gap: 0; }
.bar-meter { grid-column: 1 / -1; height: 6px; border-radius: 3px; background: var(--panel-2); overflow: hidden; box-shadow: inset 0 0 0 1px var(--line); }
.bar-meter > i { display: block; height: 100%; border-radius: 3px; }
.bar-step { display: flex; gap: 4px; grid-column: 1 / -1; }
.bar-step .btn { flex: 1; }
.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chip {
  display: inline-flex; align-items: center; gap: 4px; height: 26px; padding: 0 4px 0 9px;
  border-radius: 999px; background: var(--panel-2); border: 1px solid var(--line); font-size: 13px; font-weight: 500;
}
.chip button { border: 0; background: transparent; width: 18px; height: 18px; border-radius: 50%; cursor: pointer; display: grid; place-items: center; color: var(--ink-2); padding: 0; }
.chip button:hover { background: var(--line); color: var(--ink); }
.chip button svg { width: 12px; height: 12px; }
.md-view {
  font-size: 13.5px; line-height: 1.45; background: var(--panel-2); border-radius: 8px; padding: 8px 10px;
  overflow-wrap: anywhere; border: 1px solid transparent;
}
.md-view.editable { cursor: text; }
.md-view.editable:hover { border-color: var(--line-2); }
.md-view h1, .md-view h2, .md-view h3 { margin: 6px 0 4px; line-height: 1.2; }
.md-view h1 { font-size: 16px; } .md-view h2 { font-size: 15px; } .md-view h3 { font-size: 14px; }
.md-view > :first-child { margin-top: 0; }
.md-view p { margin: 0 0 4px; }
.md-view ul { margin: 0 0 4px; padding-left: 18px; }
.md-view hr { border: 0; border-top: 1px solid var(--line-2); margin: 8px 0; }
.md-view code { font-size: 12.5px; background: rgba(30,41,53,.07); padding: 0 3px; border-radius: 3px; }
.insp-section > .label .btn { height: 22px; font-size: 12.5px; }

/* ---------- Hero sheets (Party panel) ---------- */
.sheet-panel {
  position: fixed; top: 64px; left: var(--gap); bottom: calc(var(--init-h) + var(--gap) * 2); z-index: 13;
  width: min(680px, calc(100vw - var(--dice-w) - var(--gap) * 3));
  display: flex; flex-direction: column;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-panel); box-shadow: var(--shadow);
  overflow: hidden;
}
.sp-head { display: flex; align-items: center; gap: 6px; padding: 8px 8px 8px 10px; border-bottom: 1px solid var(--line); background: var(--panel-2); }
.sp-heroes { display: flex; align-items: center; gap: 4px; flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: thin; }
.hero-tab {
  display: flex; align-items: center; gap: 6px; flex: none; height: 34px; padding: 0 10px; border-radius: 8px;
  border: 1px solid transparent; background: transparent; cursor: pointer; max-width: 200px;
}
.hero-tab:hover { background: var(--panel); border-color: var(--line); }
.hero-tab[aria-selected="true"] { background: var(--panel); border-color: var(--line-2); box-shadow: var(--shadow-sm); }
.hero-tab .dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.hero-tab .hn { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hero-tab small { color: var(--ink-2); font-size: 12px; white-space: nowrap; }
.sp-sub { display: flex; align-items: center; gap: 8px; padding: 0 8px 0 10px; border-bottom: 1px solid var(--line); }
.sp-tabs { display: flex; gap: 2px; flex: 1; }
.sp-owner { font-size: 12.5px; color: var(--ink-2); }
.sp-body { flex: 1; overflow: auto; overscroll-behavior: contain; padding: 14px 16px 24px; }
.sp-empty { max-width: 420px; margin: 40px auto; display: grid; gap: 12px; text-align: center; justify-items: center; }
.sp-empty h3 { margin: 0; font-size: 20px; }
.sp-empty p { margin: 0; color: var(--ink-2); }
.spage { display: grid; gap: 12px; }
.srow { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.srow .grow { flex: 1 1 200px; }
.sfield { display: grid; gap: 4px; min-width: 0; }
.sfield.w-num { width: 84px; }
.slabel { font-size: 11.5px; font-weight: 700; color: var(--ink-2); display: flex; align-items: center; gap: 8px; }
.sp-body input:not([type="checkbox"]), .sp-body select, .sp-body textarea { height: 32px; }
.sp-body textarea { height: auto; min-height: 52px; }
.sp-body input.num { text-align: center; font-weight: 700; padding: 0 4px; }
.sp-body.readonly input[readonly], .sp-body.readonly textarea[readonly] { background: var(--panel-2); border-color: transparent; }
.with-list { display: block; }
.with-list input { width: 100%; }
.sbox { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; display: grid; gap: 8px; align-content: start; min-width: 0; }
.sbox-title { margin: 0; font-size: 13px; font-weight: 800; color: #8B2A1E; text-transform: none; }
.shint { margin: 0; font-size: 12px; color: var(--ink-2); line-height: 1.35; }
.grid2s { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid3s { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.aspects { display: grid; grid-template-columns: repeat(auto-fit, minmax(270px, 1fr)); gap: 8px; }
.aspect { border: 1px solid var(--line-2); border-radius: 10px; padding: 8px; display: grid; gap: 6px; min-width: 0; }
.aspect-head { display: grid; grid-template-columns: 1fr auto; grid-template-rows: auto auto; column-gap: 6px; align-items: center; }
.aspect-name { font-size: 17px; font-weight: 800; }
.aspect-sub { grid-row: 2; font-size: 11px; color: var(--ink-2); }
.aspect .score { grid-row: 1 / span 2; grid-column: 2; width: 46px; height: 38px !important; font-size: 18px; }
.eff { display: grid; grid-template-columns: repeat(6, 1fr); gap: 2px; }
.eff-cell { display: grid; justify-items: center; padding: 3px 0; border-radius: 5px; color: var(--ink-3); }
.eff-cell b { font-size: 11.5px; }
.eff-cell small { font-size: 10.5px; }
.eff-cell.on { background: var(--ink); color: var(--panel); }
.trackers { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 8px; }
.tracker { display: flex; align-items: center; justify-content: space-between; gap: 8px; border: 1px solid var(--line-2); border-radius: 10px; padding: 8px 10px; }
.tracker > b { font-size: 15px; }
.tracker .pips { flex-wrap: nowrap; gap: 3px; }
.tracker .pip { width: 19px; height: 19px; }
.pips { display: flex; flex-wrap: wrap; gap: 4px; }
.pip { width: 20px; height: 20px; border-radius: 50%; border: 1.5px solid var(--ink); background: var(--panel); padding: 0; cursor: pointer; }
.pip.on { background: var(--ink); }
.pip:disabled { cursor: default; }
.pip:not(:disabled):hover { box-shadow: 0 0 0 3px var(--accent-soft); }
.boxes { display: inline-flex; gap: 3px; }
.boxes input { width: 16px; height: 16px; margin: 0; accent-color: var(--ink); }
.sheet-check { font-size: 12.5px; color: var(--ink); }
.bond-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; }
.bond-row .pip { width: 17px; height: 17px; }
.num-row { display: grid; grid-template-columns: 20px 1fr auto; gap: 6px; align-items: center; margin-bottom: 4px; }
.num-row .n { font-size: 12px; color: var(--ink-3); text-align: right; font-weight: 700; }
.num-row.dim { opacity: .45; }
.num-row input { height: 28px !important; }
.bagtag { font-size: 10.5px; font-weight: 700; color: var(--ink-3); }
.inv-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.gear { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.sref { border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; }
.sref summary { cursor: pointer; font-weight: 700; font-size: 13px; }
.sref-part { margin-top: 10px; }
.sblocks { display: grid; gap: 6px; }
.sb-h { margin: 6px 0 0; font-size: 13px; font-weight: 800; }
.sblocks h6.sb-h { font-size: 12.5px; color: var(--ink-2); margin-top: 2px; }
.smd { font-size: 13px; line-height: 1.45; }
.smd p { margin: 0 0 4px; }
.smd.inline p { display: inline; margin: 0; }
.smd.inline p + p::before { content: " "; }
.stable-wrap { overflow-x: auto; }
.stable { border-collapse: collapse; width: 100%; font-size: 12.5px; }
.stable th { text-align: left; font-size: 11.5px; color: var(--ink-2); border-bottom: 1px solid var(--line-2); padding: 3px 6px; }
.stable td { border-bottom: 1px solid var(--line); padding: 4px 6px; vertical-align: top; }
.stable td p { margin: 0; }
.job-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.job-name { margin: 0; font-size: 26px; font-weight: 800; line-height: 1.1; }
.job-tag { margin: 2px 0 0; color: var(--ink-2); font-style: italic; }
.job-tag .stars { font-style: normal; color: #B7860B; letter-spacing: 1px; }
.comps-line { margin: 0; font-size: 13px; }
.job-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.jstat { border: 1px solid var(--line-2); border-radius: 10px; padding: 6px 10px; display: grid; gap: 2px; }
.jstat b { font-size: 18px; }
.res-box { gap: 10px; }
.res-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.res-row .res-name { font-size: 15px; min-width: 64px; }
.res-row .sfield.w-num { width: 64px; }
.res-row .shint { flex-basis: auto; }
.job-sec .sbox-title, .progression .sbox-title, .goals .sbox-title { font-size: 15px; }
.lvl { display: grid; gap: 4px; padding-top: 8px; border-top: 1px dashed var(--line); }
.lvl.dim { opacity: .55; }
.lvl-label { margin: 0; font-size: 13px; font-weight: 800; }
.abil { display: grid; grid-template-columns: 18px 1fr; gap: 8px; align-items: start; padding: 4px 6px; border-radius: 6px; cursor: pointer; }
.abil input { margin: 3px 0 0; width: 15px; height: 15px; accent-color: var(--ink); }
.abil.picked { background: var(--turn-soft); }
.abil-text { font-size: 13px; line-height: 1.45; }
.abil-text .cost { margin: 0 6px; font-weight: 700; color: #B7860B; font-size: 12px; }
.goal { display: grid; grid-template-columns: auto 1fr; gap: 10px; align-items: start; font-size: 13px; padding: 4px 0; border-bottom: 1px solid var(--line); }
.goal:last-child { border-bottom: 0; }
.empty-job { justify-items: start; }
@media (max-width: 760px) {
  .job-stats { grid-template-columns: 1fr 1fr; }
  .grid2s, .grid3s, .inv-cols { grid-template-columns: 1fr; }
  .gear { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 900px) {
  .sheet-panel { left: var(--gap); right: var(--gap); width: auto; z-index: 21; }
}

/* Token info cards */
#popHost { position: fixed; inset: 0; pointer-events: none; z-index: 7; }
.token-pop {
  position: absolute; top: 0; left: 0; width: 232px; pointer-events: auto;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow);
  font-size: 13px;
}
.token-pop.is-hidden { border-style: dashed; border-color: #B7860B; }
.tp-head { display: flex; align-items: center; gap: 7px; padding: 6px 4px 6px 8px; border-bottom: 1px solid var(--line); cursor: grab; user-select: none; }
.tp-head:active { cursor: grabbing; }
.tp-face {
  width: 22px; height: 22px; border-radius: 50%; flex: none; display: grid; place-items: center;
  font-size: 9.5px; font-weight: 800; color: #fff; background-size: cover; background-position: center;
  box-shadow: 0 0 0 1.5px var(--panel), 0 0 0 3px var(--ring, var(--line-2));
}
.tp-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13.5px; }
.tp-head .insp-tag { font-size: 10.5px; padding: 1px 6px; }
.tp-btn { width: 24px; height: 24px; border: 0; background: transparent; border-radius: 6px; display: grid; place-items: center; cursor: pointer; color: var(--ink-2); padding: 0; flex: none; }
.tp-btn:hover { background: var(--panel-2); color: var(--ink); }
.tp-btn svg { width: 14px; height: 14px; }
.tp-bars { display: grid; gap: 7px; padding: 8px 10px 4px; }
.tp-bar { display: grid; gap: 3px; }
.tp-bar-top { display: flex; align-items: center; gap: 6px; min-height: 24px; }
.tp-bar-label { flex: 1; min-width: 0; font-weight: 700; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tp-bar-num { font-weight: 800; }
.tp-bar-edit { display: flex; align-items: center; gap: 3px; }
.tp-step {
  width: 22px; height: 22px; border-radius: 6px; border: 1px solid var(--line-2); background: var(--panel);
  font-weight: 800; font-size: 14px; line-height: 1; cursor: pointer; padding: 0; display: grid; place-items: center;
}
.tp-step:hover { border-color: var(--ink-3); background: var(--panel-2); }
input.tp-val { width: 44px; height: 24px; padding: 0 4px; text-align: right; font-weight: 800; font-size: 13.5px; }
.tp-max { color: var(--ink-2); font-weight: 600; white-space: nowrap; }
.tp-conds { display: flex; flex-wrap: wrap; gap: 4px; padding: 6px 10px 9px; align-items: center; }
.tp-chip { height: 24px; padding: 0 3px 0 8px; font-size: 12.5px; gap: 2px; }
.tp-chip button { font-weight: 800; font-size: 13px; }
.tp-chip > button:first-child { margin-left: -5px; }
input.tp-add { flex: 1 1 90px; min-width: 90px; height: 24px; font-size: 12.5px; padding: 0 7px; border-style: dashed; }
.readonly-notes { white-space: pre-wrap; font-size: 13.5px; background: var(--panel-2); border-radius: 8px; padding: 8px 10px; margin: 0; }

/* ---------- Dice panel ---------- */
.dice-panel {
  position: fixed; top: 64px; right: var(--gap); bottom: var(--gap); width: var(--dice-w); z-index: 9;
  display: flex; flex-direction: column;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-panel);
  box-shadow: var(--shadow); overflow: hidden;
}
body.dice-hidden .dice-panel { display: none; }
.dp-tabs { display: flex; gap: 4px; padding: 8px 8px 0; border-bottom: 1px solid var(--line); }
.dp-tab {
  border: 0; background: transparent; padding: 8px 12px 9px; cursor: pointer; font-weight: 700; color: var(--ink-2);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.dp-tab[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--ink); }
.dp-tab .count { font-weight: 500; color: var(--ink-3); margin-left: 4px; }
.dp-tabs .spacer { flex: 1; }
.dp-log { flex: 1; overflow: auto; padding: 6px 0; overscroll-behavior: contain; }
.dp-empty { padding: 24px 18px; color: var(--ink-2); }
.roll { padding: 9px 14px; display: grid; grid-template-columns: 1fr auto; column-gap: 10px; row-gap: 5px; }
.roll + .roll { border-top: 1px solid var(--panel-2); }
.roll.fresh { animation: rollIn .5s ease-out; }
@keyframes rollIn { from { background: var(--accent-soft); } to { background: transparent; } }
.roll-who { display: flex; align-items: center; gap: 6px; min-width: 0; font-size: 13px; }
.roll-who .dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.roll-who b { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.roll-who .lbl { color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.roll-tag { font-size: 11px; font-weight: 700; padding: 1px 6px; border-radius: 999px; background: var(--turn-soft); color: var(--turn-ink); flex: none; }
.roll-total { grid-row: 1 / span 2; grid-column: 2; align-self: center; font-size: 26px; font-weight: 800; line-height: 1; min-width: 34px; text-align: right; }
.roll-detail { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; font-size: 12.5px; color: var(--ink-2); }
.roll-expr { border: 0; background: none; padding: 0; color: var(--ink-2); cursor: pointer; font-size: 12.5px; text-decoration: underline dotted var(--line-2); text-underline-offset: 3px; }
.roll-expr:hover { color: var(--accent); }
.die {
  display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 4px;
  border-radius: 5px; font-weight: 700; font-size: 12.5px; color: var(--ink);
  background: var(--panel); border: 1px solid var(--line-2);
}
.die.drop { color: var(--ink-3); text-decoration: line-through; border-style: dashed; background: transparent; }
.die.ex { border-color: var(--turn); }
.die.hit { background: var(--ink); color: var(--panel); border-color: var(--ink); }
.die.max:not(.drop) { box-shadow: inset 0 -2px 0 var(--ok); }
.die.min:not(.drop) { box-shadow: inset 0 -2px 0 var(--danger); }
.op { color: var(--ink-3); font-weight: 700; padding: 0 1px; }

.dp-compose { border-top: 1px solid var(--line); padding: 10px 12px 12px; display: grid; gap: 8px; background: var(--panel-2); }
.macro-row { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; }
.macro-row .row-label { font-size: 12px; font-weight: 700; color: var(--ink-2); margin-right: 2px; }
.macro {
  height: 26px; padding: 0 9px; border-radius: 999px; border: 1px solid var(--line-2);
  background: var(--panel); cursor: pointer; font-size: 13px; font-weight: 500;
}
.macro:hover { border-color: var(--accent); color: var(--accent); }
.macro.add { border-style: dashed; color: var(--ink-2); }
.quick-dice { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.quick-dice button {
  height: 28px; border: 1px solid var(--line-2); border-radius: 6px; background: var(--panel);
  font-size: 12.5px; font-weight: 700; cursor: pointer; padding: 0;
}
.quick-dice button:hover { border-color: var(--ink-3); }
.roll-input { display: flex; gap: 6px; }
.roll-input input { flex: 1; font-size: 15px; height: 36px; }
.roll-input .btn { height: 36px; }
.roll-opts { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.roll-err { color: var(--danger); font-size: 12.5px; margin: 0; }
.roll-err:empty { display: none; }

.pools { flex: 1; overflow: auto; padding: 10px 12px; display: grid; align-content: start; gap: 10px; }
.pool { border: 1px solid var(--line); border-radius: 10px; padding: 10px; display: grid; gap: 8px; }
.pool-head { display: flex; align-items: center; gap: 6px; }
.pool-head b { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pool-sum { font-size: 12.5px; color: var(--ink-2); }
.pool-dice { display: flex; flex-wrap: wrap; gap: 5px; }
.pool-die {
  width: 34px; height: 34px; border-radius: 7px; border: 1.5px solid var(--ink);
  background: var(--panel); font-weight: 800; font-size: 15px; cursor: pointer; padding: 0;
  display: grid; place-items: center; position: relative;
}
.pool-die small { position: absolute; bottom: 1px; right: 3px; font-size: 8.5px; font-weight: 700; color: var(--ink-3); }
.pool-die.spent { border-style: dashed; border-color: var(--line-2); color: var(--ink-3); background: var(--panel-2); text-decoration: line-through; }
.pool-die:disabled { cursor: default; }
.pool-new { border: 1px dashed var(--line-2); border-radius: 10px; padding: 10px; display: grid; gap: 8px; }
.pool-new .row { display: grid; grid-template-columns: 1fr 64px 72px; gap: 6px; }

/* ---------- Initiative ---------- */
.initiative {
  position: fixed; left: var(--gap); right: calc(var(--dice-w) + var(--gap) * 2); bottom: var(--gap);
  height: var(--init-h); z-index: 8;
  display: grid; grid-template-columns: 92px 1fr auto; grid-template-rows: 100%;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-panel);
  box-shadow: var(--shadow); overflow: hidden;
}
body.dice-hidden .initiative { right: var(--gap); }
.ini-side {
  display: grid; grid-template-rows: 38px 1fr 1fr; border-right: 1px solid var(--line);
  background: var(--panel-2);
}
.ini-round { display: flex; align-items: center; gap: 2px; padding: 0 4px 0 10px; border-bottom: 1px solid var(--line); }
.ini-round .word { font-size: 13px; font-weight: 700; color: var(--ink-2); }
.ini-round .n {
  font-size: 20px; font-weight: 800; border: 0; background: transparent; padding: 0 4px; border-radius: 6px;
  min-width: 30px; text-align: left; cursor: default;
}
.ini-round button.n:hover { background: var(--line); cursor: pointer; }
.ini-rowlabel { display: flex; align-items: center; padding: 0 10px; overflow: hidden; text-overflow: ellipsis; font-size: 13px; font-weight: 700; color: var(--ink-2); }
.ini-rowlabel + .ini-rowlabel { border-top: 1px dashed var(--line); }
.ini-lanes { display: flex; overflow-x: auto; overflow-y: hidden; min-width: 0; }
.lane {
  flex: 1 0 96px; min-width: 0; display: grid; grid-template-rows: 38px 1fr 1fr; border-right: 1px solid var(--line);
  position: relative; transition: background-color .2s;
}
.lane.upkeep { flex: 0.6 0 84px; background: repeating-linear-gradient(135deg, transparent 0 9px, rgba(30,41,53,.025) 9px 18px); }
.lane:last-child { border-right: 0; }
.lane-head { display: flex; align-items: center; gap: 4px; padding: 0 6px 0 8px; border-bottom: 1px solid var(--line); min-width: 0; }
.lane-num { font-size: 21px; font-weight: 800; line-height: 1; color: var(--ink); }
.lane-name {
  font-size: 12.5px; font-weight: 700; color: var(--ink-2); min-width: 0; flex: 0 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  border: 0; background: transparent; padding: 2px 4px; border-radius: 5px; text-align: left;
}
button.lane-name:hover { background: var(--panel-2); cursor: text; }
.lane-title {
  display: flex; align-items: center; gap: 5px; min-width: 0; border: 0; background: transparent;
  padding: 3px 5px; margin-left: -5px; border-radius: 6px; cursor: text; text-align: left;
}
.lane-title:hover { background: rgba(30, 41, 53, 0.06); }
.lane-name-input { min-width: 0; flex: 1; }
.lane-name-input { height: 26px; font-size: 13px; font-weight: 700; }
.lane.active { background: var(--turn-soft); }
.lane.active::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 4px; background: var(--turn);
}
.lane.active .lane-num { color: var(--turn-ink); }
.lane.active .lane-name { color: var(--turn-ink); }
.lane-row {
  display: flex; align-items: center; gap: 6px; padding: 2px 8px; min-width: 0; overflow-x: auto; overflow-y: hidden;
  position: relative; scrollbar-width: none;
}
.lane-row::-webkit-scrollbar { display: none; }
.lane-row + .lane-row { border-top: 1px dashed var(--line); }
.lane-row.drop-ok { background: var(--accent-soft); box-shadow: inset 0 0 0 2px var(--accent); }
.lane-row .add {
  width: 28px; height: 28px; border-radius: 50%; border: 1.5px dashed var(--line-2); background: transparent;
  color: var(--ink-3); cursor: pointer; flex: none; display: grid; place-items: center; padding: 0;
  opacity: 0; transition: opacity .12s;
}
.lane:hover .add, .lane-row .add:focus-visible, .lane-row.empty .add { opacity: 1; }
.lane-row .add:hover { border-color: var(--accent); color: var(--accent); }
.lane-row .add svg { width: 15px; height: 15px; }
.ap-box { display: flex; align-items: center; gap: 3px; margin-left: auto; flex: none; }
.ap-box span { font-size: 11px; font-weight: 700; color: var(--ink-3); }
.lane.active .ap-box span { color: var(--turn-ink); }
.ap-box input:placeholder-shown:not(:focus) { border-color: transparent; background: transparent; box-shadow: none; }
.lane:hover .ap-box input:placeholder-shown:not(:focus) { border-color: var(--line-2); background: var(--panel); }
.ap-box input::placeholder { color: var(--ink-3); font-weight: 700; font-size: 11px; }
.ap-box input { width: 30px; height: 26px; padding: 0 4px; text-align: center; font-weight: 700; font-size: 13px; }
.ap-box output { font-weight: 800; font-size: 14px; min-width: 14px; }
.upkeep-note { grid-row: 2 / span 2; padding: 8px 10px; font-size: 12.5px; color: var(--ink-2); }

.ini-chip {
  position: relative; flex: none; width: 44px; display: grid; justify-items: center; gap: 2px;
  cursor: pointer; border: 0; background: transparent; padding: 0; border-radius: 6px;
}
.ini-chip[draggable="true"] { cursor: grab; }
.ini-chip .face {
  width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  font-size: 12px; font-weight: 800; color: #fff; background-size: cover; background-position: center;
  box-shadow: 0 0 0 2px var(--panel), 0 0 0 3.5px var(--ring, var(--line-2));
  text-shadow: 0 1px 1px rgba(0,0,0,.3);
}
.ini-chip .nm { font-size: 11px; font-weight: 700; max-width: 44px; line-height: 1.2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink); }
.ini-chip .mini { width: 30px; height: 3px; border-radius: 2px; background: var(--line); overflow: hidden; }
.ini-chip .mini > i { display: block; height: 100%; }
.ini-chip.is-hidden .face { opacity: .45; }
.ini-chip.focus .face { box-shadow: 0 0 0 2px var(--panel), 0 0 0 4.5px var(--turn); }
.ini-chip.focus .nm { color: var(--turn-ink); }
.ini-chip .x {
  position: absolute; top: -4px; right: 0; width: 18px; height: 18px; border-radius: 50%;
  background: var(--ink); color: var(--panel); border: 2px solid var(--panel); display: none; place-items: center; padding: 0; cursor: pointer;
}
.ini-chip .x svg { width: 9px; height: 9px; }
.ini-chip:hover .x, .ini-chip:focus-within .x { display: grid; }
.ini-chip.dragging { opacity: .4; }
.lane-row.crowded .ini-chip + .ini-chip { margin-left: -20px; }
.lane-row.crowded .ini-chip .nm { visibility: hidden; }
.lane-row.crowded .ini-chip:hover, .lane-row.crowded .ini-chip:focus-visible { z-index: 2; }
.lane-row.crowded .ini-chip:hover .nm { visibility: visible; background: var(--panel); border-radius: 4px; padding: 0 3px; max-width: none; position: relative; z-index: 3; }
.lane-row.crowded { gap: 0; }
.lane-row.crowded .add { margin-left: 4px; }
.ini-ctl { display: grid; grid-template-rows: 38px 1fr; border-left: 1px solid var(--line); width: 118px; }
.ini-ctl-top { display: flex; align-items: center; justify-content: flex-end; gap: 2px; padding: 0 6px; border-bottom: 1px solid var(--line); }
.ini-ctl-main { display: grid; align-content: center; gap: 8px; padding: 8px 10px; }
.ini-next { height: 46px; flex-direction: column; gap: 0; line-height: 1.15; }
.ini-next small { font-weight: 500; opacity: .85; font-size: 12px; }
.ini-status { font-size: 12.5px; color: var(--ink-2); text-align: center; }
body.init-collapsed .initiative { grid-template-columns: 1fr auto; }
body.init-collapsed .ini-side, body.init-collapsed .ini-lanes { display: none; }
body.init-collapsed .ini-ctl { grid-template-rows: 100%; grid-column: 2; }
body.init-collapsed .ini-ctl-main { display: none; }
body.init-collapsed .ini-ctl-top { border-bottom: 0; }
.ini-mini { display: none; align-items: center; gap: 10px; padding: 0 14px; font-weight: 700; min-width: 0; }
body.init-collapsed .ini-mini { display: flex; }
.ini-mini .pill { background: var(--turn-soft); color: var(--turn-ink); padding: 3px 10px; border-radius: 999px; }

/* Turn order mode */
.ini-side.turns { grid-template-rows: 38px 1fr; }
.ini-side.turns .ini-rowlabel { align-items: flex-start; padding-top: 12px; }
.ini-track {
  display: flex; align-items: center; gap: 8px; padding: 8px 12px; min-width: 0;
  overflow-x: auto; overflow-y: hidden; overscroll-behavior: contain;
}
.ini-track.drop-ok { background: var(--accent-soft); box-shadow: inset 0 0 0 2px var(--accent); }
.turn-empty { margin: 0; color: var(--ink-2); max-width: 420px; }
.turn-card {
  position: relative; flex: none; width: 84px; display: grid; justify-items: center; align-content: center; gap: 4px;
  padding: 8px 6px 7px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); cursor: pointer;
}
.turn-card[draggable="true"] { cursor: grab; }
.turn-card:hover { border-color: var(--line-2); }
.turn-card.current { background: var(--turn-soft); border-color: var(--turn); box-shadow: inset 0 4px 0 var(--turn); }
.turn-card.current .nm { color: var(--turn-ink); }
.turn-card.dragging { opacity: .4; }
.turn-card .face {
  width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center;
  font-size: 15px; font-weight: 800; color: #fff; background-size: cover; background-position: center;
  box-shadow: 0 0 0 2px var(--panel), 0 0 0 4px var(--ring, var(--line-2)); text-shadow: 0 1px 1px rgba(0,0,0,.3);
}
.turn-card.is-hidden .face { opacity: .45; }
.turn-card .nm { font-size: 12.5px; font-weight: 700; max-width: 80px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.turn-card .mini { width: 46px; height: 4px; border-radius: 2px; background: var(--line); overflow: hidden; }
.turn-card .mini > i { display: block; height: 100%; }
.turn-card .init { font-size: 15px; font-weight: 800; line-height: 24px; height: 24px; }
.turn-card .init-in { width: 48px; height: 24px; padding: 0 4px; text-align: center; font-weight: 800; font-size: 14px; }
.turn-card .init-in:placeholder-shown:not(:focus) { border-style: dashed; }
.turn-card .x {
  position: absolute; top: -6px; right: -6px; width: 20px; height: 20px; border-radius: 50%;
  background: var(--ink); color: var(--panel); border: 2px solid var(--panel); display: none; place-items: center; padding: 0; cursor: pointer;
}
.turn-card .x svg { width: 10px; height: 10px; }
.turn-card:hover .x, .turn-card:focus-within .x { display: grid; }
.turn-add {
  flex: none; width: 40px; height: 40px; border-radius: 50%; border: 1.5px dashed var(--line-2); background: transparent;
  color: var(--ink-3); cursor: pointer; display: grid; place-items: center; padding: 0;
}
.turn-add:hover { border-color: var(--accent); color: var(--accent); }
.turn-add svg { width: 18px; height: 18px; }
body.init-collapsed .ini-track { display: none; }

/* Picker popover */
.picker { width: 280px; max-height: 360px; overflow: auto; padding: 8px; }
.picker .tok { display: flex; align-items: center; gap: 8px; }
.picker .tok .face { width: 24px; height: 24px; border-radius: 50%; flex: none; background-size: cover; background-position: center; display: grid; place-items: center; font-size: 10px; color: #fff; font-weight: 800; }
.picker .tok .where { margin-left: auto; font-size: 12px; color: var(--ink-3); }
.picker .custom { display: grid; grid-template-columns: 1fr auto; gap: 6px; padding: 6px 4px 2px; }

/* ---------- Zoom ---------- */
.zoombox {
  position: fixed; left: var(--gap); bottom: calc(var(--init-h) + var(--gap) * 2); z-index: 8;
  display: flex; align-items: center; gap: 0; padding: 3px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow-sm);
}
.zoomlabel { min-width: 56px; font-size: 13px; padding: 0 6px; }
.zoombox .zsep { width: 1px; height: 20px; background: var(--line); margin: 0 3px; }
#rangesBtn { font-size: 13px; padding: 0 10px; }
#rangesBtn[aria-pressed="true"] { background: var(--turn-soft); color: var(--turn-ink); }

/* ---------- Banner, toasts, modal ---------- */
.banner {
  position: fixed; top: 64px; left: 50%; transform: translateX(calc(-50% - var(--dice-w) / 2)); z-index: 30;
  display: flex; align-items: center; gap: 12px; padding: 10px 10px 10px 16px; max-width: min(640px, 90vw);
  background: var(--ink); color: var(--panel); border-radius: 10px; box-shadow: var(--shadow);
}
.banner .btn { height: 30px; }
.banner .btn.ghost { color: var(--panel); }
.banner .btn.ghost:hover { background: rgba(255,255,255,.12); }
.toasts { position: fixed; bottom: calc(var(--init-h) + var(--gap) * 2); left: 50%; transform: translateX(calc(-50% - var(--dice-w) / 2)); z-index: 50; display: grid; gap: 6px; justify-items: center; pointer-events: none; }
.toast {
  background: var(--ink); color: var(--panel); padding: 9px 14px; border-radius: 9px; box-shadow: var(--shadow);
  font-weight: 500; max-width: 480px; animation: toastIn .2s ease-out;
}
.toast.error { background: var(--danger); }
@keyframes toastIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.modal-back { position: fixed; inset: 0; z-index: 60; background: rgba(30, 41, 53, 0.32); display: grid; place-items: center; padding: 20px; }
.modal {
  width: min(460px, 100%); max-height: calc(100vh - 40px); overflow: auto;
  background: var(--panel); border-radius: 14px; box-shadow: var(--shadow); padding: 20px; display: grid; gap: 14px;
}
.modal h2 { margin: 0; font-size: 19px; font-weight: 800; }
.modal .body { display: grid; gap: 12px; }
.modal .foot { display: flex; justify-content: flex-end; gap: 8px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.modal-section { margin: 6px 0 -4px; font-size: 15px; font-weight: 800; padding-top: 12px; border-top: 1px solid var(--line); }
.band-edit { display: grid; grid-template-columns: 1fr 76px auto auto; gap: 6px; align-items: center; }
.band-edit .muted { font-size: 13px; }
.per-row { display: grid; grid-template-columns: 96px 96px; gap: 6px; }
.macro-edit { display: grid; grid-template-columns: 1fr 1.4fr auto; gap: 6px; align-items: center; }

@media (max-width: 900px) {
  :root { --dice-w: 0px; --init-h: 156px; }
  .dice-panel { width: auto; left: var(--gap); display: none; z-index: 20; }
  body.dice-open-mobile .dice-panel { display: flex; }
  .toolbar { transform: translateX(-50%); top: 60px; max-width: calc(100vw - 24px); overflow-x: auto; }
  .stylebar { top: 112px; transform: translateX(-50%); }
  .tablename { max-width: 40vw; }
  .inspector { top: 112px; width: min(300px, calc(100vw - 24px)); }
  .initiative { grid-template-columns: 66px 1fr auto; }
  .ini-round { flex-direction: column; align-items: flex-start; justify-content: center; gap: 0; }
  .ini-round .word { font-size: 11px; line-height: 1; }
  .ini-round .n { font-size: 18px; line-height: 1.1; padding: 0; }
  .ini-rowlabel { font-size: 12px; padding: 0 8px; }
  .ini-ctl { width: 76px; }
  .ini-next { height: 48px; }
  .lane { flex-basis: 104px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
