/* Pitwall. Warm paper, serif voice, one clay accent. See DESIGN.md. */

@font-face { font-family: "Newsreader"; src: url("/fonts/newsreader.woff2") format("woff2"); font-weight: 200 800; font-style: normal; font-display: swap; }
@font-face { font-family: "Newsreader"; src: url("/fonts/newsreader-italic.woff2") format("woff2"); font-weight: 200 800; font-style: italic; font-display: swap; }
@font-face { font-family: "Geist"; src: url("/fonts/geist.woff2") format("woff2"); font-weight: 100 900; font-display: swap; unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Geist"; src: url("/fonts/geist-ext.woff2") format("woff2"); font-weight: 100 900; font-display: swap; unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }

:root {
  --bg: #f4f1ea;
  --paper: #fcfaf6;
  --sunk: #ebe7dc;
  --ink: #1d1c19;
  --body: #46433d;
  --muted: #6e695f;
  --line: #e2ddd0;
  --line-strong: #cbc4b4;
  --accent: #c4583a;
  --accent-deep: #a5442a;
  --accent-wash: #f6e3da;
  --good: #3f8266;
  --good-wash: #e0ede5;
  --throttle: #3f8266;
  --brake: #b93a4e;
  --warn: #c98a1b;
  --warn-deep: #8c5d08;
  --warn-wash: #f6ead0;
  --cold: #4a78b0;
  --cold-wash: #e1e9f3;
  --serif: "Newsreader", "Iowan Old Style", Georgia, serif;
  --sans: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --r: 14px;
  --r-lg: 22px;
  --pad: clamp(18px, 4vw, 40px);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --on-accent: #fff;
  --good-ink: #2c634c;
  --bad-wash: var(--bad-wash);
  --bad-ink: var(--bad-ink);
  --cold-ink: var(--cold-ink);
  --tyre: #1d1c19;
  --on-ink-muted: #c9c3b6;
  --lift: var(--lift);
  color-scheme: light;
  --shadow: 0 1px 2px rgb(70 50 20 / 0.05), 0 12px 32px -18px rgb(70 50 20 / 0.22);
  --top: 60px;
}

:root[data-theme="dark"] {
  --bg: #191816;
  --paper: #22211e;
  --sunk: #2d2b27;
  --ink: #f2eee5;
  --body: #cec9be;
  --muted: #9d978b;
  --line: #33312d;
  --line-strong: #4c4942;
  --accent: #d97757;
  --accent-deep: #e9957a;
  --accent-wash: #40291f;
  --good: #62ab88;
  --good-wash: #1f3329;
  --throttle: #62ab88;
  --brake: #e2677c;
  --warn: #dba23a;
  --warn-deep: #e8bd66;
  --warn-wash: #3a2e16;
  --cold: #7ba6de;
  --cold-wash: #1f2b3c;
  --on-accent: #1b1210;
  --good-ink: #93cfb0;
  --bad-wash: #40232a;
  --bad-ink: #f2a0ad;
  --cold-ink: #a9c6ec;
  --tyre: #0f0e0d;
  --on-ink-muted: #6e695f;
  --lift: rgb(0 0 0 / 0.4);
  color-scheme: dark;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.3), 0 16px 36px -20px rgb(0 0 0 / 0.7);
}

*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--top) + 64px); }
body { background: var(--bg); color: var(--body); font: 400 16px/1.55 var(--sans); -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; min-height: 100dvh; }
ul, ol { list-style: none; padding: 0; }
a { color: inherit; text-decoration: none; }
button, input, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; }
button:disabled { cursor: not-allowed; }
em { font-style: italic; }
table { border-collapse: collapse; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 6px; }
#app:focus { outline: none; }
::selection { background: var(--accent-wash); color: var(--ink); }

.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip { position: absolute; left: 12px; top: -60px; z-index: 50; background: var(--ink); color: var(--paper); padding: 10px 16px; border-radius: 999px; transition: top 0.2s; }
.skip:focus { top: 12px; }
.noscript { padding: 40px var(--pad); }

