/* Tutti i colori di Care. Un tema = un blocco [data-theme] che sovrascrive le variabili. */
:root,
[data-theme="barbie"] {
  --bg: #FFF5F8;
  --primary: #F7C6D9;
  --accent: #F29BBF;
  --text: #3A2A33;
  --text-soft: #7A6670;
  --card: #FFFFFF;
  --header-text: #FFFFFF;
  --shadow: 0 4px 16px rgba(58, 42, 51, 0.08);
}

[data-theme="triste"] {
  --bg: #121826;
  --primary: #2C3E66;
  --accent: #7FA3D9;
  --text: #E6ECF5;
  --text-soft: #A9B6CC;
  --card: #1E2740;
  --header-text: #E6ECF5;
  --shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
}

[data-theme="strega-autunnale"] {
  --bg: #FBF3E4;
  --primary: #C8A27A;
  --accent: #E07B39;
  --text: #4A3222;
  --text-soft: #8A6B55;
  --card: #FFFAF0;
  --header-text: #FFFAF0;
  --shadow: 0 4px 16px rgba(74, 50, 34, 0.12);
}

:root {
  --radius: 22px;
  --radius-small: 14px;
  --tab-height: 64px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
  font-size: 17px;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
  transition: background 0.3s, color 0.3s;
}

/* Intestazione rosa con il logo in corsivo */
.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--primary);
  padding: calc(env(safe-area-inset-top) + 12px) 20px 14px;
  border-radius: 0 0 var(--radius) var(--radius);
  box-shadow: var(--shadow);
  text-align: center;
}

.logo {
  margin: 0;
  color: var(--header-text);
  font-family: "Snell Roundhand", "Brush Script MT", "Segoe Script", cursive;
  font-size: 40px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

main {
  padding: 18px 16px calc(var(--tab-height) + env(safe-area-inset-bottom) + 24px);
  max-width: 640px;
  margin: 0 auto;
}

.tab {
  display: none;
}

.tab.active {
  display: block;
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
  margin-bottom: 16px;
}

.card h2 {
  margin: 0 0 6px;
  font-size: 20px;
}

.card p {
  margin: 0;
}

.placeholder {
  text-align: center;
  padding: 32px 20px;
}

.emoji {
  font-size: 44px;
  margin-bottom: 8px !important;
}

.hint {
  color: var(--text-soft);
  font-size: 15px;
  margin-bottom: 12px !important;
}

/* Selettore del tema */
.theme-picker {
  display: grid;
  gap: 10px;
}

.theme-option {
  font: inherit;
  text-align: left;
  padding: 12px 16px;
  border-radius: var(--radius-small);
  border: 2px solid transparent;
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
}

.theme-option.selected {
  border-color: var(--accent);
  font-weight: 600;
}

/* Barra delle schede in basso */
.tab-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10;
  display: flex;
  justify-content: space-around;
  background: var(--card);
  padding: 6px 8px calc(env(safe-area-inset-bottom) + 6px);
  border-radius: var(--radius) var(--radius) 0 0;
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.06);
}

.tab-button {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-height: 52px;
  font: inherit;
  font-size: 12px;
  color: var(--text-soft);
  background: none;
  border: none;
  border-radius: var(--radius-small);
  cursor: pointer;
}

.tab-button span {
  font-size: 22px;
}

.tab-button.active {
  color: var(--text);
  font-weight: 600;
  background: var(--bg);
}

/* Pagina di accesso */
.login-card {
  max-width: 380px;
  margin: 40px auto 0;
  text-align: center;
}

.login-card input {
  width: 100%;
  margin: 12px 0;
  padding: 14px 16px;
  border: 2px solid var(--primary);
  border-radius: var(--radius-small);
  background: var(--bg);
  color: var(--text);
  font: inherit;
}

.login-card input:focus {
  outline: none;
  border-color: var(--accent);
}

.login-button {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: var(--radius-small);
  background: var(--accent);
  color: #FFFFFF;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow);
}

.login-error {
  margin: 12px 0 0;
  color: var(--accent);
  font-weight: 600;
}

/* Chat di carico */
.chat-messages {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-bottom: 80px; /* spazio per il campo di testo */
}

.bubble {
  max-width: 80%;
  padding: 10px 14px;
  border-radius: 20px;
  box-shadow: var(--shadow);
  white-space: pre-wrap;
  word-wrap: break-word;
}

.bubble.care {
  align-self: flex-start;
  background: var(--card);
  border-bottom-left-radius: 6px;
}

.bubble.user {
  align-self: flex-end;
  background: var(--primary);
  border-bottom-right-radius: 6px;
}

/* Messaggio in coda, non ancora inviato */
.bubble.pending {
  opacity: 0.6;
}

.bubble.pending::after {
  content: " ⏳";
}

.item-card {
  align-self: flex-start;
  width: 85%;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 14px;
  background: var(--card);
  border: 2px dashed var(--primary);
  border-radius: var(--radius-small);
}

.item-card.saved {
  border-style: solid;
}

.item-info {
  display: flex;
  flex-direction: column;
}

.item-info span {
  color: var(--text-soft);
  font-size: 14px;
}

.item-buttons {
  display: flex;
  gap: 8px;
  color: var(--text-soft);
  font-size: 14px;
}

.item-buttons button {
  flex: 1;
  padding: 8px;
  border: none;
  border-radius: var(--radius-small);
  font: inherit;
  cursor: pointer;
}

.item-save {
  background: var(--accent);
  color: #FFFFFF;
  font-weight: 600;
}

.item-discard {
  background: var(--bg);
  color: var(--text);
}

.chat-form {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(var(--tab-height) + env(safe-area-inset-bottom) + 8px);
  z-index: 9;
  display: flex;
  gap: 8px;
  max-width: 640px;
  margin: 0 auto;
  padding: 0 16px;
}

.chat-form textarea {
  flex: 1;
  resize: none;
  padding: 12px 16px;
  border: 2px solid var(--primary);
  border-radius: 22px;
  background: var(--card);
  color: var(--text);
  font: inherit;
  box-shadow: var(--shadow);
}

.chat-form textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.chat-send {
  /* sempre tonda, anche se il messaggio va su più righe */
  flex: 0 0 auto;
  align-self: flex-end;
  width: 42px;
  height: 42px;
  margin-bottom: 2px;
  border: none;
  border-radius: 50%;
  background: var(--accent);
  color: #FFFFFF;
  font-size: 17px;
  cursor: pointer;
  box-shadow: var(--shadow);
}

.switch-row { display: flex; align-items: center; gap: 10px; }
.chat-mic {
  flex: 0 0 auto;
  align-self: flex-end;
  width: 42px;
  height: 42px;
  margin-bottom: 2px;
  border: none;
  border-radius: 50%;
  background: var(--pink-soft, #FFDBE0);
  color: var(--text);
  font-size: 17px;
  cursor: pointer;
  box-shadow: var(--shadow);
}

.chat-mic.listening {
  animation: mic-pulse 1.2s ease-in-out infinite;
}

@keyframes mic-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

.item-card.undone {
  opacity: 0.5;
}

.item-saved-label {
  flex: 1;
  align-self: center;
}

/* Avviso discreto (piano B, rilettura) */
.chat-notice {
  align-self: center;
  color: var(--text-soft);
  font-size: 13px;
  text-align: center;
  padding: 0 12px;
}

.heart-chat-button {
  align-self: flex-start;
  padding: 10px 16px;
  border: none;
  border-radius: 20px;
  background: var(--primary);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow);
}

