/* Setup walkthrough (setup-wizard.js). Built on the welcome dialog (welcome-v3.css);
   tokens only, so every theme works. Under the planner's confirm dialogs (toast.js,
   z-index 10000) so a question asked from a step shows on top. */
.sw-back { z-index: 9995; }
/* The welcome's blur, over a planner that repaints every second, re-ran on each repaint behind the dialog: a plain tint
   instead. The hero's checker wipe would replay on every step. */
.sw-back { backdrop-filter: none; background: color-mix(in srgb, var(--bg) 90%, transparent); }
.sw-hero .w3-check { animation: none; }
/* Header (title, steps) and footer (what is missing, Back / Next) stay put; only the step's content scrolls. */
.sw-card { max-width: 600px; display: flex; flex-direction: column; max-height: calc(100vh / var(--z, 1) - 32px); max-height: calc(100dvh / var(--z, 1) - 32px); }
.sw-hero { flex: none; flex-direction: row; justify-content: center; padding: var(--s4) var(--s5) var(--s3); }
.sw-logo { height: 36px; animation: none; }
.sw-body { --sw-pad: var(--s5); flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; padding: var(--s4) var(--sw-pad) var(--s4); }
.sw-head, .sw-foot { flex: none; }
.sw-scroll { flex: 0 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; margin: 0 calc(-1 * var(--sw-pad)); padding: 2px var(--sw-pad) var(--s3); }
.sw-foot { border-top: 1px solid var(--v2-line, var(--v2-line-2)); padding-top: var(--s2); }
.sw-foot .sw-prev { margin-right: auto; }
.sw-foot .sw-skip:first-child { margin-right: auto; }   /* step 1 has no Back: Skip setup sits where it would */
.sw-step input[aria-invalid="true"] { outline: 2px solid var(--warn, var(--accent)); outline-offset: 1px; }
.sw-title { margin-bottom: var(--s3); animation: none; font-size: clamp(20px, 5vw, 24px); }

.sw-steps { list-style: none; margin: 0 0 var(--s4); padding: 0; display: flex; gap: var(--s2); }
.sw-steps li { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; gap: 4px; font-size: var(--v2-fs-xs); color: var(--text-3, var(--text)); }
.sw-steps li::before { content: ''; display: block; height: 4px; border-radius: 2px; background: var(--v2-line-2); }
.sw-steps li.is-done::before, .sw-steps li.is-now::before { background: var(--accent); }
.sw-steps li.is-now { color: var(--text-hi, var(--text)); font-weight: 600; }
.sw-dot { margin-right: 4px; color: var(--accent); font-weight: 700; }
.sw-lbl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.sw-who { margin: 0 0 var(--s3); font-size: var(--v2-fs-sm); color: var(--text-3, var(--text)); }
.sw-shared { margin-bottom: var(--s2); color: var(--text-2, var(--text)); }
.sw-shared::before { content: 'CF'; margin-right: 6px; color: var(--accent); font-size: .8em; }
.sw-q { margin: 0 0 var(--s2); font-family: var(--v2-font-display); font-size: var(--v2-fs-lg, 18px); color: var(--text-hi, var(--text)); }
.sw-lede { margin: 0 0 var(--s4); color: var(--text-2, var(--text)); line-height: 1.45; }
.sw-step { display: grid; gap: var(--s3); }
.sw-step > * { margin-top: 0; margin-bottom: 0; }

.sw-field { display: grid; gap: 4px; min-width: 0; }
.sw-flabel { font-size: var(--v2-fs-sm); font-weight: 600; color: var(--text-2, var(--text)); }
.sw-field input, .sw-field select, .sw-drv input { width: 100%; box-sizing: border-box; min-height: var(--v2-h-lg, 40px); font-size: 16px; }
.sw-field[hidden] { display: none; }
.sw-hint { font-size: var(--v2-fs-sm); color: var(--text-3, var(--text)); line-height: 1.4; }
.sw-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s3); }

