/* =========================================================================
   Car-diology — styling.

   Two cars, two colours. The whole palette hangs off four accent tokens that
   are re-declared per vehicle on <html data-vehicle="…">, so switching tabs
   re-colours the app without a single rule being duplicated: bottle green for
   the Freelander, sapphire blue for the Corolla Cross.

   Order below:
     1  Tokens — neutrals, then the two accents, then dark
     2  Frame — topbar, tabs, footer
     3  Hero and tiles
     4  Items, the substance of the page
     5  History, the car, modals
     6  Small print — toast, responsive, print
   ========================================================================= */

/* ---------------- 1. Tokens ---------------- */
:root {
  --bg:        #f5f7f5;
  --surface:   #ffffff;
  --surface-2: #fbfcfb;
  --line:      #e1e6e2;
  --line-soft: #eef1ee;
  --text:      #16211c;
  /* Both readable at 4.5:1 or better on every ground they sit on (page,
     card, tint): small grey text read beside a pump in daylight. */
  --dim:       #4f5d56;
  --faint:     #64736b;

  /* Status is deliberately independent of the accent: a car's colour must
     never be mistaken for a verdict on its condition. */
  --late:      #c0392b;
  --late-tint: #fdecea;
  --late-ink:  #8e2118;
  --soon:      #b9770e;
  --soon-tint: #fdf3e1;
  --soon-ink:  #8a5906;
  --fine:      #2f7d5a;
  --fine-tint: #e9f5ef;
  --fine-ink:  #1f5d41;
  --idle:      #8a978f;
  --idle-tint: #f0f2f0;
  --idle-ink:  #5f6f67;

  --radius:    14px;
  --radius-sm: 10px;
  --gap:       16px;
  --shadow:    0 1px 2px rgba(16, 30, 24, .05), 0 6px 18px rgba(16, 30, 24, .05);
  --shadow-lg: 0 12px 40px rgba(16, 30, 24, .18);

  --fs-meta:   12.5px;
  --fs-sm:     13.5px;
  --fs-base:   15px;

  --sans: "Inter", "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, Helvetica, Arial, sans-serif;

  /* ── The dark palette's values, stated once ──────────────────────────────
     Two selectors below switch the live tokens over to these: an explicit
     data-theme="dark", and the un-stamped document on a dark system. Neither
     of those blocks carries a colour of its own, so the two can never drift
     apart — which is the failure this indirection exists to prevent. */
  --d-bg: #0e1412;  --d-surface: #151d1a;  --d-surface-2: #1a2320;
  --d-line: #26302c;  --d-line-soft: #1f2925;
  --d-text: #e7eeea;  --d-dim: #a9b6af;  --d-faint: #87978f;
  --d-late: #e57368;  --d-late-tint: #33201d;  --d-late-ink: #f2a79f;
  --d-soon: #e0a44a;  --d-soon-tint: #322718;  --d-soon-ink: #f0c684;
  --d-fine: #4fb98a;  --d-fine-tint: #172a22;  --d-fine-ink: #86d7b4;
  --d-idle: #74847c;  --d-idle-tint: #1d2622;  --d-idle-ink: #9daba4;
  --d-shadow:    0 1px 2px rgba(0, 0, 0, .4), 0 6px 18px rgba(0, 0, 0, .3);
  --d-shadow-lg: 0 14px 44px rgba(0, 0, 0, .55);

  /* Bottle green, dark. A bottle is dark by definition, and a dark colour on
     a dark ground is not a colour, it is an absence — so this is the same
     hue carried up to where it can still be read, not the same value. */
  --dg-accent: #2eb58a;  --dg-strong: #52cba5;  --dg-ink: #85dbba;
  --dg-on: #041a13;  --dg-tint: #122a23;  --dg-line: #1f4a3e;
  --dg-glow: rgba(46, 181, 138, .18);
  /* Sapphire, dark. */
  --ds-accent: #6da4ff;  --ds-strong: #96beff;  --ds-ink: #a9c9ff;
  --ds-on: #0b1730;  --ds-tint: #1a2540;  --ds-line: #2c3e63;
  --ds-glow: rgba(109, 164, 255, .18);
}

/* Bottle green — the Landie.
   `--accent-ink` is accent-coloured TEXT on a tinted ground; `--on-accent` is
   text on a filled accent button. They were one token until dark mode needed
   them to point in opposite directions. */
:root[data-accent="bottle"] {
  --accent:        #064e3b;
  --accent-strong: #03372a;
  --accent-ink:    #02291f;
  --on-accent:     #ffffff;
  --accent-tint:   #e6efea;
  --accent-line:   #bed3c9;
  --accent-glow:   rgba(6, 78, 59, .16);
}

/* Sapphire — the Toyota. */
:root[data-accent="sapphire"] {
  --accent:        #17509f;
  --accent-strong: #103d7c;
  --accent-ink:    #0b2a56;
  --on-accent:     #ffffff;
  --accent-tint:   #e8eefa;
  --accent-line:   #c3d3ee;
  --accent-glow:   rgba(23, 80, 159, .16);
}

/* ── Dark, three states not two ───────────────────────────────────────────
   A viewer who has chosen dark gets `data-theme="dark"`; a viewer who has
   chosen light gets `data-theme="light"`; a viewer on "system" — most of
   them — gets NEITHER, and only prefers-color-scheme separates them. So each
   switch is written twice: once for the stamp, once for the un-stamped
   document, guarded with :not([data-theme="light"]) so an explicit light
   choice still beats a dark operating system. */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: var(--d-bg);  --surface: var(--d-surface);  --surface-2: var(--d-surface-2);
  --line: var(--d-line);  --line-soft: var(--d-line-soft);
  --text: var(--d-text);  --dim: var(--d-dim);  --faint: var(--d-faint);
  --late: var(--d-late);  --late-tint: var(--d-late-tint);  --late-ink: var(--d-late-ink);
  --soon: var(--d-soon);  --soon-tint: var(--d-soon-tint);  --soon-ink: var(--d-soon-ink);
  --fine: var(--d-fine);  --fine-tint: var(--d-fine-tint);  --fine-ink: var(--d-fine-ink);
  --idle: var(--d-idle);  --idle-tint: var(--d-idle-tint);  --idle-ink: var(--d-idle-ink);
  --shadow: var(--d-shadow);  --shadow-lg: var(--d-shadow-lg);
}
:root[data-theme="dark"][data-accent="bottle"] {
  --accent: var(--dg-accent);  --accent-strong: var(--dg-strong);
  --accent-ink: var(--dg-ink);  --on-accent: var(--dg-on);
  --accent-tint: var(--dg-tint);  --accent-line: var(--dg-line);
  --accent-glow: var(--dg-glow);
}
:root[data-theme="dark"][data-accent="sapphire"] {
  --accent: var(--ds-accent);  --accent-strong: var(--ds-strong);
  --accent-ink: var(--ds-ink);  --on-accent: var(--ds-on);
  --accent-tint: var(--ds-tint);  --accent-line: var(--ds-line);
  --accent-glow: var(--ds-glow);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: var(--d-bg);  --surface: var(--d-surface);  --surface-2: var(--d-surface-2);
    --line: var(--d-line);  --line-soft: var(--d-line-soft);
    --text: var(--d-text);  --dim: var(--d-dim);  --faint: var(--d-faint);
    --late: var(--d-late);  --late-tint: var(--d-late-tint);  --late-ink: var(--d-late-ink);
    --soon: var(--d-soon);  --soon-tint: var(--d-soon-tint);  --soon-ink: var(--d-soon-ink);
    --fine: var(--d-fine);  --fine-tint: var(--d-fine-tint);  --fine-ink: var(--d-fine-ink);
    --idle: var(--d-idle);  --idle-tint: var(--d-idle-tint);  --idle-ink: var(--d-idle-ink);
    --shadow: var(--d-shadow);  --shadow-lg: var(--d-shadow-lg);
  }
  :root:not([data-theme="light"])[data-accent="bottle"] {
    --accent: var(--dg-accent);  --accent-strong: var(--dg-strong);
    --accent-ink: var(--dg-ink);  --on-accent: var(--dg-on);
    --accent-tint: var(--dg-tint);  --accent-line: var(--dg-line);
    --accent-glow: var(--dg-glow);
  }
  :root:not([data-theme="light"])[data-accent="sapphire"] {
    --accent: var(--ds-accent);  --accent-strong: var(--ds-strong);
    --accent-ink: var(--ds-ink);  --on-accent: var(--ds-on);
    --accent-tint: var(--ds-tint);  --accent-line: var(--ds-line);
    --accent-glow: var(--ds-glow);
  }
}

/* ── An added car's colour ────────────────────────────────────────────────
   The two cars keep green and blue; a car added in the app picks one of
   these (vehicles.js, GARAGE_ACCENTS). Each is the same set of tokens, light
   and dark, at the same contrast as the two above. */
