/* CarMate — instrument-cluster theme, in two skins.
   Dark ("night cluster") is the default; light ("day cluster") keeps the same
   amber + mono identity on a bright ground. Toggled via data-theme on <html>.
   Every text token is kept at >= 4.5:1 against the surface it sits on. */

:root, :root[data-theme="dark"] {
  --bg: #0A0C10;
  --surface: #171D25;
  --surface-2: #232C38;
  --surface-3: #303B4A;
  --text: #FFFFFF;
  --text-dim: #CBD6E2;
  --text-faint: #A7B4C3;
  --border: #3A4555;
  --border-bright: #556374;

  --accent: #FFB43D;          /* amber for TEXT and icons */
  --accent-solid: #F5A524;    /* amber for FILLS (buttons, arcs, indicators) */
  --accent-glow: rgba(245,165,36,.45);
  --accent-dim: #33260F;
  --on-accent: #14100A;       /* text that sits on an amber fill */

  --ok: #5FE3AE;
  --ok-dim: #103026;
  --warn: #FFB43D;
  --warn-dim: #33260F;
  --danger: #FF8A7E;
  --danger-dim: #3A1815;

  --radius: 12px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, "Roboto Mono", "Courier New", monospace;
  --gauge-ok: #5FE3AE;
  --gauge-warn: #F5A524;
  --gauge-over: #FF7367;

}

:root[data-theme="macaron"] {
  --bg: #F8F1F5;
  --surface: #FFFFFF;
  --surface-2: #F5E8F0;
  --surface-3: #E9D6E3;
  --text: #33262F;
  --text-dim: #63525E;
  --text-faint: #7A6874;
  --border: #EDDCE7;
  --border-bright: #D9BDCE;

  --accent: #A33769;          /* raspberry macaron — readable as text */
  --accent-solid: #F4A9C8;    /* pastel pink fill */
  --accent-glow: rgba(214,142,178,.42);
  --accent-dim: #FCE9F2;
  --on-accent: #3D1A2C;       /* dark plum on the pastel fill */

  --ok: #24705A;              /* pistachio */
  --ok-dim: #E0F2EB;
  --warn: #85520E;            /* caramel */
  --warn-dim: #FCEFDC;
  --danger: #9C2C46;          /* rose */
  --danger-dim: #FCE5EA;
  --gauge-ok: #6BC2A4;
  --gauge-warn: #F0A94B;
  --gauge-over: #EE7C97;

}

:root[data-theme="light"] {
  --bg: #EEF1F6;
  --surface: #FFFFFF;
  --surface-2: #E5EBF2;
  --surface-3: #D3DCE7;
  --text: #0D141C;
  --text-dim: #46535F;
  --text-faint: #5C6975;
  --border: #CFD8E2;
  --border-bright: #A9B6C4;

  --accent: #8A5000;
  --accent-solid: #E8940C;
  --accent-glow: rgba(180,105,0,.35);
  --accent-dim: #FCEFD9;
  --on-accent: #1A1204;

  --ok: #0F7A54;
  --ok-dim: #DCF3EA;
  --warn: #8A5000;
  --warn-dim: #FCEFD9;
  --danger: #B32B20;
  --danger-dim: #FBE4E1;
  --gauge-ok: #12A06E;
  --gauge-warn: #E8940C;
  --gauge-over: #DB4133;

}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", "PingFang HK",
    "Hiragino Sans TC", "Microsoft JhengHei", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
  line-height: 1.55;
}

button, input, select, textarea { font-family: inherit; color: inherit; font-size: 15px; }
button { cursor: pointer; }

/* Fine carbon weave, used behind the header and the car panel. */
.carbon {
  background-image:
    repeating-linear-gradient(45deg, rgba(255,255,255,.022) 0 1px, transparent 1px 4px),
    repeating-linear-gradient(-45deg, rgba(255,255,255,.022) 0 1px, transparent 1px 4px);
}

/* ---------- header ---------- */
.app-header {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(env(safe-area-inset-top, 0px) + 14px) 18px 12px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  background-image:
    repeating-linear-gradient(45deg, rgba(255,255,255,.02) 0 1px, transparent 1px 4px),
    repeating-linear-gradient(-45deg, rgba(255,255,255,.02) 0 1px, transparent 1px 4px);
}
.app-header h1 {
  font-size: 15px; margin: 0; font-weight: 700;
  text-transform: uppercase; letter-spacing: 2.4px;
}
.app-header h1::before {
  content: ""; display: inline-block; vertical-align: middle;
  width: 3px; height: 15px; margin-right: 10px; border-radius: 2px;
  background: var(--accent-solid); box-shadow: 0 0 10px var(--accent-glow);
}

