:root {
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #f7f9fc;
  --surface-hover: #eaf3ff;
  --line: #e3e8ef;
  --line-strong: #d3dce7;
  --text: #182230;
  --text-strong: #182230;
  --muted: #738094;
  --muted-dark: #59677b;
  --accent: #147efb;
  --accent-strong: #147efb;
  --accent-soft: #eaf3ff;
  --danger: #d94c57;
  --danger-soft: #fff0f0;
  --shadow: 0 2px 8px #26344a10, 0 12px 30px #26344a08;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  --radius: 13px;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #11151b;
  --surface: #191f28;
  --surface-2: #202833;
  --surface-hover: #1c324a;
  --line: #303a48;
  --line-strong: #465365;
  --text: #eef3fa;
  --text-strong: #eef3fa;
  --muted: #9ba8ba;
  --muted-dark: #c0ccdc;
  --accent: #59a7ff;
  --accent-strong: #59a7ff;
  --accent-soft: #1c324a;
  --danger: #ff737d;
  --danger-soft: #3a2226;
  --shadow: 0 2px 8px #0002, 0 12px 30px #0001;
}

*, *::before, *::after { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body { min-width: 320px; min-height: 100vh; margin: 0; background: var(--bg); color: var(--text); transition: background .2s, color .2s; }
button, select { font: inherit; }
button { color: inherit; }
.app-shell { width: min(1040px, 100% - 64px); margin: 0 auto; }
.topbar { min-height: 72px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.brand { display: inline-flex; gap: 9px; align-items: center; text-decoration: none; color: var(--text-strong); }
.brand-mark { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 9px; background: var(--accent-soft); color: var(--accent); }
.brand-mark svg { width: 25px; height: 25px; }
.brand-name { font-size: 19px; font-weight: 750; letter-spacing: -.85px; }
.brand-period { color: var(--accent); }
.topbar-actions { display: flex; gap: 20px; align-items: center; }
.privacy-badge, .eyebrow, .ride-state, .live-pill, .lean-side, .stat-label, .stat-note, .trip-label, .gps-indicator, .disclaimer, .app-footer, .ride-date, .ride-location { font-family: var(--mono); }
.privacy-badge { display: inline-flex; gap: 8px; align-items: center; color: var(--muted-dark); font-size: 9px; letter-spacing: .1em; }
.privacy-dot, .heading-indicator, .state-dot, .gps-dot, .foot-dot { width: 7px; height: 7px; display: inline-block; flex: 0 0 auto; border-radius: 50%; background: var(--accent); }
.theme-picker select { max-width: 112px; padding: 8px 24px 8px 10px; border: 1px solid var(--line); border-radius: 7px; background-color: var(--surface); color: var(--muted-dark); font-size: 11px; cursor: pointer; }
main { padding-top: 36px; }
.ride-heading { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 24px; }
.eyebrow { margin: 0; color: var(--muted); font-size: 9px; font-weight: 500; letter-spacing: .15em; }
.ride-heading .eyebrow { display: flex; gap: 9px; align-items: center; }
.heading-indicator { width: 6px; height: 6px; }
h1 { margin: 11px 0 5px; color: var(--text-strong); font-size: clamp(34px, 5vw, 43px); font-weight: 650; line-height: 1.08; letter-spacing: -2px; }
h1 span { color: var(--accent); }
.intro { margin: 0; color: var(--muted-dark); font-size: 12px; }
.ride-state { display: inline-flex; gap: 8px; align-items: center; margin-bottom: 5px; color: var(--muted); font-size: 9px; letter-spacing: .11em; }
.ride-state.recording .state-dot, .ride-state.recording .live-pill > span { background: var(--danger); box-shadow: 0 0 0 4px color-mix(in srgb, var(--danger) 14%, transparent); animation: pulse 1.8s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .6; } }
.dashboard { display: grid; grid-template-columns: 1.25fr 1fr; gap: 15px; }
.card { min-width: 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.lean-card { min-height: 314px; padding: 20px 24px 15px; }
.card-heading { display: flex; justify-content: space-between; align-items: center; }
.card-caption { margin: 5px 0 0; color: var(--muted); font-size: 11px; }
.live-pill { display: inline-flex; gap: 7px; align-items: center; padding: 6px 9px; border: 1px solid var(--line); border-radius: 20px; color: var(--muted-dark); font-size: 8px; letter-spacing: .08em; }
.live-pill > span { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); }
.live-pill.is-live { border-color: color-mix(in srgb, var(--accent) 30%, var(--line)); color: var(--accent); }
.live-pill.is-live > span { background: var(--accent); }
.lean-display { display: flex; justify-content: center; align-items: baseline; margin: 22px 0 0; color: var(--accent); font-family: var(--mono); line-height: .94; }
.lean-sign { width: .35em; text-align: center; font-size: clamp(47px, 8vw, 69px); font-weight: 400; }
.lean-number { font-size: clamp(76px, 12vw, 105px); font-weight: 400; letter-spacing: -.105em; }
.lean-unit { margin-left: 9px; color: var(--muted); font-size: 29px; }
.lean-side { min-height: 13px; margin-top: 7px; color: var(--muted); text-align: center; font-size: 8px; letter-spacing: .15em; }
.lean-meter { display: grid; grid-template-columns: 12px 1fr 12px; gap: 9px; align-items: center; margin-top: 22px; }
.meter-label { color: var(--muted); font-family: var(--mono); font-size: 9px; }
.meter-label:first-child { color: var(--danger); }
.meter-label:last-child { color: var(--accent); text-align: right; }
.meter-track { position: relative; height: 5px; overflow: visible; border-radius: 5px; background: linear-gradient(90deg, var(--danger-soft) 0%, var(--line-strong) 48%, var(--line-strong) 52%, var(--accent-soft) 100%); }
.meter-center { position: absolute; top: -3px; left: 50%; width: 1px; height: 11px; background: var(--muted); }
.meter-needle { position: absolute; top: -4px; left: 50%; width: 12px; height: 12px; border: 2px solid var(--surface); border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 1.5px var(--accent); transform: translateX(-50%); transition: left .18s ease-out; }
.lean-scale { display: flex; justify-content: space-between; margin: 6px 21px 0; color: var(--muted); font-family: var(--mono); font-size: 8px; }
.card-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; min-height: 36px; margin-top: 9px; padding-top: 10px; border-top: 1px solid var(--line); color: var(--muted); font-size: 10px; }
.card-foot > span { display: flex; gap: 7px; align-items: center; }
.foot-dot { width: 6px; height: 6px; background: var(--muted); }
.foot-dot.is-ready { background: var(--accent); }
.text-button { padding: 6px 0 6px 8px; border: 0; background: none; color: var(--accent); font-size: 10px; font-weight: 600; cursor: pointer; }
.text-button:disabled { color: var(--muted); cursor: default; }
.side-stack { display: grid; grid-template-rows: 1fr auto; gap: 15px; }
.stats-card { min-height: 182px; padding: 20px 22px 16px; }
.stats-icon { width: 28px; height: 28px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 8px; color: var(--muted-dark); font-size: 15px; }
.max-stats { display: grid; grid-template-columns: 1fr 1px 1fr; align-items: center; margin-top: 23px; }
.max-stat { display: grid; gap: 7px; }
.max-left { padding-left: 9px; }
.max-right { padding-left: 22px; }
.stat-label { color: var(--muted); font-size: 9px; letter-spacing: .13em; }
.max-left .stat-label { color: var(--danger); }
.max-right .stat-label { color: var(--accent); }
.max-stat > div { display: flex; gap: 5px; align-items: baseline; }
.stat-number { color: var(--text-strong); font-family: var(--mono); font-size: 42px; letter-spacing: -3px; }
.stat-degree { color: var(--muted); font-family: var(--mono); font-size: 16px; }
.stat-divider, .trip-divider { width: 1px; height: 37px; background: var(--line); }
.stat-note { margin: 7px 0 0; color: var(--muted); font-size: 8px; }
.trip-card { display: grid; grid-template-columns: 1fr 1px 1fr 1px 1fr; align-items: center; min-height: 93px; padding: 16px 15px; }
.trip-cell { display: grid; gap: 9px; justify-items: center; }
.trip-label { color: var(--muted); font-size: 8px; letter-spacing: .1em; }
.trip-value { color: var(--text-strong); font-family: var(--mono); font-size: 16px; letter-spacing: -.5px; }
.trip-unit { margin-left: 4px; color: var(--muted); font-size: 9px; }
.controls-row { display: flex; align-items: center; gap: 18px; margin-top: 17px; }
.record-button { min-height: 47px; display: inline-flex; align-items: center; justify-content: center; gap: 11px; padding: 0 17px; border: 0; border-radius: 8px; background: var(--accent-strong); color: #fff; font-size: 12px; font-weight: 600; cursor: pointer; transition: transform .15s, background .15s; }
.record-button:hover { background: var(--accent); transform: translateY(-1px); }
.record-button:focus-visible, select:focus-visible, .text-button:focus-visible, .ride-action:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 38%, transparent); outline-offset: 3px; }
.record-button.is-recording { background: var(--danger); }
.record-button.is-recording:hover { background: color-mix(in srgb, var(--danger) 88%, var(--text)); }
.record-icon { width: 10px; height: 10px; border: 1.5px solid currentColor; border-radius: 50%; }
.record-button.is-recording .record-icon { border-radius: 3px; background: currentColor; }
.record-shortcut { margin-left: 12px; opacity: .75; font-size: 15px; }
.control-hint { max-width: 385px; color: var(--muted); font-size: 10px; line-height: 1.5; }
.gps-indicator { display: inline-flex; gap: 7px; align-items: center; margin-left: auto; color: var(--muted); font-size: 8px; letter-spacing: .09em; white-space: nowrap; }
.gps-dot { width: 6px; height: 6px; background: var(--muted); }
.gps-dot.is-ready { background: var(--accent); }
.gps-dot.is-searching { background: #daa94b; animation: pulse 1.5s ease-in-out infinite; }
.lower-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; margin-top: 22px; }
.how-card, .history-card { min-height: 270px; padding: 20px 21px 15px; }
.section-heading { display: flex; justify-content: space-between; align-items: center; }
.section-heading h2 { margin: 6px 0 0; color: var(--text-strong); font-size: 16px; font-weight: 600; letter-spacing: -.4px; }
.lock-icon { display: grid; place-items: center; width: 29px; height: 29px; border-radius: 8px; background: var(--accent-soft); color: var(--accent); font-size: 18px; }
.feature-list { display: grid; gap: 15px; margin-top: 19px; }
.feature { display: flex; gap: 11px; align-items: flex-start; }
.feature-icon { width: 24px; height: 24px; display: grid; flex: 0 0 auto; place-items: center; border-radius: 7px; background: var(--surface-2); color: var(--accent); font-size: 14px; }
.feature strong { color: var(--text); font-size: 10px; font-weight: 600; }
.feature p { margin: 3px 0 0; color: var(--muted); font-size: 9px; line-height: 1.5; }
.disclaimer { margin: 15px 0 0; color: var(--muted); font-size: 8px; line-height: 1.6; }
.history-heading { margin-bottom: 14px; }
.ride-count { display: inline-grid; min-width: 20px; height: 20px; place-items: center; margin-left: 4px; padding: 0 5px; border-radius: 10px; background: var(--surface-2); color: var(--muted); font-family: var(--mono); font-size: 9px; vertical-align: 1px; }
.clear-button { color: var(--muted-dark); }
.ride-list { display: grid; gap: 8px; max-height: 202px; overflow-y: auto; }
.empty-state { display: grid; justify-items: center; align-content: center; min-height: 166px; padding: 14px; border: 1px dashed var(--line-strong); border-radius: 9px; text-align: center; }
.empty-icon { display: grid; width: 31px; height: 31px; place-items: center; margin-bottom: 7px; border-radius: 50%; background: var(--surface-2); color: var(--muted); font-size: 17px; }
.empty-state strong { color: var(--text); font-size: 10px; font-weight: 600; }
.empty-state p { max-width: 220px; margin: 5px 0 0; color: var(--muted); font-size: 9px; line-height: 1.5; }
.ride-item { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; padding: 10px 11px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); }
.ride-item-info { display: grid; gap: 5px; min-width: 0; }
.ride-date { color: var(--text); font-size: 9px; }
.ride-location { overflow: hidden; color: var(--muted); font-size: 8px; text-overflow: ellipsis; white-space: nowrap; }
.ride-item-stats { display: flex; gap: 8px; color: var(--muted-dark); font-family: var(--mono); font-size: 8px; white-space: nowrap; }
.ride-item-stats strong { color: var(--text); font-weight: 500; }
.ride-actions { display: flex; gap: 7px; align-items: center; }
.ride-action { display: grid; min-width: 29px; height: 29px; place-items: center; padding: 0 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--muted-dark); font-size: 9px; cursor: pointer; }
.ride-action:hover { border-color: var(--accent); color: var(--accent); }
.ride-action:disabled { opacity: .6; cursor: wait; }
.app-footer { display: flex; justify-content: space-between; gap: 12px; margin-top: 21px; padding: 13px 0 max(16px, env(safe-area-inset-bottom)); border-top: 1px solid var(--line); color: var(--muted); font-size: 8px; letter-spacing: .1em; }
.settings-dialog { width: min(420px, calc(100% - 32px)); padding: 0; border: 1px solid var(--line-strong); border-radius: 13px; background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.settings-dialog::backdrop { background: #11151b80; backdrop-filter: blur(3px); }
.settings-form { display: grid; gap: 10px; padding: 23px; }
.settings-form h2 { margin: 0; color: var(--text-strong); font-size: 19px; letter-spacing: -.4px; }
.settings-form p { margin: 0 0 5px; color: var(--muted-dark); font-size: 12px; line-height: 1.5; }
.settings-form label { color: var(--muted-dark); font-size: 11px; font-weight: 600; }
.settings-form input { width: 100%; min-height: 40px; padding: 9px 11px; border: 1px solid var(--line-strong); border-radius: 7px; background: var(--surface-2); color: var(--text); font: inherit; font-size: 12px; }
.settings-form input:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 38%, transparent); outline-offset: 2px; }
.settings-actions { display: flex; justify-content: flex-end; align-items: center; gap: 17px; margin-top: 8px; }
.settings-save { min-height: 35px; padding: 0 13px; border: 0; border-radius: 7px; background: var(--accent); color: #fff; font-size: 11px; font-weight: 650; cursor: pointer; }
.settings-save:hover { filter: brightness(.94); }
.notice { position: fixed; z-index: 2; right: max(18px, env(safe-area-inset-right)); bottom: max(18px, env(safe-area-inset-bottom)); max-width: min(360px, calc(100vw - 36px)); padding: 12px 16px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); color: var(--text); box-shadow: var(--shadow); font-size: 12px; line-height: 1.5; opacity: 0; transform: translateY(7px); pointer-events: none; transition: opacity .2s, transform .2s; }
.notice.show { opacity: 1; transform: translateY(0); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; clip-path: inset(50%); }

