/* Quaderno idee — stile ispirato a Fotonizer: carte pastello, pillole, fogli dal basso */
:root {
  color-scheme: light;
  --font-sans: ui-rounded, "SF Pro Rounded", -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, "Segoe UI", Roboto, sans-serif;

  /* sfondo */
  --base: #eef1f7;

  /* vetro */
  --glass: #ffffff;
  --glass-strong: #ffffff;
  --glass-border: #dfe4ef;
  --glass-shadow: 0 6px 18px rgba(44, 66, 130, 0.12), 0 1px 2px rgba(44, 66, 130, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.95);
  --glass-light: inset 0 1px 0 rgba(255, 255, 255, 0.95);
  --colore-ombra: 0 6px 16px rgba(44, 66, 130, 0.13), 0 1px 2px rgba(44, 66, 130, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.75);
  --colore-bordo: rgba(255, 255, 255, 0.85);
  --lucido: linear-gradient(180deg, rgba(255, 255, 255, 0.62) 0%, rgba(255, 255, 255, 0) 58%);

  /* nomi usati dal resto del foglio, ora in versione vetro */
  --bg-app: var(--base);
  --bg-surface: var(--glass);
  --bg-input: #e8ecf4;
  --line: #dfe4ef;
  --text-primary: #17202f;
  --text-secondary: #586882;
  --text-muted: #6b7a93;
  --accent: #2f6bff; --accent-soft: #dfe9ff; --accent-fg: #ffffff;
  --danger: #d6342b; --danger-soft: #fde8e6; --rec: #ff3b30;

  /* categorie e stati: colori pieni, ben distinti */
  --cat-blue-bg: #e6f1fb;   --cat-blue-fg: #0c447c;
  --cat-teal-bg: #e1f5ee;   --cat-teal-fg: #085041;
  --cat-amber-bg: #faeeda;   --cat-amber-fg: #633806;
  --cat-purple-bg: #eeedfe;   --cat-purple-fg: #3c3489;
  --cat-coral-bg: #faece7;   --cat-coral-fg: #712b13;
  --cat-pink-bg: #fbeaf0;   --cat-pink-fg: #72243e;
  --cat-green-bg: #eaf3de;   --cat-green-fg: #27500a;
  --cat-gray-bg: #ecebe5;   --cat-gray-fg: #444441;

  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 20px; --sp-6: 24px; --sp-8: 32px;
  --r-card: 22px; --r-big: 28px; --r-ctrl: 18px; --r-sheet: 28px; --r-pill: 999px;
  --shadow-fab: 0 6px 16px rgba(47, 107, 255, 0.35);
  --shadow-sheet: 0 -8px 40px rgba(44, 66, 130, 0.2);
  --backdrop: rgba(20, 30, 60, 0.35);
  --ease: cubic-bezier(.2, .8, .2, 1); --ease-spring: cubic-bezier(.34, 1.56, .64, 1);
  --t-fast: 150ms; --t-base: 250ms; --t-slow: 350ms;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --base: #0f1320;

    --glass: #1a2032;
    --glass-strong: #1a2032;
    --glass-border: #2b3350;
    --glass-shadow: 0 8px 22px rgba(0, 0, 0, 0.38), 0 1px 2px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.12);
    --glass-light: inset 0 1px 0 rgba(255, 255, 255, 0.12);
    --colore-ombra: 0 6px 18px rgba(0, 0, 0, 0.35), 0 1px 2px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.16);
    --colore-bordo: rgba(255, 255, 255, 0.16);
    --lucido: linear-gradient(180deg, rgba(255, 255, 255, 0.11) 0%, rgba(255, 255, 255, 0) 58%);

    --bg-input: #252d44;
    --line: #2b3350;
    --text-primary: #eef2fb;
    --text-secondary: #9eabc2;
    --text-muted: #8d9ab2;
    --accent: #6c9bff; --accent-soft: #22335c; --accent-fg: #0a1226;
    --danger: #ff8a80; --danger-soft: #4a1d19; --rec: #ff5a50;

    --cat-blue-bg: #0c447c;   --cat-blue-fg: #b5d4f4;
    --cat-teal-bg: #085041;   --cat-teal-fg: #9fe1cb;
    --cat-amber-bg: #633806;   --cat-amber-fg: #fac775;
    --cat-purple-bg: #3c3489;   --cat-purple-fg: #cecbf6;
    --cat-coral-bg: #712b13;   --cat-coral-fg: #f5c4b3;
    --cat-pink-bg: #72243e;   --cat-pink-fg: #f4c0d1;
    --cat-green-bg: #27500a;   --cat-green-fg: #c0dd97;
    --cat-gray-bg: #3a3a38;   --cat-gray-fg: #d3d1c7;

    --shadow-fab: 0 6px 16px rgba(108, 155, 255, 0.3);
    --shadow-sheet: 0 -8px 40px rgba(0, 0, 0, 0.5);
    --backdrop: rgba(0, 0, 0, 0.55);
  }
}

