:root {
  --bg: #0b0b0b;
  --bg2: #161616;
  --surface: #1c1c1c;
  --surface2: #242424;
  --line: #303030;
  --text: #f5f5f5;
  --muted: #a0a0a0;
  --accent: #e50914;
  --accent-dim: #b20710;
  --danger: #e87c03;
  --radius: 6px;
  --shadow: 0 8px 24px rgba(0,0,0,.5);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: radial-gradient(1200px 600px at 50% -10%, #15151f 0%, var(--bg) 60%);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

.wordmark {
  font-weight: 800;
  letter-spacing: -.02em;
  font-size: 24px;
  color: var(--accent);
}
.wordmark::before { content: "▸ "; color: var(--text); }
.wordmark.big { font-size: 46px; margin-bottom: 8px; }

/* ---------- buttons ---------- */
.btn {
  border: 0; cursor: pointer; font: inherit; font-weight: 600;
  padding: 10px 16px; border-radius: 4px; color: var(--text);
  transition: transform .12s ease, background .18s ease, opacity .18s ease;
}
.btn:active { transform: scale(.96); }
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover { background: #f6121d; }
.btn.ghost { background: transparent; border: 1px solid var(--line); color: var(--muted); }
.btn.ghost:hover { color: var(--text); border-color: var(--muted); }

/* ---------- login ---------- */
.login {
  position: fixed; inset: 0; display: grid; place-items: center;
  background: radial-gradient(900px 500px at 50% 0%, #1a1010, var(--bg));
}
.login-card {
  display: flex; flex-direction: column; gap: 14px; width: min(360px, 88vw);
  padding: 36px 30px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 8px; box-shadow: var(--shadow); text-align: center;
  animation: rise .5s ease both;
}
.login-card input {
  padding: 13px 14px; border-radius: 4px; border: 1px solid var(--line);
  background: var(--bg2); color: var(--text); font-size: 15px; outline: none;
}
.login-card input:focus { border-color: var(--accent); }
.login-card button { padding: 13px; border-radius: 4px; border: 0; background: var(--accent); color: #fff; font-weight: 700; cursor: pointer; }
.login-err { color: #ff6b81; font-size: 13px; min-height: 16px; }

/* ---------- topbar ---------- */
.app { animation: fade .4s ease both; }
.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 40;
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px clamp(16px, 4vw, 48px);
  background: linear-gradient(180deg, rgba(0,0,0,.72), transparent);
  transition: background .3s ease, box-shadow .3s ease;
}
.topbar.scrolled { background: var(--bg); box-shadow: 0 1px 0 var(--line); }
.actions { display: flex; gap: 10px; margin-left: auto; }

/* ---------- hero (full-bleed cinematic) ---------- */
.hero {
  position: relative; height: min(74vh, 580px); overflow: hidden;
  display: flex; align-items: flex-end;
  background-size: cover; background-position: center 20%;
  animation: fade .6s ease both;
}
.hero::after {
  content: ""; position: absolute; inset: 0;
  background:
    linear-gradient(0deg, var(--bg) 1%, rgba(11,11,11,.15) 40%, rgba(11,11,11,.4) 100%),
    linear-gradient(90deg, rgba(11,11,11,.88) 0%, rgba(11,11,11,.25) 55%, transparent 100%);
}
.hero-inner { position: relative; z-index: 2; padding: 0 clamp(16px,4vw,48px) clamp(30px,5vw,60px); max-width: 720px; }
.hero-tag { color: var(--accent); font-weight: 700; font-size: 12.5px; letter-spacing: .18em; text-transform: uppercase; margin-bottom: 10px; }
.hero-inner h1 { font-size: clamp(30px, 5.5vw, 60px); line-height: 1.03; margin-bottom: 12px; text-shadow: 0 2px 24px rgba(0,0,0,.6); }
.hero-meta { color: var(--muted); font-size: 14px; margin-bottom: 18px; }
.hero-actions { display: flex; gap: 12px; }
.btn.lg { font-size: 16px; padding: 12px 26px; }

/* ---------- content / sections ---------- */
.content { position: relative; z-index: 5; padding-bottom: 80px; }
.rail-section, .lib-section { padding: 0 clamp(16px, 4vw, 48px); margin-bottom: 34px; }
.section-title { font-size: 19px; margin-bottom: 14px; color: var(--text); font-weight: 700; }

/* ---------- horizontal rail ---------- */
.rail-wrap { position: relative; }
.rail {
  display: flex; gap: 14px; overflow-x: auto; overflow-y: hidden;
  scroll-snap-type: x proximity; padding: 10px 0 16px; scrollbar-width: none;
}
.rail::-webkit-scrollbar { display: none; }
.card-rail { flex: 0 0 clamp(220px, 24vw, 300px); scroll-snap-align: start; }
.card-rail:hover { transform: scale(1.05); }
.rail-arrow {
  position: absolute; top: 10px; bottom: 16px; width: 52px; z-index: 6;
  border: 0; cursor: pointer; color: #fff; font-size: 30px; line-height: 1;
  background: rgba(0,0,0,.45); opacity: 0; transition: opacity .2s ease, background .2s ease;
}
.rail-arrow.left { left: 0; border-radius: 0 6px 6px 0; }
.rail-arrow.right { right: 0; border-radius: 6px 0 0 6px; }
.rail-wrap:hover .rail-arrow { opacity: 1; }
.rail-arrow:hover { background: rgba(0,0,0,.72); }
@media (hover: none) { .rail-arrow { display: none; } }
.grid {
  display: grid; gap: 18px;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}
.card {
  background: var(--surface); border-radius: var(--radius); overflow: hidden;
  cursor: pointer; border: 1px solid transparent;
  transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
  animation: rise .4s ease both;
}
.card:hover { transform: translateY(-4px) scale(1.02); border-color: var(--line); box-shadow: var(--shadow); }
.card .thumb {
  position: relative; aspect-ratio: 16/9; background: #000 center/cover no-repeat;
  display: grid; place-items: center;
}
.card .thumb::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(180deg, transparent 55%, rgba(0,0,0,.55));
  opacity: 0; transition: opacity .18s ease;
}
.card:hover .thumb::after { opacity: 1; }
.card .play {
  position: absolute; z-index: 2; width: 54px; height: 54px; border-radius: 50%;
  background: rgba(229,9,20,.95); color: #fff; display: grid; place-items: center;
  font-size: 22px; opacity: 0; transform: scale(.8); transition: all .18s ease; padding-left: 4px;
}
.card:hover .play { opacity: 1; transform: scale(1); }
.card .dur {
  position: absolute; bottom: 8px; right: 8px; z-index: 2;
  background: rgba(0,0,0,.78); color: #fff; font-size: 12px; font-weight: 600;
  padding: 3px 7px; border-radius: 3px;
}
.card .trash {
  position: absolute; top: 8px; right: 8px; z-index: 3; width: 32px; height: 32px;
  border: 0; border-radius: 4px; background: rgba(0,0,0,.6); color: #fff; cursor: pointer;
  opacity: 0; transition: opacity .18s ease, background .18s ease; font-size: 14px;
}
.card:hover .trash { opacity: 1; }
.card .trash:hover { background: var(--accent); }
.card .meta { padding: 11px 13px 14px; }
.card .meta .title { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card.removing { opacity: 0; transform: scale(.9); transition: all .35s ease; }

.empty { text-align: center; padding: 70px 20px; color: var(--muted); display: grid; gap: 14px; justify-items: center; }
.empty-art { font-size: 54px; }

/* ---------- player ---------- */
.player {
  position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,.95);
  display: grid; place-items: center; animation: fade .25s ease both;
}
.player video { width: min(94vw, 1280px); max-height: 84vh; border-radius: 4px; background: #000; box-shadow: var(--shadow); }
.player-title { position: absolute; top: 20px; left: 24px; font-weight: 700; font-size: 18px; }
.player-close {
  position: absolute; top: 16px; right: 20px; z-index: 2; width: 44px; height: 44px;
  border: 0; border-radius: 50%; background: rgba(255,255,255,.12); color: #fff; font-size: 18px; cursor: pointer;
  transition: background .18s ease;
}
.player-close:hover { background: rgba(255,255,255,.25); }

/* ---------- upload modal ---------- */
.modal { position: fixed; inset: 0; z-index: 70; background: rgba(0,0,0,.7); display: grid; place-items: center; padding: 20px; animation: fade .2s ease both; }
.modal-card { position: relative; width: min(560px, 94vw); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 26px; box-shadow: var(--shadow); animation: rise .3s ease both; }
.modal-card h3 { margin-bottom: 16px; }
.modal-close { position: absolute; top: 14px; right: 16px; border: 0; background: transparent; color: var(--muted); font-size: 18px; cursor: pointer; }
.drop {
  display: block; border: 2px dashed var(--line); border-radius: 6px; padding: 34px 20px;
  text-align: center; cursor: pointer; transition: border-color .18s ease, background .18s ease; color: var(--muted);
}
.drop:hover, .drop.over { border-color: var(--accent); background: rgba(229,9,20,.08); color: var(--text); }
.drop-icon { font-size: 30px; margin-bottom: 8px; }
.drop .link { color: var(--accent); text-decoration: underline; }
.drop .hint { font-size: 12px; margin-top: 8px; opacity: .8; }
.queue { margin-top: 16px; display: grid; gap: 10px; }
.qitem { background: var(--bg2); border: 1px solid var(--line); border-radius: 4px; padding: 10px 12px; font-size: 13px; }
.qitem .qtop { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 7px; }
.qitem .qname { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; flex: 1; }
.qitem .qpct { color: var(--accent); font-weight: 600; flex-shrink: 0; }
.bar { height: 6px; background: #000; border-radius: 4px; overflow: hidden; }
.bar > i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s ease; }
.qitem.done .qpct { color: #5ad17f; }
.qitem.err .qpct { color: #ff6b81; }

/* ---------- confirm dialog ---------- */
.confirm-card {
  position: relative; width: min(380px, 92vw);
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 8px; padding: 24px 24px 20px; box-shadow: var(--shadow);
  animation: rise .25s ease both;
}
.confirm-card h3 { font-size: 17px; margin-bottom: 8px; }
.confirm-card p { color: var(--muted); font-size: 14px; margin-bottom: 22px; word-break: break-word; }
.confirm-actions { display: flex; justify-content: flex-end; gap: 10px; }

@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
