@font-face { font-family: "Barlow"; font-weight: 400; font-style: normal; font-display: swap; src: url("/static/fonts/barlow-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Barlow"; font-weight: 500; font-style: normal; font-display: swap; src: url("/static/fonts/barlow-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Barlow"; font-weight: 600; font-style: normal; font-display: swap; src: url("/static/fonts/barlow-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Barlow Condensed"; font-weight: 500; font-style: normal; font-display: swap; src: url("/static/fonts/barlow-condensed-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Barlow Condensed"; font-weight: 600; font-style: normal; font-display: swap; src: url("/static/fonts/barlow-condensed-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Barlow Condensed"; font-weight: 700; font-style: normal; font-display: swap; src: url("/static/fonts/barlow-condensed-latin-700-normal.woff2") format("woff2"); }
:root {
  --bg: #E9ECEF;          /* concrete pit floor */
  --surface: #FFFFFF;
  --ink: #1C232B;
  --muted: #5B6670;
  --line: #CDD3D9;
  --plate: #F5C400;       /* number-plate yellow */
  --plate-ink: #1C232B;
  --ok: #23955A;
  --due: #E08A00;
  --over: #D2392C;
  --off: #D8DDE2;
  --bar: #1F262D;
  --display: "Barlow Condensed", "Arial Narrow", "Roboto Condensed", sans-serif;
  --body: "Barlow", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color-scheme: light;
  box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161B20; --surface: #20272E; --ink: #E8ECEF; --muted: #9AA5AF;
    --line: #333C45; --off: #343D46; --bar: #0F1317; color-scheme: dark;
  }
}
*, *::before, *::after { box-sizing: border-box; }
html { scroll-padding-top: env(safe-area-inset-top, 0px); }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 400 16px/1.45 var(--body);
  -webkit-text-size-adjust: 100%;
}
main { max-width: 640px; margin: 0 auto; padding: 12px 14px 96px; outline: none; }

/* ---------- header plate ---------- */
.topbar {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5;
  background: var(--bar); color: #fff; padding: 10px 14px;
}
.plate {
  max-width: 640px; margin: 0 auto; display: flex; align-items: center; gap: 14px;
}
.plate .num {
  background: var(--plate); color: var(--plate-ink); border-radius: 6px;
  font: 700 30px/1 var(--display); padding: 6px 10px 4px; min-width: 92px; text-align: center;
  font-variant-numeric: tabular-nums;
}
.plate .num small { font-size: 15px; font-weight: 600; margin-left: 2px; }
.plate .meta { font-size: 13px; line-height: 1.35; color: #C9D1D8; }
.plate .meta strong { color: #fff; font-weight: 600; }

/* ---------- tabs ---------- */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--bar); padding-bottom: env(safe-area-inset-bottom, 0px);
}
.tabs button {
  appearance: none; border: 0; background: none; color: #AEB8C1;
  font: 600 13px/1 var(--display); letter-spacing: .03em; padding: 9px 0 8px;
  border-top: 3px solid transparent; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.tab-icon { position: relative; display: block; width: 26px; height: 26px; }
.tab-icon svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.tab-icon .tab-badge { position: absolute; top: -4px; left: 17px; margin: 0; }
.tab-label { font-size: 14px; }
.tabs button[aria-current="page"] { color: #fff; border-top-color: var(--plate); }

/* ---------- headings ---------- */
h2 {
  font: 700 22px/1.1 var(--display); margin: 26px 0 8px;
  display: flex; align-items: baseline; justify-content: space-between; gap: 8px;
}
h2 .aside { font: 500 15px/1 var(--body); color: var(--muted); }
h2:first-child { margin-top: 8px; }
.hint { color: var(--muted); font-size: 14px; margin: 4px 0 12px; }

/* ---------- part rows (signature: rev-light wear strip) ---------- */
.list { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.row {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 12px; align-items: center;
  width: 100%; text-align: left; background: none; border: 0; color: inherit; font: inherit;
  padding: 12px 14px; border-top: 1px solid var(--line); cursor: pointer;
}
.row:first-child { border-top: 0; }
.row:active { background: color-mix(in srgb, var(--line) 35%, transparent); }
.row .name { font-weight: 600; }
.row .sub { grid-column: 1; font-size: 13px; color: var(--muted); }
.row .big {
  grid-row: 1 / span 2; grid-column: 2; text-align: right;
  font: 700 30px/1 var(--display); font-variant-numeric: tabular-nums;
}
.row .big small { font-size: 14px; font-weight: 600; color: var(--muted); margin-left: 2px; }
.row .big.muted { font-size: 18px; color: var(--muted); font-weight: 500; }
.revs { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(10, 1fr); gap: 3px; margin-top: 8px; }
.revs i { height: 7px; border-radius: 2px; background: var(--off); }
.revs i.on { background: var(--ok); }
.revs.due i.on { background: var(--due); }
.revs.over i.on { background: var(--over); }
.badge { font: 600 12px/1 var(--body); padding: 3px 6px; border-radius: 4px; margin-left: 6px; vertical-align: 2px; }
.badge.due { background: var(--due); color: #fff; }
.badge.over { background: var(--over); color: #fff; }
.badge.wet { background: #2B6CB0; color: #fff; }
.badge.dry { background: var(--plate); color: var(--plate-ink); }
.badge.off { background: var(--off); color: var(--muted); }

details.more { margin-top: 8px; }
details.more summary { cursor: pointer; color: var(--muted); font-size: 14px; padding: 8px 2px; }

/* ---------- forms ---------- */
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 4px; margin: 8px 0 16px; }
.seg button { border: 0; background: none; font: 600 18px/1 var(--display); padding: 12px; border-radius: 7px; color: var(--muted); cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--bar); color: #fff; }
form.card, .card { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 14px; }
label { display: block; font-size: 14px; font-weight: 600; margin: 14px 0 6px; }
label:first-child { margin-top: 0; }
input, select, textarea {
  width: 100%; font: 400 17px/1.3 var(--body); color: var(--ink);
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 11px 12px;
}
textarea { min-height: 70px; resize: vertical; }
input.minutes { font: 700 34px/1 var(--display); text-align: center; padding: 10px; font-variant-numeric: tabular-nums; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chips button { border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 18px; padding: 8px 14px; font: 600 15px/1 var(--body); cursor: pointer; }
.checks { display: grid; gap: 2px; }
.checks .group { font-size: 13px; color: var(--muted); margin: 10px 0 2px; font-weight: 600; }
.check { display: flex; align-items: center; gap: 10px; font-weight: 500; margin: 0; padding: 9px 4px; font-size: 16px; border-radius: 6px; }
.check input { width: 22px; height: 22px; accent-color: var(--bar); flex: none; }
.check .since { margin-left: auto; color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.btn {
  display: block; width: 100%; margin-top: 18px; padding: 15px; border: 0; border-radius: 9px;
  background: var(--plate); color: var(--plate-ink); font: 700 20px/1 var(--display); cursor: pointer;
}
.btn.secondary { background: var(--bar); color: #fff; }
.btn.ghost { background: none; border: 1px solid var(--line); color: var(--ink); }
.btn.danger { background: none; border: 1px solid var(--over); color: var(--over); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row2 label { margin-top: 14px; }

/* ---------- stats grid in part sheet ---------- */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; margin: 12px 0; }
.stats div { background: var(--surface); padding: 10px; }
.stats b { display: block; font: 700 24px/1.1 var(--display); font-variant-numeric: tabular-nums; }
.stats span { font-size: 12px; color: var(--muted); }

/* ---------- history ---------- */
.day { font: 600 15px/1 var(--display); color: var(--muted); margin: 20px 2px 6px; display: flex; justify-content: space-between; align-items: baseline; }
.day-total { font: 700 18px/1 var(--display); color: var(--ink); font-variant-numeric: tabular-nums; }
.item { display: flex; gap: 12px; align-items: baseline; }
.item .tag { flex: none; font: 700 13px/1 var(--display); padding: 4px 6px; border-radius: 4px; min-width: 52px; text-align: center; }
.item .tag.s { background: var(--bar); color: #fff; }
.item .tag.c { background: var(--plate); color: var(--plate-ink); }
.item .what { font-weight: 500; }
.item .detail { font-size: 13px; color: var(--muted); }

/* ---------- sheet & toast ---------- */
.sheet {
  border: 0; padding: 0; width: 100%; max-width: 640px; max-height: 88vh;
  margin: auto auto 0; border-radius: 14px 14px 0 0; background: var(--bg); color: var(--ink);
}
.sheet::backdrop { background: rgba(10, 14, 18, .55); }
#sheet-body { padding: 16px 14px calc(20px + env(safe-area-inset-bottom, 0px)); }
.sheet h3 { font: 700 24px/1.1 var(--display); margin: 2px 0 4px; display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.close { border: 0; background: var(--surface); color: var(--ink); border-radius: 50%; width: 36px; height: 36px; font-size: 20px; cursor: pointer; flex: none; }
.toast {
  position: fixed; left: 50%; bottom: calc(76px + env(safe-area-inset-bottom, 0px)); transform: translate(-50%, 20px);
  background: var(--bar); color: #fff; padding: 10px 16px; border-radius: 8px; font-weight: 500;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 20; max-width: 90vw;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { background: var(--over); }
.empty { text-align: center; padding: 30px 16px; color: var(--muted); }

:focus-visible { outline: 3px solid var(--plate); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { .toast { transition: none; } }

/* ---------- tyre pressures: 2x2 grid laid out like the kart seen from above ---------- */
fieldset.press { border: 0; padding: 0; margin: 16px 0 0; min-width: 0; }
fieldset.press legend { font-size: 14px; font-weight: 600; padding: 0; margin-bottom: 6px; }
.press { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.press .hint, .press .link { grid-column: 1 / -1; }
.press-title { font-size: 13px; color: var(--muted); font-weight: 600; margin-bottom: 4px; }
.wheels { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.wheels input { text-align: center; font: 600 18px/1 var(--display); padding: 10px 4px; font-variant-numeric: tabular-nums; }
.link { background: none; border: 0; padding: 8px 0 0; color: var(--ink); text-decoration: underline; font: 500 14px/1.3 var(--body); text-align: left; cursor: pointer; }

/* ---------- login ---------- */
form.login { margin-top: 24px; }
.login-error { margin: 0 0 12px; padding: 10px 12px; border-radius: 8px; background: var(--over); color: #fff; font-weight: 500; }

/* ---------- date/time fields: iOS gives these an intrinsic width and right-aligns the value ---------- */
input[type="datetime-local"] {
  -webkit-appearance: none; appearance: none; display: block;
  min-width: 0; max-width: 100%; min-height: 46px; text-align: left;
}
input[type="datetime-local"]::-webkit-date-and-time-value { text-align: left; margin: 0; }

/* ---------- tab badge ---------- */
.tab-badge {
  display: inline-block; min-width: 18px; margin-left: 4px; padding: 2px 5px; border-radius: 9px;
  background: var(--plate); color: var(--plate-ink); font: 700 12px/1 var(--body); vertical-align: 2px;
}

/* ---------- lists ---------- */
form.quick { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; margin-bottom: 4px; }
form.quick .btn { margin: 0; width: auto; padding: 0 18px; }
.li { display: flex; align-items: center; gap: 4px; border-top: 1px solid var(--line); padding-left: 10px; }
.li:first-child { border-top: 0; }
.tick {
  flex: none; width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--muted);
  background: none; cursor: pointer; position: relative;
}
.tick[aria-pressed="true"] { background: var(--ok); border-color: var(--ok); }
.tick[aria-pressed="true"]::after {
  content: ""; position: absolute; left: 7px; top: 3px; width: 6px; height: 11px;
  border: solid #fff; border-width: 0 2.5px 2.5px 0; transform: rotate(45deg);
}
.li-body { flex: 1; min-width: 0; text-align: left; background: none; border: 0; color: inherit; font: inherit; padding: 12px 8px; cursor: pointer; }
.li-body .name { display: block; font-weight: 500; overflow-wrap: anywhere; }
.li-body .sub { display: block; font-size: 13px; color: var(--muted); }
.li.done .name { text-decoration: line-through; color: var(--muted); }
.src { flex: none; font-size: 13px; color: var(--ink); padding: 0 12px; }
.mini-actions { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 8px; }
.mini { border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 7px; padding: 8px 12px; font: 600 14px/1 var(--body); cursor: pointer; }
.mini-note { font-size: 13px; color: var(--muted); }

/* ---------- settings button in the header ---------- */
.gear-btn {
  margin-left: auto; flex: none; width: 44px; height: 44px; border-radius: 50%; border: 0;
  background: rgba(255,255,255,.08); color: #fff; display: grid; place-items: center; cursor: pointer;
}
.gear-btn[aria-pressed="true"] { background: var(--plate); color: var(--plate-ink); }

/* ---------- kart setup ---------- */
.setval { grid-row: 1 / span 2; grid-column: 2; text-align: right; font: 700 20px/1.1 var(--display); max-width: 45vw; overflow-wrap: anywhere; }
.setval.muted { font-weight: 500; font-size: 16px; color: var(--muted); }
.item .tag.u { background: #2B6CB0; color: #fff; }
details.su-group { border-top: 1px solid var(--line); margin-top: 14px; }
details.su-group summary { cursor: pointer; font: 700 19px/1 var(--display); padding: 14px 2px 4px; }
.su-count { font: 600 13px/1 var(--body); color: var(--due); margin-left: 6px; }
label.su-field { font-weight: 600; }
input.changed { border-color: var(--due); box-shadow: 0 0 0 2px color-mix(in srgb, var(--due) 35%, transparent); }

/* ---------- best lap, weather, personal bests ---------- */

fieldset.wx { border: 0; padding: 0; margin: 16px 0 0; min-width: 0; }
fieldset.wx legend { font-size: 14px; font-weight: 600; padding: 0; margin-bottom: 2px; }
.wx-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.wx-row label { font-size: 12px; font-weight: 600; margin: 6px 0 4px; color: var(--muted); }
.wx-row input { text-align: center; padding: 10px 4px; }
fieldset.wx .mini { margin-top: 10px; }
.stats-line { display: flex; flex-wrap: wrap; gap: 4px 10px; margin: 2px 0 1px; font-size: 13px; color: var(--ink); font-variant-numeric: tabular-nums; }
.stats-line .kv { white-space: nowrap; }
.stats-line .lap { font: 700 15px/1.2 var(--display); }
.pb { display: inline-block; background: #7B3FE4; color: #fff; font: 700 11px/1 var(--body); padding: 2px 5px; border-radius: 4px; vertical-align: 1px; }
.pb-row { grid-template-columns: minmax(0, 1fr) auto; }
.pb-cells { grid-row: 1; grid-column: 2; display: flex; gap: 14px; }
.pb-cell { display: grid; justify-items: end; gap: 2px; min-width: 76px; }
.pb-cell b { font: 700 20px/1 var(--display); font-variant-numeric: tabular-nums; }
.pb-cell small { font-size: 11px; color: var(--muted); }

/* ---------- best lap: min : sec . ms ---------- */
fieldset.lapf { border: 0; padding: 0; margin: 16px 0 0; min-width: 0; }
fieldset.lapf legend { font-size: 14px; font-weight: 600; padding: 0; margin-bottom: 6px; }
.lap-row { display: grid; grid-template-columns: 1.4fr auto 2fr auto 3fr; align-items: center; gap: 6px; }
.lap-row input { text-align: center; font: 700 26px/1 var(--display); font-variant-numeric: tabular-nums; padding: 10px 4px; }
.lap-sep { font: 700 26px/1 var(--display); color: var(--muted); }
.lap-labels { margin-top: 3px; font-size: 12px; color: var(--muted); text-align: center; }

/* ---------- needs-attention card ---------- */
.attention { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 4px 6px 6px; margin-top: 4px; }
.attention h2 { margin: 10px 8px 6px; font-size: 19px; }
.att-item { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; background: none; border: 0; color: inherit;
  font: 500 15px/1.3 var(--body); padding: 9px 8px; border-radius: 8px; cursor: pointer; }
div.att-item { cursor: default; }
button.att-item:active { background: color-mix(in srgb, var(--line) 40%, transparent); }
.att-dot { flex: none; width: 10px; height: 10px; border-radius: 50%; background: var(--muted); }
.att-item.over .att-dot { background: var(--over); }
.att-item.due .att-dot { background: var(--due); }
.att-item.ok .att-dot { background: var(--ok); }
.att-item.todo .att-dot { background: var(--plate); }
.att-item.last .att-dot { background: var(--bar); }
@media (prefers-color-scheme: dark) { .att-item.last .att-dot { background: var(--muted); } }
.att-text { flex: 1; min-width: 0; }
.att-val { flex: none; color: var(--muted); font: 600 14px/1 var(--body); font-variant-numeric: tabular-nums; }
.att-item.over .att-val { color: var(--over); }

/* ---------- history rows: lap time on the right, tyre-type edge ---------- */
.item { align-items: flex-start; }
.item-main { flex: 1; min-width: 0; }
.lapbox { flex: none; display: grid; justify-items: end; gap: 3px; padding-left: 6px; }
.lapbox b { font: 700 24px/1 var(--display); font-variant-numeric: tabular-nums; }
.lapbox small { font-size: 11px; color: var(--muted); }
.row.edge-dry { box-shadow: inset 4px 0 0 var(--plate); }
.row.edge-wet { box-shadow: inset 4px 0 0 #2B6CB0; }
.stats-line { font-size: 12px; color: var(--muted); }

/* ---------- history filters ---------- */
.filters { display: grid; gap: 8px; margin: 4px 0 6px; }
.chips-row { display: flex; gap: 6px; flex-wrap: wrap; }
.fchip { border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 18px; padding: 8px 14px; font: 600 14px/1 var(--body); cursor: pointer; }
.fchip[aria-pressed="true"] { background: var(--bar); border-color: var(--bar); color: #fff; }
#h-track { padding: 9px 12px; font-size: 15px; }