.sw-drvs { display: grid; gap: var(--s2); }
.sw-drv { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--s2); }
.sw-add { justify-self: start; }
.sw-teams { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; }

.sw-note { color: var(--text-2, var(--text)); line-height: 1.45; }
.sw-found { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); flex-wrap: wrap;
    padding: var(--s3); border: 1px solid var(--accent); border-radius: var(--v2-r, 8px); background: var(--v2-inset); }
.sw-found p { margin: 0; flex: 1 1 220px; }
.sw-ok { font-size: var(--v2-fs-sm); font-weight: 600; color: var(--good, var(--accent)); }
.sw-warn { font-size: var(--v2-fs-sm); line-height: 1.45; color: var(--warn, var(--text)); border-left: 3px solid var(--warn, currentColor); padding-left: var(--s2, 8px); }

.sw-how { padding: var(--s3); border-radius: var(--v2-r, 8px); background: var(--v2-inset); }
.sw-how p { margin: 0 0 var(--s2); line-height: 1.45; }
.sw-how p:last-child { margin-bottom: 0; }
.sw-code code { font-size: 18px; letter-spacing: .04em; }
.sw-prog { margin: 0 0 6px; font-size: var(--v2-fs-md); }
.sw-bar { height: 8px; border-radius: 4px; background: var(--v2-line-2); overflow: hidden; }
.sw-bar span { display: block; height: 100%; background: var(--accent); transition: width .3s ease; }
.sw-got { font-size: var(--v2-fs-md); }

/* Community numbers: below the boxes, set off by a rule, one compact row (secondary to Saved data). */
.sw-comm { margin-top: var(--s4); padding-top: var(--s3); border-top: 1px solid var(--v2-line-2, var(--line)); }
.sw-comm-row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--s2) var(--s3); margin-top: var(--s2); }
.sw-comm-row .sw-field { flex: 1 1 220px; }
.sw-comm-row .v2-btn { min-height: var(--v2-h-lg, 40px); }
.sw-comm .sw-ok { margin: var(--s2) 0 0; }
.sw-gh { margin: var(--s2) 0 0; font-size: var(--v2-fs-sm); text-transform: uppercase; letter-spacing: .06em; color: var(--text-3, var(--text)); }
.sw-opts { display: grid; gap: var(--s2); }
.sw-opt { display: grid; gap: 4px; width: 100%; text-align: left; padding: var(--s3); cursor: pointer;
    border: 1px solid var(--v2-line-2); border-radius: var(--v2-r, 8px); background: var(--v2-panel); color: var(--text); font: inherit; }
.sw-opt:hover:not([disabled]) { border-color: var(--accent); }
.sw-opt[aria-pressed="true"] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); background: var(--v2-inset); }
.sw-opt[disabled] { opacity: .6; cursor: default; }
.sw-opt-h { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; }
.sw-opt-l { font-size: var(--v2-fs-sm); color: var(--text-2, var(--text)); line-height: 1.4; }

.sw-explain p { margin: 0; line-height: 1.45; }

/* Quiet until Next is pressed with something missing, then the warning color. */
.sw-miss { min-height: 1.4em; margin: 0 0 var(--s2); font-size: var(--v2-fs-sm); color: var(--text-3, var(--text)); }
.sw-miss.is-tried { color: var(--warn, var(--text-2)); font-weight: 600; }
/* Step 3's three ways to get the numbers, the one in use marked. */
.sw-ways { margin: 0; padding: 0; list-style: none; display: grid; gap: 4px; }
.sw-ways li { padding: 6px var(--s2); border-left: 2px solid var(--v2-line-2); line-height: 1.45; color: var(--text-2, var(--text)); }
.sw-ways li.is-now { border-left-color: var(--accent); background: var(--v2-inset); }
.sw-acts { animation: none; }
.sw-out { margin: var(--s2) 0 0; text-align: center; font-size: var(--v2-fs-sm); color: var(--text-3, var(--text)); }
.sw-link { background: none; border: 0; padding: 8px 4px; color: var(--text-2, var(--text)); text-decoration: underline; cursor: pointer; font: inherit; }
.sw-danger { color: var(--bad, var(--text-2)); }