.header-btn { color: var(--text-dim); border: 1px solid var(--border-bright); background: var(--surface-2); border-radius: 8px; padding: 6px; }
.header-btn:active { color: var(--accent); background: var(--surface-3); }
.lang-pill {
  background: var(--surface-2); border: 1px solid var(--border-bright); color: var(--text-dim);
  font-family: var(--mono);
  font-size: 11px; font-weight: 700; letter-spacing: 1px;
  padding: 5px 11px; border-radius: 6px;
}
.lang-pill:active { background: var(--surface-3); color: var(--accent); }

#main { padding: 16px 16px calc(150px + var(--safe-bottom)); max-width: 600px; margin: 0 auto; }
.screen { animation: fadein .16s ease; }
@keyframes fadein { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }

/* ---------- type ---------- */
.section-title {
  font-size: 11px; font-weight: 700; margin: 26px 0 10px;
  text-transform: uppercase; letter-spacing: 1.6px; color: var(--text-dim);
  display: flex; align-items: center; gap: 10px;
}
.section-title::after {
  content: ""; flex: 1; height: 1px; background: var(--border);
}
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 26px; }
.section-head .section-title { margin: 0; flex: 1; }

.muted { color: var(--text-dim); font-size: 14px; }
.empty-msg { color: var(--text-dim); font-size: 13.5px; text-align: center; padding: 20px 8px; margin: 0; }
.footnote { color: var(--text-faint); font-size: 12px; text-align: center; margin: 22px 0 0; }
.hint { color: var(--text-dim); font-size: 12.5px; margin: 5px 0 14px; }
.card-label {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 1.6px; color: var(--text-dim);
}
.link-btn {
  background: none; border: none; color: var(--accent);
  font-size: 11px; font-weight: 700; padding: 4px 0;
  text-transform: uppercase; letter-spacing: 1.2px;
}

/* ---------- panels ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 15px 16px; margin-bottom: 12px;
}
.intro-card h2 { margin: 0 0 8px; font-size: 18px; }
.intro-card .btn { margin-top: 14px; }

/* car identity panel */
.car-card {
  position: relative; overflow: hidden;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 18px; margin-bottom: 12px;
  background-image:
    repeating-linear-gradient(45deg, rgba(255,255,255,.022) 0 1px, transparent 1px 4px),
    repeating-linear-gradient(-45deg, rgba(255,255,255,.022) 0 1px, transparent 1px 4px);
}
.car-card::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--accent-solid); box-shadow: 0 0 14px var(--accent-glow);
}
.car-card-name { font-size: 18px; font-weight: 700; letter-spacing: .3px; }
.car-card-sub {
  font-family: var(--mono); font-size: 11.5px; color: var(--text-dim);
  margin-top: 3px; letter-spacing: .3px;
}
.car-card-plate {
  font-family: var(--mono); font-weight: 700; font-size: 13px; letter-spacing: 2px;
  background: var(--bg); border: 1px solid var(--border-bright); color: var(--text);
  padding: 7px 11px; border-radius: 6px; white-space: nowrap;
}

/* ---------- gauge ---------- */
.gauge-wrap { display: flex; justify-content: center; margin: 6px 0 4px; }
.gauge { width: 100%; max-width: 260px; height: auto; display: block; }
.gauge-track { stroke: var(--surface-3); }
.gauge-value { stroke: var(--gauge-ok); transition: stroke-dasharray .45s ease; }
.gauge-value.warn { stroke: var(--gauge-warn); }
.gauge-value.over { stroke: var(--gauge-over); }
/* the marker stays full-contrast in every theme so the position is unmistakable */
.gauge-mark, .gauge-mark.warn, .gauge-mark.over { stroke: var(--text); }
.gauge-tick { stroke: var(--border-bright); }
.gauge-tick.hot { stroke: var(--danger); opacity: .75; }
.gauge-big {
  font-family: var(--mono); font-size: 34px; font-weight: 700;
  fill: var(--text); letter-spacing: -1px;
}
.gauge-big.warn { fill: var(--warn); }
.gauge-big.over { fill: var(--danger); }
.gauge-unit {
  font-size: 11px; fill: var(--text-dim); letter-spacing: 1.4px;
  text-transform: uppercase; font-weight: 700;
}
.gauge-caption {
  text-align: center; font-size: 12px; color: var(--text-dim);
  margin: 2px 0 14px; letter-spacing: .4px;
}