.bubble.thinking {
  color: var(--text-soft);
  font-style: italic;
}

/* Orsetto Care (riferimento: docs/ispirazioni/care-riferimento.jpg).
   Pelo rosa cipria con sfumatura; ogni umore cambia un po' il colore (mai fucsia). */
.bear {
  --bear-fur: #EFBCC5;
  --bear-fur-light: #FADDE2;
  --bear-cheek: #EE9EAE;
  --bear-ink: #4A2C22;
  width: 100%;
  height: 100%;
}

.bear[data-mood="arrabbiato"] { --bear-fur: #EDA6B8; --bear-fur-light: #F8C9D4; --bear-cheek: #EC7F9A; }
.bear[data-mood="triste"]     { --bear-fur: #D6C3E3; --bear-fur-light: #EBE0F3; --bear-cheek: #C4A9DA; }
.bear[data-mood="orgoglioso"] { --bear-fur: #F2B2BF; --bear-fur-light: #FCD6DE; --bear-cheek: #F08FA5; }
.bear[data-mood="assonnato"]  { --bear-fur: #DAD5EA; --bear-fur-light: #EEEBF6; --bear-cheek: #CBC2E2; }
.bear[data-mood="sorpreso"]   { --bear-fur: #F1C0CB; --bear-fur-light: #FCE1E7; --bear-cheek: #EF9DB1; }

.bear svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

.bear .stop-fur       { stop-color: var(--bear-fur); transition: stop-color 0.6s; }
.bear .stop-fur-light { stop-color: var(--bear-fur-light); transition: stop-color 0.6s; }
.bear .ear-inner  { fill: #F3DDC8; }
.bear .stitch     { fill: none; stroke: #D8B99F; stroke-width: 1.5; stroke-dasharray: 3 3; }
.bear .cheek      { fill: var(--bear-cheek); opacity: 0.35; transition: fill 0.6s; }
.bear .cheek.puffed { opacity: 0.6; }
.bear .nose       { fill: #E6A0AC; }
.bear .eye-rim    { fill: #0B0809; }
.bear .pupil      { fill: #050304; }
.bear .shine      { fill: #FFFFFF; }
.bear .brow       { fill: none; stroke: #B48B74; stroke-width: 5; stroke-linecap: round; opacity: 0.85; }
.bear .mouth-open { fill: var(--bear-ink); }
.bear .line       { fill: none; stroke: var(--bear-ink); stroke-width: 2.5; stroke-linecap: round; }
.bear .line.thick { stroke-width: 4; }
.bear .tear       { fill: #9FC8F0; }
.bear .sparkle    { fill: #F7D774; }
.bear .surprise   { fill: var(--bear-ink); font: 800 30px -apple-system, sans-serif; }
.bear .zzz        { fill: #8E86B8; font: 700 22px -apple-system, sans-serif; }
.bear .zzz.small  { font-size: 15px; }

/* Si vede solo l'espressione dell'umore attuale, con passaggio morbido */
.bear .mood { opacity: 0; transition: opacity 0.4s; }
.bear[data-mood="felice"] .mood-felice,
.bear[data-mood="arrabbiato"] .mood-arrabbiato,
.bear[data-mood="triste"] .mood-triste,
.bear[data-mood="orgoglioso"] .mood-orgoglioso,
.bear[data-mood="assonnato"] .mood-assonnato,
.bear[data-mood="sorpreso"] .mood-sorpreso { opacity: 1; }

/* Respiro continuo */
.bear .bear-body {
  transform-origin: 100px 180px;
  animation: bear-breathe 3.5s ease-in-out infinite;
}

/* Ammiccamento ogni tanto (solo occhi aperti) */
.bear .eyes {
  transform-box: fill-box;
  transform-origin: center;
  animation: bear-blink 5s infinite;
}

.bear .sparkle { transform-box: fill-box; transform-origin: center; animation: bear-sparkle 1.6s ease-in-out infinite; }
.bear .zzz     { animation: bear-zzz 2.4s ease-in-out infinite; }

/* Un movimento per ogni umore */
.bear { transform-origin: 50% 100%; }
.bear[data-mood="felice"]     { animation: bear-wiggle 3s ease-in-out infinite; }
.bear[data-mood="arrabbiato"] { animation: bear-shake 2.2s ease-in-out infinite; }
.bear[data-mood="triste"]     { animation: bear-droop 4s ease-in-out infinite; }
.bear[data-mood="orgoglioso"] { animation: bear-proud 2s ease-in-out infinite; }
.bear[data-mood="assonnato"]  { animation: bear-sway 4.5s ease-in-out infinite; }
.bear[data-mood="sorpreso"]   { animation: bear-pop 0.5s ease-out; }

@keyframes bear-wiggle { 0%, 80%, 100% { transform: rotate(0); } 85% { transform: rotate(-4deg); } 90% { transform: rotate(4deg); } 95% { transform: rotate(-2deg); } }
@keyframes bear-shake { 0%, 70%, 100% { transform: translateX(0); } 75%, 85%, 95% { transform: translateX(-3px); } 80%, 90% { transform: translateX(3px); } }
@keyframes bear-droop { 0%, 100% { transform: translateY(3px) rotate(-2deg); } 50% { transform: translateY(5px) rotate(2deg); } }
@keyframes bear-proud { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.06); } }
@keyframes bear-sway { 0%, 100% { transform: rotate(-5deg); } 50% { transform: rotate(5deg); } }
@keyframes bear-pop { 0% { transform: scale(0.8) translateY(0); } 40% { transform: scale(1.15, 0.9) translateY(-12px); } 70% { transform: scale(0.95, 1.05); } 100% { transform: scale(1); } }

/* Saltello quando arriva un messaggio */
.bear.bounce svg { animation: bear-bounce 0.6s ease-out; }

@keyframes bear-breathe { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.025); } }
@keyframes bear-blink { 0%, 92%, 100% { transform: scaleY(1); } 95% { transform: scaleY(0.1); } }
@keyframes bear-sparkle { 0%, 100% { opacity: 0.4; transform: scale(0.8); } 50% { opacity: 1; transform: scale(1.1); } }
@keyframes bear-zzz { 0%, 100% { opacity: 0.3; transform: translateY(0); } 50% { opacity: 1; transform: translateY(-4px); } }
@keyframes bear-bounce { 0% { transform: translateY(0); } 35% { transform: translateY(-14px); } 65% { transform: translateY(0); } 80% { transform: translateY(-4px); } 100% { transform: translateY(0); } }

@media (prefers-reduced-motion: reduce) {
  .bear, .bear .bear-body, .bear .eyes, .bear .sparkle, .bear .zzz, .bear.bounce svg { animation: none !important; }
}

/* L'orsetto in alto nella chat */
.bear-box {
  position: sticky;
  top: calc(env(safe-area-inset-top) + 84px);
  z-index: 5;
  width: 96px;
  height: 96px;
  margin: 0 auto 8px;
}

/* ===== Time table (scheda Oggi) — stile scelto con Maria in docs/time-table.md ===== */
:root {
  /* Sfondi crema (Pink Latte), blocchi rosa Pastel Romance, lampone solo per esami e scadenze */
  --tt-cream: #FDF7EA; /* crema chiaro scelto da Maria (4 nov): non cambiarlo */
  /* Colori "di dettaglio": ogni tema li ridefinisce (vedi in fondo al file) */
  --pink-soft: #FFDBE0;
  --pink-softer: #FFE6F0;
  --pink-strong: #E98BAF;
  --fill-from: #FFB6C1;
  --fill-to: #E98BAF;
  --washi-a: #FFDBE0;
  --washi-b: #FFE9EE;
  --gap-a: #FFD9E3;
  --gap-b: #FFF4F7;
  --gap-text: #8C3A5A;
  --weekend-day: #FFFCF5;
  --on-cream: #3A2A33; /* testo sopra il crema: scuro in tutti i temi */
  --on-cream-soft: #7A6670;
  --mark-wake: #F5BE3A;
  --mark-night: #8E86B8;
  --tt-raspberry: #BC335F;
  --kind-lezione: #FFB6C1;
  --kind-studio: #E3D2F5;
  --kind-appunti: #FFDBE0;
  --kind-pisolino: #DDE5F7;
  --kind-palestra: #FFD6C2;
  --kind-pasto: #FCEBB8;
  --kind-uscita: #CDEBDD;
  --kind-scadenza: var(--tt-raspberry);
  --kind-esame: var(--tt-raspberry);
  --kind-compleanno: #F7A1B3;
  --kind-evento: #CFE0F5;
  --kind-ciclo: #F6D3DC;
  --kind-auto: #D5E8B5;
  --kind-promemoria: #FFE6F0;
  --kind-altro: #EBDDD3;
}

.kind-lezione { --kind: var(--kind-lezione); }
.kind-studio { --kind: var(--kind-studio); }
.kind-appunti { --kind: var(--kind-appunti); }
.kind-pisolino { --kind: var(--kind-pisolino); }
.kind-palestra { --kind: var(--kind-palestra); }
.kind-pasto { --kind: var(--kind-pasto); }
.kind-uscita { --kind: var(--kind-uscita); }
.kind-scadenza { --kind: var(--kind-scadenza); --kind-text: #FFFFFF; }
.kind-esame { --kind: var(--kind-esame); --kind-text: #FFFFFF; }
.kind-compleanno { --kind: var(--kind-compleanno); }
.kind-evento { --kind: var(--kind-evento); }
.kind-ciclo { --kind: var(--kind-ciclo); }
.kind-auto { --kind: var(--kind-auto); }
.kind-promemoria { --kind: var(--kind-promemoria); }
.kind-altro { --kind: var(--kind-altro); }

/* Nastro washi tape per i titoli */
.washi {
  display: inline-block;
  margin: 0 0 10px;
  padding: 3px 14px;
  font-size: 15px;
  transform: rotate(-1.5deg);
  background: repeating-linear-gradient(45deg, var(--washi-a) 0 8px, var(--washi-b) 8px 16px);
  border-radius: 3px;
}

.tt-switch {
  display: flex;
  gap: 6px;
  justify-content: center;
  margin-bottom: 14px;
}

.tt-view {
  font: inherit;
  font-size: 15px;
  padding: 8px 16px;
  border: none;
  border-radius: 999px;
  background: var(--card);
  color: var(--text-soft);
  box-shadow: var(--shadow);
  cursor: pointer;
}

.tt-view.active {
  background: var(--primary);
  color: var(--text);
  font-weight: 600;
}

.tt-layout {
  display: grid;
  grid-template-columns: 1fr 52px;
  gap: 10px;
  align-items: start;
}

.tt-main {
  min-width: 0;
}

/* Date in colonna sul lato */
.tt-dates {
  position: sticky;
  top: calc(env(safe-area-inset-top) + 84px);
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: calc(100vh - 220px);
  overflow-y: auto;
  scrollbar-width: none;
}

.tt-date {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 6px 0;
  border: none;
  border-radius: 14px;
  background: var(--card); /* giorni feriali bianchi */
  color: var(--text);
  font: inherit;
  cursor: pointer;
}

.tt-date-wd { font-size: 11px; color: var(--text-soft); text-transform: uppercase; }
.tt-date-n { font-size: 17px; font-weight: 600; }
.tt-date.weekend { background: var(--weekend-day); } /* sabato e domenica: crema più chiaro (scelta di Maria) */
.tt-date.today .tt-date-n { color: var(--tt-raspberry); }
/* Oggi: bordo lampone sottilissimo, sempre (si sposta da solo ogni giorno) */
.tt-date.today { box-shadow: inset 0 0 0 1px var(--tt-raspberry); }
.tt-date.selected { outline: 2px solid var(--tt-raspberry); }

/* Intestazione del giorno: data in corsivo */
.tt-day-head { margin-bottom: 10px; }

.tt-script-date {
  font-family: "Snell Roundhand", "Brush Script MT", "Segoe Script", cursive;
  font-size: 38px;
  font-weight: 700;
  line-height: 1.1;
  color: var(--tt-raspberry);
}

.tt-date-line { color: var(--text-soft); font-size: 15px; }

/* Barra della giornata */
.tt-bar-wrap { position: relative; margin: 6px 0 16px; }

/* Il momento di adesso sulla barra della giornata */
.tt-bar-now {
  position: absolute;
  top: -4px;
  width: 4px;
  height: 24px;
  margin-left: -2px;
  border-radius: 2px;
  background: var(--tt-raspberry);
  box-shadow: 0 0 0 2px var(--bg);
}

.tt-bar {
  position: relative;
  height: 16px;
  border-radius: 999px;
  background: var(--tt-cream);
  box-shadow: inset 0 0 0 1px rgba(58, 42, 51, 0.08);
  overflow: hidden;
}

.tt-bar > .tt-seg { opacity: 0.35; }

.tt-bar-filled {
  position: absolute;
  inset: 0;
  /* la parte di giornata già passata si colora (si vede avanzare con le ore) */
  background: linear-gradient(90deg, var(--fill-from), var(--fill-to));
  border-radius: 999px;
}

.tt-seg {
  position: absolute;
  top: 0;
  bottom: 0;
  background: var(--kind);
  /* tacchetta al cambio di attività */
  border-left: 2px solid rgba(255, 255, 255, 0.9);
}

.tt-bar-hours {
  position: relative;
  height: 14px;
  font-size: 11px;
  color: var(--text-soft);
  margin-top: 3px;
}

.tt-bar-hours span { position: absolute; transform: translateX(-50%); }
.tt-bar-hours span:first-child { transform: none; }
.tt-bar-hours span:last-child { transform: translateX(-100%); }

.tt-top3 ol { margin: 0; padding-left: 20px; }
.tt-top3 li { margin: 4px 0; }

.tt-exams { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }

.tt-exam-chip {
  padding: 5px 12px;
  border-radius: 999px;
  background: var(--tt-raspberry);
  color: #FFFFFF;
  font-size: 14px;
  font-weight: 600;
}

/* Abitudini */
.tt-habits-title { font-weight: 600; margin-bottom: 8px; }

.tt-progress {
  height: 10px;
  border-radius: 999px;
  background: var(--tt-cream);
  overflow: hidden;
}

.tt-progress.small { height: 6px; margin: 6px 0; }

.tt-progress-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--fill-from), var(--fill-to));
  transition: width 0.5s;
}

.tt-habit-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }

.tt-habit {
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--tt-cream);
  font-size: 14px;
}

.tt-habit.done { background: var(--pink-soft); color: var(--text); font-weight: 600; }

/* Linea del tempo */
.tt-timeline { display: flex; flex-direction: column; gap: 8px; }

.tt-block {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 10px;
  width: 100%;
  padding: 12px 14px;
  border: none;
  border-left: 8px solid var(--kind);
  border-radius: 18px;
  background: color-mix(in srgb, var(--kind) 30%, var(--card));
  color: var(--text);
  font: inherit;
  text-align: left;
  box-shadow: var(--shadow);
  cursor: pointer;
}

.tt-block.kind-esame,
.tt-block.kind-scadenza { background: color-mix(in srgb, var(--kind) 15%, var(--card)); }
.tt-block.done .tt-block-title { text-decoration: line-through; opacity: 0.6; }
.tt-block-time { font-size: 13px; color: var(--text-soft); min-width: 86px; }
.tt-block-title { flex: 1; font-weight: 500; }

.tt-block.suggestion {
  background: var(--card);
  border: 2px dashed var(--kind);
  border-left-width: 8px;
  border-left-style: solid;
  box-shadow: none;
  cursor: default;
}

.tt-accept {
  padding: 6px 12px;
  border: none;
  border-radius: 999px;
  background: var(--accent);
  color: #FFFFFF;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

/* Tempo libero: deve staccarsi bene dal resto (richiesta di Maria) */
.tt-gap {
  padding: 12px 14px;
  border: 2px dashed var(--pink-strong);
  border-radius: 18px;
  background: repeating-linear-gradient(-45deg, var(--gap-a) 0 10px, var(--gap-b) 10px 20px);
  color: var(--gap-text);
  font-size: 14px;
  font-weight: 600;
  text-align: center;
}

.tt-now {
  position: relative;
  padding-left: 14px;
  color: var(--tt-raspberry);
  font-size: 13px;
  font-weight: 700;
}

.tt-now::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--tt-raspberry);
  transform: translateY(-50%);
}

/* Pannello per un blocco: fatto, sposta, elimina */
.tt-sheet {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(58, 42, 51, 0.25);
}

.tt-sheet[hidden] { display: none; }

.tt-sheet-panel {
  width: 100%;
  max-width: 640px;
  margin: 0;
  padding-bottom: calc(env(safe-area-inset-bottom) + 20px);
  border-radius: var(--radius) var(--radius) 0 0;
}

.tt-sheet-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 12px 0; }

.tt-sheet-button {
  padding: 12px;
  border: none;
  border-radius: var(--radius-small);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  cursor: pointer;
}

.tt-sheet-button.primary { background: var(--accent); color: #FFFFFF; font-weight: 600; }
.tt-sheet-button.danger { color: var(--tt-raspberry); }

/* Settimana: card grandi e arrotondate */
.tt-week-day {
  display: block;
  width: 100%;
  margin-bottom: 10px;
  padding: 14px 16px;
  border: none;
  border-radius: 24px;
  background: var(--card);
  color: var(--text);
  font: inherit;
  text-align: left;
  box-shadow: var(--shadow);
  cursor: pointer;
}

.tt-week-day.today { outline: 2px solid var(--tt-raspberry); }
.tt-week-head { display: flex; justify-content: space-between; align-items: baseline; }
.tt-week-name { font-weight: 700; }
.tt-week-full { font-size: 13px; color: var(--text-soft); }
.tt-week-chips { display: flex; flex-wrap: wrap; gap: 5px; }

.tt-chip {
  padding: 3px 9px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--kind, #EBDDD3) 45%, var(--card));
  color: var(--kind-text, var(--text));
  font-size: 13px;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tt-chip.kind-esame,
.tt-chip.kind-scadenza { background: var(--kind); }

/* Mese */
.tt-month-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.tt-month-head .tt-script-date { flex: 1; color: var(--text); }
.tt-month-sticker { font-size: 34px; filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.12)); }
.tt-month-nav { display: flex; gap: 6px; }
.tt-month-nav .tt-view { padding: 6px 14px; }

.tt-month-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 5px;
  margin-bottom: 16px;
}

.tt-month-wd { text-align: center; font-size: 12px; color: var(--text-soft); }

.tt-month-day {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  min-height: 52px;
  padding: 6px 2px;
  border: none;
  border-radius: 14px;
  background: color-mix(in srgb, var(--month-color, var(--pink-soft)) calc(20% + var(--fullness, 0) * 80%), var(--card));
  color: var(--text);
  font: inherit;
  cursor: pointer;
}

.tt-month-day.today { outline: 2px solid var(--tt-raspberry); }
.tt-month-n { font-size: 14px; font-weight: 600; }
.tt-dots { display: flex; gap: 2px; }
.tt-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--kind); }

/* Griglia abitudini del mese */
.tt-hgrid {
  display: grid;
  grid-template-columns: 26px repeat(var(--days), 1fr);
  gap: 2px;
  align-items: center;
}

.tt-hgrid-label { font-size: 14px; }
.tt-hgrid-day { font-size: 10px; text-align: center; white-space: nowrap; }
.tt-hgrid-day.today { color: var(--tt-raspberry); font-weight: 700; }
.tt-hcell { height: 8px; border-radius: 3px; background: var(--tt-cream); }
.tt-hcell.planned { background: var(--pink-softer); }
.tt-hcell.done { background: var(--pink-strong); }
/* Il quadratino di oggi è appena più grande degli altri */
.tt-hcell.today { transform: scale(1.25); }

/* Care piccolo nell'angolo in alto, accanto alla data (non copre niente) */
.tt-bear {
  float: right;
  width: 64px;
  height: 64px;
  margin: 0 0 4px 8px;
}

.tt-date-today {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 8px 0;
  background: var(--tt-raspberry);
  color: #FFFFFF;
  font-size: 12px;
  font-weight: 700;
}

/* Sveglia e ora di andare a letto */
.tt-sleep {
  padding: 10px 14px;
  border-radius: 18px;
  background: #FFF4D6;
  color: #7A5A1E;
  font-size: 14px;
  font-weight: 600;
}

.tt-sleep.night {
  background: #E4E0F5;
  color: #4B3F7A;
}

.tt-week-title { flex: 1; font-weight: 700; font-size: 17px; }

/* Impostazioni: calendari */
.cal-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }

.cal-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-small);
  background: var(--tt-cream);
}

