/* styles.css — how everything looks.

   The app uses the Xero Point Racing colours and nothing else:
     XPR      yellow      #eeee22
     XFINITE  light blue  #30abe2
     XNOVA    purple      #8729cc
   all on carbon black, with greys and white for everything quiet.

   What each colour is used for:
     yellow      the main colour: buttons, what is selected, what is happening now
     light blue  good news: done, ahead, finished
     purple      things that need attention: warnings, errors, running out of fuel

   Pit stops use none of the three: they are white on the dark theme and black on the
   light theme, like the white stripe on the cars, so they never clash with a driver's colour.

   The lists below hold every colour: one list for the dark theme, one for the light
   theme. Change a colour there and the whole app follows. */

:root,
:root[data-theme='dark'] {
  --bg: #0c0c0c;
  --surface: #161616;
  --raised: #1f1f1f;
  --hover: #2a2a2a;
  --line: #383838;
  --line-soft: #272727;
  --text: #f4f4f4;
  --muted: #a3a3a3;
  --faint: #707070;

  --accent: #eeee22;        /* XPR yellow, as a fill */
  --accent-strong: #f7f76a;
  --accent-ink: #0c0c0c;    /* text on top of yellow */
  --accent-text: #eeee22;   /* yellow used for text and thin lines */
  --accent-soft: rgba(238, 238, 34, 0.12);
  --accent-line: rgba(238, 238, 34, 0.55);

  --stop: #f4f4f4;          /* pit stops: plain white */
  --stop-line: #8a8a8a;     /* the dashed line beside a pit stop in the stint list */

  --alert: #a55ceb;         /* XNOVA purple, lightened to read on black */
  --alert-fill: #8729cc;    /* XNOVA purple, as a fill under white text */
  --alert-soft: rgba(165, 92, 235, 0.15);
  --alert-text: #c9a0f5;

  --ok: #30abe2;            /* XFINITE light blue */
  --ok-ink: #04141d;

  --warn: #eeee22;
  --warn-soft: rgba(238, 238, 34, 0.12);

  --open: #5e5e5e;
  --stripe-a: #2d2d2d;
  --stripe-b: #242424;
  --block-ink: #0c0c0c;
  --block-mix: #000;
  --glass: rgba(12, 12, 12, 0.86);
  --backdrop: rgba(0, 0, 0, 0.72);
  --shadow: 0 30px 80px rgba(0, 0, 0, 0.65);
  --card-shadow: none;
  --glow: rgba(238, 238, 34, 0.09);
  --tyre-soft: #f4f4f4;
  --tyre-soft-line: #f4f4f4;
  --tyre-medium-line: #eeee22;
  color-scheme: dark;
}

:root[data-theme='light'] {
  --bg: #f3f3f1;
  --surface: #ffffff;
  --raised: #efefec;
  --hover: #e3e3df;
  --line: #cfcfca;
  --line-soft: #e3e3df;
  --text: #0c0c0c;
  --muted: #5e5e5a;
  --faint: #8b8b86;

  --accent: #eeee22;
  --accent-strong: #e0e000;
  --accent-ink: #0c0c0c;
  --accent-text: #0c0c0c;   /* yellow text is unreadable on white, so it becomes black */
  --accent-soft: rgba(238, 238, 34, 0.4);
  --accent-line: #0c0c0c;

  --stop: #0c0c0c;          /* pit stops: plain black */
  --stop-line: #8b8b86;

  --alert: #7624c1;         /* XNOVA purple */
  --alert-fill: #7624c1;
  --alert-soft: rgba(118, 36, 193, 0.09);
  --alert-text: #5e1aa3;

  --ok: #1583b8;            /* XFINITE light blue, darkened to read on white */
  --ok-ink: #ffffff;

  --warn: #0c0c0c;
  --warn-soft: rgba(238, 238, 34, 0.45);

  --open: #a9a9a4;
  --stripe-a: #e3e3df;
  --stripe-b: #efefec;
  --block-ink: #0c0c0c;
  --block-mix: #fff;
  --glass: rgba(243, 243, 241, 0.9);
  --backdrop: rgba(12, 12, 12, 0.45);
  --shadow: 0 30px 70px rgba(12, 12, 12, 0.22);
  --card-shadow: 0 1px 2px rgba(12, 12, 12, 0.05), 0 4px 16px rgba(12, 12, 12, 0.04);
  --glow: rgba(238, 238, 34, 0.3);
  --tyre-soft: #ffffff;
  --tyre-soft-line: #8b8b86;
  --tyre-medium-line: #a8a800;
  color-scheme: light;
}