*, *::before, *::after { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg-app); color: var(--text-primary);
  font: 15px/1.4 var(--font-sans); -webkit-font-smoothing: antialiased;
  overflow-x: hidden; overscroll-behavior-y: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; text-align: left; }
h1, h2, h3, p { margin: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.nascosto { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
[hidden] { display: none !important; }

.ico { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.ico--sm { width: 16px; height: 16px; }
.ico--lg { width: 56px; height: 56px; stroke-width: 1.4; }

/* Colori per categoria: una sola regola per carte, chip e campioni */
[data-cat] { --c-bg: var(--cat-blue-bg); --c-fg: var(--cat-blue-fg); }
[data-cat="teal"]   { --c-bg: var(--cat-teal-bg);   --c-fg: var(--cat-teal-fg); }
[data-cat="amber"]  { --c-bg: var(--cat-amber-bg);  --c-fg: var(--cat-amber-fg); }
[data-cat="purple"] { --c-bg: var(--cat-purple-bg); --c-fg: var(--cat-purple-fg); }
[data-cat="coral"]  { --c-bg: var(--cat-coral-bg);  --c-fg: var(--cat-coral-fg); }
[data-cat="pink"]   { --c-bg: var(--cat-pink-bg);   --c-fg: var(--cat-pink-fg); }
[data-cat="green"]  { --c-bg: var(--cat-green-bg);  --c-fg: var(--cat-green-fg); }
[data-cat="gray"]   { --c-bg: var(--cat-gray-bg);   --c-fg: var(--cat-gray-fg); }

/* ---------- Struttura ---------- */
.app { min-height: 100dvh; }
.nav, .scheda { min-width: 0; padding: 0 max(var(--sp-4), env(safe-area-inset-right)) 0 max(var(--sp-4), env(safe-area-inset-left)); }
.barra { display: none; }
button, a, select { touch-action: manipulation; }
.col { width: 100%; max-width: 520px; margin: 0 auto; padding: max(var(--sp-5), env(safe-area-inset-top)) 0 calc(110px + env(safe-area-inset-bottom)); }
.scheda { display: none; }
body.in-scheda .nav { display: none; }
body.in-scheda .scheda { display: block; }

@media (min-width: 900px) {
  .app { display: grid; grid-template-columns: 380px minmax(0, 1fr); height: 100dvh; }
  .nav, .scheda { display: block !important; height: 100dvh; overflow-y: auto; }
  .nav { border-right: 1px solid var(--line); background: var(--bg-app); }
  .col { max-width: none; }
  .scheda .col { max-width: 700px; padding-bottom: 80px; }
  .btn-indietro { display: none !important; }
  .fab { left: 190px; }
}

/* ---------- Intestazioni ---------- */
.header { display: flex; justify-content: space-between; align-items: center; gap: var(--sp-2); margin-bottom: var(--sp-3); }
.header h1 { font-size: 24px; font-weight: 600; letter-spacing: -.01em; overflow-wrap: anywhere; }
.header__sub { font-size: 13px; color: var(--text-secondary); }
.header__tools { display: flex; gap: 2px; margin-right: -10px; flex: none; }
.icon-btn {
  width: 44px; height: 44px; display: grid; place-items: center; border-radius: 50%;
  color: var(--text-secondary); position: relative;
  transition: background var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
}
.icon-btn:active { transform: scale(.92); background: var(--bg-input); }
.icon-btn:hover { background: var(--bg-input); }
.indietro {
  display: inline-flex; align-items: center; gap: 2px; margin: 0 0 var(--sp-2) -6px; padding: 0 8px 0 2px;
  height: 36px; border-radius: var(--r-pill); color: var(--accent); font-weight: 500;
}
.indietro:hover { background: var(--accent-soft); }

/* ---------- Campi ---------- */
.campo-wrap { position: relative; margin-bottom: var(--sp-3); }
.campo-wrap .ico { position: absolute; left: 14px; top: 50%; margin-top: -10px; color: var(--text-muted); pointer-events: none; }
.campo {
  width: 100%; height: 44px; padding: 0 14px; border: 1px solid transparent; border-radius: 12px;
  background: var(--bg-input); font-size: 16px; /* 16 px: niente zoom su iPhone */
}
.campo-wrap .campo { padding-left: 42px; }
textarea.campo { height: auto; min-height: 96px; padding: 10px 14px; resize: vertical; line-height: 1.45; }
.campo::placeholder { color: var(--text-muted); }
.campo:focus { border-color: var(--accent); background: var(--bg-surface); outline: none; }
select.campo { appearance: none; padding-right: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238A8F98' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; }

/* ---------- Pillole ---------- */
.pills { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-bottom: var(--sp-4); }
.pill {
  height: 32px; padding: 0 14px; border-radius: var(--r-pill); font-size: 13px; font-weight: 500;
  color: var(--text-secondary); background: var(--bg-surface); display: inline-flex; align-items: center; gap: 6px;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.pill .n { color: var(--text-muted); font-variant-numeric: tabular-nums; }
.pill[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); }
.pill[aria-pressed="true"] .n { color: inherit; opacity: .8; }
.pill--stato[aria-pressed="true"] { background: var(--c-bg); color: var(--c-fg); box-shadow: inset 0 0 0 2px var(--c-fg); }
.pill--stato { height: 38px; }

/* ---------- Carte delle sezioni ---------- */
.cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-2); }
.sez {
  display: flex; flex-direction: column; justify-content: space-between; min-height: 104px; padding: 12px;
  border-radius: var(--r-card); background: var(--c-bg); color: var(--c-fg);
  transition: transform var(--t-fast) var(--ease);
}
.sez:active { transform: scale(.97); }
.sez-wrap { position: relative; display: flex; }
.sez-wrap .sez { flex: 1; min-width: 0; }
.sez__top { display: flex; align-items: center; justify-content: space-between; }
.sez__base { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--sp-2); margin-top: var(--sp-3); }
.sez__base .sez__nome { margin: 0; min-width: 0; }
.sez__modifica { position: absolute; top: 6px; right: 6px; width: 36px; height: 36px; display: grid; place-items: center; border-radius: 50%; color: var(--c-fg); opacity: .7; transition: background var(--t-fast) var(--ease), opacity var(--t-fast) var(--ease); }
.sez__modifica:hover { opacity: 1; background: rgba(255, 255, 255, .35); }
.sez__top .ico { width: 22px; height: 22px; }
.sez__n { font-size: 26px; font-weight: 600; line-height: 1; font-variant-numeric: tabular-nums; }
.sez__nome { font-size: 15px; font-weight: 600; overflow-wrap: anywhere; margin-top: var(--sp-3); }
.sez__sub { font-size: 12px; opacity: .8; }
.sez--tutte { grid-column: 1 / -1; min-height: 76px; flex-direction: row; align-items: center; gap: var(--sp-3); }
.sez--tutte .sez__nome { margin: 0; }
.sez--tutte .sez__n { margin-left: auto; }

/* ---------- Righe delle idee ---------- */
.lista { display: flex; flex-direction: column; gap: var(--sp-2); }
.idea {
  display: block; width: 100%; padding: 12px 14px; border-radius: var(--r-card); background: var(--bg-surface);
  transition: transform var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
}
.idea:active { transform: scale(.985); }
.idea[aria-current="true"] { background: var(--accent-soft); }
.idea__top { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--sp-3); }
.idea__title { font-size: 16px; font-weight: 600; overflow-wrap: anywhere; min-width: 0; }
.idea__prev {
  display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  margin-top: 2px; font-size: 14px; color: var(--text-secondary); overflow-wrap: anywhere;
}
.idea__meta { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); margin-top: var(--sp-2); font-size: 12px; color: var(--text-muted); }
.chip {
  flex: none; display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border-radius: var(--r-pill);
  background: var(--c-bg); color: var(--c-fg); font-size: 12px; font-weight: 600; white-space: nowrap;
}