:root[data-accent="graphite"] {
  --accent: #3d4650;  --accent-strong: #2b323a;  --accent-ink: #1c2127;  --on-accent: #ffffff;
  --accent-tint: #eceef0;  --accent-line: #cdd2d7;  --accent-glow: rgba(61, 70, 80, .16);
}
:root[data-accent="burgundy"] {
  --accent: #7a1f35;  --accent-strong: #5c1727;  --accent-ink: #3f0f1b;  --on-accent: #ffffff;
  --accent-tint: #f6e9ec;  --accent-line: #e3c3cb;  --accent-glow: rgba(122, 31, 53, .16);
}
:root[data-accent="copper"] {
  --accent: #8a4a14;  --accent-strong: #6b390f;  --accent-ink: #4a270a;  --on-accent: #ffffff;
  --accent-tint: #f6ede3;  --accent-line: #e5ccb4;  --accent-glow: rgba(138, 74, 20, .16);
}
:root[data-accent="violet"] {
  --accent: #5b3a9a;  --accent-strong: #452c77;  --accent-ink: #2f1e52;  --on-accent: #ffffff;
  --accent-tint: #efeaf8;  --accent-line: #d4c9ec;  --accent-glow: rgba(91, 58, 154, .16);
}
:root[data-theme="dark"][data-accent="graphite"] {
  --accent: #aab5c0;  --accent-strong: #c8d0d8;  --accent-ink: #d2d9e0;  --on-accent: #12161a;
  --accent-tint: #1f2429;  --accent-line: #39414a;  --accent-glow: rgba(170, 181, 192, .18);
}
:root[data-theme="dark"][data-accent="burgundy"] {
  --accent: #f08ba3;  --accent-strong: #f6abbc;  --accent-ink: #f8bccb;  --on-accent: #2a0a12;
  --accent-tint: #2c1a1f;  --accent-line: #53303a;  --accent-glow: rgba(240, 139, 163, .18);
}
:root[data-theme="dark"][data-accent="copper"] {
  --accent: #efa868;  --accent-strong: #f5c08f;  --accent-ink: #f7cca4;  --on-accent: #2a1606;
  --accent-tint: #2b2018;  --accent-line: #503a28;  --accent-glow: rgba(239, 168, 104, .18);
}
:root[data-theme="dark"][data-accent="violet"] {
  --accent: #b59df2;  --accent-strong: #cab8f6;  --accent-ink: #d5c6f8;  --on-accent: #1b1233;
  --accent-tint: #231d33;  --accent-line: #40365c;  --accent-glow: rgba(181, 157, 242, .18);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"])[data-accent="graphite"] {
  --accent: #aab5c0;  --accent-strong: #c8d0d8;  --accent-ink: #d2d9e0;  --on-accent: #12161a;
  --accent-tint: #1f2429;  --accent-line: #39414a;  --accent-glow: rgba(170, 181, 192, .18);
  }
  :root:not([data-theme="light"])[data-accent="burgundy"] {
  --accent: #f08ba3;  --accent-strong: #f6abbc;  --accent-ink: #f8bccb;  --on-accent: #2a0a12;
  --accent-tint: #2c1a1f;  --accent-line: #53303a;  --accent-glow: rgba(240, 139, 163, .18);
  }
  :root:not([data-theme="light"])[data-accent="copper"] {
  --accent: #efa868;  --accent-strong: #f5c08f;  --accent-ink: #f7cca4;  --on-accent: #2a1606;
  --accent-tint: #2b2018;  --accent-line: #503a28;  --accent-glow: rgba(239, 168, 104, .18);
  }
  :root:not([data-theme="light"])[data-accent="violet"] {
  --accent: #b59df2;  --accent-strong: #cab8f6;  --accent-ink: #d5c6f8;  --on-accent: #1b1233;
  --accent-tint: #231d33;  --accent-line: #40365c;  --accent-glow: rgba(181, 157, 242, .18);
  }
}

* { box-sizing: border-box; }

/* Several things below are laid out with flex or grid, which outranks the
   browser's own rule for [hidden] and would leave a "hidden" pane on screen.
   This settles it once for the whole sheet. */
[hidden] { display: none !important; }

html, body { height: 100%; }

/* The page never moves sideways. Long unbroken text (a document's file
   name, a station written without spaces) wraps instead of pushing a row
   wider than the screen, and anything that still would is clipped at the
   edge — `clip`, not `hidden`, so no scroll container is made and the sticky
   title bar keeps working. */
html, body { overflow-x: clip; }
body { overflow-wrap: anywhere; }
/* …but never inside a button or a unit: a word on a button is one word, and
   a flex row that is short of room otherwise squeezes "Update" into
   "Updat / e" and "km" into "k / m" rather than giving up a little of the
   box beside it. */
button, .btn, .chip, .seg, .odo-unit { overflow-wrap: normal; }

/* On a phone the scroll bar is noise: the page is scrolled with a thumb. */
@media (pointer: coarse), (display-mode: standalone) {
  html { scrollbar-width: none; }
  ::-webkit-scrollbar { display: none; width: 0; height: 0; }
}

body {
  margin: 0;
  font-family: var(--sans);
  font-size: var(--fs-base);
  line-height: 1.5;
  color: var(--text);
  /* A whisper of the car's colour in the paper itself, so the two vehicles
     feel like different rooms rather than the same page relabelled. */
  background:
    radial-gradient(1100px 460px at 50% -220px, var(--accent-glow), transparent 70%),
    var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  transition: background-color .25s ease;
}

h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }

.app { min-height: 100%; display: flex; flex-direction: column; }
.muted { color: var(--dim); font-size: var(--fs-sm); }

/* ---------------- 2. Frame ---------------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--gap);
  padding: 14px clamp(16px, 4vw, 40px);
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 20;
}

.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
/* The logo carries its own ground, so the box is only a frame for it: the
   corner radius a phone would give it, and a hairline so the light tile does
   not dissolve into a light page. */
.brand-mark {
  width: 40px; height: 40px; flex: 0 0 auto;
  border-radius: 10px; overflow: hidden;
  border: 1px solid var(--line);
}
.brand-mark img, .gate-mark img { display: block; width: 100%; height: 100%; }
.brand-mark .logo-dark, .gate-mark .logo-dark { display: none; }
:root[data-theme="dark"] .brand-mark .logo-light,
:root[data-theme="dark"] .gate-mark .logo-light { display: none; }
:root[data-theme="dark"] .brand-mark .logo-dark,
:root[data-theme="dark"] .gate-mark .logo-dark { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .brand-mark .logo-light,
  :root:not([data-theme="light"]) .gate-mark .logo-light { display: none; }
  :root:not([data-theme="light"]) .brand-mark .logo-dark,
  :root:not([data-theme="light"]) .gate-mark .logo-dark { display: block; }
}

.wordmark { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.wordmark b { font-size: 16px; font-weight: 700; letter-spacing: .16em; }
/* The name breaks at its hyphen if it must, never inside a word. */
.wordmark b { overflow-wrap: normal; word-break: keep-all; }
@media (max-width: 400px) { .wordmark b { letter-spacing: .1em; } }
.wordmark i {
  font-style: normal; font-size: var(--fs-meta); color: var(--faint);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.topbar-right { display: flex; align-items: center; gap: 10px; }
.today {
  font-size: var(--fs-meta); color: var(--dim);
  padding: 5px 11px; border: 1px solid var(--line); border-radius: 999px;
  white-space: nowrap;
}

/* Whether this browser is on its own or sharing one history with the other
   devices. It says which, always — a sync you cannot see is a sync you cannot
   trust with the only record of what the car has had done. */
.sync {
  display: inline-flex; align-items: center; gap: 7px; white-space: nowrap;
  font-size: var(--fs-meta); color: var(--dim);
  padding: 5px 11px; border: 1px solid var(--line); border-radius: 999px;
}
.sync i { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); flex: 0 0 auto; }
.sync b { font-weight: 550; }
.sync.is-live i { background: var(--fine); }
.sync.is-live { color: var(--fine-ink); border-color: color-mix(in srgb, var(--fine) 30%, var(--line)); }
/* Not reaching the server: kept here, waiting to go. */
.sync.is-waiting i { background: var(--soon); }
.sync.is-waiting { color: var(--soon-ink); border-color: color-mix(in srgb, var(--soon) 30%, var(--line)); }
.sync.is-busy i { background: var(--soon); }

.icon-btn {
  width: 36px; height: 36px; display: grid; place-items: center;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); color: var(--dim);
  cursor: pointer; transition: color .15s, border-color .15s, background .15s;
}
.icon-btn:hover { color: var(--text); border-color: var(--accent-line); }
.icon-btn svg { width: 18px; height: 18px; }

/* ── The two cars ─────────────────────────────────────────────────────────
   Big targets, because this is the one control the app is built around: one
   press and you are in that car's world. The chosen one lifts off the strip
   and takes the accent; the other stays quiet but still shows its worst
   status, so a glance at the tab you are not on still tells you something. */
.tabs {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
  padding: 18px clamp(16px, 4vw, 40px) 0;
  max-width: 1180px; width: 100%; margin: 0 auto;
}

.tab {
  /* min-width:0 matters: a grid item defaults to min-content width, and the
     no-wrap registration line inside would otherwise push the tab wider than
     its column and scroll the whole page sideways on a phone. */
  position: relative; display: flex; align-items: center; gap: 14px; min-width: 0;
  padding: 14px 16px; text-align: left; cursor: pointer;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); color: var(--text);
  box-shadow: var(--shadow);
  transition: transform .16s ease, border-color .16s, box-shadow .16s, background .16s;
}
.tab:hover { transform: translateY(-2px); }
/* Landscape, not square: both marques are wider than they are tall, and a
   square well would leave each one floating in a band of empty tint. */
.tab .tab-ico {
  width: 54px; height: 46px; flex: 0 0 auto; display: grid; place-items: center;
  border-radius: 12px; color: var(--faint);
  background: var(--idle-tint); border: 1px solid var(--line);
  transition: color .16s, background .16s, border-color .16s;
}
.tab .tab-ico .marque { width: 42px; height: 32px; }
/* The marques carry their own colours now, so the selected car can no
   longer be shown by tinting its badge. The unselected one steps back
   instead — muted and slightly faded, the way an inactive tab should be. */
.tab:not(.is-on) .tab-ico .marque { opacity: .7; filter: saturate(.35); }
.tab-txt { display: flex; flex-direction: column; min-width: 0; gap: 2px; }
.tab-name { font-weight: 650; font-size: 16px; }
.tab-meta { font-size: var(--fs-meta); color: var(--dim);
            white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tab-flag { margin-left: auto; display: flex; align-items: center; gap: 7px;
            font-size: var(--fs-meta); font-weight: 600; white-space: nowrap; }
.tab-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--idle); }
.tab-flag.is-late { color: var(--late-ink); } .tab-flag.is-late .tab-dot { background: var(--late); }
.tab-flag.is-soon { color: var(--soon-ink); } .tab-flag.is-soon .tab-dot { background: var(--soon); }
.tab-flag.is-fine { color: var(--fine-ink); } .tab-flag.is-fine .tab-dot { background: var(--fine); }

/* The selected car. `--tab-accent` is set inline per tab so the unselected
   tab can still hint at its own colour on hover without owning the page. */
