* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #f5f1ea; --card: #fffdf9; --ink: #1f1b16; --muted: #6f675c; --line: #e3dcd0;
  --accent: #0d6b5e; --accent-soft: #dcefe9; --warn: #b4541a; --warn-soft: #f8e6d6; --error: #a3262b; --error-soft: #f7e1e1;
}
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased; color: var(--ink); background: var(--bg); line-height: 1.45; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
button:disabled { cursor: default; }
a { color: inherit; }

.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 28px; padding: 16px 40px;
  background: rgba(245,241,234,.92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.brand { font-size: 24px; letter-spacing: -.02em; font-weight: 400; text-decoration: none; white-space: nowrap; }
.brand b { font-weight: 800; }
.brand span { color: var(--accent); font-weight: 650; }
.top form { flex: none; }
.field { flex: 1; max-width: 720px; position: relative; }
.field input { width: 100%; font: inherit; font-size: 16px; padding: 13px 44px 13px 46px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--card); color: var(--ink); outline: none; }
.field input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.field::before { content: ""; position: absolute; left: 18px; top: 50%; width: 13px; height: 13px; margin-top: -9px;
  border: 2px solid var(--muted); border-radius: 50%; }
.field::after { content: ""; position: absolute; left: 31px; top: 50%; width: 7px; height: 2px; margin-top: 5px;
  background: var(--muted); transform: rotate(45deg); }
#clear { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); width: 30px; height: 30px; border-radius: 50%;
  color: var(--muted); display: none; }
#clear:hover { background: var(--line); }
.summary { margin-left: auto; text-align: right; font-size: 13px; color: var(--muted); white-space: nowrap; }
.summary strong { display: block; color: var(--ink); font-size: 14px; }

main { padding: 28px 40px 40px; max-width: 1500px; margin: 0 auto; min-height: calc(100vh - 150px); }
h1 { font-size: 26px; letter-spacing: -.02em; font-weight: 700; }
.sub { color: var(--muted); margin-top: 2px; }
.chips { display: flex; gap: 8px; margin: 20px 0 24px; flex-wrap: wrap; }
.chip { padding: 7px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); font-size: 14px; }
.chip:hover { border-color: var(--muted); }
.chip.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.chip span { opacity: .6; margin-left: 4px; font-variant-numeric: tabular-nums; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(172px, 1fr)); gap: 28px 22px; }
.tile { text-align: left; display: flex; flex-direction: column; gap: 6px; border-radius: 14px; padding: 8px; margin: -8px;
  transition: background .15s; }
.tile:hover { background: var(--card); }
.tile:hover .cover img { transform: scale(1.03); }
.cover { position: relative; display: block; aspect-ratio: 1; border-radius: 12px; overflow: hidden; background: var(--line);
  box-shadow: 0 1px 2px rgba(31,27,22,.08), 0 8px 22px -12px rgba(31,27,22,.35); }
