/* MAVISPED - portale interno. Stile sobrio; nessuna risorsa esterna. */
:root {
  --azzurro: #0078B8; --blu: #1863DC; --blu-scuro: #124ca8; --blu-chiaro: #e8f0fc;
  --notte: #0f1e33; --antracite: #1f2933; --testo: #1f2933; --muted: #4a5563;
  --bianco: #fff; --grigio-50: #f6f8fa; --grigio-100: #eef1f5; --grigio-200: #dfe4ea; --bordo: #d3d9e0;
  --giallo: #F4AC0E; --verde: #1d7a46; --rosso: #b42318;
  --radius: 6px; --radius-sm: 4px;
  --shadow: 0 1px 2px rgba(15,30,51,.08), 0 2px 8px rgba(15,30,51,.08);
  --panel: rgba(255,255,255,.96);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "Liberation Sans", sans-serif;
}
* { box-sizing: border-box; }
html { font-size: 16px; }
body {
  margin: 0; min-height: 100vh; display: flex; flex-direction: column;
  font-family: var(--font); color: var(--testo); line-height: 1.55;
  background-color: #dfe4ea; background-repeat: no-repeat;
  background-size: cover; background-position: center; background-attachment: fixed;
}
a { color: var(--blu-scuro); }
a:hover { color: var(--notte); }
:focus-visible { outline: 3px solid var(--blu); outline-offset: 2px; }
.skip { position: absolute; left: -999px; top: 0; background: var(--bianco); color: var(--notte); padding: .5rem 1rem; z-index: 10; }
.skip:focus { left: 1rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- intestazione ---------- */
.topbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1.5rem; padding: .55rem 1.5rem;
  background: var(--azzurro); color: #fff; border-bottom: 3px solid #0c3f6c;
  position: sticky; top: 0; z-index: 5;
}
.brand { display: flex; align-items: center; gap: .65rem; text-decoration: none; color: #fff; }
.brand:hover { color: #fff; }
.brand-chip { display: inline-flex; align-items: center; }
.brand-chip img { display: block; height: 32px; width: auto; filter: drop-shadow(0 1px 1px rgba(12,63,108,.35)); }
.brand-sub { font-size: .78rem; color: #f2f9fd; letter-spacing: .04em; font-weight: 500; }


.mainnav { display: flex; flex-wrap: wrap; gap: .15rem; flex: 1; }
.mainnav a {
  padding: .45rem .8rem; text-decoration: none; color: #fff; font-weight: 600; font-size: .93rem;
  border-bottom: 2px solid transparent; border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}
.mainnav a:hover { color: #fff; background: rgba(255,255,255,.16); }
.mainnav a.active { color: #fff; border-bottom-color: var(--giallo); background: rgba(12,63,108,.28); }
.userbox { display: flex; align-items: center; gap: .6rem; }
.uname { font-weight: 600; font-size: .9rem; line-height: 1.15; color: #fff; }
.uname small { display: block; font-weight: 400; color: #f2f9fd; font-size: .78rem; }
.topbar .btn.ghost { color: #fff; border-color: rgba(255,255,255,.6); }
.topbar .btn.ghost:hover { background: rgba(255,255,255,.18); }
.avatar { border-radius: 50%; object-fit: cover; background: var(--grigio-100); border: 1px solid var(--bordo); }
.avatar.sm { width: 32px; height: 32px; border-color: rgba(255,255,255,.5); }
.avatar.lg { width: 96px; height: 96px; }
.avatar.xs { width: 22px; height: 22px; flex: 0 0 auto; }
.byline { display: flex; align-items: center; gap: .4rem; }
td.byline { display: table-cell; }
td.byline .avatar { vertical-align: middle; margin-right: .35rem; }
.toast.has-avatar { display: flex; align-items: center; gap: .55rem; }
.toast.has-avatar > .avatar.xs { width: 28px; height: 28px; }

/* ---------- impaginazione ---------- */
main { width: 100%; max-width: 1120px; margin: 1.75rem auto; padding: 0 1rem; flex: 1; }
main.wide { max-width: 1320px; }
h1, h2, h3 { line-height: 1.25; color: var(--notte); font-weight: 600; }
h1 { font-size: 1.55rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.02rem; }
/* titoli e testi fuori dai pannelli: sempre su fondo chiaro opaco, mai direttamente sulla foto */
main > h1, main > section > h1, main > section > h2, main > p.muted, main > section > p.muted {
  background: var(--panel); color: var(--notte); padding: .65rem 1rem; margin: 0 0 1rem;
  border-left: 4px solid var(--blu); border-radius: var(--radius-sm); box-shadow: var(--shadow);
}
main > p.muted, main > section > p.muted { border-left-color: var(--grigio-200); color: var(--muted); }
.card {
  background: var(--panel); border: 1px solid var(--grigio-200); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 1.15rem 1.35rem; margin: 0 0 1rem;
}
@supports ((-webkit-backdrop-filter: blur(4px)) or (backdrop-filter: blur(4px))) {
  .card, main > h1, main > section > h1, main > section > h2, main > p.muted, main > section > p.muted, .tabs, .pin {
    -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  }
}
.card h2 { margin-top: 0; font-size: 1.1rem; padding-bottom: .45rem; border-bottom: 1px solid var(--grigio-200); }
.card h3 { margin: .3rem 0; }
.narrow { max-width: 440px; margin: 2.5rem auto; }
.center { text-align: center; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; }
.row { display: flex; gap: .75rem; align-items: flex-end; flex-wrap: wrap; }
.row.between { justify-content: space-between; align-items: center; }
.row.wrap > label { flex: 1 1 180px; }
.stack { display: flex; flex-direction: column; gap: .8rem; }
.inline { display: inline; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.pre { white-space: pre-wrap; overflow-wrap: anywhere; }
.strike { text-decoration: line-through; color: var(--muted); }
code { background: var(--grigio-100); padding: .05rem .35rem; border-radius: var(--radius-sm); font-size: .9em; }
.hero { border-left: 4px solid var(--blu); }
.hero h1 { margin: .1rem 0 .4rem; }
.tile { text-decoration: none; color: var(--testo); display: block; transition: border-color .15s ease, box-shadow .15s ease; }
.tile:hover { color: var(--testo); border-color: var(--blu); box-shadow: 0 2px 12px rgba(24,99,220,.18); }
.tile h2 { color: var(--blu-scuro); }
.archived { opacity: .7; }

/* ---------- moduli ---------- */
label { display: flex; flex-direction: column; gap: .3rem; font-weight: 600; font-size: .9rem; color: var(--antracite); }
label.opt { flex-direction: row; align-items: center; font-weight: 500; gap: .4rem; }
fieldset { border: 1px solid var(--grigio-200); border-radius: var(--radius); padding: .55rem .85rem; }
legend { font-weight: 600; font-size: .9rem; padding: 0 .3rem; }
input, select, textarea {
  font: inherit; font-weight: 400; padding: .5rem .65rem; border: 1px solid #b9c2cd; border-radius: var(--radius-sm);
  background: #fff; color: var(--testo); max-width: 100%;
}
input:focus, select:focus, textarea:focus { border-color: var(--blu); outline: none; box-shadow: 0 0 0 3px rgba(24,99,220,.2); }
textarea { resize: vertical; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem; font: inherit; font-size: .93rem; font-weight: 600; cursor: pointer;
  padding: .5rem 1rem; min-height: 2.35rem; border-radius: var(--radius-sm); border: 1px solid var(--blu); background: #fff; color: var(--blu-scuro);
  text-decoration: none; line-height: 1.2;
}
.btn:hover { background: var(--blu-chiaro); color: var(--blu-scuro); }
.btn.primary { background: var(--blu); border-color: var(--blu); color: #fff; }
.btn.primary:hover { background: var(--blu-scuro); border-color: var(--blu-scuro); color: #fff; }
.btn.danger { border-color: var(--rosso); color: var(--rosso); }
.btn.danger:hover { background: #fdf0ef; }
.btn.ghost { border-color: transparent; background: transparent; color: inherit; }
.btn.ghost:hover { background: rgba(0,0,0,.06); }
.btn.sm { padding: .25rem .7rem; min-height: 1.9rem; font-size: .84rem; }
.btn[disabled] { opacity: .6; cursor: default; }
.flash { padding: .7rem 1rem; border-radius: var(--radius-sm); margin: 0 0 1rem; font-weight: 500; background: #fff; border: 1px solid var(--grigio-200); box-shadow: var(--shadow); }
.flash.ok { border-left: 4px solid var(--verde); }
.flash.err { border-left: 4px solid var(--rosso); }

/* ---------- tabelle ---------- */
.tablewrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { text-align: left; padding: .55rem .65rem; border-bottom: 1px solid var(--grigio-200); vertical-align: top; overflow-wrap: anywhere; }
th { background: var(--grigio-100); font-weight: 600; color: var(--antracite); font-size: .85rem; text-transform: uppercase; letter-spacing: .03em; }
tbody tr:hover td { background: var(--grigio-50); }
table.compact td { padding: .3rem .5rem; font-size: .85rem; }
td.actions { white-space: nowrap; }
tr.sub td { background: var(--grigio-50); }

/* ---------- bacheca ---------- */
.pins { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.pin { background: var(--panel); border: 1px solid var(--grigio-200); border-top: 3px solid var(--blu); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem 1.15rem; }
.pin.status-eseguito { border-top-color: var(--verde); }
.pin.filepin.status-nuovo { border-top-color: var(--giallo); background: #fff; }
.pin.filepin.status-letto { opacity: .9; }
.pin.filepin h3 { overflow-wrap: anywhere; }
.pin header { display: flex; justify-content: space-between; gap: .5rem; font-size: .84rem; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
details.sent { border-bottom: 1px solid var(--grigio-200); padding: .45rem 0; }
details.sent:last-child { border-bottom: none; }
details summary { cursor: pointer; }
.badge { display: inline-block; padding: .08rem .5rem; border-radius: var(--radius-sm); background: var(--grigio-100); color: var(--antracite); font-size: .78rem; font-weight: 600; white-space: nowrap; text-transform: none; letter-spacing: 0; border: 1px solid var(--grigio-200); }
.st-nuovo { background: #fff6e0; border-color: #f1d79a; color: #6b4a00; }
.st-letto { background: var(--blu-chiaro); border-color: #c4d6f5; color: #123d85; }
.st-in_lavorazione { background: #fdf1e3; border-color: #efcfa6; color: #7a3f00; }
.st-eseguito { background: #e5f4ec; border-color: #b7dec8; color: #155c35; }
.chips { display: flex; flex-wrap: wrap; gap: .35rem; margin: .7rem 0 .4rem; }
.chip { font: inherit; font-size: .82rem; padding: .25rem .65rem; border-radius: var(--radius-sm); border: 1px solid #b9c2cd; background: #fff; color: var(--antracite); cursor: pointer; }
.chip:hover { border-color: var(--blu); }
.chip.on { background: var(--blu); color: #fff; border-color: var(--blu); }
.checklist { list-style: none; padding: 0; margin: .4rem 0; }
.checklist li { margin: .2rem 0; }
.checkbtn { font-size: 1.1rem; background: none; border: none; cursor: pointer; padding: 0 .3rem; color: var(--blu); }
.blocks { list-style: none; padding: 0; margin: 0; }
.blocks li { padding: .55rem 0; border-bottom: 1px solid var(--grigio-200); }
.blocks li:last-child { border-bottom: none; }

/* ---------- chat ---------- */
.tabs { display: flex; gap: .25rem; flex-wrap: wrap; margin-bottom: 1rem; background: var(--panel); padding: .3rem; border-radius: var(--radius); border: 1px solid var(--grigio-200); box-shadow: var(--shadow); }
.tabs a { padding: .4rem .9rem; border-radius: var(--radius-sm); text-decoration: none; color: var(--antracite); font-weight: 600; font-size: .92rem; }
.tabs a:hover { background: var(--grigio-100); }
.tabs a.active { background: var(--blu); color: #fff; }
.messages { list-style: none; margin: 0; padding: .5rem; height: 55vh; min-height: 280px; overflow-y: auto; display: flex; flex-direction: column; gap: .55rem; background: var(--grigio-50); border: 1px solid var(--grigio-200); border-radius: var(--radius-sm); }
.msg { display: flex; gap: .5rem; align-items: flex-end; max-width: 85%; }
.msg.mine { align-self: flex-end; flex-direction: row-reverse; }
.msg .bubble { background: #fff; border: 1px solid var(--grigio-200); border-radius: var(--radius); padding: .45rem .75rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.mine .bubble { background: var(--blu); border-color: var(--blu); color: #fff; }
.msg.cosimo .bubble { background: #fff; border-left: 3px solid var(--blu); }
.msg.system .bubble { background: var(--grigio-100); font-style: italic; }
.msg .meta { display: block; font-size: .72rem; opacity: .8; margin-bottom: .1rem; }
.chatform { display: flex; gap: .5rem; margin-top: .75rem; align-items: flex-end; }
.chatform textarea { flex: 1; }

/* ---------- chat e file (sezione unica) ---------- */
.hub { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 1.25rem; align-items: start; }
.hub-chat { position: sticky; top: 4.5rem; }
.chat h2 { margin-bottom: .6rem; }
.dropzone { transition: box-shadow .15s ease, border-color .15s ease; }
.dropzone.dragover { border-color: var(--blu); box-shadow: 0 0 0 3px rgba(24,99,220,.35), var(--shadow); background: #f4f8ff; }
.dropbar { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem .75rem; margin-top: .6rem; }
progress { width: 100%; height: .6rem; accent-color: var(--blu); }
.msg .attachment a { color: inherit; font-weight: 600; }
.msg.mine .attachment a { color: #fff; }
.pin.is-new { box-shadow: 0 0 0 2px var(--giallo), var(--shadow); }
.phrase { margin: .6rem 0 0; padding: .55rem .8rem; background: var(--grigio-50); border-left: 3px solid var(--giallo); border-radius: var(--radius-sm); color: var(--antracite); font-style: italic; }
@media (max-width: 960px) { .hub { grid-template-columns: 1fr; } .hub-chat { position: static; } }

/* ---------- crediti fotografici ---------- */
.credits-list { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; }
.credits-list li { border: 1px solid var(--grigio-200); border-radius: var(--radius); overflow: hidden; background: #fff; }
.credits-list img { display: block; width: 100%; height: 140px; object-fit: cover; background: var(--grigio-100); }
.credits-list .meta { padding: .6rem .8rem; font-size: .86rem; }
.credits-list .meta strong { display: block; color: var(--notte); margin-bottom: .15rem; }

/* ---------- piede di pagina ---------- */
.foot { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .5rem 1rem; padding: .65rem 1.5rem; background: var(--notte); color: #d5dde7; font-size: .84rem; border-top: 1px solid rgba(255,255,255,.08); }
.foot a { color: #c9dbff; }
.foot a:hover { color: #fff; }
.foot .btn.ghost { color: #e8edf3; border-color: rgba(255,255,255,.3); }
.foot .btn.ghost:hover { background: rgba(255,255,255,.1); }
.photo-credit { margin: 0; font-size: .78rem; color: #b9c4d2; flex: 1 1 320px; }
.foot-brand { flex-basis: 100%; font-size: .75rem; color: #8f9cad; }
.bgctl { display: flex; gap: .35rem; flex-wrap: wrap; }
.login h1 { margin-top: 0; }

/* ---------- notifiche ---------- */
.notif-badge { display: inline-block; min-width: 1.35em; padding: 0 .35em; margin-left: .25rem; border-radius: 999px; background: var(--giallo); color: var(--notte); font-size: .72rem; font-weight: 700; text-align: center; }
.notif-badge[hidden] { display: none; }
.toasts { position: fixed; right: 1rem; bottom: 4.5rem; z-index: 20; display: flex; flex-direction: column; gap: .5rem; max-width: min(360px, calc(100vw - 2rem)); }
.toast { display: flex; align-items: flex-start; gap: .5rem; background: #fff; border: 1px solid var(--grigio-200); border-left: 4px solid var(--blu); border-radius: var(--radius); box-shadow: 0 6px 20px rgba(15,30,51,.2); padding: .7rem .8rem; animation: toast-in .2s ease-out; }
.toast a { flex: 1; text-decoration: none; color: var(--testo); overflow-wrap: anywhere; }
.toast strong { display: block; color: var(--notte); }
.toast-close { background: none; border: none; font-size: 1.3rem; line-height: 1; cursor: pointer; color: var(--muted); }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

@media (max-width: 720px) {
  .topbar { padding: .5rem .75rem; }
  .uname { display: none; }
  .mainnav { order: 3; width: 100%; overflow-x: auto; flex-wrap: nowrap; }
  .mainnav a { white-space: nowrap; }
  .msg { max-width: 95%; }
  body { background-attachment: scroll; }
  .foot { padding: .65rem .75rem; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; scroll-behavior: auto !important; } }

/* pulsante per sbloccare l'audio delle notifiche (policy autoplay dei browser) */
.audio-unlock { position: fixed; left: 1rem; bottom: 1rem; z-index: 60; background: var(--giallo); color: #1f2933; border: 0; border-radius: var(--radius); padding: .6rem .95rem; font-weight: 600; font-size: .92rem; box-shadow: var(--shadow); cursor: pointer; }
.audio-unlock:hover { filter: brightness(1.05); }
.audio-unlock[hidden] { display: none; }

/* ---------- bacheca: filtri per stato ---------- */
.board-filters { display: flex; flex-wrap: wrap; gap: .35rem; margin: 0 0 .9rem; padding: .4rem; background: var(--panel); border: 1px solid var(--grigio-200); border-radius: var(--radius); box-shadow: var(--shadow); }
.board-filters .chip { font-weight: 600; }
.board-filters .chip .count { font-weight: 400; }
.board-filters .chip.on .count { color: #fff; }
.board-filters[hidden], .board-empty[hidden], .pin[hidden] { display: none; }

/* ---------- app installabile (PWA) ---------- */
.pwa-install[hidden], [data-push-on][hidden], [data-push-off][hidden], .push-invite[hidden] { display: none; }
.topbar .pwa-install { order: 1; margin-left: auto; }
.topbar .userbox { order: 2; }
.push-invite { border-left: 4px solid var(--giallo); }
.cosimo-new { margin: 0 0 .8rem; }
.pwa-steps { margin: .4rem 0 .8rem; padding-left: 1.2rem; }
.pwa-steps li { margin: .2rem 0; }
.offline-page main { max-width: 640px; }

/* Bacheca admin: destinatari con avatar, voci checklist, aggiornamento in tempo reale */
.picker { border: 1px solid var(--grigio-200); border-radius: var(--radius-sm); padding: .5rem .7rem; }
.picker-filter { margin: .2rem 0 .5rem; max-width: 320px; }
.picker-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: .25rem .8rem; max-height: 260px; overflow-y: auto; }
label.pick { display: flex; flex-direction: row; align-items: center; gap: .45rem; font-weight: 500; padding: .15rem 0; }
label.pick[hidden] { display: none; }
.avatar-stack { display: flex; flex-wrap: wrap; align-items: center; gap: .2rem; margin: .2rem 0 .4rem; }
.avatar.ring { border-width: 2px; }
.avatar.ring.st-nuovo { border-color: #e0b44a; }
.avatar.ring.st-letto { border-color: #5b86d6; }
.avatar.ring.st-in_lavorazione { border-color: #e39a45; }
.avatar.ring.st-eseguito { border-color: #3f9e6a; }
.status-sum .badge { margin: 0 .15rem .2rem 0; }
.check-sum h4 { margin: .6rem 0 .25rem; font-size: .92rem; }
.checks-admin { margin: 0 0 .5rem 1.2rem; padding: 0; }
.checks-admin li { margin: .15rem 0; }
.ck-mini { list-style: none; margin: .25rem 0 0; padding: 0; font-size: .82rem; }
.ck-mini li { margin: .05rem 0; }
.ck-mini .ck-done { color: #155c35; }
.ck-mini .ck-todo { color: var(--muted); }
table.recipients td { vertical-align: top; }
.live-info { margin-top: -.3rem; }
.notice { border-left: 4px solid var(--blu); }
.flash-row { animation: flash-row 1.6s ease-out; }
@keyframes flash-row { from { background: #fff6c8; } to { background: transparent; } }

/* Chat Cosimo stile assistente AI: conversazioni a sinistra, area messaggi, compositore in basso */
.cx { display: grid; grid-template-columns: 270px 1fr; gap: 0; height: calc(100vh - 150px); min-height: 520px; background: #fff; border: 1px solid var(--grigio-200); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); position: relative; }
.cx-side { display: flex; flex-direction: column; gap: .5rem; padding: .75rem; background: var(--grigio-50); border-right: 1px solid var(--grigio-200); min-height: 0; }
.cx-newform { margin: 0; }
.cx-new { width: 100%; justify-content: center; }
.cx-filter { width: 100%; font-size: .88rem; }
.cx-nav { flex: 1; overflow-y: auto; min-height: 0; margin: 0 -.25rem; }
.cx-list { list-style: none; margin: 0; padding: 0 .25rem; }
.cx-group { font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: .8rem .4rem .25rem; }
.cx-item { display: block; width: 100%; text-align: left; font: inherit; font-size: .9rem; background: none; border: 0; border-radius: var(--radius-sm); padding: .45rem .55rem; color: var(--antracite); cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cx-item:hover { background: var(--grigio-100); }
.cx-list li.on .cx-item { background: var(--blu-chiaro); color: #123d85; font-weight: 600; }
.cx-sidefoot { display: flex; flex-direction: column; gap: .35rem; border-top: 1px solid var(--grigio-200); padding-top: .6rem; }
.cx-sidefoot .btn { justify-content: flex-start; }
.cx-main { display: flex; flex-direction: column; min-width: 0; min-height: 0; padding: 0; border: 0; border-radius: 0; }
.cx-head { display: flex; align-items: center; gap: .6rem; padding: .6rem 1rem; border-bottom: 1px solid var(--grigio-200); }
.cx-title { font-size: 1.05rem; margin: 0; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cx-actions { display: flex; gap: .35rem; }
.cx-toggle { display: none; font-size: 1.2rem; background: none; border: 1px solid var(--grigio-200); border-radius: var(--radius-sm); padding: .15rem .5rem; cursor: pointer; }
.cx-scroll { flex: 1; overflow-y: auto; min-height: 0; padding: 1rem 0; }
.cx-msgs { height: auto; min-height: 0; max-width: 820px; margin: 0 auto; padding: 0 1rem; background: none; border: 0; overflow: visible; }
.cx-msgs .msg { max-width: 100%; }
.cx-msgs .msg.mine { max-width: 80%; }
.cx-msgs .msg.cosimo .bubble { border: 0; border-left: 0; background: none; padding: .2rem 0; white-space: normal; }
.cx-msgs .msg.mine .bubble { white-space: pre-wrap; border-radius: 18px; padding: .55rem .9rem; }
.cx-av { width: 28px; height: 28px; align-self: flex-start; }
.md p { margin: .35rem 0; }
.md ul, .md ol { margin: .35rem 0 .35rem 1.3rem; padding: 0; }
.md pre { background: #0f1e33; color: #e8eef7; padding: .7rem .8rem; border-radius: var(--radius-sm); overflow-x: auto; font-size: .85rem; }
.md code { background: var(--grigio-100); padding: .05rem .3rem; border-radius: 4px; font-size: .88em; }
.md pre code { background: none; padding: 0; color: inherit; }
.md a { color: var(--blu); text-decoration: underline; }
.md-h { margin-top: .7rem; }
.cx-copy { font: inherit; font-size: .72rem; background: none; border: 1px solid var(--grigio-200); border-radius: var(--radius-sm); color: var(--muted); padding: .05rem .45rem; cursor: pointer; margin-top: .25rem; }
.cx-note { list-style: none; align-self: center; font-size: .8rem; color: var(--muted); background: var(--grigio-50); border: 1px dashed var(--grigio-200); border-radius: var(--radius-sm); padding: .25rem .6rem; max-width: 90%; }
.cx-typing .dots::after { content: ' …'; animation: cx-blink 1.2s infinite; }
@keyframes cx-blink { 50% { opacity: .2; } }
.cx-empty { max-width: 640px; margin: 8vh auto 0; text-align: center; padding: 0 1rem; }
.cx-hello { font-size: 1.6rem; font-weight: 600; color: var(--antracite); margin-bottom: .3rem; }
.cx-suggest { display: flex; flex-wrap: wrap; gap: .5rem; justify-content: center; margin-top: 1rem; }
.cx-compose { max-width: 820px; width: calc(100% - 2rem); margin: 0 auto .4rem; border: 1px solid #b9c2cd; border-radius: 16px; padding: .5rem .6rem .4rem; background: #fff; box-shadow: 0 2px 10px rgba(15,30,51,.08); }
.cx-compose:focus-within { border-color: var(--blu); }
.cx-compose textarea { width: 100%; border: 0; resize: none; outline: none; font: inherit; min-height: 1.6em; max-height: 260px; padding: .25rem .3rem; box-shadow: none; }
.cx-tools { display: flex; align-items: center; gap: .5rem; }
.cx-hint { flex: 1; }
.cx-main > #chat-status, .cx-disclaimer { max-width: 820px; width: calc(100% - 2rem); margin: 0 auto .4rem; text-align: center; }
.cx-mem { max-width: 640px; width: 92vw; border: 1px solid var(--grigio-200); border-radius: var(--radius); padding: 1rem 1.2rem; }
.cx-mem::backdrop { background: rgba(15,30,51,.45); }
.cx-memlist { list-style: none; padding: 0; margin: .6rem 0; max-height: 45vh; overflow-y: auto; }
.cx-memlist li { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; padding: .4rem 0; border-bottom: 1px solid var(--grigio-100); }
.cx-memlist li span { flex: 1 1 60%; }
.grow { flex: 1 1 auto; }
.cx.dropzone.dragover, .cx-main.dragover { box-shadow: inset 0 0 0 3px rgba(24,99,220,.35); background: #f4f8ff; }
@media (max-width: 820px) {
  .cx { grid-template-columns: 1fr; height: calc(100vh - 120px); }
  .cx-toggle { display: inline-block; }
  .cx-side { position: absolute; inset: 0 auto 0 0; width: 82%; max-width: 300px; z-index: 5; transform: translateX(-105%); transition: transform .2s ease; box-shadow: 4px 0 18px rgba(15,30,51,.2); }
  .cx.side-open .cx-side { transform: none; }
  .cx-hint { display: none; }
}

/* Tabella "File inviati a Cosimo": a tutta larghezza, testi su una riga */
.cosimo-files { margin-top: 1.2rem; }
table.ftable { width: 100%; border-collapse: collapse; }
table.ftable th, table.ftable td { white-space: nowrap; word-break: normal; overflow-wrap: normal; vertical-align: middle; padding: .5rem .7rem; }
table.ftable th { text-transform: none; letter-spacing: 0; font-size: .85rem; }
table.ftable td.fname { white-space: normal; overflow-wrap: anywhere; min-width: 14rem; font-weight: 600; }
table.ftable td.actions { text-align: right; }
table.ftable td.actions .btn, table.ftable td.actions form { display: inline-block; margin: .1rem 0 .1rem .25rem; }
@media (max-width: 720px) {
  table.ftable thead { display: none; }
  table.ftable, table.ftable tbody, table.ftable tr, table.ftable td { display: block; width: 100%; }
  table.ftable tr { border-bottom: 1px solid var(--grigio-200); padding: .5rem 0; }
  table.ftable td { padding: .15rem .3rem; white-space: normal; }
  table.ftable td.actions { text-align: left; }
}

/* Bozze di Cosimo per la Bacheca: scheda con conferma */
.cx-actions { list-style: none; max-width: 640px; }
.cx-action { border: 1px solid var(--grigio-200); border-left: 4px solid var(--blu); border-radius: var(--radius-sm); background: #fff; padding: .6rem .8rem; margin: .3rem 0 .6rem 36px; box-shadow: 0 1px 4px rgba(15,30,51,.06); }
.cx-action.st-inviata { border-left-color: #3f9e6a; }
.cx-action.st-annullata { opacity: .65; border-left-color: var(--grigio-200); }
.cx-action.st-errore { border-left-color: #c0392b; }
.cx-action-head { display: flex; justify-content: space-between; gap: .5rem; font-size: .88rem; }
.cx-action-st { color: var(--muted); font-size: .8rem; }
.cx-action-title { font-weight: 600; margin: .35rem 0 .2rem; }
.cx-action-body { white-space: pre-wrap; font-size: .92rem; }
.cx-action-checks { margin: .3rem 0 .3rem 1.2rem; padding: 0; font-size: .9rem; }
.cx-action-to { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem; margin: .4rem 0; font-size: .85rem; }
.cx-action-to .chip { display: inline-flex; align-items: center; gap: .2rem; }
.cx-action-err { color: #a12a1c; font-size: .85rem; margin: .3rem 0; }
.cx-action-btns { display: flex; gap: .4rem; margin-top: .4rem; }
