* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 15px/1.5 var(--font); -webkit-font-smoothing: antialiased; display: flex; flex-direction: column; }
h1, h2 { font-weight: 500; letter-spacing: -0.01em; margin: 0; }
button, input, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* Boutons */
.btn { border: 1px solid var(--line); background: var(--paper-2); border-radius: var(--radius); padding: 8px 14px; cursor: pointer; font-weight: 500; font-size: 14px; display: inline-flex; align-items: center; gap: 8px; transition: background .12s, border-color .12s; white-space: nowrap; }
.btn:hover:not(:disabled) { border-color: var(--gray); }
.btn:focus-visible, .wave:focus-visible, .chip:focus-visible, .row:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.btn.primary:hover:not(:disabled) { background: var(--ink-2); }
.btn.red { background: var(--red); border-color: var(--red); color: var(--ink); }
.btn.red:hover:not(:disabled) { background: var(--red-hover); border-color: var(--red-hover); }
#btn-load { background: var(--red); border-color: var(--red); color: var(--ink); }
#btn-load:hover:not(:disabled) { background: var(--red-hover); border-color: var(--red-hover); }
.row[aria-selected="true"] { box-shadow: inset 3px 0 0 var(--red), inset 0 0 0 1px var(--line); }
.stat b { color: var(--ink); }
.chip[aria-pressed="true"] .star { color: var(--red); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover:not(:disabled) { background: var(--paper-3); border-color: transparent; }
.btn.small { padding: 4px 10px; font-size: 13px; }

/* En-tête */
.top { display: flex; align-items: center; gap: 14px; padding: 12px 22px; border-bottom: 1px solid var(--line); background: var(--paper); }
.brand { display: flex; }
.by { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--mute); text-decoration: none; padding-top: 4px; }
.by b { color: var(--ink); letter-spacing: .06em; font-weight: 700; font-size: 11px; }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 4px; }
.out-label { font-size: 13px; color: var(--mute); margin-right: 8px; max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.out-label b { color: var(--ink); font-weight: 500; }

/* Mise en page */
.layout { flex: 1; display: grid; grid-template-columns: minmax(300px, 380px) minmax(0, 1fr); min-height: 0; }
.files { border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; background: var(--paper); }
.files-head { padding: 18px 18px 12px; }
.files-head h2 { font-size: 16px; margin-bottom: 10px; }
.count { color: var(--mute); font-weight: 400; }
.add { display: flex; gap: 8px; flex-wrap: wrap; }
.drop { flex: 1; min-height: 0; overflow: auto; margin: 0 10px; border-radius: var(--radius-lg); position: relative; }
.drop.over { background: var(--paper-3); outline: 2px dashed var(--gray); outline-offset: -6px; }
.empty { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 24px; color: var(--ink); border: 1.5px dashed var(--line); border-radius: var(--radius-lg); margin: 6px; }
.empty p { margin: 6px 0 0; max-width: 260px; }
.hint { color: var(--mute); font-size: 13px; }
.files-foot { display: flex; gap: 8px; padding: 12px 18px 6px; align-items: center; }
.progress { margin: 0; padding: 0 18px 14px; font-size: 13px; color: var(--mute); min-height: 34px; }

/* Liste des titres */
.list { list-style: none; margin: 0; padding: 4px 0; }
.row { display: grid; grid-template-columns: 18px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 9px 10px; border-radius: var(--radius); cursor: pointer; }
.row:hover { background: var(--paper-3); }
.row[aria-selected="true"] { background: var(--paper-2); box-shadow: inset 0 0 0 1px var(--line); }
.row .name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 14px; }
.row .sub { font-size: 12px; color: var(--mute); font-variant-numeric: tabular-nums; }
.row .badge { font-size: 11px; padding: 2px 7px; border-radius: 99px; background: var(--paper-3); color: var(--mute); font-variant-numeric: tabular-nums; white-space: nowrap; }
.row .badge.ok { background: #E3EFE7; color: var(--ok); }
.row .badge.err { background: #F8E1DC; color: var(--red-dark); }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--line); justify-self: center; }
.dot.ready { background: var(--ink); }
.dot.busy { background: var(--gray); animation: pulse 1s infinite alternate; }
.dot.done { background: var(--ok); }
.dot.error { background: var(--red); }
@keyframes pulse { to { opacity: .3; } }

/* Éditeur */
.editor { overflow: auto; padding: 26px 30px; }
.editor-empty { max-width: 560px; margin: 8vh auto 0; }
.editor-empty h1 { font-size: 34px; letter-spacing: -0.03em; line-height: 1.15; }
.editor-empty h1::after { content: '.'; color: var(--red); }
.steps { padding-left: 20px; color: var(--ink-2); }
.steps li { margin: 10px 0; padding-left: 6px; }
.ed-head { display: flex; gap: 20px; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; margin-bottom: 18px; }
.ed-title { min-width: 0; }
.ed-title h2 { font-size: 22px; letter-spacing: -0.02em; overflow-wrap: anywhere; }
.meta { margin: 4px 0 0; color: var(--mute); font-size: 13px; font-variant-numeric: tabular-nums; }
.ed-stats { display: flex; gap: 8px; }
.stat { background: var(--paper-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 14px; min-width: 96px; }
.stat span { display: block; font-size: 12px; color: var(--mute); }
.stat b { font-weight: 500; font-size: 18px; font-variant-numeric: tabular-nums; }
.wave-wrap { background: var(--paper-2); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 14px 14px 8px; }
.wave { width: 100%; height: 220px; display: block; cursor: crosshair; border-radius: 6px; }
.wave-tools { display: flex; align-items: center; justify-content: space-between; margin-top: 6px; }
.legend { font-size: 12px; color: var(--mute); display: flex; align-items: center; gap: 6px; }
.legend i { display: inline-block; width: 12px; height: 10px; border-left: 1px solid var(--gray); margin-left: 6px; }
.legend i.lg-phr { border-left: 2px dashed var(--red); }
.zoom .btn[aria-pressed="true"] { background: var(--paper-3); }
.cuts { display: flex; align-items: center; gap: 12px; margin: 16px 0; flex-wrap: wrap; }
.cuts-label { font-size: 13px; color: var(--mute); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line); background: var(--paper-2); border-radius: 99px; padding: 5px 12px; font-size: 13px; cursor: pointer; font-variant-numeric: tabular-nums; }
.chip:hover { border-color: var(--gray); }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.chip .star { color: var(--red); margin-left: 4px; }
.transport { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.transport .btn.red { margin-left: auto; }
.kbd-hint { font-size: 12px; color: var(--mute); margin-left: 8px; }
.ico-play { width: 0; height: 0; border-left: 9px solid currentColor; border-top: 6px solid transparent; border-bottom: 6px solid transparent; }
.play.playing .ico-play { width: 9px; height: 11px; border: 0; border-left: 3px solid currentColor; border-right: 3px solid currentColor; }

/* Fenêtres */
.dlg { border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--paper-2); color: var(--ink); padding: 26px; max-width: 560px; width: calc(100% - 32px); }
.dlg::backdrop { background: rgba(22, 24, 29, .45); }
.dlg h2 { font-size: 20px; }
.dlg .grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; margin: 18px 0 8px; }
.dlg label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; font-weight: 500; }
.dlg label.check { flex-direction: row; align-items: center; grid-column: 1 / -1; font-weight: 400; gap: 8px; }
.dlg .unit { color: var(--mute); font-weight: 400; }
.dlg input:not([type=checkbox]), .dlg select { border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 10px; background: var(--paper); font-weight: 400; }
.dlg input:focus-visible, .dlg select:focus-visible { outline: 2px solid var(--ink); outline-offset: 0; }
.dlg.account { max-width: 620px; position: relative; }
.dlg .close { position: absolute; top: 14px; right: 14px; }
.dlg .grid.one { grid-template-columns: 1fr; }
.dlg .full { grid-column: 1 / -1; }
.dlg .trap { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.dlg a { color: var(--ink); }
.form-error { color: var(--red-dark); font-size: 13px; min-height: 1em; margin: 8px 0 0; }
.form-error.ok { color: var(--ok); }
.legal { font-size: 12px; color: var(--mute); margin: 18px 0 0; }
.legal a { color: var(--mute); }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: var(--paper); padding: 10px 18px; border-radius: var(--radius); font-size: 14px; z-index: 50; max-width: calc(100% - 32px); }
#btn-account.signed { background: var(--paper-3); border-color: transparent; }
.feedback-link { margin: 0 18px 16px; align-self: flex-start; background: none; border: 0; padding: 0; color: var(--mute); font-size: 13px; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.feedback-link:hover { color: var(--ink); }
.feedback-link::before { content: ''; display: inline-block; width: 2px; height: 11px; background: var(--red); margin-right: 8px; vertical-align: -1px; border-radius: 1px; }
.dlg textarea { border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 10px; background: var(--paper); font: inherit; font-weight: 400; resize: vertical; }
.hint.small { font-size: 12px; }

/* Boucle */
#btn-loop[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--red); }
#btn-loop[aria-pressed="true"]::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--red); animation: pulse .8s infinite alternate; }

/* Renommage */
.naming { padding: 10px 18px 0; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 6px 10px; align-items: center; }
.naming label { font-size: 13px; color: var(--mute); }
.naming select, .naming input { border: 1px solid var(--line); border-radius: var(--radius); padding: 6px 8px; background: var(--paper-2); font-size: 13px; min-width: 0; }
.naming input { grid-column: 1 / -1; }
.naming .hint { grid-column: 1 / -1; margin: 0; }
.rename { display: flex; align-items: center; gap: 8px; margin-top: 8px; font-size: 13px; color: var(--mute); }
.rename-field { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper-2); }
.rename-field:focus-within { border-color: var(--ink); }
.rename input { border: 0; background: transparent; padding: 6px 8px; font-size: 14px; color: var(--ink); width: min(360px, 50vw); outline: none; }
.rename .ext { padding-right: 8px; color: var(--mute); font-family: var(--mono); font-size: 12px; }
.row { grid-template-columns: 18px minmax(0, 1fr) auto auto; }
.row .move { display: none; gap: 2px; }
.row[aria-selected="true"] .move, .row:hover .move { display: inline-flex; }
.row .move button { border: 1px solid var(--line); background: var(--paper-2); border-radius: 6px; width: 22px; height: 20px; padding: 0; font-size: 10px; line-height: 1; cursor: pointer; color: var(--mute); }
.row .move button:hover { color: var(--ink); border-color: var(--gray); }
.row .export-name { font-family: var(--mono); font-size: 11px; color: var(--red-dark); }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.help { padding-left: 18px; }
.help li { margin: 8px 0; color: var(--ink-2); }
code { font-family: var(--mono); font-size: 13px; background: var(--paper-3); padding: 1px 5px; border-radius: 4px; }

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .files { border-right: 0; border-bottom: 1px solid var(--line); max-height: 50vh; }
  .editor { padding: 20px 16px; }
  .kbd-hint, .by, .out-label { display: none; }
  .dlg .grid { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