.cal-item > div { display: flex; flex-direction: column; }
.cal-item .hint { margin: 0 !important; font-size: 13px; }

.cal-remove {
  border: none;
  background: none;
  color: var(--tt-raspberry);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}

.cal-form { display: flex; flex-direction: column; gap: 8px; }

.cal-form select,
.cal-form input {
  padding: 12px 14px;
  border: 2px solid var(--primary);
  border-radius: var(--radius-small);
  background: var(--bg);
  color: var(--text);
  font: inherit;
}

.cal-help { margin: 12px 0; }
.cal-help summary { cursor: pointer; font-weight: 600; }
.cal-help p { margin: 8px 0 !important; font-size: 15px; }
.cal-file { display: inline-block; margin-top: 6px; color: var(--tt-raspberry); font-weight: 600; cursor: pointer; }

/* Festività italiane */
.tt-holiday {
  display: inline-block;
  margin-top: 4px;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--pink-softer);
  color: var(--tt-raspberry);
  font-size: 14px;
  font-weight: 600;
}

.tt-month-day.holiday .tt-month-n { color: var(--tt-raspberry); }

/* ===== Vista Giorno a griglia: ogni attività è alta quanto dura ===== */
.tt-grid {
  --tt-grid-left: 46px;
  position: relative;
  margin-top: 10px;
}