/* Part B: Yes / No, a select with its Preview button, checkboxes. */
.sw-yn { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s2); }
.sw-ynb { text-align: center; font-weight: 600; min-height: var(--v2-h-lg, 40px); }
.sw-row { display: flex; gap: var(--s2); align-items: center; min-width: 0; }
.sw-row select { flex: 1 1 auto; min-width: 0; }
.sw-check { display: flex; gap: var(--s2); align-items: flex-start; }
.sw-check > span { display: grid; gap: 2px; }
.sw-more summary { cursor: pointer; }
.sw-more .explain-body { padding-top: var(--s3); }

/* Rates: Recalculate in the Fuel saving row, Spare laps, and the fuel-save wear cut. */
.fs-recalc { font-size: var(--fs-small, 13px); opacity: .85; margin-left: var(--s2); white-space: nowrap; }
#fsAutoMath { max-width: 70ch; line-height: 1.45; }
.rates-spare { max-width: 260px; margin: var(--s3) 0; }
.fs-wear-less { display: inline-flex; align-items: center; gap: var(--s2); white-space: nowrap; font-size: var(--fs-small, 13px); color: var(--text-2, var(--text)); }
.fs-wear-less input { width: 72px; }

/* "Add when you can drive" (setup-wizard.js paintAvail): a banner on the Drivers tab, a close X and a wrapping row of hour toggles. */
.sw-avail { position: relative; display: grid; gap: var(--s2); margin: 0 0 var(--s3); padding: var(--s3) 48px var(--s3) var(--s3);
    border: 1px solid var(--accent); border-radius: var(--v2-r, 8px); background: var(--v2-inset); }
.sw-avail > * { margin: 0; }
.sw-avail .sw-acts { display: flex; flex-wrap: wrap; gap: var(--s2); }
.sw-x { position: absolute; top: var(--s2); right: var(--s2); z-index: 1; width: 40px; height: 40px; padding: 0;
    border: 0; border-radius: var(--v2-r, 8px); background: none; color: var(--text-2, var(--text)); font-size: 24px; line-height: 1; cursor: pointer; }
.sw-x:hover { background: var(--v2-inset); }
.sw-avail .sw-title { padding-right: 40px; }
.sw-hours { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 6px; }
.sw-hr { min-height: 40px; padding: 0 4px; text-align: center; place-content: center; font-variant-numeric: tabular-nums; }
.sw-hr[aria-pressed="false"] { color: var(--text-3, var(--text)); }
/* Maybe: the availability grid's look (app.css .av-cell.maybe) on the accent, with its ? mark. */
.sw-hr[aria-pressed="mixed"] { background: color-mix(in srgb, var(--accent) 9%, transparent); box-shadow: inset 2px 0 0 color-mix(in srgb, var(--accent) 45%, transparent); color: var(--text-2); font-style: italic; }
.sw-hr[aria-pressed="mixed"]::after { content: "?"; margin-left: 3px; font-size: .85em; font-style: normal; opacity: .85; }
.sw-avail .sw-acts { flex-wrap: wrap; }
.sw-avail .sw-acts > button { flex: 1 0 auto; }

@media (max-width: 480px), (max-height: 640px) {
    .sw-hero { display: none; }   /* the logo strip; room for the step on a phone or short window */
}
@media (max-width: 480px) {
    .sw-body { --sw-pad: var(--s4); padding: var(--s3) var(--sw-pad) var(--s3); }
    .sw-grid, .sw-drv { grid-template-columns: minmax(0, 1fr); }
    .sw-drv { padding-bottom: var(--s2); border-bottom: 1px solid var(--v2-line); }
    .sw-lbl { display: none; }
    .sw-steps li.is-now .sw-lbl { display: block; }
}

