/* Shared paper-and-ink theme. Load after the component stylesheets. */
:root {
  color-scheme: light;
  --bg: #eee5d3;
  --card: #f8f2e5;
  --card-hover: #eadcc0;
  --border: #cbb895;
  --text: #2f2921;
  --text-dim: #71634f;
  --muted: var(--text-dim);
  --accent: #9b3d30;
  --accent2: #75603a;
  --gold: #825913;
  --green: #3f6d4b;
  --red: #a63932;
  --orange: #9c5926;
  --paper: #fcf7ed;
  --paper-shade: #e8dcc4;
  --ink-line: #dfd0b3;
  --accent-soft: #edddcb;
  --gold-soft: #eee1bf;
  --green-soft: #e4e8d6;
  --red-soft: #f0ddd4;
  --purple: #76518a;
  --purple-soft: #ece1e9;
  --combat-cyan: var(--accent);
  --combat-cyan-soft: var(--accent-soft);
  --cp-border: var(--border);
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  -webkit-tap-highlight-color: rgba(155, 61, 48, .13);
}

body::before {
  background: linear-gradient(120deg, rgba(255, 251, 238, .4), transparent 55%),
    linear-gradient(0deg, rgba(165, 130, 73, .045), transparent 65%);
}

::selection { background: #dcc3a6; color: var(--text); }
body :is(button, input, select, textarea, summary, a):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
body :is(input, select, textarea, progress) { accent-color: var(--accent); }
body :is(input, select, textarea) { font-variant-numeric: tabular-nums; }
body :is(input, textarea)::placeholder { color: #817562; opacity: 1; }
body :is(input, textarea, select):disabled { color: var(--text-dim); }
body :is(button, select, input, textarea) { border-radius: 4px; }
body input::file-selector-button {
  margin-right: 9px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: var(--paper-shade);
  color: var(--text);
  font: inherit;
  cursor: pointer;
}
body input::file-selector-button:hover { border-color: var(--accent); }
body :is(h1, h2, h3) { color: var(--text); }
.seq-app-header h1,
.seq-panel-heading h2,
.cp-head h3,
.cet-dialog-head h3,
.ci-header h2,
.assist-atlas h2 {
  font-family: "Songti SC", "STSong", "Noto Serif SC", serif;
  font-weight: 700;
}
header h1 { background: none; -webkit-text-fill-color: currentColor; color: var(--text); }

/* Navigation and actions use cinnabar and old gold rather than luminous blue. */
:root .seq-tabs,
:root .seq-save-identity {
  border-color: var(--border);
  border-radius: 5px;
  background: var(--card);
  box-shadow: none;
}
:root .seq-tab,
:root .seq-workspace-group { border-radius: 3px; color: var(--text-dim); }
:root .seq-tab:hover,
:root .seq-tab:focus-visible,
:root .seq-workspace-group:hover { background: var(--paper-shade); color: var(--text); }
:root .seq-tab.is-active,
:root .seq-workspace-group[aria-pressed="true"],
:root .seq-workspace-tablist .seq-tab.is-active {
  background: var(--gold-soft);
  color: var(--accent);
  border-color: var(--border);
  box-shadow: inset 0 -2px var(--accent);
}
:root .seq-workspace-tablist,
:root .seq-save-compat-body,
:root .seq-owned-equipment-menu,
:root .cp-data-menu-items {
  border-color: var(--border);
  border-radius: 5px;
  background: var(--paper);
  box-shadow: 0 6px 20px rgba(74, 48, 24, .18);
}
:root .seq-save-compat summary { color: var(--text-dim); }
:root .seq-save-compat-field { border-color: var(--ink-line); background: var(--card); }
:root .seq-save-compat-field input { background: var(--paper); }
:root .seq-save-identity.is-loading { border-color: var(--gold); }
:root .seq-save-identity.is-success { border-color: var(--green); }
:root .seq-save-identity.is-error { border-color: var(--red); }

:root .seq-button {
  border-color: var(--border);
  border-radius: 4px;
  background: var(--card);
  color: var(--text);
  box-shadow: none;
}
:root .seq-button:hover { background: var(--paper-shade); border-color: var(--accent); }
:root .seq-button-primary,
:root .cet-dialog .cet-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--paper);
}
:root .seq-button-primary:hover,
:root .cet-dialog .cet-primary:hover { background: #823226; color: var(--paper); }
:root .seq-button-secondary {
  background: var(--red-soft);
  border-color: #c3937e;
  color: var(--red);
}
:root .seq-choice-button.is-active,
:root .seq-material-button.is-active,
:root .seq-jianwang-future-number.is-active,
:root .seq-hengshan-pagination button.is-active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  box-shadow: none;
}