/* ---------- readout rows (ODO / NEXT / DUE) ---------- */
.readout { display: flex; align-items: baseline; gap: 8px; padding: 7px 0; }
.readout + .readout { border-top: 1px solid var(--border); }
.ro-k {
  font-family: var(--mono); font-size: 11.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 1.4px; color: var(--text-dim);
  flex: 0 0 auto; min-width: 74px;
}
.ro-dots { flex: 1; border-bottom: 1px dotted var(--border-bright); transform: translateY(-3px); }
.ro-v {
  font-family: var(--mono); font-size: 14.5px; font-weight: 600;
  color: var(--text); flex: 0 0 auto; text-align: right;
  font-variant-numeric: tabular-nums;
}
.ro-v.dim { color: var(--text-dim); font-weight: 500; }
/* a readout whose value can be a sentence: label on top, value wraps below */
.readout-wrap { flex-direction: column; align-items: flex-start; gap: 4px; }
.readout-wrap .ro-v { text-align: left; white-space: normal; font-size: 13.5px; }
.ro-v.warn { color: var(--warn); }
.ro-v.over { color: var(--danger); }

/* odometer strip */
.mileage-card { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.mileage-value {
  font-family: var(--mono); font-size: 26px; font-weight: 700; margin-top: 4px;
  letter-spacing: -.5px; font-variant-numeric: tabular-nums;
}
.mileage-value .unit {
  font-size: 11px; font-weight: 700; color: var(--text-dim);
  letter-spacing: 1.4px; text-transform: uppercase; margin-left: 4px;
}

.oil-card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.oil-sub {
  font-family: var(--mono); font-size: 12.5px; color: var(--text-dim);
  margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--border); line-height: 1.7;
}

/* legacy linear bar, still used for the secondary time axis */
.bar { height: 4px; border-radius: 999px; background: var(--surface-3); overflow: hidden; margin-top: 7px; }
.bar span { display: block; height: 100%; border-radius: 999px; background: var(--ok); transition: width .3s ease; }
.bar.warn span { background: var(--warn); }
.bar.over span { background: var(--danger); }

.spec-card .spec-row { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; font-size: 13.5px; }
.spec-card .spec-row + .spec-row { border-top: 1px solid var(--border); }
.spec-card .spec-row span:first-child { color: var(--text-dim); }
.spec-card .spec-row span:last-child { font-family: var(--mono); font-weight: 600; text-align: right; }

/* ---------- badges ---------- */
.badge {
  font-family: var(--mono); font-size: 10.5px; font-weight: 700;
  padding: 4px 9px; border-radius: 4px; white-space: nowrap;
  text-transform: uppercase; letter-spacing: 1.1px;
  background: var(--ok-dim); color: var(--ok); border: 1px solid transparent;
}
.badge.warn { background: var(--warn-dim); color: var(--warn); }
.badge.over { background: var(--danger-dim); color: var(--danger); }
.badge.info { background: var(--surface-2); color: var(--text-dim); }

/* ---------- quick grid ---------- */
.quick-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.quick-btn {
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 13px 12px; text-align: left; font-size: 13.5px; font-weight: 600; color: var(--text);
  display: flex; align-items: center; justify-content: space-between; gap: 8px; line-height: 1.35;
}
.quick-btn:active { background: var(--surface-2); border-color: var(--accent); }
.quick-btn::after { content: "›"; color: var(--accent); font-size: 19px; font-weight: 700; }