/* Type */
.display { font: 400 clamp(36px, 6.4vw, 68px)/1.04 var(--serif); letter-spacing: -0.022em; color: var(--ink); text-wrap: balance; font-optical-sizing: auto; }
.display em, .display-s em { color: var(--accent-deep); }
.display-s { font: 400 clamp(26px, 3.2vw, 34px)/1.12 var(--serif); letter-spacing: -0.015em; color: var(--ink); text-wrap: balance; }
.prose { color: var(--body); max-width: 62ch; text-wrap: pretty; }
.eyebrow { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; font-size: 14px; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum", "zero" 0; }
.path { font-size: 0.92em; background: var(--sunk); padding: 1px 7px; border-radius: 6px; white-space: nowrap; color: var(--ink); }
.field-label { font-size: 14px; font-weight: 500; color: var(--ink); }
.field-msg { color: var(--brake); font-size: 14px; min-height: 0; }
.field-msg:empty { display: none; }

/* Icons: Phosphor regular, painted through a mask so they take the text colour. */
.ic { display: inline-block; width: 1.15em; height: 1.15em; flex: none; background: currentColor; mask: var(--u) center / contain no-repeat; -webkit-mask: var(--u) center / contain no-repeat; vertical-align: -0.2em; }
.ic-arrow-left { --u: url("/icons/arrow-left.svg"); }
.ic-arrow-right { --u: url("/icons/arrow-right.svg"); }
.ic-arrow-up { --u: url("/icons/arrow-up.svg"); }
.ic-caret-down { --u: url("/icons/caret-down.svg"); }
.ic-check { --u: url("/icons/check.svg"); }
.ic-file-text { --u: url("/icons/file-text.svg"); }
.ic-paperclip { --u: url("/icons/paperclip.svg"); }
.ic-plus { --u: url("/icons/plus.svg"); }
.ic-sign-out { --u: url("/icons/sign-out.svg"); }
.ic-trash { --u: url("/icons/trash.svg"); }
.ic-warning-circle { --u: url("/icons/warning-circle.svg"); }
.ic-x { --u: url("/icons/x.svg"); }
.ic-moon { --u: url("/icons/moon.svg"); }
.ic-sun { --u: url("/icons/sun.svg"); }

.logo { width: 26px; height: 26px; flex: none; }
.logo path { fill: none; stroke: var(--accent); stroke-width: 2.4; stroke-linejoin: round; stroke-linecap: round; }
.logo.draw path { stroke-dasharray: 1; stroke-dashoffset: 1; }
.in .logo.draw path { animation: draw 1.6s var(--ease) 0.15s forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }

/* Controls */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--paper); color: var(--ink); font-size: 15px; font-weight: 500; white-space: nowrap; transition: background-color 0.2s, border-color 0.2s, transform 0.2s var(--ease), box-shadow 0.2s; }
.btn:hover { border-color: var(--ink); }
.btn:active { transform: scale(0.98); }
.btn-soft { border-color: transparent; background: var(--sunk); cursor: pointer; }
.btn-soft:hover { border-color: var(--line-strong); }
.btn-accent { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-accent:hover { background: var(--accent-deep); border-color: var(--accent-deep); }
.btn-danger { color: var(--brake); }
.btn-danger:hover { border-color: var(--brake); }
.btn:disabled { opacity: 0.5; }
.send { width: 44px; height: 44px; flex: none; display: inline-grid; place-items: center; border-radius: 50%; background: var(--accent); color: var(--on-accent); font-size: 18px; transition: background-color 0.2s, transform 0.2s var(--ease), opacity 0.2s; }
.send:hover { background: var(--accent-deep); }
.send:active { transform: scale(0.94); }
.send:disabled { background: var(--line-strong); }
.icon-btn { width: 36px; height: 36px; flex: none; display: inline-grid; place-items: center; border-radius: 50%; color: var(--muted); transition: background-color 0.2s, color 0.2s; }
.icon-btn:hover { background: var(--sunk); color: var(--ink); }
.link { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 12px; border-radius: 999px; font-size: 15px; color: var(--body); transition: background-color 0.2s, color 0.2s; }
.link:hover { background: var(--sunk); color: var(--ink); }
.input { width: 100%; min-height: 48px; padding: 10px 16px; background: var(--paper); color: var(--ink); border: 1px solid var(--line-strong); border-radius: var(--r); transition: border-color 0.2s, box-shadow 0.2s; }
.input:hover { border-color: var(--muted); }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-wash); }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }

.pill { display: inline-flex; align-items: center; min-height: 26px; padding: 0 11px; border-radius: 999px; background: var(--sunk); color: var(--body); font-size: 13px; font-weight: 500; white-space: nowrap; }
.pill-accent { background: var(--accent-wash); color: var(--accent-deep); }
.pill-good { background: var(--good-wash); color: var(--good-ink); }
.pill-warn { background: var(--warn-wash); color: var(--warn-deep); }
.pill-bad { background: var(--bad-wash); color: var(--bad-ink); }
.pill-cold { background: var(--cold-wash); color: var(--cold-ink); }

.theme .ic-sun { display: none; }
[data-theme="dark"] .theme .ic-sun { display: inline-block; }
[data-theme="dark"] .theme .ic-moon { display: none; }
.gate-theme { position: fixed; top: 10px; right: max(var(--pad), env(safe-area-inset-right)); margin-right: -12px; }
body, .top, .tabs { transition: background-color 0.3s; }

/* Motion primitives */
.rv { opacity: 0; transform: translateY(10px); transition: opacity 0.7s var(--ease), transform 0.7s var(--ease); transition-delay: calc(var(--i, 0) * 60ms); }
.rv.in { opacity: 1; transform: none; }
.skel { display: block; height: 14px; border-radius: 8px; background: linear-gradient(90deg, var(--sunk) 0%, var(--line) 50%, var(--sunk) 100%); background-size: 200% 100%; animation: skel 1.5s linear infinite; }
.skel-s { width: 110px; } .skel-m { width: 240px; max-width: 70%; } .skel-h { width: min(460px, 80%); height: 48px; }
.skel-block { width: 100%; height: 300px; border-radius: var(--r-lg); }
@keyframes skel { to { background-position: -200% 0; } }
.shake { animation: shake 0.35s; }
@keyframes shake { 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }

/* Shell */
.top { position: sticky; top: 0; z-index: 20; height: var(--top); display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 var(--pad); padding-left: max(var(--pad), env(safe-area-inset-left)); padding-right: max(var(--pad), env(safe-area-inset-right)); background: color-mix(in srgb, var(--bg) 86%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); }
.brand { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; font: 500 22px/1 var(--serif); letter-spacing: -0.01em; color: var(--ink); }
.brand-lg { font-size: 26px; }
.brand-lg .logo { width: 32px; height: 32px; }
.top-nav { display: flex; align-items: center; gap: 2px; margin-right: -12px; }
.page { max-width: 1160px; margin: 0 auto; padding: clamp(20px, 4vw, 48px) var(--pad) 96px; display: grid; gap: clamp(40px, 6vw, 72px); grid-template-columns: minmax(0, 1fr); }
.foot { padding: 28px var(--pad) calc(28px + env(safe-area-inset-bottom)); color: var(--muted); font-size: 13px; text-align: center; }
.section { display: grid; gap: 14px; grid-template-columns: minmax(0, 1fr); align-content: start; }
.section-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 24px; }
.section-head .muted { font-size: 14px; max-width: 56ch; }
.back { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; width: fit-content; margin: -8px 0 calc(clamp(40px, 6vw, 72px) * -1 + 8px) -12px; padding: 0 12px; border-radius: 999px; font-size: 15px; color: var(--muted); transition: background-color 0.2s, color 0.2s; }
.back:hover { background: var(--sunk); color: var(--ink); }
.back .ic { transition: transform 0.3s var(--ease); }
.back:hover .ic { transform: translateX(-3px); }
.blank { display: grid; gap: 18px; justify-items: start; max-width: 680px; padding: 16px 0 40px; }
.blank .back { margin: 0 0 0 -12px; }
.loading { display: grid; gap: 16px; }

/* Sign in */
.gate { min-height: 100dvh; display: grid; place-items: center; padding: 32px var(--pad); }
.gate-card { width: min(100%, 520px); display: grid; gap: 20px; }
.gate-card > * { opacity: 0; transform: translateY(12px); transition: opacity 0.9s var(--ease), transform 0.9s var(--ease); }
.gate.in .gate-card > * { opacity: 1; transform: none; }
.gate.in .gate-card > :nth-child(2) { transition-delay: 0.1s; }
.gate.in .gate-card > :nth-child(3) { transition-delay: 0.2s; }
.gate.in .gate-card > :nth-child(4) { transition-delay: 0.3s; }
.gate.in .gate-card > :nth-child(5) { transition-delay: 0.4s; }
.gate-title { font-size: clamp(38px, 8vw, 60px); margin-top: 12px; }
.gate-form { display: grid; gap: 8px; margin-top: 12px; }
.gate-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 6px 6px 6px 0; background: var(--paper); border: 1px solid var(--line-strong); border-radius: 999px; box-shadow: var(--shadow); transition: border-color 0.2s, box-shadow 0.2s; }
.gate-row:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-wash), var(--shadow); }
.gate-row .input { border: 0; background: transparent; border-radius: 999px; padding-left: 22px; box-shadow: none; }
.gate-foot { font-size: 13px; color: var(--muted); margin-top: 8px; }

