/* ==========================================================================
   GaiAi · stile "iOS" con accento verde salvia
   Tutti i colori e le misure sono variabili: per cambiare il look si parte da qui.
   ========================================================================== */

:root {
  color-scheme: light dark;

  /* superfici e testo */
  --bg: #f2f2ee;
  --surface: #ffffff;
  --surface-2: #f6f6f2;
  --ink: #1c1c1a;
  --muted: #6f6c66;
  --faint: #b3b0a8;
  --line: rgba(28, 28, 26, 0.09);
  --seg-on: #ffffff;           /* voce scelta nei selettori (Lista | Bacheca, Tema…) */

  /* accento verde salvia */
  --accent: #4e7a68;
  --accent-ink: #2f5d4f;
  --accent-soft: #e4ede8;
  --on-accent: #ffffff;

  /* stati */
  --danger: #c2412d;
  --danger-soft: #fbe9e5;
  --warn: #a2650f;
  --warn-soft: #f7ecd8;

  /* colori per tipo di elemento */
  --t-chiamata: #2f6fd6;      --t-chiamata-soft: #e5edfb;
  --t-appuntamento: #7350c4;  --t-appuntamento-soft: #eee8fa;
  --t-scadenza: #a8690c;      --t-scadenza-soft: #f7ecd8;
  --t-task: #6f6c66;          --t-task-soft: #eeede8;
  --t-evento: #4e7a68;        --t-evento-soft: #e4ede8;

  /* misure */
  --radius: 14px;
  --radius-sm: 9px;
  --sidebar: 236px;
  --tabbar: 64px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI Variable Text", "Segoe UI",
          Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* tema scuro: automatico (segue il telefono) oppure scelto in Altro → Aspetto (data-theme su <html>) */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111110;
    --surface: #1c1c1a;
    --surface-2: #242422;
    --ink: #ecebe6;
    --muted: #a19e96;
    --faint: #5f5c57;
    --line: rgba(255, 255, 255, 0.08);
    --seg-on: #3d3d3a;

    --accent: #7fae99;
    --accent-ink: #a3cbb8;
    --accent-soft: #21312a;
    --on-accent: #10201a;

    --danger: #f07c68;
    --danger-soft: #3a1f1a;
    --warn: #e0a64b;
    --warn-soft: #382a14;

    --t-chiamata: #7fa9f2;      --t-chiamata-soft: #1c2940;
    --t-appuntamento: #ab8ff0;  --t-appuntamento-soft: #2a2340;
    --t-scadenza: #e0a64b;      --t-scadenza-soft: #382a14;
    --t-task: #a19e96;          --t-task-soft: #2a2a27;
    --t-evento: #7fae99;        --t-evento-soft: #21312a;
  }
}
:root[data-theme="dark"] {
  --bg: #111110;
  --surface: #1c1c1a;
  --surface-2: #242422;
  --ink: #ecebe6;
  --muted: #a19e96;
  --faint: #5f5c57;
  --line: rgba(255, 255, 255, 0.08);
  --seg-on: #3d3d3a;

  --accent: #7fae99;
  --accent-ink: #a3cbb8;
  --accent-soft: #21312a;
  --on-accent: #10201a;

  --danger: #f07c68;
  --danger-soft: #3a1f1a;
  --warn: #e0a64b;
  --warn-soft: #382a14;

  --t-chiamata: #7fa9f2;      --t-chiamata-soft: #1c2940;
  --t-appuntamento: #ab8ff0;  --t-appuntamento-soft: #2a2340;
  --t-scadenza: #e0a64b;      --t-scadenza-soft: #382a14;
  --t-task: #a19e96;          --t-task-soft: #2a2a27;
  --t-evento: #7fae99;        --t-evento-soft: #21312a;
}
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }

/* ---------------------------------------------------------------- base */

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 16px/1.4 var(--font);
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.icon {
  width: 20px; height: 20px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.9;
  stroke-linecap: round; stroke-linejoin: round;
}
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------------------------------------------------------------- struttura */

