:root {
    --bg: #f5f7fa;
    --surface: #ffffff;
    --surface-alt: #eef2f7;
    --text: #17202b;
    --muted: #5a6778;
    --border: #dde3ea;
    --primary: #0356c0;
    --primary-hover: #024497;
    --primary-soft: rgba(3, 86, 192, 0.1);
    --on-primary: #ffffff;
    --walk: #8a5a00;
    --whatsapp: #0e7a3f;
    --whatsapp-hover: #0b6e38;
    --whatsapp-text: #0e7a3f;
    --walk-soft: rgba(224, 150, 0, 0.14);
    --link: #0d7478; /* verde acqua di "GO", scurito per il contrasto dei testi */
    --error: #b42318;
    --error-soft: rgba(180, 35, 24, 0.14);
    --ok: #146c2e;
    --ok-soft: rgba(26, 127, 55, 0.15);
    --radius: 12px;
    color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #11161d;
        --surface: #1a212b;
        --surface-alt: #222b37;
        --text: #e8edf3;
        --muted: #9aa7b6;
        --border: #2d3846;
        --primary: #5aa7f2;
        --primary-hover: #7cb9f5;
        --primary-soft: rgba(90, 167, 242, 0.15);
        --on-primary: #0b1520;
        --whatsapp-text: #3fcf7b;
        --walk: #f0b44c;
        --walk-soft: rgba(240, 180, 76, 0.15);
        --link: #1dcdc4; /* verde acqua dell'icona */
        --error: #ff8a80;
        --error-soft: rgba(255, 138, 128, 0.18);
        --ok: #3fb950;
        --ok-soft: rgba(63, 185, 80, 0.18);
    }
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 16px/1.5 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

main { max-width: 820px; margin: 0 auto; padding: 1.5rem 16px 3rem; }

/* Barra in alto con il tasto Home */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 0.8rem; }
.brand { display: inline-flex; align-items: center; gap: 0.55rem; text-decoration: none; }
.brand img { display: block; }
.brand span { font-size: 1.6rem; font-weight: 800; letter-spacing: 0.01em; color: var(--primary); }
.brand b { font-weight: 800; color: var(--link); }
.brand:focus-visible, .clear:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* Menu lingua: pallino con la sigla, elenco a tendina allineato a destra */
.lang-menu { position: relative; margin-left: auto; }
.lang-menu summary {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.4rem 0.7rem;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text);
    background: var(--surface-alt);
    border: 1px solid var(--border);
    border-radius: 999px;
    cursor: pointer;
    list-style: none;
}
.lang-menu summary::-webkit-details-marker { display: none; }
.lang-menu summary:hover { border-color: var(--primary); }
.lang-menu[open] summary { border-color: var(--primary); }
.lang-menu ul {
    position: absolute;
    z-index: 5;
    top: calc(100% + 0.3rem);
    right: 0;
    display: grid;
    gap: 0.1rem;
    min-width: 8.5rem;
    margin: 0;
    padding: 0.35rem;
    list-style: none;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
}
.lang-menu a { display: block; padding: 0.4rem 0.6rem; border-radius: 6px; color: var(--text) !important; font-weight: 600 !important; text-decoration: none !important; }
.lang-menu a:hover, .lang-menu a[aria-current] { background: var(--primary-soft); color: var(--primary) !important; }

h1 { margin: 0.5rem 0 0.2rem; font-size: clamp(1.7rem, 4vw, 2.4rem); letter-spacing: -0.02em; }
.lead { margin: 0 0 1rem; color: var(--muted); }

.search {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.8rem;
    padding: 1.2rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.search label { display: grid; gap: 0.3rem; font-size: 0.85rem; font-weight: 600; color: var(--muted); }
.field { display: grid; gap: 0.3rem; align-content: start; }
.field label { font-size: 0.85rem; font-weight: 600; color: var(--muted); }
.field-head { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; min-height: 1.75rem; }
/* Campo obbligatorio vuoto: bordo e messaggio nel colore d'errore */
.field-error { display: flex; align-items: flex-start; gap: 0.35rem; margin: 0.1rem 0 0; font-size: 0.85rem; font-weight: 600; line-height: 1.4; color: var(--error); }
.field-error svg { flex: none; margin-top: 0.1rem; }
.field-error[hidden] { display: none; }
.search input[aria-invalid="true"] { border-color: var(--error); box-shadow: 0 0 0 3px var(--error-soft); }
.search input[aria-invalid="true"]:focus { outline-color: var(--error); }
/* "Vicino a me": azione principale alternativa alla ricerca, ben visibile in cima al modulo */
.near-me { grid-column: 1 / -1; display: grid; gap: 0.5rem; }
.search .locate {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    min-height: 54px;
    padding: 0 0.6rem;
    font-size: 1.02rem;
    font-weight: 700;
    color: var(--on-primary);
    background: var(--primary);
    border: 1px solid var(--primary);
    border-radius: 10px;
}
.search .locate:hover { background: var(--primary-hover); }
.search .locate[hidden] { display: none; }
.search .locate:disabled { opacity: 0.7; cursor: progress; }
.locate-status { margin: 0; padding: 0.6rem 0.8rem; font-size: 0.92rem; color: var(--text); background: var(--surface-alt); border-radius: 8px; }
.locate-status.is-error { color: var(--error); background: var(--error-soft); font-weight: 600; }
.locate-status[hidden] { display: none; }
.or-divider[hidden] { display: none; }
.or-divider { display: flex; align-items: center; gap: 0.7rem; margin: 0.5rem 0 0.1rem; font-size: 0.85rem; color: var(--muted); }
.or-divider::before, .or-divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.search .swap {
    padding: 0.3rem 0.7rem;
    min-height: 36px;
    font-size: 0.85rem;
    color: var(--primary);
    background: var(--primary-soft);
    border-radius: 8px;
}
.search .swap:hover { background: var(--surface-alt); }
/* Opzioni avanzate: chiuse finche' non servono */
.search .more { grid-column: 1 / -1; margin: 0; font-size: 1rem; border-top: 1px solid var(--border); padding-top: 0.6rem; }
.search .more > summary { display: flex; align-items: center; gap: 0.5rem; min-height: 44px; font-size: 0.9rem; font-weight: 400; color: var(--muted); list-style: none; }
.search .more > summary:hover, .search .more > summary:focus-visible { color: var(--text); text-decoration: none; }
.search .more > summary::-webkit-details-marker { display: none; }
.search .more > summary::before { content: "▸"; font-size: 0.75em; opacity: 0.7; transition: none; }
.search .more[open] > summary::before { content: "▾"; }
.more-body { display: grid; gap: 0.9rem; padding: 0.4rem 0 0.2rem; }
.more-body > * { min-width: 0; }
.search .submit { grid-column: 1 / -1; width: 100%; min-height: 52px; font-size: 1.1rem; }
.search .submit:disabled { opacity: 0.75; cursor: progress; }
/* Durante la ricerca: rotella dentro il pulsante, prima del testo "Cerco gli autobus...". */
.search .submit[aria-busy="true"] { display: inline-flex; align-items: center; justify-content: center; gap: 0.6em; }
.search .submit[aria-busy="true"]::before {
    content: ""; flex: none; width: 1.1em; height: 1.1em; box-sizing: border-box;
    border: 2.5px solid currentColor; border-right-color: transparent; border-radius: 50%;
    animation: spin 0.75s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.suggest li small { display: block; margin-top: 0.15rem; font-size: 0.85rem; color: var(--muted); }
.combo { position: relative; }
.search .combo input { width: 100%; padding-right: 2.8rem; }
/* Rotella di attesa dei suggerimenti: dentro il campo, a sinistra della X (che compare solo se c'e' del testo). */
.combo-spin {
    position: absolute;
    top: 50%;
    right: 3rem;
    width: 1.1rem;
    height: 1.1rem;
    margin-top: -0.55rem;
    box-sizing: border-box;
    border: 2.5px solid var(--primary);
    border-right-color: transparent;
    border-radius: 50%;
    pointer-events: none;
    animation: spin 0.75s linear infinite;
}
.combo-spin[hidden] { display: none; }

/* X per cancellare il campo */
.clear {
    position: absolute;
    top: 50%;
    right: 0.35rem;
    display: grid;
    place-items: center;
    width: 2.2rem;
    height: 2.2rem;
    padding: 0;
    color: var(--muted);
    background: transparent;
    border-radius: 999px;
    transform: translateY(-50%);
}
.clear:hover { color: var(--text); background: var(--surface-alt); }
.clear[hidden] { display: none; }

/* Menu dei suggerimenti delle fermate */
.suggest {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    z-index: 20;
    right: 0;
    max-height: min(60vh, 440px);
    margin: 0;
    padding: 6px;
    overflow-y: auto;
    overscroll-behavior: contain;
    list-style: none;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18);
}
.suggest li {
    padding: 0.85rem 1rem;
    font-size: 1.1rem;
    line-height: 1.3;
    border-radius: 8px;
    cursor: pointer;
}
.suggest li + li { margin-top: 2px; }
.suggest li strong { color: var(--primary); }
.suggest li.suggest-vuoto { color: var(--muted); font-size: 0.95rem; cursor: default; }
.suggest li:hover:not(.suggest-vuoto),
.suggest li[aria-selected="true"] { background: var(--primary-soft); }
.search input {
    width: 100%;
    min-width: 0;
    padding: 0.65rem 0.8rem;
    font: inherit;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
}
.search input:focus { outline: 2px solid var(--primary); outline-offset: 1px; }
/* Solo andata / Andata e ritorno */
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.search fieldset { margin: 0; padding: 0; border: 0; min-width: 0; }
.search .mode { padding: 4px; }
.mode {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: 1fr 1fr;
    padding: 4px;
    background: var(--surface-alt);
    border-radius: 10px;
}
.mode label, .chips label { position: relative; cursor: pointer; }
.mode input, .chips input { position: absolute; opacity: 0; pointer-events: none; }
.mode span {
    display: block;
    padding: 0.55rem 0.5rem;
    font-weight: 600;
    text-align: center;
    color: var(--muted);
    border-radius: 7px;
}
.mode input:checked + span { color: var(--text); background: var(--surface); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15); }
.mode input:focus-visible + span, .chips input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: 2px; }