.tt-hour {
  position: absolute;
  left: 0;
  right: 0;
  border-top: 1px solid rgba(58, 42, 51, 0.08);
}

.tt-hour-label {
  position: absolute;
  left: 0;
  top: 0;
  transform: translateY(-50%);
  width: calc(var(--tt-grid-left) - 6px);
  padding-right: 4px;
  background: var(--bg);
  color: var(--text-soft);
  font-size: 12px;
  text-align: right;
}

.tt-slot {
  position: absolute;
  z-index: 2;
  display: flex;
}

/* Le card restano quelle di prima, ma riempiono la loro casella */
.tt-slot > .tt-block {
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-start;
  flex-wrap: nowrap;
  gap: 2px;
  height: 100%;
  padding: 6px 10px;
  border-radius: 14px;
  overflow: hidden;
}

.tt-slot .tt-block-time { min-width: 0; font-size: 12px; }
.tt-slot .tt-block-title { flex: 0 1 auto; font-size: 15px; line-height: 1.25; }

/* Attività corte: tutto su una riga */
.tt-slot.compact > .tt-block {
  flex-direction: row;
  align-items: center;
  gap: 6px;
  padding: 2px 10px;
}

.tt-slot.compact .tt-block-title,
.tt-slot.compact .tt-block-time { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tt-slot.compact .tt-block-title { font-size: 13px; }
.tt-slot.compact .tt-block-time { display: none; } /* l'ora si vede già dalla posizione */

.tt-slot .tt-block.suggestion { border-width: 2px; border-left-width: 6px; padding-right: 92px; }
.tt-slot.compact .tt-block.suggestion { padding-right: 40px; }
.tt-slot.compact .tt-accept { top: 50%; transform: translateY(-50%); padding: 1px 9px; font-size: 14px; }

.tt-slot .tt-accept {
  position: absolute;
  top: 4px;
  right: 6px;
  padding: 3px 10px;
  font-size: 12px;
}

/* Tempo libero: un'area a righe nel suo tratto di giornata */
.tt-grid .tt-gap {
  position: absolute;
  left: var(--tt-grid-left);
  right: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px 10px;
  font-size: 13px;
  text-align: center;
}

/* Righe: adesso, sveglia, a letto */
.tt-mark {
  position: absolute;
  left: var(--tt-grid-left);
  right: 0;
  z-index: 3;
  height: 0;
  border-top: 2px solid var(--mark-color);
  pointer-events: none;
}

.tt-mark-label {
  position: absolute;
  top: 0;
  transform: translateY(-50%);
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--mark-color);
  color: #FFFFFF;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.tt-mark.now { --mark-color: var(--tt-raspberry); z-index: 4; }
.tt-mark.now .tt-mark-label { left: calc(-1 * var(--tt-grid-left) + 2px); }
.tt-mark.wake { --mark-color: var(--mark-wake); }
.tt-mark.night { --mark-color: var(--mark-night); }
.tt-mark.wake .tt-mark-label,
.tt-mark.night .tt-mark-label { right: 6px; }

/* Pranzo e cena automatici: più leggeri, non si toccano */
.tt-block.meal { cursor: default; opacity: 0.85; }

.tt-all-day { margin-left: 6px; border: none; font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; }

/* Tempo libero cliccabile e idee di Care */
.tt-grid .tt-gap { border: 2px dashed var(--pink-strong); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; }
.tt-ideas { display: flex; flex-direction: column; gap: 8px; margin: 10px 0; }
.tt-idea {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-small);
  background: var(--tt-cream);
}
.tt-idea .tt-accept { position: static; padding: 4px 12px; font-size: 16px; }