/* ---------- Pulsanti ---------- */
.btn {
  height: 44px; padding: 0 20px; border-radius: var(--r-pill); font-size: 15px; font-weight: 600;
  background: var(--bg-input); display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  transition: transform var(--t-fast) var(--ease);
}
.btn:active { transform: scale(.96); }
.btn--primary { background: var(--accent); color: var(--accent-fg); box-shadow: var(--shadow-fab); }
.btn--danger { background: var(--danger-soft); color: var(--danger); }
.btn--ghost { background: transparent; color: var(--text-secondary); }
.btn--sm { height: 34px; padding: 0 14px; font-size: 13px; }
.fab {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(16px + env(safe-area-inset-bottom));
  display: inline-flex; align-items: center; gap: 6px; height: 48px; padding: 0 22px; border-radius: var(--r-pill);
  background: var(--accent); color: var(--accent-fg); font-weight: 600; font-size: 15px; box-shadow: var(--shadow-fab);
  z-index: 10; white-space: nowrap; transition: transform var(--t-fast) var(--ease);
}
.fab:active { transform: translateX(-50%) scale(.96); }

/* ---------- Stati vuoti e promemoria ---------- */
.vuoto { text-align: center; color: var(--text-muted); padding: var(--sp-8) var(--sp-4); }
.vuoto h2 { margin: var(--sp-3) 0 var(--sp-1); font-size: 17px; font-weight: 600; color: var(--text-primary); }
.vuoto p { margin: 0 auto var(--sp-4); max-width: 30ch; font-size: 14px; color: var(--text-secondary); }
.promemoria {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2) var(--sp-3);
  background: var(--accent-soft); color: var(--text-primary); border-radius: var(--r-card);
  padding: var(--sp-3) var(--sp-4); margin-bottom: var(--sp-3); font-size: 14px;
}
.promemoria p { flex: 1 1 180px; }
.scheda-vuota { display: none; }
@media (min-width: 900px) {
  .scheda-vuota { display: block; margin: 30vh auto 0; max-width: 300px; text-align: center; color: var(--text-muted); }
  .scheda-vuota h2 { margin: var(--sp-3) 0 var(--sp-1); font-size: 17px; font-weight: 600; color: var(--text-primary); }
  .scheda-vuota p { font-size: 14px; color: var(--text-secondary); }
}