.tab.is-on {
  border-color: var(--accent-line);
  background: linear-gradient(180deg, var(--accent-tint), var(--surface) 70%);
  box-shadow: var(--shadow), inset 0 0 0 1px var(--accent-line);
}
.tab.is-on .tab-ico {
  color: var(--accent); background: var(--surface); border-color: var(--accent-line);
}
.tab.is-on::after {
  content: ""; position: absolute; left: 16px; right: 16px; bottom: -1px; height: 3px;
  border-radius: 3px 3px 0 0; background: var(--accent);
}
.tab:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.sheet {
  flex: 1; width: 100%; max-width: 1180px; margin: 0 auto;
  padding: var(--gap) clamp(16px, 4vw, 40px) 40px;
  display: flex; flex-direction: column; gap: var(--gap);
}

/* ── Footer ───────────────────────────────────────────────────────────────
   A maker's mark, the way a painting is signed: present, quiet, and not
   asking to be read. The ink is a mask filled with the footer's own text
   colour, so it follows light and dark rather than arriving as a white plate
   on a dark page. */
.foot {
  padding: 18px clamp(16px, 4vw, 40px) 26px;
  max-width: 1180px; width: 100%; margin: 0 auto;
  border-top: 1px solid var(--line-soft);
  color: var(--faint); font-size: var(--fs-meta);
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--gap); flex-wrap: wrap;
}
.foot-mark { display: inline-flex; align-items: center; gap: .4em;
             opacity: .55; white-space: nowrap; transition: opacity .15s ease; }
.foot-mark:hover { opacity: .85; }
.foot-sig {
  /* 4.3 : 1.3em matches the artwork's own 512×155, so `contain` leaves no
     slack either side and the ink sits where the box says it does. */
  width: 4.3em; height: 1.3em;
  background-color: currentColor;
  -webkit-mask: url("assets/signature.png") no-repeat center / contain;
          mask: url("assets/signature.png") no-repeat center / contain;
}

/* ---------------- 3. Hero and tiles ---------------- */
/* Grid rather than flex, so the odometer stays in the right-hand column
   whatever the length of the car's name — on flex, the longer of the two
   titles wrapped the reading onto its own line and the two cars looked like
   two different layouts. */
.hero {
  display: grid; grid-template-columns: minmax(0, 1fr) auto;
  align-items: end; gap: var(--gap) 28px;
  padding: 20px 22px;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); box-shadow: var(--shadow);
}
.hero-id { display: flex; align-items: center; gap: 16px; min-width: 0; }
.hero-badge {
  width: 78px; height: 62px; flex: 0 0 auto; display: grid; place-items: center;
  border-radius: 16px; color: var(--accent);
  background: var(--accent-tint); border: 1px solid var(--accent-line);
}
.hero-badge .marque { width: 60px; height: 44px; }

/* The emblems are two different shapes — the Land Rover oval is far wider for
   its height than the Toyota — so each is fitted inside its well rather than
   stretched to it. user-select/drag off: they are furniture, not content. */
.marque { object-fit: contain; -webkit-user-drag: none; user-select: none; }
.hero h1 { font-size: clamp(20px, 2.4vw, 26px); }
.hero-sub { color: var(--dim); font-size: var(--fs-sm); margin-top: 3px; }
.hero-sub b { color: var(--accent); font-weight: 600; }

.hero-odo { min-width: 260px; }
.hero-odo > label {
  display: block; font-size: var(--fs-meta); color: var(--faint);
  text-transform: uppercase; letter-spacing: .09em; margin-bottom: 6px;
}
.odo-row { display: flex; align-items: center; gap: 8px; }
/* The reading box gives way when the row is tight; the unit and the buttons
   keep their size and stay on one line. */
.odo-row input {
  flex: 0 1 150px; width: 150px; min-width: 0; padding: 9px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--surface-2);
  font-variant-numeric: tabular-nums; font-size: 17px; font-weight: 600;
}
.odo-row input:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
.odo-unit { color: var(--faint); font-size: var(--fs-sm); }
.odo-row .odo-unit, .odo-row .btn { flex: none; white-space: nowrap; }
@media (max-width: 340px) {
  .odo-row { gap: 6px; }
  .odo-row input { padding: 9px 8px; }
  .odo-row .btn-accent { padding: 8px 11px; }
}
.odo-note { margin-top: 7px; font-size: var(--fs-meta); color: var(--faint); }
.odo-photo { padding: 8px 10px; display: inline-grid; place-items: center; }
.odo-photo svg { width: 20px; height: 20px; display: block; }
/* A reading from the photo, waiting to be checked: tinted until it is saved
   or typed over. */
#odoInput.is-read { border-color: var(--accent-line); background: var(--accent-tint); }
.odo-note.is-read { color: var(--accent-ink); }
.odo-note.is-warn { color: var(--soon-ink); }

.banner {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 14px 16px; border-radius: var(--radius);
  border: 1px solid var(--accent-line); background: var(--accent-tint);
  color: var(--accent-ink);
}
.banner-ico { flex: 0 0 auto; color: var(--accent); }
.banner-ico svg { width: 20px; height: 20px; display: block; margin-top: 1px; }
.banner b { display: block; font-size: var(--fs-base); }
.banner p { font-size: var(--fs-sm); opacity: .85; margin-top: 2px; }

/* The monthly check sits above the setup banner and can appear with it, so it
   is warned rather than accented: two identical panels stacked read as one
   long one, and the eye stops separating them. */
.banner-month {
  border-color: var(--soon); background: var(--soon-tint); color: var(--soon-ink);
}
.banner-month .banner-ico { color: var(--soon); }

/* A week's notice is not the same as a job waiting. Quieter, so that when the
   Saturday does arrive the banner changing colour means something. */
.banner-month.is-notice {
  border-color: var(--line); background: var(--surface-2); color: var(--dim);
}
.banner-month.is-notice .banner-ico { color: var(--faint); }
.banner-month.is-notice b { color: var(--text); }
#monthBanner + #setupBanner:not([hidden]) { margin-top: 10px; }

/* A backup that has stopped: the one banner in the late colour, because it is
   the one that is about losing things. */
.banner-backup { border-color: var(--late); background: var(--late-tint); color: var(--late-ink); margin-bottom: 10px; }
.banner-backup .banner-ico { color: var(--late); }
.banner-main { min-width: 0; flex: 1 1 auto; }
.banner-acts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }

.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.tile {
  padding: 14px 16px; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--surface);
  box-shadow: var(--shadow); cursor: pointer; text-align: left;
  transition: transform .14s ease, border-color .14s;
}
.tile:hover { transform: translateY(-2px); }
.tile .tile-n { font-size: 30px; font-weight: 680; line-height: 1.05;
                font-variant-numeric: tabular-nums; }
.tile .tile-l { font-size: var(--fs-sm); color: var(--dim); margin-top: 3px; }
.tile .tile-s { font-size: var(--fs-meta); color: var(--faint); margin-top: 2px; }
/* A count of nought keeps the neutral border: an outlined red tile reading
   "0 Overdue" is an alarm about nothing. */
.tile.late .tile-n { color: var(--late); }
.tile.late:not(.is-zero) { border-color: color-mix(in srgb, var(--late) 35%, var(--line)); }
.tile.is-zero .tile-n { color: var(--faint); }
.tile.soon .tile-n { color: var(--soon); }
.tile.fine .tile-n { color: var(--fine); }
.tile.idle .tile-n { color: var(--faint); }

/* ---------------- 4. Items ---------------- */
.segs { display: flex; gap: 4px; padding: 4px; border-radius: 12px;
        background: var(--idle-tint); border: 1px solid var(--line); align-self: flex-start; }
.seg {
  padding: 8px 16px; border: 0; border-radius: 9px; cursor: pointer;
  background: transparent; color: var(--dim); font-size: var(--fs-sm); font-weight: 550;
  transition: background .14s, color .14s;
}
.seg:hover { color: var(--text); }
.seg.is-on { background: var(--surface); color: var(--accent); box-shadow: var(--shadow); }

.pane { display: flex; flex-direction: column; gap: var(--gap); }

.filters { display: flex; align-items: center; justify-content: space-between;
           gap: 12px; flex-wrap: wrap; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  padding: 7px 14px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface);
  color: var(--dim); font-size: var(--fs-sm);
  transition: color .14s, border-color .14s, background .14s;
}
.chip:hover { color: var(--text); border-color: var(--accent-line); }
.chip.is-on { background: var(--accent); border-color: var(--accent);
              color: var(--on-accent); font-weight: 550; }

.search { position: relative; flex: 1; min-width: 220px; max-width: 380px; }
.search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
              width: 16px; height: 16px; color: var(--faint); pointer-events: none; }
.search input {
  width: 100%; padding: 9px 12px 9px 34px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface);
}
.search input:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }

.group {
  margin-bottom: 12px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); box-shadow: var(--shadow);
}
/* The heading is the whole row: icon, name, how it stands, and a chevron. */
.group-head {
  display: grid; grid-template-columns: 60px minmax(0, 1fr) auto 18px;
  align-items: center; gap: 14px; padding: 12px 16px 12px 12px; min-height: 84px;
  cursor: pointer; list-style: none; border-radius: var(--radius);
  -webkit-tap-highlight-color: transparent;
}
.group-head::-webkit-details-marker { display: none; }
.group-head:hover { background: var(--surface-2); }
.group-head:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.group[open] > .group-head { border-radius: var(--radius) var(--radius) 0 0; }
.group-head h2 { font-size: 16px; letter-spacing: .01em; margin: 0; }
.group-text { min-width: 0; }

/* The icons are line drawings (assets/jobs/, made with ImagineArt), used as a
   mask so they take the car's own colour — green for the Freelander, blue
   for the Corolla — and follow the theme, light or dark. */