@media (min-width: 1100px) { .app-shell { width: min(1040px, 100% - 96px); } }
@media (max-width: 650px) {
  .app-shell { width: calc(100% - 32px); }
  .topbar { min-height: 61px; }
  .topbar-actions { gap: 10px; }
  .privacy-badge { font-size: 0; gap: 0; }
  .privacy-dot { width: 7px; height: 7px; }
  main { padding-top: 27px; }
  .ride-heading { gap: 10px; align-items: flex-end; margin-bottom: 18px; }
  .ride-heading .eyebrow { font-size: 8px; }
  h1 { font-size: 35px; }
  .intro { max-width: 290px; font-size: 11px; line-height: 1.45; }
  .ride-state { gap: 6px; font-size: 7px; white-space: nowrap; }
  .dashboard { grid-template-columns: 1fr; gap: 12px; }
  .lean-card { min-height: 298px; padding: 17px 19px 12px; }
  .lean-number { font-size: clamp(88px, 26vw, 105px); }
  .side-stack { grid-template-columns: 1fr; grid-template-rows: auto auto; gap: 12px; }
  .stats-card { min-height: 162px; padding: 16px 19px 12px; }
  .max-stats { margin-top: 15px; }
  .max-left { padding-left: 12px; }
  .max-right { padding-left: 24px; }
  .stat-number { font-size: 37px; }
  .trip-card { min-height: 80px; }
  .controls-row { flex-wrap: wrap; gap: 10px 14px; margin-top: 14px; }
  .record-button { min-height: 46px; }
  .control-hint { flex: 1; min-width: 135px; font-size: 9px; }
  .gps-indicator { margin-left: auto; }
  .lower-grid { grid-template-columns: 1fr; gap: 12px; margin-top: 17px; }
  .how-card, .history-card { min-height: unset; padding: 17px 18px 14px; }
  .feature-list { gap: 12px; margin-top: 15px; }
  .feature strong { font-size: 10px; }
  .app-footer { margin-top: 16px; font-size: 7px; }
}
@media (max-width: 380px) {
  .app-shell { width: calc(100% - 24px); }
  .theme-picker select { max-width: 100px; font-size: 10px; }
  .ride-heading { align-items: flex-start; }
  .ride-state { margin-top: 26px; }
  .trip-card { padding-inline: 9px; }
  .trip-label { font-size: 7px; }
  .trip-value { font-size: 14px; }
}
@media (orientation: landscape) and (max-height: 520px) and (min-width: 651px) {
  .topbar { min-height: 55px; }
  main { padding-top: 19px; }
  .ride-heading { margin-bottom: 12px; }
  h1 { margin-top: 6px; font-size: 32px; }
  .lean-card { min-height: 270px; padding-top: 14px; }
  .lean-display { margin-top: 13px; }
  .lean-number { font-size: 80px; }
  .lean-meter { margin-top: 14px; }
  .stats-card { min-height: 160px; padding-block: 15px; }
  .max-stats { margin-top: 16px; }
  .lower-grid { margin-top: 14px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