/* ---------- lists ---------- */
.record-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 7px; }
.record-item {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 12px 14px; text-align: left; width: 100%;
}
.record-item:active { background: var(--surface-2); }
.rec-icon {
  width: 32px; height: 32px; flex: 0 0 32px; border-radius: 7px;
  background: var(--surface-2); color: var(--text-dim); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
}
.rec-icon.accent { background: var(--accent-dim); color: var(--accent); border-color: transparent; }
.rec-main { flex: 1; min-width: 0; display: block; }
.rec-title, .rec-sub { display: block; }
.rec-title { font-size: 14px; font-weight: 600; }
.rec-sub {
  font-family: var(--mono); font-size: 12px; color: var(--text-faint); margin-top: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.rec-right { text-align: right; font-size: 12px; color: var(--text-dim); white-space: nowrap; }
.rec-cost { font-family: var(--mono); font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }

.due-list { display: flex; flex-direction: column; gap: 7px; }
.due-item {
  display: flex; align-items: center; gap: 11px;
  background: var(--surface); border: 1px solid var(--border);
  border-left: 3px solid var(--ok); border-radius: 8px; padding: 11px 13px;
}
.due-item.warn { border-left-color: var(--warn); }
.due-item.over { border-left-color: var(--danger); }
.due-main { flex: 1; min-width: 0; display: block; }
.due-title, .due-sub { display: block; }
.due-title { font-size: 13.5px; font-weight: 600; }
.due-sub { font-family: var(--mono); font-size: 12px; color: var(--text-faint); margin-top: 1px; }

/* ---------- chips ---------- */
.chip-row { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 10px; -webkit-overflow-scrolling: touch; }
.chip-row::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto; background: var(--surface); border: 1px solid var(--border);
  color: var(--text-dim); font-size: 12px; font-weight: 600;
  padding: 6px 12px; border-radius: 6px; white-space: nowrap;
}
.chip.active { background: var(--accent-dim); border-color: var(--accent); color: var(--accent); }

/* ---------- forms ---------- */
form h2 { font-size: 17px; margin: 0 0 18px; letter-spacing: .3px; }
label {
  display: block; font-size: 10.5px; font-weight: 700; margin-bottom: 6px;
  color: var(--text-dim); text-transform: uppercase; letter-spacing: 1.2px;
}
input[type=text], input[type=number], input[type=date], select, textarea {
  width: 100%; background: var(--bg); border: 1px solid var(--border-bright);
  border-radius: 8px; padding: 11px 12px; margin-bottom: 14px;
  -webkit-appearance: none; appearance: none;
  color-scheme: dark;
}
input[type=number], input[type=date] { font-family: var(--mono); }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
select {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path fill='%237E8B9B' d='M7 10l5 5 5-5z'/></svg>");
  background-repeat: no-repeat; background-position: right 10px center; background-size: 20px; padding-right: 34px;
}
textarea { resize: vertical; }
.field-row { display: flex; gap: 12px; }
.field-col { flex: 1; min-width: 0; }
.checkbox-row { display: flex; align-items: center; gap: 9px; margin-bottom: 16px; }
.checkbox-row input { width: 18px; height: 18px; margin: 0; accent-color: var(--accent); }
.checkbox-row label { margin: 0; color: var(--text); font-weight: 500; text-transform: none; letter-spacing: 0; font-size: 13.5px; }
.check-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; margin-bottom: 16px; }
.check-grid .checkbox-row { margin-bottom: 0; }

.btn {
  border: 1px solid transparent; border-radius: 8px; padding: 12px 18px;
  font-size: 13px; font-weight: 700; letter-spacing: 1.2px; text-transform: uppercase;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent-solid); color: var(--on-accent); }
.btn-secondary { background: var(--surface-2); color: var(--text); border-color: var(--border-bright); }
.btn-ghost { background: transparent; color: var(--accent); border-color: var(--border-bright); padding: 9px 14px; font-size: 11.5px; }
.btn-danger { background: var(--danger-dim); color: var(--danger); border-color: transparent; }
.btn.full { width: 100%; margin-top: 10px; }
.form-actions { display: flex; gap: 12px; margin-top: 22px; }
.form-actions .btn { flex: 1; }

.danger-zone { margin-top: 34px; padding-top: 18px; border-top: 1px solid var(--border); }
.danger-zone h3 { font-size: 10.5px; color: var(--danger); margin: 0 0 10px; text-transform: uppercase; letter-spacing: 1.6px; }
.danger-zone .btn { width: 100%; }

/* ---------- learn ---------- */
.seg-row {
  display: flex; gap: 2px; background: var(--surface); border: 1px solid var(--border);
  padding: 4px; border-radius: 9px; margin-bottom: 14px; overflow-x: auto;
}
.seg-row::-webkit-scrollbar { display: none; }
.seg-btn {
  flex: 1 0 auto; background: none; border: none; color: var(--text-dim);
  font-size: 12.5px; font-weight: 700; padding: 8px 10px; border-radius: 6px; white-space: nowrap;
}
.seg-btn.active { background: var(--accent-dim); color: var(--accent); }

.disclaimer {
  font-size: 12.5px; color: var(--text-dim); background: var(--surface);
  border: 1px solid var(--border); border-left: 3px solid var(--accent-solid);
  border-radius: 8px; padding: 11px 14px; margin: 0 0 16px; line-height: 1.55;
}

