/* Night Desk — mobile-first.
 *
 * Base styles target a phone held in one hand: full-width layout,
 * 44px+ touch targets, 16px form text (so iOS Safari doesn't
 * auto-zoom on focus), and a chunky bottom player. min-width media
 * queries then enhance upward for tablet and desktop. The palette
 * and identity are unchanged from the original desktop-first sheet.
 */
:root {
  /* Native controls (select popups, scrollbars, checkboxes) render in
   * dark mode to match the theme — without this the opened dropdown
   * list falls back to a white OS popup with hard-to-read text. */
  color-scheme: dark;
  --bg: #101418;
  --panel: #1a2129;
  --panel2: #232d38;
  --text: #e8edf2;
  --muted: #93a3b4;
  --accent: #e8b34b;
  --accent-dim: #8a6d2f;
  --danger: #e0655f;
  --ok: #6fbf73;
  --radius: 12px;
  --border: #26303c;
  --border-strong: #33404e;
  --shadow: 0 1px 2px rgba(0,0,0,.35), 0 8px 24px rgba(0,0,0,.18);
  /* Design elevation pass (v25): a brighter lamp gold for gradients,
   * a deep gold for gradient feet, the ink used on gold surfaces, a
   * hairline for lit edges, an inset top highlight that makes cards
   * read as lit from above, and a serif stack for the wordmark and
   * headings (system fonts only — the shell must work offline). */
  --gold-bright: #f6cd6e;
  --gold-deep: #c9962e;
  --ink: #171106;
  --hairline: rgba(255,255,255,.055);
  --card-hi: inset 0 1px 0 rgba(255,255,255,.05);
  --serif: ui-serif, "New York", Georgia, "Times New Roman", serif;
}
* { box-sizing: border-box; }
::selection { background: rgba(232,179,75,.35); }
html, body { margin: 0; padding: 0; overflow-x: clip; }
body {
  /* A faint lamplight glow at the top of the desk, fading into the dark. */
  background:
    radial-gradient(120% 340px at 50% -80px, rgba(232,179,75,.09), rgba(232,179,75,0) 70%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  /* Room for the fixed player deck, which is tall on phones. */
  padding-bottom: 276px;
}
body.auth { padding-bottom: 24px; }
a { color: var(--accent); }
img { max-width: 100%; }

button {
  background: var(--panel2); color: var(--text); border: 1px solid var(--border-strong);
  border-radius: 10px; padding: 10px 14px; font-size: 15px; cursor: pointer;
  min-height: 44px;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: border-color .15s ease, background .15s ease, transform .08s ease, box-shadow .15s ease;
}
button:hover { border-color: var(--accent-dim); }
button:active { transform: scale(.98); }
button.primary {
  background: linear-gradient(180deg, #f2c66d, var(--accent));
  color: #1a1405; border-color: var(--accent); font-weight: 600;
  box-shadow: 0 2px 10px rgba(232,179,75,.22);
}
button.small { padding: 9px 12px; font-size: 14px; min-height: 44px; }
button.icon { padding: 9px 12px; min-width: 44px; }
button.active { border-color: var(--accent); color: var(--accent); }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px;
}

input:not([type=checkbox]):not([type=range]), select, textarea {
  background: var(--panel); color: var(--text); border: 1px solid var(--border-strong);
  border-radius: 10px; padding: 11px 12px;
  /* 16px minimum: anything smaller makes iOS Safari zoom on focus. */
  font-size: 16px;
  width: 100%; max-width: 100%; min-height: 48px;
  transition: border-color .15s ease, box-shadow .15s ease;
}
input:not([type=checkbox]):not([type=range]):focus, select:focus, textarea:focus {
  border-color: var(--accent-dim);
  box-shadow: 0 0 0 3px rgba(232,179,75,.14);
  outline: none;
}
/* Belt and braces for browsers that style the opened option list from
 * CSS (desktop Chrome/Firefox): keep options on theme colors too. */
select option { background: var(--panel); color: var(--text); }
textarea { resize: vertical; }
input[type=checkbox] { width: 24px; height: 24px; flex: none; accent-color: var(--accent); }
label { display: block; font-size: 14px; color: var(--muted); margin: 12px 0 5px; }

/* Sticky header: title bar + tab bar travel together. */
.stickhead {
  position: sticky; top: 0; z-index: 20;
  background: rgba(16,20,24,.92);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 6px 18px rgba(0,0,0,.25);
  padding-top: env(safe-area-inset-top);
}
.brandmark { width: 22px; height: 22px; color: var(--accent); flex: none; filter: drop-shadow(0 0 6px rgba(232,179,75,.45)); }
header.topbar {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 14px;
  padding-left: max(14px, env(safe-area-inset-left));
  padding-right: max(14px, env(safe-area-inset-right));
  min-height: 56px;
}
header.topbar h1 { font-size: 20px; margin: 0; letter-spacing: .4px; white-space: nowrap; }
header.topbar h1 span { color: var(--accent); }
header.topbar .spacer { flex: 1; }
header.topbar #whoami { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

nav.tabs {
  display: flex; gap: 6px; flex-wrap: nowrap;
  overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none;
  padding: 8px 14px 10px;
  padding-left: max(14px, env(safe-area-inset-left));
  padding-right: max(14px, env(safe-area-inset-right));
}
nav.tabs::-webkit-scrollbar { display: none; }
nav.tabs button { flex: none; white-space: nowrap; padding: 10px 16px; border-radius: 999px; }
nav.tabs button.active {
  background: linear-gradient(180deg, #f2c66d, var(--accent));
  color: #1a1405; border-color: var(--accent); font-weight: 600;
  box-shadow: 0 2px 10px rgba(232,179,75,.25);
}

main {
  padding: 12px 14px 20px;
  padding-left: max(14px, env(safe-area-inset-left));
  padding-right: max(14px, env(safe-area-inset-right));
}
h2.section {
  font-size: 13px; text-transform: uppercase; letter-spacing: 1.4px; color: var(--muted);
  margin: 22px 0 10px; display: flex; align-items: center; gap: 9px;
}
h2.section::before { content: ""; width: 18px; height: 2px; border-radius: 1px; background: var(--accent); flex: none; }
.empty { color: var(--muted); padding: 14px 4px; }

/* Shows: two artwork-forward columns on phones. */
.show-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.show-card {
  background: linear-gradient(180deg, #1d2530, var(--panel));
  border-radius: 14px; padding: 10px; cursor: pointer;
  border: 1px solid var(--border); box-shadow: var(--shadow); min-width: 0;
  transition: border-color .15s ease, transform .15s ease;
}
@media (hover: hover) { .show-card:hover { border-color: var(--accent-dim); transform: translateY(-2px); } }
.show-card img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 10px; background: var(--panel2); display: block; box-shadow: 0 4px 14px rgba(0,0,0,.35); }
.show-card .t { font-weight: 600; font-size: 15px; margin-top: 8px; line-height: 1.3; overflow-wrap: break-word; }
.show-card .c { color: var(--muted); font-size: 12px; margin-top: 3px; }
.badge { display: inline-block; background: var(--accent); color: #1a1405; border-radius: 20px; font-size: 11px; font-weight: 700; padding: 1px 7px; }

.ep-list { display: flex; flex-direction: column; gap: 8px; }
.ep {
  background: linear-gradient(180deg, #1c242e, var(--panel));
  border-radius: 14px; padding: 13px;
  display: flex; gap: 10px; align-items: flex-start;
  border: 1px solid var(--border); box-shadow: var(--shadow);
}
.ep.playing { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), var(--shadow); }
.ep .main { flex: 1; min-width: 0; }
.ep .title { font-weight: 600; font-size: 16px; line-height: 1.35; cursor: pointer; overflow-wrap: break-word; }
.ep .meta { color: var(--muted); font-size: 13px; margin-top: 3px; overflow-wrap: break-word; }
.ep .desc { color: var(--muted); font-size: 14px; margin-top: 6px; line-height: 1.5; max-height: 6em; overflow: hidden; overflow-wrap: break-word; }
.ep.played .title { color: var(--muted); font-weight: 500; }
.ep .actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.progress-track { height: 4px; background: #2c3846; border-radius: 2px; margin-top: 8px; }
.progress-fill { height: 100%; background: var(--accent); border-radius: 2px; }

/* Live transcription progress */
.tx-progress {
  background: var(--panel2); border: 1px solid #33404e;
  border-radius: 14px; padding: 18px; margin: 6px 0;
}
.tx-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.tx-label { font-size: 16px; font-weight: 600; }
.tx-pct { font-size: 30px; font-weight: 700; color: var(--accent); line-height: 1; font-variant-numeric: tabular-nums; }
.tx-bar {
  height: 10px; border-radius: 5px; margin-top: 14px; overflow: hidden;
  background: color-mix(in srgb, var(--accent) 14%, transparent);
}
.tx-fill {
  height: 100%; width: 0%; border-radius: 5px;
  background: linear-gradient(90deg, color-mix(in srgb, var(--accent) 72%, white), var(--accent));
  box-shadow: 0 0 10px color-mix(in srgb, var(--accent) 45%, transparent);
  transition: width .6s ease;
}
.tx-fill.indeterminate {
  width: 38%;
  animation: tx-slide 1.4s ease-in-out infinite alternate;
}
@keyframes tx-slide { from { margin-left: 0; } to { margin-left: 62%; } }
.tx-meta { margin-top: 12px; color: var(--muted); font-size: 14px; font-variant-numeric: tabular-nums; }
.tx-last {
  margin-top: 14px; padding: 10px 12px; font-style: italic; font-size: 14px;
  line-height: 1.5; color: var(--muted);
  border-left: 3px solid var(--accent); background: var(--panel);
  border-radius: 0 8px 8px 0;
}

/* Transcripts tab */
.tx-show {
  font-size: 11.5px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 1.1px; color: var(--accent); margin-bottom: 3px;
  overflow-wrap: break-word;
}
.tx-ep-title { font-weight: 600; font-size: 16px; line-height: 1.35; overflow-wrap: break-word; }
.tx-card { cursor: pointer; transition: border-color .15s ease, transform .15s ease; }
@media (hover: hover) { .tx-card:hover { border-color: var(--accent-dim); transform: translateY(-1px); } }
.tx-snippet { color: var(--muted); font-size: 14px; line-height: 1.6; margin-top: 8px; overflow-wrap: break-word; }
.tx-snippet mark, .cue mark {
  background: rgba(232,179,75,.85); color: #1a1405;
  border-radius: 3px; padding: 0 2px;
}
.src-badge {
  display: inline-block; border: 1px solid var(--border-strong); color: var(--muted);
  border-radius: 999px; font-size: 11px; font-weight: 700; letter-spacing: .4px;
  padding: 1px 8px; margin-right: 8px; vertical-align: 1px;
}
.src-badge.whisper { border-color: var(--accent-dim); color: var(--accent); background: rgba(232,179,75,.08); }
/* Chapters panel header (v36): the source reads as a quiet caption
 * label beside Regenerate — the .src-badge pill is designed for inline
 * meta lines and looked stranded floating in this toolbar row. */
.ch-head { align-items: center; }
.ch-source {
  font-size: 12.5px; font-weight: 600; letter-spacing: .05em;
  text-transform: uppercase; color: var(--muted);
}
.ch-source.generated { color: var(--accent); }
.tx-active-card {
  background: linear-gradient(180deg, #1c242e, var(--panel));
  border: 1px solid var(--border); box-shadow: var(--shadow);
  border-radius: 14px; padding: 13px; margin-bottom: 8px;
}
.tx-active-card .tx-progress { margin: 10px 0 2px; }
.tx-failed { color: var(--danger); font-size: 14px; line-height: 1.5; margin-top: 6px; }
/* Queue lineup: numbered medallions on a connecting rail, show
 * artwork, and a slim reorder rail instead of buttons in the crowd. */
.q-summary { color: var(--muted); font-size: 13.5px; }
.q-hint { color: var(--muted); font-size: 13px; margin: 0 0 10px; }
#queueList { position: relative; }
#queueList.has-items::before {
  content: ""; position: absolute; left: 29px; top: 10px; bottom: 10px; width: 2px;
  background: linear-gradient(180deg, transparent, #2c3846 5%, #2c3846 95%, transparent);
}
.q-card { align-items: flex-start; }
.q-left { flex: none; width: 34px; display: flex; justify-content: center; padding-top: 2px; }
.q-num {
  width: 30px; height: 30px; border-radius: 50%; flex: none;
  border: 1.5px solid var(--border-strong); background: var(--panel);
  color: var(--muted); font-size: 13.5px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  position: relative; z-index: 1; font-variant-numeric: tabular-nums;
}
.q-num.first {
  background: linear-gradient(180deg, #f2c66d, var(--accent));
  border-color: var(--accent); color: #1a1405;
  box-shadow: 0 2px 10px rgba(232,179,75,.3);
}
.q-num.now { border-color: var(--accent); background: rgba(232,179,75,.12); }
.q-eq { display: flex; gap: 2.5px; align-items: flex-end; height: 12px; }
.q-eq i { width: 3px; border-radius: 1px; background: var(--accent); animation: qeq .8s ease-in-out infinite alternate; }
.q-eq i:nth-child(1) { height: 7px; animation-duration: .7s; }
.q-eq i:nth-child(2) { height: 12px; animation-duration: .95s; }
.q-eq i:nth-child(3) { height: 5px; animation-duration: .6s; }
@keyframes qeq { from { transform: scaleY(.45); } to { transform: scaleY(1); } }
.q-eq i { transform-origin: bottom; }
.q-art {
  width: 56px; height: 56px; border-radius: 10px; object-fit: cover; flex: none;
  background: var(--panel2); box-shadow: 0 4px 12px rgba(0,0,0,.35);
}
.q-art-empty { border: 1px solid var(--border); box-shadow: none; }
.q-rail { flex: none; display: flex; flex-direction: column; gap: 6px; }
.q-rail-btn {
  min-width: 40px; min-height: 40px; padding: 6px; border-radius: 9px;
  font-size: 15px; line-height: 1; color: var(--muted);
}
.q-rail-btn:hover { color: var(--text); }
.q-rail-btn:disabled { opacity: .28; pointer-events: none; }
.q-card .desc {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  max-height: none;
}

.fav-on { color: var(--accent); border-color: var(--accent); }
.tstatus { font-size: 12px; color: var(--muted); }
.tstatus.failed { color: var(--danger); }
.tstatus.done { color: var(--ok); }

/* Transcript state chips on episode cards: a gold document chip when a
 * transcript exists (tap opens it), a muted pulsing chip while one is
 * being made, a small red chip when the last attempt failed. */
.tx-chip {
  display: inline-flex; align-items: center; gap: 5px;
  min-height: 30px; padding: 4px 11px; border-radius: 999px;
  font-size: 12px; font-weight: 600; letter-spacing: .2px;
}
.tx-chip.has {
  color: var(--accent); border-color: rgba(232,179,75,.45);
  background: rgba(232,179,75,.09);
}
.tx-chip.has:hover { background: rgba(232,179,75,.17); }
.tx-chip.busy { color: var(--muted); border-color: var(--border); background: var(--panel2); }
.tx-chip.failed { color: #ff9d94; border-color: rgba(255,107,97,.4); background: rgba(255,107,97,.08); }
.tx-chip:disabled { cursor: default; opacity: 1; }
.tx-dot {
  width: 7px; height: 7px; border-radius: 50%; flex: none;
  background: var(--accent); animation: txpulse 1.1s ease-in-out infinite;
}
@keyframes txpulse { 0%, 100% { opacity: .3; } 50% { opacity: 1; } }

/* Download / delete row above the transcript in the player panel. */
#transcriptTools { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
#transcriptTools:empty { display: none; }

.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 10px 0; }
.toolbar select, .toolbar input { width: auto; }
.toolbar > * { min-height: 44px; }
.checkline { display: flex; align-items: center; gap: 9px; font-size: 15px; color: var(--text); margin: 0; min-height: 44px; cursor: pointer; }
.checkline input { width: 24px; }

.panel {
  background: linear-gradient(180deg, #1c242e, var(--panel));
  border: 1px solid var(--border); box-shadow: var(--shadow);
  border-radius: 14px; padding: 14px; margin: 12px 0;
}
.panel h3 { margin: 0 0 8px; font-size: 17px; }
.panel summary {
  cursor: pointer; font-size: 16px; font-weight: 600;
  min-height: 44px; display: flex; align-items: center;
  touch-action: manipulation;
}
details.panel > label:first-of-type { margin-top: 10px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; word-break: break-all; }
.flash { background: #14301a; border: 1px solid var(--ok); color: #cdeecd; border-radius: 8px; padding: 10px 12px; margin: 10px 0; font-size: 14px; }
.err { background: #3a1a18; border: 1px solid var(--danger); color: #f3cfcc; border-radius: 8px; padding: 10px 12px; margin: 10px 0; font-size: 14px; }

/* Player: a proper bottom deck — show artwork and a two-line title
 * block, a seek bar that fills gold as it plays with the times at its
 * ends, a centered circular transport cluster, and one quiet row of
 * pill controls. Fixed, full-width, safe-area aware. */
#player {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  background: linear-gradient(180deg, rgba(35,44,56,.93), rgba(17,22,28,.97));
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  border-top: 1px solid rgba(232,179,75,.32);
  border-radius: 18px 18px 0 0;
  box-shadow: 0 -14px 38px rgba(0,0,0,.55);
  padding: 12px 14px calc(10px + env(safe-area-inset-bottom));
  padding-left: max(14px, env(safe-area-inset-left));
  padding-right: max(14px, env(safe-area-inset-right));
}
.p-head { display: flex; gap: 11px; align-items: center; min-height: 46px; }
.p-art {
  width: 46px; height: 46px; border-radius: 9px; object-fit: cover; flex: none;
  box-shadow: 0 4px 12px rgba(0,0,0,.4); transition: box-shadow .3s;
}
#player.is-playing .p-art { box-shadow: 0 0 0 2px rgba(232,179,75,.55), 0 4px 14px rgba(0,0,0,.45); }
.p-titles { flex: 1; min-width: 0; }
.p-show {
  font-size: 11px; font-weight: 700; letter-spacing: 1.1px; text-transform: uppercase;
  color: var(--accent); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.p-show:empty { display: none; }
#player .now {
  font-size: 14.5px; font-weight: 600; line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.p-seekrow { display: flex; align-items: center; gap: 10px; margin-top: 2px; }
#player .time { font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; min-width: 42px; }
#timeCur { text-align: right; }
#timeDur { text-align: left; }
/* A seek bar a thumb can actually grab: tall hit area, big thumb, and
 * the played portion painted gold through the --fill variable. */
#player input[type=range] {
  flex: 1; min-width: 0; height: 36px; margin: 0;
  -webkit-appearance: none; appearance: none;
  background: transparent; border: none; padding: 0; cursor: pointer;
}
#player input[type=range]::-webkit-slider-runnable-track {
  height: 6px; border-radius: 3px;
  background: linear-gradient(90deg, var(--accent) var(--fill, 0%), #2c3846 var(--fill, 0%));
}
#player input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--accent); border: 2px solid #141a21; margin-top: -9px;
  box-shadow: 0 2px 8px rgba(0,0,0,.5);
}
#player input[type=range]::-moz-range-track { height: 6px; border-radius: 3px; background: #2c3846; }
#player input[type=range]::-moz-range-progress { height: 6px; border-radius: 3px; background: var(--accent); }
#player input[type=range]::-moz-range-thumb { width: 22px; height: 22px; border-radius: 50%; background: var(--accent); border: 2px solid #141a21; }
.p-transport {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; margin-top: 2px;
}
.p-transport #playerStatus {
  justify-self: start; min-width: 0; font-size: 11.5px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.p-cluster { display: flex; align-items: center; gap: 14px; }
#playBtn {
  width: 62px; height: 62px; border-radius: 50%; flex: none;
  display: flex; align-items: center; justify-content: center;
  font-size: 23px; padding: 0 0 0 2px;
  background: linear-gradient(180deg, #f2c66d, var(--accent));
  color: #1a1405; border: none;
  box-shadow: 0 5px 18px rgba(232,179,75,.35);
}
.skip {
  width: 50px; height: 50px; border-radius: 50%; flex: none; padding: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 13.5px; font-weight: 700; color: var(--text);
  background: var(--panel2); border: 1px solid var(--border-strong);
}
.skip.next { justify-self: end; width: 44px; height: 44px; font-size: 15px; }
#player .row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.p-controls { margin-top: 9px; }
.ctl-label {
  font-size: 11px; font-weight: 700; letter-spacing: 1.1px;
  text-transform: uppercase; color: var(--muted);
}
#player select { min-height: 38px; font-size: 13.5px; padding: 6px 10px; border-radius: 999px; }
#playerPanel { max-height: 38vh; overflow-y: auto; padding: 4px 2px 8px; }
#playerPanel .toolbar input { min-height: 44px; }
.cue { padding: 10px 8px; border-radius: 6px; cursor: pointer; font-size: 14px; line-height: 1.5; overflow-wrap: break-word; }
.cue:hover { background: var(--panel2); }
.cue.now { background: rgba(232,179,75,.13); box-shadow: inset 2px 0 0 var(--accent); }
.cue .ts { color: var(--accent); font-size: 12px; margin-right: 7px; font-family: ui-monospace, Menlo, monospace; }
.chapter { padding: 11px 8px; border-radius: 6px; cursor: pointer; font-size: 14px; overflow-wrap: break-word; }
.chapter:hover { background: var(--panel2); }
.chapter .ts { color: var(--accent); font-size: 12px; margin-right: 7px; font-family: ui-monospace, Menlo, monospace; }
.hidden { display: none !important; }

@media (prefers-reduced-motion: reduce) {
  .tx-fill.indeterminate { animation: none; }
  .tx-dot { animation: none; }
  .q-eq i { animation: none; }
  .modal-overlay, .modal-card { animation: none; }
  main section:not(.hidden) { animation: none; }
  button, .show-card, .tx-card, .tx-fill { transition: none; }
}

/* Add-a-podcast modal: a bottom sheet on phones, a centered card on
 * larger screens. Sits above the player (z 30) and the sticky head. */
.modal-overlay {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(5,8,11,.66);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fadeIn .18s ease;
}
@keyframes fadeIn { from { opacity: 0; } }
.modal-card {
  background: linear-gradient(180deg, #1d2530, var(--panel));
  border: 1px solid var(--border-strong); border-bottom: none;
  border-radius: 18px 18px 0 0; box-shadow: 0 -18px 50px rgba(0,0,0,.5);
  width: 100%; max-height: 86vh; max-height: 86dvh; overflow-y: auto;
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
  animation: sheetUp .24s cubic-bezier(.32,.9,.35,1);
}
@keyframes sheetUp { from { transform: translateY(26px); opacity: .4; } to { transform: none; opacity: 1; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 2px; }
.modal-head h3 { margin: 0; font-size: 18px; }
.modal-or {
  display: flex; align-items: center; gap: 10px; color: var(--muted);
  font-size: 12px; text-transform: uppercase; letter-spacing: 1.2px; margin: 18px 0 6px;
}
.modal-or::before, .modal-or::after { content: ""; flex: 1; height: 1px; background: var(--border); }
@media (min-width: 640px) {
  .modal-overlay { align-items: center; padding: 20px; }
  .modal-card { max-width: 560px; border-radius: 18px; border-bottom: 1px solid var(--border-strong); animation: viewIn .22s ease; }
}

/* Custom artwork: the painted night-desk scene (gold crescent lamp,
 * headphones, notebook) generated for the app. Used as the auth banner
 * and as the visual for empty states. */
.auth-art {
  width: 100%; display: block; border-radius: 14px;
  border: 1px solid var(--border); box-shadow: var(--shadow);
}
.empty-art {
  width: 100%; max-height: 170px; object-fit: cover; object-position: 50% 68%;
  display: block; border-radius: 12px; border: 1px solid var(--border);
  margin-bottom: 10px;
}

/* Views fade/slide in gently when switched to. */
main section:not(.hidden) { animation: viewIn .22s ease; }
@keyframes viewIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* Episode descriptions fade out instead of cutting off mid-line. */
.ep .desc {
  -webkit-mask-image: linear-gradient(180deg, #000 72%, transparent);
  mask-image: linear-gradient(180deg, #000 72%, transparent);
}
.progress-fill { background: linear-gradient(90deg, color-mix(in srgb, var(--accent) 70%, white), var(--accent)); }

/* Auth pages: full-width card on phones, capped and centered above. */
.auth-wrap { width: 100%; margin: 5vh auto 0; padding: 0 14px; }
.auth-wrap .panel { padding: 18px; }
.auth-wrap h1 { text-align: center; font-size: 26px; margin: 10px 0 6px; }
.auth-wrap h1 span { color: var(--accent); }
.auth-wrap p.sub { text-align: center; color: var(--muted); font-size: 14px; line-height: 1.5; }
.auth-wrap button[type=submit] { width: 100%; min-height: 52px; font-size: 16px; }

/* ------------------------------------------------------------------ */
/* Tablet and up                                                       */
/* ------------------------------------------------------------------ */
@media (min-width: 640px) {
  body { padding-bottom: 244px; }
  .show-grid { grid-template-columns: repeat(3, 1fr); gap: 12px; }
  main { padding: 14px 20px 24px; }
  #playerPanel { max-height: 42vh; }
  .auth-wrap { max-width: 420px; margin-top: 8vh; padding: 0 16px; }
  .auth-wrap .panel { padding: 22px; }
}

/* ------------------------------------------------------------------ */
/* Desktop                                                             */
/* ------------------------------------------------------------------ */
@media (min-width: 960px) {
  main { max-width: 880px; margin: 0 auto; }
  .show-grid { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
  #player {
    padding-left: max(12px, calc((100vw - 880px) / 2));
    padding-right: max(12px, calc((100vw - 880px) / 2));
  }
  #playerPanel { max-height: 46vh; }
}

/* ------------------------------------------------------------------ */
/* Design elevation pass (shell v25)                                   */
/* One material language across every surface: cards lit from above    */
/* by the inset highlight, gold reserved for what is live or primary,  */
/* serif for the wordmark and headings, pills for anything tappable    */
/* inside a card. No layout or behavior changes — finish only.         */
/* ------------------------------------------------------------------ */

/* Foundation: a deeper room, the lamp glow a touch warmer. */
body {
  background:
    radial-gradient(130% 380px at 50% -100px, rgba(232,179,75,.12), rgba(232,179,75,0) 70%),
    radial-gradient(90% 300px at 50% 115%, rgba(232,179,75,.045), rgba(232,179,75,0) 70%),
    #0c0f13;
  background-attachment: fixed;
}

/* Buttons: machined, not flat — a lit top edge on every control, and
 * the primary gradient gets a bright head and a deep foot. */
button {
  background: linear-gradient(180deg, #28323e, var(--panel2));
  box-shadow: var(--card-hi);
}
button.primary, nav.tabs button.active {
  background: linear-gradient(180deg, var(--gold-bright), var(--accent) 55%, var(--gold-deep));
  color: var(--ink);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.5), 0 3px 12px rgba(232,179,75,.28);
}
#playBtn {
  background: linear-gradient(180deg, var(--gold-bright), var(--accent) 55%, var(--gold-deep));
  color: var(--ink);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.5), 0 6px 20px rgba(232,179,75,.38);
}
#player.is-playing #playBtn { animation: playPulse 2.4s ease-out infinite; }
@keyframes playPulse {
  0% { box-shadow: inset 0 1px 0 rgba(255,255,255,.5), 0 0 0 0 rgba(232,179,75,.4), 0 6px 20px rgba(232,179,75,.35); }
  70% { box-shadow: inset 0 1px 0 rgba(255,255,255,.5), 0 0 0 13px rgba(232,179,75,0), 0 6px 20px rgba(232,179,75,.35); }
  100% { box-shadow: inset 0 1px 0 rgba(255,255,255,.5), 0 0 0 0 rgba(232,179,75,0), 0 6px 20px rgba(232,179,75,.35); }
}

/* Header: the moon mark sits in a small gold-ringed chip, the wordmark
 * goes serif, and the tabs become one segmented pill rail. */
.stickhead {
  background: rgba(11,14,18,.88);
  border-bottom: 1px solid rgba(232,179,75,.14);
}
.brandmark {
  width: 30px; height: 30px; padding: 5px;
  background: radial-gradient(circle at 50% 38%, rgba(232,179,75,.22), rgba(232,179,75,.05));
  border: 1px solid rgba(232,179,75,.35); border-radius: 9px;
}
header.topbar h1 { font-family: var(--serif); font-size: 21px; font-weight: 600; letter-spacing: .2px; }
#logoutBtn { background: transparent; border-color: var(--border); color: var(--muted); box-shadow: none; }
nav.tabs {
  background: rgba(255,255,255,.03);
  border: 1px solid var(--border); border-radius: 999px;
  margin: 0 10px 10px; padding: 4px;
  padding-left: 4px; padding-right: 4px;
}
nav.tabs button { border-color: transparent; background: transparent; box-shadow: none; min-height: 40px; }
nav.tabs button:not(.active) { color: var(--muted); }
@media (hover: hover) { nav.tabs button:not(.active):hover { color: var(--text); border-color: transparent; } }

/* Section headings and panel titles share one voice. */
h2.section { font-size: 12.5px; letter-spacing: 1.6px; }
h2.section::before { box-shadow: 0 0 8px rgba(232,179,75,.55); }
.panel h3 {
  font-family: var(--serif); font-size: 18.5px; font-weight: 600; letter-spacing: .2px;
  display: flex; align-items: center; gap: 9px;
}
.panel h3::before { content: ""; width: 14px; height: 2px; border-radius: 1px; background: var(--accent); flex: none; }
details.panel > summary { list-style: none; }
details.panel > summary::-webkit-details-marker { display: none; }
details.panel > summary::after {
  content: "›"; margin-left: auto; color: var(--muted); font-size: 22px; line-height: 1;
  transition: transform .2s ease;
}
details.panel[open ] > summary::after { transform: rotate(90deg); }

/* Cards: one material everywhere — gradient, lit top edge, soft drop. */
.show-card, .ep, .panel, .tx-active-card {
  box-shadow: var(--card-hi), var(--shadow);
}
.show-card img { border: 1px solid var(--hairline); }
.show-card .t {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.ep.playing {
  background: linear-gradient(180deg, rgba(232,179,75,.075), rgba(232,179,75,.02) 55%), linear-gradient(180deg, #1c242e, var(--panel));
  box-shadow: inset 3px 0 0 var(--accent), var(--card-hi), var(--shadow);
}
.ep.played { background: linear-gradient(180deg, #181e26, #151a21); }
.ep .actions button { border-radius: 999px; padding: 8px 13px; }
.ep .meta { font-variant-numeric: tabular-nums; }
.progress-track { height: 5px; border-radius: 3px; }
.progress-fill { box-shadow: 0 0 6px rgba(232,179,75,.45); }

/* Forms: settings rows breathe, checklines read as tappable rows. */
.checkline { padding: 7px 9px; margin-left: -9px; margin-right: -9px; border-radius: 10px; }
@media (hover: hover) { .checkline:hover { background: rgba(255,255,255,.03); } }
label { letter-spacing: .2px; }

/* Queue: the rail picks up the lamp tint; artwork gets a lit ring. */
#queueList.has-items::before {
  background: linear-gradient(180deg, transparent, rgba(232,179,75,.28) 6%, rgba(232,179,75,.28) 94%, transparent);
}
.q-art { border: 1px solid var(--hairline); }
.q-summary { font-variant-numeric: tabular-nums; }

/* Banners and empty states: quiet cards, not raw text. */
.flash { border-left: 3px solid var(--ok); }
.err { border-left: 3px solid var(--danger); }
.empty {
  border: 1px dashed var(--border-strong); border-radius: var(--radius);
  background: rgba(255,255,255,.02);
  padding: 20px 16px; text-align: center; line-height: 1.55;
}
.auth-art, .empty-art { border-color: rgba(232,179,75,.25); }

/* Player deck: richer glass, a hairline of lamplight along its top,
 * glass skip keys, and a slightly larger, ringed artwork. */
#player {
  background: linear-gradient(180deg, rgba(37,47,59,.94), rgba(12,16,21,.98));
  border-top: 1px solid rgba(232,179,75,.42);
  box-shadow: 0 -1px 0 rgba(246,205,110,.12), 0 -16px 42px rgba(0,0,0,.6);
}
.p-art { width: 52px; height: 52px; border-radius: 11px; border: 1px solid var(--hairline); }
.skip { background: rgba(255,255,255,.05); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
#player select { background: rgba(255,255,255,.05); }
.cue, .chapter { border-radius: 8px; }
#playerPanel { scrollbar-width: thin; scrollbar-color: #33404e transparent; }
#playerPanel::-webkit-scrollbar { width: 6px; }
#playerPanel::-webkit-scrollbar-thumb { background: #33404e; border-radius: 3px; }

/* Modal sheet: a grab handle on phones, serif title. */
.modal-head h3 { font-family: var(--serif); font-size: 19px; font-weight: 600; }
.modal-card::before {
  content: ""; display: block; width: 38px; height: 4px; border-radius: 2px;
  background: #3a4656; margin: 0 auto 13px;
}
@media (min-width: 640px) { .modal-card::before { display: none; } }

/* Auth pages: the wordmark leads. */
.auth-wrap h1 { font-family: var(--serif); font-size: 30px; font-weight: 600; }

@media (prefers-reduced-motion: reduce) {
  #player.is-playing #playBtn { animation: none; }
  details.panel > summary::after { transition: none; }
}

/* Multi-select mode (v30): a checkbox row at the top of a card and a
 * gold outline on selected cards. The bulk action bars themselves are
 * plain .toolbar rows shown only while a view is selecting. */
.sel-check {
  display: flex; align-items: center; gap: 8px;
  margin: 0 0 8px; min-height: 32px;
  font-size: 13px; color: var(--muted); cursor: pointer;
}
.sel-check input { width: 22px; height: 22px; flex: none; }
.ep.selected, .tx-card.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 1.5px var(--accent), var(--card-hi), var(--shadow);
}

/* Downloads cards (v31): played-state chip + a quieter second meta line
 * for the on-device facts (size, when it was downloaded). */
.dl-sub { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.state-chip {
  display: inline-block; padding: 1px 8px; border-radius: 999px;
  border: 1px solid var(--line);
  font-size: 11px; font-weight: 700; letter-spacing: .04em;
  text-transform: uppercase; color: var(--muted); white-space: nowrap;
}
.state-chip.unplayed { color: var(--accent); border-color: rgba(232, 181, 76, .45); }
.state-chip.played { color: var(--muted); }

/* Masthead artwork (v38): the desk art behind the sticky header + tab
 * rail, on a ::before layer so it can be brightened independently.
 * Tyler's v37 verdict was "looks the same" — measured why: the art is
 * a very dark scene (its top three-quarters average luminance ~17/255;
 * the lamp and desk light live in the bottom quarter), and v37 both
 * cropped that dark band and buried it under a heavy overlay. Now the
 * crop sits on the lit desk band (center 80%), the layer is brightened
 * ~1.85x, and the gradient overlay is much lighter — dark enough for
 * the wordmark and tabs, light enough that the art actually reads. */
.stickhead { overflow: hidden; border-bottom: 1px solid rgba(232, 179, 75, .18); }
.stickhead::before {
  content: ''; position: absolute; inset: 0; z-index: 0;
  background:
    linear-gradient(180deg, rgba(13, 10, 6, .30), rgba(13, 10, 6, .48) 72%, rgba(16, 12, 6, .68)),
    url('/img/desk-art.webp') center 80% / cover no-repeat;
  filter: brightness(1.85) saturate(1.15);
}
.stickhead > * { position: relative; z-index: 1; }

/* Tab rail legibility over the masthead art (v40, Tyler's catch): the
 * v25 rail was nearly transparent with muted text — fine over plain
 * dark glass, washed out over the brightened artwork. The rail now
 * carries its own darker frosted backing (its backdrop-filter blurs
 * the art layer beneath it), and inactive labels go brighter with a
 * soft shadow so they hold up over busy parts of the image. The
 * active tab was already high-contrast gold and is unchanged. */
nav.tabs {
  background: rgba(10, 8, 5, .55);
  -webkit-backdrop-filter: blur(9px) saturate(1.1);
  backdrop-filter: blur(9px) saturate(1.1);
  border-color: rgba(232, 179, 75, .22);
}
nav.tabs button:not(.active) {
  color: #ccd6e2;
  text-shadow: 0 1px 3px rgba(0, 0, 0, .7);
}