:root {
  /* Tyre compounds: soft white, medium yellow, hard red, wet light blue.
     The red is the one colour from outside the team scheme, because that is how
     the WEC marks its hard tyre. */
  --tyre-medium: #eeee22;
  --tyre-hard: #e5352b;
  --tyre-wet: var(--ok);
  --radius: 16px;
  --font: 'Inter', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  --mono: ui-monospace, 'SF Mono', 'JetBrains Mono', Menlo, Consolas, monospace;
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14.5px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, p, ul { margin: 0; }
h2 { font-size: 16px; font-weight: 650; letter-spacing: -0.005em; }
h3 { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.09em; color: var(--muted); margin: 26px 0 10px; }
small { font-size: 12.5px; color: var(--muted); }
em { font-style: normal; color: var(--muted); font-size: 12.5px; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.muted { color: var(--muted); }
.warn-text { color: var(--alert); }
.strong { font-weight: 650; }
.right { text-align: right; }

:focus-visible { outline: 2px solid var(--accent-text); outline-offset: 2px; }

/* ---------- buttons ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 15px; border-radius: 10px;
  background: var(--raised); border: 1px solid var(--line);
  font-weight: 560; font-size: 13.5px; white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, transform 0.05s;
}
.btn:hover { background: var(--hover); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent-strong); color: var(--accent-ink); font-weight: 650; }
.btn.primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn.danger { background: transparent; border-color: var(--alert); color: var(--alert); }
.btn.danger:hover { background: var(--alert-soft); }
.btn.big { padding: 14px 22px; font-size: 15.5px; border-radius: 12px; }
.btn.tiny { padding: 5px 11px; font-size: 12.5px; border-radius: 8px; }
.btn.block-btn { width: 100%; margin-top: 14px; }
.btn.flash { animation: flash 1s ease-in-out infinite; border-color: var(--accent-text); color: var(--accent-text); }
@keyframes flash { 50% { background: var(--accent-soft); } }

.icon-btn { display: inline-grid; place-items: center; background: none; border: 0; color: var(--muted); font-size: 16px; padding: 8px; border-radius: 10px; }
.icon-btn:hover { background: var(--raised); color: var(--text); }
.theme-toggle svg { width: 19px; height: 19px; display: block; }
:root[data-theme='dark'] .theme-toggle .moon, :root[data-theme='light'] .theme-toggle .sun { display: none; }

/* segmented switch (Plan / Live / Report and friends) */
.seg { display: inline-flex; background: var(--raised); border: 1px solid var(--line-soft); border-radius: 12px; padding: 3px; gap: 2px; }
.seg > button, .seg > label > span {
  display: block; padding: 7px 15px; border-radius: 9px; border: 0; background: none;
  color: var(--muted); font-weight: 560; font-size: 13.5px; text-align: center; cursor: pointer;
}
.seg > button:hover, .seg > label:hover > span { color: var(--text); }
.seg > button.on { background: var(--surface); color: var(--text); box-shadow: 0 0 0 1px var(--line), var(--card-shadow); }
.seg.wide { display: flex; }
.seg.wide > * { flex: 1; }
.seg.small > button { padding: 5px 12px; font-size: 12.5px; }
.seg.choice label { position: relative; }
.seg.choice input { position: absolute; opacity: 0; pointer-events: none; }
.seg.choice span small { display: block; font-weight: 400; font-size: 11.5px; }
.seg.choice input:checked + span { background: var(--accent-soft); color: var(--accent-text); box-shadow: inset 0 0 0 1px var(--accent-line); }
.seg.choice input:checked + span small { color: var(--accent-text); opacity: 0.85; }
.seg.choice input:focus-visible + span { outline: 2px solid var(--accent-text); outline-offset: 2px; }
.class-choice { flex-wrap: wrap; }
.class-choice > label { flex: 1 1 86px; }
.class-choice > label > span { padding: 8px 6px; }

/* ---------- form fields ---------- */

input, select, textarea {
  width: 100%; padding: 10px 12px; border-radius: 10px;
  background: var(--bg); border: 1px solid var(--line); color: var(--text);
  font: inherit; transition: border-color 0.15s, box-shadow 0.15s;
}
:root[data-theme='light'] input, :root[data-theme='light'] select, :root[data-theme='light'] textarea { background: var(--surface); }
input::placeholder, textarea::placeholder { color: var(--faint); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent-text); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { resize: vertical; }
input[type='checkbox'] { width: 17px; height: 17px; padding: 0; accent-color: var(--accent-text); flex: none; }
input[type='range'] { padding: 0; border: 0; background: none; accent-color: var(--accent-text); box-shadow: none; }

.field { display: grid; gap: 6px; align-content: start; }
.field > span { font-size: 13px; color: var(--muted); font-weight: 500; }
.field > span em { margin-left: 4px; font-size: 11.5px; opacity: 0.8; }
.stack { display: grid; gap: 16px; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; }
.grid > .field:has(select[name='tyreStrategy']) { grid-column: span 2; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.unit-input { position: relative; display: block; }
.unit-input input { padding-right: 54px; font-family: var(--mono); }
.unit-input i { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); font-style: normal; font-size: 12.5px; color: var(--muted); pointer-events: none; }
.lap-inputs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.datetime { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 8px; }
.date-box input:not(.native-date) { padding-right: 44px; }
.cal-btn { position: absolute; right: 5px; top: 50%; transform: translateY(-50%); display: grid; place-items: center; width: 32px; height: 32px; border: 0; border-radius: 8px; background: none; color: var(--muted); }
.cal-btn:hover { background: var(--raised); color: var(--text); }
.cal-btn svg { width: 17px; height: 17px; }
.native-date { position: absolute; right: 0; bottom: 0; width: 1px; height: 1px; padding: 0; border: 0; opacity: 0; pointer-events: none; }
.start-form { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 10px; text-align: left; }
.start-form .datetime { width: 300px; max-width: 100%; }
.me-btn.on { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent-text); }
.range { display: flex; align-items: center; gap: 14px; }
.range output { font: 600 14px var(--mono); min-width: 48px; text-align: right; }

.tip {
  display: inline-grid; place-items: center; width: 16px; height: 16px; margin-left: 4px;
  border-radius: 50%; border: 1px solid var(--line); color: var(--muted);
  font-style: normal; font-size: 10.5px; cursor: help;
}
.hint { font-size: 13px; color: var(--muted); margin-top: 12px; }
.hint b { color: var(--text); }
.check { display: flex; align-items: center; gap: 10px; margin-top: 14px; font-size: 13.5px; }
.check > span { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.check .unit-input { width: 112px; }
.form .check + .grid { margin-top: 12px; }
.form-error { color: var(--alert); font-size: 13.5px; margin-top: 12px; }

.form fieldset { border: 0; border-top: 1px solid var(--line-soft); margin: 20px 0 0; padding: 16px 0 0; min-width: 0; }
.form fieldset:first-child { border-top: 0; margin-top: 4px; padding-top: 4px; }
.form legend { padding: 0 12px 0 8px; border-left: 3px solid var(--accent); font-size: 11.5px; font-weight: 650; text-transform: uppercase; letter-spacing: 0.09em; color: var(--accent-text); }
.form .field + .field, .form .grid + .field, .form .field + .grid, .form .grid + .grid, .form > .field, .form > .grid { margin-top: 14px; }
.form .grid > .field + .field { margin-top: 0; }

.sub-box { margin-top: 14px; padding: 14px; border-radius: 12px; background: var(--raised); }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line-soft); }

