/* =========================================================
   My Pocket — design system "Liquid Glass" (iOS 26, 2026)
   Materiali traslucidi, tab bar flottante, large title che
   collassa, molle/curve Apple, light/dark, safe-area.
   ========================================================= */
:root {
  /* Colori sistema (light) */
  --bg: #ffffff;
  --bg-2: #f2f2f7;
  --bg-3: #ffffff;          /* superfici raggruppate */
  --label: #000000;
  --label-2: rgba(60,60,67,0.6);
  --label-3: rgba(60,60,67,0.3);
  --separator: rgba(60,60,67,0.29);
  --accent: #007aff;
  --accent-press: #0066d6;
  --red: #ff3b30;
  --green: #34c759;
  --orange: #ff9500;
  --memory: #5856d6;        /* indigo iOS: il "filo della memoria" (allineamento Obsidian) */

  /* Vetro */
  --glass-blur: 24px;
  --glass-fill: rgba(255,255,255,0.62);
  --glass-fill-strong: rgba(255,255,255,0.8);
  --glass-stroke: rgba(255,255,255,0.4);
  --glass-rim: inset 0 1px 0 rgba(255,255,255,0.6), inset 0 -1px 0 rgba(255,255,255,0.12), 0 8px 24px rgba(0,0,0,0.12);

  /* Forma */
  --gutter: 16px;
  --r-card: 18px;
  --r-sheet: 22px;
  --r-pill: 999px;
  --touch: 44px;

  /* Tipografia */
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", system-ui, "Segoe UI", Roboto, sans-serif;

  /* Motion (curve Apple) */
  --ease-smooth: cubic-bezier(0.32, 0.72, 0, 1);
  --ease-standard: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-snappy: cubic-bezier(0.2, 0.9, 0.25, 1.05);
  --ease-spring: cubic-bezier(0.34, 1.45, 0.5, 1);
  --dur: 0.45s;
  --dur-fast: 0.25s;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --nav-h: 50px;
  --tabbar-h: 58px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --bg-2: #1c1c1e;
    --bg-3: #1c1c1e;
    --label: #ffffff;
    --label-2: rgba(235,235,245,0.6);
    --label-3: rgba(235,235,245,0.3);
    --separator: rgba(84,84,88,0.6);
    --accent: #0a84ff;
    --accent-press: #409cff;
    --red: #ff453a;
    --green: #30d158;
    --orange: #ff9f0a;
    --memory: #5e5ce6;
    --glass-fill: rgba(30,30,32,0.6);
    --glass-fill-strong: rgba(40,40,43,0.82);
    --glass-stroke: rgba(255,255,255,0.14);
    --glass-rim: inset 0 1px 0 rgba(255,255,255,0.14), inset 0 -1px 0 rgba(0,0,0,0.3), 0 8px 24px rgba(0,0,0,0.4);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

html, body {
  margin: 0; padding: 0; height: 100%;
  background: var(--bg); color: var(--label);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
body { display: flex; flex-direction: column; }
button { font-family: inherit; cursor: pointer; color: inherit; }
input, select, textarea { font-family: inherit; font-size: 17px; color: var(--label); }

.muted { color: var(--label-2); }
.center { text-align: center; }
.mt-8 { margin-top: 8px; }
.mt-14 { margin-top: 14px; }
.mt-18 { margin-top: 18px; }

/* Icone SVG inline (MP.icon): seguono colore e dimensione del testo */
.ic { width: 1.1em; height: 1.1em; flex: 0 0 auto; }
.block__h .ic { width: 15px; height: 15px; }
.sheet__btn .ic { width: 20px; height: 20px; color: var(--accent); }
.sheet__btn.danger .ic { color: var(--red); }
.btn .ic { width: 18px; height: 18px; }
.chip .ic { width: 12px; height: 12px; vertical-align: -1.5px; margin-right: 3px; }
.empty__icon .ic { width: 46px; height: 46px; color: var(--label-3); }

/* Utility vetro */
.glass {
  background: var(--glass-fill);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(180%);
  backdrop-filter: blur(var(--glass-blur)) saturate(180%);
  border: 0.5px solid var(--glass-stroke);
  box-shadow: var(--glass-rim);
}

/* ---------- Contenitore viste ---------- */
#app { flex: 1; position: relative; overflow: hidden; }
.view { position: absolute; inset: 0; display: flex; flex-direction: column; }
.view[hidden] { display: none !important; }
.view.is-entering { animation: viewIn var(--dur-fast) var(--ease-standard); }
@keyframes viewIn { from { opacity: 0; } to { opacity: 1; } }

.scroll {
  flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding-bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 28px);
}
/* per le viste con navbar opaca (statica): il contenuto parte sotto la navbar */
.scroll--padtop { padding-top: calc(var(--nav-h) + var(--safe-top) + 10px); }

/* ---------- Navbar (vetro) + large title che collassa ---------- */
.navbar {
  position: absolute; top: 0; left: 0; right: 0; z-index: 10;
  height: calc(var(--nav-h) + var(--safe-top));
  padding: var(--safe-top) 8px 0;
  display: flex; align-items: center; gap: 4px;
  background: transparent; border-bottom: 0.5px solid transparent;
  transition: background var(--dur-fast) var(--ease-standard), border-color var(--dur-fast);
}
.view.is-scrolled .navbar, .navbar.navbar--static {
  background: var(--glass-fill);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(180%);
  backdrop-filter: blur(var(--glass-blur)) saturate(180%);
  border-bottom-color: var(--separator);
}
.navbar__title {
  position: absolute; left: 50%; transform: translateX(-50%);
  font-size: 17px; font-weight: 600; max-width: 60%;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  opacity: 0; transition: opacity var(--dur-fast) var(--ease-standard);
}
.view.is-scrolled .navbar__title, .navbar--static .navbar__title { opacity: 1; }
.navbar__btn {
  height: 36px; min-width: 36px; padding: 0 8px; border: none; background: none;
  color: var(--accent); font-size: 17px; display: inline-flex; align-items: center; gap: 3px;
  border-radius: 10px; z-index: 1;
}
.navbar__btn:active { opacity: 0.4; }
.navbar__btn--icon { font-size: 22px; }
.navbar__spacer { flex: 1; }

.largetitle {
  font-size: 34px; font-weight: 700; letter-spacing: 0.37px;
  margin: 0; padding: calc(var(--nav-h) + var(--safe-top) + 6px) var(--gutter) 8px;
}
.largetitle__sub { font-size: 15px; font-weight: 400; color: var(--label-2); margin: 2px 0 0; letter-spacing: normal; }

/* ---------- Liste raggruppate iOS ---------- */
.group { margin: 14px var(--gutter) 0; }
.group__hdr { font-size: 13px; color: var(--label-2); text-transform: uppercase; letter-spacing: 0.5px; padding: 0 4px 7px; }
.group__hdr--plain { text-transform: none; letter-spacing: normal; font-size: 13px; }
.inset {
  background: var(--bg-3); border-radius: var(--r-card); overflow: hidden;
  box-shadow: 0 0 0 0.5px var(--separator);
}
@media (prefers-color-scheme: dark) { .inset { background: var(--bg-2); box-shadow: none; } }
.row {
  display: flex; align-items: center; gap: 12px; min-height: var(--touch);
  padding: 11px 16px; position: relative; background: none; border: none; width: 100%;
  text-align: left; font-size: 17px; color: var(--label);
}
.row + .row::before { content: ""; position: absolute; top: 0; left: 16px; right: 0; height: 0.5px; background: var(--separator); }
.row:active { background: var(--label-3); }
.row__label { flex: 1; }
.row__value { color: var(--label-2); font-size: 17px; }
.row__chev { color: var(--label-3); font-size: 18px; }
.row__field { flex: 1; border: none; background: none; outline: none; text-align: right; }
.row__field.left { text-align: left; }
select.row__field { text-align-last: right; -webkit-appearance: none; appearance: none; }

/* ---------- Bottoni capsula ---------- */
.btn {
  border: none; border-radius: var(--r-pill); min-height: var(--touch);
  padding: 0 22px; font-size: 17px; font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: transform 0.12s var(--ease-standard), filter 0.12s, opacity 0.12s;
}
.btn:active { transform: scale(0.96); filter: brightness(0.92); }
.btn--primary { background: var(--accent); color: #fff; }
.btn--glass { color: var(--accent); }
.btn--block { width: 100%; }
.btn--danger { color: var(--red); }
.btn--ghost { background: var(--bg-2); color: var(--accent); }

/* =========================================================
   REGISTRA — una cosa sola: il bottone, in zona pollice
   ========================================================= */
.record {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  padding: calc(var(--nav-h) + var(--safe-top) + 8px) 24px 0; text-align: center;
}
.record__top { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; width: 100%; }
.record__status { color: var(--label-2); font-size: 16px; min-height: 1.2em; transition: color var(--dur-fast); }
.is-recording .record__status { color: var(--red); }
.record__timer { font-size: 64px; font-weight: 200; font-variant-numeric: tabular-nums; letter-spacing: 1px; line-height: 1; }
/* il bottone vive nel terzo inferiore, vicino al pollice */
.record__bottom { padding: 26px 0 calc(var(--tabbar-h) + var(--safe-bottom) + 34px); }

.waveform { display: flex; align-items: center; justify-content: center; gap: 3px; height: 56px; width: 100%; max-width: 320px; margin: 6px 0; }
.waveform span { width: 4px; height: 4px; border-radius: 2px; background: var(--accent); transition: height 0.08s linear, opacity 0.3s; opacity: 0.5; }
.is-recording .waveform span { opacity: 1; }

.recordbtn {
  width: 84px; height: 84px; border-radius: 50%; border: none; padding: 0;
  background: none; position: relative; display: grid; place-items: center;
}
.recordbtn::before {
  content: ""; position: absolute; inset: 0; border-radius: 50%;
  border: 4px solid var(--separator);
}
.recordbtn__core {
  width: 66px; height: 66px; border-radius: 50%; background: var(--red);
  transition: width var(--dur-fast) var(--ease-snappy), height var(--dur-fast) var(--ease-snappy), border-radius var(--dur-fast) var(--ease-snappy);
}
.is-recording .recordbtn__core { width: 30px; height: 30px; border-radius: 8px; }
.recordbtn:active .recordbtn__core { filter: brightness(0.85); }
/* alone pulsante quando arrivato da deep-link (?action=record) */
.recordbtn.is-primed::after {
  content: ""; position: absolute; inset: -8px; border-radius: 50%;
  border: 3px solid var(--accent); animation: pulse 1.4s var(--ease-standard) infinite;
}
@keyframes pulse { 0% { transform: scale(0.9); opacity: 0.8; } 100% { transform: scale(1.25); opacity: 0; } }

/* =========================================================
   PILLOLA DI STATO (non bloccante, stile Dynamic Island)
   Mostra: registrazione in corso (fuori dalla vista Registra),
   elaborazione, nota pronta, errore. Sempre tappabile, mai modale.
   ========================================================= */
.pill {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 18px); z-index: 35;
  display: flex; align-items: center; gap: 8px;
  min-height: 40px; padding: 0 16px; border-radius: var(--r-pill);
  font-size: 14px; font-weight: 600; color: var(--label);
  max-width: 86%; border-width: 0.5px;
  animation: pillIn 0.45s var(--ease-spring);
}
@keyframes pillIn { from { opacity: 0; transform: translate(-50%, 16px) scale(0.9); } to { opacity: 1; transform: translate(-50%, 0) scale(1); } }
.pill:active { transform: translate(-50%, 0) scale(0.96); }
.pill__txt { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pill__icon { display: inline-flex; }
.pill__dot { width: 9px; height: 9px; border-radius: 50%; background: var(--red); animation: dotPulse 1.1s ease-in-out infinite; }
@keyframes dotPulse { 50% { opacity: 0.3; } }
.pill--rec { color: var(--red); }
.pill--error { color: var(--red); }
.pill--done { color: var(--green); }
.pill--done .ic, .pill--error .ic { width: 16px; height: 16px; }

/* =========================================================
   LA DOMANDA — popup di allineamento con la memoria
   (componente pronto: si userà per le domande dal backend)
   ========================================================= */
.qmodal { position: fixed; inset: 0; z-index: 55; display: grid; place-items: center; padding: 24px; }
.qmodal__scrim {
  position: absolute; inset: 0; background: rgba(0,0,0,0.45);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  opacity: 0; transition: opacity 0.35s var(--ease-smooth);
}
.qmodal.show .qmodal__scrim { opacity: 1; }
.qmodal__card {
  position: relative; width: 100%; max-width: 360px;
  background: var(--glass-fill-strong);
  -webkit-backdrop-filter: blur(30px) saturate(180%); backdrop-filter: blur(30px) saturate(180%);
  border: 0.5px solid var(--glass-stroke);
  border-radius: 26px; padding: 22px 20px 16px;
  box-shadow: 0 24px 60px rgba(0,0,0,0.35);
  transform: translateY(34px) scale(0.92); opacity: 0;
  transition: transform 0.5s var(--ease-spring), opacity 0.3s var(--ease-standard);
}
.qmodal.show .qmodal__card { transform: none; opacity: 1; }
.qmodal__badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 700; letter-spacing: 0.6px; text-transform: uppercase;
  color: var(--memory); background: color-mix(in srgb, var(--memory) 14%, transparent);
  border-radius: var(--r-pill); padding: 5px 12px; margin-bottom: 14px;
}
.qmodal__badge .ic { width: 13px; height: 13px; }
.qmodal__q { font-size: 21px; font-weight: 700; line-height: 1.3; letter-spacing: -0.2px; margin: 0 0 6px; }
.qmodal__ctx { font-size: 14px; color: var(--label-2); line-height: 1.5; margin: 0 0 18px; }
.qmodal__opt {
  width: 100%; border: none; border-radius: 14px; min-height: 50px;
  padding: 13px 16px; font-size: 16px; font-weight: 600;
  background: var(--bg-2); color: var(--label); margin-bottom: 8px; text-align: left;
  display: flex; align-items: center; gap: 10px;
  transition: transform 0.12s var(--ease-standard);
}
.qmodal__opt:active { transform: scale(0.97); filter: brightness(0.92); }
.qmodal__opt--primary { background: var(--memory); color: #fff; }
.qmodal__opt--danger { color: var(--red); }
.qmodal__skip { width: 100%; border: none; background: none; color: var(--label-2); font-size: 15px; font-weight: 600; padding: 12px; }
.qmodal__skip:active { opacity: 0.5; }

/* Onboarding (benvenuto / chiave API) dentro lo sheet */
.ob { padding: 0 4px; }
.ob__icon { width: 54px; height: 54px; border-radius: 16px; display: grid; place-items: center; margin: 4px auto 12px; background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); }
.ob__icon .ic { width: 28px; height: 28px; }
.ob__title { text-align: center; font-size: 20px; font-weight: 700; margin-bottom: 6px; }
.ob__p { text-align: center; font-size: 15px; color: var(--label-2); line-height: 1.5; margin: 0 0 14px; }
.ob__steps { margin: 0 0 14px; padding-left: 22px; font-size: 15px; line-height: 1.5; color: var(--label); }
.ob__steps li { margin: 6px 0; }
.ob__input {
  width: 100%; border: 0.5px solid var(--separator); border-radius: 13px;
  background: var(--bg-2); padding: 13px 15px; font-size: 16px; outline: none; margin-top: 10px;
}

/* =========================================================
   NOTE (lista)
   ========================================================= */
.searchbar { margin: 6px var(--gutter) 4px; }
.searchbar input {
  width: 100%; border: none; border-radius: 11px; background: var(--bg-2);
  padding: 10px 14px; font-size: 17px; outline: none;
}
.notecard {
  display: block; width: 100%; text-align: left; border: none;
  background: var(--bg-3); box-shadow: 0 0 0 0.5px var(--separator);
  border-radius: var(--r-card); padding: 14px 16px; margin-bottom: 10px;
}
@media (prefers-color-scheme: dark) { .notecard { background: var(--bg-2); box-shadow: none; } }
.notecard:active { transform: scale(0.985); transition: transform 0.1s; }
.notecard__top { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.notecard__title { font-size: 17px; font-weight: 600; }
.notecard__date { font-size: 13px; color: var(--label-2); white-space: nowrap; }
.notecard__snippet { font-size: 15px; color: var(--label-2); line-height: 1.4; margin-top: 4px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.notecard__meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip { font-size: 12px; padding: 3px 9px; border-radius: var(--r-pill); background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent); }
.chip--time { background: var(--bg-2); color: var(--label-2); }
.chip--processing { background: color-mix(in srgb, var(--orange) 20%, transparent); color: var(--orange); }
.chip--error { background: color-mix(in srgb, var(--red) 18%, transparent); color: var(--red); }

.empty { text-align: center; color: var(--label-2); padding: 80px 30px; }
.empty__icon { font-size: 52px; margin-bottom: 12px; }
.empty p { line-height: 1.5; }

/* =========================================================
   NOTA (dettaglio)
   ========================================================= */
.segmented {
  display: flex; gap: 2px; margin: 4px var(--gutter) 8px; padding: 2px;
  background: var(--bg-2); border-radius: 10px;
}
.segmented button {
  flex: 1; border: none; background: none; border-radius: 8px; padding: 7px;
  font-size: 13px; font-weight: 600; color: var(--label); transition: background var(--dur-fast);
}
.segmented button.is-active { background: var(--bg-3); box-shadow: 0 1px 3px rgba(0,0,0,0.12); }
@media (prefers-color-scheme: dark) { .segmented button.is-active { background: #48484a; } }

.notebody { padding: 0 var(--gutter); }
.block { margin: 22px 0; }
.block__h { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; color: var(--label-2); margin-bottom: 10px; }
.block ul { margin: 0; padding-left: 1.15em; }
.block li { margin: 6px 0; line-height: 1.45; }
.block p { line-height: 1.5; margin: 6px 0; }

/* Panoramica (TL;DR + contesto): il blocco "capisci tutto al volo" */
.overview { background: var(--bg-3); box-shadow: 0 0 0 0.5px var(--separator); border-radius: 14px; padding: 14px 16px; border-left: 3px solid var(--accent); }
@media (prefers-color-scheme: dark) { .overview { background: var(--bg-2); box-shadow: none; } }
.overview__tldr { font-size: 17px; font-weight: 500; line-height: 1.4; }
.overview__ctx { font-size: 15px; color: var(--label-2); line-height: 1.55; margin-top: 8px; }

/* Persone */
.people { display: flex; flex-direction: column; gap: 8px; }
.person { display: flex; align-items: center; gap: 11px; background: var(--bg-3); box-shadow: 0 0 0 0.5px var(--separator); border-radius: 12px; padding: 10px 12px; }
@media (prefers-color-scheme: dark) { .person { background: var(--bg-2); box-shadow: none; } }
.person__av { width: 34px; height: 34px; border-radius: 50%; flex: 0 0 auto; display: grid; place-items: center; font-size: 14px; font-weight: 600; background: color-mix(in srgb, var(--accent) 20%, transparent); color: var(--accent); }
.person__nome { font-size: 16px; font-weight: 500; }
.person__ruolo { font-size: 13px; color: var(--label-2); }
.concept { margin: 7px 0; line-height: 1.45; }
.concept b { color: var(--label); }

.todo { display: flex; gap: 11px; align-items: flex-start; background: var(--bg-3); box-shadow: 0 0 0 0.5px var(--separator); border-radius: 12px; padding: 11px 13px; margin: 8px 0; }
@media (prefers-color-scheme: dark) { .todo { background: var(--bg-2); box-shadow: none; } }
.todo__box { width: 22px; height: 22px; border-radius: 6px; border: 2px solid var(--accent); flex: 0 0 auto; margin-top: 1px; }
.todo__meta { color: var(--label-2); font-size: 13px; margin-top: 3px; }

.mindmap { background: var(--bg-3); box-shadow: 0 0 0 0.5px var(--separator); border-radius: 12px; padding: 14px 16px; }
@media (prefers-color-scheme: dark) { .mindmap { background: var(--bg-2); box-shadow: none; } }
.mindmap__root { font-weight: 700; color: var(--accent); margin-bottom: 8px; font-size: 17px; }
.mindmap ul { list-style: none; padding-left: 14px; border-left: 2px solid var(--separator); margin: 5px 0; }
.mindmap > ul { border: none; padding-left: 0; }
.mindmap li { margin: 5px 0; line-height: 1.4; }

/* Analisi suoni & contesto */
.scene-grid { display: flex; flex-direction: column; gap: 10px; }
.scene-item { background: var(--bg-3); box-shadow: 0 0 0 0.5px var(--separator); border-radius: 12px; padding: 12px 14px; }
@media (prefers-color-scheme: dark) { .scene-item { background: var(--bg-2); box-shadow: none; } }
.scene-item__h { font-size: 13px; color: var(--label-2); margin-bottom: 4px; }
.scene-item__v { font-size: 16px; line-height: 1.4; }
.sound-tag { display: inline-flex; align-items: center; gap: 6px; background: var(--bg-2); border-radius: var(--r-pill); padding: 5px 11px; margin: 3px 4px 0 0; font-size: 14px; }
.conf { font-size: 11px; padding: 1px 7px; border-radius: var(--r-pill); }
.conf--alta { background: color-mix(in srgb, var(--green) 22%, transparent); color: var(--green); }
.conf--media { background: color-mix(in srgb, var(--orange) 22%, transparent); color: var(--orange); }
.conf--bassa, .conf--incerto { background: var(--label-3); color: var(--label-2); }
.scene-note { font-size: 13px; color: var(--label-2); font-style: italic; margin-top: 6px; }

/* Trascrizione */
.segment { display: flex; gap: 12px; padding: 8px 0; border-bottom: 0.5px solid var(--separator); }
.segment__t { color: var(--accent); font-size: 13px; font-variant-numeric: tabular-nums; min-width: 44px; padding-top: 2px; }
.segment__txt { flex: 1; line-height: 1.5; font-size: 16px; }
.plaintext { line-height: 1.6; white-space: pre-wrap; font-size: 16px; }

.player { background: var(--bg-3); box-shadow: 0 0 0 0.5px var(--separator); border-radius: 14px; padding: 18px; text-align: center; }
@media (prefers-color-scheme: dark) { .player { background: var(--bg-2); box-shadow: none; } }
.player audio { width: 100%; margin-top: 8px; }

/* =========================================================
   CHIEDI (chat)
   ========================================================= */
.asklog { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: calc(var(--nav-h) + var(--safe-top) + 12px) var(--gutter) 12px; display: flex; flex-direction: column; gap: 10px; }
.ask-empty { text-align: center; color: var(--label-2); margin: auto 0; line-height: 1.5; }
.bubble { max-width: 86%; padding: 11px 15px; border-radius: 20px; line-height: 1.45; font-size: 16px; animation: bubbleIn 0.3s var(--ease-snappy); }
@keyframes bubbleIn { from { opacity: 0; transform: translateY(8px) scale(0.96); } to { opacity: 1; transform: none; } }
.bubble.user { align-self: flex-end; background: var(--accent); color: #fff; border-bottom-right-radius: 6px; }
.bubble.ai { align-self: flex-start; background: var(--bg-2); border-bottom-left-radius: 6px; }
.bubble.ai ul { padding-left: 1.1em; margin: 6px 0; }
.bubble.ai li { margin: 4px 0; }
.askbar { display: flex; gap: 8px; padding: 8px var(--gutter); padding-bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 16px); }
.askbar input { flex: 1; border: 0.5px solid var(--separator); border-radius: var(--r-pill); padding: 11px 16px; background: var(--bg-2); outline: none; }
.sendbtn { width: 40px; height: 40px; border-radius: 50%; border: none; background: var(--accent); color: #fff; font-size: 20px; flex: 0 0 auto; }
.sendbtn:active { filter: brightness(0.9); }

/* =========================================================
   IMPOSTAZIONI
   ========================================================= */
.callout { margin: 14px var(--gutter); border-radius: var(--r-card); padding: 14px 16px; background: color-mix(in srgb, var(--accent) 12%, var(--bg-3)); box-shadow: 0 0 0 0.5px color-mix(in srgb, var(--accent) 40%, transparent); }
.callout strong { display: block; margin-bottom: 6px; }
.callout p { margin: 0; font-size: 14px; line-height: 1.5; color: var(--label-2); }
.help { font-size: 13px; color: var(--label-2); padding: 6px var(--gutter) 0; line-height: 1.45; }
.toggle-switch { position: relative; width: 51px; height: 31px; flex: 0 0 auto; }
.toggle-switch input { opacity: 0; width: 100%; height: 100%; margin: 0; }
.toggle-switch span { position: absolute; inset: 0; border-radius: var(--r-pill); background: var(--label-3); transition: background var(--dur-fast); pointer-events: none; }
.toggle-switch span::after { content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff; box-shadow: 0 2px 5px rgba(0,0,0,0.25); transition: transform var(--dur-fast) var(--ease-snappy); }
.toggle-switch input:checked + span { background: var(--green); }
.toggle-switch input:checked + span::after { transform: translateX(20px); }

/* =========================================================
   TAB BAR flottante (vetro)
   ========================================================= */
.tabbar {
  position: fixed; left: var(--gutter); right: var(--gutter);
  bottom: calc(var(--safe-bottom) + 8px); z-index: 30;
  height: var(--tabbar-h); border-radius: var(--r-pill);
  display: flex; align-items: stretch;
  transition: transform var(--dur) var(--ease-smooth), opacity var(--dur);
}
.tabbar.is-min { transform: translateY(8px) scale(0.96); opacity: 0.85; }
.tabbar__item {
  flex: 1; border: none; background: none; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 3px; color: var(--label-2);
  border-radius: var(--r-pill); transition: color var(--dur-fast);
}
.tabbar__item svg { width: 25px; height: 25px; }
.tabbar__item small { font-size: 10px; font-weight: 500; }
.tabbar__item.is-active { color: var(--accent); }
.tabbar__item:active { opacity: 0.5; }

/* =========================================================
   SHEET / OVERLAY / TOAST
   ========================================================= */
.scrim { position: fixed; inset: 0; z-index: 40; background: rgba(0,0,0,0.4); opacity: 0; transition: opacity var(--dur) var(--ease-smooth); }
.scrim.show { opacity: 1; }

.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 41; transform: translateY(100%); transition: transform var(--dur) var(--ease-smooth); }
.sheet.show { transform: translateY(0); }
.sheet__panel {
  background: var(--glass-fill-strong);
  -webkit-backdrop-filter: blur(30px) saturate(180%); backdrop-filter: blur(30px) saturate(180%);
  border-radius: var(--r-sheet) var(--r-sheet) 0 0;
  padding: 8px var(--gutter) calc(16px + var(--safe-bottom));
  box-shadow: 0 -8px 40px rgba(0,0,0,0.25);
}
.sheet__grab { width: 36px; height: 5px; border-radius: 3px; background: var(--label-3); margin: 0 auto 12px; }
.sheet__title { text-align: center; font-size: 15px; font-weight: 600; color: var(--label-2); padding-bottom: 12px; }
.sheet__btn { width: 100%; border: none; background: var(--bg-3); color: var(--label); padding: 15px 16px; border-radius: 13px; margin-bottom: 8px; font-size: 17px; text-align: left; display: flex; gap: 12px; align-items: center; }
@media (prefers-color-scheme: dark) { .sheet__btn { background: var(--bg-2); } }
.sheet__btn:active { opacity: 0.6; }
.sheet__btn.danger { color: var(--red); }
.sheet__btn.cancel { justify-content: center; color: var(--accent); font-weight: 600; margin-top: 4px; }

.spinner { width: 38px; height: 38px; border-radius: 50%; border: 3px solid var(--label-3); border-top-color: var(--accent); animation: spin 0.8s linear infinite; }
.spinner--sm { width: 16px; height: 16px; border-width: 2px; }
@keyframes spin { to { transform: rotate(360deg); } }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 22px); z-index: 60; background: rgba(40,40,43,0.92); color: #fff; -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px); padding: 11px 18px; border-radius: var(--r-pill); font-size: 14px; max-width: 88%; text-align: center; animation: toastIn 0.3s var(--ease-snappy); }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 12px); } to { opacity: 1; transform: translate(-50%, 0); } }
.toast.error { background: var(--red); }
.toast.ok { background: var(--green); }

.bigtext { width: 100%; min-height: 150px; border: 0.5px solid var(--separator); border-radius: 12px; padding: 12px; background: var(--bg-3); outline: none; line-height: 1.5; resize: vertical; font-size: 16px; }
@media (prefers-color-scheme: dark) { .bigtext { background: var(--bg-2); } }

/* ---------- Accessibilità ---------- */
/* Testo solo per screen reader (annunci di stato) */
.visually-hidden {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  /* indicatori di attività: stato statico invece del loop (niente sfarfallio) */
  .pill__dot { animation: none !important; opacity: 1; }
  .spinner { animation: none !important; }
  .recordbtn.is-primed::after { animation: none !important; opacity: 0.4; transform: scale(1.1); }
}
@media (prefers-reduced-transparency: reduce) {
  .glass, .navbar.navbar--static, .view.is-scrolled .navbar, .tabbar, .sheet__panel, .qmodal__card {
    -webkit-backdrop-filter: none !important; backdrop-filter: none !important;
    background: var(--bg) !important;
  }
  /* il toast resta scuro-opaco: bianco-su-bianco mai */
  .toast { -webkit-backdrop-filter: none; backdrop-filter: none; background: rgb(40,40,43); }
}
