/* ============================================================
   Rotta — foglio di stile unico
   Palette su :root, tema scuro come variante.
   ============================================================ */

:root {
  --bg:        #f6f7fb;
  --bg-soft:   #ffffff;
  --card:      #ffffff;
  --card-2:    #f0f2f8;
  --line:      #e2e6f0;
  --line-soft: #edf0f7;
  --text:      #1a1d27;
  --text-dim:  #656c82;
  --text-faint:#98a0b8;

  --accent:      #5b5bd6;
  --accent-soft: #ecebfd;
  --accent-text: #ffffff;

  --ok:      #17936b;
  --ok-soft: #e2f6ee;
  --warn:    #c2760c;
  --warn-soft:#fdf1dd;
  --danger:  #d0402f;
  --danger-soft:#fdeae7;

  --shadow: 0 1px 2px rgba(20,25,50,.06), 0 8px 24px rgba(20,25,50,.06);
  --shadow-lg: 0 12px 48px rgba(20,25,50,.18);

  --r-sm: 8px;
  --r:    14px;
  --r-lg: 20px;

  --nav-w: 232px;
  --tabbar-h: 64px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:        #0f1117;
    --bg-soft:   #151823;
    --card:      #171a26;
    --card-2:    #1f2331;
    --line:      #272c3c;
    --line-soft: #1e2230;
    --text:      #e8eaf2;
    --text-dim:  #9aa2ba;
    --text-faint:#6b7390;

    --accent:      #7c78f0;
    --accent-soft: #23233f;
    --accent-text: #ffffff;

    --ok:      #3ecf9a;
    --ok-soft: #14302a;
    --warn:    #e2a33c;
    --warn-soft:#302713;
    --danger:  #f0705c;
    --danger-soft:#331b1a;

    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.28);
    --shadow-lg: 0 12px 48px rgba(0,0,0,.5);
  }
}

:root[data-theme="dark"] {
  --bg:        #0f1117;
  --bg-soft:   #151823;
  --card:      #171a26;
  --card-2:    #1f2331;
  --line:      #272c3c;
  --line-soft: #1e2230;
  --text:      #e8eaf2;
  --text-dim:  #9aa2ba;
  --text-faint:#6b7390;

  --accent:      #7c78f0;
  --accent-soft: #23233f;
  --accent-text: #ffffff;

  --ok:      #3ecf9a;
  --ok-soft: #14302a;
  --warn:    #e2a33c;
  --warn-soft:#302713;
  --danger:  #f0705c;
  --danger-soft:#331b1a;

  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.28);
  --shadow-lg: 0 12px 48px rgba(0,0,0,.5);
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; height: 100%; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
  /* Niente in quest'app deve scorrere di lato: se succede è un errore,
     e nasconderlo evita la striscia grigia in fondo allo schermo. */
  overflow-x: hidden;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: none; }
h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -.01em; }

/* ---------- Impalcatura ---------- */

.app {
  display: grid;
  grid-template-columns: var(--nav-w) 1fr;
  min-height: 100vh;
  min-height: 100dvh;
}

/* ---------- Barra laterale (desktop) ---------- */

.sidebar {
  background: var(--bg-soft);
  border-right: 1px solid var(--line);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
}

.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; }
.brand svg { width: 30px; height: 30px; flex: none; }
.brand-name { font-weight: 700; font-size: 17px; letter-spacing: -.02em; }
.brand-sub { font-size: 11.5px; color: var(--text-faint); margin-top: -2px; }

.nav-btn {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  color: var(--text-dim);
  font-weight: 550;
  font-size: 14.5px;
  text-align: left;
  width: 100%;
  transition: background .12s, color .12s;
}
.nav-btn:hover { background: var(--card-2); color: var(--text); }
.nav-btn.active { background: var(--accent-soft); color: var(--accent); }
.nav-btn .ico { width: 19px; height: 19px; flex: none; }
.nav-btn .badge {
  margin-left: auto;
  background: var(--accent); color: var(--accent-text);
  font-size: 11px; font-weight: 700;
  min-width: 19px; height: 19px; line-height: 19px;
  padding: 0 5px; border-radius: 10px; text-align: center;
}

.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 2px; }
.sidebar-foot .nav-btn { font-size: 13.5px; padding: 8px 12px; }

/* ---------- Area principale ---------- */

.main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  padding-bottom: env(safe-area-inset-bottom);
}

