/* Crate - version « assistant » : mêmes couleurs que la signature, mais pensée pour un débutant.
   Texte plus grand, contraste plus fort, boutons pleins, une étape à la fois. */
:root {
  --bg: #0A0A0A;
  --surface: #141414;
  --surface-2: #1B1B1B;
  --fg: #DEDEDD;
  --fg-muted: #B4B4B2;   /* plus clair que la signature (#9A9A98) pour la lisibilité */
  --border: #2E2E2D;
  --brand: #82A8A3;
  --brand-dim: #5C8580;
  --brand-muted: rgba(130, 168, 163, 0.12);
  --error: #D07A73;
  --sans: 'Inter', system-ui, -apple-system, sans-serif;
  --gutter: 40px;
  color-scheme: dark;
}
@media (max-width: 768px) { :root { --gutter: 16px; } }

* { box-sizing: border-box; border-radius: 0; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 400 18px/1.6 var(--sans); -webkit-font-smoothing: antialiased; }
::selection { background: var(--brand); color: #000; }
a { color: var(--brand); }
img { display: block; max-width: 100%; }
.wrap { max-width: 1200px; margin: 0 auto; padding: 0 var(--gutter); }
b { font-weight: 600; }
em { font-style: normal; font-weight: 500; color: var(--fg); background: var(--surface-2); border: 1px solid var(--border); padding: 0 6px; white-space: nowrap; }
kbd { font: 500 15px var(--sans); color: var(--fg); background: var(--surface-2); border: 1px solid var(--border); border-bottom-width: 2px; padding: 1px 8px; white-space: nowrap; }
:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }

/* ---------- en-tête ---------- */
.top { background: var(--surface); border-bottom: 1px solid var(--border); }
.top .wrap { display: flex; align-items: center; height: 64px; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand b { display: block; font-size: 18px; line-height: 1.2; }
.brand small { display: block; font-size: 14px; color: var(--fg-muted); }
.logo { width: 22px; height: 22px; border: 2px solid var(--brand); position: relative; }
.logo::after { content: ''; position: absolute; inset: 5px; background: var(--brand); }

/* ---------- étapes ---------- */
.stepper { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 32px; }
.stepper button { display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: var(--surface); border: 1px solid var(--border); border-top: 4px solid var(--border); color: var(--fg-muted); font: 500 17px var(--sans); cursor: pointer; text-align: left; transition: border-color .2s ease-out, color .2s ease-out; }
.stepper button:hover { color: var(--fg); }
.stepper .num { flex: none; display: grid; place-items: center; width: 32px; height: 32px; border: 2px solid currentColor; font-weight: 600; font-size: 16px; }
.stepper .done { border-top-color: var(--brand-dim); color: var(--fg); }
.stepper .done .num { background: var(--brand-dim); border-color: var(--brand-dim); color: #000; font-size: 0; }
.stepper .done .num::after { content: '✓'; font-size: 17px; }
.stepper .current { border-color: var(--brand); border-top-color: var(--brand); color: var(--fg); background: var(--brand-muted); }
.stepper .current .num { background: var(--brand); border-color: var(--brand); color: #000; }
@media (max-width: 700px) {
  .stepper { gap: 4px; margin-top: 16px; }
  .stepper button { flex-direction: column; gap: 4px; padding: 10px 4px; font-size: 13px; text-align: center; }
}

/* ---------- panneau ---------- */
.panel { padding: 40px 0 64px; animation: fade .3s ease-out; }
@keyframes fade { from { opacity: 0; transform: translateY(8px); } }
.kicker { margin: 0; color: var(--brand); font-weight: 600; font-size: 16px; }
.panel h1 { font: 600 40px/1.15 var(--sans); letter-spacing: -0.01em; margin: 8px 0 12px; }
.lead { color: var(--fg-muted); max-width: 62ch; margin: 0 0 32px; font-size: 19px; }
.lead b { color: var(--fg); }
@media (max-width: 768px) { .panel { padding-top: 24px; } .panel h1 { font-size: 30px; } .lead { font-size: 18px; } }

.cols { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: 48px; align-items: start; }
@media (max-width: 960px) { .cols { grid-template-columns: 1fr; gap: 32px; } }

/* liste d'actions numérotées */
.todo { list-style: none; margin: 0; padding: 0; counter-reset: n; }
.todo li { counter-increment: n; position: relative; padding: 0 0 22px 60px; min-height: 44px; }
.todo li::before { content: counter(n); position: absolute; left: 0; top: -2px; width: 40px; height: 40px; display: grid; place-items: center; border: 2px solid var(--brand-dim); color: var(--brand); font-weight: 600; font-size: 18px; }
.todo li:not(:last-child)::after { content: ''; position: absolute; left: 19px; top: 42px; bottom: 4px; width: 2px; background: var(--border); }
.todo.compact { margin: 0 0 32px; max-width: 70ch; }
.todo .sub { display: block; margin-top: 6px; color: var(--fg-muted); font-size: 16px; }

figure { margin: 0; border: 1px solid var(--border); background: var(--bg); position: sticky; top: 24px; }
figure svg, figure img { display: block; width: 100%; height: auto; }
figcaption { border-top: 1px solid var(--border); padding: 10px 14px; font-size: 15px; color: var(--fg-muted); background: var(--surface); }
@media (max-width: 960px) { figure { position: static; } }

/* ---------- boutons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 10px 20px; font: 500 17px var(--sans); color: var(--fg); background: var(--surface); border: 1px solid var(--border); cursor: pointer; text-decoration: none; transition: background .2s ease-out, border-color .2s ease-out, color .2s ease-out; }
.btn:hover:not(:disabled) { border-color: var(--fg-muted); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #000; font-weight: 600; }
.btn.primary:hover:not(:disabled) { background: #9BBDB8; border-color: #9BBDB8; }
.btn.big { min-height: 56px; padding: 12px 28px; font-size: 18px; }
.btn:disabled { background: var(--surface); border-color: var(--border); color: #777775; cursor: not-allowed; }
.btn.danger-link { background: none; border: 0; color: var(--fg-muted); text-decoration: underline; text-underline-offset: 3px; min-height: 48px; padding: 0 8px; }
.btn.danger-link:hover { color: var(--error); }

.pager { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px; margin-top: 40px; padding-top: 24px; border-top: 1px solid var(--border); }
.pager > :last-child { margin-left: auto; }
@media (max-width: 600px) { .pager .btn.big { width: 100%; } }

/* ---------- formulaire ---------- */
.lbl { display: block; font-weight: 600; margin-bottom: 8px; }
.input { width: 100%; min-height: 56px; padding: 12px 16px; background: var(--surface); border: 2px solid var(--border); color: var(--fg); font: 400 18px var(--sans); outline: 0; transition: border-color .2s ease-out; }
.input:focus { border-color: var(--brand); }
.input::placeholder { color: #8A8A88; }
.add .row { display: flex; gap: 12px; }
.add .row .btn { white-space: nowrap; flex: none; }
@media (max-width: 700px) { .add .row { flex-direction: column; } }
.msg { min-height: 28px; margin: 10px 0 0; font-size: 17px; }
.msg.ok { color: var(--brand); }
.msg.err { color: var(--error); }
.msg.busy::before { content: ''; display: inline-block; width: 14px; height: 14px; margin-right: 10px; border: 2px solid var(--brand); border-right-color: transparent; border-radius: 50%; vertical-align: -2px; animation: turn .8s linear infinite; }
@keyframes turn { to { transform: rotate(360deg); } }

/* ---------- liste ---------- */
.list-head { display: flex; align-items: baseline; gap: 12px; margin-top: 32px; padding-bottom: 12px; border-bottom: 1px solid var(--border); }
.list-head h2 { font: 600 22px var(--sans); margin: 0; }
.count { color: var(--fg-muted); font-size: 16px; }
.tracks { list-style: none; margin: 0; padding: 0; }
.track { display: grid; grid-template-columns: 96px minmax(0, 1fr) auto; gap: 16px; align-items: center; padding: 14px 0; border-bottom: 1px solid var(--border); }
.track img { width: 96px; aspect-ratio: 16/9; object-fit: cover; background: var(--surface); }
.track .t { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.track .m { font-size: 15px; color: var(--fg-muted); }
.track .side { display: flex; align-items: center; gap: 12px; }
.state { font-size: 15px; font-weight: 500; white-space: nowrap; color: var(--fg-muted); }
.state.ok { color: var(--brand); }
.state.err { color: var(--error); }
.state.run { color: var(--fg); }
.state.run::before { content: ''; display: inline-block; width: 12px; height: 12px; margin-right: 8px; border: 2px solid var(--brand); border-right-color: transparent; border-radius: 50%; vertical-align: -1px; animation: turn .8s linear infinite; }
.rm { background: none; border: 1px solid var(--border); color: var(--fg-muted); font: 500 15px var(--sans); padding: 8px 12px; cursor: pointer; }
.rm:hover { color: var(--fg); border-color: var(--fg-muted); }
.empty { padding: 28px 0; color: var(--fg-muted); border-bottom: 1px solid var(--border); }
@media (max-width: 600px) {
  .track { grid-template-columns: 72px minmax(0, 1fr); }
  .track img { width: 72px; }
  .track .side { grid-column: 2; }
  .track .t { white-space: normal; }
}

.progress { margin-top: 24px; }
.progress .bar { height: 10px; background: var(--surface-2); border: 1px solid var(--border); }
.progress i { display: block; height: 100%; width: 0; background: var(--brand); transition: width .3s ease-out; }
.progress p { margin: 10px 0 0; font-weight: 500; }

.done-box { margin-top: 24px; padding: 24px; border: 2px solid var(--brand); background: var(--brand-muted); }
.done-box p { margin: 0 0 16px; }
.big-ok { font-size: 24px; font-weight: 600; color: var(--brand); }
.done-box.partial { border-color: var(--error); }

.aside { color: var(--fg-muted); font-size: 16px; margin: 16px 0 0; }
.warn { margin-top: 32px; padding: 18px 20px; border: 1px solid var(--border); border-left: 4px solid var(--error); background: var(--surface); }

/* ---------- accès ---------- */
.gate { position: fixed; inset: 0; z-index: 50; background: var(--bg); display: grid; place-items: center; padding: var(--gutter); }
.gate form { width: min(480px, 100%); }
.gate h1 { font: 600 40px var(--sans); margin: 0 0 8px; }
.gate p { color: var(--fg-muted); margin: 0 0 24px; }
.gate .btn { width: 100%; margin-top: 16px; }
.gate .msg { margin: 12px 0 0; }

@media (prefers-reduced-motion: reduce) {
  .panel { animation: none; }
  .msg.busy::before, .state.run::before { animation: none; }
}
