:root {
  --bg: #14110e;
  --raise: #221c16;
  --sink: #0e0c0a;
  --line: rgba(242, 223, 196, 0.16);
  --text: #f6f1e8;
  --muted: #b7ab9d;
  --faint: #84786c;
  --amber: #f0a202;
  --amber-ink: #2a1c04;
  --green: #c6ee9b;
  --green-bg: #243218;
  --red: #ffb0a2;
  --red-bg: #3d221c;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.28);
  --serif: "Newsreader", "Iowan Old Style", Georgia, serif;
  --sans: "Outfit", "Avenir Next", "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(1200px 500px at 10% -10%, rgba(240, 162, 2, 0.14), transparent 55%),
    var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.45;
}

button, input, textarea, select { font: inherit; color: inherit; }

button { cursor: pointer; }

h1, h2, h3, p { margin: 0; }

h1, h2, .serif { font-family: var(--serif); font-weight: 560; letter-spacing: -0.03em; }

.hidden { display: none !important; }

.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card, .editor, .card, .stat {
  background: linear-gradient(180deg, rgba(255, 248, 236, 0.03), transparent 40%), var(--raise);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.login-card {
  width: min(420px, 100%);
  padding: 28px;
  display: grid;
  gap: 14px;
}

.login-card h1 { font-size: 48px; line-height: 0.95; }

.eyebrow {
  color: var(--amber);
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.lede, .aside-note, .muted { color: var(--muted); }

.app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px 1fr;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 28px 20px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  border-right: 1px solid var(--line);
  background: rgba(14, 12, 10, 0.88);
}

.brand h1 { font-size: 40px; line-height: 0.9; margin-top: 8px; }

.nav { display: grid; gap: 6px; }

.nav button, .ghost, .primary, .danger {
  border: 1px solid var(--line);
  background: transparent;
  min-height: 42px;
  padding: 8px 12px;
  text-align: left;
}

.nav button[aria-current="page"] {
  background: var(--amber);
  color: var(--amber-ink);
  border-color: var(--amber);
  font-weight: 600;
}

.aside-note { margin-top: auto; font-size: 14px; }

.sign-out { width: 100%; text-align: center; }

.workspace { min-width: 0; padding: 22px 28px 48px; }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 18px;
}

.presence {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--faint);
  box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.04);
}

.dot.on { background: var(--green); }

.avatar {
  width: 32px;
  height: 32px;
  object-fit: cover;
  border: 1px solid var(--line);
}

.presence strong { display: block; }

.presence span, .meta, .card p, .help { color: var(--muted); }

.banner {
  display: none;
  margin-bottom: 16px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  background: var(--sink);
}

.banner.show { display: block; }

.banner.error {
  color: var(--red);
  background: var(--red-bg);
  border-color: transparent;
}

.view { display: grid; gap: 18px; }

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
}

.stat { padding: 16px; }

.stat b {
  display: block;
  margin-top: 6px;
  font-family: var(--serif);
  font-size: 36px;
  font-weight: 560;
  letter-spacing: -0.04em;
}

.section-head, .card-top, .form-actions, .inline-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.stack { display: grid; gap: 12px; }

.card { padding: 16px 16px 14px; display: grid; gap: 10px; }

.card h2 { font-size: 30px; line-height: 1; }

.badges, .chips { display: flex; flex-wrap: wrap; gap: 6px; }

.badge, .chip {
  font-family: var(--mono);
  font-size: 12px;
  padding: 3px 7px;
  border: 1px solid var(--line);
}

.badge.run { color: var(--green); background: var(--green-bg); border-color: transparent; }

.badge.idle { color: var(--muted); }

.badge.default, .badge.new { color: var(--amber-ink); background: var(--amber); border-color: transparent; }

.checks { display: flex; flex-wrap: wrap; gap: 8px 16px; }

.snippet, pre.table {
  margin: 0;
  white-space: pre-wrap;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.5;
  background: var(--sink);
  border: 1px solid var(--line);
  padding: 10px;
  overflow: auto;
}

