:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --card: #ffffff;
  --text: #14161c;
  --muted: #5b6170;
  --accent: #c8102e;
  --accent-hover: #a50d25;
  --accent-text: #ffffff;
  --line: #e3e5ec;
  --hero-from: #1b1f2a;
  --hero-to: #3a0d17;
  --ok: #1f8a4c;
  --error: #b3261e;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 22, 28, 0.06), 0 6px 20px rgba(20, 22, 28, 0.06);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0c0e13;
    --surface: #12151c;
    --card: #181c25;
    --text: #eceef3;
    --muted: #9aa0ad;
    --accent: #e0344a;
    --accent-hover: #f0506a;
    --accent-text: #ffffff;
    --line: #272c37;
    --hero-from: #0c0e13;
    --hero-to: #2b0a12;
    --ok: #4cc27f;
    --error: #ff8a80;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.35);
  }
}

:root[data-theme="dark"] {
  --bg: #0c0e13;
  --surface: #12151c;
  --card: #181c25;
  --text: #eceef3;
  --muted: #9aa0ad;
  --accent: #e0344a;
  --accent-hover: #f0506a;
  --accent-text: #ffffff;
  --line: #272c37;
  --hero-from: #0c0e13;
  --hero-to: #2b0a12;
  --ok: #4cc27f;
  --error: #ff8a80;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
img { max-width: 100%; }
a { color: var(--accent); }
h1, h2, h3 { line-height: 1.2; margin: 0; }
p { margin: 0; }
section[id] { scroll-margin-top: 72px; }

.wrap { width: min(1080px, 100% - 32px); margin: 0 auto; }

/* ---------- Header ---------- */
.site-header {
  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);
}
.header-inner { display: flex; align-items: center; gap: 16px; min-height: 60px; flex-wrap: wrap; }
.brand { font-weight: 800; font-size: 1.1rem; color: var(--text); text-decoration: none; letter-spacing: -0.01em; }
.brand span { color: var(--accent); }
.site-nav { display: flex; gap: 18px; flex-wrap: wrap; }
.site-nav a { color: var(--muted); text-decoration: none; font-size: 0.95rem; }
.site-nav a:hover { color: var(--text); }
.account-bar { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.user-email { color: var(--muted); font-size: 0.875rem; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Buttons & inputs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-weight: 600; text-decoration: none;
  padding: 11px 18px; border-radius: 10px; border: 1px solid var(--accent);
  background: var(--accent); color: var(--accent-text); cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.btn:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn:disabled { opacity: 0.6; cursor: default; }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--line); }
.btn-ghost:hover { background: var(--card); border-color: var(--muted); }
.btn-small { padding: 7px 12px; font-size: 0.875rem; border-radius: 8px; }
.btn-block { width: 100%; }
.link {
  background: none; border: none; padding: 0; color: var(--accent);
  font: inherit; font-size: 0.9rem; cursor: pointer;
}
.link:hover { text-decoration: underline; }

input, select {
  font: inherit; color: var(--text); background: var(--bg);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; width: 100%;
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
label > span { display: block; font-size: 0.85rem; color: var(--muted); margin-bottom: 5px; }

.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow);
}
.eyebrow {
  font-size: 0.8rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent);
}
.muted { color: var(--muted); }
.msg { min-height: 1.4em; font-size: 0.9rem; }
.msg.error { color: var(--error); }
.msg.info { color: var(--ok); }