.group-icon {
  width: 60px; height: 60px; border-radius: 16px; position: relative;
  background: var(--accent-tint); border: 1px solid var(--accent-line);
}
.group-icon::before {
  content: ""; position: absolute; inset: 6px; background: var(--accent-ink);
  -webkit-mask: var(--icon) center / contain no-repeat; mask: var(--icon) center / contain no-repeat;
}
.group-icon[data-icon="spanner"]   { --icon: url("assets/jobs/spanner.png"); }
.group-icon[data-icon="oil"]       { --icon: url("assets/jobs/oil.png"); }
.group-icon[data-icon="wheel"]     { --icon: url("assets/jobs/wheel.png"); }
.group-icon[data-icon="handbrake"] { --icon: url("assets/jobs/handbrake.png"); }
.group-icon[data-icon="airbag"]    { --icon: url("assets/jobs/airbag.png"); }
.group-icon[data-icon="cambelt"]   { --icon: url("assets/jobs/cambelt.png"); }
.group-icon[data-icon="papers"]    { --icon: url("assets/jobs/papers.png"); }

.group-count {
  font-size: var(--fs-meta); font-weight: 650; white-space: nowrap;
  padding: 4px 10px; border-radius: 999px;
}
.group-count.is-late  { background: var(--late-tint); color: var(--late-ink); }
.group-count.is-soon  { background: var(--soon-tint); color: var(--soon-ink); }
.group-count.is-ok    { background: var(--fine-tint); color: var(--fine-ink); }
.group-count.is-unset { background: var(--idle-tint); color: var(--idle-ink); }

.group-chev { width: 18px; height: 18px; fill: none; stroke: var(--dim); stroke-width: 2.2;
  stroke-linecap: round; stroke-linejoin: round; transition: transform .2s ease; }
.group[open] .group-chev { transform: rotate(180deg); }

/* Open: the jobs sit inside the section, on the page's own ground, so each
   job card still reads as a card. */
.group > .items {
  padding: 12px; border-top: 1px solid var(--line-soft);
  background: var(--bg); border-radius: 0 0 var(--radius) var(--radius);
}

/* A phone has no room for the badge beside a long name: it goes under it. */
@media (max-width: 520px) {
  .group-head { grid-template-columns: 52px minmax(0, 1fr) 18px; gap: 12px; min-height: 76px; }
  .group-icon { width: 52px; height: 52px; border-radius: 14px; }
  .group-icon::before { inset: 5px; }
  .group-count { grid-column: 2; grid-row: 2; justify-self: start; margin-top: -4px; }
  .group-chev { grid-column: 3; grid-row: 1 / span 2; }
  .group-icon { grid-row: 1 / span 2; }
  .group > .items { padding: 10px; }
}

/* min() so a narrow phone gets one full-width column instead of a 330px card
   hanging off the right edge. */
.items { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(330px, 100%), 1fr));
         gap: 12px; align-items: stretch; }

/* One card per item. The left edge carries the verdict as a colour bar, so a
   page of twenty items can be read from a metre away before a word of it. */
.item {
  position: relative; overflow: hidden;
  padding: 14px 16px 14px 18px; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--surface);
  box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 9px;
}
.item::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
  background: var(--idle);
}
.item.is-overdue::before { background: var(--late); }
.item.is-soon::before    { background: var(--soon); }
.item.is-ok::before      { background: var(--fine); }
.item.is-overdue { border-color: color-mix(in srgb, var(--late) 34%, var(--line)); }

.item-top { display: flex; align-items: flex-start; gap: 10px; }
.item-name { font-weight: 620; font-size: 15px; line-height: 1.3; }
.item-what { font-size: var(--fs-sm); color: var(--dim); }

.pill {
  margin-left: auto; flex: 0 0 auto;
  padding: 3px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 650;
  letter-spacing: .03em; text-transform: uppercase; white-space: nowrap;
  border: 1px solid transparent;
}
.pill.overdue { background: var(--late-tint); color: var(--late-ink); border-color: color-mix(in srgb, var(--late) 40%, transparent); }
.pill.soon    { background: var(--soon-tint); color: var(--soon-ink); border-color: color-mix(in srgb, var(--soon) 40%, transparent); }
.pill.ok      { background: var(--fine-tint); color: var(--fine-ink); border-color: color-mix(in srgb, var(--fine) 32%, transparent); }
.pill.unset   { background: var(--idle-tint); color: var(--idle-ink); border-color: var(--line); }

.bar { height: 6px; border-radius: 999px; background: var(--idle-tint); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 999px; background: var(--fine); transition: width .3s ease; }
.item.is-soon .bar > i    { background: var(--soon); }
.item.is-overdue .bar > i { background: var(--late); }
.item.is-unset .bar       { opacity: .5; }

.item-when { font-size: var(--fs-sm); font-weight: 550; }
.item.is-overdue .item-when { color: var(--late-ink); }
.item.is-soon .item-when    { color: var(--soon-ink); }
.item-meta { font-size: var(--fs-meta); color: var(--faint); display: flex;
             gap: 6px; flex-wrap: wrap; align-items: center; }
.item-meta .sep { opacity: .5; }
.item-spec { font-size: var(--fs-meta); color: var(--dim);
             padding: 7px 10px; border-radius: var(--radius-sm);
             background: var(--surface-2); border: 1px solid var(--line-soft); }

.flag-verify {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 1px 7px; border-radius: 999px; font-size: 11px; font-weight: 600;
  background: var(--soon-tint); color: var(--soon-ink);
  border: 1px solid color-mix(in srgb, var(--soon) 30%, transparent);
}

/* margin-top:auto lines the buttons up along the bottom of every card in a
   row, however uneven the text above them is. */
.item-acts { display: flex; gap: 7px; margin-top: auto; padding-top: 2px; flex-wrap: wrap; }

.btn {
  padding: 8px 14px; border-radius: var(--radius-sm); cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  font-size: var(--fs-sm); font-weight: 550;
  transition: border-color .14s, background .14s, color .14s, transform .1s;
}
.btn:hover { border-color: var(--accent-line); background: var(--accent-tint); color: var(--accent-ink); }
.btn:active { transform: translateY(1px); }
.btn-accent { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-accent:hover { background: var(--accent-strong); border-color: var(--accent-strong);
                    color: var(--on-accent); }
.btn-quiet { background: transparent; color: var(--dim); }
.btn-sm { padding: 6px 11px; font-size: var(--fs-meta); }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }

.empty { padding: 30px; text-align: center; color: var(--faint); font-size: var(--fs-sm); }

/* ---------------- 5. History, the car, modals ---------------- */
.hist-head { display: flex; align-items: flex-end; justify-content: space-between;
             gap: 12px; flex-wrap: wrap; }
.hist-head h2 { font-size: 17px; }

.hist-year { margin-bottom: 18px; }
.hist-year > h3 {
  font-size: var(--fs-meta); color: var(--faint); letter-spacing: .1em;
  text-transform: uppercase; padding-bottom: 8px;
  border-bottom: 1px solid var(--line-soft); margin-bottom: 10px;
  display: flex; justify-content: space-between;
}
.log {
  display: grid; grid-template-columns: 108px minmax(0, 1fr) auto auto; gap: 14px;
  align-items: baseline; padding: 11px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--line-soft); background: var(--surface); margin-bottom: 7px;
}
.log-date { font-size: var(--fs-sm); color: var(--dim); font-variant-numeric: tabular-nums; }
.log-what b { font-weight: 620; }
.log-sub { font-size: var(--fs-meta); color: var(--faint); }
.log-cost { font-variant-numeric: tabular-nums; font-weight: 600; font-size: var(--fs-sm); }
.log-del { border: 0; background: none; color: var(--faint); cursor: pointer;
           font-size: var(--fs-meta); padding: 0 2px; }
.log-del:hover { color: var(--late); }

.card {
  padding: 18px 20px; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow);
}
.card h2 { font-size: 16px; margin-bottom: 4px; }
.card h3 { font-size: var(--fs-sm); margin: 16px 0 8px; color: var(--dim); }

.facts { display: grid; gap: 2px; margin-top: 12px; }
.fact {
  display: grid; grid-template-columns: 150px 1fr; gap: 12px; align-items: center;
  padding: 8px 0; border-bottom: 1px solid var(--line-soft); font-size: var(--fs-sm);
}
.fact:last-child { border-bottom: 0; }
.fact > span, .fact > label { color: var(--faint); }
.fact > label { cursor: text; }
.fact > span i, .fact > label i { font-style: normal; opacity: .7; }
.fact input, .fact textarea {
  width: 100%; padding: 6px 9px; border-radius: 8px;
  border: 1px solid transparent; background: transparent; color: var(--text);
}
/* The value fields are textareas so a long spec wraps instead of being cut
   off at the edge of a narrow column. They are sized in JS to their content
   and must not look or behave like a box you can drag. */
.fact textarea {
  font: inherit; resize: none; overflow: hidden;
  display: block; min-height: 0; line-height: 1.45;
}
.fact input:hover, .fact textarea:hover { border-color: var(--line); }
.fact input:focus, .fact textarea:focus {
  outline: 2px solid var(--accent); outline-offset: 0; background: var(--surface-2);
}
.fact-static { color: var(--text); }
.fact-note { grid-column: 1 / -1; font-size: var(--fs-meta); color: var(--faint); margin-top: -4px; }

.remind-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(min(190px, 100%), 1fr));
  gap: 12px; margin-top: 14px;
}
.remind-note { margin-top: 10px; }

.notes { margin: 12px 0 0; padding: 0; list-style: none; display: grid; gap: 10px; }
.notes li {
  position: relative; padding-left: 20px; font-size: var(--fs-sm); color: var(--dim);
}
.notes li::before {
  content: ""; position: absolute; left: 4px; top: .55em;
  width: 6px; height: 6px; border-radius: 50%; background: var(--accent);
}

.modal {
  width: min(560px, calc(100vw - 28px)); padding: 0; border: 0;
  border-radius: var(--radius); background: var(--surface); color: var(--text);
  box-shadow: var(--shadow-lg);
}
.modal::backdrop { background: rgba(10, 18, 15, .5); backdrop-filter: blur(2px); }
.modal-head { display: flex; align-items: center; justify-content: space-between;
              gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.modal-head h2 { font-size: 16px; }
.modal-body { padding: 16px 18px; display: grid; gap: 12px;
              max-height: min(64vh, 560px); overflow: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px;
              padding: 14px 18px; border-top: 1px solid var(--line); background: var(--surface-2); }

.fld { display: grid; gap: 5px; }
.fld > span { font-size: var(--fs-meta); color: var(--faint);
              text-transform: uppercase; letter-spacing: .07em; }
.fld > span i { font-style: normal; text-transform: none; letter-spacing: 0; opacity: .75; }
.fld input, .fld select, .fld textarea {
  padding: 9px 11px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--surface-2); width: 100%;
}
.fld input:focus, .fld select:focus, .fld textarea:focus {
  outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent;
}
.fld-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.check { display: flex; align-items: center; gap: 9px; font-size: var(--fs-sm); color: var(--dim); }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }

/* ---------------- 6. Small print ---------------- */
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
  background: var(--text); color: var(--surface); padding: 10px 18px;
  border-radius: 999px; font-size: var(--fs-sm); box-shadow: var(--shadow-lg); z-index: 60;
  /* Its own width, not half the screen's: left: 50% would otherwise cap a
     shrink-to-fit pill at the half it starts from. */
  width: max-content; max-width: calc(100vw - 32px);
}
.toast.err { background: var(--late); color: #fff; }
/* With an Undo in it: the action on the right, in the accent the dark pill
   can carry. */
.toast.has-action { display: flex; align-items: center; gap: 14px; padding-right: 8px; }
.toast-undo {
  font: inherit; font-weight: 700; color: var(--accent-ink); background: var(--accent-tint);
  border: 0; border-radius: 999px; padding: 5px 12px; cursor: pointer;
}

@media (max-width: 860px) {
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hero  { grid-template-columns: 1fr; align-items: stretch; }
  .hero-odo { min-width: 0; }
  .log { grid-template-columns: minmax(0, 1fr) auto auto; }
  .log-date { grid-column: 1 / -1; }
  .fact { grid-template-columns: 1fr; gap: 2px; }
}
@media (max-width: 620px) {
  .tabs { grid-template-columns: 1fr; }
  .items { grid-template-columns: 1fr; }
  .wordmark i { display: none; }
  .today { display: none; }
  .fld-row { grid-template-columns: 1fr; }
  .segs { align-self: stretch; }
  .seg { flex: 1; text-align: center; padding: 8px 6px; }
}

@media print {
  .topbar, .tabs, .segs, .filters, .item-acts, .foot, .banner, .btn { display: none !important; }
  body { background: #fff; }
  .item, .hero, .card { break-inside: avoid; box-shadow: none; }
}

/* Reduced motion means nothing slides, spins or grows — not that nothing
   changes. Colour and fades stay, short, so a toast or a selection still
   reads as having happened. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition-property: opacity, color, background-color, border-color, outline-color !important;
    transition-duration: .15s !important;
  }
}

/* ---------------- 7. The car in three dimensions ----------------
   The car and its details side by side, ending level, with the parts list
   full width underneath where its height cannot push the car around.

   The row takes its height from the details, because every field has to be
   readable without scrolling and there are thirteen of them. The car's box
   grows to meet it. That is the opposite of what this section used to do,
   and the reason it is safe now is that the height is settled when the pane
   renders: the panel that used to set it changed as you turned the car, so
   the page moved under your thumb. Nothing here reacts to a drag. */
.stage-wrap {
  --stage-h: 420px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(250px, 25%, 310px);
  gap: var(--gap); align-items: stretch;
}
.stage-wrap > .stage-side { grid-column: 1 / -1; }
/* No model for this car: the details card takes the whole row, at its own
   height — there is nothing beside it to match. */
.stage-wrap.is-bare { grid-template-columns: minmax(0, 1fr); }


/* The card is read at a glance or it is not worth having beside the car, so
   it is never the thing that scrolls: the row takes its height from whichever
   box is taller, and the car's box grows to meet it. --stage-h is a floor, not
   a fixed height — the car keeps its own box on a car with few fields.

   What must not happen is the thing that made the page jump under a thumb:
   heights here are settled when the pane renders and cannot change while you
   are turning the car. */
.details-card { overflow: visible; }
/* Label over value in this column: the oil spec and the gearbox run to
   forty-odd characters, and beside a label in a card this narrow they would
   be cut off mid-word in a field you cannot widen. */
.stage-wrap:not(.is-bare) .fact {
  grid-template-columns: minmax(0, 1fr); gap: 0; padding: 3px 0;
}
.stage-wrap:not(.is-bare) .fact > span, .stage-wrap:not(.is-bare) .fact > label { font-size: var(--fs-meta); }
.stage-wrap:not(.is-bare) .fact textarea { padding: 4px 8px; margin-left: -8px; }

.stage {
  position: relative; min-height: var(--stage-h, 420px);
  border-radius: var(--radius); border: 1px solid var(--line);
  background:
    radial-gradient(120% 80% at 50% 12%, var(--accent-tint), transparent 70%),
    var(--surface);
  box-shadow: var(--shadow); overflow: hidden;
}
.stage canvas {
  display: block; width: 100%; height: 100%;
  cursor: grab; touch-action: none;
}
.stage canvas.is-grabbing { cursor: grabbing; }

.stage-hint {
  position: absolute; left: 0; right: 0; bottom: 10px;
  text-align: center; font-size: var(--fs-meta); color: var(--faint);
  pointer-events: none; transition: opacity .4s ease;
}
.stage-hint.is-gone { opacity: 0; }

/* Under the car now, not beside it. Nothing here can move the stage, so the
   list is free to be whatever height its region needs — which is why the
   reservation that used to pin it to its tallest is gone: side by side it
   stopped the page reflowing under your thumb, and stacked it only left four
   hundred pixels of nothing under a three-line region. */
.stage-side { display: flex; flex-direction: column; gap: 12px; min-width: 0; }

.stage-region {
  padding: 16px 18px; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow);
}
.stage-region h2 { font-size: 17px; margin: 2px 0 4px; }

/* One line per item, with its state as a dot rather than a pill: this is a
   glance surface, and five pills in a column shout. */
.region-line {
  display: grid; grid-template-columns: 9px minmax(0, 1fr) auto;
  gap: 9px; align-items: baseline;
  padding: 7px 0; border-bottom: 1px solid var(--line-soft);
  font-size: var(--fs-sm);
}
.region-line:last-child { border-bottom: 0; }
.region-line .dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--idle);
  transform: translateY(-1px);
}
.region-line.is-overdue .dot { background: var(--late); }
.region-line.is-soon .dot    { background: var(--soon); }
.region-line.is-ok .dot      { background: var(--fine); }
.region-line .when { font-size: var(--fs-meta); color: var(--faint); white-space: nowrap; }
.region-line.is-overdue .when { color: var(--late-ink); }

.stage-jump { display: flex; flex-wrap: wrap; gap: 6px; }
.stage-jump .chip { font-size: var(--fs-meta); padding: 6px 12px; }
/* Clear: puts the list away. Red, so it reads as the way out, not a part. */
.stage-jump .chip-clear, .stage-jump .chip-clear:hover {
  color: var(--late-ink); background: var(--late-tint); border-color: var(--late-tint); font-weight: 600;
}

/* No room for two columns on a phone: the details card goes under the car at
   its own height, where nothing has to scroll inside anything. */
@media (max-width: 860px) {
  .stage-wrap { --stage-h: 300px; grid-template-columns: minmax(0, 1fr); }
  .stage { min-height: 0; height: var(--stage-h); }
  .stage-wrap:not(.is-bare) .fact { gap: 2px; padding: 8px 0; }
}

@media (prefers-reduced-motion: reduce) {
  /* The idle spin is decoration; dragging still works. app.js reads this. */
  .stage { --no-autospin: 1; }
}

/* ---------------- 7. Fuel ----------------
   The graph is inline SVG rather than a library: it is one polyline, some
   gridlines and a row of labels, and a chart library for that would weigh
   more than the rest of the app put together. */
.fuel-head {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  margin-bottom: var(--gap);
}
.fuel-head .muted { font-size: var(--fs-sm); }

.fuel-card { margin-bottom: var(--gap); }
.fuel-card h2 { font-size: 17px; margin: 0 0 4px; }
.fuel-card-head {
  display: flex; gap: 12px; align-items: center; justify-content: space-between;
  flex-wrap: wrap; margin-bottom: 10px;
}
.seg-small { display: flex; gap: 6px; }
.seg-small .chip { font-size: var(--fs-meta); padding: 5px 11px; }

.fuel-chart { width: 100%; }
.fuel-chart svg { display: block; width: 100%; height: auto; }
.fuel-chart .grid { stroke: var(--line); stroke-width: 1; }
.fuel-chart .axis { fill: var(--faint); font-size: 10px; }
.fuel-chart .line { fill: none; stroke: var(--accent); stroke-width: 2.5;
                    stroke-linejoin: round; stroke-linecap: round; }
.fuel-chart .area { fill: var(--accent-glow); }
.fuel-chart .dot  { fill: var(--surface); stroke: var(--accent); stroke-width: 2; }
/* A month with no fills is a real zero, not a missing reading, so it is
   marked differently rather than drawn as an ordinary point on the line. */
.fuel-chart .dot.is-zero { fill: var(--accent); stroke: none; opacity: .35; }

.fuel-empty { color: var(--dim); font-size: var(--fs-sm); padding: 8px 0 2px; }

.fill-row {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 14px;
  align-items: baseline; padding: 11px 0; border-top: 1px solid var(--line-soft);
  cursor: pointer;
}
.fill-row:first-child { border-top: 0; }
.fill-row:hover { background: var(--surface-2); }
.fill-when { font-weight: 600; }
.fill-where { color: var(--faint); font-size: var(--fs-meta); font-weight: 400; }
.fill-amount { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.fill-row > * { min-width: 0; }
.fill-sub { grid-column: 1 / -1; color: var(--dim); font-size: var(--fs-meta); }

.fuel-rate { min-height: 1.2em; }

.slip-read { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 4px; }
.slip-read img {
  width: 92px; height: 120px; object-fit: cover; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--surface-2);
}

@media (max-width: 620px) {
  .fill-row { grid-template-columns: 1fr auto; }
  .slip-read img { width: 74px; height: 96px; }
}

