:root {
  --ground: #eceef1;
  --card: #ffffff;
  --ink: #0e0e12;
  --ink-2: #1b1b22;
  --text: #15161b;
  --quiet: #6b6f78;
  --line: #e1e4e9;
  --gold: #c9a84c;
  --gold-deep: #9c7d2a;
  --gold-soft: #f4ecd6;
  --rose: #f6dfdc;
  --sky: #dde9f8;
  --sage: #dff0e2;
  --lilac: #e8e3f6;
  --sand: #f4ecd6;
  --live: #d63b26;
  --ok: #23824f;
  --warn: #a8620a;
  --radius: 26px;
  --radius-small: 16px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background: var(--ground); }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--ground);
  color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
}

[hidden] { display: none !important; }

h1 { font-size: 2rem; line-height: 1.1; margin: 0; font-weight: 750; letter-spacing: -0.025em; }
h2 { font-size: 1.2rem; margin: 0 0 0.8rem; font-weight: 700; letter-spacing: -0.01em; }
h3 { font-size: 1rem; margin: 0; font-weight: 650; }
p { margin: 0.35rem 0; }
.hint { color: var(--quiet); font-size: 0.9rem; }
.error { color: var(--live); min-height: 1.2em; }

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

button {
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 999px;
  padding: 0.55rem 1.05rem;
  min-height: 44px;
  cursor: pointer;
  font-weight: 550;
}
button:hover { border-color: #c9ced6; }
button.dark { background: var(--ink); border-color: var(--ink); color: #fff; }
button.gold { background: var(--gold); border-color: var(--gold); color: var(--ink); }
button.stop { background: var(--live); border-color: var(--live); color: #fff; }
button.link { border: 0; background: none; text-decoration: underline; color: var(--quiet); padding: 0.4rem; min-height: 0; }
button.big { min-height: 56px; padding: 0.8rem 1.6rem; font-size: 1.08rem; font-weight: 650; }
button[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }

input, textarea, select {
  width: 100%;
  background: #f5f6f8;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.7rem 0.85rem;
  min-height: 48px;
}
input[type="color"] { padding: 4px; width: 56px; }
input[type="range"] { padding: 0; min-height: 0; background: none; border: 0; accent-color: var(--ink); }
textarea { resize: vertical; }
label { display: block; margin: 0.9rem 0 0.35rem; font-weight: 600; font-size: 0.95rem; }

:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

/* Sign in */
.signin { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; }
.signin-card { width: 100%; max-width: 380px; background: var(--card); border-radius: var(--radius); padding: 2rem 1.6rem; }
.signin-logo { display: block; width: 84px; height: 84px; margin: 0 0 1rem; }
.signin-card h1 { font-size: 1.7rem; }
.signin-card button { width: 100%; margin-top: 1.2rem; }

/* Shell: a dark rail on the left, like the references */
.shell { display: flex; min-height: 100vh; padding: 14px; gap: 14px; }
.rail {
  flex: none;
  width: 88px;
  background: var(--ink);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 18px 0;
  gap: 8px;
  position: sticky;
  top: 14px;
  height: calc(100vh - 28px);
}
.rail-logo { width: 52px; height: 52px; margin-bottom: 18px; }
.rail a, .rail button {
  width: 58px;
  height: 58px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  color: #9a9ca5;
  border: 0;
  background: transparent;
  padding: 0;
  text-decoration: none;
  position: relative;
}
.rail a:hover, .rail button:hover { color: #fff; background: var(--ink-2); }
.rail a[aria-current="page"] { color: var(--ink); background: var(--gold); }
.rail svg { width: 24px; height: 24px; }
.rail .spacer { flex: 1; }
.rail .tip {
  position: absolute; left: 68px; white-space: nowrap; z-index: 5;
  background: var(--ink); color: #fff; font-size: 0.82rem; padding: 0.3rem 0.6rem; border-radius: 8px;
  opacity: 0; pointer-events: none; transition: opacity 0.12s;
}
.rail a:hover .tip, .rail button:hover .tip, .rail a:focus-visible .tip { opacity: 1; }

.main {
  flex: 1;
  min-width: 0;
  background: #f7f8fa;
  border-radius: var(--radius);
  padding: 30px 34px 40px;
}

.top { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 26px; flex-wrap: wrap; }
.top .sub { color: var(--quiet); margin-top: 0.3rem; }
.chip {
  display: inline-flex; align-items: center; gap: 0.5rem;
  background: var(--card); border: 1px solid var(--line); border-radius: 999px;
  padding: 0.45rem 0.9rem; font-weight: 600; font-size: 0.92rem;
}
.dot { width: 10px; height: 10px; border-radius: 50%; background: #b9bec7; flex: none; }
.dot.live { background: var(--live); box-shadow: 0 0 0 4px rgb(214 59 38 / 0.18); }
.dot.ready { background: var(--gold); }

/* Cards */
.grid { display: grid; gap: 18px; grid-template-columns: repeat(12, minmax(0, 1fr)); }
.card { background: var(--card); border-radius: var(--radius); padding: 24px; min-width: 0; }
.span-12 { grid-column: span 12; }
.span-8 { grid-column: span 8; }
.span-7 { grid-column: span 7; }
.span-6 { grid-column: span 6; }
.span-5 { grid-column: span 5; }
.span-4 { grid-column: span 4; }
.span-3 { grid-column: span 3; }

.card-head { display: flex; align-items: center; justify-content: space-between; gap: 0.8rem; margin-bottom: 14px; }
.card-head h2 { margin: 0; }

/* Status card */
.status { display: flex; flex-direction: column; justify-content: space-between; min-height: 250px; }
.status .label { color: var(--quiet); font-weight: 600; display: flex; align-items: center; gap: 0.5rem; }
.status-title { font-size: 2.4rem; font-weight: 760; letter-spacing: -0.03em; line-height: 1.08; margin: 0.6rem 0 0.4rem; }
.status-sub { color: var(--quiet); max-width: 46ch; }
.status-foot { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; margin-top: 1.4rem; }
.status-note { color: var(--quiet); font-size: 0.92rem; }
.meter { height: 10px; background: #eef0f3; border-radius: 6px; overflow: hidden; margin-top: 1rem; max-width: 520px; }
.meter span { display: block; height: 100%; width: 0; background: var(--gold); border-radius: 6px; transition: width 0.9s linear; }

.big-number { font-size: 3.2rem; font-weight: 300; letter-spacing: -0.04em; line-height: 1; }
.big-number small { font-size: 1.1rem; font-weight: 500; color: var(--quiet); margin-left: 0.25rem; letter-spacing: 0; }
.tile { border-radius: var(--radius); padding: 22px; min-width: 0; display: flex; flex-direction: column; gap: 0.4rem; }
.tile.sand { background: var(--sand); }
.tile.rose { background: var(--rose); }
.tile.sky { background: var(--sky); }
.tile.sage { background: var(--sage); }
.tile.lilac { background: var(--lilac); }
.tile .tile-foot { margin-top: auto; padding-top: 0.8rem; display: flex; align-items: center; justify-content: space-between; gap: 0.6rem; flex-wrap: wrap; }

/* Platforms as coloured tiles */
.platforms { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
.platform { min-height: 170px; }
.platform-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 0.6rem; }
.platform-badge {
  width: 44px; height: 44px; border-radius: 14px; background: #fff;
  display: grid; place-items: center; font-weight: 800; font-size: 1.05rem; color: var(--ink);
}
.platform-name { font-weight: 700; font-size: 1.1rem; margin-top: 0.7rem; }
.platform-state { font-size: 0.92rem; color: #3d4048; }
.platform-state.live { color: var(--live); font-weight: 650; }
.platform-state.trouble { color: var(--warn); font-weight: 600; }
.platform-error { font-size: 0.85rem; color: var(--warn); }
.platform .edit { background: rgb(255 255 255 / 0.7); border: 0; min-height: 36px; padding: 0.3rem 0.8rem; font-size: 0.88rem; }
.add-tile {
  min-height: 170px; border: 2px dashed #cfd3da; border-radius: var(--radius); background: transparent;
  display: grid; place-items: center; color: var(--quiet); font-weight: 650;
}
.add-tile:hover { border-color: var(--gold); color: var(--gold-deep); }

/* Switch */
.toggle {
  appearance: none; -webkit-appearance: none;
  width: 52px; height: 32px; min-height: 0; padding: 0; border: 0;
  border-radius: 16px; background: #c9ced6; position: relative; flex: none; cursor: pointer;
  transition: background 0.15s;
}
.toggle::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%;
  background: #fff; transition: transform 0.15s; box-shadow: 0 1px 2px rgb(0 0 0 / 0.2);
}
.toggle:checked { background: var(--ink); }
.toggle:checked::after { transform: translateX(20px); background: var(--gold); }
.row-switch { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin: 0; }

/* Dark card for the picture, like the dark promo card in the reference */
.dark-card { background: var(--ink); color: #fff; border-radius: var(--radius); padding: 22px; min-width: 0; }
.dark-card .hint { color: #a3a6ae; }
.dark-card button { background: var(--ink-2); color: #fff; border-color: #33343c; }
.dark-card button[aria-pressed="true"] { background: var(--gold); color: var(--ink); border-color: var(--gold); }
.seg { display: flex; gap: 0.5rem; flex-wrap: wrap; }
video { width: 100%; border-radius: 18px; background: #000; aspect-ratio: 16 / 9; display: block; }
.dark-card video { margin-top: 14px; }

.warnings { list-style: none; padding: 0; margin: 0 0 18px; }
.warnings li { background: #fff4e0; color: var(--warn); border-radius: 16px; padding: 0.8rem 1rem; margin-top: 0.5rem; font-weight: 550; }

/* Lists */
.list { list-style: none; margin: 0; padding: 0; }
.list > li { padding: 16px 0; border-top: 1px solid var(--line); }
.list > li:first-child { border-top: 0; padding-top: 4px; }
.rec { display: grid; grid-template-columns: 1fr auto; gap: 0.6rem 1rem; align-items: center; }
.rec-title { font-weight: 650; }
.rec-meta { color: var(--quiet); font-size: 0.9rem; }
.rec-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.rec-actions a {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0.5rem 1rem;
  border-radius: 999px; border: 1px solid var(--line); background: var(--card); color: var(--text); text-decoration: none; font-weight: 550;
}
.rec-actions .danger { color: var(--live); }
#rec-player { margin-top: 16px; }

.form-actions { display: flex; gap: 0.6rem; align-items: center; margin-top: 1rem; flex-wrap: wrap; }
.inline { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.inline label { margin: 0; font-weight: 500; }
.inline input { width: 6rem; }

.copy-row { display: flex; gap: 0.5rem; margin-top: 0.5rem; }
.copy-row code {
  flex: 1; min-width: 0; background: #f2f3f6; border-radius: 12px; padding: 0.65rem 0.8rem;
  font: 0.82rem/1.4 ui-monospace, Menlo, monospace; overflow-wrap: anywhere;
}
.connect-title { font-weight: 650; margin: 1rem 0 0.2rem; }
.connect-title:first-child { margin-top: 0; }

.events { list-style: none; padding: 0; margin: 0; max-height: 22rem; overflow: auto; }
.events li { padding: 0.5rem 0; border-top: 1px solid var(--line); font-size: 0.92rem; }
.events li:first-child { border-top: 0; }
.events time { color: var(--quiet); margin-right: 0.6rem; font-variant-numeric: tabular-nums; }
.events .warn { color: var(--warn); }

/* Dialog */
dialog { border: 0; border-radius: var(--radius); background: var(--card); color: var(--text); width: min(94vw, 500px); max-height: 92vh; padding: 26px; }
dialog::backdrop { background: rgb(14 14 18 / 0.55); }
dialog h2 { font-size: 1.4rem; }
.choices { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.5rem; }
.choices button { border-radius: 16px; min-height: 58px; }

.mobile-brand { display: none; align-items: center; gap: 0.6rem; margin-bottom: 14px; }
.mobile-brand img { width: 40px; height: 40px; }
.mobile-brand span { font-weight: 700; }

/* Phones: the rail becomes a bar at the bottom */
@media (max-width: 860px) {
  .shell { display: block; padding: 0; }
  .rail {
    position: fixed; top: auto; bottom: 0; left: 0; right: 0; z-index: 20;
    width: auto; height: auto; flex-direction: row; justify-content: space-around;
    border-radius: 22px 22px 0 0; padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
  }
  .rail-logo, .rail .spacer, .rail .tip { display: none; }
  .rail a, .rail button { width: 54px; height: 50px; border-radius: 15px; }
  .main { border-radius: 0; padding: calc(18px + env(safe-area-inset-top)) 16px 110px; background: var(--ground); }
  .mobile-brand { display: flex; }
  .grid { grid-template-columns: 1fr; gap: 14px; }
  .grid > * { grid-column: 1 / -1 !important; }
  h1 { font-size: 1.7rem; }
  .status { min-height: 0; }
  .status-title { font-size: 1.85rem; }
  .card, .tile, .dark-card { padding: 20px; border-radius: 22px; }
  .status-foot button.big { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
.grid > .dark-card { align-self: start; }
@media (max-width: 860px) {
  .rec { grid-template-columns: 1fr; }
}
