/* SuperStacker — themes, four layouts (workbench / table / rails / phone). No external fonts or icons (LAN-friendly).
   Colors only ever come from the tokens below, so every theme recolors the whole app. */

/* ============================================================ themes */
/* Base tokens per theme. Parchment doubles as the fallback before theme.js has run. */
:root,
:root[data-theme="parchment"] {
  --bg: #f3eee3; --bar: #e9e1cf; --bar2: #f5f0e6; --surface: #fdfaf4; --surface2: #e5dcc8;
  --line: #d9cfba; --text: #2a241f; --strong: #1a1512; --muted: #6b5f50;
  --primary: #9e3b2c; --on-primary: #ffffff; --accent-text: #9e3b2c;
  --good: #2f7d4f; --partial: #a85c0c; --bad: #b3261e;
  --panel: #f8f4ec; --field: #f5f0e6; --btn: #efe8da; --line-2: #c6b89d; --text-2: #4a4037;
  --shadow-c: 70, 45, 20;
  color-scheme: light;
}
:root[data-theme="night"] {
  --bg: #1a1512; --bar: #221b16; --bar2: #1e1814; --surface: #28201a; --surface2: #3a2e25;
  --line: #45372c; --text: #f1e8d8; --strong: #fbf5ea; --muted: #b3a28c;
  --primary: #e07a62; --on-primary: #1f0d08; --accent-text: #e8876f;
  --good: #7fc495; --partial: #e9b25a; --bad: #ff8a7a;
  --panel: #231c17; --field: #211a15; --btn: #33291f; --line-2: #5a4838; --text-2: #d9ccb8;
  --shadow-c: 0, 0, 0;
  color-scheme: dark;
}
:root[data-theme="ember"] {
  --bg: #12100e; --bar: #1a1714; --bar2: #16130f; --surface: #211c17; --surface2: #2c251e;
  --line: #3b3229; --text: #f2ebe1; --strong: #fff8ee; --muted: #a99a87;
  --primary: #e3a64b; --on-primary: #1d1206; --accent-text: #e8b45f;
  --good: #7cc58a; --partial: #ef7f55; --bad: #ff8a7a;
  --shadow-c: 0, 0, 0;
  color-scheme: dark;
}
:root[data-theme="verdigris"] {
  --bg: #0c1513; --bar: #101c19; --bar2: #0e1916; --surface: #15241f; --surface2: #1c302a;
  --line: #28423a; --text: #e4f0ec; --strong: #ffffff; --muted: #8fb1a6;
  --primary: #3ec9a0; --on-primary: #04201a; --accent-text: #52d4ad;
  --good: #b4dc6e; --partial: #f0b44c; --bad: #ff8a7a;
  --shadow-c: 0, 0, 0;
  color-scheme: dark;
}
:root[data-theme="imperial"] {
  --bg: #120e19; --bar: #181223; --bar2: #150f1e; --surface: #1f172c; --surface2: #2a203b;
  --line: #3b2f54; --text: #efe9f7; --strong: #ffffff; --muted: #ab9ec3;
  --primary: #d8b25a; --on-primary: #1e1606; --accent-text: #dfbd6c;
  --good: #6fcf97; --partial: #f08a5d; --bad: #ff8a8a;
  --shadow-c: 0, 0, 0;
  color-scheme: dark;
}
:root[data-theme="signal"] {
  --bg: #111213; --bar: #17181a; --bar2: #141517; --surface: #1d1e21; --surface2: #26282c;
  --line: #35383d; --text: #ececec; --strong: #ffffff; --muted: #9ca0a8;
  --primary: #c4ec5c; --on-primary: #192106; --accent-text: #c4ec5c;
  --good: #4fd1c5; --partial: #f5a742; --bad: #ff7b7b;
  --shadow-c: 0, 0, 0;
  color-scheme: dark;
}
:root[data-theme="navy"] {
  --bg: #0b1426; --bar: #0d1830; --bar2: #0f1b33; --surface: #14223e; --surface2: #1d3b6b;
  --line: #23365c; --text: #e6edf7; --strong: #ffffff; --muted: #8fa2c2;
  --primary: #2565c0; --on-primary: #ffffff; --accent-text: #5aa9ff;
  --good: #3ccf91; --partial: #f2b84b; --bad: #ff6b6b;
  --shadow-c: 0, 0, 0;
  color-scheme: dark;
}

/* Everything the other themes don't spell out is derived from their base tokens. */
:root[data-theme="ember"], :root[data-theme="verdigris"], :root[data-theme="imperial"],
:root[data-theme="signal"], :root[data-theme="navy"] {
  --panel: color-mix(in srgb, var(--surface) 60%, var(--bg));
  --field: color-mix(in srgb, var(--surface) 35%, var(--bg));
  --btn: color-mix(in srgb, var(--surface2) 70%, var(--surface));
  --line-2: color-mix(in srgb, var(--line) 70%, var(--muted));
  --text-2: color-mix(in srgb, var(--text) 85%, var(--muted));
}

:root {
  --good-bg: color-mix(in srgb, var(--good) 16%, transparent);
  --partial-bg: color-mix(in srgb, var(--partial) 16%, transparent);
  --bad-bg: color-mix(in srgb, var(--bad) 12%, transparent);
  --stale-ring: color-mix(in srgb, var(--partial) 40%, transparent);
  /* aliases used by the account and users screens */
  --card: var(--surface); --card-2: var(--btn); --bg-2: var(--field);
  --accent: var(--accent-text); --warn: var(--partial);
  --radius: 10px; --radius-sm: 6px;
  --shadow: 0 12px 32px rgba(var(--shadow-c), .25);
  --font: system-ui, -apple-system, "Segoe UI", "Helvetica Neue", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

/* ============================================================ base */
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 13px/1.35 var(--font);
  min-height: 100vh;
}
h1, h2, h3 { margin: 0; font-weight: 650; }
h2 { font-size: 15px; }
h3 { font-size: 13px; }
small { color: var(--muted); font-weight: 400; }
a { color: var(--accent-text); }
a:hover { filter: brightness(.85); }
.muted { color: var(--muted); }
.hint { margin: .35rem 0 .5rem; color: var(--muted); font-size: 12px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: -999px; top: 0; background: var(--primary); color: var(--on-primary); padding: .4rem .8rem; z-index: 100; }
.skip-link:focus { left: .5rem; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
[hidden] { display: none !important; }
.long { display: inline; }
.short { display: none; }
svg.chev { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 2; flex: none; }

/* ============================================================ controls */
.btn {
  background: var(--btn); color: var(--text); border: 1px solid var(--line-2);
  border-radius: var(--radius-sm); height: 30px; padding: 0 12px; font: inherit; cursor: pointer;
  white-space: nowrap; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.btn:hover:not(:disabled) { border-color: var(--primary); }
.btn:disabled { opacity: .45; cursor: default; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); font-weight: 600; }
.btn-primary:hover:not(:disabled) { filter: brightness(1.08); border-color: var(--primary); }
.btn-primary.stale { box-shadow: 0 0 0 3px var(--stale-ring); }
.btn-danger:hover:not(:disabled) { border-color: var(--bad); color: var(--bad); }
.btn-icon { padding: 0; width: 30px; }
.btn-icon .btn-label { display: none; }
.btn-menu svg { flex: none; }
a.btn { text-decoration: none; }
a.btn[aria-current] { background: var(--surface); border-color: var(--primary); color: var(--accent-text); font-weight: 600; }
.link-btn { background: none; border: 0; color: var(--accent-text); font: inherit; font-size: 11.5px; cursor: pointer; padding: 4px; }
.link-btn:hover { text-decoration: underline; }

input[type="text"], input[type="password"], input[type="search"], select {
  background: var(--field); color: var(--text); border: 1px solid var(--line-2);
  border-radius: 5px; padding: 4px 7px; font: inherit; width: 100%;
}
input.num { font-family: var(--mono); font-size: 12px; text-align: right; }
input[type="text"]:focus, input[type="password"]:focus, input[type="search"]:focus, select:focus { border-color: var(--primary); outline: none; box-shadow: 0 0 0 1px var(--primary); }
input.invalid { border-color: var(--bad); }
input[type="checkbox"], input[type="radio"] { accent-color: var(--primary); }
.field-error { color: var(--bad); font-size: 11px; min-height: 0; }

.switch { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); cursor: pointer; user-select: none; font-size: 12px; }
.switch input { margin: 0; }

.segmented { display: inline-flex; flex-wrap: nowrap; border: 1px solid var(--line-2); border-radius: var(--radius-sm); overflow: hidden; }
.segmented .seg {
  background: var(--field); color: var(--muted); border: 0; border-right: 1px solid var(--line-2);
  padding: 3px 10px; font: inherit; font-size: 12px; cursor: pointer;
}
.segmented .seg:last-of-type { border-right: 0; }
.segmented .seg[aria-pressed="true"] { background: var(--primary); color: var(--on-primary); font-weight: 600; }
.segmented.wrap { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); width: 100%; }
.segmented.wrap .seg { border-bottom: 1px solid var(--line-2); padding: 5px 0; }
.segmented.wrap .seg:nth-child(5n) { border-right: 0; }
.segmented.wrap .seg:nth-last-child(-n+5) { border-bottom: 0; }
.seg-note { align-self: center; padding: 0 .6rem; color: var(--partial); font-size: 11px; }
.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; border: 1px solid var(--line-2); font-size: 11px; color: var(--muted); white-space: nowrap; }