/* Home */
.hello { display: grid; gap: 14px; padding-top: clamp(8px, 4vw, 40px); }
.hello, .composer, .how { width: 100%; max-width: 820px; margin-inline: auto; }
.hello { text-align: center; justify-items: center; }
.composer { margin-top: calc(clamp(40px, 6vw, 72px) * -0.55); display: grid; gap: 10px; padding: 14px; background: var(--paper); border: 1px solid var(--line-strong); border-radius: var(--r-lg); box-shadow: var(--shadow); transition: border-color 0.25s, box-shadow 0.25s, background-color 0.25s; }
.composer:focus-within { border-color: var(--muted); }
.composer.over { border-color: var(--accent); background: var(--accent-wash); box-shadow: 0 0 0 5px var(--accent-wash), var(--shadow); }
.composer-text { width: 100%; min-height: 48px; padding: 10px 8px; border: 0; background: transparent; color: var(--ink); font-size: 17px; resize: none; display: block; }
.composer-text::placeholder { color: var(--muted); }
.composer-text:focus { outline: none; }
textarea.composer-text { min-height: 76px; line-height: 1.5; }
.composer-bar { display: flex; align-items: center; gap: 12px; }
.composer-hint { flex: 1; min-width: 0; font-size: 14px; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips:empty { display: none; }
.chip { display: inline-flex; align-items: center; gap: 10px; max-width: 100%; padding: 8px 8px 8px 12px; background: var(--bg); border: 1px solid var(--line); border-radius: var(--r); animation: rise 0.4s var(--ease); }
.chip > .ic { color: var(--accent); font-size: 20px; }
.chip-main { display: grid; min-width: 0; line-height: 1.3; }
.chip-name { font-size: 14px; font-weight: 500; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip-sub { font-size: 12.5px; color: var(--muted); }
.chips-static .chip { padding-right: 16px; }
.progress { height: 4px; border-radius: 4px; background: var(--sunk); overflow: hidden; }
.progress span { display: block; height: 100%; width: var(--p, 0%); background: var(--accent); border-radius: 4px; transition: width 0.2s linear; }
.how { margin-top: calc(clamp(40px, 6vw, 72px) * -0.5); display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px 28px; }
.how-k { font: 500 italic 18px/1.3 var(--serif); color: var(--ink); margin-bottom: 4px; }
.how-v { font-size: 14px; color: var(--body); line-height: 1.6; }

.stints { display: grid; gap: 10px; }
.stint { display: grid; grid-template-columns: minmax(0, 1fr) auto auto 24px; align-items: center; gap: 12px 24px; min-height: 84px; padding: 16px 20px; background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-lg); transition: border-color 0.25s, box-shadow 0.25s, transform 0.3s var(--ease); }
a.stint:hover { border-color: var(--line-strong); box-shadow: var(--shadow); transform: translateY(-1px); }
.stint-main { display: grid; gap: 2px; min-width: 0; }
.stint-title { font: 500 21px/1.25 var(--serif); color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stint-sub { font-size: 14px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stint-time { font-size: 20px; font-weight: 600; line-height: 1; letter-spacing: -0.01em; color: var(--ink); }
.stint-meta { display: grid; justify-items: end; gap: 4px; }
.stint-date { font-size: 13px; color: var(--muted); }
.stint-go { color: var(--muted); transition: color 0.2s, transform 0.3s var(--ease); }
a.stint:hover .stint-go { color: var(--accent); transform: translateX(3px); }

/* Debrief header */
.dh { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 28px 56px; align-items: end; }
.dh-main { display: grid; gap: 10px; }
.dh-title { font-size: clamp(44px, 9vw, 96px); line-height: 0.98; }
.dh-sub { font-size: 17px; color: var(--body); }
.stats { display: grid; grid-template-columns: repeat(3, auto); gap: 14px 32px; }
.stat { display: grid; gap: 2px; }
.stat dt { font-size: 13px; color: var(--muted); }
.stat dd { font-size: 17px; font-weight: 500; color: var(--ink); }
.stat-lead { grid-column: 1 / -1; }
.stat-lead dd { font: 400 clamp(48px, 6vw, 68px)/1 var(--serif); letter-spacing: -0.02em; color: var(--accent-deep); }

.tabs { position: sticky; top: var(--top); z-index: 15; margin: calc(clamp(40px, 6vw, 72px) * -0.5) calc(var(--pad) * -1) calc(clamp(40px, 6vw, 72px) * -0.5); padding: 8px var(--pad); background: color-mix(in srgb, var(--bg) 86%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); }
.tabs-in { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; overscroll-behavior-x: contain; }
.tabs-in::-webkit-scrollbar { display: none; }
.tabs button { min-height: 40px; padding: 0 16px; border-radius: 999px; font-size: 15px; color: var(--muted); white-space: nowrap; transition: background-color 0.25s, color 0.25s; }
.tabs button:hover { color: var(--ink); }
.tabs button[aria-current="true"] { background: var(--ink); color: var(--paper); }

/* The call */
.call { grid-template-columns: minmax(0, 1fr) minmax(0, 330px); gap: clamp(24px, 4vw, 56px); align-items: start; }
#eng-body { display: grid; gap: 14px; grid-template-columns: minmax(0, 1fr); }
.note { display: grid; gap: 18px; padding: clamp(20px, 3.4vw, 40px); background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow); }
.note-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px; }
.avatar { width: 40px; height: 40px; flex: none; display: grid; place-items: center; border-radius: 50%; background: var(--accent-wash); }
.avatar .logo { width: 22px; height: 22px; }
.note-id { flex: 1; min-width: 0; line-height: 1.3; }
.note-who { font-weight: 500; color: var(--ink); font-size: 15px; }
.note-when { font-size: 13px; color: var(--muted); }
.note-title { font: 400 clamp(26px, 3.6vw, 38px)/1.14 var(--serif); letter-spacing: -0.015em; color: var(--ink); text-wrap: balance; }
.note-sum { font-size: 17px; line-height: 1.6; color: var(--body); max-width: 64ch; text-wrap: pretty; }
.note-block { display: grid; gap: 8px; padding-top: 18px; border-top: 1px solid var(--line); }
.note-h { font: 500 italic 19px/1.3 var(--serif); color: var(--ink); }
.note-list { display: grid; gap: 8px; }
.note-list li { position: relative; padding-left: 18px; max-width: 64ch; }
.note-list li::before { content: ""; position: absolute; left: 2px; top: 0.68em; width: 5px; height: 5px; border-radius: 50%; background: var(--line-strong); }
.note-list strong { font-weight: 500; color: var(--ink); }
.note-list strong::after { content: "."; }
.note-foot { font-size: 13px; color: var(--muted); }
.dialled { display: flex; align-items: center; gap: 12px; padding: 16px 18px; background: var(--good-wash); color: var(--good-ink); border-radius: var(--r); font-weight: 500; }

.changes { display: grid; gap: 12px; }
.change { display: grid; gap: 12px; padding: 18px clamp(16px, 2.4vw, 22px); background: var(--bg); border-radius: var(--r); }
.change-top { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.change-n { width: 24px; height: 24px; display: grid; place-items: center; border-radius: 50%; background: var(--ink); color: var(--paper); font-size: 13px; font-weight: 500; }
.change-name { flex: 1; min-width: 0; font-size: 16px; font-weight: 500; color: var(--ink); }
.change-vals { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 12px; font: 400 clamp(32px, 4.4vw, 42px)/1 var(--serif); letter-spacing: -0.01em; }
.change-vals .was { color: var(--muted); text-decoration: line-through; text-decoration-thickness: 1.5px; text-decoration-color: var(--line-strong); }
.change-vals .ic { font-size: 20px; color: var(--muted); align-self: center; }
.change-vals .now { color: var(--accent-deep); }
.change-vals .unit { font: 400 15px/1 var(--sans); color: var(--muted); letter-spacing: 0; }
.change-vals .delta { margin-left: auto; font: 500 14px/1 var(--sans); letter-spacing: 0; color: var(--body); background: var(--paper); border: 1px solid var(--line); padding: 7px 11px; border-radius: 999px; }
.range { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 12px; align-items: center; font-size: 12.5px; color: var(--muted); }
.range-track { position: relative; height: 16px; background: linear-gradient(var(--line-strong), var(--line-strong)) center / 100% 2px no-repeat; }
.range-track i { position: absolute; top: 50%; }
.range-from { left: var(--a); width: 8px; height: 8px; margin: -4px 0 0 -4px; border-radius: 50%; background: var(--bg); border: 2px solid var(--muted); }
.range-to { left: var(--a); width: 14px; height: 14px; margin: -7px 0 0 -7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 3px var(--bg); transition: left 1s var(--ease) 0.5s; }
.range-span { left: min(var(--a), var(--b)); height: 2px; margin-top: -1px; width: 0; background: var(--accent); transition: width 1s var(--ease) 0.5s; }
.range.go .range-to { left: var(--b); }
.range.go .range-span { width: max(calc(var(--b) - var(--a)), calc(var(--a) - var(--b))); }
.range.still .range-to, .range.still .range-span { transition: none; }
.expect { font-size: 15px; color: var(--body); max-width: 64ch; }
.expect strong { font: 500 italic 16px/1 var(--serif); color: var(--ink); margin-right: 4px; }

.ask { margin-top: 0; max-width: none; }
.note + .ask { margin-top: 0; }
.again { border-radius: var(--r-lg); }
.again summary { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 14px; margin-left: -4px; border-radius: 999px; cursor: pointer; list-style: none; font-size: 15px; color: var(--muted); transition: background-color 0.2s, color 0.2s; }
.again summary::-webkit-details-marker { display: none; }
.again summary:hover { background: var(--sunk); color: var(--ink); }
.again summary .ic { transition: transform 0.3s var(--ease); }
.again[open] summary .ic { transform: rotate(180deg); }
.again .ask { margin-top: 8px; animation: rise 0.4s var(--ease); }

.note-working .avatar { animation: breathe 2.4s ease-in-out infinite; }
.note-working .logo path { stroke-dasharray: 0.3 0.7; animation: lap 2.2s linear infinite; }
@keyframes lap { to { stroke-dashoffset: -1; } }
@keyframes breathe { 50% { transform: scale(1.08); } }
.thinking { display: grid; gap: 10px; }
.thinking span { height: 12px; border-radius: 8px; background: linear-gradient(90deg, var(--sunk) 0%, var(--accent-wash) 50%, var(--sunk) 100%); background-size: 200% 100%; animation: skel 1.8s linear infinite; }
.thinking span:nth-child(1) { width: 92%; } .thinking span:nth-child(2) { width: 84%; animation-delay: 0.15s; } .thinking span:nth-child(3) { width: 88%; animation-delay: 0.3s; } .thinking span:nth-child(4) { width: 46%; animation-delay: 0.45s; }

.margin { position: sticky; top: calc(var(--top) + 72px); display: grid; gap: 6px; }
.margin-h { font: 500 italic 20px/1.3 var(--serif); color: var(--ink); }
.finding { display: grid; grid-template-columns: 10px minmax(0, 1fr); gap: 12px; padding: 13px 0; border-bottom: 1px solid var(--line); }
.finding:last-child { border-bottom: 0; }
.sev { width: 8px; height: 8px; margin-top: 8px; border-radius: 50%; background: var(--line-strong); }
.sev-high .sev { background: var(--brake); }
.sev-med .sev { background: var(--warn); }
.sev-ok .sev { background: var(--good); }
.finding-t { font-size: 15px; font-weight: 500; color: var(--ink); line-height: 1.4; }
.finding-d { font-size: 14px; color: var(--muted); margin-top: 2px; }

/* The lap */
.laps { display: flex; gap: 8px; overflow-x: auto; margin: 0 calc(var(--pad) * -1); padding: 2px var(--pad) 6px; scrollbar-width: none; scroll-snap-type: x proximity; overscroll-behavior-x: contain; }
.laps::-webkit-scrollbar { display: none; }
.lap { flex: 1 0 auto; min-width: 118px; display: grid; gap: 0; padding: 9px 14px; text-align: left; background: var(--paper); border: 1px solid var(--line); border-radius: var(--r); scroll-snap-align: start; transition: border-color 0.2s, background-color 0.25s, color 0.25s, transform 0.2s var(--ease); }
.lap:hover { border-color: var(--line-strong); }
.lap:active { transform: scale(0.98); }
.lap-n { font-size: 12.5px; color: var(--muted); }
.lap-t { font-size: 18px; font-weight: 600; line-height: 1.3; letter-spacing: -0.01em; color: var(--ink); }
.lap-d { font-size: 13px; color: var(--muted); }
.lap.best .lap-d { color: var(--accent-deep); font-weight: 500; }
.lap.invalid .lap-t { color: var(--muted); }
.lap[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); }
.lap[aria-pressed="true"] .lap-t { color: var(--paper); }
.lap[aria-pressed="true"] .lap-n, .lap[aria-pressed="true"] .lap-d { color: var(--on-ink-muted); }

.lap-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }
.plate { display: grid; gap: 10px; min-width: 0; padding: clamp(14px, 1.8vw, 20px); background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-lg); }
.card-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; min-height: 36px; }
.plate-t { font: 500 italic 19px/1.3 var(--serif); color: var(--ink); }
.plate-t .muted { font: 400 14px/1 var(--sans); margin-left: 8px; font-variant-numeric: tabular-nums; }
.readout { font-size: 14px; color: var(--body); white-space: pre; }
.seg { display: inline-flex; padding: 3px; background: var(--sunk); border-radius: 999px; }
.seg button { min-height: 34px; padding: 0 14px; border-radius: 999px; font-size: 14px; color: var(--muted); transition: color 0.2s, background-color 0.25s, box-shadow 0.25s; }
.seg button:hover { color: var(--ink); }
.seg button[aria-pressed="true"] { background: var(--paper); color: var(--ink); box-shadow: 0 1px 2px var(--lift); }

