/* =====================================================================
   CalendarHub – sistema visivo (il nome mostrato agli utenti è configurabile: Ui:AppName)
   Ardesia (struttura) · Nebbia (piano di lavoro) · Sodio (il "qui e ora")
   I colori dei singoli calendari arrivano dai provider e restano riconoscibili.
   Font self-hosted (OFL): League Spartan per date e titoli, IBM Plex Sans per l'interfaccia.
   ===================================================================== */

@font-face { font-family: "League Spartan"; src: url("fonts/LeagueSpartan-SemiBold.woff2") format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: "League Spartan"; src: url("fonts/LeagueSpartan-Bold.woff2") format("woff2"); font-weight: 700; font-display: swap; }
@font-face { font-family: "IBM Plex Sans"; src: url("fonts/IBMPlexSans-Regular.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "IBM Plex Sans"; src: url("fonts/IBMPlexSans-Italic.woff2") format("woff2"); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: "IBM Plex Sans"; src: url("fonts/IBMPlexSans-Medium.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "IBM Plex Sans"; src: url("fonts/IBMPlexSans-SemiBold.woff2") format("woff2"); font-weight: 600; font-display: swap; }

:root {
    --h-rail: #1E2B33;
    --h-rail-ink: #DCE4E1;
    --h-rail-dim: #8FA19D;
    --h-rail-line: #2F3F48;
    --h-rail-hover: #26363F;

    --h-canvas: #E7ECEA;
    --h-surface: #F7F8F6;
    --h-weekend: #EEF1EF;
    --h-ink: #172126;
    --h-ink-2: #51626A;
    --h-line: #C9D1CE;
    --h-line-soft: #DAE0DE;

    --h-signal: #E9A23B;
    --h-signal-ink: #2B1C04;
    --h-danger: #A93C2A;
    --h-focus: #2F6FD6;

    --h-display: "League Spartan", "Avenir Next", "Segoe UI", sans-serif;
    --h-ui: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;

    --h-hour: 52px;
    --h-gutter: 52px;
    --h-rail-w: 288px;
    --h-radius: 4px;
    /* Etichette degli eventi con gli angoli arrotondati (patch 030) */
    --h-event-radius: 6px;

    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root {
        --h-rail: #0F1518;
        --h-rail-ink: #D5DDDA;
        --h-rail-dim: #7E8F8A;
        --h-rail-line: #1F2A2F;
        --h-rail-hover: #182126;

        --h-canvas: #141B1F;
        --h-surface: #1B2429;
        --h-weekend: #172024;
        --h-ink: #E3E9E6;
        --h-ink-2: #98A8A3;
        --h-line: #2C3A41;
        --h-line-soft: #222D33;

        --h-signal: #F0AE4A;
        --h-signal-ink: #241703;
        --h-danger: #E07A66;
        --h-focus: #7AA7F2;
        color-scheme: dark;
    }
}

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

html, body { height: 100%; }

body {
    margin: 0;
    background: var(--h-canvas);
    color: var(--h-ink);
    font: 400 15px/1.45 var(--h-ui);
    font-variant-numeric: tabular-nums;
    -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }

:focus-visible { outline: 2px solid var(--h-focus); outline-offset: 2px; }

.h-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.h-icon { flex: none; display: block; }

/* ---------------------------------------------------------------- pulsanti */

.h-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    height: 36px; padding: 0 14px;
    border: 1px solid var(--h-line); border-radius: var(--h-radius);
    background: var(--h-surface); color: var(--h-ink);
    font-weight: 500; text-decoration: none; white-space: nowrap;
}
.h-btn:hover { border-color: var(--h-ink-2); }
.h-btn:disabled { opacity: .5; cursor: not-allowed; }
.h-btn--primary { background: var(--h-signal); border-color: var(--h-signal); color: var(--h-signal-ink); font-weight: 600; }
.h-btn--primary:hover { border-color: var(--h-signal-ink); }
.h-btn--ghost { background: transparent; }
.h-btn--danger { background: var(--h-danger); border-color: var(--h-danger); color: #fff; }
.h-btn--large { height: 46px; padding: 0 22px; font-size: 16px; }
.h-btn--icon { padding: 0 10px; }

.h-iconbtn {
    display: inline-grid; place-items: center;
    width: 36px; height: 36px; padding: 0;
    border: 0; border-radius: var(--h-radius); background: transparent; color: inherit;
}
.h-iconbtn:hover { background: color-mix(in srgb, currentColor 10%, transparent); }
.h-iconbtn--small { width: 26px; height: 26px; }

.h-linkbtn { border: 0; background: none; padding: 0; color: inherit; text-decoration: underline; text-underline-offset: 3px; }

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

.h-app {
    display: grid;
    grid-template-columns: var(--h-rail-w) minmax(0, 1fr);
    height: 100dvh;
    overflow: hidden;
    /* Telefoni: niente sotto barra di stato, notch e tasti di sistema (con viewport-fit=cover). */
    box-sizing: border-box;
    padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
}

.h-main {
    display: grid;
    grid-template-rows: auto 2px auto minmax(0, 1fr);
    grid-template-columns: minmax(0, 1fr); /* la barra non allarga mai la pagina: il titolo si accorcia */
    min-width: 0;
    min-height: 0;
    overflow: hidden; /* durante lo scorrimento laterale il calendario esce di lato senza coprire altro */
}

/* ---------------------------------------------------------------- rail (sorgenti) */

.h-rail {
    background: var(--h-rail);
    color: var(--h-rail-ink);
    display: flex; flex-direction: column; gap: 22px;
    padding: 18px 16px 14px;
    overflow-y: auto;
    min-height: 0;
}

.h-rail__brand { display: flex; align-items: center; gap: 10px; font: 700 22px/1 var(--h-display); letter-spacing: .01em; }
.h-rail__brand .h-icon { color: var(--h-signal); }
.h-rail__close { margin-left: auto; display: none; }
.h-rail__heading { margin: 0 0 10px; font: 600 13px/1.2 var(--h-ui); color: var(--h-rail-dim); }

.h-mini__head { display: flex; align-items: center; gap: 2px; margin-bottom: 6px; }
.h-mini__title { flex: 1; font: 600 15px/1 var(--h-display); padding-top: 2px; }
.h-mini__grid { display: grid; grid-template-columns: 20px repeat(7, 1fr); gap: 1px; }
.h-mini__wk { display: grid; place-items: center; font-size: 10px; color: var(--h-rail-dim); opacity: .8; }
.h-mini__dow { text-align: center; font-size: 11px; color: var(--h-rail-dim); padding-bottom: 4px; }
.h-mini__day {
    height: 30px; border: 0; border-radius: 2px; background: transparent;
    font-size: 12.5px; color: var(--h-rail-ink);
}
.h-mini__day:hover { background: var(--h-rail-hover); }
.h-mini__day.is-outside { color: var(--h-rail-dim); opacity: .6; }
.h-mini__day.is-selected { background: var(--h-rail-hover); box-shadow: inset 0 -2px 0 var(--h-rail-dim); }
.h-mini__day.is-today { background: var(--h-signal); color: var(--h-signal-ink); font-weight: 600; box-shadow: none; }

.h-source { padding: 12px 0 10px; border-top: 1px solid var(--h-rail-line); }
.h-source__head { display: grid; gap: 1px; margin-bottom: 8px; }
.h-source__provider { font-size: 12px; color: var(--h-rail-dim); }
.h-source__email { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.h-source__list { list-style: none; margin: 0; padding: 0; display: grid; gap: 1px; }
.h-source__unlink { margin-top: 8px; font-size: 12.5px; color: var(--h-rail-dim); }

.h-source__problem {
    display: grid; grid-template-columns: auto 1fr; gap: 8px;
    margin: 0 0 8px; padding: 8px 10px;
    border-left: 3px solid var(--h-signal); background: var(--h-rail-hover);
    font-size: 13px;
}
.h-source__problem p { margin: 0 0 4px; }
.h-source__problem .h-icon { color: var(--h-signal); margin-top: 2px; }

/* "Jack": presa di un patch panel. Piena = calendario collegato alla vista, vuota = scollegato. */
.h-jack {
    display: grid; grid-template-columns: 16px 1fr auto; align-items: center; gap: 10px;
    width: 100%; padding: 6px 6px; border: 0; border-radius: 2px;
    background: transparent; color: var(--h-rail-ink); text-align: left;
}
.h-jack:hover { background: var(--h-rail-hover); }
.h-jack__socket {
    width: 14px; height: 14px; border-radius: 50%;
    border: 2px solid var(--cal); background: transparent;
    transition: background-color .15s ease;
}
.h-jack.is-on .h-jack__socket { background: var(--cal); box-shadow: 0 0 0 3px color-mix(in srgb, var(--cal) 25%, transparent); }
.h-jack:not(.is-on) .h-jack__name { color: var(--h-rail-dim); }
.h-jack__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.h-jack__ro { color: var(--h-rail-dim); }

.h-rail__connects { display: grid; gap: 8px; padding-top: 12px; border-top: 1px solid var(--h-rail-line); }
.h-rail__connect {
    display: flex; align-items: center; gap: 8px;
    text-decoration: none; font-weight: 500;
}
.h-rail__connect:hover { color: var(--h-signal); }
.h-rail__note { margin: 6px 0 0; font-size: 12.5px; color: var(--h-rail-dim); }

.h-user {
    margin-top: auto;
    display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px;
    padding-top: 14px; border-top: 1px solid var(--h-rail-line);
}
.h-user form { margin: 0; }
.h-user__avatar {
    width: 32px; height: 32px; border-radius: 50%;
    display: grid; place-items: center;
    background: var(--h-rail-hover); font: 700 13px/1 var(--h-display); padding-top: 2px;
}
.h-user__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.h-user .h-linkbtn { color: var(--h-rail-dim); font-size: 13px; }

/* ---------------------------------------------------------------- barra superiore */

.h-bar {
    display: flex; align-items: center; flex-wrap: wrap; gap: 10px 14px;
    padding: 16px 22px 14px;
}
.h-bar__menu { display: none; }
.h-bar__nav { display: flex; align-items: center; gap: 2px; }
.h-bar__end { display: flex; align-items: center; gap: 12px; margin-left: auto; }

.h-period { margin: 0 6px 0 0; display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.h-period__main { font: 700 40px/1 var(--h-display); letter-spacing: -.012em; padding-top: 6px; }
.h-period__year { font: 600 22px/1 var(--h-display); color: var(--h-ink-2); }

.h-seg { display: inline-flex; border: 1px solid var(--h-line); border-radius: var(--h-radius); overflow: hidden; }
.h-seg button { height: 34px; padding: 0 14px; border: 0; background: transparent; color: var(--h-ink-2); font-weight: 500; }
.h-seg button + button { border-left: 1px solid var(--h-line); }
.h-seg button.is-active { background: var(--h-ink); color: var(--h-surface); }

.h-sync {
    display: inline-flex; align-items: center; gap: 6px;
    border: 0; background: none; padding: 4px 0; color: var(--h-ink-2); font-size: 13px;
}
.h-sync:hover { color: var(--h-ink); }

/* Controlli solo telefono (vedi media query ≤ 820px) */
.h-viewpick, .h-todaybtn, .h-fab { display: none; }
.is-spinning { animation: h-spin 1s linear infinite; }
@keyframes h-spin { to { transform: rotate(360deg); } }

/* Barra di avanzamento sottile: il caricamento non nasconde mai il calendario. */
.h-progress { height: 2px; background: transparent; overflow: hidden; position: relative; }
.h-progress.is-active::after {
    content: ""; position: absolute; inset: 0 auto 0 0; width: 30%;
    background: var(--h-signal);
    animation: h-progress 1.1s ease-in-out infinite;
}
@keyframes h-progress { from { transform: translateX(-100%); } to { transform: translateX(340%); } }

.h-banner {
    display: flex; align-items: center; gap: 8px;
    margin: 0 22px 8px; padding: 8px 12px;
    background: color-mix(in srgb, var(--h-signal) 18%, var(--h-surface));
    border-left: 3px solid var(--h-signal); font-size: 13.5px;
}

/* Sempre nell'ultima riga di .h-main (anche quando l'avviso sopra non c'è), così occupa tutta l'altezza. */
.h-stage { grid-row: 4; min-height: 0; min-width: 0; display: grid; grid-template-rows: minmax(0, 1fr); grid-template-columns: minmax(0, 1fr); padding: 0 22px 18px; }

/* ---------------------------------------------------------------- vista settimana */

.h-week {
    display: grid; grid-template-rows: auto auto minmax(0, 1fr);
    min-height: 0;
    background: var(--h-surface);
    border: 1px solid var(--h-line);
}

.h-week__head, .h-week__allday, .h-week__grid {
    display: grid;
    grid-template-columns: var(--h-gutter) repeat(var(--days), minmax(0, 1fr));
}
.h-week__head { border-bottom: 1px solid var(--h-line); }

.h-dayhead {
    display: flex; align-items: baseline; gap: 8px;
    padding: 10px 10px 8px;
    border-left: 1px solid var(--h-line-soft);
    position: relative;
}
.h-dayhead__dow { font-size: 13px; color: var(--h-ink-2); }
.h-dayhead__num { font: 700 28px/1 var(--h-display); padding-top: 3px; }
.h-dayhead.is-weekend .h-dayhead__num { color: var(--h-ink-2); }
/* Oggi: una linguetta color sodio sopra la colonna */
.h-dayhead.is-today::before {
    content: ""; position: absolute; left: -1px; right: 0; top: -1px; height: 4px; background: var(--h-signal);
}
.h-dayhead.is-today .h-dayhead__num {
    background: var(--h-signal); color: var(--h-signal-ink);
    padding: 5px 6px 1px; margin: -5px 0 -1px; border-radius: 2px;
}

.h-week__gutter { border-right: 0; }
.h-week__gutter--label { font-size: 11.5px; color: var(--h-ink-2); padding: 6px 6px 0 0; text-align: right; line-height: 1.1; }

.h-week__allday { border-bottom: 1px solid var(--h-line); }
.h-allday-cell {
    display: flex; flex-direction: column; justify-content: flex-end;
    padding: 4px 3px 3px;
    /* altezza = corsie usate (+ riga "+N" se serve) */
    min-height: calc(max(1, var(--lanes, 0)) * 22px + 8px + var(--extra, 0) * 18px);
    border-left: 1px solid var(--h-line-soft);
}
.h-allday-cell.is-today { background: color-mix(in srgb, var(--h-signal) 16%, transparent); }

.h-week__scroll { overflow-y: auto; min-height: 0; position: relative; scrollbar-gutter: stable; }
.h-week__grid { position: relative; height: calc(var(--h-hour) * 24); }

.h-week__hours { position: relative; }
.h-hourlabel {
    position: absolute; right: 8px; transform: translateY(-50%);
    font-size: 11.5px; color: var(--h-ink-2);
}

.h-daycol {
    position: relative;
    border-left: 1px solid var(--h-line-soft);
    background-image:
        linear-gradient(to bottom, var(--h-line-soft) 1px, transparent 1px),
        linear-gradient(to bottom, transparent calc(var(--h-hour) / 2), color-mix(in srgb, var(--h-line-soft) 45%, transparent) calc(var(--h-hour) / 2), transparent calc(var(--h-hour) / 2 + 1px));
    background-size: 100% var(--h-hour), 100% var(--h-hour);
}
.h-daycol.is-weekend { background-color: var(--h-weekend); }
.h-daycol.is-today { background-color: color-mix(in srgb, var(--h-signal) 12%, var(--h-surface)); box-shadow: inset 2px 0 0 color-mix(in srgb, var(--h-signal) 55%, transparent), inset -2px 0 0 color-mix(in srgb, var(--h-signal) 55%, transparent); }


/* Evento: blocco piatto, filo colorato a sinistra (il calendario di provenienza). */
.h-event {
    position: absolute; z-index: 1;
    display: flex; flex-direction: column; align-items: flex-start; gap: 1px;
    padding: 4px 6px 4px 9px;
    border: 0; border-radius: var(--h-event-radius);
    background: color-mix(in srgb, var(--cal) 17%, var(--h-surface));
    box-shadow: inset 3px 0 0 var(--cal);
    color: var(--h-ink); text-align: left;
    overflow: hidden; line-height: 1.25;
}
.h-event:hover { background: color-mix(in srgb, var(--cal) 27%, var(--h-surface)); z-index: 2; }
.h-event > * { flex-shrink: 0; max-width: 100%; }
.h-event__title { font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.h-event__meta { font-size: 12px; color: var(--h-ink-2); display: flex; flex-wrap: wrap; gap: 0 6px; }
.h-event__loc { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.h-event__badge { position: absolute; right: 5px; top: 5px; color: var(--h-ink-2); }
.h-event.is-compact { flex-direction: row; align-items: center; gap: 6px; padding-top: 1px; padding-bottom: 1px; }
.h-event.is-compact .h-event__title { -webkit-line-clamp: 1; font-size: 12px; }
.h-event.is-compact .h-event__meta { order: -1; }
.h-event.is-past { opacity: .62; }
/* Sola lettura: tratteggio diagonale, leggibile anche senza colore */
.h-event.is-readonly {
    background:
        repeating-linear-gradient(135deg, transparent 0 6px, color-mix(in srgb, var(--cal) 14%, transparent) 6px 8px),
        color-mix(in srgb, var(--cal) 9%, var(--h-surface));
}
/* Da confermare: bordo tratteggiato */
.h-event.is-tentative { outline: 1px dashed color-mix(in srgb, var(--cal) 70%, var(--h-ink)); outline-offset: -1px; }

/* Adesso */
.h-now { position: absolute; left: -1px; right: 0; height: 0; border-top: 2px solid var(--h-signal); z-index: 3; pointer-events: none; }
.h-now::before { content: ""; position: absolute; left: -5px; top: -6px; width: 10px; height: 10px; border-radius: 50%; background: var(--h-signal); }

/* ---------------------------------------------------------------- chip (giorno intero, mese) */

.h-chip {
    display: flex; align-items: center; gap: 6px; min-width: 0;
    width: 100%; padding: 2px 6px; border: 0; border-radius: var(--h-event-radius);
    background: transparent; color: var(--h-ink); text-align: left;
    font-size: 12.5px; line-height: 1.35;
}
.h-chip::before { content: ""; flex: none; width: 7px; height: 7px; border-radius: 50%; background: var(--cal); }
.h-chip:hover { background: color-mix(in srgb, var(--cal) 15%, transparent); }
.h-chip--fill { background: color-mix(in srgb, var(--cal) 20%, var(--h-surface)); box-shadow: inset 3px 0 0 var(--cal); padding-left: 8px; font-weight: 500; }
.h-chip--fill::before { display: none; }
.h-chip.is-readonly.h-chip--fill { background: repeating-linear-gradient(135deg, transparent 0 6px, color-mix(in srgb, var(--cal) 16%, transparent) 6px 8px), color-mix(in srgb, var(--cal) 10%, var(--h-surface)); }
.h-chip__time { color: var(--h-ink-2); flex: none; }
.h-chip__title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.h-more { font-size: 12px; color: var(--h-ink-2); padding: 0 6px; }
.h-more--link { border: 0; background: none; text-align: left; text-decoration: underline; text-underline-offset: 2px; }

/* ---------------------------------------------------------------- vista mese */

.h-month { --h-wk: 30px; display: grid; grid-template-rows: auto minmax(0, 1fr); min-height: 0; background: var(--h-surface); border: 1px solid var(--h-line); }
.h-month__dows { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border-bottom: 1px solid var(--h-line); padding-left: var(--h-wk); }
.h-month__dows > span { padding: 8px 10px; font-size: 13px; color: var(--h-ink-2); overflow: hidden; white-space: nowrap; }
.h-dow-short { display: none; }
.h-month__grid { display: grid; grid-template-rows: repeat(6, minmax(118px, 1fr)); min-height: 0; overflow: auto; }
/* Una settimana: 7 celle (sfondo, numero, "+N") e sopra le corsie con le barre degli eventi */
.h-mweek { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); grid-template-rows: minmax(0, 1fr); min-height: 0; }
.h-mweek > .h-mcell { grid-row: 1; }
/* Numero di settimana (patch 027): colonna stretta a sinistra, come Google Calendar */
.h-mweek { position: relative; padding-left: var(--h-wk); }
.h-mweek__num {
    position: absolute; left: 0; top: 0; bottom: 0; width: var(--h-wk);
    display: flex; justify-content: center; align-items: flex-start; padding: 10px 0 0;
    border: 0; border-right: 1px solid var(--h-line-soft); border-bottom: 1px solid var(--h-line-soft);
    background: color-mix(in srgb, var(--h-ink) 4%, var(--h-surface)); color: var(--h-ink-2);
    font: 600 11px/1 var(--h-ui); cursor: pointer;
}
.h-mweek__num:hover { color: var(--h-ink); background: color-mix(in srgb, var(--h-ink) 9%, var(--h-surface)); }
.h-week__wk { display: flex; align-items: flex-end; justify-content: center; padding-bottom: 8px; font: 600 12px/1 var(--h-ui); color: var(--h-ink-2); }

.h-mcell {
    position: relative;
    display: flex; flex-direction: column; gap: 1px; min-width: 0;
    padding: 4px 4px 6px;
    border-right: 1px solid var(--h-line-soft); border-bottom: 1px solid var(--h-line-soft);
}
.h-mcell.is-weekend { background: var(--h-weekend); }
.h-mcell.is-outside .h-mcell__num { color: var(--h-ink-2); opacity: .55; }
.h-mcell__num {
    align-self: flex-start; border: 0; background: none;
    font: 700 18px/1 var(--h-display); padding: 5px 6px 2px; border-radius: 2px;
}
.h-mcell__num:hover { background: color-mix(in srgb, var(--h-ink) 8%, transparent); }
/* Oggi: cella colorata, bordo color sodio e numero pieno, ben visibile anche sul telefono e nel tema scuro. */
.h-mcell.is-today {
    background: color-mix(in srgb, var(--h-signal) 17%, var(--h-surface));
    box-shadow: inset 0 0 0 2px var(--h-signal);
}
.h-mcell.is-today .h-mcell__num {
    background: var(--h-signal); color: var(--h-signal-ink);
    border-radius: 999px; min-width: 1.7em; text-align: center; font-weight: 800;
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--h-signal) 35%, transparent);
}
/* "+N altri" subito sotto la terza corsia (32px + 3 × 22px) */
.h-mcell__more { position: absolute; left: 4px; top: 98px; padding: 0 4px; line-height: 16px; }

/* ---------------------------------------------------------------- corsie (barre su più giorni) */

.h-lanes {
    grid-row: 1; grid-column: 1 / -1; align-self: start;
    display: grid; grid-auto-rows: 20px; row-gap: 2px;
    margin-top: 32px; position: relative; z-index: 1;
    pointer-events: none; /* lo spazio vuoto tra le barre appartiene alle celle sotto */
}
.h-lanes--allday { grid-column: 2 / -1; margin-top: 4px; }
.h-lanes > .h-chip { pointer-events: auto; width: auto; min-width: 0; margin: 0 4px; padding-top: 0; padding-bottom: 0; line-height: 20px; }
.h-lanes > .h-chip--fill.is-cont-l { margin-left: 0; border-top-left-radius: 0; border-bottom-left-radius: 0; box-shadow: none; }
.h-lanes > .h-chip.is-cont-r { margin-right: 0; border-top-right-radius: 0; border-bottom-right-radius: 0; }
.h-lanes > .h-chip--fill.is-cont-r { clip-path: polygon(0 0, calc(100% - 7px) 0, 100% 50%, calc(100% - 7px) 100%, 0 100%); padding-right: 12px; }
.h-lanes > .h-chip--fill.is-cont-l { clip-path: polygon(7px 0, 100% 0, 100% 100%, 7px 100%, 0 50%); padding-left: 12px; }
.h-lanes > .h-chip--fill.is-cont-l.is-cont-r { clip-path: polygon(7px 0, calc(100% - 7px) 0, 100% 50%, calc(100% - 7px) 100%, 7px 100%, 0 50%); }
.h-chip.is-tentative { outline: 1px dashed var(--cal); outline-offset: -1px; }

/* ---------------------------------------------------------------- agenda */

.h-agenda { overflow-y: auto; min-height: 0; background: var(--h-surface); border: 1px solid var(--h-line); padding: 6px 0; }
.h-aday { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 0 18px; padding: 14px 20px; border-bottom: 1px solid var(--h-line-soft); }
.h-aday:last-child { border-bottom: 0; }
.h-aday__head { display: flex; align-items: flex-start; gap: 10px; }
.h-aday__num { font: 700 34px/0.9 var(--h-display); padding-top: 4px; }
.h-aday.is-today .h-aday__num { color: var(--h-signal-ink); background: var(--h-signal); padding: 6px 6px 0; border-radius: 2px; }
.h-aday__label { display: grid; font-weight: 500; line-height: 1.25; }
.h-aday__month { color: var(--h-ink-2); font-weight: 400; font-size: 13px; }
.h-aday__empty { margin: 6px 0; color: var(--h-ink-2); }
.h-aday__list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }

.h-arow {
    display: grid; grid-template-columns: 112px 4px minmax(0, 1fr); gap: 12px; align-items: stretch;
    width: 100%; padding: 7px 8px; border: 0; border-radius: var(--h-event-radius); background: transparent; text-align: left;
}
.h-arow:hover { background: color-mix(in srgb, var(--cal) 12%, transparent); }
.h-arow__time { color: var(--h-ink-2); font-size: 13.5px; padding-top: 1px; }
.h-arow__bar { background: var(--cal); border-radius: 3px; }
.h-arow.is-readonly .h-arow__bar { background: repeating-linear-gradient(180deg, var(--cal) 0 4px, transparent 4px 7px); }
.h-arow__body { display: grid; gap: 2px; min-width: 0; }
.h-arow__title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.h-arow__meta { display: flex; flex-wrap: wrap; gap: 2px 14px; font-size: 13px; color: var(--h-ink-2); }
.h-arow__meta span { display: inline-flex; align-items: center; gap: 4px; }

/* ---------------------------------------------------------------- pannello evento */

.h-drawer-backdrop { position: fixed; inset: 0; background: rgb(15 21 24 / .32); z-index: 40; animation: h-fade .18s ease-out; }
.h-drawer {
    position: fixed; z-index: 41; top: 0; right: 0; bottom: 0;
    width: min(440px, 100vw);
    display: flex; flex-direction: column;
    /* I pulsanti in fondo (Salva, Elimina) restano sopra i tasti di sistema del telefono. */
    box-sizing: border-box;
    padding-top: env(safe-area-inset-top, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: var(--h-surface); border-left: 1px solid var(--h-line);
    animation: h-slide .2s ease-out;
}
@keyframes h-slide { from { transform: translateX(24px); opacity: 0; } }
@keyframes h-fade { from { opacity: 0; } }

.h-drawer__head { display: flex; align-items: flex-start; gap: 12px; padding: 20px 20px 10px 24px; }
.h-drawer__head h2 { flex: 1; margin: 0; font: 700 26px/1.1 var(--h-display); padding-top: 6px; overflow-wrap: anywhere; }
.h-drawer__body { flex: 1; overflow-y: auto; padding: 6px 24px 0; display: flex; flex-direction: column; gap: 16px; }
.h-drawer__foot {
    position: sticky; bottom: 0; margin: auto -24px 0; padding: 14px 24px;
    display: flex; align-items: center; gap: 8px;
    background: var(--h-surface); border-top: 1px solid var(--h-line);
}
aside > .h-drawer__foot { margin: 0; }
.h-drawer__spacer { flex: 1; }

.h-field { display: grid; gap: 5px; }
.h-field__label { font-size: 13px; font-weight: 500; color: var(--h-ink-2); }
.h-field__hint { margin: -8px 0 0; font-size: 12.5px; color: var(--h-ink-2); }
.h-input {
    width: 100%; min-height: 38px; padding: 7px 10px;
    border: 1px solid var(--h-line); border-radius: var(--h-radius);
    background: var(--h-canvas); color: var(--h-ink);
}
.h-input:focus { outline: 2px solid var(--h-focus); outline-offset: -1px; background: var(--h-surface); }
.h-input--title { font: 600 18px/1.3 var(--h-ui); }
.h-input--area { resize: vertical; min-height: 92px; }
.h-input--static { display: flex; align-items: center; gap: 8px; background: transparent; }
.h-when { display: grid; gap: 12px; }
.h-when__pair { display: grid; grid-template-columns: 1fr 132px; gap: 8px; }
.h-when__pair:has(> :only-child) { grid-template-columns: 1fr; }
.h-check { display: flex; align-items: center; gap: 8px; }
.h-check input { width: 17px; height: 17px; accent-color: var(--h-ink); }

/* ---------------------------------------------------------------- senza rete: caricamento, fotografia, eventi in attesa */
.h-loading {
    height: 100%; min-height: 220px; display: grid; place-content: center; justify-items: center; gap: 6px;
    color: var(--h-ink-2); text-align: center; padding: 24px;
}
.h-loading p { margin: 6px 0 0; font: 600 17px/1.3 var(--h-ui); color: var(--h-ink); }
.h-loading small { font-size: 13px; }
.h-banner--offline { background: color-mix(in srgb, var(--h-signal) 22%, var(--h-surface)); }
.is-queued { outline: 1.5px dashed color-mix(in srgb, var(--h-ink) 55%, transparent); outline-offset: -1.5px; opacity: .85; }
.is-queued-error { outline-color: var(--h-danger); }
.h-queued-icon { display: inline-block; vertical-align: -1px; margin-right: 3px; }
.h-notice--error { color: var(--h-danger); }

/* ---------------------------------------------------------------- conflitti (modifiche fatte senza rete e altrove) */
.h-banner--conflict { background: color-mix(in srgb, var(--h-danger) 14%, var(--h-surface)); border-left-color: var(--h-danger); }
.h-banner__action {
    margin-left: auto; border: 0; background: none; padding: 2px 4px; color: var(--h-danger);
    font-weight: 600; text-decoration: underline; text-underline-offset: 3px; cursor: pointer;
}
.h-dialog.h-conflicts { top: 10vh; width: min(560px, calc(100vw - 32px)); max-height: 80vh; display: flex; flex-direction: column; }
.h-conflicts__list { overflow-y: auto; min-height: 0; display: grid; gap: 12px; }
.h-conflict { border: 1px solid var(--h-line); border-left: 3px solid var(--h-danger); border-radius: var(--h-radius); padding: 12px 14px; }
.h-dialog .h-conflict__msg { margin: 0 0 4px; color: var(--h-ink); font-weight: 600; overflow-wrap: anywhere; }
.h-dialog .h-conflict__meta { margin: 0 0 10px; font-size: 13px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.h-conflict__dot { width: 10px; height: 10px; border-radius: 50%; background: var(--cal); flex: none; }
.h-conflict__actions { display: flex; flex-wrap: wrap; gap: 8px; }
.h-compare { width: 100%; border-collapse: collapse; margin: 0 0 10px; font-size: 13px; table-layout: fixed; }
.h-compare th, .h-compare td { text-align: left; vertical-align: top; padding: 5px 6px; border-bottom: 1px solid var(--h-line); overflow-wrap: anywhere; white-space: pre-line; }
.h-compare thead th { font-weight: 600; color: var(--h-ink-2); }
.h-compare tbody th { width: 26%; font-weight: 500; color: var(--h-ink-2); }
.h-compare tr.is-diff td { background: color-mix(in srgb, var(--h-signal) 10%, transparent); color: var(--h-ink-2); }
.h-compare tr.is-diff td.is-chosen { background: color-mix(in srgb, var(--h-signal) 30%, transparent); color: var(--h-ink); font-weight: 500; }
.h-pick { display: flex; gap: 6px; align-items: flex-start; cursor: pointer; }
.h-pick input { margin: 2px 0 0; flex: none; accent-color: var(--h-signal); }
.h-dialog .h-conflict__hint { margin: 0 0 8px; font-size: 13px; }

/* ---------------------------------------------------------------- ripetizione e scelta "questo / successivi / tutti" */
.h-repeat > .h-field__label { display: flex; align-items: center; gap: 6px; }
.h-dialog.h-dialog--plain { border-top-color: var(--h-signal); }
.h-repeat__custom {
    display: grid; gap: 12px; margin-top: 6px; padding: 12px;
    border: 1px solid var(--h-line); border-radius: var(--h-radius); background: var(--h-canvas);
}
.h-repeat__row { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; font-size: 14px; }
.h-repeat__row > .h-input { width: auto; flex: 1; min-width: 0; }
.h-input--num { width: 72px !important; flex: none !important; text-align: center; }
.h-repeat__days { display: flex; gap: 6px; flex-wrap: wrap; }
.h-daychip {
    width: 34px; height: 34px; border-radius: 50%;
    border: 1px solid var(--h-line); background: var(--h-surface); color: var(--h-ink);
    font: 600 13px/1 var(--h-ui); cursor: pointer;
}
.h-daychip.is-on { background: var(--h-ink); border-color: var(--h-ink); color: var(--h-surface); }
.h-daychip:focus-visible { outline: 2px solid var(--h-focus); outline-offset: 2px; }
.h-repeat__end { display: grid; gap: 8px; }
.h-repeat__end .h-check { min-height: 38px; flex-wrap: wrap; }
.h-repeat__end .h-check > .h-input { width: auto; flex: 1; min-width: 120px; }
.h-repeat__end .h-check > .h-input--num { min-width: 0; }
.h-repeat__end .h-input:disabled { opacity: .5; }
.h-scope { display: grid; gap: 10px; margin: 6px 0 4px; }
.h-scope__item { font-size: 15px; min-height: 30px; }

.h-detail__calendar { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.h-detail__swatch { width: 12px; height: 12px; border-radius: 50%; background: var(--cal); flex: none; }
.h-detail__when { margin: 0; font-size: 17px; }
.h-detail__row { margin: 0; display: flex; align-items: center; gap: 8px; color: var(--h-ink-2); }
.h-detail__desc { margin: 0; white-space: pre-line; max-width: 62ch; }

.h-notice {
    margin: 0; display: flex; align-items: flex-start; gap: 8px;
    padding: 10px 12px; background: var(--h-canvas); font-size: 13.5px; color: var(--h-ink-2);
}
.h-notice .h-icon { margin-top: 2px; }
.h-error { margin: 0; padding: 10px 12px; border-left: 3px solid var(--h-danger); background: color-mix(in srgb, var(--h-danger) 10%, var(--h-surface)); }
.h-error p { margin: 0; }

.h-toast {
    position: fixed; left: 50%; bottom: 22px; z-index: 50;
    transform: translate(-50%, 16px); opacity: 0; pointer-events: none;
    padding: 10px 16px; border-radius: var(--h-radius);
    background: var(--h-ink); color: var(--h-surface); font-weight: 500;
    transition: opacity .2s ease, transform .2s ease;
}
.h-toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

.h-empty { align-self: center; justify-self: center; display: grid; gap: 14px; justify-items: center; color: var(--h-ink-2); padding: 40px 0; }
.h-skeleton { background: var(--h-surface); border: 1px solid var(--h-line); }

/* ---------------------------------------------------------------- accesso */

.h-login { box-sizing: border-box; padding-bottom: env(safe-area-inset-bottom, 0px); min-height: 100dvh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); background: var(--h-surface); }
.h-login__panel { display: flex; flex-direction: column; justify-content: center; align-items: flex-start; gap: 18px; padding: 56px clamp(24px, 6vw, 88px); max-width: 640px; }
.h-login__brand { display: flex; align-items: center; gap: 10px; font: 700 24px/1 var(--h-display); }
.h-login__brand .h-icon { color: var(--h-signal); }
.h-login__title { margin: 18px 0 0; font: 700 clamp(38px, 5vw, 60px)/0.98 var(--h-display); letter-spacing: -.015em; max-width: 13ch; }
.h-login__lead { margin: 0; font-size: 17px; line-height: 1.55; max-width: 46ch; color: var(--h-ink-2); }
.h-login__info { margin: 0; color: var(--h-ink-2); }
.h-login__actions { display: flex; flex-wrap: wrap; gap: 10px; }
.h-login__fine { margin: 12px 0 0; font-size: 13px; color: var(--h-ink-2); max-width: 52ch; }
.h-login__direct { margin-top: 18px; padding-top: 16px; border-top: 1px dashed var(--h-line); display: grid; gap: 8px; }
.h-login__direct h2 { margin: 0; font: 700 15px/1.2 var(--h-ui); text-transform: uppercase; letter-spacing: .06em; color: var(--h-ink-2); }
.h-login__direct p { margin: 0 0 4px; font-size: 14px; color: var(--h-ink-2); max-width: 52ch; }
.h-login__art { background: var(--h-rail); position: relative; overflow: hidden; }
.h-login__art svg { position: absolute; inset: 0; width: 100%; height: 100%; }

.h-plain { min-height: 100dvh; display: grid; align-content: center; justify-items: start; gap: 12px; padding: 40px clamp(24px, 8vw, 120px); }
.h-plain h1 { margin: 0; font: 700 44px/1 var(--h-display); }
.h-plain p { margin: 0; color: var(--h-ink-2); max-width: 52ch; }
.h-plain__code { font: 700 18px/1 var(--h-display); color: var(--h-signal) !important; }

/* ---------------------------------------------------------------- schermi stretti (e futura app mobile) */

@media (max-width: 1100px) {
    .h-sync span { display: none; }
}

@media (max-width: 820px) {
    :root { --h-event-radius: 4px; } /* etichette piccole del telefono */
    :root { --h-gutter: 38px; --h-hour: 48px; }
    .h-app { grid-template-columns: minmax(0, 1fr); }
    .h-rail {
        position: fixed; z-index: 30; inset: 0 auto 0 0; width: min(320px, 88vw);
        transform: translateX(-102%); transition: transform .2s ease-out;
    }
    .h-rail.is-open { transform: none; }
    .h-rail { padding-top: calc(18px + env(safe-area-inset-top, 0px)); padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px)); }
    .h-rail__close { display: inline-grid; }
    .h-rail-backdrop { position: fixed; inset: 0; z-index: 29; background: rgb(15 21 24 / .4); }
    /* Barra in UNA riga, come Google Calendar: menu · mese · vista ▾ · oggi · aggiorna. Nuovo evento = pulsante tondo. */
    .h-bar { flex-wrap: nowrap; padding: 6px 6px 6px 8px; gap: 2px; }
    .h-bar__menu { display: inline-grid; }
    .h-period { flex: 1 1 auto; min-width: 0; gap: 6px; margin: 0 4px; }
    .h-period__main { font-size: 23px; padding-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .h-period__year { display: none; } /* come Google Calendar: solo il mese (l'anno resta nel titolo della pagina) */
    .h-week__wk { font-size: 10.5px; padding-bottom: 6px; }
    .h-month { --h-wk: 20px; }
    .h-mweek__num { padding-top: 6px; font-size: 10px; font-weight: 500; }
    .h-bar__nav, .h-seg, .h-newbtn { display: none; }
    .h-bar__end { width: auto; margin-left: 0; gap: 0; }
    .h-viewpick {
        display: inline-flex; align-items: center; gap: 4px; flex: none;
        height: 34px; padding: 0 8px 0 10px; border: 1px solid var(--h-line); border-radius: var(--h-radius);
        background: transparent; color: var(--h-ink); font-weight: 500; font-size: 14px;
    }
    .h-todaybtn {
        display: inline-grid; place-items: center; width: 40px; height: 40px; padding: 0;
        border: 0; background: transparent; color: var(--h-ink);
    }
    .h-todaybtn span {
        display: grid; place-items: center; width: 22px; height: 22px; box-sizing: border-box;
        border: 2px solid currentColor; border-top-width: 5px; border-radius: 3px;
        font-size: 11px; font-weight: 700; line-height: 1;
    }
    .h-sync { width: 40px; height: 40px; justify-content: center; padding: 0; color: var(--h-ink); }
    .h-fab {
        display: grid; place-items: center;
        position: fixed; z-index: 25;
        right: calc(16px + env(safe-area-inset-right, 0px)); bottom: calc(18px + env(safe-area-inset-bottom, 0px));
        width: 56px; height: 56px; border: 0; border-radius: 16px;
        background: var(--h-signal); color: var(--h-signal-ink);
        box-shadow: 0 6px 18px rgb(15 21 24 / .3);
    }
    .h-toast { bottom: calc(86px + env(safe-area-inset-bottom, 0px)); max-width: calc(100vw - 32px); }
    .h-stage { padding: 0 0 0; }
    .h-week, .h-month, .h-agenda { border-left: 0; border-right: 0; }
    /* Settimana: 7 colonne strette senza scorrimento orizzontale (lo scorrimento laterale cambia periodo). */
    .h-dayhead { flex-direction: column; align-items: center; gap: 2px; padding: 6px 2px; }
    .h-dayhead__num { font-size: 20px; }
    .h-week .h-event { font-size: 10.5px; padding: 2px 3px; }
    .h-week .h-event__meta { display: none; }
    .h-aday { grid-template-columns: 1fr; gap: 8px; padding: 14px 14px; }
    .h-arow { grid-template-columns: 84px 4px minmax(0, 1fr); gap: 10px; }
    /* Mese: sempre tutto sullo schermo, le 6 settimane si dividono l'altezza disponibile. */
    .h-month__grid { grid-template-rows: repeat(6, minmax(0, 1fr)); overflow: hidden; }
    .h-mcell { overflow: hidden; padding: 2px 2px 4px; }
    .h-mcell__num { font-size: 15px; padding: 3px 4px 1px; }
    .h-month__dows > span { padding: 6px 4px; font-size: 12px; }
    .h-dow-long { display: none; }
    .h-dow-short { display: inline; }
    .h-lanes { margin-top: 23px; grid-auto-rows: 16px; row-gap: 2px; }
    .h-mcell__more { top: 77px; left: 2px; font-size: 10.5px; line-height: 14px; }
    .h-lanes > .h-chip { margin: 0 1px; padding-left: 3px; padding-right: 2px; gap: 3px; font-size: 10.5px; line-height: 16px; }
    .h-lanes > .h-chip::before { width: 5px; height: 5px; }
    .h-chip__time { display: none; }
    .h-login { grid-template-columns: 1fr; grid-template-rows: 140px auto; }
    .h-login__art { order: -1; }
}

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

/* ---------------------------------------------------------------- anteprima nomi (solo sviluppo) */

.h-names { min-height: 100dvh; padding: 40px clamp(20px, 5vw, 64px); display: grid; gap: 28px; align-content: start; }
.h-names__intro h1 { margin: 0 0 6px; font: 700 34px/1.05 var(--h-display); }
.h-names__intro p { margin: 0; color: var(--h-ink-2); max-width: 70ch; }
.h-namerow { display: grid; grid-template-columns: 260px minmax(0, 1fr); border: 1px solid var(--h-line); background: var(--h-surface); }
.h-namerow.is-current { box-shadow: inset 4px 0 0 var(--h-signal); }
.h-namerow__rail { background: var(--h-rail); color: var(--h-rail-ink); padding: 18px 16px; display: grid; gap: 14px; align-content: start; }
.h-namerow__rail .h-rail__brand { font-size: 21px; }
.h-namerow__tab { font-size: 12.5px; color: var(--h-rail-dim); }
.h-namerow__body { padding: 22px 28px; display: grid; gap: 10px; align-content: center; }
.h-namerow__title { margin: 0; font: 700 clamp(28px, 3.4vw, 44px)/1 var(--h-display); letter-spacing: -.012em; }
.h-namerow__line { margin: 0; color: var(--h-ink-2); max-width: 62ch; }
.h-namerow__meta { margin: 0; font-size: 13px; color: var(--h-ink-2); }
.h-namerow__meta code { color: var(--h-ink); }
@media (max-width: 820px) { .h-namerow { grid-template-columns: 1fr; } }

/* ---------------------------------------------------------------- interazioni: trascina, ridimensiona, seleziona */

.h-week__grid, .h-week__allday, .h-month__grid { user-select: none; -webkit-user-select: none; }
.h-event.is-editable, .h-chip.is-editable { cursor: grab; }
.h-event.is-readonly, .h-chip.is-readonly { cursor: pointer; }
.h-event.is-dragging, .h-chip.is-dragging { opacity: .3; }
body.h-is-dragging, body.h-is-dragging * { cursor: grabbing !important; }

.h-event__resize {
    position: absolute; left: 0; right: 0; bottom: 0; height: 8px;
    cursor: ns-resize;
}
.h-event__resize::after {
    content: ""; position: absolute; left: 50%; bottom: 2px; width: 18px; height: 2px; margin-left: -9px;
    border-radius: 1px; background: color-mix(in srgb, var(--cal) 70%, var(--h-ink)); opacity: 0;
}
.h-event.is-editable:hover .h-event__resize::after { opacity: .7; }

/* Livello grafico del trascinamento (fuori dal DOM di Blazor) */
.h-dnd-layer > * { position: fixed; z-index: 60; pointer-events: none; }
.h-dnd-layer .h-event { position: fixed; }
.h-dnd-ghost { outline: 2px solid var(--cal); outline-offset: -1px; background: color-mix(in srgb, var(--cal) 30%, var(--h-surface)) !important; }
.h-dnd-ghost .h-event__resize { display: none; }
.h-dnd-select {
    border-radius: 2px;
    background: color-mix(in srgb, var(--h-signal) 26%, transparent);
    box-shadow: inset 3px 0 0 var(--h-signal);
    padding: 3px 8px; font-size: 12px; font-weight: 600; color: var(--h-ink);
}
.h-dnd-day { background: color-mix(in srgb, var(--h-signal) 20%, transparent); }
.h-dnd-target { outline: 2px dashed var(--h-signal); outline-offset: -3px; }
.h-dnd-label span {
    display: inline-block; white-space: nowrap; padding: 2px 8px; border-radius: 2px;
    background: var(--h-signal); color: var(--h-signal-ink); font-size: 12px; font-weight: 600;
}

/* ---------------------------------------------------------------- menu contestuale */

.h-menu-backdrop { position: fixed; inset: 0; z-index: 44; }
.h-menu {
    position: fixed; z-index: 45; width: 260px; padding: 6px;
    background: var(--h-surface); border: 1px solid var(--h-line); border-radius: var(--h-radius);
    box-shadow: 0 10px 28px rgb(15 21 24 / .18);
    animation: h-fade .12s ease-out;
}
.h-menu__title {
    margin: 0 0 4px; padding: 6px 10px 8px; border-bottom: 1px solid var(--h-line-soft);
    font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.h-menu__item {
    display: flex; align-items: center; gap: 10px; width: 100%;
    padding: 8px 10px; border: 0; border-radius: 2px; background: transparent;
    color: var(--h-ink); text-align: left; text-decoration: none; font-size: 14px;
}
.h-menu__item:hover, .h-menu__item:focus-visible { background: var(--h-canvas); }
.h-menu__item .h-icon { color: var(--h-ink-2); }
.h-menu__item.is-danger, .h-menu__item.is-danger .h-icon { color: var(--h-danger); }

/* ---------------------------------------------------------------- finestra di conferma */

.h-dialog-backdrop { position: fixed; inset: 0; z-index: 46; background: rgb(15 21 24 / .32); animation: h-fade .15s ease-out; }
.h-dialog {
    position: fixed; z-index: 47; left: 50%; top: 22vh; transform: translateX(-50%);
    width: min(420px, calc(100vw - 32px)); padding: 22px 24px 18px;
    background: var(--h-surface); border: 1px solid var(--h-line); border-top: 4px solid var(--h-danger);
    border-radius: var(--h-radius);
}
.h-dialog h2 { margin: 0 0 8px; font: 700 22px/1.15 var(--h-display); overflow-wrap: anywhere; }
.h-dialog p { margin: 0 0 14px; color: var(--h-ink-2); }
.h-dialog__actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

/* ---------------------------------------------------------------- avviso con azione (Annulla) */

.h-toast { display: flex; align-items: center; gap: 14px; }
.h-toast.is-visible { pointer-events: auto; }
.h-toast__action {
    border: 0; background: none; padding: 0; color: var(--h-signal);
    font-weight: 600; text-decoration: underline; text-underline-offset: 3px;
}

/* ---------------------------------------------------------------- vista giorno */

.h-week.is-day .h-dayhead { padding-left: 14px; }
.h-week.is-day .h-dayhead__dow { font-size: 15px; }

/* ---------------------------------------------------------------- creazione rapida (solo titolo, come Google Calendar) */

/* il segnaposto resta sotto il riquadro di creazione rapida */
.h-dnd-layer > .is-pending { z-index: 43; } /* sopra l'oscuramento (42), sotto il riquadro (45) */
.h-dnd-layer > .h-dnd-select.is-pending { box-shadow: inset 3px 0 0 var(--h-signal), 0 4px 14px rgb(15 21 24 / .18); }
/* Il riquadro si stacca dallo sfondo: sfondo leggermente oscurato, bordo netto, ombra marcata. */
.h-quick-backdrop { position: fixed; inset: 0; z-index: 42; background: rgb(10 14 16 / .32); animation: h-fade .12s ease-out; }
.h-quick {
    position: fixed; z-index: 45; width: 360px; max-width: calc(100vw - 16px);
    padding: 16px 16px 12px;
    background: var(--h-surface);
    border: 1.5px solid color-mix(in srgb, var(--h-ink) 42%, transparent); border-top: 4px solid var(--h-signal);
    border-radius: var(--h-radius);
    box-shadow: 0 0 0 1px rgb(0 0 0 / .18), 0 18px 44px rgb(0 0 0 / .42);
    display: grid; gap: 10px;
    animation: h-fade .12s ease-out;
}
.h-quick__title {
    width: 100%; border: 0; border-bottom: 2px solid var(--h-line); border-radius: 0;
    padding: 4px 2px 6px; background: transparent; color: var(--h-ink);
    font: 600 20px/1.2 var(--h-display);
}
.h-quick__title:focus { outline: none; border-bottom-color: var(--h-signal); }
.h-quick__row { display: flex; align-items: center; gap: 10px; margin: 0; font-size: 14px; color: var(--h-ink); }
.h-quick__row .h-icon { flex: none; color: var(--h-ink-2); }
.h-quick__row select { flex: 1; min-width: 0; }
.h-quick__dot { flex: none; width: 12px; height: 12px; border-radius: 50%; background: var(--cal); margin: 0 3px; }
.h-quick__error { margin: 0; font-size: 13px; color: var(--h-danger); }
.h-quick__actions { display: flex; justify-content: space-between; gap: 8px; margin-top: 2px; }
/* Telefono: il riquadro sta sempre in alto, così la tastiera (che sale dal basso) non lo copre mai,
   qualunque sia il giorno toccato. Prevale sulla posizione calcolata accanto alla selezione. */
@media (max-width: 820px) {
    .h-quick {
        left: 8px !important; right: 8px; top: calc(env(safe-area-inset-top, 0px) + 8px) !important;
        width: auto; max-width: none;
        animation: h-quick-down .16s ease-out;
    }
}
@keyframes h-quick-down { from { opacity: 0; transform: translateY(-12px); } to { opacity: 1; transform: none; } }

/* ---------------------------------------------------------------- scelta lingua */

.h-lang { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; font-size: 13px; }
.h-lang .h-icon { opacity: .7; margin-right: 2px; }
.h-lang a, .h-lang button {
    border: 1px solid transparent; border-radius: 999px; background: none; color: inherit;
    padding: 3px 10px; text-decoration: none; opacity: .75; font: inherit;
}
.h-lang a:hover, .h-lang button:hover { opacity: 1; border-color: currentColor; }
.h-lang .is-active { opacity: 1; border-color: currentColor; font-weight: 600; }
.h-rail .h-lang { color: var(--h-rail-ink); padding: 0 2px; }
.h-login .h-lang { color: var(--h-ink-2); margin-top: 6px; }

/* ---------------------------------------------------------------- oggi più evidente (intestazioni) */

.h-dayhead.is-today { background: color-mix(in srgb, var(--h-signal) 16%, var(--h-surface)); }
.h-dayhead.is-today .h-dayhead__dow { color: var(--h-ink); font-weight: 700; }
.h-aday.is-today { background: color-mix(in srgb, var(--h-signal) 12%, var(--h-surface)); box-shadow: inset 4px 0 0 var(--h-signal); }

/* ---------------------------------------------------------------- telefono: zoom dal mese al giorno e ritorno */
/* Origine = giorno toccato (--zx, --zy in %). Entrando il giorno "esce" dalla sua cella; tornando il mese si
   restringe verso quella cella, come in Google Calendar. */
/* Si anima la vista dentro l'area del calendario, che durante lo zoom taglia ciò che esce (barra in alto intatta). */
.h-stage.is-zoom-in, .h-stage.is-zoom-out { overflow: hidden; }
.h-stage.is-zoom-in > *, .h-stage.is-zoom-out > * { transform-origin: var(--zx, 50%) var(--zy, 50%); }
.h-stage.is-zoom-in > * { animation: h-zoom-in .3s cubic-bezier(.2,.75,.3,1) both; }
.h-stage.is-zoom-out > * { animation: h-zoom-out .3s cubic-bezier(.2,.75,.3,1) both; }
@keyframes h-zoom-in { from { transform: scale(.18); opacity: .2; } to { transform: none; opacity: 1; } }
@keyframes h-zoom-out { from { transform: scale(2.6); opacity: 0; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
    .h-stage.is-zoom-in > *, .h-stage.is-zoom-out > * { animation: none; }
}
/* Sul telefono numero del giorno e "+N altri" fanno come il resto della cella (zoom nel giorno): non sono bersagli
   a sé, altrimenti il telefono "aggancia" un tocco vicino al bordo al numero della cella sotto. */
@media (max-width: 820px) {
    .h-mcell__num, .h-mcell__more { pointer-events: none; }
}

/* Patch installata (per controllare che sul telefono ci sia l'APK nuovo). */
.h-rail__version { margin: 4px 0 0; font-size: 11px; color: inherit; opacity: .55; text-align: right; }
.h-rail__version a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }

/* ---------------------------------------------------------------- inviti (patch 026) */
.is-invited { background: transparent !important; outline: 1.5px solid var(--cal, var(--h-signal)); outline-offset: -1.5px; }
.is-maybe { background-image: repeating-linear-gradient(135deg, transparent 0 6px, color-mix(in srgb, var(--cal) 18%, transparent) 6px 9px); }
.is-declined { opacity: .55; }
.is-declined .h-chip__title, .is-declined .h-event__title, .is-declined .h-arow__title { text-decoration: line-through; }
.h-rsvp { display: grid; gap: 8px; margin: 4px 0 14px; padding: 12px; border: 1px solid var(--h-line); border-radius: var(--h-radius); background: var(--h-canvas); }
.h-rsvp__label { font-weight: 600; }
.h-rsvp__buttons { display: flex; gap: 8px; flex-wrap: wrap; }
.h-rsvp__btn {
    min-width: 72px; padding: 8px 14px; border: 1px solid var(--h-line); border-radius: 999px;
    background: var(--h-surface); color: var(--h-ink); font: inherit; cursor: pointer;
}
.h-rsvp__btn.is-active { background: var(--h-signal); border-color: var(--h-signal); color: #1b1408; font-weight: 600; }
.h-rsvp__btn:disabled { opacity: .6; cursor: default; }

/* ---------------------------------------------------------------- vista anno (patch 026) */
.h-year { height: 100%; overflow-y: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 18px 22px; align-content: start; padding: 4px 2px 18px; }
.h-ymonth__title { border: 0; background: none; padding: 0 0 6px; font: 600 15px/1.2 var(--h-ui); color: var(--h-ink); cursor: pointer; }
.h-ymonth.is-current .h-ymonth__title { color: var(--h-signal); }
.h-ymonth__dows, .h-ymonth__grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; text-align: center; }
.h-ymonth__dows span { font-size: 10px; color: var(--h-ink-2); text-transform: uppercase; }
.h-yday { aspect-ratio: 1; border: 0; border-radius: 6px; padding: 0; font: 500 11px/1 var(--h-ui); color: var(--h-ink); background: transparent; cursor: pointer; }
.h-yday.is-outside { cursor: default; }
.h-yday--l1 { background: color-mix(in srgb, var(--h-signal) 22%, transparent); }
.h-yday--l2 { background: color-mix(in srgb, var(--h-signal) 45%, transparent); }
.h-yday--l3 { background: color-mix(in srgb, var(--h-signal) 72%, transparent); color: #1b1408; font-weight: 600; }
.h-yday.is-today { outline: 2px solid var(--h-signal); outline-offset: -2px; }
.h-yday:hover { outline: 1px solid var(--h-ink-2); outline-offset: -1px; }
@media (max-width: 820px) {
    .h-year { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 12px; padding: 4px 10px 90px; }
}

/* Promemoria nel menu laterale (patch 026) */
.h-rail__toggle { margin: 10px 0 0; font-size: 13.5px; }
.h-rail__hint { margin: 4px 0 0 26px; font-size: 12px; line-height: 1.35; opacity: .7; }
.h-rail__hint.is-warning { opacity: 1; color: #E9A23B; }

/* ---------------------------------------------------------------- ricerca (patch 027) */
.h-search-backdrop { position: fixed; inset: 0; z-index: 38; background: rgb(15 21 24 / .32); animation: h-fade .18s ease-out; }
.h-search {
    position: fixed; z-index: 39; top: 0; right: 0; bottom: 0; width: min(520px, 100vw);
    display: flex; flex-direction: column; box-sizing: border-box;
    padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px);
    background: var(--h-surface); border-left: 1px solid var(--h-line);
    animation: h-slide .2s ease-out;
}
.h-search[hidden], .h-search-backdrop[hidden] { display: none; }
.h-search__head { display: flex; align-items: center; gap: 8px; padding: 14px 16px 6px 10px; }
.h-search__head h2 { flex: 1; margin: 0; font: 700 26px/1.1 var(--h-display); }
.h-search__periodbtn { display: inline-flex; align-items: center; gap: 6px; }
.h-search__form { display: grid; gap: 8px; padding: 6px 16px 10px; }
.h-search__field {
    display: flex; align-items: center; gap: 8px; padding: 0 6px 0 10px;
    border: 1px solid var(--h-line); border-radius: var(--h-radius); background: var(--h-canvas); color: var(--h-ink-2);
}
.h-search__field:focus-within { outline: 2px solid var(--h-focus); outline-offset: -1px; background: var(--h-surface); }
.h-search__field.is-picked { border-color: var(--h-signal); }
.h-search__input { flex: 1; min-width: 0; min-height: 42px; border: 0; background: transparent; color: var(--h-ink); font: 500 16px/1.2 var(--h-ui); outline: none; }
.h-search__input::-webkit-search-cancel-button { display: none; }
.h-search__person { position: relative; }
.h-search__suggest {
    position: absolute; z-index: 2; left: 0; right: 0; top: calc(100% + 4px); margin: 0; padding: 4px 0; list-style: none;
    max-height: 290px; overflow-y: auto;
    background: var(--h-surface); border: 1px solid var(--h-line); border-radius: var(--h-radius); box-shadow: 0 10px 28px rgb(15 21 24 / .18);
}
.h-search__suggest button { width: 100%; display: flex; align-items: center; gap: 10px; padding: 7px 12px; border: 0; background: none; text-align: left; color: var(--h-ink); cursor: pointer; }
.h-search__suggest button:hover, .h-search__suggest button:focus-visible { background: color-mix(in srgb, var(--h-ink) 7%, transparent); }
.h-search__avatar { flex: none; display: grid; place-items: center; width: 30px; height: 30px; border-radius: 999px; background: color-mix(in srgb, var(--h-signal) 30%, var(--h-surface)); font: 700 12px/1 var(--h-ui); }
.h-search__who { display: grid; min-width: 0; }
.h-search__who > span { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.h-search__who small { color: var(--h-ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.h-search__period { margin: 0; font-size: 12.5px; color: var(--h-ink-2); }
.h-search__status { display: flex; flex-wrap: wrap; gap: 4px 12px; padding: 8px 16px; font-size: 13px; color: var(--h-ink-2); border-top: 1px solid var(--h-line-soft); border-bottom: 1px solid var(--h-line-soft); }
.h-search__spin, .h-search__warn { display: inline-flex; align-items: center; gap: 6px; }
.h-search__warn { color: var(--h-ink); }
.h-search__error { color: var(--h-danger); }
.h-search__results { flex: 1; overflow-y: auto; padding: 4px 8px 24px; position: relative; }
.h-sday { display: grid; grid-template-columns: 64px minmax(0, 1fr); gap: 0 8px; padding: 10px 6px; border-bottom: 1px solid var(--h-line-soft); }
.h-sday.is-past { opacity: .78; }
.h-sday.is-today { background: color-mix(in srgb, var(--h-signal) 12%, var(--h-surface)); box-shadow: inset 4px 0 0 var(--h-signal); }
.h-sday__head { margin: 0; display: grid; justify-items: center; align-content: start; gap: 2px; font: inherit; }
.h-sday__num { font: 700 26px/1 var(--h-display); }
.h-sday__label { display: grid; justify-items: center; font-size: 12px; font-weight: 500; line-height: 1.25; }
.h-sday__month { color: var(--h-ink-2); font-weight: 400; }
.h-sday__list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.h-sday .h-arow { grid-template-columns: 92px 4px minmax(0, 1fr); gap: 10px; }
.h-search__dates { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.h-search__dialog { top: 18vh; }
.h-search__dialog .h-dialog__actions { flex-wrap: wrap; align-items: center; }
.h-searchbtn { color: var(--h-ink); }
@media (max-width: 820px) {
    .h-search { width: 100vw; border-left: 0; }
    .h-search-backdrop { display: none; }
    .h-search__head { padding: 8px 10px 4px 4px; }
    .h-search__head h2 { font-size: 22px; }
    .h-sday { grid-template-columns: 48px minmax(0, 1fr); padding: 8px 2px; }
    .h-sday__num { font-size: 22px; }
    .h-sday .h-arow { grid-template-columns: 70px 4px minmax(0, 1fr); gap: 8px; padding: 6px 4px; }
    .h-searchbtn { width: 40px; height: 40px; }
    .h-search__dates { grid-template-columns: 1fr; }
}

/* ---------------------------------------------------------------- segnala un problema (patch 031) */
.h-report { top: 8vh; width: min(560px, calc(100vw - 24px)); max-height: 84vh; overflow-y: auto; display: grid; gap: 12px; }
.h-report h2, .h-report p { margin: 0; }
.h-report__message { min-height: 96px; }
.h-report__details summary { cursor: pointer; font-size: 13px; color: var(--h-ink-2); }
.h-report__details pre {
    margin: 8px 0 0; max-height: 220px; overflow: auto; padding: 10px; white-space: pre-wrap; word-break: break-word;
    font: 11.5px/1.45 ui-monospace, SFMono-Regular, Consolas, monospace; color: var(--h-ink-2);
    background: var(--h-canvas); border: 1px solid var(--h-line); border-radius: var(--h-radius);
}
.h-report__error { color: var(--h-danger); display: flex; flex-wrap: wrap; gap: 4px 12px; }
.h-report__mail { color: var(--h-ink); font-weight: 600; }
.h-report .h-dialog__actions { margin-top: 4px; }
.h-rail__report { display: inline-flex; align-items: center; gap: 8px; margin: 14px 0 4px; }
.h-error__report { margin-left: 8px; font-weight: 600; }
.h-plain__actions { display: flex; gap: 8px; flex-wrap: wrap; }