.menu { position: relative; }
.menu-list { position: absolute; right: 0; top: calc(100% + 4px); background: var(--surface); border: 1px solid var(--line-2); border-radius: 8px; box-shadow: var(--shadow); z-index: 40; min-width: 12rem; padding: 4px 0; }
.menu-list button { display: block; width: 100%; text-align: left; background: none; border: 0; color: var(--text); padding: .5rem .85rem; font: inherit; cursor: pointer; }
.menu-list button:hover, .menu-list button:focus-visible { background: var(--primary); color: var(--on-primary); outline: none; }
.menu-list button:disabled { opacity: .4; cursor: default; background: none; color: var(--text); }
.menu-list button.danger:hover:not(:disabled) { background: var(--bad); color: #fff; }
.menu-sep { border: 0; border-top: 1px solid var(--line); margin: 4px 0; }

.banner { margin: .75rem 1rem 0; padding: .6rem .9rem; border-radius: var(--radius-sm); background: var(--bad-bg); border: 1px solid var(--bad); color: var(--text); }
.banner.info { background: var(--partial-bg); border-color: var(--line-2); }

/* ============================================================ header & presets */
.app-header {
  display: flex; align-items: center; gap: 14px; padding: 8px 16px; flex-wrap: wrap;
  background: var(--bar); border-bottom: 1px solid var(--line); position: relative; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 8px; }
.brand-mark { width: 24px; height: 24px; fill: var(--surface2); stroke: var(--primary); stroke-width: 2; stroke-linejoin: round; flex: none; }
.brand-name { font-size: 15px; font-weight: 700; letter-spacing: .02em; }
.header-actions { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.calc-actions, .user-actions { display: flex; align-items: center; gap: 10px; }
.user-actions { gap: 6px; }
.calc-status { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; white-space: nowrap; min-width: 5.5rem; justify-content: flex-end; }
.calc-status:empty { display: none; }
.calc-status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--good); flex: none; }
.calc-status.stale { color: var(--partial); }
.calc-status.stale::before { background: var(--partial); }
.calc-status.busy::before { width: 10px; height: 10px; background: none; border: 2px solid var(--primary); border-right-color: transparent; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.calc-icon { display: none; }
#calculateBtn { padding: 0 14px; }

.preset-bar { display: flex; align-items: center; gap: 4px; flex: 1 1 380px; min-width: 0; }
.preset-tabs { display: flex; align-items: center; gap: 4px; min-width: 0; overflow-x: auto; scrollbar-width: thin; }
.preset-tab {
  flex: none; background: var(--surface); border: 1px solid var(--line); color: var(--text-2); border-radius: 6px;
  height: 28px; padding: 0 12px; cursor: pointer; font: inherit; font-size: 12.5px; max-width: 16rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.preset-tab:hover { border-color: var(--line-2); }
.preset-tab[aria-selected="true"] { background: var(--primary); border-color: var(--primary); color: var(--on-primary); font-weight: 600; }
.preset-tab.drag-over { outline: 2px dashed var(--primary); }
.preset-bar > .btn-icon { background: none; border-style: dashed; color: var(--muted); height: 28px; width: 28px; }
.btn-menu { height: 28px; padding: 0 8px; font-size: 12px; background: none; color: var(--muted); }
.preset-pick { display: none; align-items: center; gap: 8px; }
.preset-pick label { color: var(--muted); font-size: 12px; }
.preset-pick select { height: 30px; min-width: 180px; width: auto; font-weight: 600; background: var(--surface); }

/* ============================================================ sections (input groups) */
.sec { min-width: 0; }
.sec-head { margin: 0; font-size: inherit; font-weight: inherit; }
.sec-toggle {
  display: flex; align-items: center; gap: 8px; width: 100%; background: none; border: 0; color: inherit;
  font: inherit; text-align: left; padding: 0; cursor: default;
}
.sec-title { font-weight: 650; }
.sec-title small { font-weight: 400; }
.sec-sum { display: none; font-family: var(--mono); color: var(--muted); }
.sec .chev { display: none; }

/* tables of bonuses */
.bonus-table { width: 100%; border-collapse: separate; border-spacing: 0 3px; }
.bonus-table th { text-align: left; font-weight: 400; color: var(--text-2); padding: 0 6px 0 0; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 9rem; }
.bonus-table thead th { font-size: 10px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); text-align: right; }
.bonus-table thead th:first-child { text-align: left; }
.bonus-table td { padding: 0 0 0 6px; width: 84px; }
.bonus-table td.na, .bonus-table .na-dash { text-align: center; color: var(--line-2); }
.bonus-table .na-dash { display: block; }
/* Epic Monster tools feature flag (per user, set by the admin) */
body:not([data-epic-tools="on"]) .epic-only, body[data-epic-tools="on"] .epic-off { display: none; }
.sec-boost .segmented { margin: 0 0 4px; }
.sec-boost .segmented .seg { padding: 2px 9px; font-size: 11px; }

/* tiers */
.quick-pick { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; font-size: 11px; }
.quick-pick-buttons { display: flex; gap: 4px; flex-wrap: wrap; }
.quick-pick-buttons .btn { height: 24px; min-width: 28px; padding: 0 5px; font-size: 11.5px; background: var(--field); border-radius: 5px; }
.quick-pick-buttons .btn[aria-pressed="true"] { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.tier-selection { display: flex; flex-direction: column; gap: 6px; }
.tier-row { display: grid; grid-template-columns: 82px minmax(0, 1fr); align-items: center; gap: 6px; }
.tier-row .tier-label { color: var(--muted); font-size: 11.5px; }
.tier-chips { display: flex; flex-wrap: wrap; gap: 3px; }
.chip { position: relative; }
.chip input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; width: 100%; height: 100%; }
.chip span { display: inline-block; min-width: 30px; text-align: center; padding: 3px 4px; border: 1px solid var(--line-2); border-radius: 5px; background: var(--field); color: var(--muted); font-size: 11.5px; font-family: var(--mono); }
.chip input:checked + span { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.chip input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: 2px; }

/* kill order */
.order-block + .order-block { margin-top: 12px; }
.order-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.order-head h3 { font-size: 12px; }
.order-dies { display: none; font-size: 11px; color: var(--muted); }
.hint-touch { display: none; }
.order-hint { margin: 6px 0; }
.order-list { list-style: none; margin: 4px 0; padding: 0; display: flex; flex-direction: column; gap: 3px; }
.order-list.horizontal { flex-direction: row; flex-wrap: wrap; }
.order-item {
  display: flex; align-items: center; gap: 6px; background: var(--field); border: 1px solid var(--line-2);
  border-radius: 5px; padding: 2px 4px 2px 6px; cursor: grab; user-select: none; min-height: 28px;
}
.order-list.horizontal .order-item { flex: 1 1 7rem; justify-content: center; }
.order-item.dragging { opacity: .45; }
.order-item .handle { color: var(--muted); letter-spacing: -2px; font-size: 11px; }
.order-item .pos { font-family: var(--mono); color: var(--accent-text); min-width: 14px; text-align: right; font-size: 11.5px; }
.order-item .label { flex: 1; min-width: 0; }
.order-item .name { font-size: 12px; }
.order-item .code { display: none; font-family: var(--mono); font-size: 12px; }
.order-item .sub { display: none; }
.order-item .move { background: none; border: 1px solid transparent; color: var(--muted); border-radius: 4px; cursor: pointer; width: 22px; height: 22px; padding: 0; font: inherit; display: grid; place-items: center; }
.order-item .move svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 2; }
.order-item .move:hover:not(:disabled) { border-color: var(--line-2); color: var(--text); }
.order-item .move:disabled { opacity: .25; cursor: default; }
.order-list.horizontal .order-item .pos { display: inline; }

/* exclusions and attacks */
.excl-picker { margin: 4px 0; }
.tags { list-style: none; display: flex; flex-wrap: wrap; gap: 4px; margin: 8px 0 0; padding: 0; }
.tag { display: inline-flex; align-items: center; gap: 4px; background: var(--field); border: 1px solid var(--line-2); border-radius: 999px; padding: 1px 4px 1px 10px; font-size: 12px; }
.tag .tag-group { color: var(--muted); }
.tag button { background: none; border: 0; color: var(--muted); cursor: pointer; font: inherit; padding: 0 6px; border-radius: 999px; }
.tag button:hover { color: var(--bad); }

