:root {
  --bg: #0c0d12;
  --bg-soft: #14161f;
  --panel: #171a24;
  --panel-2: #1d212d;
  --line: #262b39;
  --text: #e8eaf2;
  --muted: #939cb4;
  --accent: #8b5cf6;
  --accent-2: #e5309a;
  --accent-3: #ff9018;
  --ok: #35d39a;
  --warn: #ffb547;
  --err: #ff5f6d;
  --radius: 14px;
  --shadow: 0 12px 32px rgba(0, 0, 0, .45);
}

* { box-sizing: border-box; }

/* Prioritaire sur les display: flex des composants. */
[hidden] { display: none !important; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  background:
    radial-gradient(1100px 600px at 12% -8%, rgba(124, 92, 255, .20), transparent 60%),
    radial-gradient(900px 520px at 92% 4%, rgba(255, 92, 168, .14), transparent 60%),
    var(--bg);
  color: var(--text);
  font: 15px/1.5 "Segoe UI", Inter, system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }

/* ---------- Structure ---------- */

.app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 20px;
  background: rgba(12, 13, 18, .82);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  letter-spacing: .3px;
  white-space: nowrap;
}

.brand .mark { width: 36px; height: 36px; display: block; filter: drop-shadow(0 3px 10px rgba(229, 48, 154, .35)); }

.brand .wordmark {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -.3px;
}

/* Signature du logo : violet -> magenta -> orange */
.gradient-text,
.tagline {
  background: linear-gradient(100deg, var(--accent), var(--accent-2) 45%, var(--accent-3));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.login-brand { text-align: center; margin-bottom: 26px; }
.login-brand .mark-lg { width: 84px; height: 84px; }

.wordmark-lg {
  margin-top: 10px;
  font-size: 34px;
  font-weight: 700;
  letter-spacing: -.5px;
  line-height: 1;
}

.tagline {
  margin-top: 8px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 2.4px;
  text-transform: uppercase;
}

.topbar .spacer { flex: 1; }

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px 6px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  font-size: 13px;
  white-space: nowrap;
}

.layout {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 420px;
  gap: 20px;
  padding: 20px;
  align-items: start;
}

/* ---------- Recherche ---------- */

.search-card {
  background: linear-gradient(180deg, var(--panel), var(--bg-soft));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}

.search-row {
  display: flex;
  gap: 10px;
}

.search-row input[type="search"] {
  flex: 1;
  min-width: 0;
  padding: 13px 16px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #0f111a;
  outline: none;
}

.search-row input[type="search"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(124, 92, 255, .18);
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 10px 15px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  font-size: 14px;
  transition: .15s border-color, .15s background, .15s transform;
}

