:root {
  --bg: #0c0d10;
  --panel: #15171c;
  --panel-2: #1c1f26;
  --line: #262a33;
  --text: #e8eaf0;
  --muted: #8b93a7;
  --accent: #5b8cff;
  --good: #3fb950;
  --warn: #d29922;
  --bad: #f85149;
  --radius: 12px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
  padding-bottom: 3rem;
}
h2 { font-size: 15px; margin: 0; letter-spacing: .02em; }
h3 { margin: 0 0 .35rem; font-size: 19px; }
button, select, input {
  font: inherit;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: .45rem .7rem;
}
button { cursor: pointer; }
button:hover { border-color: #3a4152; background: #232833; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; min-width: 3.4rem; font-size: 17px; }
button.primary:hover { filter: brightness(1.1); }
.hidden { display: none !important; }

.bar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .75rem 1rem;
  background: rgba(12,13,16,.85);
  backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: .55rem; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--bad); box-shadow: 0 0 0 3px rgba(248,81,73,.15); }
.dot.on { background: var(--good); box-shadow: 0 0 0 3px rgba(63,185,80,.15); }
.bar-meta { display: flex; gap: .5rem; flex-wrap: wrap; }
.pill { font-size: 12px; color: var(--muted); background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: .2rem .6rem; }

.panel {
  margin: 1rem; padding: 1rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.count { color: var(--muted); font-weight: 400; }
.empty { color: var(--muted); margin: .5rem 0 0; }

.now { display: grid; grid-template-columns: 120px 1fr; gap: 1rem; }
.now-art img { width: 120px; aspect-ratio: 2/3; object-fit: cover; border-radius: 9px; background: var(--panel-2); display: block; }
.now-title { font-size: 20px; font-weight: 600; }
.now-sub { color: var(--muted); margin-bottom: .8rem; }
.scrub { display: flex; align-items: center; gap: .6rem; }
.scrub input[type=range] { flex: 1; padding: 0; accent-color: var(--accent); background: none; border: none; }
.time { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 13px; min-width: 3.2rem; }
.time:last-child { text-align: right; }
.controls { display: flex; gap: .5rem; align-items: center; margin-top: .8rem; flex-wrap: wrap; }
.cache { margin-top: .7rem; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }

.peers { display: flex; flex-wrap: wrap; gap: .6rem; }
.peer { background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: .55rem .75rem; min-width: 10rem; }
.peer .n { font-weight: 600; display: flex; align-items: center; gap: .4rem; }
.peer .d { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.peer .tag { font-size: 10px; text-transform: uppercase; letter-spacing: .05em; border: 1px solid var(--line); border-radius: 5px; padding: 0 .3rem; color: var(--muted); }
.drift-ok { color: var(--good); }
.drift-warn { color: var(--warn); }
.drift-bad { color: var(--bad); }

.lib-head { display: flex; gap: .6rem; align-items: center; margin-bottom: .9rem; flex-wrap: wrap; }
.lib-head h2 { margin-right: auto; }
.lib-head input { min-width: 12rem; flex: 1; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: .8rem; }
.card { background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; cursor: pointer; text-align: left; padding: 0; }
.card:hover { border-color: var(--accent); }
.card img { width: 100%; aspect-ratio: 2/3; object-fit: cover; display: block; background: #10131a; }
.card .meta { padding: .5rem .6rem; }
.card .t { font-size: 13px; font-weight: 600; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card .s { font-size: 11px; color: var(--muted); margin-top: .15rem; }
.more { text-align: center; margin-top: 1rem; }

dialog {
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--panel); color: var(--text);
  max-width: 640px; width: calc(100% - 2rem); padding: 1.1rem;
}
dialog::backdrop { background: rgba(0,0,0,.65); backdrop-filter: blur(3px); }
.detail-head { display: grid; grid-template-columns: 92px 1fr auto; gap: 1rem; margin-bottom: 1rem; }
.detail-head img { width: 92px; aspect-ratio: 2/3; object-fit: cover; border-radius: 8px; background: var(--panel-2); }
.detail-head p { color: var(--muted); font-size: 13px; margin: 0; max-height: 7.5em; overflow: auto; }
.close { border: none; background: none; color: var(--muted); font-size: 18px; align-self: start; }
.episodes { display: flex; flex-direction: column; gap: .35rem; max-height: 55vh; overflow: auto; }
.ep { display: flex; align-items: center; gap: .6rem; text-align: left; width: 100%; }
.ep .num { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 12px; min-width: 3.4rem; }
.ep.playing { border-color: var(--accent); color: var(--accent); }

.toast {
  position: fixed; left: 50%; bottom: 1.5rem; transform: translate(-50%, 200%);
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px;
  padding: .6rem 1rem; transition: transform .25s ease; z-index: 20; max-width: 90vw;
}
.toast.show { transform: translate(-50%, 0); }
.toast.bad { border-color: var(--bad); color: var(--bad); }

@media (max-width: 560px) {
  .now { grid-template-columns: 84px 1fr; }
  .now-art img { width: 84px; }
  .panel { margin: .6rem; }
}