.main {
  padding: max(16px, env(safe-area-inset-top)) 16px calc(var(--tabbar) + 96px + env(safe-area-inset-bottom));  /* spazio per il tasto + */
}
.page { max-width: 760px; margin: 0 auto; }
.page.wide { max-width: 1240px; }

.sidebar { display: none; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; justify-content: space-around;
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(180%) blur(18px);
  -webkit-backdrop-filter: saturate(180%) blur(18px);
  border-top: 0.5px solid var(--line);
}
.tabbar a {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: 11px; color: var(--faint); padding: 4px 0;
}
.tabbar a .icon { width: 24px; height: 24px; }
.tabbar a.on { color: var(--accent); }

@media (min-width: 900px) {
  .tabbar { display: none; }
  .sidebar {
    display: flex; flex-direction: column;
    position: fixed; inset: 0 auto 0 0; width: var(--sidebar);
    padding: 22px 14px; background: var(--surface-2); border-right: 0.5px solid var(--line);
  }
  .main { margin-left: var(--sidebar); padding: 36px 40px 60px; }
}

.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 22px; font-weight: 600; }
.brand img { width: 30px; height: 30px; border-radius: 8px; }
.nav a {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 10px; margin-bottom: 2px; border-radius: var(--radius-sm);
  color: var(--muted); font-size: 15px;
}
.nav a:hover { background: var(--line); color: var(--ink); }
.nav a.on { background: var(--accent-soft); color: var(--accent-ink); font-weight: 500; }
.sidebar .me {
  margin-top: auto; display: flex; align-items: center; gap: 10px;
  padding: 10px 8px; font-size: 14px; color: var(--muted);
}
.sidebar .me a { margin-left: auto; display: flex; padding: 4px; border-radius: 6px; }
.sidebar .me a:hover { color: var(--ink); background: var(--line); }

/* ---------------------------------------------------------------- titoli */

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin: 4px 0 16px; }
.page-head h1 { font-size: 32px; line-height: 1.1; font-weight: 700; letter-spacing: -0.02em; margin: 0; }
.page-head .sub { color: var(--muted); font-size: 15px; margin-top: 4px; }
.page-head .sub .late { color: var(--danger); }
.page-head .sub .seg { white-space: nowrap; }  /* "1 fatto" non va a capo a metà */
.mobile-me { display: flex; align-items: center; }
@media (min-width: 900px) { .mobile-me { display: none; } }

.avatar {
  width: 32px; height: 32px; border-radius: 50%; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent-soft); color: var(--accent-ink); font-size: 13px; font-weight: 600;
}

/* ---------------------------------------------------------------- composer (scrivi come su Telegram) */

.composer {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface); border-radius: var(--radius);
  padding: 6px 6px 6px 14px; margin-bottom: 8px;
  box-shadow: 0 0 0 0.5px var(--line);
}
.composer .icon { color: var(--faint); }
.composer input {
  flex: 1; min-width: 0; border: 0; background: transparent; outline: none;
  font-size: 16px; padding: 8px 0;
}
.composer input::placeholder { color: var(--faint); }
.send {
  width: 36px; height: 36px; border-radius: 50%; border: 0; flex: none;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent); color: var(--on-accent);
}
.send .icon { width: 18px; height: 18px; color: var(--on-accent); }
.send:disabled { opacity: 0.5; }
.chat-reply:empty { display: none; }
.bubble {
  background: var(--accent-soft); color: var(--ink); border-radius: var(--radius);
  padding: 10px 14px; margin: 0 0 8px; font-size: 15px; white-space: pre-wrap;
}
.bubble.err { background: var(--danger-soft); color: var(--danger); }
.bubble.thinking { background: var(--surface-2); color: var(--muted); }
.bubble.thinking::after { content: ""; display: inline-block; width: 1.2em; text-align: left; animation: dots 1.2s steps(4) infinite; }
@keyframes dots { 0% { content: ""; } 25% { content: "."; } 50% { content: ".."; } 75% { content: "..."; } }
@media (prefers-reduced-motion: reduce) { .bubble.thinking::after { animation: none; content: "…"; } }
.htmx-request .send { opacity: 0.5; }
.composer-hint { font-size: 12.5px; color: var(--faint); margin: 0 4px 18px; }

