:root {
  --bg: #fafaf7;
  --surface: #ffffff;
  --text: #1c1c1e;
  --muted: #6b6b70;
  --line: #e6e6e1;
  --accent: #1c1c1e;
  --on-accent: #ffffff;
  --danger: #b3261e;
  --focus: #0a60ff;
  --radius: 14px;
  --blue: #5fa8ee;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --surface: #1c1c1e;
    --text: #f5f5f7;
    --muted: #a1a1a6;
    --line: #2c2c2e;
    --accent: #f5f5f7;
    --on-accent: #000000;
    --danger: #ff8a80;
    --focus: #6ea8ff;
    --blue: #8cc4ff;
  }
}
:root[data-theme="light"] {
  --bg: #fafaf7; --surface: #ffffff; --text: #1c1c1e; --muted: #6b6b70; --line: #e6e6e1;
  --accent: #1c1c1e; --on-accent: #ffffff; --danger: #b3261e; --focus: #0a60ff; color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #000000; --surface: #1c1c1e; --text: #f5f5f7; --muted: #a1a1a6; --line: #2c2c2e;
  --accent: #f5f5f7; --on-accent: #000000; --danger: #ff8a80; --focus: #6ea8ff; color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: -apple-system, "SF Pro Text", "Inter", system-ui, "Segoe UI", Roboto, sans-serif;
  font-size: 16px; line-height: 1.35;
}
body.noscroll { overflow: hidden; }
main {
  max-width: 560px; margin: 0 auto;
  padding: calc(44px + env(safe-area-inset-top)) 18px calc(96px + env(safe-area-inset-bottom));
  outline: 0;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; text-align: left; }
input { font: inherit; color: var(--text); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 6px; }

h1 { font-size: 28px; font-weight: 600; letter-spacing: -0.02em; margin: 0; }
h2 { font-size: 22px; font-weight: 600; letter-spacing: -0.02em; margin: 0; }
.sub { margin: 2px 0 0; font-size: 14px; color: var(--muted); }
.small { font-size: 12px; color: var(--muted); }
.mut { color: var(--muted); }
.sec { display: flex; justify-content: space-between; align-items: center; margin: 24px 4px 8px; font-size: 13px; color: var(--muted); font-weight: 500; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; font-size: 16px; position: relative; width: 100%; min-height: 52px; }
.row + .row::before { content: ""; position: absolute; top: 0; left: 14px; right: 0; height: 1px; background: var(--line); }
.grow { flex: 1; min-width: 0; }
.grow.link { display: block; }
.plus { width: 24px; text-align: center; font-size: 22px; line-height: 1; color: var(--muted); }
.row.add { color: var(--muted); }

.dot { position: relative; width: 20px; height: 20px; border-radius: 50%; border: 1.25px solid var(--muted); flex: none; display: flex; align-items: center; justify-content: center; color: var(--on-accent); transition: background .15s, border-color .15s; }
.dot::after { content: ""; position: absolute; inset: -12px; }
.dot.on { background: var(--accent); border-color: var(--accent); }
.dot.dis { opacity: .3; }
.dot svg { width: 11px; height: 11px; }

