@font-face { font-family: "DM Sans"; font-weight: 400; font-display: swap; src: url("/fonts/dm-sans-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "DM Sans"; font-weight: 500; font-display: swap; src: url("/fonts/dm-sans-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "DM Sans"; font-weight: 700; font-display: swap; src: url("/fonts/dm-sans-latin-700-normal.woff2") format("woff2"); }

/* ---------- temi ---------- */
:root {
  color-scheme: dark;
  --bg: #0c0e0d;
  --card: #151816;
  --card-2: #1d211e;
  --line: #262b27;
  --text: #edf1ed;
  --muted: #8d968f;
  --faint: #5f6761;
  --accent: #bfeaa6;        /* riempimenti: pulsanti, spunte */
  --accent-ink: #cdf0b6;    /* testi evidenziati */
  --on-accent: #101510;
  --alt: #b9a9ff;           /* colore secondario: Inbox e Completate */
  --alt-soft: rgba(185, 169, 255, .14);
  --late: #ff9d7a;
  --amber: #f5b94d;
  --red: #ff7a7a;
  --ok: #5fcf8a;
  --shadow: 0 8px 24px rgba(191, 234, 166, .18);
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #eef1ec;
  --card: #ffffff;
  --card-2: #f2f5f0;
  --line: #e0e5dd;
  --text: #151a16;
  --muted: #66706a;
  --faint: #9ca79f;
  --accent: #b6e48e;
  --accent-ink: #2f6a1b;
  --on-accent: #12170f;
  --alt: #6a4fd8;
  --alt-soft: rgba(106, 79, 216, .10);
  --late: #c2410c;
  --amber: #b7791f;
  --red: #c53030;
  --ok: #2f9e5f;
  --shadow: 0 8px 22px rgba(80, 140, 50, .22);
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    color-scheme: light;
    --bg: #eef1ec;
    --card: #ffffff;
    --card-2: #f2f5f0;
    --line: #e0e5dd;
    --text: #151a16;
    --muted: #66706a;
    --faint: #9ca79f;
    --accent: #b6e48e;
    --accent-ink: #2f6a1b;
    --on-accent: #12170f;
    --alt: #6a4fd8;
    --alt-soft: rgba(106, 79, 216, .10);
    --late: #c2410c;
    --amber: #b7791f;
    --red: #c53030;
    --ok: #2f9e5f;
    --shadow: 0 8px 22px rgba(80, 140, 50, .22);
  }
}

:root {
  --font: "DM Sans", -apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif;
  --r: 22px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 400 16px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
svg { display: block; }

.page {
  max-width: 560px;
  margin: 0 auto;
  padding: calc(14px + var(--safe-t)) 14px calc(48px + var(--safe-b));
  display: flex; flex-direction: column; gap: 12px;
}

/* ---------- card Oggi ---------- */
.today { background: var(--card); border-radius: var(--r); padding: 22px 20px 12px; }
.today-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.today h1 { margin: 0; font: 700 40px/1.05 var(--font); letter-spacing: -0.035em; color: var(--accent-ink); }
.today .date { margin: 6px 0 0; color: var(--muted); font-size: 15px; }
.head-tools { display: flex; align-items: center; gap: 2px; margin-top: 2px; }
.sync-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); margin-right: 6px; }
.sync-dot.ok { background: var(--ok); }
.sync-dot.busy { background: var(--amber); }
.sync-dot.err { background: var(--red); }
.icon-btn { width: 38px; height: 38px; border: 0; background: none; color: var(--muted); border-radius: 12px; display: grid; place-items: center; }
.icon-btn:hover { background: var(--card-2); color: var(--text); }

.progress { height: 5px; border-radius: 99px; background: var(--card-2); margin-top: 16px; overflow: hidden; }
.progress i { display: block; height: 100%; width: 0; border-radius: 99px; background: var(--accent); transition: width .35s ease; }

.tasks { display: flex; flex-direction: column; margin-top: 10px; }
.empty-line { color: var(--muted); padding: 14px 0 8px; font-size: 15px; }

