/* min-trascriptor — foglio di stile unico, nessun build step.
   Chiaro e scuro seguono il tema del sistema. */

:root {
  --bg: #faf9f7;
  --panel: #ffffff;
  --panel-2: #f4f2ef;
  --line: #e6e2dc;
  --fg: #1c1a17;
  --muted: #7a736a;
  --accent: #e8863a;
  --accent-fg: #ffffff;
  --danger: #c4453b;
  --ok: #2f8a52;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 8px 24px rgba(0,0,0,.06);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16161a;
    --panel: #1e1e23;
    --panel-2: #26262c;
    --line: #33333b;
    --fg: #ece9e4;
    --muted: #9a948b;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.35);
  }
}

* { box-sizing: border-box; }

/* Deve stare PRIMA di tutto il resto e vincere su tutto.
   L'attributo `hidden` vale `display: none` con la specificità di uno stile del
   browser: qualunque regola di classe che imposti `display` lo annulla in
   silenzio. Qui succedeva con `.gate`, `.layout` e `.modal` (tutte `display:
   grid`): il login riusciva davvero, ma la schermata della password non spariva
   e sembrava che il pulsante non facesse niente. */
[hidden] { display: none !important; }

html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font: 15px/1.55 -apple-system, "Segoe UI", Roboto, Inter, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0 0 .4em; font-weight: 650; letter-spacing: -.01em; }
h2 { font-size: 1.5rem; } h3 { font-size: 1rem; }
kbd {
  font: inherit; font-size: .85em; padding: .1em .4em; border: 1px solid var(--line);
  border-bottom-width: 2px; border-radius: 5px; background: var(--panel-2);
}
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.spacer { flex: 1; }
.err { color: var(--danger); font-size: .9rem; }

/* ── password ─────────────────────────────────────────────── */
.gate {
  position: fixed; inset: 0; display: grid; place-items: center;
  background: var(--bg); z-index: 50; padding: 24px;
}
.gate-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 32px; width: min(380px, 100%); box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 12px;
}

/* ── impianto ─────────────────────────────────────────────── */
.layout { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--panel); border-right: 1px solid var(--line);
  padding: 18px 12px; display: flex; flex-direction: column; gap: 6px;
  position: sticky; top: 0; height: 100vh;
}
.brand { padding: 6px 10px 16px; font-size: 1rem; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; }
.nav {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 9px 10px; border: 0; border-radius: 9px; background: transparent;
  color: var(--fg); font: inherit; text-align: left; cursor: pointer;
}
.nav:hover { background: var(--panel-2); }
.nav.active { background: var(--panel-2); font-weight: 600; }
.nav span { width: 1.2em; text-align: center; }
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 6px; padding: 10px; }
.badge {
  display: inline-block; padding: 3px 9px; border-radius: 999px;
  background: var(--panel-2); border: 1px solid var(--line); font-size: .8rem;
}
main { padding: 28px 32px 64px; max-width: 900px; }
.head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.head h2 { margin: 0; }
.head-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* ── controlli ────────────────────────────────────────────── */
button, input, select, textarea {
  font: inherit; color: var(--fg); border-radius: 9px; border: 1px solid var(--line);
  background: var(--panel); padding: 8px 11px;
}
textarea { resize: vertical; width: 100%; }
button { cursor: pointer; }
button:disabled { opacity: .5; cursor: not-allowed; }
.primary { background: var(--accent); color: var(--accent-fg); border-color: transparent; font-weight: 600; }
.ghost { background: var(--panel-2); }
.ghost.danger, .danger { color: var(--danger); }
.link { background: none; border: 0; color: var(--muted); text-decoration: underline; padding: 0; text-align: left; }
.check { display: flex; align-items: baseline; gap: 7px; font-size: .9rem; border: 0; padding: 0; background: none; }
.check input { width: auto; }
.row { display: flex; gap: 8px; align-items: center; }
.row input[type=text], .row select, .row input[type=search] { flex: 1; }

/* ── registratore ─────────────────────────────────────────── */
.recorder { display: flex; align-items: center; gap: 22px; margin: 26px 0; }
.recbtn {
  width: 88px; height: 88px; border-radius: 50%; border: 2px solid var(--line);
  background: var(--panel); display: grid; place-items: center; padding: 0;
  transition: transform .12s ease, box-shadow .12s ease;
}
.recbtn:hover { transform: scale(1.03); }
.recbtn .dot { width: 30px; height: 30px; border-radius: 50%; background: var(--danger); transition: all .15s ease; }
.recbtn.recording { border-color: var(--danger); box-shadow: 0 0 0 6px rgba(196,69,59,.14); animation: pulse 1.6s ease-in-out infinite; }
.recbtn.recording .dot { border-radius: 6px; width: 26px; height: 26px; }
.recbtn:disabled { opacity: .45; }
@keyframes pulse { 50% { box-shadow: 0 0 0 14px rgba(196,69,59,.05); } }
.rec-meta { display: flex; flex-direction: column; gap: 7px; }
.timer { font-size: 1.9rem; font-variant-numeric: tabular-nums; font-weight: 600; }
.level { width: 220px; height: 6px; border-radius: 4px; background: var(--panel-2); overflow: hidden; }
.level-bar { height: 100%; width: 0%; background: var(--ok); transition: width .08s linear; }

