:root {
  --bg: #0b1222;
  --bg-2: #121b30;
  --bg-3: #1a2540;
  --line: #23304d;
  --text: #eef0f6;
  --muted: #93a0bd;
  --faint: #5f6c8a;
  --accent: #5b9bff;
  --accent-ink: #07122b;
  --good: #4fd1a1;
  --bad: #ff6b6b;
  --radius: 12px;
  --shadow: 0 10px 30px rgba(0,0,0,.35);
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text); font-family: var(--font);
  font-size: 15px; line-height: 1.5; min-height: 100vh; display: flex; flex-direction: column; overflow-x: hidden;
}
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; color: inherit; }
img { display: block; max-width: 100%; }
.muted { color: var(--muted); }
.hidden { display: none !important; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: rgba(11,18,34,.85); backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: 1200px; margin: 0 auto; padding: 10px 20px;
  display: flex; align-items: center; gap: 22px;
}
.logo { display: flex; align-items: center; gap: 9px; white-space: nowrap; }
.logo svg { width: 28px; height: 28px; flex: none; }
.logo-word { font-family: 'Bricolage Grotesque', ui-sans-serif, system-ui, sans-serif; font-weight: 800; font-size: 22px; letter-spacing: -0.04em; line-height: 1; }
.mainnav { display: flex; gap: 4px; }
.mainnav a { padding: 7px 12px; border-radius: 8px; color: var(--muted); font-weight: 600; font-size: 14px; }
.mainnav a:hover { color: var(--text); background: var(--bg-2); }
.mainnav a.active { color: var(--text); background: var(--bg-3); }
.search { flex: 1; max-width: 380px; margin-left: auto; }
.search input {
  width: 100%; padding: 9px 14px 9px 36px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--bg-2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%239097ab' stroke-width='2' viewBox='0 0 24 24'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E") no-repeat 13px center;
  outline: none; transition: border-color .15s;
}
.search input:focus { border-color: var(--accent); }
.account { display: flex; align-items: center; gap: 8px; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; background: var(--bg-3); border: 1px solid var(--line);
  display: grid; place-items: center; font-weight: 700; font-size: 14px;
}

