/* TOKENS:START — condivisi con le pagine generate (scripts/build-docs.mjs) */
@font-face { font-family: 'Schibsted Grotesk'; font-style: normal; font-weight: 400 900; font-display: swap; src: url(../fonts/schibsted-grotesk-latin-wght-normal.woff2) format('woff2'); unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; }
/* Tema scuro (asfalto): predefinito */
:root {
  color-scheme: dark;
  --ground: #0F1419;
  --surface: #171D24;
  --raise: #202831;
  --sunk: #0B0F13;
  --text: #E6EAEE;
  --muted: #9AA5B0;
  --line: #313B45;
  --accent: #F2B134;
  --on-accent: #1A1305;
  --blue: #5AA9E6;
  --teal: #4CC2A6;
  --warn: #F26457;
  --unknown: #6B7682;
  --v1: #5AA9E6; --v2: #467FAC; --v3: #355C7B; --v4: #4CC2A6; --v5: #3C917F; --v6: #2F675D; --v7: #8C98A4;
  --float: 0 16px 40px rgba(0, 0, 0, 0.5);
  /* carta del biglietto e segnaletica: uguali nei due temi */
  --paper: #F3F4F3;
  --paper-ink: #14181C;
  --paper-muted: #56606A;
  --paper-dot: #C2C7C0;
  --paper-edge: #D3D6CF;
  --sign-green: #00834A;
  --sign-blue: #1F4FA0;
  --font: 'Schibsted Grotesk', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --r: 6px;
  --s1: 4px; --s2: 8px; --s3: 16px; --s4: 24px; --s5: 32px; --s6: 48px;
  --t-sm: 13px; --t-base: 15px; --t-md: 18px; --t-lg: 26px;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}
:root[data-theme='light'] {
  color-scheme: light;
  --ground: #E4E8EB; --surface: #FFFFFF; --raise: #EEF1F3; --sunk: #F7F8F9; --text: #12171C; --muted: #545F6A;
  --line: #C3CBD2; --blue: #1F6FB2; --teal: #0E7A63; --warn: #C42B1C; --unknown: #8A949E;
  --v1: #1F6FB2; --v2: #5C93C8; --v3: #9DBFE0; --v4: #0E7A63; --v5: #4FA893; --v6: #9FD3C6; --v7: #7C8792;
  --float: 0 16px 40px rgba(18, 23, 28, 0.18); --paper: #FFFFFE;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme]) {
    color-scheme: light;
    --ground: #E4E8EB; --surface: #FFFFFF; --raise: #EEF1F3; --sunk: #F7F8F9; --text: #12171C; --muted: #545F6A;
    --line: #C3CBD2; --blue: #1F6FB2; --teal: #0E7A63; --warn: #C42B1C; --unknown: #8A949E;
    --v1: #1F6FB2; --v2: #5C93C8; --v3: #9DBFE0; --v4: #0E7A63; --v5: #4FA893; --v6: #9FD3C6; --v7: #7C8792;
    --float: 0 16px 40px rgba(18, 23, 28, 0.18); --paper: #FFFFFE;
  }
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0; background: var(--ground); color: var(--text);
  font: 400 var(--t-base)/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
}
/* cifre tabellari solo dove ci sono numeri da allineare: nel carattere allargano anche la punteggiatura */
.tnum { font-variant-numeric: tabular-nums; }
::selection { background: color-mix(in srgb, var(--accent) 40%, transparent); color: var(--text); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
a { color: var(--blue); text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { color: var(--text); }
pre, code { font-family: var(--font); }
* { scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 8px; border-radius: 999px;
  font: 600 var(--t-sm)/1.3 var(--font); white-space: nowrap;
  background: color-mix(in srgb, currentColor 14%, transparent);
}
.chip[data-s='utente'] { color: var(--blue); }
.chip[data-s='rilevato'] { color: var(--teal); }
.chip[data-s='modello'] { color: var(--text); }
.chip[data-s='ipotesi'] { color: var(--accent); }
.chip[data-s='non_disponibile'], .chip[data-s='non_stimato'] { color: var(--muted); background: transparent; box-shadow: inset 0 0 0 1.5px var(--unknown); }
.chip[data-s='illustrativo'] { color: var(--warn); }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
}
/* TOKENS:END */

html { scroll-behavior: smooth; }
html, body { height: 100%; }
body { overflow: hidden; }
.sr { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip { position: absolute; left: -9999px; top: 8px; z-index: 100; background: var(--accent); color: var(--on-accent); padding: 8px 12px; border-radius: var(--r); font-weight: 600; }
.skip:focus { left: 8px; }
.ic { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.nw { white-space: nowrap; }

/* ---------- Struttura ---------- */
.app {
  display: grid; height: 100dvh;
  grid-template-columns: minmax(0, 3fr) minmax(420px, 2fr);
  grid-template-rows: minmax(0, 1fr) auto;
}
.tripbar { display: none; }
.stage { position: relative; grid-column: 1; grid-row: 1; min-height: 0; background: var(--ground); overflow: hidden; }
.panel { grid-column: 2; grid-row: 1; display: flex; flex-direction: column; min-height: 0; background: var(--surface); }
.panel:focus { outline: none; }
.statusbar {
  grid-column: 1 / -1; grid-row: 2; display: flex; align-items: center; justify-content: space-between; gap: var(--s3);
  min-height: 36px; padding: 6px var(--s3); background: var(--ground); color: var(--muted); font-size: var(--t-sm);
}
.statusbar p { margin: 0; display: flex; gap: var(--s2); flex-wrap: wrap; }
.statusbar p span + span::before { content: '·'; margin-right: var(--s2); }
.statusbar nav { display: flex; flex-wrap: wrap; gap: 4px var(--s3); }
.statusbar a { color: var(--muted); }
.statusbar a:hover { color: var(--text); }

/* ---------- Mappa e fotografia ---------- */
.map-bar { display: none; }
.map-wrap { position: absolute; inset: 0; }
#map { position: absolute; inset: 0; background: transparent; }
#map.on { background: var(--ground); }
.stage-photo { position: absolute; inset: 0; margin: 0; overflow: hidden; }
.stage-photo img { width: 100%; height: 100%; object-fit: cover; display: block; opacity: 0; transform: scale(1.06); transition: opacity 800ms var(--ease); }
.stage-photo img.on { opacity: 1; }
@media (prefers-reduced-motion: no-preference) {
  /* la fotografia scorre lentamente, come la galleria vista dall'auto */
  .stage-photo img.on { animation: drift 40s linear infinite alternate; }
}
@keyframes drift { from { transform: scale(1.06) translate3d(0, 0, 0); } to { transform: scale(1.14) translate3d(-1.5%, 1%, 0); } }
/* velo neutro sotto i testi: unica eccezione alle sfumature */
.stage-photo::after { content: ''; position: absolute; inset: 0; background: rgba(8, 11, 14, 0.64); }
:root[data-theme='light'] .stage-photo::after { background: rgba(228, 232, 235, 0.6); }
.stage-photo figcaption { position: absolute; right: var(--s3); top: var(--s3); z-index: 1; max-width: 55%; color: var(--text); font-size: var(--t-sm); text-align: right; opacity: 0.85; }
.stage-photo figcaption a { color: inherit; }
.map-wrap.loaded .stage-photo, .map-wrap.loaded .map-off { display: none; }
.map-off { position: absolute; left: 440px; right: var(--s5); bottom: var(--s6); z-index: 1; max-width: 460px; }
.map-off-h { margin: 0 0 var(--s2); font-size: var(--t-lg); font-weight: 800; line-height: 1.05; letter-spacing: -0.03em; }
.map-off p { margin: 0 0 var(--s3); color: var(--text); }
.map-off-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s3); }
.maplibregl-ctrl-attrib { font: 400 12px/1.4 var(--font) !important; background: color-mix(in srgb, var(--ground) 85%, transparent) !important; color: var(--muted); }
.maplibregl-ctrl-attrib a { color: var(--muted) !important; }
.maplibregl-ctrl-group { background: var(--surface) !important; box-shadow: none !important; }
.maplibregl-ctrl-group button + button { border-top-color: var(--raise) !important; }
:root:not([data-theme='light']) .maplibregl-ctrl-group button .maplibregl-ctrl-icon { filter: invert(0.85); }

/* ---------- Scheda del viaggio (desktop: foglio sulla mappa; telefono: pannello dal basso) ---------- */
.sheet {
  position: absolute; z-index: 3; inset: var(--s3) auto auto var(--s3); width: 400px; max-height: calc(100% - 32px);
  margin: 0; padding: 0; border: 0; border-radius: 14px; overflow: auto; overscroll-behavior: contain;
  background: var(--surface); color: var(--text); box-shadow: var(--float);
}
.sheet-head, .sheet-grip { display: none; }
.search { display: grid; gap: var(--s3); padding: 20px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s2) var(--s3); }
.row2.center { align-items: end; }
.with-btn { position: relative; display: flex; gap: var(--s2); }
.with-btn input { flex: 1; min-width: 0; }
.hint { margin: 4px 0 0; color: var(--muted); font-size: var(--t-base); line-height: 1.45; }
.search > .hint { margin-top: calc(var(--s2) * -1); }
#km-note .chip { margin-right: 6px; }
.geo-msg, .form-msg { margin: 0; font-size: var(--t-sm); }
.geo-msg:empty, .form-msg:empty { display: none; }
.form-msg { color: var(--warn); }