.error-text { color: var(--red); }

.primary {
  background: var(--amber);
  color: var(--amber-ink);
  border-color: var(--amber);
  font-weight: 600;
  text-align: center;
}

.danger { color: var(--red); text-align: center; }

.ghost { text-align: center; }

.inline-actions { justify-content: flex-start; flex-wrap: wrap; }

.inline-actions button { text-align: center; }

.editor {
  padding: 18px;
  display: grid;
  gap: 14px;
}

.editor h2 { font-size: 36px; }

label, .field { display: grid; gap: 6px; font-size: 14px; color: var(--muted); }

input, textarea, select {
  width: 100%;
  background: var(--sink);
  border: 1px solid var(--line);
  padding: 10px 12px;
  outline: none;
}

textarea { min-height: 120px; resize: vertical; }

input:focus, textarea:focus, select:focus, button:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 2px;
}

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.check { display: flex; align-items: center; gap: 8px; color: var(--text); }

.check input { width: auto; }

.form-error:empty { display: none; }

.form-error { color: var(--red); }

.help { font-size: 14px; }

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

.commands code {
  font-family: var(--mono);
  color: var(--amber);
}

.empty {
  padding: 28px 8px;
  color: var(--muted);
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  background: var(--raise);
}

table.standings {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

table.standings th,
table.standings td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

table.standings th {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 500;
}

table.standings tr.selected { background: rgba(240, 162, 2, 0.12); }

.name-button {
  background: none;
  border: 0;
  padding: 0;
  min-height: 0;
  color: var(--amber);
  text-align: left;
}

.delta.up { color: var(--green); }
.delta.down { color: var(--red); }

.chart {
  padding: 16px;
  background: var(--sink);
  border: 1px solid var(--line);
}

.chart svg { width: 100%; height: auto; display: block; }

.chart-meta { align-items: end; }

.field .inline-actions input { min-width: 0; flex: 1; }

.picker { display: grid; gap: 8px; }

.suggest { position: relative; }

.suggest-list {
  position: absolute;
  z-index: 4;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  margin: 0;
  padding: 4px;
  list-style: none;
  background: var(--raise);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  max-height: 240px;
  overflow: auto;
}

.suggest-list[hidden] { display: none; }

.suggest-empty {
  padding: 8px 10px;
  color: var(--muted);
  font-size: 14px;
}

.choice {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  width: 100%;
  border: 0;
  background: transparent;
  min-height: 40px;
  padding: 8px 10px;
  text-align: left;
}

.choice[aria-selected="true"],
.choice:hover { background: rgba(240, 162, 2, 0.16); }

.choice small, .channel-chip small { color: var(--muted); }

.player-chips, .chips { align-items: center; }

.player-chip, .channel-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 4px 4px 10px;
  background: var(--sink);
  font-family: var(--sans);
  font-size: 14px;
}

.player-chip strong, .channel-chip strong { font-weight: 560; }

.channel-chip span { display: grid; }

.channel-chip small { font-size: 12px; }

.player-chip input {
  width: 9rem;
  min-height: 0;
  padding: 4px 8px;
}

.chip-remove {
  border: 0;
  background: transparent;
  min-height: 0;
  padding: 4px 8px;
  color: var(--muted);
}

a { color: var(--amber); }

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .nav button { text-align: center; padding: 10px 6px; }
  .aside-note, .sign-out { margin-top: 0; }
  .stats, .grid-2, .commands { grid-template-columns: 1fr 1fr; }
  .workspace { padding: 16px; }
  .brand h1, .card h2, .editor h2 { font-size: 32px; }
}

@media (max-width: 640px) {
  .stats, .commands, .grid-2, .section-head, .card-top, .form-actions, .topbar {
    grid-template-columns: 1fr;
    display: grid;
  }
  .inline-actions button, .form-actions button, #refresh { width: 100%; }
}
