:root {
  color-scheme: dark;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #0b0d10;
  color: #f2f6f8;
  --bg: #0b0d10;
  --panel: #13171c;
  --panel-2: #1a2027;
  --panel-3: #222a33;
  --field: #0d1116;
  --field-border: #3b4652;
  --line: #34404c;
  --text: #f2f6f8;
  --muted: #a9b2ba;
  --accent: #d6a23e;
  --accent-strong: #f0b84f;
  --accent-soft: rgba(240, 184, 79, 0.12);
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.42);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: var(--bg);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

a {
  color: var(--accent-strong);
}

h1,
h2,
p,
dl,
dd,
ul {
  margin: 0;
}

.app-shell {
  width: min(100%, 1500px);
  margin: 0 auto;
  padding: 18px;
}

.topbar,
.brand,
.top-actions,
.section-heading,
.preset-row,
.segmented,
.checkbox-label {
  display: flex;
  align-items: center;
}

.topbar {
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.brand {
  gap: 13px;
  color: var(--text);
  text-decoration: none;
}

.brand-mark {
  width: 52px;
  height: 52px;
  flex: 0 0 52px;
  display: block;
  border-radius: 8px;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35);
}

.brand small,
.section-heading span,
.result-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.brand strong {
  display: block;
  margin-top: 2px;
  font-size: clamp(28px, 4vw, 42px);
  line-height: 1;
}

.top-actions {
  justify-content: flex-end;
  gap: 9px;
  flex-wrap: wrap;
}

.status-pill,
.ghost-button,
.preset-row button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: rgba(19, 23, 28, 0.9);
}

.status-pill {
  display: inline-grid;
  place-items: center;
  padding: 0 12px;
  color: var(--muted);
}

.ghost-button,
.preset-row button {
  padding: 0 13px;
}

.ghost-button:hover,
.preset-row button:hover {
  border-color: var(--accent);
}

.results-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.result-card,
.calculator-panel,
.info-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(19, 23, 28, 0.94);
  box-shadow: var(--shadow);
}

.result-card {
  min-height: 154px;
  padding: 18px;
  position: relative;
  overflow: hidden;
}

.result-card::after {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 4px;
  background: var(--accent);
}

.result-card.primary {
  border-color: rgba(240, 184, 79, 0.5);
  background: rgba(19, 23, 28, 0.94);
}

.result-card strong {
  display: block;
  margin-top: 9px;
  font-size: clamp(40px, 7vw, 70px);
  line-height: 0.95;
}

.result-card p {
  margin-top: 11px;
  color: var(--muted);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(340px, 0.36fr);
  gap: 16px;
  align-items: start;
}

.calculator-panel,
.side-column {
  min-width: 0;
}

.side-column {
  display: grid;
  gap: 16px;
}

.panel-section,
.info-card {
  padding: 18px;
}

.panel-section + .panel-section {
  border-top: 1px solid var(--line);
}

.section-heading {
  gap: 12px;
  margin-bottom: 14px;
}

.section-heading span {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--accent-strong);
  background: var(--panel-2);
}

.section-heading h2,
.info-card h2 {
  font-size: 22px;
  line-height: 1.1;
}

.preset-row {
  flex-wrap: wrap;
  gap: 9px;
  margin-bottom: 14px;
}

.split-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.wide-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

fieldset {
  min-width: 0;
  margin: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(26, 32, 39, 0.76);
}

legend {
  padding: 0 8px;
  font-weight: 850;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 740;
}

label + label,
label + .field-note,
label + .field-help-block,
.segmented + label {
  margin-top: 12px;
}

input,
select {
  width: 100%;
  min-height: 42px;
  padding: 0 11px;
  border: 1px solid var(--field-border);
  border-radius: 8px;
  outline: none;
  color: var(--text);
  background: var(--field);
}

input:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.field-note {
  padding: 10px;
  border: 1px solid rgba(240, 184, 79, 0.38);
  border-radius: 8px;
  color: var(--muted);
  background: var(--accent-soft);
  font-size: 13px;
  line-height: 1.42;
}

.field-help {
  color: #8f9aa5;
  font-size: 12px;
  font-weight: 560;
  line-height: 1.35;
}

.field-help-block {
  margin: 8px 0 0;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--field);
}

.segmented label {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  border-radius: 6px;
  color: var(--text);
}

.segmented input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
}

.segmented label:has(input:checked) {
  color: #11161b;
  background: var(--accent);
  font-weight: 850;
}

.checkbox-label {
  flex-wrap: wrap;
  gap: 10px;
  min-height: 42px;
  padding: 0 11px;
  border: 1px solid var(--field-border);
  border-radius: 8px;
  background: var(--field);
}

.checkbox-label .field-help {
  flex-basis: 100%;
  padding: 0 0 9px 28px;
}

.checkbox-label input {
  width: 18px;
  min-height: 18px;
  padding: 0;
  accent-color: var(--accent);
}

.info-card p,
.source-list {
  color: var(--muted);
  line-height: 1.52;
}

.info-card h2 {
  margin-bottom: 12px;
}

.breakdown-list {
  display: grid;
  gap: 9px;
}

.breakdown-list div {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: start;
  padding-bottom: 9px;
  border-bottom: 1px solid var(--line);
}

.breakdown-list div:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

dt {
  color: var(--muted);
}

dd {
  font-weight: 850;
  text-align: right;
}

.breakdown-list small {
  grid-column: 1 / -1;
  color: #8f9aa5;
  font-size: 12px;
  line-height: 1.35;
}

.breakdown-emphasis dd {
  color: var(--accent-strong);
}

.source-list {
  display: grid;
  gap: 8px;
  padding-left: 18px;
}

code {
  color: var(--accent-strong);
}

[data-defense="direct"] {
  display: none;
}

body.direct-defense [data-defense="rating"] {
  display: none;
}

body.direct-defense [data-defense="direct"] {
  display: grid;
}

@media (max-width: 1120px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .side-column {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .wide-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 840px) {
  .app-shell {
    padding: 12px;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .top-actions,
  .preset-row {
    justify-content: flex-start;
  }

  .results-grid,
  .split-grid,
  .side-column,
  .wide-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .brand {
    align-items: flex-start;
  }

  .top-actions > *,
  .preset-row button {
    width: 100%;
    justify-content: center;
  }
}
