/* ZeroCyl — dark instrument cluster. Warm ivory on near-black, one amber accent; red only for redline/warnings. */
:root {
  --bg: #08090a;
  --panel: #101113;
  --raise: #16181b;
  --line: #24272b;
  --fg: #ece8e1;
  --mute: #8d8a84;
  --faint: #4b4c4e;
  --accent: #e8892c;
  --accent-soft: rgba(232, 137, 44, .12);
  --red: #c4473a;
  --ok: #8fae8b;
  --f-num: "Spline Sans Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --f-latin: "Inter", -apple-system, "SF Pro Display", "Helvetica Neue", sans-serif;
  --f-body: "Inter", "Noto Sans TC", -apple-system, "PingFang TC", "Microsoft JhengHei", sans-serif;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--fg); }
body {
  font-family: var(--f-body); font-size: 15px; line-height: 1.55; font-weight: 400;
  -webkit-font-smoothing: antialiased; overflow: hidden; overscroll-behavior: none;
  font-feature-settings: "tnum" 1, "cv11" 1;
}
button { font: inherit; color: inherit; }
b { font-weight: 500; color: var(--fg); }

/* ───────── screens ───────── */
.screen {
  position: fixed; inset: 0; display: none; flex-direction: column;
  padding: calc(var(--safe-t) + 16px) max(20px, var(--safe-r)) calc(var(--safe-b) + 16px) max(20px, var(--safe-l));
  background: radial-gradient(120% 70% at 50% 0%, #121315 0%, var(--bg) 60%);
  overflow-y: auto; -webkit-overflow-scrolling: touch;
}
.screen[data-active] { display: flex; animation: fade .35s ease both; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* ───────── brand ───────── */
.wordmark {
  font-family: var(--f-latin); font-weight: 200; letter-spacing: .02em; margin: 0;
  font-size: 44px; line-height: 1;
}
.wordmark span { font-weight: 500; }
.wordmark.sm { font-size: 20px; }
.wordmark.xs { font-size: 15px; color: var(--mute); }
.wordmark.xs span { color: var(--fg); }
.platform { margin-left: auto; font-size: 11px; letter-spacing: .14em; color: var(--accent); }

/* ───────── safety notice (home, above the start button) ───────── */
.disclaimer {
  border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 20px 0;
}
.disclaimer h2 { font-size: 12px; font-weight: 500; letter-spacing: .2em; color: var(--accent); margin: 0 0 12px; }
.disclaimer .lead { margin: 0 0 14px; font-size: 15px; color: var(--mute); line-height: 1.7; }
.disclaimer ul { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 10px; }
.disclaimer li { font-size: 14px; color: var(--mute); padding-left: 16px; position: relative; }
.disclaimer li::before { content: ""; position: absolute; left: 0; top: .72em; width: 6px; height: 1px; background: var(--faint); }
.disclaimer.compact { padding: 14px 0; margin-bottom: 16px; }
.disclaimer.compact h2 { margin-bottom: 8px; }
.disclaimer.compact .lead { font-size: 14px; line-height: 1.6; margin-bottom: 8px; }
.disclaimer.compact ul { gap: 4px; }
.disclaimer.compact li { font-size: 12px; line-height: 1.55; }
.disclaimer .consent { margin: 10px 0 0; font-size: 12px; color: var(--faint); }
.disclaimer a, .sheet a { color: var(--mute); text-underline-offset: 3px; }
.app-meta { margin: 14px 0 0; text-align: center; font-size: 12px; color: var(--faint); }
.app-meta a { color: var(--mute); text-underline-offset: 3px; }
.update-note { margin: 0; padding: 10px 14px; border: 1px solid var(--accent); border-radius: 12px; background: var(--accent-soft); font-size: 13px; line-height: 1.6; color: var(--fg); }
.update-note[hidden] { display: none; }
.update-note a { color: var(--accent); margin-left: 4px; text-underline-offset: 3px; }

/* ───────── buttons ───────── */
.btn {
  appearance: none; border: 1px solid var(--line); background: transparent; border-radius: 999px;
  padding: 15px 22px; font-size: 15px; font-weight: 500; letter-spacing: .08em; cursor: pointer;
  transition: background .2s, border-color .2s, opacity .2s, color .2s; width: 100%;
}
.btn.primary { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.btn.primary:active { background: var(--accent); border-color: var(--accent); }
.btn.ghost { color: var(--mute); }
.btn.small { padding: 10px 16px; font-size: 13px; width: auto; }
.btn:disabled { opacity: .28; cursor: default; }
.btn.done { background: transparent; color: var(--ok); border-color: rgba(143, 174, 139, .4); }
:focus-visible { outline: 1px solid var(--accent); outline-offset: 3px; }

/* ───────── top bar & dock ───────── */
.topbar { display: flex; align-items: center; gap: 12px; min-height: 40px; }
.back { appearance: none; border: 0; background: none; font-size: 28px; line-height: 1; padding: 0 8px 4px 0; color: var(--mute); cursor: pointer; }
.dock { margin-top: auto; padding-top: 20px; max-width: 520px; width: 100%; align-self: center; }

/* ───────── setup ───────── */
.setup { max-width: 520px; width: 100%; align-self: center; display: flex; flex-direction: column; gap: 28px; padding-top: 18px; }
.label .count { font-family: var(--f-num); color: var(--faint); margin-left: 6px; letter-spacing: 0; }
.label { font-size: 11px; font-weight: 500; letter-spacing: .22em; color: var(--mute); text-transform: uppercase; margin: 0 0 12px; }
.engines { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.engine {
  appearance: none; text-align: left; cursor: pointer; border: 1px solid var(--line); background: var(--panel);
  border-radius: 14px; padding: 16px 16px 14px; display: flex; flex-direction: column; gap: 6px; transition: border-color .2s, background .2s;
}
.engine .code { font-family: var(--f-num); font-weight: 300; font-size: 26px; line-height: 1; letter-spacing: .02em; }
.engine .name { font-size: 13px; font-weight: 500; }
.engine em { font-style: normal; font-size: 12px; color: var(--mute); }
.engine .rev { font-family: var(--f-num); font-size: 11px; color: var(--faint); margin-top: 2px; }
.engine[aria-pressed="true"] { border-color: var(--accent); background: linear-gradient(180deg, var(--accent-soft), transparent 70%), var(--panel); }
.engine[aria-pressed="true"] .code { color: var(--accent); }

.modes { display: flex; flex-direction: column; gap: 10px; }
.mode {
  appearance: none; text-align: left; cursor: pointer; border: 1px solid var(--line); background: var(--panel);
  border-radius: 14px; padding: 14px 16px; display: flex; flex-direction: column; gap: 2px;
}
.mode b { font-weight: 500; font-size: 15px; }
.mode em { font-style: normal; font-size: 13px; color: var(--mute); }
.mode[aria-pressed="true"] { border-color: var(--accent); }

.field { margin-bottom: 20px; }
.row { display: flex; justify-content: space-between; align-items: baseline; font-size: 14px; }
.row output { font-family: var(--f-num); font-size: 13px; color: var(--accent); }
.hint { font-size: 12px; color: var(--mute); margin: 6px 0 0; }

input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; height: 28px; background: none; margin: 4px 0 0; }
input[type=range]::-webkit-slider-runnable-track { height: 2px; background: var(--line); border-radius: 1px; }
input[type=range]::-moz-range-track { height: 2px; background: var(--line); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 20px; height: 20px; border-radius: 50%; background: var(--fg); margin-top: -9px; border: 0; }
input[type=range]::-moz-range-thumb { width: 20px; height: 20px; border-radius: 50%; background: var(--fg); border: 0; }

/* ───────── sensor steps ───────── */
.steps { max-width: 520px; width: 100%; align-self: center; display: flex; flex-direction: column; gap: 14px; padding-top: 18px; }
.step { display: grid; grid-template-columns: 34px 1fr; gap: 6px; padding: 20px 18px; border: 1px solid var(--line); border-radius: 16px; background: var(--panel); transition: opacity .25s; }
.step[aria-disabled="true"] { opacity: .4; pointer-events: none; }
.step .num { font-family: var(--f-num); font-weight: 300; font-size: 13px; color: var(--accent); padding-top: 3px; }
.step h3 { margin: 0 0 6px; font-size: 16px; font-weight: 500; }
.step p { margin: 0 0 16px; font-size: 13.5px; color: var(--mute); }
.status-list { list-style: none; padding: 0; margin: 0 0 18px; display: flex; flex-direction: column; gap: 8px; font-size: 14px; }
.status-list li { display: flex; align-items: center; gap: 10px; }
.status-list i { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); flex: none; }
.status-list em { font-style: normal; margin-left: auto; font-size: 12px; color: var(--mute); }
.status-list li.ok i { background: var(--ok); }
.status-list li.warn i { background: var(--accent); }
.status-list li.bad i { background: var(--red); }

.notice { margin: 0 0 16px !important; padding: 12px 14px; border-radius: 10px; border: 1px solid rgba(232, 137, 44, .35); color: var(--fg) !important; font-size: 13px !important; }
.notice[hidden], .step[hidden], .field[hidden], .status-list li[hidden], .btn[hidden] { display: none; }
.cal { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.cal-ring svg { width: 44px; height: 44px; transform: rotate(-90deg); display: block; }
.cal-ring circle { fill: none; stroke: var(--line); stroke-width: 2; }
.cal-ring circle.p { stroke: var(--accent); stroke-dasharray: 106.8; stroke-dashoffset: 106.8; transition: stroke-dashoffset .1s linear; stroke-linecap: round; }
.cal-msg { margin: 0 !important; font-size: 13.5px; color: var(--fg) !important; }

/* ───────── dashboard ───────── */
#screen-dash { padding: 0; overflow: hidden; background: radial-gradient(90% 60% at 50% 45%, #111214 0%, var(--bg) 70%); }
.dash {
  position: relative; flex: 1; display: grid; min-height: 0;
  grid-template-rows: auto 1fr auto auto auto; grid-template-columns: minmax(0, 1fr);
  padding: calc(var(--safe-t) + 12px) max(16px, var(--safe-r)) calc(var(--safe-b) + 12px) max(16px, var(--safe-l));
  user-select: none; -webkit-user-select: none; touch-action: none;
}
.dash-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.chip { font-family: var(--f-body); font-size: 11px; letter-spacing: .08em; color: var(--mute); border: 1px solid var(--line); border-radius: 999px; padding: 3px 9px; display: inline-flex; align-items: center; gap: 6px; }
.chip[hidden] { display: none; }
.chip.dot::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: var(--faint); }
.chip.dot.ok::before { background: var(--ok); }
.chip.dot.warn::before { background: var(--accent); }
.chip.dot.bad::before { background: var(--red); }

.gauge { position: relative; min-height: 0; min-width: 0; display: grid; place-items: center; container-type: size; }
.dial { position: relative; width: min(92vw, 60vh); height: min(92vw, 60vh); }
@supports (container-type: size) {
  .dial { width: min(100cqw, 100cqh); height: auto; aspect-ratio: 1; }
}
#tach { position: absolute; inset: 0; width: 100%; height: 100%; display: block; font-family: var(--f-num); }
.gauge-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; pointer-events: none; }
.speed { font-family: var(--f-num); font-weight: 300; font-size: clamp(56px, 22cqmin, 200px); line-height: .9; letter-spacing: -.04em; font-variant-numeric: tabular-nums; }
.unit { font-family: var(--f-latin); font-size: clamp(11px, 2.4vmin, 15px); letter-spacing: .3em; color: var(--mute); margin-top: 1.2vmin; text-transform: uppercase; }
.gauge-foot { position: absolute; left: 50%; bottom: 3%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 4px; pointer-events: none; }
.gear {
  font-family: var(--f-num); font-weight: 400; font-size: clamp(22px, 8cqmin, 64px); line-height: 1;
  min-width: 1.6em; text-align: center; padding: .14em .2em; border: 1px solid var(--line); border-radius: .18em; color: var(--accent);
}
.rpm { font-family: var(--f-num); font-size: clamp(11px, 2.6vmin, 15px); color: var(--mute); letter-spacing: .12em; }
.rpm span { color: var(--fg); font-variant-numeric: tabular-nums; display: inline-block; min-width: 4ch; text-align: right; }

/* Hold-to-exit — deliberately requires a long press so a bump never ends the session. */
.exit {
  appearance: none; border: 0; background: none; color: var(--faint); font-size: 11px; letter-spacing: .2em;
  justify-self: center; display: inline-flex; align-items: center; gap: 8px; padding: 10px 14px; cursor: pointer; touch-action: none;
}
.exit .ring { width: 14px; height: 14px; border-radius: 50%; border: 1px solid var(--faint); background: conic-gradient(var(--fg) calc(var(--p, 0) * 1turn), transparent 0); }

/* simulator controls */
.sim { min-width: 0; display: flex; flex-direction: column; gap: 14px; max-width: 520px; width: 100%; justify-self: center; padding-bottom: 6px; touch-action: auto; }
.sim[hidden] { display: none; }
.seg { display: grid; grid-template-columns: 1fr 1fr; background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 3px; gap: 3px; }
.seg button { appearance: none; border: 0; border-radius: 999px; padding: 8px 6px; background: transparent; color: var(--mute); font-size: 13px; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--raise); color: var(--fg); }
.pedals { display: flex; gap: 14px; justify-content: center; align-items: flex-end; }
.pedals[hidden], .speed-input[hidden] { display: none; }
.pedal {
  position: relative; overflow: hidden; border-radius: 14px; border: 1px solid var(--line); background: var(--panel);
  touch-action: none; user-select: none; -webkit-user-select: none; cursor: pointer;
  background-image: repeating-linear-gradient(0deg, transparent 0 10px, rgba(255, 255, 255, .025) 10px 11px);
}
.pedal.gas { width: 110px; height: 150px; }
.pedal.brake { width: 140px; height: 96px; }
.pedal .fill { position: absolute; inset: 0; transform-origin: bottom; transform: scaleY(0); background: linear-gradient(0deg, var(--accent-soft), rgba(232, 137, 44, .3)); border-top: 1px solid var(--accent); }
.pedal.brake .fill { background: linear-gradient(0deg, rgba(196, 71, 58, .1), rgba(196, 71, 58, .3)); border-top-color: var(--red); }
.pedal span { position: absolute; inset: auto 0 12px; text-align: center; font-size: 12px; letter-spacing: .3em; color: var(--mute); }
.pedal.pressed span { color: var(--fg); }
.engine-switch { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; -webkit-mask-image: linear-gradient(90deg, #000 85%, transparent); mask-image: linear-gradient(90deg, #000 85%, transparent); }
.engine-switch::-webkit-scrollbar { display: none; }
.engine-switch button { flex: none; appearance: none; border: 1px solid var(--line); background: transparent; border-radius: 10px; padding: 8px 12px; font-family: var(--f-num); font-size: 13px; color: var(--mute); cursor: pointer; }
.engine-switch button[aria-pressed="true"] { color: var(--accent); border-color: var(--accent); }

/* Landscape on a phone mount: gauge left, controls right */
@media (orientation: landscape) and (max-height: 560px) {
  .dash { grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: auto 1fr auto auto; }
  .dash-top { grid-column: 1 / -1; }
  .gauge { grid-column: 1; grid-row: 2 / 4; }
  .sim { grid-column: 2; grid-row: 2; width: 300px; align-self: center; }
  .exit { grid-column: 2; grid-row: 3; }
  .dash.no-sim .gauge { grid-column: 1 / -1; }
}

/* toast */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--safe-b) + 24px); transform: translate(-50%, 20px); opacity: 0;
  background: var(--raise); border: 1px solid var(--line); border-radius: 999px; padding: 10px 18px; font-size: 13px;
  transition: opacity .25s, transform .25s; pointer-events: none; max-width: calc(100% - 40px); text-align: center; z-index: 10;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) { .screen[data-active] { animation: none; } }