/* ---------- Scheda ---------- */
.scheda-testa { display: flex; align-items: center; justify-content: space-between; min-height: 36px; margin-bottom: var(--sp-2); }
.salvato { font-size: 13px; color: var(--text-muted); opacity: 0; transition: opacity var(--t-slow) var(--ease); margin-left: auto; }
.salvato.visibile { opacity: 1; }
.salvato.errore { color: var(--danger); opacity: 1; font-weight: 600; }
.titolo {
  width: calc(100% + 16px); margin: 0 -8px; padding: 4px 8px; border: 1px solid transparent; border-radius: 12px;
  background: transparent; font-size: 26px; font-weight: 600; line-height: 1.2; letter-spacing: -.01em;
}
.titolo::placeholder { color: var(--text-muted); }
.titolo:hover { border-color: var(--line); }
.titolo:focus { outline: none; border-color: var(--accent); background: var(--bg-surface); }
.meta { margin-top: var(--sp-1); font-size: 13px; color: var(--text-secondary); }
.blocco { margin-top: var(--sp-6); }
.etichetta { display: block; margin-bottom: var(--sp-2); font-size: 12px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--text-secondary); }
.etichetta-riga { display: flex; align-items: center; justify-content: space-between; min-height: 40px; margin-bottom: var(--sp-1); }
.etichetta-riga .etichetta { margin: 0; }
.blocco .pills { margin-bottom: 0; }

.quaderno {
  --alt: 28px; display: block; width: 100%; min-height: calc(var(--alt) * 6 + 20px); resize: vertical;
  padding: 10px 14px; border: 1px solid transparent; border-radius: var(--r-card);
  font-size: 16px; line-height: var(--alt); background-color: var(--bg-surface);
  background-image: repeating-linear-gradient(to bottom, transparent 0, transparent calc(var(--alt) - 1px), var(--line) calc(var(--alt) - 1px), var(--line) var(--alt));
  background-attachment: local; background-position: 0 10px;
}
.quaderno:focus { outline: none; border-color: var(--accent); }
.quaderno::placeholder { color: var(--text-muted); }

/* Microfono */
.mic { display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 14px 0 10px; border-radius: var(--r-pill); background: var(--bg-surface); color: var(--text-secondary); font-size: 13px; font-weight: 600; }
.mic:active { transform: scale(.96); }
.mic[aria-pressed="true"] { background: var(--rec); color: #fff; }
.mic[aria-pressed="true"] .ico { animation: pulsa 1.2s ease-in-out infinite; }
.mic-msg { margin-top: var(--sp-2); font-size: 13px; color: var(--text-secondary); }
.mic-msg.errore { color: var(--danger); }
textarea[readonly] { cursor: default; }
@keyframes pulsa { 50% { opacity: .45; } }

/* Annotazioni */
.composer { background: var(--bg-surface); border-radius: var(--r-card); padding: var(--sp-3); display: flex; flex-direction: column; gap: var(--sp-3); }
.composer .pills { margin: 0; }
.composer textarea.campo { background: var(--bg-input); }
.composer textarea.campo:focus { background: var(--bg-app); }
.composer-piede { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--sp-2); }
.composer-piede .suggerimento { font-size: 12px; color: var(--text-muted); }
.composer-azioni { display: flex; align-items: center; gap: var(--sp-2); margin-left: auto; }
.tipi { display: flex; flex-wrap: wrap; gap: var(--sp-2); border: 0; margin: 0; padding: 0; min-width: 0; }
.tipo { position: relative; }
.tipo input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.tipo span {
  display: inline-flex; align-items: center; height: 34px; padding: 0 14px; border-radius: var(--r-pill);
  background: var(--bg-input); color: var(--text-secondary); font-size: 13px; font-weight: 500;
}
.tipo input:checked + span { background: var(--c-bg); color: var(--c-fg); font-weight: 600; box-shadow: inset 0 0 0 2px var(--c-fg); }
.tipo input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

.note { list-style: none; margin: var(--sp-3) 0 0; padding: 0; display: flex; flex-direction: column; gap: var(--sp-2); }
.nota { padding: 12px 14px; border-radius: var(--r-card); background: var(--c-bg); color: var(--c-fg); animation: pop-in var(--t-base) var(--ease) both; }
.nota__testa { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); min-height: 30px; margin-bottom: 4px; }
.nota__info { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px var(--sp-2); min-width: 0; }
.nota__tipo { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.nota__quando { font-size: 12px; opacity: .8; font-variant-numeric: tabular-nums; }
.nota__testo { white-space: pre-wrap; overflow-wrap: anywhere; color: var(--text-primary); }
.nota__azioni { display: flex; gap: 6px; flex: none; }
.nota .icon-btn { width: 32px; height: 32px; color: inherit; opacity: .75; }
.nota .icon-btn:hover { background: rgba(255, 255, 255, .35); opacity: 1; }
.nessuna { margin-top: var(--sp-3); font-size: 14px; color: var(--text-secondary); }

.zona-elimina { margin-top: var(--sp-8); padding-top: var(--sp-4); border-top: 1px solid var(--line); }
.zona-elimina p { margin-bottom: var(--sp-2); font-size: 14px; color: var(--danger); font-weight: 600; }
.riga-azioni { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); }

