/* Marsa – stile. Notte di default (si usa la sera), tema chiaro a richiesta. */
:root {
  --bg: #14131c;
  --bg2: #1b1a26;
  --card: #22202f;
  --card2: #2a2839;
  --line: #373449;
  --text: #ece8f3;
  --muted: #aaa4bd;
  --accent: #e9bd78;
  --accent-ink: #1d1608;
  --teal: #86c1bb;
  --rose: #e0a1b4;
  --blue: #9bb4e6;
  --violet: #b9a4e8;
  --danger: #f08a7c;
  --danger-bg: #3a2024;
  --radius: 16px;
  --tabs-h: 64px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  color-scheme: dark;
}
:root[data-theme="giorno"] {
  --bg: #f6f1e8;
  --bg2: #efe8dc;
  --card: #fffdf8;
  --card2: #f3ece0;
  --line: #ddd2c0;
  --text: #2b2733;
  --muted: #6d6678;
  --accent: #9a6420;
  --accent-ink: #ffffff;
  --teal: #2f7a73;
  --rose: #a8466a;
  --blue: #3f63b0;
  --violet: #6b4fb5;
  --danger: #b3382a;
  --danger-bg: #fbe6e2;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 var(--font);
  padding-bottom: calc(var(--tabs-h) + 28px + env(safe-area-inset-bottom));
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.25; margin: 0 0 .5em; }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.1rem; margin-top: 1.4em; }
p { margin: 0 0 1em; }
a { color: var(--accent); }
.small { font-size: .88rem; color: var(--muted); }
.love { text-align: center; font-family: var(--serif); font-size: 1rem; color: var(--muted); margin: 1.4rem 0 0; }
.love .heart { color: var(--accent); }
.center { text-align: center; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 0; background: var(--accent); color: var(--accent-ink); padding: 8px 12px; z-index: 100; }
.skip:focus { left: 8px; top: 8px; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
/* i titoli ricevono il focus solo da script (cambio di schermata): nessun riquadro intorno */
h1[tabindex="-1"], h2[tabindex="-1"], h3[tabindex="-1"], main[tabindex="-1"] { outline: none; }

/* barra in alto */
.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(8px + env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 8px max(16px, env(safe-area-inset-left));
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
}
.brand { display: inline-flex; align-items: center; gap: 8px; color: var(--text); text-decoration: none; font-family: var(--serif); font-size: 1.2rem; font-weight: 600; min-height: 44px; }
.brand svg { color: var(--accent); }
.top-actions { display: flex; gap: 4px; }
.icon-btn {
  width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center;
  background: transparent; border: 0; color: var(--text); border-radius: 50%; cursor: pointer;
}
.icon-btn:hover { background: var(--card); }

main { max-width: 640px; margin: 0 auto; padding: 8px max(16px, env(safe-area-inset-right)) 24px max(16px, env(safe-area-inset-left)); outline: none; }
.view[hidden] { display: none; }
.lede { color: var(--muted); font-size: 1.02rem; }

/* pulsanti */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 8px 18px; border-radius: 999px; border: 0;
  background: var(--accent); color: var(--accent-ink);
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
}
.btn:active { transform: scale(.98); }
.btn[disabled] { opacity: .45; cursor: default; }
.btn-ghost { background: transparent; color: var(--text); border: 1.5px solid var(--line); }
.btn-ghost:hover { background: var(--card); }
.btn-alert { background: var(--danger); color: #1c0b08; margin-top: 12px; }
.btn-block { width: 100%; }
.row-btns { display: flex; gap: 12px; flex-wrap: wrap; margin: 20px 0; }
.row-inline { display: flex; gap: 8px; align-items: center; }
.row-inline input { flex: 1; }

/* campi */
/* iPhone: tocco rapido senza zoom o ritardo, niente selezione di testo sui tasti, campi senza ombra interna */
button, a, summary { touch-action: manipulation; }
button { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
input[type=text], input[type=tel], textarea { -webkit-appearance: none; appearance: none; }
input[type=text], input[type=tel], textarea {
  width: 100%; font: inherit; color: var(--text);
  background: var(--bg2); border: 1.5px solid var(--line); border-radius: 12px;
  padding: 11px 14px; min-height: 48px;
}
textarea { min-height: 84px; resize: vertical; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .8; }
label.campo { display: block; font-weight: 600; margin: 16px 0 6px; }
label.campo small { display: block; font-weight: 400; color: var(--muted); }

/* schede */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 0 0 20px; }
.card h2 { margin-top: 0; }

/* stasera */
.hero { padding: 6px 0 4px; }
.hero .quando { color: var(--muted); font-size: .92rem; margin: 0 0 2px; }
.hero .quando::first-letter, .nota .n-data::first-letter { text-transform: uppercase; }
.hero h1 { font-size: 2rem; margin-bottom: .2em; }
.tema-card { border-left: 5px solid var(--accent); }
.tema-card[data-colore=teal] { border-left-color: var(--teal); }
.tema-card[data-colore=rose] { border-left-color: var(--rose); }
.tema-card[data-colore=blue] { border-left-color: var(--blue); }
.tema-card[data-colore=violet] { border-left-color: var(--violet); }
.tema-card .nome { font-family: var(--serif); font-size: 1.5rem; font-weight: 600; margin: 0; }
.tema-card .sotto { color: var(--muted); margin: 2px 0 0; }
.segui { display: flex; align-items: center; gap: 6px; margin: 0 0 14px; }
.punti { display: flex; gap: 6px; margin: 4px 0 18px; }
.punti i { flex: 1; height: 5px; border-radius: 3px; background: var(--line); }
.punti i.on { background: var(--accent); }
.passo-titolo { font-family: var(--serif); font-size: 1.3rem; margin: 0 0 10px; }
.testo p { font-size: 1.06rem; line-height: 1.65; }
.testo p + p { margin-top: 0; }
.avviso { background: var(--card2); border-radius: 12px; padding: 12px 14px; font-size: .9rem; color: var(--muted); margin: 14px 0; }
.nav-passi { display: flex; gap: 12px; justify-content: space-between; margin-top: 24px; }
.nav-passi .btn { flex: 1; }
.passi-lista { padding-left: 1.2em; margin: 0 0 12px; }
.passi-lista li { margin-bottom: 8px; }
.intro { color: var(--muted); }

/* tensione: tre livelli (stessa forma delle altre risposte) */
.scala-liv { display: grid; gap: 12px; }
.campo-t { font-weight: 600; margin: 20px 0 10px; }
#ben-form { display: grid; gap: 12px; }
#ben-form > * { margin: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 4px; }
.chip {
  min-height: 44px; padding: 6px 16px; border-radius: 999px; border: 1.5px solid var(--line);
  background: transparent; color: var(--text); font: inherit; font-size: .95rem; cursor: pointer;
}
.chip[aria-pressed=true] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }

/* respiro */
.breath { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 8px 0 4px; }
.breath-stage { width: 190px; height: 190px; display: flex; align-items: center; justify-content: center; }
.breath-circle {
  width: 110px; height: 110px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, color-mix(in srgb, var(--accent) 85%, #fff), var(--accent));
  box-shadow: 0 0 40px color-mix(in srgb, var(--accent) 45%, transparent);
  transform: scale(1);
  display: flex; align-items: center; justify-content: center;
  color: var(--accent-ink); font-weight: 700; font-size: 1.5rem; font-family: var(--serif);
}
.breath-label { font-size: 1.1rem; min-height: 1.6em; color: var(--text); text-align: center; }
.breath-time { color: var(--muted); font-size: .9rem; }

/* buonanotte */
.chiusura-frase { font-family: var(--serif); font-size: 1.5rem; line-height: 1.4; text-align: center; padding: 18px 8px; color: var(--accent); }
.audio-box audio { width: 100%; margin-top: 8px; }
.fatto { text-align: center; padding: 10px 0; }

/* elenco sere */
.sere-lista { display: grid; gap: 12px; margin-top: 16px; }
.sera-item {
  display: flex; align-items: center; gap: 14px; text-align: left; width: 100%;
  padding: 14px 16px; border-radius: var(--radius); border: 1px solid var(--line);
  background: var(--card); color: var(--text); font: inherit; cursor: pointer; min-height: 72px;
}
.sera-item:hover { background: var(--card2); }
.sera-item .gg { min-width: 5.2em; font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.sera-item .nm { font-family: var(--serif); font-size: 1.15rem; font-weight: 600; display: block; }
.sera-item .st { font-size: .9rem; color: var(--muted); }
.sera-item.oggi { border-color: var(--accent); }
.sera-item.oggi .gg { color: var(--accent); font-weight: 700; }

/* diario */
.nota { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); margin: 0 0 12px; }
.nota summary { cursor: pointer; padding: 14px 16px; list-style: none; display: flex; justify-content: space-between; gap: 12px; align-items: center; min-height: 56px; }
.nota summary::-webkit-details-marker { display: none; }
.nota .n-data { font-size: .85rem; color: var(--muted); }
.nota .n-tema { font-family: var(--serif); font-size: 1.1rem; font-weight: 600; }
.nota .n-corpo { padding: 0 16px 14px; }
.nota dt { font-weight: 600; margin-top: 10px; font-size: .92rem; color: var(--muted); }
.nota dd { margin: 2px 0 0; white-space: pre-wrap; }
.nota .n-umore { color: var(--accent); font-weight: 600; white-space: nowrap; }
.vuoto { text-align: center; color: var(--muted); padding: 28px 8px; }

/* barra in basso */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 25;
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  background: color-mix(in srgb, var(--bg2) 94%, transparent); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
  padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
.tabs a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: var(--tabs-h); color: var(--muted); text-decoration: none; font-size: .78rem; }
.tabs a[aria-current=page] { color: var(--accent); }
.tabs a[hidden] { display: none; }