/* fold-out sections for the less-used settings */
details.more { margin-top: 14px; border: 1px solid var(--line-soft); border-radius: 12px; padding: 0 14px; }
details.more summary { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 10px; padding: 12px 0; cursor: pointer; list-style: none; }
details.more summary::-webkit-details-marker { display: none; }
details.more summary::before { content: '›'; font-size: 17px; line-height: 1; color: var(--muted); transition: transform 0.15s; }
details.more[open] summary::before { transform: rotate(90deg); }
details.more[open] { padding-bottom: 14px; }
details.more summary b { font-weight: 600; font-size: 13.5px; }

/* ---------- top bar of the start page and calculator ---------- */

.appbar { display: flex; align-items: center; gap: 22px; padding: 14px 24px; border-bottom: 1px solid var(--line-soft); }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16.5px; letter-spacing: -0.01em; }
.logo { width: 28px; height: 28px; flex: none; }
.mainnav { display: flex; gap: 4px; flex: 1; }
.mainnav a { white-space: nowrap; padding: 7px 13px; border-radius: 9px; color: var(--muted); font-weight: 560; font-size: 13.5px; }
.mainnav a:hover { color: var(--text); background: var(--raised); }
.mainnav a.on { color: var(--text); background: var(--raised); }

/* ---------- start page ---------- */

