:root {
  --bg: #0d0e12;
  --card: rgba(255, 255, 255, 0.05);
  --card-hi: rgba(255, 255, 255, 0.09);
  --line: rgba(255, 255, 255, 0.09);
  --text: #f6f4f1;
  --muted: #9ea3ae;
  --warm-1: #ffbf5f;
  --warm-2: #ff6f61;
  --grad: linear-gradient(135deg, var(--warm-1), var(--warm-2));
  --on-grad: #24100a;
  --danger: #ff8f86;
  --focus: #7cc8ff;
  --r: 22px;
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html { background: var(--bg); }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font: 18px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  background:
    radial-gradient(900px 520px at -10% -12%, rgba(255, 150, 90, 0.20), transparent 60%),
    radial-gradient(700px 480px at 110% -6%, rgba(150, 110, 255, 0.16), transparent 60%),
    var(--bg);
  background-attachment: fixed;
}

main {
  max-width: 640px;
  margin: 0 auto;
  padding: calc(14px + env(safe-area-inset-top)) 18px calc(40px + env(safe-area-inset-bottom));
  outline: none;
}

h1 {
  font-size: 2.1rem;
  line-height: 1.1;
  letter-spacing: -0.02em;
  margin: 10px 0 22px;
  outline: none;
}
h2 { font-size: 1.05rem; font-weight: 650; color: var(--muted); margin: 30px 0 12px; }
p { margin: 8px 0; }
.muted { color: var(--muted); }

[tabindex="-1"]:focus { outline: none; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }

.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

svg.i { width: 1.15em; height: 1.15em; flex: none; }

/* ---------- Pulsanti ---------- */
button {
  font: inherit;
  color: inherit;
  border: 0;
  background: none;
  cursor: pointer;
}

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  min-height: 58px;
  padding: 14px 20px;
  border-radius: 18px;
  background: var(--card-hi);
  border: 1px solid var(--line);
  font-weight: 650;
  font-size: 1.05rem;
}
.btn + .btn { margin-top: 12px; }
.btn.primary {
  background: var(--grad);
  color: var(--on-grad);
  border: 0;
  box-shadow: 0 10px 30px -10px rgba(255, 120, 80, 0.65);
}
.btn.big { min-height: 72px; font-size: 1.25rem; border-radius: 22px; }
.btn.quiet { background: transparent; }
.btn.danger { color: var(--danger); background: transparent; }

.back {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 44px;
  padding: 0 6px 0 0;
  color: var(--warm-1);
  font-weight: 600;
}

.corner {
  position: absolute;
  top: calc(18px + env(safe-area-inset-top));
  right: max(18px, calc((100vw - 640px) / 2 + 18px));
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--card-hi);
  border: 1px solid var(--line);
}
.corner svg.i { width: 24px; height: 24px; }

/* ---------- Liste ---------- */
ul, ol { list-style: none; margin: 0; padding: 0; }

.tiles { display: grid; gap: 14px; margin-bottom: 18px; }
.tile {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px;
  text-align: left;
  border-radius: var(--r);
  background: var(--card);
  border: 1px solid var(--line);
}
.disc {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  flex: none;
  background:
    radial-gradient(circle at 50% 50%, var(--bg) 0 18%, transparent 19%),
    conic-gradient(from 200deg, var(--warm-1), var(--warm-2), #9b7bff, var(--warm-1));
  box-shadow: 0 6px 20px -8px rgba(255, 120, 80, 0.7);
}
.tile-text { display: grid; gap: 2px; min-width: 0; }
.tile-name { font-size: 1.25rem; font-weight: 700; overflow-wrap: anywhere; }
.tile-meta { color: var(--muted); font-size: 0.9rem; }

.songs { display: grid; gap: 10px; margin: 26px 0 22px; }
.song {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  text-align: left;
  border-radius: 18px;
  background: var(--card);
  border: 1px solid var(--line);
}
.num {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  flex: none;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--warm-1);
  background: rgba(255, 191, 95, 0.12);
}
.song-text { display: grid; min-width: 0; }
.song-title { font-weight: 650; overflow-wrap: anywhere; }
.song-artist { color: var(--muted); font-size: 0.88rem; }

.empty { color: var(--muted); text-align: center; padding: 26px 10px; }

/* Riordino */
.order { display: grid; gap: 10px; }
.order li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 8px 8px 16px;
  border-radius: 18px;
  background: var(--card);
  border: 1px solid var(--line);
}
.order .t { flex: 1; font-weight: 600; overflow-wrap: anywhere; }
.order button, .order .spacer {
  width: 50px;
  height: 50px;
  flex: none;
  border-radius: 14px;
  display: grid;
  place-items: center;
}
.order button { background: var(--card-hi); }

/* ---------- Campi ---------- */
label { display: block; font-weight: 650; margin: 18px 0 8px; }
input[type="text"], input[type="search"], textarea, select {
  width: 100%;
  font: inherit;
  font-size: 1.05rem;
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
  -webkit-appearance: none;
  appearance: none;
}
input::placeholder, textarea::placeholder { color: #6f7480; }
textarea { min-height: 55vh; line-height: 1.7; resize: vertical; }
select {
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 22px) 52%, calc(100% - 16px) 52%;
  background-size: 6px 6px;
  background-repeat: no-repeat;
}