/* Modifica orari */
.tt-edit-fields { display: flex; gap: 10px; margin: 10px 0; }
.tt-edit-label { flex: 1; display: flex; flex-direction: column; gap: 4px; font-size: 14px; color: var(--text-soft); }
.tt-time {
  padding: 10px 12px;
  border: 2px solid var(--primary);
  border-radius: var(--radius-small);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 18px;
}
.tt-save { width: 100%; margin-top: 4px; }
.tt-sheet-close { width: 100%; margin-top: 8px; }

/* Care sempre in basso a destra (si può trascinare) */
.care-float {
  position: fixed;
  right: 14px;
  bottom: 84px;
  z-index: 15;
  width: 64px;
  height: 64px;
  touch-action: none; /* per trascinarlo senza far scorrere la pagina */
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  cursor: grab;
  filter: drop-shadow(0 4px 8px rgba(58, 42, 51, 0.18));
}

.care-float.listening { filter: drop-shadow(0 0 10px var(--accent)); }

.mini-chat {
  position: fixed;
  z-index: 16;
  width: min(320px, calc(100vw - 24px));
  margin: 0;
  padding: 14px;
}

.mini-chat[hidden] { display: none; }
.mini-reply { margin: 0 0 10px !important; font-size: 15px; }
.mini-form { display: flex; gap: 8px; }

.mini-form textarea {
  flex: 1;
  resize: none;
  padding: 10px 14px;
  border: 2px solid var(--primary);
  border-radius: 20px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
}