.map { position: relative; aspect-ratio: var(--ar, 3 / 1); width: 100%; max-width: 760px; margin: 0 auto; touch-action: pan-y; }
.map svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.map-base { fill: none; stroke: var(--sunk); stroke-width: 16px; vector-effect: non-scaling-stroke; stroke-linejoin: round; stroke-linecap: round; stroke-dasharray: 1; stroke-dashoffset: 1; }
.map.in .map-base { animation: draw 1.8s var(--ease) forwards; }
.map-segs line { stroke-width: 5px; vector-effect: non-scaling-stroke; stroke-linecap: round; transition: stroke 0.4s, stroke-opacity 0.4s; }
.map-segs { opacity: 0; transition: opacity 0.9s 0.9s; }
.map.in .map-segs { opacity: 1; }
.map-pins { position: absolute; inset: 0; pointer-events: none; }
.pin { position: absolute; pointer-events: auto; width: 22px; height: 22px; margin: -11px 0 0 -11px; transform: translate(calc(var(--ox) * 26px), calc(var(--oy) * 26px)); display: grid; place-items: center; font-size: 11px; font-weight: 500; font-variant-numeric: tabular-nums; color: var(--muted); background: var(--paper); border: 1px solid var(--line-strong); border-radius: 50%; transition: color 0.2s, border-color 0.2s, background-color 0.2s, scale 0.25s var(--ease); }
.pin::after { content: ""; position: absolute; inset: -11px; }
.pin-understeer { color: var(--warn-deep); border-color: var(--warn); background: var(--warn-wash); }
.pin-oversteer { color: var(--cold-ink); border-color: var(--cold); background: var(--cold-wash); }
.pin:hover, .pin.on { background: var(--ink); color: var(--paper); border-color: var(--ink); z-index: 2; scale: 1.15; }
.map-dot { position: absolute; width: 16px; height: 16px; margin: -8px 0 0 -8px; background: var(--ink); border: 3px solid var(--paper); border-radius: 50%; box-shadow: 0 2px 6px rgb(70 50 20 / 0.3); pointer-events: none; z-index: 3; }
.map-foot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 24px; align-items: center; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 14px; color: var(--body); }
.legend li { display: inline-flex; align-items: center; gap: 7px; }
.legend i { width: 16px; height: 5px; border-radius: 3px; }

