/* Layout: una colonna stretta da telefono; scheda risultato in alto, scelte sotto come lista iOS, fogli dal basso per le scelte lunghe. */
:root {
  --bg: #f5f5f7; --surface: #ffffff; --surface-2: #f0f0f3; --fg: #1d1d1f; --muted: #6e6e73;
  --line: #d9d9de; --accent: #0071e3; --accent-soft: #e3effc; --on-accent: #ffffff;
  --band: #b9d7f7; --band-wide: #e2eefb; --scrim: rgba(0, 0, 0, .32);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --r-lg: 22px; --r-md: 14px;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --bg: #000000; --surface: #1c1c1e; --surface-2: #2c2c2e; --fg: #f5f5f7; --muted: #98989f;
  --line: #38383a; --accent: #2997ff; --accent-soft: #10294a; --on-accent: #ffffff;
  --band: #1f4f86; --band-wide: #142c49; --scrim: rgba(0, 0, 0, .6); color-scheme: dark } }
:root[data-theme="dark"] {
  --bg: #000000; --surface: #1c1c1e; --surface-2: #2c2c2e; --fg: #f5f5f7; --muted: #98989f;
  --line: #38383a; --accent: #2997ff; --accent-soft: #10294a; --on-accent: #ffffff;
  --band: #1f4f86; --band-wide: #142c49; --scrim: rgba(0, 0, 0, .6); color-scheme: dark }

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--fg); font-family: var(--font); font-size: 17px; line-height: 1.4; -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.app { max-width: 460px; margin: 0 auto; padding-block: 28px 56px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); display: flex; flex-direction: column; gap: 22px; }
.masthead h1 { margin: 0; font-size: 34px; font-weight: 700; letter-spacing: -.02em; line-height: 1.1; text-wrap: balance; }
.masthead p { margin: 6px 0 0; color: var(--muted); }

/* Risultato */
.result { background: var(--surface); border-radius: var(--r-lg); padding: 20px; display: flex; flex-direction: column; gap: 16px; }
.car-line { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; font-size: 15px; color: var(--muted); }
.car-line strong { color: var(--fg); font-weight: 600; }
.tag { font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--accent); background: var(--accent-soft); border-radius: 999px; padding: 2px 9px; }
.segmented { display: grid; grid-template-columns: repeat(3, 1fr); background: var(--surface-2); border-radius: 10px; padding: 2px; }
.segmented button { border: 0; background: none; border-radius: 8px; padding: 7px 2px; font-size: 13px; font-weight: 500; min-width: 0; }
.segmented button[aria-pressed="true"] { background: var(--surface); box-shadow: 0 1px 3px rgba(0, 0, 0, .14); font-weight: 600; }
#outcome { display: flex; flex-direction: column; gap: 16px; }
.figure { display: flex; flex-direction: column; gap: 2px; }
.figure .eyebrow { font-size: 14px; color: var(--muted); }
.figure .range { font-size: clamp(34px, 11vw, 46px); font-weight: 700; letter-spacing: -.03em; line-height: 1.05; font-variant-numeric: tabular-nums; }
.figure .mid { font-size: 15px; color: var(--muted); font-variant-numeric: tabular-nums; }
.scale { display: flex; flex-direction: column; gap: 6px; }
.scale-track { position: relative; height: 10px; border-radius: 5px; background: var(--band-wide); }
.scale-track i { position: absolute; top: 0; bottom: 0; border-radius: 5px; background: var(--band); }
.scale-track b { position: absolute; top: -4px; width: 4px; height: 18px; border-radius: 2px; background: var(--accent); transform: translateX(-2px); }
.scale-ends { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.notice { background: var(--surface-2); border-radius: var(--r-md); padding: 14px; font-size: 15px; }
.notice h3 { margin: 0 0 4px; font-size: 17px; }
.notice p { margin: 0; color: var(--muted); }
.basis { font-size: 13px; color: var(--muted); margin: 0; }
.chart svg { display: block; width: 100%; height: auto; }
.chart text { font-family: var(--font); font-size: 11px; fill: var(--muted); }
.chart figcaption { font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.chart { margin: 0; }

/* Scelte */
.group { background: var(--surface); border-radius: var(--r-lg); overflow: hidden; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; min-height: 52px; padding: 10px 16px; border: 0; background: none; text-align: left; }
.row + .row, .row + .km, .km + .row { border-top: 1px solid var(--line); }
.row .label { color: var(--fg); flex: none; }
.row .value { color: var(--muted); min-width: 0; text-align: right; overflow-wrap: anywhere; display: flex; align-items: center; gap: 6px; }
.row .value::after { content: "›"; font-size: 20px; line-height: 1; color: var(--line); }
.row.pair { gap: 8px; }
.row.pair .selects { display: flex; gap: 8px; }
.row select { border: 0; background: var(--surface-2); border-radius: 8px; padding: 6px 8px; }
.km { padding: 12px 16px 16px; display: flex; flex-direction: column; gap: 10px; }
.km-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.km-head input { width: 8.5em; border: 0; background: var(--surface-2); border-radius: 8px; padding: 6px 10px; text-align: right; font-variant-numeric: tabular-nums; }
.km input[type="range"] { width: 100%; accent-color: var(--accent); margin: 0; }

/* Metodo */
.method { font-size: 14px; color: var(--muted); }
.method summary { cursor: pointer; color: var(--accent); font-size: 15px; padding: 4px 0; }
.method dl { margin: 10px 0 0; display: grid; grid-template-columns: 1fr auto; gap: 6px 16px; }
.method dt { min-width: 0; } .method dd { margin: 0; color: var(--fg); font-variant-numeric: tabular-nums; text-align: right; }
.method p { margin: 10px 0 0; max-width: 65ch; }

/* Foglio di scelta */
.sheet-wrap { position: fixed; inset: 0; z-index: 20; display: flex; align-items: flex-end; justify-content: center; background: var(--scrim); }
.sheet { width: 100%; max-width: 460px; max-height: 86%; background: var(--surface); border-radius: var(--r-lg) var(--r-lg) 0 0; display: flex; flex-direction: column; padding-bottom: env(safe-area-inset-bottom, 0px); animation: rise .28s cubic-bezier(.2, .8, .2, 1); }
@keyframes rise { from { transform: translateY(40px); opacity: .4; } }
@media (prefers-reduced-motion: reduce) { .sheet { animation: none; } }
.sheet header { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 8px; }
.sheet header h2 { margin: 0; font-size: 20px; }
.sheet header button { border: 0; background: var(--surface-2); border-radius: 999px; width: 30px; height: 30px; font-size: 16px; line-height: 1; }
.sheet .search { margin: 0 16px 8px; border: 0; background: var(--surface-2); border-radius: 10px; padding: 9px 12px; }
.sheet ul { list-style: none; margin: 0; padding: 0 0 8px; overflow-y: auto; }
.sheet li button { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; width: 100%; border: 0; background: none; text-align: left; padding: 12px 16px; border-top: 1px solid var(--line); }
.sheet li button[aria-current="true"] { color: var(--accent); font-weight: 600; }
.sheet li small { color: var(--muted); font-size: 13px; flex: none; }
.sheet .empty { padding: 20px 16px; color: var(--muted); }
