/* DJ Mousse — interface sombre. Jetons de couleur issus de la palette de
   référence data-viz, validés pour la surface sombre #1a1a19. */

:root {
  color-scheme: dark;

  --page:           #0d0d0d;
  --surface-1:      #1a1a19;
  --surface-2:      #222220;
  --surface-3:      #2c2c2a;

  --text-primary:   #ffffff;
  --text-secondary: #c3c2b7;
  --text-muted:     #898781;

  --gridline:       #2c2c2a;
  --baseline:       #383835;
  --border:         rgba(255, 255, 255, 0.10);

  --series-1:       #3987e5;   /* énergie — série unique du graphique */
  --accent:         #3987e5;
  --accent-ink:     #ffffff;

  --good:           #0ca30c;
  --warning:        #fab219;
  --serious:        #ec835a;
  --critical:       #d03b3b;

  --radius:         10px;
  --radius-sm:      6px;
  --sans: system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--page);
  color: var(--text-primary);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
}

h1, h2, h3 { margin: 0 0 .25em; font-weight: 600; line-height: 1.25; }
h1 { font-size: 1.35rem; }
h2 { font-size: 1.05rem; letter-spacing: .01em; }

abbr { text-decoration: underline dotted var(--text-muted); cursor: help; }

/* ------------------------------------------------------------------ entête */

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  flex-wrap: wrap;
  padding: 1rem 1.5rem;
  background: var(--surface-1);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: .8rem; }
.brand-mark { font-size: 2rem; line-height: 1; }
.brand-sub { margin: 0; color: var(--text-secondary); font-size: .85rem; }

.status-pills { display: flex; gap: .5rem; flex-wrap: wrap; }
.pill {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .3rem .7rem; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--border);
  font-size: .8rem; color: var(--text-secondary);
}
.pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-muted); }
.pill.ok    .dot { background: var(--good); }
.pill.bad   .dot { background: var(--critical); }
.pill.warn  .dot { background: var(--warning); }
.pill.off   .dot { background: var(--text-muted); }

/* Badge cliquable : déclenche l'envoi de la seule ligne concernée. */
button.pill { font: inherit; font-size: .8rem; appearance: none; }
.pill-action { cursor: pointer; transition: background .12s, border-color .12s, color .12s; }
.pill-action:hover:not(:disabled) {
  background: var(--surface-3); border-color: var(--accent); color: var(--text-primary);
}
.pill-action:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.pill-action:disabled { cursor: default; opacity: .45; }

/* ------------------------------------------------------------------ onglets */

.tabs {
  display: flex; gap: .25rem; padding: 0 1.5rem;
  background: var(--surface-1); border-bottom: 1px solid var(--border);
  overflow-x: auto;
}
.tab {
  appearance: none; background: none; border: 0; border-bottom: 2px solid transparent;
  color: var(--text-secondary); font: inherit; font-size: .92rem;
  padding: .7rem 1rem; cursor: pointer; white-space: nowrap;
}
.tab:hover { color: var(--text-primary); }
.tab.is-active { color: var(--text-primary); border-bottom-color: var(--accent); }

main { max-width: 1180px; margin: 0 auto; padding: 1.5rem; }
.panel { display: none; }
.panel.is-active { display: block; }
.is-hidden { display: none !important; }

/* ------------------------------------------------------------------- cartes */

.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}
.result-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap; margin-bottom: .75rem;
}
.result-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.result-actions .input { min-width: 260px; }

.hint { color: var(--text-muted); font-size: .85rem; margin: .35rem 0 0; }
.hint-inline { color: var(--text-muted); font-size: .8rem; }

/* --------------------------------------------------------------- formulaires */

.input {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font: inherit;
  padding: .5rem .65rem;
}
.input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.input::placeholder { color: var(--text-muted); }

.param-grid {
  display: grid; gap: .85rem;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  margin: .75rem 0;
}
.param-grid label { display: flex; flex-direction: column; gap: .3rem; font-size: .85rem; color: var(--text-secondary); }
.param-grid .span2 { grid-column: span 2; }
@media (max-width: 620px) { .param-grid .span2 { grid-column: span 1; } }

.with-unit { position: relative; display: flex; align-items: center; }
.with-unit .input { padding-right: 2.6rem; }
.with-unit span { position: absolute; right: .65rem; color: var(--text-muted); font-size: .8rem; }

.switch-row { display: flex; flex-wrap: wrap; gap: 1rem; margin: .5rem 0; }
/* Deux jeux de filtres sur la même ligne : le libellé rattache visuellement
   les boutons radio à leur critère, sinon les six options se lisent en vrac. */