/* ---------- Campi ---------- */
.field { display: grid; gap: 6px; min-width: 0; }
.field-h { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); min-height: 20px; }
.field-h .info { width: 28px; height: 28px; margin: -6px -6px -6px 0; }
.field > label, .field-h > label, .label { color: var(--muted); font-size: var(--t-sm); font-weight: 500; line-height: 1.3; display: flex; align-items: center; gap: var(--s2); }
input[type='text'], input[type='number'], select {
  width: 100%; height: 44px; padding: 0 12px; border: 1px solid var(--line); border-radius: var(--r);
  background: var(--sunk); color: var(--text); font: 400 var(--t-base)/1 var(--font);
  transition: border-color 150ms var(--ease);
}
input::placeholder { color: var(--muted); opacity: 0.85; }
input:hover, select:hover { border-color: var(--muted); }
input:focus, select:focus { border-color: var(--accent); outline: 1px solid var(--accent); outline-offset: 0; }
input[aria-invalid='true'] { border-color: var(--warn); }
select { appearance: none; padding-right: 32px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239AA5B0' stroke-width='1.8' stroke-linecap='round'%3E%3Cpath d='M7 10l5 5 5-5'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; background-size: 16px; }
.unit { position: relative; display: flex; }
.unit input { padding-right: 52px; }
.unit span { position: absolute; right: 12px; top: 0; height: 44px; display: flex; align-items: center; color: var(--muted); font-size: var(--t-sm); pointer-events: none; }
.warn { margin: 0; color: var(--warn); font-size: var(--t-sm); }
.warn:empty { display: none; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 16px;
  border: 0; border-radius: var(--r); background: var(--raise); color: var(--text);
  font: 600 var(--t-base)/1 var(--font); cursor: pointer; white-space: nowrap; text-decoration: none;
  transition: background-color 150ms var(--ease), color 150ms var(--ease), transform 120ms var(--ease);
}
.btn:hover { background: color-mix(in srgb, var(--raise) 85%, var(--text)); color: var(--text); }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
.btn.ghost { background: color-mix(in srgb, var(--raise) 60%, transparent); }
.btn.ghost:hover { background: var(--raise); }
.btn.primary { background: var(--accent); color: var(--on-accent); font-weight: 700; }
.btn.primary:hover { background: color-mix(in srgb, var(--accent) 85%, #fff); color: var(--on-accent); }
.btn.sq { width: 44px; padding: 0; }
.btn.small { min-height: 36px; padding: 0 12px; font-size: var(--t-sm); }
.btn.link { min-height: 0; padding: 0; background: none; color: var(--blue); text-decoration: underline; text-underline-offset: 3px; font-weight: 500; }
.btn.link:hover { color: var(--text); background: none; }
.btn[aria-busy='true'] { cursor: progress; opacity: 0.7; }

.seg { display: grid; grid-template-columns: repeat(4, 1fr); margin: 0; padding: 3px; border: 0; border-radius: 10px; background: var(--sunk); }
.seg.n2 { grid-template-columns: repeat(2, 1fr); }
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.seg span { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 44px; padding: 4px 2px; border-radius: 8px; color: var(--muted); font-size: var(--t-sm); font-weight: 600; transition: background-color 180ms var(--ease), color 180ms var(--ease); }
.seg span svg { width: 26px; height: 18px; fill: currentColor; }
.seg input:hover + span { color: var(--text); }
.seg input:checked + span { background: var(--raise); color: var(--text); }
.seg input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 0; }

.stepper { display: flex; align-items: center; gap: var(--s2); }
.stepper output { min-width: 28px; text-align: center; font-size: var(--t-md); font-weight: 700; }
.switch { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track { position: relative; width: 40px; height: 24px; flex: none; border-radius: 12px; background: var(--raise); transition: background-color 180ms var(--ease); }
.switch .track::after { content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: var(--text); transition: transform 220ms var(--ease); }
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::after { transform: translateX(16px); background: var(--on-accent); }
.switch input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }
.check { display: inline-flex; align-items: center; gap: var(--s2); cursor: pointer; font-size: var(--t-sm); color: var(--muted); min-height: 32px; }
.check input { width: 18px; height: 18px; margin: 0; accent-color: var(--accent); }

/* ---------- Luoghi e percorso ---------- */
.combo { position: relative; flex: 1; min-width: 0; }
.with-btn .combo { position: static; }
.sug {
  position: absolute; z-index: 30; top: calc(100% + 4px); left: 0; right: 0; max-height: 320px; overflow: auto;
  margin: 0; padding: 4px; list-style: none; background: var(--raise); border-radius: 10px; box-shadow: var(--float);
}
.sug li[role='option'] { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: var(--s2); padding: 9px 12px; border-radius: 6px; cursor: pointer; }
.sug li[role='option']:hover, .sug li[aria-selected='true'] { background: var(--surface); }
.sug-t { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sug-d { grid-column: 1; color: var(--muted); font-size: var(--t-sm); line-height: 1.35; }
.sug-k { grid-column: 2; grid-row: 1; align-self: center; color: var(--muted); font-size: var(--t-sm); }
.sug-vuoto { padding: 10px 12px; color: var(--muted); font-size: var(--t-sm); }
.route { display: grid; gap: var(--s2); margin-top: var(--s2); padding: 14px; border-radius: 10px; background: var(--sunk); }
.route[aria-busy='true'] { opacity: 0.6; }
.route p { margin: 0; }
.route-sum { display: flex; flex-wrap: wrap; align-items: center; gap: 4px var(--s2); color: var(--muted); font-size: var(--t-sm); }
.route-sum b { color: var(--text); font-size: var(--t-md); font-weight: 800; }
.route-via { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: var(--t-sm); }
.route-warn { display: grid; grid-template-columns: 18px minmax(0, 1fr); gap: var(--s2); font-size: var(--t-sm); }
.route-warn .ic { color: var(--warn); margin-top: 1px; }
.route-toll { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: baseline; gap: 2px var(--s2); padding: 10px 12px; border-radius: 8px; background: var(--surface); font-size: var(--t-sm); }
.route-toll > span { display: flex; flex-wrap: wrap; align-items: center; gap: 4px var(--s2); color: var(--muted); }
.route-toll b { font-size: var(--t-md); font-weight: 800; }
.route-toll small { grid-column: 1 / -1; color: var(--muted); font-size: var(--t-sm); }
.route-opz { display: grid; gap: 6px; }
.route-opz label { position: relative; display: block; cursor: pointer; }
.route-opz input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.route-opz span { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; padding: 10px 12px; border-radius: 8px; background: var(--surface); color: var(--muted); font-size: var(--t-sm); transition: background-color 150ms var(--ease); }
.route-opz span b { color: var(--text); font-size: var(--t-base); }
.route-opz small { flex-basis: 100%; font-size: var(--t-sm); }
.route-opz input:checked + span { background: color-mix(in srgb, var(--blue) 18%, var(--surface)); color: var(--text); }
.route-opz input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 1px; }
.route-ind summary { cursor: pointer; color: var(--muted); font-size: var(--t-sm); font-weight: 600; min-height: 32px; display: flex; align-items: center; }
.route-ind summary:hover { color: var(--text); }
.route-ind ol { margin: var(--s2) 0 0; padding-left: 1.4em; max-height: 260px; overflow: auto; font-size: var(--t-sm); }
.route-ind li { padding: 4px 0; }
.route-ind li span { margin-left: 6px; color: var(--muted); white-space: nowrap; }
.route-attr { color: var(--muted); font-size: var(--t-sm); }
.route-attr a { color: var(--muted); }

/* Cartelli stradali: autostrade su verde, statali e provinciali su blu, bordo bianco come nella segnaletica */
.shield { display: inline-flex; align-items: center; min-height: 26px; padding: 3px 9px; border-radius: 5px; background: var(--sign-blue); color: #fff; font: 800 var(--t-sm)/1 var(--font); white-space: nowrap; outline: 2px solid #fff; outline-offset: -4px; }
.shield.a, .shield.e { background: var(--sign-green); }
.shield.via { background: transparent; color: inherit; outline: 0; padding: 0; font-weight: 600; }

/* ---------- Pannello ---------- */
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); min-height: 64px; padding: 0 var(--s4); flex: none; }
.title { display: flex; align-items: center; gap: var(--s2); min-width: 0; }
.title h1 { margin: 0; font-size: var(--t-md); font-weight: 800; letter-spacing: -0.02em; white-space: nowrap; }
.actions { display: flex; gap: var(--s2); }
.menu-btn .ic { width: 16px; height: 16px; color: var(--muted); }
.menu-list {
  position: fixed; inset: auto; margin: 0; min-width: 272px; max-width: calc(100vw - 16px); padding: 6px; border: 0; border-radius: 12px;
  background: var(--raise); color: var(--text); box-shadow: var(--float);
}
.menu-list:popover-open { animation: pop 180ms var(--ease); }
@keyframes pop { from { opacity: 0; transform: translateY(-6px) scale(0.98); } }
.menu-list button { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 44px; padding: 0 12px; border: 0; border-radius: 8px; background: none; color: var(--text); font: 500 var(--t-base)/1.2 var(--font); text-align: left; cursor: pointer; }
.menu-list button:hover, .menu-list button:focus-visible { background: var(--surface); outline: none; }
.menu-list button.danger { color: var(--warn); }
.menu-list .ic { color: var(--muted); }
.menu-h, .menu-note { margin: 6px 12px; color: var(--muted); font-size: var(--t-sm); }

.tabs { display: flex; gap: var(--s1); padding: 0 var(--s4) var(--s2); flex: none; overflow-x: auto; scrollbar-width: none; }
.tabs [role='tab'] {
  position: relative; display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 12px; border: 0; border-radius: 8px;
  background: none; color: var(--muted); font: 600 var(--t-base)/1 var(--font); white-space: nowrap; cursor: pointer;
  transition: color 150ms var(--ease), background-color 150ms var(--ease);
}
.tabs [role='tab'] .ic, .tabs [role='tab'] .short { display: none; }
.tabs [role='tab']:hover { color: var(--text); }
.tabs [role='tab'][aria-selected='true'] { color: var(--text); background: var(--raise); }
.tabs [role='tab']:focus-visible { outline-offset: -2px; }
.panes { flex: 1; min-height: 0; overflow: auto; overscroll-behavior: contain; scroll-behavior: smooth; view-transition-name: pannello; }
.pane { padding: var(--s3) var(--s4) var(--s6); }
.pane:focus { outline: none; }
.pane:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.lead { margin: 0 0 var(--s4); color: var(--muted); max-width: 60ch; }

/* ---------- Biglietto del viaggio ---------- */
.ticket { --rx: 0deg; --ry: 0deg; display: grid; margin: 0 0 var(--s4); perspective: 1200px; }
.ticket-card, .ticket-slip { position: relative; background: var(--paper); color: var(--paper-ink); }
.ticket-card {
  border-radius: 14px 14px 0 0; padding: 0 22px 22px; transform: rotateX(var(--rx)) rotateY(var(--ry));
  transform-style: preserve-3d; transition: transform 320ms var(--ease);
}
/* fascia ambra, come sul biglietto dell'autostrada */
.ticket-card::before { content: ''; display: block; height: 10px; margin: 0 -22px 18px; border-radius: 14px 14px 0 0; background: var(--accent); }
.ticket .chip[data-s='utente'] { color: #1F5F99; }
.ticket .chip[data-s='rilevato'] { color: #0E6B57; }
.ticket .chip[data-s='modello'] { color: var(--paper-ink); }
.ticket .chip[data-s='ipotesi'] { color: #7A5200; }
.ticket .chip[data-s='illustrativo'] { color: #A3241B; }
.ticket .chip[data-s='non_disponibile'], .ticket .chip[data-s='non_stimato'] { color: var(--paper-muted); box-shadow: inset 0 0 0 1.5px var(--paper-dot); }
.ticket .info, .paper .info { color: var(--paper-muted); }
.ticket .info:hover, .paper .info:hover { color: var(--paper-ink); background: var(--paper-edge); }
.t-head { display: grid; grid-template-columns: 48px minmax(0, 1fr); gap: 14px; align-items: center; }
.pict { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 8px; background: var(--sign-blue); color: #fff; outline: 2px solid #fff; outline-offset: -4px; }
.pict svg { width: 34px; height: 24px; fill: currentColor; }
.t-route { margin: 0; font-size: var(--t-md); font-weight: 800; letter-spacing: -0.02em; line-height: 1.15; overflow-wrap: anywhere; }
.t-meta { margin: 2px 0 0; color: var(--paper-muted); font-size: var(--t-sm); }
.t-shields { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 6px; margin-top: 2px; }
.t-main { margin-top: 22px; }
.t-big { display: block; margin: 0; font-size: clamp(44px, 12vw, 72px); font-weight: 800; line-height: 0.92; letter-spacing: -0.045em; }
.t-big.long { font-size: clamp(38px, 10vw, 62px); }
.t-big.na { font-size: var(--t-lg); color: var(--paper-muted); letter-spacing: -0.02em; }
.almeno { display: block; margin-bottom: 4px; color: #B3261E; font-size: var(--t-sm); font-weight: 700; letter-spacing: 0; }
.t-cap { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; margin: 10px 0 0; }
.t-cap b { font-weight: 700; }
.t-cap .pp { color: var(--paper-muted); }
.t-band { margin: 24px 0 6px; perspective: 700px; }
.bars3d { display: grid; gap: 12px; transform: rotateX(24deg); transform-origin: 50% 100%; transform-style: preserve-3d; }
.bar-row { display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: 10px; align-items: center; }
.bar-row > b { font-size: var(--t-sm); font-weight: 800; color: var(--paper-muted); }
.bar-row.key > b { color: var(--paper-ink); }
.bar { display: flex; gap: 3px; height: 14px; transform-style: preserve-3d; }
.seg-v { position: relative; height: 100%; min-width: 4px; border-radius: 2px; transform-style: preserve-3d; transition: flex-grow 420ms var(--ease), opacity 150ms var(--ease); }
/* faccia inferiore: ogni misura è un lingotto con il suo spessore */
.seg-v::after { content: ''; position: absolute; left: 0; right: 0; top: 100%; height: 8px; background: inherit; filter: brightness(0.62); transform: rotateX(-90deg); transform-origin: top; border-radius: 0 0 2px 2px; }
.bar .rest { flex: 1 1 0; }
.bar .unknown { flex: 0 0 22px; border-radius: 2px; box-shadow: inset 0 0 0 1.5px var(--paper-dot); }
.ticket .v1 { background: #1F6FB2; } .ticket .v2 { background: #4C8FCB; } .ticket .v3 { background: #8EB6DE; }
.ticket .v4 { background: #0E7A63; } .ticket .v5 { background: #3FA389; } .ticket .v6 { background: #92CDBF; }
.ticket .v7 { background: #6E7A85; }
.measures[data-hl] .seg-v { opacity: 0.25; }
.measures[data-hl='1'] .v1, .measures[data-hl='2'] .v2, .measures[data-hl='3'] .v3, .measures[data-hl='4'] .v4,
.measures[data-hl='5'] .v5, .measures[data-hl='6'] .v6, .measures[data-hl='7'] .v7 { opacity: 1; }
.t-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 22px 0 0; }
.t-pair > div + div { margin-top: 0; }
.t-pair > div { padding: 12px 14px; border-radius: 10px; background: color-mix(in srgb, var(--paper-edge) 55%, var(--paper)); }
.t-pair dt { display: flex; align-items: center; justify-content: space-between; gap: 6px; color: var(--paper-muted); font-size: var(--t-sm); font-weight: 600; }
.t-pair dd { margin: 2px 0 0; }
.t-pair .num { display: block; font-size: var(--t-lg); font-weight: 800; letter-spacing: -0.03em; line-height: 1.05; }
.t-pair .num.na { font-size: var(--t-md); color: var(--paper-muted); }
.t-pair .pp { color: var(--paper-muted); font-size: var(--t-sm); }
/* perforazione e tacche tra biglietto e ricevuta */
.ticket-slip { padding: 18px 22px 22px; border-top: 6px dotted var(--surface); }
.ticket-slip::before, .ticket-slip::after { content: ''; position: absolute; top: -15px; width: 24px; height: 24px; border-radius: 50%; background: var(--surface); }
.ticket-slip::before { left: -12px; }
.ticket-slip::after { right: -12px; }
.zig { display: block; width: 100%; height: 10px; fill: var(--paper); }
.slip-h { margin: 0 0 4px; font-size: var(--t-base); font-weight: 800; }
.slip-g { margin: 14px 0 0; color: var(--paper-muted); font-size: var(--t-sm); font-weight: 700; }
.slip-row { display: grid; grid-template-columns: 26px minmax(0, auto) minmax(16px, 1fr) auto 32px; align-items: center; gap: 8px; min-height: 42px; }
.slip-row .nm { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.slip-row .dots { align-self: center; height: 0; border-bottom: 4px dotted var(--paper-dot); }
.slip-row .val { text-align: right; font-weight: 700; white-space: nowrap; }
.slip-row .val.na { color: var(--paper-muted); font-weight: 500; }
.slip-row.off .nm { color: var(--paper-muted); }
.slip-tot { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); margin-top: 14px; min-height: 52px; padding: 0 16px; border-radius: 8px; background: var(--paper-ink); color: var(--paper); font-weight: 800; }
.slip-tot span:last-child { font-size: var(--t-md); }
.sw { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 5px; color: #fff; font-size: var(--t-sm); font-weight: 800; }
.sw.off { background: transparent !important; color: var(--muted); box-shadow: inset 0 0 0 1.5px var(--unknown); }
.ticket .sw.off { color: var(--paper-muted); box-shadow: inset 0 0 0 1.5px var(--paper-dot); }
.v1 { background: var(--v1); } .v2 { background: var(--v2); } .v3 { background: var(--v3); }
.v4 { background: var(--v4); } .v5 { background: var(--v5); } .v6 { background: var(--v6); } .v7 { background: var(--v7); }

/* stampa: il biglietto esce dalla fessura, riga dopo riga */
@media (prefers-reduced-motion: no-preference) {
  .ticket.printing .ticket-card { animation: print-out 760ms var(--ease) both; }
  .ticket.printing .ticket-slip, .ticket.printing .zig { animation: print-out 760ms var(--ease) 240ms both; }
  .ticket.printing .anim { animation: rise 520ms var(--ease) both; animation-delay: calc(280ms + var(--i, 0) * 70ms); }
}
@keyframes print-out { from { clip-path: inset(0 0 100% 0); transform: translateY(-18px); } to { clip-path: inset(0 0 0 0); transform: none; } }
@keyframes rise { from { opacity: 0; transform: translateY(16px); } }

.info { display: inline-grid; place-items: center; width: 32px; height: 32px; padding: 0; border: 0; border-radius: 8px; background: none; color: var(--muted); cursor: pointer; flex: none; transition: background-color 150ms var(--ease), color 150ms var(--ease); }
.info:hover { color: var(--text); background: var(--raise); }
.info:active { transform: scale(0.94); }
.info .ic { width: 17px; height: 17px; }

.banner { display: grid; grid-template-columns: 20px minmax(0, 1fr); gap: 12px; margin: 0 0 var(--s4); padding: 14px 16px; border-radius: 10px; background: color-mix(in srgb, var(--warn) 14%, var(--surface)); }
.banner .ic { color: var(--warn); margin-top: 2px; width: 20px; height: 20px; }
.banner p { margin: 0; }
.banner p + p { margin-top: 6px; color: var(--muted); font-size: var(--t-sm); }

.hyp { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: var(--s4); margin-top: var(--s5); }
.hyp h2, .sec-h { margin: 0 0 var(--s3); font-size: var(--t-md); font-weight: 800; letter-spacing: -0.02em; }
.hyp-controls { display: grid; gap: var(--s3); align-content: start; }
.gamma { display: grid; grid-template-columns: minmax(0, 1fr) 84px; gap: var(--s2) var(--s3); align-items: center; }
.gamma .field { grid-column: 1 / -1; }
input[type='range'] { width: 100%; height: 32px; margin: 0; background: none; accent-color: var(--accent); cursor: pointer; }
input[type='range']::-webkit-slider-runnable-track { height: 6px; border-radius: 3px; background: var(--raise); }
input[type='range']::-webkit-slider-thumb { -webkit-appearance: none; width: 22px; height: 22px; margin-top: -8px; border-radius: 50%; background: var(--accent); border: 3px solid var(--surface); }
input[type='range']::-moz-range-track { height: 6px; border-radius: 3px; background: var(--raise); }
input[type='range']::-moz-range-thumb { width: 16px; height: 16px; border-radius: 50%; background: var(--accent); border: 3px solid var(--surface); }
input[type='range'][data-empty]::-webkit-slider-thumb { background: var(--surface); border-color: var(--unknown); }
input[type='range'][data-empty]::-moz-range-thumb { background: var(--surface); border-color: var(--unknown); }
.range-box { align-self: start; padding: 18px; border-radius: 12px; background: var(--raise); }
.range-box .lbl { margin: 0; color: var(--muted); font-size: var(--t-sm); font-weight: 600; }
.range-box .r { margin: 6px 0 0; font-size: var(--t-md); font-weight: 800; line-height: 1.3; }
.range-box .r .arrow { color: var(--muted); font-weight: 400; }
.range-box .note { margin: var(--s2) 0 0; color: var(--muted); font-size: var(--t-sm); }
.range-box .sep { height: var(--s4); }
.conv { display: grid; gap: var(--s2); }
.conv-vals { margin: 0; color: var(--muted); font-size: var(--t-sm); }
.conv-vals b { color: var(--text); font-weight: 700; }

.empty { display: grid; gap: var(--s3); max-width: 560px; }
.empty .ticket-card { padding-bottom: 26px; border-radius: 14px; transform: none; }
.empty h2 { margin: 0; font-size: clamp(28px, 6.5vw, 38px); font-weight: 800; line-height: 1; letter-spacing: -0.04em; }
.empty p { margin: 0; }
.empty .ticket-card > p { color: var(--paper-muted); margin-top: 12px; }
.defs { display: grid; gap: 12px; margin: 20px 0 0; }
.defs div { display: grid; grid-template-columns: 30px minmax(0, 1fr); gap: 12px; align-items: baseline; }
.defs dt { font-size: var(--t-md); font-weight: 800; }
.defs dd { margin: 0; }
.defs dd span { color: var(--paper-muted); }
.ex-actions { display: flex; flex-wrap: wrap; gap: var(--s2); }
.empty-cta { display: none; }

/* ---------- Dettaglio ---------- */
.block { border-radius: 12px; background: var(--raise); margin-bottom: var(--s2); }
.block > summary { display: grid; grid-template-columns: 28px minmax(0, 1fr) auto auto 32px; align-items: center; gap: var(--s2); min-height: 56px; padding: 0 12px 0 14px; cursor: pointer; list-style: none; border-radius: 12px; transition: background-color 150ms var(--ease); }
.block > summary::-webkit-details-marker { display: none; }
.block > summary:hover { background: color-mix(in srgb, var(--raise) 92%, var(--text)); }
.block > summary h3 { margin: 0; font-size: var(--t-base); font-weight: 700; }
.block > summary .val { text-align: right; white-space: nowrap; font-weight: 700; }
.block-body { display: grid; gap: var(--s3); padding: var(--s2) 14px 20px 50px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s3); }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s3); }
.rows { display: grid; gap: var(--s2); }
.rowx { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 44px; gap: var(--s2); align-items: end; padding: 12px; border-radius: 10px; background: var(--surface); }
.rowx.t { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr) 44px; }
.rowx .field:first-child { grid-column: 1 / -1; }
.rowx .comp { grid-column: 1 / -1; margin: 0; color: var(--muted); font-size: var(--t-sm); }
.comp:empty { display: none; }
.sub-h { margin: var(--s2) 0 0; font-size: var(--t-base); font-weight: 700; }
.suggest { margin: 0; padding: 12px 14px; border-radius: 10px; background: color-mix(in srgb, var(--accent) 12%, var(--surface)); font-size: var(--t-sm); }
.suggest .chip { margin-right: 6px; }
.suggest span.src { color: var(--muted); }
.out { margin: 0; padding: 12px 14px; border-radius: 10px; background: var(--surface); font-size: var(--t-sm); line-height: 1.55; }
.out b { color: var(--text); }
.chip-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); }

/* ---------- Ripartizione ---------- */
.sp-sec { padding: var(--s4) 0 0; }
.sp-sec:first-child { padding-top: 0; }
.sp-sec > p { margin: 0 0 var(--s3); color: var(--muted); max-width: 60ch; }
.people { display: grid; gap: var(--s2); margin-top: var(--s3); }
.person { display: grid; grid-template-columns: minmax(0, 1fr) 88px 44px; gap: var(--s2); }
.person.nw { grid-template-columns: minmax(0, 1fr) 44px; }
.matrix { width: 100%; border-collapse: collapse; }
.matrix th, .matrix td { height: 48px; padding: 0 6px; border-bottom: 1px solid var(--raise); text-align: center; }
.matrix th { color: var(--muted); font-size: var(--t-sm); font-weight: 600; }
.matrix th:first-child, .matrix td:first-child { text-align: left; padding-left: 0; }
.matrix input[type='checkbox'] { width: 22px; height: 22px; accent-color: var(--accent); cursor: pointer; }
.matrix input[type='text'] { height: 40px; width: 104px; }
.scroll-x { overflow-x: auto; }
.exp { display: grid; gap: var(--s2); }
.exp-row { display: grid; grid-template-columns: minmax(0, 1.4fr) 136px minmax(0, 1fr) minmax(0, 1fr) 44px; gap: var(--s2); align-items: center; }
.exp-row .amt { display: inline-flex; align-items: center; justify-content: flex-end; gap: 2px; font-weight: 700; white-space: nowrap; }
.exp-row .amt .info { width: 28px; height: 28px; }
.exp-only { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: var(--s3); padding-left: 2px; }
.exp-head { color: var(--muted); font-size: var(--t-sm); font-weight: 600; }
/* l'esito della ripartizione è uno scontrino */
.paper { padding: 20px 22px; border-radius: 12px 12px 0 0; background: var(--paper); color: var(--paper-ink); }
.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: right; color: var(--paper-muted); font-size: var(--t-sm); font-weight: 600; padding: 0 0 8px 8px; white-space: nowrap; }
.tbl th .info { width: 28px; height: 28px; vertical-align: middle; }
.tbl td { text-align: right; height: 46px; padding: 0 0 0 8px; border-top: 4px dotted var(--paper-dot); font-weight: 700; }
.tbl th:first-child, .tbl td:first-child { text-align: left; padding-left: 0; font-weight: 500; }
.tbl .pos { color: #0E6B57; }
.tbl .neg { color: #B3261E; }
.tbl tfoot td { color: var(--paper-muted); }
.paper .field-h .label { color: var(--paper-muted); }
.transfers { list-style: none; margin: var(--s2) 0 0; padding: 0; display: grid; gap: var(--s2); }
.transfers li { display: grid; grid-template-columns: auto auto minmax(0, 1fr) auto; align-items: center; gap: var(--s2); min-height: 50px; padding: 0 16px; border-radius: 8px; background: var(--paper-ink); color: var(--paper); font-weight: 600; }
.transfers .to-arrow { opacity: 0.7; }
.transfers .amt { font-weight: 800; color: var(--accent); }
.note-v { margin: var(--s3) 0 0; color: var(--paper-muted); font-size: var(--t-sm); }
.err { color: #B3261E; font-size: var(--t-sm); margin: var(--s2) 0 0; }
.save-row { display: flex; flex-wrap: wrap; gap: var(--s2); }

/* ---------- Fonti e ipotesi ---------- */
.doc-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s2); }
.doc-list > li { padding: 16px; border-radius: 12px; background: var(--raise); }
.doc-list h3 { margin: 0 0 8px; font-size: var(--t-base); font-weight: 700; }
.doc-list pre { margin: 0 0 8px; padding: 10px 12px; border-radius: 8px; background: var(--surface); font-size: var(--t-base); white-space: pre-wrap; }
.doc-list p { margin: 0; color: var(--muted); font-size: var(--t-sm); }
.doc-list dl { display: grid; gap: 6px; margin: 0; font-size: var(--t-sm); }
.doc-list dt { color: var(--muted); font-weight: 600; }
.doc-list dd { margin: 0 0 4px; }
.doc-top { display: flex; flex-wrap: wrap; gap: var(--s2); margin: 0 0 var(--s4); }
.pane h2 { margin: var(--s4) 0 var(--s3); font-size: var(--t-md); font-weight: 800; letter-spacing: -0.02em; }
.pane h2:first-child { margin-top: 0; }

/* ---------- Cassetto ---------- */
.drawer {
  position: fixed; inset: 0 0 0 auto; width: min(500px, 100vw); height: 100%; max-width: none; max-height: none; margin: 0; padding: 0;
  border: 0; background: var(--surface); color: var(--text); box-shadow: var(--float);
}
.drawer[open] { display: flex; flex-direction: column; animation: drawer-in 260ms var(--ease); }
.drawer::backdrop { background: rgba(8, 11, 14, 0.55); }
@keyframes drawer-in { from { transform: translateX(32px); opacity: 0; } }
.drawer-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); min-height: 64px; padding: 0 var(--s4); flex: none; }
.drawer-head h2 { margin: 0; font-size: var(--t-md); font-weight: 800; letter-spacing: -0.02em; }
.drawer-body { flex: 1; overflow: auto; padding: 0 var(--s4) var(--s5); display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--s4); align-content: start; }
.drawer-body h3 { margin: 0 0 var(--s2); color: var(--muted); font-size: var(--t-sm); font-weight: 700; }
.drawer-body pre { margin: 0; padding: 14px; border-radius: 10px; background: var(--raise); font-size: var(--t-base); line-height: 1.6; white-space: pre-wrap; }
.drawer-body p { margin: 0; }
.drawer-body .big { font-size: 32px; font-weight: 800; letter-spacing: -0.03em; line-height: 1; }
.vt { width: 100%; border-collapse: collapse; font-size: var(--t-sm); }
.vt td { padding: 9px 8px 9px 0; border-bottom: 1px solid var(--raise); vertical-align: top; }
.vt td:first-child { font-weight: 700; white-space: nowrap; }
.vt .v { text-align: right; white-space: nowrap; }
.vt.pd td:first-child { font-weight: 600; white-space: normal; }
.vt .chip { white-space: normal; }
.drawer-body dl { display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: 6px var(--s3); margin: 0; font-size: var(--t-sm); }
.drawer-body dt { color: var(--muted); font-weight: 600; }
.drawer-body dd { margin: 0; overflow-wrap: anywhere; }
.drawer-body ul { margin: 0; padding-left: 1.1em; font-size: var(--t-sm); }
.drawer-body li + li { margin-top: 6px; }

.toast { position: fixed; left: 50%; bottom: 56px; transform: translateX(-50%); z-index: 50; margin: 0; max-width: calc(100vw - 32px); padding: 12px 16px; border-radius: 10px; background: var(--raise); box-shadow: var(--float); }
.toast:not([hidden]) { animation: pop 220ms var(--ease); }

/* ---------- Entrate legate allo scorrimento, dove supportate ---------- */
@supports (animation-timeline: view()) {
  @media (prefers-reduced-motion: no-preference) {
    .reveal { animation: rise linear both; animation-timeline: view(); animation-range: entry 0% entry 45%; }
  }
}
@media (prefers-reduced-motion: no-preference) {
  ::view-transition-old(pannello) { animation: vt-out 150ms var(--ease) both; }
  ::view-transition-new(pannello) { animation: vt-in 260ms var(--ease) both; }
}
@keyframes vt-out { to { opacity: 0; transform: translateX(-12px); } }
@keyframes vt-in { from { opacity: 0; transform: translateX(16px); } }

/* ---------- Portatili stretti: mappa affiancata solo da 1200 px ---------- */
@media (min-width: 1200px) and (max-width: 1439px) {
  .app { grid-template-columns: minmax(0, 1fr) minmax(440px, 46%); }
  .sheet { width: 360px; }
  .map-off { left: 400px; }
  .hyp { grid-template-columns: minmax(0, 1fr); }
}

/* ---------- Tablet e portatili sotto 1200 px: colonna unica centrata ---------- */
@media (min-width: 720px) and (max-width: 1199px) {
  .app { align-items: center; }
  .panel-head, .stage, .panes, .statusbar { width: 100%; max-width: 760px; }
  .tripbar { width: calc(100% - 32px); max-width: 728px; }
  .sheet { width: min(100%, 680px); margin: 0 auto; border-radius: 18px 18px 0 0; }
}

/* ---------- Telefono e tablet (prima di tutto) ---------- */
@media (max-width: 1199px) {
  body { overflow: auto; }
  .app { display: flex; flex-direction: column; height: auto; min-height: 100dvh; padding-bottom: calc(68px + env(safe-area-inset-bottom)); }
  .panel { display: contents; }
  .panel-head { order: -2; position: sticky; top: 0; z-index: 20; min-height: 56px; padding: 0 var(--s3); gap: var(--s2); background: var(--ground); }
  .title h1 { font-size: 17px; }
  /* sotto i 16 px iOS ingrandisce la pagina quando si tocca un campo */
  input[type='text'], input[type='number'], select { font-size: 16px; }
  #badge-esempio { display: none; }
  .actions { gap: 4px; }
  .menu-btn { padding: 0 10px; }
  .menu-btn .ic { display: none; }
  .tripbar {
    order: -1; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: var(--s2) var(--s3); margin: var(--s2) var(--s3) 0;
    padding: 14px 16px; border: 0; border-radius: 12px; background: var(--surface); color: var(--text); font: inherit; text-align: left; cursor: pointer;
    transition: transform 120ms var(--ease);
  }
  .tripbar.vuoto { background: var(--accent); color: var(--on-accent); }
  .tripbar b { display: block; font-size: var(--t-md); font-weight: 800; letter-spacing: -0.02em; line-height: 1.2; overflow-wrap: anywhere; }
  .tripbar small { display: block; margin-top: 2px; color: var(--muted); font-size: var(--t-sm); }
  .tripbar.vuoto small { color: inherit; }
  .tripbar .go { display: inline-flex; align-items: center; gap: 4px; font-size: var(--t-sm); font-weight: 700; }
  .tripbar:active { transform: scale(0.985); }
  .app:not([data-tab='risultato']) .stage, .app:not([data-tab='risultato']) .tripbar { display: none; }
  .stage { order: 0; overflow: visible; padding: var(--s2) var(--s3) 0; background: transparent; }
  .map-bar { display: block; }
  .map-toggle {
    display: flex; align-items: center; gap: var(--s2); width: 100%; min-height: 48px; padding: 0 14px; border: 0; border-radius: 12px;
    background: var(--surface); color: var(--text); font: 600 var(--t-base)/1 var(--font); cursor: pointer;
  }
  .map-toggle .map-state { margin-left: auto; color: var(--muted); font-size: var(--t-sm); font-weight: 500; }
  .map-toggle .chev { transition: transform 200ms var(--ease); }
  .map-toggle[aria-expanded='true'] .chev { transform: rotate(180deg); }
  .map-wrap { position: relative; inset: auto; height: 0; overflow: hidden; border-radius: 12px; transition: height 320ms var(--ease); }
  .map-wrap.open { height: 300px; margin-top: var(--s2); }
  .stage-photo { display: none; }
  .map-off { left: var(--s3); right: var(--s3); bottom: var(--s3); }
  .map-off-h { font-size: var(--t-md); }
  /* il modulo del viaggio diventa un pannello che sale dal basso */
  .sheet { position: fixed; inset: auto 0 0 0; width: 100%; max-width: 100%; max-height: 92dvh; border-radius: 18px 18px 0 0; padding-bottom: env(safe-area-inset-bottom); }
  .sheet:not([open]) { display: none; }
  .sheet[open] { animation: sheet-in 320ms var(--ease); }
  .sheet::backdrop { background: rgba(8, 11, 14, 0.55); }
  .sheet-grip { display: block; width: 44px; height: 5px; margin: 10px auto 0; border-radius: 3px; background: var(--line); }
  .sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 4px 12px 0 20px; touch-action: none; }
  .sheet-head h2 { margin: 0; font-size: var(--t-md); font-weight: 800; letter-spacing: -0.02em; }
  .search { padding: 8px 20px 24px; }
  .panes { order: 1; overflow: visible; }
  .pane { padding: var(--s3) var(--s3) var(--s5); }
  .tabs {
    position: fixed; z-index: 30; left: 0; right: 0; bottom: 0; height: calc(64px + env(safe-area-inset-bottom)); padding: 0 4px env(safe-area-inset-bottom);
    gap: 0; justify-content: space-around; background: var(--surface);
  }
  .tabs [role='tab'] { flex: 1; flex-direction: column; justify-content: center; gap: 4px; height: 64px; padding: 0 2px; border-radius: 0; background: none; font-size: var(--t-sm); }
  .tabs [role='tab'][aria-selected='true'] { background: none; color: var(--text); }
  .tabs [role='tab'][aria-selected='true'] .ic { color: var(--accent); }
  .tabs [role='tab'] .ic { display: block; width: 22px; height: 22px; }
  .tabs [role='tab'] .short { display: inline; }
  .tabs #t-fonti > span:not(.short) { display: none; }
  .statusbar { order: 2; display: block; padding: var(--s4) var(--s3); line-height: 1.7; }
  .statusbar nav { margin-top: var(--s2); }
  .hyp { grid-template-columns: minmax(0, 1fr); }
  .ticket-card { padding: 0 18px 20px; }
  .ticket-card::before { margin: 0 -18px 16px; }
  .ticket-slip { padding: 16px 18px 20px; }
  .ticket-slip, .ticket-slip::before, .ticket-slip::after { border-top-color: var(--ground); }
  .ticket-slip::before, .ticket-slip::after { background: var(--ground); }
  .drawer { width: 100vw; }
  .toast { bottom: 80px; }
  .empty-cta { display: inline-flex; }
}
@keyframes sheet-in { from { transform: translateY(40px); opacity: 0; } }
@media (max-width: 520px) {
  .grid2, .grid3 { grid-template-columns: minmax(0, 1fr); }
  .block-body { padding-left: 14px; }
  .rowx.t { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 44px; }
  .rowx.t .field:nth-child(4) { grid-column: 1 / span 2; }
  .exp-row { grid-template-columns: minmax(0, 1fr) 124px 44px; }
  .person { grid-template-columns: minmax(0, 1fr) 76px 44px; }
  .t-pair { grid-template-columns: 1fr; }
  .slip-row { grid-template-columns: 26px minmax(0, 1fr) auto 32px; }
  .slip-row .dots { display: none; }
}

