:root {
  --bg: #fafaf9;
  --fg: #1c1917;
  --muted: #78716c;
  --card: #fff;
  --border: #e7e5e4;
  --accent: #2563eb;
  --shared: #a8a29e;
  --free: #3b82f6;
  --paid: #eab308;
  --danger: #dc2626;
  --ok: #16a34a;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1c1917; --fg: #f5f5f4; --muted: #a8a29e; --card: #292524; --border: #44403c;
    --accent: #60a5fa; --shared: #78716c;
  }
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.5 system-ui, -apple-system, sans-serif; background: var(--bg); color: var(--fg); }
a { color: var(--accent); }
main { max-width: 1200px; margin: 0 auto; padding: 1rem 16px 3rem; }
h1 { font-size: 1.6rem; margin: .5rem 0; }
h2 { font-size: 1.15rem; margin: 1.5rem 0 .5rem; }
.muted { color: var(--muted); }
small { font-size: .82em; }
code { font-size: .85em; word-break: break-all; }

header.site { display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  padding: .75rem 16px; border-bottom: 1px solid var(--border); background: var(--card); }
header.site .brand { font-weight: 700; text-decoration: none; color: var(--fg); }
header.site nav { display: flex; gap: 1rem; align-items: center; }

.flash { padding: .5rem .75rem; border-radius: 6px; border: 1px solid var(--border); background: var(--card); }
.flash.error { border-color: var(--danger); color: var(--danger); }
.flash.ok { border-color: var(--ok); }

button, .button { font: inherit; padding: .4rem .8rem; border-radius: 6px; border: 1px solid var(--accent);
  background: var(--accent); color: #fff; cursor: pointer; text-decoration: none; display: inline-block; }
button.danger { background: var(--danger); border-color: var(--danger); }
button.link { background: none; border: none; color: var(--accent); padding: 0; }
button.link.danger { color: var(--danger); }
form.inline { display: inline; }
input, select, textarea { font: inherit; padding: .35rem .5rem; border: 1px solid var(--border); border-radius: 6px;
  background: var(--card); color: var(--fg); }

form.stacked { display: flex; flex-direction: column; gap: .75rem; max-width: 640px; }
form.stacked.narrow { max-width: 320px; }
form.stacked label { display: flex; flex-direction: column; gap: .2rem; }
form.stacked label.check { flex-direction: row; align-items: center; gap: .5rem; }
form.stacked button { align-self: flex-start; }
fieldset.row { border: 0; padding: 0; margin: 0; display: flex; gap: .75rem; flex-wrap: wrap; }
.hp { position: absolute; left: -10000px; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 1rem; }
.card { display: flex; gap: 1rem; padding: 1rem; background: var(--card); border: 1px solid var(--border);
  border-radius: 10px; text-decoration: none; color: inherit; }
.card img { width: 96px; height: 96px; border-radius: 8px; object-fit: cover; }
.card h2 { margin: 0; }
dl.mini { display: grid; grid-template-columns: auto auto; gap: 0 .75rem; margin: .5rem 0 0; font-size: .9em; }
dl.mini dt { color: var(--muted); }
dl.mini dd { margin: 0; font-variant-numeric: tabular-nums; }

.podcast-head { display: flex; gap: 1rem; align-items: center; margin-bottom: 1rem; }
.podcast-head img { width: 120px; height: 120px; border-radius: 10px; object-fit: cover; }
form.price { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .75rem; margin-bottom: 1rem; }
.stats > div { background: var(--card); border: 1px solid var(--border); border-radius: 8px; padding: .6rem .8rem;
  color: var(--muted); font-size: .85em; }
.stats span { display: block; font-size: 1.35rem; color: var(--fg); font-variant-numeric: tabular-nums; }

.legend { display: flex; gap: 1.25rem; flex-wrap: wrap; font-size: .88em; margin: .5rem 0; }
.swatch { display: inline-block; width: .9em; height: .9em; border-radius: 2px; vertical-align: -.1em; margin-right: .35em; }
.shared { background: var(--shared); }
.excl-free { background: var(--free); }
.excl-paid { background: var(--paid); }

.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: .45rem .5rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: .82em; color: var(--muted); font-weight: 600; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

table.episodes td.title { width: 26%; }
table.episodes td.title small { display: block; }
table.episodes td:nth-child(2), table.episodes td:nth-child(3) { width: 30%; }
table.episodes tr.pending, table.episodes tr.error { opacity: .65; }
.bar { position: relative; height: 16px; border-radius: 3px; overflow: hidden; background: var(--shared); min-width: 2px; }
.bar .seg { position: absolute; top: 0; bottom: 0; }
.bar + small { color: var(--muted); }
.bar .seg.playable { border: 0; padding: 0; border-radius: 0; cursor: pointer; min-width: 4px; }
.bar .seg.playable:hover, .bar .seg.playable:focus-visible { box-shadow: inset 0 0 0 2px var(--fg); outline: none; }

dialog#player { width: min(480px, calc(100vw - 32px)); border: 1px solid var(--border); border-radius: 10px;
  background: var(--card); color: var(--fg); padding: 1rem 1.25rem; }
dialog#player::backdrop { background: rgb(0 0 0 / .5); }
dialog#player h2 { margin: 0 2rem .25rem 0; font-size: 1.05rem; }
dialog#player audio { width: 100%; margin: .5rem 0; }
.player-close { position: absolute; top: .5rem; right: .75rem; }
.player-close button { font-size: 1.1rem; color: var(--muted); }
.player-nav { display: flex; gap: .5rem; flex-wrap: wrap; }
.player-nav button[disabled] { opacity: .4; }

table.admin td.url { max-width: 320px; }
tr.inactive { opacity: .6; }
.error { color: var(--danger); }
form.job-run { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; margin-bottom: .75rem; }
button[disabled] { opacity: .5; cursor: not-allowed; }
.status-succeeded { color: var(--ok); }
.status-failed, .status-cancelled { color: var(--danger); }
.danger-zone { display: flex; gap: .75rem; }

form.search { display: flex; gap: .5rem; margin: 1rem 0; }
form.search input { flex: 1; }
ul.results { list-style: none; padding: 0; }
ul.results li { display: flex; gap: .75rem; align-items: center; padding: .5rem 0; border-bottom: 1px solid var(--border); }
ul.results img { width: 56px; height: 56px; border-radius: 6px; }
ul.results .actions { margin-left: auto; display: flex; gap: .75rem; align-items: center; white-space: nowrap; }
details.free-only { margin-top: 1.5rem; }

@media (max-width: 720px) {
  table.episodes thead { display: none; }
  table.episodes tr { display: grid; grid-template-columns: 1fr 1fr; gap: .25rem .75rem; padding: .5rem 0;
    border-bottom: 1px solid var(--border); }
  table.episodes td { border: 0; padding: 0; width: auto !important; }
  table.episodes td.title { grid-column: 1 / -1; }
  table.episodes td.num { text-align: left; }
  ul.results li { flex-wrap: wrap; }
  ul.results .actions { margin-left: 0; }
}