/* ---------- Foglio dal basso ---------- */
dialog.sheet {
  position: fixed; inset: auto 0 0 0; margin: 0 auto; width: 100%; max-width: 460px; max-height: 92dvh; overflow: auto;
  overscroll-behavior: contain; border: 0; background: var(--bg-surface); color: var(--text-primary);
  border-radius: var(--r-sheet) var(--r-sheet) 0 0; box-shadow: var(--shadow-sheet);
  padding: var(--sp-3) var(--sp-5) calc(var(--sp-6) + env(safe-area-inset-bottom));
  animation: sheet-up var(--t-slow) var(--ease) both;
}
dialog.sheet::backdrop { background: var(--backdrop); animation: fade var(--t-base) var(--ease); }
dialog.sheet::before { content: ""; display: block; width: 36px; height: 4px; margin: 0 auto var(--sp-4); border-radius: 2px; background: var(--line); }
.sheet h2 { margin-bottom: var(--sp-1); font-size: 20px; font-weight: 600; }
.sheet__sub { margin-bottom: var(--sp-4); font-size: 14px; color: var(--text-secondary); }
.sheet__foot { display: flex; align-items: center; gap: var(--sp-2); margin-top: var(--sp-5); }
.sheet__foot .sp { flex: 1; }
.swatches { display: flex; flex-wrap: wrap; gap: var(--sp-3); margin-top: var(--sp-4); border: 0; padding: 0; }
.swatch { position: relative; width: 40px; height: 40px; }
.swatch input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.swatch span { display: block; width: 100%; height: 100%; border-radius: 50%; background: var(--c-bg); box-shadow: inset 0 0 0 2px var(--c-fg); opacity: .8; }
.swatch input:checked + span { opacity: 1; box-shadow: 0 0 0 3px var(--bg-surface), 0 0 0 5px var(--c-fg), inset 0 0 0 2px var(--c-fg); }
.swatch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 4px; }
@media (min-width: 900px) {
  dialog.sheet { inset: 0; margin: auto; border-radius: var(--r-sheet); }
}

