:root {
  --bg: #0d0806;
  --bg-2: #120b08;
  --card: #1a110d;
  --card-2: #241712;
  --line: rgba(255, 150, 100, .09);
  --text: #fff5ef;
  --muted: #a88b7e;
  --dim: #6e5449;
  --flame-1: #ffb33d;
  --flame-2: #ff6a2b;
  --flame-3: #ff2e63;
  --flame: linear-gradient(135deg, var(--flame-1) 0%, var(--flame-2) 48%, var(--flame-3) 100%);
  --accent: #ff7a35;
  --accent-soft: rgba(255, 122, 53, .14);
  --accent-softer: rgba(255, 122, 53, .08);
  --gold: #ffc65c;
  --wave-rest: #3f2a22;
  --loop-fill: rgba(255, 106, 43, .14);
  --tick: #ffb38a;
  --danger: #ff5a5f;
  --sheet: rgba(30, 20, 16, .94);
  --radius: 22px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --num: ui-rounded, "SF Pro Rounded", -apple-system, system-ui, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.35 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, system-ui, sans-serif;
  overscroll-behavior: none;
  -webkit-user-select: none; user-select: none;
  -webkit-text-size-adjust: 100%;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
button:focus-visible, .slider:focus-visible, .picker-list:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
svg.fill, svg .fill { fill: currentColor; stroke: none; }

.app {
  position: relative;
  display: flex; flex-direction: column; gap: 10px;
  height: 100vh; height: 100dvh;
  max-width: 560px; margin: 0 auto;
  padding-top: var(--safe-top);
  background:
    radial-gradient(120% 50% at 50% -10%, rgba(255, 106, 43, .16), transparent 60%),
    radial-gradient(80% 40% at 100% 110%, rgba(255, 46, 99, .10), transparent 60%),
    var(--bg);
  overflow: hidden;
}
@media (min-width: 600px) {
  body { background: #070403; }
  .app { border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
}

/* ---------- header ---------- */
.top { padding: 10px 16px 0; }
.brand-row { display: flex; align-items: center; justify-content: space-between; }
.brand { display: flex; align-items: center; gap: 6px; }
.logo { width: 26px; height: 26px; }
.brand-name {
  font: 800 12px/1 var(--num); letter-spacing: .22em;
  background: var(--flame); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.top-actions { display: flex; gap: 8px; }
.title-btn { display: block; width: 100%; text-align: left; margin-top: 8px; min-width: 0; }
.track-title {
  display: block; font: 700 24px/1.15 var(--num); letter-spacing: -.01em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.track-sub { display: block; margin-top: 3px; font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.icon-btn {
  position: relative;
  width: 40px; height: 40px; flex: none;
  border-radius: 50%;
  display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent);
  transition: background .15s, color .15s, opacity .15s, transform .1s;
}
.icon-btn.small { width: 34px; height: 34px; }
.icon-btn.small svg { width: 18px; height: 18px; }
.icon-btn:active { transform: scale(.93); }
.icon-btn[aria-pressed="true"] { background: var(--flame); color: #fff; box-shadow: 0 4px 14px rgba(255, 90, 50, .35); }
.icon-btn:disabled { opacity: .3; pointer-events: none; }

/* ---------- card ---------- */
.card {
  margin: 0 12px;
  background: linear-gradient(180deg, rgba(255, 255, 255, .025), transparent), var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.controls { padding: 6px 12px; }
.ctl {
  display: grid; grid-template-columns: 82px 32px 1fr 32px; align-items: center; gap: 8px;
  padding: 8px 0;
}
.ctl + .ctl { border-top: 1px solid var(--line); }
.ctl-info { display: flex; flex-direction: column; align-items: flex-start; min-width: 0; }
.ctl-label {
  display: flex; align-items: center; gap: 6px; height: 18px;
  font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--muted);
}
.reset { display: grid; place-items: center; width: 18px; height: 18px; color: var(--accent); opacity: 0; pointer-events: none; transition: opacity .2s; }
.reset svg { width: 15px; height: 15px; }
.reset.on { opacity: 1; pointer-events: auto; }
.ctl-value {
  font: 700 22px/1.1 var(--num); font-variant-numeric: tabular-nums; letter-spacing: -.01em;
  padding: 2px 0; text-align: left;
}
.ctl-value.changed { background: var(--flame); -webkit-background-clip: text; background-clip: text; color: transparent; }
.step-btn {
  width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center;
  background: rgba(255, 255, 255, .05); color: var(--text);
}
.step-btn svg { width: 16px; height: 16px; stroke-width: 2.4; }
.step-btn:active { background: var(--accent-soft); color: var(--accent); }

/* slider */
.slider {
  --p: 0;
  position: relative; height: 36px; min-width: 0;
  touch-action: none; cursor: pointer;
}
.slider-track {
  position: absolute; left: 0; right: 0; top: 50%; height: 6px; margin-top: -3px;
  border-radius: 3px; background: rgba(255, 255, 255, .08); overflow: hidden;
}
.slider-fill {
  position: absolute; left: 0; top: 0; bottom: 0;
  width: calc(var(--p) * (100% - 28px) + 14px);
  background: var(--flame);
}
.slider-thumb {
  position: absolute; top: 50%; left: calc(var(--p) * (100% - 28px));
  width: 28px; height: 20px; margin-top: -10px;
  border-radius: 10px; background: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .45), 0 0 0 4px rgba(255, 106, 43, .18);
  transition: transform .12s, box-shadow .12s;
}
.slider.active .slider-thumb { transform: scale(1.15); box-shadow: 0 2px 8px rgba(0, 0, 0, .45), 0 0 0 7px rgba(255, 106, 43, .25); }
.slider.disabled { opacity: .4; pointer-events: none; }

/* loop */
.loop-card { display: flex; align-items: center; gap: 12px; padding: 10px 12px; }
.loop-btns { display: flex; align-items: center; gap: 8px; }
.pill-btn {
  width: 38px; height: 38px; border-radius: 50%;
  font: 700 16px var(--num);
  background: var(--accent-soft); color: var(--accent);
  transition: transform .1s;
}
.pill-btn.set { background: var(--flame); color: #fff; box-shadow: 0 4px 14px rgba(255, 90, 50, .35); }
.pill-btn:active { transform: scale(.93); }
.loop-tools { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.tool-btn {
  display: flex; align-items: center; gap: 6px; height: 38px; padding: 0 12px 0 10px; border-radius: 19px;
  background: var(--accent-soft); color: var(--accent); font-size: 13px; font-weight: 600; white-space: nowrap;
}
.tool-btn svg { width: 18px; height: 18px; }
.tool-btn[aria-pressed="true"] { background: var(--flame); color: #fff; }
@media (max-width: 400px) { .loop-card > .ctl-label { display: none; } }
@media (max-width: 340px) { .tool-btn span { display: none; } .tool-btn { padding: 0 10px; } }

/* ---------- forma d'onda ---------- */
.wave-wrap { position: relative; flex: 1; min-height: 140px; margin: 0 4px; display: flex; flex-direction: column; }
.wave-tools { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 0 10px; height: 34px; flex: none; }
.wave-canvas { position: relative; flex: 1; min-height: 0; }
#wave { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: pointer; }
.zoom-btn { position: relative; }
.zoom-level {
  position: absolute; bottom: -4px; right: -6px;
  font: 800 9px/1 var(--num);
  background: #fff; color: var(--bg); border-radius: 6px; padding: 2px 4px;
}
.zoom-level:empty { display: none; }
.chip {
  display: inline-flex; align-items: center; gap: 5px; height: 30px; padding: 0 10px; border-radius: 15px;
  background: rgba(255, 198, 92, .14); color: var(--gold); font: 700 13px var(--num);
}
.chip svg { width: 15px; height: 15px; }
.marker-strip { flex: 1; min-width: 0; display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding: 2px 0; }
.marker-strip::-webkit-scrollbar { display: none; }
.mchip {
  flex: none; display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px 0 4px; border-radius: 15px;
  background: rgba(255, 198, 92, .12); color: var(--gold); font: 600 13px var(--num); white-space: nowrap; max-width: 150px;
}
.mchip b { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 11px; background: var(--gold); color: var(--bg); font-size: 11px; flex: none; }
.mchip span { overflow: hidden; text-overflow: ellipsis; }
.mchip.on { background: var(--gold); color: var(--bg); }
.mchip.on b { background: var(--bg); color: var(--gold); }
.mchip:active { transform: scale(.95); }
.mchip.add { background: rgba(255, 255, 255, .06); color: var(--muted); max-width: none; }
.mchip.add b { background: rgba(255, 198, 92, .2); color: var(--gold); font-size: 15px; }
.markers-chip[hidden] { display: none; }
.empty {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 16px; padding: 24px; text-align: center;
}
.empty-glow {
  position: absolute; width: 220px; height: 220px; border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 106, 43, .28), transparent 65%);
  filter: blur(10px); pointer-events: none;
}
.empty p { position: relative; margin: 0; color: var(--muted); font-size: 13px; max-width: 290px; }
.add-big {
  position: relative; display: flex; align-items: center; gap: 10px;
  padding: 15px 26px; border-radius: 999px;
  background: var(--flame); color: #fff; font-weight: 700; font-size: 17px;
  box-shadow: 0 10px 30px rgba(255, 80, 50, .4);
}
.add-big svg { width: 20px; height: 20px; stroke-width: 2.8; }
.add-big:active { transform: scale(.97); }
.app.has-track .empty { display: none; }
.app:not(.has-track) .wave-tools, .app:not(.has-track) .beat-strip { visibility: hidden; }
.loading {
  position: absolute; inset: 0; display: flex; flex-direction: column; gap: 12px;
  align-items: center; justify-content: center; color: var(--muted); font-size: 13px;
  background: rgba(13, 8, 6, .6); z-index: 3; border-radius: var(--radius);
}
.loading[hidden] { display: none; }
.spinner {
  width: 30px; height: 30px; border-radius: 50%;
  border: 3px solid var(--accent-soft); border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- conteggio 1-8 ---------- */
.beat-strip { display: flex; align-items: center; gap: 8px; padding: 0 12px; }
.bpm-chip { background: var(--accent-soft); color: var(--accent); gap: 3px; min-width: 76px; justify-content: center; }
.bpm-num { font-variant-numeric: tabular-nums; }
.bpm-unit { font-size: 10px; letter-spacing: .06em; opacity: .8; }
.counts { flex: 1; display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px; cursor: pointer; }
.counts:active span { background: rgba(255, 122, 53, .2); }
.counts span {
  height: 30px; border-radius: 9px; display: grid; place-items: center;
  font: 700 13px var(--num); color: var(--dim);
  background: rgba(255, 255, 255, .04);
  transition: background .08s, color .08s, transform .08s;
}
.counts span:nth-child(1), .counts span:nth-child(5) { color: var(--muted); }
.counts span.on { background: var(--flame); color: #fff; transform: scale(1.08); box-shadow: 0 4px 14px rgba(255, 90, 50, .4); }
.counts.off span { opacity: .35; }
.beat-strip.hidden-count .counts { visibility: hidden; }

/* ---------- trasporto ---------- */
.transport { padding: 0 16px; }
.seek-row { display: flex; align-items: center; gap: 10px; }
.seek-row .slider { flex: 1; }
.time { width: 44px; font: 600 13px var(--num); font-variant-numeric: tabular-nums; color: var(--muted); }
.time.right { text-align: right; }
.buttons { display: flex; align-items: center; justify-content: space-between; margin-top: 4px; }
.plain-btn { position: relative; width: 44px; height: 44px; display: grid; place-items: center; color: var(--text); }
.plain-btn svg { width: 24px; height: 24px; }
.plain-btn.mode { color: var(--dim); }
.plain-btn.mode svg { width: 21px; height: 21px; }
.plain-btn.mode[aria-pressed="true"] { color: var(--accent); }
.plain-btn:active { opacity: .6; }
.play-btn {
  width: 72px; height: 72px; border-radius: 50%; display: grid; place-items: center; color: #fff;
  background: var(--flame);
  box-shadow: 0 10px 30px rgba(255, 80, 50, .45), inset 0 1px 0 rgba(255, 255, 255, .35);
  transition: transform .12s;
}
.play-btn svg { width: 34px; height: 34px; }
.play-btn:active { transform: scale(.94); }
.play-btn .icon-pause { display: none; }
.app.playing .play-btn .icon-play { display: none; }
.app.playing .play-btn .icon-pause { display: block; }
.badge {
  position: absolute; top: 5px; right: 4px; display: none;
  font: 800 9px/14px var(--num); width: 14px; text-align: center;
  border-radius: 50%; background: var(--accent); color: #fff;
}
#repeatBtn[data-mode="one"] .badge { display: block; }

.up-next {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  margin: 0 12px calc(8px + var(--safe-bottom));
  padding: 11px 16px; border-radius: 16px;
  background: rgba(255, 255, 255, .04); color: var(--muted); font-size: 14px;
}
.up-next svg { width: 18px; height: 18px; color: var(--accent); }
.up-next span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- fogli modali ---------- */
.sheet { position: fixed; inset: 0; z-index: 20; pointer-events: none; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, .5); opacity: 0; transition: opacity .25s; }
.sheet-panel {
  position: absolute; left: 50%; bottom: 0;
  width: min(100% - 20px, 540px);
  max-height: calc(100% - var(--safe-top) - 30px);
  margin-bottom: calc(10px + var(--safe-bottom));
  transform: translate(-50%, calc(100% + 40px));
  display: flex; flex-direction: column;
  background: var(--sheet);
  -webkit-backdrop-filter: blur(24px) saturate(1.3); backdrop-filter: blur(24px) saturate(1.3);
  border: 1px solid rgba(255, 160, 120, .12);
  border-radius: 30px;
  box-shadow: 0 -10px 40px rgba(0, 0, 0, .5);
  transition: transform .32s cubic-bezier(.2, .9, .25, 1);
  overflow: hidden;
}
.sheet-panel.tall { height: 80%; }
.sheet.open { pointer-events: auto; }
.sheet.open .sheet-backdrop { opacity: 1; }
.sheet.open .sheet-panel { transform: translate(-50%, 0); }
.sheet-head { display: grid; grid-template-columns: 44px 1fr auto; align-items: center; padding: 14px 16px 6px; gap: 8px; }
.sheet-head .spacer { width: 44px; }
.sheet-title { margin: 0; text-align: center; font: 700 17px var(--num); }
.close-btn { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: rgba(255, 255, 255, .08); }
.close-btn svg { width: 18px; height: 18px; }
.text-btn { color: var(--accent); font-weight: 700; padding: 8px 4px; white-space: nowrap; }
.text-btn.center { display: block; margin: 12px auto 0; }
.sheet-intro { color: var(--muted); font-size: 14px; margin: 4px 0 6px; }

/* rullo */
.picker { position: relative; height: 290px; margin: 6px 0 22px; }
.picker-band {
  position: absolute; left: 12%; right: 12%; top: 50%; height: 52px; margin-top: -26px;
  border-radius: 26px; background: var(--accent-soft); border: 1px solid rgba(255, 122, 53, .25); pointer-events: none;
}
.picker-list {
  position: absolute; inset: 0; overflow-y: auto;
  scroll-snap-type: y mandatory; scrollbar-width: none;
  padding: 119px 0;
  -webkit-mask-image: linear-gradient(transparent, #000 30%, #000 70%, transparent);
  mask-image: linear-gradient(transparent, #000 30%, #000 70%, transparent);
}
.picker-list::-webkit-scrollbar { display: none; }
.picker-item {
  height: 52px; line-height: 52px; text-align: center;
  font: 500 30px/52px var(--num); font-variant-numeric: tabular-nums;
  scroll-snap-align: center; cursor: pointer; transform-origin: center;
}

/* liste (brani, marcatori) */
.track-list, .marker-list { list-style: none; margin: 0; padding: 4px 10px; overflow-y: auto; flex: 1; -webkit-overflow-scrolling: touch; }
.track { display: flex; align-items: center; gap: 8px; padding: 8px 6px; border-radius: 16px; }
.track + .track { margin-top: 2px; }
.track.current { background: var(--accent-soft); }
.track.dragging { background: var(--card-2); box-shadow: 0 8px 24px rgba(0, 0, 0, .5); position: relative; z-index: 2; }
.track .handle { width: 30px; height: 40px; display: grid; place-items: center; color: var(--dim); touch-action: none; cursor: grab; }
.track .info { flex: 1; min-width: 0; text-align: left; padding: 4px 0; }
.track .name { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.track.current .name { color: var(--accent); }
.track .meta { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; }
.mini { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; color: var(--muted); flex: none; }
.mini svg { width: 18px; height: 18px; }
.mini:active { background: rgba(255, 255, 255, .08); }
.hint { margin: 0; padding: 10px 20px calc(18px + var(--safe-bottom)); font-size: 12px; color: var(--muted); text-align: center; }
.list-empty { padding: 40px 20px; text-align: center; color: var(--muted); }

.marker { display: flex; align-items: center; gap: 8px; padding: 8px 4px; border-bottom: 1px solid var(--line); }
.marker .num {
  width: 26px; height: 24px; border-radius: 7px; display: grid; place-items: center; flex: none;
  background: var(--gold); color: var(--bg); font: 800 12px var(--num);
}
.marker input {
  flex: 1; min-width: 0; background: transparent; border: 0; color: var(--text);
  font: 600 16px inherit; font-family: inherit; padding: 6px 4px; border-radius: 8px;
  -webkit-user-select: text; user-select: text;
}
.marker input:focus { background: rgba(255, 255, 255, .06); outline: none; }
.marker .t { font: 600 12px var(--num); color: var(--muted); font-variant-numeric: tabular-nums; width: 40px; text-align: right; }
.marker .loop-from { font-size: 12px; font-weight: 700; color: var(--accent); padding: 6px 8px; border-radius: 10px; background: var(--accent-soft); }

/* ritmo */
.rhythm { padding: 4px 20px 22px; overflow-y: auto; }
.rhythm-big { display: flex; flex-direction: column; align-items: center; padding: 4px 0 14px; }
.big-count {
  width: 110px; height: 110px; border-radius: 50%; display: grid; place-items: center;
  font: 800 56px var(--num); color: #fff; background: var(--card-2);
  border: 1px solid var(--line);
  transition: transform .08s, background .08s;
}
.big-count.pulse { background: var(--flame); transform: scale(1.06); box-shadow: 0 10px 34px rgba(255, 80, 50, .45); }
.big-bpm { margin-top: 10px; color: var(--muted); font-size: 14px; }
.big-bpm strong { color: var(--text); font: 800 22px var(--num); }
.rhythm-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 6px; }
.soft-btn {
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 12px 8px; border-radius: 16px;
  background: rgba(255, 255, 255, .05); border: 1px solid var(--line);
}
.soft-btn strong { font-size: 15px; }
.soft-btn small { font-size: 11px; color: var(--muted); }
.soft-btn:active { background: var(--accent-soft); }
.soft-btn.tap.hit { background: var(--flame); }
.soft-btn.tap.hit small { color: #fff; }

/* impostazioni */
.settings, .export { padding: 4px 20px 22px; overflow-y: auto; }
.set-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 13px 0; border-bottom: 1px solid var(--line); font-size: 15px;
}
.seg { display: flex; background: rgba(0, 0, 0, .3); border-radius: 11px; padding: 3px; flex: none; }
.seg button { padding: 6px 10px; border-radius: 8px; font-size: 13px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.seg button.on { background: var(--flame); color: #fff; }
.stepper { display: flex; align-items: center; gap: 4px; background: rgba(0, 0, 0, .3); border-radius: 11px; padding: 3px; }
.stepper button { width: 34px; height: 30px; border-radius: 8px; font-size: 18px; font-weight: 700; color: var(--accent); }
.stepper button:active { background: var(--accent-soft); }
.stepper output { min-width: 52px; text-align: center; font: 700 15px var(--num); }
.toggle-row { cursor: pointer; }
.toggle-row input { position: absolute; opacity: 0; pointer-events: none; }
.toggle {
  flex: none; width: 51px; height: 31px; border-radius: 16px; background: rgba(255, 255, 255, .15);
  position: relative; transition: background .2s;
}
.toggle::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px;
  border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: 0 2px 4px rgba(0, 0, 0, .3);
}
.toggle-row input:checked + .toggle { background: var(--flame-2); }
.toggle-row input:checked + .toggle::after { transform: translateX(20px); }
.toggle-row input:focus-visible + .toggle { outline: 2px solid var(--accent); outline-offset: 2px; }
.set-note { color: var(--muted); font-size: 12px; padding: 8px 0; }
.set-note p { margin: 8px 0; }
.danger-btn { width: 100%; margin-top: 10px; padding: 14px; border-radius: 16px; color: var(--danger); background: rgba(255, 90, 95, .1); font-weight: 700; }
.primary-btn {
  width: 100%; margin-top: 16px; padding: 15px; border-radius: 16px;
  background: var(--flame); color: #fff; font-weight: 700; font-size: 16px;
  box-shadow: 0 8px 24px rgba(255, 80, 50, .35);
}
.primary-btn:disabled { opacity: .5; }
.export p { color: var(--muted); font-size: 14px; margin: 4px 0 8px; }
.export-status { margin-top: 14px; font-size: 14px; color: var(--muted); text-align: center; min-height: 20px; }
.export-status a, .export-status button { color: var(--accent); font-weight: 700; }

/* overlay & toast */
.drop-overlay {
  position: fixed; inset: 0; z-index: 30; display: none; place-items: center;
  background: rgba(20, 8, 4, .88); border: 3px dashed var(--accent);
  color: var(--accent); font-size: 22px; font-weight: 700;
}
.drop-overlay.on { display: grid; }
.toast {
  position: fixed; left: 50%; bottom: calc(200px + var(--safe-bottom)); z-index: 40;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--card-2); border: 1px solid var(--line); color: var(--text); padding: 10px 18px; border-radius: 14px;
  font-size: 14px; font-weight: 600; box-shadow: 0 8px 24px rgba(0, 0, 0, .5); transition: all .25s; max-width: 90%; text-align: center;
}
.toast.on { opacity: 1; transform: translate(-50%, 0); }

/* schermi bassi (iPhone SE, mini) */
@media (max-height: 720px) {
  .app { gap: 6px; }
  .track-title { font-size: 20px; }
  .track-sub { display: none; }
  .ctl { padding: 4px 0; }
  .loop-card { padding: 6px 12px; }
  .play-btn { width: 60px; height: 60px; }
  .play-btn svg { width: 28px; height: 28px; }
  .up-next { padding: 8px 16px; }
  .wave-wrap { min-height: 100px; }
}

/* ---------- stanza ---------- */
.icon-btn .dot {
  position: absolute; top: 2px; right: 2px; width: 10px; height: 10px; border-radius: 50%;
  background: #3ddc84; box-shadow: 0 0 0 2px var(--bg);
}
.soft-row {
  display: flex; align-items: center; gap: 10px; width: 100%; margin-top: 12px; padding: 14px; border-radius: 16px;
  background: rgba(255, 255, 255, .05); color: var(--text); font-weight: 600; text-align: left;
}
.soft-row svg { color: var(--accent); }
.room { padding: 4px 20px 22px; overflow-y: auto; flex: 1; }
.field { display: flex; flex-direction: column; gap: 6px; margin: 12px 0 4px; font-size: 13px; color: var(--muted); font-weight: 600; }
.field input, .join-row input {
  background: rgba(0, 0, 0, .35); border: 1px solid var(--line); border-radius: 14px; color: var(--text);
  font: 600 17px inherit; font-family: inherit; padding: 12px 14px; outline: none;
  -webkit-user-select: text; user-select: text;
}
.field input:focus, .join-row input:focus { border-color: var(--accent); }
.or { display: flex; align-items: center; gap: 10px; margin: 22px 0 12px; color: var(--muted); font-size: 12px; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.join-row { display: flex; gap: 8px; }
.join-row input { flex: 1; min-width: 0; font: 800 22px var(--num); letter-spacing: .2em; text-transform: uppercase; text-align: center; }
.primary-btn.small { width: auto; margin: 0; padding: 0 22px; }
.hint-inline { color: var(--muted); font-size: 12px; text-align: center; margin: 10px 0 0; }
.qr-wrap { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 6px 0 4px; }
.qr { background: #fff; padding: 12px; border-radius: 20px; line-height: 0; box-shadow: 0 10px 30px rgba(255, 80, 50, .25); }
.qr img, .qr svg { width: 190px; height: 190px; image-rendering: pixelated; }
.room-code { font: 800 30px var(--num); letter-spacing: .18em; background: var(--flame); -webkit-background-clip: text; background-clip: text; color: transparent; }
.guest-banner { padding: 14px; border-radius: 16px; background: var(--accent-soft); color: var(--text); font-weight: 600; text-align: center; margin: 4px 0 6px; }
.members { margin-top: 10px; }
.members-title { font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.members ul { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.members li { padding: 6px 12px; border-radius: 999px; background: rgba(255, 255, 255, .07); font-size: 14px; font-weight: 600; }
.members li.me { background: var(--accent-soft); color: var(--accent); }
.members li.empty { background: none; color: var(--muted); font-weight: 500; padding-left: 0; }
.transfers { list-style: none; margin: 12px 0 0; padding: 0; }
.transfers li { font-size: 13px; color: var(--muted); padding: 6px 0; }
.transfers .bar { height: 4px; border-radius: 2px; background: rgba(255, 255, 255, .08); margin-top: 5px; overflow: hidden; }
.transfers .bar i { display: block; height: 100%; background: var(--flame); }
.text-btn.danger { color: var(--danger); }
.sheet-foot { padding: 0 20px calc(16px + var(--safe-bottom)); }
.sheet-foot .primary-btn { margin-top: 8px; }
.check { display: flex; align-items: center; gap: 12px; padding: 12px 8px; border-radius: 14px; cursor: pointer; }
.check input { width: 22px; height: 22px; accent-color: var(--flame-2); flex: none; }
.check .name { font-weight: 600; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.check .meta { font-size: 12px; color: var(--muted); }

/* ---------- specchio ---------- */
.mirror { position: fixed; inset: 0; z-index: 50; background: #000; color: #fff; }
.mirror video#mirrorVideo { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.mirror video.flipped { transform: scaleX(-1); }
.mirror-top {
  position: absolute; left: 0; right: 0; top: 0; display: flex; align-items: center; gap: 10px;
  padding: calc(10px + var(--safe-top)) 14px 30px;
  background: linear-gradient(rgba(0, 0, 0, .55), transparent);
}
.m-info { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; text-align: center; }
.m-info strong { font: 700 16px var(--num); max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.m-info span { font: 700 13px var(--num); color: var(--flame-1); }
.m-btn {
  position: relative; width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: rgba(0, 0, 0, .45); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); color: #fff;
}
.m-btn[aria-pressed="false"] { opacity: .55; }
.m-txt { font: 800 13px var(--num); }
.m-btn .icon-pause { display: none; }
.mirror.playing .m-btn .icon-play { display: none; }
.mirror.playing .m-btn .icon-pause { display: block; }
.m-count {
  position: absolute; right: 16px; top: calc(80px + var(--safe-top));
  width: 88px; height: 88px; border-radius: 50%; display: grid; place-items: center;
  font: 800 48px var(--num); background: rgba(0, 0, 0, .4); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  transition: transform .08s, background .08s;
}
.m-count:empty { display: none; }
.m-count.pulse { background: var(--flame); transform: scale(1.08); }
.mirror.no-count .m-count { display: none; }
.m-rec-time {
  position: absolute; left: 50%; top: calc(72px + var(--safe-top)); transform: translateX(-50%);
  padding: 6px 12px; border-radius: 999px; background: #e5243b; font: 700 14px var(--num); font-variant-numeric: tabular-nums;
}
.m-countdown {
  position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none;
  font: 900 160px var(--num); color: #fff; text-shadow: 0 10px 40px rgba(0, 0, 0, .6);
}
.m-countdown.pop { animation: pop .8s ease-out; }
@keyframes pop { from { transform: scale(1.4); opacity: 0; } 30% { opacity: 1; } to { transform: scale(.9); opacity: .9; } }
.mirror-bottom {
  position: absolute; left: 0; right: 0; bottom: 0; display: flex; align-items: center; justify-content: space-around;
  padding: 40px 24px calc(24px + var(--safe-bottom));
  background: linear-gradient(transparent, rgba(0, 0, 0, .6));
}
.rec-btn { width: 78px; height: 78px; border-radius: 50%; border: 4px solid #fff; display: grid; place-items: center; }
.rec-btn span { width: 60px; height: 60px; border-radius: 50%; background: #e5243b; transition: all .2s; }
.mirror.recording .rec-btn span { width: 30px; height: 30px; border-radius: 8px; }
.m-review { position: absolute; inset: 0; z-index: 3; display: grid; place-items: center; background: rgba(0, 0, 0, .75); padding: 20px; }
.m-review-card { width: min(100%, 420px); background: var(--card); border: 1px solid var(--line); border-radius: 24px; padding: 14px; }
.m-review-card video { width: 100%; max-height: 55vh; border-radius: 14px; background: #000; }
.m-review-meta { text-align: center; color: var(--muted); font-size: 12px; margin-top: 6px; }
.m-review-row { display: flex; justify-content: space-between; padding: 8px 6px 0; }
body.mirror-open { overflow: hidden; }

/* stanza: scelte */
.room-choices { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.choice {
  display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 18px 10px 16px; border-radius: 20px; text-align: center;
  background: rgba(255, 255, 255, .05); border: 1px solid var(--line);
}
.choice svg { width: 34px; height: 34px; color: var(--accent); margin-bottom: 4px; }
.choice strong { font-size: 15px; }
.choice small { font-size: 11px; color: var(--muted); line-height: 1.3; }
.choice:active { background: var(--accent-soft); }
.choice:first-child { background: linear-gradient(160deg, rgba(255, 179, 61, .16), rgba(255, 46, 99, .12)); border-color: rgba(255, 122, 53, .3); }
.choice.busy { opacity: .6; pointer-events: none; }
.marker .play-from { display: flex; align-items: center; gap: 4px; font: 700 12px var(--num); color: var(--text); padding: 6px 8px; border-radius: 10px; background: rgba(255, 255, 255, .07); font-variant-numeric: tabular-nums; }
.marker .play-from svg { width: 12px; height: 12px; color: var(--accent); }

/* lettore QR */
.scanner { position: fixed; inset: 0; z-index: 60; background: #000; color: #fff; }
.scanner video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.scan-frame {
  position: absolute; left: 50%; top: 50%; width: min(70vw, 280px); aspect-ratio: 1; transform: translate(-50%, -50%);
  border-radius: 28px; box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .45); border: 3px solid rgba(255, 255, 255, .9);
}
.scan-hint { position: absolute; left: 0; right: 0; bottom: calc(60px + var(--safe-bottom)); text-align: center; font-weight: 700; font-size: 16px; text-shadow: 0 2px 10px #000; }
