:root {
  color-scheme: light;
  --ink: #101114;
  --muted: #676b73;
  --line: #d9dce2;
  --paper: #f7f6f2;
  --surface: #ffffff;
  --accent: #d99212;
  --accent-soft: #fff0c8;
  --good: #1f7a4d;
  --warn: #9a5d00;
  --bad: #8f2c24;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100svh;
  background: var(--paper);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body.locked .shell {
  display: none;
}

.lock-screen {
  min-height: 100svh;
  display: grid;
  align-items: center;
  width: min(760px, calc(100% - 32px));
  margin: 0 auto;
}

.lock-screen h1 {
  margin-top: 8px;
}

.lock-screen p:last-child {
  max-width: 420px;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.5;
}

.shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 40px;
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding: 18px 0 28px;
  border-bottom: 1px solid var(--line);
}

.eyebrow,
.section-head span,
.metric span {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(34px, 6vw, 78px);
  line-height: 0.95;
}

h2 {
  font-size: 18px;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 14px;
  white-space: nowrap;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--good);
  box-shadow: 0 0 0 5px rgba(31, 122, 77, 0.14);
}

.summary {
  display: grid;
  grid-template-columns: 1.4fr repeat(3, 1fr);
  gap: 1px;
  margin: 26px 0;
  border: 1px solid var(--line);
  background: var(--line);
}

.metric {
  min-height: 118px;
  padding: 18px;
  background: var(--surface);
}

.metric strong {
  display: block;
  margin-top: 16px;
  font-size: clamp(26px, 4vw, 44px);
  line-height: 1;
}

.metric.primary {
  background: var(--accent-soft);
}

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

.levels-section {
  margin: 0 0 34px;
}

.level-menu {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 1px;
  margin-top: 16px;
  border: 1px solid var(--line);
  background: var(--line);
}

.level-button {
  appearance: none;
  min-height: 118px;
  padding: 14px;
  border: 0;
  border-radius: 0;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  text-align: left;
}

.level-button.active {
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 2px var(--accent);
}

.level-button span,
.level-button strong,
.level-button em {
  display: block;
}

.level-button span {
  min-height: 42px;
  font-size: 14px;
  font-weight: 800;
  line-height: 1.25;
}

.level-button strong {
  margin-top: 12px;
  font-size: 20px;
  font-variant-numeric: tabular-nums;
}

.state {
  display: inline-flex;
  width: fit-content;
  margin-top: 10px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
  font-style: normal;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.state-running,
.state-live,
.state-ready,
.state-best {
  border-color: rgba(31, 122, 77, 0.35);
  color: var(--good);
  background: rgba(31, 122, 77, 0.08);
}

.state-waiting,
.state-candidate-ready,
.state-backup,
.state-open {
  border-color: rgba(154, 93, 0, 0.3);
  color: var(--warn);
  background: rgba(217, 146, 18, 0.1);
}

.state-stopped,
.state-locked,
.state-not-started,
.state-fallback {
  border-color: rgba(143, 44, 36, 0.22);
  color: var(--bad);
  background: rgba(143, 44, 36, 0.06);
}

.level-detail {
  padding-top: 22px;
}

.level-title {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.level-title h2 {
  margin-top: 4px;
  font-size: clamp(24px, 3vw, 40px);
}

.level-score {
  min-width: 190px;
  text-align: right;
}

.level-score span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.level-score strong {
  display: block;
  margin-top: 8px;
  font-size: 32px;
  font-variant-numeric: tabular-nums;
}

.artifact-inline {
  margin: 14px 0 18px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.level-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(280px, 0.8fr);
  gap: 28px;
}

.compact h2 {
  font-size: 16px;
}

.attempts,
.mini-tracks {
  display: grid;
  gap: 1px;
  margin-top: 14px;
  border: 1px solid var(--line);
  background: var(--line);
}

.attempt,
.mini-track {
  background: var(--surface);
}

.attempt {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  min-height: 94px;
  padding: 14px;
}

.attempt.best {
  background: var(--accent-soft);
}

.attempt strong,
.attempt span,
.attempt small,
.mini-track strong,
.mini-track span {
  display: block;
}

.attempt span,
.attempt small,
.mini-track span {
  color: var(--muted);
  line-height: 1.4;
}

.attempt span,
.attempt small {
  margin-top: 6px;
  overflow-wrap: anywhere;
}

.attempt small {
  font-size: 12px;
}

.attempt > div:last-child {
  min-width: 108px;
  text-align: right;
}

.attempt > div:last-child .state {
  margin-left: auto;
}

.mini-track {
  min-height: 96px;
  padding: 14px;
}

.mini-track .state {
  margin: 8px 0;
}

.level-notes {
  margin-top: 18px;
}

.empty {
  padding: 16px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.leaderboard {
  display: grid;
  gap: 10px;
  padding-top: 14px;
}

.row {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) 120px;
  align-items: center;
  gap: 16px;
  min-height: 56px;
  border-bottom: 1px solid var(--line);
}

.rank {
  color: var(--muted);
  font-weight: 800;
}

.bar {
  position: relative;
  height: 10px;
  overflow: hidden;
  background: #e8e5dc;
}

.bar span {
  position: absolute;
  inset: 0 auto 0 0;
  width: var(--width);
  background: var(--accent);
  transition: width 260ms ease;
}

.score {
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.side-panel,
.chart-panel,
.events-section {
  min-width: 0;
}

.params {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px 18px;
  margin: 18px 0 0;
  font-size: 14px;
}

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

.params dd {
  margin: 0;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.events-section {
  margin-top: 34px;
}

.ops-section {
  margin-top: 34px;
}

.tracks {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  margin-top: 16px;
  border: 1px solid var(--line);
  background: var(--line);
}

.track {
  appearance: none;
  width: 100%;
  border: 0;
  min-height: 104px;
  padding: 16px;
  background: var(--surface);
  color: inherit;
  cursor: default;
  font: inherit;
  text-align: left;
}

.track-button[data-level]:not([data-level=""]) {
  cursor: pointer;
  transition: background 180ms ease;
}

.track-button[data-level]:not([data-level=""]):hover {
  background: rgba(217, 146, 18, 0.08);
}

.track strong,
.track span {
  display: block;
}

.track strong {
  margin-bottom: 12px;
  font-size: 16px;
}

.track span {
  color: var(--muted);
  line-height: 1.45;
}

.artifact {
  margin-top: 16px;
  padding: 16px 0;
  border-bottom: 1px solid var(--line);
}

.artifact-path {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 14px;
  overflow-wrap: anywhere;
}

.artifact-copy {
  margin-top: 10px;
  color: var(--muted);
  line-height: 1.5;
}

.events {
  margin: 16px 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 10px;
}

.events li {
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
}

@media (max-width: 820px) {
  .topbar,
  .section-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .summary,
  .workbench,
  .tracks,
  .level-menu,
  .level-grid {
    grid-template-columns: 1fr;
  }

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

  .level-score {
    min-width: 0;
    text-align: left;
  }

  .metric {
    min-height: 96px;
  }

  .row {
    grid-template-columns: 36px minmax(0, 1fr);
  }

  .score {
    grid-column: 2;
    text-align: left;
  }
}
