/* stradio: dark theme only, phone first. The palette, tinted chips and row style
   are the Archive's (spec §7.1). No solid colour fills; no inline styles. */
:root {
  --bg: #0e1116;
  --bar: #0a0d11;
  --surface: #141820;
  --surface-2: #1a1e26;
  --border: #2a3040;
  --text: #b8c4d8;
  --muted: #8a93a8;
  --accent: #7fb3d8;
  --danger: #c45a6a;
  --accent-bg: #1f2535;
  --accent-bg-hover: #273044;
  --danger-bg: #261a1e;
  --warn: #c49238;
  --warn-bg: #241f17;
  --green: #6ab87a;
  --radius: 8px;
  --gap: 12px;
  /* Heights of the sticky top and the fixed player, measured by the app. */
  --top-h: 104px;
  --player-h: 0px;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-padding-top: var(--top-h); }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

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

button { font: inherit; color: inherit; cursor: pointer; }

h1 { font-size: 1.25rem; line-height: 1.25; margin: 0 0 var(--gap); }

h2 { font-size: 1.0625rem; margin: 20px 0 8px; }

[hidden] { display: none !important; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap;
}

/* Icons: flat shapes in the text colour with one accent part. They are drawn
   with <use> from the sprite in app.html, so rules must name the shapes' own
   classes (a selector like ".button .ic-main" never reaches inside a <use>);
   colours come in by inheritance: the text colour, and --icon-accent. */
.icon { flex: none; width: 20px; height: 20px; }
.ic-main { fill: currentColor; }
.ic-accent { fill: var(--icon-accent, var(--accent)); }

/* ---------- Top: bar and tabs ---------- */
.top {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--bar);
  border-bottom: 1px solid var(--border);
}

.topbar, .tabs {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 60rem;
  margin: 0 auto;
  padding: 8px 16px;
}

.logo { display: flex; align-items: center; gap: 8px; margin-right: auto; color: var(--text);
        text-decoration: none; font-weight: 600; letter-spacing: 0.02em; }
.logo img { display: block; width: auto; height: 28px; }

.tabs { padding-top: 0; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }

.tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  white-space: nowrap;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: none;
  color: var(--muted);
  text-decoration: none;
}

.tab:hover, .tab:focus-visible { color: var(--text); background: var(--surface-2); }

.tab[aria-current="page"] {
  border-color: var(--accent);
  background: var(--accent-bg);
  color: var(--accent);
  font-weight: 600;
}

.tab .count { color: var(--muted); font-weight: 400; font-size: 0.8125rem; }

/* Buttons: tinted chips, or plain icon buttons. */
.button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  background: var(--accent-bg);
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
}
.button:hover, .button:focus-visible { background: var(--accent-bg-hover); }
.button.danger { border-color: var(--danger); background: var(--danger-bg); color: var(--danger); }
.button.quiet { border-color: var(--border); background: none; color: var(--text); font-weight: 400; }
.button.quiet:hover, .button.quiet:focus-visible { background: var(--surface-2); }
.button[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-bg); color: var(--accent); }
.button:disabled { opacity: 0.5; cursor: default; }

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: none;
  color: var(--muted);
}
.icon-button:hover, .icon-button:focus-visible { color: var(--text); border-color: var(--border); }
.icon-button:disabled { opacity: 0.4; cursor: default; }
.icon-button .icon { width: 22px; height: 22px; }