.task { display: flex; align-items: flex-start; gap: 13px; padding: 11px 0; transition: opacity .18s ease, transform .18s ease; }
.task + .task { border-top: 1px solid var(--line); }
.task.out { opacity: 0; transform: translateX(28px); }
.check {
  flex-shrink: 0; width: 28px; height: 28px; border-radius: 50%; padding: 0; margin-top: 1px;
  border: 2px solid var(--faint); background: none; display: grid; place-items: center;
  color: transparent; transition: background .15s, border-color .15s;
}
.check.p1 { border-color: var(--amber); }
.check.p2 { border-color: var(--red); }
.task.done .check { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.task-body { flex: 1; min-width: 0; text-align: left; border: 0; background: none; padding: 2px 0 0; }
.task-title { display: block; word-break: break-word; font-size: 16px; font-weight: 500; }
.task.done .task-title { color: var(--faint); text-decoration: line-through; font-weight: 400; }
.task-meta { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 3px; font-size: 13px; color: var(--muted); }
.tag { border-radius: 999px; padding: 1px 9px; background: var(--card-2); }
.tag.late { color: var(--late); background: color-mix(in srgb, var(--late) 14%, transparent); }
.task-actions { display: flex; gap: 6px; align-items: center; padding-top: 1px; }
.pill {
  display: inline-flex; align-items: center; gap: 4px; border: 0; border-radius: 999px;
  background: var(--card-2); color: var(--muted); font-size: 13px; font-weight: 500; padding: 7px 11px; white-space: nowrap;
}
.pill:hover { color: var(--text); }
.pill:active { background: var(--accent); color: var(--on-accent); }

/* ---------- pulsante Nuova task ---------- */
.add-btn {
  width: 100%; border: 0; border-radius: 999px; background: var(--accent); color: var(--on-accent);
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 16px 20px; font-size: 17px; font-weight: 700; box-shadow: var(--shadow); transition: transform .12s;
}
.add-btn:active { transform: scale(.98); }

/* ---------- card a fisarmonica ---------- */
.fold { background: var(--card); border-radius: var(--r); overflow: hidden; }
.fold-head { width: 100%; border: 0; background: none; text-align: left; padding: 18px 20px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.fold-title { display: flex; align-items: center; gap: 10px; min-width: 0; flex-wrap: wrap; }
.fold-title b { font: 700 22px/1.1 var(--font); letter-spacing: -0.02em; color: var(--muted); }
.fold.has b { color: var(--text); }
.fold.is-open b { color: var(--accent-ink); }
.fold-title .count { font-size: 13px; font-weight: 700; min-width: 22px; text-align: center; padding: 1px 8px; border-radius: 99px; background: var(--card-2); color: var(--text); }
.fold-title small { font-size: 13px; color: var(--faint); }
.fold-arrow { color: var(--faint); transition: transform .2s; flex-shrink: 0; }
.fold.is-open .fold-arrow { transform: rotate(180deg); color: var(--muted); }
.fold-body { padding: 0 20px 14px; }
.fold-body .tasks { margin-top: 0; }
.fold-add { border: 0; background: none; color: var(--accent-ink); padding: 10px 0 2px; font-size: 14px; font-weight: 500; display: flex; align-items: center; gap: 6px; }
.fold-note { color: var(--faint); font-size: 14px; padding: 2px 0 8px; margin: 0; }

/* Inbox e Completate: colore secondario */
.fold.alt b, .fold.alt.has b, .fold.alt.is-open b { color: var(--alt); }
.fold.alt .count { background: var(--alt-soft); color: var(--alt); }
.fold.alt .fold-arrow { color: var(--alt); opacity: .7; }
.fold.alt .fold-add { color: var(--alt); }
.fold.alt.is-open { box-shadow: inset 0 0 0 1px var(--alt-soft); }

/* ---------- messaggi ---------- */
.banner { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 12px 16px; font-size: 14px; color: var(--muted); }
.banner strong { color: var(--text); font-weight: 500; }
.link { border: 0; background: none; color: var(--accent-ink); padding: 4px 2px; font-size: inherit; font-weight: 500; }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(24px + var(--safe-b)); z-index: 30;
  background: var(--text); color: var(--bg); padding: 10px 10px 10px 18px; border-radius: 999px; font-size: 14px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, .35); display: flex; align-items: center; gap: 10px; max-width: 92vw;
}
.toast button { border: 0; background: color-mix(in srgb, var(--bg) 18%, transparent); color: var(--bg); border-radius: 999px; padding: 6px 14px; font-weight: 500; }

