/* Misure prese dallo screenshot di Planner giornaliero (iPhone, 390 punti di larghezza, 01/10/2026).
   --k ingrandisce tutto sugli schermi larghi. */
:root {
  --sfondo: #000;
  --carta: #dde1eb;
  --testa-g: #f1f3f7;      /* intestazione di ogni giorno */
  --foglio: #f6f7f8;       /* corpo di ogni giorno */
  --linea-testa: #bcc2ca;
  --puntino: #9a9b9e;
  --inchiostro: #000;
  --tenue: #6b7080;
  --bordo: #c9ccd5;
  --rosso: #dd4243;
  --rosso-scheda: #ed4848;
  --barra: #101117;
  --spirale: #292929;
  --font: ui-rounded, "SF Pro Rounded", "Nunito", system-ui, -apple-system, sans-serif;
  --k: 1;
  --r: calc(14px * var(--k));      /* altezza di una riga */
  --fs: calc(12.5px * var(--k));   /* testo dei giorni (SF Rounded 12,5 come l'originale) */
  --gap: calc(16px * var(--k));    /* spazio tra i giorni */
  color-scheme: light;
}
@media (min-width: 900px) { :root { --k: 1.35; } }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--sfondo);
  color: var(--inchiostro);
  font-family: var(--font);
  display: flex; flex-direction: column;
  height: 100dvh;
  overflow: hidden;
  overscroll-behavior: none;
  padding-top: max(env(safe-area-inset-top), 12px);
}
/* Contro la sfocatura di iOS 26+ in cima all'app dalla Home. WebKit non sfoca se in cima c'è un
   riquadro fisso, opaco, largo almeno il 90% e alto più di 10 punti: ne usa il colore
   (LocalFrameView::fixedContainerEdges, thinBorderWidth = 10). Il riquadro è nero come la barra di
   stato, alto quanto la barra (se la pagina ci passa sotto) e comunque almeno 12 punti. */
#tetto { position: fixed; top: 0; left: 0; right: 0; height: max(env(safe-area-inset-top), 12px); background: #000; z-index: 30; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
svg { fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }

#vista { flex: 1; min-height: 0; position: relative; }

/* ---------- quaderno: due pagine che si toccano al centro ---------- */
.quaderno {
  position: relative;
  height: 100%;
  display: grid; grid-template-columns: 1fr 1fr;
  max-width: calc(390px * var(--k) * 1.6); margin: 0 auto;
}
.pagina {
  background: var(--carta);
  display: flex; flex-direction: column;
  min-height: 0; min-width: 0;
}
/* gli angoli verso il dorso sono curvi: in alto e in basso si apre la piega nera tra le pagine */
.pagina.sx { border-radius: 0 calc(17px * var(--k)) calc(15px * var(--k)) 0; padding: 0 calc(16px * var(--k)) 0 calc(10px * var(--k)); }
.pagina.dx { border-radius: calc(17px * var(--k)) 0 0 calc(15px * var(--k)); padding: 0 calc(10px * var(--k)) 0 calc(16px * var(--k)); }
.pagina.sola { height: 100%; max-width: calc(560px * var(--k)); margin: 0 auto; width: 100%; padding: 0 calc(10px * var(--k)); }
.vista-sola { height: 100%; }

.dorso {
  position: absolute; left: 50%; transform: translateX(-50%);
  top: calc(41px * var(--k)); bottom: calc(9px * var(--k));
  width: calc(12px * var(--k));
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='11' viewBox='0 0 12 11'%3E%3Cpath d='M2.3 7.4V5.9a3.7 3.7 0 0 1 7.4 0v1.5' fill='none' stroke='%23292929' stroke-width='2.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: repeat-y;
  background-size: 100% calc(11px * var(--k));
  pointer-events: none;
}
body.senza-dorso .dorso { display: none; }

