/* ==========================================================================
   Web app Mirko Argnani - area riservata
   Stile: monocromo del brand (nero, quasi nero, bianco, grigi), HK Grotesk 400/600,
   forme piatte con raggi minimi, linee sottili. Nessun colore d'accento.

   Indice
   1. Variabili e temi      5. Elenchi e schede      9. Pannello dal basso
   2. Base                  6. Pulsanti             10. Chat
   3. Struttura             7. Moduli               11. Avvisi e messaggi
   4. Tipografia            8. Filtri e etichette   12. Animazione di avvio
   ========================================================================== */

/* 1. Variabili e temi ------------------------------------------------------ */

@font-face {
    font-family: 'HK_Grotesk';
    src: url('/tema/webfonts/hkgrotesk-regular-webfont.woff2') format('woff2'), url('/tema/webfonts/hkgrotesk-regular-webfont.woff') format('woff');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'HK_Grotesk';
    src: url('/tema/webfonts/hkgrotesk-semibold-webfont.woff2') format('woff2'), url('/tema/webfonts/hkgrotesk-semibold-webfont.woff') format('woff');
    font-weight: 600;
    font-style: normal;
    font-display: swap;
}

:root {
    color-scheme: light dark;

    --ink: #111111;          /* testo e pulsanti principali */
    --ink-soft: #555555;
    --muted: #757575;
    --bg: #f7f7f7;           /* sfondo pagina */
    --surface: #ffffff;      /* schede, elenchi */
    --surface-2: #f1f1f1;    /* campi, riquadri interni */
    --line: rgba(0, 0, 0, .12);
    --line-strong: rgba(0, 0, 0, .24);
    --on-ink: #ffffff;       /* testo sopra --ink */
    --bubble: #e4e4e4;       /* fumetti della chat ricevuti: devono staccare dallo sfondo */
    --bubble-line: rgba(0, 0, 0, .10);
    --accent: #2563eb;       /* accenti colorati, gli stessi dell'area riservata del sito */
    --accent-2: #0ea5c6;
    --accent-3: #198754;
    --chrome: #111111;       /* barra in alto e menu: sempre scuri */
    --chrome-ink: #ffffff;
    --chrome-muted: rgba(255, 255, 255, .56);
    --ok: #2f6b47;
    --ko: #9b2c2c;

    --radius: 3px;
    --gap: 16px;
    --topbar-h: 56px;
    --tabbar-h: 60px;
    --rail-w: 92px;
    --safe-t: env(safe-area-inset-top, 0px);
    --safe-b: env(safe-area-inset-bottom, 0px);
    --safe-l: env(safe-area-inset-left, 0px);
    --safe-r: env(safe-area-inset-right, 0px);
    --font: 'HK_Grotesk', -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
    --ease: cubic-bezier(.2, .7, .2, 1);
}

/* tema scuro: automatico (segue il dispositivo) oppure scelto dal Profilo con data-theme su <html> */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --ink: #f4f4f4;
        --ink-soft: #cfcfcf;
        --muted: #9a9a9a;
        --bg: #111111;
        --surface: #1b1b1b;
        --surface-2: #242424;
        --line: rgba(255, 255, 255, .12);
        --line-strong: rgba(255, 255, 255, .26);
        --on-ink: #111111;
        --bubble: #323232;
        --bubble-line: rgba(255, 255, 255, .16);
        --chrome: #0a0a0a;
        --ok: #7fc79b;
        --ko: #e08a8a;
        color-scheme: dark;
    }
}

:root[data-theme="dark"] {
    --ink: #f4f4f4;
    --ink-soft: #cfcfcf;
    --muted: #9a9a9a;
    --bg: #111111;
    --surface: #1b1b1b;
    --surface-2: #242424;
    --line: rgba(255, 255, 255, .12);
    --line-strong: rgba(255, 255, 255, .26);
    --on-ink: #111111;
    --bubble: #323232;
    --bubble-line: rgba(255, 255, 255, .16);
    --chrome: #0a0a0a;
    --ok: #7fc79b;
    --ko: #e08a8a;
    color-scheme: dark;
}

/* 2. Base ------------------------------------------------------------------ */

*, *::before, *::after { box-sizing: border-box; }

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
}