/* usage meters */
.usage-bar { flex: 1; height: 6px; min-width: 24px; background: var(--field); border: 1px solid var(--line); border-radius: 3px; overflow: hidden; }
.usage-bar span { display: block; height: 100%; width: 0; background: var(--good); transition: width .25s; }
.usage-bar span.over { background: var(--bad); }
.limits { display: flex; flex-direction: column; gap: 8px; }
.limit { display: grid; grid-template-columns: 6.2rem minmax(0, 1fr); gap: 3px 10px; align-items: center; }
.limit label { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; }
.limit-line { display: flex; align-items: center; gap: 8px; min-width: 0; }
.limit input.cap { width: 104px; flex: none; }
.limit .usage { flex: 1; display: flex; align-items: center; gap: 8px; min-width: 0; }
.usage-pct { font-family: var(--mono); font-size: 12px; min-width: 44px; text-align: right; }
.usage-text { grid-column: 2; font-family: var(--mono); font-size: 11px; color: var(--muted); }
.usage-text b { font-weight: 500; color: var(--text); }
.limit .field-error { grid-column: 2; }

.usage-panel { min-width: 0; }
.usage-title { font-size: 13px; margin-bottom: 8px; display: none; }
.usage-list { display: flex; gap: 8px 24px; flex-wrap: wrap; }
.usage-row { flex: 1 1 260px; display: flex; align-items: center; gap: 10px; min-width: 0; }
.u-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; min-width: 76px; }
.u-pct { display: none; font-family: var(--mono); font-size: 12px; font-weight: 700; }
.u-text { font-family: var(--mono); font-size: 12px; white-space: nowrap; }
.u-text b { font-weight: 700; }
.u-cap { color: var(--muted); }
.n-short { display: none; }

