:root {
  color-scheme: light;
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #eef2f1;
  --text: #17201d;
  --muted: #63706b;
  --line: #d9dfdc;
  --accent: #0f7d6b;
  --accent-strong: #095d50;
  --warn: #b64b34;
  --gold: #9c742a;
  --blue: #2f6f9f;
  --shadow: 0 10px 26px rgba(23, 32, 29, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  letter-spacing: 0;
}

button,
select,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  min-height: 74px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 14px 22px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 5;
}

.brand-block,
.topbar-actions,
.champion-select-wrap,
.range-row,
.item-row,
.card-top,
.card-items,
.tag-row,
.scenario-heading,
.breakdown-metrics {
  display: flex;
  align-items: center;
}

.brand-block {
  gap: 14px;
  min-width: 0;
}

.brand-mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: #ffffff;
  background: #17201d;
  font-weight: 800;
}

h1,
h2 {
  margin: 0;
  font-size: 18px;
  line-height: 1.2;
}

h2 {
  font-size: 15px;
}

.subline {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
}

.subline span,
.tag,
.metric-label,
.scenario-pill {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 8px;
  background: var(--surface-2);
}

.subline .patch-current {
  color: var(--accent-strong);
  border-color: rgba(15, 125, 107, 0.35);
}

.subline .patch-stale,
.subline .patch-missing {
  color: var(--warn);
  border-color: rgba(182, 75, 52, 0.4);
  background: #fff0ec;
}

.topbar-actions {
  gap: 10px;
}

.primary-button,
.secondary-button,
.segmented button {
  min-height: 38px;
  border-radius: 8px;
  border: 1px solid var(--line);
  padding: 0 14px;
  white-space: nowrap;
}

.primary-button {
  color: #ffffff;
  background: var(--accent);
  border-color: var(--accent);
  font-weight: 700;
}

.primary-button:hover {
  background: var(--accent-strong);
}

.secondary-button,
.segmented button {
  color: var(--text);
  background: var(--surface);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(260px, 320px) 1fr;
  min-height: calc(100vh - 74px);
}

.control-panel {
  border-right: 1px solid var(--line);
  background: #fbfbfc;
  padding: 18px;
  overflow-y: auto;
}

.control-section {
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}

.control-section:first-child {
  padding-top: 0;
}

label,
.section-label {
  display: block;
  margin-bottom: 9px;
  color: #34413d;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.stacked-label {
  margin-top: 12px;
}

select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  padding: 0 12px;
}

.champion-select-wrap {
  gap: 12px;
}

.champion-select-wrap img {
  width: 52px;
  height: 52px;
  flex: 0 0 52px;
  border-radius: 8px;
  background: var(--surface-2);
  border: 1px solid var(--line);
}

.item-chip-list,
.scenario-list,
.results-list,
.detail-panel {
  display: grid;
  gap: 10px;
}

.item-chip {
  display: grid;
  grid-template-columns: 38px 1fr auto;
  gap: 10px;
  align-items: center;
  min-height: 50px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 6px;
}

.empty-core {
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
  padding: 12px;
}

.item-chip img,
.item-icon {
  width: 38px;
  height: 38px;
  border-radius: 6px;
  background: #1d2522;
  object-fit: cover;
}

.item-chip strong,
.result-card strong,
.breakdown-card strong {
  font-size: 13px;
}

.item-chip span {
  color: var(--gold);
  font-size: 12px;
  font-weight: 700;
}

.lock-pill {
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 800;
}

.segmented {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.segmented.two {
  grid-template-columns: 1fr 1fr;
}

.segmented button {
  overflow-wrap: anywhere;
}

.segmented button.active {
  background: #e0f3ef;
  border-color: var(--accent);
  color: var(--accent-strong);
  font-weight: 800;
}

.range-section input {
  width: 100%;
}

.range-row {
  gap: 10px;
}

.range-row output {
  min-width: 34px;
  text-align: right;
  color: var(--accent-strong);
  font-weight: 800;
}

.scenario-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 10px;
}

.scenario-item strong {
  display: block;
  margin-bottom: 5px;
  font-size: 12px;
}

.scenario-item span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.results-panel {
  min-width: 0;
  padding: 18px;
}

.status-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.status-strip > div {
  min-height: 66px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 12px;
  box-shadow: var(--shadow);
}

.metric-label {
  display: inline-flex;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
}

.status-strip strong {
  display: block;
  font-size: 18px;
}

.error-box,
.loading-box {
  margin-bottom: 16px;
  border-radius: 8px;
  padding: 12px;
  border: 1px solid;
}

.error-box {
  color: #7f2616;
  border-color: #e0a18d;
  background: #fff0ec;
}

.loading-box {
  color: var(--blue);
  border-color: #9fc5de;
  background: #edf7fd;
}

.results-grid {
  display: grid;
  grid-template-columns: minmax(430px, 1.1fr) minmax(360px, 0.9fr);
  gap: 18px;
  align-items: start;
}

.ranking-column,
.detail-column {
  min-width: 0;
}

.panel-heading {
  min-height: 32px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.panel-heading span {
  color: var(--muted);
  font-size: 12px;
  text-align: right;
}

.result-card,
.breakdown-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.result-card {
  padding: 12px;
}

.result-card.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(15, 125, 107, 0.18), var(--shadow);
}

