:root {
    color-scheme: dark;
    --bg: #121814;
    --panel: #1a231d;
    --panel-lift: #202c24;
    --line: #34443a;
    --text: #f0f0e6;
    --muted: #afbcad;
    --accent: #d9e6a4;
    --warning: #f4cb84;
    --danger: #ffa998;
    font-family: "Segoe UI", system-ui, sans-serif;
    font-size: 15px;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); }
h1, h2, h3, p { margin: 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .45; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.shell { width: min(1250px, calc(100% - 48px)); margin: 0 auto; }
.topbar { background: #171f19; border-bottom: 1px solid var(--line); }
.bar-inner { min-height: 65px; display: flex; align-items: center; gap: 20px; }
.brand { display: inline-flex; align-items: center; gap: 9px; font-size: 22px; font-weight: 750; color: var(--text); }
.brand-mark { display: grid; place-items: center; width: 31px; height: 31px; color: #202921; background: var(--accent); border-radius: 7px; }
.edition { font-size: 12px; color: var(--muted); border-left: 1px solid var(--line); padding-left: 18px; }
.edition span, .dot { padding: 0 4px; }
.library-link { margin-left: auto; font-size: 14px; }
.home { max-width: 1050px; }
.intro { padding: 72px 0 54px; }
.eyebrow { text-transform: uppercase; font-size: 11px; letter-spacing: .13em; font-weight: 750; color: var(--accent); }
.signal { display: inline-block; vertical-align: .06em; border-radius: 100%; width: 7px; height: 7px; margin-right: 5px; background: #b9cf82; }
.intro h1 { margin: 9px 0 13px; font-size: clamp(43px, 8vw, 83px); line-height: 1; letter-spacing: -.07em; }
.intro p { color: var(--muted); max-width: 560px; line-height: 1.55; font-size: 17px; }
.faction-grid { display: grid; grid-template-columns: repeat(auto-fit,minmax(min(250px,100%),1fr)); gap: 14px; margin-top: 29px; }
.faction-card { display: grid; text-align: left; color: var(--text); gap: 7px; padding: 22px; border-radius: 12px; border: 1px solid var(--line); background: linear-gradient(122deg,#253428,#1b251e); }
.faction-card:nth-child(even) { background: linear-gradient(122deg,#293632,#1c2621); }
.faction-card:hover { border-color: var(--accent); }
.faction-card strong { font-size: clamp(21px,3vw,31px); letter-spacing: -.045em; }
.faction-action { display: flex; align-items: center; justify-content: space-between; margin-top: 17px; color: var(--accent); font-size: 14px; }
.library { border-top: 1px solid var(--line); padding-top: 25px; }
.section-title, .panel-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.section-title h2 { margin-top: 4px; font-size: 26px; letter-spacing: -.035em; }
.library-row { display: flex; justify-content: space-between; align-items: center; padding: 17px 19px; border: 1px solid var(--line); background: var(--panel); border-radius: 8px; margin: 7px 0; }
.library-row strong { color: var(--text); }
.library-row .muted { margin-top: 4px; }
.empty { padding: 31px; border: 1px dashed var(--line); border-radius: 9px; text-align: center; }
.empty p { margin-top: 5px; color: var(--muted); font-size: 14px; }
.empty.small { padding: 23px; }
.tag { font-size: 12px; color: var(--muted); border: 1px solid var(--line); border-radius: 99px; padding: 4px 9px; white-space: nowrap; }
.source-note { color: var(--muted); padding: 22px 0; font-size: 12px; }
.workspace { padding-top: 24px; }
.roster-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.roster-header h1 { margin-top: 4px; font-size: clamp(30px, 5vw, 52px); line-height: 1.08; letter-spacing: -.055em; overflow-wrap: anywhere; }
.back { display: inline-block; margin-bottom: 15px; color: var(--muted); font-size: 13px; }
.roster-actions { display: flex; gap: 14px; align-items: center; white-space: nowrap; }
.saved { font-size: 12px; color: var(--muted); }
.button { display: inline-block; border: 1px solid var(--accent); border-radius: 7px; padding: 8px 12px; background: var(--accent); color: #202a20; font-size: 13px; font-weight: 750; text-decoration: none; }
.button:hover:not(:disabled) { filter: brightness(1.12); text-decoration: none; }
.button.secondary { color: var(--text); background: var(--panel); border-color: var(--line); }
.totals { display: grid; grid-template-columns: 1.25fr 1fr 1fr; gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; margin-bottom: 16px; }
.metric { background: var(--panel); padding: 12px 17px; display: grid; gap: 2px; align-content: start; }
.metric strong { font-size: clamp(18px, 4vw, 32px); letter-spacing: -.05em; }
.metric strong small { color: var(--muted); font-size: 15px; letter-spacing: 0; font-weight: 500; }
.meter { background: #33443a; height: 4px; margin-top: 4px; border-radius: 99px; overflow: hidden; }
.meter span { display: block; height: 100%; background: var(--accent); }
.work-grid { display: grid; grid-template-columns: minmax(285px, 1fr) minmax(0, 1.85fr); gap: 16px; align-items: start; }
.roster-column { min-width: 0; }
.army-setup > summary { margin: 0; cursor: pointer; }
.army-setup > summary::after { content: "▸"; color: var(--accent); }
.army-setup[open] > summary::after { content: "▾"; }
.army-setup[open] > summary { margin-bottom: 15px; }
.army-setup .form-stack { grid-template-columns: repeat(auto-fit, minmax(min(190px,100%),1fr)); }
.detachment-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(235px,100%),1fr)); gap: 4px 12px; }
.panel { background: var(--panel); padding: 15px 17px; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 14px; }
.panel-heading { justify-content: flex-start; gap: 9px; }
.panel-heading h2 { font-size: 19px; letter-spacing: -.025em; }
.step { font-size: 11px; font-weight: 800; border-radius: 6px; padding: 5px 7px; background: #344238; color: var(--accent); }
.push { margin-left: auto; }
.form-stack { display: grid; gap: 10px; }
label { display: block; color: var(--muted); font-size: 13px; }
label input:not([type=checkbox]), label select { display: block; width: 100%; margin-top: 5px; }
input:not([type=checkbox]), select { min-width: 0; color: var(--text); padding: 8px 9px; border: 1px solid var(--line); border-radius: 6px; background: #131d16; }
input[type=checkbox] { accent-color: var(--accent); }
.field-heading { font-size: 13px; font-weight: 700; margin: 16px 0 7px; }
.detachment-option { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: start; gap: 6px; padding: 9px 5px; border-bottom: 1px solid var(--line); }
.detachment { display: grid; grid-template-columns: auto 1fr auto; align-items: start; gap: 8px; }
.detachment-option > .preview-link { padding: 1px 2px; }
.detachment:has(input:disabled) { opacity: .52; }
.detachment.chosen { color: var(--accent); }
.detachment strong { font-size: 13px; }
.detachment small { display: block; color: var(--muted); margin-top: 2px; }
.detachment-preview { box-sizing: border-box; width: min(640px, calc(100% - 24px)); max-height: 85dvh; padding: 18px; overflow: auto; overscroll-behavior: contain; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); color: var(--text); box-shadow: 0 18px 60px #0009; }
.detachment-preview::backdrop { background: #0007; }
.detachment-preview-header { display: flex; align-items: start; justify-content: space-between; gap: 12px; }
.detachment-preview-header p { margin-top: 4px; }
.detachment-preview h4 { margin: 16px 0 8px; padding-top: 10px; border-top: 1px solid var(--line); color: var(--accent); }
.dp { white-space: nowrap; font-size: 11px; padding-top: 2px; }
.muted { font-size: 12px; color: var(--muted); }
.hint { padding-top: 10px; }
.validation { margin: 0 0 14px; padding: 12px 14px; border: 1px solid; border-radius: 8px; font-size: 13px; }
.validation.ready { background: #202f24; border-color: #4a654e; color: #d1efcc; }
.validation.draft { background: #2a271f; border-color: #665639; color: var(--warning); }
.validation ul { margin: 6px 0 0; padding-left: 17px; line-height: 1.48; }
.accent { color: var(--accent); }
.danger-text, .text-danger, .inline-error { color: var(--danger); }
.unit-card { border: 1px solid var(--line); border-radius: 7px; margin: 7px 0; background: var(--panel-lift); }
summary { cursor: pointer; }
.unit-card > summary { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px; list-style: none; }
.unit-card > summary::-webkit-details-marker { display: none; }
.unit-card > summary::before { content: "›"; color: var(--accent); font-size: 20px; }
.unit-card[open] > summary::before { transform: rotate(90deg); }
.unit-heading { flex: 1; display: grid; gap: 3px; }
.unit-price { font-size: 17px; font-weight: 750; white-space: nowrap; }
.unit-price small, .catalog-points small { color: var(--muted); font-weight: 500; }
.unit-body { padding: 10px 12px 12px; border-top: 1px solid var(--line); }
.unit-controls { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(135px,100%), 1fr)); gap: 7px; }
.wargear-heading { display: flex; align-items: baseline; gap: 9px; margin: 16px 0 8px; }
.wargear-heading h3 { font-size: 14px; }
.model-row { border-top: 1px solid var(--line); padding: 7px 0; }
.model-row summary, .model-row.fixed { color: var(--muted); font-size: 12px; }
.model-row summary strong, .model-row.fixed strong { color: var(--text); font-size: 13px; margin-right: 6px; }
.model-options { padding: 8px 4px 4px 15px; }
.gear-field { display: grid; gap: 2px; margin-bottom: 8px; }
.gear-field select { max-width: 100%; }
.unit-footer { border-top: 1px solid var(--line); margin-top: 9px; padding-top: 7px; display: flex; justify-content: space-between; align-items: center; }
.text-danger { border: 0; padding: 4px; background: transparent; font-size: 12px; }
.inline-error { font-size: 13px; margin-top: 8px; }
.filters { display: grid; grid-template-columns: 1fr auto; gap: 7px; margin-bottom: 8px; }
.catalog { position: sticky; top: 12px; min-width: 0; }
.catalog-scroll { max-height: calc(100vh - 140px); overflow: auto; padding-right: 5px; scrollbar-gutter: stable; }
.catalog-preview { grid-column: 1 / -1; min-width: 0; }
.preview-link { padding: 3px 0; border: 0; background: none; color: var(--accent); font-size: 12px; text-decoration: underline; }
.unit-category { margin: 14px 0 20px; padding: 0 10px 4px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); }
.unit-category:last-child { margin-bottom: 0; }
.category-heading { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin: -1px -11px 6px; padding: 8px 10px; border: 1px solid #62785a; border-radius: 8px 8px 0 0; background: #344831; color: #eff4d8; font-size: 13px; letter-spacing: .07em; text-transform: uppercase; }
.category-heading small { border-radius: 99px; padding: 1px 7px; background: #16241a; color: #e7efd2; font-size: 11px; letter-spacing: 0; }
.unit-category .catalog-row:first-of-type { border-top: 0; }
.catalog-row { display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); }
.catalog-row .muted { margin-top: 3px; }
.catalog-points { font-size: 15px; font-weight: 700; white-space: nowrap; }
.button.add { padding: 6px 9px; }
.print-backdrop { position: fixed; inset: 0; background: #0c130f; cursor: pointer; }
.print-sheet { position: relative; background: #fff; color: #161d17; color-scheme: light; max-width: 890px; width: calc(100% - 28px); margin: 26px auto; padding: 26px 34px; border-radius: 8px; }
.print-sheet .eyebrow, .print-sheet a { color: #485839; }
.print-sheet .validation { background: #fff8e9; color: #674615; border-color: #dbbf8c; }
.print-actions, .print-unit-title { display: flex; justify-content: space-between; align-items: center; gap: 14px; }
.print-actions { padding-bottom: 20px; margin-bottom: 20px; border-bottom: 1px solid #dce2d8; }
.print-sheet h1 { font-size: 36px; letter-spacing: -.04em; margin: 5px 0; }
.print-meta { color: #4b584a; margin: 6px 0 17px; font-size: 13px; }
.print-sheet h2 { font-size: 17px; margin-top: 15px; }
.print-sheet h3 { font-size: 15px; }
.print-unit { padding: 9px 0; border-top: 1px solid #dce2d8; font-size: 13px; }
.print-unit ul, .print-detachments { padding-left: 17px; margin: 6px 0; }
.unit-disclosure { margin-top: 9px; border-top: 1px solid var(--line); padding: 8px 0 0; }
.unit-disclosure > summary { color: var(--accent); font-size: 13px; font-weight: 700; }
.unit-disclosure > summary .tag { margin-left: 6px; }
.incoming-leader { margin: 8px 0; }
.unit-reference { margin-top: 8px; }
.profile-scroll { overflow-x: auto; margin: 7px 0 10px; }
.profile-table { border-collapse: collapse; width: 100%; font-size: 12px; }
.profile-table caption { text-align: left; margin: 0 0 4px; font-weight: 750; }
.profile-table th, .profile-table td { padding: 4px 6px; border-bottom: 1px solid var(--line); text-align: left; }
.profile-table thead th { background: var(--panel); }
.profile-table td:not(:first-child) { white-space: nowrap; }
.profile-table .weapon-abilities { white-space: normal; min-width: 7em; color: var(--muted); }
.profile-table .weapon-qty { text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; }
.unequipped-profile { color: var(--muted); }
.unit-keywords { font-size: 12px; margin: 8px 0; }
.rule-entry { margin: 8px 0; }
.rule-title { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; }
.rule-title > span { font-size: 11px; color: var(--muted); }
.rule-text { margin-top: 4px; white-space: pre-line; font-size: 13px; line-height: 1.38; overflow-wrap: anywhere; }
.attached-reference, .unit-detachment-rules { border-left: 3px solid #8da669; margin: 10px 0 8px; padding: 8px 10px; background: var(--bg); }
.unit-detachment-rules h4 { margin: 0 0 6px; font-size: 12px; color: var(--accent); }
.unit-detachment-rules .rule-entry:last-child { margin-bottom: 0; }
.enhancement-effect { margin-top: 10px; }
.effect-target { font-size: 12px; color: var(--accent); margin-top: 3px; }
.counted-gear-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(212px,100%),1fr)); gap: 9px; margin: 8px 0; }
.counted-gear { margin: 0; border: 1px solid var(--line); border-radius: 7px; padding: 8px; min-width: 0; }
.counted-gear legend { font-size: 13px; font-weight: 700; padding: 0 3px; }
.counter-row { display: grid; grid-template-columns: minmax(0,1fr) 25px 18px 25px; gap: 4px; align-items: center; padding-top: 7px; font-size: 12px; }
.counter-row small { display: block; color: var(--muted); font-size: 10px; margin-top: 2px; }
.counter-row output { text-align: center; }
.stepper { border: 1px solid var(--line); border-radius: 4px; color: var(--accent); background: var(--panel); padding: 3px 0; }
.print-sheet .unit-category { background: #fff; border-color: #a8b2a4; }
.print-sheet .category-heading { color: #263c27; background: #e5ede0; border-color: #879781; break-after: avoid; }
.print-sheet .category-heading small { color: #263c27; background: #fff; }
.print-sheet .profile-table th, .print-sheet .profile-table td { border-color: #dce2d8; }
.print-sheet .profile-table thead th { background: #eef1ec; }
.print-sheet .rule-title > span { color: #566252; }
.print-sheet .attached-reference, .print-sheet .unit-detachment-rules { border-color: #6a805e; background: #f2f6ef; }
.print-sheet .unit-detachment-rules h4 { color: #42563a; break-after: avoid; }
.print-sheet .weapon-abilities, .print-sheet .effect-target, .print-sheet .unequipped-profile { color: #566252; }
.print-reference { margin-top: 20px; }
.print-reference h3 { margin-top: 10px; }
.print-sheet .profile-scroll { overflow: visible; }
.print-sheet .profile-table td:not(:first-child) { white-space: normal; }
.print-sheet .rule-text { font-size: 12px; }
@media (max-width: 820px) {
    .shell { width: calc(100% - 28px); }
    .work-grid { grid-template-columns: 1fr; gap: 0; }
    .catalog { position: static; }
    .catalog-scroll { max-height: 40vh; }
    .intro { padding-top: 42px; }
    .print-sheet { margin: 12px; padding: 17px; }
}
@media (max-width: 515px) {
    .roster-header { align-items: flex-start; flex-direction: column; }
    .metric { padding: 9px; }
    .metric .eyebrow { letter-spacing: .05em; font-size: 9px; }
    .metric strong small { font-size: 12px; }
    .filters { grid-template-columns: 1fr; }
    .saved { order: 2; }
}
@media print {
    @page { margin: 14mm; }
    body { background: white; color: black; }
    .print-sheet { margin: 0; padding: 0; max-width: none; width: 100%; }
    .print-actions, .print-backdrop { display: none; }
    .print-sheet h1 { font-size: 24pt; }
    .print-sheet h2, .print-sheet h3, .rule-title, .profile-table caption { break-after: avoid; }
    .print-sheet .profile-table tr { break-inside: avoid; }
}
