/* Mélodia — studio de nuit : fond encre, lumière ambrée de console, vert de VU-mètre. */
:root {
  --bg: #12100e;
  --panel: #1c1916;
  --panel-2: #25211d;
  --line: #3a332c;
  --text: #f1e9de;
  --muted: #a99d8f;
  --amber: #f4a640;
  --amber-2: #ffcf87;
  --green: #7fd18b;
  --red: #ef6f5e;
  --display: "Bricolage Grotesque", "Trebuchet MS", sans-serif;
  --body: "Figtree", system-ui, "Segoe UI", sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: radial-gradient(1200px 600px at 15% -10%, #2c2116 0%, transparent 60%), var(--bg);
  color: var(--text); font: 15px/1.5 var(--body); min-height: 100vh;
}
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }
[hidden] { display: none !important; }
code { background: var(--panel-2); padding: 1px 6px; border-radius: 4px; font-size: .9em; }

/* ------------------------------------------------ logo (égaliseur animé) */
.logo { font: 700 24px/1 var(--display); display: flex; align-items: center; gap: 10px; letter-spacing: -.01em; }
.eq { display: inline-flex; align-items: flex-end; gap: 3px; height: 22px; }
.eq i { width: 4px; background: var(--amber); border-radius: 2px; animation: eq 1.1s ease-in-out infinite; }
.eq i:nth-child(1) { height: 40%; animation-delay: -.3s; } .eq i:nth-child(2) { height: 90%; animation-delay: -.7s; }
.eq i:nth-child(3) { height: 60%; animation-delay: -.1s; } .eq i:nth-child(4) { height: 75%; animation-delay: -.5s; }
@keyframes eq { 50% { transform: scaleY(.35); } }
.eq i { transform-origin: bottom; }