.filter-group { display: flex; align-items: center; flex-wrap: wrap; gap: .75rem; }
.filter-group + .filter-group {
  padding-left: 1rem; border-left: 1px solid var(--border);
}
.filter-label {
  font-size: .75rem; text-transform: uppercase; letter-spacing: .04em;
  color: var(--text-muted);
}
.switch { display: flex; align-items: center; gap: .45rem; font-size: .85rem; color: var(--text-secondary); cursor: pointer; }
.switch input { accent-color: var(--accent); width: 16px; height: 16px; }

.actions { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; margin-top: .85rem; }

.btn {
  appearance: none; cursor: pointer; font: inherit; font-size: .9rem;
  background: var(--surface-2); color: var(--text-primary);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: .5rem .95rem;
}
.btn:hover:not(:disabled) { background: var(--surface-3); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; font-weight: 600; }
.btn-primary:hover:not(:disabled) { filter: brightness(1.12); }
.btn-danger:hover:not(:disabled) { background: var(--critical); border-color: transparent; }
.btn-sm { padding: .25rem .55rem; font-size: .8rem; }

/* -------------------------------------------------------------------- thèmes */

.theme-grid {
  display: grid; gap: .7rem; margin-top: .85rem;
  grid-template-columns: repeat(auto-fill, minmax(215px, 1fr));
}
.theme-card {
  text-align: left; cursor: pointer; font: inherit;
  background: var(--surface-2); color: var(--text-primary);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: .75rem .85rem;
  display: flex; gap: .6rem; align-items: flex-start;
}
.theme-card:hover { border-color: var(--baseline); background: var(--surface-3); }
.theme-card.is-active { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.theme-card .emo { font-size: 1.35rem; line-height: 1.1; }
.theme-card .nm { font-weight: 600; font-size: .92rem; }
.theme-card .ds { color: var(--text-muted); font-size: .78rem; line-height: 1.35; margin-top: .15rem; }

.theme-list { display: flex; flex-direction: column; gap: .55rem; margin-top: .85rem; }
.theme-row {
  display: flex; align-items: center; gap: .75rem; flex-wrap: wrap;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: .6rem .8rem;
}
.theme-row .emo { font-size: 1.2rem; }
.theme-row .grow { flex: 1 1 240px; min-width: 0; }
.theme-row .nm { font-weight: 600; font-size: .9rem; }
.theme-row .rules { color: var(--text-muted); font-size: .77rem; }
.badge {
  font-size: .7rem; padding: .1rem .45rem; border-radius: 999px;
  background: var(--surface-3); color: var(--text-muted); border: 1px solid var(--border);
}

.genre-help { margin-top: 1rem; }
.genre-help summary { cursor: pointer; color: var(--text-secondary); font-size: .85rem; }
.genre-cloud { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .6rem; max-height: 220px; overflow-y: auto; }
.genre-chip {
  font: inherit; font-size: .76rem; cursor: pointer;
  background: var(--surface-2); color: var(--text-secondary);
  border: 1px solid var(--border); border-radius: 999px; padding: .18rem .55rem;
}
.genre-chip:hover { color: var(--text-primary); border-color: var(--accent); }
.genre-chip .n { color: var(--text-muted); }

/* -------------------------------------------------------------------- tuiles */

.tiles {
  display: grid; gap: .7rem; margin: 1rem 0;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}
.tile {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: .7rem .85rem;
  display: flex; flex-direction: column; gap: .15rem;
}
.tile-label { color: var(--text-muted); font-size: .76rem; }
.tile-value { font-size: 1.4rem; font-weight: 600; }
.tile-note { color: var(--text-muted); font-size: .74rem; }
.tile-hero { grid-column: span 2; }
@media (max-width: 620px) { .tile-hero { grid-column: span 1; } }
.tile-hero-value { font-size: 3rem; font-weight: 600; line-height: 1.05; }

/* ---------------------------------------------------------------- graphique */

.chart-figure { margin: 1.25rem 0 .5rem; }
.chart-figure figcaption { display: flex; flex-direction: column; gap: .15rem; margin-bottom: .6rem; }
.chart-figure figcaption strong { font-size: .95rem; font-weight: 600; }
.chart-sub { color: var(--text-muted); font-size: .8rem; }

.chart-wrap {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .5rem;
  overflow-x: auto;
}
.chart-wrap svg { display: block; }
.chart-grid  { stroke: var(--gridline); stroke-width: 1; }
.chart-axis  { stroke: var(--baseline); stroke-width: 1; }
.chart-tick  { fill: var(--text-muted); font-size: 10px; font-variant-numeric: tabular-nums; }
.chart-band  { fill: var(--text-muted); font-size: 10px; }
.chart-bar   { fill: var(--series-1); }
.chart-hit   { fill: transparent; cursor: pointer; }
.chart-hit:hover + .chart-bar, .chart-bar.is-on { fill: #7fb2f0; }
.chart-sep   { stroke: var(--baseline); stroke-width: 1; stroke-dasharray: 0; }

.chart-tip {
  position: fixed; z-index: 60; pointer-events: none;
  background: var(--surface-3); color: var(--text-primary);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: .45rem .6rem; font-size: .8rem; max-width: 280px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .5);
}
.chart-tip b { display: block; font-weight: 600; }
.chart-tip span { color: var(--text-secondary); }

/* ---------------------------------------------------------------- tableaux */

.table-wrap { overflow-x: auto; margin-top: .5rem; }
table.tracks { width: 100%; border-collapse: collapse; font-size: .86rem; }
table.tracks th {
  text-align: left; font-weight: 600; color: var(--text-muted); font-size: .76rem;
  text-transform: uppercase; letter-spacing: .04em;
  padding: .45rem .5rem; border-bottom: 1px solid var(--baseline); white-space: nowrap;
}
table.tracks td { padding: .45rem .5rem; border-bottom: 1px solid var(--gridline); vertical-align: middle; }
table.tracks tbody tr:hover { background: var(--surface-2); }
table.tracks tbody tr.is-focus { background: var(--surface-3); }
.col-num, .col-e, .col-bpm, .col-year, .col-dur { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.col-act { width: 1%; white-space: nowrap; }
.muted { color: var(--text-muted); }
/* Les URL de flux radio sont longues et sans espaces : sans coupure forcée,
   elles imposent leur largeur à toute la table. */
.radio-url { font-size: .8rem; max-width: 32rem; overflow-wrap: anywhere; }
.sec {
  font-size: .72rem; padding: .1rem .45rem; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text-secondary);
  white-space: nowrap;
}

/* ------------------------------------------------------------------ divers */

/* Liens sortants vers Lidarr et Navidrome : discrets, jamais confondus avec un
   bouton d'action. */
.ext {
  color: var(--series-1); text-decoration: none;
  font-size: .76rem; white-space: nowrap;
  border-bottom: 1px solid transparent;
}
.ext:hover { border-bottom-color: var(--series-1); }

/* Jauge de couverture : la piste non remplie est un pas plus clair de la même
   rampe, pour que l'état se lise sur toute la largeur. */
.meter {
  display: inline-block; width: 110px; height: 6px; vertical-align: middle;
  background: #1c5cab; border-radius: 999px; overflow: hidden;
}
.meter-fill { display: block; height: 100%; background: var(--series-1); border-radius: 999px; }

.notice {
  border-left: 3px solid var(--warning);
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: .6rem .8rem; margin: .5rem 0; font-size: .85rem;
  color: var(--text-secondary);
}
.notice.error { border-left-color: var(--critical); }
.notice.ok    { border-left-color: var(--good); }

.progress { height: 6px; background: var(--surface-3); border-radius: 999px; overflow: hidden; margin-top: .75rem; }
.progress-bar { height: 100%; width: 0; background: var(--accent); transition: width .25s ease; }

.log {
  margin-top: .75rem; max-height: 220px; overflow-y: auto;
  background: var(--page); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: .6rem .7rem; font-size: .75rem; color: var(--text-secondary);
  white-space: pre-wrap; word-break: break-word;
}

.pl-row {
  display: flex; align-items: center; gap: .75rem; flex-wrap: wrap;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: .65rem .8rem; margin-bottom: .55rem;
}
.pl-row .grow { flex: 1 1 260px; min-width: 0; }
.pl-row .nm { font-weight: 600; font-size: .92rem; }
.pl-row .meta { color: var(--text-muted); font-size: .78rem; }

.toast-stack { position: fixed; right: 1rem; bottom: 1rem; display: flex; flex-direction: column; gap: .5rem; z-index: 80; }
.toast {
  background: var(--surface-3); border: 1px solid var(--border);
  border-left: 3px solid var(--accent); border-radius: var(--radius-sm);
  padding: .6rem .8rem; font-size: .85rem; max-width: 380px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .5);
}
.toast.error { border-left-color: var(--critical); }
.toast.ok    { border-left-color: var(--good); }

.empty { color: var(--text-muted); font-size: .88rem; padding: .75rem 0; }
/* Split FLAC reste un module autonome côté serveur, présenté ici comme une
   surface native de DJ Mousse sous le même domaine. */
.split-flac-panel { max-width:none; padding:0; }
.split-flac-panel iframe { display:block; width:100%; min-height:720px; border:0; background:#090d0c; }