/* ---------- intestazione in alto ---------- */
.testata {
  height: calc(40px * var(--k)); flex: none;
  display: flex; align-items: center; gap: calc(8px * var(--k));
  padding-left: calc(4px * var(--k));
}
.testata.destra { justify-content: flex-end; gap: calc(14px * var(--k)); padding: 0; }
.oggi {
  position: relative;
  background: var(--rosso); color: #fff;
  width: calc(37px * var(--k)); height: calc(31px * var(--k)); border-radius: calc(7px * var(--k));
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding-left: calc(9px * var(--k));
  line-height: 1; flex: none;
}
.oggi svg { position: absolute; left: calc(3px * var(--k)); top: 50%; transform: translateY(-50%); width: calc(8px * var(--k)); height: calc(14px * var(--k)); stroke-width: 2.2; }
.oggi small { font-size: calc(9px * var(--k)); }
.oggi b { font-size: calc(14px * var(--k)); font-weight: 600; margin-top: calc(1px * var(--k)); }
.icona { position: relative; width: calc(24px * var(--k)); height: calc(24px * var(--k)); display: grid; place-items: center; flex: none; }
.icona svg { width: calc(22px * var(--k)); height: calc(22px * var(--k)); stroke-width: 1.8; }
.testata.destra .icona svg { width: calc(20px * var(--k)); height: calc(20px * var(--k)); stroke-width: 2.1; }
.titolo { line-height: 1.15; white-space: nowrap; overflow: hidden; min-width: 0; padding-left: calc(1px * var(--k)); }
.titolo b { font-size: calc(13px * var(--k)); font-weight: 500; display: block; }
.titolo small { font-size: calc(9px * var(--k)); }
.frecce { display: none; gap: 6px; margin-right: auto; }
@media (hover: hover) and (pointer: fine) { .frecce { display: flex; } }

/* ---------- caselle dei giorni ---------- */
.caselle { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: var(--gap); padding-bottom: calc(8px * var(--k)); }
.caselle > * { flex: 1 1 0; min-height: 0; }
.coppia { display: flex; flex-direction: column; gap: var(--gap); }
.coppia > .g { flex: 1 1 0; }