.landing { padding: 56px 24px 80px; background: radial-gradient(900px 420px at 50% -80px, var(--glow), transparent 70%); }
.hero { max-width: 720px; margin: 0 auto 40px; text-align: center; }
.hero h1 { font-size: clamp(30px, 5.4vw, 46px); line-height: 1.08; letter-spacing: -0.035em; font-weight: 750; }
.hero h1 em { font-size: inherit; color: var(--accent-text); }
:root[data-theme='light'] .hero h1 em { background: linear-gradient(transparent 58%, var(--accent) 58%); padding: 0 0.12em; }
.lead { color: var(--muted); font-size: 16.5px; margin-top: 14px; }
.landing-grid { max-width: 940px; margin: 0 auto; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; align-items: start; }
.landing-card { display: grid; gap: 18px; padding: 26px; }
.card-title { display: flex; align-items: center; gap: 12px; }
.card-title h2 { font-size: 20px; letter-spacing: -0.02em; }
.step { font: 650 11px var(--mono); text-transform: uppercase; letter-spacing: 0.1em; padding: 3px 9px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-text); }
.ticks { list-style: none; padding: 0; display: grid; gap: 10px; }
.ticks li { position: relative; padding-left: 28px; }
.ticks li::before { content: '✓'; position: absolute; left: 0; top: 1px; width: 19px; height: 19px; display: grid; place-items: center; border-radius: 50%; background: var(--accent-soft); color: var(--accent-text); font-size: 11px; font-weight: 700; }
.fine { font-size: 12.5px; color: var(--faint); }
.duration { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.presets { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.preset { flex: 1; padding: 7px 0; min-width: 44px; border-radius: 9px; background: var(--raised); border: 1px solid var(--line-soft); color: var(--muted); font: 12.5px var(--mono); }
.preset:hover { color: var(--text); border-color: var(--accent-text); }
.code-input { font-family: var(--mono); font-size: 22px; letter-spacing: 0.3em; text-transform: uppercase; text-align: center; }

/* ---------- room: header and toolbar ---------- */

.topbar { display: flex; align-items: center; gap: 18px; padding: 14px 24px; border-bottom: 1px solid var(--line-soft); }
.race { flex: 1; min-width: 0; padding-left: 20px; border-left: 1px solid var(--line); }
.race h1 { font-size: 19px; font-weight: 700; letter-spacing: -0.015em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.race p { color: var(--muted); font-size: 13px; }

.code-chip { display: inline-flex; align-items: center; gap: 10px; padding: 8px 14px; border-radius: 12px; background: var(--surface); border: 1px dashed var(--line); }
.code-chip b { font-family: var(--mono); font-size: 17px; letter-spacing: 0.14em; color: var(--accent-text); }
.code-chip span { color: var(--muted); }
.code-chip:hover { border-color: var(--accent-text); }

.toolbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; flex-wrap: wrap; gap: 12px;
  padding: 10px 24px; border-bottom: 1px solid var(--line-soft);
  background: var(--glass); backdrop-filter: blur(12px);
}
.toolbar-actions { display: flex; flex-wrap: wrap; gap: 8px; flex: 1; }
.iam { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13.5px; white-space: nowrap; }
.iam select { width: auto; min-width: 170px; padding: 8px 10px; }

.page { max-width: 1320px; margin: 0 auto; padding: 22px 24px 80px; display: grid; gap: 18px; }
.page > * { min-width: 0; }
.page-title h1 { font-size: 26px; letter-spacing: -0.025em; font-weight: 720; }
.page-title p { color: var(--muted); margin-top: 2px; }

.card, .tyres-panel, .tile, .empty { background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--radius); box-shadow: var(--card-shadow); }
.card { padding: 20px 22px; }
.section-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 6px 14px; margin-bottom: 14px; }
.section-head p { color: var(--muted); font-size: 13px; }

.empty { padding: 56px 24px; text-align: center; display: grid; gap: 14px; justify-items: center; }
.empty h2 { font-size: 22px; letter-spacing: -0.02em; }
.empty p { color: var(--muted); max-width: 470px; }
.empty.left { text-align: left; justify-items: start; padding: 32px; }
.checklist { list-style: none; padding: 0; display: grid; gap: 10px; }
.checklist li { display: flex; align-items: center; gap: 10px; color: var(--text); }
.checklist li i { width: 20px; height: 20px; border-radius: 50%; border: 1.5px solid var(--line); display: grid; place-items: center; font-style: normal; font-size: 11px; font-weight: 700; }
.checklist li.ok { color: var(--muted); }
.checklist li.ok i { background: var(--ok); border-color: var(--ok); color: var(--ok-ink); }

/* ---------- "your next stint" ---------- */

.me-banner {
  display: flex; align-items: center; gap: 16px; padding: 14px 20px; border-radius: var(--radius);
  background: linear-gradient(90deg, color-mix(in srgb, var(--driver) 16%, var(--surface)), var(--surface) 70%);
  border: 1px solid color-mix(in srgb, var(--driver) 35%, var(--line-soft));
}
.me-banner.quiet { background: var(--surface); border-color: var(--line-soft); color: var(--muted); }
.me-banner small { display: block; text-transform: uppercase; letter-spacing: 0.08em; font-size: 11.5px; }
.me-text { flex: 1; }
.me-text b { font-size: 15.5px; }
.me-count { text-align: right; }
.me-count b { font-family: var(--mono); font-size: 22px; color: color-mix(in srgb, var(--driver) 70%, var(--text)); }

.banner-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 14px; align-items: stretch; }
.car-block { display: flex; align-items: center; gap: 14px; min-width: 230px; max-width: 360px; padding: 12px 20px; background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--radius); box-shadow: var(--card-shadow); }
.car-block small { display: block; text-transform: uppercase; letter-spacing: 0.08em; font-size: 11.5px; }
.car-block b { display: block; font-size: 15.5px; line-height: 1.25; }
/* The logo file is used as a stencil and painted in the text colour, so it is white on black and black on white. */
.brand-logo { flex: none; width: 44px; height: 44px; background: var(--text); -webkit-mask: var(--logo) center / contain no-repeat; mask: var(--logo) center / contain no-repeat; }
.brand-mono { flex: none; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; border: 1.5px solid var(--line); font: 700 13px var(--mono); letter-spacing: 0.04em; color: var(--muted); }

