/* ============ HomeFlix ============ */
:root {
  --bg: #0b0b0f;
  --bg-raised: #16161d;
  --bg-card: #1d1d26;
  --text: #f2f2f2;
  --text-dim: #9a9aa5;
  --accent: #e50914;
  --accent-hover: #f6121d;
  --radius: 6px;
  --nav-h: 64px;
}

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

html { color-scheme: dark; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  min-height: 100vh;
}

body.no-scroll { overflow: hidden; }

a { color: var(--text); text-decoration: none; }
.dim { color: var(--text-dim); }
.dim a { color: var(--text); text-decoration: underline; }
.mono { font-family: Consolas, monospace; font-size: 0.85em; }
.err { color: #ff6b6b; }

.brand-text {
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: 2px;
  color: var(--accent);
  user-select: none;
}

.boot-splash {
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.boot-splash .brand-text { font-size: 3rem; animation: pulse 1.2s ease-in-out infinite alternate; }
@keyframes pulse { from { opacity: 0.4; } to { opacity: 1; } }

/* ---------- buttons & forms ---------- */
.btn {
  border: none;
  border-radius: var(--radius);
  padding: 10px 22px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { background: #5a5a63; cursor: default; }
.btn-ghost { background: rgba(255, 255, 255, 0.14); color: #fff; }
.btn-ghost:hover { background: rgba(255, 255, 255, 0.25); }
.btn-danger { background: transparent; color: #ff6b6b; border: 1px solid #ff6b6b55; }
.btn-danger:hover { background: #ff6b6b22; }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: 0.82rem; }

input[type="text"], input[type="password"], input[type="email"], input[type="search"], select {
  background: #26262f;
  border: 1px solid #3a3a45;
  border-radius: var(--radius);
  color: var(--text);
  padding: 10px 14px;
  font-size: 0.95rem;
  outline: none;
}
input:focus, select:focus { border-color: #6a6a78; }

/* ---------- auth ---------- */
.auth-bg {
  min-height: 100vh;
  background:
    radial-gradient(ellipse at 20% 10%, #2a0a0e 0%, transparent 50%),
    radial-gradient(ellipse at 80% 90%, #14141f 0%, transparent 60%),
    var(--bg);
}
.auth-header { padding: 24px 48px; }
.auth-card {
  max-width: 420px;
  margin: 6vh auto;
  background: rgba(0, 0, 0, 0.65);
  border: 1px solid #ffffff12;
  border-radius: 10px;
  padding: 44px 48px;
}
.auth-card h1 { font-size: 1.6rem; margin-bottom: 8px; }
.auth-card p { margin-bottom: 12px; }
.auth-card form { display: flex; flex-direction: column; gap: 14px; margin-top: 20px; }
.auth-error { color: #ff6b6b; font-size: 0.88rem; min-height: 1.2em; }
.auth-switch { margin-top: 22px; color: var(--text-dim); font-size: 0.92rem; }
.auth-switch a { color: #fff; font-weight: 600; }
.auth-switch a:hover { text-decoration: underline; }

/* ---------- profile picker ---------- */
.profiles-screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 36px;
  padding: 40px;
}
.profiles-screen h1 { font-size: 2.4rem; font-weight: 500; }
.profiles-grid { display: flex; flex-wrap: wrap; gap: 28px; justify-content: center; }
.profile-tile { display: flex; flex-direction: column; align-items: center; gap: 12px; cursor: pointer; width: 130px; }
.avatar {
  width: 120px;
  height: 120px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  font-weight: 700;
  color: #fff;
  border: 3px solid transparent;
  transition: border-color 0.15s, transform 0.15s;
}
.profile-tile:hover .avatar { border-color: #fff; transform: scale(1.05); }
.profile-tile.managing .avatar { opacity: 0.75; }
.avatar-add { background: var(--bg-card); color: var(--text-dim); font-weight: 300; }
.avatar-edit { font-size: 2rem; }
.profile-name { color: var(--text-dim); font-size: 1.05rem; }
.profile-tile:hover .profile-name { color: #fff; }
.profiles-actions { display: flex; gap: 14px; }
.avatar-sm { width: 34px; height: 34px; border-radius: 5px; font-size: 1rem; }

.color-row { display: flex; gap: 10px; flex-wrap: wrap; margin: 4px 0; }
.color-swatch {
  width: 34px; height: 34px;
  border-radius: 6px;
  border: 3px solid transparent;
  cursor: pointer;
}
.color-swatch.sel { border-color: #fff; }

/* ---------- nav ---------- */
.nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--nav-h);
  display: flex;
  align-items: center;
  gap: 32px;
  padding: 0 40px;
  background: linear-gradient(to bottom, rgba(6, 6, 10, 0.95), rgba(6, 6, 10, 0.75));
  backdrop-filter: blur(8px);
  z-index: 100;
}
.brand-link { flex-shrink: 0; }
.nav-links { display: flex; gap: 22px; }
.nav-links a { color: var(--text-dim); font-size: 0.95rem; transition: color 0.15s; }
.nav-links a:hover, .nav-links a.active { color: #fff; }
.nav-links a.active { font-weight: 600; }
.nav-right { margin-left: auto; display: flex; align-items: center; gap: 18px; }
#nav-search { width: 220px; padding: 8px 12px; font-size: 0.88rem; }

.profile-menu { position: relative; cursor: pointer; padding: 8px 0; }
.dropdown {
  position: absolute;
  top: 100%; right: 0;
  min-width: 220px;
  background: rgba(10, 10, 14, 0.97);
  border: 1px solid #ffffff1a;
  border-radius: var(--radius);
  padding: 6px 0;
  display: none;
  flex-direction: column;
}
.profile-menu:hover .dropdown { display: flex; }
.dropdown-header { padding: 10px 16px; border-bottom: 1px solid #ffffff14; font-weight: 600; font-size: 0.92rem; }
.dropdown a { padding: 10px 16px; font-size: 0.9rem; color: var(--text-dim); }
.dropdown a:hover { color: #fff; background: #ffffff0d; }

main { padding-top: var(--nav-h); min-height: 100vh; }

.loading {
  height: 40vh;
  display: flex; align-items: center; justify-content: center;
}
.loading::after {
  content: '';
  width: 42px; height: 42px;
  border: 4px solid #ffffff22;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- hero ---------- */
.hero {
  position: relative;
  height: 62vh;
  min-height: 380px;
  display: flex;
  align-items: flex-end;
  overflow: hidden;
  margin-top: calc(-1 * var(--nav-h));
}
.hero-bg {
  position: absolute; inset: -40px;
  background-size: cover;
  background-position: center 20%;
  filter: blur(18px) brightness(0.45);
}
.hero-bg-plain { background: linear-gradient(120deg, #2a0a0e, #14141f); filter: none; }
.hero-fade {
  position: absolute; inset: 0;
  background: linear-gradient(to top, var(--bg) 0%, transparent 55%);
}
.hero-content { position: relative; padding: 0 48px 56px; max-width: 700px; }
.hero-kicker { text-transform: uppercase; letter-spacing: 2px; font-size: 0.78rem; color: var(--accent); font-weight: 700; margin-bottom: 10px; }
.hero-content h1 { font-size: 3rem; line-height: 1.1; margin-bottom: 10px; text-shadow: 0 2px 12px rgba(0,0,0,0.6); }
.hero-meta { color: var(--text-dim); margin-bottom: 22px; }
.hero-buttons { display: flex; gap: 14px; }
.hero-empty { align-items: center; }
.hero-empty .hero-content { text-align: center; max-width: none; padding-bottom: 0; }

/* ---------- rows & cards ---------- */
.rows { padding: 12px 0 60px; display: flex; flex-direction: column; gap: 34px; margin-top: -20px; position: relative; }
.row h2 { font-size: 1.25rem; margin: 0 48px 12px; }
.row-scroll {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding: 4px 48px 12px;
  scrollbar-width: thin;
  scrollbar-color: #333 transparent;
}

.card { width: 168px; flex-shrink: 0; cursor: pointer; }
.grid .card { width: auto; }
.poster {
  position: relative;
  aspect-ratio: 2 / 3;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-card);
  transition: transform 0.18s, box-shadow 0.18s;
}
.card:hover .poster {
  transform: scale(1.05);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
  z-index: 2;
}
.poster img {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
}
.poster-fallback {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  padding: 14px;
  text-align: center;
  font-weight: 600;
  font-size: 0.95rem;
  background: linear-gradient(145deg, #23232e, #16161d);
  color: var(--text-dim);
}
.badge {
  position: absolute;
  top: 8px; right: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 1px;
  padding: 3px 7px;
  border-radius: 3px;
}
.poster-hover {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, 0.35);
  opacity: 0;
  transition: opacity 0.15s;
}
.card:hover .poster-hover { opacity: 1; }
.play-circle {
  width: 48px; height: 48px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  color: #000;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem;
  padding-left: 4px;
}
.card-progress {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 4px;
  background: rgba(255, 255, 255, 0.25);
}
.card-progress > div { height: 100%; background: var(--accent); }
.card-title {
  margin-top: 8px;
  font-size: 0.85rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.card-label { font-size: 0.75rem; color: var(--text-dim); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- pages / grids ---------- */
.page { padding: 36px 48px 80px; }
.page > h1 { font-size: 1.9rem; margin-bottom: 26px; }
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 20px 14px;
}
.empty-msg { font-size: 1.05rem; }

/* ---------- modal ---------- */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.75);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 6vh 20px 40px;
  overflow-y: auto;
  z-index: 200;
}
.modal {
  position: relative;
  background: var(--bg-raised);
  border: 1px solid #ffffff14;
  border-radius: 10px;
  padding: 32px;
  width: 100%;
  max-width: 440px;
  animation: modal-in 0.18s ease-out;
}
.modal-lg { max-width: 760px; }
@keyframes modal-in { from { transform: translateY(14px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal h2 { margin-bottom: 18px; }
.modal form { display: flex; flex-direction: column; gap: 16px; }
.modal-close {
  position: absolute;
  top: 14px; right: 14px;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: #fff;
  width: 34px; height: 34px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 0.9rem;
  z-index: 2;
}
.modal-close:hover { background: rgba(255, 255, 255, 0.22); }
.modal-actions { display: flex; gap: 12px; }

/* ---------- details ---------- */
.details-top { display: flex; gap: 26px; }
.details-poster {
  position: relative;
  width: 200px;
  flex-shrink: 0;
  aspect-ratio: 2 / 3;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-card);
}
.details-poster img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.details-info { flex: 1; min-width: 0; }
.details-info h2 { font-size: 1.7rem; margin-bottom: 10px; }
.details-meta { display: flex; gap: 14px; color: var(--text-dim); margin-bottom: 18px; align-items: center; flex-wrap: wrap; }
.badge-inline {
  background: #ffffff18;
  padding: 2px 9px;
  border-radius: 4px;
  font-size: 0.75rem;
  letter-spacing: 0.5px;
}
.details-actions { display: flex; gap: 12px; flex-wrap: wrap; }
.details-progress { margin-bottom: 16px; display: flex; align-items: center; gap: 10px; font-size: 0.85rem; }
.details-progress .card-progress { position: static; width: 140px; border-radius: 2px; }

.details-episodes { margin-top: 28px; }
.season-bar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.season-bar h3 { font-size: 1.15rem; }
.episode-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 14px;
  border-radius: var(--radius);
  cursor: pointer;
}
.episode-row:hover { background: #ffffff0d; }
.ep-num { color: var(--text-dim); font-size: 1.1rem; width: 28px; text-align: center; flex-shrink: 0; }
.ep-body { flex: 1; min-width: 0; }
.ep-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ep-body .card-progress { position: static; margin-top: 6px; border-radius: 2px; max-width: 220px; }
.ep-play { color: var(--text-dim); }
.episode-row:hover .ep-play { color: #fff; }

/* ---------- watch history ---------- */
.page .section-head { margin-bottom: 26px; }
.page .section-head h1 { margin: 0; }
.history-list { display: flex; flex-direction: column; max-width: 760px; }
.history-row {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 12px 14px;
  border-radius: var(--radius);
}
.history-row:hover { background: #ffffff0a; }
.h-poster {
  position: relative;
  width: 52px;
  aspect-ratio: 2 / 3;
  border-radius: 4px;
  overflow: hidden;
  background: var(--bg-card);
  flex-shrink: 0;
  cursor: pointer;
}
.h-poster img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.h-poster .poster-fallback { font-size: 1.1rem; padding: 0; }
.h-body { flex: 1; min-width: 0; }
.h-title { font-weight: 600; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.h-title:hover { text-decoration: underline; }
.h-label, .h-meta { font-size: 0.85rem; margin-top: 2px; }
.h-watched { color: #2ecc71; }
.h-body .card-progress { position: static; margin-top: 8px; border-radius: 2px; max-width: 220px; }
.history-row .pbtn { font-size: 1rem; color: var(--text-dim); }
.history-row .pbtn:hover { color: #fff; }

/* ---------- admin ---------- */
.stat-cards { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 36px; }
.stat {
  background: var(--bg-raised);
  border: 1px solid #ffffff10;
  border-radius: 8px;
  padding: 18px 28px;
  color: var(--text-dim);
  font-size: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 110px;
}
.stat span { font-size: 1.7rem; font-weight: 700; color: #fff; }

.admin-section { margin-bottom: 44px; }
.admin-section h2 { font-size: 1.25rem; margin-bottom: 14px; }
.section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.section-head h2 { margin: 0; }
.scan-status { color: var(--text-dim); font-size: 0.88rem; margin-bottom: 12px; }
.scan-status.running { color: #f5a623; }
.scan-status.running::before { content: '⟳ '; }

.admin-table { width: 100%; border-collapse: collapse; margin-bottom: 16px; }
.admin-table th {
  text-align: left;
  color: var(--text-dim);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 8px 12px;
  border-bottom: 1px solid #ffffff18;
}
.admin-table td { padding: 11px 12px; border-bottom: 1px solid #ffffff0c; font-size: 0.92rem; }
.row-actions { display: flex; gap: 8px; justify-content: flex-end; }

.version-tag { font-size: 0.9rem; font-weight: 400; }
.server-log {
  background: #08080c;
  border: 1px solid #ffffff14;
  border-radius: var(--radius);
  padding: 14px;
  font-family: Consolas, monospace;
  font-size: 0.78rem;
  line-height: 1.5;
  color: #b8b8c2;
  max-height: 320px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-all;
}
.log-follow { font-size: 0.82rem; color: var(--text-dim); }

.inline-form { display: flex; gap: 10px; flex-wrap: wrap; }
.inline-form .grow { flex: 1; min-width: 260px; }
.hint { font-size: 0.82rem; margin-top: 10px; }
.setting-row { display: flex; align-items: center; gap: 10px; font-size: 0.95rem; cursor: pointer; }

/* ---------- player ---------- */
.player {
  position: fixed; inset: 0;
  background: #000;
  z-index: 300;
}
.player.hide-cursor { cursor: none; }
.player video { width: 100%; height: 100%; }
.player video::-webkit-media-text-track-display { font-size: 1.1em; }

.player-spinner {
  position: absolute;
  top: 50%; left: 50%;
  width: 56px; height: 56px;
  margin: -28px 0 0 -28px;
  border: 4px solid #ffffff28;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.player-spinner.show { opacity: 1; }

.player-ui { position: absolute; inset: 0; pointer-events: none; transition: opacity 0.25s; }
.player-ui.hidden { opacity: 0; }
.player-top {
  position: absolute;
  top: 0; left: 0; right: 0;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 22px 28px;
  background: linear-gradient(to bottom, rgba(0,0,0,0.75), transparent);
  pointer-events: auto;
}
.player-title .pt-main { font-size: 1.15rem; font-weight: 700; }
.player-title .pt-sub { font-size: 0.88rem; color: var(--text-dim); }

.player-bottom {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  padding: 18px 28px 22px;
  background: linear-gradient(to top, rgba(0,0,0,0.8), transparent);
  pointer-events: auto;
}
.seek-row { display: flex; align-items: center; gap: 16px; margin-bottom: 10px; }
.time-label { font-size: 0.85rem; color: var(--text-dim); white-space: nowrap; font-variant-numeric: tabular-nums; }
.controls-row { display: flex; align-items: center; justify-content: space-between; }
.controls-left, .controls-right { display: flex; align-items: center; gap: 8px; }

.pbtn {
  background: transparent;
  border: none;
  color: #fff;
  font-size: 1.25rem;
  padding: 8px 12px;
  cursor: pointer;
  border-radius: var(--radius);
  line-height: 1;
}
.pbtn:hover { background: #ffffff1f; }
.pbtn.active { color: var(--accent); }
.cc-btn { font-size: 0.9rem; font-weight: 700; border: 1.5px solid #ffffff66; border-radius: 4px; padding: 5px 8px; }
.hd-badge {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 1px;
  color: #f5a623;
  border: 1px solid #f5a62366;
  border-radius: 4px;
  padding: 4px 7px;
  margin-right: 6px;
  align-self: center;
}
.next-btn { font-size: 0.9rem; font-weight: 600; }

.seek {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 5px;
  background: #ffffff33;
  border-radius: 3px;
  cursor: pointer;
}
.seek::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 15px; height: 15px;
  border-radius: 50%;
  background: var(--accent);
}
.vol {
  -webkit-appearance: none;
  appearance: none;
  width: 90px;
  height: 4px;
  background: #ffffff33;
  border-radius: 2px;
  cursor: pointer;
  margin-left: 8px;
}
.vol::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: #fff;
}

.player-error {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  max-width: 460px;
  padding: 24px;
}
.player-error p:first-child { font-size: 1.2rem; font-weight: 600; margin-bottom: 10px; }

/* ---------- toasts ---------- */
#toast-root {
  position: fixed;
  bottom: 24px; right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 400;
}
.toast {
  background: var(--bg-raised);
  border: 1px solid #ffffff1f;
  border-left: 4px solid var(--text-dim);
  border-radius: var(--radius);
  padding: 12px 18px;
  font-size: 0.9rem;
  opacity: 0;
  transform: translateX(20px);
  transition: all 0.25s;
  max-width: 360px;
}
.toast.show { opacity: 1; transform: none; }
.toast-error { border-left-color: #ff6b6b; }
.toast-success { border-left-color: #2ecc71; }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .nav { gap: 16px; padding: 0 16px; overflow-x: auto; }
  #nav-search { width: 140px; }
  .hero-content h1 { font-size: 2rem; }
  .hero-content { padding: 0 20px 40px; }
  .row h2 { margin: 0 20px 12px; }
  .row-scroll { padding: 4px 20px 12px; }
  .page { padding: 24px 20px 60px; }
  .card { width: 130px; }
  .details-top { flex-direction: column; }
  .details-poster { width: 150px; }
  .auth-card { padding: 32px 24px; }
  .avatar { width: 90px; height: 90px; font-size: 2.2rem; }
  .profile-tile { width: 100px; }
}
