
:root {
  color-scheme: light dark;
  --bg: #f0f3f1;
  --surface: #f5f7f6;
  --surface-2: #eaeeec;
  --surface-3: #e2e7e4;
  --ink: #17211d;
  --muted: #5b6761;
  --line: #cdd6d2;
  --green: #2f6f5e;
  --green-2: #d8e4de;
  --red: #7b2d26;
  --red-2: #ebddd9;
  --blue: #285f82;
  --gold: #b9852c;
  --fact-facts-bg: #eaeeec;
  --fact-row-bg: #f1f4f2;
  --fact-label: #485651;
  --chip-surface: var(--surface-2);
  --chip-border: var(--line);
  --chip-text: #2f3d37;
  --on-dark: #e7ede9;
  --shadow: 0 12px 30px rgba(20, 35, 31, 0.09);
}


html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #101513;
  --surface: #18211d;
  --surface-2: #202825;
  --surface-3: #1b2320;
  --ink: #e2e8e4;
  --muted: #9da8a3;
  --line: #31403a;
  --green: #7bb9a4;
  --green-2: #1d312b;
  --red: #d08a7f;
  --red-2: #402925;
  --blue: #74a3c4;
  --gold: #d7b05e;
  --fact-facts-bg: #121916;
  --fact-row-bg: #1a231f;
  --fact-label: #b8c3be;
  --chip-surface: var(--surface-2);
  --chip-border: var(--line);
  --chip-text: var(--ink);
  --on-dark: #e7ede9;
  --shadow: 0 16px 34px rgba(0, 0, 0, 0.38);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.45;
}

button,
input,
select {
  font: inherit;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 18px clamp(16px, 4vw, 44px);
  background: #17211d;
  color: var(--on-dark);
  border-bottom: 4px solid var(--gold);
}

.header-tools {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.theme-toggle {
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.06);
  color: var(--on-dark);
  border-radius: 999px;
  padding: 0.62rem 0.95rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

.theme-toggle:hover {
  border-color: rgba(255, 255, 255, 0.3);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.brand-mark {
  width: 46px;
  height: 46px;
  image-rendering: auto;
  flex: 0 0 auto;
}

h1,
h2,
h3,
p {
  margin: 0;
}

.brand h1 {
  font-size: 24px;
  line-height: 1.1;
  font-weight: 780;
}

.brand p,
.header-metrics {
  color: #dce6e2;
}

.header-metrics {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  font-size: 13px;
}

html[data-theme="dark"] .theme-toggle {
  border-color: var(--line);
  background: linear-gradient(180deg, #222c27, #18201d);
  color: var(--ink);
}

html[data-theme="dark"] .theme-toggle:hover {
  border-color: var(--gold);
}

.metric-pill {
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 999px;
  padding: 5px 10px;
}

.app-shell {
  width: min(1480px, 100%);
  margin: 0 auto;
  padding: 20px clamp(12px, 3vw, 28px) 44px;
}

.controls-band,
.top-grid,
.command-panel,
.stat-band,
.finder-grid,
.results-section,
.building-tech-info,
.support-info {
  width: 100%;
}

.top-grid {
  display: grid;
  grid-template-columns: minmax(420px, 0.9fr) minmax(300px, 1.1fr);
  align-items: stretch;
  gap: 12px;
}

.controls-band {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.command-panel {
  margin-top: 12px;
  padding: 10px 12px 12px;
  background: #232b27;
  border: 1px solid #1a221f;
  box-shadow: var(--shadow);
}

.command-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 20px;
  margin-bottom: 8px;
  color: var(--on-dark);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0;
}

.command-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 8px;
}

.command-button {
  min-width: 0;
  min-height: 74px;
  display: grid;
  grid-template-columns: 50px minmax(0, 1fr);
  align-items: start;
  gap: 6px 8px;
  padding: 8px;
  background: #2a332f;
  color: var(--on-dark);
  border: 1px solid #435249;
  border-radius: 4px;
  cursor: pointer;
  text-align: left;
}

.command-button:hover,
.command-button:focus {
  border-color: var(--gold);
  outline: none;
}

.command-button.is-active {
  background: #3a3324;
  border-color: var(--gold);
  box-shadow: inset 0 0 0 1px rgba(185, 133, 44, 0.8);
}

.command-icons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3px;
  align-self: start;
}

.command-button img {
  width: 25px;
  height: 25px;
  object-fit: contain;
  background: #111713;
  border: 1px solid #536258;
  border-radius: 3px;
  padding: 2px;
}

.command-copy {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.command-copy strong {
  font-size: 12px;
  line-height: 1.15;
  font-weight: 750;
}

.command-copy span {
  color: #c9d2cd;
  font-size: 10px;
  line-height: 1.1;
}

.command-badges {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 3px;
  min-height: 16px;
}

.command-badges .spawn-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: 15px;
  min-width: 22px;
  border-radius: 999px;
  padding: 1px 5px;
  border: 1px solid rgba(209, 220, 214, 0.18);
  background: #36423c;
  color: #d6ded9;
  font-size: 9px;
  font-weight: 700;
  line-height: 1;
  opacity: 0.72;
}

.command-badges .spawn-wood {
  min-width: 42px;
  background: #e8dac0;
  color: #5f4112;
  border-color: #d5b86f;
  opacity: 1;
}

.command-badges .badge-icon {
  width: 11px;
  height: 11px;
  object-fit: contain;
  background: transparent;
  border: 0;
  border-radius: 0;
  padding: 0;
}

.command-badges .spawn-unit {
  background: #3e453a;
}

.command-badges .spawn-build {
  background: #34434a;
}

.command-badges .spawn-summon {
  background: #403947;
}

.field {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.field span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  text-transform: uppercase;
  letter-spacing: 0;
}

select,
input[type="search"] {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, var(--surface), var(--surface-2));
  color: var(--ink);
  border-radius: 6px;
  padding: 0 12px;
  outline: none;
}

