:root {
  --bg:        #0b0e14;
  --bg-1:      #0f131b;
  --bg-soft:   #151b26;
  --bg-card:   #1a2130;
  --bg-hi:     #212a3b;
  --line:      #2a3344;
  --line-soft: #212938;
  --text:      #eef2f8;
  --text-dim:  #93a1b5;
  --text-mut:  #64718a;
  --accent:    #ffb066;   /* тепла бурштинова */
  --accent-2:  #ff6f9c;   /* рожевий акцент для градієнтів */
  --accent-dim:#7a5836;
  --grad: linear-gradient(120deg, #ffc074 0%, #ff7e8f 55%, #ff6f9c 100%);
  --glow: 0 14px 40px -12px rgba(255, 130, 120, .45);
  --shadow: 0 16px 40px -18px rgba(0, 0, 0, .7);
  --radius: 14px;
  --radius-sm: 10px;
  --maxw: 1320px;
  font-synthesis: none;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(1100px 560px at 50% -12%, rgba(255, 140, 110, .12), transparent 62%),
    radial-gradient(900px 500px at 100% 0%, rgba(255, 111, 156, .08), transparent 55%),
    var(--bg);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

::selection { background: rgba(255, 176, 102, .3); }

/* thin scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
*::-webkit-scrollbar { height: 8px; width: 8px; }
*::-webkit-scrollbar-thumb { background: var(--line); border-radius: 10px; }

/* ---------- topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px clamp(16px, 4vw, 32px);
  background: rgba(11, 14, 20, .72);
  backdrop-filter: saturate(140%) blur(16px);
  -webkit-backdrop-filter: saturate(140%) blur(16px);
  border-bottom: 1px solid var(--line-soft);
}
.brand {
  cursor: pointer; user-select: none;
  display: flex; align-items: baseline; gap: 9px;
  font-weight: 800; font-size: 21px; letter-spacing: .3px;
  background: var(--grad); -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
  transition: filter .15s, transform .15s;
}
.brand:hover { filter: brightness(1.08); transform: translateY(-1px); }
.brand span {
  font-weight: 600; font-size: 11px; letter-spacing: 2.5px;
  text-transform: uppercase; color: var(--text-mut);
  -webkit-text-fill-color: var(--text-mut);
  background: none;
}
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.icon-btn {
  background: var(--bg-soft); border: 1px solid var(--line); color: var(--text-dim);
  width: 38px; height: 38px; border-radius: 10px; font-size: 17px;
  cursor: pointer; transition: .16s; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn:hover { color: var(--accent); border-color: var(--accent-dim);
  background: var(--bg-hi); transform: translateY(-1px) rotate(30deg); }
.logout {
  color: var(--text-dim); text-decoration: none; font-size: 14px; font-weight: 500;
  padding: 8px 14px; border-radius: 10px; transition: .16s;
  border: 1px solid transparent;
}
.logout:hover { color: var(--text); background: var(--bg-soft); border-color: var(--line); }

/* ---------- layout ---------- */
main { max-width: var(--maxw); margin: 0 auto; padding: 30px clamp(16px, 4vw, 32px) 96px; }
.row-title {
  font-size: 13px; font-weight: 700; letter-spacing: 1.4px;
  color: var(--text-mut); text-transform: uppercase;
  margin: 0 0 18px; display: flex; align-items: center; gap: 10px;
}
.row-title::before {
  content: ""; width: 4px; height: 15px; border-radius: 3px;
  background: var(--grad);
}
.hidden { display: none !important; }

/* ---------- continue strip ---------- */
#continue-section { margin-bottom: 44px; }
.continue-strip {
  display: flex; gap: 16px; overflow-x: auto; padding: 4px 2px 10px;
  scroll-snap-type: x proximity;
}
.continue-card {
  flex: 0 0 268px; scroll-snap-align: start;
  background: var(--bg-card); border-radius: var(--radius);
  overflow: hidden; cursor: pointer; border: 1px solid var(--line-soft);
  transition: transform .18s, border-color .18s, box-shadow .18s;
}
.continue-card:hover {
  transform: translateY(-4px); border-color: var(--accent-dim); box-shadow: var(--shadow);
}
.continue-thumb {
  height: 132px; background: var(--bg-soft) center/cover no-repeat; position: relative;
}
.continue-thumb::after {
  content: "▶"; position: absolute; inset: 0; display: flex; align-items: center;
  justify-content: center; font-size: 26px; color: #fff;
  background: rgba(0,0,0,.28); opacity: 0; transition: .18s;
}
.continue-card:hover .continue-thumb::after { opacity: 1; }
.continue-body { padding: 12px 14px; }
.continue-body .t { font-size: 14.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.continue-body .e { font-size: 12px; color: var(--text-dim); margin-top: 4px; }
.mini-progress { height: 4px; background: var(--line); }
.mini-progress > i { display: block; height: 100%; background: var(--grad); }

/* ---------- grid ---------- */
.grid {
  display: grid; gap: clamp(16px, 2vw, 24px);
  grid-template-columns: repeat(auto-fill, minmax(158px, 1fr));
}
.card { cursor: pointer; }
.poster-wrap {
  position: relative; aspect-ratio: 2/3; border-radius: var(--radius);
  overflow: hidden; background: var(--bg-soft);
  border: 1px solid var(--line-soft);
  transition: transform .2s cubic-bezier(.2,.7,.2,1), border-color .2s, box-shadow .2s;
}
.poster-wrap::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(180deg, transparent 60%, rgba(0,0,0,.45));
  opacity: 0; transition: opacity .2s;
}
.card:hover .poster-wrap {
  transform: translateY(-6px) scale(1.015); border-color: var(--accent-dim);
  box-shadow: var(--glow);
}
.card:hover .poster-wrap::after { opacity: 1; }
.poster-wrap img { width: 100%; height: 100%; object-fit: cover; display: block; }
.poster-fallback {
  width: 100%; height: 100%; display: flex; align-items: center; justify-content: center;
  padding: 16px; text-align: center; font-weight: 800; font-size: 17px; line-height: 1.3;
  color: var(--text-dim);
  background: linear-gradient(160deg, #222c3d, #141a24);
}
.badge {
  position: absolute; top: 9px; right: 9px; z-index: 2;
  background: rgba(0,0,0,.6); color: #fff; font-size: 12px; font-weight: 700;
  padding: 4px 9px; border-radius: 20px; backdrop-filter: blur(4px);
}
.badge.new { background: var(--grad); color: #2a1206; box-shadow: 0 4px 14px -4px rgba(255,120,130,.6); }
.card-title {
  margin-top: 11px; font-size: 14px; font-weight: 600; line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card-sub { font-size: 12px; color: var(--text-mut); margin-top: 3px; }

.empty {
  color: var(--text-dim); padding: 56px 20px; text-align: center;
  background: var(--bg-1); border: 1px dashed var(--line); border-radius: var(--radius);
}

/* ---------- detail ---------- */
.back {
  background: var(--bg-soft); border: 1px solid var(--line); color: var(--text-dim);
  cursor: pointer; font-size: 14px; padding: 8px 14px; border-radius: 10px;
  margin-bottom: 24px; transition: .15s;
}
.back:hover { color: var(--text); border-color: var(--accent-dim); }
.detail-head { display: flex; gap: 28px; margin-bottom: 34px; align-items: flex-end; }
.detail-poster {
  width: 190px; aspect-ratio: 2/3; object-fit: cover; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--bg-soft); flex: 0 0 auto;
  box-shadow: var(--shadow);
}
.detail-meta h1 {
  margin: 0 0 10px; font-size: clamp(24px, 4vw, 32px); line-height: 1.12; letter-spacing: -.5px;
}
.detail-sub { color: var(--text-dim); font-size: 15px; }

.episode-list { display: flex; flex-direction: column; gap: 6px; }
.episode {
  display: flex; align-items: center; gap: 16px; padding: 13px 15px;
  background: var(--bg-soft); border: 1px solid var(--line-soft); border-radius: 12px;
  cursor: pointer; transition: .14s;
}
.episode:hover { background: var(--bg-card); border-color: var(--accent-dim);
  transform: translateX(3px); }
.ep-num {
  flex: 0 0 46px; height: 46px; border-radius: 10px; display: flex;
  align-items: center; justify-content: center; font-weight: 800;
  background: var(--bg); color: var(--accent); font-size: 15px;
  border: 1px solid var(--line);
}
.ep-main { flex: 1 1 auto; min-width: 0; }
.ep-main .ep-t { font-size: 15px; font-weight: 600; }
.ep-main .ep-meta { font-size: 12px; color: var(--text-dim); margin-top: 3px; }
.ep-progress { height: 4px; background: var(--line); border-radius: 3px; margin-top: 9px; overflow: hidden; max-width: 340px; }
.ep-progress > i { display: block; height: 100%; background: var(--grad); }
.ep-check {
  flex: 0 0 auto; width: 24px; height: 24px; border-radius: 50%;
  border: 2px solid var(--line); display: flex; align-items: center; justify-content: center;
  color: transparent; font-size: 13px; transition: .14s;
}
.ep-check:hover { border-color: var(--accent-dim); }
.ep-check.done { background: var(--grad); border-color: transparent; color: #2a1206; }

/* ---------- player ---------- */
.player-overlay {
  position: fixed; inset: 0; z-index: 50; background: rgba(6, 8, 12, .96);
  backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center; padding: clamp(12px, 3vw, 28px);
  animation: fade .2s ease;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.player-box { width: 100%; max-width: 1120px; }
#player {
  width: 100%; max-height: 82vh; border-radius: 14px; background: #000; display: block;
  box-shadow: 0 30px 80px -20px rgba(0,0,0,.9);
}
.player-caption { margin-top: 14px; color: var(--text-dim); font-size: 14px; text-align: center; font-weight: 500; }
.player-close {
  position: absolute; top: 20px; right: 24px; z-index: 51;
  width: 42px; height: 42px; border-radius: 50%; border: 1px solid rgba(255,255,255,.14);
  cursor: pointer; background: rgba(255,255,255,.08); color: #fff; font-size: 18px;
  transition: .15s; display: flex; align-items: center; justify-content: center;
}
.player-close:hover { background: rgba(255,255,255,.2); transform: rotate(90deg); }

/* ---------- login ---------- */
.login-body {
  display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px;
}
.login-card {
  position: relative;
  background: linear-gradient(180deg, var(--bg-card), var(--bg-1));
  padding: 42px 38px; border-radius: 20px;
  border: 1px solid var(--line); width: 340px; box-shadow: var(--shadow);
}
.login-card::before {
  content: ""; position: absolute; inset: -1px; border-radius: 20px; padding: 1px;
  background: var(--grad); -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude; opacity: .35; pointer-events: none;
}
.login-card h1 { margin: 0 0 24px; color: var(--accent); text-align: center; font-size: 30px; }
.login-brand {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  margin: 0 0 26px; line-height: 1;
  font-size: 30px; font-weight: 800; letter-spacing: -.5px;
  background: var(--grad); -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}
.login-brand span {
  font-size: 11px; font-weight: 600; letter-spacing: 3px;
  text-transform: uppercase; color: var(--text-mut); -webkit-text-fill-color: var(--text-mut);
}
.login-card form { display: flex; flex-direction: column; gap: 12px; }
.login-card input {
  padding: 13px 15px; border-radius: 11px; border: 1px solid var(--line);
  background: var(--bg-soft); color: var(--text); font-size: 15px; transition: .15s;
}
.login-card input:focus { outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(255,176,102,.14); }
.login-card button {
  margin-top: 8px; padding: 13px; border-radius: 11px; border: none; cursor: pointer;
  background: var(--grad); color: #2a1206; font-weight: 800; font-size: 15px; transition: .15s;
}
.login-card button:hover { filter: brightness(1.06); transform: translateY(-1px); }
.err { color: #ff9aa2; font-size: 13px; text-align: center; margin: 6px 0 0; }

/* ---------- settings ---------- */
.settings { max-width: 760px; margin: 0 auto; }
.settings-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; margin: 16px 0 22px;
}
.settings-head h1 { font-size: 24px; margin: 0; letter-spacing: -.3px; }

.btn-primary {
  background: var(--grad); color: #2a1206; border: none;
  padding: 11px 18px; border-radius: 11px; font-weight: 800; font-size: 14px;
  cursor: pointer; transition: .16s; white-space: nowrap;
  box-shadow: 0 8px 22px -10px rgba(255,120,130,.7);
}
.btn-primary:hover { filter: brightness(1.06); transform: translateY(-1px); }
.btn-primary:disabled { opacity: .6; cursor: default; transform: none; box-shadow: none; }

.wl-add {
  display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 14px;
  background: var(--bg-1); border: 1px solid var(--line-soft);
  border-radius: var(--radius); padding: 14px;
}
.wl-add input {
  flex: 1 1 220px; background: var(--bg-soft); border: 1px solid var(--line);
  color: var(--text); padding: 12px 14px; border-radius: 10px; font-size: 14px; transition: .15s;
}
.wl-add input:focus { outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(255,176,102,.12); }
.wl-add button {
  background: var(--bg-hi); color: var(--text); border: 1px solid var(--line);
  padding: 0 20px; border-radius: 10px; font-weight: 700; cursor: pointer; transition: .15s;
}
.wl-add button:hover { border-color: var(--accent-dim); color: var(--accent); }

.wl-msg { padding: 10px 14px; border-radius: 10px; font-size: 13px; margin-bottom: 16px; font-weight: 500; }
.wl-msg.ok  { background: rgba(90,190,130,.14); color: #8fe6ad; border: 1px solid rgba(90,190,130,.25); }
.wl-msg.err { background: rgba(230,90,110,.14); color: #ff9aa8; border: 1px solid rgba(230,90,110,.25); }

.wl-list { display: flex; flex-direction: column; gap: 9px; }
.wl-empty {
  color: var(--text-dim); padding: 40px 20px; text-align: center;
  background: var(--bg-1); border: 1px dashed var(--line); border-radius: var(--radius);
}
.wl-row {
  display: flex; align-items: center; gap: 14px;
  background: var(--bg-card); border: 1px solid var(--line-soft);
  border-radius: var(--radius); padding: 13px 15px; transition: .15s;
}
.wl-row:hover { border-color: var(--line); }
.wl-row.off { opacity: .5; }
.wl-toggle { display: inline-flex; }
.wl-toggle input { width: 19px; height: 19px; accent-color: var(--accent); cursor: pointer; }
.wl-main { flex: 1; min-width: 0; }
.wl-topic { font-weight: 700; font-size: 15px; }
.wl-sub { font-size: 12px; color: var(--text-mut); margin-top: 3px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wl-del {
  background: none; border: none; color: var(--text-mut); font-size: 16px;
  cursor: pointer; padding: 8px; border-radius: 8px; transition: .15s;
}
.wl-del:hover { color: #ff9aa2; background: var(--bg-soft); }

/* ---------- responsive ---------- */
@media (max-width: 640px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 14px; }
  .detail-head { flex-direction: column; align-items: flex-start; gap: 18px; }
  .detail-poster { width: 140px; }
  .settings-head { flex-wrap: wrap; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