.live { border-color: var(--danger); background: var(--danger-bg); color: var(--danger); }
.live:hover, .live:focus-visible { background: #2f1f24; }
.live { --icon-accent: var(--danger); }

/* The menu: an icon that opens a small list. */
.menu { position: relative; }
.menu summary { list-style: none; }
.menu summary::-webkit-details-marker { display: none; }
.menu nav {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  min-width: 12rem;
  display: flex;
  flex-direction: column;
  padding: 6px 0;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  z-index: 30;
}
.menu nav a, .menu nav button {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  border: 0;
  background: none;
  color: var(--text);
  text-align: left;
  text-decoration: none;
}
.menu nav a:hover, .menu nav a:focus, .menu nav button:hover, .menu nav button:focus { background: var(--border); }

/* ---------- Banner ---------- */
.banner {
  max-width: 60rem;
  margin: 12px auto 0;
  padding: 8px 12px;
  border-left: 3px solid var(--warn);
  background: var(--warn-bg);
  border-radius: 4px;
}

/* A short message about something that just failed (e.g. nothing to play yet). */
.notice {
  max-width: 60rem;
  margin: 12px auto 0;
  padding: 8px 12px;
  border-left: 3px solid var(--danger);
  background: var(--surface-2);
  border-radius: 4px;
}

/* ---------- Content ---------- */
main {
  max-width: 60rem;
  margin: 0 auto;
  padding: 12px 16px calc(var(--player-h) + 24px);
}

.view-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 4px 0 8px; }
.view-head h1 { margin: 0 auto 0 0; }
.empty { color: var(--muted); }
.hint { color: var(--muted); font-size: 0.875rem; margin: 4px 0 12px; }

.day-nav { display: flex; align-items: center; gap: 4px; }
.day-nav select { min-width: 10rem; }

select, input:not([type]), input[type="text"], input[type="search"], input[type="password"] {
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font: inherit;
}
select:focus, input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

.search-form { display: flex; gap: 8px; margin: 0 0 12px; }
.search-form input { flex: 1; min-width: 0; }

/* ---------- Programme rows ---------- */
.rows { list-style: none; margin: 0; padding: 0; }

.row { border-bottom: 1px solid var(--border); padding-left: 8px; }
/* What's on now: a red edge that doesn't move the row's contents. */
.row.now { box-shadow: inset 3px 0 0 var(--danger); }
.row.upcoming .row-title { color: var(--muted); }

.row-line { display: flex; align-items: center; gap: 4px; }

.row-head {
  flex: 1;
  min-width: 0;
  color: inherit;
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 0;
  border: 0;
  background: none;
  text-align: left;
}

.row-time { flex: none; width: 3rem; color: var(--muted); font-variant-numeric: tabular-nums; font-size: 0.875rem; }
.row-time .row-day { display: block; font-size: 0.75rem; }

.picture { flex: none; width: 44px; height: 44px; border-radius: 6px; object-fit: cover; background: var(--surface-2); }
.picture.none { display: inline-flex; align-items: center; justify-content: center; color: var(--muted); }