/* ---------- Hero ---------- */
.hero {
  background:
    radial-gradient(1200px 400px at 85% -10%, color-mix(in srgb, var(--accent) 28%, transparent), transparent 60%),
    linear-gradient(160deg, var(--hero-from), var(--hero-to));
  color: #f5f5f7;
  padding: 72px 0 80px;
}
.hero .eyebrow { color: #ff6b7f; }
.hero-grid {
  display: grid; grid-template-columns: 1.15fr 1fr; gap: 48px; align-items: center;
}
.hero h1 { font-size: clamp(2rem, 4.5vw, 3.2rem); font-weight: 800; letter-spacing: -0.02em; margin: 10px 0 16px; }
.lead { font-size: 1.1rem; color: #c9ccd6; max-width: 52ch; }
.countdown { display: flex; align-items: baseline; gap: 12px; margin: 28px 0; }
.countdown-num { font-size: clamp(3rem, 7vw, 4.5rem); font-weight: 800; line-height: 1; color: #fff; }
.countdown-label { color: #c9ccd6; font-size: 1.1rem; }
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; }
.hero .btn-ghost { color: #fff; border-color: rgba(255, 255, 255, 0.3); background: transparent; }
.hero .btn-ghost:hover { background: rgba(255, 255, 255, 0.08); }
.hero .card { color: var(--text); }
.hero-side { width: 100%; max-width: 420px; justify-self: end; }

.auth-card h2 { font-size: 1.4rem; margin-bottom: 6px; }
.auth-card .muted { margin-bottom: 18px; font-size: 0.95rem; }
.form { display: grid; gap: 14px; }
.auth-links { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; margin-top: 14px; }

.summary { display: grid; gap: 12px; }
.summary-pct { font-size: 3rem; font-weight: 800; line-height: 1; }
.bar { height: 10px; border-radius: 999px; background: var(--line); overflow: hidden; }
#progress-bar { height: 100%; width: 0; background: var(--ok); transition: width 0.4s ease; }
.next-line { font-size: 1rem; }

/* ---------- Sections ---------- */
.section { padding: 64px 0; }
.section + .section { border-top: 1px solid var(--line); }
.section-title { font-size: clamp(1.5rem, 3vw, 1.9rem); font-weight: 800; letter-spacing: -0.01em; margin-bottom: 20px; }
.section-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.section-head .section-title { margin-bottom: 6px; }
.count { color: var(--muted); font-weight: 500; font-size: 1rem; }

.features { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.feature h3 { font-size: 1.1rem; margin: 10px 0 8px; }
.feature-num {
  display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 50%;
  background: var(--accent); color: #fff; font-weight: 700;
}

.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.stat { display: grid; gap: 4px; padding: 18px; }
.stat span { font-size: 1.9rem; font-weight: 800; }
.stat small { color: var(--muted); }

/* ---------- Route ---------- */
.route-list { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.route-item {
  display: grid; grid-template-columns: 52px 1fr; gap: 12px; align-items: center;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px;
}
.route-item.is-next { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.route-item .poster { width: 52px; height: 78px; }
.route-item h3 { font-size: 0.98rem; }
.route-num { font-size: 0.8rem; color: var(--muted); }
.empty-note { color: var(--muted); padding: 24px 0; }

/* ---------- Library ---------- */
.toolbar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  font: inherit; font-size: 0.9rem; padding: 7px 14px; border-radius: 999px; cursor: pointer;
  background: transparent; color: var(--text); border: 1px solid var(--line);
}
.chip.on { background: var(--text); color: var(--bg); border-color: var(--text); }
.sort { display: flex; align-items: center; gap: 8px; }
.sort span { color: var(--muted); font-size: 0.9rem; }
.sort select { width: auto; padding: 7px 10px; }

.title-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 18px; }
.title-card {
  display: flex; flex-direction: column; background: var(--card);
  border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow);
}
.title-media { position: relative; aspect-ratio: 2 / 3; background: var(--line); }
.title-media .poster { width: 100%; height: 100%; object-fit: cover; display: block; }
.poster-missing { border: 1px dashed var(--muted); }
.tag {
  position: absolute; top: 8px; left: 8px; font-size: 0.72rem; font-weight: 700;
  padding: 3px 8px; border-radius: 999px; background: rgba(12, 14, 19, 0.82); color: #fff;
}
.tag-watched { left: auto; right: 8px; background: var(--ok); }
.title-card.is-watched .title-media .poster { filter: grayscale(0.5) brightness(0.8); }
.title-body { padding: 12px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.title-body h3 { font-size: 0.98rem; }
.title-body .meta { color: var(--muted); font-size: 0.82rem; }
.title-body .btn { margin-top: auto; width: 100%; }

.poster { display: block; object-fit: cover; border-radius: 6px; background: var(--line); }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--line); padding: 28px 0 40px; color: var(--muted); font-size: 0.85rem; }
.site-footer p + p { margin-top: 6px; }
.site-footer a { color: var(--muted); }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .hero-grid { grid-template-columns: 1fr; gap: 32px; }
  .hero-side { justify-self: start; max-width: 100%; }
  .features { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

/* Browser-only version: progress transfer card */
.transfer { margin-top: 20px; display: grid; gap: 12px; }
.transfer h3 { font-size: 1.1rem; }
.transfer-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.file-btn { position: relative; overflow: hidden; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }

@media (max-width: 560px) {
  .hero { padding: 44px 0 56px; }
  .section { padding: 48px 0; }
  .user-email { display: none; }
  .title-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .card { padding: 18px; }
}