.g {
  position: relative;
  background: var(--foglio);
  border-radius: calc(9px * var(--k));
  display: flex; flex-direction: column;
  min-height: 0; overflow: hidden;
  font-size: var(--fs);
}
/* in fondo a ogni giorno il grigio sfuma nel bianco, come nell'originale */
.g::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: calc(18px * var(--k));
  background: linear-gradient(rgba(254,254,254,0), rgba(254,254,254,.95));
  pointer-events: none;
}
.g-testa {
  flex: none;
  display: flex; align-items: center; justify-content: space-between;
  height: calc(22px * var(--k));
  padding: 0 calc(8px * var(--k)) 0 calc(9px * var(--k));
  background: var(--testa-g);
  border-bottom: 1px solid var(--linea-testa);
  font-size: calc(13.5px * var(--k));
  white-space: nowrap;
}
.g-testa b { font-weight: 600; }
.g-testa .apri, .g-testa .quad { width: calc(20px * var(--k)); height: calc(20px * var(--k)); display: grid; place-items: center; color: #222; }
.g-testa .apri svg { width: calc(12px * var(--k)); height: calc(12px * var(--k)); stroke-width: 2; }
.g-testa .quad { display: none; }
.g-testa .quad svg { width: calc(15px * var(--k)); height: calc(15px * var(--k)); stroke-width: 2; }
.g.scrivendo .g-testa .apri { display: none; }
.g.scrivendo .g-testa .quad { display: grid; }

.righe {
  flex: 1; min-height: 0;
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 0 calc(6.5px * var(--k));
  line-height: var(--r);
  scrollbar-width: none;
  display: flex; flex-direction: column;
  background-image: radial-gradient(circle, var(--puntino) 0.55px, transparent 0.95px);
  background-size: calc(3px * var(--k)) var(--r);
  background-position: 0 calc(var(--r) / 2 - 0.5px);
  background-attachment: local;
}
.testo {
  flex: 1 0 auto;
  outline: none;
  overflow-wrap: anywhere;
  -webkit-user-select: text; user-select: text;
  cursor: text;
  padding-bottom: var(--r);
}
.testo > div { min-height: var(--r); }
.righe::-webkit-scrollbar { display: none; }
.testo > div.c { position: relative; padding-left: calc(var(--fs) * 1.39); }
.testo > div.c::before {
  content: ""; position: absolute; left: calc(var(--fs) * -0.04); top: calc((var(--r) - var(--fs) * 0.83) / 2);
  width: calc(var(--fs) * 0.83); height: calc(var(--fs) * 0.83); box-sizing: border-box;
  border: calc(var(--fs) * 0.12) solid var(--inchiostro); border-radius: calc(var(--fs) * 0.2);
  background: center / 80% no-repeat;
}
.testo > div.c[data-f="1"]::before {
  background-color: var(--inchiostro);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5' fill='none' stroke='%23fff' stroke-width='3.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

/* giorno a tutta pagina */
.g.grande { --r: calc(21px * var(--k)); --fs: calc(15.5px * var(--k)); flex: 1; margin-bottom: calc(10px * var(--k)); }
.g.grande .g-testa { height: calc(30px * var(--k)); font-size: calc(16px * var(--k)); }
.g.grande .righe { padding: 0 calc(10px * var(--k)); }

/* ---------- appunti ---------- */
.appunti {
  flex: 1; min-height: 0; margin-bottom: 10px;
  background: var(--foglio); border-radius: calc(9px * var(--k));
  display: flex;
}
.appunti textarea {
  --r: calc(21px * var(--k));
  flex: 1; width: 100%;
  font: inherit; font-size: calc(15.5px * var(--k)); line-height: var(--r); color: inherit;
  border: 0; outline: none; resize: none;
  padding: 6px 10px 40px;
  background-color: transparent;
  background-image: radial-gradient(circle, var(--puntino) 0.55px, transparent 0.95px);
  background-size: 3px var(--r);
  background-position: 0 calc(6px + var(--r) / 2 - 0.5px);
  background-attachment: local;
  border-radius: calc(9px * var(--k));
}

/* ---------- impostazioni ---------- */
.lista { background: var(--foglio); border-radius: calc(9px * var(--k)); margin: 4px 0 12px; }
.lista .voce {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: 52px; padding: 8px 14px; font-size: 17px;
}
.lista .voce + .voce { border-top: 1px solid var(--bordo); }
.lista .voce small { display: block; font-size: 13px; color: var(--tenue); }
.lista a.pulsante, .lista button.pulsante {
  background: var(--inchiostro); color: #fff; text-decoration: none;
  border-radius: 10px; padding: 8px 14px; font-size: 15px; white-space: nowrap;
}
.interruttore { position: relative; width: 51px; height: 31px; flex: none; }
.interruttore input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.interruttore span { position: absolute; inset: 0; border-radius: 16px; background: #c7c9d1; transition: background .2s; pointer-events: none; }
.interruttore span::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .2s;
}
.interruttore input:checked + span { background: #34c759; }
.interruttore input:checked + span::after { transform: translateX(20px); }
.nota { color: var(--tenue); font-size: 13px; padding: 0 6px; }
.pagina h2 { font-size: calc(13px * var(--k)); font-weight: 500; margin: 0; }

/* ---------- schede in basso ---------- */
#schede {
  flex: none;
  background: var(--barra);
  display: grid; grid-template-columns: repeat(4, 1fr);
  padding-bottom: env(safe-area-inset-bottom);
}
#schede button { position: relative; height: 49px; display: grid; place-items: center; color: #f2f2f2; }
#schede svg { width: 28px; height: 28px; stroke-width: 1.8; }
#schede button.attiva { color: var(--rosso-scheda); }
#schede button.attiva::before {
  content: ""; position: absolute; top: 0; left: 50%; transform: translateX(-50%);
  width: 66px; height: 2.5px; background: var(--rosso-scheda);
}
body.fuori #schede { display: none; }

/* ---------- fogli (menu e ricerca) ---------- */
.foglio { position: fixed; inset: 0; z-index: 10; background: rgba(0,0,0,.35); display: flex; align-items: flex-end; }
.foglio[hidden] { display: none; }
.foglio-dentro {
  width: 100%; max-width: 480px; margin: 0 auto;
  background: #f2f2f7; border-radius: 16px 16px 0 0;
  padding: 10px 12px calc(12px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 8px;
}
.foglio-titolo { margin: 4px 6px; font-size: 14px; color: var(--tenue); text-align: center; overflow-wrap: anywhere; }
.foglio-dentro button, .foglio-dentro .bottone {
  position: relative; display: block; width: 100%;
  background: #fff; border-radius: 12px; height: 50px; line-height: 50px;
  font-size: 17px; text-align: center; cursor: pointer;
}
.foglio-dentro .bottone input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; -webkit-appearance: none; appearance: none; border: 0; }
.foglio-dentro .rosso { color: var(--rosso); }
.foglio-dentro .annulla { font-weight: 600; margin-top: 4px; }
.foglio-dentro [hidden] { display: none; }

/* ---------- grassetto ed evidenziatore in alto a destra ---------- */
.formati-posto { display: flex; gap: calc(14px * var(--k)); opacity: .3; }
.formati-posto svg { width: calc(20px * var(--k)); height: calc(20px * var(--k)); margin: calc(2px * var(--k)); }
body.scrivendo .formati-posto { visibility: hidden; }
#formati {
  position: fixed; z-index: 24; display: flex; gap: calc(14px * var(--k));
  padding: 5px 9px; border-radius: 14px;
}
#formati[hidden] { display: none; }
#formati svg { width: calc(20px * var(--k)); height: calc(20px * var(--k)); }
#formati.galleggia { background: rgba(255,255,255,.96); box-shadow: 0 3px 14px rgba(0,0,0,.2); }
#tavolozza {
  position: absolute; top: calc(100% + 8px); right: 0; z-index: 25; display: flex; gap: 10px; padding: 9px 11px;
  background: #fff; border-radius: 22px; box-shadow: 0 4px 18px rgba(0,0,0,.18);
}
#tavolozza[hidden] { display: none; }
#tavolozza button { width: 26px; height: 26px; border-radius: 50%; border: 1px solid rgba(0,0,0,.12); }
#tavolozza .togli { background: #fff linear-gradient(135deg, transparent 46%, #dd4243 46%, #dd4243 54%, transparent 54%); }