/* ---------- buttons & forms ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 16px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg-2);
  font-weight: 600; font-size: 14px; cursor: pointer; transition: background .15s, border-color .15s, transform .05s;
  white-space: nowrap;
}
.btn:hover { background: var(--bg-3); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { background: transparent; }
.btn.danger { border-color: rgba(255,107,107,.4); color: var(--bad); background: transparent; }
.btn.small { padding: 6px 11px; font-size: 13px; border-radius: 8px; }
.btn.on { background: rgba(79,209,161,.12); border-color: rgba(79,209,161,.45); color: var(--good); }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 13px; color: var(--muted); font-weight: 600; }
.field input, select.input {
  padding: 11px 13px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg-2); outline: none;
}
.field input:focus, select.input:focus { border-color: var(--accent); }
.form-error { color: var(--bad); font-size: 14px; min-height: 20px; margin: 0 0 8px; }

/* ---------- layout ---------- */
.app { flex: 1; width: 100%; max-width: 1200px; margin: 0 auto; padding: 28px 20px 60px; outline: none; }
.section { margin-bottom: 40px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
h1 { font-size: 30px; letter-spacing: -.02em; margin: 0 0 6px; line-height: 1.15; }
h2 { font-size: 20px; letter-spacing: -.01em; margin: 0; }
h3 { font-size: 16px; margin: 0; }
.page-title { margin-bottom: 22px; }

.grid {
  display: grid; gap: 18px 14px;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
}
.card { position: relative; display: block; }
.poster {
  aspect-ratio: 2 / 3; border-radius: 10px; overflow: hidden; background: var(--bg-3);
  box-shadow: 0 4px 14px rgba(0,0,0,.3); position: relative;
}
.poster img { width: 100%; height: 100%; object-fit: cover; transition: transform .25s; }
.card:hover .poster img { transform: scale(1.04); }
.poster .noimg { position: absolute; inset: 0; display: grid; place-items: center; padding: 10px; text-align: center; color: var(--faint); font-size: 13px; }
.card-title { font-weight: 600; font-size: 14px; margin-top: 8px; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-sub { font-size: 12.5px; color: var(--muted); }
.badge {
  position: absolute; top: 8px; left: 8px; padding: 2px 8px; border-radius: 6px; font-size: 11px; font-weight: 700;
  background: rgba(11,18,34,.82); backdrop-filter: blur(4px); text-transform: uppercase; letter-spacing: .04em;
}
.badge.tracked { left: auto; right: 8px; background: var(--accent); color: var(--accent-ink); }
.progress { height: 4px; border-radius: 4px; background: var(--bg-3); overflow: hidden; margin-top: 7px; }
.progress > span { display: block; height: 100%; background: var(--accent); border-radius: 4px; }
.progress.big { height: 8px; }

/* horizontal rows */
.row { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(140px, 160px); gap: 14px; overflow-x: auto; padding-bottom: 8px; scroll-snap-type: x proximity; }
.row > * { scroll-snap-align: start; }
.row::-webkit-scrollbar { height: 6px; } .row::-webkit-scrollbar-thumb { background: var(--line); border-radius: 6px; }

/* up next cards */
.upnext { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 14px; }
.un-card {
  display: flex; gap: 14px; background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px; align-items: center;
}
.un-card .thumb { width: 64px; flex: none; aspect-ratio: 2/3; border-radius: 8px; overflow: hidden; background: var(--bg-3); }
.un-card .thumb img { width: 100%; height: 100%; object-fit: cover; }
.un-card .info { flex: 1; min-width: 0; }
.un-card .name { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.un-card .ep { color: var(--accent); font-weight: 700; font-size: 13px; }
.un-card .left { color: var(--muted); font-size: 12.5px; }
.check-btn {
  width: 42px; height: 42px; border-radius: 50%; border: 2px solid var(--line); background: transparent; cursor: pointer;
  display: grid; place-items: center; flex: none; transition: all .15s; color: var(--muted);
}
.check-btn:hover { border-color: var(--good); color: var(--good); }
.check-btn.done { background: var(--good); border-color: var(--good); color: #062418; }

/* hero */
.hero {
  border-radius: 20px; padding: 56px 40px; margin-bottom: 40px; position: relative; overflow: hidden;
  background: radial-gradient(1200px 400px at 0% 0%, rgba(91,155,255,.20), transparent 60%), var(--bg-2);
  border: 1px solid var(--line);
}
.hero h1 { font-size: 42px; max-width: 640px; }
.hero p { color: var(--muted); font-size: 17px; max-width: 560px; margin: 10px 0 24px; }
.hero .actions { display: flex; gap: 10px; flex-wrap: wrap; }
.points { display: flex; gap: 22px; flex-wrap: wrap; margin-top: 28px; color: var(--muted); font-size: 14px; }
.points span::before { content: "✓ "; color: var(--good); font-weight: 700; }

/* detail page */
.detail-hero { position: relative; margin: -28px calc(50% - 50vw) 28px; padding: 40px 20px 30px; overflow: hidden; }
.detail-hero .bd { position: absolute; inset: 0; background-size: cover; background-position: center 25%; opacity: .28; }
.detail-hero .bd::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(11,18,34,.3), var(--bg) 92%); }
.detail-inner { position: relative; max-width: 1160px; margin: 0 auto; display: flex; gap: 30px; align-items: flex-end; }
.detail-poster { width: 210px; flex: none; }
.detail-meta { flex: 1; min-width: 0; padding-bottom: 6px; }
.detail-meta h1 { font-size: 36px; }
.meta-line { color: var(--muted); font-size: 14px; display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.meta-line span + span::before { content: "·"; margin-right: 8px; color: var(--faint); }
.overview { color: #cdd1de; max-width: 760px; margin: 0 0 18px; }
.actions-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.status-pill { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.status-pill button { border: 0; background: var(--bg-2); padding: 9px 13px; font-weight: 600; font-size: 13.5px; cursor: pointer; color: var(--muted); }
.status-pill button + button { border-left: 1px solid var(--line); }
.status-pill button:hover { color: var(--text); background: var(--bg-3); }
.status-pill button.sel { background: var(--accent); color: var(--accent-ink); }
.progress-box { margin-top: 18px; max-width: 520px; }
.progress-box .pl { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); margin-bottom: 6px; }

/* seasons */
.season { border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg-2); margin-bottom: 10px; overflow: hidden; }
.season-head { display: flex; align-items: center; gap: 14px; padding: 14px 16px; cursor: pointer; user-select: none; }
.season-head:hover { background: var(--bg-3); }
.season-head .chev { transition: transform .2s; color: var(--muted); }
.season.open .season-head .chev { transform: rotate(90deg); }
.season-head .sname { font-weight: 700; flex: 1; }
.season-head .scount { color: var(--muted); font-size: 13px; }
.season-head .progress { width: 110px; margin: 0; }
.episodes { border-top: 1px solid var(--line); }
.ep-row { display: flex; gap: 14px; padding: 12px 16px; align-items: flex-start; }
.ep-row + .ep-row { border-top: 1px solid var(--line); }
.ep-row .still { width: 150px; flex: none; aspect-ratio: 16/9; border-radius: 8px; overflow: hidden; background: var(--bg-3); }
.ep-row .still img { width: 100%; height: 100%; object-fit: cover; }
.ep-row .ep-info { flex: 1; min-width: 0; }
.ep-row .ep-title { font-weight: 600; }
.ep-row .ep-num { color: var(--accent); font-weight: 700; margin-right: 6px; }
.ep-row .ep-sub { font-size: 12.5px; color: var(--muted); }
.ep-row .ep-over { font-size: 13.5px; color: #b9bfcf; margin-top: 4px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.ep-row.unaired { opacity: .5; }
.ep-row .upto { font-size: 12px; color: var(--muted); background: none; border: 0; padding: 0; cursor: pointer; margin-top: 6px; text-decoration: underline; text-underline-offset: 2px; }
.ep-row .upto:hover { color: var(--text); }

/* tabs */
.tabs { display: flex; gap: 6px; margin-bottom: 20px; flex-wrap: wrap; }
.tabs button { border: 1px solid var(--line); background: transparent; padding: 7px 14px; border-radius: 999px; cursor: pointer; font-weight: 600; font-size: 13.5px; color: var(--muted); }
.tabs button .n { opacity: .7; margin-left: 4px; }
.tabs button.sel { background: var(--text); color: var(--bg); border-color: var(--text); }

/* auth */
.btn.google { width: 100%; background: #fff; color: #1f1f1f; border-color: #fff; padding: 11px 16px; }
.btn.google:hover { background: #f1f1f1; }
.or { display: flex; align-items: center; gap: 12px; color: var(--faint); font-size: 12.5px; margin: 18px 0; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.auth-box { max-width: 400px; margin: 30px auto; background: var(--bg-2); border: 1px solid var(--line); border-radius: 18px; padding: 32px; }
.auth-box h1 { font-size: 26px; }
.auth-box .switch { text-align: center; color: var(--muted); font-size: 14px; margin-top: 16px; }
.auth-box .switch a { color: var(--accent); font-weight: 600; }

.panel { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; margin-bottom: 16px; max-width: 640px; }
.panel h2 { margin-bottom: 6px; }
.panel p { color: var(--muted); margin: 0 0 14px; font-size: 14px; }

.empty { text-align: center; padding: 50px 20px; color: var(--muted); border: 1px dashed var(--line); border-radius: var(--radius); }
.empty h3 { color: var(--text); margin-bottom: 6px; }
.empty .btn { margin-top: 14px; }

.skeleton { background: linear-gradient(90deg, var(--bg-2), var(--bg-3), var(--bg-2)); background-size: 200% 100%; animation: sh 1.3s infinite; border-radius: 10px; }
@keyframes sh { to { background-position: -200% 0; } }

.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 10px; font-weight: 600; font-size: 14px;
  transition: all .2s; z-index: 50; box-shadow: var(--shadow);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--bad); color: #fff; }

.footer { border-top: 1px solid var(--line); padding: 26px 20px 90px; text-align: center; font-size: 12.5px; color: var(--muted); }
.footer p { margin: 6px auto; max-width: 620px; }
.tmdb-logo { display: inline-block; opacity: .8; } .tmdb-logo:hover { opacity: 1; }

.tabbar { display: none; }

/* ---------- mobile ---------- */
@media (max-width: 760px) {
  .mainnav { display: none; }
  .topbar-inner { gap: 12px; padding: 10px 14px; }
  .logo-word { display: none; }
  .search { max-width: none; }
  .app { padding: 20px 14px 40px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 14px 10px; }
  .hero { padding: 34px 22px; } .hero h1 { font-size: 30px; }
  .detail-hero { margin: -20px calc(50% - 50vw) 20px; padding: 24px 14px 20px; }
  .detail-inner { flex-direction: column; align-items: flex-start; gap: 18px; }
  .detail-poster { width: 130px; }
  .detail-meta h1 { font-size: 26px; }
  .ep-row .still { width: 104px; }
  .season-head .progress { display: none; }
  .tabbar {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
    background: rgba(11,18,34,.94); backdrop-filter: blur(14px); border-top: 1px solid var(--line);
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
  }
  .tabbar a { flex: 1; text-align: center; font-size: 11px; font-weight: 600; color: var(--muted); padding: 6px 0; display: flex; flex-direction: column; align-items: center; gap: 2px; }
  .tabbar a.active { color: var(--accent); }
  .tabbar svg { width: 22px; height: 22px; }
  .status-pill button { padding: 8px 10px; font-size: 12.5px; }
}