.traces { position: relative; display: grid; cursor: crosshair; touch-action: pan-y; }
.traces.wipe .trace svg { animation: wipe 0.9s var(--ease); }
@keyframes wipe { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }
.bands { position: relative; height: 24px; border-bottom: 1px solid var(--line); }
.band { position: absolute; top: 2px; height: 20px; font-size: 11px; font-variant-numeric: tabular-nums; color: var(--muted); background: var(--sunk); border-radius: 5px; text-align: center; overflow: hidden; transition: color 0.2s, background-color 0.2s; }
.band-understeer { background: var(--warn-wash); color: var(--warn-deep); }
.band-oversteer { background: var(--cold-wash); color: var(--cold-ink); }
.band.on { background: var(--ink); color: var(--paper); }
.trace { position: relative; border-bottom: 1px solid var(--line); padding: 4px 0; }
.trace:last-of-type { border-bottom: 0; }
.trace-head { position: absolute; left: 0; right: 0; top: 5px; display: flex; justify-content: space-between; pointer-events: none; z-index: 1; }
.trace-head .label { font-size: 13px; color: var(--muted); }
.trace-val { font-size: 13px; font-weight: 500; color: var(--ink); white-space: pre; background: var(--paper); padding-left: 8px; }
.trace svg { display: block; width: 100%; overflow: visible; }
.trace[data-ch="speed"] svg { height: 112px; margin-top: 14px; }
.trace[data-ch="pedals"] svg, .trace[data-ch="steer"] svg { height: 56px; margin-top: 22px; }
.trace[data-ch="delta"] svg { height: 44px; margin-top: 22px; }
.trace[data-ch="slip"] svg { height: 36px; margin-top: 22px; }
.trace path, .trace line { vector-effect: non-scaling-stroke; fill: none; }
.t-line { stroke-width: 1.75px; stroke-linejoin: round; stroke-linecap: round; }
.t-speed { stroke: var(--ink); }
.t-ref { stroke: var(--muted); stroke-width: 1.25px; stroke-dasharray: 4 3; opacity: 0.75; }
.t-ref-throttle { stroke: var(--throttle); }
.t-ref-brake { stroke: var(--brake); }
.t-ref-steer { stroke: var(--cold); }
.compare { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.compare select { min-height: 36px; padding: 0 30px 0 14px; border: 1px solid var(--line-strong); border-radius: 999px; background: var(--paper); color: var(--ink); font-size: 14px; font-variant-numeric: tabular-nums; appearance: none; -webkit-appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 17px) 55%, calc(100% - 12px) 55%; background-size: 5px 5px; background-repeat: no-repeat; cursor: pointer; }
.compare select:hover { border-color: var(--muted); }
.trace-key { display: flex; align-items: center; gap: 8px; color: var(--muted); font-variant-numeric: tabular-nums; }
.trace-key[hidden] { display: none; }
.trace-key i { width: 18px; border-top: 2px solid var(--ink); }
.trace-key i.key-dash { border-top: 2px dashed var(--muted); margin-left: 10px; }
.trace-card .card-head .readout { margin-left: auto; }
.t-delta { stroke: var(--accent); }
.t-steer { stroke: var(--cold); }
.t-zero { stroke: var(--line); stroke-width: 1px; }
.trace .t-throttle { fill: color-mix(in srgb, var(--throttle) 16%, transparent); }
.trace .t-brake { fill: color-mix(in srgb, var(--brake) 18%, transparent); }
.trace .t-slip { fill: color-mix(in srgb, var(--warn) 20%, transparent); }
.t-throttle-l { stroke: var(--throttle); }
.t-brake-l { stroke: var(--brake); }
.t-slip-l { stroke: var(--warn); }
.trace-cursor { position: absolute; top: 0; bottom: 0; width: 1.5px; margin-left: -0.75px; background: var(--ink); opacity: 0.55; pointer-events: none; z-index: 2; }
.trace-axis { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--muted); }