.status { padding: 11px 14px; border-radius: 9px; background: var(--panel-2); border: 1px solid var(--line); margin-bottom: 16px; }
.status.error { border-color: var(--danger); color: var(--danger); }
/* `display: flex` qui è sicuro solo grazie a `[hidden] { display: none !important }`
   in cima al file: senza, questa regola vincerebbe su `hidden` e la barra di
   recupero resterebbe visibile per sempre. Vedi CLAUDE.md. */
.salvage { display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
           padding: 11px 14px; border-radius: 9px; margin-bottom: 16px;
           background: var(--panel-2); border: 1px solid var(--accent); }
/* L'avviso "mi fermo fra Ns" sul suggerimento del pulsante di registrazione. */
.small.warn, .muted.warn { color: var(--accent); }

/* ── card e risultato ─────────────────────────────────────── */
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; margin-bottom: 16px; box-shadow: var(--shadow);
}
.result-head { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.chip { font-size: .78rem; padding: 3px 9px; border-radius: 999px; background: var(--panel-2); border: 1px solid var(--line); color: var(--muted); }
.chip.warn { color: var(--danger); border-color: var(--danger); }
.result-text {
  font-size: 1.08rem; line-height: 1.7; padding: 12px; border-radius: 9px;
  background: var(--panel-2); border: 1px solid transparent; min-height: 3em; outline: none;
}
.result-text:focus { border-color: var(--accent); }
.learn {
  margin-top: 12px; padding: 10px 12px; border-radius: 9px; background: var(--panel-2);
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
}
.learn b { padding: 2px 8px; border-radius: 6px; background: rgba(232,134,58,.22); }
.learn input { flex: 1; min-width: 140px; }

.corrections { margin-top: 12px; display: flex; flex-direction: column; gap: 6px; }
.corr {
  display: flex; align-items: center; gap: 8px; font-size: .87rem;
  padding: 6px 10px; border-radius: 8px; background: var(--panel-2);
}
.corr b { font-weight: 600; }
.corr .was { color: var(--muted); text-decoration: line-through; }

/* ── liste ────────────────────────────────────────────────── */
.list { display: flex; flex-direction: column; gap: 8px; }
.item {
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  padding: 12px 14px; display: flex; gap: 12px; align-items: flex-start;
}
.item .grow { flex: 1; min-width: 0; }
.item .meta { font-size: .8rem; color: var(--muted); margin-top: 4px; display: flex; gap: 10px; flex-wrap: wrap; }
.item .text { white-space: pre-wrap; word-break: break-word; }
.item.clickable { cursor: pointer; }
.item.clickable:hover { border-color: var(--accent); }
.tag { font-size: .74rem; padding: 2px 7px; border-radius: 999px; background: var(--panel-2); border: 1px solid var(--line); color: var(--muted); }
.tag.off { opacity: .55; text-decoration: line-through; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.tile .n { font-size: 1.9rem; font-weight: 650; font-variant-numeric: tabular-nums; }
.tile .l { color: var(--muted); font-size: .85rem; }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; font-size: .9rem; }
.kv b { font-weight: 600; color: var(--muted); }

.test-out { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.test-out .line { padding: 9px 12px; border-radius: 8px; background: var(--panel-2); }
.test-out mark { background: rgba(232,134,58,.28); color: inherit; border-radius: 4px; padding: 0 2px; }

/* ── modale ───────────────────────────────────────────────── */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: grid; place-items: center; z-index: 40; padding: 20px; }
.modal-card {
  background: var(--panel); border-radius: var(--radius); padding: 24px;
  width: min(540px, 100%); max-height: 90vh; overflow: auto;
  display: flex; flex-direction: column; gap: 12px; box-shadow: var(--shadow);
}
.modal-card label { display: flex; flex-direction: column; gap: 5px; font-size: .9rem; }
.modal-card label.check { flex-direction: row; }
.modal-card details { border-top: 1px solid var(--line); padding-top: 10px; }
.modal-card details summary { cursor: pointer; color: var(--muted); font-size: .9rem; margin-bottom: 10px; }
.modal-card details > *:not(summary) { margin-bottom: 10px; }
.modal-actions { display: flex; gap: 8px; align-items: center; margin-top: 4px; }

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--fg); color: var(--bg); padding: 10px 18px; border-radius: 999px;
  font-size: .9rem; z-index: 60; box-shadow: var(--shadow);
}

@media (max-width: 760px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; align-items: center; overflow-x: auto; }
  .sidebar nav { flex-direction: row; }
  .brand, .sidebar-foot { display: none; }
  main { padding: 20px 16px 48px; }
}
