/* Piano Flow — design system sombre, pensé pour l'iPhone en paysage.
   Turquoise = main gauche · Violet = main droite. */
:root {
  --bg: #060a13;
  --bg-2: #0a1020;
  --surface: #0f172a;
  --surface-2: #141e35;
  --surface-3: #1b2744;
  --glass: rgba(18, 27, 48, 0.72);
  --line: rgba(148, 170, 215, 0.14);
  --line-2: rgba(148, 170, 215, 0.26);
  --text: #eef3ff;
  --muted: #9aa7c0;
  --faint: #66738e;
  --lh: #2ee6d3;          /* main gauche · turquoise */
  --lh-2: #14b8a6;
  --lh-soft: rgba(46, 230, 211, 0.16);
  --rh: #b18cff;          /* main droite · violet */
  --rh-2: #8b5cf6;
  --rh-soft: rgba(177, 140, 255, 0.16);
  --accent: linear-gradient(135deg, #2ee6d3 0%, #8f7dff 55%, #c48cff 100%);
  --good: #4ee6a0;
  --good-soft: rgba(78, 230, 160, 0.14);
  --bad: #ff8f6b;
  --bad-soft: rgba(255, 143, 107, 0.15);
  --warn: #ffd166;
  --r-lg: 18px;
  --r-md: 12px;
  --r-sm: 9px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  --rail-w: 72px;
  --sa-l: env(safe-area-inset-left, 0px);
  --sa-r: env(safe-area-inset-right, 0px);
  --sa-b: env(safe-area-inset-bottom, 0px);
  --sa-t: env(safe-area-inset-top, 0px);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI Variable Text", "Segoe UI", Inter, Roboto, system-ui, sans-serif;
  --font-display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI Variable Display", "Segoe UI", Inter, Roboto, system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  font: 15px/1.45 var(--font);
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 85% -10%, rgba(143, 125, 255, 0.13), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(46, 230, 211, 0.08), transparent 60%),
    var(--bg);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid #8ee8ff; outline-offset: 2px; }
a { color: #8ee8ff; }
h1, h2, h3 { font-family: var(--font-display); letter-spacing: -0.02em; margin: 0; }
.ic { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.ic.fill { fill: currentColor; stroke: none; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.num { font-variant-numeric: tabular-nums; }

/* ───── Écran de secours (JS inactif / aperçu iPhone) ───── */
.boot {
  position: fixed; inset: 0; display: grid; place-items: center; padding: 24px; text-align: center;
  background: var(--bg); z-index: 100;
}
.boot-card { max-width: 520px; }
.boot-logo { width: 64px; height: 64px; margin: 0 auto 16px; border-radius: 18px; background: var(--accent); box-shadow: 0 10px 40px rgba(143, 125, 255, 0.35); }
.boot h1 { font-size: 24px; margin-bottom: 8px; }
.boot p { color: var(--muted); line-height: 1.6; }
.boot .boot-warn { margin-top: 18px; padding: 14px; border-radius: var(--r-md); background: var(--surface); border: 1px solid var(--line-2); color: #cfd8ea; font-size: 14px; text-align: left; }

/* ───── Bandeau d'erreur ───── */
.error-banner {
  position: fixed; left: 50%; top: calc(10px + var(--sa-t)); transform: translateX(-50%); z-index: 90;
  max-width: min(680px, 94vw); padding: 12px 14px; border-radius: var(--r-md);
  background: #3a1620; border: 1px solid #ff8f6b88; color: #ffd9cc; font-size: 13px; box-shadow: var(--shadow);
  display: flex; gap: 10px; align-items: flex-start;
}
.error-banner pre { margin: 6px 0 0; white-space: pre-wrap; font: 11px/1.4 var(--mono); color: #ffb8a3; max-height: 120px; overflow: auto; }

/* ───── Coquille de l'application ───── */
.app { display: grid; grid-template-columns: calc(var(--rail-w) + var(--sa-l)) minmax(0, 1fr); height: 100vh; height: 100dvh; }
.rail {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: calc(10px + var(--sa-t)) 6px calc(10px + var(--sa-b)) calc(6px + var(--sa-l));
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.9), rgba(8, 12, 24, 0.9));
  border-right: 1px solid var(--line);
  overflow-y: auto; scrollbar-width: none;
}
.rail::-webkit-scrollbar { display: none; }
.rail-logo { width: 36px; height: 36px; border-radius: 11px; background: var(--accent); display: grid; place-items: center; margin-bottom: 10px; box-shadow: 0 6px 22px rgba(143, 125, 255, 0.35); flex: none; }
.rail-logo svg { width: 22px; height: 22px; }
.nav-btn {
  width: 58px; min-height: 52px; border: 0; border-radius: 14px; background: transparent; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font-size: 10px; font-weight: 650; letter-spacing: 0.01em; padding: 6px 2px; flex: none;
  transition: background 0.15s, color 0.15s;
}
.nav-btn .ic { width: 22px; height: 22px; }
.nav-btn:hover { color: var(--text); background: rgba(255, 255, 255, 0.04); }
.nav-btn[aria-current="page"] { color: #fff; background: linear-gradient(160deg, rgba(46, 230, 211, 0.18), rgba(177, 140, 255, 0.22)); box-shadow: inset 0 0 0 1px rgba(177, 140, 255, 0.35); }
.rail-spacer { flex: 1; }

.views { position: relative; min-width: 0; min-height: 0; padding-right: var(--sa-r); }
.view { position: absolute; inset: 0; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; padding-right: var(--sa-r); }
.page { max-width: 1180px; margin: 0 auto; padding: calc(22px + var(--sa-t)) 22px calc(40px + var(--sa-b)); }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.eyebrow { font-size: 11px; font-weight: 800; letter-spacing: 0.18em; text-transform: uppercase; background: var(--accent); -webkit-background-clip: text; background-clip: text; color: transparent; }
.page-head h1 { font-size: clamp(26px, 3.4vw, 36px); margin-top: 4px; }
.page-head p { color: var(--muted); margin: 6px 0 0; max-width: 640px; }

/* ───── Boutons et contrôles ───── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 8px 14px; border-radius: var(--r-sm);
  border: 1px solid var(--line-2); background: var(--surface-2); color: var(--text);
  font-weight: 650; font-size: 14px; white-space: nowrap; transition: background 0.15s, border-color 0.15s, transform 0.1s;
  touch-action: manipulation;
}
.btn:hover { background: var(--surface-3); }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
.btn.primary { border: 0; background: var(--accent); color: #0a0f1d; font-weight: 800; box-shadow: 0 6px 22px rgba(143, 125, 255, 0.28); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--text); background: rgba(255, 255, 255, 0.05); }
.btn.danger { color: #ffc2b0; border-color: rgba(255, 143, 107, 0.4); background: rgba(255, 143, 107, 0.08); }
.btn.sm { min-height: 32px; padding: 5px 10px; font-size: 13px; border-radius: 8px; }
.btn.icon { padding: 0; width: 40px; min-width: 40px; }
.btn.icon.sm { width: 32px; min-width: 32px; }
.btn.on { border-color: rgba(46, 230, 211, 0.6); background: rgba(46, 230, 211, 0.12); color: #c9fff8; }

.seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: 11px; background: rgba(255, 255, 255, 0.04); border: 1px solid var(--line); flex: none; }
.seg button {
  border: 0; background: transparent; color: var(--muted); font-weight: 700; font-size: 13px;
  min-height: 32px; padding: 4px 11px; border-radius: 8px; white-space: nowrap; display: inline-flex; align-items: center; gap: 6px;
  touch-action: manipulation;
}
.seg button[aria-pressed="true"] { background: var(--surface-3); color: var(--text); box-shadow: 0 1px 0 rgba(255, 255, 255, 0.06) inset, 0 2px 8px rgba(0, 0, 0, 0.3); }
.seg button.lh[aria-pressed="true"] { color: var(--lh); box-shadow: inset 0 0 0 1px rgba(46, 230, 211, 0.45); }
.seg button.rh[aria-pressed="true"] { color: var(--rh); box-shadow: inset 0 0 0 1px rgba(177, 140, 255, 0.45); }
.seg button.both[aria-pressed="true"] { background: linear-gradient(135deg, rgba(46, 230, 211, 0.2), rgba(177, 140, 255, 0.25)); color: #fff; }

.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; font-size: 14px; }
.switch input { appearance: none; -webkit-appearance: none; width: 42px; height: 25px; border-radius: 99px; background: var(--surface-3); border: 1px solid var(--line-2); position: relative; transition: background 0.15s; flex: none; margin: 0; }
.switch input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 19px; height: 19px; border-radius: 50%; background: #cfd8ea; transition: transform 0.18s; }
.switch input:checked { background: var(--lh-2); border-color: var(--lh); }
.switch input:checked::after { transform: translateX(17px); background: #fff; }

.field { display: flex; flex-direction: column; gap: 6px; font-size: 12px; font-weight: 700; color: var(--muted); min-width: 0; }
.field input, .field select, .field textarea, .input {
  min-height: 42px; padding: 9px 12px; border-radius: var(--r-sm); background: var(--bg-2); border: 1px solid var(--line-2);
  color: var(--text); font-size: 15px; font-weight: 500; width: 100%; min-width: 0;
}
.field textarea { min-height: 150px; resize: vertical; font: 13px/1.55 var(--mono); }
.field input:focus, .field select:focus, .field textarea:focus, .input:focus { outline: none; border-color: #7fdcff; box-shadow: 0 0 0 3px rgba(127, 220, 255, 0.15); }
input[type="range"] { accent-color: var(--lh); width: 100%; }

.card { background: linear-gradient(160deg, rgba(20, 30, 53, 0.9), rgba(13, 20, 37, 0.9)); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 18px; }
.card h2 { font-size: 18px; }
.card h3 { font-size: 16px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 9px; border-radius: 99px; font-size: 12px; font-weight: 700; background: rgba(255, 255, 255, 0.05); border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.chip.lh { color: var(--lh); border-color: rgba(46, 230, 211, 0.35); background: var(--lh-soft); }
.chip.rh { color: var(--rh); border-color: rgba(177, 140, 255, 0.35); background: var(--rh-soft); }
.chip.good { color: var(--good); border-color: rgba(78, 230, 160, 0.35); background: var(--good-soft); }
.chip.warn { color: var(--warn); border-color: rgba(255, 209, 102, 0.35); background: rgba(255, 209, 102, 0.1); }
.chip.bad { color: var(--bad); border-color: rgba(255, 143, 107, 0.4); background: var(--bad-soft); }
.notice { padding: 12px 14px; border-radius: var(--r-md); background: rgba(255, 255, 255, 0.03); border: 1px solid var(--line); color: #cbd5e8; font-size: 14px; line-height: 1.55; }
.notice.good { background: var(--good-soft); border-color: rgba(78, 230, 160, 0.35); color: #c9f9e1; }
.notice.bad { background: var(--bad-soft); border-color: rgba(255, 143, 107, 0.4); color: #ffd4c6; }
.notice.warn { background: rgba(255, 209, 102, 0.08); border-color: rgba(255, 209, 102, 0.3); color: #ffe7ad; }
.meter { height: 8px; border-radius: 99px; background: rgba(255, 255, 255, 0.07); overflow: hidden; }
.meter > i { display: block; height: 100%; width: 0; border-radius: 99px; background: linear-gradient(90deg, var(--lh), var(--rh)); transition: width 0.08s linear; }
.kbd { font: 12px var(--mono); padding: 1px 6px; border-radius: 5px; background: var(--surface-3); border: 1px solid var(--line-2); }

/* ───── Vue JOUER ───── */
.view-play { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; overflow: hidden; }
.topbar, .bottombar {
  display: flex; align-items: center; gap: 8px; padding: 8px 12px; min-width: 0;
  overflow-x: auto; scrollbar-width: none; background: rgba(8, 12, 24, 0.75); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.topbar::-webkit-scrollbar, .bottombar::-webkit-scrollbar { display: none; }
.topbar { padding-top: calc(8px + var(--sa-t)); border-bottom: 1px solid var(--line); }
.bottombar { padding-bottom: calc(8px + var(--sa-b)); border-top: 1px solid var(--line); }
.song-btn { display: flex; align-items: center; gap: 8px; min-width: 0; max-width: 260px; padding: 4px 10px 4px 4px; border-radius: 12px; border: 1px solid transparent; background: transparent; text-align: left; flex: 0 1 auto; }
.song-btn:hover { background: rgba(255, 255, 255, 0.04); border-color: var(--line); }
.song-btn .cover { width: 34px; height: 34px; border-radius: 10px; flex: none; background: var(--accent); display: grid; place-items: center; color: #0a0f1d; font-weight: 900; font-size: 15px; }
.song-btn .t { display: block; font-weight: 750; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.song-btn .s { display: block; font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.song-btn > span { min-width: 0; }
.tb-gap { flex: 1 0 4px; }

.mic-btn { position: relative; }
.mic-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--faint); flex: none; box-shadow: 0 0 0 0 transparent; }
.mic-btn[data-state="on"] { border-color: rgba(78, 230, 160, 0.55); color: #d4ffe9; background: rgba(78, 230, 160, 0.1); }
.mic-btn[data-state="on"] .mic-dot { background: var(--good); animation: pulse 1.6s infinite; }
.mic-btn[data-state="gated"] .mic-dot { background: var(--warn); }
.mic-btn[data-state="gated"] { border-color: rgba(255, 209, 102, 0.5); }
.mic-btn[data-state="error"] .mic-dot { background: var(--bad); }
.mic-btn[data-state="error"] { border-color: rgba(255, 143, 107, 0.5); }
.mic-level { position: absolute; left: 8px; right: 8px; bottom: 3px; height: 2px; border-radius: 2px; background: transparent; overflow: hidden; }
.mic-level > i { display: block; height: 100%; width: 0; background: var(--good); }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(78, 230, 160, 0.6); } 70% { box-shadow: 0 0 0 7px rgba(78, 230, 160, 0); } 100% { box-shadow: 0 0 0 0 rgba(78, 230, 160, 0); } }

.stage { position: relative; min-height: 0; overflow: hidden; background: #050811; touch-action: none; }
.stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.hud { position: absolute; left: 12px; top: 10px; right: 12px; display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; pointer-events: none; z-index: 2; }
.hud-left { display: flex; gap: 8px; align-items: stretch; flex-wrap: wrap; }
.hud-card { pointer-events: auto; background: rgba(10, 15, 29, 0.72); border: 1px solid var(--line); border-radius: 14px; padding: 7px 12px; backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); min-width: 0; }
.hud-label { font-size: 10px; font-weight: 800; letter-spacing: 0.14em; text-transform: uppercase; color: var(--faint); }
.hud-note { font-family: var(--font-display); font-size: 26px; font-weight: 800; line-height: 1.1; letter-spacing: -0.02em; white-space: nowrap; }
.hud-note.lh { color: var(--lh); }
.hud-note.rh { color: var(--rh); }
.hud-note.both { background: var(--accent); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hud-sub { font-size: 11px; color: var(--muted); white-space: nowrap; }
.hud-heard { font-size: 20px; font-weight: 800; white-space: nowrap; }
.hud-heard.ok { color: var(--good); }
.hud-heard.ko { color: var(--bad); }
.hud-msg { pointer-events: none; position: absolute; left: 50%; bottom: calc(var(--kb-h, 120px) + 16px); transform: translateX(-50%); z-index: 3; max-width: min(520px, 60%); text-align: center; padding: 8px 14px; border-radius: 12px; font-size: 14px; font-weight: 650; background: rgba(10, 15, 29, 0.82); border: 1px solid var(--line-2); opacity: 0; transition: opacity 0.2s, transform 0.2s; }
.hud-msg.show { opacity: 1; }
.hud-msg.good { border-color: rgba(78, 230, 160, 0.5); color: #c9f9e1; }
.hud-msg.bad { border-color: rgba(255, 143, 107, 0.6); color: #ffd4c6; animation: shake 0.3s; }
@keyframes shake { 0%, 100% { transform: translateX(-50%); } 25% { transform: translateX(calc(-50% - 6px)); } 75% { transform: translateX(calc(-50% + 6px)); } }
.hud-right { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.hud-stats { font-size: 12px; color: var(--muted); text-align: right; }
.hud-stats b { color: var(--text); }
.center-overlay { position: absolute; inset: 0; display: grid; place-items: center; z-index: 2; pointer-events: none; }
.center-card { pointer-events: auto; text-align: center; padding: 18px 22px; border-radius: 18px; background: rgba(10, 15, 29, 0.8); border: 1px solid var(--line-2); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); max-width: min(440px, 86%); box-shadow: var(--shadow); }
.center-card h2 { font-size: 20px; margin-bottom: 6px; }
.center-card p { color: var(--muted); font-size: 14px; margin: 0 0 14px; }
.center-card .row { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }

.play-btn { width: 44px; height: 44px; min-width: 44px; border-radius: 50%; border: 0; background: var(--accent); color: #0a0f1d; display: grid; place-items: center; box-shadow: 0 6px 20px rgba(143, 125, 255, 0.35); flex: none; }
.play-btn .ic { width: 20px; height: 20px; }
.timeline { position: relative; flex: 1 1 200px; min-width: 140px; height: 34px; border-radius: 9px; background: rgba(255, 255, 255, 0.04); border: 1px solid var(--line); cursor: pointer; touch-action: none; overflow: hidden; }
.timeline canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.time-label { font: 600 12px var(--mono); color: var(--muted); white-space: nowrap; flex: none; }
.passage-btn { max-width: 190px; }
.passage-btn span { overflow: hidden; text-overflow: ellipsis; }

.rotate-hint { display: none; }
@media (orientation: portrait) and (max-width: 700px) {
  .hud-msg { bottom: calc(var(--kb-h, 120px) + 54px); }
  .rotate-hint { display: flex; position: absolute; left: 10px; right: 10px; bottom: calc(var(--kb-h, 120px) + 10px); z-index: 1; gap: 8px; align-items: center; justify-content: center; padding: 8px 12px; border-radius: 12px; background: rgba(10, 15, 29, 0.85); border: 1px solid var(--line-2); font-size: 13px; color: #cbd5e8; pointer-events: none; }
}

/* ───── Panneaux latéraux (sheets) ───── */
.scrim { position: fixed; inset: 0; background: rgba(2, 5, 12, 0.55); z-index: 40; opacity: 0; pointer-events: none; transition: opacity 0.2s; }
.scrim.show { opacity: 1; pointer-events: auto; }
.sheet {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(440px, 94vw); z-index: 41;
  background: linear-gradient(180deg, #111a30, #0b1222); border-left: 1px solid var(--line-2); box-shadow: var(--shadow);
  transform: translateX(105%); transition: transform 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
  display: flex; flex-direction: column; padding-right: var(--sa-r);
}
.sheet.wide { width: min(620px, 96vw); }
.sheet.open { transform: none; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: calc(14px + var(--sa-t)) 16px 12px 18px; border-bottom: 1px solid var(--line); }
.sheet-head h2 { font-size: 18px; }
.sheet-body { flex: 1; overflow-y: auto; padding: 16px 18px calc(24px + var(--sa-b)); display: flex; flex-direction: column; gap: 16px; overscroll-behavior: contain; }
.sec-title { font-size: 11px; font-weight: 800; letter-spacing: 0.14em; text-transform: uppercase; color: var(--faint); margin-bottom: 8px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }

/* Éditeur de passages */
.pe-wrap { position: relative; height: 120px; border-radius: 12px; background: #070c18; border: 1px solid var(--line-2); overflow: hidden; touch-action: none; cursor: crosshair; }
.pe-wrap canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.pe-axis { display: flex; justify-content: space-between; font: 11px var(--mono); color: var(--faint); margin-top: 4px; }
.presets { display: flex; gap: 6px; flex-wrap: wrap; }
.presets .btn { min-height: 30px; padding: 4px 10px; font-size: 12px; border-radius: 99px; }
.presets .btn.sel { border-color: var(--lh); color: #c9fff8; background: var(--lh-soft); }
.cp-list { display: flex; flex-direction: column; gap: 8px; }
.cp-item { display: flex; align-items: center; gap: 10px; padding: 10px 10px 10px 12px; border-radius: 12px; background: rgba(255, 255, 255, 0.03); border: 1px solid var(--line); }
.cp-item.active { border-color: rgba(46, 230, 211, 0.55); background: var(--lh-soft); }
.cp-item .info { flex: 1; min-width: 0; }
.cp-item .name { font-weight: 750; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cp-item .meta { font-size: 12px; color: var(--muted); }

/* Micro & calibrage */
.mic-hero { display: flex; gap: 14px; align-items: center; }
.mic-orb { width: 64px; height: 64px; border-radius: 50%; flex: none; display: grid; place-items: center; background: radial-gradient(circle at 35% 30%, #2a3a63, #121b33); border: 1px solid var(--line-2); position: relative; }
.mic-orb .ic { width: 28px; height: 28px; }
.mic-orb.on { background: radial-gradient(circle at 35% 30%, #1f6b5d, #0e2e2a); border-color: rgba(78, 230, 160, 0.6); color: #d4ffe9; }
.mic-orb .ring { position: absolute; inset: -6px; border-radius: 50%; border: 2px solid rgba(78, 230, 160, 0.55); opacity: 0; transform: scale(0.9); transition: opacity 0.08s, transform 0.08s; }
.live-note { display: flex; align-items: baseline; gap: 10px; }
.live-note .big { font-family: var(--font-display); font-size: 34px; font-weight: 800; min-width: 92px; }
.tuner { position: relative; height: 22px; border-radius: 8px; background: rgba(255, 255, 255, 0.04); border: 1px solid var(--line); overflow: hidden; }
.tuner::before { content: ""; position: absolute; left: 50%; top: 3px; bottom: 3px; width: 2px; background: rgba(255, 255, 255, 0.35); transform: translateX(-1px); }
.tuner i { position: absolute; top: 4px; bottom: 4px; width: 8px; border-radius: 4px; background: var(--good); left: 50%; transform: translateX(-4px); transition: left 0.08s; }
.cal-steps { display: flex; gap: 6px; flex-wrap: wrap; }
.cal-step { min-width: 62px; padding: 8px 10px; border-radius: 10px; text-align: center; background: rgba(255, 255, 255, 0.04); border: 1px solid var(--line); font-weight: 750; font-size: 14px; }
.cal-step small { display: block; font-size: 10px; color: var(--faint); font-weight: 650; }
.cal-step.cur { border-color: var(--rh); background: var(--rh-soft); color: #fff; }
.cal-step.done { border-color: rgba(78, 230, 160, 0.5); background: var(--good-soft); color: var(--good); }

/* ───── Mes pianos ───── */
.pn-current { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; background: linear-gradient(135deg, rgba(46, 230, 211, 0.08), rgba(177, 140, 255, 0.1)); border: 1px solid var(--line-2); }
.pn-current .ic { width: 26px; height: 26px; color: var(--rh); }
.pn-current-name { font-weight: 800; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pn-list { display: flex; flex-direction: column; gap: 10px; }
.pn-card { display: flex; flex-direction: column; gap: 10px; padding: 14px; border-radius: 14px; background: rgba(255, 255, 255, 0.03); border: 1px solid var(--line); }
.pn-card.active { border-color: rgba(177, 140, 255, 0.6); background: linear-gradient(160deg, rgba(177, 140, 255, 0.12), rgba(46, 230, 211, 0.06)); box-shadow: 0 8px 26px rgba(143, 125, 255, 0.12); }
.pn-top { display: flex; align-items: center; gap: 12px; min-width: 0; }
.pn-badge { width: 42px; height: 42px; border-radius: 12px; flex: none; display: grid; place-items: center; background: var(--surface-3); color: var(--muted); }
.pn-card.active .pn-badge { background: var(--accent); color: #0a0f1d; }
.pn-badge .ic { width: 24px; height: 24px; }
.pn-name { font-weight: 800; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pn-meta { font-size: 12.5px; color: var(--muted); }
.pn-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.pn-editor { display: flex; flex-direction: column; gap: 12px; padding: 14px; border-radius: 14px; border: 1px solid rgba(46, 230, 211, 0.45); background: rgba(46, 230, 211, 0.05); }
.pn-sounds { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.pn-sound { display: flex; flex-direction: column; gap: 6px; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line-2); background: var(--bg-2); cursor: pointer; text-align: left; color: var(--text); }
.pn-sound[aria-checked="true"] { border-color: var(--rh); background: var(--rh-soft); box-shadow: inset 0 0 0 1px rgba(177, 140, 255, 0.4); }
.pn-sound b { font-size: 14px; }
.pn-sound small { color: var(--muted); font-size: 12px; line-height: 1.4; }
.pn-sound .row { gap: 6px; margin-top: auto; }
@media (max-width: 560px) { .pn-sounds { grid-template-columns: 1fr; } }

/* ───── Bibliothèque ───── */
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr)); gap: 14px; }
.song-card { position: relative; display: flex; flex-direction: column; gap: 12px; padding: 16px; border-radius: var(--r-lg); background: linear-gradient(160deg, rgba(22, 32, 57, 0.95), rgba(13, 20, 37, 0.95)); border: 1px solid var(--line); overflow: hidden; min-width: 0; }
.song-card.current { border-color: rgba(177, 140, 255, 0.55); box-shadow: 0 0 0 1px rgba(177, 140, 255, 0.25), 0 12px 40px rgba(143, 125, 255, 0.12); }
.song-card .roll-thumb { height: 64px; border-radius: 10px; background: #070c18; border: 1px solid var(--line); display: block; width: 100%; }
.song-card h3 { font-size: 18px; overflow-wrap: anywhere; }
.song-card .by { color: var(--muted); font-size: 13px; margin-top: 2px; }
.song-card .chips { display: flex; flex-wrap: wrap; gap: 6px; }
.song-card .actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: auto; }
.song-card .actions .btn.primary { flex: 1; }
.progress-ring { position: absolute; top: 14px; right: 14px; width: 44px; height: 44px; }
.progress-ring text { font: 800 11px var(--font); fill: var(--text); }

/* ───── Ajouter ───── */
.add-grid { display: grid; grid-template-columns: 1.2fr 1fr; gap: 16px; align-items: start; }
.drop { border: 1.5px dashed rgba(148, 170, 215, 0.35); border-radius: var(--r-lg); padding: 26px 18px; text-align: center; background: rgba(255, 255, 255, 0.02); transition: border-color 0.15s, background 0.15s; }
.drop.over { border-color: var(--lh); background: var(--lh-soft); }
.drop .big-ic { width: 44px; height: 44px; margin: 0 auto 10px; border-radius: 14px; display: grid; place-items: center; background: var(--surface-3); }
.drop p { color: var(--muted); margin: 6px 0 14px; font-size: 14px; }
.preview-box { display: flex; flex-direction: column; gap: 12px; }
.preview-box canvas { width: 100%; height: 110px; border-radius: 10px; background: #070c18; border: 1px solid var(--line); display: block; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 650; }
.steps3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.step-card { padding: 14px; border-radius: var(--r-md); background: rgba(255, 255, 255, 0.03); border: 1px solid var(--line); font-size: 14px; color: #cbd5e8; }
.step-card b { display: block; color: var(--text); margin-bottom: 4px; }
.prompt-pre { margin: 0; max-height: 220px; overflow: auto; padding: 12px; border-radius: 10px; background: #070c18; border: 1px solid var(--line); font: 12px/1.5 var(--mono); color: #b9c6df; white-space: pre-wrap; }

/* ───── Toasts ───── */
.toasts { position: fixed; z-index: 60; left: 50%; bottom: calc(70px + var(--sa-b)); transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; width: min(520px, 92vw); }
.toast { pointer-events: auto; padding: 10px 14px; border-radius: 12px; background: rgba(17, 26, 48, 0.96); border: 1px solid var(--line-2); box-shadow: var(--shadow); font-size: 14px; font-weight: 600; animation: toastIn 0.25s ease-out; display: flex; gap: 10px; align-items: center; }
.toast.good { border-color: rgba(78, 230, 160, 0.5); }
.toast.bad { border-color: rgba(255, 143, 107, 0.6); }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ───── Portrait téléphone : barre d'onglets en bas ───── */
@media (max-width: 700px) and (orientation: portrait) {
  .app { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; }
  .rail { order: 2; flex-direction: row; justify-content: space-around; padding: 4px calc(4px + var(--sa-r)) calc(4px + var(--sa-b)) calc(4px + var(--sa-l)); border-right: 0; border-top: 1px solid var(--line); overflow-x: auto; overflow-y: hidden; }
  .rail-logo, .rail-spacer { display: none; }
  .nav-btn { width: auto; flex: 1; min-width: 52px; min-height: 50px; }
  .views { order: 1; }
  .add-grid, .steps3 { grid-template-columns: 1fr; }
  .page { padding: calc(16px + var(--sa-t)) 14px 30px; }
  .grid3 { grid-template-columns: 1fr 1fr; }
}
/* ───── Paysage téléphone : tout pour le clavier ───── */
@media (orientation: landscape) and (max-height: 520px) {
  :root { --rail-w: 58px; }
  .nav-btn { width: 48px; min-height: 42px; font-size: 9px; padding: 4px 2px; }
  .nav-btn .ic { width: 20px; height: 20px; }
  .rail { gap: 2px; padding-top: calc(6px + var(--sa-t)); padding-bottom: calc(6px + var(--sa-b)); }
  .rail-logo { display: none; }
  .topbar { padding: calc(5px + var(--sa-t)) 8px 5px; gap: 6px; }
  .bottombar { padding: 5px 8px calc(5px + var(--sa-b)); gap: 6px; }
  .seg button { min-height: 28px; padding: 3px 8px; font-size: 12px; }
  .btn { min-height: 34px; padding: 5px 10px; font-size: 13px; }
  .btn.icon { width: 34px; min-width: 34px; }
  .song-btn .cover { width: 28px; height: 28px; font-size: 13px; }
  .song-btn .s { display: none; }
  .play-btn { width: 36px; height: 36px; min-width: 36px; }
  .timeline { height: 28px; }
  .hud { left: 8px; right: 8px; top: 6px; }
  .hud-card { padding: 5px 9px; border-radius: 11px; }
  .hud-note { font-size: 20px; }
  .hud-heard { font-size: 16px; }
  .hud-label { font-size: 9px; }
  .page { padding-top: calc(14px + var(--sa-t)); }
  .center-overlay { place-items: start center; padding-top: 10px; }
  .center-card { padding: 10px 16px; border-radius: 14px; max-width: min(420px, 70%); }
  .center-card h2 { font-size: 16px; margin-bottom: 2px; }
  .center-card p { font-size: 12.5px; margin-bottom: 8px; line-height: 1.4; }
  .hud-sub { display: none; }
  .hud-msg { font-size: 13px; padding: 6px 12px; }
}
@media (max-width: 900px) {
  .add-grid { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
