:root {
  --bg: #0f1115;
  --bg-elev: #171a21;
  --bg-card: #1c212b;
  --bg-card-hover: #232936;
  --border: #2a3140;
  --text: #e8ecf4;
  --muted: #9aa3b5;
  --accent: #6ea8ff;
  --accent-2: #7ddeca;
  --ok: #3ecf8e;
  --warn: #f0b429;
  --danger: #ff6b7a;
  --radius: 14px;
  --shadow: 0 8px 28px rgba(0,0,0,.35);
  --font: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); font-family: var(--font); }
body { min-height: 100vh; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select { font: inherit; }
.app { max-width: 1200px; margin: 0 auto; padding: 20px 16px 64px; }
.topbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.brand { display: flex; flex-direction: column; gap: 2px; }
.brand h1 { margin: 0; font-size: 1.35rem; letter-spacing: .2px; }
.brand p { margin: 0; color: var(--muted); font-size: .9rem; }
.stats { display: flex; flex-wrap: wrap; gap: 8px; }
.pill { background: var(--bg-elev); border: 1px solid var(--border); border-radius: 999px; padding: 6px 12px; font-size: .85rem; color: var(--muted); }
.pill strong { color: var(--text); font-weight: 600; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.tab { background: transparent; border: 1px solid var(--border); color: var(--muted); border-radius: 999px; padding: 8px 14px; cursor: pointer; }
.tab:hover { color: var(--text); border-color: #3a455a; }
.tab.active { background: #24304a; color: var(--text); border-color: #3d5a8c; }
.toolbar { display: grid; grid-template-columns: 1.6fr repeat(5, minmax(110px, .65fr)) auto; gap: 8px; margin-bottom: 16px; }
@media (max-width: 900px) {
  .toolbar { grid-template-columns: 1fr 1fr; }
}
.search, .select, .btn {
  background: var(--bg-elev); border: 1px solid var(--border); color: var(--text);
  border-radius: 10px; padding: 10px 12px;
}
.search { width: 100%; }
.btn { cursor: pointer; white-space: nowrap; }
.btn:hover { background: #222836; }
.btn.primary { background: #2a4578; border-color: #3d5f9e; }
.btn.primary:hover { background: #33528c; }
.btn.ghost { background: transparent; }
.btn.danger { border-color: #6e3340; color: #ffb4bc; }
.panel { display: none; }
.panel.active { display: block; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow); display: flex; flex-direction: column;
  transition: background .15s ease, transform .15s ease;
}
.card:hover { background: var(--bg-card-hover); transform: translateY(-1px); }
.card.watched { opacity: .72; }
.thumb-wrap { position: relative; aspect-ratio: 16/9; background: #0a0c10; }
.thumb-wrap img { width: 100%; height: 100%; object-fit: cover; display: block; }
.badge {
  position: absolute; top: 8px; left: 8px; font-size: .72rem; font-weight: 700;
  padding: 4px 8px; border-radius: 999px; background: rgba(15,17,21,.85); border: 1px solid var(--border);
}
.badge.ok { color: var(--ok); border-color: #2f6b4f; }
.badge.new { color: var(--accent); }
.duration {
  position: absolute; right: 8px; bottom: 8px; font-size: .75rem;
  background: rgba(0,0,0,.75); padding: 3px 7px; border-radius: 6px;
}
.card-body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.card-body h3 { margin: 0; font-size: 1rem; line-height: 1.35; }
.meta { color: var(--muted); font-size: .82rem; display: flex; flex-wrap: wrap; gap: 6px; }
.chip { background: #243041; border-radius: 999px; padding: 2px 8px; }
.desc { color: #c5ccd9; font-size: .88rem; line-height: 1.4; margin: 0;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.actions { display: flex; gap: 8px; margin-top: auto; padding-top: 4px; flex-wrap: wrap; }
.actions .btn { flex: 1; text-align: center; }
.empty { text-align: center; color: var(--muted); padding: 48px 16px; border: 1px dashed var(--border); border-radius: var(--radius); }
.progress-list { display: grid; gap: 10px; }
.progress-item {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; cursor: pointer;
}
.progress-item:hover { background: var(--bg-card-hover); }
.progress-head { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.bar { height: 8px; background: #10141c; border-radius: 999px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: linear-gradient(90deg, #3d6db5, #6ea8ff); }
.channel-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.channel-card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; cursor: pointer;
}
.channel-card:hover { background: var(--bg-card-hover); }
.channel-card h3 { margin: 0 0 4px; }
.channel-card p { margin: 0 0 10px; color: var(--muted); font-size: .88rem; }
.settings {
  background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; margin-top: 18px;
}
.settings h2 { margin: 0 0 8px; font-size: 1rem; }
.settings-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.toast {
  position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%);
  background: #24304a; border: 1px solid #3d5a8c; color: var(--text);
  padding: 10px 16px; border-radius: 999px; opacity: 0; pointer-events: none; transition: opacity .2s;
  z-index: 50;
}
.toast.show { opacity: 1; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }

/* iPhone / PWA */
body {
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  -webkit-tap-highlight-color: transparent;
}
.app { padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
@media (max-width: 700px) {
  .app { padding: 12px 12px calc(72px + env(safe-area-inset-bottom)); }
  .brand h1 { font-size: 1.15rem; }
  .tabs {
    position: sticky;
    top: 0;
    z-index: 20;
    background: rgba(15,17,21,.92);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 8px 0;
    margin: 0 -4px 12px;
  }
  .tab { flex: 1; text-align: center; padding: 10px 8px; font-size: .9rem; min-height: 44px; }
  .toolbar { grid-template-columns: 1fr; gap: 8px; }
  .search, .select, .btn { min-height: 44px; font-size: 16px; }
  .grid { grid-template-columns: 1fr; gap: 12px; }
  .actions .btn { min-height: 44px; }
  .settings { margin-top: 14px; }
  .toast { bottom: calc(18px + env(safe-area-inset-bottom)); max-width: calc(100vw - 24px); text-align: center; }
}

.sync-status{font-size:.8rem;color:var(--muted);margin-top:.25rem;min-height:1.1em}