@keyframes sheet-up { from { transform: translateY(24px); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }
@keyframes pop-in { from { opacity: 0; transform: scale(.97); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}

/* Pulsante + in alto */
.icon-btn--primario { background: var(--accent); color: var(--accent-fg); margin-right: var(--sp-2); box-shadow: var(--shadow-fab); }
.icon-btn--primario:hover { background: var(--accent); filter: brightness(1.08); }

/* Pulsanti tondi (microfono / invia), come nei messaggi vocali */
.tondo {
  flex: none; width: 44px; height: 44px; display: grid; place-items: center; border-radius: 50%;
  background: var(--accent); color: var(--accent-fg); transition: transform var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
}
.tondo:active { transform: scale(.92); }
.tondo--mic { background: var(--bg-surface); color: var(--text-secondary); width: 40px; height: 40px; }
.tondo--mic:hover { background: var(--bg-input); }
.tondo[aria-pressed="true"] { background: var(--rec); color: #fff; }
.tondo[aria-pressed="true"] .ico { animation: pulsa 1.2s ease-in-out infinite; fill: currentColor; }
.composer-riga { display: flex; align-items: flex-end; gap: var(--sp-2); }
.composer-riga textarea.campo { flex: 1; min-width: 0; min-height: 44px; max-height: 200px; resize: none; border-radius: 22px; padding: 10px 16px; overflow-y: auto; }
.composer .suggerimento { font-size: 12px; color: var(--text-muted); }
.anteprime:empty { display: none; }
.anteprime { display: flex; flex-direction: column; gap: var(--sp-2); }

/* Anteprima di un link */
.link-card {
  display: flex; align-items: center; gap: var(--sp-3); margin-top: var(--sp-2); padding: 10px 12px; min-width: 0;
  border-radius: 14px; background: var(--bg-surface); color: var(--text-primary); text-decoration: none;
  transition: transform var(--t-fast) var(--ease);
}
.anteprime .link-card { margin-top: 0; background: var(--bg-input); }
.link-card:active { transform: scale(.985); }
.link-card .marca { width: 36px; height: 36px; flex: none; border-radius: 9px; }
.link-card__testo { display: flex; flex-direction: column; min-width: 0; }
.link-card__nome { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.link-card__sub { font-size: 12px; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nota__testo a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }

/* ---------- iPhone: barra in basso ---------- */
.tabbar { display: none; }
@media (max-width: 899px) {
  .tabbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; align-items: center; justify-content: space-around;
    padding: 6px max(var(--sp-4), env(safe-area-inset-right)) calc(6px + env(safe-area-inset-bottom)) max(var(--sp-4), env(safe-area-inset-left));
    background: color-mix(in srgb, var(--bg-surface) 88%, transparent);
    -webkit-backdrop-filter: saturate(180%) blur(18px); backdrop-filter: saturate(180%) blur(18px);
    border-top: 1px solid var(--line);
  }
  body.in-scheda .tabbar { display: none; }
  .tab {
    flex: 1; max-width: 120px; min-height: 48px; display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 2px; color: var(--text-muted); font-size: 11px; font-weight: 500; text-align: center;
  }
  .tab[aria-current="true"] { color: var(--accent); }
  .tab--nuova {
    flex: none; width: 52px; height: 52px; min-height: 0; border-radius: 50%; background: var(--accent); color: var(--accent-fg);
    box-shadow: var(--shadow-fab); margin-top: -18px;
  }
  .tab--nuova .ico { width: 26px; height: 26px; }
  .tab:active { transform: scale(.94); }
  .col { padding-bottom: calc(120px + env(safe-area-inset-bottom)); }
  body.in-scheda .col { padding-bottom: calc(35vh + env(safe-area-inset-bottom)); }
}

/* ---------- Mac: tre colonne ---------- */
@media (min-width: 1200px) {
  .app { grid-template-columns: clamp(250px, 16vw, 320px) clamp(360px, 25vw, 440px) minmax(0, 1fr); }
  .barra { display: block; height: 100dvh; overflow-y: auto; padding: 0 var(--sp-3); background: var(--bg-app); border-right: 1px solid var(--line); }
  .nav { border-right: 1px solid var(--line); }
  .indietro--nav { display: none; }
  .barra__col { padding: max(var(--sp-5), env(safe-area-inset-top)) 0 var(--sp-6); }
  .barra .header h1 { font-size: 20px; }
  .barra .header__tools { margin-right: -6px; }
  .barra .icon-btn { width: 36px; height: 36px; }
  .barra .icon-btn--primario { margin-right: 2px; }
  .barra-etichetta { margin: var(--sp-5) var(--sp-2) var(--sp-1); }
  .barra-sez { display: flex; flex-direction: column; gap: 2px; margin-top: var(--sp-3); }
  .voce-wrap { position: relative; display: flex; }
  .voce {
    flex: 1; min-width: 0; display: flex; align-items: center; gap: var(--sp-2); height: 36px; padding: 0 var(--sp-2);
    border-radius: 10px; color: var(--text-primary); font-weight: 500;
    transition: background var(--t-fast) var(--ease);
  }
  .voce:hover { background: var(--bg-input); }
  .voce[aria-current="true"] { background: var(--accent-soft); color: var(--accent); }
  .voce__ico { width: 24px; height: 24px; border-radius: 7px; display: grid; place-items: center; background: var(--c-bg); color: var(--c-fg); flex: none; }
  .voce__nome { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .voce__n { font-size: 12px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
  .voce__modifica {
    position: absolute; right: 4px; top: 3px; width: 30px; height: 30px; display: none; place-items: center; border-radius: 8px;
    background: var(--bg-input); color: var(--text-secondary);
  }
  .voce-wrap:hover .voce__modifica, .voce__modifica:focus-visible { display: grid; }
  .voce-wrap:hover .voce__n { visibility: hidden; }
  .scorciatoie { display: flex; flex-wrap: wrap; gap: var(--sp-2) var(--sp-3); margin-top: var(--sp-8); padding: 0 var(--sp-2); font-size: 12px; color: var(--text-muted); }
  .scorciatoie span { display: inline-flex; align-items: center; gap: 4px; }
  kbd {
    display: inline-block; min-width: 20px; padding: 1px 5px; border-radius: 5px; background: var(--bg-surface);
    border: 1px solid var(--line); font: 600 11px var(--font-sans); color: var(--text-secondary); text-align: center;
  }
  .nav .col { padding-bottom: var(--sp-8); }
}

/* Mac: effetto al passaggio del mouse sulle righe */
@media (hover: hover) {
  .idea:hover:not([aria-current="true"]) { background: color-mix(in srgb, var(--bg-surface) 70%, var(--bg-input)); }
  .sez:hover { filter: brightness(.97); }
}
@media (hover: none) { .sez__modifica { opacity: .9; } }

/* Menu col tasto destro */
.menu {
  position: fixed; z-index: 60; min-width: 200px; padding: 6px; border-radius: 14px; background: var(--bg-surface);
  box-shadow: 0 10px 40px rgba(0, 0, 0, .22), 0 0 0 1px var(--line); animation: pop-in var(--t-fast) var(--ease) both;
}
.menu__voce { display: flex; align-items: center; gap: var(--sp-2); width: 100%; height: 34px; padding: 0 var(--sp-3) 0 var(--sp-2); border-radius: 8px; font-size: 14px; }
.menu__voce:hover, .menu__voce:focus-visible { background: var(--accent); color: var(--accent-fg); outline: none; }
.menu__vuoto { display: inline-block; width: 16px; flex: none; }

.btn--sezione { background: var(--accent-soft); color: var(--accent); margin-right: var(--sp-2); }
@media (min-width: 1200px) { .barra .header h1 { font-size: 17px; white-space: nowrap; } }

.h1-home { white-space: nowrap; font-size: 22px !important; }

/* Riepilogo nel pannello di destra */
.panoramica { display: none; }
@media (min-width: 900px) {
  .panoramica { display: block; width: 100%; max-width: 720px; margin: 0 auto; padding: max(48px, 9vh) var(--sp-6) var(--sp-8); }
  .panoramica h2 { font-size: 26px; font-weight: 600; letter-spacing: -.01em; margin-bottom: var(--sp-5); }
  .panoramica .etichetta { margin-top: var(--sp-8); }
  .benvenuto { text-align: center; color: var(--text-muted); padding-top: 12vh; }
  .benvenuto h2 { margin: var(--sp-4) 0 var(--sp-2); color: var(--text-primary); }
  .benvenuto p { margin: 0 auto var(--sp-5); max-width: 36ch; color: var(--text-secondary); }
}
.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--sp-2); }
.tile { display: flex; flex-direction: column; justify-content: space-between; gap: var(--sp-4); min-height: 96px; padding: 14px; border-radius: var(--r-card); background: var(--c-bg); color: var(--c-fg); }
.tile__n { font-size: 30px; font-weight: 600; line-height: 1; font-variant-numeric: tabular-nums; }
.tile__l { font-size: 14px; font-weight: 600; }
@media (max-width: 1100px) { .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* Barra dei dati in fondo alla colonna dei Mac */
@media (min-width: 1200px) {
  .barra-dati { margin-top: var(--sp-6); padding-top: var(--sp-3); border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 2px; }
  .voce--dati { color: var(--text-secondary); }
  .voce--dati .voce__ico { background: var(--bg-input); color: var(--text-secondary); }
}

/* Indicatore di sincronizzazione */
.sync-riga { margin: 0 0 var(--sp-3); display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); }
.icon-btn--piccolo { width: 36px; height: 36px; margin-right: -8px; }
.menu__voce--pericolo { color: var(--danger); }
.menu__voce--pericolo:hover, .menu__voce--pericolo:focus-visible { background: var(--danger); color: #fff; }
.sync-chip { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 12px 0 10px; border-radius: var(--r-pill); background: var(--bg-surface); color: var(--text-secondary); font-size: 12px; font-weight: 600; }
.sync-punto { width: 8px; height: 8px; border-radius: 50%; background: var(--text-muted); }
.sync-chip[data-stato="ok"] .sync-punto { background: #2FB24C; }
.sync-chip[data-stato="corso"] .sync-punto { background: var(--accent); animation: pulsa 1s ease-in-out infinite; }
.sync-chip[data-stato="accedi"] { background: var(--accent-soft); color: var(--accent); }
.sync-chip[data-stato="accedi"] .sync-punto, .sync-chip[data-stato="errore"] .sync-punto { background: var(--danger); }
.sync-chip[data-stato="offline"] .sync-punto { background: #E0A100; }

.btn--grande { width: 100%; height: 52px; font-size: 16px; margin-bottom: var(--sp-2); }

/* ---------- Pagina di accesso ---------- */
.accesso { display: none; }
body.bloccata .accesso {
  display: flex; align-items: center; justify-content: center; min-height: 100dvh;
  padding: max(var(--sp-6), env(safe-area-inset-top)) var(--sp-4) max(var(--sp-6), env(safe-area-inset-bottom));
}
body.bloccata .app, body.bloccata .tabbar, body.bloccata dialog.sheet:not([open]) { display: none; }
.accesso__scheda {
  width: 100%; max-width: 380px; display: flex; flex-direction: column; align-items: stretch; gap: var(--sp-3); text-align: center;
}
.accesso__logo { align-self: center; border-radius: 18px; box-shadow: var(--shadow-fab); margin-bottom: var(--sp-2); }
.accesso__scheda h1 { font-size: 28px; font-weight: 600; letter-spacing: -.01em; }
.accesso__sub { color: var(--text-secondary); margin-bottom: var(--sp-3); }
.accesso__form { display: flex; flex-direction: column; gap: var(--sp-3); }
.accesso__scheda .btn--grande { margin-bottom: 0; }
.accesso__scheda .mic-msg { margin: 0; }

.piede-home { margin-top: var(--sp-8); display: flex; justify-content: center; }


/* =====================================================================
   Stile lucido: colori pieni e separati, riflesso e bordo luminoso, nessuna sfocatura né trasparenza
   ===================================================================== */
html, body { background: var(--base); }

/* superfici bianche (o scure): bordo netto e ombra appena accennata */
.idea, .composer, .link-card, .quaderno, .campo, .pill, .sync-chip, .tondo--mic, .promemoria, .tipo span,
.btn:not(.btn--primary):not(.btn--danger):not(.btn--ghost), .menu, dialog.sheet, .tabbar, .accesso__scheda {
  background: var(--glass); border: 1px solid var(--glass-border); box-shadow: var(--glass-shadow);
}
/* carte colorate: tinta piena, bordo luminoso, ombra morbida */
.sez, .tile, .nota { border: 1px solid var(--colore-bordo); box-shadow: var(--colore-ombra); }

.idea, .link-card, .nota { border-radius: 22px; }
.composer, .accesso__scheda { border-radius: var(--r-big); }
.sez, .tile { border-radius: 24px; }
.quaderno { border-radius: var(--r-ctrl); background-color: var(--glass); }
.campo { border-radius: var(--r-ctrl); }
.idea[aria-current="true"] { background: var(--accent-soft); border-color: var(--accent); }
.anteprime .link-card { background: var(--bg-input); box-shadow: var(--glass-light); }
.campo:focus, .quaderno:focus, .composer textarea.campo:focus { background: var(--glass); border-color: var(--accent); }
.composer textarea.campo { background: var(--bg-input); border-radius: 22px; box-shadow: inset 0 1px 2px rgba(44, 66, 130, 0.12); border-color: transparent; }
.composer textarea.campo:focus { background: var(--glass); border-color: var(--accent); }
.promemoria { background: var(--accent-soft); border-color: var(--colore-bordo); box-shadow: var(--colore-ombra); border-radius: var(--r-ctrl); }
.tipo span { background: var(--bg-input); border-color: transparent; box-shadow: var(--glass-light); }
.tipo input:checked + span { background: var(--c-bg); }
.sync-chip { background: var(--glass); }

/* filtri a pillola: attivo = accento pieno */
.pill { color: var(--text-secondary); }
.pill[aria-pressed="true"]:not(.pill--stato) {
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 86%, white), var(--accent)); color: var(--accent-fg);
  border-color: transparent; font-weight: 600; box-shadow: 0 4px 12px color-mix(in srgb, var(--accent) 35%, transparent), inset 0 1px 0 rgba(255, 255, 255, 0.45);
}

/* pulsanti: colori pieni */
.btn { color: var(--text-primary); }
.btn--primary {
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 86%, white), var(--accent)); color: var(--accent-fg);
  border: 1px solid rgba(255, 255, 255, 0.35);
  box-shadow: 0 6px 16px color-mix(in srgb, var(--accent) 35%, transparent), inset 0 1px 0 rgba(255, 255, 255, 0.45);
}
.btn--danger { background: var(--danger-soft); color: var(--danger); border: 1px solid var(--colore-bordo); box-shadow: var(--colore-ombra); }
.btn--ghost { background: transparent; box-shadow: none; border: 0; }
.btn--sezione { background: var(--accent-soft); color: var(--accent); border: 1px solid var(--colore-bordo); box-shadow: var(--colore-ombra); }
.icon-btn--primario, .tab--nuova {
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 86%, white), var(--accent));
  box-shadow: 0 6px 16px color-mix(in srgb, var(--accent) 35%, transparent), inset 0 1px 0 rgba(255, 255, 255, 0.45);
}