/* Tyres and corners */
.split { display: grid; grid-template-columns: minmax(0, 1fr); gap: clamp(40px, 5vw, 64px); align-items: start; }
.tyres { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.tyre { display: grid; gap: 8px; padding: 12px 14px; background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-lg); }
.tyre-name { font-size: 14px; font-weight: 500; color: var(--ink); }
.tread { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 4px; background: var(--tyre); border-radius: 13px; }
.strip { display: grid; align-content: space-between; justify-items: center; height: 62px; padding: 7px 0 6px; background: var(--c); color: #fff; border-radius: 9px; font-size: 15px; font-weight: 500; transform-origin: bottom; text-shadow: 0 1px 1px rgb(0 0 0 / 0.18); }
.rv.in .strip { animation: grow 0.9s var(--ease) backwards; }
.strip:nth-child(2) { animation-delay: 0.07s !important; }
.strip:nth-child(3) { animation-delay: 0.14s !important; }
@keyframes grow { from { transform: scaleY(0.25); opacity: 0; } }
.strip-k { font-size: 11px; font-weight: 400; opacity: 0.9; }
.tyre-psi { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; font-size: 14px; color: var(--muted); }
.tyre-psi > .num { font-size: 20px; font-weight: 600; line-height: 1; letter-spacing: -0.01em; color: var(--ink); }
.tyre-psi .pill { margin-left: auto; align-self: center; }
.tyre-sub { font-size: 13px; color: var(--muted); }

.table-wrap { overflow-x: auto; background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 6px 8px; }
.ctable { width: 100%; font-size: 14px; font-variant-numeric: tabular-nums; }
.ctable th, .ctable td { padding: 6px 10px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
.ctable tbody tr:last-child > * { border-bottom: 0; }
.ctable thead th { font-size: 13px; font-weight: 400; color: var(--muted); }
.ctable tbody th { font-weight: 500; color: var(--ink); }
.ctable tbody td { color: var(--body); }
.ctable tbody tr { transition: background-color 0.15s; }
.ctable tbody tr:hover, .ctable tbody tr.on { background: var(--bg); }
.ctable .warn { color: var(--warn-deep); font-weight: 500; }
.balbar { position: relative; display: inline-block; vertical-align: middle; margin-right: 10px; width: 84px; height: 12px; background: linear-gradient(var(--line-strong), var(--line-strong)) center / 1.5px 100% no-repeat; }
.balbar i { position: absolute; top: 3px; height: 6px; width: var(--w); background: var(--line-strong); border-radius: 3px; }
.balbar.pos i { left: 50%; }
.balbar.neg i { right: 50%; }
.balbar.understeer i { background: var(--warn); }
.balbar.oversteer i { background: var(--cold); }

/* Setup */
.sheet { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; align-items: start; }
.sheet-group { padding: 14px 18px 8px; background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-lg); }
.sheet-h { font-size: 14px; font-weight: 600; color: var(--ink); margin-bottom: 4px; }
.sheet-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 16px; align-items: baseline; padding: 6px 0; border-top: 1px solid var(--line); font-size: 14px; font-variant-numeric: tabular-nums; }
.sheet-row:first-child { border-top: 0; }
.sheet-row dd { display: inline-flex; align-items: baseline; gap: 8px; color: var(--ink); font-weight: 500; }
.sheet-row .unit { min-width: 40px; font-size: 13px; font-weight: 400; color: var(--muted); }
.sheet-row .new:empty { display: none; }
.sheet-row.changed { margin: 0 -10px; padding-inline: 10px; background: var(--accent-wash); border-radius: 9px; border-top-color: transparent; }
.sheet-row.changed + .sheet-row { border-top-color: transparent; }
.sheet-row.changed .cur { color: var(--muted); font-weight: 400; text-decoration: line-through; }
.sheet-row.changed .new { color: var(--accent-deep); }