body {
    margin: 0;
    min-height: 100dvh;
    background: var(--bg);
    color: var(--ink);
    font: 400 16px/1.5 var(--font);
    letter-spacing: -.002em;
    -webkit-font-smoothing: antialiased;
    overscroll-behavior-y: none;
}

h1, h2, h3, h4, p, ul, ol, figure { margin: 0; padding: 0; }
ul, ol { list-style: none; }
img { max-width: 100%; height: auto; display: block; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; }
[hidden] { display: none !important; }

:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.topbar :focus-visible, .tabbar :focus-visible, .bare :focus-visible { outline-color: #fff; }

.icon { flex: none; display: block; }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

@view-transition { navigation: auto; }

/* 3. Struttura ------------------------------------------------------------- */

.topbar {
    position: fixed;
    inset: 0 0 auto 0;
    z-index: 30;
    height: calc(var(--topbar-h) + var(--safe-t));
    padding: var(--safe-t) calc(8px + var(--safe-r)) 0 calc(8px + var(--safe-l));
    display: flex;
    align-items: center;
    gap: 4px;
    background: var(--chrome);
    color: var(--chrome-ink);
}

.topbar-logo { padding: 0 8px; display: block; }
.topbar-logo img { width: 132px; height: auto; }

.topbar-title {
    flex: 1;
    min-width: 0;
    font-size: 17px;
    font-weight: 600;
    letter-spacing: -.02em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 2px; }

.topbar-btn, .icon-btn {
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    border-radius: var(--radius);
    color: inherit;
    flex: none;
}

.icon-btn:active, .topbar-btn:active { opacity: .6; }

.tabbar {
    position: fixed;
    inset: auto 0 0 0;
    z-index: 30;
    height: calc(var(--tabbar-h) + var(--safe-b));
    padding: 0 var(--safe-r) var(--safe-b) var(--safe-l);
    display: flex;
    background: var(--chrome);
    color: var(--chrome-muted);
    border-top: 1px solid rgba(255, 255, 255, .08);
}

.tabbar a {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: .08em;
    text-transform: uppercase;
    position: relative;
    transition: color .2s var(--ease);
}

.tabbar a.is-active { color: var(--chrome-ink); }

.tabbar a.is-active::before {
    content: '';
    position: absolute;
    top: -1px;
    left: 50%;
    width: 24px;
    height: 1px;
    margin-left: -12px;
    background: var(--chrome-ink);
}

.page {
    padding: calc(var(--topbar-h) + var(--safe-t) + var(--gap)) calc(var(--gap) + var(--safe-r)) calc(var(--tabbar-h) + var(--safe-b) + 32px) calc(var(--gap) + var(--safe-l));
    max-width: 760px;
    margin: 0 auto;
}

.page-wide { max-width: 1120px; }

/* tablet e iPad: il menu diventa una colonna a sinistra */
@media (min-width: 900px) {
    .tabbar {
        inset: 0 auto 0 0;
        width: calc(var(--rail-w) + var(--safe-l));
        height: auto;
        padding: calc(var(--topbar-h) + var(--safe-t) + 16px) 0 var(--safe-b) var(--safe-l);
        flex-direction: column;
        justify-content: flex-start;
        gap: 4px;
        border-top: 0;
        border-right: 1px solid rgba(255, 255, 255, .08);
    }

    .tabbar a { flex: none; height: 68px; }
    .tabbar a.is-active::before { top: 50%; left: 0; width: 1px; height: 24px; margin: -12px 0 0; }
    .topbar { z-index: 31; }
    body:not(.is-bare) .page { margin-left: calc(var(--rail-w) + var(--safe-l)); max-width: none; padding: calc(var(--topbar-h) + var(--safe-t) + 32px) 40px 48px; }
    body:not(.is-bare) .page > * { max-width: 760px; margin-left: auto; margin-right: auto; }
    body:not(.is-bare) .page.page-wide > *, body:not(.is-bare) .page > .wide { max-width: 1120px; }
}

/* pagine senza barre: login, offline, non abilitato (sempre su fondo scuro) */
body.is-bare { background: #111111; color: #ffffff; }
body.is-bare .page { padding: 0; max-width: none; }

.bare {
    min-height: 100dvh;
    padding: calc(48px + var(--safe-t)) 24px calc(32px + var(--safe-b));
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 40px;
}

.bare-logo { width: 220px; }

.bare-card {
    width: 100%;
    max-width: 360px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    --ink: #ffffff;
    --on-ink: #111111;
    --muted: #9a9a9a;
    --surface-2: rgba(255, 255, 255, .06);
    --line-strong: rgba(255, 255, 255, .26);
    --line: rgba(255, 255, 255, .14);
    --ko: #e08a8a;
}

.bare-title { font-size: 13px; font-weight: 600; letter-spacing: .16em; text-transform: uppercase; text-align: center; margin-bottom: 8px; }
.bare-links { display: flex; justify-content: space-between; gap: 16px; font-size: 14px; color: #bbbbbb; margin-top: 4px; }
.bare-links a { padding: 8px 0; }
.bare-note { font-size: 11px; color: #757575; text-align: center; }
.bare-note a { text-decoration: underline; }
.bare-card > .icon { margin: 0 auto; }
.bare-card > p { text-align: center; }

/* 4. Tipografia ------------------------------------------------------------ */

.page-title { font-size: 28px; font-weight: 600; line-height: 1.15; letter-spacing: -.035em; }
.page-sub { color: var(--muted); margin-top: 4px; }
.page-head { margin-bottom: 24px; }
.page-head.with-action { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; }

/* titoletto di sezione: maiuscoletto spaziato, come "DESIGN FURNITURE" nel logo */
.eyebrow {
    display: block;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .16em;
    text-transform: uppercase;
    color: var(--muted);
    margin: 28px 0 10px;
}

.eyebrow:first-child { margin-top: 0; }

.h2 { font-size: 20px; font-weight: 600; letter-spacing: -.03em; line-height: 1.2; }
.h3 { font-size: 16px; font-weight: 600; letter-spacing: -.02em; line-height: 1.3; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.strong { font-weight: 600; }
.nowrap { white-space: nowrap; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.num { font-variant-numeric: tabular-nums; }

/* testo che arriva dal CMS (descrizioni, news) */
.prose { overflow-wrap: anywhere; }
.prose > * + * { margin-top: .75em; }
.prose a { text-decoration: underline; text-underline-offset: 2px; }
.prose ul, .prose ol { padding-left: 1.2em; list-style: revert; }
.prose img { height: auto; }
.prose h1, .prose h2, .prose h3, .prose h4 { font-size: 17px; font-weight: 600; letter-spacing: -.02em; }

/* 5. Elenchi e schede ------------------------------------------------------ */

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: var(--gap);
}

.card + .card { margin-top: 12px; }
.card-flush { padding: 0; overflow: hidden; }
.stack > * + * { margin-top: 12px; }
.stack-lg > * + * { margin-top: 24px; }

/* elenco di righe toccabili dentro un riquadro */
.list {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
}

.row {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 56px;
    padding: 10px var(--gap);
    width: 100%;
    text-align: left;
    color: inherit;
}

.row + .row { border-top: 1px solid var(--line); }
a.row:active, button.row:active { background: var(--surface-2); }
.row-body { flex: 1; min-width: 0; }
.row-title { font-weight: 600; letter-spacing: -.01em; overflow-wrap: anywhere; }
.row-sub { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.row-end { margin-left: auto; display: flex; align-items: center; gap: 8px; color: var(--muted); flex: none; }
.row > .icon { color: var(--muted); }

/* riquadro immagine/logo quadrato a sinistra di una riga */
.thumb {
    width: 48px;
    height: 48px;
    flex: none;
    display: grid;
    place-items: center;
    background: var(--surface-2);
    border-radius: var(--radius);
    overflow: hidden;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: .04em;
    color: var(--muted);
}

.thumb img { width: 100%; height: 100%; object-fit: contain; }
.thumb-lg { width: 72px; height: 72px; }
.avatar { border-radius: 50%; }
.avatar img { object-fit: cover; }

.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.grid-2 { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; }

/* coppie etichetta/valore */
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; text-align: right; overflow-wrap: anywhere; }

/* avanzamento (budget) */
.meter { height: 2px; background: var(--line); position: relative; margin: 10px 0 8px; }
.meter > i { position: absolute; inset: 0 auto 0 0; background: var(--ink); max-width: 100%; }
.meter-row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.meter-value { font-size: 22px; font-weight: 600; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }

/* galleria orizzontale a scorrimento */
.strip {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    margin: 0 calc(-1 * var(--gap));
    padding: 0 var(--gap);
    scrollbar-width: none;
}

.strip::-webkit-scrollbar { display: none; }
.strip > * { flex: none; scroll-snap-align: center; }
.strip img { height: 200px; width: auto; border-radius: var(--radius); object-fit: cover; }

.empty { text-align: center; color: var(--muted); padding: 48px 16px; }
.empty .icon { margin: 0 auto 12px; }

/* sezione richiudibile (details/summary) */
.fold { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.fold + .fold { margin-top: 8px; }
.fold > summary { list-style: none; display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 10px var(--gap); cursor: pointer; font-weight: 600; }
.fold > summary::-webkit-details-marker { display: none; }
.fold > summary .chev { margin-left: auto; color: var(--muted); transition: transform .2s var(--ease); }
.fold[open] > summary .chev { transform: rotate(180deg); }
.fold-body { padding: 0 var(--gap) var(--gap); }
.fold-body.flush { padding: 0; border-top: 1px solid var(--line); }

/* 6. Pulsanti -------------------------------------------------------------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 48px;
    padding: 0 22px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 600;
    letter-spacing: .08em;
    text-transform: uppercase;
    white-space: nowrap;
    transition: opacity .15s var(--ease), background .15s var(--ease);
}

.btn:active { opacity: .7; }
.btn[disabled], .btn.is-busy { opacity: .45; pointer-events: none; }
.btn-primary { background: var(--ink); border-color: var(--ink); color: var(--on-ink); }
.btn-danger { color: var(--ko); border-color: currentColor; }
.btn-block { width: 100%; }
.btn-sm { min-height: 38px; padding: 0 14px; font-size: 12px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.btn-row > .btn { flex: 1; }

/* azione testuale in riga */
.link { font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }

/* pulsante tondo flottante (nuovo progetto, nuovo messaggio) */
.fab {
    position: fixed;
    right: calc(var(--gap) + var(--safe-r));
    bottom: calc(var(--tabbar-h) + var(--safe-b) + 16px);
    z-index: 20;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: var(--ink);
    color: var(--on-ink);
    box-shadow: 0 6px 20px rgba(0, 0, 0, .22);
}

@media (min-width: 900px) { .fab { bottom: 32px; right: 40px; } }

/* 7. Moduli ---------------------------------------------------------------- */

.form { display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 11px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.field-hint { font-size: 13px; color: var(--muted); }
.field-error, .field-validation-error { font-size: 13px; color: var(--ko); }
.field-validation-valid { display: none; }

.input, .select, .textarea {
    width: 100%;
    min-height: 48px;
    padding: 12px 14px;
    background: var(--surface-2);
    border: 1px solid transparent;
    border-bottom-color: var(--line-strong);
    border-radius: var(--radius) var(--radius) 0 0;
    font-size: 16px; /* sotto i 16px iOS ingrandisce la pagina al tocco */
    appearance: none;
    -webkit-appearance: none;
    transition: border-color .15s var(--ease);
}

.input:focus, .select:focus, .textarea:focus { outline: none; border-bottom-color: var(--ink); }
.input::placeholder, .textarea::placeholder { color: var(--muted); opacity: 1; }
.input.input-validation-error, .textarea.input-validation-error, .select.input-validation-error { border-bottom-color: var(--ko); }
.textarea { min-height: 112px; resize: vertical; line-height: 1.45; }

.select {
    padding-right: 40px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' fill='none' stroke='%23757575' stroke-width='1.25'%3E%3Cpath d='M6 9.5l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
}

.check { display: flex; align-items: center; gap: 10px; min-height: 44px; font-size: 15px; }

.check input {
    appearance: none;
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    margin: 0;
    flex: none;
    border: 1px solid var(--line-strong);
    border-radius: 2px;
    display: grid;
    place-items: center;
}

.check input:checked { background: var(--ink); border-color: var(--ink); }
.check input:checked::after { content: ''; width: 10px; height: 5px; border-left: 1.5px solid var(--on-ink); border-bottom: 1.5px solid var(--on-ink); transform: translateY(-1px) rotate(-45deg); }

/* campo di ricerca con icona */
.search { position: relative; }
.search .icon { position: absolute; left: 12px; top: 50%; margin-top: -12px; color: var(--muted); pointer-events: none; }
.search .input { padding-left: 46px; }

/* selezione file: l'input vero è nascosto dentro l'etichetta */
.filepick { display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 10px 14px; border: 1px dashed var(--line-strong); border-radius: var(--radius); color: var(--muted); cursor: pointer; }
.filepick input[type=file] { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.filepick.has-files { color: var(--ink); border-style: solid; }
.filepick-names { flex: 1; min-width: 0; font-size: 14px; overflow-wrap: anywhere; }

/* 8. Filtri e etichette ---------------------------------------------------- */

.chips {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    margin: 0 calc(-1 * var(--gap));
    padding: 2px var(--gap);
    scrollbar-width: none;
}

.chips::-webkit-scrollbar { display: none; }
.chips.wrap { flex-wrap: wrap; overflow: visible; margin: 0; padding: 0; }

.chip {
    flex: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 36px;
    padding: 0 14px;
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    font-size: 13px;
    white-space: nowrap;
    color: var(--ink-soft);
}

.chip.is-active { background: var(--ink); border-color: var(--ink); color: var(--on-ink); }

/* etichetta di stato non toccabile */
.tag {
    display: inline-flex;
    align-items: center;
    min-height: 22px;
    padding: 0 8px;
    border: 1px solid var(--line-strong);
    border-radius: 2px;
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: .1em;
    text-transform: uppercase;
    white-space: nowrap;
    color: var(--ink-soft);
}

.tag-solid { background: var(--ink); border-color: var(--ink); color: var(--on-ink); }
.tag-ok { color: var(--ok); border-color: currentColor; }
.tag-ko { color: var(--ko); border-color: currentColor; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }

.badge { min-width: 20px; height: 20px; padding: 0 6px; display: inline-grid; place-items: center; border-radius: 10px; background: var(--ink); color: var(--on-ink); font-size: 11px; font-weight: 600; font-variant-numeric: tabular-nums; }

/* selettore a due o tre voci */
.segmented { display: flex; border: 1px solid var(--line-strong); border-radius: var(--radius); overflow: hidden; }
.segmented > * { flex: 1; min-height: 40px; display: grid; place-items: center; font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.segmented > * + * { border-left: 1px solid var(--line-strong); }
.segmented > .is-active { background: var(--ink); color: var(--on-ink); }
.segmented > button { cursor: pointer; min-height: 44px; }

/* 9. Pannello dal basso ---------------------------------------------------- */

.sheet-backdrop {
    position: fixed;
    inset: 0;
    z-index: 60;
    background: rgba(0, 0, 0, .5);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    animation: fade .2s var(--ease);
}

.sheet {
    width: 100%;
    max-width: 640px;
    max-height: calc(100dvh - 40px - var(--safe-t));
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border-radius: 12px 12px 0 0;
    animation: rise .28s var(--ease);
}

.sheet-head { display: flex; align-items: center; gap: 8px; padding: 10px 8px 10px var(--gap); border-bottom: 1px solid var(--line); flex: none; }
.sheet-title { flex: 1; min-width: 0; font-size: 17px; font-weight: 600; letter-spacing: -.02em; }
.sheet-body { padding: var(--gap) var(--gap) calc(var(--gap) + var(--safe-b)); overflow-y: auto; -webkit-overflow-scrolling: touch; }

@media (min-width: 700px) {
    .sheet-backdrop { align-items: center; }
    .sheet { border-radius: var(--radius); max-height: calc(100dvh - 80px); }
}

@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(24px); opacity: 0; } }

/* 10. Chat ----------------------------------------------------------------- */

/* pagina a tutta altezza: i messaggi scorrono, il campo di scrittura resta in basso sopra il menu */
.chat { display: flex; flex-direction: column; gap: 14px; padding-bottom: 88px; }
.msg { max-width: 86%; align-self: flex-start; display: flex; align-items: flex-start; gap: 10px; }
.msg-body { min-width: 0; }
.msg-avatar { flex: none; width: 36px; height: 36px; margin-top: 22px; border-radius: 50%; display: grid; place-items: center; font-size: 13px; font-weight: 600; letter-spacing: .02em; color: #fff; background: #111111; }
.msg-avatar.tinta-1 { background: var(--accent); }
.msg-avatar.tinta-2 { background: var(--accent-2); }
.msg-avatar.tinta-3 { background: var(--accent-3); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .msg-avatar:not(.tinta-1):not(.tinta-2):not(.tinta-3) { background: #4a4a4a; } }
:root[data-theme="dark"] .msg-avatar:not(.tinta-1):not(.tinta-2):not(.tinta-3) { background: #4a4a4a; }
.msg.mine { align-self: flex-end; }
.msg-meta { display: flex; gap: 8px; align-items: baseline; font-size: 11px; color: var(--muted); margin-bottom: 4px; }
.msg.mine .msg-meta { justify-content: flex-end; }
.msg-author { font-weight: 600; letter-spacing: .06em; text-transform: uppercase; }
.msg-bubble { padding: 10px 14px; background: var(--bubble); border: 1px solid var(--bubble-line); border-radius: 2px 12px 12px 12px; overflow-wrap: anywhere; white-space: pre-line; }
.msg.mine .msg-bubble { background: var(--accent); border-color: var(--accent); color: #fff; border-radius: 12px 2px 12px 12px; }
.msg-files { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
.msg-file { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius); font-size: 13px; background: var(--surface); overflow-wrap: anywhere; }
.msg-file img { width: 100%; max-width: 240px; border-radius: 2px; }
.msg-actions { display: flex; gap: 14px; justify-content: flex-end; font-size: 12px; color: var(--muted); margin-top: 4px; }
.chat-day { align-self: center; font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }

.composer {
    position: fixed;
    left: 0;
    right: 0;
    bottom: calc(var(--tabbar-h) + var(--safe-b));
    z-index: 25;
    padding: 8px calc(8px + var(--safe-r)) 8px calc(8px + var(--safe-l));
    background: var(--surface);
    border-top: 1px solid var(--line);
}

.composer-row { display: flex; align-items: flex-end; gap: 4px; max-width: 760px; margin: 0 auto; }
.composer textarea { flex: 1; min-height: 44px; max-height: 140px; padding: 10px 12px; background: var(--surface-2); border: 0; border-radius: var(--radius); font-size: 16px; resize: none; line-height: 1.4; }
.composer textarea:focus { outline: none; }
.composer-files { max-width: 760px; margin: 0 auto 6px; font-size: 13px; color: var(--muted); padding: 0 8px; }
.composer .icon-btn[type=submit] { background: var(--ink); color: var(--on-ink); }

@media (min-width: 900px) { .composer { left: calc(var(--rail-w) + var(--safe-l)); bottom: 0; padding-bottom: calc(12px + var(--safe-b)); } }

/* 11. Avvisi e messaggi ---------------------------------------------------- */

.alert { padding: 12px 14px; border: 1px solid var(--line-strong); border-radius: var(--radius); font-size: 14px; }
.alert-error { color: var(--ko); border-color: currentColor; }
.alert-ok { color: var(--ok); border-color: currentColor; }
.note { display: flex; gap: 12px; padding: 12px 14px; background: var(--surface-2); border-radius: var(--radius); font-size: 14px; color: var(--ink-soft); }
.note .icon { color: var(--muted); }

.toast {
    position: fixed;
    left: 50%;
    bottom: calc(var(--tabbar-h) + var(--safe-b) + 20px);
    z-index: 80;
    max-width: calc(100vw - 32px);
    padding: 12px 18px;
    background: #111111;
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, .16);
    border-radius: var(--radius);
    font-size: 14px;
    text-align: center;
    transform: translate(-50%, 16px);
    opacity: 0;
    pointer-events: none;
    transition: transform .25s var(--ease), opacity .25s var(--ease);
}

.toast.is-on { transform: translate(-50%, 0); opacity: 1; }
.toast.is-ko { border-color: #e08a8a; }

.spinner { width: 22px; height: 22px; border: 1px solid var(--line-strong); border-top-color: var(--ink); border-radius: 50%; animation: spin .7s linear infinite; margin: 24px auto; }
@keyframes spin { to { transform: rotate(360deg); } }

/* 12. Animazione di avvio -------------------------------------------------- */

/* Il logotipo si compone su fondo scuro: le dodici lettere di MIRKOARGNANI salgono al loro posto
   una dopo l'altra, poi la riga DESIGN FURNITURE si apre dal centro. Ogni lettera è una finestra
   (clip-path) sull'immagine originale del logo, quindi a fine animazione il marchio è esatto. */

.splash {
    position: fixed;
    inset: 0;
    z-index: 100;
    background: #111111;
    display: grid;
    place-items: center;
    animation: splash-out .45s var(--ease) 1.95s forwards;
}

.no-splash .splash { display: none; }

.splash-logo { position: relative; width: min(64vw, 300px); aspect-ratio: 376 / 74; }

.splash-logo i {
    position: absolute;
    inset: 0;
    background: url('/app-assets/brand/logo-white.png') 0 0 / 100% 100% no-repeat;
}

.splash-logo .l {
    clip-path: inset(0 calc(var(--r) - .2%) 27% calc(var(--l) - .2%)); /* lieve sovrapposizione: niente fessure tra le lettere */
    opacity: 0;
    transform: translateY(14px);
    animation: splash-letter .6s var(--ease) calc(.15s + var(--i) * .055s) forwards;
}

/* bordi delle lettere misurati sull'immagine (larghezza 376px): M I R K O A R G N A N I */
.splash-logo .l0  { --i: 0;  --l: 0%;     --r: 87%; }
.splash-logo .l1  { --i: 1;  --l: 13%;    --r: 85.1%; }
.splash-logo .l2  { --i: 2;  --l: 14.9%;  --r: 77.3%; }
.splash-logo .l3  { --i: 3;  --l: 22.7%;  --r: 70.2%; }
.splash-logo .l4  { --i: 4;  --l: 29.8%;  --r: 60.1%; }
.splash-logo .l5  { --i: 5;  --l: 39.9%;  --r: 48.9%; }
.splash-logo .l6  { --i: 6;  --l: 51.1%;  --r: 41.6%; }
.splash-logo .l7  { --i: 7;  --l: 58.4%;  --r: 30.2%; }
.splash-logo .l8  { --i: 8;  --l: 69.8%;  --r: 21.1%; }
.splash-logo .l9  { --i: 9;  --l: 78.9%;  --r: 11%; }
.splash-logo .l10 { --i: 10; --l: 89%;    --r: 2%; }
.splash-logo .l11 { --i: 11; --l: 98%;    --r: 0%; }

.splash-logo .sub {
    clip-path: inset(73% 50% 0 50%);
    opacity: 0;
    animation: splash-sub .7s var(--ease) 1.05s forwards;
}

@keyframes splash-letter { to { opacity: 1; transform: none; } }
@keyframes splash-sub { to { opacity: 1; clip-path: inset(73% 0 0 0); } }
@keyframes splash-out { to { opacity: 0; visibility: hidden; } }

@media (prefers-reduced-motion: reduce) {
    .splash { animation-delay: .6s; animation-duration: .3s !important; }
    .splash-logo .l, .splash-logo .sub { opacity: 1; transform: none; clip-path: inset(0 var(--r, 0%) 27% var(--l, 0%)); animation: none; }
    .splash-logo .sub { clip-path: inset(73% 0 0 0); }
}

/* logo sempre presente su schermi larghi anche nelle pagine con la freccia "indietro" */
.topbar-logo-wide { display: none; }
@media (min-width: 900px) {
    .topbar-logo-wide { display: block; margin-right: 12px; }
}

/* menu in alto a destra: profilo ed uscita */
.topmenu { position: relative; }
.topmenu > summary { list-style: none; cursor: pointer; }
.topmenu > summary::-webkit-details-marker { display: none; }
.topmenu-panel {
    position: absolute; right: 0; top: calc(100% + 6px); z-index: 40; min-width: 220px; padding: 6px 0;
    background: var(--surface); color: var(--ink); border: 1px solid var(--line-strong); border-radius: 6px;
}
.topmenu-user { display: flex; flex-direction: column; padding: 10px 16px 12px; border-bottom: 1px solid var(--line); font-size: 14px; }
.topmenu-user span { font-size: 12px; color: var(--muted); }
.topmenu-panel a, .topmenu-panel button {
    width: 100%; min-height: 48px; padding: 0 16px; display: flex; align-items: center; gap: 12px;
    font-size: 15px; text-align: left; color: inherit; background: none; border: 0; cursor: pointer;
}
.topmenu-panel a.is-active { font-weight: 600; }
.topmenu-panel a:active, .topmenu-panel button:active { background: var(--surface-2); }
.topmenu-panel :focus-visible { outline-color: var(--ink); }