/* colonne */
.nav { background: transparent; }
@media (min-width: 1200px) {
  .nav { border-right: 1px solid var(--line); }
  .barra { background: var(--glass); border-right: 1px solid var(--glass-border); }
  .voce[aria-current="true"] { background: var(--accent-soft); box-shadow: var(--glass-light); }
}

/* fogli, menu, barra in basso: pieni */
dialog.sheet { border-bottom: 0; border-radius: var(--r-sheet) var(--r-sheet) 0 0; box-shadow: var(--shadow-sheet); }
.menu { border-radius: 20px; box-shadow: 0 8px 28px rgba(20, 30, 60, 0.18); }
.tabbar { border-width: 1px 0 0; border-radius: 0; box-shadow: 0 -4px 16px rgba(44, 66, 130, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.9); }
@media (min-width: 900px) { dialog.sheet { border: 1px solid var(--glass-border); border-radius: var(--r-sheet); } }
.accesso__scheda { padding: 32px 24px; }

.titolo { font-weight: 700; }
.campo-wrap .ico { z-index: 1; }

/* riflesso lucido in alto sulle superfici (colori pieni, nessuna sfocatura) */
.idea, .idea[aria-current="true"], .composer, .link-card, .sync-chip, .menu, dialog.sheet, .accesso__scheda, .barra,
.sez, .tile, .nota, .promemoria, .pill:not([aria-pressed="true"]), .pill--stato[aria-pressed="true"], .tipo input:checked + span, .tondo--mic,
.btn:not(.btn--ghost):not(.btn--primary), .tabbar {
  background-image: var(--lucido) !important;
}
/* righe del quaderno nella descrizione */
.quaderno {
  background-image: repeating-linear-gradient(to bottom, transparent 0, transparent calc(var(--alt) - 1px), var(--line) calc(var(--alt) - 1px), var(--line) var(--alt));
  background-attachment: local; background-position: 0 10px;
}