select option {
  background: var(--surface);
  color: var(--ink);
}

select:focus,
input[type="search"]:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(47, 111, 94, 0.16);
}

.stat-band {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 12px;
  padding: 12px 14px;
  background: var(--surface-2);
  border: 1px solid var(--line);
}

.segmented {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.segment-button {
  border: 1px solid var(--chip-border);
  background: var(--chip-surface);
  color: var(--muted);
  border-radius: 999px;
  padding: 7px 11px;
  cursor: pointer;
  min-height: 34px;
}

.segment-button.is-disabled,
.segment-button:disabled {
  background: #d7dddb;
  border-color: #d2dad7;
  color: #9aa5a1;
  cursor: not-allowed;
  opacity: 0.72;
}

.segment-button.is-active {
  background: var(--green);
  border-color: var(--green);
  color: var(--on-dark);
}

.segment-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  margin-left: 6px;
  border-radius: 999px;
  background: var(--surface-2);
  color: #40514a;
  font-size: 11px;
  font-weight: 800;
}

.segment-button.is-active .segment-count {
  background: rgba(255, 255, 255, 0.2);
  color: var(--on-dark);
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  white-space: nowrap;
  color: var(--ink);
  font-weight: 700;
}

.toggle input {
  width: 18px;
  height: 18px;
  accent-color: var(--green);
}

.finder-grid {
  display: grid;
  grid-template-columns: minmax(300px, 360px) minmax(0, 1fr);
  align-items: start;
  gap: 16px;
  margin-top: 16px;
}

.unit-column {
  display: grid;
  gap: 12px;
  position: sticky;
  top: 14px;
}

.unit-summary,
.civ-summary,
.coverage-summary {
  background: var(--surface);
  border: 1px solid var(--line);
  padding: 16px;
}

.top-grid .civ-summary {
  padding: 12px;
}

.compact-title {
  margin-bottom: 6px;
}

.compact-title img {
  width: 42px;
  height: 42px;
}

.top-grid .civ-summary .bonus-list {
  gap: 4px;
  margin-top: 6px;
}

.top-grid .civ-summary .bonus-list li {
  font-size: 12px;
  line-height: 1.25;
}

.team-bonus {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
  color: #263630;
  font-size: 12px;
  line-height: 1.3;
}

.team-bonus strong {
  color: var(--green);
  margin-right: 6px;
}

.summary-title {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.summary-title img {
  width: 54px;
  height: 54px;
  object-fit: contain;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 4px;
}

.summary-title h2,
.section-heading h2 {
  font-size: 18px;
  line-height: 1.2;
}

.summary-title p,
.section-heading p,
.source-note,
.muted {
  color: var(--muted);
  font-size: 13px;
}

.unit-facts {
  display: grid;
  gap: 8px;
  margin-top: 12px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--fact-facts-bg);
}

.fact-row {
  display: grid;
  grid-template-columns: 96px 1fr;
  align-items: start;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px;
  background: var(--fact-row-bg);
  min-width: 0;
}

