/* =============================================================
   PianoFlow — Lecteur (Player) — fidèle à l'app iPad
   ============================================================= */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
.player-body {
  background: #060505;
  color: var(--pf-ivory, #F0E6D8);
  font-family: var(--pf-font-sans, -apple-system, system-ui, sans-serif);
  -webkit-font-smoothing: antialiased;
  overflow: hidden; user-select: none; -webkit-user-select: none;
}
button { font-family: inherit; cursor: pointer; }
[hidden] { display: none !important; }

:root {
  --note-right: #66C7FF; --note-left: #FF6B2C; --note-both: #FFBB40;
  --felt: #E0352F;
  --key-white: #F4ECDD; --key-black: #15100d;
  --pp: #A78BFA; /* purple loop */
}

.player-app { position: fixed; inset: 0; }

/* ===================== STAGE (full-screen behind bar) ===================== */
.pv-stage { position: absolute; inset: 0; z-index: 1; }
#roll { display: block; width: 100%; height: 100%; touch-action: none; }

/* ===================== FLOATING TOP BAR ===================== */
.pv-bar {
  position: absolute; z-index: 20;
  top: 12px; left: 12px; right: 12px;
  display: flex; align-items: center; gap: 9px;
  padding: 8px 12px;
  border-radius: 22px;
  background: rgba(22,17,14,0.62);
  -webkit-backdrop-filter: blur(28px) saturate(180%);
  backdrop-filter: blur(28px) saturate(180%);
  border: 0.5px solid rgba(255,255,255,0.12);
  box-shadow: 0 10px 34px rgba(0,0,0,0.4), inset 0 1px 0 rgba(255,255,255,0.06);
}
.pv-sep { width: 1px; height: 26px; background: rgba(255,255,255,0.14); margin: 0 2px; flex: none; }

.pv-icn {
  width: 42px; height: 42px; flex: none;
  display: grid; place-items: center; border-radius: 50%;
  background: rgba(255,255,255,0.07); border: 0.5px solid rgba(255,255,255,0.14);
  color: #fff; transition: background .2s, transform .15s, filter .2s;
}
.pv-icn:hover { background: rgba(255,255,255,0.14); }
.pv-icn:active { transform: scale(0.93); }
.pv-icn.sm { width: 32px; height: 32px; }
.pv-icn svg { width: 19px; height: 19px; }
.pv-icn.loop.on { background: var(--pp); border-color: transparent; color: #fff; box-shadow: 0 6px 18px rgba(167,139,250,0.5); }

.pv-play {
  width: 48px; height: 48px; flex: none; display: grid; place-items: center;
  border-radius: 16px;
  background: linear-gradient(135deg, #FF8A3D, #FF6B2C);
  border: none; color: #fff; box-shadow: 0 8px 20px rgba(255,107,44,0.5);
  transition: transform .15s, filter .2s;
}
.pv-play:hover { filter: brightness(1.06); }
.pv-play:active { transform: scale(0.93); }
.pv-play svg { width: 22px; height: 22px; }

.pv-stat { display: inline-flex; align-items: center; gap: 5px; padding: 6px 10px; border-radius: 999px; font-size: 13px; font-weight: 800; font-variant-numeric: tabular-nums; }
.pv-stat.ok { background: rgba(52,199,89,0.14); color: #34C759; border: 0.5px solid rgba(52,199,89,0.3); }
.pv-stat.bad { background: rgba(255,59,48,0.14); color: #FF453A; border: 0.5px solid rgba(255,59,48,0.3); }

.pv-time { font-size: 13px; font-weight: 700; color: rgba(240,230,216,0.7); font-variant-numeric: tabular-nums; min-width: 34px; text-align: center; }

.pv-scrub { flex: 1; min-width: 70px; height: 5px; position: relative; border-radius: 4px; background: rgba(255,255,255,0.16); cursor: pointer; }
.pv-scrub .fill { position: absolute; left: 0; top: 0; bottom: 0; width: 0%; border-radius: 4px; background: linear-gradient(90deg, #FF6B2C, #FFBB40); pointer-events: none; }
.pv-scrub .knob { position: absolute; left: 0%; top: 50%; transform: translate(-50%,-50%); width: 15px; height: 15px; border-radius: 50%; background: #fff; box-shadow: 0 2px 6px rgba(0,0,0,0.5); pointer-events: none; }
.pv-scrub .loopseg { position: absolute; top: -3px; bottom: -3px; border-radius: 4px; background: rgba(167,139,250,0.30); border: 1px solid var(--pp); pointer-events: none; }

.pv-speed { display: inline-flex; align-items: center; gap: 2px; }
.pv-step { width: 30px; height: 32px; border: none; background: rgba(255,255,255,0.07); color: #fff; font-size: 18px; font-weight: 700; border-radius: 10px; }
.pv-step:hover { background: rgba(255,255,255,0.14); }
.pv-speed-val { display: inline-flex; align-items: center; gap: 5px; padding: 0 8px; font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.pv-speed-val svg { width: 17px; height: 17px; opacity: .85; }

.pv-hands { display: inline-flex; gap: 2px; padding: 3px; border-radius: 999px; background: rgba(255,255,255,0.07); border: 0.5px solid rgba(255,255,255,0.14); }
.pv-hands button { border: none; background: none; color: rgba(240,230,216,0.7); font-size: 14px; font-weight: 700; padding: 7px 14px; border-radius: 999px; transition: background .25s, color .25s; }
.pv-hands button.on { background: var(--pf-gold, #FFBB40); color: #2a1c00; box-shadow: 0 2px 8px rgba(255,187,64,0.4); }

/* ===================== LOOP EDITOR BAR ===================== */
.pv-loopbar {
  position: absolute; z-index: 21;
  top: 12px; left: 12px; right: 12px;
  display: flex; align-items: center; gap: 14px;
  padding: 10px 14px; border-radius: 22px;
  background: rgba(40,28,58,0.72);
  -webkit-backdrop-filter: blur(28px) saturate(180%); backdrop-filter: blur(28px) saturate(180%);
  border: 0.5px solid rgba(167,139,250,0.4);
  box-shadow: 0 10px 34px rgba(0,0,0,0.4);
}
.pv-loop-end { text-align: center; }
.pv-loop-end .l { font-size: 10px; font-weight: 800; letter-spacing: .1em; color: rgba(255,255,255,0.55); }
.pv-loop-end .v { font-size: 16px; font-weight: 800; font-variant-numeric: tabular-nums; }
.pv-loop-track { flex: 1; height: 6px; position: relative; border-radius: 4px; background: rgba(255,255,255,0.14); }
.pv-loop-track .seg { position: absolute; top: -2px; bottom: -2px; border-radius: 4px; background: rgba(167,139,250,0.35); border: 1px solid var(--pp); }
.pv-loop-track .h { position: absolute; top: 50%; transform: translate(-50%,-50%); width: 16px; height: 22px; border-radius: 6px; background: var(--pp); box-shadow: 0 2px 8px rgba(0,0,0,0.5); cursor: ew-resize; }
.pv-loop-hint { font-size: 12.5px; color: rgba(255,255,255,0.6); }
.pv-loop-confirm { display: inline-flex; align-items: center; gap: 7px; border: none; background: var(--pp); color: #fff; font-size: 15px; font-weight: 800; padding: 10px 18px; border-radius: 14px; box-shadow: 0 6px 18px rgba(167,139,250,0.5); }
.pv-loop-confirm svg { width: 16px; height: 16px; }
.pv-loop-confirm.off { background: rgba(255,255,255,0.1); box-shadow: none; }

/* ===================== DROP HINT ===================== */
.pv-drop { position: absolute; inset: 0; display: grid; place-items: center; z-index: 14; transition: opacity .3s; }
.pv-drop.hide { opacity: 0; pointer-events: none; }
.pv-drop.dragover .pv-drop-card { border-color: var(--pf-orange, #FF6B2C); box-shadow: 0 0 0 3px rgba(255,107,44,0.3), 0 30px 70px rgba(0,0,0,0.5); transform: scale(1.02); }
.pv-drop-card { text-align: center; padding: 40px 44px; max-width: 440px; border-radius: 24px; background: rgba(28,22,18,0.86); -webkit-backdrop-filter: blur(24px); backdrop-filter: blur(24px); border: 1px solid rgba(255,255,255,0.14); box-shadow: 0 30px 70px rgba(0,0,0,0.5); transition: transform .25s, box-shadow .25s, border-color .25s; }
.pv-drop-card > svg { width: 46px; height: 46px; color: var(--pf-orange, #FF6B2C); margin-bottom: 16px; }
.pv-drop-card .t { font-size: 22px; font-weight: 800; letter-spacing: -0.02em; }
.pv-drop-card .s { font-size: 14px; color: rgba(240,230,216,0.62); margin: 10px auto 22px; line-height: 1.5; max-width: 32ch; }
.pv-drop-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.pv-btn { border: 0.5px solid rgba(255,255,255,0.16); background: rgba(255,255,255,0.08); color: #fff; font-size: 14px; font-weight: 700; padding: 12px 20px; border-radius: 14px; transition: filter .2s, background .2s, transform .15s; }
.pv-btn:hover { background: rgba(255,255,255,0.14); }
.pv-btn:active { transform: scale(0.97); }
.pv-btn.primary { background: linear-gradient(135deg, #FF6B2C, #FFBB40); border: none; box-shadow: 0 8px 20px rgba(255,107,44,0.4); }
.pv-btn.block { width: 100%; }

/* ===================== SETTINGS PANEL (3 tabs) ===================== */
.pv-settings {
  position: absolute; top: 12px; right: 12px; bottom: 12px; z-index: 30;
  width: min(380px, 88vw);
  border-radius: 26px;
  background: rgba(24,18,15,0.92);
  -webkit-backdrop-filter: blur(34px) saturate(180%); backdrop-filter: blur(34px) saturate(180%);
  border: 0.5px solid rgba(255,255,255,0.12);
  box-shadow: -10px 0 50px rgba(0,0,0,0.5);
  overflow-y: auto; padding: 20px;
  animation: slideIn .32s cubic-bezier(0.22,1,0.36,1);
}
.pv-settings::-webkit-scrollbar { width: 0; }
@keyframes slideIn { from { transform: translateX(16px); opacity: 0; } to { transform: none; opacity: 1; } }
.pv-set-over { font-size: 10px; font-weight: 800; letter-spacing: .12em; color: rgba(240,230,216,0.42); }
.pv-set-head { display: flex; align-items: flex-end; justify-content: space-between; margin: 2px 0 18px; }
.pv-set-head .ttl { font-size: 26px; font-weight: 800; letter-spacing: -0.03em; }

.pv-tabs { display: flex; gap: 3px; padding: 3px; border-radius: 13px; background: rgba(255,255,255,0.06); border: 0.5px solid rgba(255,255,255,0.1); margin-bottom: 20px; }
.pv-tabs button { flex: 1; border: none; background: none; color: rgba(240,230,216,0.65); font-size: 14px; font-weight: 700; padding: 9px 6px; border-radius: 10px; transition: background .2s, color .2s; }
.pv-tabs button.on { background: linear-gradient(135deg, rgba(255,107,44,0.9), rgba(216,72,26,0.9)); color: #fff; }

.pv-tabpane { display: none; }
.pv-tabpane.on { display: block; }
.pv-sec-label { font-size: 11px; font-weight: 800; letter-spacing: .09em; color: rgba(240,230,216,0.5); margin: 20px 0 10px; }
.pv-sec-label:first-child { margin-top: 0; }

/* big choice cards */
.pv-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.pv-cards.three { grid-template-columns: repeat(3,1fr); }
.pv-card { text-align: left; padding: 14px; border-radius: 16px; background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.1); color: #fff; position: relative; transition: border-color .2s, background .2s; }
.pv-card.on { border-color: var(--pf-orange, #FF6B2C); background: rgba(255,107,44,0.12); }
.pv-card .ci { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; margin-bottom: 10px; background: rgba(255,255,255,0.1); color: #fff; }
.pv-card.on .ci { background: linear-gradient(135deg,#FF8A3D,#FF6B2C); }
.pv-card .ci svg { width: 19px; height: 19px; }
.pv-card .ct { font-size: 14px; font-weight: 800; line-height: 1.15; }
.pv-card .cs { font-size: 11px; color: rgba(240,230,216,0.55); margin-top: 3px; line-height: 1.25; }
.pv-card .chk { position: absolute; top: 10px; right: 10px; width: 18px; height: 18px; border-radius: 50%; background: var(--pf-orange,#FF6B2C); display: none; place-items: center; }
.pv-card.on .chk { display: grid; }
.pv-card .chk svg { width: 11px; height: 11px; color: #fff; }

/* toggle rows */
.pv-row { display: flex; align-items: center; gap: 12px; padding: 13px 2px; border-top: 0.5px solid rgba(255,255,255,0.08); }
.pv-row:first-of-type { border-top: none; }
.pv-row .ri { width: 30px; height: 30px; flex: none; border-radius: 9px; display: grid; place-items: center; background: rgba(255,255,255,0.08); color: rgba(240,230,216,0.8); }
.pv-row .ri svg { width: 16px; height: 16px; }
.pv-row .rt { flex: 1; }
.pv-row .rt .rl { font-size: 15px; font-weight: 600; }
.pv-row .rt .rd { font-size: 12px; color: rgba(240,230,216,0.5); margin-top: 2px; line-height: 1.35; }
.pv-switch { width: 48px; height: 28px; flex: none; border-radius: 999px; border: none; background: rgba(255,255,255,0.16); position: relative; transition: background .25s; }
.pv-switch i { position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: transform .25s cubic-bezier(0.34,1.56,0.64,1); }
.pv-switch.on { background: #34C759; }
.pv-switch.on.blue { background: #2A9BE0; }
.pv-switch.on.purple { background: var(--pp); }
.pv-switch.on i { transform: translateX(20px); }

.pv-inline { display: flex; align-items: center; justify-content: space-between; padding: 6px 2px; }
.pv-inline .il { font-size: 15px; font-weight: 600; }
.pv-mini-seg { display: inline-flex; gap: 2px; padding: 3px; border-radius: 999px; background: rgba(255,255,255,0.07); border: 0.5px solid rgba(255,255,255,0.12); }
.pv-mini-seg button { border: none; background: none; color: rgba(240,230,216,0.7); font-size: 13px; font-weight: 700; padding: 6px 13px; border-radius: 999px; }
.pv-mini-seg button.on { background: var(--pf-gold,#FFBB40); color: #2a1c00; }

/* sliders */
.pv-sliders { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 6px; }
.pv-slider .sh { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.pv-slider .sl { font-size: 11px; font-weight: 800; letter-spacing: .08em; color: rgba(240,230,216,0.5); }
.pv-slider .sv { font-size: 15px; font-weight: 800; font-variant-numeric: tabular-nums; }
.pv-range { -webkit-appearance: none; appearance: none; width: 100%; height: 6px; border-radius: 4px; background: rgba(255,255,255,0.14); outline: none; }
.pv-range::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 2px 6px rgba(0,0,0,0.5); cursor: pointer; }
.pv-range::-moz-range-thumb { width: 18px; height: 18px; border: none; border-radius: 50%; background: #fff; box-shadow: 0 2px 6px rgba(0,0,0,0.5); cursor: pointer; }
.pv-range.orange { background: linear-gradient(90deg,#FF6B2C var(--p,50%), rgba(255,255,255,0.14) var(--p,50%)); }
.pv-range.gold { background: linear-gradient(90deg,#FFBB40 var(--p,86%), rgba(255,255,255,0.14) var(--p,86%)); }
.pv-range.green { background: linear-gradient(90deg,#34C759 var(--p,50%), rgba(255,255,255,0.14) var(--p,50%)); }

/* MIDI row */
.pv-midi { display: flex; align-items: center; justify-content: space-between; padding: 14px; border-radius: 14px; background: rgba(255,255,255,0.05); border: 0.5px solid rgba(255,255,255,0.1); margin-top: 8px; }
.pv-midi .ml { font-size: 14px; font-weight: 700; }
.pv-midi .badge { font-size: 11px; font-weight: 800; color: var(--pf-gold,#FFBB40); display: inline-flex; align-items: center; gap: 5px; }
.pv-midi .badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--pf-gold,#FFBB40); }
.pv-link { color: rgba(240,230,216,0.7); font-size: 13px; font-weight: 700; background: none; border: none; display: inline-flex; align-items: center; gap: 5px; }

/* radio list (Touches / Notes) */
.pv-list { display: grid; gap: 2px; }
.pv-li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 15px 14px; border-radius: 13px; background: rgba(255,255,255,0.04); border: 0.5px solid transparent; color: #fff; font-size: 15px; font-weight: 600; text-align: left; }
.pv-li:hover { background: rgba(255,255,255,0.07); }
.pv-li .def { font-size: 12px; color: rgba(240,230,216,0.45); font-weight: 600; margin-left: 6px; }
.pv-li .tick { width: 20px; height: 20px; color: #34C759; display: none; }
.pv-li.on .tick { display: block; }
.pv-li.on { background: rgba(255,255,255,0.07); }
.pv-help { font-size: 13px; color: rgba(240,230,216,0.55); line-height: 1.5; margin: 0 0 14px; }
.pv-set-note { font-size: 12px; color: rgba(240,230,216,0.45); margin: 14px 0 0; line-height: 1.5; }

/* loading */
.pv-loading { position: absolute; inset: 0; z-index: 40; display: grid; place-content: center; justify-items: center; gap: 16px; background: rgba(12,10,9,0.7); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); font-size: 14px; color: rgba(240,230,216,0.8); font-weight: 600; }
.pv-spin { width: 38px; height: 38px; border-radius: 50%; border: 3px solid rgba(255,255,255,0.15); border-top-color: var(--pf-orange,#FF6B2C); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 1080px) {
  .pv-bar { flex-wrap: wrap; }
  .pv-scrub { order: 10; flex-basis: 100%; margin-top: 2px; }
}
/* iPhone : barre compacte — l'essentiel, le scrubber sur sa propre ligne */
@media (max-width: 640px) {
  .pv-bar {
    gap: 6px; padding: 7px 9px;
    top: 8px; left: 8px; right: 8px;
    border-radius: 18px;
    flex-wrap: wrap; justify-content: center;
  }
  .pv-stat, #restartBtn, #rewBtn, #fwdBtn, .pv-speed { display: none; }
  .pv-icn { width: 36px; height: 36px; }
  .pv-icn svg { width: 17px; height: 17px; }
  .pv-play { width: 42px; height: 42px; border-radius: 13px; }
  .pv-play svg { width: 19px; height: 19px; }
  .pv-hands button { padding: 6px 11px; font-size: 13px; }
  .pv-time { min-width: 28px; font-size: 12px; }
  /* saut de ligne avant le groupe scrubber */
  .pv-bar::after { content: ""; flex-basis: 100%; order: 19; height: 0; }
  #curTime { order: 20; }
  #scrub { order: 21; flex: 1 1 auto; min-width: 0; margin-top: 0; }
  #durTime { order: 22; }
}