/* Smaller screens */
@media (max-width: 1020px) {
  .call { grid-template-columns: minmax(0, 1fr); }
  .tyres { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .margin { position: static; }
  .sheet { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dh { grid-template-columns: minmax(0, 1fr); }
  .stats { grid-template-columns: repeat(3, minmax(0, auto)); justify-content: start; }
}
@media (max-width: 700px) {
  :root { --top: 56px; }
  .hide-s { display: none; }
  .top-nav .link span { display: none; }
  .hello { text-align: left; justify-items: start; }
  .how { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .composer-hint { font-size: 13px; }
  .composer-text { font-size: 16px; }
  .stint { grid-template-columns: minmax(0, 1fr) auto; gap: 10px 16px; padding: 16px; }
  .stint-meta { grid-column: 1 / -1; grid-row: 2; display: flex; justify-content: space-between; align-items: center; }
  .stint-go { display: none; }
  .stats { gap: 14px 20px; }
  .ask .composer-bar { flex-wrap: wrap; }
  .ask .btn { width: 100%; }
  .change-vals .delta { margin-left: 0; }
  .sheet { grid-template-columns: minmax(0, 1fr); }
  .tyre { padding: 12px; }
  .strip { height: 60px; font-size: 14px; }
  .compare span { display: none; }
  .tyre-psi .pill { margin-left: 0; }
  .pin { width: 18px; height: 18px; margin: -9px 0 0 -9px; font-size: 10px; transform: translate(calc(var(--ox) * 15px), calc(var(--oy) * 15px)); }
  .map-base { stroke-width: 10px; }
  .map-segs line { stroke-width: 3.5px; }
  .band { font-size: 0; }
  .balbar { width: 48px; }
  .ctable th, .ctable td { padding: 8px 6px; }
  .table-wrap { padding: 4px; }
  .readout { display: none; }
  .trace[data-ch="speed"] svg { height: 100px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; transition-delay: 0s !important; scroll-behavior: auto !important; }
  .rv { opacity: 1; transform: none; }
  .logo.draw path, .map-base { stroke-dashoffset: 0; }
  .note-working .logo path { stroke-dasharray: none; }
}

[data-theme="dark"] .seg button[aria-pressed="true"] { background: var(--line-strong); }

/* Desktop: map beside the traces, so one cursor reads both without scrolling */
@media (min-width: 1021px) {
  .lap-grid { grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); }
  .lap-grid { align-items: start; }
  .lap-grid .map-card { position: sticky; top: 124px; }
}