/* Tesla in-car browser: big landscape screen, bigger touch targets in settings */
[data-platform="tesla"] body { font-size: 17px; }
[data-platform="tesla"] .setup, [data-platform="tesla"] .steps, [data-platform="tesla"] .dock { max-width: 760px; }
[data-platform="tesla"] .btn { padding: 18px 24px; font-size: 17px; }

/* ───────── views: engine ⇄ radar (one tap, no restart) ───────── */
[data-view="engine"] [data-only="radar"],
[data-view="radar"] [data-only="engine"] { display: none !important; }

.mode-seg { background: var(--panel); }
.mode-seg.big button { padding: 13px 8px; font-size: 15px; }
.mode-seg button[aria-pressed="true"] { background: var(--raise); color: var(--accent); }
.mode-hint { margin: -16px 0 0; }
.dash-top .mode-seg { width: 132px; flex: none; }
.dash-top .mode-seg button { padding: 6px 4px; font-size: 12px; }
.dash.is-sim .dash-top .mode-seg { display: none; }
.dash-top .wordmark.xs { flex: none; }
.dash-top .chips { flex: 1; min-width: 0; }

.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 14px; cursor: pointer; }
.switch input { appearance: none; -webkit-appearance: none; width: 42px; height: 24px; border-radius: 12px; background: var(--line); position: relative; flex: none; cursor: pointer; transition: background .2s; margin: 0; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: var(--mute); transition: transform .2s, background .2s; }
.switch input:checked { background: var(--accent-soft); }
.switch input:checked::after { transform: translateX(18px); background: var(--accent); }
.step h3 .opt { font-size: 12px; font-weight: 400; color: var(--mute); margin-left: 8px; }
.dock .btn + .btn { margin-top: 10px; }
.btn[data-only] { display: block; }

