:root {
  --bg: #141414;
  --bg-dark: #0a0a0a;
  --bg-card: #181818;
  --bg-elev: #232323;
  --text: #ffffff;
  --text-2: #b3b3b3;
  --text-3: #737373;
  --red: #e50914;
  --red-hover: #f40612;
  --border: #303030;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

button { font-family: inherit; }
a { color: var(--text); text-decoration: none; }
a:hover { text-decoration: underline; }

/* =====================================================
   AUTH (login / signup)
===================================================== */
.auth-body {
  min-height: 100vh;
  background: #000;
  display: flex;
  flex-direction: column;
  position: relative;
}
.auth-bg {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at top, rgba(229, 9, 20, 0.25), transparent 60%),
    linear-gradient(180deg, #000 0%, #0a0a0a 50%, #141414 100%);
  z-index: 0;
}
.auth-header {
  position: relative;
  z-index: 1;
  padding: 1.5rem 2rem;
}
.logo-big {
  font-size: 2rem;
  font-weight: 900;
  color: var(--red);
  letter-spacing: -1px;
}
.logo-big span {
  color: var(--text);
  font-weight: 400;
  font-size: 1.3rem;
  margin-left: .3rem;
  letter-spacing: .5rem;
}
.auth-main {
  position: relative;
  z-index: 1;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.auth-card {
  width: 100%;
  max-width: 420px;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(10px);
  padding: 2.5rem 2rem;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}
.auth-tabs {
  display: flex;
  gap: 2px;
  margin-bottom: 1.5rem;
  background: #222;
  border-radius: 4px;
  padding: 2px;
}
.auth-tabs .tab {
  flex: 1;
  background: transparent;
  border: 0;
  color: var(--text-2);
  padding: .7rem;
  cursor: pointer;
  font-size: .95rem;
  border-radius: 3px;
  font-weight: 500;
}
.auth-tabs .tab.active {
  background: var(--bg-elev);
  color: var(--text);
}
.auth-form { display: none; }
.auth-form.active { display: block; }
.auth-form h1 {
  font-size: 1.75rem;
  font-weight: 700;
  margin: 0 0 1.5rem;
}
.auth-form input {
  display: block;
  width: 100%;
  padding: 1rem;
  margin-bottom: .8rem;
  background: #333;
  border: 0;
  border-radius: 4px;
  color: var(--text);
  font-size: 1rem;
  transition: background .15s;
}
.auth-form input:focus {
  outline: none;
  background: #454545;
}
.btn-red {
  width: 100%;
  padding: 1rem;
  background: var(--red);
  border: 0;
  color: #fff;
  font-size: 1rem;
  font-weight: 700;
  border-radius: 4px;
  cursor: pointer;
  margin-top: .5rem;
  transition: background .15s;
}
.btn-red:hover:not(:disabled) { background: var(--red-hover); }
.btn-red:disabled { opacity: .5; cursor: not-allowed; }
.auth-error {
  color: #ffa09a;
  font-size: .85rem;
  min-height: 1.2em;
  margin: .6rem 0 0;
}
.auth-hint {
  color: var(--text-2);
  font-size: .9rem;
  margin: 1.2rem 0 0;
}
.auth-hint a { color: var(--text); font-weight: 500; }

/* =====================================================
   NAV
===================================================== */
.nav {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 2rem;
  background: linear-gradient(180deg, rgba(0,0,0,0.85) 0%, rgba(0,0,0,0.3) 80%, transparent 100%);
  transition: background .3s;
}
.nav.scrolled { background: var(--bg-dark); }
.nav-left { display: flex; align-items: center; gap: 1rem; }
.logo-small {
  font-weight: 900;
  color: var(--red);
  font-size: 1.4rem;
  letter-spacing: -1px;
  background: rgba(0, 0, 0, 0.5);
  padding: 2px 8px;
  border-radius: 4px;
}
.brand-text {
  font-size: .85rem;
  font-weight: 500;
  letter-spacing: 3px;
  color: var(--text);
}
.nav-right { display: flex; align-items: center; gap: 1rem; }
.nav-btn {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
}
.profile {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding-left: 1rem;
  border-left: 1px solid rgba(255,255,255,0.1);
}
.username {
  font-size: .9rem;
  color: var(--text);
}

.btn-ghost, .btn-ghost-lg {
  background: rgba(109, 109, 110, 0.5);
  border: 0;
  color: var(--text);
  padding: .5rem .9rem;
  border-radius: 4px;
  font-size: .85rem;
  cursor: pointer;
  font-weight: 500;
  transition: background .15s;
  display: inline-flex;
  align-items: center;
  gap: .4rem;
}
.btn-ghost:hover { background: rgba(109, 109, 110, 0.7); }
.btn-ghost-lg {
  padding: .7rem 1.4rem;
  font-size: 1rem;
}
.btn-white {
  background: var(--text);
  color: #000;
  border: 0;
  padding: .7rem 1.4rem;
  border-radius: 4px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  transition: background .15s;
}
.btn-white:hover { background: rgba(255,255,255,0.85); }

/* =====================================================
   HERO
===================================================== */
.hero {
  position: relative;
  height: min(70vh, 620px);
  min-height: 420px;
  margin-top: -72px;
  overflow: hidden;
}
.hero-video {
  position: absolute;
  inset: 0;
  background: #000;
}
.hero-video video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}
.hero-info {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 2rem 3rem;
  z-index: 10;
  max-width: 740px;
  pointer-events: none;
}
.hero-info > * { pointer-events: auto; }
.hero-title {
  font-size: clamp(1rem, 1.8vw, 1.4rem);
  font-weight: 700;
  margin: 0 0 .4rem;
  text-shadow: 0 2px 8px rgba(0,0,0,0.8);
  line-height: 1.2;
}
.hero-meta {
  font-size: clamp(.85rem, 1.2vw, 1.05rem);
  color: var(--text-2);
  margin-bottom: 1.2rem;
  text-shadow: 0 1px 4px rgba(0,0,0,0.8);
  max-width: 600px;
  line-height: 1.4;
}
.hero-actions { display: flex; gap: .7rem; flex-wrap: wrap; }
.hero-fade {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 30%;
  background: linear-gradient(180deg, transparent 0%, var(--bg) 100%);
  pointer-events: none;
  z-index: 1;
}
.hero:not(.has-track) .hero-video { display: flex; align-items: center; justify-content: center; }
.hero:not(.has-track) video { display: none; }
.hero:not(.has-track)::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 30% 30%, rgba(229, 9, 20, 0.25), transparent 60%),
    linear-gradient(180deg, #1a0a0a 0%, var(--bg) 100%);
}