.ar-periods { grid-column: 1 / -1; display: grid; gap: 0.8rem; }
.chips { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.chips legend { width: 100%; margin-bottom: 0.35rem; font-size: 0.85rem; font-weight: 600; color: var(--muted); }
.chips label > span {
    display: inline-block;
    padding: 0.4rem 0.8rem;
    font-size: 0.92rem;
    font-weight: 600;
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 8px;
}
.chips input:checked + span { color: var(--on-primary); background: var(--primary); border-color: var(--primary); }

/* Giorno del viaggio: pulsanti rapidi con lo stesso aspetto dei periodi */
.when { grid-column: 1 / -1; display: grid; gap: 0.8rem; }
.day-chips button {
    padding: 0.4rem 0.8rem;
    font: inherit;
    font-size: 0.92rem;
    font-weight: 600;
    color: var(--text);
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
}
.day-chips button:hover { color: var(--text); background: var(--primary-soft); border-color: var(--primary); }
.day-chips button[aria-pressed="true"]:hover { color: var(--on-primary); background: var(--primary-hover); }
.day-chips button[aria-pressed="true"] { color: var(--on-primary); background: var(--primary); border-color: var(--primary); }
.day-chips button:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.day-chips input[type="date"] { max-width: 16rem; margin-top: 0.5rem; }
.day-chips input[hidden] { display: none; }

/* Campi visibili solo in una delle due modalita' */
.search .ar-only { display: none; }
.search:has(input[name="ar"][value="1"]:checked) .ar-only { display: grid; }

.leg-info { margin: -0.2rem 0 0.7rem; color: var(--muted); }

.search .check {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text);
    cursor: pointer;
}
.search .check input { width: 1.2rem; height: 1.2rem; margin: 0; accent-color: var(--primary); }
.actions { grid-column: 1 / -1; display: flex; gap: 0.6rem; }
button {
    padding: 0.7rem 1.3rem;
    font: inherit;
    font-weight: 600;
    color: var(--on-primary);
    background: var(--primary);
    border: 0;
    border-radius: 8px;
    cursor: pointer;
}
button:hover { background: var(--primary-hover); }
button.secondary { color: var(--text); background: var(--surface-alt); border: 1px solid var(--border); }

.notice {
    margin: 1.5rem 0;
    padding: 1rem 1.2rem;
    color: var(--muted);
    background: var(--surface-alt);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.notice code { padding: 0.1rem 0.35rem; background: var(--surface); border-radius: 6px; }

.summary { margin: 1.6rem 0 0.6rem; color: var(--muted); }
/* Corse divise per momento della giornata */
.periods { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0 0 0.4rem; }
.periods a {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0.7rem;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--primary);
    text-decoration: none;
    background: var(--primary-soft);
    border-radius: 8px;
}
.periods a span {
    min-width: 1.4rem;
    padding: 0 0.35rem;
    font-size: 0.8rem;
    text-align: center;
    color: var(--surface);
    background: var(--primary);
    border-radius: 999px;
}
.period { scroll-margin-top: 1rem; }
.period h2 {
    display: flex;
    align-items: baseline;
    gap: 0.6rem;
    margin: 1.4rem 0 0.6rem;
    font-size: 1.15rem;
}
.period h2 span { font-size: 0.85rem; font-weight: 500; color: var(--muted); }
.results { display: grid; gap: 0.6rem; margin: 0; padding: 0; list-style: none; }
.trip { padding: 0.9rem 1.1rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.trip-main { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 0.2rem 1rem; }
.times { font-size: 1.5rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.arrow { margin: 0 0.3rem; font-weight: 400; color: var(--muted); }
.duration { font-size: 0.9rem; color: var(--muted); }
.duration { font-size: 1rem; font-weight: 600; }
/* Etichette sotto la corsa: gestore, linea, diretto, tratto a piedi */
.trip-tags { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.55rem; }
.tag {
    padding: 0.2rem 0.6rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text);
    background: var(--surface-alt);
    border-radius: 999px;
}
.tag { display: inline-flex; align-items: center; gap: 0.35rem; line-height: 1.3; }
.tag .ico { width: 1.35em; height: 1.35em; margin-top: -0.09em; }
.tag.operator { font-weight: 700; }
.tag.line { font-weight: 700; color: var(--primary); background: var(--primary-soft); }
.tag.direct { color: var(--ok); background: var(--ok-soft); }
.tag.walk-badge { color: var(--walk); background: var(--walk-soft); }
/* Su schermi stretti il tag dei minuti a piedi e' solo "🚶 2 min" (il testo intero resta per chi usa lo screen reader), cosi' non va a capo. */
.tag.walk-badge .walk-breve { display: none; }
@media (max-width: 600px) {
    .tag.walk-badge { white-space: nowrap; }
    .tag.walk-badge .walk-testo { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
    .tag.walk-badge .walk-breve { display: inline-flex; align-items: center; gap: 0.3rem; }
}
/* Nota sopra i risultati: orari programmati, fonte e aggiornamento */
.sched-note { display: flex; align-items: flex-start; gap: 0.4rem; margin: 0 0 0.4rem; font-size: 0.88rem; color: var(--muted); line-height: 1.4; }
.sched-note svg { flex: none; margin-top: 0.15rem; }
.retry { display: flex; flex-wrap: wrap; gap: 0.4rem 1.2rem; margin-top: 0.7rem; }
.retry a { font-weight: 600; min-height: 44px; display: inline-flex; align-items: center; }
.legs { margin: 0.5rem 0 0; padding: 0; list-style: none; font-size: 0.92rem; color: var(--muted); }
/* Icone in linea (SVG, colore del testo): stessa misura e stesso tratto, allineate alla prima riga del testo. */
.ico { flex: none; width: 1em; height: 1em; }
.legs li { position: relative; padding: 0.15rem 0 0.15rem 1.9rem; line-height: 1.4; }
.legs li > .ico { position: absolute; left: 0; top: 0.125rem; width: 1.35em; height: 1.35em; }
.leg-bus { color: var(--text); }
.leg-cambio { color: var(--walk); font-weight: 600; }
.via { margin-top: 0.25rem; font-size: 0.88rem; color: var(--muted); }
.stops { margin-top: 0.3rem; font-size: 0.9rem; color: var(--muted); }
/* Il pulsante WhatsApp sta sulla riga di "Tutte le fermate"; l'elenco usa tutta la larghezza. */
.trip-foot { position: relative; margin-top: 0.5rem; min-height: 2rem; }
.trip-foot details { margin-top: 0; }
.trip-foot summary { padding: 0.35rem 0; margin-right: 7.5rem; }
.share-wa {
    position: absolute;
    top: 0;
    right: 0;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0.75rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: #fff;
    text-decoration: none;
    background: var(--whatsapp);
    border-radius: 8px;
}
.share-wa:hover { background: var(--whatsapp-hover); }
/* Condivisione di tutta la ricerca, accanto al riepilogo */
.summary-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem 1rem; margin: 1.6rem 0 0.6rem; }
.summary-row .summary, .summary-row .periods { margin: 0; }
.share-wa.share-search { position: static; padding: 0.45rem 0.9rem; font-size: 0.9rem; }
.share-wa:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
details { margin-top: 0.4rem; font-size: 0.9rem; }
summary { color: var(--link); font-weight: 600; cursor: pointer; }
summary:hover, summary:focus-visible { text-decoration: underline; text-underline-offset: 3px; }
details ol { margin: 0.5rem 0 0; padding-left: 1.2rem; color: var(--muted); }
details ol span { margin-right: 0.4rem; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--text); }
details ol li.own-stop { font-weight: 700; color: var(--text); }
details ol li.own-stop::marker { color: var(--primary); }
details ol li.own-stop em {
    margin-left: 0.5rem;
    padding: 0.05rem 0.45rem;
    font-size: 0.75rem;
    font-style: normal;
    font-weight: 700;
    color: var(--primary);
    background: var(--primary-soft);
    border-radius: 999px;
}
details ol li.other-stop { opacity: 0.55; }

