:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --text: #15171c;
  --muted: #5e6572;
  --border: #e2e5ea;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-text: #ffffff;
  --ok: #15803d;
  --err: #c62828;
  --badge-l: 38%;
  --badge-bg: 93%;
  --radius: 14px;
  --check: #dde1e7;
  --shadow: 0 1px 2px rgb(0 0 0 / .04), 0 4px 14px rgb(0 0 0 / .05);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1014;
    --surface: #171a20;
    --surface-2: #1e222a;
    --text: #e9ebf0;
    --muted: #9aa1ad;
    --border: #2a2f39;
    --accent: #818cf8;
    --accent-hover: #a5b4fc;
    --accent-text: #0e1014;
    --ok: #4ade80;
    --err: #f87171;
    --badge-l: 74%;
    --badge-bg: 20%;
    --check: #2a2f39;
    --shadow: none;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

main { width: 100%; max-width: 1080px; margin: 0 auto; padding: 0 16px 48px; flex: 1; }

/* En-tête */
.top {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  max-width: 1080px; width: 100%; margin: 0 auto; padding: 18px 16px;
}
.logo { color: var(--text); text-decoration: none; font-weight: 700; font-size: 1.15rem; display: flex; align-items: center; gap: 8px; }
.logo-mark {
  display: grid; place-items: center; width: 32px; height: 32px; border-radius: 9px;
  background: var(--accent); color: var(--accent-text); font-size: 1.1rem;
}
.tag { color: var(--muted); font-size: .85rem; }

/* Accueil */
.hero { text-align: center; padding: 32px 0 20px; }
.hero h1 { font-size: clamp(1.6rem, 4vw, 2.4rem); margin: 0 0 8px; letter-spacing: -.02em; }
.hero p { color: var(--muted); margin: 0 auto 22px; max-width: 620px; }
#q {
  width: 100%; max-width: 520px; padding: 13px 18px; font: inherit; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: 999px; outline: none;
  box-shadow: var(--shadow);
}
#q:focus { border-color: var(--accent); }

.chips { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin: 8px 0 24px; }
.chip {
  font: inherit; font-size: .9rem; padding: 6px 14px; border-radius: 999px; cursor: pointer;
  background: var(--surface); color: var(--muted); border: 1px solid var(--border);
}
.chip:hover { color: var(--text); }
.chip[aria-selected="true"] { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; }
.card {
  display: flex; flex-direction: column; gap: 8px; padding: 16px; text-decoration: none; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); transition: transform .12s, border-color .12s;
}
.card:hover { transform: translateY(-2px); border-color: var(--accent); }
.card .pair { display: flex; align-items: center; gap: 6px; font-weight: 600; }
.card .arrow { color: var(--muted); }
.card small { color: var(--muted); font-size: .85rem; line-height: 1.35; }
.empty { text-align: center; color: var(--muted); }

.badge {
  display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: .8rem; font-weight: 700; letter-spacing: .02em;
  background: hsl(var(--h, 230) 70% var(--badge-bg)); color: hsl(var(--h, 230) 65% var(--badge-l));
}

/* Outil */
.back { display: inline-block; margin: 16px 0 8px; color: var(--muted); text-decoration: none; }
.back:hover { color: var(--accent); }
.tool-head h1 { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 6px 0 4px; font-size: 1.7rem; }
.tool-head h1 .badge { font-size: 1.1rem; padding: 4px 12px; }
.tool-head p { color: var(--muted); margin: 0 0 20px; }

.drop {
  display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center;
  padding: 40px 16px; border: 2px dashed var(--border); border-radius: var(--radius);
  background: var(--surface); cursor: pointer; transition: border-color .15s, background .15s;
}
.drop:hover, .drop:focus-visible, .drop.over { border-color: var(--accent); outline: none; }
.drop.over { background: var(--surface-2); }
.drop-icon { font-size: 1.8rem; color: var(--accent); }
.drop span { color: var(--muted); }
.drop small { color: var(--muted); margin-top: 6px; font-size: .8rem; }

.files { list-style: none; padding: 0; margin: 14px 0; display: grid; gap: 8px; }
.files li {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; min-width: 0;
}
.files .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.files .size { color: var(--muted); font-size: .85rem; white-space: nowrap; }
.files .thumb { width: 44px; height: 44px; object-fit: contain; border-radius: 6px; background: var(--surface-2); flex: none; }
.icon-btn {
  border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 1.1rem; padding: 4px 8px; border-radius: 6px;
}
.icon-btn:hover { color: var(--err); background: var(--surface-2); }

.opts { display: flex; flex-wrap: wrap; gap: 14px 24px; margin: 4px 0 18px; }
.opts:empty { display: none; }
.opt { display: flex; flex-direction: column; gap: 4px; font-size: .9rem; color: var(--muted); }
.opt select, .opt input[type=range] { font: inherit; color: var(--text); }
.opt select { padding: 7px 10px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; }
.opt input[type=range] { accent-color: var(--accent); width: 200px; max-width: 100%; }
.opt output { color: var(--text); font-weight: 600; }

.actions { display: flex; gap: 10px; flex-wrap: wrap; }
.btn {
  font: inherit; font-weight: 600; padding: 10px 20px; border-radius: 10px; cursor: pointer; text-decoration: none;
  background: var(--surface); color: var(--text); border: 1px solid var(--border);
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.btn.primary:hover { background: var(--accent-hover); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.small { padding: 6px 12px; font-size: .9rem; }

.status { min-height: 1.5em; margin: 14px 0; color: var(--muted); }
.status.ok { color: var(--ok); }
.status.err { color: var(--err); }

.checker { background: repeating-conic-gradient(var(--check) 0 25%, var(--surface) 0 50%) 0 0 / 16px 16px; }
.preview:empty { display: none; }
.preview { margin: 0 0 18px; }
.preview canvas { display: block; max-width: 100%; max-height: 60vh; border-radius: var(--radius); border: 1px solid var(--border); }

.player {
  margin: 8px 0 14px; padding: 12px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
}
.player-head { display: flex; align-items: center; justify-content: space-between; gap: 8px 16px; flex-wrap: wrap; margin-bottom: 10px; min-width: 0; }
.player-head .name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player-bg { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; color: var(--muted); font-size: .85rem; }
.chips.small { margin: 0; justify-content: flex-start; gap: 6px; }
.chips.small .chip { font-size: .8rem; padding: 3px 10px; }
.chip[aria-pressed="true"] { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.stage { display: grid; place-items: center; border-radius: 10px; overflow: hidden; }
.stage video, .stage img { display: block; max-width: 100%; max-height: 70vh; }
.stage img { cursor: pointer; }
.stage.bg-checker { background: repeating-conic-gradient(var(--check) 0 25%, var(--surface) 0 50%) 0 0 / 16px 16px; }
.stage.bg-black { background: #000; }
.stage.bg-white { background: #fff; }
.stage.bg-green { background: #00ff00; }

.results-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.results-head h2 { margin: 8px 0; font-size: 1.2rem; }

footer { text-align: center; color: var(--muted); font-size: .8rem; padding: 24px 16px; }

@media (max-width: 520px) {
  .files .size { display: none; }
  .actions .btn { flex: 1; justify-content: center; }
}