.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--driver, var(--open)); flex: none; }

/* ---------- numbers at the top ---------- */

.summary { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 18px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.tiles.six { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 620px) { .tiles.six { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.tile { padding: 15px 17px; display: grid; gap: 2px; align-content: start; }
.tile > small { text-transform: uppercase; letter-spacing: 0.08em; font-size: 11.5px; }
.tile > b { font-family: var(--mono); font-size: 24px; font-weight: 600; letter-spacing: -0.03em; line-height: 1.25; }
.tile > b small { display: block; font-family: var(--font); letter-spacing: 0; font-weight: 400; }
.tile > span { font-size: 12.5px; color: var(--muted); }

.tyres-panel { padding: 16px 18px; }
.tyres-panel.danger { border-color: var(--alert); }
.tyre-numbers { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.tyre-numbers b { display: block; font-family: var(--mono); font-size: 24px; font-weight: 600; line-height: 1.2; }
.legend-row { display: flex; flex-wrap: wrap; gap: 10px; }
.tyres-panel > .legend-row { margin-top: 12px; }
.legend { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; color: var(--muted); }
.warning { margin-top: 12px; padding: 9px 12px; border-radius: 10px; background: var(--alert-soft); color: var(--alert-text); font-size: 13px; }

.tyre { display: inline-block; width: 9px; height: 9px; border-radius: 50%; border: 2px solid var(--open); background: transparent; }
.tyre.soft { background: var(--tyre-soft); border-color: var(--tyre-soft-line); }
.tyre.medium { background: var(--tyre-medium); border-color: var(--tyre-medium-line); }
.tyre.hard { background: var(--tyre-hard); border-color: var(--tyre-hard); }
.tyre.wet { background: var(--tyre-wet); border-color: var(--tyre-wet); }
.tyre.off { opacity: 0.55; }
.tyre-dots { display: inline-grid; grid-template-columns: 9px 9px; gap: 2px; vertical-align: middle; margin-right: 4px; }
.tyre-cell { display: flex; align-items: center; gap: 4px; }

/* ---------- timeline ---------- */

.track { position: relative; height: 30px; border-radius: 8px; background: var(--raised); }
.track.tall { height: 48px; }

.block {
  position: absolute; top: 0; bottom: 0; padding: 0 7px; border: 0; border-radius: 6px;
  background: color-mix(in srgb, var(--driver) 86%, var(--block-mix));
  box-shadow: inset 0 0 0 1.5px var(--surface);
  color: var(--block-ink); font-size: 12px; font-weight: 650; text-align: left;
  overflow: hidden; white-space: nowrap;
}
.block span { display: block; overflow: hidden; text-overflow: ellipsis; }
.block:hover { filter: brightness(1.1); z-index: 1; }
.block.open { background: repeating-linear-gradient(135deg, var(--stripe-a) 0 6px, var(--stripe-b) 6px 12px); color: var(--muted); }
.block.done { opacity: 0.4; }
.block.current { box-shadow: inset 0 0 0 2px var(--text); }
.block.calc-block { --driver: var(--accent); text-align: center; padding: 0 2px; }

.pit { position: absolute; top: -3px; bottom: -3px; min-width: 3px; background: var(--stop); box-shadow: 0 0 0 1px var(--surface); border-radius: 2px; z-index: 2; pointer-events: none; }
.pit.unplanned { background: var(--accent); box-shadow: 0 0 0 1px var(--accent-ink); }
.pit b { position: absolute; left: calc(100% + 5px); top: 50%; transform: translateY(-50%); font: 600 10.5px var(--mono); color: var(--stop); white-space: nowrap; }
.pit.unplanned b { color: var(--warn); }

.flag { position: absolute; top: -5px; bottom: -5px; border-left: 2px dashed var(--text); opacity: 0.7; z-index: 3; pointer-events: none; }
.now { position: absolute; top: -6px; bottom: -6px; width: 2px; background: var(--accent-text); z-index: 4; pointer-events: none; }
.now::before { content: ''; position: absolute; top: -4px; left: -4px; width: 10px; height: 10px; border-radius: 50%; background: var(--accent-text); }

.axis { position: relative; height: 24px; }
.tick { position: absolute; top: 7px; padding-left: 6px; border-left: 1px solid var(--line); font: 11.5px var(--mono); color: var(--muted); white-space: nowrap; }

.lanes-scroll { overflow-x: auto; padding-bottom: 4px; }
.lanes { display: grid; gap: 8px; }
.lane { display: grid; grid-template-columns: 124px minmax(0, 1fr); align-items: center; }
.lane-label {
  position: sticky; left: 0; z-index: 5; align-self: stretch;
  display: flex; align-items: center; gap: 8px; padding-right: 10px;
  background: var(--surface); font-size: 13px; font-weight: 550;
  overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
}
.pit-lane .lane-label { color: var(--stop); }
.pit-lane .track { background: transparent; height: 22px; border-bottom: 1px dashed var(--line); border-radius: 0; }
.pit-lane .pit { top: 3px; bottom: 3px; }

/* ---------- team + stints ---------- */

.board { display: grid; gap: 18px; align-items: start; }
.board.with-side { grid-template-columns: 290px minmax(0, 1fr); }
.team { position: sticky; top: 70px; }
.team-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.team-list li { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line-soft); }
.team-list li:last-child { border-bottom: 0; }
.team-list li > div { display: grid; min-width: 0; }
.team-list li > div b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.team-list .right { margin-left: auto; text-align: right; flex: none; }
.team-list .right b { font-family: var(--mono); }

/* One shared set of columns for all stint rows, so everything lines up. */
.stints {
  min-width: 0; display: grid; column-gap: 18px;
  grid-template-columns: 34px 132px minmax(130px, 1fr) 150px minmax(0, 1.4fr) auto;
}
.stints.live { grid-template-columns: 30px 34px 132px minmax(130px, 1fr) 150px minmax(0, 1.4fr) auto; }
.stints > * { grid-column: 1 / -1; }

.stint {
  display: grid; align-items: center; grid-template-columns: subgrid;
  padding: 13px 16px 13px 14px;
  background: var(--surface); border: 1px solid var(--line-soft);
  border-left: 3px solid var(--driver); border-radius: 13px; box-shadow: var(--card-shadow);
}
.stint.mine { background: color-mix(in srgb, var(--driver) 7%, var(--surface)); }
.stint.done { opacity: 0.55; }
.stint.current { border-color: var(--accent-text); border-left-color: var(--accent-text); box-shadow: 0 0 0 3px var(--accent-soft); opacity: 1; }

.stint-no { font-size: 15px; color: var(--muted); font-weight: 600; }
.stint-time { display: grid; }
.stint-time b { font-size: 17px; font-weight: 600; }
.stint-time span { color: var(--muted); font-size: 13px; }
.stint-driver { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; min-width: 0; }
.stint-driver small { flex-basis: 100%; }
.stint-laps b { font-size: 17px; font-weight: 600; }
.stint-laps span { color: var(--muted); }
.stint-laps small { display: block; }
.stint-flags { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-width: 0; }
.stint-actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
.note { color: var(--muted); font-size: 13px; }

.driver-chip { display: inline-flex; align-items: center; gap: 7px; font-weight: 600; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.driver-chip.open { color: var(--muted); font-weight: 500; padding: 2px 9px; border: 1px dashed var(--line); border-radius: 999px; font-size: 13px; }

.pill { display: inline-flex; align-items: center; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--raised); color: var(--muted); }
.pill.live { background: var(--accent-soft); color: var(--accent-text); }
.pill.bad { background: var(--alert-soft); color: var(--alert-text); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }

.tick-box { width: 26px; height: 26px; border-radius: 8px; border: 1.5px solid var(--line); background: var(--bg); color: transparent; font-size: 14px; font-weight: 700; padding: 0; }
.tick-box:hover { border-color: var(--ok); }
.tick-box.on { background: var(--ok); border-color: var(--ok); color: var(--ok-ink); }

/* the pit stop shown between two stints */
.stop {
  display: flex; align-items: center; flex-wrap: wrap; gap: 4px 16px; width: calc(100% - 30px);
  margin: 0 0 0 30px; padding: 7px 14px; border: 0; border-left: 2px dashed var(--stop-line);
  background: none; color: var(--muted); font-size: 13px; text-align: left; border-radius: 0 8px 8px 0;
}
.stop:hover { background: var(--surface); color: var(--text); }
.stop b { color: var(--text); font-weight: 600; }
.stop.unplanned { border-left-color: var(--warn); }
.box-tag { font: 700 11px var(--mono); letter-spacing: 0.1em; text-transform: uppercase; color: var(--stop); }
.stop.unplanned .box-tag { color: var(--warn); }
.stop-clock { margin-left: auto; }

/* ---------- tables (report, calculator) ---------- */

.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); font-weight: 600; padding: 8px 14px 8px 0; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 11px 14px 11px 0; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table td small { display: block; }
.table td:last-child, .table th:last-child { padding-right: 0; }
.table-scroll { overflow-x: auto; }
.calc-table { min-width: 620px; }
.calc-table td b { font-size: 15px; font-weight: 600; }
.calc-table tr:has(+ .flag-row) td { border-bottom: 0; padding-bottom: 4px; }
.flag-row td { padding-top: 0; }
.flag-row .pill { margin: 0 6px 4px 0; }
.share { display: flex; align-items: center; gap: 10px; }
.share i { height: 8px; border-radius: 4px; background: var(--driver); min-width: 2px; flex: none; }

/* ---------- strategy options ---------- */

.options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.option { display: grid; gap: 10px; align-content: start; padding: 16px 18px; border-radius: 14px; border: 1.5px solid var(--line-soft); background: var(--raised); text-align: left; }
.option:hover { border-color: var(--line); }
.option.selected { border-color: var(--accent-text); background: var(--accent-soft); }
.option-head { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.option-head b { font-size: 16px; }
.option-facts { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; margin: 0; font-size: 13.5px; }
.option-facts dt { color: var(--muted); }
.option-facts dd { margin: 0; font-family: var(--mono); font-weight: 600; }
.option-result { font-size: 13px; color: var(--muted); }
.option-result.good { color: var(--ok); font-weight: 600; }
.verdict { font-size: 14.5px; }
.verdict b { color: var(--accent-text); }
@media (max-width: 620px) { .options, .stop-edit { grid-template-columns: minmax(0, 1fr); } }

/* ---------- pit stop calculator ---------- */

.calc-grid { display: grid; grid-template-columns: minmax(340px, 430px) minmax(0, 1fr); gap: 20px; align-items: start; }
.calc-form { position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow-y: auto; }
#calc-results { display: grid; gap: 16px; min-width: 0; }
#calc-results > * { min-width: 0; }
.calc-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px 20px; }
.calc-head h2 { font-size: 20px; letter-spacing: -0.02em; }
.calc-head p { color: var(--muted); font-size: 13.5px; }

.target-banner { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 20px; padding: 12px 18px; border-radius: var(--radius); background: var(--accent-soft); border: 1px solid var(--accent-line); }
.target-banner small { display: block; text-transform: uppercase; letter-spacing: 0.08em; font-size: 11.5px; color: var(--accent-text); }
.target-banner b { font-size: 15px; }
.target-banner p { flex: 1; min-width: 200px; color: var(--muted); font-size: 13.5px; }

.recent { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.recent > span { flex-basis: 100%; font-size: 12.5px; color: var(--muted); }
.recent-room { display: inline-flex; align-items: center; gap: 8px; max-width: 100%; padding: 6px 11px; border-radius: 9px; border: 1px solid var(--line-soft); background: var(--raised); font-size: 13px; color: var(--text); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.recent-room b { font: 600 12.5px var(--mono); color: var(--accent-text); letter-spacing: 0.06em; }
.recent-room:hover { border-color: var(--accent-text); }
.form [data-where] { margin-top: 14px; }
.form [data-where] .recent { margin-top: 10px; }
.form [data-where] + .field { margin-top: 14px; }

/* ---------- pop-up forms ---------- */

dialog.modal {
  width: min(560px, calc(100vw - 24px)); max-height: min(92vh, 920px); padding: 0;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--line); border-radius: 20px;
  box-shadow: var(--shadow);
}
dialog.modal.wide { width: min(760px, calc(100vw - 24px)); }
dialog.modal.confirm { width: min(440px, calc(100vw - 24px)); }
dialog.modal.confirm p { font-size: 15px; }
dialog::backdrop { background: var(--backdrop); backdrop-filter: blur(3px); }
.modal-head { position: sticky; top: 0; z-index: 6; display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; padding: 20px 24px 14px; background: var(--surface); border-bottom: 1px solid var(--line-soft); }
.modal-head h2 { font-size: 19px; letter-spacing: -0.015em; }
.modal-head p { color: var(--muted); font-size: 13.5px; margin-top: 2px; }
.modal-body { padding: 10px 24px 22px; }
.confirm .modal-body { padding-top: 24px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }
.push-left { margin-right: auto; }
.push { margin-left: auto; }

.stop-edit { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 20px; align-items: start; }
.form .stop-edit .field + .field { margin-top: 0; }
.corners { display: grid; grid-template-columns: 76px 76px; gap: 8px; }
.corners label { position: relative; }
.corners input { position: absolute; opacity: 0; pointer-events: none; }
.corners span { display: grid; place-items: center; height: 44px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); font: 600 12.5px var(--mono); color: var(--muted); cursor: pointer; }
.corners input:checked + span { background: var(--accent-soft); border-color: var(--accent-text); color: var(--accent-text); }
.corners input:focus-visible + span { outline: 2px solid var(--accent-text); outline-offset: 2px; }
.corner-quick { display: flex; gap: 6px; margin-top: 8px; }

.add-driver { display: flex; gap: 10px; margin: 16px 0; }
.driver-card { border: 1px solid var(--line-soft); border-left: 3px solid var(--driver); border-radius: 13px; padding: 14px 16px; margin-bottom: 12px; background: var(--raised); }
.driver-card.locked .chip:not(.mine) { opacity: 0.4; }
.driver-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px; margin-bottom: 12px; }
.driver-head > input[name='name'] { width: 170px; font-weight: 600; }
.driver-head input { background: var(--surface); }
.lap-wrap { display: grid; gap: 4px; width: 232px; }
.lap-wrap .unit-input input { padding-right: 38px; }
.lap-wrap .unit-input i { right: 9px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { padding: 6px 10px; border-radius: 9px; border: 1px solid var(--line); background: var(--surface); font: 12.5px var(--mono); color: var(--text); }
.chip b { color: var(--muted); margin-right: 4px; }
.chip:hover:not(:disabled) { border-color: var(--driver); }
.chip.mine { background: color-mix(in srgb, var(--driver) 86%, var(--block-mix)); border-color: transparent; color: var(--block-ink); font-weight: 600; }
.chip.mine b { color: inherit; opacity: 0.65; }
.chip.taken { opacity: 0.45; border-style: dashed; cursor: not-allowed; }
.chip small { margin-left: 6px; font-family: var(--font); }
.chip:disabled { cursor: not-allowed; }

/* ---------- little messages at the bottom ---------- */

#toasts { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); width: min(560px, calc(100vw - 32px)); z-index: 2147483647; display: grid; gap: 8px; justify-items: center; pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 14px; padding: 12px 17px; border-radius: 13px; background: var(--text); color: var(--bg); box-shadow: var(--shadow); font-size: 14px; max-width: 100%; animation: rise 0.2s ease-out; }
.toast .btn { background: transparent; border-color: currentColor; color: inherit; }
.toast.bad { background: var(--alert-fill); color: #fff; }
.toast.warn { background: var(--accent); color: var(--accent-ink); }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

/* ---------- smaller screens ---------- */

@media (max-width: 1080px) {
  .summary, .board.with-side, .calc-grid { grid-template-columns: minmax(0, 1fr); }
  .team, .calc-form { position: static; max-height: none; }
}
@media (max-width: 860px) {
  .topbar { flex-wrap: wrap; gap: 12px; padding: 14px 16px; }
  .race { order: 4; flex-basis: 100%; padding-left: 0; border-left: 0; }
  .topbar .brand { margin-right: auto; }
  .appbar { padding: 12px 16px; gap: 8px; }
  .appbar .brand span { display: none; }
  .mainnav a { padding: 7px 10px; }
  .toolbar { padding: 10px 16px; position: static; }
  .toolbar-actions { order: 3; flex-basis: 100%; }
  .toolbar-actions .btn { flex: 1 1 auto; }
  .iam { margin-left: auto; }
  .iam select { min-width: 0; max-width: 150px; }
  .page { padding: 16px 16px 80px; }
  .landing { padding: 32px 16px 60px; }
  .landing-grid { grid-template-columns: minmax(0, 1fr); }
  .stints, .stints.live { display: block; }
  .stint { grid-template-columns: auto minmax(0, 1fr) auto; gap: 6px 14px; }
  .stint .tick-box { grid-row: span 2; }
  .stint-flags, .stint-actions { grid-column: 1 / -1; justify-content: flex-start; }
  .stop { margin-left: 14px; width: calc(100% - 14px); }
  .me-banner { flex-wrap: wrap; }
  .banner-row { grid-template-columns: minmax(0, 1fr); }
  .car-block { max-width: none; }
  .grid.four { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ---------- printing / saving as PDF: always light paper, no buttons ---------- */

@media print {
  :root, :root[data-theme='dark'], :root[data-theme='light'] {
    --bg: #fff; --surface: #fff; --raised: #f1f1ee; --line: #cfcfca; --line-soft: #e3e3df;
    --text: #0c0c0c; --muted: #5e5e5a; --accent: #eeee22; --accent-text: #0c0c0c; --accent-soft: #f6f6a0; --accent-line: #0c0c0c;
    --alert: #7624c1; --alert-text: #5e1aa3; --ok: #1583b8; --warn: #0c0c0c; --open: #a9a9a4;
    --stop: #0c0c0c; --stop-line: #8b8b86;
    --stripe-a: #e3e3df; --stripe-b: #efefec; --block-mix: #fff; --card-shadow: none;
    color-scheme: light;
  }
  .no-print, #toasts, dialog, .mainnav, .calc-form { display: none !important; }
  body { font-size: 11.5px; }
  .page { padding: 0; max-width: none; }
  .topbar, .appbar { padding: 0 0 12px; }
  .board.with-side, .summary, .calc-grid { grid-template-columns: minmax(0, 1fr); }
  .team { position: static; }
  .stint, .table tr { break-inside: avoid; }
  .brand-logo { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .lanes-scroll { overflow: visible; }
  .lanes { min-width: 0 !important; }
  .block, .pit, .tyre, .dot, .chip.mine, .share i { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