/* Route planning uses the same paper controls as the rest of the workbench. */
:root :is(.seq-talent-mode-buttons, .seq-talent-goal-mode) {
  background: var(--paper-shade);
  border-color: var(--border);
}
:root :is(.seq-talent-mode-buttons, .seq-talent-goal-mode)
  .seq-choice-button:not(.is-active) {
  background: var(--paper);
  border-color: var(--border);
  color: var(--text-dim);
}
:root .seq-talent-custom-goal {
  background: var(--paper);
  border-color: var(--border);
}
:root .seq-talent-target-count {
  background: var(--gold-soft);
  color: var(--gold) !important;
}
:root .seq-talent-target-card {
  background: var(--paper);
  border-color: var(--border);
  color: var(--text);
}
:root .seq-talent-target-copy small {
  color: var(--text-dim);
  opacity: 1;
}
:root .seq-talent-target-card.is-selected {
  background: var(--accent-soft);
  border-color: var(--accent);
}
:root .seq-talent-target-card.is-selected .seq-talent-target-copy small {
  color: var(--text);
}
:root .seq-talent-target-card.is-avoided {
  background: var(--paper);
  border-color: var(--red);
  border-style: dashed;
}
:root .seq-talent-intent-button {
  background: var(--paper);
  border-color: var(--border);
  color: var(--text-dim);
}
:root .seq-talent-intent-button:is(:hover, :focus-visible):not(:disabled) {
  background: var(--paper-shade);
  border-color: var(--accent);
  color: var(--text);
}
:root .seq-talent-intent-button.is-want.is-active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}
:root .seq-talent-intent-button.is-avoid.is-active {
  background: var(--paper);
  border-color: var(--red);
  border-style: dashed;
  color: var(--red);
}
:root .seq-talent-intent-button:disabled {
  opacity: 1;
}
:root .seq-talent-intent-button:disabled:not(.is-active) {
  background: var(--card);
  color: var(--text-dim);
}
:root .seq-talent-quality-dot {
  background: var(--paper);
  border: 1px solid currentColor;
}
:root .seq-talent-quality-dot.is-4 { color: var(--purple); }
:root .seq-talent-quality-dot.is-3 { color: #365d81; }
:root .seq-talent-quality-dot.is-2 { color: var(--green); }
:root .seq-talent-quality-dot.is-1 { color: var(--text-dim); }

/* Forms retain their current dimensions, so import/edit and drag flows stay put. */
:root :is(.seq-toolbar, .seq-forge-toolbar, .seq-strong-toolbar,
  .seq-special-controls, .seq-jianwang-future-controls,
  .seq-strong-strategies, .seq-talent-pill-limit, .seq-query-horizon,
  .seq-hengshan-toolbar, .seq-hengshan-talent-filters,
  .seq-hengshan-replacement-filters, .seq-hengshan-stat-filters,
  .seq-hengshan-route-controls, .seq-hengshan-replacement-controls)
  :is(input:not([type="checkbox"]):not([type="radio"]), select, textarea),
:root .seq-slot-filter,
:root .seq-special-raw-head select,
:root .seq-query-card #seqPreferredLocation,
:root .refinement-sequence-count input,
:root .refinement-slot-filter,
:root .slot-select,
:root .seq-owned-equipment-trigger,
:root .seq-strong-equipment-picker [data-strong-equipment-select],
:root .seq-strong-equipment-picker :is(option, optgroup) {
  background: var(--paper);
  border-color: var(--border);
  color: var(--text);
  border-radius: 4px;
}
:root :is(.seq-query-label, .seq-query-horizon, .seq-special-controls label,
  .seq-save-compat-field, .seq-save-compat summary) { color: var(--text-dim); }
:root :is(.seq-query-card, [data-seq-panel="talent"] > .seq-toolbar) {
  background: var(--card);
  border-color: var(--border);
  border-radius: 5px;
  box-shadow: none;
}
:root .seq-table th,
:root .seq-special-raw-table th,
:root .refinement-sequence-table thead { background: var(--paper-shade); color: var(--text-dim); }
:root :is(.seq-table, .detail-table, .refinement-sequence-table) :is(th, td) { border-color: var(--ink-line); }
:root .seq-table tbody tr:hover,
:root .seq-table tbody tr[data-forge-candidate]:hover,
:root .seq-table tbody tr[data-forge-candidate]:focus-visible { background: var(--accent-soft); }
:root .seq-table tbody tr.is-location-prize { background: linear-gradient(90deg, var(--gold-soft), transparent 55%); }
:root .seq-table td small { color: var(--text-dim); }
:root .refinement-sequence-table td strong { color: var(--accent); }

/* Sequence planning, forging, tempering and disciples share the same paper. */
:root :is(.seq-status, .seq-inline-summary, .seq-metric-note, .seq-affix-legend article,
  .seq-jianwang-section, .seq-jianwang-future-controls, .seq-jianwang-future-number,
  .seq-jianwang-stage-line, .seq-jianwang-current, .seq-jianwang-choice-result,
  .seq-jianwang-row, .seq-strong-toolbar, .seq-strong-card, .seq-strong-detail,
  .seq-strong-level, .seq-strong-level-detail, .seq-strong-attempt,
  .seq-talent-search-status, .seq-route-talent, .seq-hengshan-disciple,
  .seq-hengshan-detail, .seq-hengshan-power-grid article,
  .seq-hengshan-native-parts, .seq-hengshan-native-parts figure,
  .seq-hengshan-talent, .seq-hengshan-route-way,
  .seq-hengshan-replacement-step) {
  background: var(--card);
  border-color: var(--border);
  border-radius: 5px;
  color: var(--text);
  box-shadow: none;
}
:root .seq-callout,
:root .seq-owned-equipment-actions,
:root .seq-hengshan-route-planner,
:root .seq-hengshan-route-step { background: var(--accent-soft); border-color: #c79f80; }
:root .seq-callout-warn,
:root .seq-simulator-audit,
:root .seq-hengshan-replacement-filters,
:root .seq-hengshan-replacement-current,
:root .seq-hengshan-dossier { background: var(--gold-soft); border-color: #c4aa73; }
:root .seq-material-picker,
:root .seq-red-material-section,
:root .seq-jianwang-card { background: var(--red-soft); border-color: #ccaa94; border-radius: 5px; }
:root :is(.seq-material-picker-head strong, .seq-special-material-label,
  .seq-tag-special, .seq-jianwang-card header strong,
  .seq-jianwang-row b, .seq-jianwang-current.is-special) { color: var(--red); }
:root .seq-special-material-label,
:root .seq-tag-special { background: var(--red-soft); border-color: #ccaa94; }
:root .seq-jianwang-current.is-special { border-left-color: var(--red); }
:root .seq-jianwang-card code { color: var(--text-dim); }
:root .seq-owned-equipment-option:hover,
:root .seq-owned-equipment-option:focus-visible,
:root .seq-owned-equipment-option.is-active,
:root .seq-strong-card:hover,
:root .seq-strong-card.is-active,
:root .seq-strong-level.is-active,
:root .seq-hengshan-disciple:hover,
:root .seq-hengshan-disciple.is-active,
:root .seq-hengshan-replacement-step:hover,
:root .seq-hengshan-replacement-step.is-active { background: var(--paper-shade); }
:root .seq-strong-grade { color: var(--text-dim); background: var(--paper-shade); border-color: var(--border); }
:root .seq-strong-grade.is-good,
:root .seq-strong-attempt.is-good { color: #3c5f80; border-color: #8298a8; }
:root .seq-strong-grade.is-excellent,
:root .seq-strong-attempt.is-excellent { color: var(--gold); background: var(--gold-soft); border-color: #c4aa73; }
:root .seq-strong-grade.is-perfect,
:root .seq-strong-attempt.is-perfect { color: var(--red); background: var(--red-soft); border-color: #c3937e; }
:root .seq-strong-costs .is-melt { color: var(--orange); }
:root .seq-strong-metrics b,
:root .seq-jianwang-family-status.is-available { color: var(--green); }
:root .seq-jianwang-affixes i { color: var(--accent2); border-color: var(--border); }
:root .seq-jianwang-affixes i.is-signature { color: var(--gold); background: var(--gold-soft); border-color: #b79451; box-shadow: none; }
:root .seq-jianwang-affixes i.is-yawjiu-speed { color: var(--red); background: var(--red-soft); border-color: #c3937e; box-shadow: none; }
:root .seq-jianwang-signature-matches button { background: var(--gold-soft); border-color: #c4aa73; }
:root .seq-talent-purple-row { background: linear-gradient(90deg, var(--purple-soft), transparent 72%); }
:root .seq-talent-purple-row td:first-child { box-shadow: inset 3px 0 var(--purple); }
:root .seq-talent-gap,
:root .seq-replacement-talent.is-purple strong,
:root .seq-hengshan-route-way > header b { color: var(--purple); }
:root .seq-talent-variant-panel { background: var(--purple-soft); border-color: #b39bbd; border-radius: 5px; }
:root .seq-talent-variant-heading > strong { color: var(--purple); }
:root .seq-talent-variant-button { color: var(--text); background: var(--paper); border-color: var(--border); }
:root .seq-talent-variant-button.is-active { color: var(--purple); background: #e0cfe3; border-color: var(--purple); box-shadow: inset 3px 0 var(--purple); }
:root .seq-route-talent.is-purple { color: var(--purple); background: var(--purple-soft); border-color: #b39bbd; }

:root :is(.seq-status, .seq-inline-summary, .seq-talent-search-status).is-success,
:root .seq-replacement-summary.is-success,
:root .seq-route-proof.is-proven,
:root .seq-route-finish,
:root .seq-hengshan-route-proof { color: var(--green); background: var(--green-soft); border-color: #97ab87; }
:root :is(.seq-status, .seq-inline-summary, .seq-talent-search-status).is-error { color: var(--red); background: var(--red-soft); border-color: #c3937e; }
:root .seq-route-summary.is-best-found,
:root .seq-route-proof.is-best-found,
:root .seq-route-finish.is-upper-bound { color: var(--gold); background: var(--gold-soft); border-color: #c4aa73; }
:root .seq-route-final-row { background: linear-gradient(90deg, var(--green-soft), transparent 64%); }
:root .seq-rec-card.is-top { border-color: #c4aa73; box-shadow: inset 0 2px #b79451; }
:root .seq-location-chip.is-available,
:root .seq-bonus-badge.is-hit,
:root .seq-replacement-note.is-verified strong { color: var(--green); }
:root .seq-bonus-badge.is-miss,
:root .seq-replacement-note.is-blocked strong { color: var(--red); }
:root .seq-bonus-badge.is-pending,
:root .seq-replacement-note.is-unverified strong { color: var(--gold); }
:root :is(.seq-tag, .seq-tag-smith, .seq-location-chip, .seq-smith-card,
  .seq-auto-local-badge, .seq-refine-metric, .seq-affix-line) {
  background: var(--paper-shade);
  border-color: var(--border);
  color: var(--text-dim);
}
:root .seq-affix-line.is-smith { color: var(--accent2); }
:root .seq-affix-line.is-red,
:root .seq-affix-line.is-special { color: var(--red); }
:root .seq-smith-card small { color: var(--text-dim); }
:root .seq-smith-card.has-pool { border-color: #b79451; background: var(--gold-soft); }
:root .seq-row-actions button,
:root .seq-hengshan-pagination button,
:root .seq-hengshan-branch-actions button { background: var(--paper); border-color: var(--border); color: var(--text); }
:root .seq-row-actions button:last-child,
:root .seq-hengshan-branch-actions button:first-of-type { background: var(--accent-soft); border-color: #c79f80; color: var(--accent); }

:root .seq-hengshan-view-tabs { background: var(--paper-shade); border-radius: 4px; }
:root .seq-hengshan-view-tabs button.is-active { background: var(--gold-soft); color: var(--accent); box-shadow: inset 0 -2px var(--accent); }
:root .seq-hengshan-disciple.is-recommended { box-shadow: inset 3px 0 #b79451; }
:root .seq-hengshan-disciple .seq-hengshan-card-stats { color: var(--text-dim); }
:root .seq-hengshan-disciple .seq-hengshan-replacement-hint,
:root .seq-hengshan-replacement-current .is-highlight,
:root .seq-hengshan-replacement-step.is-highlight span { color: var(--gold); }
:root .seq-hengshan-avatar { background: radial-gradient(circle at 50% 42%, #e2d2ae, #f8f2e5 72%); border-color: var(--border); }
:root .seq-hengshan-sprite.is-missing { border-color: var(--border); }
:root .seq-hengshan-portrait-stage { background: radial-gradient(circle at 50% 35%, #ede0bb, var(--card) 70%); }
:root .seq-hengshan-stats b { color: var(--text); background: var(--paper-shade); }
:root .seq-hengshan-stats b.is-total,
:root .seq-hengshan-talent.is-highlight,
:root .seq-hengshan-replacement-step.is-highlight { background: var(--gold-soft); border-color: #c4aa73; }
:root :is(.seq-hengshan-stats b strong, .seq-hengshan-power-grid strong,
  .seq-hengshan-route-planner h4, .seq-hengshan-replacement-current .is-result,
  .seq-hengshan-replacement-step strong) { color: var(--text); }
:root .seq-hengshan-power-grid em,
:root .seq-hengshan-route-step ol { color: var(--text-dim); }
:root .seq-hengshan-route-proof strong { color: var(--green); }
:root .seq-hengshan-route-error { color: var(--red); }
:root .seq-hengshan-route-done { color: var(--green) !important; }
:root .seq-hengshan-route-way footer { border-top-color: var(--ink-line); }

/* Existing rarity classes and Color=1..6 use readable tones on paper. */
:root :is(.seq-quality-white, [data-quality="1"]) { --quality-color: #635c50; color: var(--quality-color); }
:root :is(.seq-quality-green, [data-quality="2"]) { --quality-color: #376749; color: var(--quality-color); }
:root :is(.seq-quality-blue, [data-quality="3"]) { --quality-color: #365d81; color: var(--quality-color); }
:root :is(.seq-quality-purple, [data-quality="4"]) { --quality-color: #76518a; color: var(--quality-color); }
:root :is(.seq-quality-orange, [data-quality="5"]) { --quality-color: #8b5816; color: var(--quality-color); }
:root :is(.seq-quality-red, [data-quality="6"]) { --quality-color: #a63932; color: var(--quality-color); }
:root :is(option, optgroup):is(.seq-quality-white, .seq-quality-green, .seq-quality-blue,
  .seq-quality-purple, .seq-quality-orange, .seq-quality-red) { color: var(--quality-color) !important; background: var(--paper); }
:root .seq-strong-equipment-picker[class*="seq-quality-"] { color: var(--quality-color); }
:root .seq-owned-equipment-trigger[class*="seq-quality-"],
:root .seq-owned-equipment-option[class*="seq-quality-"] { color: var(--quality-color); }
:root :is(.cet-slot, .cet-person-slot, .cet-candidate)[class*="seq-quality-"],
:root :is(.cet-slot, .cet-person-slot, .cet-candidate)[data-quality] {
  border-left: 3px solid var(--quality-color);
  color: var(--quality-color);
}
:root :is(.cet-slot, .cet-person-slot, .cet-candidate)[class*="seq-quality-"] strong,
:root :is(.cet-slot, .cet-person-slot, .cet-candidate)[data-quality] strong { color: var(--quality-color); }

/* Combat cards, inline editor and shared dialogs. */
:root .combat-workspace { --combat-cyan: var(--accent); --combat-cyan-soft: var(--accent-soft); }
:root :is(.combat-plan, .combat-input-card, .ci-controls, .ci-detail, .ci-empty-state,
  .upload-zone, .stat-card, .equip-card, .plan, .modal, .refinement-sequence-scroll) { border-radius: 5px; }
:root .combat-proof-badge { color: var(--green); background: var(--green-soft); border-color: #97ab87; border-radius: 4px; }
:root .combat-card-heading > span { background: var(--gold-soft); border-color: var(--border); color: var(--accent); border-radius: 3px; }
:root .combat-field-grid label { color: var(--text-dim); }
:root .combat-field-grid input { background: var(--paper); border-radius: 4px; }
:root .combat-field-grid input:focus { box-shadow: 0 0 0 2px var(--accent-soft); }
:root .combat-result-grid article,
:root .combat-formula-strip { background: var(--card); border-color: var(--border); border-radius: 5px; }
:root .combat-result-hero { background: linear-gradient(110deg, var(--gold-soft), var(--card) 70%); border-color: #c4aa73; border-radius: 5px; }
:root .combat-formula-strip span { color: var(--text-dim); }
:root .combat-formula-strip code { color: var(--text); }
:root .combat-input-source { color: var(--accent); }
:root .combat-input-source[data-source="example"] { color: var(--gold); }
:root .combat-input-source[data-source="manual"] { color: var(--text-dim); }
:root .combat-input-source[data-source="stale"] { color: var(--red); }
:root .combat-input-summary { color: var(--gold); background: var(--gold-soft); border-color: #c4aa73; }
:root .combat-plan :is(button, input, select),
:root .cp-popup-content :is(button, input, select),
:root .combat-inspector :is(button, select),
:root .ci-import { border-radius: 4px; }
:root .cp-side-tabs button[aria-pressed="true"],
:root .combat-plan .cp-editor-tabs button[aria-selected="true"],
:root .cp-typed-allocation .cp-typed-modes button[aria-pressed="true"],
:root .combat-inspector .is-selected {
  background: var(--gold-soft);
  color: var(--accent);
  border-color: var(--accent);
}
:root .combat-plan .cp-editor-tabs button { border-radius: 3px 3px 0 0; }
:root .cp-duel,
:root .cp-fresh { background: var(--paper-shade); border-radius: 4px; }
:root .cp-duel[data-state="error"] { color: var(--red); background: var(--red-soft); }
:root .cp-duel[data-state="error"] strong { color: var(--red); }
:root .cp-trial-tag { color: var(--gold); border-color: #c4aa73; background: var(--gold-soft); border-radius: 3px; }
:root .cp-hedao-summary span,
:root .cp-reference-sources small { color: var(--text-dim); }
:root .cp-reference-sources a { color: var(--accent); }
:root .cp-build-martials span { background: var(--paper-shade); }
:root .combat-plan .cp-roster-token { border-color: var(--border); }
:root .combat-plan .cp-manual-switch input { background: #d7c8ac; border-color: #bca789; }
:root .combat-plan .cp-manual-switch input::before { background: var(--paper); }
:root .combat-plan .cp-manual-switch input:checked { background: var(--accent); border-color: var(--accent); }
:root .combat-plan .cp-manual-switch input:checked::before { background: var(--paper); }
:root .combat-plan .cp-stat-inputs input[readonly] { color: var(--text); }
:root .cp-formation-error { color: var(--red); border-left-color: var(--red); }
:root .cp-drag-ghost { color: var(--text); background: var(--paper); border-color: var(--accent); box-shadow: 0 6px 18px rgba(74, 48, 24, .2); }

/* Warm stone platforms keep occupied, selected, disabled and drop states distinct. */
:root :is(.cp-tile-platform, .ci-tile-platform) { background: #bba782; box-shadow: inset 0 -8px #a18a66; }
:root :is(.cp-tile-platform, .ci-tile-platform)::after { background: #e9dcc1; }
:root .cp-formation-tile[data-occupied="true"] .cp-tile-platform,
:root .ci-formation-tile[data-occupied="true"] .ci-tile-platform { background: #91734c; }
:root .cp-formation-tile[data-allowed="false"] .cp-tile-platform,
:root .ci-formation-tile[data-allowed="false"] .ci-tile-platform { background: #cec6b7; box-shadow: inset 0 -8px #b7afa0; }
:root .cp-formation-tile[data-allowed="false"] .cp-tile-platform::after,
:root .ci-formation-tile[data-allowed="false"] .ci-tile-platform::after { background: #ded7c9; }
:root .cp-formation-tile[data-allowed="false"] :is(.cp-tile-name, .cp-tile-caption),
:root .ci-formation-tile[data-allowed="false"] :is(.ci-tile-name, .ci-tile-caption) { color: #847a6b; }
:root .cp-formation-tile[aria-pressed="true"] .cp-tile-platform,
:root .cp-formation-tile[data-allowed="true"]:hover .cp-tile-platform,
:root .cp-formation-tile:focus-visible .cp-tile-platform,
:root .ci-formation-tile.is-selected .ci-tile-platform,
:root .ci-formation-tile:focus-within .ci-tile-platform { background: var(--accent); }
:root .cp-formation-tile:focus-visible .cp-tile-platform::after { background: var(--gold-soft); }
:root .cp-formation-tile[data-conflict="true"] .cp-tile-platform,
:root .ci-formation-tile[data-conflict="true"] .ci-tile-platform { background: var(--orange); }
:root .cp-formation-tile[data-cp-drop="true"] .cp-tile-platform { background: var(--green); }
:root .cp-formation-tile[data-cp-drop="false"] .cp-tile-platform { background: var(--red); }
:root .combat-inspector .ci-tile-name.is-selected,
:root .combat-inspector button.ci-tile-name:hover { color: var(--accent); }
:root .ci-formation-assist { background: var(--paper-shade); }

:root .cet-dialog {
  --cet-bg: var(--paper);
  --cet-card: var(--card);
  --cet-border: var(--border);
  --cet-text: var(--text);
  --cet-muted: var(--text-dim);
  --cet-accent: var(--accent);
  border-radius: 6px;
  background: var(--card);
  box-shadow: 0 12px 42px rgba(74, 48, 24, .26);
}
:root .cet-dialog::backdrop { background: rgba(53, 42, 29, .48); backdrop-filter: none; }
:root .cet-dialog :is(button, input, select, textarea) { border-radius: 4px; }
:root .cet-dialog button { background: var(--paper); color: var(--text); }
:root .cet-dialog button:hover { background: var(--paper-shade); border-color: var(--accent); }
:root .cet-dialog :is(input, select, textarea) { background: var(--paper); border-color: var(--border); color: var(--text); }
:root .cet-dialog .cet-tabs button { background: transparent; border-radius: 0; }
:root .cet-dialog .cet-tabs button[aria-pressed="true"] { background: var(--gold-soft); border-bottom-color: var(--accent); color: var(--accent); }
:root .cet-dialog .cet-person-slot[aria-pressed="true"],
:root .cet-dialog .cet-candidate[aria-pressed="true"] { background: var(--gold-soft); border-color: var(--accent); box-shadow: inset 2px 0 var(--accent); }
:root .cet-equipment-grid .cet-slot { background: var(--paper); border-radius: 4px; }
:root .cet-comparison [data-cet-delta="up"] { color: var(--green); }
:root .cet-comparison [data-cet-delta="down"] { color: var(--red); }
:root .overlay,
:root .seq-wash-planner-modal,
:root .seq-hengshan-replacement-modal { background: rgba(53, 42, 29, .48); backdrop-filter: none; }
:root .modal,
:root .seq-wash-planner-dialog,
:root .seq-auto-workspace .seq-wash-planner-dialog,
:root .seq-hengshan-replacement-dialog { background: var(--card); border-radius: 6px; box-shadow: 0 12px 42px rgba(74, 48, 24, .26); }
:root .seq-wash-planner-close,
:root .seq-hengshan-replacement-close { background: var(--paper); border-radius: 4px; }
:root .seq-wash-planner-close:hover,
:root .seq-hengshan-replacement-close:hover { color: var(--paper); background: var(--accent); }
:root .equip-card:hover { transform: translateY(-2px); box-shadow: 0 5px 16px rgba(74, 48, 24, .12); }
:root .equip-card::before { background: var(--accent); }
:root :is(.file-tag, .mini-tag, .refinement-sequence-controls, .refinement-sequence-presets button) { background: var(--paper-shade); border-color: var(--border); }
:root .refinement-sequence-presets button.is-active { color: var(--accent); background: var(--gold-soft); }
:root .slot-row,
:root .ratio-bar { border-color: var(--ink-line); }
:root .slot-label { color: var(--accent2); }
:root .ratio-bar { background: var(--paper-shade); }

/* Calculated role panels and the assist library also appear outside the duel. */
:root .role-simulator { background: var(--card); color: var(--text); border-color: var(--border); border-radius: 5px; }
:root .role-simulator :is(input, select),
:root .role-sim-inputs select,
:root .atlas-effect-filters select,
:root .combat-save-import-panel input { background: var(--paper); color: var(--text); border-color: var(--border); border-radius: 4px; }
:root .role-sim-stats > div,
:root .combat-loadout pre { background: var(--paper-shade); border-radius: 3px; }
:root :is(.role-sim-head p, .role-sim-stats small, .role-simulator details,
  .atlas-effect-filters p, .combat-save-import-panel p, .combat-save-import-source) { color: var(--text-dim); }
:root .role-simulator a { color: var(--accent); }
:root :is(.assist-atlas, .assist-standalone) { --assist-border: var(--border); background: var(--card); color: var(--text); border-radius: 5px; }
:root .assist-atlas :is(h2, h3, h4) { color: var(--text); }
:root :is(.assist-back, .assist-atlas a, .assist-eyebrow, .assist-count),
:root .assist-atlas .assist-number { color: var(--accent); }
:root .assist-atlas small,
:root .assist-muted,
:root .assist-atlas .assist-diagnostics,
:root .assist-atlas .assist-diagnostics > summary,
:root .assist-atlas .assist-conditions,
:root .assist-empty { color: var(--text-dim); }
:root .assist-atlas :is(input, select, button) { background: var(--paper); color: var(--text); border-radius: 4px; }
:root .assist-atlas button:hover { background: var(--paper-shade); }
:root .assist-roles button[aria-pressed="true"] { background: var(--gold-soft); border-color: var(--accent); box-shadow: inset 3px 0 var(--accent); }
:root .assist-status { background: var(--green-soft); color: var(--green); }
:root .assist-status.warning { background: var(--gold-soft); color: var(--gold); }
:root .assist-note { background: var(--gold-soft); border-left-color: #b79451; }
:root .assist-conditions { border-left-color: var(--accent); }
:root .assist-atlas summary { color: var(--text); }
:root .assist-atlas pre,
:root .assist-calc { background: var(--paper-shade); color: var(--text); }
:root .assist-calc output { color: var(--accent); }

/* The atlas loads its stylesheet on demand; extra scope preserves this theme. */
:root body.martial-atlas-standalone { background: var(--bg); color: var(--text); color-scheme: light; }
:root body.martial-atlas-standalone .martial-atlas-back { color: var(--accent); }
:root body .martial-atlas {
  --atlas-bg: var(--bg);
  --atlas-card: var(--card);
  --atlas-border: var(--border);
  --atlas-text: var(--text);
  --atlas-muted: var(--text-dim);
  --atlas-accent: var(--accent);
  --atlas-gold: var(--gold);
  --atlas-cyan: var(--accent);
  color: var(--text);
  color-scheme: light;
}
:root body .martial-atlas :is(.atlas-button, .atlas-close, input, select) {
  color: var(--text);
  background: var(--paper);
  border-color: var(--border);
  border-radius: 4px;
}
:root body .martial-atlas :is(.atlas-button, .atlas-close):hover { color: var(--accent); background: var(--paper-shade); border-color: var(--accent); }
:root body .martial-atlas input::placeholder { color: #817562; }
:root body .martial-atlas .atlas-filter-group { background: var(--paper-shade); border-color: var(--border); border-radius: 4px; }
:root body .martial-atlas .atlas-filter-group button { color: var(--text-dim); border-radius: 3px; }
:root body .martial-atlas .atlas-filter-group button:hover { color: var(--text); background: var(--card); }
:root body .martial-atlas .atlas-filter-group button[aria-pressed="true"] { background: var(--gold-soft); color: var(--accent); box-shadow: inset 0 -2px var(--accent); }
:root body .martial-atlas .atlas-filter-group [data-atlas-school="少林"],
:root body .martial-atlas .atlas-filter-group [data-atlas-school="天刀"] { color: var(--gold); }
:root body .martial-atlas .atlas-filter-group [data-atlas-school="太乙"],
:root body .martial-atlas .atlas-filter-group [data-atlas-school="苍狼"] { color: #365d81; }
:root body .martial-atlas .atlas-filter-group [data-atlas-school="冷月"],
:root body .martial-atlas .atlas-filter-group [data-atlas-school="极乐谷"] { color: var(--purple); }
:root body .martial-atlas .atlas-filter-group [data-atlas-school="恒山"] { color: var(--green); }
:root body .martial-atlas .atlas-filter-group [data-atlas-school="剑王阁"] { color: var(--red); }
:root body .martial-atlas .atlas-filter-group [data-atlas-category="taolu"] { color: var(--red); }
:root body .martial-atlas .atlas-filter-group [data-atlas-category="neigong"] { color: var(--gold); }
:root body .martial-atlas .atlas-filter-group [data-atlas-category="qinggong"] { color: var(--green); }
:root body .martial-atlas :is(.atlas-list-item, .atlas-record, .atlas-status, .atlas-evidence-item) { background: var(--card); border-color: var(--border); border-radius: 5px; }
:root body .martial-atlas .atlas-list-item:hover { background: var(--paper-shade); border-color: #b79451; }
:root body .martial-atlas .atlas-list-item[aria-pressed="true"] { background: var(--gold-soft); border-color: var(--accent); }
:root body .martial-atlas :is(.atlas-item-name, .atlas-record h4, .atlas-empty strong,
  .atlas-code-intro strong, .atlas-evidence-item > strong) { color: var(--text); }
:root body .martial-atlas .atlas-card-category {
  width: fit-content;
  padding: 2px 5px;
  border: 1px solid var(--ink-line);
  border-radius: 2px;
  background: var(--gold-soft);
  color: var(--accent2);
}
:root body .martial-atlas :is(.atlas-item-meta, .atlas-item-meta code, .atlas-card-traits,
  .atlas-list-footnote, .atlas-description, .atlas-overview code,
  .atlas-detail-tabs button span, .atlas-view-note, .atlas-id,
  .atlas-values dt, .atlas-values dt code, .atlas-raw > summary,
  .atlas-field-table tbody th, .atlas-field-table th code,
  .atlas-code-intro p, .atlas-code-hints, .atlas-function-index > p,
  .atlas-function-item span, .atlas-function-item small,
  .atlas-code-reader-heading p, .atlas-evidence-item > span,
  .atlas-record-trial, .atlas-role-trial, .atlas-conditions,
  .atlas-order-note, .atlas-reading-evidence > summary,
  .atlas-trigger-stage, .atlas-calc-inputs label > span) { color: var(--text-dim); }
:root body .martial-atlas :is(.atlas-detail-tabs, .atlas-parent-description,
  .atlas-values > div, .atlas-calculator, .atlas-function-item) { border-color: var(--ink-line); }
:root body .martial-atlas .atlas-detail-tabs button:hover { color: var(--accent); }
:root body .martial-atlas :is(.atlas-effect-readable, .atlas-calc-result > span,
  .atlas-function-item strong, .atlas-calc-method pre,
  .atlas-field-table td code, .atlas-disassembly) { color: var(--text); }
:root body .martial-atlas .atlas-effect-readable { border-left-color: var(--accent); }
:root body .martial-atlas .atlas-effect-readable h5 { color: var(--accent); }
:root body .martial-atlas :is(.atlas-field-table thead, .atlas-code-chip,
  .atlas-function-index, .atlas-code-reader, .atlas-json, .atlas-modal-tools) { background: var(--paper-shade); color: var(--text); border-color: var(--border); }
:root body .martial-atlas .atlas-code-chip:hover,
:root body .martial-atlas .atlas-code-chip[aria-pressed="true"],
:root body .martial-atlas .atlas-function-item:hover,
:root body .martial-atlas .atlas-function-item[aria-pressed="true"] { background: var(--gold-soft); border-color: var(--accent); color: var(--accent); }
:root body .martial-atlas .atlas-calc-inputs input { background: var(--paper); }
:root body .martial-atlas :is(.atlas-boundary, .atlas-search-evidence) { background: var(--gold-soft); border-color: #c4aa73; }
:root body .martial-atlas :is(.atlas-boundary strong, .atlas-match-reason,
  .atlas-search-evidence > h4, .atlas-search-evidence[open] > summary,
  .atlas-calc-pending > small) { color: var(--gold); }
:root body .martial-atlas .atlas-boundary span { color: var(--text-dim); }
:root body .martial-atlas .atlas-record-match { border-color: #b79451 !important; box-shadow: inset 2px 0 #b79451; }
:root body .martial-atlas .atlas-encoding-note { color: var(--gold) !important; border-left-color: #b79451; }
:root body .martial-atlas .atlas-error { color: var(--red); border-color: #c3937e; background: var(--red-soft); }
:root body .martial-atlas .atlas-modal { background: var(--card); color: var(--text); border-color: var(--border); border-radius: 6px; box-shadow: 0 12px 42px rgba(74, 48, 24, .26); }
:root body .martial-atlas .atlas-modal::backdrop { background: rgba(53, 42, 29, .48); }
:root body .martial-atlas .atlas-modal-tools { background: var(--card); }
:root body .martial-atlas :is(.atlas-list, [data-atlas-code-list], .atlas-disassembly) { scrollbar-color: #bca789 transparent; }

/* The embedded wash simulator reads these aliases inside its own document. */
:root {
  --bg-primary: var(--bg);
  --bg-secondary: var(--paper);
  --bg-card: var(--card);
  --bg-card-hover: var(--paper-shade);
  --border-color: var(--border);
  --border-accent: var(--accent);
  --text-primary: var(--text);
  --text-secondary: var(--text-dim);
  --text-muted: var(--text-dim);
  --white: #635c50;
  --white-dim: #635c50;
  --green-bright: #376749;
  --blue: #365d81;
  --blue-bright: #365d81;
  --purple-bright: var(--purple);
}
:root.workbench-embed {
  --embed-bg: var(--bg);
  --embed-card: var(--card);
  --embed-card-soft: var(--paper);
  --embed-border: var(--border);
  --embed-text: var(--text);
  --embed-muted: var(--text-dim);
  --embed-accent: var(--accent);
  --embed-accent-2: var(--purple);
}
:root body :is(.config-panel, .talent-display, .action-panel,
  .stats-panel, .history-panel, .modal-content, .talent-card) { border-radius: 5px; }
:root body :is(.history-controls, .purple-pane-seq, .selected-exchange-card,
  .selected-exchange-card.fixed-node, .multi-exchange-item,
  .route-pad-stepper .pad-jump input, .custom-wash-group input[type="number"],
  .search-box input, .exchange-stepper .step-btn, .btn-reset-role) { background: var(--paper); border-color: var(--border); color: var(--text); }
:root body :is(.btn-wash-custom, .btn-select-exchange) { color: var(--accent); background: var(--accent-soft); border-color: #c79f80; }
:root body :is(.btn-wash-custom:hover, .btn-select-exchange:hover) { color: var(--accent); background: var(--paper-shade); border-color: var(--accent); }
:root body :is(.btn-analyze-purple, .btn-select-exchange.active, .native-route-handoff) { background: var(--purple-soft); border-color: #b39bbd; color: var(--purple); }
:root body .btn-analyze-purple:hover { background: #e0cfe3; border-color: var(--purple); color: var(--purple); }
:root body :is(.purple-table th, .route-pad-table thead th) { background: var(--paper-shade); color: var(--text-dim); }
:root body .modal-overlay { background: rgba(53, 42, 29, .48); }
:root body .modal-content { box-shadow: 0 12px 42px rgba(74, 48, 24, .26); }
:root body .talent-card.q1 { border-color: var(--border); }
:root body .talent-card.q2 { border-color: #97ab87; }
:root body .talent-card.q3 { border-color: #8298a8; }
:root body .talent-card.q4 { background: var(--purple-soft); border-color: #b39bbd; }
:root body .talent-card.locked { background: var(--purple-soft); }
:root body .talent-card.conflict { background: var(--red-soft); border-color: #c3937e; }
:root body :is(.talent-exchange-btn, .talent-lock-btn.locked) { color: var(--purple); background: var(--purple-soft); border-color: #b39bbd; }
:root.workbench-embed body :is(.btn-wash, .btn-analyze-purple) { color: var(--accent); background: var(--gold-soft); border-color: #c4aa73; }
:root body .pity-fill { background: var(--purple); }
:root body .purple-table tr.row-highlight { background: var(--purple-soft) !important; }
:root body .route-pad-row.current-step,
:root body .multi-exchange-item.current-step { background: var(--purple-soft); }

/* One-strike comparison: both people, both results and final attributes together. */
:root .strike-person-selectors {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: end;
  gap: 10px;
  margin: 12px 0 10px;
}
:root .strike-person-selectors > label { display: grid; min-width: 0; gap: 5px; color: var(--text-dim); font-size: 12px; }
:root .strike-person-selectors select {
  width: 100%;
  min-width: 0;
  min-height: 40px;
  padding: 8px;
  border: 1px solid var(--border);
  background: var(--paper);
  color: var(--text);
  font: inherit;
  border-radius: 4px;
}
:root .strike-versus { align-self: end; padding-bottom: 9px; color: var(--accent); font-family: "Songti SC", serif; }
:root .role-sim-inputs.strike-options { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr) minmax(110px, .7fr); }
:root .strike-options label { min-width: 0; color: var(--text-dim); font-size: 12px; }
:root .strike-options :is(input, select) { width: 100%; min-width: 0; background: var(--paper); }
:root #combatStrikeComparison { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; margin: 12px 0; }
:root .strike-comparison-card { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; min-width: 0; padding: 12px; border: 1px solid var(--border); border-radius: 5px; background: var(--paper); }
:root .strike-comparison-card > div { display: grid; gap: 5px; min-width: 0; }
:root .strike-comparison-card h4 { margin: 0 0 9px; color: var(--accent); font-family: "Songti SC", serif; font-size: 16px; }
:root .strike-comparison-card :is(dl, .combat-result-grid) { margin: 0; }
:root .strike-comparison-card :is(dt, small, span) { color: var(--text-dim); }
:root .strike-comparison-card dd { color: var(--text); font-variant-numeric: tabular-nums; }
:root .strike-comparison-card strong { color: var(--text); }
:root :is(.strike-final-stats, .strike-coverage) { margin-top: 10px; padding-top: 9px; border-top: 1px solid var(--border); color: var(--text); }
:root :is(.strike-final-stats, .strike-coverage) > summary { cursor: pointer; color: var(--accent); font-size: 13px; font-weight: 600; }
:root #combatStrikeFinalStats { max-width: 100%; overflow-x: auto; margin-top: 8px; }
:root :is(#combatStrikeFinalStats, .strike-final-stats) table { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
:root :is(#combatStrikeFinalStats, .strike-final-stats) :is(th, td) { border-bottom: 1px solid var(--ink-line); padding: 7px 10px; text-align: right; }
:root :is(#combatStrikeFinalStats, .strike-final-stats) :is(th, td):first-child { text-align: left; }
:root :is(#combatStrikeFinalStats, .strike-final-stats) thead th { background: var(--paper-shade); color: var(--text-dim); font-weight: 500; }
:root #combatStrikeCoverage { margin: 7px 0; color: var(--text-dim); font-size: 12px; line-height: 1.6; }
:root #combatStrikeBuffChoices { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 10px; }
:root #combatStrikeBuffChoices[hidden] { display: none; }
:root .strike-buff-side { min-width: 0; padding: 10px; background: var(--paper); border: 1px solid var(--border); border-radius: 4px; }
:root .strike-buff-side :is(h4, legend) { color: var(--accent); font-size: 13px; font-weight: 600; margin: 0 0 6px; }
:root .strike-buff-checklist { display: grid; gap: 3px; max-height: 240px; overflow-y: auto; }
:root :is(.strike-buff-side, .strike-buff-checklist) label { display: flex; align-items: center; gap: 7px; min-height: 32px; color: var(--text); font-size: 12px; }
:root :is(.strike-buff-side, .strike-buff-checklist) input[type="checkbox"] { width: 16px; height: 16px; flex-shrink: 0; margin: 0; }
:root .strike-buff-side small { color: var(--text-dim); }

@media (max-width: 680px) {
  :root .seq-workspace-group,
  :root .seq-workspace-tablist .seq-tab,
  :root .seq-button,
  :root .combat-plan button,
  :root .combat-inspector button,
  :root .cet-dialog button { min-height: 42px; }
  :root .seq-workspace-group { padding-inline: 7px; }
  :root .seq-workspace-tablist { max-width: calc(100vw - 24px); }
  :root :is(.seq-toolbar, .seq-special-controls, .seq-jianwang-future-controls,
    .seq-strong-toolbar, .seq-hengshan-toolbar, .seq-hengshan-replacement-controls,
    .combat-plan, .combat-inspector, .role-simulator, .cet-dialog,
    .assist-atlas, .combat-save-import-panel) :is(input, select, textarea) { font-size: 16px; }
  :root .cet-dialog { width: calc(100vw - 16px); max-height: calc(100dvh - 16px); border-radius: 5px; }
  :root .cet-dialog-head { padding: 10px 12px; }
  :root .cet-dialog-body { padding-inline: 12px; }
  :root .cet-actions { background: var(--card); }
  :root .slot-label { color: var(--accent2); }
  :root .strike-person-selectors { gap: 6px; }
  :root .strike-person-selectors select { font-size: 16px; min-height: 42px; padding: 8px 5px; }
  :root .role-sim-inputs.strike-options { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  :root .strike-options > label:first-child { grid-column: 1 / -1; }
  :root #combatStrikeComparison { gap: 7px; }
  :root .strike-comparison-card { padding: 9px; }
  :root .strike-comparison-card h4 { font-size: 15px; }
  :root :is(.strike-buff-side, .strike-buff-checklist) label { min-height: 40px; }
  :root #combatStrikeFinalStats :is(th, td) { padding-inline: 6px; }
  :root body .martial-atlas :is(input, select) { font-size: 16px; min-height: 42px; }
  :root body .martial-atlas :is(.atlas-button, .atlas-close, .atlas-filter-group button) { min-height: 40px; }
  :root body .martial-atlas .atlas-modal { border-radius: 5px; }
  :root body .app-container :is(select, input:not([type="checkbox"])) { font-size: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  :root :is(.equip-card, .seq-tab, .seq-button, .modal) { animation: none; transition: none; }
  :root .equip-card:hover { transform: none; }
}

@media print {
  :root { --bg: #fff; --card: #fff; --text: #222; --text-dim: #555; }
  body::before { display: none; }
}