/* =====================================================
   ROWS (carousels)
===================================================== */
.rows {
  padding: 2rem 0 4rem;
  position: relative;
  z-index: 2;
}
.row {
  margin-bottom: 3rem;
  position: relative;
}
.row-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 3rem;
  margin-bottom: .8rem;
}
.row-title {
  font-size: 1.3rem;
  font-weight: 700;
  margin: 0;
  color: var(--text);
}
.row-actions { display: flex; gap: .4rem; }
.row-actions button {
  background: transparent;
  border: 0;
  color: var(--text-2);
  font-size: .85rem;
  cursor: pointer;
  padding: .4rem .6rem;
  border-radius: 4px;
  transition: color .15s, background .15s;
}
.row-actions button:hover { color: var(--text); background: var(--bg-elev); }

.carousel-wrap {
  position: relative;
}
.carousel {
  display: flex;
  gap: .4rem;
  padding: 0 3rem;
  overflow-x: auto;
  scroll-behavior: smooth;
  scroll-padding: 3rem;
  scrollbar-width: none;
}
.carousel::-webkit-scrollbar { display: none; }

.carousel-arrow {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 3rem;
  background: rgba(20, 20, 20, 0.6);
  border: 0;
  color: var(--text);
  font-size: 1.6rem;
  cursor: pointer;
  z-index: 3;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, background .2s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.carousel-wrap:hover .carousel-arrow {
  opacity: 1;
  pointer-events: auto;
}
.carousel-arrow:hover { background: rgba(20, 20, 20, 0.85); }
.carousel-arrow.left { left: 0; }
.carousel-arrow.right { right: 0; }

.card {
  flex: 0 0 auto;
  width: 260px;
  border-radius: 4px;
  overflow: hidden;
  cursor: pointer;
  background: var(--bg-card);
  transition: transform .2s ease, box-shadow .2s ease;
  position: relative;
}
.card:hover {
  transform: scale(1.06);
  box-shadow: 0 10px 30px rgba(0,0,0,0.7);
  z-index: 5;
}
.card.playing { outline: 2px solid var(--red); }
.card-thumb {
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000 center/cover;
  position: relative;
}
.card-thumb .dur {
  position: absolute;
  right: 6px;
  bottom: 6px;
  background: rgba(0,0,0,0.85);
  font-size: .72rem;
  padding: 2px 5px;
  border-radius: 3px;
  font-weight: 500;
}
.card-body {
  padding: .5rem .7rem .7rem;
}
.card-title {
  font-size: .85rem;
  font-weight: 500;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: .2rem;
}
.card-author {
  font-size: .75rem;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.card-del {
  position: absolute;
  top: 6px;
  right: 6px;
  background: rgba(0, 0, 0, 0.75);
  border: 0;
  color: var(--text);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1rem;
  opacity: 0;
  line-height: 1;
  transition: opacity .15s, background .15s;
  z-index: 2;
}
.card:hover .card-del { opacity: 1; }
.card-del:hover { background: var(--red); }

.card-add {
  flex: 0 0 auto;
  width: 260px;
  aspect-ratio: 16 / 9;
  border: 2px dashed rgba(255,255,255,0.2);
  background: transparent;
  color: var(--text-2);
  border-radius: 4px;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  transition: border-color .2s, color .2s, background .2s;
}
.card-add:hover {
  border-color: var(--text);
  color: var(--text);
  background: rgba(255,255,255,0.04);
}

.row-empty {
  padding: 2rem 3rem;
  color: var(--text-3);
  font-size: .9rem;
}

.add-row {
  text-align: center;
  padding: 2rem;
}
.add-row button {
  background: transparent;
  border: 2px dashed rgba(255,255,255,0.2);
  color: var(--text-2);
  padding: 1rem 2rem;
  border-radius: 4px;
  font-size: 1rem;
  cursor: pointer;
  transition: border-color .15s, color .15s;
}
.add-row button:hover { border-color: var(--text); color: var(--text); }

/* =====================================================
   MODAL
===================================================== */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.modal[hidden] { display: none; }
.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
}
.modal-content {
  position: relative;
  background: var(--bg-card);
  border-radius: 8px;
  width: 100%;
  max-width: 800px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 2rem;
  box-shadow: 0 20px 60px rgba(0,0,0,0.8);
}
.modal-sm .modal-content { max-width: 440px; padding: 2.5rem; }

#listForm {
  display: flex;
  flex-direction: column;
  gap: .8rem;
  margin-top: .5rem;
}
#listForm input {
  width: 100%;
  padding: 1rem 1.1rem;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  font-size: 1rem;
  font-family: inherit;
  transition: border-color .15s, background .15s;
}
#listForm input::placeholder { color: var(--text-3); }
#listForm input:hover { border-color: var(--text-3); }
#listForm input:focus {
  outline: none;
  border-color: var(--red);
  background: var(--bg-dark);
}
#listForm button {
  margin-top: .3rem;
  width: 100%;
}
#listModalError:empty { display: none; }
#listModalError {
  color: #ffa09a;
  font-size: .85rem;
  margin: .4rem 0 0;
  padding: .5rem .8rem;
  background: rgba(229, 9, 20, 0.1);
  border-radius: 4px;
  border-left: 2px solid var(--red);
}
.modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: transparent;
  border: 0;
  color: var(--text);
  font-size: 1.3rem;
  cursor: pointer;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  transition: background .15s;
}
.modal-close:hover { background: var(--bg-elev); }
.modal-content h2 {
  font-size: 1.3rem;
  font-weight: 700;
  margin: 0 0 1.2rem;
}

