/* =====================================================================
   Alpha Strike Table Helper (phase 2, Step Flow) — shell layout and
   positioning only; the look comes from ../styles/styles.css tokens and
   components. Feature modules bring their own pv.css / tables.css.
   The host pads :root by the safe-area insets, so bars only add the
   inset on their own outer edge.
   ===================================================================== */

:root {
  --tabbar-h: 64px; --topbar-h: 56px; --gutter: 16px; --col: 640px; --rail-w: 0px;
  --safe-top: env(safe-area-inset-top, 0px);
  --top-offset: calc(var(--safe-top) + var(--topbar-h));
}

html { height: 100%; scroll-padding-top: calc(var(--top-offset) + 12px); scroll-padding-bottom: calc(var(--tabbar-h) + 72px); }
body { min-height: 100%; }
body.has-sheet { overflow: hidden; }
svg.ico { width: 20px; height: 20px; flex: none; }

.skip-link { position: fixed; left: 8px; top: -80px; z-index: 100; min-height: var(--tap); padding: 10px 14px; background: var(--surface); color: var(--fg); border: 2px solid var(--focus); border-radius: var(--radius-sm); font: inherit; }
.skip-link:focus { top: calc(var(--safe-top) + 8px); }

.small { font-size: 0.875rem; }
.app { padding-bottom: calc(var(--tabbar-h, 64px) + 8px); }
.view[data-view="home"] { padding-bottom: calc(var(--tabbar-h, 64px) + 16px); }

/* ---- top bar ------------------------------------------------------- */
.topbar {
  position: sticky; top: var(--safe-top); z-index: 20;
  background-color: var(--bg);
  background-image: var(--texture);
  border-bottom: var(--border-w) solid var(--line);
}
/* covers the status-bar strip above the sticky bar when content scrolls under it */
.topbar::before { content: ""; position: absolute; left: 0; right: 0; bottom: 100%; height: var(--safe-top); background: var(--bg); }
.topbar-inner {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "left title right"; align-items: center; gap: 4px;
  margin: 0 auto; min-height: 56px;
  padding: 4px max(8px, env(safe-area-inset-right, 0px)) 4px max(8px, env(safe-area-inset-left, 0px));
}
.tb-brand { display: none; grid-area: brand; }
.tb-left { grid-area: left; display: flex; min-width: 0; }
.tb-left:empty + .tb-title { padding-left: 8px; }
.tb-title { grid-area: title; min-width: 0; display: flex; flex-direction: column; line-height: 1.1; padding-left: 4px; }
.tb-eyebrow { font-family: var(--font-label, var(--font-mono)); font-size: 0.75rem; letter-spacing: var(--eyebrow-track, 0.1em); text-transform: uppercase; color: var(--fg-muted); }
.tb-name {
  font-family: var(--font-heading); font-weight: var(--display-weight); font-stretch: var(--display-stretch);
  text-transform: var(--display-case); letter-spacing: var(--display-track);
  font-size: calc(1.125rem * var(--display-scale)); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tb-right { grid-area: right; display: flex; align-items: center; gap: 2px; }
#tb-extra { display: contents; }
.icon-btn {
  position: relative; display: inline-grid; place-items: center; flex: none;
  width: var(--tap); height: var(--tap); padding: 0; border: 0; border-radius: var(--radius-sm);
  background: transparent; color: var(--fg); touch-action: manipulation;
}
.icon-btn .ico { width: 24px; height: 24px; }
@media (hover: hover) { .icon-btn:hover { background-color: var(--surface-2); } }
.icon-btn:active { background-color: var(--surface-3); }
.tb-dot { position: absolute; top: 9px; right: 9px; width: 9px; height: 9px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 2px var(--bg); }

/* ---- tab bar ------------------------------------------------------- */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; padding-left: env(safe-area-inset-left, 0px); padding-right: env(safe-area-inset-right, 0px); }
@media (min-width: 900px) { .tabbar > a { flex: 0 1 180px; } .tabbar { justify-content: center; } }

/* ---- view ---------------------------------------------------------- */
.view {
  display: block; outline: none; overflow-x: clip;
  padding: 16px max(var(--gutter), env(safe-area-inset-right, 0px)) 24px max(var(--gutter), env(safe-area-inset-left, 0px));
}
.view > * { max-width: var(--col); margin-inline: auto; }
.view[data-view="lookup"] > *, .view[data-view="entry"] > * { max-width: 1180px; }
.view[data-view="home"] > * { max-width: 880px; }
.page-title { font-size: calc(1.75rem * var(--display-scale)); margin: 4px 0 4px; }

.field-label {
  display: block; margin: 0;
  font-family: var(--font-label, var(--font-mono)); font-size: 0.75rem; font-weight: 600; line-height: 1.2;
  letter-spacing: var(--eyebrow-track, 0.1em); text-transform: uppercase; color: var(--fg-muted);
}
[data-style="record-sheet"] .field-label { color: var(--fg); }

/* ---- wizard: progress dots ----------------------------------------- */
.dots { display: flex; list-style: none; margin: -8px -6px 2px; padding: 0; counter-reset: dot; }
.dot { position: relative; flex: 1 1 0; min-width: 0; }
.dot + .dot::before { /* connector */
  content: ""; position: absolute; top: 15px; right: calc(50% + 11px); left: calc(-50% + 11px);
  height: 2px; background: var(--line-strong); opacity: 0.55;
}
.dot.is-done + .dot::before, .dot.is-current::before { background: var(--accent); opacity: 1; }
.dot > button {
  display: flex; flex-direction: column; align-items: center; gap: 4px; width: 100%; min-height: var(--tap);
  padding: 4px 2px; border: 0; background: none; color: var(--fg-muted); border-radius: var(--radius-sm);
  font-family: var(--font-ui); text-transform: var(--ui-case); letter-spacing: var(--ui-track); touch-action: manipulation;
}
.dot > button:disabled { cursor: default; }
.dot-mark {
  position: relative; z-index: 1; display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid var(--line-strong); background: var(--bg);
}
.dot-mark .ico { width: 13px; height: 13px; }
.dot.is-done .dot-mark { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.dot.is-current .dot-mark { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 22%, transparent); }
.dot.is-current .dot-mark::after { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.dot-label { font-size: 0.75rem; font-weight: 600; line-height: 1.1; letter-spacing: min(var(--ui-track), 0.02em); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dot.is-current .dot-label { color: var(--fg); }
@media (max-width: 400px) { .dot-label { letter-spacing: 0; } .dots { margin-inline: -10px; } }
@media (max-width: 340px) { .dot > button { padding-inline: 0; } .dots { margin-inline: -14px; } }
[data-style="hangar"] .dot-label { font-stretch: 85%; }
@media (hover: hover) { .dot > button:not(:disabled):hover { background: var(--surface-2); } }
[data-style="cockpit"] .dot-mark, [data-style="record-sheet"] .dot-mark { border-radius: 2px; }
[data-style="hangar"] .dot.is-done .dot-mark { color: var(--accent-fg); }

/* ---- wizard: step -------------------------------------------------- */
.wiz { display: flex; flex-direction: column; min-height: calc(100dvh - var(--top-offset) - var(--tabbar-h) - 40px - env(safe-area-inset-bottom, 0px)); }
.wiz-step { flex: 1; }
.step-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 44px; margin-top: 4px; }
.step-top .eyebrow { margin: 0; }
.step-q {
  margin: 4px 0 8px; font-family: var(--font-display);
  font-size: calc(clamp(1.5rem, 6.4vw, 2.1rem) * var(--display-scale)); line-height: 1.05; outline: none;
}
.step-hint { display: flex; align-items: flex-start; gap: 0; margin: 0 0 12px; border-radius: var(--radius-sm); background: var(--surface-2); color: var(--fg-muted); font-size: 0.9375rem; line-height: 1.4; border: 1px solid var(--line); }
.hint-toggle {
  flex: 1; min-width: 0; display: flex; gap: 8px; align-items: center; min-height: var(--tap); padding: 4px 4px 4px 10px;
  border: 0; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; touch-action: manipulation; border-radius: inherit;
}
/* two lines, then "more" (shown only when the text is cut: .is-clamped, set after render) */
.hint-toggle { align-items: flex-start; padding-block: 8px; flex-wrap: wrap; }
.hint-toggle > .ico { margin-top: 2px; }
.hint-t { flex: 1; min-width: 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.step-hint.is-open .hint-t { display: block; -webkit-line-clamp: unset; }
.hint-more { display: none; flex: none; align-items: center; gap: 2px; align-self: flex-end; color: var(--accent-text); font-size: 0.8125rem; font-weight: 700; white-space: nowrap; }
.hint-more .ico { width: 16px; height: 16px; margin: 0; }
.step-hint.is-clamped .hint-more { display: inline-flex; }
.step-hint.is-open .hint-more .ico { transform: rotate(180deg); }
.step-hint > .ref-link, .step-hint > .ref-plain { margin: 0; align-self: center; flex: none; }
.step-hint .ico, .fact .ico { width: 18px; height: 18px; flex: none; color: var(--accent-text); }
.fact .ico { margin-top: 2px; }
.ref-link {
  display: inline-flex; align-items: center; justify-content: center; min-height: var(--tap); min-width: 44px; margin-block: -14px; padding: 0 4px; vertical-align: baseline;
  border: 0; background: none; color: var(--accent-text); font-family: var(--font-mono); font-size: 0.8125rem; font-weight: 600;
  text-decoration: underline; text-decoration-style: dotted; text-underline-offset: 0.2em; cursor: pointer;
}
.ref-plain { font-size: 0.8125rem; color: var(--fg-faint); white-space: nowrap; }
.step-body { padding-bottom: 16px; }

.tn-chip {
  display: inline-flex; align-items: center; gap: 8px; min-height: var(--tap); padding: 0 12px 0 10px;
  border: var(--border-w) solid var(--line-strong); border-radius: 999px; background: var(--surface); color: var(--fg);
  font-family: var(--font-ui); touch-action: manipulation; box-shadow: var(--shadow);
}
[data-style="cockpit"] .tn-chip, [data-style="record-sheet"] .tn-chip, [data-style="field-manual"] .tn-chip { border-radius: var(--radius-sm); }
.tb-right .tn-chip { gap: 6px; padding: 0 10px 0 8px; margin-right: 2px; box-shadow: none; }
@media (max-width: 380px) { .tb-right .tn-chip .tn-chip-l { display: none; } }
.tn-chip::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--warn); }
.tn-chip[data-band="good"]::before { background: var(--good); }
.tn-chip[data-band="bad"]::before { background: var(--bad); }
.tn-chip-l { font-size: 0.75rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--fg-muted); font-family: var(--font-label, var(--font-mono)); }
.tn-chip strong { font-family: var(--tn-font); font-size: 1.35rem; line-height: 1; color: var(--tn-hue); font-variant-numeric: tabular-nums; }
.tn-chip-p { font-size: 0.875rem; color: var(--fg-muted); font-variant-numeric: tabular-nums; }