/* ---------------------------------------------------------------- gruppi e righe */

.group-title {
  display: flex; align-items: baseline; justify-content: space-between;
  font-size: 13px; color: var(--muted); margin: 22px 16px 6px;
}
.group-title.late { color: var(--danger); }
.group-title a { color: var(--accent-ink); }
.group { background: var(--surface); border-radius: var(--radius); overflow: hidden; }

.row { position: relative; display: flex; align-items: center; gap: 12px; padding: 0 12px 0 14px; min-height: 58px; }
.row + .row::before {
  content: ""; position: absolute; top: 0; left: 52px; right: 0;
  border-top: 0.5px solid var(--line);
}
.row-main { flex: 1; min-width: 0; padding: 10px 0; display: flex; flex-direction: column; gap: 1px; }
.row-title {
  font-size: 16px; overflow: hidden; text-overflow: ellipsis; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2;  /* fino a 2 righe */
}
/* una sola riga, tagliata con "…" se troppo lunga: niente "·" orfani a inizio riga */
.row-meta {
  display: block; font-size: 13.5px; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.row-meta .m + .m::before { content: "·"; margin: 0 6px; color: var(--faint); }
.row-meta .pill { margin-right: 6px; vertical-align: 1px; }
.row-meta .m + .pill { margin-left: 6px; }
.row-meta .late { color: var(--danger); }
.row:hover { background: var(--surface-2); }

.check {
  width: 26px; height: 26px; flex: none; border-radius: 50%;
  border: 2px solid var(--faint); background: transparent; padding: 0;
  display: flex; align-items: center; justify-content: center;
  transition: border-color .15s, background .15s;
}
.check:hover { border-color: var(--accent); }
.is-late .check { border-color: var(--danger); }
.check .icon { width: 16px; height: 16px; stroke-width: 3; color: var(--on-accent); }
.is-done .check { background: var(--accent); border-color: var(--accent); }
.is-done .row-title { color: var(--muted); text-decoration: line-through; }
.check.static { border-style: dashed; cursor: default; }

.badge {
  width: 32px; height: 32px; flex: none; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
}
.badge .icon { width: 18px; height: 18px; }
a.badge:hover { filter: brightness(0.95); }
.t-chiamata { background: var(--t-chiamata-soft); color: var(--t-chiamata); }
.t-appuntamento { background: var(--t-appuntamento-soft); color: var(--t-appuntamento); }
.t-scadenza { background: var(--t-scadenza-soft); color: var(--t-scadenza); }
.t-task { background: var(--t-task-soft); color: var(--t-task); }
.t-evento { background: var(--t-evento-soft); color: var(--t-evento); }

.pill {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 12px; font-weight: 500; line-height: 1; padding: 4px 7px; border-radius: 99px;
}
.pill .icon { width: 13px; height: 13px; }
.pill.doing { background: var(--accent-soft); color: var(--accent-ink); }
.pill.blocked { background: var(--warn-soft); color: var(--warn); }
.pill.prio { background: var(--danger-soft); color: var(--danger); }

.empty {
  background: var(--surface); border-radius: var(--radius);
  padding: 28px 20px; text-align: center; color: var(--muted); font-size: 15px;
}
.empty .icon { width: 30px; height: 30px; color: var(--accent); margin-bottom: 6px; }

details.done-group > summary {
  list-style: none; cursor: pointer; font-size: 13px; color: var(--muted); margin: 22px 16px 6px;
}
details.done-group > summary::-webkit-details-marker { display: none; }
details.done-group > summary::after { content: " ›"; }
details.done-group[open] > summary::after { content: " ⌄"; }

/* ---------------------------------------------------------------- filtri e controlli */

.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 0 0 6px; }
.select {
  appearance: none; -webkit-appearance: none;
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 10px center;
  border: 0; box-shadow: 0 0 0 0.5px var(--line); border-radius: 99px;
  padding: 7px 30px 7px 14px; font-size: 14.5px; max-width: 100%;
}
.select.active { background-color: var(--accent-soft); color: var(--accent-ink); }