.row-main { min-width: 0; flex: 1; }
.row-title { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-sub { display: block; color: var(--muted); font-size: 0.875rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-marks { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 2px; }

.progress { height: 3px; margin-top: 4px; background: var(--border); border-radius: 2px; overflow: hidden; }
.progress span { display: block; height: 100%; background: var(--accent); }

.marker {
  padding: 0 6px;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.75rem;
  line-height: 1.5;
  color: var(--muted);
  white-space: nowrap;
}
.marker.listened { border-color: var(--green); color: var(--green); }
.marker.now { border-color: var(--danger); color: var(--danger); }
.marker.partly, .marker.blanked { border-color: var(--warn); color: var(--warn); }
.marker.kept { border-color: var(--accent); color: var(--accent); }
.marker.queued { border-color: var(--accent); color: var(--accent); }

.row-body { padding: 0 0 12px 3.625rem; }
.row-body p { margin: 0 0 8px; }
.row-body .series { color: var(--muted); font-size: 0.875rem; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* A small confirmation that drops down under the button that asked for it. */
.confirm {
  margin-top: 8px;
  padding: 10px 12px;
  border: 1px solid var(--danger);
  border-radius: var(--radius);
  background: var(--danger-bg);
}
.confirm p { margin: 0 0 8px; }

.queue-tools { display: inline-flex; gap: 2px; }
.rows.paused { opacity: 0.55; }
.queue-tools .icon-button { width: 34px; height: 34px; }

/* ---------- Settings ---------- */
.panel {
  margin: 0 0 16px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.panel h2 { margin-top: 0; }
.field { display: grid; gap: 4px; margin: 0 0 12px; }
.field > span { color: var(--muted); font-size: 0.9375rem; }
.choices { display: flex; flex-wrap: wrap; gap: 6px; }
.form-ok { color: var(--green); }
.form-error { color: var(--danger); }

/* ---------- Player ---------- */
.player {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  background: var(--bar);
  border-top: 1px solid var(--border);
}
.player-inner { max-width: 60rem; margin: 0 auto; padding: 6px 16px 8px; }

.seek { position: relative; height: 22px; margin: 0 0 2px; cursor: pointer; touch-action: none; }
.seek-track { position: absolute; left: 0; right: 0; top: 9px; height: 4px; background: var(--border); border-radius: 2px; }
.seek-margin { position: absolute; top: 9px; height: 4px; background: #1b2030; }
.seek-gap { position: absolute; top: 7px; height: 8px; background: repeating-linear-gradient(90deg, #3a4050 0 3px, transparent 3px 6px); }
.seek-done { position: absolute; left: 0; top: 9px; height: 4px; background: var(--accent); border-radius: 2px; }
.seek-knob { position: absolute; top: 4px; width: 14px; height: 14px; margin-left: -7px; border-radius: 50%;
             background: var(--bg); border: 2px solid var(--accent); }

.player-times { display: flex; justify-content: space-between; color: var(--muted); font-size: 0.75rem;
                font-variant-numeric: tabular-nums; margin-top: -2px; }

.player-row { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; margin-top: 4px; }
/* Phones: title on one line, the controls centred under it. */
.player-what { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1 1 100%; }
.player-text { min-width: 0; }
.player-controls { margin: 0 auto; }
.player-what .picture { width: 40px; height: 40px; }
.player-title { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player-sub { display: block; color: var(--muted); font-size: 0.8125rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.player-controls { display: flex; align-items: center; gap: 2px; }
.player-controls .play { width: 46px; height: 46px; border-color: var(--accent); background: var(--accent-bg); color: var(--accent); }
.player-controls .play .icon { width: 24px; height: 24px; }

.player-options { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; margin-top: 6px; font-size: 0.875rem; }
.player-options .button { padding: 3px 10px; }
.player-options .label { color: var(--muted); }
/* A label and its buttons wrap as one: never "Stop" on one line and "Continue" on the next. */
.player-options .option-group { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }

/* Phones: the player's options fold away until asked for. */
.player .more { display: none; }
.player.open .more { display: flex; }

/* Narrow phones: the five tabs still fit on one line. */
@media (max-width: 30rem) {
  .tabs { gap: 4px; }
  .tab { padding: 5px 8px; font-size: 0.875rem; }
}

@media (min-width: 48rem) {
  .topbar, .tabs, main { padding-left: 24px; padding-right: 24px; }
  .player-inner { padding-left: 24px; padding-right: 24px; }
  .player .more { display: flex; }
  .player .more-toggle { display: none; }
  .player-row { flex-wrap: nowrap; }
  .player-what { flex: 1 1 auto; }
  .player-controls { margin: 0; }
  .row-time { width: 3.5rem; }
  .row-body { padding-left: 4.125rem; }
}

/* ---------- Sign-in ---------- */
.signin-page { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.signin {
  width: min(22rem, 100%);
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.signin .logo { justify-content: center; margin: 0 0 16px; font-size: 1.25rem; }
.signin .logo img { height: 40px; }
.signin form { display: grid; gap: 12px; }
.signin label { display: grid; gap: 4px; color: var(--muted); font-size: 0.9375rem; }
.signin input { width: 100%; }
.signin .button { justify-content: center; padding: 9px 14px; }
.signin #message { min-height: 1.5em; margin: 0; color: var(--danger); }