.topbar {
  position: sticky; top: 0; z-index: 30;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--line-soft);
  padding: 14px 24px;
  padding-top: max(14px, env(safe-area-inset-top));
  display: flex; align-items: center; gap: 14px;
}
.topbar h1 { font-size: 21px; }
.topbar .sub { font-size: 13px; color: var(--text-dim); margin-top: 1px; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.view { padding: 22px 24px 40px; max-width: 1080px; width: 100%; }
.view[hidden] { display: none; }

/* ---------- Elementi comuni ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 15px;
  border-radius: 10px;
  background: var(--card-2);
  color: var(--text);
  font-weight: 570; font-size: 14px;
  border: 1px solid transparent;
  transition: filter .12s, background .12s;
  white-space: nowrap;
}
.btn:hover { filter: brightness(.96); }
.btn svg { width: 17px; height: 17px; flex: none; }
.btn-primary { background: var(--accent); color: var(--accent-text); }
.btn-ghost { background: transparent; border-color: var(--line); }
.btn-ghost:hover { background: var(--card-2); }
.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-icon { padding: 8px; border-radius: 9px; }
.btn-sm { padding: 6px 11px; font-size: 13px; border-radius: 8px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow);
}

.section-title {
  font-size: 12.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .07em;
  color: var(--text-faint);
  margin: 26px 0 11px;
  display: flex; align-items: center; gap: 8px;
}
.section-title:first-child { margin-top: 0; }

.empty {
  text-align: center;
  padding: 34px 20px;
  color: var(--text-faint);
  font-size: 14px;
}
.empty strong {
  display: block; color: var(--text-dim);
  font-size: 15px; margin-bottom: 4px; font-weight: 600;
}

/* ---------- Cruscotto di apertura ---------- */

.hero {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 20px 22px;
  box-shadow: var(--shadow);
  margin-bottom: 22px;
}
.hero-top { display: flex; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.hero-greet { font-size: 19px; font-weight: 650; letter-spacing: -.015em; }
.hero-msg { color: var(--text-dim); font-size: 14px; margin-top: 3px; max-width: 52ch; }
.hero-ring { margin-left: auto; display: flex; align-items: center; gap: 14px; }

.ring { position: relative; width: 62px; height: 62px; flex: none; }
.ring svg { transform: rotate(-90deg); width: 62px; height: 62px; }
.ring-bg { stroke: var(--line); }
.ring-fg { stroke: var(--accent); stroke-linecap: round; transition: stroke-dashoffset .5s cubic-bezier(.4,0,.2,1); }
.ring-label {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  font-size: 14px; font-weight: 700;
}

.hero-stats { display: flex; gap: 10px; margin-top: 18px; flex-wrap: wrap; }
.stat {
  flex: 1 1 118px;
  background: var(--card-2);
  border-radius: var(--r-sm);
  padding: 11px 13px;
}
.stat-n { font-size: 20px; font-weight: 700; letter-spacing: -.02em; line-height: 1.2; }
.stat-l { font-size: 12px; color: var(--text-dim); margin-top: 1px; }
.stat.hot .stat-n { color: var(--warn); }

/* ---------- Riga impegno ---------- */

.task {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px 14px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  margin-bottom: 8px;
  transition: border-color .12s, opacity .2s;
}
.task:hover { border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); }
.task.done { opacity: .5; }
.task.done .task-title { text-decoration: line-through; }
.task.overdue { border-color: color-mix(in srgb, var(--danger) 45%, var(--line)); }

.check {
  width: 21px; height: 21px; flex: none;
  border: 2px solid var(--line);
  border-radius: 7px;
  margin-top: 1px;
  display: grid; place-items: center;
  transition: background .13s, border-color .13s;
}
.check:hover { border-color: var(--accent); }
.check svg { width: 13px; height: 13px; opacity: 0; color: #fff; transition: opacity .13s; }
.task.done .check { background: var(--ok); border-color: var(--ok); }
.task.done .check svg { opacity: 1; }

.task-body { flex: 1; min-width: 0; }
.task-title { font-weight: 540; font-size: 14.8px; word-break: break-word; }
.task-meta {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  font-size: 12.5px; color: var(--text-dim);
  margin-top: 3px;
}
.task-meta .late { color: var(--danger); font-weight: 620; }
.task-note { font-size: 13px; color: var(--text-dim); margin-top: 4px; white-space: pre-wrap; }

.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11.5px; font-weight: 620;
  background: var(--card-2); color: var(--text-dim);
}
.pill.goal { background: var(--accent-soft); color: var(--accent); }
.pill.p-alta { background: var(--danger-soft); color: var(--danger); }
.pill.p-bassa { background: var(--card-2); color: var(--text-faint); }
.pill.rep { background: var(--ok-soft); color: var(--ok); }

.task-actions { display: flex; gap: 2px; opacity: 0; transition: opacity .12s; }
.task:hover .task-actions, .task:focus-within .task-actions { opacity: 1; }
@media (hover: none) { .task-actions { opacity: 1; } }
.task-actions button {
  padding: 5px; border-radius: 7px; color: var(--text-faint);
  display: grid; place-items: center;
}
.task-actions button:hover { background: var(--card-2); color: var(--text); }
.task-actions svg { width: 16px; height: 16px; }

/* ---------- Timeline oraria ---------- */

.timeline {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  overflow: hidden;
  box-shadow: var(--shadow);
  position: relative;
}
.hour-row {
  display: grid;
  grid-template-columns: 62px 1fr;
  border-bottom: 1px solid var(--line-soft);
  min-height: 56px;
}
.hour-row:last-child { border-bottom: none; }
.hour-row.now { background: color-mix(in srgb, var(--accent) 6%, transparent); }
.hour-label {
  padding: 9px 12px;
  font-size: 12px; font-weight: 620;
  color: var(--text-faint);
  border-right: 1px solid var(--line-soft);
  font-variant-numeric: tabular-nums;
}
.hour-row.now .hour-label { color: var(--accent); }
.hour-slot { padding: 7px 10px; display: flex; flex-direction: column; gap: 6px; }
.hour-slot:empty::after {
  content: "+ aggiungi qui";
  font-size: 12.5px; color: transparent;
  padding: 3px 2px;
  transition: color .12s;
}
.hour-row:hover .hour-slot:empty::after { color: var(--text-faint); }
.hour-slot .task { margin: 0; padding: 9px 11px; }

.now-line {
  position: absolute; left: 62px; right: 0;
  height: 2px; background: var(--danger);
  z-index: 2; pointer-events: none;
}
.now-line::before {
  content: ""; position: absolute; left: -4px; top: -3px;
  width: 8px; height: 8px; border-radius: 50%; background: var(--danger);
}

/* ---------- Settimana ---------- */

.week-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 9px;
}
.day-col {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 10px 9px;
  min-height: 170px;
  display: flex; flex-direction: column; gap: 6px;
}
.day-col.today { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.day-col.past { opacity: .62; }
.day-head { display: flex; align-items: baseline; gap: 6px; margin-bottom: 3px; }
.day-dow {
  font-size: 11.5px; font-weight: 700; color: var(--text-faint);
  text-transform: uppercase; letter-spacing: .04em;
}
.day-num { font-size: 17px; font-weight: 700; letter-spacing: -.02em; }
.day-col.today .day-num, .day-col.today .day-dow { color: var(--accent); }

.mini {
  font-size: 12.6px;
  padding: 5px 8px;
  border-radius: 7px;
  background: var(--card-2);
  border-left: 3px solid var(--accent);
  cursor: pointer;
  word-break: break-word;
  line-height: 1.35;
  text-align: left;
  width: 100%;
}
.mini:hover { filter: brightness(.96); }
.mini.done { opacity: .45; text-decoration: line-through; border-left-color: var(--ok); }
.mini .t {
  color: var(--text-faint); font-weight: 640; font-size: 11.5px;
  margin-right: 4px; font-variant-numeric: tabular-nums;
}
.day-add {
  margin-top: auto; font-size: 12.5px; color: var(--text-faint);
  padding: 4px; border-radius: 6px; text-align: center;
}
.day-add:hover { background: var(--card-2); color: var(--text); }

/* ---------- Mese ---------- */

.month-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 5px;
}
.month-dow {
  text-align: center; font-size: 11.5px; font-weight: 700;
  color: var(--text-faint); text-transform: uppercase;
  letter-spacing: .05em; padding-bottom: 4px;
}
.mcell {
  aspect-ratio: 1 / 1;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 6px;
  display: flex; flex-direction: column;
  cursor: pointer;
  transition: border-color .12s;
  min-height: 60px;
}
.mcell:hover { border-color: var(--accent); }
.mcell.out { opacity: .32; }
.mcell.today { background: var(--accent-soft); border-color: var(--accent); }
.mcell-n { font-size: 12.5px; font-weight: 650; color: var(--text-dim); }
.mcell.today .mcell-n { color: var(--accent); font-weight: 750; }
.mcell-dots { display: flex; flex-wrap: wrap; gap: 3px; margin-top: auto; }
.mdot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.mdot.done { background: var(--ok); opacity: .5; }
.mdot.late { background: var(--danger); }

