/* Pensiero Positivo — tre stili: prato (prato verde), lago (lago azzurro), sera (sera tranquilla) */
:root, [data-theme="prato"] {
  --bg: #F2F6EC; --surface: #FFFFFF; --surface2: #E6EFDD; --ink: #1E3829; --muted: #5C7264;
  --accent: #4E8A57; --on-accent: #FFFFFF; --accent2: #4C9BCB; --line: #DCE6D3;
  --hero-sky1: #BFE2F5; --hero-sky2: #EEF7E8; --hill1: #8DBF74; --hill2: #6EA65E; --hill3: #4E8A57; --water: #9ED0EC;
  --shadow: 0 6px 22px rgba(46, 84, 52, .10); --radius: 22px;
}
[data-theme="lago"] {
  --bg: #EDF5FA; --surface: #FFFFFF; --surface2: #DDEDF7; --ink: #15324A; --muted: #587287;
  --accent: #2F86BF; --on-accent: #FFFFFF; --accent2: #6FAE6B; --line: #D3E4EF;
  --hero-sky1: #A9D8F2; --hero-sky2: #EAF5FB; --hill1: #A6CF92; --hill2: #86BC77; --hill3: #5E9E5A; --water: #7CC0E8;
  --shadow: 0 6px 22px rgba(30, 80, 120, .10); --radius: 26px;
}
[data-theme="sera"] {
  --bg: #0F221E; --surface: #17312B; --surface2: #1F3F37; --ink: #EEF3EC; --muted: #A5BBB0;
  --accent: #9CCB86; --on-accent: #10231B; --accent2: #8EC5E6; --line: #28483F;
  --hero-sky1: #24476B; --hero-sky2: #3D6A7C; --hill1: #2F5B45; --hill2: #264C3A; --hill3: #1C3D2F; --water: #3E7A97;
  --shadow: 0 8px 26px rgba(0, 0, 0, .35); --radius: 22px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--ink);
  font-family: "Assistant", "Segoe UI", system-ui, sans-serif; font-size: 17px; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { font-family: "Frank Ruhl Libre", Georgia, serif; font-weight: 700; margin: 0 0 .4em; line-height: 1.2; }
h1 { font-size: 30px; } h2 { font-size: 22px; } h3 { font-size: 18px; }
p { margin: 0 0 .6em; }
a { color: var(--accent); }
button, input, textarea, select { font: inherit; color: inherit; }
.ltr { direction: ltr; unicode-bidi: isolate; display: inline-block; }
.muted { color: var(--muted); }
.small { font-size: 15px; }

/* Struttura */
#app { min-height: 100vh; }
main { max-width: 760px; margin: 0 auto; padding: 0 18px 120px; }
.top { display: flex; align-items: center; gap: 12px; padding: 18px 0 12px; }
.top h1 { flex: 1; margin: 0; font-size: 26px; }
.iconbtn { width: 48px; height: 48px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); display: grid; place-items: center; cursor: pointer; }
.iconbtn svg { width: 22px; height: 22px; }
[dir="rtl"] .flip { transform: scaleX(-1); }

/* Navigazione in basso */
nav.bottom {
  position: fixed; bottom: 12px; left: 12px; right: 12px; z-index: 20;
  max-width: 560px; margin: 0 auto; display: flex; justify-content: space-around;
  background: var(--surface); border: 1px solid var(--line); border-radius: 26px; box-shadow: var(--shadow); padding: 6px;
}
nav.bottom a { flex: 1; min-height: 56px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; text-decoration: none; color: var(--muted); font-size: 13px; border-radius: 20px; }
nav.bottom a svg { width: 22px; height: 22px; }
nav.bottom a.on { color: var(--accent); background: var(--surface2); font-weight: 700; }
@media (min-width: 900px) {
  nav.bottom { top: 0; bottom: 0; left: auto; right: auto; inset-inline-start: 0; width: 200px; margin: 0; border-radius: 0; flex-direction: column; justify-content: flex-start; padding: 90px 12px 12px; gap: 6px; border-width: 0; border-inline-end-width: 1px; }
  nav.bottom a { flex: none; flex-direction: row; justify-content: flex-start; padding: 0 14px; font-size: 16px; gap: 10px; }
  #app.withnav main { margin-inline-start: 200px; margin-inline-end: auto; padding-inline: 40px; max-width: 900px; }
  .brandside { display: block !important; position: fixed; top: 22px; inset-inline-start: 22px; z-index: 21; font-family: "Frank Ruhl Libre", serif; font-weight: 700; font-size: 19px; color: var(--accent); }
}
.brandside { display: none; }