.fact-row strong {
  font-size: 13px;
  font-weight: 750;
  min-width: 0;
  overflow-wrap: anywhere;
}

.fact-row span {
  color: var(--fact-label);
  font-size: 11px;
  text-transform: uppercase;
}

.unit-line-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
}

.unit-line-list span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  border: 1px solid var(--chip-border);
  border-radius: 999px;
  padding: 4px 8px 4px 5px;
  background: var(--chip-surface);
  color: var(--chip-text);
  font-size: 12px;
  font-weight: 700;
}

.unit-line-list img {
  width: 22px;
  height: 22px;
  object-fit: contain;
}

.bonus-list,
.compact-list {
  display: grid;
  gap: 7px;
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
}

.bonus-list li,
.compact-list li {
  position: relative;
  padding-left: 14px;
  color: #263630;
  font-size: 13px;
}

.bonus-list li::before,
.compact-list li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.65em;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--green);
}

.coverage-bars {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.coverage-row {
  display: grid;
  grid-template-columns: 112px 1fr 32px;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

.bar {
  height: 8px;
  background: var(--surface-3);
  border-radius: 999px;
  overflow: hidden;
}

.bar span {
  display: block;
  height: 100%;
  background: var(--blue);
  border-radius: inherit;
}

.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  margin: 0 0 12px;
}

.tech-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: 12px;
}

.tech-card {
  display: grid;
  grid-template-columns: 64px 1fr;
  gap: 12px;
  padding: 14px;
  min-height: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 4px solid var(--green);
}

.tech-card.effect-scenario {
  border-left-color: var(--green);
}

.tech-card.effect-workbook {
  border-left-color: #9b7531;
}

.tech-card.effect-base {
  border-left-color: #2f6f94;
}

.tech-card.effect-unknown {
  border-left-color: #8e9a95;
}

.tech-icon {
  width: 58px;
  height: 58px;
  object-fit: contain;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 4px;
}

.tech-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.tech-title-row h3 {
  font-size: 17px;
  line-height: 1.2;
}

.probability {
  flex: 0 0 auto;
  min-width: 44px;
  text-align: center;
  color: var(--on-dark);
  background: var(--red);
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 800;
}

.tech-age {
  background: #2f6f94;
  min-width: 58px;
}

.meta-line,
.tag-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.meta-chip,
.tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 12px;
  font-weight: 700;
}

.meta-chip {
  background: var(--green-2);
  color: #1f594a;
}

.meta-chip.warn {
  background: var(--red-2);
  color: var(--red);
}

.tag {
  background: #e7ebea;
  color: #40514a;
}

.cost-chip {
  gap: 6px;
  border: 1px solid transparent;
}

.cost-scenario {
  background: #d8e4de;
  color: #1f594a;
  border-color: #b9d6cc;
}

.cost-legacy {
  background: #ebddd9;
  color: #7b2d26;
  border-color: #dfc1bc;
}

.cost-unknown {
  background: #e7ebea;
  color: #40514a;
  border-color: #d7ddda;
}

.resource-cost-item {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.resource-cost-item img {
  width: 14px;
  height: 14px;
  object-fit: contain;
}

.cost-empty {
  font-weight: 800;
}

.effect-text {
  margin-top: 8px;
  color: #263630;
  font-size: 13px;
}

.note-text {
  margin-top: 6px;
  color: var(--red);
  font-size: 12px;
}

.match-reason {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
}

.empty-state {
  grid-column: 1 / -1;
  background: var(--surface);
  border: 1px solid var(--line);
  padding: 28px;
  text-align: center;
  color: var(--muted);
}

.spawn-table {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 10px;
}

.spawn-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 8px;
  background: #27312c;
  border: 1px solid #435249;
  color: var(--on-dark);
  padding: 8px;
}

.spawn-row strong {
  display: block;
  font-size: 14px;
}

.spawn-row span,
.spawn-row em {
  color: #c9d2cd;
  font-size: 12px;
  font-style: normal;
}

.spawn-icons {
  display: flex;
  align-items: center;
  gap: 4px;
}

.spawn-icons img {
  width: 28px;
  height: 28px;
  object-fit: contain;
  background: #121815;
  border: 1px solid #536258;
  border-radius: 3px;
  padding: 2px;
}

.spawn-row .spawn-badge {
  align-self: start;
  background: var(--green-2);
  color: #1f594a;
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 800;
}

.building-tech-info,
.support-info {
  margin-top: 22px;
}