/* camera pill over the engine view */
.cam-pill {
  position: absolute; top: 2%; left: 50%; transform: translateX(-50%); display: inline-flex; align-items: center; gap: 8px;
  padding: 7px 14px; border-radius: 999px; border: 1px solid var(--accent); background: rgba(8, 9, 10, .85);
  font-family: var(--f-num); font-size: 14px; color: var(--fg); pointer-events: none; white-space: nowrap;
}
.cam-pill[hidden] { display: none; }
.cam-pill svg { width: 16px; height: 16px; fill: none; stroke: var(--accent); stroke-width: 1.6; }
.cam-pill .sep { color: var(--faint); }
.cam-pill.over { border-color: var(--red); }
.cam-pill.over svg { stroke: var(--red); }
.speed.over { color: var(--red); }

/* radar view */
.radar { min-height: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5vmin; }
.radar-speed { display: flex; flex-direction: column; align-items: center; }
.radar .speed { font-size: clamp(96px, 34vmin, 260px); }
.radar-next { display: flex; align-items: center; gap: 20px; width: min(100%, 460px); padding: 18px 20px; border: 1px solid var(--line); border-radius: 18px; background: var(--panel); opacity: .55; transition: opacity .3s, border-color .3s; }
.radar-next.active { opacity: 1; border-color: var(--accent); }
.limit-sign {
  flex: none; width: 76px; height: 76px; border-radius: 50%; border: 7px solid var(--red); background: var(--fg); color: var(--bg);
  display: grid; place-items: center; font-family: var(--f-num); font-weight: 500; font-size: 28px; letter-spacing: -.03em;
}
.radar-next:not(.active) .limit-sign { border-color: var(--line); background: transparent; color: var(--faint); }
.radar-info { flex: 1; min-width: 0; }
.r-dist { font-family: var(--f-num); font-weight: 300; font-size: 34px; line-height: 1.1; }
.r-label { font-size: 13px; color: var(--mute); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.r-bar { height: 3px; background: var(--line); border-radius: 2px; margin-top: 10px; overflow: hidden; }
.r-bar b { display: block; height: 100%; background: var(--accent); transform-origin: left; transform: scaleX(0); transition: transform .9s linear; }
.r-source { font-size: 11px; color: var(--faint); margin: 0; text-align: center; }
.radar-next.report.active { border-color: var(--red); }
.radar-next.report .limit-sign { font-size: 0; }
.radar-next.report .limit-sign::after { content: "移"; font-size: 30px; font-family: var(--f-body); }
.radar-next.hotspot .limit-sign { font-size: 0; border-color: var(--accent); }
.radar-next.hotspot .limit-sign::after { content: "常"; font-size: 30px; font-family: var(--f-body); }

/* one-tap mobile speed-trap report: big target, readable at a glance */
.report-btn {
  appearance: none; cursor: pointer; width: min(100%, 460px); min-height: 64px; padding: 12px 20px;
  border: 1px solid var(--line); border-radius: 18px; background: var(--raise); color: var(--fg);
  display: flex; align-items: center; justify-content: center; gap: 10px;
  font-size: 17px; font-weight: 500; letter-spacing: .08em; transition: background .2s, border-color .2s, opacity .2s;
  touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
.report-btn .sub { font-size: 13px; font-weight: 400; color: var(--mute); letter-spacing: .04em; }
.report-btn .sub:empty { display: none; }
.report-btn:active { border-color: var(--accent); }
.report-btn[data-state="busy"] { opacity: .6; }
.report-btn[data-state="done"] { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.report-btn[data-state="bad"] { border-color: var(--red); color: var(--red); }
.report-btn[hidden] { display: none; }

/* phase 2: 還在／不在了 after passing a reported spot (auto-hides after 10 s) */
.vote-bar { position: relative; overflow: hidden; width: min(100%, 460px); padding: 12px 14px 14px; border: 1px solid var(--accent); border-radius: 18px; background: var(--raise); }
.vote-bar[hidden] { display: none; }
.vote-q { margin: 0 0 10px; text-align: center; font-size: 14px; color: var(--fg); }
.vote-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.vote-btns button {
  appearance: none; cursor: pointer; min-height: 56px; border-radius: 14px; border: 1px solid var(--line);
  background: var(--panel); color: var(--fg); font-size: 17px; font-weight: 500; letter-spacing: .08em;
  touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
.vote-btns button:disabled { opacity: .5; }
#vote-here { border-color: var(--accent); color: var(--accent); }
.vote-timer { position: absolute; left: 0; bottom: 0; height: 2px; width: 100%; background: var(--accent); transform-origin: left; }
.vote-bar.counting .vote-timer { transform: scaleX(0); transition: transform var(--vote-ms, 10s) linear; }

/* ad slot — static, no motion; dimmed on the driving screen */
.ad-slot { margin-top: 12px; }
.ad-slot[hidden] { display: none; }
.ad-house { display: flex; align-items: center; gap: 12px; min-height: 50px; padding: 8px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); }
.ad-mark { font-family: var(--f-latin); font-weight: 300; font-size: 14px; white-space: nowrap; }
.ad-mark b { font-weight: 500; }
.ad-copy { flex: 1; font-size: 12px; color: var(--mute); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ad-cta { appearance: none; border: 1px solid var(--line); background: transparent; border-radius: 999px; padding: 6px 12px; font-size: 12px; color: var(--fg); cursor: pointer; }
.dash-ad { margin-top: 4px; opacity: .6; touch-action: auto; }

@media (orientation: landscape) and (max-height: 560px) {
  .radar { grid-column: 1 / -1; grid-row: 2; flex-flow: row wrap; align-content: center; gap: 2vh 6vw; }
  .r-source { flex-basis: 100%; }
  .dash-ad { grid-column: 1 / -1; grid-row: 4; }
  .dash.no-sim .exit { grid-column: 1 / -1; grid-row: 3; }
}

/* average-speed zone card */
.radar-zone { width: min(100%, 460px); padding: 16px 20px 14px; border: 1px solid var(--accent); border-radius: 18px; background: var(--panel); }
.radar-zone[hidden] { display: none; }
.radar-zone.over { border-color: var(--red); }
.z-head { display: flex; justify-content: space-between; align-items: baseline; font-size: 13px; color: var(--mute); }
.z-tag { color: var(--accent); letter-spacing: .2em; font-size: 12px; }
.z-limit b { font-family: var(--f-num); font-weight: 500; color: var(--fg); font-size: 16px; }
.z-avg { display: flex; align-items: baseline; gap: 10px; margin-top: 4px; }
.z-avg span { font-family: var(--f-num); font-weight: 300; font-size: 44px; line-height: 1.05; }
.z-avg small { font-size: 12px; color: var(--mute); letter-spacing: .1em; }
.radar-zone.over .z-avg span { color: var(--red); }
.z-meta { font-family: var(--f-num); font-size: 12px; color: var(--mute); margin-top: 6px; text-align: right; }

/* ───────── settings sheet ───────── */
.icon-btn { appearance: none; border: 1px solid var(--line); background: transparent; width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; cursor: pointer; flex: none; color: var(--mute); padding: 0; }
.icon-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; }
.icon-btn:active { color: var(--accent); border-color: var(--accent); }
.topbar .icon-btn { margin-left: auto; }
.topbar .platform:not(:empty) { margin-left: auto; }
.topbar .platform:not(:empty) + .icon-btn { margin-left: 12px; }
.topbar .platform:empty { display: none; }

.sheet-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, .55); z-index: 20; opacity: 0; transition: opacity .2s; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 21; max-height: 86vh; display: flex; flex-direction: column;
  background: var(--panel); border-top: 1px solid var(--line); border-radius: 20px 20px 0 0;
  padding: 0 max(20px, var(--safe-r)) calc(var(--safe-b) + 12px) max(20px, var(--safe-l));
  transform: translateY(100%); transition: transform .22s ease;
}
.sheet-backdrop[hidden], .sheet[hidden] { display: none; }
.sheet-open .sheet { transform: none; }
.sheet-open .sheet-backdrop { opacity: 1; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 0 12px; border-bottom: 1px solid var(--line); }
.sheet-head h2 { margin: 0; font-size: 16px; font-weight: 500; }
.sheet-close { appearance: none; border: 0; background: none; color: var(--accent); font-size: 15px; cursor: pointer; padding: 6px 0 6px 12px; }
.sheet-body { overflow-y: auto; padding-top: 18px; -webkit-overflow-scrolling: touch; }
.sheet .drive-warn { margin: 12px 0 0 !important; }
.sheet-engines { margin-top: 10px; -webkit-mask-image: none; mask-image: none; flex-wrap: wrap; }
.saved-hint { text-align: center; margin: 4px 0 8px; }
/* Landscape / big screens: side panel instead of bottom sheet */
@media (min-width: 700px), (orientation: landscape) and (max-height: 560px) {
  .sheet { left: auto; top: 0; width: min(420px, 90vw); max-height: none; border-radius: 0; border-top: 0; border-left: 1px solid var(--line);
    padding-top: var(--safe-t); transform: translateX(100%); }
}