.cover img, .cover .no-image { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .25s; }
.no-image { display: grid !important; place-items: center; font-size: 44px; font-weight: 800; color: var(--muted); background: var(--line); }
.badge { position: absolute; left: 8px; top: 8px; padding: 3px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 700;
  background: var(--accent); color: #fff; letter-spacing: .01em; }
.tile .title { font-weight: 650; font-size: 15px; line-height: 1.25; margin-top: 4px; display: -webkit-box; -webkit-line-clamp: 2;
  -webkit-box-orient: vertical; overflow: hidden; min-height: 2.5em; }
.tile .meta { font-size: 13px; color: var(--muted); }
.bar { display: flex; height: 5px; border-radius: 3px; background: var(--line); overflow: hidden; }
.bar i { display: block; height: 100%; }
.bar .in-feed { background: var(--accent); }
.bar .no-audio { background: repeating-linear-gradient(135deg, var(--warn) 0 3px, #e7b48c 3px 6px); }
.bar.busy .in-feed { animation: pulse 1.1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .45; } }
.state { font-size: 12.5px; font-weight: 600; }
.state.ok { color: var(--accent); } .state.missing { color: var(--warn); } .state.failed { color: var(--error); }
.state.busy, .state.paused, .state.partial, .state.muted { color: var(--muted); }

.note { margin: 14px 0 0; padding: 10px 14px; border-radius: 10px; background: var(--warn-soft); color: #6d3410; font-size: 13.5px; }
.note.error { background: var(--error-soft); color: #6f1a1d; }
.note button { text-decoration: underline; text-underline-offset: 3px; margin-left: 8px; font-weight: 600; }
.results { margin-top: 20px; display: grid; grid-template-columns: repeat(auto-fill, minmax(430px, 1fr)); gap: 12px; }
.result { display: flex; gap: 16px; align-items: center; padding: 12px; border-radius: 14px; background: var(--card); border: 1px solid var(--line); }
.result img, .result .no-image { width: 84px; height: 84px; border-radius: 10px; flex: none; object-fit: cover; font-size: 30px; }
.result .body { flex: 1; min-width: 0; }
.result .name { font-weight: 650; }
.kind { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.result .text { font-size: 13px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.btn { padding: 9px 16px; border-radius: 999px; background: var(--accent); color: #fff; font-weight: 650; font-size: 14px; white-space: nowrap;
  text-decoration: none; display: inline-block; }
.btn:hover { filter: brightness(1.1); }
.btn.light { background: var(--card); color: var(--ink); border: 1px solid var(--line); }
.btn.light:hover { border-color: var(--muted); filter: none; }
.btn.small { padding: 6px 12px; font-size: 13px; }
.btn:disabled { background: var(--line); color: var(--muted); filter: none; border-color: var(--line); }
.empty { padding: 60px 0; text-align: center; color: var(--muted); }
.waiting { padding: 50px 0; color: var(--muted); display: flex; gap: 12px; align-items: center; }
.spin { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--accent); animation: turn .8s linear infinite; }
@keyframes turn { to { transform: rotate(360deg); } }

h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin: 44px 0 10px; font-weight: 700; }
.orphan { display: flex; gap: 14px; align-items: center; padding: 10px 14px; border-radius: 10px; background: var(--card); border: 1px solid var(--line);
  margin-bottom: 8px; font-size: 14px; }
.orphan .what { flex: 1; min-width: 0; }
.orphan .what small { display: block; color: var(--muted); overflow-wrap: anywhere; }

#veil { position: fixed; inset: 0; background: rgba(31,27,22,.28); opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 8; }
#veil.on { opacity: 1; pointer-events: auto; }
#drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(480px, 100vw); background: var(--card); z-index: 9; overflow-y: auto;
  transform: translateX(102%); transition: transform .24s cubic-bezier(.2,.7,.2,1); padding: 26px 28px 40px; }
#drawer.on { transform: none; box-shadow: -18px 0 40px -24px rgba(31,27,22,.5); }
.close { position: absolute; right: 16px; top: 14px; width: 34px; height: 34px; border-radius: 50%; font-size: 17px; color: var(--muted); }
.close:hover { background: var(--line); }
.head { display: flex; gap: 18px; align-items: flex-end; padding-right: 26px; }
.head img, .head .no-image { width: 124px; height: 124px; border-radius: 14px; flex: none; object-fit: cover; }
.head h3 { font-size: 21px; line-height: 1.2; letter-spacing: -.01em; }
.head .kind { margin-bottom: 4px; }
.about { margin-top: 14px; font-size: 14px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.trouble { margin-top: 16px; padding: 12px 14px; border-radius: 10px; background: var(--error-soft); color: #6f1a1d; font-size: 13.5px; }
.trouble.paused { background: var(--bg); color: var(--ink); }
.trouble p { overflow-wrap: anywhere; }
.trouble .btn { margin-top: 10px; }
.figures { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 20px 0 10px; }
.figures div { padding: 10px 12px; border-radius: 10px; background: var(--bg); }
.figures b { display: block; font-size: 22px; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.figures span { font-size: 12px; color: var(--muted); }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin-top: 8px; flex-wrap: wrap; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.hint { font-size: 12.5px; color: var(--muted); margin-top: 8px; }
#drawer h4 { font-size: 13px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin: 26px 0 10px; }
.subscribe { display: flex; gap: 16px; }
.address { display: flex; gap: 8px; align-items: center; padding: 9px 9px 9px 12px; border-radius: 10px; background: var(--bg); font-size: 12.5px;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; word-break: break-all; }
.address span { flex: 1; }
.options { margin-top: 10px; display: grid; gap: 5px; font-size: 13.5px; }
.options label { display: flex; gap: 8px; align-items: center; cursor: pointer; }
.options input { accent-color: var(--accent); width: 15px; height: 15px; }
#qr { flex: none; padding: 8px; background: #fff; border-radius: 10px; border: 1px solid var(--line); width: 150px; height: 150px; }
#qr img, #qr canvas { display: block; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.episode { display: grid; grid-template-columns: 64px 1fr auto; gap: 10px; padding: 9px 0; border-top: 1px solid var(--line); font-size: 13.5px; align-items: baseline; }
.episode .when, .episode .length { color: var(--muted); font-size: 12.5px; white-space: nowrap; }
.episode .length.none { color: var(--warn); font-weight: 600; }
.more { margin-top: 12px; }

.foot { padding: 0 40px 30px; max-width: 1500px; margin: 0 auto; font-size: 12.5px; color: var(--muted); }
.foot a { margin-right: 14px; }
.foot span { opacity: .8; }
#toast { position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 20px); background: var(--ink); color: var(--bg); padding: 11px 18px;
  border-radius: 999px; font-size: 14px; opacity: 0; transition: all .2s; z-index: 20; pointer-events: none; max-width: min(92vw, 640px); text-align: center; }
#toast.on { opacity: 1; transform: translate(-50%, 0); }

/* sign-in page */
.sign-in main { min-height: 100vh; max-width: 420px; padding: 12vh 24px 40px; display: flex; flex-direction: column; gap: 22px; }
.sign-in .brand { font-size: 30px; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 26px 26px 28px; display: flex; flex-direction: column; gap: 10px;
  box-shadow: 0 8px 30px -18px rgba(31,27,22,.35); }
.panel .note { margin: 4px 0; }
.panel label { font-size: 13px; color: var(--muted); margin-top: 8px; }
.panel input { font: inherit; font-size: 16px; padding: 12px 14px; border-radius: 10px; border: 1px solid var(--line); background: #fff; color: var(--ink); outline: none; }
.panel input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.panel .btn { margin-top: 10px; padding: 12px 16px; border-radius: 10px; font-size: 15px; }
.panel code { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 13px; background: var(--bg); padding: 1px 5px; border-radius: 5px; }
.back { font-size: 14px; color: var(--muted); text-decoration: none; }
.back:hover { color: var(--ink); }
.when-closed, .when-error { display: none; }
[data-state="closed"] .when-open { display: none; }
[data-state="closed"] .when-closed { display: flex; }
[data-state="error"] .when-error { display: block; }

@media (max-width: 760px) {
  .top { padding: 12px 16px; gap: 12px; flex-wrap: wrap; } .summary { display: none; } main { padding: 20px 16px 30px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 22px 14px; } .results { grid-template-columns: 1fr; }
  .subscribe { flex-direction: column; } .foot { padding: 0 16px 24px; }
  .result { flex-wrap: wrap; }
  .top form { margin-left: auto; }
}