.fuel-filter {
  display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap;
  margin-bottom: var(--gap);
}
.fuel-filter .fld { min-width: 0; }
.fuel-filter select { min-width: 132px; }
.fuel-chart .dot.is-pick { fill: var(--accent); stroke: var(--surface); stroke-width: 2.5; }

/* The two ways to a slip. Big targets with a picture on each: this is read
   at arm's length at a pump, often in sunlight. */
.modal-narrow { max-width: 420px; }
.pickers { display: grid; gap: 10px; }
.picker {
  display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto;
  column-gap: 14px; align-items: center; text-align: left;
  padding: 16px; border-radius: var(--radius); cursor: pointer;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--text);
  font: inherit;
}
.picker:hover, .picker:focus-visible {
  border-color: var(--accent-line); background: var(--accent-tint);
}
.picker:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.picker-ico { grid-row: 1 / 3; color: var(--accent); }
.picker-ico svg { width: 30px; height: 30px; display: block; }
.picker-t { font-weight: 600; }
.picker-s { font-size: var(--fs-meta); color: var(--dim); }

/* ---- the period wheels ----
   Scroll-snap, not drag maths: the platform's own inertia, keyboard handling
   and accessibility come with it, and on a phone this is the same gesture
   the native date picker uses. */
.period { display: flex; flex-direction: column; align-items: flex-start; gap: 1px;
          padding: 8px 14px; }
.period-l { font-size: var(--fs-meta); color: var(--faint); }
.period-v { font-weight: 600; }

.wheels { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.wheel-col { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.wheel-h { font-size: var(--fs-meta); color: var(--faint); letter-spacing: .06em;
           text-transform: uppercase; }

.wheel {
  --item: 42px;
  position: relative; height: calc(var(--item) * 5);
  overflow-y: auto; scroll-snap-type: y mandatory;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface-2);
  /* Hidden, because the band in the middle is the affordance and a bar down
     the side of a wheel reads as a list that has been squashed. */
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}
.wheel::-webkit-scrollbar { display: none; }

/* Two blank items above and below, so the first and last can reach the
   middle. Without them the wheel can only centre its interior. */
.wheel-pad { height: calc(var(--item) * 2); }

.wheel-item {
  height: var(--item); scroll-snap-align: center;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; color: var(--dim);
  transition: color .12s ease, font-weight .12s ease;
  cursor: pointer; user-select: none;
}
.wheel-item.is-on { color: var(--accent-ink); font-weight: 650; font-size: 16.5px; }
.wheel:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* The band that says which one counts. A sibling of the scroller rather than
   a child, or it scrolls away with the list it is marking. Behind the items,
   and ignoring the pointer so a tap lands on a row and not on decoration. */
.wheel-wrap { position: relative; --item: 42px; }
.wheel-band {
  position: absolute; left: 1px; right: 1px; top: 50%;
  height: var(--item); transform: translateY(-50%);
  border-top: 1px solid var(--accent-line); border-bottom: 1px solid var(--accent-line);
  background: var(--accent-tint); pointer-events: none; z-index: 0;
}
.wheel { position: relative; z-index: 1; background: transparent; }
.wheel-wrap::before {
  /* The scroller's own surface, under the band. */
  content: ''; position: absolute; inset: 0; border-radius: var(--radius-sm);
  background: var(--surface-2);
}

.hist-acts { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* ---------------- 8. Papers ----------------
   The drawer: what the car costs every month, and the paper that says so. */
.papers-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; margin-bottom: 4px;
}
.papers-head h2 { margin-bottom: 2px; }

/* One line per document, the kind as a quiet tag on the left so a drawer of
   twenty can be skimmed for the contract without reading any of the names. */
.doc {
  display: grid; grid-template-columns: 96px minmax(0, 1fr) auto auto;
  gap: 14px; align-items: baseline;
  padding: 11px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--line-soft); background: var(--surface); margin-bottom: 7px;
}
.doc-kind {
  font-size: var(--fs-meta); color: var(--faint);
  text-transform: uppercase; letter-spacing: .06em;
}
.doc-name { font-size: var(--fs-sm); font-weight: 560; overflow-wrap: anywhere; }
.doc-meta { font-size: var(--fs-meta); color: var(--faint); white-space: nowrap; }
.doc-acts { display: flex; gap: 10px; align-items: center; }

/* ---------------- The lock ----------------
   A whole screen, not a box over the app: nothing of the cars shows round its
   edges, and in the app switcher a locked Car-diology is a logo and nothing
   else. Until the app has decided who is there, <html> carries is-gated and
   the app underneath is not drawn at all. */
html.is-gated .app { visibility: hidden; }
.gate {
  position: fixed; inset: 0; z-index: 100;
  width: 100%; height: 100%; max-width: none; max-height: none; margin: 0;
  border: 0; padding: max(24px, env(safe-area-inset-top)) 20px max(24px, env(safe-area-inset-bottom));
  background: var(--bg); color: var(--text);
  display: flex; align-items: center; justify-content: center;
}
.gate:not([open]) { display: none; }
.gate:focus, .gate:focus-visible { outline: none; }
.gate::backdrop { background: var(--bg); }
.gate-card {
  width: min(360px, 100%); display: grid; gap: 14px; justify-items: center; text-align: center;
}
.gate-mark {
  width: 72px; height: 72px; border-radius: 18px; overflow: hidden;
  border: 1px solid var(--line); box-shadow: var(--shadow);
}
.gate h1 { font-size: 20px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; margin: 2px 0 0; }
.gate-msg { color: var(--dim); font-size: var(--fs-sm); margin: 0; max-width: 32ch; }
.gate-step { display: grid; gap: 10px; width: 100%; text-align: left; margin-top: 6px; }
.gate-step .fld input { font-size: 16px; padding: 11px 12px; } /* 16px: iOS zooms on anything smaller */
.gate-go { width: 100%; justify-content: center; padding-top: 12px; padding-bottom: 12px; font-size: 15px; }
.gate-step .btn-quiet { justify-self: center; }
.gate-err {
  margin: 0; width: 100%; padding: 10px 12px; border-radius: var(--radius-sm);
  background: var(--late-tint); color: var(--late-ink); font-size: var(--fs-sm); text-align: left;
}
/* The cover while the app is in the background: the logo, nothing else. */
.gate.is-cover .gate-msg, .gate.is-cover h1 { visibility: hidden; }