.acc { border: 1px solid var(--border); border-radius: 10px; background: var(--surface); margin-bottom: 9px; overflow: hidden; }
.acc.open { border-color: var(--border-bright); }
.acc-head {
  width: 100%; background: none; border: none; text-align: left;
  padding: 14px 16px; font-size: 14px; font-weight: 700; color: var(--text);
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.acc-head::after { content: "+"; font-family: var(--mono); color: var(--accent); font-weight: 700; font-size: 17px; }
.acc.open .acc-head { color: var(--accent); }
.acc.open .acc-head::after { content: "\2212"; }
.acc-body { padding: 0 16px 16px; font-size: 14px; color: var(--text); }
.acc-body p { margin: 0 0 12px; }
.acc-body p:last-child { margin-bottom: 0; }
.acc-body b { font-weight: 700; color: var(--text); }
.acc-body h4 {
  font-size: 11px; margin: 20px 0 9px; color: var(--text-dim);
  text-transform: uppercase; letter-spacing: 1.4px;
}

.def-list { display: flex; flex-direction: column; gap: 8px; margin: 4px 0 0; }
.def-item { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 11px 13px; }
.def-item .def-k { font-weight: 700; font-size: 13px; color: var(--accent); }
.def-item .def-v { font-size: 13.5px; color: var(--text-dim); margin-top: 3px; }

.step-list { counter-reset: st; list-style: none; margin: 4px 0 0; padding: 0; display: flex; flex-direction: column; gap: 13px; }
.step-list li { position: relative; padding-left: 36px; font-size: 13.5px; }
.step-list li::before {
  counter-increment: st; content: counter(st, decimal-leading-zero);
  position: absolute; left: 0; top: 1px;
  font-family: var(--mono); font-size: 11px; font-weight: 700;
  color: var(--accent); border: 1px solid var(--border-bright);
  border-radius: 5px; padding: 2px 5px; background: var(--bg);
}
.step-list .st-title { font-weight: 700; display: block; margin-bottom: 3px; font-size: 13.5px; }
.step-list .st-body { color: var(--text-dim); }

.bullets { margin: 4px 0 0; padding-left: 18px; font-size: 13.5px; color: var(--text-dim); }
.bullets li { margin-bottom: 8px; }
.bullets li::marker { color: var(--accent); }

.type-card { border: 1px solid var(--border); border-radius: 10px; padding: 14px 15px; margin-bottom: 9px; background: var(--bg); }
.type-card-head { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; margin-bottom: 4px; }
.type-card-head h4 { margin: 0; font-size: 15px; }
.type-interval { font-family: var(--mono); font-size: 11.5px; color: var(--accent); font-weight: 600; margin-bottom: 10px; }
.type-card dl { margin: 0; font-size: 13.5px; }
.type-card dt {
  font-weight: 700; font-size: 10.5px; text-transform: uppercase;
  letter-spacing: 1.3px; color: var(--text-faint); margin-top: 10px;
}
.type-card dd { margin: 3px 0 0; color: var(--text-dim); }

.brand-card { border: 1px solid var(--border); border-radius: 10px; padding: 14px 15px; margin-bottom: 9px; background: var(--bg); }
.brand-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.brand-head h4 { margin: 0; font-size: 14.5px; }
.brand-origin { font-family: var(--mono); font-size: 12px; color: var(--text-faint); margin-top: 2px; }
.brand-note { font-size: 13.5px; margin: 10px 0 0; color: var(--text-dim); }
.brand-lines { font-family: var(--mono); font-size: 12.5px; color: var(--text-dim); margin: 9px 0 0; }
.brand-lines b { color: var(--text-dim); }
.price-dots { white-space: nowrap; font-size: 9px; letter-spacing: 3px; color: var(--accent-solid); flex: 0 0 auto; padding-top: 4px; }
.price-dots i { opacity: .22; font-style: normal; }

.myth-card { border: 1px solid var(--border); border-radius: 10px; padding: 13px 15px; margin-bottom: 8px; background: var(--bg); }
.myth-q { font-weight: 700; font-size: 13.5px; margin: 0 0 6px; }
.myth-q::before {
  content: "\00D7"; font-family: var(--mono); color: var(--danger);
  font-weight: 700; margin-right: 7px;
}
.myth-a { font-size: 13.5px; color: var(--text-dim); margin: 0; }

.note-box {
  background: var(--accent-dim); border: 1px solid var(--accent-solid);
  border-radius: 8px; padding: 12px 14px; margin: 4px 0 14px; font-size: 13px;
}
.note-box h4 {
  margin: 0 0 6px; font-size: 10.5px; color: var(--accent);
  text-transform: uppercase; letter-spacing: 1.4px;
}
.note-box p { color: var(--text); }

.sched-table {
  width: 100%; border-collapse: collapse; font-size: 13px;
  background: var(--surface); border-radius: 10px; overflow: hidden; border: 1px solid var(--border);
}
.sched-table th, .sched-table td { padding: 10px 11px; text-align: left; border-bottom: 1px solid var(--border); }
.sched-table th {
  font-size: 10px; text-transform: uppercase; letter-spacing: 1.3px;
  color: var(--text-faint); background: var(--bg); font-weight: 700;
}
.sched-table tr:last-child td { border-bottom: none; }
.sched-table td:nth-child(2), .sched-table td:nth-child(3) {
  font-family: var(--mono); font-size: 12.5px; color: var(--text-dim);
  white-space: nowrap; font-variant-numeric: tabular-nums;
}

.station-item { display: flex; align-items: flex-start; gap: 11px; }
.station-svcs { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 7px; }
.svc-tag {
  font-size: 11px; font-weight: 700; background: var(--surface-2); color: var(--text-faint);
  padding: 3px 8px; border-radius: 4px; letter-spacing: .4px;
}
.svc-tag.on { background: var(--ok-dim); color: var(--ok); }

/* ---------- bottom nav ---------- */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-around;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--border);
  padding: 7px 6px calc(7px + var(--safe-bottom));
}
.nav-btn {
  position: relative; flex: 1; background: none; border: none; color: var(--text-dim);
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  font-size: 9.5px; font-weight: 700; padding: 5px 2px;
  text-transform: uppercase; letter-spacing: .8px;
}
.nav-btn.active { color: var(--accent); }
.nav-btn.active::before {
  content: ""; position: absolute; top: -8px; left: 50%; transform: translateX(-50%);
  width: 20px; height: 2px; border-radius: 0 0 2px 2px;
  background: var(--accent-solid); box-shadow: 0 0 8px var(--accent-glow);
}
.fab {
  flex: 0 0 auto; width: 50px; height: 50px; border-radius: 50%;
  border: 1px solid var(--accent-solid);
  background: var(--accent-solid); color: var(--on-accent); margin: -20px 4px 0;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 18px var(--accent-glow);
}
.fab:active { transform: translateY(1px); }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(96px + var(--safe-bottom)); z-index: 60;
  background: var(--surface-3); color: var(--text);
  border: 1px solid var(--border-bright);
  font-family: var(--mono); font-size: 12px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 1.2px;
  padding: 10px 18px; border-radius: 6px;
  animation: toastin .2s ease;
}
@keyframes toastin { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }

@media (min-width: 620px) {
  .quick-grid { grid-template-columns: repeat(4, 1fr); }
}

/* ---------- onboarding ---------- */
.ob-wrap { padding-top: 24px; text-align: center; }
.ob-icon { border-radius: 20px; margin-bottom: 14px; box-shadow: 0 8px 28px rgba(0,0,0,.35); }
.ob-wrap h2 { margin: 0 0 8px; font-size: 22px; }
.ob-wrap .muted { margin: 0 auto 26px; max-width: 320px; }
.ob-wrap form { text-align: left; }
#ob-name { font-size: 18px; padding: 14px 14px; }

/* ---------- car card as a switcher ---------- */
button.car-card { width: 100%; text-align: left; cursor: pointer; font: inherit; color: inherit; }
button.car-card:active { background: var(--surface-2); }
.car-card-main { min-width: 0; flex: 1; }
.car-card-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.car-card-right { display: flex; flex-direction: column; align-items: flex-end; gap: 7px; flex: 0 0 auto; }
.car-card-switch {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: 10.5px; font-weight: 700; letter-spacing: 1.2px; text-transform: uppercase;
  color: var(--accent);
}

.title-tag {
  font-family: var(--mono); font-size: 11px; font-weight: 600;
  color: var(--accent); letter-spacing: .4px; text-transform: none; margin-left: 6px;
}
.section-title .title-tag:empty { display: none; }

