:root {
  --bg: #f6f7fb; --surface: #fff; --text: #14151a; --muted: #6b7080; --line: #e6e8f0;
  --accent: #4f46e5; --accent-weak: #eef0ff; --ok: #0f9d6b; --ok-weak: #e3f6ee; --warn-weak: #f1f2f6;
  --danger: #d33a3a; --radius: 14px; --shadow: 0 1px 2px rgba(20,21,26,.05), 0 8px 24px rgba(20,21,26,.06);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e0f14; --surface: #171923; --text: #eceef5; --muted: #9096aa; --line: #262938;
    --accent: #7c83ff; --accent-weak: #232650; --ok: #3ccf98; --ok-weak: #12332a; --warn-weak: #222534;
    --danger: #ff6b6b; --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.35);
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
.hidden { display: none !important; }

/* layout */
.topbar {
  position: sticky; top: 0; z-index: 10; background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
}
.topbar-inner { max-width: 1100px; margin: 0 auto; padding: 12px 16px; display: flex; align-items: center; gap: 16px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: -.01em; }
.logo { width: 30px; height: 30px; border-radius: 9px; background: var(--accent); display: grid; place-items: center; color: #fff; }
.nav { display: flex; gap: 4px; margin-left: 12px; }
.nav a { padding: 7px 12px; border-radius: 9px; color: var(--muted); text-decoration: none; font-weight: 500; }
.nav a.active { background: var(--accent-weak); color: var(--accent); }
.spacer { flex: 1; }
main { max-width: 1100px; margin: 0 auto; padding: 24px 16px 140px; }
h1 { font-size: 26px; letter-spacing: -.02em; margin: 0; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.sub { color: var(--muted); margin: 2px 0 0; }

/* controls */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--line);
  background: var(--surface); padding: 9px 14px; border-radius: 10px; cursor: pointer; font-weight: 600; min-height: 40px;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--danger); }
.btn.sm { padding: 5px 10px; min-height: 32px; font-size: 13px; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.icon { width: 18px; height: 18px; fill: currentColor; flex: none; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 99px; background: var(--warn-weak); color: var(--muted); }
.pill.live { background: var(--ok-weak); color: var(--ok); }
.pill.live::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--ok); }
.tag { font-size: 12px; color: var(--muted); border: 1px solid var(--line); border-radius: 6px; padding: 1px 7px; text-transform: capitalize; }

/* stats */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 20px; }
.stat { padding: 16px; }
.stat b { font-size: 24px; letter-spacing: -.02em; display: block; }
.stat span { color: var(--muted); font-size: 13px; }