.support-heading,
.building-tech-heading {
  margin-top: 0;
}

.support-grid {
  display: grid;
  grid-template-columns: minmax(280px, 0.95fr) minmax(320px, 1.25fr);
  gap: 12px;
}

.building-tech-list {
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
}

.compact-empty {
  padding: 16px;
  text-align: left;
}

.full-width-panel {
  width: 100%;
}

.manual-unit-grid {
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}

.support-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  padding: 14px;
}

.support-panel h3 {
  font-size: 15px;
}

.manual-unit-groups,
.support-tech-list {
  display: grid;
  gap: 10px;
  margin-top: 10px;
}

.manual-group {
  border: 1px solid var(--line);
  background: var(--surface);
  padding: 10px;
}


.manual-building {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.manual-building img,
.support-tech-icon {
  width: 34px;
  height: 34px;
  object-fit: contain;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 3px;
}

.manual-units {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.manual-units > span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px solid var(--chip-border);
  border-radius: 999px;
  padding: 4px 8px 4px 4px;
  background: var(--chip-surface);
  font-size: 12px;
  font-weight: 700;
}

.manual-unit {
  max-width: 100%;
}

.manual-unit-name {
  white-space: nowrap;
}

.manual-unit-cost {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  margin-left: 2px;
  padding-left: 6px;
  border-left: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.manual-unit-cost .resource-cost-item {
  gap: 2px;
}

.manual-units .manual-unit-cost img {
  width: 13px;
  height: 13px;
  padding: 0;
  background: transparent;
  border: 0;
}

.manual-units img {
  width: 22px;
  height: 22px;
  object-fit: contain;
}

.support-tech {
  display: grid;
  grid-template-columns: 40px 1fr;
  gap: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  padding: 10px;
}

.support-tech-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.support-tech-title span,
.support-tech p {
  color: var(--muted);
  font-size: 12px;
}

.support-tech p {
  margin-top: 5px;
}

html[data-theme="dark"] body {
  background:
    radial-gradient(circle at top left, rgba(215, 176, 94, 0.12), transparent 28%),
    radial-gradient(circle at top right, rgba(123, 185, 164, 0.1), transparent 24%),
    var(--bg);
}

html[data-theme="dark"] .app-header {
  background: #0c1210;
  color: var(--ink);
}

html[data-theme="dark"] .brand p,
html[data-theme="dark"] .header-metrics,
html[data-theme="dark"] .metric-pill,
html[data-theme="dark"] .summary-title p,
html[data-theme="dark"] .section-heading p,
html[data-theme="dark"] .source-note,
html[data-theme="dark"] .muted,
html[data-theme="dark"] .team-bonus,
html[data-theme="dark"] .bonus-list li,
html[data-theme="dark"] .compact-list li,
html[data-theme="dark"] .spawn-row span,
html[data-theme="dark"] .spawn-row em,
html[data-theme="dark"] .support-tech-title span,
html[data-theme="dark"] .support-tech p,
html[data-theme="dark"] .match-reason,
html[data-theme="dark"] .note-text,
html[data-theme="dark"] .effect-text,
html[data-theme="dark"] .raw-details summary {
  color: var(--muted);
}

html[data-theme="dark"] .brand h1,
html[data-theme="dark"] .summary-title h2,
html[data-theme="dark"] .unit-summary .summary-title p,
html[data-theme="dark"] .section-heading h2,
html[data-theme="dark"] .fact-row strong,
html[data-theme="dark"] .command-copy strong,
html[data-theme="dark"] .command-panel-header,
html[data-theme="dark"] .spawn-row strong,
html[data-theme="dark"] .support-panel h3,
html[data-theme="dark"] .unit-line-list span {
  color: var(--ink);
}

html[data-theme="dark"] .command-panel {
  background: #171e1b;
  border-color: var(--line);
}

html[data-theme="dark"] .command-button {
  background: linear-gradient(180deg, #232c27, #1a211d);
  border-color: #415048;
  color: var(--on-dark);
}

html[data-theme="dark"] .command-button.is-active {
  background: linear-gradient(180deg, #3a3324, #2e281c);
  border-color: var(--gold);
  box-shadow: inset 0 0 0 1px rgba(215, 176, 94, 0.75);
}

html[data-theme="dark"] .command-button img {
  background: #101614;
  border-color: #536258;
}

html[data-theme="dark"] .command-copy span {
  color: #c7d0cb;
}

html[data-theme="dark"] .command-badges .spawn-badge {
  background: #2d3632;
  color: #d5ddd8;
  border-color: #49554f;
}

html[data-theme="dark"] .command-badges .spawn-wood {
  background: #45351d;
  color: #f2ddb0;
  border-color: #8d6b2a;
}

html[data-theme="dark"] .panel,
html[data-theme="dark"] .summary-card,
html[data-theme="dark"] .linked-card,
html[data-theme="dark"] .details-card,
html[data-theme="dark"] .match-card,
html[data-theme="dark"] .muted-box,
html[data-theme="dark"] .unit-summary,
html[data-theme="dark"] .civ-summary,
html[data-theme="dark"] .coverage-summary,
html[data-theme="dark"] .support-panel,
html[data-theme="dark"] .empty-state {
  background: linear-gradient(180deg, var(--surface), #131917);
}

html[data-theme="dark"] button,
html[data-theme="dark"] .file-button,
html[data-theme="dark"] input,
html[data-theme="dark"] select,
html[data-theme="dark"] textarea {
  background: linear-gradient(180deg, #212923, #181f1b);
  border-color: #3a4943;
  color: var(--ink);
}

html[data-theme="dark"] select option {
  background: var(--surface);
  color: var(--ink);
}

html[data-theme="dark"] .pill,
html[data-theme="dark"] .tag,
html[data-theme="dark"] .meta-chip {
  background: rgba(255, 255, 255, 0.04);
  border-color: var(--line);
  color: var(--muted);
}

html[data-theme="dark"] .browser-card,
html[data-theme="dark"] .tech-card,
html[data-theme="dark"] .data-table-wrap,
html[data-theme="dark"] .checklist,
html[data-theme="dark"] .data-table td,
html[data-theme="dark"] .data-table th,
html[data-theme="dark"] .tech-effect-item {
  background: #151c19;
  border-color: var(--line);
}

html[data-theme="dark"] .browser-card img,
html[data-theme="dark"] .tech-card img,
html[data-theme="dark"] .summary-head img,
html[data-theme="dark"] .civ-unique-section .civ-icon,
html[data-theme="dark"] .linked-card img,
html[data-theme="dark"] .manual-building img,
html[data-theme="dark"] .support-tech-icon {
  background: #101614;
  border-color: var(--line);
}

html[data-theme="dark"] .mode-button.is-active {
  background: linear-gradient(180deg, #203129, #1a2721);
  border-color: var(--green);
}

html[data-theme="dark"] .segment-button {
  background: #1a221f;
  border-color: var(--line);
  color: var(--muted);
}

html[data-theme="dark"] .segment-button.is-active {
  background: linear-gradient(180deg, #203129, #1a2721);
  border-color: var(--green);
  color: var(--ink);
}

html[data-theme="dark"] .segment-count {
  background: #24312c;
  color: var(--ink);
}

html[data-theme="dark"] .tag.emphasis {
  background: #332b1b;
  border-color: #776038;
  color: #f0dfb0;
}

html[data-theme="dark"] .data-table th {
  background: #1b221f;
}

html[data-theme="dark"] .check-option.is-checked {
  background: #1e322c;
  border-color: #355145;
}

html[data-theme="dark"] .check-option input {
  accent-color: var(--green);
}

html[data-theme="dark"] .raw-details summary {
  color: var(--green);
}

@media (max-width: 1120px) {
  .top-grid,
  .support-grid {
    grid-template-columns: 1fr;
  }

  .finder-grid {
    grid-template-columns: minmax(260px, 320px) minmax(0, 1fr);
  }
}

@media (max-width: 760px) {
  .app-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .header-tools {
    width: 100%;
    justify-content: flex-start;
  }

  .header-metrics {
    justify-content: flex-start;
  }

  .controls-band,
  .top-grid,
  .finder-grid,
  .tech-grid {
    grid-template-columns: 1fr;
  }

  .unit-column {
    position: static;
  }

  .search-field {
    grid-column: auto;
  }

  .stat-band,
  .section-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .toggle {
    white-space: normal;
  }

  .command-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  }
}

@media (max-width: 460px) {
  .brand h1 {
    font-size: 20px;
  }

  .tech-card {
    grid-template-columns: 52px 1fr;
  }

  .tech-icon {
    width: 48px;
    height: 48px;
  }

  .fact-row {
    grid-template-columns: 82px 1fr;
  }

  .command-button {
    min-height: 76px;
    grid-template-columns: 50px minmax(0, 1fr);
  }

  .command-button img {
    width: 24px;
    height: 24px;
  }
}