/* Micro animazioni */
.txt { background: linear-gradient(currentColor, currentColor) no-repeat 0 56% / 0 1.5px; transition: color .2s; }
.row.done .txt { background-size: 100% 1.5px; color: var(--muted); }
.row.done { color: var(--muted); }
.row.just .txt { animation: strike .4s ease-out; }
.dot.pop, .got.pop { animation: pop .38s cubic-bezier(.3, 1.7, .5, 1); }
.dot.pop svg path { stroke-dasharray: 24; animation: draw .32s .06s ease-out both; }
.bp { position: absolute; left: 50%; top: 50%; width: 4px; height: 4px; margin: -2px; border-radius: 50%; background: var(--accent); pointer-events: none; animation: fly .5s ease-out forwards; }
@keyframes pop { 0% { transform: scale(1); } 40% { transform: scale(1.35); } 100% { transform: scale(1); } }
@keyframes draw { from { stroke-dashoffset: 24; } to { stroke-dashoffset: 0; } }
@keyframes strike { from { background-size: 0 1.5px; } to { background-size: 100% 1.5px; } }
@keyframes fly { to { transform: rotate(var(--a)) translateX(22px) scale(.3); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

.radio { width: 20px; height: 20px; border-radius: 50%; border: 1.25px solid var(--muted); flex: none; position: relative; }
.radio.on { border-color: var(--accent); }
.radio.on::after { content: ""; position: absolute; inset: 4px; border-radius: 50%; background: var(--accent); }
.lnk { font-size: 13px; color: var(--text); font-weight: 500; padding: 4px 2px; }
.hint { margin: 10px 4px 0; font-size: 13px; color: var(--muted); line-height: 1.4; }
.emo { font-size: 17px; line-height: 1; vertical-align: -1px; }
.pname { margin: 16px 2px 8px; font-size: 14px; font-weight: 600; }
.arow { display: grid; grid-template-columns: 1fr 110px 24px; align-items: center; gap: 10px; padding: 8px 0; font-size: 15px; }
.arow input { width: 100%; accent-color: var(--accent); }
.bar { height: 4px; background: var(--line); border-radius: 2px; margin-top: 8px; overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--accent); border-radius: 2px; }
.mscroll { overflow-y: auto; scroll-snap-type: y mandatory; overscroll-behavior: contain; scrollbar-width: none; }
.mscroll::-webkit-scrollbar { display: none; }
.mscroll .mblock { margin-top: 0; padding-bottom: 10px; scroll-snap-align: start; }

.field { display: block; padding: 14px; }
.field input { width: 100%; border: 0; background: none; outline: 0; font-size: 16px; padding: 0; }
.field input::placeholder { color: var(--muted); }

.pill { font-size: 13px; border: 1px solid var(--muted); border-radius: 999px; padding: 6px 12px; white-space: nowrap; display: inline-block; }
.pill.on { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.seg { display: flex; background: var(--line); border-radius: 10px; padding: 2px; margin: 12px 0 0; }
.seg button { flex: 1; text-align: center; font-size: 14px; padding: 7px 0; border-radius: 8px; color: var(--muted); }
.seg button.sel { background: var(--surface); color: var(--text); font-weight: 600; }

.wrap { background: var(--accent); color: var(--on-accent); border-radius: var(--radius); padding: 14px; margin-top: 16px; display: flex; align-items: center; gap: 12px; font-size: 15px; }
.wrap .small { color: var(--on-accent); opacity: .75; }
.wrap .pill { border-color: var(--on-accent); color: var(--on-accent); }

.remind { margin-top: 16px; padding: 14px; border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius); display: flex; align-items: center; gap: 12px; font-size: 15px; }
.remind .pill { border-color: var(--text); }

/* Settimana */
.wk { display: flex; justify-content: space-between; align-items: center; margin: 24px 4px 8px; font-size: 13px; color: var(--muted); font-weight: 500; }
.wk button { font-size: 24px; width: 40px; height: 32px; text-align: center; color: var(--text); }
.strip { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; text-align: center; }
.strip button { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 4px 0; text-align: center; }
.strip .l { font-size: 12px; color: var(--muted); }
.strip .n { width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 17px; font-variant-numeric: tabular-nums; }
.strip .today .n { border: 1.5px solid var(--muted); }
.strip .sel .n { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.strip .dts { display: flex; gap: 3px; height: 6px; }
.strip .dts i { width: 5px; height: 5px; border-radius: 50%; border: 1px solid var(--muted); }
.strip .dts i.f { background: var(--muted); }

/* Recap */
.mblock { margin-top: 22px; scroll-margin-top: 12px; }
.mname { font-size: 13px; font-weight: 500; color: var(--muted); margin: 0 0 6px; }
.cells { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.cells.sm { gap: 4px; }
.cells.sm .sq { border-radius: 8px; font-size: 13px; }
.cells.sm .wd { font-size: 11px; }
.wd { font-size: 12px; text-align: center; color: var(--muted); }
.sq { aspect-ratio: 1; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); display: flex; align-items: center; justify-content: center; font-size: 13px; font-variant-numeric: tabular-nums; }
.sq.l1 { background: color-mix(in srgb, var(--accent) 22%, var(--surface)); }
.sq.l2 { background: color-mix(in srgb, var(--accent) 55%, var(--surface)); color: var(--on-accent); }
.sq.l3 { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.sq.f { background: none; border-color: transparent; color: var(--muted); }
.leg { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); margin-top: 12px; }
.leg i { width: 18px; height: 18px; aspect-ratio: auto; border-radius: 5px; display: block; }
.leg { margin-top: 18px; }
.kpi { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 30px; }
.kpi > div { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 10px; }
.num { font-size: 26px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.radar { padding: 6px; }
.radar svg { width: 100%; height: auto; display: block; }
.tools { display: flex; gap: 10px; margin-top: 28px; }
.tools button { font-size: 14px; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 8px 14px; }

/* Tab bar come in 1000 */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0;
  display: flex; justify-content: center; gap: 4px;
  padding: 6px 12px calc(6px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  border-top: 1px solid var(--line); z-index: 10;
}
.tab {
  flex: 1; max-width: 160px; min-height: 52px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  border-radius: var(--radius); color: var(--muted); font-size: 12px; font-weight: 500; text-align: center;
}
.tab svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tab[aria-current="page"] { color: var(--text); font-weight: 600; }

/* Fogli */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.55); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); z-index: 30; display: flex; align-items: flex-end; justify-content: stretch; }
.panel { background: var(--bg); width: 100%; max-width: none; max-height: 88vh; overflow: auto; border-radius: 20px 20px 0 0; padding: 20px 18px calc(20px + env(safe-area-inset-bottom)); }
.shead { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.x { width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; color: var(--muted); }
.box { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { font-size: 14px; border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 7px 13px; }
.chip.on { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.cl { margin: 16px 2px 8px; }
.sbtns { display: flex; gap: 10px; margin-top: 20px; justify-content: flex-end; }
.btn { font-size: 16px; padding: 11px 20px; border-radius: 12px; border: 1px solid var(--line); text-align: center; }
.btn.primary { background: var(--accent); color: var(--on-accent); border-color: var(--accent); font-weight: 600; }
.btn.danger { color: var(--danger); }
.err { color: var(--danger); font-size: 13px; margin: 8px 2px 0; }
.step { display: flex; align-items: center; justify-content: space-between; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 8px 14px; margin-top: 10px; }
.step button { width: 36px; height: 36px; font-size: 22px; text-align: center; }
.list { margin-top: 12px; overflow: hidden; }

/* Storie */
.story { position: fixed; inset: 0; z-index: 40; background: var(--accent); color: var(--on-accent); display: flex; flex-direction: column; }
.story .bars { display: flex; gap: 4px; padding: calc(16px + env(safe-area-inset-top)) 16px 0; }
.story .bars i { flex: 1; height: 3px; border-radius: 2px; background: var(--on-accent); opacity: .3; }
.story .bars i.on { opacity: 1; }
.story .top { display: flex; justify-content: flex-end; padding: 6px 10px; }
.story .top button { padding: 10px; color: var(--on-accent); }
.story .body { flex: 1; display: flex; flex-direction: column; justify-content: center; padding: 24px 28px; max-width: 560px; width: 100%; margin: 0 auto; }
.story .k { font-size: 15px; opacity: .75; margin: 0 0 10px; }
.story .big { font-weight: 600; letter-spacing: -0.03em; line-height: 1.05; margin: 0; }
.story .t { font-size: 20px; margin: 14px 0 0; }
.story .nav { display: flex; justify-content: space-between; padding: 0 20px calc(24px + env(safe-area-inset-bottom)); }
.story .nav button { border: 1px solid var(--on-accent); border-radius: 999px; padding: 9px 18px; font-size: 14px; color: var(--on-accent); }
.story .go { margin-top: 26px; align-self: flex-start; border: 1px solid var(--on-accent); border-radius: 999px; padding: 11px 20px; font-size: 16px; color: var(--on-accent); }

.toast { position: fixed; left: 18px; right: 18px; bottom: calc(84px + env(safe-area-inset-bottom)); max-width: 524px; margin: 0 auto; background: var(--accent); color: var(--on-accent); border-radius: 12px; padding: 12px 16px; font-size: 14px; z-index: 50; }

/* Giorni che scorrono in orizzontale */
.days { position: relative; display: flex; gap: 2px; overflow-x: auto; margin: 16px -18px 0; padding: 0 18px; scrollbar-width: none; }
.days::-webkit-scrollbar { display: none; }
.day { flex: none; width: 44px; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 4px 0; text-align: center; }
.day .l { font-size: 12px; color: var(--muted); }
.day .n { width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 17px; font-variant-numeric: tabular-nums; }
.day.today .n { border: 1.5px solid var(--muted); }
.day.sel .n { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }

/* Legenda del radar */
.rlegend { display: flex; justify-content: center; gap: 16px; flex-wrap: wrap; font-size: 12px; color: var(--muted); padding: 2px 8px 10px; }
.rlegend span { display: flex; align-items: center; gap: 6px; }
.rlegend i { width: 8px; height: 8px; border-radius: 50%; display: block; }

.rrows { border-top: 1px solid var(--line); margin: 4px 12px 0; padding: 4px 0 10px; }
.rrow { display: flex; justify-content: space-between; align-items: center; padding: 5px 0; font-size: 15px; font-variant-numeric: tabular-nums; }
.rrow b { font-weight: 600; }

.ycat { margin: 16px 4px 6px; font-size: 14px; font-weight: 600; }

/* pulsante Raggiunto e spunta con data */
.reach { flex: none; font-size: 13px; border: 1px solid var(--muted); border-radius: 999px; padding: 6px 12px; white-space: nowrap; }
.got { position: relative; flex: none; display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); padding: 6px 2px 6px 8px; white-space: nowrap; }
.got svg { width: 16px; height: 16px; padding: 3px; border-radius: 50%; background: var(--accent); color: var(--on-accent); }
.sq { position: relative; }
.sq .gi { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 22px; font-style: normal; line-height: 1; pointer-events: none; }
[data-lp] { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
.sug { margin-top: 6px; }
.add-ghost { color: var(--muted); }

/* introduzione */
.onb { position: fixed; inset: 0; z-index: 60; background: var(--bg); display: flex; flex-direction: column; padding: calc(24px + env(safe-area-inset-top)) 18px calc(24px + env(safe-area-inset-bottom)); }
.onb-body { flex: 1; overflow-y: auto; display: flex; flex-direction: column; justify-content: center; width: 100%; max-width: 480px; margin: 0 auto; }
.onb-in { text-align: left; }
.onb-in h2 { font-size: 30px; margin: 0 0 8px; outline: 0; }
.onb-in p { margin: 0 0 22px; font-size: 16px; line-height: 1.45; color: var(--muted); }
.onb-mock { margin-bottom: 28px; pointer-events: none; }
.onb-emo { font-size: 64px; line-height: 1; margin-bottom: 20px; }
.onb-dots { display: flex; justify-content: center; gap: 8px; padding: 12px 0 16px; }
.onb-dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--line); transition: background .2s, width .2s; }
.onb-dots i.on { background: var(--accent); width: 20px; border-radius: 4px; }
.onb-btns { display: flex; gap: 10px; width: 100%; max-width: 480px; margin: 0 auto; }
.onb-btns .btn { flex: 1; text-align: center; }