/* ============================================================ results: shared pieces */
.panel.results { min-width: 0; outline: none; }
.r-totals { display: none; }
.results-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.rt-left { display: flex; align-items: baseline; gap: 8px; }
.rt-right { display: flex; align-items: center; gap: 8px; }
.rt-hint { font-size: 11px; color: var(--muted); }
.show-excl { display: none; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; cursor: pointer; }
.show-excl input { margin: 0; }
.btn-copyall { height: 28px; padding: 0 10px; }
.r-tabs { display: none; }
.warnings { margin: 0 0 8px; padding: 6px 8px 6px 24px; border: 1px solid var(--partial); border-radius: var(--radius-sm); background: var(--partial-bg); color: var(--text); font-size: 12px; }
.empty-note { color: var(--muted); padding: 10px 0; }
/* Epic Monster attack: striking power and full-loss revive cost of one attack */
.epic-strip { display: grid; grid-template-columns: minmax(0, 1.4fr) repeat(2, minmax(0, 1fr)); gap: 8px; margin: 0 0 10px; }
.epic-strip[hidden] { display: none; }
.ep { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; min-width: 0; }
.ep-label { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.ep-tag { color: var(--accent-text); font-weight: 700; }
.ep-value { font-family: var(--mono); font-size: 18px; font-weight: 700; color: var(--strong); }
.ep-sub { font-size: 11px; color: var(--muted); font-family: var(--mono); overflow-wrap: anywhere; }
.ep-share { display: flex; height: 5px; border-radius: 3px; overflow: hidden; background: var(--surface2); margin: 3px 0 4px; }
.ep-share span { display: block; height: 100%; }
/* One hue at three strengths, always with a text label: sections are identified by name, not color. */
.epic-strip .s-army { background: var(--primary); }
.epic-strip .s-monsters { background: color-mix(in srgb, var(--primary) 58%, var(--surface)); }
.epic-strip .s-mercenaries { background: color-mix(in srgb, var(--primary) 34%, var(--muted)); }
.ep-share span + span { border-left: 2px solid var(--panel); }
.battle { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; margin: 0 0 10px; }
.battle[hidden] { display: none; }
.battle > summary { cursor: pointer; padding: 8px 12px; display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; list-style-position: inside; }
.b-title { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; font-weight: 700; }
.b-sum { font-family: var(--mono); font-size: 12px; color: var(--text); }
.b-body { padding: 0 12px 10px; }
.b-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
.b-note { font-size: 11px; color: var(--muted); flex: 1 1 260px; }
.b-chart { position: relative; }
.b-chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.b-chart .grid { stroke: var(--line); stroke-width: 1; }
.b-chart .axis-t { fill: var(--muted); font-family: var(--mono); font-size: 9px; }
.b-chart .bar { fill: var(--primary); pointer-events: none; }
.b-chart .hit { fill: transparent; cursor: default; }
.b-chart .hit:hover + .bar, .b-chart .bar.on { fill: color-mix(in srgb, var(--primary) 75%, var(--strong)); }
.b-chart .lbl { fill: var(--text); font-family: var(--mono); font-size: 10px; }
.b-tip { position: absolute; pointer-events: none; background: var(--surface); color: var(--text); border: 1px solid var(--line-2); border-radius: 6px; padding: 5px 8px; font-size: 11px; font-family: var(--mono); white-space: nowrap; box-shadow: 0 4px 12px rgba(var(--shadow-c), .18); z-index: 5; }
.b-tip b { color: var(--strong); }
.b-table { width: 100%; border-collapse: collapse; margin-top: 8px; font-size: 12px; }
@media (max-width: 560px) {
  .b-table .b-silver { display: none; }
  .b-table.b-table td.killed { min-width: 0; }
  .b-table.b-table th, .b-table.b-table td { padding: 5px 6px; }
}
.b-table td.killed { font-family: inherit; color: var(--text-2); white-space: normal; min-width: 180px; }
.b-table td.num { white-space: nowrap; }
.b-lead, .b-table .killed .lead { text-decoration: underline dotted; text-underline-offset: 3px; }
.b-table .killed s { text-decoration: line-through; color: var(--bad); }
.ep-key { display: inline-block; width: 7px; height: 7px; border-radius: 2px; margin-right: 3px; vertical-align: 0; }
@media (max-width: 560px) {
  .epic-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ep-strike { grid-column: 1 / -1; }
}
.footnote { font-size: 11px; margin: 12px 0 0; }
.fn { display: none; }
.view-table, .view-grid, .view-list { display: none; }
.col-headers { display: grid; grid-template-columns: 58px minmax(0, 1fr); gap: 6px; }
.col-headers .cols div { color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .08em; text-align: center; }
.sticky-cols { position: sticky; top: 0; z-index: 5; background: var(--panel); padding: 4px 0; }

/* view switches: only the container that matches the active view shows */
#results[data-view="cards"] .fn-cards, #results[data-view="table"] .fn-table, #results[data-view="grid"] .fn-grid { display: inline; }
#results[data-view="table"] .view-table, #results[data-view="grid"] .view-grid, #results[data-view="list"] .view-list { display: block; }
#results:not([data-view="cards"]) .result-section, #results:not([data-view="cards"]) .col-headers { display: none; }
#results[data-view="cards"][data-tab="army"] .result-section:not([data-section="army"]),
#results[data-view="cards"][data-tab="monsters"] .result-section:not([data-section="monsters"]),
#results[data-view="cards"][data-tab="mercs"] .result-section:not([data-section="mercs"]) { display: none; }
#results[data-tab="army"] [data-section-block]:not([data-section-block="army"]),
#results[data-tab="monsters"] [data-section-block]:not([data-section-block="monsters"]),
#results[data-tab="mercs"] [data-section-block]:not([data-section-block="mercs"]) { display: none; }

/* ------------------------------------------------------------ cards (workbench, phone) */
.result-section { margin-top: 10px; }
.result-section h3 { display: flex; align-items: baseline; gap: 10px; border-bottom: 1px solid var(--line); padding-bottom: 4px; margin-bottom: 6px; }
.section-total { color: var(--muted); font-weight: 400; font-size: 11px; font-family: var(--mono); }
.troop-grid { display: flex; flex-direction: column; gap: 6px; }
.tier-group { display: grid; grid-template-columns: 58px minmax(0, 1fr); gap: 6px; align-items: stretch; }
.tier-label { font-family: var(--mono); font-weight: 700; color: var(--accent-text); display: flex; flex-direction: column; justify-content: center; }
.tier-label .partial { font-family: var(--font); font-size: 10px; font-weight: 500; color: var(--partial); }
.tier-label .tier-name, .tier-label .tier-total { display: none; }
.cols { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.col { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.col:empty { display: none; }
.extra-row { grid-column: 2; display: flex; flex-wrap: wrap; gap: 6px; }
.extra-row .troop-card { flex: 0 1 calc(25% - 5px); min-width: 9rem; }

.troop-card {
  position: relative; background: var(--card); border: 1px solid var(--line); border-radius: 6px;
  padding: 5px 7px 6px; cursor: pointer; display: flex; flex-direction: column; gap: 1px; min-width: 0;
  transition: border-color .15s, opacity .15s, transform .15s;
}
.troop-card:hover { border-color: var(--line-2); }
.troop-card .t-cat { display: none; font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.troop-card .t-name { font-size: 11.5px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-right: 28px; }
.troop-card .t-line { display: flex; align-items: baseline; justify-content: space-between; gap: 4px; }
.troop-card .t-count { font-family: var(--mono); font-size: 16px; font-weight: 700; color: var(--strong); }
.troop-card .t-count small { font-size: 10px; color: var(--muted); font-weight: 400; }
.troop-card .t-hp { font-family: var(--mono); font-size: 10.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.troop-card .t-hp span + span::before { content: " · "; }
.troop-card .copy {
  position: absolute; top: 4px; right: 4px; width: 24px; height: 22px; display: grid; place-items: center; padding: 0;
  background: var(--field); border: 1px solid var(--line-2); color: var(--muted); border-radius: 4px; cursor: pointer;
}
.troop-card .copy svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.troop-card .copy:hover { color: var(--text); border-color: var(--primary); }
.troop-card.zero .t-count { color: var(--muted); }
.troop-card.ghost { opacity: .45; border-style: dashed; border-color: var(--line-2); }
.troop-card.ghost:hover { opacity: .75; }
.troop-card.flash { transform: scale(.97); border-color: var(--good); }
.troop-card.ghost .t-name { padding-right: 0; }
.status { font-size: 9.5px; padding: 0 4px; border-radius: 3px; font-weight: 700; letter-spacing: .04em; white-space: nowrap; }
.status.FULL { background: var(--good-bg); color: var(--good); }
.status.PARTIAL { background: var(--partial-bg); color: var(--partial); }
.status.REMOVED { background: color-mix(in srgb, var(--muted) 18%, transparent); color: var(--muted); }

/* ------------------------------------------------------------ table (shell B) */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); }
.r-table { width: 100%; border-collapse: collapse; min-width: 820px; }
.r-table thead tr, .b-table thead tr { background: var(--field); }
.r-table th, .b-table th { text-align: left; padding: 7px 10px; font-size: 10.5px; font-weight: 500; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.r-table th.num, .r-table td.num, .b-table th.num, .b-table td.num { text-align: right; }
.r-table tbody th.group { text-align: left; padding: 8px 10px 6px; border-top: 1px solid var(--line-2); border-bottom: 1px solid var(--line); background: var(--surface); font-size: 13px; font-weight: 650; text-transform: none; letter-spacing: 0; color: var(--text); }
.r-table tbody th.group .tot { margin-left: 10px; font-size: 11px; font-weight: 400; color: var(--muted); font-family: var(--mono); }
.r-table td, .b-table td { padding: 5px 10px; }
.r-table tr.item, .b-table tr.item { border-top: 1px solid color-mix(in srgb, var(--line) 60%, transparent); }
.r-table tr.item.first { border-top-color: var(--line); }
.r-table td.tier { font-family: var(--mono); font-weight: 700; color: var(--accent-text); width: 56px; }
.r-table td.cat { color: var(--muted); font-size: 12px; }
.r-table td.count { font-family: var(--mono); font-size: 14px; font-weight: 700; color: var(--strong); }
.r-table td.hp { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.r-table td.act { text-align: right; white-space: nowrap; width: 96px; padding: 3px 8px; }
.r-table tr.ghost { opacity: .7; border-top-style: dashed; }
.r-table tr.ghost td.name { color: var(--muted); text-decoration: line-through; }
.r-table .icon-btn { width: 28px; height: 26px; display: inline-grid; place-items: center; padding: 0; background: var(--field); border: 1px solid var(--line-2); color: var(--muted); border-radius: 5px; cursor: pointer; }
.r-table .icon-btn.quiet { background: none; border-color: transparent; }
.r-table .icon-btn:hover { color: var(--text); border-color: var(--primary); }
.r-table .icon-btn svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.r-table .restore { height: 26px; background: none; border: 1px solid var(--line-2); color: var(--muted); border-radius: 5px; cursor: pointer; font: inherit; font-size: 11.5px; padding: 0 8px; }
.r-table .restore:hover { color: var(--text); border-color: var(--primary); }
.r-table tr.flash td { background: var(--good-bg); }

/* ------------------------------------------------------------ grid (shell C) */
.g-grid { display: grid; grid-template-columns: 54px repeat(4, minmax(0, 1fr)); gap: 5px; margin-top: 10px; }
.g-head { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; text-align: center; }
.g-divider { grid-column: 1 / -1; display: flex; align-items: baseline; gap: 8px; padding: 8px 0 2px; border-bottom: 1px solid var(--line); margin-bottom: 2px; }
.g-divider h3 { font-size: 12.5px; }
.g-divider span { font-size: 11px; color: var(--muted); font-family: var(--mono); }
.g-label { font-family: var(--mono); font-weight: 700; color: var(--accent-text); align-self: center; }
.g-label.partial { color: var(--partial); }
.g-cell {
  display: flex; flex-direction: column; align-items: flex-start; gap: 1px; min-width: 0; text-align: left;
  background: var(--card); border: 1px solid var(--line); border-radius: 6px; padding: 5px 8px; font: inherit; color: inherit; cursor: copy;
}
.g-cell:hover { border-color: var(--line-2); }
.g-cell.partial { border-color: color-mix(in srgb, var(--partial) 45%, var(--line)); }
.g-cell.ghost { border-style: dashed; border-color: var(--line-2); opacity: .45; cursor: pointer; }
.g-cell.flash { border-color: var(--good); }
.g-cell .g-name { font-size: 11px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.g-cell .g-count { font-family: var(--mono); font-size: 15px; font-weight: 700; color: var(--strong); }
.g-cell.empty { visibility: hidden; }

/* ------------------------------------------------------------ dense list (phone) */
.l-section { background: var(--panel); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 8px 14px 5px; display: flex; align-items: baseline; justify-content: space-between; margin-top: 8px; }
.l-section h3 { font-size: 13px; }
.l-section span { font-family: var(--mono); font-size: 11px; color: var(--muted); }
.l-tier { background: var(--bg); border-bottom: 1px solid var(--line); padding: 8px 14px 5px; display: flex; align-items: baseline; justify-content: space-between; }
.l-tier h3 { font-size: 12.5px; }
.l-tier h3 b { font-family: var(--mono); color: var(--accent-text); font-weight: 700; }
.l-tier span { font-family: var(--mono); font-size: 11px; color: var(--muted); }
.l-item { display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 0 4px 0 14px; border-bottom: 1px solid color-mix(in srgb, var(--line) 60%, transparent); cursor: pointer; }
.l-item.ghost { opacity: .45; }
.l-abbr { flex: none; width: 26px; height: 22px; border-radius: 5px; background: var(--card); border: 1px solid var(--line-2); color: var(--text-2); font-size: 10px; font-weight: 700; display: grid; place-items: center; }
.l-main { flex: 1; min-width: 0; }
.l-name { font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.l-hp { font-family: var(--mono); font-size: 10.5px; color: var(--muted); }
.l-count { font-family: var(--mono); font-size: 17px; font-weight: 700; color: var(--strong); }
.l-copy { flex: none; width: 44px; height: 44px; background: none; border: 0; color: var(--accent-text); display: grid; place-items: center; cursor: pointer; }
.l-copy svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; }

/* ============================================================ shell A · compact workbench */
.shell { display: flex; flex-direction: column; min-width: 0; }
.shell-a .a-caps { padding: 10px 16px; background: var(--bar2); border-bottom: 1px solid var(--line); }
.shell-a #secCaps .sec-head { display: none; }
.shell-a #secCaps .limits { flex-direction: row; flex-wrap: wrap; gap: 10px 20px; }
.shell-a #secCaps .limit { flex: 1 1 250px; }
.a-main { display: flex; flex-wrap: wrap; gap: 12px; padding: 12px 16px 20px; align-items: flex-start; }
.a-inputs { flex: 1 1 340px; max-width: 400px; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.tabcard, .glance { background: var(--card); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.a-tabs { display: flex; border-bottom: 1px solid var(--line); background: var(--panel); }
.a-tabs button { flex: 1; background: none; border: 0; border-bottom: 2px solid transparent; color: var(--muted); font: inherit; font-size: 12px; padding: 9px 4px 7px; cursor: pointer; }
.a-tabs button[aria-selected="true"] { border-bottom-color: var(--primary); color: var(--text); font-weight: 600; }
.a-pane { padding: 8px 12px 12px; display: flex; flex-direction: column; gap: 6px; }
.shell-a .sec-bonus + .sec-bonus, .shell-a .a-pane .sec-bonus:not(:first-child) { margin-top: 6px; }
.shell-a .a-pane .sec-head { margin-top: 2px; padding-bottom: 3px; border-bottom: 1px solid var(--line); }
.shell-a .a-pane .sec-title { font-size: 11px; font-weight: 650; color: var(--accent-text); text-transform: uppercase; letter-spacing: .06em; }
.shell-a .a-pane .sec-title small { display: none; }
.shell-a .a-pane .sec-head, .shell-a .a-pane .sec-toggle { pointer-events: none; }
.shell-a #secBoost { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; column-gap: 8px; }
.shell-a #secBoost .sec-head { grid-column: 1; }
.shell-a #secBoost .sec-body { display: contents; }
.shell-a #secBoost .segmented { grid-column: 2; grid-row: 1; margin: 0 0 3px; }
.shell-a #secBoost .bonus-table { grid-column: 1 / -1; }
.shell-a #secOrder .sec-head, .shell-a #secTiers .sec-head, .shell-a #secExcl .sec-head, .shell-a #secMult .sec-head { display: none; }
.glance { padding: 4px 0; }
.glance button { display: grid; grid-template-columns: 84px minmax(0, 1fr) 14px; gap: 8px; align-items: center; width: 100%; background: none; border: 0; border-bottom: 1px solid color-mix(in srgb, var(--line) 70%, transparent); color: var(--text); padding: 7px 12px; font: inherit; text-align: left; cursor: pointer; }
.glance button:last-child { border-bottom: 0; }
.glance button:hover { background: var(--panel); }
.glance .g-l { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .05em; }
.glance .g-v { font-family: var(--mono); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.glance svg { width: 12px; height: 12px; fill: none; stroke: var(--muted); stroke-width: 2; }
.a-results { flex: 999 1 640px; min-width: 0; }
.shell-a #results { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px 12px; }
.shell-a #results .rt-hint { display: inline; }

/* ============================================================ shell B · results-first table */
.shell-b .b-settings { position: relative; padding: 10px 16px; background: var(--bar2); border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 10px; }
.b-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-wrap { position: relative; }
.chip-btn { display: flex; align-items: center; gap: 8px; background: var(--card); border: 1px solid var(--line-2); border-radius: 7px; height: 32px; padding: 0 10px; color: var(--text); font: inherit; cursor: pointer; max-width: 28rem; }
.chip-btn[aria-expanded="true"] { border-color: var(--primary); background: var(--btn); }
.chip-btn .c-l { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; white-space: nowrap; }
.chip-btn .c-v { font-family: var(--mono); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip-btn svg { width: 11px; height: 11px; fill: none; stroke: var(--muted); stroke-width: 2; flex: none; }
.pop { position: absolute; left: 0; top: calc(100% + 6px); z-index: 30; width: 420px; max-width: calc(100vw - 24px); background: var(--btn); border: 1px solid var(--line-2); border-radius: 10px; box-shadow: var(--shadow); padding: 12px 14px; }
.pop-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.pop-head h2 { font-size: 13px; }
.pop-close { background: none; border: 0; color: var(--muted); cursor: pointer; width: 28px; height: 28px; display: grid; place-items: center; }
.pop-close svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; }
.pop .sec-head { display: none; }
.pop .limit { grid-template-columns: 6.2rem minmax(0, 1fr); }
.pop .limits { gap: 8px; }
.pop .bonus-table td { width: 92px; }
.shell-b .b-order { min-width: 0; }
.shell-b #secOrder .sec-head { display: none; }
.shell-b #secOrder .sec-body { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; }
.shell-b #secOrder .order-block { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin: 0; }
.shell-b #secOrder .order-block + .order-block { padding-left: 14px; border-left: 1px solid var(--line-2); }
.shell-b #secOrder .order-head { gap: 8px 14px; }
.shell-b #secOrder .order-head h3 { display: none; }
.shell-b #secOrder .order-dies { display: inline; }
.shell-b #secOrder .dies-arrow, .shell-b #secOrder .order-hint { display: none; }
.shell-b #secOrder .order-list { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 4px 16px; margin: 0; }
.shell-b #secOrder .order-item { position: relative; background: var(--card); border-color: var(--line-2); padding: 3px 7px 3px 4px; min-height: 0; gap: 4px; flex: none; }
.shell-b #secOrder .order-item .pos, .shell-b #secOrder .order-item .name, .shell-b #secOrder .order-item .move { display: none; }
.shell-b #secOrder .order-item .code { display: inline; }
.shell-b #secOrder .order-item:not(:last-child)::after { content: "›"; position: absolute; right: -12px; top: 50%; transform: translateY(-50%); color: var(--line-2); }
.shell-b #secOrder .order-list.horizontal { gap: 4px; }
.shell-b #secOrder .order-list.horizontal .order-item { padding: 3px 8px; }
.shell-b #secOrder .order-list.horizontal .order-item .name { display: inline; }
.shell-b #secOrder .order-list.horizontal .order-item .handle { display: none; }
.shell-b #secOrder .order-list.horizontal .order-item::after { content: none; }
.shell-b #secOrder .order-list.horizontal .order-item .pos { display: none; }
.b-usage { padding: 10px 16px 0; }
.b-results { padding: 12px 16px 24px; }
.shell-b #results .show-excl { display: inline-flex; }
.shell-b .usage-row { display: flex; }

/* ============================================================ shell C · three panes */
.shell-c { flex-direction: row; flex-wrap: wrap; gap: 12px; padding: 12px 16px 20px; align-items: flex-start; }
.c-left { flex: 1 1 280px; max-width: 300px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.c-left-head { display: flex; align-items: center; justify-content: space-between; padding: 9px 12px; border-bottom: 1px solid var(--line); background: var(--panel); }
.c-left-head h2 { font-size: 13px; }
.c-center { flex: 999 1 560px; min-width: 0; }
.c-right { flex: 1 1 260px; max-width: 290px; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.c-card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.c-card:empty { display: none; }
.c-acc .sec { border-bottom: 1px solid color-mix(in srgb, var(--line) 70%, transparent); }
.c-acc .sec:last-child { border-bottom: 0; }
.c-acc .sec-toggle { display: grid; grid-template-columns: minmax(0, 1fr) 14px; gap: 2px 8px; padding: 8px 12px; cursor: pointer; }
.c-acc .sec[data-open="true"] .sec-toggle { background: var(--btn); }
.c-acc .sec-title { font-size: 12.5px; }
.c-acc .sec-title small { display: none; }
.c-acc .sec .chev { display: block; grid-row: span 2; align-self: center; stroke: var(--muted); transition: transform .15s; }
.c-acc .sec[data-open="true"] .chev { transform: rotate(180deg); }
.c-acc .sec-sum { display: block; grid-column: 1; font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.c-acc .sec-body { padding: 4px 12px 12px; }
.c-acc .sec[data-open="false"] .sec-body { display: none; }
.c-acc .bonus-table td { width: 70px; }
.c-acc .limit { grid-template-columns: 1fr; }
.c-acc .limit input.cap { width: 100%; }
.c-acc .limit .limit-line { }
.c-right .usage-title, .c-card .usage-title { display: block; }
.c-right .usage-list { flex-direction: column; gap: 8px; }
.c-right .usage-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 8px; flex: none; }
.c-right .u-label { text-transform: none; letter-spacing: 0; font-size: 11.5px; min-width: 0; }
.c-right .usage-bar { grid-column: 1 / -1; grid-row: 2; }
.c-right .u-text { font-size: 11.5px; grid-row: 1; grid-column: 2; }
.c-right #secOrder .sec-head, .c-right #secMult .sec-head { margin-bottom: 8px; }
.c-right .sec-toggle { cursor: default; }
.c-right .sec-title { font-size: 13px; }
.c-right #secOrder .sec-body > .order-block:first-child .order-head { display: grid; grid-template-columns: 1fr; gap: 6px; }
.c-right #secOrder .order-dies { display: block; position: absolute; }
.c-right #secOrder .segmented { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); width: 100%; }
.c-right #secOrder .segmented .seg { padding: 4px 0; }
.c-right #secOrder .order-block:first-child .order-dies { display: none; }
.c-right #secOrder .order-cat .segmented { display: flex; width: auto; }
.c-right #secOrder .order-cat .segmented .seg { padding: 2px 8px; font-size: 11px; }
.c-right #secOrder .order-cat .order-list.horizontal { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 3px; }
.c-right #secOrder .order-cat .order-item { justify-content: center; padding: 3px 0; }
.c-right #secOrder .order-cat .order-item .handle { display: none; }
.c-right #secOrder .order-cat .order-item .pos { display: none; }
.c-right #secOrder .order-cat .order-item .move { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.c-right #secOrder .order-cat .order-item .move:focus-visible { position: static; width: 22px; height: 22px; clip: auto; overflow: visible; }
.c-right #secOrder .order-hint { display: none; }
.c-right #secMult .segmented.wrap .seg { font-size: 12px; }

.shell-c #results { display: flex; flex-direction: column; gap: 10px; }
.shell-c .r-totals { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.r-total { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; }
.rt-label { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.rt-value { font-family: var(--mono); font-size: 18px; font-weight: 700; color: var(--strong); }
.rt-sub { font-size: 11px; color: var(--muted); font-family: var(--mono); }
.shell-c .r-card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; column-gap: 8px; }
.shell-c .r-card > * { grid-column: 1 / -1; }
.shell-c .results-toolbar { display: contents; }
.shell-c .rt-left, .shell-c .rt-hint { display: none; }
.shell-c .rt-right { grid-column: 2; grid-row: 1; margin: 0; }
.shell-c .r-tabs { display: flex; gap: 4px; grid-column: 1; grid-row: 1; }
.r-tab { background: none; border: 1px solid var(--line); color: var(--muted); border-radius: 6px; padding: 4px 10px; font: inherit; cursor: pointer; white-space: nowrap; }
.r-tab[aria-selected="true"] { background: var(--btn); border-color: var(--primary); color: var(--text); font-weight: 600; }
.r-count { opacity: .75; font-weight: 400; }

/* ============================================================ shell M · phone */
html[data-shell="M"] body { padding-bottom: 0; }
html[data-shell="M"] .app-header { position: sticky; top: 0; gap: 4px; padding: 4px 6px 4px 14px; flex-wrap: nowrap; min-height: 52px; }
html[data-shell="M"] .brand-name { display: none; }
html[data-shell="M"] body[data-view="calcView"] .phone-preset { display: flex; }
body:not([data-view="calcView"]) .preset-bar { display: none; }
html[data-shell="M"] .header-actions { gap: 2px; flex: 1; min-width: 0; justify-content: flex-end; }
html[data-shell="M"] .calc-actions { gap: 2px; }
html[data-shell="M"] .calc-status { min-width: 0; font-size: 12px; }
html[data-shell="M"] .calc-status { font-size: 0; }
html[data-shell="M"] .long { display: none; }
html[data-shell="M"] .short { display: inline; }
html[data-shell="M"] .switch { min-height: 44px; padding: 0 6px; }
html[data-shell="M"] .switch input { width: 20px; height: 20px; }
html[data-shell="M"] #calculateBtn { width: 44px; height: 44px; padding: 0; background: none; border: 0; color: var(--muted); }
html[data-shell="M"] #calculateBtn .calc-icon { display: block; }
html[data-shell="M"] #calculateBtn .calc-label { display: none; }
html[data-shell="M"] #calculateBtn.stale { color: var(--partial); box-shadow: none; }
html[data-shell="M"] .user-actions .btn { height: 44px; }
html[data-shell="M"] #userMenuBtn { max-width: 6.5rem; overflow: hidden; text-overflow: ellipsis; }
html[data-shell="M"] #calcLink, html[data-shell="M"] #usersLink, html[data-shell="M"] #citadelLink { padding: 0 8px; }
/* No room for the Calculator / Citadel tabs on the phone's calculator header: Citadel moves into the account menu. */
html[data-shell="M"] body[data-view="calcView"] #calcLink,
html[data-shell="M"] body[data-view="calcView"] #citadelLink { display: none; }
#citadelMenuItem { display: none; }
html[data-shell="M"] body[data-view="calcView"] #citadelMenuItem { display: block; }
.phone-preset { display: none; align-items: center; gap: 6px; height: 44px; background: none; border: 0; color: var(--text); font: inherit; font-size: 17px; font-weight: 700; padding: 0 6px; cursor: pointer; min-width: 0; max-width: 11rem; }
.phone-preset span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.phone-preset svg { flex: none; stroke: var(--muted); }

.shell-m { padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
.m-pane { display: flex; flex-direction: column; }
.m-head { display: flex; align-items: baseline; gap: 8px; padding: 12px 16px 6px; }
.m-head h1 { font-size: 17px; }
.m-head-sub { font-size: 13px; }
.m-usage { padding: 10px 12px 8px; }
.shell-m .usage-title { display: none; }
.shell-m .usage-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.shell-m .usage-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 6px; flex: none; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 7px 9px; align-items: baseline; }
.shell-m .u-label { min-width: 0; font-size: 10.5px; }
.shell-m .u-pct { display: block; text-align: right; }
.shell-m .usage-bar { grid-column: 1 / -1; height: 4px; margin: 1px 0; border: 0; }
.shell-m .u-text { grid-column: 1 / -1; font-size: 10.5px; color: var(--muted); }
.shell-m .n-long { display: none; }
.shell-m .n-short { display: inline; }
.m-results { padding: 0 12px 80px; }
.shell-m #results .r-card { display: block; }
.shell-m .results-toolbar { margin: 0; }
.shell-m .rt-left, .shell-m .rt-hint, .shell-m .show-excl { display: none; }
.shell-m .rt-right { position: fixed; right: 14px; bottom: calc(82px + env(safe-area-inset-bottom)); z-index: 15; }
.shell-m .btn-copyall { height: 48px; padding: 0 18px; border-radius: 24px; background: var(--primary); border-color: var(--primary); color: var(--on-primary); font-weight: 600; box-shadow: 0 8px 22px rgba(var(--shadow-c), .28); gap: 8px; }
.shell-m .btn-copyall svg { width: 18px; height: 18px; }
.shell-m .r-tabs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); margin: 0 0 8px; background: var(--field); border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.shell-m .r-tab { height: 38px; border: 0; border-radius: 7px; font-size: 13.5px; }
.shell-m .r-tab[data-rtab="all"] { display: none; }
.shell-m .r-tab[aria-selected="true"] { background: var(--primary); color: var(--on-primary); }
.shell-m .col-headers { display: none; }
.shell-m .result-section { margin-top: 6px; }
.shell-m .result-section > h3 { display: none; }
.shell-m .troop-grid { gap: 12px; }
.shell-m .tier-group { grid-template-columns: 1fr; gap: 6px; }
.shell-m .tier-label { flex-direction: row; align-items: baseline; justify-content: flex-start; gap: 6px; font-size: 14px; }
.shell-m .tier-label .tier-name { display: inline; font-family: var(--font); font-weight: 500; color: var(--text-2); }
.shell-m .tier-label .tier-total { display: inline; margin-left: auto; font-size: 11.5px; font-weight: 400; color: var(--muted); }
.shell-m .tier-label .partial { margin-left: 4px; }
.shell-m .cols { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.shell-m .extra-row { grid-column: 1; }
.shell-m .extra-row .troop-card { flex-basis: calc(50% - 3px); min-width: 0; }
.shell-m .troop-card { border-radius: 10px; padding: 8px 46px 8px 10px; }
.shell-m .troop-card .t-cat { display: block; }
.shell-m .troop-card .t-name { font-size: 12.5px; padding-right: 0; }
.shell-m .troop-card .t-count { font-size: 19px; }
.shell-m .troop-card .copy { width: 40px; height: 44px; top: 4px; right: 4px; border-radius: 8px; }
.shell-m .troop-card .copy svg { width: 17px; height: 17px; }
.shell-m .troop-card.ghost .copy { display: none; }
.shell-m .footnote { display: none; }
.shell-m .view-list { margin: 0 -12px; }
html[data-shell="M"] .troop-grid .troop-card .t-line { flex-wrap: wrap; }

.m-acc { padding: 6px 12px 12px; display: flex; flex-direction: column; gap: 8px; }
.m-acc .sec { background: var(--card); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.m-acc .sec-toggle { display: grid; grid-template-columns: minmax(0, 1fr) 16px; gap: 2px 8px; align-items: center; min-height: 56px; padding: 8px 14px; cursor: pointer; }
.m-acc .sec-title { font-size: 14px; }
.m-acc .sec-title small { margin-left: 4px; }
.m-acc .sec-sum { display: block; grid-column: 1; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.m-acc .sec .chev { display: block; grid-row: span 2; width: 16px; height: 16px; stroke: var(--muted); transition: transform .15s; }
.m-acc .sec[data-open="true"] .chev { transform: rotate(180deg); }
.m-acc .sec[data-open="true"] .sec-toggle { min-height: 48px; }
.m-acc .sec[data-open="true"] .sec-sum { display: none; }
.m-acc .sec[data-open="false"] .sec-body { display: none; }
.m-acc .sec-body { padding: 0 14px 12px; }
.m-acc .bonus-table td { width: 92px; }
.m-acc .limit { grid-template-columns: 1fr; gap: 3px; }
.m-acc .limit input.cap { width: 100%; }
.m-acc .tier-row { grid-template-columns: 1fr; gap: 3px; }
.m-acc .chip span { min-width: 36px; padding: 9px 6px; }
.m-acc .quick-pick-buttons .btn { height: 36px; min-width: 38px; }
.shell-m .segmented .seg { padding: 0 12px; min-height: 40px; }
.shell-m .sec-boost .segmented .seg { min-height: 36px; }
.shell-m .segmented.wrap .seg { min-height: 44px; }
html[data-shell="M"] input.num, html[data-shell="M"] select, html[data-shell="M"] input[type="text"] { font-size: 16px; min-height: 44px; border-radius: 8px; }
.shell-m .tag button { min-width: 36px; min-height: 32px; }

.shell-m #secOrder .sec-head { display: none; }
.shell-m .hint-pointer { display: none; }
.shell-m .hint-touch { display: inline; }
.shell-m #secOrder .order-block { padding: 0 12px; }
.shell-m #secOrder .order-head { margin-top: 12px; }
.shell-m #secOrder .order-head > .segmented { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); width: 100%; background: var(--field); border-radius: 10px; padding: 3px; }
.shell-m #secOrder .order-head > .segmented .seg { min-height: 40px; border: 0; border-radius: 7px; font-size: 14px; background: none; }
.shell-m #secOrder .order-head > .segmented .seg[aria-pressed="true"] { background: var(--primary); color: var(--on-primary); }
.shell-m #secOrder .order-dies { display: none; }
.shell-m #secOrder .order-list { gap: 5px; }
.shell-m #secOrder .order-item { min-height: 52px; padding: 0 0 0 10px; background: var(--card); border-color: var(--line); border-radius: 10px; gap: 8px; }
.shell-m #secOrder .order-item .name { font-weight: 600; font-size: 14px; }
.shell-m #secOrder .order-item .move { width: 44px; height: 44px; border-radius: 0; }
.shell-m #secOrder .order-item .move svg { width: 18px; height: 18px; }
.shell-m #secOrder .order-item .pos { font-size: 13px; }
.shell-m #secOrder .order-item .name { display: block; }
.shell-m #secOrder .order-item .sub { display: block; font-family: var(--mono); font-size: 11.5px; color: var(--muted); }
.shell-m #secOrder .order-item .label { flex: 1; min-width: 0; }
.shell-m #secOrder .order-cat { background: var(--card); border: 1px solid var(--line); border-radius: 12px; margin: 10px 12px 0; padding: 10px 12px; }
.shell-m #secOrder .order-cat .order-head { margin-top: 0; }
.shell-m #secOrder .order-cat .segmented { display: flex; width: auto; padding: 2px; }
.shell-m #secOrder .order-cat .segmented .seg { min-height: 36px; font-size: 13px; }
.shell-m #secOrder .order-cat .order-list.horizontal { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); margin-top: 10px; gap: 5px; }
.shell-m #secOrder .order-cat .order-item { min-height: 44px; padding: 0 0 0 8px; border-radius: 8px; background: var(--field); border-color: var(--line-2); gap: 4px; }
.shell-m #secOrder .order-cat .order-item .handle { display: none; }
.shell-m #secOrder .order-cat .order-item .move { width: 36px; height: 42px; }
.shell-m #secOrder .order-cat .order-item .name { font-weight: 400; font-size: 13px; }
.shell-m #secOrder .order-cat .order-item .pos { font-size: 11px; min-width: 0; }
.shell-m #secOrder .order-cat .order-item .sub { display: none; }
.shell-m .m-presets { padding: 0 12px; }
.shell-m .preset-bar { flex-direction: column; align-items: stretch; gap: 8px; }
.shell-m .preset-tabs { flex-direction: column; align-items: stretch; overflow: visible; gap: 5px; }
.shell-m .preset-tab { height: 52px; max-width: none; text-align: left; padding: 0 14px; border-radius: 10px; font-size: 15px; }
.shell-m .preset-bar > .btn-icon { width: 100%; height: 48px; justify-content: center; border-radius: 10px; }
.shell-m .preset-bar > .btn-icon .btn-label { display: inline; }
.shell-m #presetMenuBtn { display: none; }
.shell-m #presetMenuWrap { position: static; }
.shell-m #presetMenu { display: block !important; position: static; box-shadow: none; background: var(--card); border-color: var(--line); border-radius: 12px; }
.shell-m #presetMenu button { min-height: 48px; font-size: 15px; }
.shell-m .m-more { padding: 12px 12px 0; }
.m-row { display: flex; align-items: center; justify-content: space-between; width: 100%; min-height: 52px; padding: 0 14px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; color: var(--text); font: inherit; font-size: 15px; cursor: pointer; text-align: left; }
.m-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 25; height: calc(68px + env(safe-area-inset-bottom)); display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
  background: var(--bar); border-top: 1px solid var(--line); padding-bottom: calc(6px + env(safe-area-inset-bottom));
}
.m-nav button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; background: none; border: 0; color: var(--muted); font: inherit; font-size: 11px; cursor: pointer; }
.m-nav svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.m-nav button[aria-current="page"] { color: var(--accent-text); font-weight: 600; }
html:not([data-shell="M"]) .m-nav { display: none; }

/* ============================================================ footer, toast, dialogs */
.app-footer { padding: 8px 16px 24px; font-size: 11px; text-align: center; }
html[data-shell="M"] .app-footer { display: none; }
.toast { position: fixed; left: 50%; bottom: 1.5rem; transform: translateX(-50%); background: var(--btn); border: 1px solid var(--primary); color: var(--text); padding: .55rem 1rem; border-radius: var(--radius-sm); box-shadow: var(--shadow); z-index: 60; }
html[data-shell="M"] .toast { bottom: calc(150px + env(safe-area-inset-bottom)); max-width: calc(100vw - 24px); }
.dialog { background: var(--surface); color: var(--text); border: 1px solid var(--line-2); border-radius: var(--radius); padding: 1rem 1.1rem; max-width: min(92vw, 28rem); box-shadow: var(--shadow); }
.dialog.wide { max-width: min(94vw, 40rem); width: 40rem; }
.dialog::backdrop { background: rgba(3, 8, 18, .6); }
.dialog h2 { margin-bottom: .5rem; font-size: 1.05rem; }
.dialog menu { display: flex; justify-content: flex-end; gap: .5rem; padding: 0; margin: 1rem 0 0; }
.import-items { list-style: none; padding: 0; margin: .5rem 0; max-height: 45vh; overflow: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.import-items li { padding: .4rem .6rem; border-bottom: 1px solid var(--line); font-size: .85rem; }
.import-items li:last-child { border-bottom: 0; }
.import-items .renamed { color: var(--partial); }
.import-items .err { color: var(--bad); }
.import-items .warn { color: var(--partial); }
.import-items .empty { color: var(--muted); font-style: italic; }
.import-mode { border: 1px solid var(--line); border-radius: var(--radius-sm); display: grid; gap: .3rem; }
.import-mode legend { color: var(--muted); padding: 0 .3rem; }
.drop-overlay { position: fixed; inset: 0; background: color-mix(in srgb, var(--bg) 85%, transparent); border: 3px dashed var(--primary); display: grid; place-items: center; font-size: 1.3rem; z-index: 70; pointer-events: none; }

/* appearance dialog */
.dialog.appearance { width: 30rem; max-height: 92vh; overflow: auto; }
.ap-group { border: 0; padding: 0; margin: 0 0 14px; min-width: 0; }
.ap-group legend { padding: 0; margin-bottom: 6px; font-weight: 650; }
.ap-options { display: flex; flex-direction: column; gap: 5px; }
.ap-opt { display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 5px 12px; background: transparent; border: 1px solid var(--line); border-radius: 10px; color: var(--text); font: inherit; text-align: left; cursor: pointer; width: 100%; }
.ap-opt[aria-checked="true"] { background: var(--card); border-color: var(--primary); }
.ap-opt:hover { border-color: var(--line-2); }
.ap-swatch { flex: none; display: flex; border-radius: 8px; overflow: hidden; border: 1px solid rgba(127, 127, 127, .35); }
.ap-swatch i { display: block; width: 14px; height: 28px; }
.ap-text { flex: 1; min-width: 0; }
.ap-text b { display: block; font-weight: 650; }
.ap-text span { display: block; font-size: 12px; color: var(--muted); }
.ap-radio { flex: none; width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--muted); display: grid; place-items: center; }
.ap-radio i { width: 9px; height: 9px; border-radius: 50%; background: transparent; }
.ap-opt[aria-checked="true"] .ap-radio { border-color: var(--primary); }
.ap-opt[aria-checked="true"] .ap-radio i { background: var(--primary); }
.ap-opt.ap-layout .ap-glyph { flex: none; width: 44px; height: 30px; border: 1px solid var(--line-2); border-radius: 5px; background: var(--field); display: block; }
.ap-glyph svg { width: 100%; height: 100%; display: block; fill: none; stroke: var(--muted); stroke-width: 1.4; }
.ap-glyph svg .fill { fill: var(--primary); stroke: none; opacity: .65; }
.ap-note { font-size: 12px; color: var(--muted); margin: 4px 0 0; }

/* ============================================================ accounts */
a.btn { text-decoration: none; }
.count-badge { display: inline-block; min-width: 1.3rem; padding: 0 .35rem; border-radius: 999px; background: var(--partial); color: var(--bg); font-size: .75rem; font-weight: 700; text-align: center; }
.account-view { display: grid; place-items: start center; padding: 3rem 1rem; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem .9rem; }
.card h2 { margin-bottom: .5rem; }
.card h3 { margin: .75rem 0 .3rem; }
.account-card { width: min(100%, 26rem); }
.account-card h1 { font-size: 1.3rem; margin-bottom: .75rem; }
.account-card form { display: grid; gap: .35rem; margin-bottom: .75rem; }
.account-card label { color: var(--muted); margin-top: .35rem; }
.account-card .btn-primary { margin-top: .6rem; height: 36px; }
.account-card .btn { height: 34px; }
.account-card input { padding: .5rem .6rem; }
.small { font-size: .8rem; }
.form-error { color: var(--bad); margin: .35rem 0 0; }
.hint.ok { color: var(--good); }

.impersonation-banner {
  position: sticky; top: 0; z-index: 25; display: flex; align-items: center; justify-content: center; gap: 1rem;
  padding: .5rem 1rem; background: #6b2a00; border-bottom: 2px solid #ff9a3c; color: #fff1e0; font-size: .95rem;
}
.impersonation-banner small { color: #ffd2a8; }
body.impersonating .app-header { box-shadow: inset 0 -3px 0 #ff9a3c; }

.users-view { display: grid; gap: 1rem; padding: 1rem; max-width: 72rem; margin: 0 auto; }
.users-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: .5rem; }
.users-filters { display: flex; gap: .5rem; }
.users-filters select { width: auto; }
.users-table { width: 100%; border-collapse: collapse; }
.users-table th, .users-table td { text-align: left; padding: .4rem .5rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.users-table th { color: var(--muted); font-weight: 500; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; }
.users-table .actions { display: flex; flex-wrap: wrap; gap: .3rem; justify-content: flex-end; }
.users-table .nowrap { white-space: nowrap; }
.users-table .btn { height: auto; padding: .25rem .55rem; font-size: .85rem; }
.state { display: inline-block; padding: .05rem .5rem; border-radius: 999px; font-size: .75rem; border: 1px solid var(--line-2); }
.state-approved { color: var(--good); border-color: var(--good); }
.state-pending { color: var(--partial); border-color: var(--partial); }
.state-rejected, .state-disabled { color: var(--bad); border-color: var(--bad); }
.role { margin-left: .35rem; color: var(--accent-text); font-size: .75rem; }
.audit-table td { font-size: .85rem; }
.audit-table td:last-child { color: var(--muted); font-family: var(--mono); font-size: .75rem; word-break: break-word; }
#auditMore { margin-top: .5rem; }
.secret { font-family: var(--mono); font-size: 1.4rem; letter-spacing: .05em; padding: .6rem .8rem; background: var(--field); border: 1px dashed var(--primary); border-radius: var(--radius-sm); text-align: center; user-select: all; margin-top: .5rem; }
#adminDialogInput { margin-top: .5rem; }

/* ============================================================ narrow windows (not a phone) */
@media (max-width: 1100px) {
  .a-inputs { max-width: none; flex-basis: 100%; }
  .shell-c .c-left, .shell-c .c-right { max-width: none; flex-basis: 100%; }
}
@media (max-width: 700px) {
  .users-view { padding: .5rem; }
  .users-table thead { display: none; }
  .users-table tr { display: grid; gap: .2rem; padding: .5rem 0; border-bottom: 1px solid var(--line); }
  .users-table td { border: 0; padding: 0; }
  .users-table .actions { justify-content: flex-start; }
  .account-view { padding: 1.5rem .75rem; }
  .impersonation-banner { flex-wrap: wrap; gap: .5rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation-duration: .01ms !important; }
}
@media print {
  .app-header, .m-nav, .toast, .shell-a .a-inputs, .b-settings, .c-left, .c-right { display: none !important; }
  body { background: #fff; color: #000; }
}

.avatar { display: none; width: 28px; height: 28px; border-radius: 50%; background: var(--btn); border: 1px solid var(--line-2); font-weight: 700; font-size: 12px; place-items: center; }
html[data-shell="M"] #userMenuBtn { padding: 0 8px; }
html[data-shell="M"] #userMenuBtn .avatar { display: grid; }
html[data-shell="M"] #userMenuBtn #userName, html[data-shell="M"] #userMenuBtn > svg { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ============================================================ citadel */
.citadel-view { padding: 10px 16px 16px; max-width: 90rem; margin: 0 auto; }
.cz-bar { display: flex; align-items: center; gap: 4px; min-width: 0; margin-bottom: 10px; }
.cz-bar .preset-tabs { flex: 0 1 auto; }
.cz-bar .cz-add { background: none; border-style: dashed; color: var(--muted); height: 28px; width: 28px; }
.cz-bar .calc-status { margin-left: auto; }
.cz-menu-list { left: 0; right: auto; }
.citadel-view .banner { margin: 0 0 10px; }

.cz-layout { display: grid; grid-template-columns: 20rem minmax(0, 1fr); gap: 12px; align-items: start; }
.cz-side { display: flex; flex-direction: column; gap: 12px; position: sticky; top: 10px; max-height: calc(100vh - 20px); overflow-y: auto; scrollbar-width: thin; }
.cz-title { font-size: 11px; font-weight: 650; color: var(--accent-text); text-transform: uppercase; letter-spacing: .06em; margin: 0 0 8px; }
.cz-field { display: grid; gap: 4px; margin-bottom: 10px; }
.cz-label, .cz-input > span { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; }
.cz-seg { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); width: 100%; }
.cz-seg .seg { padding: 6px 8px; }
.cz-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.cz-actions .btn { flex: 1 1 auto; }

.cz-results-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.cz-meta { font-family: var(--mono); font-size: 11.5px; color: var(--muted); margin: -4px 0 8px; }
.cz-meta:empty { display: none; }
.cz-warnings { list-style: disc; }
.cz-totals { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.cz-total { display: flex; align-items: center; gap: 8px; padding: 4px 6px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); }
.cz-total-name { flex: 1; min-width: 0; font-size: 12.5px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cz-total-count { font-family: var(--mono); font-size: 15px; color: var(--strong); }
.cz-total-line { font-family: var(--mono); font-size: 11.5px; color: var(--muted); margin: 8px 0 0; }
.cz-results .hint { margin-bottom: 0; }

.citadel-view .copy {
  flex: none; width: 24px; height: 22px; display: grid; place-items: center; padding: 0;
  background: var(--field); border: 1px solid var(--line-2); color: var(--muted); border-radius: 4px; cursor: pointer;
}
.citadel-view .copy svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.citadel-view .copy:hover { color: var(--text); border-color: var(--primary); }
.citadel-view .copy[hidden] { display: none; }

.cz-icon { flex: none; border-radius: 6px; border: 1px solid var(--line); background: var(--surface2); object-fit: cover; }
.cz-icon.s28 { width: 28px; height: 28px; }
.cz-icon.s32 { width: 32px; height: 32px; }
.cz-icon.s40 { width: 40px; height: 40px; }
.cz-icon-empty { display: inline-block; border-style: dashed; border-color: var(--line-2); background: var(--field); }

.cz-waves { display: grid; grid-template-columns: repeat(auto-fill, minmax(15.5rem, 1fr)); gap: 10px; }
.cz-wave { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.cz-wave-title { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 13px; font-weight: 650; }
.cz-step { display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 999px; background: var(--primary); color: var(--on-primary); font-size: 11px; font-weight: 700; }
.cz-wall .cz-step { background: var(--surface2); color: var(--text); border: 1px solid var(--line-2); }
.cz-first { border-color: var(--primary); }
.cz-pick { display: flex; align-items: flex-end; gap: 8px; }
.cz-pick .cz-input { flex: 1; min-width: 0; }
.cz-input { display: grid; gap: 3px; }
.cz-input input, .cz-input select { height: 30px; }
.cz-input input:disabled, .cz-input select:disabled { opacity: .5; }
.cz-input input.cz-hp { border-color: color-mix(in srgb, var(--bad) 45%, var(--line-2)); }
.cz-out { margin-top: auto; padding: 6px 8px; border-radius: 6px; background: var(--panel); border: 1px solid var(--line); display: grid; gap: 2px; }
.cz-out-row { display: flex; align-items: center; justify-content: space-between; gap: 6px; min-height: 22px; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.cz-out-row b { font-family: var(--mono); font-size: 12px; color: var(--text); text-transform: none; letter-spacing: 0; }
.cz-req-row span { flex: 1; }
.cz-req-row .cz-req { font-size: 16px; color: var(--strong); }
.cz-losses { margin: 0; font-size: 11.5px; color: var(--muted); }
.cz-losses b { font-family: var(--mono); color: var(--bad); }
.cz-locked { margin: 0; font-size: 11.5px; color: var(--partial); }
.cz-off { border-style: dashed; }
.cz-credit { text-align: center; margin: 14px 0 0; }
.cz-help h3 { margin: .8rem 0 .2rem; color: var(--accent-text); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
.cz-help p { margin: 0 0 .35rem; }
.cz-rule { border-left: 3px solid var(--bad); padding-left: .6rem; }

@media (max-width: 900px) {
  .cz-layout { grid-template-columns: 1fr; }
  .cz-side { position: static; max-height: none; overflow: visible; }
}
@media (max-width: 700px) {
  .citadel-view { padding: 8px 10px 16px; }
  .cz-waves { grid-template-columns: 1fr; }
  .cz-input input, .cz-input select { height: 40px; font-size: 16px; }
  .cz-seg .seg { padding: 10px 8px; font-size: 14px; }
  .cz-actions .btn, .cz-results .btn { height: 40px; }
  .citadel-view .copy { width: 36px; height: 32px; }
}
