:root {
  --brand: #128c7e;
  --deep: #0e6f64;
  --tint: #e8f5f3;
  --soft: #f2f7f6;
  --line: #e1eae8;
  --ink: #12201e;
  --muted: #4d6965;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body { font: 16px/1.5 system-ui, -apple-system, 'Segoe UI', sans-serif; color: var(--ink); background: #fff; }
button, label { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.app { min-height: 100dvh; display: flex; flex-direction: column; max-width: 520px; margin: 0 auto; padding: 0 24px; }
.screen { flex: 1; display: flex; flex-direction: column; }

.top { display: flex; align-items: center; gap: 10px; padding: 28px 0 0; }
.rec-icon { margin-left: auto; width: 44px; height: 44px; border: 0; border-radius: 22px; background: transparent; color: var(--deep); display: flex; align-items: center; justify-content: center; padding: 0; cursor: pointer; }
.rec-icon:active { background: #e8f5f3; }
.logo { width: 32px; height: 32px; border-radius: 10px; background: var(--brand); color: #fff; display: flex; align-items: center; justify-content: center; }
.wordmark { font-size: 18px; font-weight: 800; letter-spacing: -.2px; color: var(--deep); }

.status { align-self: flex-start; margin: 16px 0 0; padding: 8px 14px; border-radius: 12px; background: var(--tint); color: var(--deep); font-size: 14px; font-weight: 600; }
.status:empty { display: none; }
.status.err { background: #fdeaea; color: #a3001b; }

h1 { margin: 28px 0 0; font-size: 26px; line-height: 1.2; font-weight: 800; letter-spacing: -.5px; }

.player { margin-top: 24px; display: flex; align-items: center; gap: 14px; padding: 12px 16px 12px 12px; border-radius: 18px; background: var(--soft); }
.play { width: 44px; height: 44px; flex: none; padding: 0; border: 0; border-radius: 50%; background: var(--brand); color: #fff; display: flex; align-items: center; justify-content: center; }
.play .i-pause { display: none; }
.play.playing .i-play { display: none; }
.play.playing .i-pause { display: block; }
.track { flex: 1; min-width: 0; }
.bar { height: 28px; display: flex; align-items: center; position: relative; touch-action: none; }
.bar::before { content: ''; position: absolute; left: 0; right: 0; height: 4px; border-radius: 2px; background: #d3e2df; }
.fill { position: relative; height: 4px; width: 0; border-radius: 2px; background: var(--brand); }
.times { display: flex; justify-content: space-between; font-size: 12px; font-weight: 500; color: #5b7470; }

.idle { align-items: center; justify-content: center; text-align: center; padding-bottom: 48px; }
.idle h1 { margin-top: 28px; }
.hero { width: 104px; height: 104px; border-radius: 50%; background: var(--tint); color: var(--brand); display: flex; align-items: center; justify-content: center; box-shadow: 0 0 0 14px #f2f9f8; }
.lead { margin: 8px 0 0; color: var(--muted); }
.steps { list-style: none; margin: 32px 0 0; padding: 8px 16px; width: 100%; border-radius: 20px; background: var(--soft); text-align: left; }
.steps li { display: flex; align-items: center; gap: 14px; min-height: 56px; font-size: 16px; }
.steps li + li { border-top: 1px solid var(--line); }
.steps .n { width: 28px; height: 28px; flex: none; border-radius: 50%; background: var(--brand); color: #fff; font-size: 14px; font-weight: 700; display: flex; align-items: center; justify-content: center; }

.working { align-items: center; justify-content: center; text-align: center; padding-bottom: 48px; }
.working h1 { margin-top: 28px; }
.wave { height: 72px; display: flex; align-items: center; justify-content: center; gap: 7px; }
.wave i { width: 7px; height: 56px; border-radius: 4px; background: var(--brand); transform: scaleY(.3); animation: wave 1s ease-in-out infinite alternate; will-change: transform; }
.wave i:nth-child(1) { animation-delay: -.9s; } .wave i:nth-child(2) { animation-delay: -.6s; } .wave i:nth-child(3) { animation-delay: -.3s; }
.wave i:nth-child(4) { animation-delay: 0s; } .wave i:nth-child(5) { animation-delay: -.45s; } .wave i:nth-child(6) { animation-delay: -.75s; } .wave i:nth-child(7) { animation-delay: -.15s; }
@keyframes wave { to { transform: scaleY(1); } }
.rec-time { margin-top: 20px; font-size: 44px; font-weight: 800; letter-spacing: -1px; font-variant-numeric: tabular-nums; }
.rec-btn { margin-top: 24px; max-width: 320px; }
#recording .lead { margin-top: 4px; }
.wsteps { list-style: none; margin: 28px 0 8px; padding: 6px 16px; width: 100%; border-radius: 20px; background: var(--soft); text-align: left; }
.wsteps li { display: flex; align-items: center; gap: 14px; min-height: 56px; font-size: 16px; font-weight: 500; color: #6d8480; transition: color .2s; }
.wsteps li + li { border-top: 1px solid var(--line); }
.wsteps li[data-state=active], .wsteps li[data-state=done] { color: var(--ink); }
.wsteps li[data-state=active] { font-weight: 700; }
.wsteps li[hidden] { display: none; }
.wi { width: 24px; height: 24px; flex: none; display: flex; align-items: center; justify-content: center; border-radius: 50%; color: #fff; }
.wi i, .wi svg { display: none; }
li[data-state=pending] .w-pend { display: block; width: 18px; height: 18px; border: 2px solid #c3d3d0; border-radius: 50%; }
li[data-state=active] .w-act { display: block; width: 20px; height: 20px; border: 3px solid #cfe5e1; border-top-color: var(--brand); border-radius: 50%; animation: spin .8s linear infinite; }
li[data-state=done] .wi { background: var(--brand); }
li[data-state=done] .w-done { display: block; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .wave i { animation: none; transform: scaleY(.6); } .w-act { animation-duration: 2.4s !important; } }

.modes { margin-top: 18px; display: flex; flex-direction: column; gap: 12px; }
.mode { position: relative; display: flex; align-items: center; gap: 14px; min-height: 76px; padding: 14px 16px; border: 2px solid var(--line); border-radius: 18px; background: #fff; }
.mode input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.mode .ico { width: 44px; height: 44px; flex: none; border-radius: 14px; background: #eaf3f1; color: var(--deep); display: flex; align-items: center; justify-content: center; }
.mode .txt { flex: 1; min-width: 0; }
.mode b { display: block; font-size: 16px; font-weight: 700; }
.mode small { display: block; margin-top: 2px; font-size: 13px; color: var(--muted); }
.mode .check { width: 24px; height: 24px; flex: none; border-radius: 50%; background: var(--brand); color: #fff; display: none; align-items: center; justify-content: center; }
.mode:has(input:checked) { border-color: var(--brand); background: var(--tint); }
.mode:has(input:checked) .ico { background: var(--brand); color: #fff; }
.mode:has(input:checked) .check { display: flex; }
.mode:has(input:focus-visible) { outline: 3px solid #7cc9bf; outline-offset: 2px; }

.cta { position: sticky; bottom: 0; margin-top: auto; padding: 12px 0 calc(24px + env(safe-area-inset-bottom)); background: linear-gradient(rgba(255,255,255,0), #fff 24px); display: flex; flex-direction: column; gap: 4px; }
.row { display: flex; gap: 12px; }
.row > button { flex: 1; }

.primary, .secondary { height: 56px; border-radius: 18px; border: 2px solid var(--deep); font-weight: 700; font-size: 17px; display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; }
.primary { background: var(--deep); color: #fff; }
.secondary { background: #fff; color: var(--deep); border-color: var(--brand); font-size: 16px; }
.row .primary { font-size: 16px; }
.primary:disabled { opacity: .6; }

.link { align-self: center; min-height: 44px; padding: 0 16px; border: 0; background: none; color: var(--deep); font-weight: 600; font-size: 15px; text-decoration: underline; }
.icon-btn { width: 44px; height: 44px; padding: 0; border: 0; border-radius: 50%; background: none; color: var(--deep); display: flex; align-items: center; justify-content: center; }

.rhead { display: flex; align-items: center; gap: 4px; margin: 12px -12px 0; }
.eyebrow { font-size: 13px; font-weight: 700; letter-spacing: .4px; text-transform: uppercase; color: var(--muted); }
.out { margin-top: 12px; padding: 22px 20px; border-radius: 22px; background: var(--soft); font-size: 17px; line-height: 1.5; font-weight: 500; display: flex; flex-direction: column; gap: 16px; user-select: text; word-wrap: break-word; }
.out p { margin: 0; }
.out .brief { padding-bottom: 16px; border-bottom: 1px solid #dbe6e3; font-weight: 700; color: var(--deep); }
.out .brief small { display: block; margin-bottom: 2px; font-size: 12px; font-weight: 700; letter-spacing: .4px; text-transform: uppercase; color: var(--muted); }
.out .item { display: flex; gap: 12px; align-items: flex-start; }
.out .item small { display: block; margin-top: 2px; font-size: 0.82em; color: var(--muted, #5b6b68); line-height: 1.35; }
.out .item::before { content: ''; width: 8px; height: 8px; margin-top: 10px; flex: none; border-radius: 50%; background: var(--brand); }

.event { margin-top: 12px; padding: 18px 20px 8px; border: 2px solid var(--line); border-radius: 22px; background: #fff; }
.event .eyebrow { margin-bottom: 4px; }
.ev-row { display: flex; align-items: center; gap: 14px; padding: 10px 0; }
.ev-row + .ev-row { border-top: 1px solid var(--line); }
.ev-ico { width: 40px; height: 40px; flex: none; border-radius: 12px; background: var(--tint); color: var(--deep); display: flex; align-items: center; justify-content: center; }
.ev-txt { min-width: 0; }
.ev-note { margin: 8px 4px 12px; font-size: 12px; color: #6d8480; }
.ev-txt small { display: block; font-size: 12px; font-weight: 600; color: var(--muted); }
.ev-date { display: block; margin-top: 1px; font-size: 14px; font-weight: 500; color: var(--muted); }
.ev-txt b { display: block; font-size: 17px; font-weight: 700; word-wrap: break-word; }

.env { margin: 4px 0 12px; font-size: 12px; color: #6d8480; text-align: center; }

.banner { position: sticky; top: 0; z-index: 2; padding: 10px 16px; background: #fff3cd; display: flex; gap: 12px; align-items: center; }
.banner button { min-height: 40px; padding: 0 16px; border: 0; border-radius: 10px; background: var(--deep); color: #fff; font-weight: 700; }

/* invito a installare */
.banner.install { background: #e8f5f3; color: #12201e; font-size: 14px; }
.banner.install span { flex: 1; }
.banner.install .x { min-height: 40px; min-width: 40px; padding: 0; background: transparent; color: var(--deep); font-size: 24px; line-height: 1; }

/* più vocali insieme */
.add-more { display: block; margin: 12px auto 0; min-height: 44px; text-align: center; font: inherit; font-size: 15px; font-weight: 700; line-height: 44px; color: var(--deep); text-decoration: underline; text-underline-offset: 3px; }
.waiting { margin-top: 12px; padding: 10px 14px; border-radius: 14px; background: var(--soft); font-size: 14px; color: #12201e; }
.w-actions { display: flex; gap: 20px; }
.waiting a, .waiting button { display: inline-block; min-height: 44px; padding: 0 8px 0 0; border: 0; background: none; font: inherit; font-weight: 700; line-height: 44px; color: var(--deep); text-decoration: none; }
.group { margin-top: 16px; padding: 12px 14px; border-radius: 18px; background: var(--soft); }
.g-head { display: flex; justify-content: space-between; align-items: baseline; font-size: 14px; color: #4d6965; }
.g-head b { color: #12201e; font-size: 15px; }
.g-list { list-style: none; margin: 8px 0 0; padding: 0; }
.g-row { display: flex; align-items: center; gap: 4px; border-top: 1px solid #e1eae8; }
.g-row:first-child { border-top: 0; }
.g-main { flex: 1; min-height: 44px; padding: 0; border: 0; background: none; text-align: left; font: inherit; font-size: 15px; color: #12201e; }
.g-row.on .g-main { font-weight: 700; color: var(--deep); }
.g-dur { font-size: 13px; color: #4d6965; }
.g-x { width: 44px; height: 44px; border: 0; background: none; color: #4d6965; font-size: 22px; line-height: 1; }
.g-hint { margin: 8px 0 0; font-size: 12px; color: #6d8480; }

/* modalità Commento */
.tone { display: flex; gap: 8px; margin: 12px 0 0; }
.tone button { flex: 1; min-height: 44px; border: 2px solid #e1eae8; border-radius: 14px; background: #fff; color: var(--deep); font: inherit; font-weight: 600; }
.tone button[aria-pressed="true"] { background: #e8f5f3; border-color: var(--brand); }
.c-line { margin: -6px 0 6px; padding: 4px 0 4px 12px; border-left: 3px solid var(--brand); font-style: italic; color: var(--deep); }
.c-note { margin: 4px 0 0; font-size: 12px; color: #6d8480; }

.lang { display: flex; align-items: center; gap: 8px; margin: auto 0 0; padding: 8px 0 4px; font-size: 13px; color: var(--muted); position: sticky; bottom: 0; background: #fff; z-index: 2; }
.lang span { margin-right: auto; }
.lang button { min-height: 44px; padding: 0 14px; border: 2px solid var(--line); border-radius: 14px; background: #fff; color: var(--deep); font: inherit; font-weight: 600; }
.lang button[aria-pressed="true"] { background: var(--tint); border-color: var(--brand); }

/* schermata iniziale: tutto in una pagina fissa, senza scorrimento (lingua inclusa) */
body[data-view=idle] { height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
body[data-view=idle] .app { flex: 1; min-height: 0; width: 100%; overflow: hidden; }
body[data-view=idle] .idle { min-height: 0; padding-bottom: 8px; }
@media (max-height: 700px) {
  body[data-view=idle] .top { padding-top: 16px; }
  body[data-view=idle] .hero { width: 80px; height: 80px; box-shadow: 0 0 0 10px #f2f9f8; }
  body[data-view=idle] .hero svg { width: 36px; height: 36px; }
  body[data-view=idle] .idle h1 { margin-top: 20px; font-size: 22px; }
  body[data-view=idle] .steps { margin-top: 16px; padding: 4px 16px; }
  body[data-view=idle] .steps li { min-height: 44px; }
}
@media (max-height: 560px) {
  body[data-view=idle] .hero { display: none; }
  body[data-view=idle] .idle h1 { margin-top: 0; }
}