/* ---------- Obiettivi ---------- */

.goal-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 18px 19px;
  box-shadow: var(--shadow);
  margin-bottom: 13px;
  border-top: 3px solid var(--accent);
}
.goal-head { display: flex; align-items: flex-start; gap: 12px; }
.goal-title { font-size: 16.5px; font-weight: 660; letter-spacing: -.01em; }
.goal-why {
  font-size: 13.5px; color: var(--text-dim);
  margin-top: 5px; font-style: italic;
  border-left: 2px solid var(--line); padding-left: 10px;
}
.goal-deadline { font-size: 12.5px; color: var(--text-faint); margin-top: 7px; }
.goal-deadline.soon { color: var(--warn); font-weight: 620; }
.goal-deadline.past { color: var(--danger); font-weight: 620; }

.bar {
  height: 9px; background: var(--card-2);
  border-radius: 20px; overflow: hidden; margin-top: 13px;
}
.bar-fill {
  height: 100%; background: var(--accent);
  border-radius: 20px;
  transition: width .45s cubic-bezier(.4,0,.2,1);
}
.bar-fill.full { background: var(--ok); }
.goal-nums {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-top: 7px; font-size: 12.5px; color: var(--text-dim);
}
.goal-nums b { color: var(--text); font-size: 14px; }

.streak {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--warn-soft); color: var(--warn);
  padding: 4px 10px; border-radius: 20px;
  font-size: 12.5px; font-weight: 680;
  margin-top: 11px;
}
.streak.cold { background: var(--card-2); color: var(--text-faint); }
.streak svg { width: 14px; height: 14px; }

.goal-steps { margin-top: 13px; display: flex; flex-direction: column; gap: 5px; }
.step {
  display: flex; align-items: center; gap: 9px;
  font-size: 13.5px; color: var(--text-dim);
  padding: 5px 0;
}
.step .check { width: 18px; height: 18px; border-radius: 6px; margin-top: 0; }
.step.done { color: var(--text-faint); text-decoration: line-through; }
.goal-actions { display: flex; gap: 7px; margin-top: 14px; flex-wrap: wrap; }

/* ---------- Barra di inserimento rapido ---------- */

.quickbar {
  position: sticky; bottom: 0; z-index: 25;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line-soft);
  padding: 12px 24px;
  padding-bottom: max(12px, env(safe-area-inset-bottom));
  display: flex; gap: 9px; align-items: center;
}
.quick-input {
  flex: 1;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px 15px;
  font-size: 14.5px;
  outline: none;
  transition: border-color .13s, box-shadow .13s;
  min-width: 0;
}
.quick-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.quick-input::placeholder { color: var(--text-faint); }