/* ---------- vista dei mesi: misure dallo screenshot di Planner giornaliero ---------- */
#mesi {
  position: fixed; inset: 0; z-index: 12;
  background: rgba(0,0,0,.4);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}
#mesi[hidden] { display: none; }
.mesi-carta {
  position: absolute; top: 16px; bottom: 50px; left: 50%; transform: translateX(-50%);
  width: min(317px, calc(100% - 32px));
  background: #f5f7f9; border-radius: 17px; overflow: hidden;
  display: flex; flex-direction: column;
  font-family: -apple-system, system-ui, sans-serif; color: #0b0c13;
}
.mesi-chiudi { position: absolute; top: 9px; right: 9px; width: 24px; height: 24px; display: grid; place-items: center; }
.mesi-chiudi svg { width: 15px; height: 15px; stroke-width: 2.4; }
.mesi-lettere {
  flex: none; height: 72px; padding-top: 40px;
  display: grid; grid-template-columns: repeat(7, 1fr); align-items: start;
  font-size: 9.5px; font-weight: 600; text-align: center;
}
.mesi-lettere .festa { color: #8e908f; }
#mesi-scorri { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
#mesi-scorri::-webkit-scrollbar { display: none; }
.mese h3 { margin: 0; height: 64px; line-height: 64px; text-align: center; font-size: 24px; font-weight: 700; }
.mese-griglia { display: grid; grid-template-columns: repeat(7, 1fr); }
.mese-griglia > * { height: 70px; }
.mese-griglia button {
  position: relative; border-top: 1px solid #d0d2d4;
  display: flex; flex-direction: column; align-items: center;
  font-size: 17.5px; font-weight: 400; color: #0b0c13;
}
.mese-griglia button.festa { color: #b2b4b3; }
.mese-griglia button b { font-weight: 400; margin-top: 12px; line-height: 1.2; }
.mese-griglia button i { position: absolute; top: 45px; left: 50%; transform: translateX(-50%); width: 8.5px; height: 8.5px; border-radius: 50%; }
.mese-griglia button.pieno i { background: #a8abaa; }

#ricerca { align-items: stretch; background: #f2f2f7; }
.ricerca-dentro { width: 100%; max-width: 760px; margin: 0 auto; display: flex; flex-direction: column; min-height: 0; }
.ricerca-barra { display: flex; gap: 10px; align-items: center; padding: 10px 12px; }
.ricerca-barra input {
  flex: 1; font: inherit; font-size: 17px; padding: 9px 12px;
  border: 0; border-radius: 10px; background: #e3e4ea; outline: none;
}
.ricerca-barra button { color: var(--rosso); font-size: 17px; }
#ricerca-risultati { list-style: none; margin: 0; padding: 0 12px 20px; overflow-y: auto; flex: 1; }
#ricerca-risultati li { background: #fff; border-radius: 12px; padding: 10px 12px; margin-bottom: 8px; cursor: pointer; font-size: 16px; }
#ricerca-risultati li small { display: block; color: var(--tenue); font-size: 13px; margin-bottom: 2px; }
#ricerca-risultati li.niente { background: none; color: var(--tenue); text-align: center; cursor: default; }
#ricerca-risultati mark { background: #ffe58a; color: inherit; border-radius: 3px; }

#avviso {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(70px + env(safe-area-inset-bottom)); z-index: 20;
  background: #2c2c2e; color: #fff; padding: 9px 16px; border-radius: 20px; font-size: 14px;
  max-width: 90vw; text-align: center;
}

/* ---------- entrata ---------- */
.entra { height: 100%; display: grid; place-items: center; padding: 20px; }
.entra form {
  background: var(--carta); border-radius: 22px; padding: 28px 22px;
  width: 100%; max-width: 340px; display: flex; flex-direction: column; gap: 12px;
}
.entra h1 { margin: 0 0 6px; font-size: 28px; font-weight: 700; text-align: center; }
.entra input { font: inherit; font-size: 17px; padding: 12px 14px; border: 0; border-radius: 12px; background: #fff; outline: none; }
.entra button { background: var(--rosso); color: #fff; border-radius: 12px; height: 48px; font-size: 17px; font-weight: 600; }
.entra .errore { margin: 0; min-height: 1.2em; color: var(--rosso); text-align: center; font-size: 14px; }
