:root {
  --bg: #fafaf8;
  --card: #ffffff;
  --ink: #1d1d1b;
  --muted: #8b8a85;
  --line: #e9e7e2;
  --soft: #f2f1ed;
  --ok: #2f9e5b;
  --ok-bg: #e8f5ed;
  --bad: #d4463c;
  --bad-bg: #fbeceb;
  --near: #d98a1e;
  --near-bg: #fcf3e4;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;
  --r: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--ink);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
[hidden] { display: none !important; }

.wrap { max-width: 1080px; margin: 0 auto; padding: 0 20px 80px; }
.narrow { max-width: 820px; }

/* ---------- top bar ---------- */
.top { display: flex; align-items: center; justify-content: space-between; padding: 22px 0 26px; gap: 12px; }
.logo { font-weight: 650; letter-spacing: -.02em; font-size: 17px; text-decoration: none; display: flex; align-items: center; gap: 8px; }
.logo img { width: 22px; height: 22px; }
.logo span { color: var(--muted); font-weight: 450; }
.who { display: flex; align-items: center; gap: 14px; color: var(--muted); font-size: 14px; }

.btn {
  border: 1px solid var(--line); background: var(--card); border-radius: 10px;
  padding: 7px 13px; font-size: 14px; display: inline-flex; align-items: center; gap: 6px;
  transition: background .15s, border-color .15s;
}
.btn:hover { border-color: #d6d3cc; background: var(--soft); }
.btn.primary { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn.primary:hover { background: #000; }
.btn.ghost { border-color: transparent; background: none; }
.btn.ghost:hover { background: var(--soft); }
.btn.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.btn:disabled { opacity: .45; cursor: default; }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login form { width: 100%; max-width: 340px; display: grid; gap: 12px; }
.login h1 { font-size: 24px; letter-spacing: -.03em; margin: 0 0 4px; }
.login p { color: var(--muted); margin: 0 0 14px; font-size: 14px; }
.field {
  width: 100%; border: 1px solid var(--line); background: var(--card); border-radius: 10px;
  padding: 10px 12px; outline: none; transition: border-color .15s, box-shadow .15s;
}
.field:focus { border-color: var(--ink); box-shadow: 0 0 0 3px rgba(29,29,27,.07); }
.login a.hint { text-align: center; text-decoration: none; }
.login a.hint:hover { color: var(--ink); }
.invite {
  position: fixed; top: 76px; right: max(20px, calc(50vw - 520px)); z-index: 40; width: min(440px, calc(100vw - 32px));
  background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px; box-shadow: 0 16px 40px -12px rgba(0,0,0,.2);
}
.invite p { color: var(--muted); font-size: 13px; margin: 2px 0 10px; }
.invite .field { font-size: 13px; }
.invite .close { position: absolute; top: 8px; right: 8px; padding: 2px 8px; }
.err { color: var(--bad); font-size: 13px; min-height: 18px; }

/* ---------- library ---------- */
.lib-head { display: flex; align-items: end; justify-content: space-between; margin-bottom: 18px; gap: 12px; }
.lib-head h2 { margin: 0; font-size: 26px; letter-spacing: -.03em; }
.lib-head small { color: var(--muted); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 22px; }
.card { text-decoration: none; display: block; position: relative; }
.thumb {
  position: relative; aspect-ratio: 16/9; border-radius: var(--r); overflow: hidden; background: var(--soft);
  box-shadow: 0 1px 2px rgba(0,0,0,.04);
  transition: transform .25s ease, box-shadow .25s ease;
}
.card:hover .thumb { transform: translateY(-2px); box-shadow: 0 10px 28px -10px rgba(0,0,0,.25); }
.thumb img, .thumb iframe { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; border: 0; }
.thumb iframe { pointer-events: none; opacity: 0; transition: opacity .5s; transform: scale(1.02); }
.thumb iframe.show { opacity: 1; }
.hoverbar { position: absolute; left: 0; bottom: 0; height: 3px; width: 0; background: #fff; opacity: .9; z-index: 2; }
.card.arming .hoverbar { width: 100%; transition: width 1s linear; }
.card.playing .hoverbar { opacity: 0; }
.badge {
  position: absolute; top: 9px; right: 9px; z-index: 3; font-size: 12px; font-weight: 600;
  background: rgba(255,255,255,.92); backdrop-filter: blur(6px); padding: 2px 8px; border-radius: 99px;
}
.badge.full { background: var(--ok); color: #fff; }
.meta { padding: 10px 2px 0; }
.meta b { display: block; font-weight: 600; font-size: 15px; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.meta span { color: var(--muted); font-size: 13.5px; }
.bar { height: 4px; border-radius: 9px; background: var(--line); overflow: hidden; margin-top: 8px; }
.bar i { display: block; height: 100%; background: var(--ink); border-radius: 9px; transition: width .4s; }
.stats { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; margin-top: 5px; }
.del {
  position: absolute; top: 9px; left: 9px; z-index: 3; width: 26px; height: 26px; border-radius: 99px; border: 0;
  background: rgba(255,255,255,.92); opacity: 0; transition: opacity .15s; font-size: 14px; line-height: 1;
}
.card:hover .del { opacity: 1; }

.add { border: 1px dashed #d6d3cc; border-radius: var(--r); padding: 18px; margin-top: 34px; background: var(--card); }
.add summary { cursor: pointer; font-weight: 600; list-style: none; }
.add summary::-webkit-details-marker { display: none; }
.add form { display: grid; gap: 10px; margin-top: 14px; grid-template-columns: 1fr 1fr; }
.add form .full { grid-column: 1 / -1; }
.add textarea { min-height: 110px; font-family: var(--mono); font-size: 12.5px; resize: vertical; }
.hint { color: var(--muted); font-size: 13px; }

/* ---------- ajout via Claude ---------- */
.ask { display: flex; gap: 8px; margin-bottom: 12px; }
.ask .field { padding: 12px 14px; font-size: 15px; }
.ask .btn { white-space: nowrap; padding: 0 18px; }
.jobs { display: grid; gap: 8px; margin-bottom: 26px; }
.jobs:empty { margin-bottom: 18px; }
.job { display: flex; align-items: center; gap: 12px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; font-size: 13.5px; }
.job > div { flex: 1; min-width: 0; }
.job b { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.job span:not(.dot) { color: var(--muted); }
.job .dot { width: 9px; height: 9px; border-radius: 99px; background: var(--muted); flex: none; }
.job.running .dot, .job.pending .dot { background: var(--near); animation: pulse 1.1s ease-in-out infinite; }
.job.done .dot { background: var(--ok); }
.job.error .dot { background: var(--bad); }
.job.error span:not(.dot) { color: var(--bad); }
@keyframes pulse { 50% { opacity: .3; transform: scale(.7); } }

/* ---------- player ---------- */
.song-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.song-head h2 { margin: 0; font-size: 20px; letter-spacing: -.02em; line-height: 1.2; }
.song-head p { margin: 0; color: var(--muted); font-size: 14px; }
.video { position: relative; aspect-ratio: 16/9; border-radius: var(--r); overflow: hidden; background: #000; }
.video iframe, .video > div { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

.blocked {
  position: absolute; inset: 0; z-index: 5; background: rgba(250,250,248,.97); display: flex; flex-direction: column;
  justify-content: center; align-items: center; gap: 8px; padding: 24px; text-align: center;
}
.blocked p { color: var(--muted); margin: 0 0 6px; font-size: 14px; max-width: 460px; }
.blocked form { display: flex; gap: 8px; width: 100%; max-width: 520px; }
.blocked a { font-size: 13px; color: var(--muted); }

.controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 14px 0 10px; }
.controls .sep { flex: 1; }
.group { display: inline-flex; align-items: center; gap: 2px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); padding: 2px; }
.group .btn { border: 0; padding: 5px 9px; border-radius: 8px; }
.group output { font-size: 13px; color: var(--muted); min-width: 50px; text-align: center; font-variant-numeric: tabular-nums; }

.dots { display: flex; flex-wrap: wrap; gap: 4px; margin: 6px 0 22px; }
.dots button { width: 11px; height: 11px; padding: 0; border: 0; border-radius: 3px; background: var(--line); transition: transform .1s; }
.dots button:hover { transform: scale(1.35); }
.dots button.s-ok { background: var(--ok); }
.dots button.s-near { background: var(--near); }
.dots button.s-bad { background: var(--bad); }
.dots button.cur { outline: 2px solid var(--ink); outline-offset: 1.5px; }

.ex { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 30px 28px 22px; text-align: center; }
.ex-top { display: flex; justify-content: space-between; color: var(--muted); font-size: 13px; margin: -12px -8px 18px; }
.slots { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px 18px; font-family: var(--mono); font-size: 22px; min-height: 40px; cursor: text; }
.w { display: inline-flex; gap: 2px; }
.ch { display: inline-block; width: .72em; text-align: center; border-bottom: 2px solid #cfccc4; line-height: 1.25; color: var(--ink); transition: border-color .1s; }
.ch.filled { border-color: var(--ink); }
.ch.fixed { border-color: transparent; color: var(--muted); width: auto; }
.ch.extra { color: var(--bad); border-color: var(--bad); }
.w.cur .ch:not(.fixed) { border-color: #9d9a92; }
.w.cur .ch.filled { border-color: var(--ink); }

.typer {
  width: 100%; max-width: 560px; margin: 22px auto 0; display: block; text-align: center;
  border: 0; border-bottom: 1px solid var(--line); background: none; padding: 8px; outline: none; font-size: 16px;
}
.typer:focus { border-color: var(--ink); }
.keys { color: var(--muted); font-size: 12.5px; margin-top: 14px; }
kbd { font-family: var(--mono); font-size: 11px; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; padding: 0 5px; background: var(--bg); }

.result { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 8px; font-size: 22px; font-weight: 500; letter-spacing: -.01em; }
.rw { display: inline-flex; flex-direction: column; align-items: center; padding: 1px 7px; border-radius: 8px; cursor: help; transition: transform .1s; }
.rw:hover { transform: translateY(-1px); }
.rw.ok { color: var(--ok); background: var(--ok-bg); }
.rw.bad { color: var(--bad); background: var(--bad-bg); }
.rw.near { color: var(--near); background: var(--near-bg); }
.rw small { font-size: 12px; font-weight: 400; text-decoration: line-through; opacity: .75; line-height: 1.2; }
.fr { color: var(--muted); font-size: 14.5px; margin-top: 14px; font-style: italic; min-height: 22px; }
.score { margin-top: 16px; font-size: 13px; color: var(--muted); }
.score b { color: var(--ink); }

.done { text-align: center; padding: 30px 10px; }
.done h3 { font-size: 26px; margin: 0 0 6px; letter-spacing: -.03em; }

/* ---------- tooltip ---------- */
.tip {
  position: fixed; z-index: 50; max-width: 320px; background: var(--ink); color: #f4f3ef; border-radius: 12px;
  padding: 12px 14px; font-size: 13px; line-height: 1.45; box-shadow: 0 12px 34px -8px rgba(0,0,0,.35);
  pointer-events: none; text-align: left;
}
.tip h4 { margin: 0; font-size: 16px; display: flex; gap: 8px; align-items: baseline; }
.tip h4 em { font-weight: 400; color: #a9a7a0; font-size: 13px; font-style: normal; }
.tip .tfr { color: #fff; font-weight: 550; margin: 4px 0 8px; }
.tip .tm { border-top: 1px solid #37362f; padding-top: 6px; margin-top: 6px; color: #d8d6cf; }
.tip .tm i { color: #a9a7a0; font-size: 12px; }
.tip .tsyn { color: #a9a7a0; font-size: 12px; margin-top: 2px; }
.tip .tex { color: #a9a7a0; font-size: 12px; font-style: italic; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 9px 16px; border-radius: 10px; font-size: 14px; z-index: 60; }

@media (max-width: 640px) {
  .add form { grid-template-columns: 1fr; }
  .slots, .result { font-size: 18px; }
  .ex { padding: 22px 14px 16px; }
}