.mic {
  width: 42px; height: 42px; flex: none;
  border-radius: 12px;
  background: var(--card-2);
  display: grid; place-items: center;
  color: var(--text-dim);
  transition: background .15s, color .15s;
}
.mic:hover { background: var(--accent-soft); color: var(--accent); }
.mic svg { width: 19px; height: 19px; }
.mic.listening {
  background: var(--danger); color: #fff;
  animation: pulse 1.4s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--danger) 55%, transparent); }
  50%      { box-shadow: 0 0 0 11px transparent; }
}
.mic[hidden] { display: none; }

/* Invito a parlare dopo il saluto d'apertura. */
.mic.invito {
  background: var(--accent); color: var(--accent-text);
  animation: mic-invito 1.5s ease-in-out infinite;
}
@keyframes mic-invito {
  0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 60%, transparent); }
  50%      { box-shadow: 0 0 0 12px transparent; }
}

.quick-hint {
  font-size: 12px; color: var(--text-faint);
  padding: 0 24px 10px;
  background: var(--bg);
}
.quick-hint code {
  background: var(--card-2); padding: 1px 5px;
  border-radius: 4px; font-size: 11.5px;
}

.heard {
  position: fixed; left: 50%; bottom: 92px;
  transform: translateX(-50%);
  background: var(--text); color: var(--bg);
  padding: 9px 17px; border-radius: 22px;
  font-size: 14px; font-weight: 540;
  box-shadow: var(--shadow-lg);
  z-index: 60; max-width: 88vw;
  text-align: center;
}
.heard[hidden] { display: none; }

/* ---------- Risposta dell'assistente ---------- */

.risposta {
  position: fixed; left: 50%; bottom: 96px;
  transform: translateX(-50%);
  z-index: 65;
  display: flex; align-items: flex-start; gap: 12px;
  background: var(--card);
  border: 1px solid var(--accent);
  border-radius: var(--r-lg);
  padding: 15px 17px;
  box-shadow: var(--shadow-lg);
  max-width: min(560px, calc(100vw - 32px));
  animation: rise .22s cubic-bezier(.2,.8,.3,1);
}
.risposta[hidden] { display: none; }
.risposta-ico { width: 19px; height: 19px; flex: none; color: var(--accent); margin-top: 2px; }
.risposta-ico svg { width: 100%; height: 100%; }
.risposta-corpo { flex: 1; min-width: 0; }
.risposta-testo { font-size: 14.5px; line-height: 1.5; }
.risposta-azioni { display: flex; gap: 7px; margin-top: 11px; flex-wrap: wrap; }
.risposta-azioni[hidden] { display: none; }
#risposta-chiudi {
  flex: none; width: 26px; height: 26px;
  border-radius: 8px; color: var(--text-faint);
  display: grid; place-items: center;
}
#risposta-chiudi:hover { background: var(--card-2); color: var(--text); }
#risposta-chiudi svg { width: 15px; height: 15px; }

/* ---------- Finestra modale ---------- */

.modal-back {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(10,12,20,.55);
  backdrop-filter: blur(3px);
  display: grid; place-items: center;
  padding: 18px;
  animation: fade .16s ease;
}
.modal-back[hidden] { display: none; }
@keyframes fade { from { opacity: 0; } }

.modal {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  width: 100%; max-width: 470px;
  max-height: 88vh; overflow-y: auto;
  animation: rise .2s cubic-bezier(.2,.8,.3,1);
}
@keyframes rise { from { transform: translateY(14px); opacity: 0; } }

.modal-head { padding: 19px 22px 0; display: flex; align-items: center; gap: 12px; }
.modal-head h3 { font-size: 17.5px; }
.modal-head button { margin-left: auto; color: var(--text-faint); padding: 5px; border-radius: 7px; }
.modal-head button:hover { background: var(--card-2); color: var(--text); }
.modal-body { padding: 18px 22px; display: flex; flex-direction: column; gap: 14px; }
.modal-foot {
  padding: 0 22px 20px;
  display: flex; gap: 9px; justify-content: flex-end; flex-wrap: wrap;
}
.modal-foot .spacer { margin-right: auto; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12.5px; font-weight: 640; color: var(--text-dim); }
.field input, .field textarea, .field select {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14.5px;
  outline: none;
  width: 100%;
  transition: border-color .13s, box-shadow .13s;
}
.field input:focus, .field textarea:focus, .field select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.field textarea { resize: vertical; min-height: 62px; font-family: inherit; }
.field-row { display: flex; gap: 11px; }
.field-row .field { flex: 1; min-width: 0; }
.hint { font-size: 12px; color: var(--text-faint); }

.benvenuto-voce {
  font-size: 13.4px;
  line-height: 1.5;
  color: var(--text-dim);
  padding: 10px 12px;
  background: var(--card-2);
  border-radius: 10px;
  margin-bottom: 7px;
}
.benvenuto-voce b { color: var(--text); font-weight: 620; }
.benvenuto-voce code {
  background: var(--bg); padding: 1px 5px;
  border-radius: 4px; font-size: 12px;
}

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  padding: 6px 12px; border-radius: 20px;
  border: 1px solid var(--line);
  font-size: 13px; font-weight: 560;
  color: var(--text-dim);
  transition: background .12s, border-color .12s, color .12s;
}
.chip:hover { border-color: var(--accent); color: var(--accent); }
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }

/* ---------- Impostazioni ---------- */

.set-row {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 16px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  margin-bottom: 8px;
}
.set-row .txt { flex: 1; min-width: 0; }
.set-row .t { font-weight: 580; font-size: 14.5px; }
.set-row .d { font-size: 12.8px; color: var(--text-dim); margin-top: 2px; }

.switch {
  width: 44px; height: 25px; flex: none;
  background: var(--line); border-radius: 20px;
  position: relative; transition: background .18s;
}
.switch::after {
  content: ""; position: absolute;
  top: 3px; left: 3px; width: 19px; height: 19px;
  background: #fff; border-radius: 50%;
  transition: transform .18s cubic-bezier(.4,0,.2,1);
  box-shadow: 0 1px 3px rgba(0,0,0,.25);
}
.switch.on { background: var(--accent); }
.switch.on::after { transform: translateX(19px); }

/* ---------- Notifica interna ---------- */

.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: 22px; z-index: 200;
  background: var(--text); color: var(--bg);
  padding: 11px 19px; border-radius: 12px;
  font-size: 14px; font-weight: 550;
  box-shadow: var(--shadow-lg);
  animation: rise .2s ease;
  max-width: 90vw; text-align: center;
}
.toast[hidden] { display: none; }
.toast.ok { background: var(--ok); color: #fff; }
.toast.err { background: var(--danger); color: #fff; }

/* ---------- Priorità del giorno ---------- */

.task.chiave { border-left: 3px solid var(--warn); }
.task-actions button.acceso { color: var(--warn); }
.task-actions button.acceso svg { fill: color-mix(in srgb, var(--warn) 25%, transparent); }

.blocco-chiave {
  background: color-mix(in srgb, var(--warn) 5%, transparent);
  border: 1px dashed color-mix(in srgb, var(--warn) 35%, var(--line));
  border-radius: var(--r);
  padding: 10px 10px 2px;
}
.blocco-chiave .task { background: var(--card); }

.task.compatto {
  align-items: center;
  padding: 9px 12px;
  border-left: none;
}
.task.compatto .task-title { font-size: 14.2px; }
.compatto-ora {
  font-size: 12.5px; font-weight: 640;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
  flex: none;
}

.section-title svg { width: 14px; height: 14px; }

.suggerimento {
  display: flex; gap: 12px; align-items: flex-start;
  background: var(--card-2);
  border-radius: var(--r);
  padding: 13px 15px;
  font-size: 13.4px;
  color: var(--text-dim);
  line-height: 1.45;
  margin-bottom: 4px;
}
.suggerimento svg { width: 17px; height: 17px; flex: none; margin-top: 1px; color: var(--warn); }

.pill.cat { background: var(--accent-soft); color: var(--accent); opacity: .85; }

/* ---------- Appunti ---------- */

.appunto-nuovo {
  display: flex; gap: 9px; align-items: flex-end;
  margin-bottom: 20px;
}
.appunto-nuovo textarea {
  flex: 1;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 12px 14px;
  font: inherit; font-size: 14.5px;
  resize: vertical; min-height: 54px;
  outline: none;
  transition: border-color .13s, box-shadow .13s;
}
.appunto-nuovo textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.appunto {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 13px 15px;
  margin-bottom: 8px;
  box-shadow: var(--shadow);
}
.appunto.su { border-color: color-mix(in srgb, var(--warn) 45%, var(--line)); }
.appunto-testo { font-size: 14.5px; white-space: pre-wrap; word-break: break-word; }
.appunto-piede {
  display: flex; align-items: center; gap: 10px;
  margin-top: 9px;
}
.appunto-data { font-size: 12px; color: var(--text-faint); }

/* ---------- Grafico dell'andamento ---------- */

.grafico { padding: 18px 16px 14px; }
.grafico-barre {
  display: flex; align-items: flex-end; gap: 5px;
  height: 168px;
}
.col-g {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; align-items: center;
  gap: 5px; height: 100%;
}
.col-val {
  font-size: 10.5px; font-weight: 700; color: var(--text-faint);
  height: 13px; font-variant-numeric: tabular-nums;
}
.col-barra {
  flex: 1; width: 100%;
  background: var(--card-2);
  border-radius: 6px;
  position: relative;
  display: flex; align-items: flex-end;
  overflow: hidden;
}
.col-riemp { width: 100%; border-radius: 6px; transition: height .5s cubic-bezier(.4,0,.2,1); }
.col-riemp.piena  { background: var(--ok); }
.col-riemp.media  { background: var(--accent); }
.col-riemp.scarsa { background: color-mix(in srgb, var(--accent) 45%, var(--card-2)); }
.col-riemp.vuota  { background: transparent; }
.col-focus {
  position: absolute; bottom: 0; left: 50%;
  transform: translateX(-50%);
  width: 4px; border-radius: 3px;
  background: var(--warn);
  opacity: .9;
}
.col-etich {
  font-size: 10.5px; color: var(--text-faint);
  text-align: center; line-height: 1.25; font-weight: 620;
}
.col-etich span { display: block; font-weight: 500; opacity: .75; }
.col-g.adesso .col-etich { color: var(--accent); font-weight: 750; }

.legenda {
  display: flex; gap: 14px; flex-wrap: wrap;
  margin-top: 14px; padding-top: 12px;
  border-top: 1px solid var(--line-soft);
  font-size: 11.5px; color: var(--text-faint);
}
.legenda span { display: inline-flex; align-items: center; gap: 5px; }
.legenda .q { width: 9px; height: 9px; border-radius: 3px; display: inline-block; }
.legenda .q.piena { background: var(--ok); }
.legenda .q.media { background: var(--accent); }
.legenda .q.scarsa { background: color-mix(in srgb, var(--accent) 45%, var(--card-2)); }
.legenda .q.focus { background: var(--warn); width: 4px; border-radius: 2px; }

/* ---------- Sessione di concentrazione ---------- */

.focus {
  position: fixed; right: 20px; bottom: 84px; z-index: 70;
  display: flex; align-items: center; gap: 14px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 13px 16px;
  box-shadow: var(--shadow-lg);
  animation: rise .25s cubic-bezier(.2,.8,.3,1);
  max-width: calc(100vw - 40px);
}
.focus[hidden] { display: none; }
.focus.sospeso { opacity: .68; }
.focus.riposo { border-color: var(--ok); }

.focus-ring { position: relative; width: 72px; height: 72px; flex: none; }
.focus-ring svg { transform: rotate(-90deg); width: 72px; height: 72px; }
.fr-bg { stroke: var(--card-2); }
.fr-fg { stroke: var(--accent); transition: stroke-dashoffset 1s linear; }
.focus.riposo .fr-fg { stroke: var(--ok); }
.focus-tempo {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  font-size: 15px; font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.02em;
}
.focus-testo { min-width: 0; }
.focus-titolo {
  font-weight: 620; font-size: 14.5px;
  max-width: 210px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.focus-fase { font-size: 12.3px; color: var(--text-dim); margin-top: 2px; }
.focus-cmd { display: flex; flex-direction: column; gap: 5px; }

/* ---------- Barra di ricerca ---------- */

.cerca-box {
  display: flex; align-items: center; gap: 9px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 14px;
  margin-bottom: 18px;
}
.cerca-box svg { width: 18px; height: 18px; color: var(--text-faint); flex: none; }
.cerca-box input {
  flex: 1; border: none; background: none; outline: none;
  font-size: 15px; min-width: 0;
}

/* ---------- Rassegna serale ---------- */

.rassegna-riga {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px;
  background: var(--card-2);
  border-radius: 10px;
  margin-bottom: 7px;
}
.rassegna-riga .titolo { flex: 1; min-width: 0; font-size: 14px; }
.rassegna-riga .scelte { display: flex; gap: 5px; }

/* ---------- Studio ---------- */

.studio-testata {
  display: flex; align-items: flex-start; gap: 14px;
  margin-bottom: 20px; flex-wrap: wrap;
}
.studio-testata > div:first-child { flex: 1; min-width: 0; }
.studio-titolo { font-size: 21px; font-weight: 680; letter-spacing: -.015em; word-break: break-word; }
.studio-sub { font-size: 13px; color: var(--text-dim); margin-top: 3px; }

.materiale {
  display: flex; align-items: center; gap: 4px;
  width: 100%;
  padding: 8px 12px 8px 8px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  margin-bottom: 8px;
  transition: border-color .12s, background .12s;
}
.materiale:hover { border-color: var(--accent); }
.materiale.sul-tavolo {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 7%, var(--card));
}

.mat-apri {
  flex: 1; min-width: 0;
  display: flex; align-items: center; gap: 13px;
  text-align: left; padding: 5px 3px;
}

/* Il segno di spunta che mette un documento sul tavolo */
.mat-scelta {
  width: 26px; height: 26px; flex: none;
  border: 2px solid var(--line);
  border-radius: 8px;
  display: grid; place-items: center;
  color: #fff;
  transition: background .13s, border-color .13s;
}
.mat-scelta:hover { border-color: var(--accent); }
.mat-scelta.on { background: var(--accent); border-color: var(--accent); }
.mat-scelta svg { width: 14px; height: 14px; }

/* ---------- Barra del tavolo ---------- */

.tavolo-barra {
  position: sticky; bottom: 0;
  display: flex; align-items: center; gap: 10px;
  margin-top: 14px;
  padding: 12px 14px;
  background: color-mix(in srgb, var(--card) 96%, transparent);
  backdrop-filter: blur(12px);
  border: 1px solid var(--accent);
  border-radius: var(--r);
  box-shadow: var(--shadow);
}
.tv-testo { flex: 1; min-width: 0; }
.tv-testo b { display: block; font-size: 13.5px; }
.tv-testo span {
  display: block; font-size: 12.2px; color: var(--text-dim);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.tavolo-elenco { margin-bottom: 16px; }
.tv-doc {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  margin-bottom: 7px;
}
.tv-num {
  width: 26px; height: 26px; flex: none;
  border-radius: 50%;
  background: var(--accent-soft); color: var(--accent);
  display: grid; place-items: center;
  font-size: 12.5px; font-weight: 700;
}
.tv-tit { font-weight: 570; font-size: 14.3px; }
.tv-meta { font-size: 12.2px; color: var(--text-dim); margin-top: 2px; }
.mat-icona {
  width: 34px; height: 34px; flex: none;
  border-radius: 9px;
  background: var(--accent-soft); color: var(--accent);
  display: grid; place-items: center;
}
.mat-icona svg { width: 18px; height: 18px; }
.mat-corpo { flex: 1; min-width: 0; }
.mat-titolo { font-weight: 570; font-size: 14.8px; word-break: break-word; }
.mat-meta { font-size: 12.3px; color: var(--text-dim); margin-top: 2px; }

.studio-chiedi { display: flex; gap: 9px; margin-bottom: 10px; }
.studio-chiedi input {
  flex: 1; min-width: 0;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 11px 14px;
  font-size: 14.5px; outline: none;
  transition: border-color .13s, box-shadow .13s;
}
.studio-chiedi input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.studio-scorciatoie { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }

.studio-invito {
  display: flex; align-items: center; gap: 10px;
  background: var(--card-2);
  border-radius: var(--r);
  padding: 11px 14px;
  font-size: 13px; color: var(--text-dim);
  margin-bottom: 12px;
}
.studio-invito svg { width: 17px; height: 17px; flex: none; color: var(--accent); }

/* ---------- Deposito: si trascina o si incolla ---------- */

.deposito {
  display: flex; align-items: center; gap: 16px;
  border: 2px dashed var(--line);
  border-radius: var(--r-lg);
  padding: 22px 24px;
  background: var(--card);
  transition: border-color .16s, background .16s, transform .16s;
  margin-bottom: 12px;
}
.deposito.sopra {
  border-color: var(--accent);
  background: var(--accent-soft);
  transform: scale(1.008);
}
.deposito.occupato { border-style: solid; border-color: var(--accent); }
.deposito.occupato .dep-icona { animation: dep-lavora 1.1s ease-in-out infinite; }
@keyframes dep-lavora { 0%,100% { opacity: .35; } 50% { opacity: 1; } }

.dep-icona {
  width: 46px; height: 46px; flex: none;
  border-radius: 13px;
  background: var(--accent-soft); color: var(--accent);
  display: grid; place-items: center;
}
.dep-icona svg { width: 23px; height: 23px; }
.dep-testo { flex: 1; min-width: 0; font-size: 14.5px; line-height: 1.5; }
.dep-testo b { font-weight: 620; }
.dep-testo span { color: var(--text-dim); font-size: 13.2px; }

.dep-incolla {
  width: 100%;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 13px 15px;
  font: inherit; font-size: 14.3px;
  min-height: 86px; resize: vertical;
  outline: none;
  transition: border-color .13s, box-shadow .13s;
}
.dep-incolla:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.dep-azione {
  display: flex; align-items: center; gap: 12px;
  margin-top: 10px;
}
.dep-azione[hidden] { display: none; }
.dep-azione span { font-size: 12.8px; color: var(--text-dim); flex: 1; }

/* ---------- Il filo delle domande ---------- */

.studio-filo { margin-bottom: 14px; }

.sd-scambio { margin-bottom: 20px; }

.sd-tu {
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 14px 14px 4px 14px;
  padding: 10px 14px;
  font-size: 14px; font-weight: 540;
  margin-left: auto;
  max-width: 82%;
  width: fit-content;
  word-break: break-word;
}

.sd-lui {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 4px 14px 14px 14px;
  padding: 15px 17px;
  margin-top: 9px;
  font-size: 14.4px;
  line-height: 1.62;
  box-shadow: var(--shadow);
}
.sd-lui.fallito { border-left: 3px solid var(--warn); }

/* Il markdown reso dalle risposte di studio */
.sd-lui p { margin: 0 0 10px; }
.sd-lui p:last-child { margin-bottom: 0; }
.sd-lui ul, .sd-lui ol { margin: 0 0 12px; padding-left: 22px; }
.sd-lui li { margin-bottom: 5px; }
.sd-lui li:last-child { margin-bottom: 0; }
.sd-lui b { font-weight: 660; color: var(--text); }
.sd-lui code {
  background: var(--card-2); padding: 1px 5px;
  border-radius: 4px; font-size: 13px;
}
.sr-titolo {
  font-size: 14.5px; font-weight: 680;
  margin: 16px 0 8px; color: var(--accent);
  letter-spacing: -.01em;
}
.sd-lui .sr-titolo:first-child { margin-top: 0; }

.sd-attesa {
  display: flex; align-items: center; gap: 10px;
  color: var(--text-faint); font-style: italic;
}
.sd-attesa i {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent); display: inline-block;
  animation: sd-pulsa 1.1s ease-in-out infinite;
}
@keyframes sd-pulsa { 0%,100% { opacity: .25; transform: scale(.75); } 50% { opacity: 1; transform: scale(1); } }

.studio-vuoto-filo {
  display: flex; gap: 13px; align-items: flex-start;
  background: var(--card-2);
  border-radius: var(--r);
  padding: 16px 18px;
  font-size: 13.4px; line-height: 1.5;
  color: var(--text-dim);
}
.studio-vuoto-filo svg { width: 20px; height: 20px; flex: none; color: var(--accent); margin-top: 1px; }

/* ---------- Sezioni ripiegabili ---------- */

.studio-piega {
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--card);
  margin-bottom: 8px;
  overflow: hidden;
}
.studio-piega summary {
  padding: 13px 16px;
  font-size: 13.5px; font-weight: 570;
  cursor: pointer;
  color: var(--text-dim);
  list-style: none;
  display: flex; align-items: center; gap: 9px;
}
.studio-piega summary::-webkit-details-marker { display: none; }
.studio-piega summary::before {
  content: "›";
  font-size: 17px; line-height: 1;
  transition: transform .16s;
  color: var(--text-faint);
}
.studio-piega[open] summary::before { transform: rotate(90deg); }
.studio-piega summary:hover { color: var(--text); }
.studio-piega > *:not(summary) { padding: 0 16px 14px; }

/* ---------- Esempi nella schermata vuota ---------- */

.studio-esempi {
  margin-top: 24px; text-align: left;
  display: flex; flex-wrap: wrap; gap: 7px;
  justify-content: center;
}
.se-titolo {
  flex: 1 1 100%; text-align: center;
  font-size: 12px; letter-spacing: .06em;
  text-transform: uppercase; color: var(--text-faint);
  margin-bottom: 4px;
}
.studio-esempi span {
  background: var(--card-2);
  border-radius: 20px;
  padding: 6px 13px;
  font-size: 13px; color: var(--text-dim);
}

.studio-passo {
  font-size: 13.4px; line-height: 1.55;
  padding: 9px 12px;
  background: var(--card-2);
  border-radius: 9px;
  margin-bottom: 6px;
}
.studio-passo mark {
  background: var(--accent); color: var(--accent-text);
  padding: 0 3px; border-radius: 3px;
}

.studio-chiavi { display: flex; gap: 6px; flex-wrap: wrap; }
.studio-chiavi .pill b { opacity: .6; font-weight: 700; }

.studio-testo {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 16px 18px;
  font-size: 14.2px; line-height: 1.65;
  white-space: pre-wrap; word-break: break-word;
  max-height: 420px; overflow-y: auto;
}

.studio-avviso {
  display: flex; gap: 12px; align-items: flex-start;
  background: var(--warn-soft);
  border-radius: var(--r);
  padding: 13px 15px;
  font-size: 13.2px; line-height: 1.5;
  color: var(--text-dim);
}
.studio-avviso svg { width: 18px; height: 18px; flex: none; color: var(--warn); margin-top: 1px; }

/* ---------- Barra inferiore (mobile) ---------- */

.tabbar { display: none; }

/* ---------- Adattamento mobile ---------- */

@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { display: none; }

  .main { padding-bottom: calc(var(--tabbar-h) + 62px + env(safe-area-inset-bottom)); }
  .topbar { padding: 12px 16px; padding-top: max(12px, env(safe-area-inset-top)); }
  .topbar h1 { font-size: 19px; }
  .view { padding: 16px 16px 24px; }

  .quickbar {
    position: fixed; left: 0; right: 0;
    bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
    padding: 10px 14px;
  }
  .quick-hint { display: none; }

  .tabbar {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    background: var(--bg-soft);
    border-top: 1px solid var(--line);
  }
  .tab {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 3px; color: var(--text-faint);
    font-size: 10.5px; font-weight: 620;
    position: relative;
  }
  .tab svg { width: 21px; height: 21px; }
  .tab.active { color: var(--accent); }
  .tab .badge {
    position: absolute; top: 7px; right: 50%; margin-right: -18px;
    background: var(--danger); color: #fff;
    font-size: 9.5px; font-weight: 700;
    min-width: 16px; height: 16px; line-height: 16px;
    padding: 0 4px; border-radius: 8px; text-align: center;
  }

  .heard { bottom: 148px; }
  .risposta { bottom: 152px; padding: 13px 14px; }

  .focus {
    right: 12px; left: 12px;
    bottom: calc(var(--tabbar-h) + 74px + env(safe-area-inset-bottom));
    padding: 11px 13px; gap: 11px;
  }
  .focus-ring { width: 58px; height: 58px; }
  .focus-ring svg { width: 58px; height: 58px; }
  .focus-tempo { font-size: 13px; }
  .focus-titolo { max-width: 42vw; }
  .focus-cmd { margin-left: auto; }

  .grafico-barre { height: 138px; gap: 3px; }
  .col-val { font-size: 9px; }
  .appunto-nuovo { flex-direction: column; align-items: stretch; }

  /*
    Sul telefono i controlli non stanno accanto alla descrizione:
    con quattro pastiglie del tema finivano una sopra l'altra.
    Qui la riga va a capo e il controllo prende tutta la larghezza.
  */
  .set-row { flex-wrap: wrap; align-items: flex-start; }
  .set-row .txt { flex: 1 1 100%; }
  .set-row .chips { flex: 1 1 100%; }
  .set-row .chips .chip { flex: 1 1 auto; text-align: center; }
  .set-row > select,
  .set-row > input:not([type="checkbox"]) { flex: 1 1 100%; max-width: none !important; }

  /* L'interruttore invece deve restare in linea con il testo. */
  .set-row:has(.switch) { flex-wrap: nowrap; align-items: center; }
  .set-row:has(.switch) .txt { flex: 1; }

  .week-grid { grid-template-columns: 1fr; gap: 8px; }
  .day-col { min-height: auto; }
  .field-row { flex-direction: column; gap: 14px; }
  .hero-ring { margin-left: 0; width: 100%; margin-top: 12px; }
  .hour-row { grid-template-columns: 52px 1fr; }
  .now-line { left: 52px; }
  .mcell { min-height: 46px; padding: 4px; }
}

@media (max-width: 380px) {
  .stat { flex-basis: 100%; }
}

@media print {
  .sidebar, .tabbar, .quickbar, .topbar-actions { display: none !important; }
}
