:root {
  color-scheme: dark light;
  --accent: #ff5a1f;
  --accent-ink: #fff;
  --bg: #0d0e11;
  --surface: #16181d;
  --surface-2: #1e2127;
  --surface-3: #272a32;
  --line: #2b2f38;
  --text: #eef0f4;
  --muted: #979eab;
  --good: #22c38e;
  --mid: #f2b705;
  --bad: #ff5d5d;
  --radius: 20px;
  --shadow: 0 1px 0 rgba(255,255,255,.04) inset, 0 12px 32px rgba(0,0,0,.35);

  --c-stage: radial-gradient(120% 90% at 50% 0%, #252932 0%, #15171c 70%);
  --c-ground: #111317;
  --c-ground-line: #3a3f4a;
  --c-grid: rgba(255,255,255,.07);
  --c-dim: #7d8594;
  --c-tire: #0b0c0e;
  --c-rim: #555b67;
  --c-metal: #aab1bd;
  --c-bike-dark: #30343c;
  --c-engine: #474c56;
  --c-seat: #34373e;
  --c-glass: rgba(150, 190, 240, .45);
  --c-light: #fff3cf;
  --c-suit: #e4e7ee;
  --c-suit-far: #9aa0ab;
  --c-boot: #0f1013;
  --c-boot-far: #2a2d33;
  --c-glove: #0f1013;
  --c-helmet: #fafafa;
  --c-visor: #1a2230;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f3f4f7;
    --surface: #ffffff;
    --surface-2: #f1f2f5;
    --surface-3: #e6e8ee;
    --line: #e2e4ea;
    --text: #14161b;
    --muted: #666d7a;
    --shadow: 0 1px 2px rgba(20,22,27,.06), 0 10px 28px rgba(20,22,27,.08);
    --c-stage: radial-gradient(120% 90% at 50% 0%, #ffffff 0%, #eceef2 75%);
    --c-ground: #e2e5ea;
    --c-ground-line: #b9bec8;
    --c-grid: rgba(0,0,0,.07);
    --c-dim: #7d8594;
    --c-rim: #8a909b;
    --c-metal: #9aa1ad;
    --c-bike-dark: #3a3e46;
    --c-engine: #5b606b;
    --c-suit: #2c323d;
    --c-suit-far: #5f6673;
    --c-helmet: #ffffff;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
button { font: inherit; color: inherit; cursor: pointer; }
svg { display: block; }
[hidden] { display: none !important; }

.app { min-height: 100%; display: flex; flex-direction: column; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  padding: calc(10px + var(--safe-top)) 16px 10px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(1.6) blur(18px);
  -webkit-backdrop-filter: saturate(1.6) blur(18px);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; margin-right: auto; color: inherit; text-decoration: none; border-radius: 12px; }
.brand:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
.brand:active .logo { transform: scale(.94); }
.logo { width: 36px; height: 36px; flex: none; }
.brand strong { display: block; font-size: 17px; letter-spacing: -.01em; }
.brand span { display: block; font-size: 12px; color: var(--muted); }
.views { display: none; }
.top-actions { display: flex; gap: 6px; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface); display: grid; place-items: center; padding: 0;
  font-size: 13px; font-weight: 650;
}
.icon-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn:active { transform: scale(.96); }

/* ---------- Bike tabs ---------- */
.bike-bar {
  display: flex; gap: 8px; align-items: center;
  padding: 4px 16px 12px;
  position: sticky; top: calc(60px + var(--safe-top)); z-index: 19;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(1.6) blur(18px);
  -webkit-backdrop-filter: saturate(1.6) blur(18px);
}
.bike-tabs { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; flex: 1; min-width: 0; scroll-snap-type: x proximity; }
.bike-tabs::-webkit-scrollbar { display: none; }
.bike-tab {
  flex: none; display: flex; align-items: center; gap: 8px;
  padding: 7px 8px 7px 12px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface);
  font-size: 14px; font-weight: 600; white-space: nowrap; scroll-snap-align: start;
  transition: background .2s, border-color .2s;
}
.bike-tab .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--c); flex: none; }
.bike-tab .x { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; color: var(--muted); font-size: 16px; line-height: 1; }
.bike-tab .x:hover { background: var(--surface-3); color: var(--text); }
.bike-tab[aria-selected="true"] { border-color: var(--c); background: color-mix(in srgb, var(--c) 16%, var(--surface)); }
.add-btn {
  flex: none; display: flex; align-items: center; gap: 6px;
  padding: 8px 14px 8px 10px; border-radius: 999px; border: 0;
  background: var(--accent); color: var(--accent-ink); font-weight: 650; font-size: 14px;
  box-shadow: 0 6px 18px color-mix(in srgb, var(--accent) 40%, transparent);
}
.add-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; }
.add-btn:active { transform: scale(.97); }

