:root {
  /* Shared colours (copied from ~/Code/platform/design/colours.css). Light: pale sage. */
  --bg: #EEF1E8;
  --surface: #E3E8DA;      /* shared --sunk: pressed buttons, artwork well */
  --text: #2A2622;         /* 13.1:1 on --bg */
  --muted: #5E655C;        /* 5.3:1 on --bg */
  --accent: #3D6A54;       /* sage for words and links, 5.4:1 on --bg */
  --fill: #4A7A62;         /* sage for the play button and Add */
  --accent-text: #FBF8F2;  /* shared --on-fill: 4.7:1 on --fill */
  --current-bg: #E3E8DA;   /* shared --sunk; --accent on it: 5:1, --muted: 4.8:1 */
  --line: #D6DCCB;
  --field-line: #7A8075;   /* 3.5:1 on --bg */
  --danger: #A3361F;       /* 5.9:1 on --bg */
  --serif: ui-serif, "New York", "Iowan Old Style", Georgia, serif;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    /* Dark: Today's night. */
    --bg: #1C1F1D;
    --surface: #2F3430;    /* shared --sunk */
    --text: #EEE8E1;       /* 13.7:1 on --bg */
    --muted: #ABA49C;      /* 6.7:1 on --bg */
    --accent: #9FD0B4;     /* 9.6:1 on --bg */
    --fill: #9FD0B4;
    --accent-text: #14201A; /* 9.7:1 on --fill */
    --current-bg: #2F3430; /* --accent on it: 7.4:1, --muted: 5.2:1 */
    --line: #3A403B;
    --field-line: #6E756B; /* 3.5:1 on --bg */
    --danger: #F09C86;     /* 7.8:1 on --bg */
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  -webkit-tap-highlight-color: transparent;
}

[hidden] { display: none !important; }

button { font: inherit; color: inherit; }

p { margin: 0; }

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

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

.screen { max-width: 640px; margin: 0 auto; padding: 0 16px 32px; }

.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 52px;
}
.bar h1 { font-family: var(--serif); font-size: 22px; font-weight: 600; margin: 0; }
.icon-button { color: var(--muted); margin: 0 -10px 0 0; display: flex; align-items: center; }
.icon-button svg { width: 26px; height: 26px; }
.bar-spacer { width: 80px; }

.text-button {
  background: none;
  border: 0;
  color: var(--accent);
  font-size: 17px;
  min-height: 44px;
  min-width: 44px;
  padding: 8px 10px;
  margin: 0 -10px;
  border-radius: 10px;
  cursor: pointer;
}
.text-button.danger { color: var(--danger); margin: 0; }
.text-button:active { background: var(--surface); }

.button {
  background: var(--fill);
  color: var(--accent-text);
  border: 0;
  border-radius: 12px;
  min-height: 48px;
  padding: 10px 18px;
  font-weight: 600;
  cursor: pointer;
}
.button:disabled { opacity: 0.7; }

.meta { color: var(--muted); font-size: 15px; }
.empty { padding: 48px 8px; text-align: center; color: var(--muted); }

/* ---- Now playing ---- */
.art {
  display: block;
  width: min(280px, 76vw);
  aspect-ratio: 1;
  margin: 12px auto 28px;
  border-radius: 18px;
  object-fit: cover;
  background: var(--surface);
}
#show { text-align: center; font-size: 14px; letter-spacing: 0.02em; }
.title {
  font-family: var(--serif);
  font-size: 24px;
  font-weight: 600;
  line-height: 1.22;
  margin: 6px 0 0;
  text-align: center;
  text-wrap: balance;
}

.seek {
  display: block;
  width: 100%;
  margin: 20px 0 0;
  accent-color: var(--accent);
  height: 28px;
}
.times {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

/* Five equal slots with play in the middle one: −15 and +30 sit evenly
   either side, Next takes the last slot and the first stays empty. */
.controls {
  display: grid;
  grid-template-columns: 1fr 1fr 72px 1fr 1fr;
  align-items: center;
  justify-items: center;
  gap: 8px;
  margin-top: 6px;
}
.controls #back { grid-column: 2; }
.control { width: 100%; }
.control {
  min-height: 56px;
  border: 0;
  border-radius: 14px;
  background: none;
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.control svg { width: 32px; height: 32px; }
.control:active { background: var(--surface); }
.control.play {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--fill);
  color: var(--accent-text);
  padding: 0;
}
.control.play:active { background: var(--fill); transform: scale(0.96); }
.control.play svg { width: 30px; height: 30px; }
.player-note { margin-top: 6px; color: var(--danger); font-size: 15px; text-align: center; }

h2 { font-family: var(--serif); font-size: 20px; font-weight: 600; margin: 32px 0 10px; }

/* ---- Chapters ---- */
.chapters { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.chapter { display: flex; align-items: center; border-bottom: 1px solid var(--line); }
.chapter.current { background: var(--current-bg); box-shadow: inset 4px 0 0 var(--accent); }
.chapter-jump {
  flex: 1;
  min-width: 0;
  display: flex;
  gap: 12px;
  align-items: baseline;
  text-align: left;
  background: none;
  border: 0;
  padding: 10px 8px 10px 12px;
  min-height: 44px;
  cursor: pointer;
}
.chapter-time { color: var(--muted); font-size: 15px; font-variant-numeric: tabular-nums; min-width: 3.4em; }
.chapter.current .chapter-title { font-weight: 600; }
.chapter-link { flex: none; font-size: 15px; padding: 10px 12px; }

/* ---- Show notes ---- */
.notes { overflow-wrap: anywhere; }
.notes p, .notes ul, .notes ol { margin: 0 0 12px; }
.notes ul, .notes ol { padding-left: 22px; }
.notes a:not([href]) { color: inherit; }
.notes img { max-width: 100%; height: auto; }
.notes h1, .notes h2, .notes h3, .notes h4 { font-size: 17px; margin: 16px 0 8px; }
.notes table { display: block; max-width: 100%; overflow-x: auto; }

/* ---- Shows screen ---- */
.add-form label { display: block; font-weight: 600; margin: 8px 0; }
.add-row { display: flex; gap: 8px; }
.add-row input {
  flex: 1;
  min-width: 0;
  min-height: 48px;
  font-size: 17px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--field-line);
  background: var(--bg);
  color: var(--text);
}
.add-result { margin: 12px 0; min-height: 1.4em; }
.add-result.error, .error { color: var(--danger); font-size: 15px; }

.sync { margin-top: 32px; }
.sync h2 { font-size: 17px; margin: 0 0 8px; }
.sync .meta { margin: 0 0 12px; }
.sync .add-row + .add-row { margin-top: 8px; }
#sync-link { font-size: 15px; color: var(--muted); }

.shows { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.show {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.show-text { flex: 1; min-width: 0; }
.show-title { font-weight: 600; }
.url { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
