:root {
  --bg: #f6f1e7;
  --card: #ffffff;
  --ink: #13233c;
  --muted: #4f5b6b;
  --line: #e3dccd;
  --brand: #d8613c;
  --brand-ink: #ffffff;
  --brand-soft: #f8e1d6;
  --ok: #1f9d55;
  --ok-soft: #dcf5e6;
  --bad: #d93f3f;
  --bad-soft: #fde2e2;
  --warn: #c98200;
  --warn-soft: #fff1cf;
  --now: #195275;
  --radius: 18px;
  --shadow: 0 1px 2px rgba(29, 34, 48, .06), 0 8px 24px rgba(29, 34, 48, .06);
  color-scheme: light;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  font: 17px/1.45 ui-rounded, "SF Pro Rounded", "Nunito", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink); background: var(--bg);
  padding-bottom: 110px;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--now); outline-offset: 2px; border-radius: 8px; }

.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px clamp(14px, 4vw, 40px); }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); font-size: 22px; letter-spacing: -.01em; }
.brand b { color: var(--brand); }
.brand { font-weight: 800; color: #13233c; }
.brand img { border-radius: 9px; }
.privacy-pill { display: inline-flex; align-items: center; gap: 6px; border: 1px solid #bfe6cf; background: var(--ok-soft); color: #11613a; border-radius: 999px; padding: 6px 12px; font-size: 14px; font-weight: 600; }

main { max-width: 1180px; margin: 0 auto; padding: 0 clamp(14px, 4vw, 40px); }

/* scelta brano */
.hero h1 { font-size: clamp(28px, 4.4vw, 46px); line-height: 1.08; letter-spacing: -.025em; margin: 18px 0 10px; max-width: 18ch; }
.hero p { color: var(--muted); font-size: 19px; max-width: 58ch; margin: 0 0 22px; }
.drop { display: grid; place-items: center; gap: 4px; text-align: center; padding: 34px 20px; border: 2.5px dashed #c9b99a; border-radius: var(--radius); background: #fffdf8; cursor: pointer; color: var(--brand); transition: background .15s, border-color .15s; }
.drop strong { font-size: 21px; color: var(--ink); }
.drop span { color: var(--muted); }
.drop.over, .drop:hover { background: var(--brand-soft); border-color: var(--brand); }
.examples h2 { font-size: 16px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 26px 0 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 10px; }
.chip { border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 10px 16px; box-shadow: var(--shadow); font-weight: 600; }
.chip small { color: var(--muted); font-weight: 400; margin-left: 6px; }
.chip:hover { border-color: var(--brand); }

/* studio */
.titlebar { display: flex; align-items: center; gap: 12px; margin: 6px 0 12px; }
.titles { flex: 1; min-width: 0; }
.titles h1 { margin: 0; font-size: clamp(22px, 3vw, 30px); letter-spacing: -.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.titles p { margin: 0; color: var(--muted); font-size: 15px; }
.ghost { border: 1px solid var(--line); background: var(--card); border-radius: 12px; padding: 8px 14px; font-weight: 600; }
.ghost:hover { border-color: var(--ink); }

.settings { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px; box-shadow: var(--shadow); font-size: 15px; }
.settings label { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-weight: 600; }
.settings select, .settings input[type=number] { border: 1px solid var(--line); border-radius: 10px; padding: 6px 10px; background: #fff; color: var(--ink); font-weight: 600; }
.settings input[type=number] { width: 64px; }
.settings .tempo input { width: 130px; accent-color: var(--brand); }
.settings output { min-width: 46px; color: var(--ink); font-variant-numeric: tabular-nums; }
.settings .tog input { width: 18px; height: 18px; accent-color: var(--brand); }

.score-wrap { position: relative; margin-top: 14px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 10px 6px; min-height: 180px; }
.score svg { display: block; width: 100%; height: auto; }
.score .note, .score .chord { transition: fill .12s; }
.score g.now, .score g.now * { fill: var(--now) !important; stroke: var(--now) !important; }
.score g.s-ok, .score g.s-ok * { fill: var(--ok) !important; stroke: var(--ok) !important; }
.score g.s-wrong, .score g.s-wrong *, .score g.s-missed, .score g.s-missed * { fill: var(--bad) !important; stroke: var(--bad) !important; }
.score g.s-warn, .score g.s-warn *, .score g.s-octave, .score g.s-octave * { fill: var(--warn) !important; stroke: var(--warn) !important; }
.score g.s-missed { opacity: .55; }
.score g.note.clickable { cursor: pointer; }
.score g.measure.out { opacity: .28; }
.score g.measure.hot > .staff { }
.bar-hl { fill: var(--brand-soft); }
.loading { padding: 40px; text-align: center; color: var(--muted); }

.live-note { position: sticky; bottom: 120px; margin: 8px auto 0; width: max-content; background: var(--ink); color: #fff; border-radius: 999px; padding: 6px 16px; font-weight: 700; }

/* azioni in basso */
.actions { position: fixed; left: 0; right: 0; bottom: 0; display: flex; justify-content: center; gap: 10px; padding: 12px 12px calc(12px + env(safe-area-inset-bottom)); background: rgba(246, 241, 231, .93); backdrop-filter: blur(8px); border-top: 1px solid var(--line); z-index: 10; }
.act { display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 104px; border: 1px solid var(--line); background: var(--card); border-radius: 16px; padding: 8px 14px; font-weight: 700; font-size: 15px; box-shadow: var(--shadow); }
.act .ic { font-size: 20px; line-height: 1; }
.act.main { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); min-width: 150px; }
.act.main .ic { color: #fff; }
.act.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.act:disabled { opacity: .45; cursor: default; }

/* conto alla rovescia */
.countdown { position: fixed; inset: 0; display: grid; place-content: center; text-align: center; background: rgba(29, 34, 48, .55); color: #fff; z-index: 30; pointer-events: none; }
.countdown div { font-size: 140px; font-weight: 800; line-height: 1; }
.countdown p { margin: 0; font-size: 22px; font-weight: 700; }

/* risultato */
.result { margin-top: 16px; display: grid; grid-template-columns: minmax(250px, 340px) 1fr; gap: 16px; }
@media (max-width: 820px) { .result { grid-template-columns: 1fr; } }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.stars { font-size: 38px; letter-spacing: 4px; color: #f2b01e; line-height: 1; }
.stars .off { color: #e7dfd2; }
.opener { font-size: 21px; font-weight: 800; margin: 10px 0 14px; letter-spacing: -.01em; }
.meter { margin: 10px 0; }
.meter .lbl { display: flex; justify-content: space-between; font-weight: 700; font-size: 15px; }
.meter .bar { height: 10px; background: #ebe4d6; border-radius: 99px; overflow: hidden; margin-top: 4px; }
.meter .bar i { display: block; height: 100%; border-radius: 99px; background: var(--ok); }
.meter.mid .bar i { background: var(--warn); }
.meter.low .bar i { background: var(--bad); }
.tips h3 { margin: 0 0 10px; font-size: 18px; }
.tip { display: flex; gap: 12px; align-items: flex-start; padding: 12px; border-radius: 14px; background: #f8f4ec; margin-bottom: 10px; }
.tip .n { flex: none; width: 28px; height: 28px; border-radius: 50%; background: var(--brand); color: #fff; display: grid; place-items: center; font-weight: 800; }
.tip p { margin: 0; }
.tip button { margin-top: 8px; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 14px; color: var(--muted); margin: 12px 0 0; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 50%; margin-right: 6px; vertical-align: -1px; }
.row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.btn { border: 1px solid var(--line); background: #fff; border-radius: 12px; padding: 9px 14px; font-weight: 700; }
.btn.primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn:hover { border-color: var(--ink); }
.btn.primary:hover { filter: brightness(1.05); }
audio { width: 100%; margin-top: 10px; }
.history { font-size: 14px; color: var(--muted); margin-top: 10px; }

/* popover nota */
.pop { position: absolute; z-index: 20; background: #fff; border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 12px 30px rgba(0,0,0,.15); padding: 12px 14px; min-width: 220px; font-size: 15px; }
.pop h4 { margin: 0 0 6px; font-size: 16px; }
.pop .row { margin-top: 8px; gap: 6px; }
.pop .btn { padding: 6px 10px; font-size: 14px; }

/* dialoghi */
.dlg { border: none; border-radius: 22px; padding: 0; max-width: min(560px, 94vw); box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.dlg::backdrop { background: rgba(29, 34, 48, .45); }
.dlg .in { padding: 22px; }
.dlg h2 { margin: 0 0 10px; }
.dlg ul { padding-left: 20px; }
.dlg li { margin: 6px 0; }
.dlg textarea { width: 100%; min-height: 90px; border: 1px solid var(--line); border-radius: 12px; padding: 10px; font: 13px/1.4 ui-monospace, monospace; }

/* accordatore */
.tuner { text-align: center; }
.tuner .name { font-size: 76px; font-weight: 800; line-height: 1; }
.tuner .hz { color: var(--muted); }
.tuner .gauge { position: relative; height: 54px; margin: 18px 0 6px; background: linear-gradient(90deg, var(--bad-soft), var(--warn-soft) 35%, var(--ok-soft) 45%, var(--ok-soft) 55%, var(--warn-soft) 65%, var(--bad-soft)); border-radius: 12px; }
.tuner .needle { position: absolute; top: -6px; bottom: -6px; width: 4px; margin-left: -2px; left: 50%; background: var(--ink); border-radius: 4px; transition: left .08s; }
.tuner .msg { font-weight: 800; font-size: 20px; min-height: 30px; }
.tuner .strings { display: flex; justify-content: center; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.tuner .strings span { border: 1px solid var(--line); border-radius: 10px; padding: 4px 10px; font-weight: 700; }
.tuner .strings span.hit { background: var(--ok); color: #fff; border-color: var(--ok); }

.toast { position: fixed; left: 50%; bottom: 110px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 12px; z-index: 40; font-weight: 600; max-width: 90vw; }

@media print {
  .top, .actions, .settings, .titlebar .ghost, .row, audio, .privacy-pill { display: none !important; }
  body { background: #fff; padding: 0; }
  .card, .score-wrap { box-shadow: none; }
}

/* diteggiatura */
.finger-box { position: fixed; right: 16px; bottom: 110px; z-index: 15; background: #fff; border: 1px solid var(--line); border-radius: 18px; box-shadow: 0 12px 30px rgba(0,0,0,.12); padding: 12px 14px; text-align: center; max-width: min(372px, calc(100vw - 16px)); max-height: calc(100vh - 130px); overflow: auto; }
.finger-box h4, .finger h4 { margin: 0 0 6px; font-size: 16px; }
.finger-box p, .finger p { margin: 6px 0 0; font-size: 15px; color: #13233c; max-width: 34ch; margin-inline: auto; }
.finger svg { display: block; margin: 6px auto 0; max-width: 100%; height: auto; }
.finger-box svg { display: block; margin: 0 auto; max-width: 100%; height: auto; }
@media (max-width: 640px) { .finger-box { left: 50%; right: auto; transform: translateX(-50%); width: max-content; bottom: 100px; max-height: calc(100vh - 120px); } }
.pop { max-width: min(372px, calc(100% - 8px)); }
.fb-toggle { margin-top: 6px; border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 6px 12px; font: inherit; font-size: 14px; font-weight: 600; color: #13233c; }
.finger-box.mini .finger > div:not(.fhead), .finger-box.mini .finger p { display: none; }
.finger .fhead { display: flex; align-items: center; justify-content: center; gap: 8px; }
.finger .fhead h4 { margin: 0; }
.finger .fstaff svg { display: block; margin: 0; max-width: none; }
@media (max-width: 440px) {
  .pop { position: fixed; left: 4px !important; right: 4px; top: auto !important; bottom: 6px; max-width: none; max-height: 75vh; overflow: auto; padding: 10px 6px; }
  .finger-box { max-width: calc(100vw - 8px); padding: 10px 6px; }
}
.pop .finger svg { max-width: 100%; height: auto; }

/* tocco lime della palette (solo decorativo: il lime non regge il testo) */
.hero h1::after { content: ''; display: block; width: 72px; height: 6px; border-radius: 6px; background: #cbd817; margin-top: 12px; }
.act.main:hover { filter: brightness(1.06); }