/* fields */
.field { margin: 0 0 14px; }
.field-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.field-note { font-size: 0.8125rem; color: var(--fg-muted); text-align: right; }
.field-row { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0 14px; }
@media (min-width: 560px) { .field-row { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.field .seg { width: 100%; }
.field-inline { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.fi-head { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.fi-head .field-note { text-align: left; }
.field-inline > .seg { width: auto; flex: 0 1 auto; }
.field-inline > .stepper { flex: none; }
.seg-heat > button, .seg-num > button { min-width: 44px; padding-inline: 0; }
.chip-row.field { margin-bottom: 12px; }
.seg-tall > button { flex-direction: column; min-height: 56px; gap: 0; white-space: normal; line-height: 1.15; }
.seg-tall > button small { font-size: 0.8125rem; }
.seg > [aria-checked="true"] small, .seg > [aria-pressed="true"] small, .seg > [aria-selected="true"] small { opacity: 1; }

.stepper-big > button { width: 64px; min-height: 64px; font-size: 1.75rem; }
.stepper-big > output { min-width: 4.2ch; font-size: 2.25rem; }
.stepper.is-vertical { display: flex; flex-direction: column; width: 100%; }
.stepper.is-vertical > button { width: 100%; min-height: var(--tap); }
.stepper.is-vertical > output { min-height: 44px; border-inline: 0; border-block: 1px solid var(--line); font-size: 1.75rem; padding: 0; }
[data-style="record-sheet"] .stepper.is-vertical > output { border-inline: 0; border-block: var(--border-w) solid var(--line-strong); }

.atk-dmg-grid { display: grid; grid-template-columns: repeat(var(--cols, 3), minmax(0, 1fr)); gap: 10px; }
.atk-dmg-grid[style*="--cols:1"] { max-width: 120px; }
.atk-dmg-col { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.atk-dmg-b { display: flex; align-items: center; justify-content: center; gap: 6px; font-family: var(--font-num); font-weight: 700; font-size: 1rem; color: var(--fg-muted); min-height: 20px; }
.atk-dmg-used { font-family: var(--font-label, var(--font-mono)); font-size: 0.75rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; padding: 1px 5px; border-radius: 3px; background: var(--accent); color: var(--accent-fg); }
.atk-dmg-col.is-used .stepper { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.atk-dmg-col.is-used .atk-dmg-b { color: var(--fg); }

.choice-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.choice {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-height: 64px; padding: 6px 4px;
  border: var(--border-w) solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--fg);
  font-family: var(--font-ui); text-transform: var(--ui-case); letter-spacing: var(--ui-track); touch-action: manipulation; text-align: center;
}
.choice-name { font-weight: var(--ui-weight); font-size: var(--fs-ui); line-height: 1.1; }
.choice-mod { font-family: var(--font-num); font-size: 0.8125rem; color: var(--fg-muted); font-variant-numeric: tabular-nums; }
.choice[aria-checked="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.choice[aria-checked="true"] .choice-mod { color: inherit; }
@media (hover: hover) { .choice:not([aria-checked="true"]):hover { background: var(--surface-2); } }
[data-style="cockpit"] .choice[aria-checked="true"] { box-shadow: 0 0 14px -2px var(--glow); }

.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { max-width: 100%; }
.chip-mod { font-family: var(--font-num); font-size: max(0.78em, 0.75rem); font-weight: 500; letter-spacing: 0; text-transform: none; }
.chip:not([aria-pressed="true"]) .chip-mod { color: var(--fg-muted); }
.chip .count { opacity: 1; }
.chip:not([aria-pressed="true"]):not([aria-selected="true"]) .count { color: var(--fg-muted); }
.chip-more { border-style: dashed; }
.chip-static { display: inline-block; margin: 4px 6px 0 0; padding: 4px 8px; border-radius: var(--chip-radius); background: var(--surface-2); border: 1px solid var(--line); font-size: 0.875rem; }
.fact { display: flex; gap: 10px; align-items: flex-start; margin: 0 0 16px; padding: 10px 12px; border-left: 3px solid var(--accent); background: var(--surface-2); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; font-size: 0.9375rem; }
.fact-inline { display: inline-flex; align-items: center; min-height: var(--tap); color: var(--fg-muted); font-size: 0.9375rem; }

.disclosure { margin: 8px 0 16px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.disc-head {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 52px; padding: 6px 2px; border: 0; background: none; color: var(--fg); text-align: left;
  font-family: var(--font-ui); touch-action: manipulation;
}
.disc-title { font-weight: 600; flex: none; }
.disc-sum { flex: 1; min-width: 0; color: var(--fg-muted); font-size: 0.875rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: right; }
.disc-head .ico { width: 20px; height: 20px; flex: none; color: var(--fg-muted); }
.disclosure.is-open .disc-head .ico { transform: rotate(180deg); }
.disc-body { padding: 4px 0 8px; }
.disc-body .field:last-child, .disc-body .chip-row:last-child { margin-bottom: 4px; }
.disc-body > .chip-row { margin-bottom: 16px; }

/* type tiles */
.type-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.type-tile {
  position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 4px; min-height: 104px; padding: 10px 12px;
  border: var(--border-w) solid var(--line-strong); border-radius: var(--radius); background-color: var(--surface); color: var(--fg);
  box-shadow: var(--shadow); text-align: left; touch-action: manipulation; font-family: var(--font-body);
}
.type-tile .pict { width: 36px; height: 36px; color: var(--accent-text); }
[data-style="hangar"] .type-tile .pict { color: var(--fg); }
.tt-name { font-family: var(--font-heading); font-weight: var(--display-weight); font-stretch: var(--display-stretch); text-transform: var(--display-case); letter-spacing: var(--display-track); font-size: calc(1.15rem * var(--display-scale)); line-height: 1.1; margin-top: auto; }
.tt-sub { font-size: 0.8125rem; color: var(--fg-muted); line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.type-tile[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent), var(--shadow); background-color: var(--accent-soft); }
.type-tile[aria-pressed="true"]::after { content: ""; position: absolute; top: 12px; right: 12px; width: 12px; height: 12px; border-radius: 50%; background: var(--accent); }
@media (hover: hover) { .type-tile:hover { border-color: var(--accent); } }
.type-tile:active { transform: scale(0.985); }
.type-more { grid-column: 1 / -1; min-height: 52px; flex-direction: row; align-items: center; gap: 12px; padding-block: 4px; }
.type-more .tt-name { margin: 0; }
.type-more .pict { width: 28px; height: 28px; }
[data-style="cockpit"] .type-tile, [data-style="record-sheet"] .type-tile { border-radius: var(--radius-sm); }
[data-style="record-sheet"] .type-tile { border-width: 2px; }
[data-style="field-manual"] .type-tile { border-radius: 2px; background-color: var(--surface); }
[data-style="hangar"] .type-tile { background-image: linear-gradient(180deg, var(--surface), var(--surface-2)); }
[data-style="hangar"] .type-tile[aria-pressed="true"] { background-image: none; }
[data-style="cockpit"] .type-tile[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--accent), 0 0 18px -4px var(--glow); }

/* footer */
.wiz-foot {
  position: sticky; bottom: var(--tabbar-h); z-index: 10;
  display: flex; align-items: center; gap: 8px;
  margin: 8px calc(-1 * var(--gutter)) -24px; padding: 8px var(--gutter);
  background-color: var(--bg); background-image: var(--texture);
  border-top: var(--border-w) solid var(--line);
  box-shadow: 0 -10px 14px -12px color-mix(in srgb, var(--fg) 45%, transparent); /* content scrolls on under it */
}
.wiz-foot .btn { min-height: 48px; }
.foot-next { margin-left: auto; min-width: 128px; }
.foot-next .ico { width: 20px; height: 20px; }
.foot-back .ico { width: 20px; height: 20px; }
.foot-skip { flex: 0 1 auto; min-width: 0; margin-inline: auto; padding-inline: 10px; white-space: nowrap; }
.foot-skip .ico { width: 18px; height: 18px; }
.foot-spacer { flex: 1; }
.foot-hint { margin-left: auto; color: var(--fg-muted); font-size: 0.9375rem; padding-right: 4px; }
@media (max-width: 380px) { .foot-back span { display: none; } .foot-back { padding-inline: 0; } .foot-next { min-width: 112px; } }
.wiz-foot .btn-primary:only-of-type { flex: 1; }
.b-banner { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 2px dashed var(--line-strong); border-radius: var(--radius-sm); background: var(--surface-2); font-size: 0.9375rem; }

/* step change animation */
@media (prefers-reduced-motion: no-preference) {
  .enter-next { animation: a-in-next 0.24s cubic-bezier(0.2, 0.7, 0.2, 1); }
  .enter-prev { animation: a-in-prev 0.24s cubic-bezier(0.2, 0.7, 0.2, 1); }
  .disc-head .ico { transition: transform 0.18s ease; }
  .type-tile { transition: border-color 0.12s, box-shadow 0.12s, background-color 0.12s, transform 0.08s; }
  .choice { transition: background-color 0.12s, color 0.12s, border-color 0.12s; }
  .bt-mark { transition: left 0.22s cubic-bezier(0.2, 0.7, 0.2, 1); }
  .vd-fill { transition: height 0.3s ease; }
}
@keyframes a-in-next { from { opacity: 0; transform: translateX(28px); } to { opacity: 1; transform: none; } }
@keyframes a-in-prev { from { opacity: 0; transform: translateX(-28px); } to { opacity: 1; transform: none; } }

/* range */
/* Range step: one tap on the bracket (no distance input) */
.choice-bracket { margin-bottom: 18px; }
.choice-bracket.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.choice-bracket .choice { min-height: 108px; gap: 5px; padding: 10px 4px; }
.choice-bracket .choice-name { font-size: 1.0625rem; }
.choice-bracket .br-in { font-family: var(--font-num); font-size: 0.875rem; color: var(--fg-muted); letter-spacing: 0; text-transform: none; font-variant-numeric: tabular-nums; }
.choice-bracket .br-mod { font-family: var(--tn-font); font-weight: var(--tn-weight); font-stretch: var(--display-stretch); font-size: 1.875rem; line-height: 1; color: var(--tn-hue); letter-spacing: var(--tn-track); }
.choice-bracket .choice[aria-checked="true"] .br-in, .choice-bracket .choice[aria-checked="true"] .br-mod { color: inherit; }
.choice-bracket .choice:disabled { border-style: dashed; color: var(--fg-muted); cursor: default; }
.choice-bracket .choice:disabled .br-mod { font-family: var(--font-ui); font-size: 0.875rem; color: var(--fg-muted); }
@media (max-width: 479px) { .choice-bracket.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .choice-bracket.cols-4 .choice { min-height: 92px; } }
.is-large-text .choice-bracket { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.range-card { padding: 14px; margin-bottom: 18px; border: var(--border-w) solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.range-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.range-val { font-family: var(--tn-font); font-weight: var(--tn-weight); font-stretch: var(--display-stretch); font-size: 4.25rem; line-height: 0.95; color: var(--tn-hue); letter-spacing: var(--tn-track); }
.range-val .unit { font-size: 0.5em; color: var(--fg-muted); margin-left: 2px; }
.range-badge { --badge-c: var(--accent-text); font-size: 0.8125rem; padding: 0.35em 0.65em; }
.range-steps { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin: 12px 0 14px; }
.range-steps .btn { min-height: 56px; padding: 0; font-family: var(--font-num); font-size: 1.3rem; font-weight: 700; }
.bracket-track { position: relative; display: flex; gap: 3px; height: 22px; }
.bt-seg { display: flex; align-items: center; justify-content: center; min-width: 0; border-radius: 4px; background: var(--surface-3); color: var(--fg-muted); font-family: var(--font-num); font-weight: 700; font-size: 0.8125rem; }
/* bracket letters sit above the track, where the range marker never covers them */
.bt-letters { display: flex; gap: 3px; margin-bottom: 8px; font-family: var(--font-num); font-weight: 700; font-size: 0.875rem; line-height: 1.2; color: var(--fg-muted); }
.bt-letters > span { min-width: 0; text-align: center; }
.bt-letters > .is-on { color: var(--accent-text); }
.bt-seg.is-on { background: var(--accent); color: var(--accent-fg); }
.bt-seg.is-out { background: repeating-linear-gradient(-45deg, var(--surface-3) 0 4px, transparent 4px 8px); }
.bt-mark { position: absolute; top: -5px; bottom: -5px; width: 4px; margin-left: -2px; border-radius: 2px; background: var(--fg); box-shadow: 0 0 0 2px var(--surface); }
.bt-scale { position: relative; height: 18px; margin-top: 6px; font-family: var(--font-mono); font-size: 0.75rem; color: var(--fg-muted); }
.bt-scale span { position: absolute; top: 0; transform: translateX(-50%); }
.bt-scale span:first-child { transform: none; left: 0; }
.bt-scale span[style*="right"] { transform: none; }
[data-style="record-sheet"] .bt-seg, [data-style="cockpit"] .bt-seg, [data-style="field-manual"] .bt-seg { border-radius: 0; }
.spotter { margin: 4px 0 18px; display: grid; gap: 12px; }
.spotter .card-title { margin: 0; }

/* extras */
.xgroup { margin: 0 0 18px; }
.xgroup > .field-label { margin-bottom: 8px; }
.followups { margin: -6px 0 18px; padding: 12px; border-radius: var(--radius-sm); background: var(--surface-2); display: grid; gap: 10px; }
.followups .field { margin: 0; }
.picked { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 6px; }
.picked li { display: grid; gap: 2px; padding: 8px 10px; border-left: 3px solid var(--accent); background: var(--surface-2); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.picked .badge { justify-self: start; margin-top: 4px; }
.picked-name { justify-self: start; display: inline-flex; align-items: center; min-height: 32px; padding: 0; border: 0; background: none; color: var(--accent-text); font-weight: 700; text-decoration: underline; text-decoration-style: dotted; text-underline-offset: 0.2em; }
.picked-sum { font-size: 0.875rem; color: var(--fg-muted); }

.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.switch-row .what { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; min-height: var(--tap); padding: 6px 0; cursor: pointer; }
.switch-row .what small { display: block; color: var(--fg-muted); font-size: 0.8125rem; line-height: 1.3; }
.switch-row .what .ico { width: 26px; height: 26px; flex: none; color: var(--accent-text); }
.vd-row { margin-top: 8px; padding: 8px 14px; border: var(--border-w) solid var(--line); border-radius: var(--radius); background: var(--surface); }

/* ---- result -------------------------------------------------------- */
.res-top { display: flex; align-items: center; justify-content: space-between; gap: 4px 8px; min-height: 44px; flex-wrap: wrap; }
.res-top-acts { display: flex; gap: 6px; margin-left: auto; }
.top-warn { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.top-warn li { display: flex; gap: 8px; align-items: center; padding: 6px 6px 6px 10px; border-radius: var(--radius-sm); background: color-mix(in srgb, var(--warn) 12%, var(--surface)); border: 1px solid color-mix(in srgb, var(--warn) 45%, transparent); font-size: 0.875rem; }
.top-warn li > span { flex: 1; min-width: 0; }
.top-warn .ico { width: 18px; height: 18px; flex: none; color: var(--warn); }
.res-top .eyebrow { margin: 0; }
.btn-sm { min-height: var(--tap); padding: 0 10px; }
.btn-sm .ico, .btn .ico { width: 20px; height: 20px; }
.res-main, .res-layout { display: grid; gap: 14px; align-content: start; }
.res-main > .card, .atk-live > .card { margin: 0; }
.res-head { display: grid; gap: 10px; }
.res-tn-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.res-tn-row .tn-readout { min-width: 0; }
.res-odds { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; text-align: right; padding-bottom: 4px; }
.res-pct { font-family: var(--font-num); font-weight: 700; font-size: 2.6rem; line-height: 0.95; color: var(--fg); letter-spacing: -0.02em; }
.res-pct-label { font-size: 0.875rem; color: var(--fg-muted); }
.res-roll { margin: 0; color: var(--fg-muted); font-size: 0.9375rem; }
.illegal { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.illegal li, .warn-list li, .cmp-illegal { display: flex; gap: 8px; align-items: flex-start; }
.illegal li { color: var(--bad); font-weight: 600; }
.illegal .ico, .warn-list .ico, .cmp-illegal .ico { width: 18px; height: 18px; flex: none; margin-top: 2px; }
.sec-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 4px; flex-wrap: wrap; }
.sec-title { margin: 0; font-size: calc(1.1rem * var(--display-scale)); }
.sec-note { font-size: 0.8125rem; color: var(--fg-muted); }
.sub-title { margin: 14px 0 4px; font-size: 0.9375rem; font-family: var(--font-body); text-transform: none; letter-spacing: 0; font-weight: 700; }

.why-list, .atk-dmg-lines { list-style: none; margin: 0; padding: 0; }
.line-item.why { position: relative; }
.row-hit { position: absolute; inset: 0; z-index: 0; width: 100%; padding: 0; border: 0; background: transparent; border-radius: var(--radius-sm); cursor: pointer; }
.row-hit:focus-visible { outline-offset: -2px; }
.line-item.why > .label, .line-item.why > .value { position: relative; pointer-events: none; }
.line-item.why > .ref, .line-item.why > .note { position: relative; z-index: 1; }
.line-item.why > button.ref {
  display: inline-flex; align-items: center; justify-content: flex-end; min-height: var(--tap); min-width: 44px; margin-block: calc((var(--tap) - 1.4em) / -2);
  padding: 0 0 0 6px; border: 0; background: none; color: var(--accent-text); text-decoration: underline; text-decoration-style: dotted; cursor: pointer;
  font-family: var(--font-mono); font-size: 0.75rem;
}
@media (hover: hover) { .line-item.why:has(.row-hit:hover) { background: color-mix(in srgb, var(--accent) 7%, transparent); } }
.row-step { display: inline-block; margin-left: 8px; padding: 0 5px; border-radius: 3px; font-family: var(--font-label, var(--font-mono)); font-size: 0.75rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--fg-faint); border: 1px solid var(--line); vertical-align: 0.15em; }
.line-item.is-total .value { font-family: var(--tn-font); }
.atk-dmg-lines { margin-top: 8px; border-top: 1px solid var(--line); }

.atk-dmg-head { display: grid; gap: 10px; margin: 6px 0 4px; }
.atk-dmg-roll { display: flex; align-items: center; gap: 10px; margin: 0; font-size: 1.125rem; line-height: 1.3; }
.atk-dmg-roll .ico { width: 28px; height: 28px; flex: none; color: var(--accent-text); }
.atk-dmg-roll strong { font-size: 1.5rem; color: var(--tn-hue); }
.atk-dmg-plus { color: var(--fg-muted); font-size: 0.9375rem; }
.atk-dmg-stats { display: flex; flex-wrap: wrap; gap: 8px 28px; }
.atk-dmg-stats > span { display: flex; flex-direction: column; }
.atk-dmg-big { font-family: var(--tn-font); font-weight: var(--tn-weight); font-stretch: var(--display-stretch); font-size: 2.75rem; line-height: 1; color: var(--fg); }
.atk-dmg-cap { font-size: 0.8125rem; color: var(--fg-muted); }
.atk-dmg-note { display: flex; gap: 8px; align-items: flex-start; margin: 0; font-size: 0.875rem; color: var(--fg-muted); }
.atk-dmg-note .ico { width: 18px; height: 18px; flex: none; color: var(--good); margin-top: 1px; }
.vd-mini { display: inline-flex; align-items: center; gap: 8px; min-height: var(--tap); font-size: 0.8125rem; color: var(--fg-muted); cursor: pointer; }

/* VD chart: each bar reads "1 dmg · 26%" underneath */
.vd-chart { display: flex; align-items: flex-end; gap: 4px; margin: 8px 0 4px; padding: 0 2px; }
.vd-bar { flex: 1 1 0; min-width: 0; max-width: 64px; display: grid; grid-template-rows: 96px auto auto; justify-items: center; align-items: end; }
.vd-fill { display: block; width: 100%; height: calc(var(--h) * 92px); min-height: 2px; border-radius: 3px 3px 0 0; background: var(--accent); box-shadow: 0 1px 0 var(--line-strong); }
[data-style="hangar"] .vd-fill { background: var(--tn-hue); }
.vd-k { margin-top: 5px; font-size: 0.75rem; line-height: 1.15; color: var(--fg-muted); white-space: nowrap; }
.vd-k .num { font-size: 0.9375rem; font-weight: 700; color: var(--fg); }
.vd-p { font-family: var(--font-num); font-size: 0.75rem; line-height: 1.15; color: var(--fg-muted); white-space: nowrap; }

.heat-row { display: flex; gap: 10px; align-items: flex-start; margin: 12px 0 0; padding: 10px 12px; border-radius: var(--radius-sm); background: color-mix(in srgb, var(--warn) 10%, var(--surface)); border: 1px solid color-mix(in srgb, var(--warn) 40%, transparent); font-size: 0.9375rem; }
.heat-row .ico { width: 20px; height: 20px; flex: none; color: var(--warn); }
.self-row { display: flex; gap: 12px; align-items: center; margin-top: 12px; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--surface-2); }
.self-row .self-n { font-family: var(--tn-font); font-weight: var(--tn-weight); font-size: 2.2rem; line-height: 1; color: var(--warn); min-width: 1.2ch; text-align: center; }
.self-row.is-bad .self-n { color: var(--bad); }
.self-row small { display: block; color: var(--fg-muted); }
.bullets { margin: 0; padding-left: 1.15em; color: var(--fg-muted); font-size: 0.9375rem; }
.bullets li { margin: 3px 0; }
.exp-line { margin: 14px 0 0; padding-top: 10px; border-top: 1px solid var(--line); font-size: 0.9375rem; }
.exp-line strong { font-size: 1.2rem; }
.partial { margin: 8px 0; padding: 8px 12px; border-left: 3px solid var(--good); background: var(--surface-2); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.partial p { margin: 0; }
.sec-roll { display: flex; gap: 8px; align-items: center; margin: 6px 0; font-size: 0.9375rem; }
.sec-roll .ico { width: 18px; height: 18px; color: var(--accent-text); }
.warn-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; font-size: 0.9375rem; color: var(--fg-muted); }
.warn-list .ico { color: var(--warn); }
.res-warn { border-left: 3px solid var(--warn); }

.res-actions { display: grid; gap: 10px; margin-top: 4px; }
.res-actions-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 4px; }
.res-actions .btn, .res-actions-row .btn { min-height: 52px; }
.res-actions .btn-primary { font-size: 1rem; }
.res-recap { order: 2; }
.recap { list-style: none; margin: 4px 0 0; padding: 0; }
.recap-row {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 56px; padding: 8px 4px; border: 0; border-bottom: 1px solid var(--line);
  background: none; color: var(--fg); text-align: left; font-family: var(--font-body);
}
.recap li:last-child .recap-row { border-bottom: 0; }
.recap-n { display: grid; place-items: center; width: 26px; height: 26px; flex: none; border-radius: 50%; background: var(--surface-3); font-size: 0.8125rem; font-weight: 700; }
.recap-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.recap-l { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--fg-muted); font-family: var(--font-label, var(--font-mono)); }
.recap-v { font-weight: 600; }
.recap-row .ico { width: 18px; height: 18px; color: var(--fg-muted); flex: none; }
@media (hover: hover) { .recap-row:hover { background: var(--surface-2); } }

/* compare */
.cmp-verdict { font-size: 1.0625rem; margin: 0 0 8px; }
.cmp-diff { margin: 0 0 12px; }
.cmp-diff .field-label { margin-bottom: 2px; }
.cmp-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 12px; }
.cmp-col { --card-pad: 12px; display: grid; gap: 10px; align-content: start; min-width: 0; }
.cmp-col.is-better { border-color: var(--good); box-shadow: 0 0 0 2px var(--good), var(--shadow); }
.cmp-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.cmp-name { margin: 0; font-family: var(--font-heading); font-weight: var(--display-weight); text-transform: var(--display-case); font-stretch: var(--display-stretch); letter-spacing: var(--display-track); font-size: 1rem; line-height: 1.2; min-width: 0; overflow-wrap: anywhere; }
.cmp-q { font-size: calc(clamp(1.3rem, 5.6vw, 1.9rem) * var(--display-scale)); overflow-wrap: anywhere; }
.cmp-or { color: var(--fg-muted); font-size: 0.8em; }
.cmp-key dd { font-size: 1.375rem; }
.cmp-cost.is-cost dd { color: var(--warn); }
.cmp-more summary { display: flex; align-items: center; min-height: 44px; cursor: pointer; font-size: 0.875rem; font-weight: 600; color: var(--fg-muted); }
.cmp-best .ico { width: 12px; height: 12px; }
.cmp-tn { --tn-size: clamp(2.8rem, 14vw, 4rem); }
.cmp-stats { display: grid; gap: 0; margin: 0; }
.cmp-stats > div { display: flex; justify-content: space-between; align-items: baseline; gap: 6px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.cmp-stats dt { font-size: 0.8125rem; color: var(--fg-muted); }
.cmp-stats dd { margin: 0; font-weight: 700; font-size: 1.125rem; text-align: right; }
.cmp-stats dd small { display: block; font-size: 0.75rem; font-weight: 400; color: var(--fg-muted); }
.cmp-recap { list-style: none; margin: 0; padding: 0; font-size: 0.8125rem; color: var(--fg-muted); display: grid; gap: 4px; }
.cmp-recap span { display: block; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--fg-muted); }
.cmp-illegal { color: var(--bad); font-size: 0.875rem; margin: 0; }
.ab-tag { display: inline-grid; place-items: center; width: 28px; height: 28px; flex: none; border-radius: 50%; font-family: var(--font-num); font-weight: 800; font-size: 0.9375rem; background: var(--accent); color: var(--accent-fg); }
.ab-tag.is-b { background: var(--fg); color: var(--bg); }

/* desktop attack */
.atk-wide { display: grid; grid-template-columns: minmax(0, 600px) minmax(0, 470px); gap: 32px; justify-content: center; max-width: none !important; }
.view[data-view="attack"] > .atk-wide { max-width: 1140px !important; }
.atk-live { position: sticky; top: calc(var(--top-offset) + 12px); align-self: start; max-height: calc(100dvh - var(--top-offset) - var(--tabbar-h) - 32px); overflow: auto; display: grid; gap: 12px; padding: 2px 4px 12px 2px; }
.atk-live .res-head .tn-readout { --tn-size: 4.5rem; }
.live-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 32px; }
.live-head .eyebrow { margin: 0; }
@media (min-width: 1100px) {
  .view[data-view="attack"] > .atk-narrow { max-width: 1100px; }
  .atk-narrow .wiz { max-width: 640px; margin-inline: auto; }
  .atk-narrow .res-layout { grid-template-columns: 340px minmax(0, 1fr); gap: 24px; align-items: start; }
  .atk-narrow .res-recap { order: -1; position: sticky; top: calc(var(--top-offset) + 12px); }
  .atk-narrow .res-layout.no-recap { grid-template-columns: minmax(0, 720px); justify-content: center; }
  .atk-narrow .res-top { max-width: none; }
  .atk-narrow .cmp-screen { max-width: 900px; margin-inline: auto; }
  .wiz-foot { margin-inline: 0; border-radius: var(--radius) var(--radius) 0 0; border: var(--border-w) solid var(--line); border-bottom: 0; }
}

/* ---- home ---------------------------------------------------------- */
.home { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
.home-hero .eyebrow { margin-bottom: 2px; }
.home-title { margin: 0; font-size: calc(clamp(1.9rem, 8vw, 2.6rem) * var(--display-scale)); }
.home-tiles { display: grid; gap: 10px; }
.home-tile { display: flex; align-items: center; gap: 14px; min-height: 92px; padding: 16px; text-decoration: none; color: var(--fg); }
.ht-icon { display: grid; place-items: center; width: 56px; height: 56px; flex: none; border-radius: var(--radius-sm); background: var(--accent-soft); color: var(--accent-text); }
.ht-icon .ico { width: 30px; height: 30px; }
.tile-attack .ht-icon { background: var(--accent); color: var(--accent-fg); }
.ht-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.ht-name { font-family: var(--font-heading); font-weight: var(--display-weight); font-stretch: var(--display-stretch); text-transform: var(--display-case); letter-spacing: var(--display-track); font-size: calc(1.35rem * var(--display-scale)); line-height: 1.1; }
.ht-sub { font-size: 0.9rem; color: var(--fg-muted); line-height: 1.3; }
.ht-go .ico { width: 22px; height: 22px; color: var(--fg-muted); }
.tile-attack { min-height: 112px; }
.tile-attack .ht-icon { width: 68px; height: 68px; }
.tile-attack .ht-icon .ico { width: 38px; height: 38px; }
.tile-attack .ht-name { font-size: calc(1.6rem * var(--display-scale)); }
[data-style="cockpit"] .tile-attack .ht-icon { box-shadow: 0 0 18px -4px var(--glow); }
.vd-headline { --card-pad: 10px 16px; }
.vd-headline.is-on { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), var(--shadow); }
.vd-headline .what strong { font-size: 1.125rem; font-family: var(--font-heading); text-transform: var(--display-case); font-stretch: var(--display-stretch); letter-spacing: var(--display-track); }
.vd-icon { display: grid; place-items: center; width: 44px; height: 44px; flex: none; border-radius: var(--radius-sm); background: var(--surface-2); }
.vd-icon .ico { width: 26px; height: 26px; }
.home-topics .field-label { margin-bottom: 8px; }
.topic-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
@media (min-width: 720px) { .topic-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.topic-link {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 52px; padding: 0 14px;
  border: var(--border-w) solid var(--line); border-radius: var(--radius-sm); background: var(--surface); color: var(--fg);
  text-decoration: none; font-weight: 600; font-family: var(--font-ui); text-transform: var(--ui-case); letter-spacing: var(--ui-track);
}
@media (hover: hover) { .topic-link:hover { border-color: var(--accent); } }
.topic-p { font-size: 0.75rem; color: var(--fg-muted); font-weight: 400; text-transform: none; letter-spacing: 0; }

/* ---- rules ---------------------------------------------------------- */
.rules-page { display: grid; gap: 14px; }
.rules-page > p { margin: 0; }
.rules-vd { --card-pad: 6px 16px; border-color: var(--accent); }
.rules-card { --card-pad: 2px 16px; }
.rules-sec { display: grid; gap: 8px; }
.rules-sec > p { margin: 0; }
.rule-row { border-bottom: 1px solid var(--line); padding: 4px 0; }
.rules-card .rule-row:last-child, .rules-vd .rule-row:last-child { border-bottom: 0; }
.rule-row .what { flex-direction: column; align-items: flex-start; gap: 2px; }
.rule-name { font-weight: 700; }
.rule-meta { color: var(--fg-muted) !important; }
.rule-row.is-sub { margin-left: 14px; padding-left: 14px; border-left: 2px solid var(--line-strong); }
.rule-row.is-off .rule-name { color: var(--fg-muted); }
.rules-all { --card-pad: 12px 16px; margin-bottom: 8px; }
.rules-all ul { list-style: none; margin: 0; padding: 0; }
.rules-all li { display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 44px; border-bottom: 1px solid var(--line); font-size: 0.9375rem; }
.rules-all li:last-child { border-bottom: 0; }
.rules-all a { display: inline-flex; align-items: center; min-height: 44px; min-width: 44px; }
.rules-all .mono { font-size: 0.75rem; white-space: nowrap; }
.sheet .rules-vd, .sheet .rules-sec { margin-bottom: 12px; }

/* ---- lookup -------------------------------------------------------- */
.lk { display: block; }
.lk.is-wide { display: grid; grid-template-columns: minmax(340px, 460px) minmax(0, 1fr); gap: 24px; align-items: start; }
.lk-top {
  position: sticky; top: var(--top-offset); z-index: 5;
  display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; margin: -16px calc(-1 * var(--gutter)) 0; padding: 12px var(--gutter) 6px;
  background-color: var(--bg); background-image: var(--texture); border-bottom: 1px solid var(--line);
}
.lk.is-wide .lk-top { margin-inline: 0; padding-inline: 0; }
.lk-search { min-height: 56px; font-size: 1.125rem; }
.lk-search input { min-height: 54px; min-width: 0; flex: 1 1 auto; font-size: max(18px, 1.125rem) !important; }
.kind-tabs { display: flex; flex-wrap: wrap; gap: 6px; padding: 2px 0 4px; }
.lk.is-wide .kind-tabs { margin-inline: 0; padding-inline: 0; gap: 6px; }
.lk.is-wide .kind-tabs .chip { padding-inline: 0.7em; }
.kind-tabs::-webkit-scrollbar { display: none; }
.kind-tabs .chip { flex: 0 1 auto; padding-inline: 0.75em; }
.lk-opt { min-height: 44px; }
.lk-opt .what { flex-direction: column; align-items: flex-start; gap: 0; padding: 2px 0; }
.lk-results { padding-top: 8px; }
.lk-h { margin: 14px 0 6px; }
.lk-count { margin: 6px 0; font-size: 0.875rem; color: var(--fg-muted); }
.lk-empty { padding: 24px 4px; color: var(--fg-muted); }
.lk-list { list-style: none; margin: 0; padding: 0; }
.lk-row {
  display: grid; gap: 4px; padding: 12px 10px; min-height: 64px; border-bottom: 1px solid var(--line); color: var(--fg); text-decoration: none;
  border-radius: var(--radius-sm);
}
@media (hover: hover) { .lk-row:hover { background: var(--surface-2); } }
.lk-row.is-active { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
.lk-row-top { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px; }
.lk-name { font-weight: 700; font-size: 1.0625rem; }
.lk-row-sum { color: var(--fg-muted); font-size: 0.9rem; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.lk-row-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.lk-page { font-family: var(--font-mono); font-size: 0.75rem; color: var(--fg-muted); }
.lk-detail { position: sticky; top: calc(var(--top-offset) + 12px); max-height: calc(100dvh - var(--top-offset) - var(--tabbar-h) - 32px); overflow: auto; --card-pad: 20px 24px; }
.lk-placeholder { display: grid; place-items: center; align-content: center; gap: 10px; min-height: 320px; border: 2px dashed var(--line); border-radius: var(--radius); color: var(--fg-muted); }
.lk-placeholder .ico { width: 40px; height: 40px; }

/* entry */
.entry { display: grid; gap: 14px; min-width: 0; }
.entry > *, .entry-head > *, .entry-page, .lk-detail { min-width: 0; }
.entry-title { overflow-wrap: anywhere; }
.entry-head { display: grid; gap: 6px; }
.entry-badges { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.entry-page { font-size: 0.8125rem; color: var(--fg-muted); margin-left: auto; }
.entry-title { margin: 0; font-size: calc(clamp(1.8rem, 8vw, 2.4rem) * var(--display-scale)); line-height: 1.05; outline: none; }
.entry-abbr { margin: 0; }
.kbd-lg { font-size: 1.125rem; padding: 0.15em 0.5em 0.1em; }
.entry-summary { margin: 0; font-size: 1.1875rem; line-height: 1.45; }
.entry-meta { margin: 0; display: flex; flex-wrap: wrap; gap: 4px 6px; font-size: 0.9375rem; }
.entry-details ul { margin: 6px 0 0; padding-left: 1.15em; }
.entry-details li { margin: 6px 0; line-height: 1.45; }
.fx .eyebrow { margin-bottom: 8px; }
.fx-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.fx-cell { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--line); min-width: 0; }
.fx-val { font-family: var(--font-num); font-weight: 700; font-size: clamp(1.25rem, 6vw, 1.75rem); line-height: 1.05; color: var(--tn-hue); overflow-wrap: anywhere; min-width: 0; }
.fx-val.is-long { font-size: 1.0625rem; line-height: 1.25; }
.fx-what { font-family: var(--font-label, var(--font-mono)); font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--fg); }
.fx-when { font-size: 0.8125rem; color: var(--fg-muted); line-height: 1.3; }
.fx-types { font-size: 0.75rem; color: var(--fg-muted); }
.vd-note { --card-pad: 12px 14px; border-left: 3px solid var(--accent); box-shadow: none; }
.vd-note-head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.vd-note-head .ico { width: 22px; height: 22px; color: var(--accent-text); }
.vd-note-head .eyebrow { margin: 0; }
.vd-note p { margin: 0 0 6px; }
.vd-rows { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.vd-rows li { display: grid; gap: 2px; padding-top: 8px; border-top: 1px solid var(--line); font-size: 0.9375rem; }
.vd-rows em { font-size: 0.8125rem; color: var(--warn); font-style: normal; }
.entry-related .eyebrow { margin-bottom: 8px; }
.entry-related .chip { text-decoration: none; white-space: normal; min-width: 0; height: auto; text-align: left; overflow-wrap: anywhere; }
.entry-page-wrap, .entry-page { padding-top: 4px; }

/* ---- sheet --------------------------------------------------------- */
#sheet-root { position: fixed; inset: 0; z-index: 50; pointer-events: none; }
#sheet-root:empty { display: none; }
#sheet-root .sheet-backdrop { position: absolute; inset: 0; opacity: 0; pointer-events: auto; }
#sheet-root .sheet {
  position: absolute; left: 0; right: 0; bottom: 0; margin-inline: auto; max-width: 640px; pointer-events: auto;
  max-height: min(88dvh, 860px); transform: translateY(100%);
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
}
#sheet-root.is-open .sheet-backdrop { opacity: 1; }
#sheet-root.is-open .sheet { transform: none; }
@media (prefers-reduced-motion: no-preference) {
  #sheet-root .sheet { transition: transform 0.22s cubic-bezier(0.2, 0.8, 0.2, 1); }
  #sheet-root .sheet-backdrop { transition: opacity 0.18s ease; }
}
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.sheet-head .eyebrow { margin: 0; }
.sheet-title { margin: 0; font-size: calc(1.3rem * var(--display-scale)); outline: none; }
.sheet .field-label { margin: 14px 0 8px; }
.sheet-list { display: grid; gap: 8px; }
.sheet-item {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 60px; padding: 10px 14px; text-align: left;
  border: var(--border-w) solid var(--line); border-radius: var(--radius-sm); background: var(--surface-2); color: var(--fg); font-family: var(--font-body);
}
.sheet-item > span { flex: 1; min-width: 0; }
.sheet-item .si-main { display: block; font-weight: 700; }
.sheet-item .si-sub { display: block; font-size: 0.875rem; color: var(--fg-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sheet-item .ico { width: 18px; height: 18px; flex: none; color: var(--fg-muted); }
.sheet-item { flex-wrap: wrap; }
.sheet-item .si-main { flex-basis: calc(100% - 30px); }
.sheet-item .si-sub { order: 3; flex-basis: 100%; }
@media (hover: hover) { .sheet-item:hover { border-color: var(--accent); } }
.sheet-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; }
.sheet-actions .btn { flex: 1 1 auto; text-decoration: none; }
.sheet-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 16px 0 0; font-size: 0.875rem; }
.sheet-foot a { display: inline-flex; align-items: center; min-height: 44px; font-weight: 600; }
.sheet-entry .entry-title { font-size: calc(1.6rem * var(--display-scale)); }

.style-list { display: grid; gap: 8px; }
.style-item {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 56px; padding: 6px 12px 6px 8px;
  border: var(--border-w) solid var(--line); border-radius: var(--radius-sm); background: var(--surface); color: var(--fg); text-align: left; font-family: var(--font-body);
}
.style-item[aria-checked="true"] { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.swatch { position: relative; width: 44px; height: 40px; flex: none; border-radius: 6px; border: 1px solid var(--line-strong); overflow: hidden; }
.swatch i { position: absolute; left: 6px; top: 6px; width: 22px; height: 16px; border-radius: 3px; border: 2px solid; }
.swatch b { position: absolute; right: 5px; bottom: 5px; width: 14px; height: 14px; border-radius: 50%; }
.style-name { flex: 1; font-weight: 600; }
.style-on .ico { width: 20px; height: 20px; color: var(--accent-text); }

.spa-list { list-style: none; margin: 10px 0 0; padding: 0; }
.spa-item {
  display: flex; gap: 12px; align-items: flex-start; width: 100%; min-height: 56px; padding: 10px 4px; border: 0; border-bottom: 1px solid var(--line);
  background: none; color: var(--fg); text-align: left; font-family: var(--font-body);
}
.spa-check { display: grid; place-items: center; width: 26px; height: 26px; flex: none; margin-top: 1px; border: 2px solid var(--line-strong); border-radius: 6px; color: transparent; }
.spa-check .ico { width: 16px; height: 16px; }
.spa-item[aria-pressed="true"] .spa-check { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.spa-txt { display: grid; gap: 2px; min-width: 0; }
.spa-name { font-weight: 700; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.spa-cost { font-family: var(--font-mono); font-size: 0.75rem; font-weight: 400; color: var(--fg-muted); }
.spa-sum { font-size: 0.875rem; color: var(--fg-muted); }
.spa-cut { padding: 16px 4px 4px; }
.spa-item.is-misfit:disabled { color: var(--fg-muted); border-bottom-style: dashed; }
.picked li.is-misfit { border-left-color: var(--bad); }
.range-uw { margin: 12px 0 0; }

/* toast */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + 84px); z-index: 60; transform: translate(-50%, 8px);
  max-width: calc(100vw - 32px); padding: 10px 16px; border-radius: 999px; background: var(--fg); color: var(--bg);
  font-size: 0.9375rem; font-weight: 600; box-shadow: var(--shadow); opacity: 0; pointer-events: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }
@media (prefers-reduced-motion: no-preference) { .toast { transition: opacity 0.2s, transform 0.2s; } }
[data-style="cockpit"] .toast, [data-style="record-sheet"] .toast { border-radius: var(--radius-sm); }

/* =====================================================================
   Phase 2 shell additions
   ===================================================================== */

/* ---- style button (current style's swatch, drawn from its own tokens) */
.style-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; flex: none;
  min-height: var(--tap); min-width: var(--tap); padding: 0 6px; margin-left: 2px;
  border: var(--border-w) solid transparent; border-radius: var(--radius-sm); background: transparent; color: var(--fg);
  font-family: var(--font-ui); font-size: 0.8125rem; font-weight: var(--ui-weight); text-transform: var(--ui-case);
  letter-spacing: min(var(--ui-track), 0.04em); touch-action: manipulation;
}
.style-sw { position: relative; width: 32px; height: 28px; flex: none; border-radius: 6px; border: 1px solid var(--line-strong); background: var(--bg); overflow: hidden; }
.style-sw i { position: absolute; left: 4px; top: 4px; width: 17px; height: 12px; border-radius: 2px; border: 2px solid var(--fg); background: var(--surface); }
.style-sw b { position: absolute; right: 3px; bottom: 3px; width: 11px; height: 11px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 1px var(--bg); }
[data-style="cockpit"] .style-sw, [data-style="record-sheet"] .style-sw { border-radius: 2px; }
.style-btn-name { display: none; white-space: nowrap; }
@media (hover: hover) { .style-btn:hover { background-color: var(--surface-2); } }
.style-btn:active { background-color: var(--surface-3); }
@media (min-width: 600px) {
  .style-btn-name { display: inline; }
  .style-btn { padding: 0 12px 0 6px; border-color: var(--line); }
}
.style-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.style-blurb { font-size: 0.8125rem; color: var(--fg-muted); line-height: 1.25; }

/* ---- module host ----------------------------------------------------- */
.view[data-view="pv"] > *, .view[data-view="turn"] > *, .view[data-view="damage"] > * { max-width: 1120px; }
.mod-loading { display: flex; align-items: center; gap: 12px; min-height: 120px; justify-content: center; color: var(--fg-muted); }
.spinner { width: 20px; height: 20px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); }
@media (prefers-reduced-motion: no-preference) { .spinner { animation: spin 0.8s linear infinite; } }
@keyframes spin { to { transform: rotate(360deg); } }
.mod-error { display: grid; gap: 8px; justify-items: start; }

/* ---- home ------------------------------------------------------------- */
.home-title { margin: 0; }
.home-main { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
.home-search {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 56px; padding: 0 14px;
  border: var(--border-w) solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--fg-muted);
  font-family: var(--font-body); font-size: 1rem; text-align: left; touch-action: manipulation; box-shadow: var(--shadow);
}
.home-search .ico { width: 22px; height: 22px; color: var(--fg-muted); }
.hs-txt { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hs-kbd { flex: none; }
@media (hover: hover) { .home-search:hover { border-color: var(--accent); } }
.home-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.home-tile.tile-sm { flex-direction: column; align-items: flex-start; gap: 8px; min-height: 0; padding: 12px 14px 14px; }
.tile-sm .ht-icon { width: 36px; height: 36px; }
.tile-sm .ht-icon .ico { width: 22px; height: 22px; }
.tile-sm .ht-txt { gap: 3px; }
.tile-sm .ht-name { font-size: calc(1.05rem * var(--display-scale)); line-height: 1.1; }
.tile-sm .ht-sub { font-size: 0.8125rem; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tile-sm .ht-go { display: none; }
.rip { --card-pad: 12px 16px 14px; display: grid; gap: 4px; }
.rip.is-on { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), var(--shadow); }
.rip-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.rip-all { display: inline-flex; align-items: center; gap: 2px; min-height: var(--tap); padding-left: 8px; font-size: 0.875rem; font-weight: 600; text-decoration: none; white-space: nowrap; }
.rip-all .ico { width: 16px; height: 16px; }
.rip-vd .what strong { font-size: 1.125rem; font-family: var(--font-heading); text-transform: var(--display-case); font-stretch: var(--display-stretch); letter-spacing: var(--display-track); }
.rip-kids { display: flex; flex-wrap: wrap; gap: 6px; padding: 2px 0 4px; }
/* VD off: its options keep their setting but show as inactive (dashed, muted), with the reason in words */
.rip-chip.is-inactive { border-style: dashed; color: var(--fg-muted); background-color: transparent; }
.rip-chip.is-inactive[aria-pressed="true"] { border-color: var(--accent); color: var(--fg-muted); background-color: transparent; }
.rip-kids-note { align-self: center; font-size: 0.8125rem; color: var(--fg-muted); font-style: italic; }
.rip-chip { padding-inline: 0.7em; }
.rip-others { margin: 4px 0 0; padding-top: 8px; border-top: 1px solid var(--line); display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 0.875rem; }
.chip-link { text-decoration: none; }
.home-recent { display: grid; gap: 4px; }
.recent-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.recent-row { display: flex; align-items: center; gap: 8px; min-height: 48px; padding: 6px 4px; border-bottom: 1px solid var(--line); color: var(--fg); text-decoration: none; }
.recent-name { flex: 1; min-width: 0; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (hover: hover) { .recent-row:hover { background: var(--surface-2); } }
@media (min-width: 640px) {
  .home-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (min-width: 900px) {
  .home { grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); align-items: start; gap: 18px 24px; }
  .home > .home-hero, .home > .home-main, .home > .home-grid { grid-column: 1 / -1; }
  .home-main { grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); align-items: stretch; }
  .home-search { min-height: 0; height: 100%; flex-direction: column; justify-content: center; align-items: flex-start; gap: 8px; padding: 16px; }
  .home-search .hs-txt { white-space: normal; font-size: 1.0625rem; }
  .home > .rip { grid-column: 1; grid-row: span 2; }
  .home-tile.tile-sm { min-height: 150px; }
  .home .topic-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ---- rule switches: reset ------------------------------------------- */
.reset-box { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.reset-box .small { display: inline-flex; align-items: center; gap: 6px; }
.reset-box.is-clean .ico { width: 16px; height: 16px; color: var(--good); }
.reset-box.is-confirm { display: grid; gap: 6px; padding: 12px 14px; border: 2px solid var(--warn); border-radius: var(--radius-sm); background: color-mix(in srgb, var(--warn) 9%, var(--surface)); }
.reset-box.is-confirm p { margin: 0; }
.reset-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.reset-actions .btn { flex: 1 1 auto; white-space: nowrap; }
.rule-changed { --badge-c: var(--accent-text); }
.rule-row .rule-ref { margin-block: 0; flex: none; }

/* ---- errata ---------------------------------------------------------- */
.badge-errata { --badge-c: var(--warn); }
.errata-note { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: var(--radius-sm); border: 1px solid color-mix(in srgb, var(--warn) 45%, transparent); background: color-mix(in srgb, var(--warn) 8%, var(--surface)); font-size: 0.9375rem; line-height: 1.4; }
.errata-icon .ico { width: 22px; height: 22px; color: var(--warn); }
.errata-txt small { display: block; margin-top: 4px; color: var(--fg-muted); }
.errata-ref { font-family: var(--font-mono); font-size: 0.875rem; }

/* ---- desktop: rail + dialog sheets ---------------------------------- */
.rail { display: none; }
@media (min-width: 900px) {
  :root { --rail-w: 92px; }
  .tabbar { display: none; }
  .app { padding-left: var(--rail-w); padding-bottom: 24px; }
  .view[data-view="home"] { padding-bottom: 32px; }
  .topbar { margin-left: calc(-1 * var(--rail-w)); }
  .topbar-inner { grid-template-columns: var(--rail-w) auto minmax(0, 1fr) auto; grid-template-areas: "brand left title right"; padding-left: 0; padding-right: max(16px, env(safe-area-inset-right, 0px)); }
  .tb-brand { display: grid; place-items: center; height: 100%; }
  .tb-mark { display: grid; place-items: center; width: 40px; height: 40px; border-radius: var(--radius-sm); background: var(--accent); color: var(--accent-fg); }
  .tb-mark svg { width: 24px; height: 24px; }
  [data-style="cockpit"] .tb-mark { box-shadow: 0 0 16px -3px var(--glow); }
  .rail {
    display: flex; flex-direction: column; gap: 4px; position: fixed; z-index: 15; left: 0; bottom: 0; top: var(--top-offset);
    width: var(--rail-w); padding: 12px 8px calc(12px + env(safe-area-inset-bottom, 0px)); overflow-y: auto;
    border-right: var(--border-w) solid var(--line); background-color: var(--tabbar-bg, var(--surface));
  }
  .rail a {
    position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
    min-height: 64px; padding: 8px 4px; border-radius: var(--radius-sm); color: var(--fg-muted); text-decoration: none;
    font-family: var(--font-ui); font-size: 0.75rem; font-weight: var(--ui-weight); line-height: 1.1; text-align: center;
    text-transform: var(--ui-case); letter-spacing: min(var(--ui-track), 0.04em); touch-action: manipulation;
  }
  .rail a svg { width: 24px; height: 24px; flex: none; }
  .rail a[aria-current="page"] { color: var(--accent-text); background: var(--accent-soft); }
  .rail a[aria-current="page"]::before { content: ""; position: absolute; left: -8px; top: 12px; bottom: 12px; width: 3px; border-radius: 0 2px 2px 0; background: var(--accent); }
  @media (hover: hover) { .rail a:not([aria-current="page"]):hover { color: var(--fg); background: var(--surface-2); } }
  .rail a[data-tab="pv"] { margin-top: 13px; }
  .rail a[data-tab="pv"]::after { content: ""; position: absolute; top: -9px; left: 18%; right: 18%; height: 1px; background: var(--line-strong); }
  [data-style="cockpit"] .rail a[aria-current="page"] svg { filter: drop-shadow(0 0 4px var(--glow)); }

  #sheet-root .sheet {
    top: 50%; bottom: auto; max-width: 600px; max-height: min(86dvh, 860px);
    border-bottom: var(--border-w) solid var(--line-strong); border-radius: var(--sheet-radius);
    padding-bottom: 1.25rem; transform: translateY(-46%); opacity: 0;
  }
  #sheet-root .sheet::before { display: none; }
  #sheet-root.is-open .sheet { transform: translateY(-50%); opacity: 1; }
  @media (prefers-reduced-motion: no-preference) { #sheet-root .sheet { transition: transform 0.2s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.16s ease; } }
}

/* ---- attack: phase 2 inputs ---------------------------------------- */
.fact-body { min-width: 0; }
.fact-body p { margin: 0 0 6px; }
.fact-body p:last-child { margin-bottom: 0; }
.fact.small { font-size: 0.875rem; }
.fact .ref-link, .water-tip .ref-link, .range-flat-note .ref-link { vertical-align: baseline; }
/* special weapon attacks under "More…" */
.type-sub { display: flex; flex-direction: column; gap: 2px; margin: 20px 0 10px; font-size: 1rem; }
.type-sub .field-label { margin: 0; }
.type-sub-note { font-family: var(--font-body); font-weight: 400; font-size: 0.875rem; color: var(--fg-muted); text-transform: none; letter-spacing: 0; }
.type-tile.is-variant { flex-direction: row; align-items: center; gap: 10px; min-height: 64px; padding: 8px 12px; }
.type-tile.is-variant .pict { width: 28px; height: 28px; flex: none; }
.tt-txt { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.type-tile.is-variant .tt-name { margin: 0; font-size: calc(1.02rem * var(--display-scale)); }
.type-tile.is-variant .tt-sub { -webkit-line-clamp: 2; }
.type-tile.is-variant[aria-pressed="true"]::after { top: 8px; right: 8px; width: 10px; height: 10px; }
.type-grid-v .type-tile.is-variant:last-child:nth-child(odd) { grid-column: 1 / -1; }
.type-more .tt-txt { gap: 0; }
/* artillery */
.art-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.art-item {
  display: grid; align-content: start; gap: 2px; min-height: 64px; padding: 8px 10px; text-align: left;
  border: var(--border-w) solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--fg);
  font-family: var(--font-body); touch-action: manipulation;
}
.art-code { font-family: var(--font-mono); font-weight: 700; font-size: 0.8125rem; color: var(--accent-text); letter-spacing: 0.02em; }
.art-name { font-weight: 700; font-size: 0.9375rem; line-height: 1.2; }
.art-meta { font-size: 0.8125rem; color: var(--fg-muted); line-height: 1.25; }
.art-item[aria-checked="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.art-item[aria-checked="true"] .art-code, .art-item[aria-checked="true"] .art-meta { color: inherit; }
@media (hover: hover) { .art-item:not([aria-checked="true"]):hover { background: var(--surface-2); } }
[data-style="cockpit"] .art-item[aria-checked="true"] { box-shadow: 0 0 14px -2px var(--glow); }
@media (min-width: 640px) { .art-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.fact-art .ico, .fact-water .ico { color: var(--accent-text); }
.range-card.is-flat .range-val { font-size: 3.25rem; }
.bracket-track.is-flat .bt-seg { font-family: var(--font-body); font-weight: 600; font-size: 0.8125rem; }
.range-flat-note { margin: 12px 0 0; font-size: 0.9375rem; color: var(--fg-muted); }
.range-flat-note strong { color: var(--fg); }
/* water */
.field-water { margin-bottom: 8px; }
.water-tip { margin: 0 0 16px; font-size: 0.875rem; color: var(--fg-muted); line-height: 1.45; }
.water-tip strong, .water-tip em { color: var(--fg); font-style: normal; font-weight: 600; }
/* choices */
.seg-2 > button { white-space: normal; line-height: 1.15; min-height: 52px; }
.seg-wrap { flex-wrap: wrap; }
.seg-wrap > button { flex: 1 0 auto; min-width: 56px; }
.choice-air { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.choice-air .choice { min-height: 56px; }
/* follow-ups, ammo, other modifier */
.ammo-fu { margin-top: 10px; }
.other-mod { margin: 4px 0 6px; padding: 10px 14px 0; border: 1px dashed var(--line-strong); border-radius: var(--radius); }
.other-mod .field-inline { margin-bottom: 10px; }
.spotter .disclosure { margin: 0; border-bottom: 0; }
.spotter .disc-body .field { margin-bottom: 4px; }
/* result: crits and heat */
.crit-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 14px 0 4px; flex-wrap: wrap; }
.crit-head .sub-title { margin: 0; }
.crit-link { gap: 6px; text-decoration: none; }
.crit-link .ico { width: 18px; height: 18px; }
.heat-lines { margin-top: 6px; border-top: 0; }
.live-head .btn-sm { padding: 0 10px; font-size: 0.875rem; }
.live-head .btn-sm .ico { width: 16px; height: 16px; }

/* =====================================================================
   Refinement round: wording, presets, lookup header, two panes, large text
   ===================================================================== */

/* ---- switch rows: the whole row toggles, state in words ------------- */
.sw-hit { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; min-height: var(--tap); cursor: pointer; }
.sw-hit > .what { flex: 1; min-width: 0; }
label.switch-row { cursor: pointer; }
label.switch-row > .what { flex: 1; min-width: 0; }
.sw-state { flex: none; min-width: 2.1em; text-align: right; font-family: var(--font-ui); font-size: 0.8125rem; font-weight: 700; text-transform: var(--ui-case); letter-spacing: min(var(--ui-track), 0.04em); color: var(--fg-muted); }
.sw-hit:has(.switch:checked) .sw-state, label.switch-row:has(.switch:checked) .sw-state { color: var(--accent-text); }
.sw-hit:has(.switch:disabled) { cursor: default; }
.rule-row { align-items: flex-start; flex-wrap: wrap; column-gap: 8px; }
.rule-row .sw-hit { padding: 6px 0; }
.rule-row .rule-ref { align-self: center; }
@media (hover: hover) { .sw-hit:hover .what, label.switch-row:hover .what { color: var(--fg); } }
.vd-mini .sw-state { min-width: 0; }

/* ---- table preset --------------------------------------------------- */
.preset-card { --card-pad: 12px 14px 14px; display: grid; gap: 6px; border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), var(--shadow); }
.preset-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.preset-title { margin: 0; padding-top: 8px; font-size: calc(1.15rem * var(--display-scale)); line-height: 1.15; }
.preset-head .icon-btn { margin: -4px -8px 0 0; }
.preset-sub { margin: 0; font-size: 0.875rem; color: var(--fg-muted); }
.preset-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.preset-actions .btn { flex: 1 1 auto; min-height: 48px; white-space: normal; text-align: left; line-height: 1.2; text-decoration: none; }
.preset-actions .btn-primary { flex: 2 1 220px; }
.preset-row { --card-pad: 10px 14px; display: flex; align-items: center; justify-content: space-between; gap: 8px 12px; flex-wrap: wrap; }
.preset-txt { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.preset-txt small { color: var(--fg-muted); font-size: 0.8125rem; }
.preset-row .badge .ico { width: 1em; height: 1em; }
.table-banner { --card-pad: 12px 14px; display: grid; gap: 6px; border: 2px solid var(--accent); }
.table-banner p { margin: 0; }

/* ---- theme toggle (top bar) ------------------------------------------ */
.theme-btn .ico-sun { display: none; }
.theme-btn.is-dark .ico-sun { display: block; }
.theme-btn.is-dark .ico-moon { display: none; }
.style-done { align-items: center; justify-content: space-between; }
.style-done .muted { flex: 1 1 160px; }
.style-done .btn { flex: 0 1 auto; min-width: 120px; }

/* ---- tab bar: never split a label inside a word ---------------------- */
.tabbar > a { overflow-wrap: normal; word-break: keep-all; hyphens: none; }
.tab-l { display: block; max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: clip; }

/* ---- attack: small additions ------------------------------------------ */
.field-sub { display: flex; gap: 8px; align-items: center; margin: -6px 0 14px; font-size: 0.875rem; color: var(--fg-muted); }
.field-sub .ico { width: 16px; height: 16px; flex: none; color: var(--accent-text); }
.narc-note .fact-acts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.narc-note .fact-acts .btn { min-height: var(--tap); }
.res-dmg .narc-note { margin: 12px 0 0; }
.art-assumed { --badge-c: var(--fg-muted); margin-left: 6px; border-style: dashed; vertical-align: 0.05em; }
.art-item[aria-checked="true"] .art-assumed { --badge-c: currentColor; }
.art-note { color: var(--fg-muted); }
.assumed-row {
  display: flex; align-items: center; gap: 8px; width: 100%; min-height: var(--tap); margin: 6px 0 4px; padding: 6px 10px;
  border: 1px dashed var(--line-strong); border-radius: var(--radius-sm); background: var(--surface-2); color: var(--fg); text-align: left; font-family: var(--font-body); font-size: 0.9375rem;
}
.assumed-row > span:nth-child(2) { flex: 1; min-width: 0; }
.assumed-change { color: var(--accent-text); font-weight: 700; text-decoration: underline; text-decoration-style: dotted; text-underline-offset: 0.2em; }
.seg-bracket > button { min-width: 0; padding-inline: 4px; }
.qb { display: flex; flex-direction: column; align-items: center; line-height: 1.1; font-weight: 700; }
.qb-r { font-family: var(--font-num); font-size: 0.8125rem; font-weight: 500; letter-spacing: 0; white-space: nowrap; }
.cmp-assumed .chip { margin: 4px 6px 0 0; }
.cmp-assumed .chip .chip-mod { color: var(--accent-text); text-decoration: underline; text-decoration-style: dotted; }

/* ---- lookup: category chips wrap so every one is visible (Jerry: no hidden options); header slides away while scrolling down */
.lk-top { gap: 6px; padding-top: 10px; padding-bottom: 6px; }
.lk-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 2px 0 4px; }
.lk-chips::-webkit-scrollbar { display: none; }
.lk.is-wide .lk-chips { margin-inline: 0; padding-inline: 0; flex-wrap: wrap; overflow: visible; }
.lk-chips .kind-tabs { display: flex; flex-wrap: wrap; gap: 6px; padding: 0; }
.lk.is-wide .lk-chips .kind-tabs { flex-wrap: wrap; }
.lk-chips .chip { flex: none; white-space: nowrap; }
.kind-tabs .chip.is-zero:not([aria-selected="true"]) { border-style: dashed; color: var(--fg-muted); background-color: transparent; }
.lk-opt-chip { margin-left: 4px; }
.lk-opt-chip .ico { width: 16px; height: 16px; margin-right: 2px; }
@media (prefers-reduced-motion: no-preference) { .lk-top { transition: transform 0.2s ease; } }
.lk-top.is-collapsed { transform: translateY(calc(-100% - var(--border-w))); }
.lk-row-val { font-weight: 600; font-size: 0.9375rem; color: var(--accent-text); }
.entry-abbr { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.entry-abbr-val { font-weight: 600; color: var(--accent-text); }

/* ---- errata in words ---------------------------------------------------- */
.errata-list { display: grid; gap: 4px; margin-top: 4px; }
.errata-item .mono { font-size: 0.875rem; font-weight: 600; }

/* ---- two panes from about 720px (tablet portrait) ----------------------- */
@media (min-width: 720px) and (max-width: 1099.98px) {
  .atk-wide { grid-template-columns: minmax(0, 1fr) minmax(0, 0.82fr); gap: 20px; }
  .view[data-view="attack"] > .atk-wide { max-width: 1100px !important; }
  .atk-live .res-head .tn-readout { --tn-size: 3.6rem; }
  .lk.is-wide { grid-template-columns: minmax(280px, 0.9fr) minmax(0, 1.1fr); gap: 18px; }
  .lk-detail { --card-pad: 16px 18px; }
}
.atk-wide .wiz-foot { margin-inline: 0; border-radius: var(--radius) var(--radius) 0 0; border: var(--border-w) solid var(--line); border-bottom: 0; }

/* ---- large text (the reader's own size, 140%+): wrap, stack, icons-only tab bar */
.is-large-text .tabbar .tab-l { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.is-large-text .tabbar > a { min-height: 56px; }
/* words never split: the title wraps between words, and app.js fitTitle() shrinks it when one word is wider than the bar */
.is-large-text .tb-name { white-space: normal; overflow: visible; overflow-wrap: normal; word-break: normal; hyphens: manual; line-height: 1.05; }
.is-large-text .tb-eyebrow { display: none; }
/* narrow phone at large text: the one-tap theme button gives its room to the title (Theme stays in the Style and theme sheet) */
@media (max-width: 479px) { .is-large-text #theme-btn { display: none; } }
.is-large-text .style-btn-name { display: none; }
.is-large-text .tb-right .tn-chip .tn-chip-l, .is-large-text .tb-right .tn-chip .tn-chip-p { display: none; }
.is-large-text .res-tn-row { flex-wrap: wrap; align-items: flex-start; }
.is-large-text .res-odds { align-items: flex-start; text-align: left; }
.is-large-text .dot-label { display: none; }
.is-large-text .dots { margin-bottom: 8px; }
.is-large-text .field-inline { flex-wrap: wrap; }
.is-large-text .field-head, .is-large-text .disc-head, .is-large-text .sec-head { flex-wrap: wrap; }
.is-large-text .disc-sum { white-space: normal; text-align: left; }
.is-large-text .choice-grid, .is-large-text .choice-air { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.is-large-text .type-grid, .is-large-text .art-grid, .is-large-text .home-grid, .is-large-text .topic-grid, .is-large-text .res-actions-row, .is-large-text .cmp-grid { grid-template-columns: minmax(0, 1fr); }
.is-large-text .range-steps { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.is-large-text .seg { flex-wrap: wrap; }
.is-large-text .seg > button { flex: 1 1 auto; white-space: normal; }
.is-large-text .wiz-foot { flex-wrap: wrap; }
.is-large-text .foot-back span { display: none; }
.is-large-text .foot-next { min-width: 0; }
.is-large-text .tile-sm .ht-sub, .is-large-text .tt-sub, .is-large-text .lk-row-sum { -webkit-line-clamp: unset; display: block; }
.is-large-text .hs-txt, .is-large-text .recent-name, .is-large-text .sheet-item .si-sub { white-space: normal; }
.is-large-text .chip, .is-large-text .btn { white-space: normal; height: auto; min-width: 0; overflow-wrap: break-word; }
/* a modifier such as "+1" or "−4" never splits across lines */
.is-large-text .chip-mod { white-space: nowrap; }
.is-large-text .atk-dmg-grid { grid-template-columns: repeat(min(var(--cols, 3), 2), minmax(0, 1fr)); }
/* zero specificity: lets long words wrap at large text without beating any explicit min-width (tap targets) */
:where(.is-large-text) :where(.view, .sheet) :where(*) { min-width: 0; }
.step-q, .page-title, .entry-title, .home-title, .sec-title, .ht-name, .tt-name, .cmp-name, .rule-name, .preset-title { overflow-wrap: anywhere; hyphens: manual; }
.badge-house { --badge-c: var(--warn); }
.chip-hints { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 2px; font-size: 0.8125rem; line-height: 1.35; color: var(--fg-muted); }
.chip-hints strong { color: var(--fg); font-weight: 600; }

/* ==========================================================================
   2D6 TABLES MIRRORED ON 7, AND THE LOOKUP "TABLES" ENTRIES
   Owner: tables builder (round 3). Markup: helper/damage.js mirrorTableHTML() and helper/lookup.js tableDetail().
   Used by the Damage helper and by the Lookup (which loads only this file), so it lives here. Prefixes: tbl-sym-,
   tbl-key, tbl-entry-. Rows: 7, then 6·8, 5·9, 4·10, 3·11, 2·12. Each row is one group centred on the middle line
   with the rolls right beside their result: 7 on its own line over its result, "6 Weapon Hit 8", and a split pair
   "2 Ammo Hit | Unit Destroyed 12" whose halves meet at the middle line. Every roll keeps its x/36 under it, and
   the bar under each row is as wide as each roll is likely (6/36 = full width), so the 2D6 bell shows.
   ========================================================================== */
.tbl-sym { container: tblsym / inline-size; min-width: 0; max-width: 40rem; margin: 0; }
.tbl-sym-rows { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.tbl-sym-row {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: center;
  row-gap: 6px; padding: 8px 0; border-bottom: 1px solid var(--line); min-width: 0;
}
.tbl-sym-row:last-child { border-bottom: 0; }
/* a group: the roll(s) and the result, side by side */
.tbl-sym-g { display: flex; align-items: center; gap: 0.375rem; min-width: 0; }
.tbl-sym-g.is-mid { grid-column: 1 / -1; flex-direction: column; gap: 4px; }
.tbl-sym-g.is-all { grid-column: 1 / -1; justify-content: center; }
.tbl-sym-g.is-lo, .tbl-sym-g.is-hi { align-self: stretch; }
.tbl-sym-g.is-lo { grid-column: 1; justify-content: flex-end; padding-right: 0.375rem; border-right: 2px solid var(--line-strong); }
.tbl-sym-g.is-hi { grid-column: 2; justify-content: flex-start; padding-left: 0.375rem; }
.tbl-sym-n { flex: none; display: grid; justify-items: center; align-content: center; gap: 3px; min-width: 0; line-height: 1; }
.tbl-sym-n b {
  display: inline-block; min-width: 1.6em; padding: 0.14em 0.2em; border-radius: 999px; text-align: center;
  font-family: var(--font-num); font-size: 1.375rem; font-weight: 700; line-height: 1; letter-spacing: 0;
  font-variant-numeric: tabular-nums; color: var(--fg);
}
.tbl-sym-n small { font-family: var(--font-mono); font-size: 0.75rem; line-height: 1.1; color: var(--fg-muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl-sym-r {
  flex: 0 1 auto; min-width: 0; padding: 3px 6px; border-radius: var(--radius-sm);
  font-family: var(--font-body); font-size: 0.9375rem; font-weight: 600; line-height: 1.25; letter-spacing: 0; text-transform: none;
  color: var(--fg); overflow-wrap: break-word; hyphens: manual; text-wrap: balance;
}
.tbl-sym-g.is-mid .tbl-sym-r, .tbl-sym-g.is-all .tbl-sym-r { text-align: center; }
/* a wrapped half keeps its lines against its roll: low half left-aligned after the roll, high half right-aligned before it */
.tbl-sym-g.is-lo .tbl-sym-r { text-align: left; }
.tbl-sym-g.is-hi .tbl-sym-r { text-align: right; }
.tbl-sym-bar { grid-column: 1 / -1; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); height: 0.375rem; min-width: 0; }
.tbl-sym-row.is-split .tbl-sym-bar { column-gap: 3px; }
.tbl-sym-bar > i { display: block; height: 100%; background: var(--fg-muted); }
.tbl-sym-bar > i:first-child { justify-self: end; border-radius: 999px 0 0 999px; }
.tbl-sym-bar > i:last-child { justify-self: start; border-radius: 0 999px 999px 0; }
.tbl-sym-bar > i[data-w="1"] { width: calc(100% / 6); }
.tbl-sym-bar > i[data-w="2"] { width: calc(200% / 6); }
.tbl-sym-bar > i[data-w="3"] { width: 50%; }
.tbl-sym-bar > i[data-w="4"] { width: calc(400% / 6); }
.tbl-sym-bar > i[data-w="5"] { width: calc(500% / 6); }
.tbl-sym-bar > i[data-w="6"] { width: 100%; }
.tbl-sym-bar > i.is-good { background: var(--good); }
.tbl-sym-bar > i.is-warn { background: var(--warn); }
.tbl-sym-bar > i.is-bad { background: var(--bad); }
[data-style="cockpit"] .tbl-sym-bar > i, [data-style="record-sheet"] .tbl-sym-bar > i { border-radius: 0; }
/* the roll just tapped (Damage helper) */
.tbl-sym-n.is-on b { background: var(--accent); color: var(--accent-fg); }
.tbl-sym-r.is-on { background: var(--accent-soft); color: var(--fg); box-shadow: inset 0 0 0 2px var(--accent); font-weight: 700; }
/* narrow table or large text: a split pair puts its halves on two centred lines ("2 Ammo Hit", then
   "Unit Destroyed 12"), each roll still right beside its result; matched pairs and 7 stay as they are */
@container tblsym (max-width: 17.5rem) {
  .tbl-sym-row.is-split { grid-template-columns: minmax(0, 1fr); row-gap: 4px; }
  .tbl-sym-row.is-split .tbl-sym-g.is-lo { grid-column: 1; grid-row: 1; justify-content: center; padding-right: 0; border-right: 0; }
  .tbl-sym-row.is-split .tbl-sym-g.is-hi { grid-column: 1; grid-row: 2; justify-content: center; padding-left: 0; }
  .tbl-sym-row.is-split .tbl-sym-bar { grid-column: 1; grid-row: 3; }
}

/* Lookup: Tables entries */
.badge[data-kind="table"], .badge-table { --badge-c: var(--accent-text); }
.entry-table .tbl-entry-sec { display: grid; gap: 8px; min-width: 0; }
.entry-table .tbl-entry-sec > .eyebrow { margin: 0; }
.entry-table .tbl-entry-sec.entry-details > .eyebrow + ul { margin-top: 0; }
.tbl-entry-hint { margin: 0; font-size: 0.875rem; line-height: 1.45; color: var(--fg-muted); }
.tbl-entry-var { display: grid; gap: 6px; min-width: 0; padding: 10px 12px; border: 1px var(--line-style, solid) var(--line); border-radius: var(--radius-sm); }
.tbl-entry-vh { margin: 0; font-family: var(--font-body); font-size: 1rem; font-weight: 700; line-height: 1.3; text-transform: none; letter-spacing: 0; }
.tbl-keys { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; min-width: 0; }
.tbl-key { --tone: var(--line-strong); display: grid; gap: 4px; min-width: 0; padding: 2px 0 2px 12px; border-left: 4px solid var(--tone); }
.tbl-key.is-good { --tone: var(--good); }
.tbl-key.is-warn { --tone: var(--warn); }
.tbl-key.is-bad { --tone: var(--bad); }
.tbl-key > p, .tbl-key > ul { margin: 0; min-width: 0; }
.tbl-key-top { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; }
.tbl-key-name { font-size: 1rem; font-weight: 700; color: var(--fg); }
.tbl-key-odds { font-size: 0.875rem; color: var(--fg-muted); font-variant-numeric: tabular-nums; }
.tbl-key-text, .tbl-key-hits { font-size: 0.9375rem; line-height: 1.45; overflow-wrap: break-word; }
.tbl-key-hits { padding-left: 1.1em; }
.tbl-key-hits li + li { margin-top: 4px; }
.tbl-key-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.tbl-key-meta:empty { display: none; }
.tbl-key-link { text-decoration: none; white-space: normal; height: auto; min-height: var(--tap, 44px); min-width: var(--tap, 44px); text-align: left; overflow-wrap: anywhere; }
/* ==== end of 2D6 tables mirrored on 7 ==== */
