:root {
  --bg: #f5f5f7;
  --card: #ffffff;
  --ink: #1d1d1f;
  --muted: #6e6e73;
  --line: #e5e5ea;
  --accent: #0071e3;
  --accent-ink: #ffffff;
  --live: #ff3b30;
  --ok: #34c759;
  --radius: 18px;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", Inter, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --card: #1c1c1e;
    --ink: #f5f5f7;
    --muted: #98989d;
    --line: #2c2c2e;
    --accent: #2997ff;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { min-height: 100vh; -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }

.wrap { max-width: 1080px; margin: 0 auto; padding: 24px 16px 64px; }
header.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 24px; }
.brand { font-weight: 700; letter-spacing: -0.02em; font-size: 15px; color: var(--muted); }
.brand b { color: var(--ink); }
h1 { font-size: clamp(28px, 5vw, 44px); letter-spacing: -0.03em; line-height: 1.05; margin: 8px 0 8px; }
.lead { color: var(--muted); font-size: 17px; margin: 0 0 24px; max-width: 640px; }

.card { background: var(--card); border-radius: var(--radius); padding: 20px; border: 1px solid var(--line); }
.grid { display: grid; gap: 16px; }
@media (min-width: 820px) { .grid-2 { grid-template-columns: 1.2fr 1fr; } .grid-4 { grid-template-columns: repeat(4, 1fr); } }
.label { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin-bottom: 8px; }

/* Pulsante microfono */
.mic-area { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 28px 12px; }
.mic {
  width: 132px; height: 132px; border-radius: 50%; border: none; cursor: pointer;
  background: var(--accent); color: var(--accent-ink); font-size: 46px;
  box-shadow: 0 10px 30px rgba(0, 113, 227, 0.35); transition: transform .15s ease, background .2s ease;
}
.mic:active { transform: scale(0.96); }
.mic.live { background: var(--live); box-shadow: 0 0 0 0 rgba(255, 59, 48, 0.6); animation: pulse 1.6s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(255,59,48,.55); } 70% { box-shadow: 0 0 0 26px rgba(255,59,48,0); } 100% { box-shadow: 0 0 0 0 rgba(255,59,48,0); } }
.status { font-size: 15px; color: var(--muted); min-height: 20px; text-align: center; }
.meter { width: 180px; height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.meter > i { display: block; height: 100%; width: 0%; background: var(--ok); transition: width .08s linear; }

.live-text { font-size: 22px; line-height: 1.35; min-height: 60px; letter-spacing: -0.01em; }
.live-text .partial { color: var(--muted); }
.chunks { display: flex; flex-direction: column; gap: 6px; max-height: 220px; overflow: auto; margin-top: 12px; }
.chunk { font-size: 15px; padding: 8px 10px; border-radius: 10px; background: var(--bg); }

.lang-col h3 { margin: 0 0 6px; font-size: 16px; display: flex; justify-content: space-between; align-items: baseline; }
.lang-col h3 small { color: var(--muted); font-weight: 500; font-size: 12px; }
.lang-col .lines { display: flex; flex-direction: column; gap: 8px; max-height: 260px; overflow: auto; }
.line { font-size: 15px; line-height: 1.35; }
.line .t { display: block; font-size: 11px; color: var(--muted); margin-top: 2px; }

.qr-box { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.qr-box #qr { background: #fff; padding: 8px; border-radius: 12px; }
.url { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 14px; word-break: break-all; }
.err { color: var(--live); font-size: 14px; margin-top: 8px; min-height: 18px; }
.pin-gate { display: flex; flex-direction: column; align-items: center; text-align: center; max-width: 420px; margin: 40px auto; padding: 32px 24px; }
.pin-gate.hidden { display: none !important; }
input.pin { font: inherit; font-size: 22px; letter-spacing: 4px; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); width: 140px; text-align: center; }

/* Pagina ascolto */
.langs { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.lang-btn {
  font: inherit; font-size: 18px; font-weight: 600; padding: 22px 12px; border-radius: var(--radius);
  border: 2px solid var(--line); background: var(--card); color: var(--ink); cursor: pointer;
}
.lang-btn span { display: block; font-size: 34px; margin-bottom: 6px; }
.lang-btn.sel { border-color: var(--accent); }
.big-btn {
  font: inherit; font-size: 18px; font-weight: 600; width: 100%; padding: 18px; margin-top: 16px;
  border-radius: 999px; border: none; background: var(--accent); color: var(--accent-ink); cursor: pointer;
}
.subs { display: flex; flex-direction: column; gap: 14px; }
.sub { font-size: clamp(22px, 5.5vw, 30px); line-height: 1.3; letter-spacing: -0.01em; }
.sub.old { color: var(--muted); font-size: clamp(17px, 4vw, 20px); }
.sub .orig { display: block; font-size: 14px; color: var(--muted); margin-top: 4px; }
.pill { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.dot.on { background: var(--ok); }
.dot.speaking { background: var(--live); }
.hidden { display: none !important; }
footer { color: var(--muted); font-size: 12px; text-align: center; margin-top: 40px; }