/* pittogrammi dei veicoli: pieni, con le ruote staccate dal colore del fondo */
.pv { width: 26px; height: 18px; fill: currentColor; stroke: none; }
.pict { --pb: var(--sign-blue); }
.seg span { --pb: var(--sunk); }
.seg input:checked + span { --pb: var(--raise); }
.menu-list { --pb: var(--raise); }
.menu-list button:hover, .menu-list button:focus-visible { --pb: var(--surface); }

.pair-cap { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-top: 6px; font-size: var(--t-sm); }
.pair-cap b { font-weight: 700; }
.t-pair .pp { display: block; }

/* cosa manca, dentro il biglietto */
.manca { margin: 20px 0 0; padding: 16px; border-radius: 10px; background: color-mix(in srgb, var(--accent) 16%, var(--paper)); }
.manca h3 { margin: 0 0 10px; font-size: var(--t-base); font-weight: 800; }
.manca-row { display: grid; gap: 6px; margin-top: 12px; }
.manca-row > label { font-size: var(--t-sm); font-weight: 600; color: var(--paper-ink); }
.manca-in { display: flex; gap: 8px; }
.manca-in .unit { flex: 1; }
.manca input[type='text'] { background: #fff; color: var(--paper-ink); border-color: var(--paper-dot); }
.manca input::placeholder { color: var(--paper-muted); }
.manca .unit span { color: var(--paper-muted); }
.manca .zero { min-height: 44px; background: var(--paper); color: var(--paper-ink); box-shadow: inset 0 0 0 1.5px var(--paper-dot); }
.manca .zero:hover { background: #fff; color: var(--paper-ink); }
.manca-nota { margin: 0; color: var(--paper-muted); font-size: var(--t-sm); }
.manca-resto { margin: 14px 0 0; font-size: var(--t-sm); color: var(--paper-ink); }
.manca .btn.link { color: #1F5F99; }