.mini-open {
  margin-top: 8px;
  border: none;
  background: none;
  color: var(--accent);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

/* Sopra il crema il testo è sempre scuro (anche nel tema triste) */
.tt-habit, .cal-item, .tt-idea { color: var(--on-cream); }
.cal-item .hint, .tt-idea .hint { color: var(--on-cream-soft); }

/* ===== Temi: tutti i colori che cambiano (in fondo al file, così vincono sui valori di base) =====
   Regola d'oro: in ogni tema tutto deve restare leggibile. */

/* Il testo dentro i messaggi di Maria segue il colore principale del tema */
.bubble.user { color: var(--on-primary, var(--text)); }

/* --- Triste: rosa → blu, bianco → blu scuro, testo → bianco; crema e lampone restano --- */
[data-theme="triste"] {
  --bg: #121826;
  --primary: #2C3E66;
  --accent: #4F7BC8;
  --text: #E6ECF5;
  --text-soft: #A9B6CC;
  --card: #1E2740;
  --header-text: #E6ECF5;
  --on-primary: #E6ECF5;
  --pink-soft: #3A5A94;
  --pink-softer: #2E4470;
  --pink-strong: #7FA3D9;
  --washi-a: #3A5A94;
  --washi-b: #2E4470;
  --gap-a: #2E4470;
  --gap-b: #24365A;
  --gap-text: #D6E4FF;
  --weekend-day: #2E3E66; /* un blu un po' più chiaro degli altri giorni */
  --kind-lezione: #6F95D6;
  --kind-studio: #8C82D9;
  --kind-appunti: #5F7FB8;
  --kind-pisolino: #4E6A9E;
  --kind-palestra: #7FB3D9;
  --kind-pasto: #9FB4D6;
  --kind-uscita: #6FB3B0;
  --kind-compleanno: #7FA3D9;
  --kind-evento: #5E8FD0;
  --kind-ciclo: #8FA0C9;
  --kind-auto: #7FAF9A;
  --kind-promemoria: #4E6A9E;
  --kind-altro: #6B7A99;
}

/* --- Strega autunnale: più arancione, marrone e crema; il lampone diventa arancione acceso --- */
[data-theme="strega-autunnale"] {
  --bg: #F6E8D3;
  --primary: #9C6644;
  --accent: #D9772B;
  --text: #3E2618;
  --text-soft: #7A5A44;
  --card: #FFF7EA;
  --header-text: #FFF4E0;
  --on-primary: #FFF4E0;
  --shadow: 0 4px 16px rgba(74, 50, 34, 0.14);
  --tt-raspberry: #E8630A;
  --pink-soft: #F3D2B5;
  --pink-softer: #F7E2CC;
  --pink-strong: #C9824F;
  --fill-from: #E9B48A;
  --fill-to: #C9824F;
  --washi-a: #E9C29E;
  --washi-b: #F6DFC6;
  --gap-a: #F0D3B6;
  --gap-b: #FBEEDD;
  --gap-text: #7A3E12;
  --weekend-day: #F3E1C8;
  --kind-lezione: #E9A06B;
  --kind-studio: #C99A6B;
  --kind-appunti: #E8C39E;
  --kind-pisolino: #D9C7A8;
  --kind-palestra: #D98B5F;
  --kind-pasto: #F0C987;
  --kind-uscita: #B5835A;
  --kind-compleanno: #E9A06B;
  --kind-evento: #C8A27A;
  --kind-ciclo: #E3B8A0;
  --kind-auto: #B8C08A;
  --kind-promemoria: #F3DDC0;
  --kind-altro: #D8C3A5;
}

/* L'orsetto al posto dell'emoji: nella barra in basso e nella pagina della password */
.tab-bear { display: block; width: 28px; height: 28px; font-size: 0 !important; }
.tab-bear .bear { animation: none !important; }
.login-bear { width: 110px; height: 110px; margin: 0 auto 8px; }

/* Il mese fisso in cima alla colonna dei giorni, sotto "Oggi" */
.tt-date-month {
  position: sticky;
  top: 34px;
  z-index: 1;
  padding: 3px 0;
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font-size: 11px;
  font-weight: 700;
  text-align: center;
  box-shadow: 0 2px 6px rgba(58, 42, 51, 0.08);
}

/* ===== Emoji disegnate nello stile di Care (prova: /emoji-demo) — i colori seguono il tema ===== */
:root {
  --icon-main: #F29BBF;
  --icon-light: #FFDBE0;
  --icon-ink: #5A3A46;
  --icon-accent: #F5BE3A;
  --icon-blush: #F7A1B3;
}

[data-theme="triste"] {
  --icon-main: #6F95D6;
  --icon-light: #C9DAF5;
  --icon-ink: #1E2740;
  --icon-accent: #F5D06A;
  --icon-blush: #9FB4E8;
  --icon-lead: #C9DAF5; /* chiara, così sul blu scuro si vede */
  --icon-eraser: #B4C2EE;
}

[data-theme="strega-autunnale"] {
  /* zucca morbida, panna, oro e rosa antico */
  --icon-main: #E39A5F;
  --icon-light: #FBE6CF;
  --icon-ink: #5A3826;
  --icon-accent: #EDB93F;
  --icon-blush: #E9A48E;
  --icon-petal: #F0A08C; /* rosa pesca: il fiore non deve sembrare marrone */
}

.care-icon .i-main { fill: var(--icon-main); }
.care-icon .i-light { fill: var(--icon-light); }
.care-icon .i-ink { fill: var(--icon-ink); }
.care-icon .i-ink-soft { fill: var(--icon-ink); opacity: 0.55; }
.care-icon .i-accent { fill: var(--icon-accent); }
.care-icon .i-blush { fill: var(--icon-blush); opacity: 0.7; }
.care-icon .i-flame { fill: #F7A440; }
.care-icon .i-petal { fill: var(--icon-petal, var(--icon-main)); }
.care-icon .i-steam { fill: none; stroke: var(--icon-main); stroke-width: 2.4; stroke-linecap: round; opacity: 0.5; }
.care-icon .i-line { fill: none; stroke: var(--icon-ink); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.care-icon .i-line.soft { opacity: 0.45; }
.care-icon .ring { stroke: var(--icon-main); stroke-width: 4; }
.care-icon .stroke { stroke: var(--icon-ink); stroke-width: 1.5; stroke-linejoin: round; }
.care-icon .i-zzz { fill: var(--icon-main); font: 800 13px -apple-system, sans-serif; }
.care-icon .i-zzz.small { font-size: 10px; }
.care-icon .petal-shine { opacity: 0.45; }
.care-icon .i-shade { fill: var(--icon-ink); opacity: 0.15; }
/* Matita: legno, mina e gomma con colori da matita vera, abbinati al tema */
.care-icon .i-wood { fill: #F2DDB8; }
.care-icon .i-lead { fill: var(--icon-lead, var(--icon-ink)); }
.care-icon .i-eraser { fill: var(--icon-eraser, var(--icon-accent)); }
.care-icon .i-pages { fill: none; stroke: var(--icon-main); stroke-width: 1; opacity: 0.5; }
.care-icon .band { opacity: 0.8; }
.care-icon .label { opacity: 0.85; }

/* Le emoji disegnate dentro i testi */
.icon-inline { display: inline-flex; vertical-align: -0.2em; }
.icon-inline .care-icon { display: block; }
.tt-hgrid-label .icon-inline { vertical-align: middle; }

/* Icone disegnate nella barra in basso */
.tab-icon { display: block; height: 26px; font-size: 0 !important; }
.tab-icon .icon-inline { vertical-align: top; }

/* La card del giorno di Care */
.briefing-card { position: relative; }
.briefing-text { white-space: pre-line; margin: 0 !important; }
.briefing-close {
  position: absolute;
  top: 8px;
  right: 10px;
  border: none;
  background: none;
  color: var(--text-soft);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

/* ===== Scheda Studio ===== */
.career-row { display: flex; justify-content: space-around; margin: 6px 0 12px; text-align: center; }
.career-number strong { display: block; font-size: 26px; color: var(--tt-raspberry); }
.career-number span { font-size: 13px; color: var(--text-soft); }
.career-hint { margin-top: 8px !important; }

.study-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 10px; }
.study-chip {
  padding: 6px 12px;
  border: 2px solid var(--subject);
  border-radius: 999px;
  background: var(--card);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}
.study-chip.selected { background: color-mix(in srgb, var(--subject) 55%, var(--card)); font-weight: 700; }

.study-clock {
  margin: 10px 0;
  font-size: 54px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  text-align: center;
  color: var(--text);
}
.study-clock.over { color: var(--tt-raspberry); }
.study-now { margin: 0 !important; text-align: center; font-weight: 600; }
.study-over { text-align: center; }
.study-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.study-title { margin: 6px 0 12px; }
.subject-card { border-left: 8px solid var(--subject); }
.subject-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.subject-grade { font-weight: 700; color: var(--tt-raspberry); white-space: nowrap; }
.subject-head .tt-exam-chip { font-size: 12px; white-space: nowrap; }
.subject-info { margin: 4px 0 6px !important; font-size: 13px; }
.subject-format { margin: 0 0 6px !important; font-size: 14px; }
.subject-minutes { margin: 2px 0 0 !important; font-size: 13px; }
.subject-edit { margin-top: 8px; border: none; background: none; color: var(--accent); font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; padding: 0; }
.subject-editor { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }

/* Obiettivo e esami da rifare */
.goal-box { margin-top: 16px; padding-top: 12px; border-top: 1px dashed var(--pink-strong); }
.goal-line { margin: 6px 0 !important; font-size: 15px; }
.tt-exam-chip.retake { background: var(--accent); }
.retake-label { display: flex; align-items: center; gap: 6px; font-size: 15px; }

/* Nella chat, se Care è in basso, sale sopra il campo per scrivere */
body[data-tab="care"] .care-float { margin-bottom: 58px; }
body:not([data-tab]) .care-float { margin-bottom: 58px; } /* all'apertura si è nella chat */

/* Finestre apribili 1°, 2° e 3° anno */
.year-panel { padding: 0; overflow: hidden; }
.year-summary {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  padding: 16px 20px;
}
.year-summary strong { flex: 1; font-size: 17px; }
.year-summary .hint { margin: 0 !important; font-size: 13px; }
.year-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  border-top: 1px solid rgba(58, 42, 51, 0.06);
  border-left: 6px solid var(--subject);
}
.year-name { display: flex; flex-direction: column; font-size: 14px; }
.year-name .hint { margin: 0 !important; font-size: 12px; }
.year-status { flex-shrink: 0; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--tt-cream); color: var(--on-cream); white-space: nowrap; }
.year-status.done { background: var(--pink-soft); color: var(--text); }
.year-status.now { background: var(--accent); color: #FFFFFF; }
.year-status.retake { background: var(--tt-raspberry); color: #FFFFFF; }
.year-note { margin: 0 20px 16px !important; }

/* "Le mie materie" con le etichette da toccare accanto */
.study-head { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin: 6px 0 12px; }
.study-head .study-title { margin: 0; white-space: nowrap; font-size: 14px; padding: 3px 10px; }
.study-pills { display: flex; gap: 4px; flex-shrink: 0; }
.study-pill {
  min-width: 30px;
  padding: 5px 9px;
  font-size: 13px !important;
  border: none;
  border-radius: 999px;
  background: var(--card);
  color: var(--text-soft);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  box-shadow: var(--shadow);
  cursor: pointer;
}
.study-pill.active { background: var(--primary); color: var(--text); }

/* "Carriera" accanto al titolo: su schermi stretti gli anni vanno sulla riga sotto */
.study-head { flex-wrap: wrap; }
/* "La mia carriera" subito accanto a "Le mie materie"; lo spazio libero va prima degli anni */
.study-head { justify-content: flex-start; }
.career-pill { margin-right: 0; }
.study-pills { margin-left: auto; }
#study-career[hidden] { display: none; }

/* Il titolo "Le mie materie" è un'etichetta da toccare */
button.study-title { border: none; font: inherit; font-weight: 700; color: var(--text); cursor: pointer; }
button.study-title:not(.active) { opacity: 0.6; }

/* Tre bottoni uguali in fila; nel piano di studi gli anni stanno sotto */
.study-head { flex-wrap: wrap; justify-content: flex-start; gap: 6px; }
.study-plan .study-pills { margin: 0 0 10px; }
.study-plan .study-pill { padding: 6px 12px; }
/* Sul telefono i tre bottoni stanno su una riga sola */
@media (max-width: 420px) {
  .study-head { gap: 3px; flex-wrap: nowrap; }
  .study-head .study-title { font-size: 12px; padding: 3px 5px; letter-spacing: -0.3px; }
  .study-head .study-title .icon-inline .care-icon { width: 14px; height: 14px; }
}

/* Piano di studi: cartellini del voto obiettivo */
.year-badges { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex-shrink: 0; }
.target-tag {
  padding: 2px 9px;
  border: 1.5px dashed var(--tt-raspberry);
  border-radius: 999px;
  color: var(--tt-raspberry);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}
.year-row { flex-wrap: wrap; }
.year-row.editable { cursor: pointer; }
.target-editor { flex-basis: 100%; display: flex; flex-direction: column; gap: 8px; margin-top: 8px; cursor: default; }
.graduation-line { margin: 4px 0 !important; font-size: 14px; }
.year-name { flex: 1 1 0; min-width: 0; } /* il nome va a capo, i cartellini restano a destra */

/* Appunti, Spiegamelo facile, Esse3 */
.subject-actions { display: flex; gap: 16px; }
.notes-box { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.notes-list { display: flex; flex-direction: column; gap: 8px; }
.note-item { position: relative; padding: 10px 12px; border-radius: var(--radius-small); background: var(--tt-cream); color: var(--on-cream); }
.note-item.summary { background: var(--pink-soft); color: var(--text); }
.note-item.complete { background: #fff; color: var(--text); border: 1.5px solid var(--pink-soft); }
.note-item.previous { background: var(--tt-cream); color: var(--on-cream); opacity: 0.85; }
.note-head { display: flex; justify-content: space-between; align-items: center; }
.note-delete { position: static; font-size: 18px; }
.note-text { margin: 6px 0 0 !important; white-space: pre-line; font-size: 14px; cursor: pointer; }
.note-text.collapsed { max-height: 4.5em; overflow: hidden; -webkit-mask-image: linear-gradient(#000 60%, transparent); mask-image: linear-gradient(#000 60%, transparent); }
.notes-input {
  width: 100%;
  resize: vertical;
  padding: 10px 12px;
  border: 2px solid var(--primary);
  border-radius: var(--radius-small);
  background: var(--bg);
  color: var(--text);
  font: inherit;
}
.notes-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.merge-button { width: 100%; }
.explain-card .notes-actions { margin-top: 8px; }
.explain-answer { margin: 10px 0 0 !important; white-space: pre-line; }
.esse3-card .tt-sheet-button { width: 100%; margin-top: 8px; }
.esse3-results { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.esse3-item { width: 100%; }

/* Schemi completi: il testo in Markdown e il PDF come in Pages */
.note-open { display: block; text-align: center; text-decoration: none; margin: 6px 0; }
.md { font-size: 15px; line-height: 1.45; }
.md.note-text { white-space: normal; }
.md.note-text.collapsed { max-height: 7em; }
.md h3, .md h4, .md h5, .md h6 { margin: 14px 0 6px; color: var(--tt-raspberry); line-height: 1.25; }
.md h3 { font-size: 19px; } .md h4 { font-size: 17px; } .md h5, .md h6 { font-size: 15px; }
.md p { margin: 6px 0; }
.md ul, .md ol { margin: 6px 0; padding-left: 20px; }
.md li { margin: 3px 0; }
.md li.nested { margin-left: 18px; list-style-type: circle; }
.md blockquote { margin: 8px 0; padding: 6px 10px; border-left: 4px solid var(--pink-strong); border-radius: 6px; background: var(--pink-soft); }
.md hr { border: none; border-top: 1px solid var(--pink-soft); margin: 12px 0; }
.md code { padding: 0 4px; border-radius: 4px; background: var(--pink-soft); }
.md-table { overflow-x: auto; margin: 8px 0; }
.md table { border-collapse: collapse; font-size: 13px; min-width: 100%; }
.md th, .md td { padding: 5px 6px; border: 1px solid var(--pink-soft); text-align: left; vertical-align: top; }
.md th { background: var(--pink-soft); }
.md-image { max-width: 100%; border-radius: 8px; cursor: zoom-in; }
.md-image.zoom { position: fixed; inset: 0; z-index: 50; max-width: none; width: 100vw; height: 100vh; object-fit: contain; background: rgba(0, 0, 0, 0.85); border-radius: 0; cursor: zoom-out; }

/* Progetti di gruppo (Passo 12b) */
.project-box { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.project-item { display: flex; flex-direction: column; gap: 8px; padding: 10px 12px; border-radius: var(--radius-small); background: var(--tt-cream); color: var(--on-cream); }
.project-item.done { opacity: 0.7; }
.project-item p { margin: 0; }
.project-label { margin: 0 !important; }
.project-part-line { display: flex; align-items: center; gap: 6px; }
.project-part { flex: 1; display: flex; justify-content: space-between; align-items: baseline; gap: 8px; padding: 9px 10px; border: 1.5px solid var(--pink-soft); border-radius: var(--radius-small); background: #fff; color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.project-part.done span { text-decoration: line-through; opacity: 0.7; }
.project-part small { white-space: nowrap; opacity: 0.75; }
.project-part-line .note-delete { position: static; }

/* Mock exam (Passo 12) */
.mock-box { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.mock-chapter { padding: 10px; border: 1.5px solid var(--pink-soft); border-radius: var(--radius-small); background: var(--surface, #fff); color: var(--text); font: inherit; }
.mock-title { margin: 0; font-weight: 700; }
.mock-question { display: flex; flex-direction: column; gap: 6px; padding: 10px 12px; border-radius: var(--radius-small); background: var(--tt-cream); color: var(--on-cream); }
.mock-question.right { background: #EAF6EC; }
.mock-question.half { background: #FFF6DC; }
.mock-question.wrong { background: #FDE8EC; }
.mock-question p { margin: 0; }
.mock-text { font-weight: 600; }
.mock-option { text-align: left; padding: 9px 12px; border: 1.5px solid var(--pink-soft); border-radius: var(--radius-small); background: #fff; color: var(--text); font: inherit; cursor: pointer; }
.mock-option.chosen { border-color: var(--pink-strong, #E79AB8); background: var(--pink-soft); font-weight: 600; }
.mock-fill { padding: 10px; border: 1.5px solid var(--pink-soft); border-radius: var(--radius-small); background: #fff; color: var(--text); font: inherit; }
.mock-right { font-weight: 600; color: var(--tt-raspberry); }
.mock-grade { display: flex; align-items: baseline; gap: 10px; padding: 12px; border-radius: var(--radius-small); background: #FDE8EC; color: var(--text); }
.mock-grade.passed { background: #EAF6EC; }
.mock-grade strong { font-size: 2rem; }
.mock-review { margin: 0; white-space: pre-line; }
.mock-history-title { margin: 8px 0 0; font-weight: 700; }
.daily-plan-list { display: flex; flex-direction: column; gap: 8px; }
.daily-plan-day { display: flex; flex-direction: column; gap: 2px; padding: 9px 12px; border-radius: var(--radius-small); background: var(--tt-cream); color: var(--on-cream); }
.mock-history-row { display: flex; justify-content: space-between; gap: 8px; padding: 9px 12px; border: none; border-radius: var(--radius-small); background: var(--tt-cream); color: var(--on-cream); font: inherit; text-align: left; cursor: pointer; }
.esse3-item .item-save { padding: 8px; border: none; border-radius: var(--radius-small); font: inherit; cursor: pointer; }

/* Avviso spese di Google Cloud (Passo 14b): rosso, in cima, appena si apre Care */
.billing-alert { position: sticky; top: 0; z-index: 50; margin: 0; padding: 12px 16px; background: #C62828; color: #fff; font-weight: 700; text-align: center; }

/* Meteo furbo (Passo 15) */
.tt-weather ul { margin: 6px 0 0; padding-left: 0; list-style: none; display: flex; flex-direction: column; gap: 4px; }

/* Andiamo 🚗 (Passo 15): checklist prima di uscire */
.tt-checklist { display: flex; flex-direction: column; gap: 6px; margin: 8px 0; }
.tt-check-row { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: var(--radius-small); background: var(--tt-cream); color: var(--on-cream); }
.tt-check-row input:checked + span { text-decoration: line-through; opacity: 0.6; }
a.tt-sheet-button { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }

/* Persone (Passo 17) */
.people-list { display: flex; flex-direction: column; gap: 6px; margin: 8px 0; }
.people-row { padding: 9px 12px; border-radius: var(--radius-small); background: var(--tt-cream); color: var(--on-cream); }
.people-row summary { cursor: pointer; }
.people-info { margin: 6px 0 0; }
.people-facts { margin: 6px 0; padding-left: 0; list-style: none; display: flex; flex-direction: column; gap: 4px; }
.people-facts li { display: flex; justify-content: space-between; gap: 8px; }
.people-remove { border: none; background: none; color: inherit; cursor: pointer; opacity: 0.6; }
.people-add { display: flex; flex-wrap: wrap; gap: 8px; }
.people-add input { flex: 1 1 140px; }

/* "Sei arrivata a casa?" (Passo 18) */
.home-question { position: sticky; top: 0; z-index: 49; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 16px; background: var(--primary); color: #fff; font-weight: 700; }
.home-question[hidden] { display: none; }
.home-question .tt-sheet-button { width: auto; margin: 0; }

/* Il riquadro del briefing resta fisso sopra la chat mentre si scorre (richiesta di Maria del 9 nov) */
.chat-banner { position: sticky; top: calc(var(--header-h, 76px) + 6px); z-index: 5; }
.chat-banner:empty { display: none; }
.chat-banner .briefing-card { max-height: 30vh; overflow-y: auto; margin-bottom: 8px; box-shadow: var(--shadow); }

/* Sveglie sull'iPhone */
.alarm-button { margin-top: 8px; }
.alarm-steps { padding-left: 20px; margin: 6px 0 10px; }
.tt-alarm .hint { margin: 0; }
