/* Hero Designer Web. Layout follows Hero Designer's: tabs across the top; on each ability tab the
   character's list beside the Available tree; items open in dialogs. Two panes from 960px wide,
   one pane with an Add sheet below that; dialogs become full-screen sheets on phones. */

:root {
  color-scheme: light;
  --bg: #eef1f6;
  --panel: #ffffff;
  --panel-2: #f6f8fb;
  --ink: #18202e;
  --ink-2: #4a5568;
  --muted: #6b7686;
  --line: #d9dfe8;
  --line-2: #e8ecf2;
  --accent: #2f5bd3;
  --accent-ink: #ffffff;
  --accent-soft: #e6edff;
  --sel: #dbe6ff;
  --sel-line: #9fb7f5;
  --warn: #c98a00;
  --stop: #c62f3a;
  --ok: #217a4b;
  --bad: #b3261e;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.08);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, 0.18);
  --radius: 10px;
  --radius-sm: 7px;
  --font: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --mono: ui-monospace, 'Cascadia Mono', Consolas, monospace;
  --row: 34px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    color-scheme: dark;
    --bg: #12151b;
    --panel: #1b2029;
    --panel-2: #222835;
    --ink: #e6e9ef;
    --ink-2: #b8c0cc;
    --muted: #8a94a3;
    --line: #2f3746;
    --line-2: #262d3a;
    --accent: #6d8dff;
    --accent-ink: #0d1120;
    --accent-soft: #232d4a;
    --sel: #263559;
    --sel-line: #4a64b8;
    --warn: #e0a72a;
    --stop: #f0606b;
    --ok: #4cc38a;
    --bad: #ff8a80;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.5);
  }
}
:root[data-theme='dark'] {
  color-scheme: dark;
  --bg: #12151b;
  --panel: #1b2029;
  --panel-2: #222835;
  --ink: #e6e9ef;
  --ink-2: #b8c0cc;
  --muted: #8a94a3;
  --line: #2f3746;
  --line-2: #262d3a;
  --accent: #6d8dff;
  --accent-ink: #0d1120;
  --accent-soft: #232d4a;
  --sel: #263559;
  --sel-line: #4a64b8;
  --warn: #e0a72a;
  --stop: #f0606b;
  --ok: #4cc38a;
  --bad: #ff8a80;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; font: 14px/1.45 var(--font); color: var(--ink); background: var(--bg); -webkit-text-size-adjust: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
.ico { width: 16px; height: 16px; flex: none; vertical-align: -3px; }
.ico.warn { color: var(--warn); }
.ico.stop { color: var(--stop); }
.ico.dot { color: var(--muted); }
.ico.folder { color: #d1a33a; }
.pre { white-space: pre-wrap; }
.muted { color: var(--muted); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.hide { display: none !important; }

/* ---- buttons and inputs ---- */
.btn, button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 32px; padding: 5px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--panel); color: var(--ink); cursor: pointer; white-space: nowrap; }
button:hover:not(:disabled), .btn:hover { border-color: var(--sel-line); }
button:disabled { opacity: 0.45; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
button.ghost { background: transparent; border-color: transparent; }
button.ghost:hover:not(:disabled) { background: var(--panel-2); border-color: var(--line); }
button.danger { color: var(--bad); }
button.attn { border-color: var(--accent); color: var(--accent); font-weight: 600; }
button.icon { padding: 5px 8px; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, .row:focus-visible, .tree-item:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
input[type='text'], input[type='number'], input:not([type]), select, textarea { min-height: 32px; padding: 5px 8px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--panel); width: 100%; }
textarea { resize: vertical; line-height: 1.4; }
input[type='checkbox'] { width: 16px; height: 16px; accent-color: var(--accent); margin: 0; flex: none; }
label { color: var(--ink-2); }
.field { display: grid; gap: 4px; }
.field > span { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em; }
.check { display: inline-flex; align-items: center; gap: 8px; color: var(--ink); cursor: pointer; }
.stepper { display: inline-flex; align-items: stretch; }
.stepper button { min-height: 32px; padding: 0 10px; border-radius: 0; }
.stepper button:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.stepper button:last-child { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.stepper input { width: 64px; border-radius: 0; border-left: 0; border-right: 0; text-align: center; }

/* ---- app shell ---- */
.app { display: flex; flex-direction: column; height: 100dvh; }
.topbar { display: flex; align-items: center; gap: 10px; padding: 8px 14px; background: var(--panel); border-bottom: 1px solid var(--line); min-height: 52px; }
.brand { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.brand b { font-size: 16px; letter-spacing: -0.01em; white-space: nowrap; }
.brand .who { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.points { display: flex; gap: 6px; margin-left: auto; flex-wrap: nowrap; }
.chip { display: inline-flex; align-items: baseline; gap: 5px; padding: 3px 10px; border-radius: 999px; background: var(--panel-2); border: 1px solid var(--line-2); white-space: nowrap; font-size: 13px; color: var(--ink-2); }
.chip b { color: var(--ink); font-variant-numeric: tabular-nums; }
.chip.over b { color: var(--bad); }
.chip.left b { color: var(--ok); }
.menus { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; min-width: 0; }
.menus .short { display: none; }
/* Nothing in the top bar may push the page wider than the screen: a phone or tablet browser would zoom the whole
   page out to fit, shrinking every dialog with it (Steve's tablet, 2026-10-15). */
.topbar { flex-wrap: wrap; }
/* The character's name gives way first (ellipsis), so the menus stay on the top row. */
.topbar .brand { flex: 1 1 0; min-width: 120px; }
@media (max-width: 1099px) {
  .topbar .points { order: 3; width: 100%; margin-left: 0; overflow-x: auto; scrollbar-width: none; }
  .topbar .points::-webkit-scrollbar { display: none; }
  .topbar .menus { margin-left: auto; }
}
.menu { position: relative; }
.menu-pop { position: absolute; top: calc(100% + 4px); right: 0; z-index: 50; min-width: 230px; padding: 6px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-lg); display: none; }
.menu.left .menu-pop { left: 0; right: auto; }
.menu.open .menu-pop { display: block; }
.menu-pop button { width: 100%; justify-content: flex-start; border: 0; background: transparent; min-height: 34px; }
.menu-pop button:hover:not(:disabled) { background: var(--panel-2); }
.menu-pop hr { border: 0; border-top: 1px solid var(--line-2); margin: 5px 2px; }
.menu-pop .menu-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); padding: 6px 10px 2px; }
.menu-pop label.check { width: 100%; padding: 6px 10px; border-radius: var(--radius-sm); }
.menu-pop label.check:hover { background: var(--panel-2); }

.tabs { display: flex; gap: 2px; padding: 0 10px; background: var(--panel); border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: transparent; padding: 10px 12px; min-height: 42px; color: var(--ink-2); }
.tabs button.on { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.tabs button .count { font-size: 11px; color: var(--muted); font-weight: 500; }

.main { flex: 1; min-height: 0; overflow: auto; padding: 14px; }
.empty-state { max-width: 560px; margin: 8vh auto; text-align: center; color: var(--ink-2); }
.empty-state h1 { font-size: 22px; color: var(--ink); margin: 0 0 8px; }
.empty-state .actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 18px; }

/* ---- the ability tabs: list and Available panes ---- */
.panes { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(300px, 1fr); gap: 14px; height: 100%; min-height: 0; }
.pane { display: flex; flex-direction: column; min-height: 0; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.pane-head { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-bottom: 1px solid var(--line-2); background: var(--panel-2); min-height: 46px; flex-wrap: wrap; }
.pane-head h2 { font-size: 14px; margin: 0; }
.pane-head .total { color: var(--muted); font-size: 13px; }
.pane-head .spacer { flex: 1; }
.pane-body { flex: 1; min-height: 0; overflow: auto; }
.pane-foot { display: flex; gap: 6px; padding: 8px 10px; border-top: 1px solid var(--line-2); background: var(--panel-2); flex-wrap: wrap; align-items: center; }

.list-head, .row { display: grid; grid-template-columns: 54px 34px minmax(0, 1fr) 44px; align-items: start; gap: 6px; padding: 7px 10px; }
.list-head { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; padding-top: 6px; padding-bottom: 6px; border-bottom: 1px solid var(--line-2); position: sticky; top: 0; background: var(--panel); z-index: 1; }
.row { border-bottom: 1px solid var(--line-2); cursor: default; user-select: none; -webkit-user-select: none; }
.row:hover { background: var(--panel-2); }
.row.sel { background: var(--sel); box-shadow: inset 3px 0 0 var(--accent); }
.row .cost { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.row .pre-col { color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
.row .end { text-align: right; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.row .desc { min-width: 0; overflow-wrap: anywhere; }
.row .desc.custom { color: var(--accent); }
.row .note { display: block; margin-top: 3px; font-size: 12.5px; color: var(--ink-2); }
.row .note b { color: var(--ink-2); }
.row.list-row .desc { font-weight: 600; }
.row.slot { padding-left: 22px; }
.row.part .desc::before { content: '↳ '; color: var(--muted); }
.row.part { padding-left: 38px; }
.row.separator { min-height: 18px; }
.list-empty { padding: 32px 16px; text-align: center; color: var(--muted); }
.insert-line { height: 0; border-top: 2px solid var(--accent); margin: -1px 10px; position: relative; }

.tree-tools { display: flex; gap: 6px; padding: 8px 10px; border-bottom: 1px solid var(--line-2); align-items: center; }
.search { position: relative; flex: 1; }
.search .ico { position: absolute; left: 9px; top: 8px; color: var(--muted); }
.search input { padding-left: 30px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; }
.seg button { border: 0; border-radius: 0; min-height: 30px; padding: 4px 12px; background: var(--panel); }
.seg button.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.tree { padding: 4px 0 10px; }
.tree-group > .tree-item { font-weight: 600; }
.tree-item { display: flex; align-items: center; gap: 6px; width: 100%; padding: 5px 10px; min-height: 30px; border: 0; border-radius: 0; background: transparent; text-align: left; justify-content: flex-start; color: var(--ink); cursor: pointer; }
.tree-item:hover { background: var(--panel-2); }
.tree-item.sel { background: var(--sel); }
.tree-item .chev { transition: transform 0.12s; color: var(--muted); }
.tree-group.open > .tree-item .chev { transform: rotate(90deg); }
.tree-children { display: none; padding-left: 18px; }
.tree-group.open > .tree-children { display: block; }
.tree-item .label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.tree-hint { padding: 10px 12px; color: var(--muted); font-size: 12.5px; }

/* phones and narrow tablets: one pane; Available opens as a sheet from the Add button */
.fab { display: none; }
@media (max-width: 959px) {
  .panes { grid-template-columns: minmax(0, 1fr); }
  .panes .avail-pane { display: none; }
  .fab { display: inline-flex; position: fixed; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom)); z-index: 30; border-radius: 999px; min-height: 52px; padding: 0 20px; box-shadow: var(--shadow-lg); font-weight: 700; }
  .main { padding: 10px 10px 84px; }
}
@media (max-width: 720px) {
  .topbar { flex-wrap: wrap; gap: 6px 8px; padding: 8px 10px; }
  .brand { flex: 1; min-width: 0; }
  .brand b { display: none; }
  .brand .who { color: var(--ink); font-weight: 700; font-size: 15px; }
  .brand .who:empty::before { content: 'Hero Suite'; }
  .menus button { padding: 5px 6px; }
  .topbar .menus .split #saveCaret { padding: 5px 4px; }
  .topbar .menus { order: 2; width: 100%; margin-left: 0; justify-content: space-between; gap: 2px; }
  .menus .long { display: none; }
  .menus .short { display: inline; }
  .pane-head { flex-wrap: nowrap; }
  .pane-head .total { white-space: nowrap; }
  .pane-head .menu > button { padding: 5px 6px; }
  .points { order: 3; width: 100%; margin-left: 0; overflow-x: auto; scrollbar-width: none; }
  .points::-webkit-scrollbar { display: none; }
  .tabs { padding: 0 4px; }
  .tabs button { padding: 10px 10px; }
  .tabs .long { display: none; }
  .list-head, .row { grid-template-columns: 44px 26px minmax(0, 1fr) 36px; gap: 4px; padding-left: 8px; padding-right: 8px; }
  .row.slot { padding-left: 14px; }
  .row.part { padding-left: 26px; }
  .pane-foot .lbl { display: none; }
  .main { padding: 8px 8px 84px; }
}
@media (min-width: 721px) {
  .tabs .short { display: none; }
}

/* ---- dialogs: centred on desktop, full-screen sheets on phones ---- */
dialog.modal { padding: 0; border: 1px solid var(--line); border-radius: 14px; background: var(--panel); color: var(--ink); box-shadow: var(--shadow-lg); width: min(820px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); }
dialog.modal.small { width: min(460px, calc(100vw - 32px)); }
dialog.modal.wide { width: min(980px, calc(100vw - 32px)); }
dialog.modal[open] { display: flex; flex-direction: column; }
dialog::backdrop { background: rgba(10, 14, 22, 0.45); }
.modal-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line-2); }
.modal-head h2 { margin: 0; font-size: 16px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.modal-head .costs { color: var(--ink-2); font-size: 13px; white-space: nowrap; }
.modal-head .costs b { color: var(--ink); }
.modal-body { padding: 14px 16px; overflow: auto; flex: 1; min-height: 0; }
.modal-foot { display: flex; gap: 8px; padding: 10px 16px; border-top: 1px solid var(--line-2); justify-content: flex-end; flex-wrap: wrap; align-items: center; }
.modal-foot .grow { flex: 1; }
@media (max-width: 720px) {
  dialog.modal, dialog.modal.small, dialog.modal.wide { width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; border-radius: 0; border: 0; margin: 0; }
  dialog.modal.small { height: auto; max-height: 100dvh; margin: auto 0 0; border-radius: 14px 14px 0 0; }
  .modal-foot { padding-bottom: calc(10px + env(safe-area-inset-bottom)); }
  .modal-head { flex-wrap: wrap; row-gap: 2px; }
  .modal-head .costs { order: 3; flex-basis: 100%; font-size: 12px; }
}

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px 14px; }
.section { margin-top: 16px; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.section > h3 { margin: 0; padding: 8px 12px; font-size: 13px; background: var(--panel-2); border-bottom: 1px solid var(--line-2); display: flex; align-items: center; gap: 8px; }
.section > h3 .spacer { flex: 1; }
.section-body { padding: 8px 12px; }
.banner { margin: 0 0 12px; padding: 10px 12px; border-radius: var(--radius-sm); border: 1px solid; font-size: 13px; white-space: pre-wrap; }
.banner.info { background: var(--accent-soft); border-color: var(--sel-line); }
.banner.warn { background: color-mix(in srgb, var(--warn) 12%, var(--panel)); border-color: color-mix(in srgb, var(--warn) 45%, var(--panel)); }

/* adders: a nested checklist with points, as Hero Designer lists them */
.adder { display: flex; align-items: center; gap: 8px; padding: 5px 0; flex-wrap: wrap; }
.adder .name { flex: 1; min-width: 160px; color: var(--ink); }
.adder .pts { color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.adder .extra { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.adder .extra select { width: auto; max-width: 260px; }
.adder .extra input[type='number'] { width: 76px; }
.adder-children { padding-left: 24px; border-left: 2px solid var(--line-2); margin-left: 7px; }
.custom-adder { display: grid; grid-template-columns: auto minmax(0, 1fr) 90px auto; gap: 8px; align-items: center; padding: 5px 0; }

/* modifiers: one row each, as in Hero Designer's Modifiers panel */
.mod { border-bottom: 1px solid var(--line-2); padding: 8px 0; }
.mod:last-child { border-bottom: 0; }
.mod-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.mod-line .name { flex: 1; min-width: 150px; font-weight: 600; }
.mod-line .val { font-variant-numeric: tabular-nums; color: var(--ink-2); min-width: 44px; text-align: right; }
.mod-line select { width: auto; max-width: 300px; }
.mod-line .lv { width: 76px; }
.mod-more { padding: 6px 0 0 4px; }
.mod-group-title { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; margin: 8px 0 0; }
.tag { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 999px; background: var(--panel-2); border: 1px solid var(--line); color: var(--muted); font-weight: 600; }

/* the Add Modifier picker (Hero Designer's tabs down the side) */
.picker { display: grid; grid-template-columns: 210px minmax(0, 1fr); gap: 0; min-height: 360px; }
.picker-tabs { display: flex; flex-direction: column; gap: 2px; padding: 8px; border-right: 1px solid var(--line-2); background: var(--panel-2); }
.picker-tabs button { justify-content: flex-start; border: 0; background: transparent; }
.picker-tabs button.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.picker-list { padding: 8px; overflow: auto; }
.picker-list .tree-item .reason { display: none; }
.picker-detail { padding: 10px 12px; border-top: 1px solid var(--line-2); background: var(--panel-2); display: flex; flex-direction: column; gap: 8px; }
@media (max-width: 720px) {
  .picker { grid-template-columns: minmax(0, 1fr); }
  .picker-tabs { flex-direction: row; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line-2); }
  .picker-tabs button { flex: none; }
}

/* the characteristics grid (Value with steppers, Char, Base, Cost, Total, Roll, Notes) */
.chars { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.chars th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); padding: 8px 10px; background: var(--panel-2); border-bottom: 1px solid var(--line); }
.chars td { padding: 6px 10px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.chars tr:last-child td { border-bottom: 0; }
.chars .char { font-weight: 700; }
.chars .stepper input { width: 56px; }
.chars-foot { margin-top: 10px; color: var(--ink-2); }
@media (max-width: 720px) {
  .chars .c-base, .chars .c-notes { display: none; }
  .chars td, .chars th { padding: 6px 6px; }
  .chars .stepper button { padding: 0 8px; }
  .chars .stepper input { width: 46px; }
}
.char-note { display: none; font-size: 12px; color: var(--muted); }
@media (max-width: 720px) { .char-note { display: block; } }

/* Basic Info and Background */
.sheet { max-width: 980px; margin: 0 auto; display: grid; gap: 14px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; }
.card h2 { margin: 0 0 12px; font-size: 15px; }

.toast { position: fixed; left: 50%; bottom: 20px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none; z-index: 100; padding: 10px 16px; border-radius: 999px; background: var(--ink); color: var(--panel); box-shadow: var(--shadow-lg); transition: 0.18s; max-width: calc(100vw - 32px); text-align: center; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.bad { background: var(--bad); color: #fff; }
@media (max-width: 959px) { .toast { bottom: 84px; } }

table.plain { width: 100%; border-collapse: collapse; }
table.plain th, table.plain td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line-2); }
table.plain th { font-size: 11px; text-transform: uppercase; color: var(--muted); letter-spacing: 0.04em; }
table.plain tr.group td { font-weight: 700; background: var(--panel-2); }

/* ---- the suite's app switch (Designer / Combat) ---- */
.apps { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; padding: 2px; background: var(--panel-2); flex: none; }
.apps button { border: 0; border-radius: 999px; min-height: 28px; padding: 3px 12px; background: transparent; color: var(--ink-2); }
.apps button.on { background: var(--panel); color: var(--accent); font-weight: 600; box-shadow: var(--shadow); }
body[data-app='combat'] #undoBtn, body[data-app='combat'] #redoBtn, body[data-app='combat'] #fileMenu, body[data-app='combat'] #sheetMenu, body[data-app='combat'] #charMenu, body[data-app='combat'] .tabs, body[data-app='combat'] .points { display: none; }
body[data-app='combat'] .apps { margin-left: auto; }

/* ---- Combat: Combat Core's GM console (fight board first; specs 01-08) ---- */
.combat { display: grid; gap: 14px; max-width: 1400px; margin: 0 auto; }
.combat .card, .combat .strip { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px 14px; min-width: 0; }
.combat h2 { font-size: 14px; margin: 0 0 10px; }
.combat h2.mt { margin-top: 18px; }
.combat .small { font-size: 12.5px; }
.fight-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.fight-title { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; min-width: 0; }
.fight-title h1 { font-size: 20px; margin: 0; }
.fight-actions { display: flex; gap: 6px; margin-left: auto; align-items: center; }
.combat-cols { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 14px; align-items: start; }
.tag { display: inline-block; font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 999px; margin-left: 6px; vertical-align: 1px; }
.tag.ok { background: color-mix(in srgb, var(--ok) 16%, transparent); color: var(--ok); }
.tag.bad { background: color-mix(in srgb, var(--bad) 16%, transparent); color: var(--bad); }
.hscroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.now-next { display: flex; gap: 8px 22px; flex-wrap: wrap; margin-bottom: 8px; }
.speedchart { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
.speedchart th, .speedchart td { border-bottom: 1px solid var(--line-2); padding: 4px 6px; text-align: center; }
.speedchart .who { text-align: left; white-space: nowrap; }
.speedchart th.sc { cursor: pointer; color: var(--muted); font-weight: 600; min-width: 28px; }
.speedchart th.sc:hover { color: var(--accent); }
.speedchart .cur { background: var(--accent-soft); }
.speedchart th.cur { color: var(--accent); }
.speedchart td.acts { color: var(--accent); font-weight: 700; }
.board-wrap { overflow-x: auto; }
.board { border-collapse: collapse; width: 100%; }
.board th { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; text-align: left; padding: 6px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.board td { padding: 5px 6px; border-bottom: 1px solid var(--line-2); white-space: nowrap; vertical-align: middle; }
.board .brow { cursor: pointer; }
.board .brow:hover { background: var(--panel-2); }
.board .brow.hurt { background: color-mix(in srgb, var(--warn) 14%, transparent); }
.board .brow.down { background: color-mix(in srgb, var(--bad) 16%, transparent); }
.board .brow.ko { opacity: 0.55; }
.board .brow.sel { box-shadow: inset 3px 0 0 var(--accent); }
.board .brow.sel:not(.hurt):not(.down) { background: var(--sel); }
.board .who .nm { font-weight: 600; }
.board input.cell { width: 52px; min-height: 30px; padding: 3px 6px; text-align: right; font-variant-numeric: tabular-nums; }
.board .mx { color: var(--muted); margin-left: 2px; font-variant-numeric: tabular-nums; }
.board td.acts button + button { margin-left: 4px; }
.board td.conds button + button { margin-left: 3px; }
.cond { min-height: 28px; min-width: 32px; padding: 2px 6px; font-size: 12px; font-weight: 700; color: var(--muted); }
.cond.on { background: var(--warn); border-color: var(--warn); color: #1d1500; }
.detail-head { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 6px; }
.detail-head h2 { margin: 0; }
.detail-head .spacer { flex: 1; }
.note-box { background: var(--accent-soft); border-radius: var(--radius-sm); padding: 8px 10px; font-size: 12.5px; margin: 0 0 10px; color: var(--ink-2); }
.dup { display: flex; align-items: end; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.dup input { width: 72px; }
.dup .muted { font-size: 12.5px; padding-bottom: 7px; }
.combat table.plain, .modal table.plain { width: 100%; border-collapse: collapse; margin-bottom: 10px; }
.combat table.plain caption, .modal table.plain caption { text-align: left; font-weight: 700; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; padding: 4px 0; }
.combat table.plain th { padding: 4px 6px; border-bottom: 1px solid var(--line); }
.combat table.plain td { padding: 5px 6px; vertical-align: top; }
.combat table.plain th.num, .combat table.plain td.num, .modal table.plain th.num, .modal table.plain td.num { text-align: right; }
.combat table.plain tr.total td, .modal table.plain tr.total td { border-top: 1px solid var(--line); }
.combat .mods, .modal .mods { color: var(--ink-2); font-size: 12.5px; }
.combat .stat { max-width: 440px; }
.def-notes { margin: -4px 0 10px; padding-left: 18px; font-size: 12.5px; color: var(--ink-2); }
.combat-luck { background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 6px 10px; font-size: 12.5px; margin: -4px 0 10px; }
.fws { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 8px 12px; margin-bottom: 12px; }
.form-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: end; margin-bottom: 10px; }
.form-row .field { min-width: 0; }
.form-row .field input[type='number'] { width: 90px; }
.form-row .field.grow { flex: 1; min-width: 160px; }
.form-row.checks { align-items: center; gap: 10px 18px; }
.form-row .lvl input { width: 64px; }
.form-row.apply-row { margin-top: 10px; align-items: center; }
.combat .prose, .modal .prose { background: var(--panel-2); border: 1px solid var(--line-2); border-radius: var(--radius-sm); padding: 8px 10px; font-size: 13px; line-height: 1.55; }
.log { display: grid; gap: 4px; font-size: 13px; max-height: 320px; overflow: auto; }
.pick-list { display: grid; gap: 2px; }
.pick-group { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); padding: 10px 6px 2px; }
.pick { display: flex; align-items: center; gap: 8px; border-radius: var(--radius-sm); }
.pick.on { background: var(--sel); }
.pick-name { flex: 1; justify-content: flex-start; text-align: left; white-space: normal; min-height: 36px; }
.stepper.small button { min-height: 28px; padding: 0 9px; }
.stepper.small .n { min-width: 28px; text-align: center; align-self: center; font-weight: 700; }
@media (max-width: 1099px) {
  .combat-cols { grid-template-columns: minmax(0, 1fr); }
  .wide-only { display: none; }
  .board input.cell { width: 46px; }
}
@media (max-width: 720px) {
  .apps button { padding: 3px 10px; }
  .combat { gap: 10px; }
  .combat .card, .combat .strip { padding: 10px; }
  .fight-actions { margin-left: 0; width: 100%; }
  .fight-actions .primary { flex: 1; }
  /* the board becomes one card per combatant */
  .board thead { display: none; }
  .board, .board tbody { display: block; }
  .board .brow { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 10px; padding: 10px 8px; border-bottom: 1px solid var(--line); }
  .board td { display: flex; align-items: center; gap: 2px; border: 0; padding: 0; white-space: normal; }
  .board td[data-l]::before { content: attr(data-l); font-size: 11px; font-weight: 700; color: var(--muted); min-width: 40px; }
  .board td.who { grid-column: 1 / -1; font-size: 15px; }
  .board td.acts, .board td.conds { grid-column: 1 / -1; }
  .board td.acts button { flex: 1; }
  .board td.conds { justify-content: flex-end; }
  .board input.cell { width: 46px; }
}

/* ---- the rules drawer (HeroBot) ---- */
.rules-drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(440px, 100vw); z-index: 60; background: var(--panel); border-left: 1px solid var(--line); box-shadow: var(--shadow-lg); display: flex; flex-direction: column; transform: translateX(105%); transition: transform 0.18s; }
.rules-drawer.open { transform: none; }
.rules-head { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--line-2); }
.rules-head h2 { margin: 0; font-size: 16px; }
.rules-head .spacer { flex: 1; }
.rules-tabs { display: flex; gap: 2px; padding: 0 10px; border-bottom: 1px solid var(--line-2); }
.rules-tabs button { border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: transparent; min-height: 40px; }
.rules-tabs button.on { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.rules-body { flex: 1; overflow: auto; padding: 12px 14px; display: grid; gap: 10px; align-content: start; }
.table-picks { display: flex; flex-wrap: wrap; gap: 6px; }
.table-picks button { min-height: 28px; padding: 3px 10px; border-radius: 999px; font-size: 12.5px; }
.table-picks button.on { border-color: var(--accent); color: var(--accent); font-weight: 600; }
.ref h2 { margin: 2px 0 8px; font-size: 16px; }
.ref h3 { margin: 12px 0 4px; font-size: 13px; color: var(--accent); }
.ref ul { margin: 4px 0 8px; padding-left: 18px; }
.ref-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.ref-table th { text-align: left; font-weight: 600; border-bottom: 1px solid var(--line); padding: 4px 6px; vertical-align: bottom; }
.ref-table td { border-bottom: 1px solid var(--line-2); padding: 4px 6px; vertical-align: top; }
.ref-table tbody tr:nth-child(even) td { background: var(--panel-2); }
.rules-search { display: flex; gap: 6px; }
.passage { border: 1px solid var(--line-2); border-radius: var(--radius-sm); padding: 8px 10px; }
.passage-head { padding: 0; min-height: 0; gap: 8px; justify-content: flex-start; white-space: normal; text-align: left; }
.passage .book { font-size: 11px; font-weight: 700; color: var(--accent); }
.passage .heading { font-weight: 600; }
.passage .path { font-size: 11.5px; margin: 2px 0 6px; }
.passage-text { white-space: pre-wrap; font-size: 13px; line-height: 1.5; max-height: 7.5em; overflow: hidden; }
.passage.open .passage-text { max-height: none; }
.passage-foot { display: flex; gap: 6px; margin-top: 6px; }
button.small { min-height: 26px; padding: 2px 8px; font-size: 12.5px; }
.ctx { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.ctx-chip { display: inline-flex; align-items: center; gap: 2px; padding: 2px 4px 2px 10px; border-radius: 999px; background: var(--accent-soft); font-size: 12.5px; }
.ctx-chip button { min-height: 22px; padding: 0 4px; }
.answer { font-size: 13.5px; line-height: 1.55; }
.answer p { margin: 0 0 8px; }
.answer .bad, .rules-body .bad { color: var(--bad); }
.ruling { border-bottom: 1px solid var(--line-2); padding-bottom: 10px; }
.ruling h3 { font-size: 14px; margin: 0 0 4px; }
.rules-body .small { font-size: 12.5px; }
.rules-body .note-box { background: var(--accent-soft); border-radius: var(--radius-sm); padding: 8px 10px; font-size: 12.5px; }
.rules-tabs .count { font-size: 11px; color: var(--muted); }

/* Save: a dot while there are unsaved changes */
#saveBtn.dirty { border-color: var(--accent); color: var(--accent); font-weight: 600; }
#saveBtn.dirty::after { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
body[data-app='combat'] #saveBtn { display: none; }

/* Save | ▾ : a split button (the arrow opens Save / Save as…) */
.menu.split { display: inline-flex; }
.menu.split > #saveBtn { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.menu.split > #saveCaret { border-top-left-radius: 0; border-bottom-left-radius: 0; border-left: 0; padding: 5px 7px; min-width: 0; }
body[data-app='combat'] #saveMenu { display: none; }

/* Combat: a framework in full (every slot, Hero Designer's line, the active slot) */
.fw-card { border: 1px solid var(--line); border-radius: var(--radius-sm); margin: 0 0 12px; overflow: hidden; }
.fw-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; padding: 7px 10px; background: var(--panel-2); border-bottom: 1px solid var(--line-2); }
.fw-kind { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--accent); }
.fw-title { flex: 1; min-width: 0; font-weight: 600; }
.fw-head .check.small { font-size: 12.5px; color: var(--muted); }
.combat table.slots { margin: 0; }
.combat table.slots td { vertical-align: top; }
.combat table.slots td.pick { width: 28px; padding-top: 8px; }
.combat table.slots tr.on td { background: var(--accent-soft); }
.combat table.slots .slot-text { font-size: 12.5px; color: var(--ink-2); margin-top: 2px; }
.combat table.slots td.num { white-space: nowrap; color: var(--ink-2); font-size: 12.5px; }
.combat table.slots td.acts { white-space: nowrap; text-align: right; }

.combat table.slots tr.slot-row { cursor: pointer; }
.combat table.slots tr.slot-row:hover td { background: var(--panel-2); }
.combat table.slots tr.slot-row.on:hover td { background: var(--accent-soft); }

/* ---- Build (HeroBot) ---- */
.tabs button.build-tab { color: var(--accent); font-weight: 600; margin-left: 6px; border-bottom-color: transparent; display: inline-flex; align-items: center; gap: 2px; }
.tabs button.build-tab:hover { background: color-mix(in srgb, var(--accent) 10%, transparent); }
.build-btn { background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 60%, #b54bff)); color: #fff; border: 0; font-weight: 600; padding: 10px 18px; display: inline-flex; align-items: center; gap: 6px; }
.build-btn:hover { filter: brightness(1.08); }
.empty-state .build-actions { margin-top: 22px; }
.empty-state .build-hint { font-size: 13px; color: var(--muted); margin-top: 8px; }
dialog.modal.build { width: min(640px, calc(100vw - 32px)); }
.build-lead { margin: 0 0 10px; color: var(--ink-2); }
.build-ask { width: 100%; box-sizing: border-box; resize: vertical; font: inherit; padding: 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg, var(--panel)); color: var(--ink); }
.build-run { margin-top: 12px; }
.build-state { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.build-time { color: var(--muted); font-size: 12px; margin-left: auto; }
.build-bad { color: var(--bad, #c0392b); }
.build-log { margin: 10px 0 0; padding: 8px 10px 8px 24px; list-style: disc; max-height: 260px; overflow-y: auto; font-size: 12.5px; background: color-mix(in srgb, var(--ink) 4%, transparent); border-radius: 8px; color: var(--ink-2); }
.build-log li { margin: 2px 0; }
.build-log li.step { color: var(--accent); font-weight: 600; list-style: none; margin-left: -14px; }
.build-log li.problem { color: var(--bad, #c0392b); }
.build-summary { margin-top: 12px; white-space: pre-wrap; padding: 10px 12px; border-left: 3px solid var(--accent); background: color-mix(in srgb, var(--accent) 7%, transparent); border-radius: 0 8px 8px 0; font-size: 14px; }
.build-note { margin-right: auto; font-size: 12px; color: var(--muted); }
.spinner { width: 14px; height: 14px; border: 2px solid color-mix(in srgb, var(--accent) 25%, transparent); border-top-color: var(--accent); border-radius: 50%; animation: build-spin 0.8s linear infinite; display: inline-block; }
@keyframes build-spin { to { transform: rotate(360deg); } }

[hidden] { display: none !important; }

/* ---- HeroHelper Hosting: sign-in pages (account.html) and the admin page (admin.html) ---- */
.account-page { min-height: 100vh; display: flex; align-items: flex-start; justify-content: center; padding: 10vh 16px 32px; box-sizing: border-box; }
.account-card { width: 100%; max-width: 380px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px 22px 18px; }
.account-card h1 { font-size: 20px; margin: 0 0 4px; letter-spacing: -0.01em; }
.account-card p { margin: 0 0 14px; color: var(--ink-2); }
.account-card form { display: grid; gap: 12px; }
.account-card label { display: grid; gap: 4px; font-weight: 600; font-size: 13px; color: var(--ink-2); }
.account-card input[type='email'], .account-card input[type='password'], .admin-page input[type='email'] { min-height: 36px; padding: 6px 10px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--panel); width: 100%; box-sizing: border-box; font-weight: 400; color: var(--ink); }
.account-card button.primary { min-height: 38px; justify-content: center; }
.form-error { color: var(--bad); font-size: 13px; min-height: 1em; margin: 0; }
.form-ok { color: var(--ok); font-size: 13px; margin: 0; }
.admin-page { max-width: 980px; margin: 0 auto; padding: 18px 16px 40px; }
.admin-page h1 { font-size: 20px; margin: 0; }
.admin-page h2 { font-size: 15px; margin: 26px 0 8px; }
.admin-page .panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; overflow-x: auto; }
.admin-page table { width: 100%; border-collapse: collapse; font-size: 13px; }
.admin-page th, .admin-page td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line-2); vertical-align: top; }
.admin-page th { color: var(--muted); font-weight: 600; font-size: 12px; }
.admin-page .invite-form { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; }
.admin-page .invite-form label { display: grid; gap: 4px; font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.admin-page .link-box { margin-top: 12px; padding: 10px; border-radius: var(--radius-sm); background: var(--accent-soft); word-break: break-all; font-family: var(--mono); font-size: 12.5px; }
.admin-page .tag { display: inline-block; padding: 1px 7px; border-radius: 999px; font-size: 11.5px; background: var(--panel-2); border: 1px solid var(--line-2); color: var(--ink-2); }
.admin-page .tag.open { color: var(--ok); }
.admin-page .tag.off { color: var(--bad); }