/* Stato degli orari: quando sono stati pubblicati e controllati */
.data-status {
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
    margin: 1.5rem 0 1rem;
    padding: 0.6rem 0.85rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.data-status .dot { flex: none; width: 10px; height: 10px; margin-top: 0.4rem; border-radius: 50%; }
.data-status .dot.ok { background: var(--ok); box-shadow: 0 0 0 4px var(--ok-soft); }
.data-status .dot.old { background: var(--walk); box-shadow: 0 0 0 4px var(--walk-soft); }
.data-status p { margin: 0; }
.data-main { font-size: 0.95rem; }
.data-main .sep { margin: 0 0.3rem; color: var(--muted); }
.data-note { margin-top: 0.25rem !important; font-size: 0.82rem; color: var(--muted); line-height: 1.5; }
.narrow-only { display: none; }

@media (max-width: 600px) {
    .search { grid-template-columns: 1fr; }
}

/* Piede di pagina */
.site-footer {
    display: grid;
    grid-template-columns: minmax(150px, auto) 1fr;
    gap: 1.5rem;
    margin-top: 2rem;
    padding-top: 1.5rem;
    font-size: 0.85rem;
    color: var(--muted);
    border-top: 1px solid var(--border);
}
.footer-side { display: grid; align-content: start; gap: 0.4rem; }
.footer-brand { display: inline-flex; align-items: center; gap: 0.5rem; text-decoration: none; }
.footer-brand img { border-radius: 7px; }
.footer-brand span { font-size: 1.1rem; font-weight: 800; color: var(--primary); }
.footer-brand b { color: var(--link); }
.footer-links { display: grid; gap: 0; }
.site-footer .copyright { margin: 0; line-height: 1.6; }
/* Icona di Facebook: cerchio con la "f" bianca (blu di Facebook), bersaglio da 28px. Sul desktop sta accanto al copyright senza alzare il piede. */
.site-footer .footer-socials { display: inline-flex; gap: 0.5rem; margin: -6px 0 -6px 0.5rem; vertical-align: middle; }
.site-footer .footer-social { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; color: #fff; background: #1877f2; border-radius: 50%; }
.site-footer .footer-instagram, .site-footer .footer-instagram:hover { background: linear-gradient(45deg, #f09433, #dc2743 55%, #bc1888); }
.site-footer .footer-instagram:hover { filter: brightness(0.9); }
.site-footer .footer-social:hover, .site-footer .footer-social:focus-visible { color: #fff; background: #0e63d1; text-decoration: none; }
.site-footer .footer-social:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
/* Riga verticale tra le due colonne */
/* Sul desktop il piede e' una griglia a tre righe: marchio e voci a sinistra, l'avviso a destra su quelle due righe, "© AutobusGO" sotto.
   L'avviso e l'ultima voce ("Contatti") finiscono sulla stessa linea qualunque sia l'altezza dei due blocchi; la riga verticale
   accompagna l'avviso. I 0,2rem in fondo centrano l'ultima riga rispetto alla voce, alta 28px. */
.site-footer { grid-template-areas: "marchio avviso" "voci avviso" "copyright ."; grid-template-rows: auto 1fr auto; gap: 0 1.5rem; }
.footer-side { display: contents; }
.footer-brand { grid-area: marchio; justify-self: start; margin-bottom: 0.4rem; }
.footer-links { grid-area: voci; align-self: end; }
.site-footer .copyright { grid-area: copyright; margin-top: 0.4rem; }
.footer-note { grid-area: avviso; display: flex; flex-direction: column; justify-content: flex-end; padding-left: 1.5rem; padding-bottom: 0.2rem; border-left: 2px solid var(--border); }
.footer-note p { margin: 0 0 0.6rem; line-height: 1.6; }
.footer-note p:last-child { margin-bottom: 0; }
.footer-note strong { color: var(--text); font-weight: 600; }
@media (max-width: 600px) {
    /* Su telefono: prima gli avvisi, poi il blocco del marchio con le voci e, come ultima riga, "© AutobusGO" a sinistra e l'icona di Facebook a destra. */
    .site-footer { display: flex; flex-direction: column; gap: 0; }
    .footer-side { display: contents; }
    .footer-brand, .footer-links, .site-footer .copyright, .footer-note { grid-area: auto; margin: 0; }
    .footer-note { order: 1; display: block; padding: 0 0 1.2rem; border-left: 0; border-bottom: 1px solid var(--border); }
    .footer-brand { order: 2; margin: 1.2rem 0 0.4rem; align-self: flex-start; }
    .footer-links { order: 3; display: flex; flex-wrap: wrap; gap: 0.4rem 1rem; }
    .site-footer .copyright { order: 4; display: flex; align-items: center; justify-content: space-between; margin-top: 1.2rem; }
    .site-footer .footer-socials { margin: 0 -8px 0 0; } /* le icone finiscono a 8px dal bordo dello schermo (il margine della pagina e' 16px), mai attaccate al bordo */
}

/* Segnalazione errori sotto i risultati */
.report { display: grid; justify-items: start; gap: 0.7rem; margin: 1.6rem 0 1.4rem; font-size: 0.9rem; line-height: 1.45; color: var(--muted); }

/* Contatti */
.contact-actions { display: grid; gap: 0.75rem; margin: 1.2rem 0; }
.contact-card {
    display: grid;
    gap: 0.25rem;
    padding: 0.9rem 1rem;
    color: var(--text) !important;
    text-decoration: none;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.contact-card strong { color: var(--primary); }
.contact-card span { font-size: 0.92rem; color: var(--muted); line-height: 1.5; }
.contact-card:hover { border-color: var(--primary); background: var(--primary-soft); }
.contact-card:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.contact-arst { margin-top: 1.6rem; line-height: 1.6; }

/* Pagine legali */
.legal h1 { margin-top: 0.8rem; }
.legal h2 { margin: 1.8rem 0 0.5rem; font-size: 1.2rem; }
.legal h3 { margin: 1.2rem 0 0.4rem; font-size: 1.02rem; }
.legal p, .legal li { line-height: 1.65; }
.legal ul { padding-left: 1.2rem; }
.legal .updated { margin-top: -0.4rem; font-size: 0.9rem; color: var(--muted); }
.translation-note { margin: -0.3rem 0 1rem; padding: 0.6rem 0.9rem; font-size: 0.88rem; color: var(--muted); background: var(--surface-alt); border-radius: 8px; }
.legal .back { margin-top: 2rem; }
.fonti-tabella { width: 100%; margin-top: 1rem; border-collapse: collapse; font-size: 0.95rem; }
.fonti-tabella th, .fonti-tabella td { padding: 0.55rem 0.7rem; text-align: left; border-bottom: 1px solid var(--surface-alt); }
.fonti-tabella th { color: var(--muted); font-weight: 600; font-size: 0.85rem; }

/* Area dei risultati: la pagina ci scende dopo la ricerca */
.results-area { scroll-margin-top: 12px; }
.results-area:focus { outline: none; }

/* Link di testo: tutti dello stesso verde acqua, sottolineati al passaggio del mouse */
.legal a, .data-note a, .report a, .footer-links a, .notice a, .avvisi-note a {
    color: var(--link);
    font-weight: 600;
    text-decoration: none;
}
.legal a:hover, .data-note a:hover, .report a:hover, .footer-links a:hover, .notice a:hover, .avvisi-note a:hover,
.legal a:focus-visible, .data-note a:focus-visible, .report a:focus-visible, .footer-links a:focus-visible, .notice a:focus-visible, .avvisi-note a:focus-visible {
    text-decoration: underline;
    text-underline-offset: 3px;
}
/* ...tranne logo, schede e pulsanti, che non sono link di testo */
.legal a.brand, .legal a.brand:hover, .legal a.footer-brand, .legal a.footer-brand:hover,
.legal a.contact-card, .legal a.contact-card:hover, .legal .stats-bar a, .legal .stats-bar a:hover {
    font-weight: inherit;
    text-decoration: none;
}
.legal .stats-bar a.on { font-weight: 600; }
.contact-card strong { color: var(--link); }

/* Pulsanti dello stesso gruppo sempre su una riga: sul telefono si dividono lo spazio */
.search > *, .when, .ar-periods, .ar-periods > div { min-width: 0; }
.search .chips:not(.day-chips), .search .chip-row { display: flex; flex-wrap: nowrap; gap: 0.4rem; }
.search .day-chips { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0; } /* la colonna non si allarga oltre il riquadro */
.search .chips label { flex: 1 1 auto; min-width: 0; }
.search .chips label > span { display: block; text-align: center; white-space: nowrap; }
.search .chip-row > button { flex: 1 1 auto; min-width: 0; white-space: nowrap; }
.search .chip-row > .chip-icon { flex: 0 0 auto; display: inline-grid; place-items: center; padding: 0.4rem 0.7rem; }
@media (max-width: 600px) {
    .search .chips label > span, .search .chip-row > button { padding-left: 0.35rem; padding-right: 0.35rem; font-size: 0.88rem; }
    .search .chip-row > .chip-icon { padding-left: 0.55rem; padding-right: 0.55rem; }
    .wide-only { display: none; }
    .narrow-only { display: inline; }
}
@media (max-width: 360px) {
    .search .chips:not(.day-chips), .search .chip-row { gap: 0.25rem; }
    .search .chips label > span, .search .chip-row > button { padding-left: 0.25rem; padding-right: 0.25rem; font-size: 0.82rem; }
    .search .chip-row > .chip-icon { padding-left: 0.45rem; padding-right: 0.45rem; }
}
@media (max-width: 340px) {
    .search .chips label > span, .search .chip-row > button { padding-left: 0.1rem; padding-right: 0.1rem; }
    .search .chip-row { gap: 0.15rem; }
}


/* Bersagli touch di almeno 44px (WCAG 2.2, 2.5.8) */
.day-chips button, .chips label > span { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; }
.search .chips label > span { display: flex; }
.clear { width: 2.75rem; height: 2.75rem; right: 0.1rem; }
.search .check { min-height: 44px; }
.search .check input { width: 1.4rem; height: 1.4rem; }
button:focus-visible, summary:focus-visible, .search input:focus-visible, .check input:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.search .locate { text-align: center; }
@media (max-width: 360px) {
    .search { padding: 0.9rem; }
    .day-chips button { padding-left: 0.2rem; padding-right: 0.2rem; }
    .search .chip-row > .chip-icon { padding-left: 0.4rem; padding-right: 0.4rem; }
}

/* Bersagli touch: menu lingua, logo, etichette dei periodi, pulsanti delle corse, piede di pagina */
.lang-menu summary, .brand, .periods a, .share-wa.share-search { min-height: 44px; }
.footer-brand { min-height: 32px; }
.lang-menu a { display: flex; align-items: center; min-height: 44px; }
.trip-foot { min-height: 44px; }
.trip-foot summary { display: flex; align-items: center; min-height: 44px; padding: 0; }
.share-wa { min-height: 44px; }
/* Piede di pagina compatto: bersagli da 28px (il minimo WCAG 2.2 AA e' 24px), niente interlinea in piu' */
.footer-links a { display: inline-flex; align-items: center; min-height: 28px; }
.search .chip-row > .chip-icon { min-width: 44px; }
.search .swap { min-height: 44px; min-width: 44px; }
.search .field-head { min-height: 44px; }
.site-footer .footer-links { gap: 0 1rem; }
.suggest li { min-height: 44px; }
.fonti-tabella a { display: inline-block; padding: 0.6rem 0; }
.chips legend { padding: 0; }

/* Pagine di zona: regioni, localita' e tratte */
.zona-tabella { width: 100%; margin: 0.5rem 0 1rem; border-collapse: collapse; font-size: 0.95rem; }
.zona-tabella th, .zona-tabella td { padding: 0.5rem 0.5rem; text-align: left; vertical-align: top; border-bottom: 1px solid var(--surface-alt); }
.zona-tabella th { font-size: 0.85rem; font-weight: 600; color: var(--muted); }
.zona-tabella .ora { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.zona-meta { font-size: 0.85rem; color: var(--muted); }
.zona-tabella .zona-meta { display: block; }
.zona-lista { padding-left: 1.2rem; }
.zona-lista li { margin: 0.3rem 0; }
.breadcrumb { margin: 0.6rem 0 0; font-size: 0.85rem; color: var(--muted); }
.breadcrumb ol { display: flex; flex-wrap: wrap; gap: 0.15rem 0.4rem; margin: 0; padding: 0; list-style: none; }
.breadcrumb li + li::before { content: "›"; margin-right: 0.4rem; color: var(--muted); }
.breadcrumb a { color: var(--link); text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }
.breadcrumb + h1 { margin-top: 0.3rem; }
.legal .zona-cerca { margin: 1rem 0 1.2rem; }
.near-me[hidden] { display: none; }
.search a.locate { text-decoration: none; }
.search a.locate:hover { text-decoration: none; }
@media (max-width: 600px) { .legal .zona-cerca { grid-template-columns: 1fr; } }
.zona-chips { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0; padding: 0; list-style: none; }
.zona-chips a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 0.8rem; background: var(--surface-alt); border: 1px solid var(--border); border-radius: 8px; }
.legal .sched-note { margin: -0.2rem 0 1rem; }
.legal .zona-chips, .coverage .zona-chips { padding-left: 0; }
.coverage { margin-top: 2rem; }
.coverage h2 { font-size: 1.15rem; margin: 0 0 0.3rem; }
.coverage p { margin: 0 0 0.6rem; color: var(--muted); }
.coverage ul + h2 { margin-top: 1.5rem; }

/* Usalo come app: finestra sopra la pagina, una volta al giorno (le istruzioni stanno in un'altra finestra) */
.app-promo { position: relative; width: min(92vw, 22rem); text-align: center; }
.app-promo[open] { display: block; }
.app-promo img { width: 64px; height: 64px; border-radius: 15px; }
.app-promo h2 { margin: 0.6rem 0 0.3rem; font-size: 1.2rem; }
/* Il nome come nel logo: "Autobus" nel colore del marchio, "GO" nel colore dei link */
.app-promo h2 .brand-name { font-weight: 800; color: var(--primary); }
.app-promo h2 .brand-name b { font-weight: 800; color: var(--link); }
.app-promo p { margin: 0 0 1rem; font-size: 0.95rem; line-height: 1.5; color: var(--muted); }
.app-promo-passi { display: grid; gap: 0.6rem; margin: 0 0 1rem; padding: 0; list-style: none; text-align: left; }
.app-promo-passi[hidden] { display: none; }
.app-promo-passi li { display: grid; grid-template-columns: 1.6rem 1fr; align-items: center; gap: 0.7rem; font-size: 0.95rem; line-height: 1.4; color: var(--text); }
.app-promo-passi .passo-n { display: grid; place-items: center; width: 1.6rem; height: 1.6rem; font-size: 0.85rem; font-weight: 700; color: #fff; background: var(--primary); border-radius: 50%; }
.app-promo-passi .icona-condividi { display: inline-block; vertical-align: -0.3em; color: var(--primary); }
.app-banner { display: grid; grid-template-columns: 40px 1fr auto auto; align-items: center; gap: 0.7rem; margin: 0 0 1rem; padding: 0.7rem 0.8rem; background: var(--surface-alt); border: 1px solid var(--border); border-radius: 12px; }
.app-banner[hidden] { display: none; }
.app-banner img { width: 40px; height: 40px; border-radius: 10px; }
.app-banner p { min-width: 0; margin: 0; font-size: 0.92rem; font-weight: 600; line-height: 1.35; color: var(--text); }
.app-banner-apri { display: inline-flex; align-items: center; justify-content: center; min-height: 40px; padding: 0 0.9rem; font-weight: 700; color: var(--on-primary); text-decoration: none; background: var(--primary); border-radius: 8px; }
.app-banner-chiudi { width: 36px; height: 40px; padding: 0; font-size: 1.5rem; line-height: 1; color: var(--muted); background: transparent; border: 0; cursor: pointer; }
.app-banner-chiudi:hover, .app-banner-chiudi:focus-visible { color: var(--text); }
@media (max-width: 520px) {
    /* Telefono: icona, testo e chiusura sulla prima riga, il pulsante a tutta larghezza sotto. */
    .app-banner { grid-template-columns: 40px 1fr 36px; }
    .app-banner-chiudi { grid-column: 3; grid-row: 1; }
    .app-banner-apri { grid-column: 1 / -1; grid-row: 2; }
}
.app-promo-actions { display: grid; gap: 0.5rem; }
.app-promo-actions [hidden] { display: none; }
.app-promo-actions button { min-height: 44px; }
.app-promo-actions .secondary { background: transparent; }
.app-promo-close { position: absolute; top: 0.2rem; right: 0.3rem; width: 44px; height: 44px; padding: 0; font-size: 1.6rem; line-height: 1; color: var(--muted); background: transparent; border: 0; cursor: pointer; }
.app-promo-close:hover, .app-promo-close:focus-visible { color: var(--text); }
dialog { width: min(92vw, 26rem); padding: 1.2rem; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
dialog::backdrop { background: rgba(0, 0, 0, 0.5); }
dialog h2 { margin: 0 0 0.6rem; font-size: 1.15rem; }
dialog p { line-height: 1.6; }
dialog p[hidden] { display: none; }
dialog form { margin-top: 1rem; }
dialog button { min-height: 44px; }
/* Avviso "sei offline" */
.coverage a, .footer-note a { color: var(--link); font-weight: 600; text-decoration: none; }
.coverage a:hover, .footer-note a:hover, .coverage a:focus-visible, .footer-note a:focus-visible { text-decoration: underline; text-underline-offset: 3px; }

/* Due modi: cerca una tratta / prossimi autobus */
.modes { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; margin: 0 0 0.8rem; padding: 4px; background: var(--surface-alt); border-radius: 10px; }
.modes a { display: flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 0.5rem; font-weight: 600; color: var(--muted); text-align: center; text-decoration: none; border-radius: 7px; }
.modes a[aria-current="page"] { color: var(--text); background: var(--surface); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15); }
.modes a:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.search .field-wide { grid-column: 1 / -1; }

/* "Vicino a me": fermate con distanza e prossime partenze */
.near-panel { display: grid; gap: 0.7rem; padding: 0; }
.near-panel[hidden] { display: none; }
.near-panel { overflow: hidden; }
.near-panel.near-uscita { opacity: 0; filter: blur(6px); transform: scale(0.96) translateY(-10px); margin-block: 0; pointer-events: none; }
@media (prefers-reduced-motion: no-preference) {
    .near-panel.near-uscita { transition: height 0.55s ease, opacity 0.4s ease, filter 0.5s ease, transform 0.55s ease, margin 0.55s ease; }
    #locate-status:not([hidden]) { animation: near-riga 0.5s ease 0.2s both; }
}
@keyframes near-riga { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.near-panel:focus { outline: none; }
.near-panel h2 { margin: 0.2rem 0 0; font-size: 1.1rem; }
.near-card { padding: 0.8rem 0.9rem; background: var(--surface-alt); border: 1px solid var(--border); border-radius: var(--radius); }
.near-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 0.1rem 0.8rem; }
.near-dist { font-size: 0.95rem; font-weight: 700; color: var(--text); } /* distanza e minuti a piedi in grassetto: il nome della fermata puo' contenere numeri (es. "SS 130 KM 49.900") */
.near-deps, .near-more ul { margin: 0.5rem 0 0; padding: 0; list-style: none; }
.near-deps li { display: grid; grid-template-columns: 3.6rem 1fr; gap: 0 0.5rem; align-items: baseline; padding: 0.3rem 0; border-top: 1px solid var(--border); }
.near-deps li.near-none, .near-deps li.near-day { display: block; }
.near-deps .dep-time { font-variant-numeric: tabular-nums; }
.near-deps .dep-meta { grid-column: 2; font-size: 0.85rem; color: var(--muted); }
.near-more small { font-size: 0.85rem; color: var(--muted); }
.near-none, .near-day { font-size: 0.9rem; color: var(--muted); }
.near-actions { display: flex; flex-wrap: wrap; gap: 0.5rem 1rem; align-items: center; margin-top: 0.4rem; }
.near-actions a, .near-more a { display: inline-flex; align-items: center; min-height: 44px; font-weight: 600; color: var(--link); text-decoration: none; }
.near-actions a:hover, .near-more a:hover { text-decoration: underline; text-underline-offset: 3px; }
.near-actions button { min-height: 44px; }
.near-more h3 { margin: 0; font-size: 0.95rem; }
.near-note { margin: 0; font-size: 0.85rem; color: var(--muted); }

/* Prossimi autobus: elenco delle partenze */
.next-title { margin: 1.4rem 0 0.2rem; font-size: 1.15rem; }
.departures { display: grid; margin: 0.4rem 0 0; padding: 0; list-style: none; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.departures li { display: grid; grid-template-columns: 4.2rem 1fr; gap: 0.6rem; align-items: baseline; padding: 0.7rem 1rem; }
.departures li + li { border-top: 1px solid var(--border); }
.dep-time { font-size: 1.3rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.dep-main { display: grid; gap: 0.1rem; }
.dep-dest { font-weight: 600; }
.dep-meta { font-size: 0.88rem; color: var(--muted); }

/* Segnalazioni con categoria */
.report p { margin: 0; }
.report .report-contact { margin-top: 0.1rem; font-size: 0.88rem; }
.report .report-contact a { font-weight: 600; }
.report .report-status[hidden] { display: none; }
.report-cats { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0; padding: 0; list-style: none; }
.report-cats a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 0.8rem; font-weight: 600; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; text-decoration: none; }
.report-cats a:hover { border-color: var(--primary); background: var(--primary-soft); text-decoration: none; }

/* Segnalazione in pagina: icone, un tocco */
.report-cats[hidden] { display: none; }
.report-cat { display: flex; flex-direction: row; align-items: center; justify-content: flex-start; gap: 0.5rem; width: 100%; min-height: 44px; padding: 0.4rem 0.9rem 0.4rem 0.75rem; font: inherit; font-size: 0.8rem; font-weight: 600; line-height: 1.2; text-align: left; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 10px; cursor: pointer; }
.report-cat svg { flex: none; width: 20px; height: 20px; color: var(--error); }
.report-cat:hover:not(:disabled) { border-color: var(--error); background: color-mix(in srgb, var(--error) 8%, var(--surface)); }
.report-cat:disabled { cursor: default; }
.report-cat:hover:disabled { background: var(--surface); }
.report-cat .check { display: none; }
.report-cat.sent { border-color: color-mix(in srgb, var(--error) 28%, var(--border)); background: color-mix(in srgb, var(--error) 7%, var(--surface)); }
.report-cat.sent:hover:disabled { background: color-mix(in srgb, var(--error) 7%, var(--surface)); }
.report-cat.sent svg > *:not(.check) { display: none; }
.report-cat.sent .check { display: inline; }
.report-status.sr { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.report-cat[aria-busy="true"] { opacity: 0.6; }
#report-cats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.5rem; }
@media (min-width: 720px) { #report-cats { grid-template-columns: repeat(4, 1fr); } }
.report-status { margin: 0.6rem 0 0; padding: 0.6rem 0.8rem; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); }
.report-status.ok { border-color: var(--ok); color: var(--text); }
.report-status.err { border-color: var(--error); color: var(--text); }
.report-contact { margin: 0.6rem 0 0; font-size: 0.85rem; }

/* Rifiniture: pressione dei pulsanti e rispetto di "riduci animazioni" */
button:active:not(:disabled), .modes a:active, .report-cats a:active, .contact-card:active { transform: translateY(1px); }
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* Ricerche recenti (solo su questo dispositivo) */
.recent { margin-top: 1rem; }
.recent[hidden] { display: none; }
.recent-head { display: flex; align-items: baseline; justify-content: space-between; gap: 0.6rem; }
.recent h2 { margin: 0 0 0.4rem; font-size: 1.05rem; }
.link-button { min-height: 44px; padding: 0 0.4rem; font: inherit; font-size: 0.9rem; font-weight: 600; color: var(--link); background: none; border: 0; cursor: pointer; }
.link-button:hover { text-decoration: underline; text-underline-offset: 3px; }
.recent-list { display: grid; gap: 0.5rem; margin: 0; padding: 0; list-style: none; }
.recent-list a { display: grid; gap: 0.1rem; min-height: 52px; padding: 0.6rem 0.9rem; color: var(--text); text-decoration: none; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.recent-list a:hover { border-color: var(--primary); background: var(--primary-soft); }
.recent-list a:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.r-route { font-weight: 700; }
.r-when { font-size: 0.85rem; color: var(--muted); }
.recent-note { margin: 0.4rem 0 0; font-size: 0.78rem; color: var(--muted); }

/* Dettaglio della corsa (elenco fermate e informazioni) */
.trip-count { margin: 0.5rem 0 0.2rem; font-size: 0.88rem; font-weight: 600; color: var(--muted); }
.trip-count[hidden] { display: none; }

/* Mappa del percorso (MapLibre con tessere del sito, vedi public/mappe/) */
.trip-map { margin: 0.6rem 0 0.4rem; }
.trip-map[hidden] { display: none; }
.map-gl { position: relative; width: 100%; height: 16rem; margin: 0 0 0.6rem; background: var(--surface-alt); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
@media (min-width: 700px) { .map-gl { height: 22rem; } }
.map-gl .maplibregl-ctrl-attrib { font-size: 0.7rem; }
.map-legenda { position: absolute; left: 8px; bottom: 8px; z-index: 2; margin: 0; padding: 0.3rem 0.55rem; list-style: none; font-size: 0.72rem; line-height: 1.5; color: var(--text); background: color-mix(in srgb, var(--surface) 90%, transparent); border-radius: 8px; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.18); pointer-events: none; }
.map-legenda li { display: flex; align-items: center; gap: 0.45rem; }
.map-legenda i { flex: none; width: 1.5rem; height: 0; border-top: 4px solid var(--primary); border-radius: 2px; }
.map-legenda .leg-resto, .map-legenda .leg-piedi { height: 3px; border: 0; background: repeating-linear-gradient(90deg, var(--muted) 0 5px, transparent 5px 8px); }
.map-legenda .leg-piedi { background: repeating-linear-gradient(90deg, var(--walk) 0 3px, transparent 3px 6px); }
/* Il pulsante dei crediti e' un <summary>: le regole delle schede (altezza minima, margini) non devono toccarlo. */
.map-gl .maplibregl-ctrl-attrib-button { display: block; box-sizing: border-box; width: 29px; height: 29px; min-height: 0; margin: 0; padding: 0; background-repeat: no-repeat; }
.map-viste { position: absolute; top: 8px; left: 8px; z-index: 2; display: flex; flex-wrap: wrap; gap: 0.3rem; max-width: calc(100% - 56px); margin: 0; }
.map-chip { min-height: 1.75rem; padding: 0 0.6rem; font: inherit; font-size: 0.75rem; font-weight: 600; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 999px; cursor: pointer; }
.map-chip[aria-pressed="true"] { color: var(--on-primary); background: var(--primary); border-color: var(--primary); }
.map-chip:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.map-links { margin: 0.5rem 0 0; font-size: 0.85rem; line-height: 1.5; color: var(--text); }
.map-links strong { color: var(--text); }
.map-links a { color: var(--link); font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }
.map-links a.map-gm { white-space: nowrap; }
.map-popup .maplibregl-popup-content { padding: 0.4rem 0.65rem; font-size: 0.85rem; font-weight: 600; line-height: 1.35; color: #17202b; border-radius: 8px; }
.map-note { margin: 0.4rem 0 0; font-size: 0.78rem; line-height: 1.4; color: var(--muted); }
.trip-meta { margin: 0.7rem 0 0.2rem; font-size: 0.82rem; line-height: 1.5; color: var(--muted); }
.trip-meta a { color: var(--link); font-weight: 600; }

/* Pagina 404 */
.err404 { margin: 0.4rem 0 1.6rem; text-align: center; }
.err404-bus { width: min(100%, 26rem); height: auto; margin: 0.4rem auto 0; overflow: visible; }
.err404-asfalto { stroke: var(--border); stroke-width: 4; stroke-linecap: round; }
.err404-strisce { stroke: var(--border); stroke-width: 3; stroke-dasharray: 18 14; }
.err404-corpo { fill: var(--primary); }
.err404-fascia { fill: var(--on-primary); opacity: 0.28; }
.err404-vetro { fill: var(--surface); }
.err404-tabella { fill: var(--surface); stroke: var(--on-primary); stroke-width: 2; }
.err404-numero { font: 800 26px system-ui, sans-serif; fill: var(--error); }
.err404-faro { fill: var(--walk); }
.err404-ruota { fill: var(--text); }
.err404-mozzo { fill: var(--surface-alt); }
.err404-scritta { font: 800 15px system-ui, sans-serif; letter-spacing: 0.14em; fill: var(--error); }
.err404-lead { max-width: 32rem; margin: 1rem auto 1.2rem; font-size: 1.1rem; line-height: 1.6; color: var(--muted); }
.err404-bottone {
    display: inline-block;
    padding: 0.8rem 1.4rem;
    color: var(--on-primary) !important;
    font-weight: 700;
    text-decoration: none !important;
    background: var(--primary);
    border-radius: var(--radius);
}
.err404-bottone:hover { background: var(--primary-hover); }
.err404-bottone:focus-visible { outline: 2px solid var(--primary); outline-offset: 3px; }
.err404-altro { margin: 1.4rem 0 0.4rem; color: var(--muted); }
.err404-nota { margin: 0.2rem 0 0; font-size: 0.9rem; }
@media (prefers-reduced-motion: no-preference) {
    .err404-corsa { animation: err404-rimbalzo 0.9s ease-in-out infinite alternate; transform-origin: 160px 150px; }
    .err404-strisce { animation: err404-strada 1.1s linear infinite; }
}
@keyframes err404-rimbalzo { from { transform: translateY(0); } to { transform: translateY(-3px); } }
@keyframes err404-strada { to { stroke-dashoffset: -32; } }
.legal:has(.err404) h1 { text-align: center; }

/* Segnalazione dentro la scheda della corsa: testo piccolo, come i dettagli */
.trip-report { margin-top: 0; font-size: 0.8rem; }
.trip-report > summary { display: flex; align-items: center; min-height: 36px; font-weight: 500; color: var(--muted); }
.trip-report .report-cats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.35rem; padding-bottom: 0.2rem; }
.trip-report .report-cat { min-height: 40px; padding: 0.3rem 0.4rem; font-size: 0.75rem; }
.trip-report .report-cat svg { width: 18px; height: 18px; }
.trip-report .report-cats a { min-height: 40px; padding: 0 0.5rem; font-size: 0.75rem; }

/* --- Revisione grafica: intestazione, scheda corsa compatta, selettore date --- */

/* Intestazione piu' incisiva e meno alta: titolo con interlinea stretta, sottotitolo piu' piccolo */
h1 { margin: 0.3rem 0 0.3rem; font-size: clamp(1.75rem, 5.2vw, 2.2rem); font-weight: 800; line-height: 1.12; letter-spacing: -0.025em; }
.lead { max-width: 48rem; margin: 0 0 0.9rem; font-size: 0.97rem; line-height: 1.4; }
/* Schede "Cerca una tratta / Prossimi autobus": comandi a schede, non una barra a tutta larghezza */
.modes { max-width: 30rem; margin-bottom: 0.7rem; }
.modes a[aria-current="page"] { color: var(--primary); font-weight: 700; }

/* Scheda corsa: orario in evidenza, un solo gesto principale (Fermate e dettagli), WhatsApp come icona */
.results { gap: 0.5rem; }
.trip { padding: 0.65rem 0.9rem 0.65rem; }
.times { font-size: 1.6rem; line-height: 1.2; letter-spacing: -0.01em; }
.duration { font-size: 0.95rem; }
.stops { margin-top: 0.15rem; font-size: 0.9rem; line-height: 1.35; }
.via { margin-top: 0.1rem; font-size: 0.85rem; }
.trip-tags { gap: 0.3rem; margin-top: 0.45rem; }
.tag { padding: 0.1rem 0.5rem; font-size: 0.78rem; }
.trip-foot { margin-top: 0.4rem; min-height: 44px; }
.trip-foot > details > summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    min-height: 44px;
    margin-right: 3.4rem;
    padding: 0 0.9rem;
    font-weight: 700;
    color: var(--primary);
    background: var(--primary-soft);
    border-radius: 10px;
    list-style: none;
}
.trip-foot > details > summary::-webkit-details-marker { display: none; }
.trip-foot > details > summary::after { content: "›"; font-size: 1.4rem; line-height: 1; transition: transform 0.15s; }
.trip-foot > details[open] > summary::after { transform: rotate(90deg); }
.trip-foot > details > summary:hover { text-decoration: none; background: var(--primary-soft); box-shadow: inset 0 0 0 1px var(--primary); }
.trip-foot > details > summary:focus-visible { text-decoration: none; }
.trip-foot .share-wa:not(.share-search) {
    width: 44px;
    height: 44px;
    padding: 0;
    justify-content: center;
    color: var(--whatsapp-text);
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 10px;
}
.trip-foot .share-wa:not(.share-search):hover { color: #fff; background: var(--whatsapp); border-color: var(--whatsapp); }
.trip-foot .share-wa svg { width: 22px; height: 22px; }
/* Segnalazione: azione discreta, dentro il pannello dei dettagli */
.trip-report { margin-top: 0.6rem; padding-top: 0.2rem; border-top: 1px solid var(--border); }
.trip-report > summary { font-weight: 500; font-size: 0.82rem; color: var(--muted); min-height: 44px; }

/* Selettore date su telefono: i pulsanti devono stare dentro il riquadro */
@media (max-width: 430px) {
    .search { padding: 1rem; }
    .search .chip-row { gap: 0.3rem; }
    .search .chip-row > button { padding-left: 0.3rem; padding-right: 0.3rem; font-size: 0.86rem; }
    .search .chip-row > .chip-icon { padding-left: 0.4rem; padding-right: 0.4rem; min-width: 44px; }
}

/* Corsa arrivata da un link condiviso: bordo nel colore del marchio */
.trip-shared { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }

/* --- Pagine tratta/localita' e Fonti: sottotitoli piu' marcati, tabelle su una riga, destinazioni come chip --- */
.legal h2 { padding-left: 0.65rem; border-left: 4px solid var(--link); line-height: 1.25; }
.legal h3 { display: inline-block; padding: 0.15rem 0.6rem; font-size: 0.95rem; color: var(--primary); background: var(--primary-soft); border-radius: 999px; }
.legal .sched-note { display: block; width: fit-content; max-width: 100%; margin: 0.1rem 0 1rem; padding: 0.35rem 0.7rem; font-size: 0.9rem; background: var(--surface-alt); border-radius: 8px; }
.legal p.lead { font-size: 1.05rem; color: var(--text); }

/* Tabelle degli orari: una corsa per riga anche su telefono (orario, arrivo e durata senza andare a capo) */
.zona-tabella th, .zona-tabella td { padding: 0.5rem 0.4rem; white-space: nowrap; }
.zona-partenze td:nth-child(2) { white-space: normal; font-weight: 600; }
.zona-tabella tbody tr:nth-child(even) { background: var(--surface-alt); }
.zona-tabella .zona-linea { display: none; }
@media (max-width: 480px) {
    /* Partenze di una localita': su telefono la linea passa sotto la destinazione e la colonna sparisce */
    .zona-partenze th:nth-child(3), .zona-partenze td:nth-child(3) { display: none; }
    .zona-partenze .zona-linea { display: inline; }
    .zona-partenze .zona-linea::before { content: " · "; }
    .zona-partenze td:nth-child(2) .zona-meta:not(.zona-linea) { display: inline; }
    .zona-partenze td:nth-child(2) .zona-meta:not(.zona-linea)::before { content: ""; display: block; }
}
@media (max-width: 480px) { .zona-tabella { font-size: 0.9rem; } .zona-tabella th, .zona-tabella td { padding-left: 0.3rem; padding-right: 0.3rem; } }

/* Destinazioni e tratte collegate: chip con il numero di corse */
.zona-chips a { gap: 0.5rem; font-weight: 600; text-decoration: none; }
.zona-chips a:hover { border-color: var(--primary); background: var(--primary-soft); }
.zona-chips .zona-meta { display: inline; font-weight: 500; }

/* Fonti: tabella compatta e note in riquadri */
.fonti-tabella td { white-space: nowrap; }
.fonti-tabella td:first-child { white-space: normal; font-weight: 600; }
.legal p.note { padding: 0.7rem 0.9rem; font-size: 0.92rem; line-height: 1.55; background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--link); border-radius: 8px; }
.zona-partenze .zona-meta { font-weight: 500; }

/* Telefoni molto piccoli (320px): niente scorrimento orizzontale nelle righe dei pulsanti della data e nelle tabelle */
@media (max-width: 340px) {
    .search { padding: 0.7rem; }
    .search .chip-row > .chip-icon { min-width: 36px; padding-left: 0.25rem; padding-right: 0.25rem; }
    .search .chip-row > button { padding-left: 0.1rem; padding-right: 0.1rem; }
}
@media (max-width: 360px) {
    .zona-tabella { font-size: 0.85rem; }
    .zona-tabella th, .zona-tabella td { padding-left: 0.2rem; padding-right: 0.2rem; }
    .zona-tabella th:last-child, .zona-tabella td:last-child { white-space: normal; }
    .fonti-tabella { font-size: 0.88rem; }
    .fonti-tabella th, .fonti-tabella td { padding-left: 0.3rem; padding-right: 0.3rem; }
    .fonti-tabella td { white-space: normal; }
    .fonti-tabella td:last-child { white-space: nowrap; }
}

/* Solo a 320px: carattere piu' piccolo nei pulsanti della data (va in fondo al file perche' piu' su la regola dei 430px lo riporta a 0.86rem) */
@media (max-width: 320px) {
    .search .chips label > span, .search .chip-row > button { font-size: 0.78rem; }
}

/* --- Scheda corsa come mini tracciato: orario di partenza, linea con la durata, orario di arrivo --- */
.trip-main { display: grid; grid-template-columns: auto minmax(3.5rem, 1fr) auto; align-items: center; gap: 0 0.7rem; max-width: 30rem; }
.trip-main .t { font-size: 1.6rem; font-weight: 700; line-height: 1.2; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.trip-main .leg { display: grid; justify-items: center; gap: 0.15rem; min-width: 0; }
.trip-main .duration { font-size: 0.8rem; font-weight: 600; line-height: 1.1; color: var(--muted); white-space: nowrap; }
.trip-main .rail { position: relative; display: block; width: 100%; height: 2px; background: var(--primary); border-radius: 2px; }
.trip-main .rail::before, .trip-main .rail::after { content: ""; position: absolute; top: 50%; width: 9px; height: 9px; margin-top: -4.5px; border: 2px solid var(--primary); border-radius: 50%; background: var(--surface); }
.trip-main .rail::before { left: -1px; }
.trip-main .rail::after { right: -1px; background: var(--primary); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Etichette: la linea e' una targa (come il numero sulla fiancata); gestore e "Diretto" restano discreti */
.tag.line { padding: 0.12rem 0.55rem; font-weight: 800; letter-spacing: 0.01em; color: var(--on-primary); background: var(--primary); border-radius: 6px; }
.tag.operator { padding-left: 0; padding-right: 0.2rem; font-weight: 600; color: var(--muted); background: transparent; }
.tag.direct { padding-left: 0.1rem; padding-right: 0.1rem; background: transparent; }

/* Tracciato: la linea sta al centro verticale degli orari, la durata subito sopra */
.trip-main .leg { position: relative; display: flex; align-items: center; align-self: stretch; }
.trip-main .rail { flex: 1 1 auto; }
.trip-main .duration { position: absolute; left: 0; right: 0; bottom: calc(50% + 5px); text-align: center; line-height: 1; }

/* Tratta della corsa su una riga sola: se non ci sta, si accorcia con i puntini (il testo intero e' nel suggerimento e nei dettagli) */
.trip .stops { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: clamp(0.78rem, 3.3vw, 0.9rem); }
.results > li, .trip { min-width: 0; }
@media (max-width: 480px) { .trip .stops .dir { display: none; } }

.voti-corsa { display: flex; align-items: center; gap: 0.3rem; margin-top: 0.6rem; padding-top: 0.4rem; border-top: 1px solid var(--border); }
.voti-corsa[hidden] { display: none; }
.voti-testo { margin-right: auto; font-size: 0.85rem; color: var(--muted); }
.voto { display: inline-flex; align-items: center; justify-content: center; width: 38px; min-height: 44px; padding: 0; font: inherit; color: var(--muted); background: transparent; border: 1px solid transparent; border-radius: 8px; cursor: pointer; }
.voto svg { width: 18px; height: 18px; color: currentColor; }
.voto-su:hover:not(:disabled), .voto-su.sent { color: var(--ok); background: var(--ok-soft); }
.voto-su.sent { cursor: default; }
.voto-su.sent svg { fill: currentColor; fill-opacity: 0.25; }
.voto-giu:hover, .voto-giu[aria-expanded="true"] { color: var(--error); background: color-mix(in srgb, var(--error) 8%, transparent); }
.trip-report[hidden] { display: none; }
.trip-report { margin: 0.5rem 0 0; padding: 0.5rem 0.6rem; border: 1px solid color-mix(in srgb, var(--error) 30%, var(--border)); border-radius: 10px; background: color-mix(in srgb, var(--error) 5%, var(--surface)); }
.trip-report p { margin: 0 0 0.4rem; font-size: 0.82rem; color: var(--muted); }
/* Fermate di una corsa: una linea verticale con un punto per fermata, senza numeri. Linea e punti sono disegnati dalla stessa voce, cosi' restano allineati. */
details[data-trip] > ol { margin: 0.6rem 0 0; padding: 0; list-style: none; }
details[data-trip] > ol > li { position: relative; padding: 0.2rem 0 0.2rem 1.5rem; line-height: 1.4; }
details[data-trip] > ol > li::before { content: ""; position: absolute; left: 5px; top: 0; bottom: 0; width: 2px; background: var(--border); }
details[data-trip] > ol > li:first-child::before { top: 13px; }
details[data-trip] > ol > li:last-child::before { bottom: auto; height: 13px; }
details[data-trip] > ol > li:only-child::before { display: none; }
details[data-trip] > ol > li::after { content: ""; position: absolute; left: 0; top: 7px; width: 12px; height: 12px; box-sizing: border-box; border-radius: 50%; background: var(--surface); border: 2px solid var(--border); }
details[data-trip] > ol > li.own-stop::after { background: var(--primary); border-color: var(--primary); }
.search .locate .icona-pos { flex: none; width: 22px; height: 22px; }
.chip-data { margin-left: 0.3rem; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.chip-data:empty { display: none; }
.search .chip-row > .chip-icon.con-data { display: inline-flex; align-items: center; justify-content: center; }
@media (max-width: 380px) {
    .chip-icon.con-data svg { display: none; }
    .chip-icon.con-data .chip-data { margin-left: 0; }
}
.scelta-ambigua { margin: 0.8rem 0; padding: 0.8rem 1rem; color: var(--error); background: var(--error-soft); border: 1px solid var(--error); border-radius: 10px; }
.scelta-ambigua .scelta-titolo { font-size: 1rem; }
.scelta-ambigua .zona-meta { color: var(--error); }
.scelta-ambigua a { color: var(--error); text-decoration: underline; }
.scelta-ambigua p { margin: 0 0 0.5rem; }
.scelta-opzioni { margin: 0; padding: 0; list-style: none; display: grid; gap: 0.3rem; }
.scelta-opzioni a { font-weight: 600; min-height: 44px; display: inline-flex; align-items: center; }

/* Sotto i risultati: un solo riquadro a 12 colonne. A sinistra (7) le informazioni sui dati, a destra (5) la segnalazione "manca una corsa",
   divise da una linea verticale che non tocca i bordi del riquadro. Su telefono una sotto l'altra, divise da una linea orizzontale. */
.dati-riga { margin: 1.5rem 0 1rem; }
.dati-riga .data-status { margin: 0; }
.dati-riga.con-segnala { display: grid; align-items: stretch; grid-template-columns: minmax(0, 1fr); padding: 1rem 1.1rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.dati-riga.con-segnala .data-status { padding: 0; background: none; border: 0; border-radius: 0; order: 2; margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.dati-riga.con-segnala .report { order: 1; margin: 0; }
@media (min-width: 760px) {
    .dati-riga.con-segnala { grid-template-columns: repeat(12, minmax(0, 1fr)); }
    .dati-riga.con-segnala .data-status { grid-column: 1 / span 7; grid-row: 1; order: 0; align-self: stretch; margin: 0; padding: 0 1.4rem 0 0; border-top: 0; }
    .dati-riga.con-segnala .report { grid-column: 8 / span 5; grid-row: 1; align-self: stretch; position: relative; padding-left: 1.4rem; }
    .dati-riga.con-segnala .report::before { content: ""; position: absolute; left: 0; top: 0.2rem; bottom: 0.2rem; width: 1px; background: var(--border); }
}
/* Nel riquadro dei dati la segnalazione e' discreta: il pulsante diventa un piccolo link con l'icona */
.dati-riga .report { gap: 0.35rem; }
.dati-riga .report-cat { width: auto; min-height: 32px; padding: 0.2rem 0; font-size: 0.85rem; background: none; border: 0; border-radius: 0; color: var(--link); }
.dati-riga .report-cat svg { width: 16px; height: 16px; }
.dati-riga .report-cat:hover:not(:disabled) { background: none; text-decoration: underline; }
.dati-riga .report-cat.sent, .dati-riga .report-cat.sent:hover:disabled { background: none; border: 0; color: var(--text); }
.dati-riga .report .report-contact { margin: 0; font-size: 0.82rem; }
.dati-riga .report .report-contact a { font-weight: 400; }
.dati-riga .report-cat { white-space: nowrap; }
.dati-riga .report-cat span { white-space: nowrap; }

/* In alto: i loghi dei social accanto alla scelta della lingua */
.top-tools { display: flex; align-items: center; gap: 0.6rem; margin-left: auto; }
.top-tools .lang-menu { margin: 0; }
.top-socials { display: inline-flex; gap: 0.4rem; }
.top-socials .footer-social { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; color: #fff; background: #1877f2; border-radius: 50%; }
.top-socials .footer-instagram, .top-socials .footer-instagram:hover { background: linear-gradient(45deg, #f09433, #dc2743 55%, #bc1888); }
.top-socials .footer-instagram:hover { filter: brightness(0.9); }
.top-socials .footer-social:hover, .top-socials .footer-social:focus-visible { color: #fff; text-decoration: none; }
.top-socials .footer-social:not(.footer-instagram):hover { background: #0e63d1; }
.top-socials .footer-social:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.top-socials .footer-social svg { width: 20px; height: 20px; }
/* Loghi e pulsante della lingua: stessa altezza (40px) e centrati sulla stessa linea */
.top-tools .lang-menu summary { display: flex; box-sizing: border-box; min-height: 40px; height: 40px; padding-top: 0; padding-bottom: 0; }

/* Viaggi con un cambio */
.cambi-nota { margin: 0 0 0.8rem; font-size: 0.85rem; line-height: 1.45; color: var(--muted); }
.cambio-tag { color: var(--walk); background: var(--walk-soft); }