.segmented { display: inline-flex; background: var(--line); border-radius: 10px; padding: 2px; gap: 2px; }
.segmented a, .segmented button {
  display: inline-flex; align-items: center; gap: 6px;
  border: 0; background: transparent; border-radius: 8px;
  padding: 6px 12px; font-size: 14px; color: var(--muted);
}
.segmented .on { background: var(--seg-on); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.segmented .icon { width: 16px; height: 16px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 0; border-radius: 10px; padding: 9px 14px; font-size: 15px;
  background: var(--surface); box-shadow: 0 0 0 0.5px var(--line);
}
.btn.primary { background: var(--accent); color: var(--on-accent); box-shadow: none; }
.btn.danger { color: var(--danger); }
.btn .icon { width: 17px; height: 17px; }

/* ---------------------------------------------------------------- bacheca (kanban) */

.board { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; align-items: start; }
@media (min-width: 1100px) {
  .board { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .board.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 1099px) { .board section.is-empty { display: none; } }
.board .group-title { margin-top: 10px; }
.board .row-title { white-space: normal; }

/* ---------------------------------------------------------------- dettaglio */

.back { display: inline-flex; align-items: center; gap: 4px; color: var(--accent-ink); font-size: 16px; margin: 0 0 12px -4px; }
.detail-head { display: flex; gap: 14px; align-items: flex-start; margin-bottom: 18px; }
.detail-head .badge { width: 44px; height: 44px; border-radius: 12px; }
.detail-head .badge .icon { width: 24px; height: 24px; }
.detail-head h1 { font-size: 24px; line-height: 1.2; margin: 2px 0 4px; font-weight: 700; letter-spacing: -0.01em; }
.detail-head .sub { color: var(--muted); font-size: 14.5px; }

.info .kv { display: flex; align-items: center; gap: 12px; padding: 12px 14px; min-height: 48px; }
.info .kv + .kv { border-top: 0.5px solid var(--line); }
.info .k { color: var(--muted); width: 120px; flex: none; font-size: 15px; }
.info .v { flex: 1; min-width: 0; font-size: 15.5px; }
.info .v a { color: var(--accent-ink); }
.info .v.late { color: var(--danger); }

.status-form { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.status-form button {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  border: 0; border-radius: 12px; padding: 10px 4px; font-size: 13px;
  background: var(--surface); color: var(--muted); box-shadow: 0 0 0 0.5px var(--line);
}
.status-form button .icon { width: 20px; height: 20px; }
.status-form button.on { background: var(--accent); color: var(--on-accent); box-shadow: none; }
.status-form button.on.blocked { background: var(--warn); }
.detail-actions { display: flex; justify-content: flex-end; margin-top: 10px; }

.note-form { display: flex; gap: 8px; margin: 0 0 8px; }
.note-form input {
  flex: 1; min-width: 0; border: 0; border-radius: 12px; padding: 11px 14px; font-size: 16px;
  background: var(--surface); box-shadow: 0 0 0 0.5px var(--line); outline: none;
}
.log .entry { padding: 11px 14px; }
.log .entry + .entry { border-top: 0.5px solid var(--line); }
.log .when { font-size: 12.5px; color: var(--muted); }
.log .text { font-size: 15px; margin-top: 1px; }
.log .entry.nota .text { color: var(--ink); }
.log .entry.modifica .text, .log .entry.creato .text { color: var(--muted); }

/* ---------------------------------------------------------------- team */

.person-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 12px 14px; border-bottom: 0.5px solid var(--line); }
.person-head .name { font-weight: 600; flex: 1 1 auto; min-width: 0; }
.person-head .counts { margin-left: auto; display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
/* nome e tasti sulla prima riga, contatori sotto, allineati al nome (anche con tanti contatori) */
.person-head .actions { display: flex; gap: 6px; order: 2; margin-left: auto; }
.person-head .counts { order: 3; width: 100%; margin-left: 0; padding-left: 48px; justify-content: flex-start; }
.person-head .off { font-size: 13px; color: var(--muted); font-weight: 400; }
.team-grid { display: grid; gap: 14px; }
@media (min-width: 1100px) { .team-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.team-grid .group { align-self: start; }
.team-grid .group-title { margin-top: 0; }

/* ---------------------------------------------------------------- login */

.login { min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login .card { background: var(--surface); border-radius: 20px; padding: 32px 28px; max-width: 380px; text-align: center; }
.login img { width: 64px; height: 64px; border-radius: 16px; }
.login h1 { font-size: 22px; margin: 14px 0 6px; }
.login p { color: var(--muted); margin: 0; }
.login code { background: var(--accent-soft); color: var(--accent-ink); padding: 1px 6px; border-radius: 6px; }

/* ---------------------------------------------------------------- modulo modifica, banner, azioni */

.form .field {
  display: flex; align-items: center; gap: 12px; padding: 6px 14px; min-height: 50px; position: relative;
}
.form .field + .field { border-top: 0.5px solid var(--line); }
.form .field > span:first-child { width: 110px; flex: none; color: var(--muted); font-size: 15px; }
.form .field small { color: var(--faint); font-size: 12px; white-space: nowrap; }
.form input:not([type=checkbox]), .form select, .form textarea {
  flex: 1; min-width: 0; border: 0; background: transparent; outline: none;
  font-size: 16px; padding: 8px 0; color: var(--ink);
}
.form select { appearance: none; -webkit-appearance: none; cursor: pointer; }
.form input::placeholder, .form textarea::placeholder { color: var(--faint); }
.form .check-field { gap: 10px; cursor: pointer; }
.form .check-field input { width: 20px; height: 20px; accent-color: var(--accent); margin: 0; }
.form .check-field span { color: var(--ink) !important; width: auto !important; }
.form .field-area { align-items: stretch; }
.form textarea { resize: vertical; min-height: 90px; font: inherit; }
.form textarea.autogrow { resize: none; min-height: 0; overflow: hidden; line-height: 1.35; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.form-actions .btn { min-width: 110px; }
@media (max-width: 600px) { .form-actions .btn { flex: 1; } }

.banner {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  background: var(--warn-soft); color: var(--warn); border-radius: var(--radius); padding: 12px 14px; font-size: 15px;
}
.banner .icon { width: 17px; height: 17px; vertical-align: -3px; }
.detail-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.btn.small { padding: 7px 10px; font-size: 14px; }
.row form { flex: none; }
.link { color: var(--accent-ink); display: inline-flex; align-items: center; gap: 6px; }
.link .icon { width: 16px; height: 16px; }
@media (max-width: 600px) { .hide-sm { display: none; } }

/* ---------------------------------------------------------------- navigazione: nuovo, archivio, altro */

.new-btn { width: 100%; margin: 0 0 16px; }
.nav-title { font-size: 12px; color: var(--faint); margin: 18px 10px 6px; }
.sidebar-bottom { margin-top: auto; }
.sidebar .me { margin-top: 0; }
.nav-link {
  display: flex; align-items: center; gap: 11px; padding: 9px 10px; border-radius: var(--radius-sm);
  color: var(--muted); font-size: 15px;
}
.nav-link:hover { background: var(--line); color: var(--ink); }
.nav-link.on { background: var(--accent-soft); color: var(--accent-ink); font-weight: 500; }

.fab {
  position: fixed; z-index: 25; right: 18px; bottom: calc(var(--tabbar) + 18px + env(safe-area-inset-bottom));
  width: 56px; height: 56px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent); color: var(--on-accent);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18), 0 1px 3px rgba(0, 0, 0, 0.12);
}
.fab .icon { width: 26px; height: 26px; stroke-width: 2.2; }
@media (min-width: 900px) { .fab { display: none; } }

.wide-btn { width: 100%; padding: 13px; font-size: 16px; }
.menu a, .menu .menu-row {
  display: flex; align-items: center; gap: 12px; padding: 0 14px; min-height: 52px; font-size: 16px; position: relative;
}
.menu a + a::before, .menu .menu-row + a::before {
  content: ""; position: absolute; top: 0; left: 46px; right: 0; border-top: 0.5px solid var(--line);
}
.menu a > span, .menu .menu-row > span:not(.avatar) { flex: 1; }
.menu .icon { color: var(--accent-ink); }
.menu .chev { color: var(--faint); width: 18px; height: 18px; }
.menu small { color: var(--muted); font-size: 14px; }
.menu a.danger, .menu a.danger .icon { color: var(--danger); }
.menu a:hover { background: var(--surface-2); }

/* ---------------------------------------------------------------- link, chip, paginazione */

.sub-link { color: inherit; text-decoration: underline; text-decoration-color: var(--faint); text-underline-offset: 3px; }
.sub-link.late { color: var(--danger); }
.chip-link {
  display: inline-flex; align-items: center; gap: 4px; border-radius: 99px; padding: 6px 10px 6px 14px;
  background: var(--accent-soft); color: var(--accent-ink); font-size: 14.5px;
}
.chip-link .icon { width: 15px; height: 15px; }
.toolbar-links { display: flex; gap: 14px; margin-left: auto; font-size: 14.5px; }
@media (max-width: 600px) { .toolbar-links { width: 100%; margin: 4px 4px 0; } }
.pager { display: flex; justify-content: center; gap: 8px; margin: 18px 0 8px; }
a.pill { text-decoration: none; }
a.pill:hover { filter: brightness(0.96); }
.pill.add { background: var(--accent); color: var(--on-accent); padding: 4px 6px; }
.person-head a.name { color: var(--ink); }
.person-head a.name:hover { text-decoration: underline; }
.info .v a { text-decoration: underline; text-decoration-color: var(--faint); text-underline-offset: 3px; }

/* ---------------------------------------------------------------- impostazioni */

.settings-list details + details { border-top: 0.5px solid var(--line); }
.setting summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; gap: 12px; padding: 10px 14px; min-height: 58px;
}
.setting summary::-webkit-details-marker { display: none; }
.setting summary .chev { color: var(--faint); width: 18px; height: 18px; transition: transform .15s; }
.setting[open] summary .chev { transform: rotate(180deg); }
.setting.inactive .s-title { color: var(--muted); }
.s-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.s-title { font-size: 16px; }
.s-body { padding: 4px 14px 14px 58px; }
.inline-form { display: flex; gap: 8px; margin: 6px 0; }
.inline-form input, .invite-row input {
  flex: 1; min-width: 0; border: 0; border-radius: 10px; padding: 9px 12px; font-size: 16px;
  background: var(--surface-2); box-shadow: 0 0 0 0.5px var(--line); outline: none; color: var(--ink);
}
.s-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.invite { margin-bottom: 8px; }
.invite .k { font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.invite-row { display: flex; gap: 8px; }
.invite-row input { font-size: 13.5px; color: var(--muted); }
@media (max-width: 600px) { .s-body { padding-left: 14px; } }

.days-field { flex-wrap: wrap; padding-top: 10px !important; padding-bottom: 10px !important; }
.days { display: flex; flex-wrap: wrap; gap: 6px; flex: 1; }
.day input { position: absolute; opacity: 0; pointer-events: none; }
.day span {
  display: inline-block; min-width: 44px; text-align: center; padding: 7px 8px; border-radius: 9px; font-size: 14px;
  background: var(--surface-2); box-shadow: 0 0 0 0.5px var(--line); color: var(--muted); cursor: pointer;
}
.day input:checked + span { background: var(--accent); color: var(--on-accent); box-shadow: none; }
.day input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------------------------------------------------------------- revisione UX */

/* "+" in alto a destra nella testata (telefono); su PC c'è "Nuovo" nella barra laterale */
.head-actions { display: flex; align-items: center; gap: 10px; }
.head-add {
  width: 36px; height: 36px; border-radius: 50%; flex: none;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent); color: var(--on-accent); position: relative;
}
.head-add .icon { width: 22px; height: 22px; stroke-width: 2.3; }
.head-add::after { content: ""; position: absolute; inset: -6px; }   /* area tocco 48px */
@media (min-width: 900px) { .head-add { display: none; } }

/* ricerca nella barra laterale (PC) */
.side-search {
  display: flex; align-items: center; gap: 8px; margin: -6px 0 14px;
  background: var(--surface); border-radius: 10px; padding: 0 10px; box-shadow: 0 0 0 0.5px var(--line);
}
.side-search .icon { width: 16px; height: 16px; color: var(--faint); }
.side-search input { flex: 1; min-width: 0; border: 0; background: transparent; outline: none; padding: 8px 0; font-size: 14.5px; }
.composer.search { margin-bottom: 12px; }

/* zone da toccare di almeno 44px (Apple HIG) senza cambiare l'aspetto */
.check { position: relative; }
.check::after { content: ""; position: absolute; inset: -10px; }
a.badge { position: relative; }
a.badge::after { content: ""; position: absolute; inset: -7px; }
.person-head .pill { min-height: 28px; padding: 6px 9px; }
.pill.manage { background: var(--surface-2); color: var(--muted); box-shadow: 0 0 0 0.5px var(--line); padding: 6px 7px; }
.group-title a { padding: 8px 0; margin: -8px 0; }

@media (min-width: 900px) { .mobile-only { display: none !important; } }

/* l'attributo hidden vince sempre (es. .field ha display: flex) */
[hidden] { display: none !important; }

/* avviso in basso quando un'azione non riesce */
.toast {
  position: fixed; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  max-width: min(92vw, 460px); padding: 11px 16px; border-radius: 14px; z-index: 50;
  background: var(--ink); color: var(--bg); font-size: 15px; box-shadow: 0 6px 24px rgba(0, 0, 0, 0.18);
  opacity: 0; transition: opacity 0.2s; pointer-events: none;
}
.toast.show { opacity: 1; }
@media (min-width: 900px) { .toast { bottom: 28px; } }

/* Altro → Aspetto */
.menu .menu-row + .menu-row::before {
  content: ""; position: absolute; top: 0; left: 46px; right: 0; border-top: 0.5px solid var(--line);
}
.menu .pref { flex-wrap: wrap; gap: 8px 12px; padding-top: 8px; padding-bottom: 8px; }
.menu .pref > span { display: inline-flex; align-items: center; gap: 12px; }
.menu .pref .segmented { margin-left: auto; }
.segmented.small button { padding: 6px 10px; min-height: 32px; }


button.link { border: 0; background: none; padding: 0; font: inherit; cursor: pointer; }

/* ---------------------------------------------------------------- Agenda: Lista | Mese */
.view-switch { display: flex; width: fit-content; margin: 0 0 14px; }
@media (max-width: 600px) { .view-switch { width: 100%; } .view-switch a { flex: 1; justify-content: center; } }

.cal-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 4px 20px; align-items: start; }
@media (min-width: 1100px) {
  .cal-layout { grid-template-columns: minmax(0, 1fr) 340px; }
  .cal-day-panel { position: sticky; top: 16px; }
  .cal-day-panel .group-title:first-child { margin-top: 52px; }
}
.cal-nav { display: flex; align-items: center; gap: 8px; margin: 0 0 10px; }
.cal-nav h2 { font-size: 19px; font-weight: 650; margin: 0 6px; min-width: 9.5em; text-align: center; }
.cal-nav .cal-today { margin-left: auto; }
.icon-btn { padding: 8px; min-width: 40px; min-height: 40px; justify-content: center; }

.cal {
  display: grid; grid-template-columns: repeat(7, minmax(0, 1fr));
  background: var(--surface); border-radius: var(--radius); overflow: hidden;
  box-shadow: 0 0 0 0.5px var(--line);
}
.cal-wd { padding: 8px 0 6px; text-align: center; font-size: 12px; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.04em; border-bottom: 0.5px solid var(--line); }
.cal-wd .short { display: none; }
.cal-day {
  position: relative; display: flex; flex-direction: column; gap: 3px; min-width: 0;
  min-height: 108px; padding: 6px 6px 8px; color: var(--ink); text-decoration: none;
  border-right: 0.5px solid var(--line); border-bottom: 0.5px solid var(--line);
}
.cal-day:nth-child(7n + 7) { border-right: 0; }          /* ultima colonna (le 7 intestazioni contano) */
.cal-day:hover { background: var(--surface-2); }
.cal-day.out { background: var(--surface-2); }
.cal-day.out .num { color: var(--faint); }
.cal-day .num {
  align-self: flex-start; min-width: 26px; height: 26px; padding: 0 6px; border-radius: 13px;
  display: inline-flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 500;
}
.cal-day.today .num { background: var(--accent); color: var(--on-accent); font-weight: 650; }
.cal-day.sel { box-shadow: inset 0 0 0 2px var(--accent); }
.cal-day.sel:not(.today) .num { color: var(--accent-ink); font-weight: 650; }

.cal-day .chips { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.chip {
  display: block; font-size: 12px; line-height: 1.35; padding: 1px 6px; border-radius: 5px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  border-left: 3px solid var(--t-task); background: var(--t-task-soft); color: var(--ink);
}
.chip b { font-weight: 600; }
.chip.t-chiamata { border-color: var(--t-chiamata); background: var(--t-chiamata-soft); }
.chip.t-appuntamento { border-color: var(--t-appuntamento); background: var(--t-appuntamento-soft); }
.chip.t-scadenza { border-color: var(--t-scadenza); background: var(--t-scadenza-soft); }
.chip.t-evento { border-color: var(--t-evento); background: var(--t-evento-soft); }
.chip.late { color: var(--danger); }
.chip.done { color: var(--muted); text-decoration: line-through; opacity: 0.75; }
.cal-day .more { font-size: 11.5px; color: var(--muted); padding-left: 6px; }

.cal-day .dots { display: none; }
.dots i { width: 6px; height: 6px; border-radius: 3px; background: var(--t-task); }
.dots i.t-chiamata { background: var(--t-chiamata); }
.dots i.t-appuntamento { background: var(--t-appuntamento); }
.dots i.t-scadenza { background: var(--t-scadenza); }
.dots i.t-evento { background: var(--t-evento); }
.dots i.late { background: var(--danger); }
.dots i.done { opacity: 0.35; }

/* telefono e schermi medi: celle compatte con i pallini, la lista del giorno sotto */
@media (max-width: 899px) {
  .cal-wd .long { display: none; }
  .cal-wd .short { display: inline; }
  .cal-day { min-height: 54px; padding: 5px 2px 6px; align-items: center; gap: 5px; }
  .cal-day .num { align-self: center; }
  .cal-day .chips { display: none; }
  .cal-day .dots { display: flex; gap: 3px; flex-wrap: wrap; justify-content: center; max-width: 30px; }
  .cal-nav h2 { font-size: 17px; min-width: 0; flex: 1; }
  .cal-day-panel { margin-top: 6px; }
}