main { flex: 1; padding: 0 16px calc(96px + var(--safe-bottom)); max-width: 1280px; width: 100%; margin: 0 auto; }
.view { display: none; animation: fade .25s ease; }
.view[data-active] { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } }

/* ---------- Empty state ---------- */
.empty { text-align: center; max-width: 560px; margin: 8px auto 0; }
.empty-art { border-radius: var(--radius); background: var(--c-stage); overflow: hidden; margin-bottom: 20px; box-shadow: var(--shadow); }
.empty h1 { font-size: clamp(26px, 6vw, 36px); letter-spacing: -.02em; margin: 0 0 8px; }
.empty p { color: var(--muted); line-height: 1.5; margin: 0 0 20px; }
.quick { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 22px; }
.quick button { border: 1px solid var(--line); background: var(--surface); padding: 8px 12px; border-radius: 999px; font-size: 14px; }
.primary {
  border: 0; background: var(--accent); color: var(--accent-ink);
  padding: 13px 22px; border-radius: 14px; font-weight: 650; font-size: 16px;
  box-shadow: 0 8px 22px color-mix(in srgb, var(--accent) 35%, transparent);
}
.primary:active { transform: scale(.98); }
.primary.wide { width: 100%; }
a.primary { display: inline-flex; align-items: center; gap: 8px; text-decoration: none; }

/* ---------- Simulatore ---------- */
.sim { display: grid; gap: 16px; }
.stage-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden;
}
.stage-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 16px 18px 6px; }
.stage-brand { font-size: 13px; color: var(--muted); font-weight: 600; }
.stage-head h2 { margin: 2px 0 0; font-size: 22px; letter-spacing: -.02em; }
.pill { font-size: 12px; font-weight: 700; padding: 6px 10px; border-radius: 999px; background: var(--surface-3); white-space: nowrap; text-transform: uppercase; letter-spacing: .04em; }
.pill[data-k="relax"] { background: color-mix(in srgb, var(--good) 22%, transparent); color: var(--good); }
.pill[data-k="upright"] { background: color-mix(in srgb, #3ba7ff 22%, transparent); color: #3ba7ff; }
.pill[data-k="sport"] { background: color-mix(in srgb, var(--mid) 22%, transparent); color: var(--mid); }
.pill[data-k="race"] { background: color-mix(in srgb, var(--bad) 22%, transparent); color: var(--bad); }
.stage { position: relative; background: var(--c-stage); touch-action: pan-y; user-select: none; -webkit-user-select: none; }
.stage svg { width: 100%; height: auto; aspect-ratio: 2650 / 2160; max-height: 62vh; }
.dim-text { fill: var(--c-dim); font-size: 64px; font-weight: 600; }
.nav-arrow {
  position: absolute; top: 50%; translate: 0 -50%; width: 40px; height: 40px; border-radius: 50%;
  border: 1px solid var(--line); background: color-mix(in srgb, var(--surface) 80%, transparent);
  backdrop-filter: blur(8px); display: grid; place-items: center; padding: 0; opacity: .9;
}
.nav-arrow svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.nav-arrow.prev { left: 10px; } .nav-arrow.next { right: 10px; }
.stage-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 14px 14px; flex-wrap: wrap; }
.dots { display: flex; gap: 6px; }
.dots i { width: 8px; height: 8px; border-radius: 50%; background: var(--surface-3); transition: all .25s; }
.dots i.on { width: 22px; border-radius: 4px; background: var(--c, var(--accent)); }
.toggles { display: flex; gap: 6px; flex-wrap: wrap; }
.chip-toggle { border: 1px solid var(--line); background: var(--surface-2); border-radius: 999px; padding: 6px 12px; font-size: 13px; font-weight: 600; color: var(--muted); }
.chip-toggle[aria-pressed="true"] { color: var(--text); border-color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, var(--surface-2)); }
.warn { margin: 0 14px 14px; padding: 10px 12px; border-radius: 12px; font-size: 14px; background: color-mix(in srgb, var(--mid) 16%, transparent); color: var(--text); border: 1px solid color-mix(in srgb, var(--mid) 40%, transparent); }