/* episode list */
.list { overflow: hidden; }
.ep { display: grid; grid-template-columns: 56px 1fr 90px 110px 90px auto; gap: 16px; align-items: center; padding: 14px 16px; border-top: 1px solid var(--line); }
.ep:first-child { border-top: 0; }
.ep.head { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; font-weight: 600; padding: 10px 16px; background: color-mix(in srgb, var(--bg) 60%, var(--surface)); }
.art { width: 56px; height: 56px; border-radius: 10px; background: var(--accent-weak); object-fit: cover; display: grid; place-items: center; color: var(--accent); overflow: hidden; position: relative; cursor: pointer; border: 0; padding: 0; }
.art img { width: 100%; height: 100%; object-fit: cover; }
.art .play { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(0,0,0,.35); color: #fff; opacity: 0; transition: opacity .15s; }
.art:hover .play, .art.playing .play { opacity: 1; }
.ep-title { font-weight: 600; overflow: hidden; }
.ep-title .t { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.ep-meta { color: var(--muted); font-size: 13px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 2px; }
.num { font-variant-numeric: tabular-nums; }
.actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
.info { display: contents; }
.col-label { display: none; }
.empty { padding: 56px 20px; text-align: center; color: var(--muted); }
.empty h3 { color: var(--text); margin: 8px 0 4px; }

/* forms / modal */
.overlay { position: fixed; inset: 0; background: rgba(10,11,16,.5); z-index: 30; display: grid; place-items: center; padding: 16px; }
.modal { width: min(640px, 100%); max-height: calc(100dvh - 32px); overflow: auto; padding: 24px; }
.modal h2 { margin: 0 0 16px; letter-spacing: -.01em; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-weight: 600; font-size: 13px; }
.field small { color: var(--muted); }
input[type=text], input[type=number], input[type=email], input[type=datetime-local], select, textarea {
  width: 100%; border: 1px solid var(--line); background: var(--bg); border-radius: 10px; padding: 10px 12px; min-height: 42px; font-size: 16px;
}
textarea { min-height: 120px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.drop { border: 1.5px dashed var(--line); border-radius: 12px; padding: 14px; display: flex; align-items: center; gap: 14px; background: var(--bg); }
.drop input[type=file] { flex: 1; min-width: 0; font-size: 14px; }
.preview { width: 64px; height: 64px; border-radius: 10px; object-fit: cover; background: var(--accent-weak); flex: none; }
.foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; align-items: center; }
.err { color: var(--danger); font-size: 14px; margin-right: auto; }
.progress { height: 6px; border-radius: 6px; background: var(--line); overflow: hidden; margin-top: 12px; }
.progress > div { height: 100%; width: 0; background: var(--accent); transition: width .2s; }

/* settings */
.feedbox { display: flex; gap: 8px; }
.feedbox input { flex: 1; font-family: ui-monospace, Menlo, monospace; font-size: 14px; }
.dirs { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; margin-top: 12px; }
.dir { padding: 14px; text-decoration: none; color: var(--text); display: block; }
.dir:hover { border-color: var(--accent); }
.dir b { display: block; } .dir span { color: var(--muted); font-size: 13px; }

/* player */
.player {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: var(--surface); border-top: 1px solid var(--line);
  box-shadow: 0 -8px 24px rgba(0,0,0,.08); padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
}
.player-inner { max-width: 1100px; margin: 0 auto; display: grid; grid-template-columns: minmax(0, 260px) auto 1fr; gap: 16px; align-items: center; }
.pt { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-weight: 600; }
.pc { display: flex; gap: 6px; align-items: center; }
.pb { border: 0; background: var(--accent-weak); color: var(--accent); width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; cursor: pointer; }
.pb.plain { background: transparent; color: var(--text); width: 38px; height: 38px; font-size: 11px; font-weight: 700; }
.seek { display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.seek input[type=range] { flex: 1; accent-color: var(--accent); min-height: 0; padding: 0; border: 0; background: none; }

/* login */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 16px; }
.login .card { padding: 32px; width: min(400px, 100%); text-align: center; }
.login .logo { width: 52px; height: 52px; border-radius: 16px; margin: 0 auto 16px; }
.login h1 { font-size: 24px; }
.sso { display: flex; flex-direction: column; gap: 10px; margin-top: 24px; }
.sso .btn { width: 100%; min-height: 46px; }
.login .err { display: block; margin: 12px 0 0; }

#toast { position: fixed; left: 50%; bottom: 90px; transform: translate(-50%, 20px); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; opacity: 0; transition: .25s; pointer-events: none; z-index: 50; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* mobile */
@media (max-width: 760px) {
  .ep { grid-template-columns: 56px 1fr; grid-template-areas: "art title" "info info" "act act"; gap: 10px 12px; }
  .ep.head { display: none; }
  .ep .art { grid-area: art; }
  .ep .ep-title { grid-area: title; }
  .ep .info { grid-area: info; display: flex; gap: 14px; flex-wrap: wrap; color: var(--muted); font-size: 13px; }
  .ep .info > * { display: inline-flex; gap: 4px; }
  .ep .actions { grid-area: act; justify-content: flex-start; }
  .col-label { display: inline; }
  .row { grid-template-columns: 1fr; }
  .nav { margin-left: 0; }
  .brand span { display: none; }
  .stats { gap: 8px; } .stat { padding: 12px; } .stat b { font-size: 20px; }
  .player-inner { grid-template-columns: 1fr auto; row-gap: 6px; }
  .seek { grid-column: 1 / -1; }
  .overlay { align-items: end; padding: 0; }
  .modal { border-radius: 18px 18px 0 0; max-height: 94dvh; width: 100%; }
}