/* ---------- bottom sheet ---------- */
.modal {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(0,0,0,.55);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fadein .15s ease;
}
.sheet {
  width: 100%; max-width: 600px;
  background: var(--surface); border: 1px solid var(--border); border-bottom: none;
  border-radius: 18px 18px 0 0;
  padding: 14px 16px calc(20px + var(--safe-bottom));
  max-height: 80vh; overflow-y: auto;
  animation: sheetin .22s cubic-bezier(.2,.8,.2,1);
}
@keyframes sheetin { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.sheet-head h2 { margin: 0; font-size: 17px; }
.icon-btn {
  background: none; border: none; color: var(--text-dim); padding: 6px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
}
.icon-btn:active { background: var(--surface-2); }

.car-row { position: relative; }
.car-row.active { border-color: var(--accent); background: var(--accent-dim); }
.car-row .rec-icon.plate {
  width: auto; min-width: 32px; padding: 0 8px; font-family: var(--mono);
  font-size: 10.5px; font-weight: 700; letter-spacing: 1px; color: var(--text);
  white-space: nowrap;
}
.car-row .badge { flex: 0 0 auto; }

/* tab strip now has 7 entries — let it wrap on narrow screens instead of clipping */
.seg-row { flex-wrap: wrap; }
.seg-row .seg-btn { flex: 1 1 auto; }

/* ---------- documents ---------- */
.docs-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.doc-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  overflow: hidden; text-align: left; padding: 0; width: 100%; color: inherit; font: inherit;
}
.doc-card:active { border-color: var(--accent); }
.doc-thumb {
  aspect-ratio: 4 / 3; background: var(--bg); display: flex; align-items: center; justify-content: center;
  overflow: hidden; border-bottom: 1px solid var(--border);
}
.doc-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.doc-thumb .pdf-badge {
  font-family: var(--mono); font-size: 12px; font-weight: 700; letter-spacing: 2px;
  color: var(--danger); border: 2px solid var(--danger); border-radius: 6px; padding: 6px 10px;
}
.doc-card-body { padding: 9px 11px 10px; }
.doc-card-type { font-size: 13px; font-weight: 700; }
.doc-card-sub { font-family: var(--mono); font-size: 10.5px; color: var(--text-faint); margin-top: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.doc-preview { margin: 6px 0 14px; border-radius: 10px; overflow: hidden; border: 1px solid var(--border); background: var(--bg); }
.doc-preview img { width: 100%; display: block; max-height: 260px; object-fit: contain; }

.doc-modal { align-items: stretch; background: rgba(0,0,0,.92); }
.doc-view { width: 100%; max-width: 700px; margin: 0 auto; display: flex; flex-direction: column; height: 100%; }
.doc-view-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: calc(env(safe-area-inset-top, 0px) + 12px) 14px 10px; color: #fff;
}
.doc-view-meta { min-width: 0; }
.doc-view-title { font-weight: 700; font-size: 15px; }
.doc-view-sub { font-family: var(--mono); font-size: 11px; opacity: .7; }
.doc-view-head .icon-btn { color: #fff; }
.doc-view-body { flex: 1; overflow: auto; display: flex; align-items: center; justify-content: center; padding: 0 8px; }
.doc-view-body img { max-width: 100%; max-height: 100%; object-fit: contain; display: block; }
.doc-view-body .pdf-badge {
  font-family: var(--mono); font-size: 18px; font-weight: 700; letter-spacing: 3px;
  color: var(--danger); border: 3px solid var(--danger); border-radius: 10px; padding: 18px 26px;
}
.doc-view-actions {
  display: flex; gap: 10px; padding: 12px 14px calc(14px + var(--safe-bottom));
}
.doc-view-actions .btn { flex: 1; text-align: center; text-decoration: none; display: flex; align-items: center; justify-content: center; }

/* ---------- assistant ---------- */
.chat-fab {
  position: fixed; right: 16px; bottom: calc(84px + var(--safe-bottom)); z-index: 40;
  width: 54px; height: 54px; border-radius: 50%; border: 1px solid var(--accent-solid);
  background: var(--surface); color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 20px rgba(0,0,0,.35), 0 0 0 3px var(--accent-dim);
}
.chat-fab:active { transform: translateY(1px); background: var(--accent-dim); }

.chat-modal { align-items: stretch; background: rgba(0,0,0,.55); }
.chat {
  width: 100%; max-width: 640px; margin: 0 auto; height: 100%;
  display: flex; flex-direction: column;
  background: var(--bg); border-left: 1px solid var(--border); border-right: 1px solid var(--border);
}
.chat-head {
  display: flex; align-items: center; gap: 6px;
  padding: calc(env(safe-area-inset-top, 0px) + 12px) 12px 10px 16px;
  border-bottom: 1px solid var(--border); background: var(--surface);
}
.chat-head-meta { flex: 1; min-width: 0; }
.chat-title { font-weight: 700; font-size: 15px; }
.chat-status {
  font-family: var(--mono); font-size: 10.5px; letter-spacing: 1.2px; text-transform: uppercase;
  color: var(--text-dim); margin-top: 1px;
}
.chat-status.on { color: var(--ok); }
.chat-emergency {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--danger-dim); color: var(--danger); border-bottom: 1px solid var(--danger);
  padding: 10px 14px; font-size: 13.5px; font-weight: 700;
}
.chat-emergency .btn { padding: 8px 14px; font-size: 12px; white-space: nowrap; text-decoration: none; background: var(--danger); color: #fff; }

.chat-log { flex: 1; overflow-y: auto; padding: 14px 14px 6px; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 88%; padding: 10px 13px; border-radius: 14px; font-size: 14.5px; line-height: 1.55; }
.msg.user { align-self: flex-end; background: var(--accent-solid); color: var(--on-accent); border-bottom-right-radius: 4px; }
.msg.bot { align-self: flex-start; background: var(--surface); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.msg.bot p { margin: 0 0 8px; } .msg.bot p:last-child { margin: 0; }
.msg.bot ol, .msg.bot ul { margin: 4px 0 8px; padding-left: 20px; }
.msg.bot li { margin-bottom: 4px; }
.msg.bot li::marker { color: var(--accent); font-weight: 700; }
.msg.bot b { color: var(--text); }
.msg-note { display: block; font-family: var(--mono); font-size: 10.5px; color: var(--text-faint); margin-bottom: 6px; }
.msg.pending::after { content: "▍"; color: var(--accent); animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }

.chat-chips { display: flex; gap: 6px; overflow-x: auto; padding: 4px 14px 8px; }
.chat-chips::-webkit-scrollbar { display: none; }
.chat-chips:empty { display: none; }
.chat-form {
  display: flex; gap: 8px; padding: 8px 12px calc(12px + var(--safe-bottom));
  border-top: 1px solid var(--border); background: var(--surface);
}
.chat-form input { flex: 1; margin: 0; font-size: 16px; }
.chat-form .btn { width: 46px; padding: 0; display: flex; align-items: center; justify-content: center; flex: 0 0 46px; }


/* ---------- consolidated layout ---------- */
/* car card: tappable head + odometer strip */
.car-card { display: block; padding: 0; }
.car-card-head {
  width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: none; border: none; padding: 16px 18px; text-align: left; font: inherit; color: inherit; cursor: pointer;
}
.car-card-head:active { background: var(--surface-2); }
.car-card-odo {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 18px 12px; border-top: 1px solid var(--border);
}
.car-card-odo .ro-k { min-width: 0; }
.odo-value { flex: 1; font-family: var(--mono); font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.3px; }
.odo-value .unit { font-size: 11px; font-weight: 700; color: var(--text-dim); letter-spacing: 1.2px; text-transform: uppercase; margin-left: 2px; }

/* learn topic list */
.topic-list { display: flex; flex-direction: column; gap: 9px; margin-top: 12px; }
.topic-card {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 13px 14px; color: inherit; font: inherit; cursor: pointer;
}
.topic-card:active { background: var(--surface-2); border-color: var(--accent); }
.topic-card .rec-icon { width: 38px; height: 38px; flex-basis: 38px; }
.topic-card.urgent { border-left: 3px solid var(--danger); }
.topic-card.urgent .rec-icon { background: var(--danger-dim); color: var(--danger); border-color: transparent; }
.topic-main { flex: 1; min-width: 0; display: block; }
.topic-title, .topic-sub { display: block; }
.topic-title { font-size: 15px; font-weight: 700; }
.topic-sub { font-size: 12.5px; color: var(--text-dim); margin-top: 1px; }
.topic-card::after { content: "›"; color: var(--accent); font-size: 22px; font-weight: 700; }
.topic-head { display: flex; flex-direction: column; gap: 2px; margin-bottom: 12px; }
.topic-head h2 { margin: 0; font-size: 20px; }

/* my car */
#car-view .btn.full { margin-top: 8px; }
#car-summary:empty { display: none; }

/* help bubble */
.chat-fab { width: auto; height: 50px; padding: 0 16px 0 12px; border-radius: 999px; gap: 7px; }
.chat-fab-label { font-size: 12.5px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; }