/* ---------------- Invoices on history entries ---------------- */
.invoice-pick { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.log-inv {
  margin-top: 5px; font: inherit; font-size: var(--fs-meta); font-weight: 600; cursor: pointer;
  color: var(--accent-ink); background: var(--accent-tint); border: 1px solid var(--accent-line);
  border-radius: 999px; padding: 3px 10px;
}
.log-inv.is-add { background: transparent; color: var(--dim); border-style: dashed; }

/* ---------------- The vault ---------------- */
.vault-key {
  font: 600 15px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  letter-spacing: .02em; word-break: break-all; user-select: all; -webkit-user-select: all;
  padding: 12px 14px; border-radius: var(--radius-sm);
  background: var(--surface-2); border: 1px dashed var(--accent-line); color: var(--text);
}
.vault-steps { margin: 4px 0 0; padding-left: 20px; display: grid; gap: 8px; font-size: var(--fs-sm); color: var(--dim); }
.vault-steps code { font-size: 12.5px; background: var(--surface-2); padding: 1px 5px; border-radius: 5px; }
.backup-line {
  margin: 10px 0 4px; padding: 10px 12px; border-radius: var(--radius-sm);
  background: var(--fine-tint); color: var(--fine-ink); font-size: var(--fs-sm);
}
.backup-line.is-bad { background: var(--late-tint); color: var(--late-ink); }
.backup-line.is-idle { background: var(--idle-tint); color: var(--idle-ink); }
.seal-note {
  display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; justify-content: space-between;
  margin: 8px 0 12px; padding: 10px 12px; border-radius: var(--radius-sm);
  background: var(--soon-tint); color: var(--soon-ink); font-size: var(--fs-sm);
}
.doc-lock { font-size: var(--fs-meta); color: var(--faint); margin-left: 6px; }
.restore-list { margin: 8px 0 0; padding-left: 18px; display: grid; gap: 4px; font-size: var(--fs-sm); color: var(--dim); }
.restore-list .is-missing { color: var(--late-ink); }

/* ---------------- The 3D scan ---------------- */
.stage canvas[hidden] { display: none; }
#scanStage, #modelStage { position: absolute; inset: 0; display: block; width: 100%; height: 100%; touch-action: none; }
.scan-load {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  display: grid; gap: 8px; justify-items: center; width: min(260px, 80%);
  font-size: var(--fs-sm); color: var(--dim); text-align: center;
}
.scan-load progress, .scan-progress progress { width: 100%; height: 6px; accent-color: var(--accent); }
.scan-tools {
  position: absolute; left: 10px; right: 10px; bottom: 10px;
  display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; justify-content: space-between;
  padding: 8px 10px; border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: blur(6px);
  border: 1px solid var(--line); font-size: var(--fs-meta); color: var(--dim);
}
.scan-tool-btns { display: flex; gap: 6px; margin-left: auto; }
.scan-progress { display: grid; gap: 6px; margin: 10px 0 4px; }
.scan-how { margin-top: 10px; font-size: var(--fs-sm); color: var(--dim); }
.scan-how summary { cursor: pointer; color: var(--accent-ink); font-weight: 550; }
.scan-how ol { margin: 10px 0 0; padding-left: 20px; display: grid; gap: 7px; }

.doc.passkey-row { grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 2px 12px; }
.doc.passkey-row .doc-meta { grid-column: 1; }
.doc.passkey-row .btn { grid-column: 2; grid-row: 1 / span 2; }

.fld-check {
  display: flex; align-items: center; gap: 10px; margin-top: 14px;
  font-size: var(--fs-sm); color: var(--dim); cursor: pointer;
}
.fld-check input { width: 17px; height: 17px; accent-color: var(--accent); cursor: pointer; }

@media (max-width: 620px) {
  .doc { grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; }
  .doc-kind { grid-column: 1 / -1; }
  .doc-acts { grid-column: 1 / -1; margin-top: 6px; }
}

/* ---------------- Settings ----------------
   A list of rows, each opening in place. The state on the right of a row is
   the answer to "is this on?", so the window can be read without opening
   anything. On a phone it is the whole screen, like the phone's own. */
/* A small window hanging from the gear at the top right (app.js places it
   under the gear), opening out of that corner and folding back into it. */
.settings {
  position: fixed; inset: auto; margin: 0;
  width: min(400px, calc(100vw - 28px)); max-width: calc(100vw - 28px);
  transform-origin: top right;
  border: 1px solid var(--line);
  box-shadow: 0 18px 50px rgba(16, 30, 24, .22), 0 2px 6px rgba(16, 30, 24, .08);
}
.settings[open] { display: flex; flex-direction: column; animation: set-in .22s cubic-bezier(.2, .8, .3, 1); }
.settings.is-closing { animation: set-out .17s ease-in forwards; }
.settings::backdrop { background: rgba(10, 18, 15, .06); backdrop-filter: none; }
@keyframes set-in  { from { opacity: 0; transform: translateY(-6px) scale(.94); } to { opacity: 1; transform: none; } }
@keyframes set-out { from { opacity: 1; transform: none; } to { opacity: 0; transform: translateY(-6px) scale(.94); } }
.settings .modal-head { flex: 0 0 auto; padding: 12px 14px 12px 18px; }
/* In the narrow window the name keeps its line and the state takes what is
   left, trimmed with an ellipsis only if it must be. */
.settings .set-sec > summary { grid-template-columns: 34px auto minmax(0, 1fr) 12px; gap: 10px; padding-inline: 16px; }
.settings .set-name { white-space: nowrap; }
.settings .set-state { max-width: none; min-width: 0; }
.settings .set-body { padding-left: 18px; }

/* The gear turns as Settings opens, and back the other way as it closes. */
#settingsBtn svg { transition: transform .5s cubic-bezier(.3, .7, .25, 1); }
#settingsBtn.is-open svg { transform: rotate(180deg); }
#settingsBtn.is-open { color: var(--accent-ink); border-color: var(--accent-line); background: var(--accent-tint); }
.set-list { flex: 1 1 auto; overflow: auto; overscroll-behavior: contain; padding: 4px 0 8px; }
.set-sec { border-bottom: 1px solid var(--line-soft); }
.set-sec:last-child { border-bottom: 0; }
.set-sec > summary {
  list-style: none; cursor: pointer; min-height: 58px;
  display: grid; grid-template-columns: 34px minmax(0, 1fr) auto 12px; align-items: center; gap: 12px;
  padding: 11px 18px; -webkit-tap-highlight-color: transparent;
}
.set-sec > summary::-webkit-details-marker { display: none; }
.set-sec > summary:hover, .set-sec[open] > summary { background: var(--surface-2); }
.set-sec > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.set-ico {
  width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center;
  background: var(--accent-tint); color: var(--accent-ink);
}
.set-ico svg { width: 18px; height: 18px; }
.set-name { font-weight: 600; }
.set-state {
  font-size: var(--fs-meta); color: var(--dim); text-align: right;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 220px;
}
.set-state.is-on { color: var(--fine-ink); }
.set-state.is-bad { color: var(--late); font-weight: 600; }
.set-chev {
  width: 8px; height: 8px; justify-self: center;
  border-right: 2px solid var(--faint); border-bottom: 2px solid var(--faint);
  transform: rotate(-45deg); transition: transform .15s;
}
.set-sec[open] > summary .set-chev { transform: rotate(45deg); }
.set-body { padding: 6px 18px 18px 64px; display: grid; gap: 10px; background: var(--surface-2); }
.set-body .btn-row { margin-top: 2px; }
.set-body .remind-grid { margin-top: 2px; }
.set-body .scan-how { margin-top: 0; }
.set-part h3 { font-size: var(--fs-sm); margin-bottom: 4px; }
.set-part:not([hidden]) ~ .set-part { border-top: 1px solid var(--line); padding-top: 14px; margin-top: 4px; }
.set-pick .chip { padding-inline: 14px; }

@media (max-width: 620px) {
  .set-list { padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px)); }
}

/* ---------------- Tyres ----------------
   The forecast on the Tyre replacement card: how far this set has gone,
   when to start shopping, when it is due. */
.tyre-cast {
  margin-top: 8px; padding: 9px 11px; border-radius: var(--radius-sm);
  background: var(--accent-tint); color: var(--text);
  font-size: var(--fs-sm); display: grid; gap: 4px; line-height: 1.45;
}
.tyre-cast b { font-weight: 650; }
.item.is-soon .tyre-cast { background: var(--soon-tint); }
.item.is-overdue .tyre-cast { background: var(--late-tint); }

/* The tyre warning: amber to start looking, red once the set is used up. */
.banner-tyres { border-color: var(--soon); background: var(--soon-tint); color: var(--soon-ink); margin-bottom: 10px; }
.banner-tyres .banner-ico { color: var(--soon); }
.banner-tyres.is-red { border-color: var(--late); background: var(--late-tint); color: var(--late-ink); }
.banner-tyres.is-red .banner-ico { color: var(--late); }
.banner-tyres.is-red .btn-accent { background: var(--late); border-color: var(--late); color: #fff; }

/* A vault key: shown as dots without being a password field, so browsers
   do not fill the sign-in password into it. */
.key-field { display: flex; gap: 8px; align-items: center; }
.key-field input { flex: 1 1 auto; min-width: 0; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.secret { -webkit-text-security: disc; }
.secret.is-shown { -webkit-text-security: none; }
.set-version { text-align: center; font-size: var(--fs-meta); color: var(--faint); margin: 14px 0 4px; }

/* ---------------- Fingers ----------------
   On a touch screen every control is at least 44 px tall (Apple's figure):
   chips, small buttons, the gear, the toggles in Settings. A mouse needs no
   such room, so the desktop keeps its tighter look. */
@media (pointer: coarse) {
  .btn, .chip, .seg-small .chip, .stage-jump .chip, .btn-sm { min-height: 44px; }
  .btn-sm { padding-inline: 14px; }
  .icon-btn { width: 44px; height: 44px; }
  .search input { min-height: 44px; }
  .scan-how summary { padding-block: 12px; }
  .fld-check { min-height: 44px; }
}

/* The tiles and the set-up note belong to Jobs waiting: on History, The car,
   Fuel and Papers they stand down (app.js stamps the pane on <html>). */
html[data-pane]:not([data-pane="schedule"]) #tiles,
html[data-pane]:not([data-pane="schedule"]) #setupBanner { display: none !important; }

/* ---------------- Ask the car ----------------
   A line of its own at the foot of The car: the conversation above it,
   the box and the button on one row, a quiet note under. */
.ask-card { margin-top: var(--gap); display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
.ask-card > *, .ask-thread > * { min-width: 0; }
.ask-row { display: flex; gap: 8px; align-items: center; }
.ask-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.ask-row input {
  flex: 1 1 auto; min-width: 0; min-height: 44px; padding: 10px 14px;
  border-radius: 999px; border: 1px solid var(--line); background: var(--surface-2); color: var(--text);
  font: inherit; font-size: var(--fs-base);
}
.ask-row input:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
.ask-row .btn { flex: none; min-height: 44px; padding-inline: 20px; border-radius: 999px; }
.ask-foot { margin: 0; font-size: var(--fs-meta); color: var(--faint); }
.ask-again {
  font: inherit; color: var(--accent-ink); background: none; border: 0; padding: 0;
  text-decoration: underline; cursor: pointer;
}
.ask-thread { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; max-height: 560px; overflow-y: auto; padding-right: 2px; }
.ask-msg { border-radius: 14px; padding: 10px 14px; font-size: var(--fs-sm); line-height: 1.5; max-width: 100%; }
.ask-user { justify-self: end; background: var(--accent); color: var(--on-accent); max-width: 85%; border-bottom-right-radius: 4px; }
.ask-model { background: var(--surface-2); border: 1px solid var(--line-soft); border-bottom-left-radius: 4px; }
.ask-model.is-pending { color: var(--faint); font-style: italic; }
.ask-model.is-error { background: var(--late-tint); color: var(--late-ink); border-color: var(--late-tint); }
.ask-answer p { margin: 0 0 8px; }
.ask-answer ul { margin: 0 0 8px; padding-left: 18px; }
.ask-answer li { margin: 2px 0; }
.ask-answer > :last-child { margin-bottom: 0; }
.ask-refs { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line-soft); }
.ask-refs-h { width: 100%; font-size: var(--fs-meta); color: var(--faint); }
.ask-ref {
  display: inline-flex; align-items: center; gap: 6px; max-width: 100%;
  padding: 5px 11px; border-radius: 999px; font-size: var(--fs-meta); text-decoration: none;
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ask-ref::before { content: ""; flex: none; width: 12px; height: 12px; background: var(--accent-ink);
  -webkit-mask: var(--ref-icon) center / contain no-repeat; mask: var(--ref-icon) center / contain no-repeat; }
.ask-ref-article { --ref-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round'%3E%3Cpath d='M6 3h9l4 4v14H6z'/%3E%3Cpath d='M9 11h7M9 15h7'/%3E%3C/svg%3E"); }
.ask-ref-video { --ref-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M8 5v14l11-7z' fill='black'/%3E%3C/svg%3E"); }
.ask-ref:hover { border-color: var(--accent-line); background: var(--accent-tint); }
.ask-ref span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (pointer: coarse) { .ask-ref { min-height: 36px; } }

/* Every fill: a window about five fills tall that scrolls (app.js sets the
   height from the rows). The bottom edge fades while there is more below. */
#fuelList { position: relative; }
#fuelList.is-scroll {
  overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
  border-bottom: 1px solid var(--line-soft);
  -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 44px), transparent);
          mask-image: linear-gradient(to bottom, #000 calc(100% - 44px), transparent);
}
#fuelList.is-scroll.at-end { -webkit-mask-image: none; mask-image: none; }

/* Formalities, inside Settings: the finance and the documents need more
   room than a row of settings, so the window widens while it is open, and
   the two cards sit flat on the section rather than floating in it. */
.settings.is-wide { width: min(620px, calc(100vw - 28px)); max-width: calc(100vw - 28px); }
.set-papers { gap: 14px; }
.set-papers > .card { box-shadow: none; margin: 0; padding: 14px; background: var(--surface); }
.set-papers .papers-head { flex-wrap: wrap; gap: 10px; }

/* You */
.pref-email { display: flex; gap: 8px; align-items: center; }
.pref-email input {
  flex: 1 1 auto; min-width: 0; min-height: 44px; padding: 9px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--surface); color: var(--text); font: inherit;
}
.pref-email input:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
.pref-email .btn { flex: none; }
.pref-note { font-size: var(--fs-meta); }

/* Settings → You → Text size: Larger. The type scale steps up as a whole. */
html[data-text="large"] { --fs-meta: 14px; --fs-sm: 15.5px; --fs-base: 17px; }
html[data-text="large"] body { font-size: 17px; }

/* ---------------- Log fuel ----------------
   A small round button, bottom-right on every tab, with the pump alone. */
.fuel-fab {
  position: fixed; z-index: 40;
  right: max(16px, env(safe-area-inset-right, 0px) + 12px);
  bottom: max(18px, env(safe-area-inset-bottom, 0px) + 12px);
  width: 52px; height: 52px; border-radius: 50%; border: 0; padding: 0;
  display: grid; place-items: center; cursor: pointer;
  background: var(--accent); color: var(--on-accent);
  box-shadow: 0 8px 20px rgba(6, 30, 22, .28), 0 2px 5px rgba(6, 30, 22, .16);
  transition: transform .15s ease, box-shadow .15s ease;
  -webkit-tap-highlight-color: transparent;
}
.fuel-fab svg { width: 24px; height: 24px; }
.fuel-fab:hover { transform: translateY(-1px); box-shadow: 0 10px 24px rgba(6, 30, 22, .32); }
.fuel-fab:active { transform: scale(.94); }
.fuel-fab:focus-visible { outline: 3px solid var(--accent-line); outline-offset: 3px; }
/* Room at the foot of every page so the button never sits on the last line. */
.app { padding-bottom: 84px; }

/* Inside the dialog */
.fuel-car {
  margin-left: auto; font: inherit; font-size: var(--fs-meta); font-weight: 650; cursor: pointer;
  padding: 6px 12px; border-radius: 999px; min-height: 32px;
  background: var(--accent-tint); color: var(--accent-ink); border: 1px solid var(--accent-line);
}
.fuel-quick { display: grid; gap: 6px; }
.fuel-snap {
  display: grid; justify-items: center; gap: 6px; width: 100%; cursor: pointer;
  padding: 22px 14px; border-radius: 16px; font: inherit; text-align: center;
  border: 2px dashed var(--accent-line); background: var(--accent-tint); color: var(--accent-ink);
}
.fuel-snap svg { width: 40px; height: 40px; }
.fuel-snap b { font-size: 16px; }
.fuel-snap small { font-size: var(--fs-meta); color: var(--dim); }
.fuel-snap:hover { border-color: var(--accent); }
.fuel-or { margin: 4px 0 0; text-align: center; font-size: var(--fs-meta); color: var(--faint); }
.fuel-last { margin: -4px 0 0; font-size: var(--fs-meta); }

/* ---------------- No zooming by accident ----------------
   An iPhone zooms the whole page in when a box with text under 16px is
   tapped, and leaves it zoomed: the "the fill screen blows up" problem.
   On touch screens every typing box is 16px or more, which stops it. The
   odometer box keeps its larger figure. Pinch-to-zoom still works for
   anyone who wants it; double-tap no longer zooms, and turning the phone
   no longer inflates the text. */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; touch-action: manipulation; }
@media (pointer: coarse) {
  input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]),
  textarea, select { font-size: 16px !important; }
  #odoInput { font-size: 17px !important; }
}


