:root {
  --bg: #07070c;
  --surface: #111118;
  --hover: #1a1a24;
  --border: #272733;
  --primary: #7c6cf0;
  --accent: #2dd4bf;
  --muted: #8b8b9a;
  --fg: #f2f2f7;
  --danger: #f87171;
  --radius: 1rem;
}
* { box-sizing: border-box; }
html { color-scheme: dark; }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--fg);
  font-family: ui-sans-serif, system-ui, -apple-system, sans-serif;
}
.bg-mesh {
  background-image:
    radial-gradient(ellipse 80% 50% at 50% -20%, color-mix(in srgb, var(--primary) 18%, transparent), transparent),
    radial-gradient(ellipse 60% 40% at 100% 0%, color-mix(in srgb, var(--accent) 10%, transparent), transparent);
}
.gradient {
  background: linear-gradient(135deg, #a78bfa, #7c6cf0 40%, #2dd4bf);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.top, .foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 72rem;
  margin: 0 auto;
  padding: 1.25rem 1.5rem;
  gap: 1rem;
}
.foot { justify-content: center; gap: 1.5rem; font-size: .85rem; }
.foot a, .muted a { color: var(--muted); }
.brand { display: flex; align-items: center; gap: .7rem; font-size: 1.35rem; }
.logo {
  width: 2.25rem; height: 2.25rem; border-radius: .75rem;
  display: grid; place-items: center;
  background: color-mix(in srgb, var(--primary) 20%, transparent);
  color: var(--primary); font-size: .9rem;
}
.hero { text-align: center; max-width: 48rem; margin: 2rem auto 0; padding: 0 1.5rem; }
.hero h1 { font-size: clamp(2rem, 6vw, 3.5rem); line-height: 1.1; }
.lead { color: var(--muted); font-size: 1.1rem; }
.pill {
  display: inline-flex; gap: .4rem; align-items: center;
  border: 1px solid var(--border); background: color-mix(in srgb, var(--surface) 80%, transparent);
  border-radius: 999px; padding: .4rem .9rem; font-size: .85rem; color: var(--muted);
}
.auth-wrap { max-width: 24rem; margin: 3rem auto; padding: 0 1.5rem 3rem; }
.login-page {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
}
.login-shell { width: min(100%, 22rem); }
.login-brand { justify-content: center; margin-bottom: 1.25rem; }
.login-card h1 { margin: 0 0 .35rem; font-size: 1.35rem; }
.login-lead { margin: 0 0 1rem; }
.login-card .btn.primary:disabled { opacity: .65; cursor: wait; }
.card {
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  border: 1px solid var(--border); border-radius: var(--radius); padding: 1.5rem;
}
label { display: block; margin: .75rem 0; font-size: .9rem; color: var(--muted); }
input, select {
  width: 100%; margin-top: .35rem; padding: .7rem .8rem;
  border-radius: .7rem; border: 1px solid var(--border);
  background: var(--bg); color: var(--fg); font: inherit;
}
.check { display: flex; gap: .5rem; align-items: flex-start; }
.check input { width: auto; margin: .2rem 0 0; }
.btn {
  border: 1px solid var(--border); background: var(--surface); color: var(--fg);
  border-radius: .8rem; padding: .7rem 1.1rem; font: inherit; cursor: pointer;
}
.btn.primary { background: var(--primary); border-color: transparent; width: 100%; margin-top: .5rem; }
.btn.ghost { background: transparent; }
.btn:hover { filter: brightness(1.08); }
.link { background: none; border: 0; color: var(--accent); cursor: pointer; font: inherit; padding: 0; }
.err { color: var(--danger); font-size: .9rem; }
.muted { color: var(--muted); font-size: .9rem; }
.app { display: grid; grid-template-columns: 14rem 1fr; min-height: 100dvh; }
.nav {
  border-right: 1px solid var(--border); padding: 1.2rem .8rem;
  display: flex; flex-direction: column; gap: .5rem;
}
.nav nav { display: flex; flex-direction: column; gap: .25rem; margin-top: 1rem; }
.nav nav button {
  text-align: left; background: transparent; border: 0; color: var(--muted);
  padding: .65rem .8rem; border-radius: .7rem; font: inherit; cursor: pointer;
}
.nav nav button.active, .nav nav button:hover { background: var(--hover); color: var(--fg); }
.nav-foot { margin-top: auto; display: flex; flex-direction: column; gap: .5rem; }
.view[hidden] { display: none !important; }
main {
  min-width: 0;
  overflow-x: clip;
  padding: 1.25rem 1.5rem 2rem;
}
.view h2 { margin: 1.1rem 0 .65rem; font-size: 1.15rem; }
.player-wrap {
  position: relative; background: #000; border-radius: 1rem; overflow: hidden;
  aspect-ratio: 16/9; max-height: 28rem; margin-bottom: 1.25rem;
}
.player-wrap .err {
  position: absolute; left: .75rem; right: .75rem; bottom: .75rem;
  margin: 0; padding: .5rem .7rem; border-radius: .6rem;
  background: color-mix(in srgb, #000 70%, transparent);
  pointer-events: none;
}
video { width: 100%; height: 100%; background: #000; }
.player-wrap .empty {
  position: absolute; inset: 0; display: grid; place-items: center;
  margin: 0; color: var(--muted); pointer-events: none;
}
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .75rem; margin-bottom: 1.5rem; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: .9rem; padding: 1rem; }
.stat b { display: block; font-size: 1.4rem; }
.toolbar { display: flex; gap: .6rem; margin-bottom: 1rem; flex-wrap: wrap; }
.toolbar input, .toolbar select { margin: 0; min-width: 0; flex: 1 1 10rem; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr)); gap: .75rem; }
.ch {
  background: var(--surface); border: 1px solid var(--border); border-radius: .9rem;
  padding: .8rem; cursor: pointer; text-align: left; color: inherit;
  display: flex; flex-direction: column; gap: .4rem; min-height: 6rem; min-width: 0;
}
.ch:hover { background: var(--hover); }
.ch img { width: 2.4rem; height: 2.4rem; object-fit: contain; }
.ch .name { font-weight: 600; overflow-wrap: anywhere; }
.ch .meta { font-size: .75rem; color: var(--muted); overflow-wrap: anywhere; }
.heart { align-self: flex-end; background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 1rem; }
.heart.on { color: #fb7185; }
.playlist-row {
  display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  padding: .8rem 0; border-bottom: 1px solid var(--border); min-width: 0;
}
.playlist-row > div:first-child { min-width: 0; overflow-wrap: anywhere; }
.playlist-actions { display: flex; gap: .4rem; flex-shrink: 0; flex-wrap: wrap; }
.guide-list { display: flex; flex-direction: column; gap: .75rem; }
.guide-row {
  display: grid; grid-template-columns: 11rem 1fr; gap: 1rem;
  padding: .85rem 1rem; background: var(--surface); border: 1px solid var(--border);
  border-radius: .9rem;
}
.guide-when { color: var(--muted); font-size: .85rem; }
.guide-desc { margin: .35rem 0 0; color: var(--muted); font-size: .9rem; }
.plain { padding-left: 1.2rem; line-height: 1.6; }
.legal { max-width: 40rem; margin: 0 auto; padding: 2rem 1.5rem; line-height: 1.6; }
.legal a { color: var(--accent); }
@media (max-width: 800px) {
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr auto;
    min-height: 100dvh;
  }
  main {
    order: 1;
    overflow-y: auto;
    padding: 1rem 1rem 1.25rem;
  }
  .nav {
    order: 2;
    position: sticky;
    bottom: 0;
    z-index: 30;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    gap: .35rem;
    padding: .4rem .45rem calc(.4rem + env(safe-area-inset-bottom, 0px));
    border-right: 0;
    border-top: 1px solid var(--border);
    background: color-mix(in srgb, var(--bg) 92%, transparent);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
  }
  .nav .brand { gap: .45rem; font-size: 1rem; flex-shrink: 0; }
  .nav .brand .gradient { display: none; }
  .nav .logo { width: 2rem; height: 2rem; border-radius: .65rem; font-size: .8rem; }
  .nav nav {
    flex-direction: row;
    flex-wrap: nowrap;
    margin: 0;
    flex: 1;
    min-width: 0;
    gap: .15rem;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .nav nav::-webkit-scrollbar { display: none; }
  .nav nav button {
    flex: 0 0 auto;
    white-space: nowrap;
    padding: .55rem .7rem;
    font-size: .82rem;
  }
  .nav-foot {
    flex-direction: row;
    margin: 0;
    align-items: center;
    flex-shrink: 0;
    gap: .25rem;
  }
  .nav-foot #who {
    display: none;
  }
  .nav-foot .btn {
    padding: .55rem .7rem;
    font-size: .82rem;
  }
  .player-wrap { max-height: none; border-radius: .75rem; }
  .guide-row { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .toolbar { flex-direction: column; }
  .toolbar input, .toolbar select { flex: 1 1 auto; width: 100%; }
}

@media (max-width: 380px) {
  main { padding: .7rem .65rem 1rem; }
  .card { padding: 1rem; }
  .stats { gap: .45rem; }
  .stat { padding: .65rem; }
  .stat b { font-size: 1.15rem; }
  .stat span { font-size: .78rem; }
  .grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: .45rem;
  }
  .ch { min-height: 5rem; padding: .6rem; gap: .3rem; }
  .ch img { width: 2rem; height: 2rem; }
  .ch .name { font-size: .86rem; line-height: 1.25; }
  .playlist-row {
    flex-direction: column;
    align-items: stretch;
    gap: .55rem;
  }
  .playlist-actions { width: 100%; }
  .playlist-actions .btn { flex: 1 1 auto; }
  .login-page { padding: .85rem; }
  .login-card h1 { font-size: 1.2rem; }
  .btn { padding: .65rem .9rem; }
}