/* ------------------------------------------------ connexion */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card { width: min(400px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 30px; display: flex; flex-direction: column; gap: 10px; }
.login-card p { color: var(--muted); margin: 4px 0 10px; }
.login-card input { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px; }
.err { color: var(--red) !important; }

/* ------------------------------------------------ en-tête */
.top { display: flex; align-items: center; gap: 14px; padding: 16px 28px; border-bottom: 1px solid var(--line); }
.badge { background: #3b2b12; color: var(--amber-2); border: 1px solid #6a4a1a; font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 99px; }
.usage { margin-left: auto; color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.link { color: var(--muted); text-decoration: none; font-size: 14px; }
.link:hover { color: var(--text); }
.banner { margin: 0; padding: 10px 28px; background: #3a1d17; color: #ffd2c9; font-size: 14px; }

/* ------------------------------------------------ disposition */
.studio { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 22px; padding: 22px 28px 40px; max-width: 1400px; margin: 0 auto; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 22px 24px; }
.panel h1, .panel h2 { font: 700 26px/1.1 var(--display); margin: 0 0 16px; letter-spacing: -.01em; }

/* ------------------------------------------------ modes */
.modes { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 18px; }
.modes button { text-align: left; border: 1px solid var(--line); background: var(--bg); border-radius: 12px; padding: 11px 14px; cursor: pointer; }
.modes button b { display: block; font-weight: 600; }
.modes button small { color: var(--muted); font-size: 12.5px; }
.modes button[aria-selected="true"] { border-color: var(--amber); background: #2a2014; box-shadow: inset 0 0 0 1px var(--amber); }

/* ------------------------------------------------ champs */
.field > .lbl { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; font-size: 13.5px; color: var(--muted); font-weight: 500; }
.field input, .field select, .field textarea, .sections input, .sections textarea, #lib-search, select {
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; color: var(--text); font-weight: 400;
}
.field textarea { resize: vertical; min-height: 90px; }
.field input[type=range] { padding: 0; border: 0; background: none; accent-color: var(--amber); }
.field output { color: var(--amber-2); font-variant-numeric: tabular-nums; }
.opt { font-weight: 400; color: #7d7266; font-size: 12px; }
.row3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.inline { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13.5px; }
.hint { color: #8e8273; font-size: 12.5px; margin: 6px 0 12px; }

.chips-group { border: 0; padding: 0; margin: 0 0 14px; min-width: 0; }
.chips-group legend { font-size: 13.5px; color: var(--muted); font-weight: 500; margin-bottom: 6px; padding: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--line); background: var(--bg); border-radius: 99px; padding: 5px 12px; cursor: pointer; font-size: 13.5px; transition: background .12s, border-color .12s; }
.chip:hover { border-color: #5a4e40; }
.chip[aria-pressed="true"] { background: var(--amber); border-color: var(--amber); color: #1a1208; font-weight: 600; }

.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; margin: 2px 0 16px; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch span { width: 40px; height: 22px; background: var(--line); border-radius: 99px; position: relative; transition: background .15s; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: var(--text); transition: transform .15s; }
.switch input:checked + span { background: var(--green); }
.switch input:checked + span::after { transform: translateX(18px); }
.switch input:focus-visible + span { outline: 2px solid var(--amber); outline-offset: 2px; }

details.more { border-top: 1px solid var(--line); padding-top: 10px; margin: 6px 0 4px; }
details.more summary { cursor: pointer; color: var(--muted); font-size: 14px; margin-bottom: 12px; }

/* ------------------------------------------------ boutons */
.btn { border: 1px solid var(--line); background: var(--panel-2); border-radius: 10px; padding: 9px 15px; cursor: pointer; font-weight: 600; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }
.btn:hover { border-color: #5a4e40; }
.btn.primary { background: var(--amber); border-color: var(--amber); color: #1a1208; }
.btn.primary:hover { background: var(--amber-2); }
.btn.big { padding: 13px 26px; font-size: 16px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.go { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-top: 8px; }
.go-note { color: var(--muted); font-size: 13px; }

/* ------------------------------------------------ éditeur de chanson */
.assist { background: #211b14; border: 1px dashed #5a4528; border-radius: 12px; padding: 12px 14px; margin-bottom: 14px; display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.assist .hint { flex-basis: 100%; margin: 0; }
.sections { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; counter-reset: sec; }
.section { background: var(--bg); border: 1px solid var(--line); border-left: 3px solid var(--amber); border-radius: 12px; padding: 10px 12px; }
.section.instrumental { border-left-color: var(--green); }
.section-head { display: grid; grid-template-columns: 1fr 92px auto; gap: 8px; align-items: center; margin-bottom: 8px; }
.section-head input { padding: 6px 9px !important; }
.section-head .name { font-weight: 600; }
.dur { display: flex; align-items: center; gap: 4px; color: var(--muted); font-size: 13px; }
.dur input { width: 64px; }
.tools { display: flex; gap: 2px; }
.icon { border: 0; background: transparent; color: var(--muted); width: 30px; height: 30px; border-radius: 8px; cursor: pointer; font-size: 15px; }
.icon:hover { background: var(--panel-2); color: var(--text); }
.icon.danger:hover { color: var(--red); }
.section textarea { width: 100%; min-height: 84px; resize: vertical; line-height: 1.55; }
.section .styles { width: 100%; margin-top: 6px; font-size: 13px; }
.section .count { font-size: 12px; color: #7d7266; text-align: right; margin-top: 3px; }
.section .count.over { color: var(--red); }
.add-sections { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 12px 0 4px; font-size: 13px; color: var(--muted); }
.add-sections button { border: 1px dashed #5a4e40; background: transparent; border-radius: 99px; padding: 4px 11px; cursor: pointer; font-size: 13px; }
.add-sections button:hover { border-style: solid; color: var(--amber-2); }
.total { font-size: 13px; color: var(--muted); }
.total.over { color: var(--red); }

/* ------------------------------------------------ génération en cours */
.progress { margin-top: 18px; background: var(--bg); border: 1px solid var(--line); border-radius: 14px; padding: 18px; }
.progress p { margin: 8px 0 0; }
.progress #progress-time { color: var(--amber-2); font-variant-numeric: tabular-nums; }
.bars { display: flex; align-items: center; gap: 4px; height: 46px; }
.bars i { flex: 1; background: linear-gradient(var(--amber-2), var(--amber)); border-radius: 3px; height: 30%; animation: bar 1s ease-in-out infinite alternate; }
.bars i:nth-child(3n) { animation-duration: .7s; } .bars i:nth-child(4n+1) { animation-duration: 1.3s; } .bars i:nth-child(5n+2) { animation-duration: .9s; }
@keyframes bar { to { height: 100%; } }
.error-box { margin-top: 16px; background: #2e1714; border: 1px solid #6b2c23; color: #ffd2c9; border-radius: 12px; padding: 14px 16px; white-space: pre-line; }
.error-box pre { white-space: pre-wrap; background: #1a0d0b; padding: 8px; border-radius: 8px; font-size: 12.5px; }

/* ------------------------------------------------ bibliothèque */
.lib-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.lib-head h2 { margin: 0 auto 0 0 !important; }
#lib-search { width: 180px; }
.tracks { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.track { background: var(--bg); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; }
.track-top { display: flex; gap: 12px; align-items: center; }
.play { flex: 0 0 auto; width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--amber); color: #1a1208; cursor: pointer; display: grid; place-items: center; }
.play svg { width: 16px; height: 16px; }
.play:disabled { background: var(--line); color: var(--muted); }
.track-info { flex: 1; min-width: 0; }
.track-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: text; }
.track-meta { font-size: 12.5px; color: var(--muted); }
.track-meta .demo { color: var(--amber-2); }
.scrub { display: flex; align-items: center; gap: 10px; margin-top: 10px; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.scrub .rail { flex: 1; height: 6px; background: var(--line); border-radius: 99px; cursor: pointer; position: relative; }
.scrub .fill { position: absolute; inset: 0 auto 0 0; width: 0; background: var(--amber); border-radius: 99px; }
.track-actions { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 10px; }
.track-actions a, .track-actions button { border: 1px solid var(--line); background: transparent; border-radius: 8px; padding: 4px 10px; font-size: 13px; cursor: pointer; text-decoration: none; color: var(--text); }
.track-actions a:hover, .track-actions button:hover { border-color: #5a4e40; }
.track-actions .fav[aria-pressed="true"] { color: var(--amber-2); border-color: #6a4a1a; }
.track-actions .del:hover { color: var(--red); border-color: var(--red); }
.lyrics { margin-top: 10px; background: var(--panel); border-radius: 10px; padding: 10px 14px; font-size: 14px; white-space: pre-line; max-height: 300px; overflow: auto; }
.lyrics b { color: var(--amber-2); display: block; margin-top: 8px; font-size: 12.5px; text-transform: uppercase; letter-spacing: .04em; }
.track.generating .track-meta { color: var(--amber-2); }
.track.failed .track-meta { color: var(--red); }
.tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.tags span { font-size: 11.5px; background: var(--panel-2); color: var(--muted); border-radius: 99px; padding: 1px 8px; }
.empty { color: var(--muted); text-align: center; padding: 30px 10px; }

.toast { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); background: var(--panel-2); border: 1px solid var(--line); padding: 10px 16px; border-radius: 10px; z-index: 50; max-width: 90vw; }

@media (max-width: 980px) {
  .studio { grid-template-columns: minmax(0, 1fr); padding: 14px; }
  .top { padding: 12px 14px; flex-wrap: wrap; }
}
@media (max-width: 560px) {
  .row3, .modes { grid-template-columns: 1fr; }
  .panel { padding: 18px 16px; border-radius: 14px; }
  .studio { padding: 12px; gap: 14px; }
  .banner { padding: 10px 16px; }
  #lib-search { width: 100%; order: 3; }
  .section-head { grid-template-columns: 1fr auto; }
  .section-head .tools { grid-column: 1 / -1; justify-content: flex-end; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