.search { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: end; }
.search label { grid-column: 1 / -1; margin: 0; }
.search .btn { width: auto; min-height: 56px; }

.results { display: grid; gap: 10px; }
.result {
  width: 100%;
  display: grid;
  gap: 2px;
  padding: 14px 16px;
  text-align: left;
  border-radius: 18px;
  background: var(--card);
  border: 1px solid var(--line);
}
.result .t { font-weight: 650; }
.result .a { color: var(--muted); font-size: 0.9rem; }
.badge {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--on-grad);
  background: var(--grad);
  vertical-align: 2px;
}

.artist { color: var(--muted); font-size: 1.1rem; margin: -14px 0 24px; }

/* Impostazioni */
fieldset { border: 0; padding: 0; margin: 0; }
legend { font-weight: 650; padding: 0; margin: 18px 0 8px; }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 6px; border-radius: 18px; background: var(--card); border: 1px solid var(--line); }
.seg label { margin: 0; position: relative; }
.seg input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; }
.seg span {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 50px;
  border-radius: 14px;
  font-weight: 600;
  color: var(--muted);
}
.seg input:checked + span { background: var(--grad); color: var(--on-grad); }
.seg input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }

.switch {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
  margin: 12px 0 0;
  border-radius: 18px;
  background: var(--card);
  border: 1px solid var(--line);
  font-weight: 600;
}
.switch input {
  -webkit-appearance: none;
  appearance: none;
  flex: none;
  width: 54px;
  height: 32px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  position: relative;
  margin: 0;
  transition: background .2s;
}
.switch input::after {
  content: "";
  position: absolute;
  top: 3px; left: 3px;
  width: 26px; height: 26px;
  border-radius: 50%;
  background: #fff;
  transition: transform .2s;
}
.switch input:checked { background: var(--warm-2); }
.switch input:checked::after { transform: translateX(22px); }
.switch small { display: block; color: var(--muted); font-weight: 400; font-size: 0.85rem; margin-top: 2px; }

.confirm {
  margin-top: 12px;
  padding: 16px;
  border-radius: 18px;
  background: rgba(255, 111, 97, 0.10);
  border: 1px solid rgba(255, 111, 97, 0.35);
}
.confirm p { margin: 0 0 12px; font-weight: 600; }

.foot { margin-top: 34px; }

/* ---------- Avvisi ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(22px + env(safe-area-inset-bottom));
  transform: translate(-50%, 12px);
  width: max-content;
  max-width: calc(100vw - 36px);
  text-align: center;
  padding: 12px 20px;
  border-radius: 999px;
  background: #f6f4f1;
  color: #15161a;
  font-weight: 650;
  box-shadow: 0 12px 30px -10px rgba(0, 0, 0, 0.7);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 10;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Palco ---------- */
body.stage-mode { background: #000; }
body.stage-mode main { max-width: none; padding: 0; }

.stage { position: fixed; inset: 0; background: #000; overflow: hidden; }

.stage-top {
  position: relative;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 14px 8px;
}
.stage-exit {
  min-height: 40px;
  padding: 6px 16px;
  border-radius: 999px;
  background: #1b1b1f;
  color: #c9c9cf;
  font-size: 0.9rem;
  font-weight: 600;
}
.stage-song {
  flex: 1;
  text-align: right;
  color: #6d6d75;
  font-size: 0.9rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.stage-bar { position: relative; z-index: 3; height: 3px; margin: 0 14px; border-radius: 3px; background: #1c1c20; overflow: hidden; }
.stage-bar i { display: block; height: 100%; width: 0; background: var(--grad); transition: width .25s ease; }

/* Lo slider copre tutto lo schermo sotto la barra: ogni tocco con VoiceOver finisce su di lui. */
.stage-slider {
  -webkit-appearance: none;
  appearance: none;
  position: absolute;
  z-index: 1;
  left: 0; right: 0;
  top: calc(64px + env(safe-area-inset-top));
  bottom: 0;
  width: 100%;
  height: auto;
  margin: 0;
  background: transparent;
  opacity: 0.01;
  touch-action: none;
}
.stage-slider::-webkit-slider-thumb { -webkit-appearance: none; width: 1px; height: 1px; }
.stage-slider::-moz-range-thumb { width: 1px; height: 1px; border: 0; }

.stage-visual {
  position: absolute;
  z-index: 2;
  inset: calc(64px + env(safe-area-inset-top)) 0 0;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 22px;
  padding: 20px 26px calc(40px + env(safe-area-inset-bottom));
  text-align: center;
}
.stage-visual .prev, .stage-visual .next { color: #4f4f57; font-size: 1.15rem; min-height: 1.5em; }
.stage-visual .current { color: #fff; font-size: 2.2rem; font-weight: 750; line-height: 1.2; letter-spacing: -0.01em; }
.stage-visual .current.pop { animation: pop .28s ease-out; }
@keyframes pop {
  from { opacity: 0; transform: translateY(10px) scale(.98); }
  to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