.metrics { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: 16px; }
.metric {
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 12px 14px 14px;
  display: flex; flex-direction: column; gap: 4px; min-width: 0;
}
.metric.wide { grid-column: 1 / -1; }
.metric .m-label { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.metric .m-value { font-size: 26px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.metric .m-value small { font-size: 14px; color: var(--muted); font-weight: 600; margin-left: 4px; }
.metric .m-note { font-size: 12.5px; color: var(--muted); }
.meter { height: 6px; border-radius: 3px; background: var(--surface-3); overflow: hidden; margin-top: 4px; }
.meter i { display: block; height: 100%; border-radius: 3px; background: var(--q); transition: width .35s ease, background .35s; }
.reach-steps { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; margin-top: 6px; }
.reach-steps i { height: 6px; border-radius: 3px; background: var(--surface-3); }
.reach-steps i.on { background: var(--q); }

/* ---------- Pannelli ---------- */
.controls { display: flex; flex-direction: column; gap: 10px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.panel summary {
  list-style: none; display: flex; align-items: center; gap: 10px; padding: 14px 16px; font-weight: 650; cursor: pointer;
}
.panel summary::-webkit-details-marker { display: none; }
.panel summary::after { content: ""; width: 8px; height: 8px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); rotate: 45deg; margin-left: 8px; transition: rotate .2s; translate: 0 -2px; }
.panel[open] summary::after { rotate: 225deg; translate: 0 2px; }
.p-ico { font-size: 18px; width: 28px; height: 28px; display: grid; place-items: center; border-radius: 8px; background: var(--surface-2); }
.p-sub { margin-left: auto; font-weight: 500; font-size: 13px; color: var(--muted); }
.panel-body { padding: 2px 16px 16px; display: flex; flex-direction: column; gap: 14px; }
.field { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 6px 10px; }
.field > label { font-size: 14px; font-weight: 600; display: flex; gap: 8px; align-items: center; }
.field input[type=range], .field .scale-labels { grid-column: 1 / -1; }
.field:has(.scale-labels) > label { grid-column: 1 / -1; }
.scale-labels { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-bottom: -4px; }
.stepper { display: flex; align-items: center; background: var(--surface-2); border-radius: 10px; border: 1px solid var(--line); }
.stepper button { width: 34px; height: 32px; border: 0; background: none; font-size: 18px; color: var(--muted); }
.stepper button:active { color: var(--text); }
.stepper output { min-width: 74px; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; font-size: 15px; }
.link { border: 0; background: none; color: var(--accent); font-size: 12.5px; font-weight: 600; padding: 0; }
.hint { font-size: 12.5px; color: var(--muted); margin: -4px 0 0; line-height: 1.45; }
input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; height: 28px; background: transparent; margin: 0; }
input[type=range]::-webkit-slider-runnable-track { height: 6px; border-radius: 3px; background: linear-gradient(to right, var(--accent) var(--p, 50%), var(--surface-3) var(--p, 50%)); }
input[type=range]::-moz-range-track { height: 6px; border-radius: 3px; background: linear-gradient(to right, var(--accent) var(--p, 50%), var(--surface-3) var(--p, 50%)); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 24px; height: 24px; border-radius: 50%; background: #fff; margin-top: -9px; box-shadow: 0 1px 4px rgba(0,0,0,.35), 0 0 0 1px rgba(0,0,0,.06); }
input[type=range]::-moz-range-thumb { width: 24px; height: 24px; border: 0; border-radius: 50%; background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.35); }
.segmented { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(3, 1fr); padding: 3px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; }
.segmented button { border: 0; background: none; padding: 8px; border-radius: 9px; font-size: 14px; font-weight: 600; color: var(--muted); }
.segmented button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.switch { display: flex; align-items: center; gap: 12px; font-size: 14px; font-weight: 600; cursor: pointer; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch span { width: 44px; height: 26px; border-radius: 13px; background: var(--surface-3); position: relative; transition: background .2s; flex: none; }
.switch span::after { content: ""; position: absolute; left: 3px; top: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: translate .2s; box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { translate: 18px 0; }
.switch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.ghost-btn { border: 1px solid var(--line); background: var(--surface-2); border-radius: 12px; padding: 10px; font-weight: 600; font-size: 14px; }

/* ---------- Confronto ---------- */
.compare { display: grid; gap: 16px; }
.compare-empty { text-align: center; padding: 48px 12px; color: var(--muted); }
.compare-empty h2 { color: var(--text); }
.legend { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 14px 14px; }
.legend span { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; padding: 5px 10px; border-radius: 999px; background: var(--surface-2); }
.legend i { width: 10px; height: 10px; border-radius: 50%; background: var(--c); }
.bars { display: grid; gap: 10px; }
.bar-card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 14px 16px; }
.bar-card h3 { margin: 0 0 2px; font-size: 15px; }
.bar-card p { margin: 0 0 10px; font-size: 12.5px; color: var(--muted); }
.bar-row { display: grid; grid-template-columns: minmax(90px, 1.1fr) 3fr auto; gap: 10px; align-items: center; padding: 4px 0; font-size: 13.5px; }
.bar-row .name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; }
.bar-row .track { height: 10px; border-radius: 5px; background: var(--surface-3); overflow: hidden; }
.bar-row .track i { display: block; height: 100%; border-radius: 5px; background: var(--c); transition: width .4s ease; }
.bar-row .val { font-variant-numeric: tabular-nums; font-weight: 700; min-width: 58px; text-align: right; }
.bar-row .best { color: var(--good); font-size: 11px; margin-left: 4px; }

/* ---------- Info ---------- */
.info { max-width: 720px; margin: 0 auto; display: flex; flex-direction: column; gap: 12px; }
.info h2 { margin: 18px 0 4px; font-size: 20px; }
.info-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.info-card h3 { margin: 0 0 6px; }
.info-card p { color: var(--muted); margin: 0 0 14px; line-height: 1.5; }
.info-card.install { display: flex; align-items: center; gap: 16px; justify-content: space-between; }
.info-card.install p { margin: 0; }
.faq { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 0 16px; }
.faq summary { padding: 14px 0; font-weight: 650; cursor: pointer; }
.faq p { color: var(--muted); line-height: 1.55; margin: 0 0 16px; }
/* In attesa della traduzione (vedi lo script in testa a index.html) */
.i18n-wait .app { visibility: hidden; }
.fineprint { text-align: center; color: var(--muted); font-size: 12px; margin-top: 18px; }
.support-line { display: block; padding: 12px; text-align: center; color: var(--muted); font-size: 13px; text-decoration: none; }
.support-line:hover span, .support-line:focus-visible span { text-decoration: underline; }

/* ---------- Bottom nav ---------- */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(3, 1fr);
  padding: 6px 12px calc(6px + var(--safe-bottom));
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  backdrop-filter: saturate(1.6) blur(18px); -webkit-backdrop-filter: saturate(1.6) blur(18px);
  border-top: 1px solid var(--line);
}
.bottom-nav button { border: 0; background: none; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px; font-size: 11.5px; font-weight: 600; color: var(--muted); }
.bottom-nav svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.bottom-nav button[aria-selected="true"] { color: var(--accent); }