/* ---------- finestre ---------- */
dialog { border: 0; padding: 0; background: var(--card); color: var(--text); width: min(500px, 100%); max-width: 100%; max-height: 92vh; border-radius: 26px; box-shadow: 0 24px 70px rgba(0, 0, 0, .5); }
dialog::backdrop { background: rgba(0, 0, 0, .5); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); }
@media (max-width: 600px) { dialog { width: 100%; margin: auto 0 0; border-radius: 26px 26px 0 0; max-height: 94vh; } }
.sheet { padding: 10px 20px calc(22px + var(--safe-b)); display: flex; flex-direction: column; gap: 14px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 0 2px; }
.sheet-head > * { min-width: 72px; }
.sheet-head strong { text-align: center; font-weight: 700; font-size: 17px; }
.sheet-head > :last-child { text-align: right; }
.field { display: flex; flex-direction: column; gap: 7px; }
.field > span { font-size: 12px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 500; }
.field input, .field textarea, .field select { width: 100%; padding: 12px 14px; border-radius: 14px; border: 1px solid var(--line); background: var(--card-2); outline: none; font-size: 16px; }
.field input:focus, .field textarea:focus, .field select:focus { border-color: var(--accent); }
.field textarea { resize: vertical; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.chips, .seg { display: flex; gap: 6px; flex-wrap: wrap; }
.chips button, .seg button { border: 1px solid var(--line); background: var(--card-2); border-radius: 999px; padding: 8px 15px; font-size: 14px; }
.seg button { flex: 1; border-radius: 12px; }
.chips button.on, .seg button.on { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 700; }
button.primary { border: 0; background: var(--accent); color: var(--on-accent); border-radius: 999px; padding: 12px 20px; font-weight: 700; }
button.ghost { border: 1px solid var(--line); background: var(--card-2); border-radius: 999px; padding: 12px 18px; font-weight: 500; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.btn-row.end { justify-content: space-between; align-items: center; }
.hint { margin: 0; font-size: 13px; color: var(--muted); min-height: 1em; }
.hint.err { color: var(--red); }
.hint.ok { color: var(--accent-ink); }
.preview { margin: 0; font-size: 14px; color: var(--accent-ink); font-weight: 500; min-height: 1.3em; }
button.danger { border: 0; background: none; color: var(--red); padding: 10px; font-weight: 500; }
hr { border: 0; border-top: 1px solid var(--line); width: 100%; margin: 2px 0; }
.big-input { font-size: 18px !important; padding: 15px 16px !important; }

.folds { display: flex; flex-direction: column; gap: 12px; }

/* ---------- intestazione ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 2px 4px 0; }
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.logo { width: 44px; height: 44px; border-radius: 13px; flex-shrink: 0; box-shadow: 0 0 0 1px var(--line); }
.hello { margin: 0; font: 700 21px/1.2 var(--font); letter-spacing: -0.02em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.today h1 { margin: 0; }

/* ---------- accessibilità e tocco ---------- */
.icon-btn { width: 44px; height: 44px; }
.check { position: relative; }
.check::before { content: ""; position: absolute; inset: -8px; }
.pill { position: relative; min-height: 36px; }
.pill::after { content: ""; position: absolute; inset: -4px; }
button:focus-visible { outline: 2px solid var(--accent-ink); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}

/* ---------- accesso e account ---------- */
.hint.big { font-size: 15px; line-height: 1.5; }
.hint.legal { font-size: 12px; text-align: center; }
.hint.legal a { color: var(--accent-ink); }
.code-input { font-size: 30px !important; font-weight: 700; letter-spacing: 12px; text-align: center; padding: 14px 8px !important; }
.btn-row.between { justify-content: space-between; }
button.wide { width: 100%; padding: 15px 20px; font-size: 16px; }
button.primary:disabled { opacity: .55; }
.link:disabled { opacity: .5; text-decoration: none; }
.acc-email { margin: 0; font-weight: 700; font-size: 16px; word-break: break-all; }
a.ghost { display: inline-flex; align-items: center; border: 1px solid var(--line); background: var(--card-2); border-radius: 999px; padding: 12px 18px; font-weight: 500; color: var(--text); text-decoration: none; font-size: 16px; }