/* finestre */
dialog {
  border: 0; padding: 0; border-radius: 20px; width: min(560px, calc(100vw - 20px)); max-height: calc(100dvh - 24px);
  background: var(--bg2); color: var(--text); box-shadow: 0 20px 60px rgba(0,0,0,.55); overscroll-behavior: contain;
}
dialog::backdrop { background: rgba(5,4,10,.7); }
.dlg-in { padding: 20px 20px 24px; }
.dlg-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.dlg-head h2 { margin: 0; }
.alert { background: var(--danger-bg); border: 1px solid var(--danger); border-radius: 14px; padding: 14px 16px; margin: 0 0 14px; }
.alert strong { color: var(--danger); display: block; }

.acc { background: var(--card); border: 1px solid var(--line); border-radius: 14px; margin: 0 0 12px; }
.acc summary { cursor: pointer; padding: 12px 16px; font-weight: 600; list-style: none; min-height: 48px; display: flex; align-items: center; }
.acc summary::-webkit-details-marker { display: none; }
.acc summary::after { content: "＋"; margin-left: auto; color: var(--muted); }
.acc[open] summary::after { content: "－"; }
.acc-body { padding: 0 16px 14px; }
.acc-body ul, .acc-body ol { padding-left: 1.2em; margin: 0 0 10px; }
.five { list-style: none; padding: 0 !important; }
.five li { padding: 6px 0; }
.five b { display: inline-block; min-width: 1.4em; color: var(--accent); font-family: var(--serif); font-size: 1.15rem; }
.contatto { display: flex; align-items: center; gap: 8px; padding: 6px 0; }
.contatto .chiama { flex: 1; display: flex; flex-direction: column; text-decoration: none; color: var(--text); min-height: 44px; justify-content: center; }
.contatto .chiama span { color: var(--muted); font-size: .88rem; }
.contatto .del { color: var(--muted); }
.contatti-form { display: grid; gap: 12px; margin-top: 12px; }
.numero { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.numero:last-child { border-bottom: 0; }
.numero small { display: block; color: var(--muted); }

@media (prefers-reduced-motion: reduce) {
  .breath-circle { transition: none !important; }
  .btn:active { transform: none; }
}
@media (min-width: 700px) {
  body { font-size: 18px; }
}
@media print {
  .top, .tabs { display: none; }
}

/* domande a scelta multipla */
.quiz .sotto { color: var(--muted); font-size: .85rem; margin: 0 0 4px; }
.quiz-dom { font-family: var(--serif); font-size: 1.12rem; line-height: 1.5; margin: 0 0 12px; }
.quiz-opz { display: grid; gap: 12px; }
.quiz-o, .liv {
  display: block; width: 100%; text-align: left; min-height: 44px; padding: 10px 14px;
  border-radius: 14px; border: 1.5px solid var(--line); background: transparent; color: var(--text);
  font: inherit; line-height: 1.4; cursor: pointer;
}
.quiz-o:hover, .liv:hover { background: var(--card2); }
.quiz-o[aria-pressed=true], .liv[aria-pressed=true] { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, transparent); font-weight: 600; }
.quiz-spieg:empty { display: none; }
.quiz-spieg { margin-top: 16px; padding: 12px 14px; border-radius: 12px; background: var(--card2); border-left: 4px solid var(--accent); }
.quiz-sp + .quiz-sp { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.quiz-sp b { display: block; margin-bottom: 2px; }
.quiz-sp p { margin: 0; line-height: 1.55; }
.quiz-spieg .chip { margin-top: 12px; border-color: var(--danger); color: var(--danger); }
.riepilogo { text-align: left; margin: 16px 0; padding: 14px 16px; border-radius: 12px; background: var(--card2); border-left: 4px solid var(--teal); }
.riepilogo .sotto { margin: 0 0 6px; color: var(--muted); font-size: .85rem; }
.riepilogo p { line-height: 1.55; }

/* Arrivo: piccolo passo, fonte, rimandi alle altre app */
.quiz-passo { margin: 10px 0 0 !important; }
.quiz-sp .breath { margin-top: 12px; }
.quiz-sp .btn { margin-top: 12px; }
.quiz-q + .quiz-q { margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--line); }
.card.quiz .intro { margin: 0 0 14px; }
.app-link-list { display: grid; gap: 12px; }
.app-link { display: block; padding: 12px 14px; border-radius: 12px; border: 1.5px solid var(--line); text-decoration: none; color: var(--text); }
.app-link b { display: block; font-family: var(--serif); font-size: 1.1rem; color: var(--accent); }
.app-link span { color: var(--muted); font-size: .92rem; }
/* profilo personale («Per te») */
.quiz-perte { margin: 10px 0 0 !important; padding: 10px 12px; border-radius: 10px; background: color-mix(in srgb, var(--teal) 14%, transparent); border-left: 3px solid var(--teal); }
.perte-sum { flex-wrap: wrap; gap: 2px 12px; }
.perte-sum small { display: block; width: 100%; font-weight: 400; color: var(--muted); }
.perte-h { margin-top: 28px; }
#profilo-box { margin: 0 0 12px; }
#profilo-box textarea { margin-bottom: 12px; }
/* scelta del momento della giornata (mattina, pomeriggio, sera, notte) */
.momenti { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 10px 0 4px; }
.momento { min-height: 44px; padding: 0 4px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--card); color: var(--text); font: inherit; font-size: .875rem; font-weight: 600; cursor: pointer; touch-action: manipulation; }
.momento[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.tre-minuti { text-align: center; margin-top: 12px; }
.tre-minuti .punti { justify-content: center; }
.tm-titolo { font-family: var(--serif); font-size: 1.25rem; font-weight: 600; margin: 0 0 6px; min-height: 1.4em; }
.tm-testo { margin: 0 0 12px; }
.tema-card[data-colore=amber] { border-left-color: var(--accent); }
/* Le fonti: sempre piccole e in corsivo, ovunque compaiano. */
.fonte { margin: 10px 0 0; font-size: .76rem; line-height: 1.45; font-style: italic; color: var(--muted); }
/* Illustrazioni (fascia 2:1): a filo in cima alla scheda; nel tema scuro un po' abbassate, per non abbagliare. */
.tema-card, .dlg-in { overflow: hidden; }
.fascia { margin: -16px -16px 14px; aspect-ratio: 2 / 1; background: var(--line); overflow: hidden; }
.fascia img { display: block; width: 100%; height: 100%; object-fit: cover; }
.dlg-in > .fascia { margin: -20px -20px 16px; }
.fascia.fascia-piccola { margin: 0 0 12px; border-radius: 12px; }
:root:not([data-theme="giorno"]) .fascia img { filter: brightness(.86) saturate(.92); }

/* Rimandi a Diario GET (sotto una scena e a fine serata) */
.rimando { display: flex; align-items: center; min-height: 44px; margin-top: 12px; font-size: .9rem; font-weight: 600; text-decoration: none; }
.ponte-get { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.ponte-get .rimando { margin-top: 4px; }