/* Tire wear: four corner boxes across the grid. */
.sw-wear { grid-column: 1 / -1; margin: 0; padding: 0; border: 0; min-width: 0; }
.sw-corners { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s2, 8px); }

/* Step 2 pickers: track tiles with the country flag; car class, then brand, then model. */
.sw-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); grid-auto-rows: min-content; gap: var(--s2); }
.sw-tiles[data-live="track"] { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); max-height: 280px; overflow-y: auto; padding: 2px; }
.sw-tile { margin: 0; display: flex; align-items: center; gap: var(--s2); min-height: var(--v2-h-lg, 40px); padding: var(--s2) var(--s3); text-align: left; cursor: pointer;
    border: 1px solid var(--v2-line-2); border-radius: var(--v2-r, 8px); background: var(--v2-panel); color: var(--text); font: inherit; line-height: 1.3; }
.sw-tile:hover { border-color: var(--accent); }
.sw-tile:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sw-tile[aria-pressed="true"] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); background: var(--v2-inset); }
.sw-classes { grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); }
.sw-class { justify-content: center; min-height: 64px; font-family: var(--v2-font-display); font-size: var(--v2-fs-lg, 18px); font-weight: 600; }
.sw-brands { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
.sw-brand { flex-direction: column; justify-content: center; text-align: center; gap: 6px; min-height: 112px; }
.sw-brand .sw-hint { font-size: var(--v2-fs-xs); }
.sw-mark { width: 48px; height: 48px; object-fit: contain; flex: none; }
.sw-mark.sw-chip { display: grid; place-items: center; border-radius: 50%; background: var(--brand); color: #fff; font-weight: 700; font-size: 15px; letter-spacing: .02em; }
.sw-flag { width: 28px; height: 21px; flex: none; border-radius: 2px; box-shadow: 0 0 0 1px var(--v2-line-2); object-fit: cover; }
.sw-flag.sw-chip { display: grid; place-items: center; font-size: 11px; font-weight: 700; background: var(--v2-inset); color: var(--text-2, var(--text)); }
.sw-noflag { box-shadow: none; }
.sw-cback { justify-self: start; padding-left: 0; }
[data-live="car"] { display: grid; gap: var(--s2); }

/* Step 2 "Pick an official race": day tabs (the /official day picker, .ofl-day), then that day's series as the Schedule
   tab's cards (official.html .ofl-*) in a scrolling list, each with a small card image and a wrapping grid of start chips
   (dashed: estimated); below the list, the wizard's own car picker for the picked race. */
.sw-offdays { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: thin; border-bottom: 1px solid var(--v2-line-2); }
.sw-offday { flex: none; min-height: 40px; padding: 4px 10px; border: 0; border-bottom: 2px solid transparent; background: transparent; cursor: pointer;
    color: var(--text-2, var(--text)); font: inherit; font-size: var(--v2-fs-sm); font-weight: 600; white-space: nowrap; }
.sw-offday:hover { color: var(--text-hi, var(--text)); }
.sw-offday:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.sw-offday[aria-pressed="true"] { border-bottom-color: var(--accent); color: var(--text-hi, var(--text)); }
.sw-offlist { display: grid; gap: var(--s2); max-height: min(48vh, 420px); overflow-y: auto; overscroll-behavior: contain; padding: 2px; }
.sw-offsec { display: grid; gap: var(--s2); }
.sw-offsec .sw-gh { margin: var(--s2) 0 0; }
.sw-offsec:first-child .sw-gh { margin-top: 0; }
.sw-offcard { display: flex; gap: var(--s3); min-width: 0; padding: var(--s2) var(--s3); border: 1px solid var(--v2-line-2); border-radius: var(--v2-r, 8px); background: var(--v2-panel); }
.sw-offimg { flex: none; width: 96px; height: 54px; object-fit: cover; border-radius: var(--v2-r-md, 6px); background: var(--v2-inset); }
.sw-offcb { flex: 1 1 auto; min-width: 0; display: grid; gap: 2px; }
.sw-offcb > p { margin: 0; }
.sw-offname { font-weight: 650; color: var(--text-hi, var(--text)); }
.sw-offslots { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 6px; margin-top: 6px; }
.sw-offslot { min-height: 40px; padding: 4px 6px; cursor: pointer; text-align: center; white-space: nowrap; font-variant-numeric: tabular-nums;
    border: 1px solid var(--v2-line-2); border-radius: var(--v2-r-md, 6px); background: transparent; color: var(--text); font: inherit; font-size: var(--v2-fs-sm); font-weight: 600; }
.sw-offslot.is-est { border-style: dashed; }
.sw-offslot:hover { border-color: var(--accent); }
.sw-offslot:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sw-offslot[aria-pressed="true"] { border-color: var(--accent); border-style: solid; box-shadow: inset 0 0 0 1px var(--accent); background: var(--v2-inset); }
.sw-offcars { display: grid; gap: var(--s2); }
.sw-offpicked { margin: var(--s2) 0 0; font-weight: 600; color: var(--text-hi, var(--text)); }
.sw-vh { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
@media (max-width: 480px) {
    .sw-offimg { display: none; }
    .sw-offlist { max-height: 44vh; }
}

/* Step 2's filled official race: a summary card of read-only facts (label left, value right), the race's car picker,
   then Change race / Edit details. Steps 3 and 4 reuse the fact rows, each with a small edit link. */
.sw-offsum { display: grid; gap: var(--s3); padding: var(--s3); border: 1px solid var(--accent); border-radius: var(--v2-r, 8px); background: var(--v2-inset); }
.sw-offsum > * { margin: 0; }
.sw-offsum:focus { outline: none; }
.sw-offsum:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sw-facts { display: grid; gap: 0; }
.sw-fact { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 2px var(--s3); padding: 6px 0; border-bottom: 1px solid var(--v2-line, var(--v2-line-2)); }
.sw-fact:last-child { border-bottom: 0; }
.sw-fact .sw-flabel { font-weight: 500; color: var(--text-3, var(--text)); }
.sw-fval { margin: 0; font-weight: 600; color: var(--text-hi, var(--text)); text-align: right; font-variant-numeric: tabular-nums; }
.sw-fact .sw-link { padding: 4px 6px; font-weight: 400; font-size: var(--v2-fs-sm); }
.sw-offcars > .sw-fval { text-align: left; }
.sw-offacts { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2) var(--s3); }
.sw-offacts .v2-btn { min-height: var(--v2-h-lg, 40px); }

/* Wide screens: a wider, tighter card so most steps fit without scrolling (fields, options and tiles go across, not down).
   Phones and narrow windows keep the 600 px card above. */
@media (min-width: 1100px) {
    .sw-card { max-width: 920px; }
    .sw-hero { padding: var(--s2) var(--s5); }
    .sw-logo { height: 28px; }
    .sw-body { padding-top: var(--s3); padding-bottom: var(--s3); }
    .sw-title { margin-bottom: var(--s2); }
    .sw-steps { margin-bottom: var(--s3); }
    .sw-lede { margin-bottom: 0; }
    .sw-grid { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
    .sw-opts { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
    .sw-ways { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .sw-brands { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); }
    .sw-brand { min-height: 84px; gap: 4px; padding: var(--s2); }
    .sw-brand .sw-mark { width: 36px; height: 36px; }
    .sw-class { min-height: 52px; }
    .sw-opt { padding: var(--s2) var(--s3); }
    .sw-scroll [data-live] > .sw-note { margin: 0; }   /* the fuel-save line: no paragraph margins on top of the grid gap */
}