.card-top {
  justify-content: space-between;
  gap: 10px;
}

.rank-score {
  display: grid;
  justify-items: end;
  gap: 2px;
  flex: 0 0 auto;
}

.rank-score b {
  color: var(--accent-strong);
  font-size: 18px;
}

.rank-score span,
.item-row span,
.breakdown-card span {
  color: var(--muted);
  font-size: 12px;
}

.card-items {
  flex-wrap: wrap;
  gap: 6px;
  margin: 12px 0;
}

.card-items img {
  border: 1px solid rgba(0, 0, 0, 0.12);
}

.tag-row {
  flex-wrap: wrap;
  gap: 6px;
}

.rune-page {
  display: grid;
  grid-template-columns: 36px 1fr auto;
  gap: 8px;
  align-items: center;
  min-height: 48px;
  margin: 10px 0;
  border-radius: 8px;
  background: #f5f2e9;
  border: 1px solid #e4d7b9;
  padding: 6px;
}

.rune-page > img {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #1d2522;
}

.rune-page strong,
.rune-page span {
  display: block;
}

.rune-page span,
.rune-alt-row span {
  color: var(--muted);
  font-size: 12px;
}

.minor-runes {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.minor-runes img {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #1d2522;
}

.rune-alt-row {
  display: grid;
  gap: 5px;
  margin-top: 10px;
}

.rune-comparison-list,
.rune-audit-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.rune-comparison-row,
.rune-audit-row {
  border-radius: 8px;
  background: var(--surface-2);
  padding: 9px;
}

.rune-comparison-row strong,
.rune-comparison-row span,
.rune-comparison-row p,
.rune-audit-row strong,
.rune-audit-row span,
.rune-audit-row p {
  display: block;
}

.rune-comparison-row span,
.rune-audit-row p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.rune-audit-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.proof-pill {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 7px;
  color: var(--muted);
  background: var(--surface);
  font-size: 11px;
  text-transform: uppercase;
}

.proof-pill.hard {
  color: var(--accent-strong);
  border-color: rgba(15, 125, 107, 0.35);
}

.proof-pill.soft,
.proof-pill.needs-validation {
  color: var(--gold);
  border-color: rgba(156, 116, 42, 0.35);
}

.evidence-flags {
  margin: 8px 0 12px;
}

.evidence-metrics {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.evidence-note {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.reason-summary {
  display: grid;
  gap: 4px;
  margin-bottom: 12px;
}

.reason-summary p,
.build-order-row p,
.reason-line p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.42;
}

.build-order-list,
.rune-reason-block {
  display: grid;
  gap: 8px;
}

.build-order-row {
  display: grid;
  grid-template-columns: 26px 38px 1fr;
  gap: 9px;
  align-items: start;
  border-top: 1px solid var(--line);
  padding-top: 8px;
}

.order-badge {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  color: #ffffff;
  background: var(--accent);
  font-size: 12px;
  font-weight: 800;
}

.build-order-row span,
.reason-line span {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
}

.build-order-row strong,
.reason-line strong {
  display: block;
  margin-bottom: 2px;
}

.rune-reason-block {
  margin-top: 12px;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.reason-line {
  display: grid;
  gap: 2px;
  border-radius: 8px;
  background: var(--surface-2);
  padding: 8px;
}

.tag {
  min-height: 20px;
  color: #31403b;
  font-size: 11px;
  text-transform: lowercase;
}

.card-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.card-metrics div {
  border-radius: 8px;
  background: var(--surface-2);
  padding: 8px;
  min-width: 0;
}

.card-metrics span {
  display: block;
  color: var(--muted);
  font-size: 11px;
}

.card-metrics b {
  display: block;
  margin-top: 3px;
  font-size: 13px;
}

.detail-panel {
  align-content: start;
}

.empty-state {
  min-height: 260px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.55);
  padding: 18px;
  color: var(--muted);
}

.breakdown-card {
  padding: 12px;
}

.scenario-heading {
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.scenario-heading strong {
  min-width: 0;
}

.scenario-pill {
  color: var(--blue);
  font-size: 11px;
  white-space: nowrap;
}

.item-row {
  flex-wrap: wrap;
  gap: 6px;
  min-height: 40px;
  margin-bottom: 10px;
}

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

.breakdown-metrics div {
  border-top: 1px solid var(--line);
  padding-top: 8px;
  min-width: 0;
}

.breakdown-metrics b {
  display: block;
  margin-top: 2px;
}

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

  .control-panel {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
}

@media (max-width: 720px) {
  .topbar,
  .topbar-actions,
  .status-strip,
  .card-metrics,
  .breakdown-metrics {
    grid-template-columns: 1fr;
  }

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

  .topbar-actions {
    display: grid;
    width: 100%;
  }

  .workspace {
    min-height: 0;
  }

  .control-panel,
  .results-panel {
    padding: 14px;
  }

  .panel-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .rune-page {
    grid-template-columns: 36px 1fr;
  }

  .minor-runes {
    grid-column: 1 / -1;
    justify-content: flex-start;
  }

  .rune-audit-title {
    align-items: flex-start;
    flex-direction: column;
  }

  .build-order-row {
    grid-template-columns: 26px 38px minmax(0, 1fr);
  }

  .segmented.two {
    grid-template-columns: 1fr;
  }
}