/* ---------- Sheet ---------- */
.sheet { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.5); animation: fadeIn .2s; }
@keyframes fadeIn { from { opacity: 0; } }
.sheet-panel {
  position: relative; width: 100%; max-width: 720px; max-height: min(88vh, 900px);
  background: var(--surface); border-radius: 24px 24px 0 0; display: flex; flex-direction: column;
  padding-bottom: var(--safe-bottom); animation: up .3s cubic-bezier(.2,.9,.3,1); box-shadow: 0 -10px 40px rgba(0,0,0,.4);
}
@keyframes up { from { transform: translateY(100%); } }
.sheet-grip { width: 40px; height: 5px; border-radius: 3px; background: var(--surface-3); margin: 8px auto 0; }
.sheet-head { flex: none; display: flex; align-items: center; justify-content: space-between; padding: 8px 16px 8px 20px; }
.sheet-head h2 { margin: 0; font-size: 20px; }
.search { flex: none; margin: 4px 16px 10px; display: flex; align-items: center; gap: 8px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 0 12px; }
.search svg { width: 18px; height: 18px; fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; }
.search input { flex: 1; border: 0; background: none; color: var(--text); font-size: 16px; padding: 12px 0; outline: none; }
.cat-chips { flex: none; display: flex; gap: 6px; overflow-x: auto; padding: 0 16px 10px; scrollbar-width: none; }
.cat-chips::-webkit-scrollbar { display: none; }
.cat-chips button { flex: none; border: 1px solid var(--line); background: var(--surface-2); border-radius: 999px; padding: 7px 12px; font-size: 13.5px; font-weight: 600; color: var(--muted); }
.cat-chips button[aria-pressed="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }
.picker-list { overflow-y: auto; padding: 0 8px 16px; flex: 1; overscroll-behavior: contain; }
.group-title { position: sticky; top: 0; background: var(--surface); padding: 12px 10px 6px; font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; z-index: 1; }
.bike-item { width: 100%; display: flex; align-items: center; gap: 12px; padding: 10px; border: 0; background: none; border-radius: 12px; text-align: left; }
.bike-item:hover, .bike-item:focus-visible { background: var(--surface-2); outline: none; }
.bike-item .thumb { width: 64px; height: 44px; flex: none; border-radius: 8px; background: var(--surface-2); overflow: hidden; }
.bike-item .thumb svg { width: 100%; height: 100%; }
.bike-item .t { flex: 1; min-width: 0; }
.bike-item .t b { display: block; font-size: 15px; }
.bike-item .t span { font-size: 12.5px; color: var(--muted); }
.bike-item .t .alt { display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 12px; }
.bike-item .seat { font-size: 13px; font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; }
.bike-item.added { opacity: .45; }
.no-results { text-align: center; color: var(--muted); padding: 30px 16px; }

.custom-form { overflow-y: auto; padding: 4px 16px 20px; display: flex; flex-direction: column; gap: 12px; }
.custom-form label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: var(--muted); }
.custom-form input, .custom-form select { font: inherit; font-size: 16px; color: var(--text); background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; outline: none; }
.custom-form input:focus, .custom-form select:focus { border-color: var(--accent); }
.custom-form fieldset { border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px 12px; margin: 0; }
.custom-form legend { font-size: 13px; font-weight: 700; padding: 0 6px; }
.custom-preview { border-radius: 14px; background: var(--c-stage); overflow: hidden; }
.custom-preview svg { width: 100%; height: auto; max-height: 30vh; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.u { font-weight: 500; opacity: .8; }

.toast {
  position: fixed; left: 50%; bottom: calc(92px + var(--safe-bottom)); translate: -50% 20px; opacity: 0; pointer-events: none;
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-weight: 600; font-size: 14px; z-index: 60;
  transition: opacity .2s, translate .2s;
}
.toast.show { opacity: 1; translate: -50% 0; }

/* ---------- Desktop ---------- */
@media (min-width: 900px) {
  .views { display: flex; gap: 4px; background: var(--surface); border: 1px solid var(--line); padding: 4px; border-radius: 12px; }
  .views button { border: 0; background: none; padding: 8px 16px; border-radius: 9px; font-weight: 600; color: var(--muted); }
  .views button[aria-selected="true"] { background: var(--surface-3); color: var(--text); }
  .bottom-nav { display: none; }
  main { padding-bottom: 40px; }
  .bike-bar { top: 60px; max-width: 1280px; margin: 0 auto; width: 100%; }
  .sim { grid-template-columns: minmax(0, 1fr) 360px; align-items: start; gap: 20px; }
  .metrics { grid-template-columns: repeat(3, 1fr); }
  .controls { position: sticky; top: 124px; }
  .compare { grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); align-items: start; }
  .sheet { align-items: center; }
  .sheet-panel { border-radius: 24px; max-height: 84vh; }
  .sheet-grip { display: none; }
  .toast { bottom: 32px; }
}
@media (hover: none) { .nav-arrow { display: none; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

@media (max-width: 520px) {
  .add-btn { width: 40px; height: 40px; padding: 0; justify-content: center; }
  .add-btn span { display: none; }
  .metric .m-value { font-size: 24px; }
}
.switch b { font-weight: inherit; }
.segmented.two { grid-template-columns: repeat(2, 1fr); }

/* ---------- Misura da foto ---------- */
.photo-open { width: 100%; }
.photo-panel { max-width: 900px; }
.photo-body { overflow-y: auto; padding: 4px 16px 20px; }
.photo-empty { display: flex; flex-direction: column; gap: 12px; }
.photo-empty p { margin: 0; color: var(--muted); line-height: 1.5; }
.photo-tips { margin: 0; padding-left: 20px; color: var(--muted); line-height: 1.6; font-size: 14px; }
.file-btn { text-align: center; cursor: pointer; }
.photo-work { display: flex; flex-direction: column; gap: 10px; }
.photo-steps { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.photo-steps::-webkit-scrollbar { display: none; }
.photo-steps button { flex: none; display: flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--surface-2); border-radius: 999px; padding: 5px 11px 5px 5px; font-size: 13px; font-weight: 600; color: var(--muted); }
.photo-steps button i { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; font-style: normal; font-size: 11px; background: var(--surface-3); color: var(--text); }
.photo-steps button.ok i { background: var(--c); color: #fff; }
.photo-steps button[aria-pressed="true"] { border-color: var(--c); color: var(--text); background: color-mix(in srgb, var(--c) 14%, var(--surface-2)); }
.photo-steps small { font-weight: 500; opacity: .7; }
.photo-hint { margin: 0; font-size: 14px; font-weight: 600; }
.photo-stage { position: relative; border-radius: 12px; overflow: hidden; background: #000; touch-action: none; user-select: none; -webkit-user-select: none; cursor: crosshair; }
.photo-stage img { display: block; width: 100%; height: auto; max-height: none; -webkit-user-drag: none; }
.photo-stage svg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.photo-stage canvas { position: absolute; width: 120px; height: 120px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 6px 20px rgba(0,0,0,.5); pointer-events: none; background: #000; }
.photo-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.photo-row label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: var(--muted); }
.photo-row input { font: inherit; font-size: 16px; color: var(--text); background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; width: 140px; outline: none; }
.photo-row input:focus { border-color: var(--accent); }
.photo-actions { display: flex; gap: 16px; padding-bottom: 10px; }
.file-link { cursor: pointer; font-size: 14px !important; color: var(--accent) !important; }
.photo-result:empty { display: none; }
.photo-values { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.photo-values div { background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; }
.photo-values span { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.photo-values b { font-size: 15px; font-variant-numeric: tabular-nums; }
.photo-values small { color: var(--muted); font-size: 12px; }
.photo-note { font-size: 13px; color: var(--muted); margin: 8px 0 0; }
.photo-warn { font-size: 13px; margin: 8px 0 0; padding: 8px 10px; border-radius: 10px; background: color-mix(in srgb, var(--mid) 16%, transparent); border: 1px solid color-mix(in srgb, var(--mid) 40%, transparent); }
@media (max-width: 520px) { .photo-values { grid-template-columns: 1fr; } }
.grid2 > * { min-width: 0; }
.custom-form input, .custom-form select { width: 100%; min-width: 0; }

/* ---------- Moto personalizzata: punti di accesso ---------- */
.empty-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.empty-actions .ghost-btn { padding: 13px 18px; font-size: 15px; border-radius: 14px; }
.mods-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.mods-divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; }
.mods-divider::before, .mods-divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.bike-item.create { border: 1px dashed var(--line); margin: 6px 0 4px; }
.bike-item.create .thumb { display: grid; place-items: center; font-size: 22px; color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, var(--surface-2)); }
.photo-ref-block { display: flex; flex-direction: column; gap: 8px; min-width: 240px; }
.photo-ref-label { font-size: 13px; font-weight: 600; color: var(--muted); }
.photo-ref-block .segmented { grid-column: auto; }