.btn:hover:not(:disabled) { border-color: #3a4158; background: #232838; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.btn.primary {
  background: linear-gradient(135deg, var(--accent), #6446e8);
  border-color: transparent;
  font-weight: 600;
}

.btn.pink { background: linear-gradient(135deg, var(--accent-2), #ff6a3d); border-color: transparent; font-weight: 600; }
.btn.ghost { background: transparent; }
.btn.small { padding: 6px 10px; font-size: 13px; border-radius: 9px; }
.btn.danger:hover:not(:disabled) { border-color: var(--err); color: #ffb9be; }

.options-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
  font-size: 13px;
  color: var(--muted);
}

.options-row select {
  padding: 7px 10px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: #0f111a;
}

.hint {
  margin-top: 10px;
  font-size: 12.5px;
  color: var(--muted);
}

/* ---------- Resultats ---------- */

.results-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 22px 2px 12px;
}

.results-head h2 { margin: 0; font-size: 16px; font-weight: 600; }
.results-head .count { color: var(--muted); font-size: 13px; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}

.card {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: .18s transform, .18s border-color;
}

.card:hover { transform: translateY(-2px); border-color: #39405a; }

.thumb {
  position: relative;
  aspect-ratio: 16 / 9;
  background: #0a0b11 center/cover no-repeat;
}

.thumb .badge {
  position: absolute;
  right: 8px;
  bottom: 8px;
  padding: 2px 7px;
  border-radius: 6px;
  background: rgba(0, 0, 0, .78);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.card-body { padding: 11px 12px 12px; display: flex; flex-direction: column; gap: 8px; flex: 1; }

.card-title {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-meta { font-size: 12.5px; color: var(--muted); display: flex; gap: 8px; align-items: center; }
.card-meta span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.card-actions { display: flex; gap: 7px; margin-top: auto; }
.card-actions .btn { flex: 1; justify-content: center; }
.card-actions .more { flex: 0 0 38px; }

/* ---------- Menu qualite ---------- */

.popover {
  position: absolute;
  z-index: 60;
  min-width: 210px;
  padding: 8px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  box-shadow: var(--shadow);
}

.popover h4 { margin: 6px 8px; font-size: 11.5px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); }
.popover button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 7px 9px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  font-size: 13.5px;
}
.popover button:hover { background: #2a3043; }

/* ---------- Panneau lateral ---------- */

.side {
  position: sticky;
  top: 76px;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 96px);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.tabs { display: flex; border-bottom: 1px solid var(--line); }

.tabs button {
  flex: 1;
  padding: 13px 10px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-weight: 600;
  font-size: 14px;
  border-bottom: 2px solid transparent;
}

.tabs button.active { color: var(--text); border-bottom-color: var(--accent); background: rgba(124, 92, 255, .07); }
.tabs .pill {
  display: inline-block;
  min-width: 20px;
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 11.5px;
}
.tabs .pill.zero { background: #333a4d; color: var(--muted); }

.tab-panel { display: none; flex-direction: column; min-height: 0; flex: 1; }
.tab-panel.active { display: flex; }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-soft);
}

.toolbar .grow { flex: 1; }

.scroll { overflow-y: auto; padding: 10px 12px 16px; display: flex; flex-direction: column; gap: 10px; }

.scroll::-webkit-scrollbar { width: 10px; }
.scroll::-webkit-scrollbar-thumb { background: #2b3145; border-radius: 8px; border: 3px solid var(--panel); }

.empty { padding: 34px 18px; text-align: center; color: var(--muted); font-size: 13.5px; }

/* ---------- Elements de liste ---------- */

.row {
  display: flex;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg-soft);
}

.row .mini {
  flex: 0 0 62px;
  height: 40px;
  border-radius: 8px;
  background: #0a0b11 center/cover no-repeat;
}

.row .info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 5px; }

.row .name {
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}

.row .sub { font-size: 12px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.row .actions { display: flex; gap: 6px; align-items: flex-start; }
.row .actions .btn { padding: 6px 9px; }
.row input[type="checkbox"] { width: 17px; height: 17px; accent-color: var(--accent); margin-top: 3px; }

.tag {
  padding: 1px 7px;
  border-radius: 6px;
  background: #262c3d;
  font-size: 11.5px;
  color: #c3cbe2;
  white-space: nowrap;
}
.tag.audio { background: rgba(53, 211, 154, .16); color: #7ff0c6; }
.tag.video { background: rgba(124, 92, 255, .18); color: #c1b2ff; }
.tag.keep { background: rgba(255, 181, 71, .16); color: #ffd08a; }
.tag.err { background: rgba(255, 95, 109, .16); color: #ffaeb4; }

.bar {
  height: 6px;
  border-radius: 999px;
  background: #232838;
  overflow: hidden;
}

.bar > i {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2) 55%, var(--accent-3));
  transition: width .3s ease;
}

.bar.indeterminate > i {
  width: 35%;
  animation: slide 1.2s ease-in-out infinite;
}

@keyframes slide {
  0% { margin-left: -35%; }
  100% { margin-left: 100%; }
}

.usage {
  padding: 10px 12px;
  border-top: 1px solid var(--line);
  background: var(--bg-soft);
  font-size: 12px;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* ---------- Divers ---------- */

.spinner {
  width: 16px; height: 16px;
  border: 2px solid rgba(255, 255, 255, .25);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.toasts {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 80;
  display: flex;
  flex-direction: column;
  gap: 9px;
  max-width: min(360px, 90vw);
}

.toast {
  padding: 11px 14px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  box-shadow: var(--shadow);
  font-size: 13.5px;
  animation: pop .2s ease;
}

.toast.ok { border-color: rgba(53, 211, 154, .5); }
.toast.err { border-color: rgba(255, 95, 109, .5); }

@keyframes pop { from { opacity: 0; transform: translateY(8px); } }

.skeleton {
  border-radius: var(--radius);
  height: 210px;
  background: linear-gradient(90deg, #171a24, #1e2231, #171a24);
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite;
}

@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- Connexion ---------- */

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(380px, 100%);
  padding: 28px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.login-card h1 { margin: 14px 0 6px; font-size: 22px; }
.login-card { text-align: left; }
.login-card p.sub { margin: 0 0 22px; color: var(--muted); font-size: 13.5px; }

.field { margin-bottom: 14px; display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12.5px; color: var(--muted); }
.field input {
  padding: 11px 13px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: #0f111a;
  outline: none;
}
.field input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(124, 92, 255, .18); }

.error-box {
  display: none;
  margin-bottom: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(255, 95, 109, .12);
  border: 1px solid rgba(255, 95, 109, .4);
  font-size: 13px;
}

/* ---------- Administration ---------- */

.admin-wrap { max-width: 1000px; margin: 0 auto; padding: 24px 20px 60px; }
.admin-wrap h1 { font-size: 20px; }

table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .5px; }
td .btn.small { margin-right: 6px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin: 18px 0 26px; }
.stat { padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); }
.stat b { display: block; font-size: 20px; margin-bottom: 2px; }
.stat span { font-size: 12px; color: var(--muted); }

/* ---------- Suggestions ---------- */

.reco-section { margin-bottom: 30px; }

.reco-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 2px 12px;
}

.reco-head h3 { margin: 0; font-size: 15px; font-weight: 600; }

/* ---------- Bouton lecture sur la vignette ---------- */

.thumb .play-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  width: 100%;
  border: 0;
  background: rgba(8, 9, 14, .45);
  color: #fff;
  font-size: 30px;
  opacity: 0;
  transition: opacity .15s;
}

.card:hover .thumb .play-overlay,
.thumb .play-overlay:focus-visible { opacity: 1; }

@media (hover: none) {
  .thumb .play-overlay {
    inset: auto 8px 8px auto;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: rgba(124, 92, 255, .92);
    font-size: 17px;
    opacity: 1;
  }
}

/* ---------- Lecteur ---------- */

.player {
  position: sticky;
  bottom: 0;
  z-index: 40;
  display: none;
  grid-template-columns: minmax(0, 1.4fr) auto minmax(220px, 2fr) auto;
  align-items: center;
  gap: 18px;
  padding: 10px 18px;
  background: rgba(18, 20, 28, .96);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  box-shadow: 0 -8px 26px rgba(0, 0, 0, .4);
}

.player.visible { display: grid; }

.player-track { display: flex; align-items: center; gap: 12px; min-width: 0; }
.player-track .mini { flex: 0 0 54px; height: 34px; border-radius: 7px; background: #0a0b11 center/cover no-repeat; }
.player-meta { min-width: 0; }
.player-meta .name {
  font-size: 13.5px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.player-meta .sub { display: flex; gap: 7px; align-items: center; font-size: 12px; color: var(--muted); }
.player-meta .sub span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.player-controls { display: flex; align-items: center; gap: 8px; }

.btn.round {
  width: 40px;
  height: 40px;
  padding: 0;
  justify-content: center;
  border-radius: 50%;
  font-size: 15px;
}

.badge-mini {
  margin-left: 3px;
  font-size: 10.5px;
  color: var(--accent);
  vertical-align: super;
}

.player-progress {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 11.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.player-progress input[type="range"] { flex: 1; min-width: 0; }

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  border-radius: 999px;
  background: #2b3145;
  outline: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
}

input[type="range"]::-moz-range-thumb {
  width: 13px; height: 13px;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
}

input[type="range"]:disabled { opacity: .5; }
input[type="range"]:disabled::-webkit-slider-thumb { background: #4c5470; cursor: default; }

.player-extras { display: flex; align-items: center; gap: 10px; }
.player-extras input[type="range"] { width: 88px; }

.radio-toggle.on {
  border-color: var(--accent);
  color: #cdbfff;
  background: rgba(124, 92, 255, .14);
}

.row.compact { padding: 8px 10px; align-items: center; cursor: pointer; }
.row.compact:hover { border-color: #39405a; }
.row.playing { border-color: var(--accent); background: rgba(124, 92, 255, .1); }

/* ---------- Fenêtre de compte ---------- */

.modal {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(6, 7, 11, .7);
  backdrop-filter: blur(3px);
  overflow-y: auto;
}

.modal-card {
  width: min(560px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.modal-head {
  display: flex;
  align-items: center;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}
.modal-head h2 { margin: 0; font-size: 16px; flex: 1; }

.modal-section { padding: 16px 18px; border-bottom: 1px solid var(--line); }
.modal-section:last-child { border-bottom: 0; }
.modal-section h3 { margin: 0 0 8px; font-size: 14px; display: flex; gap: 8px; align-items: center; }
.modal-section .muted { color: var(--muted); font-size: 12.5px; margin: 6px 0; }
.modal-section code { background: #0f111a; padding: 1px 5px; border-radius: 5px; font-size: 12px; }
.modal-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.modal-actions label.btn { cursor: pointer; }

.warn-box {
  margin: 10px 0 0;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 181, 71, .4);
  background: rgba(255, 181, 71, .1);
  font-size: 12.5px;
  color: #ffdca8;
}

/* ---------- Responsive ---------- */

@media (max-width: 1080px) {
  .layout { grid-template-columns: 1fr; }
  .side { position: static; max-height: none; }
  .scroll { max-height: 60vh; }
}

@media (max-width: 900px) {
  .player {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "track controls" "progress progress" "extras extras";
    gap: 8px 12px;
    padding: 10px 12px;
  }
  .player-track { grid-area: track; }
  .player-controls { grid-area: controls; }
  .player-progress { grid-area: progress; }
  .player-extras { grid-area: extras; justify-content: space-between; }
  .player-extras input[type="range"] { flex: 1; margin: 0 10px; }
}

@media (max-width: 620px) {
  .topbar { padding: 10px 12px; gap: 10px; }
  .layout { padding: 12px; gap: 14px; }
  .search-row { flex-direction: column; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
  .user-chip .who { display: none; }
}