/* ── The car switcher ─────────────────────────────────────────────────────
   One car on screen at a time. The emblem in the header is the button; a
   small chevron on its corner says it opens. The list drops from it: each
   car with its worst status, then Add a car. */
.hero { position: relative; }
.car-switch {
  position: relative; flex: 0 0 auto; padding: 0; border: 0; background: none;
  border-radius: 16px; cursor: pointer; color: inherit;
  transition: transform .16s ease;
}
.car-switch:hover { transform: translateY(-1px); }
.car-switch:active { transform: scale(.97); }
.car-switch:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.car-switch-chev {
  position: absolute; right: -6px; bottom: -6px; width: 24px; height: 24px;
  display: grid; place-items: center; border-radius: 50%;
  background: var(--accent); color: var(--on-accent);
  border: 2px solid var(--surface); box-shadow: var(--shadow);
}
.car-switch-chev svg { width: 15px; height: 15px; transition: transform .2s ease; }
.car-switch.is-open .car-switch-chev svg { transform: rotate(180deg); }
#heroName { cursor: pointer; }

.car-menu {
  /* Hung from the header card rather than the emblem, so on a phone it can
     take the card's whole width and never runs off the screen. */
  position: absolute; z-index: 40; top: calc(20px + 62px + 14px); left: 12px;
  width: min(380px, calc(100% - 24px));
  padding: 10px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-lg);
  animation: car-menu-in .16s ease-out;
}
@keyframes car-menu-in { from { opacity: 0; transform: translateY(-6px); } }
.car-menu-head {
  font-size: var(--fs-meta); color: var(--faint); text-transform: uppercase;
  letter-spacing: .09em; padding: 4px 6px 8px;
}
.car-menu .tabs {
  display: grid; grid-template-columns: 1fr; gap: 8px; padding: 0; max-width: none; margin: 0;
}
.car-menu .tab { box-shadow: none; padding: 10px 12px; gap: 12px; }
.car-menu .tab:hover { transform: none; background: var(--surface-2); }
.car-menu .tab.is-on:hover { background: linear-gradient(180deg, var(--accent-tint), var(--surface) 70%); }
.car-menu .tab-flag { flex-direction: row; }
.car-menu-foot { display: flex; gap: 8px; margin-top: 8px; }
.car-add, .car-edit {
  min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border-radius: var(--radius-sm); cursor: pointer; font-weight: 600; font-size: var(--fs-sm);
}
.car-add {
  flex: 1; border: 1px dashed var(--accent-line); background: var(--accent-tint); color: var(--accent-ink);
}
.car-add svg { width: 18px; height: 18px; }
.car-add:hover { border-style: solid; }
.car-edit {
  padding: 0 14px; border: 1px solid var(--line); background: var(--surface); color: var(--dim);
  white-space: nowrap; max-width: 50%; overflow: hidden; text-overflow: ellipsis;
}
.car-edit:hover { color: var(--text); }
.car-add:focus-visible, .car-edit:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* An added car's emblem: its make's initials in its own colour. The colour
   is the car's, not the page's, so each one in the list keeps its own. */
.marque-mono {
  display: grid; place-items: center; border-radius: 10px;
  font-weight: 750; letter-spacing: .02em; line-height: 1;
  background: var(--mono-bg, #3d4650); color: #fff;
}
.marque-mono[data-accent="graphite"] { --mono-bg: #3d4650; }
.marque-mono[data-accent="burgundy"] { --mono-bg: #7a1f35; }
.marque-mono[data-accent="copper"]   { --mono-bg: #8a4a14; }
.marque-mono[data-accent="violet"]   { --mono-bg: #5b3a9a; }
.marque-mono[data-accent="bottle"]   { --mono-bg: #064e3b; }
.marque-mono[data-accent="sapphire"] { --mono-bg: #17509f; }
.hero-badge .marque-mono { width: 46px; height: 46px; font-size: 18px; }
.tab .tab-ico .marque-mono { width: 32px; height: 32px; font-size: 13px; border-radius: 8px; }

/* Add a car: the colour swatches. */
.swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.swatch {
  width: 44px; height: 44px; border-radius: 50%; padding: 0; cursor: pointer;
  display: grid; place-items: center; background: var(--surface);
  border: 2px solid transparent;
}
.swatch i { width: 30px; height: 30px; border-radius: 50%; background: var(--sw, #3d4650); }
.swatch[data-accent="bottle"]   { --sw: #064e3b; }
.swatch[data-accent="sapphire"] { --sw: #17509f; }
.swatch[data-accent="graphite"] { --sw: #3d4650; }
.swatch[data-accent="burgundy"] { --sw: #7a1f35; }
.swatch[data-accent="copper"]   { --sw: #8a4a14; }
.swatch[data-accent="violet"]   { --sw: #5b3a9a; }
.swatch.is-on { border-color: var(--text); }
.swatch:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.fld-err { color: var(--late-ink); font-size: var(--fs-sm); min-height: 1em; }
.fld-err:empty { display: none; }
#carRemove { margin-right: auto; color: var(--late-ink); }
@media (max-width: 520px) {
  #carModal .fld-row { grid-template-columns: 1fr 1fr; }
  #carModal .modal-foot { flex-wrap: wrap; }
}

/* ── Connected apps ─────────────────────────────────────────────────────── */
.api-key-make { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; margin-top: 10px; }
.api-key-make .fld { flex: 1 1 200px; }
.api-key-new {
  margin-top: 10px; padding: 12px; border-radius: var(--radius-sm);
  background: var(--accent-tint); border: 1px solid var(--accent-line); display: grid; gap: 10px;
}
.api-key-new p { font-size: var(--fs-sm); }
.api-key-code {
  display: block; padding: 10px 12px; border-radius: var(--radius-sm);
  background: var(--surface); border: 1px solid var(--line);
  font: 13px/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  word-break: break-all; user-select: all; -webkit-user-select: all;
}
.api-howto { margin-top: 12px; font-size: var(--fs-sm); color: var(--dim); }
.api-howto summary { cursor: pointer; color: var(--accent-ink); font-weight: 600; min-height: 32px; display: flex; align-items: center; }
.api-howto p { margin-top: 6px; }
.api-howto code { font-size: 12.5px; background: var(--surface-2); padding: 1px 5px; border-radius: 5px; word-break: break-word; }
#apiKeyList .doc.passkey-row .btn { grid-row: 1 / span 3; }