/* Hero con prato e cigni */
.hero { position: relative; border-radius: var(--radius); overflow: hidden; margin: 6px 0 18px; box-shadow: var(--shadow); }
.hero svg.land { display: block; width: 100%; height: 190px; }
.hero .over { position: absolute; inset: 0; padding: 20px 22px; display: flex; flex-direction: column; justify-content: flex-start; }
.hero .over h1 { color: #17321F; margin-bottom: 2px; }
[data-theme="sera"] .hero .over h1 { color: #F3F7F1; }
.hero .over p { color: #2E4A39; margin: 0; font-weight: 600; }
[data-theme="sera"] .hero .over p { color: #D6E4DA; }

/* Carte */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 14px; box-shadow: var(--shadow); }
.card.soft { background: var(--surface2); box-shadow: none; border-color: transparent; }
.sec { margin: 26px 0 10px; display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.sec h2 { margin: 0; }
.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 8px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.kpi b { display: block; font-size: 34px; line-height: 1.1; font-family: "Frank Ruhl Libre", serif; }
.kpi span { color: var(--muted); font-size: 15px; }
.kpi.main { background: var(--accent); color: var(--on-accent); border-color: transparent; }
.kpi.main span { color: var(--on-accent); opacity: .85; }
.kpi b span { font-size: inherit; color: inherit; opacity: 1; }
@media (min-width: 700px) { .kpis { grid-template-columns: repeat(4, 1fr); } }

/* Pensiero */
.thought { font-family: "Frank Ruhl Libre", serif; font-size: 25px; line-height: 1.35; margin: 6px 0 8px; }
.source { color: var(--muted); font-size: 15px; }
.ex { margin-top: 14px; padding: 14px; border-radius: 16px; background: var(--surface2); }
.ex b { display: block; font-size: 14px; color: var(--accent); margin-bottom: 2px; }
.label { font-size: 14px; font-weight: 700; color: var(--accent); letter-spacing: .02em; }

/* Liste */
.list { display: flex; flex-direction: column; gap: 10px; }
.item { display: flex; align-items: center; gap: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 12px 14px; min-height: 64px; text-decoration: none; color: inherit; cursor: pointer; }
.item .av { width: 42px; height: 42px; flex: none; border-radius: 50%; background: var(--surface2); color: var(--accent); display: grid; place-items: center; font-weight: 700; }
.item .av svg { width: 20px; height: 20px; }
.item .tx { flex: 1; min-width: 0; }
.item .tx b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .tx span { color: var(--muted); font-size: 15px; }
.item .end { text-align: end; font-size: 15px; }

.status { display: inline-block; padding: 3px 12px; border-radius: 999px; font-size: 14px; font-weight: 700; white-space: nowrap; }
.c-green { background: #DDF0D6; color: #2D6A2E; } .c-yellow { background: #FBF0C9; color: #7A5A00; }
.c-red { background: #FBDCD8; color: #9A2B20; } .c-blue { background: #D8EBF8; color: #1D5F8C; }
.c-gray { background: #E8EBE8; color: #555F59; } .c-teal { background: #D4F0EC; color: #1C6B60; }
[data-theme="sera"] .status { filter: saturate(.9) brightness(.95); }

/* Ricerca e filtri */
.search { width: 100%; height: 52px; border-radius: 26px; border: 1px solid var(--line); background: var(--surface); padding: 0 20px; margin-bottom: 10px; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 8px; scrollbar-width: none; }
.chip { flex: none; min-height: 40px; padding: 0 16px; border-radius: 20px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-size: 15px; }
.chip.on { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.tabs { display: flex; gap: 8px; margin: 4px 0 14px; }
.tabs .chip { flex: 1; }

/* Bottoni */
.btn { min-height: 52px; padding: 0 22px; border-radius: 26px; border: 0; background: var(--accent); color: var(--on-accent); font-weight: 700; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; }
.btn.ghost { background: var(--surface2); color: var(--ink); }
.btn.line { background: transparent; border: 1px solid var(--line); color: var(--ink); }
.btn.full { width: 100%; }
.btn svg { width: 20px; height: 20px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row .btn { flex: 1; }
.fab { position: fixed; bottom: 100px; inset-inline-end: 22px; width: 60px; height: 60px; border-radius: 50%; background: var(--accent); color: var(--on-accent); border: 0; box-shadow: var(--shadow); display: grid; place-items: center; cursor: pointer; z-index: 19; text-decoration: none; }
.fab svg { width: 26px; height: 26px; }
@media (min-width: 900px) { .fab { bottom: 30px; } }

/* Moduli */
.form label { display: block; font-weight: 700; margin: 14px 0 6px; font-size: 15px; }
.form input, .form textarea, .form select { width: 100%; min-height: 52px; border-radius: 16px; border: 1px solid var(--line); background: var(--surface); padding: 12px 16px; }
.form textarea { min-height: 96px; resize: vertical; }
.form .err { color: #B03A2E; font-size: 14px; margin-top: 4px; }
.form .tri { display: grid; gap: 8px; }
.form .tri > div { display: flex; gap: 8px; align-items: flex-start; }
.form .tri > div span { flex: none; width: 34px; min-height: 52px; display: grid; place-items: center; font-size: 13px; font-weight: 700; color: var(--muted); }
.opts { display: flex; flex-wrap: wrap; gap: 8px; }
.opts .chip { min-height: 46px; }
.savebar { position: sticky; bottom: 92px; padding: 14px 0; background: linear-gradient(to top, var(--bg) 70%, transparent); }
@media (min-width: 900px) { .savebar { bottom: 0; } }

/* Dettaglio */
.fields { display: grid; gap: 2px; }
.fields div { display: flex; justify-content: space-between; gap: 16px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.fields div:last-child { border-bottom: 0; }
.fields dt { color: var(--muted); } .fields dd { margin: 0; text-align: end; white-space: pre-wrap; }

/* Area partecipante */
.streak { display: flex; align-items: center; gap: 14px; }
.streak b { font-size: 46px; font-family: "Frank Ruhl Libre", serif; color: var(--accent); line-height: 1; }
.dots { display: grid; grid-template-columns: repeat(14, 1fr); gap: 5px; margin-top: 12px; }
.dots i { aspect-ratio: 1; border-radius: 50%; background: var(--surface2); border: 1px solid var(--line); }
.dots i.on { background: var(--accent); border-color: var(--accent); }
.dots i.today { outline: 2px solid var(--accent2); outline-offset: 1px; }
.player { margin-top: 12px; }
.player audio { width: 100%; }
.done-msg { display: flex; align-items: center; gap: 10px; padding: 14px; border-radius: 16px; background: var(--surface2); font-weight: 700; color: var(--accent); }
.grat input { margin-bottom: 8px; }
.gratday { padding: 12px 0; border-bottom: 1px solid var(--line); }
.gratday:last-child { border: 0; }
.gratday ol { margin: 6px 0 0; padding-inline-start: 22px; }

/* Ingresso */
.login { max-width: 460px; margin: 0 auto; padding: 18px; }
.langs { display: flex; gap: 8px; justify-content: center; margin: 6px 0 18px; }
.langs .chip { min-width: 90px; }
.note { font-size: 15px; color: var(--muted); text-align: center; margin-top: 14px; }

/* Avviso */
.toast { position: fixed; bottom: 104px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 12px 18px; border-radius: 16px; z-index: 50; display: flex; gap: 14px; align-items: center; box-shadow: var(--shadow); max-width: 92vw; }
.toast button { background: none; border: 0; color: var(--accent2); font-weight: 700; cursor: pointer; min-height: 40px; }
.empty { text-align: center; padding: 30px 16px; color: var(--muted); }
.empty .btn { margin-top: 12px; }

/* Sentimenti */
.feelbox { margin: 14px 0 6px; padding: 14px; border-radius: 16px; background: var(--surface2); }
.feelbox b { display: block; margin-bottom: 4px; }
.feels .chip { min-height: 42px; }
.feels .chip.neg:not(.on) { background: transparent; }
.shift { margin: 10px 0 0; font-weight: 700; color: var(--accent); }
.done-msg svg, .chip svg { width: 20px; height: 20px; flex: none; vertical-align: middle; }

/* Quaderno dei 21 giorni */
.sentence { font-family: "Frank Ruhl Libre", serif; font-size: 20px; line-height: 1.4; margin: 6px 0 8px; padding: 14px 16px; border-radius: 16px; background: var(--surface2); }
.sentence.big { font-size: 23px; }
.dots.d21 { grid-template-columns: repeat(7, 1fr); max-width: 250px; gap: 7px; }
.dots.d21.small { max-width: 210px; gap: 5px; }
.dots i.half { background: var(--accent2); border-color: var(--accent2); opacity: .55; }
.rules summary { cursor: pointer; min-height: 32px; }
.rules ol, .details { margin: 10px 0 4px; padding-inline-start: 22px; }
.rules li, .details li { margin-bottom: 6px; }
a.item-card { display: block; text-decoration: none; color: inherit; }
.imggrid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.imggrid figure { position: relative; margin: 0; border-radius: 18px; overflow: hidden; aspect-ratio: 1; background: var(--surface2); }
.imggrid img { width: 100%; height: 100%; object-fit: cover; display: block; }
.imgdel { position: absolute; top: 8px; inset-inline-end: 8px; width: 40px; height: 40px; border-radius: 50%; border: 0; background: rgba(255,255,255,.9); color: #333; display: grid; place-items: center; cursor: pointer; }
.imgdel svg { width: 18px; height: 18px; }
.btn:disabled { opacity: .45; cursor: default; }
.form textarea.detail { min-height: 64px; margin-bottom: 8px; }

/* Sveglia */
.alrow { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.alrow label { margin: 0; flex: 1; }
.alrow input[type=time] { width: 130px; flex: none; }
.alrow .chip { min-width: 74px; }
.label svg { width: 18px; height: 18px; vertical-align: -3px; }

/* Immagini del desiderio */
.imggrid img[data-act] { cursor: zoom-in; }
.card.wish img { width: 100%; aspect-ratio: 4 / 5; object-fit: cover; border-radius: 16px; display: block; margin-top: 8px; cursor: zoom-in; max-height: 420px; }
.viewer { position: fixed; inset: 0; z-index: 60; background: #0d1a14; display: flex; flex-direction: column; }
.viewer img { flex: 1; min-height: 0; width: 100%; object-fit: contain; }
.viewer .vtext { padding: 14px 18px 22px; }
.viewer .sentence { background: rgba(255,255,255,.92); color: #1E3829; }
.viewer .btn { width: 100%; }

/* Messaggi privati */
.thread { display: flex; flex-direction: column; gap: 8px; margin: 10px 0 14px; }
.bub { max-width: 82%; padding: 10px 14px; border-radius: 18px; }
.bub p { margin: 0 0 2px; white-space: pre-wrap; }
.bub span { font-size: 12px; opacity: .7; }
.bub.me { align-self: flex-end; background: var(--accent); color: var(--on-accent); border-end-end-radius: 6px; }
.bub.them { align-self: flex-start; background: var(--surface); border: 1px solid var(--line); border-end-start-radius: 6px; }
.msgform { position: sticky; bottom: 92px; background: var(--bg); padding: 8px 0; }
@media (min-width: 900px) { .msgform { bottom: 0; } }