.list-picker {
  display: flex;
  align-items: center;
  gap: .6rem;
  margin-bottom: 1.2rem;
  flex-wrap: wrap;
  padding: .8rem 1rem;
  background: var(--bg-elev);
  border-radius: 6px;
}
.list-picker label {
  font-size: .8rem;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: .5px;
  font-weight: 500;
}
.list-picker select {
  background: var(--bg-dark);
  color: var(--text);
  border: 1px solid var(--border);
  padding: .6rem .9rem;
  padding-right: 2.2rem;
  border-radius: 4px;
  font-size: .95rem;
  font-weight: 500;
  flex: 1;
  min-width: 180px;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23b3b3b3' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right .8rem center;
  transition: border-color .15s, background-color .15s;
}
.list-picker select:hover { border-color: var(--text-2); }
.list-picker select:focus { outline: none; border-color: var(--red); }

.search-form {
  display: flex;
  gap: .5rem;
  margin-bottom: 1rem;
}
.search-form input {
  flex: 1;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  color: var(--text);
  padding: .7rem 1rem;
  border-radius: 4px;
  font-size: .95rem;
}
.search-form input:focus { outline: none; border-color: var(--text-2); }
.search-form button {
  background: var(--red);
  border: 0;
  color: #fff;
  padding: 0 1.2rem;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.search-form button:hover:not(:disabled) { background: var(--red-hover); }
.search-form button:disabled { opacity: .4; cursor: wait; }

/* =====================================================
   LOADER / PROGRESS
===================================================== */
.loader {
  display: flex;
  flex-direction: column;
  gap: .5rem;
  padding: .8rem 1rem;
  background: var(--bg-elev);
  border-radius: 6px;
  margin-bottom: 1rem;
}
.loader[hidden] { display: none; }
.loader-row { display: flex; align-items: center; gap: .7rem; }
.spinner {
  width: 22px; height: 22px;
  border: 3px solid #333;
  border-top-color: var(--red);
  border-radius: 50%;
  animation: spin .8s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loader-text { font-size: .9rem; color: var(--text-2); flex: 1; }
.loader-percent { font-size: .85rem; font-weight: 500; font-variant-numeric: tabular-nums; }
.progress {
  width: 100%; height: 4px;
  background: #333; border-radius: 2px;
  overflow: hidden;
}
.progress-bar {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--red), #ff4d4d);
  transition: width .2s ease-out;
}
.progress-bar.indeterminate {
  width: 30%;
  animation: indet 1.2s ease-in-out infinite;
}
@keyframes indet { 0% { margin-left: -30%; } 100% { margin-left: 100%; } }

.status {
  font-size: .85rem;
  color: var(--text-2);
  min-height: 1.2em;
  margin: 0 0 1rem;
}

/* =====================================================
   RESULTS GRID (search)
===================================================== */
.results-grid {
  display: grid;
  gap: .5rem;
  margin-bottom: 1rem;
}
.results-grid li {
  display: grid;
  grid-template-columns: auto 168px 1fr;
  gap: .8rem;
  align-items: center;
  padding: .5rem;
  border-radius: 6px;
  cursor: pointer;
  background: var(--bg-elev);
  transition: background .15s;
  list-style: none;
}
.results-grid li:hover { background: #2a2a2a; }
.results-grid li.selected { background: rgba(229, 9, 20, 0.15); border: 1px solid var(--red); padding: calc(.5rem - 1px); }
.results-grid li.already { opacity: .5; cursor: default; }
.results-grid input[type="checkbox"] {
  width: 18px; height: 18px; accent-color: var(--red); cursor: pointer;
}
.results-grid .r-thumb {
  width: 168px;
  aspect-ratio: 16 / 9;
  border-radius: 4px;
  background: #000 center/cover;
  position: relative;
}
.results-grid .r-thumb .dur {
  position: absolute; right: 4px; bottom: 4px;
  background: rgba(0,0,0,0.85);
  font-size: .7rem;
  padding: 1px 4px;
  border-radius: 3px;
}
.results-grid .r-info { min-width: 0; }
.results-grid .r-info .t {
  font-size: .9rem; font-weight: 500; line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; margin-bottom: .25rem;
}
.results-grid .r-info .a { font-size: .78rem; color: var(--text-3); }
.already-tag { font-size: .7rem; color: var(--red); margin-left: .3rem; }

.results-actions {
  display: flex;
  gap: .5rem;
  justify-content: flex-end;
}

/* =====================================================
   Responsive
===================================================== */

/* Tablette (≤ 1024px) */
@media (max-width: 1024px) {
  .nav { padding: .9rem 1.5rem; }
  .hero-info { padding: 1.5rem 2rem; }
  .row-header { padding: 0 1.5rem; }
  .carousel { padding: 0 1.5rem; scroll-padding: 1.5rem; }
  .card, .card-add { width: 230px; }
}

/* Mobile (≤ 768px) */
@media (max-width: 768px) {
  .nav { padding: .7rem 1rem; }
  .brand-text { display: none; }
  .profile { padding-left: .5rem; border-left: 0; }
  .username { display: none; }
  .nav-btn span { display: none; }
  .nav-btn { padding: .5rem .6rem; }

  .hero { min-height: 260px; height: 45vh; margin-top: -56px; }
  .hero-info { padding: 1rem 1rem 1.2rem; max-width: 100%; }
  .hero-title { font-size: 1rem; margin-bottom: .3rem; }
  .hero-meta { font-size: .8rem; margin-bottom: .8rem; }
  .hero-actions { gap: .5rem; }
  .btn-white, .btn-ghost-lg { padding: .55rem 1rem; font-size: .88rem; }

  .rows { padding-top: 1rem; }
  .row { margin-bottom: 2rem; }
  .row-header { padding: 0 1rem; flex-wrap: wrap; gap: .4rem; }
  .row-title { font-size: 1.05rem; }
  .row-actions { flex-wrap: wrap; }
  .row-actions button { font-size: .8rem; padding: .3rem .5rem; }

  .carousel { padding: 0 1rem; gap: .3rem; scroll-padding: 1rem; }
  .card, .card-add { width: 180px; }
  .card:hover { transform: none; box-shadow: none; }
  .card-del { opacity: 1; width: 24px; height: 24px; font-size: .85rem; }
  .carousel-arrow { display: none; }

  .modal { padding: 0; align-items: flex-end; }
  .modal-content {
    padding: 1.2rem;
    max-height: 95vh;
    max-width: 100%;
    border-radius: 12px 12px 0 0;
  }
  .modal-sm { align-items: center; padding: 1rem; }
  .modal-sm .modal-content {
    padding: 1.5rem;
    border-radius: 8px;
  }
  .list-picker { padding: .6rem .8rem; }
  .list-picker select { min-width: 0; width: 100%; }
  .list-picker .btn-ghost { width: 100%; justify-content: center; }
  .search-form { flex-wrap: nowrap; }
  .search-form input { min-width: 0; }
  .results-grid li { grid-template-columns: auto 120px 1fr; gap: .5rem; padding: .4rem; }
  .results-grid .r-thumb { width: 120px; }
  .results-grid .r-info .t { font-size: .85rem; }
  .results-actions { flex-wrap: wrap; }
  .results-actions button { flex: 1; min-width: 0; }
}

/* Très petit (≤ 480px) */
@media (max-width: 480px) {
  .logo-small { font-size: 1.2rem; }
  .hero { min-height: 220px; }
  .hero-info { padding: .8rem .8rem 1rem; }
  .hero-title { font-size: .95rem; }
  .hero-meta { font-size: .75rem; margin-bottom: .6rem; }
  .btn-white svg, .btn-ghost-lg svg { width: 14px; height: 14px; }
  .card, .card-add { width: 150px; }
  .card-title { font-size: .78rem; }
  .card-author { font-size: .7rem; }
  .auth-card { padding: 2rem 1.2rem; }
  .auth-form h1 { font-size: 1.4rem; }
  .logo-big { font-size: 1.5rem; }
  .logo-big span { font-size: 1rem; letter-spacing: .3rem; }
}

/* Orientation paysage sur petit écran — hero plus court */
@media (max-height: 500px) and (orientation: landscape) {
  .hero { min-height: 200px; height: 75vh; }
  .hero-info { padding: 1rem 2rem; }
  .hero-title { font-size: 1rem; }
}

/* Écrans sans hover (tactile) */
@media (hover: none) {
  .card:hover { transform: none; box-shadow: none; z-index: auto; }
  .card-del { opacity: 1; }
  .carousel-arrow { display: none; }
}
