/* Formulation Lab design system: tokens, shell, and the shared parts every
   screen is built from. Screen-only rules live in public/screens/<screen>.css.
   See DESIGN.md for the reasoning. */

@font-face {
  font-family: 'Instrument Sans';
  src: url(/fonts/instrument-sans-latin.woff2) format('woff2');
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Instrument Sans';
  src: url(/fonts/instrument-sans-latin-italic.woff2) format('woff2');
  font-weight: 400 700;
  font-style: italic;
  font-display: swap;
}

/* ---------- Tokens ---------- */

:root {
  color-scheme: light;
  --canvas: #f2f3f1;
  --surface: #ffffff;
  --ink: #1b1f1c;
  --muted: #5c6460;
  --faint: #8a928d;
  --line: #e2e5e1;
  --line-strong: #cfd4cf;
  --hover: #f5f6f4;
  --pill: #eceeeb;
  --well: #f7f8f6;
  --bay: #1d6b45;
  --bay-dark: #165636;
  --bay-tint: #e7f2ec;
  --bay-line: #bcdcc9;
  --chili: #b3261e;
  --chili-tint: #fcefed;
  --chili-line: #f0c8c3;
  --amber: #855600;
  --amber-tint: #fcf4e0;
  --amber-line: #ecd8a3;
  --spice-1: #f1c14e;
  --spice-2: #e09a3c;
  --spice-3: #c8752f;
  --spice-4: #a85528;
  --spice-5: #7e3e22;
  --spice-6: #55301f;
  --radius-control: 8px;
  --radius-card: 12px;
  --radius-surface: 16px;
  --shadow-card: 0 1px 2px rgba(27, 31, 28, 0.04);
  --shadow-float: 0 1px 2px rgba(27, 31, 28, 0.05), 0 8px 28px rgba(27, 31, 28, 0.09);
  --shadow-dock: 0 2px 4px rgba(27, 31, 28, 0.06), 0 14px 40px rgba(27, 31, 28, 0.16);
  --sidebar: 252px;
  --rail: 68px;
  --font: 'Instrument Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
}

/* ---------- Base ---------- */

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html { background: var(--canvas); }

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar) minmax(0, 1fr);
  background: var(--canvas);
  color: var(--ink);
  font: 400 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body.nav-collapsed { grid-template-columns: var(--rail) minmax(0, 1fr); }

h1, h2, h3, h4, p, ul, ol, dl, dd, figure { margin: 0; }

a { color: var(--bay); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--bay-dark); }

:focus-visible { outline: 2px solid var(--bay); outline-offset: 2px; border-radius: 4px; }

.vh {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.skip {
  position: absolute;
  left: 12px;
  top: -3rem;
  z-index: 60;
  background: var(--ink);
  color: #fff;
  padding: 8px 12px;
  border-radius: var(--radius-control);
}

.skip:focus { top: 12px; }

/* ---------- Icons: CSS masks over SVG files on this origin ---------- */

[data-icon]::before {
  content: '';
  display: inline-block;
  flex: none;
  width: 18px;
  height: 18px;
  background-color: currentColor;
  -webkit-mask: var(--icon) center / contain no-repeat;
  mask: var(--icon) center / contain no-repeat;
}

.btn:not(.has-icon)::before,
button:not(.has-icon):not(.icon-btn)::before { content: none; }

summary::before {
  content: '';
  display: inline-block;
  flex: none;
  width: 14px;
  height: 14px;
  background-color: var(--muted);
  -webkit-mask: url(/icons/chevron.svg) center / contain no-repeat;
  mask: url(/icons/chevron.svg) center / contain no-repeat;
  transition: transform 160ms var(--ease);
}

[data-icon='import'] { --icon: url(/icons/import.svg); }
[data-icon='catalog'] { --icon: url(/icons/catalog.svg); }
[data-icon='target'] { --icon: url(/icons/target.svg); }
[data-icon='drafts'] { --icon: url(/icons/drafts.svg); }
[data-icon='sheet'] { --icon: url(/icons/sheet.svg); }
[data-icon='scorecard'] { --icon: url(/icons/scorecard.svg); }
[data-icon='compare'] { --icon: url(/icons/compare.svg); }
[data-icon='citations'] { --icon: url(/icons/citations.svg); }
[data-icon='expert'] { --icon: url(/icons/notes.svg); }
[data-icon='notes'] { --icon: url(/icons/notes.svg); }
[data-icon='backup'] { --icon: url(/icons/backup.svg); }
[data-icon='menu'] { --icon: url(/icons/menu.svg); }
[data-icon='close'] { --icon: url(/icons/close.svg); }
[data-icon='collapse'] { --icon: url(/icons/collapse.svg); }
[data-icon='upload'] { --icon: url(/icons/upload.svg); }
[data-icon='download'] { --icon: url(/icons/download.svg); }
[data-icon='check'] { --icon: url(/icons/check.svg); }
[data-icon='chevron'] { --icon: url(/icons/chevron.svg); }
[data-icon='alert'] { --icon: url(/icons/alert.svg); }
[data-icon='info'] { --icon: url(/icons/info.svg); }
[data-icon='flask'] { --icon: url(/icons/flask.svg); }
[data-icon='plus'] { --icon: url(/icons/plus.svg); }
[data-icon='search'] { --icon: url(/icons/search.svg); }
[data-icon='trash'] { --icon: url(/icons/trash.svg); }
[data-icon='edit'] { --icon: url(/icons/edit.svg); }

/* ---------- Shell: sidebar ---------- */

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 16px 14px 14px;
  background: var(--surface);
  border-right: 1px solid var(--line);
  overflow-y: auto;
  overflow-x: hidden;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 2px 12px 4px;
}

.wordmark {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1 1 auto;
  min-width: 0;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.015em;
  white-space: nowrap;
}

.mark {
  flex: none;
  width: 30px;
  height: 30px;
  background: url(/favicon.svg) center / contain no-repeat;
}

.icon-btn {
  flex: none;
  width: 36px;
  height: 36px;
  min-height: 0;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-control);
  cursor: pointer;
}

.icon-btn:hover { background: var(--hover); color: var(--ink); border-color: transparent; }
.icon-btn[aria-pressed='true'] { color: var(--ink); }

#nav-close { display: none; }

nav#nav { flex: 1 1 auto; }

.nav-group { padding: 6px 0 10px; }
.nav-group + .nav-group { border-top: 1px solid var(--line); padding-top: 10px; }

.nav-group-title {
  padding: 2px 10px 6px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--faint);
}

nav ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 40px;
  padding: 8px 10px;
  border-radius: var(--radius-control);
  color: var(--ink);
  font-size: 15px;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 140ms var(--ease);
}

.nav-link::before { color: var(--muted); width: 19px; height: 19px; }
.nav-link:hover { background: var(--hover); color: var(--ink); }
.nav-link[aria-current='page'] { background: var(--pill); font-weight: 600; }
.nav-link[aria-current='page']::before { color: var(--ink); }

.sidebar-foot {
  border-top: 1px solid var(--line);
  padding-top: 12px;
  display: grid;
  gap: 10px;
}

.tag { font-size: 12.5px; color: var(--muted); line-height: 1.45; padding: 0 6px; }

.who-row { display: flex; align-items: center; gap: 10px; padding: 4px 4px 2px 6px; min-width: 0; }

.avatar {
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--ink);
  color: #fff;
  font-weight: 600;
  font-size: 13px;
}

.who-text { flex: 1 1 auto; min-width: 0; display: grid; line-height: 1.25; }
.who-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14.5px; font-weight: 600; }
.who-role { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#who-change { flex: none; padding: 0 8px; }

.who-form { display: grid; gap: 8px; padding: 12px; border: 1px solid var(--bay-line); border-radius: var(--radius-card); background: var(--bay-tint); }
.who-form .field { gap: 4px; }
.who-form .field > span:first-child { font-size: 13px; }
.who-form input { max-width: none; background: var(--surface); }

/* Collapsed rail */

.nav-collapsed .sidebar { padding-left: 10px; padding-right: 10px; }
.nav-collapsed .brand { flex-direction: column; gap: 8px; padding: 0 0 8px; }
.nav-collapsed .wordmark { justify-content: center; }
.nav-collapsed .wordmark-text,
.nav-collapsed .nav-group-title,
.nav-collapsed .tag,
.nav-collapsed .who-text,
.nav-collapsed #who-change { display: none; }
.nav-collapsed .nav-link { font-size: 0; justify-content: center; padding: 10px; gap: 0; }
.nav-collapsed .nav-link::before { width: 20px; height: 20px; }
.nav-collapsed .who-row { justify-content: center; padding: 4px 0; }
.nav-collapsed .who-form { display: none; }

/* ---------- Shell: phone app bar and drawer ---------- */

.appbar {
  display: none;
  position: sticky;
  top: 0;
  z-index: 20;
  height: 56px;
  align-items: center;
  gap: 6px;
  padding: 0 10px;
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--line);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  backdrop-filter: saturate(1.4) blur(10px);
}

.appbar .wordmark { justify-content: flex-start; }

.avatar-btn {
  flex: none;
  width: 36px;
  height: 36px;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--ink);
  color: #fff;
  font: 600 13px var(--font);
  cursor: pointer;
}

.avatar-btn:hover { background: #000; color: #fff; }

.backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 25;
  background: rgba(27, 31, 28, 0.36);
}

/* ---------- Shell: work surface ---------- */

.surface {
  min-width: 0;
  padding: 12px 12px 12px 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-content: start;
  gap: 10px;
}

main {
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-surface);
  min-height: calc(100vh - 24px);
  padding: 32px 36px 64px;
}

main:focus { outline: none; }

body.has-dock main { padding-bottom: 128px; }

#alert,
#banner {
  border-radius: var(--radius-card);
  padding: 10px 14px;
  font-size: 14px;
  font-weight: 500;
}

#alert { background: var(--chili-tint); border: 1px solid var(--chili-line); color: var(--chili); }
#alert:empty { display: none; }

#banner { display: none; align-items: center; gap: 10px 14px; flex-wrap: wrap; background: var(--amber-tint); border: 1px solid var(--amber-line); color: var(--amber); }
#banner.is-on { display: flex; }
#banner::before { content: ''; width: 18px; height: 18px; flex: none; background: currentColor; -webkit-mask: url(/icons/flask.svg) center / contain no-repeat; mask: url(/icons/flask.svg) center / contain no-repeat; }
#banner p { flex: 1 1 18rem; }
#banner button { background: var(--surface); border-color: var(--amber-line); }

/* ---------- Shell: the bench dock ---------- */

.dock {
  position: sticky;
  bottom: 18px;
  z-index: 15;
  justify-self: center;
  margin-top: -96px;
  display: none;
  align-items: center;
  gap: 4px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow-dock);
  max-width: calc(100% - 32px);
}

body.has-dock .dock { display: flex; }

.dock-step {
  padding: 0 12px 0 10px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.dock-item {
  display: grid;
  justify-items: center;
  gap: 3px;
  min-width: 84px;
  padding: 8px 12px 7px;
  border-radius: 11px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 140ms var(--ease);
}

.dock-item::before { width: 20px; height: 20px; }
.dock-item:hover { background: var(--hover); color: var(--ink); }
.dock-item[aria-current='page'] { background: var(--ink); color: #fff; }
.dock-item[aria-current='page']:hover { background: #000; color: #fff; }

.dock-sep { width: 1px; align-self: stretch; margin: 8px 6px; background: var(--line); }

.dock .key-hint { padding: 0 10px 0 4px; }

/* ---------- Screen head ---------- */

.screen { display: grid; gap: 24px; align-content: start; }

.screen-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px 24px;
  flex-wrap: wrap;
}

.screen-head-text { min-width: 0; flex: 1 1 26rem; display: grid; gap: 6px; }
.screen-head-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

#screen-title { font-size: 26px; line-height: 1.15; font-weight: 600; letter-spacing: -0.02em; }

.lead { color: var(--muted); max-width: 64ch; font-size: 15px; }

h2 { font-size: 18px; line-height: 1.3; font-weight: 600; letter-spacing: -0.01em; }
h3 { font-size: 14px; line-height: 1.4; font-weight: 600; }

.section { display: grid; gap: 12px; }
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }

.meta { font-size: 12.5px; line-height: 1.45; color: var(--muted); }
.num { font-variant-numeric: tabular-nums; text-align: right; }
.muted { color: var(--muted); }
.prose { max-width: 68ch; }
.pre { white-space: pre-wrap; }
.quote { font-style: italic; }

.actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.stack { display: grid; gap: 16px; }
.plain-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.bullets { padding-left: 20px; display: grid; gap: 4px; }

/* ---------- Buttons ---------- */

button, .btn {
  font: 500 14px/1.2 var(--font);
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-control);
  padding: 0 14px;
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 1px 0 rgba(27, 31, 28, 0.03);
  transition: background-color 140ms var(--ease), border-color 140ms var(--ease), transform 140ms var(--ease), box-shadow 140ms var(--ease);
}

button:hover, .btn:hover { background: var(--hover); border-color: #b5bcb6; color: var(--ink); }
button:active, .btn:active { transform: translateY(1px); }
button:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
button::before, .btn::before { width: 17px; height: 17px; }

.btn-primary { background: var(--bay); border-color: var(--bay); color: #fff; box-shadow: 0 1px 2px rgba(22, 86, 54, 0.25); }
.btn-primary:hover { background: var(--bay-dark); border-color: var(--bay-dark); color: #fff; }

.btn-quiet { background: transparent; border-color: transparent; color: var(--bay); padding: 0 10px; box-shadow: none; }
.btn-quiet:hover { background: var(--bay-tint); border-color: transparent; color: var(--bay-dark); }

.btn-danger { color: var(--chili); }
.btn-danger:hover { background: var(--chili-tint); border-color: var(--chili-line); color: var(--chili); }

.btn-small { min-height: 32px; padding: 0 11px; font-size: 13px; border-radius: 7px; }

/* ---------- Forms ---------- */

label { display: block; font-size: 14px; font-weight: 500; }

.field { display: grid; gap: 6px; align-content: start; }
.field > span:first-child { font-size: 13.5px; font-weight: 500; }
.field .hint { font-size: 12.5px; font-weight: 400; color: var(--muted); }
.field .error, .field-error { font-size: 13px; font-weight: 500; color: var(--chili); }
.field-error:empty { display: none; }

.check { display: flex; align-items: center; gap: 10px; font-weight: 400; min-height: 28px; cursor: pointer; }
.check > span { display: flex; align-items: center; gap: 8px; }

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: 16px 20px; }
.form-row { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; }

input, select, textarea {
  font: 400 15px/1.3 var(--font);
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-control);
  padding: 0 12px;
  min-height: 40px;
  width: 100%;
  max-width: 32rem;
  transition: border-color 140ms var(--ease), box-shadow 140ms var(--ease);
}

select {
  appearance: none;
  padding-right: 34px;
  background: var(--surface) url(/icons/chevron-down.svg) right 10px center / 14px no-repeat;
  cursor: pointer;
}

input:hover, select:hover, textarea:hover { border-color: #b5bcb6; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: none; border-color: var(--bay); box-shadow: 0 0 0 3px var(--bay-tint); }
input[aria-invalid='true'], textarea[aria-invalid='true'], select[aria-invalid='true'] { border-color: var(--chili); box-shadow: 0 0 0 3px var(--chili-tint); }
input::placeholder, textarea::placeholder { color: #9aa29d; }

textarea { padding: 9px 12px; min-height: 92px; resize: vertical; line-height: 1.45; }

input[type='checkbox'], input[type='radio'] {
  width: 18px;
  height: 18px;
  min-height: 0;
  margin: 0;
  padding: 0;
  accent-color: var(--bay);
  flex: none;
  cursor: pointer;
}

input[type='file'] { padding: 7px; font-size: 14px; }

input.short, .short input { max-width: 10rem; }

fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
legend { padding: 0; font-size: 14px; font-weight: 600; margin-bottom: 8px; }

/* ---------- Segmented control ---------- */

.seg {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  background: var(--pill);
  border-radius: 10px;
}

.seg-btn {
  min-height: 30px;
  padding: 0 12px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  box-shadow: none;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}

.seg-btn:hover { background: rgba(255, 255, 255, 0.6); border: 0; color: var(--ink); }
.seg-btn.is-on, .seg-btn[aria-pressed='true'] { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px rgba(27, 31, 28, 0.12); }

/* Radios dressed as a segmented control, for forms */
.seg label { position: relative; margin: 0; }
.seg label > span { display: flex; align-items: center; gap: 6px; padding: 0 12px; min-height: 30px; border-radius: 7px; font-size: 13px; color: var(--muted); cursor: pointer; }
.seg label input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.seg label input:checked + span { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px rgba(27, 31, 28, 0.12); }
.seg label input:focus-visible + span { box-shadow: inset 0 0 0 2px var(--bay); }

/* ---------- Tables ---------- */

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

caption { text-align: left; font-size: 14px; font-weight: 600; padding: 0 0 8px; }

th {
  text-align: left;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
  background: var(--surface);
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

thead th { position: sticky; top: 0; z-index: 2; }

td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
tbody tr { transition: background-color 120ms var(--ease); }
tbody tr:hover > td, tbody tr:hover > th { background: var(--hover); }
th.num, td.num { text-align: right; }
td .meta { display: block; }
tfoot th, tfoot td { border-bottom: 0; border-top: 1px solid var(--line-strong); font-weight: 600; color: var(--ink); background: transparent; }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius-card); }
.table-wrap table th:first-child, .table-wrap table td:first-child { padding-left: 16px; }
.table-wrap table th:last-child, .table-wrap table td:last-child { padding-right: 16px; }
.table-wrap tbody tr:last-child td { border-bottom: 0; }

tr.row-out td { color: var(--muted); }
del { text-decoration-thickness: 1.5px; text-decoration-color: var(--faint); }

th[aria-sort] button { all: unset; cursor: pointer; display: inline-flex; gap: 4px; align-items: center; }
th[aria-sort='ascending'] button::after { content: '↑'; }
th[aria-sort='descending'] button::after { content: '↓'; }

/* ---------- Chips, notices, status ---------- */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.2;
  padding: 4px 9px;
  border-radius: 999px;
  background: var(--pill);
  color: var(--ink);
  white-space: nowrap;
}

.chip-broken { background: var(--chili-tint); color: var(--chili); }
.chip-warn { background: var(--amber-tint); color: var(--amber); }
.chip-ok { background: var(--bay-tint); color: var(--bay); }
.chip-info { background: var(--well); color: var(--muted); box-shadow: inset 0 0 0 1px var(--line); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }

mark { background: var(--bay-tint); color: var(--bay); padding: 1px 6px; border-radius: 4px; font-weight: 600; }

.notice {
  display: grid;
  gap: 6px;
  padding: 12px 14px 12px 42px;
  border-radius: var(--radius-card);
  border: 1px solid var(--line);
  background: var(--well);
  font-size: 14px;
  position: relative;
}

.notice::before {
  content: '';
  position: absolute;
  left: 14px;
  top: 13px;
  width: 18px;
  height: 18px;
  background: currentColor;
  -webkit-mask: url(/icons/info.svg) center / contain no-repeat;
  mask: url(/icons/info.svg) center / contain no-repeat;
}

.notice-title { font-weight: 600; }
.notice-error { background: var(--chili-tint); border-color: var(--chili-line); color: var(--chili); }
.notice-error::before { -webkit-mask-image: url(/icons/alert.svg); mask-image: url(/icons/alert.svg); }
.notice-warn { background: var(--amber-tint); border-color: var(--amber-line); color: var(--amber); }
.notice-warn::before { -webkit-mask-image: url(/icons/alert.svg); mask-image: url(/icons/alert.svg); }
.notice-ok { background: var(--bay-tint); border-color: var(--bay-line); color: var(--bay); }
.notice-ok::before { -webkit-mask-image: url(/icons/check.svg); mask-image: url(/icons/check.svg); }
.notice-info { color: var(--ink); }
.notice-info::before { color: var(--muted); }
.notice p:not(.notice-title) { color: var(--ink); }
.notice-links { display: flex; flex-wrap: wrap; gap: 6px 16px; }

.status {
  border-radius: var(--radius-card);
  border: 1px solid var(--line);
  background: var(--well);
  padding: 10px 14px;
  font-size: 14px;
  font-weight: 500;
  max-width: 68ch;
}

.status:empty { display: none; }
.status-error, .status[data-state='error'] { background: var(--chili-tint); border-color: var(--chili-line); color: var(--chili); }
.status-ok, .status[data-state='success'], .status[data-state='recorded'] { background: var(--bay-tint); border-color: var(--bay-line); color: var(--bay); }
.status-warn { background: var(--amber-tint); border-color: var(--amber-line); color: var(--amber); }

.flag-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 5px; font-size: 13.5px; }
.flag-list li { display: flex; gap: 8px; align-items: flex-start; color: var(--ink); }
.flag-list li::before { content: ''; flex: none; width: 6px; height: 6px; border-radius: 50%; margin-top: 7px; background: currentColor; opacity: 0.55; }

/* ---------- Empty and first-run states ---------- */

.empty {
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-card);
  background: var(--well);
  padding: 40px 32px;
  display: grid;
  justify-items: start;
  gap: 10px;
  max-width: 46rem;
}

.empty-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--ink);
  margin-bottom: 6px;
}

.empty-icon::before { width: 22px; height: 22px; }
.empty h2 { font-size: 18px; }
.empty p { color: var(--muted); max-width: 56ch; }
.empty .actions { margin-top: 8px; }

/* ---------- Floating context cards ---------- */

.float-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-float);
  padding: 16px 18px;
  display: grid;
  gap: 10px;
  align-content: start;
  min-width: 0;
}

.card-label { font-size: 13px; color: var(--muted); }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: 20px;
  display: grid;
  gap: 14px;
  align-content: start;
  min-width: 0;
}

/* ---------- Figures ---------- */

.stat { display: grid; gap: 2px; }
.stat-value { font-size: 28px; line-height: 1.1; font-weight: 600; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat-value .unit { font-size: 14px; font-weight: 500; color: var(--muted); margin-left: 3px; letter-spacing: 0; }
.stat-label { font-size: 13px; color: var(--muted); }
.stat-ok .stat-value { color: var(--bay); }
.stat-warn .stat-value { color: var(--amber); }
.stat-broken .stat-value { color: var(--chili); }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); gap: 12px; }
.stats .stat { padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--radius-card); background: var(--surface); }

.meter { height: 6px; border-radius: 99px; background: var(--pill); overflow: hidden; }
.meter-fill { display: block; height: 100%; width: 0; border-radius: 99px; background: var(--bay); }
.meter.is-over .meter-fill { background: var(--chili); }

/* ---------- Key hints ---------- */

.key-hint { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; color: var(--muted); white-space: nowrap; }
.key-hint span { margin-left: 4px; }

kbd {
  display: inline-grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  font: 600 12px/1 var(--font);
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  border-radius: 5px;
}

/* ---------- Disclosure ---------- */

details { border: 1px solid var(--line); border-radius: var(--radius-card); background: var(--surface); }
summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 8px; padding: 10px 14px; font-size: 14px; font-weight: 500; min-height: 40px; border-radius: var(--radius-card); }
summary:hover { background: var(--hover); }
summary::-webkit-details-marker { display: none; }
details[open] > summary::before { transform: rotate(90deg); }
details > :not(summary) { padding: 0 14px 14px; }

/* ---------- The blend strip: every version drawn to its grams ---------- */

.strip {
  display: flex;
  gap: 2px;
  width: 100%;
  height: 16px;
  border-radius: 6px;
  overflow: hidden;
}

.strip-small { height: 8px; gap: 1px; border-radius: 4px; }
.strip-seg { flex: 1 1 0; min-width: 2px; background: var(--line); }
.swatch { display: inline-block; flex: none; width: 10px; height: 10px; border-radius: 3px; background: var(--line); }
.swatch-out { background: transparent; box-shadow: inset 0 0 0 1.5px var(--line-strong); }
.seg-1 { background: var(--spice-1); }
.seg-2 { background: var(--spice-2); }
.seg-3 { background: var(--spice-3); }
.seg-4 { background: var(--spice-4); }
.seg-5 { background: var(--spice-5); }
.seg-6 { background: var(--spice-6); }
.seg-new { background: var(--bay); }
.seg-gap { background: repeating-linear-gradient(135deg, var(--pill) 0 4px, var(--surface) 4px 8px); }


/* ---------- Phone ---------- */

@media (max-width: 759px) {
  body { grid-template-columns: minmax(0, 1fr); font-size: 16px; }
  body.nav-collapsed { grid-template-columns: minmax(0, 1fr); }

  .appbar { display: flex; }

  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: min(304px, 86vw);
    height: 100vh;
    height: 100dvh;
    z-index: 30;
    transform: translateX(-100%);
    transition: transform 220ms var(--ease);
    box-shadow: none;
  }

  body.nav-open .sidebar { transform: none; box-shadow: var(--shadow-dock); }
  body.nav-open .backdrop { display: block; }
  body.nav-open { overflow: hidden; }

  #nav-collapse { display: none; }
  #nav-close { display: inline-flex; }
  .nav-collapsed .wordmark-text, .nav-collapsed .nav-group-title, .nav-collapsed .tag, .nav-collapsed .who-text, .nav-collapsed #who-change, .nav-collapsed .who-form { display: revert; }
  .nav-collapsed .nav-link { font-size: 15px; justify-content: flex-start; padding: 8px 10px; gap: 12px; }

  .surface { padding: 8px; }
  main { padding: 22px 16px 48px; border-radius: var(--radius-card); min-height: calc(100vh - 72px); }
  body.has-dock main { padding-bottom: 112px; }

  button, .btn, input, select, .nav-link, summary, .btn-small, .seg-btn, .seg label > span { min-height: 44px; }
  .check { min-height: 44px; }
  input[type='checkbox'], input[type='radio'] { min-height: 0; width: 22px; height: 22px; }
  .icon-btn, .avatar-btn { width: 44px; height: 44px; }
  input, select, textarea { max-width: none; font-size: 16px; }

  thead th { top: 56px; }

  #screen-title { font-size: 24px; }
  .screen { gap: 20px; }
  .empty { padding: 26px 20px; }

  .dock {
    position: fixed;
    left: 8px;
    right: 8px;
    bottom: 8px;
    justify-self: stretch;
    margin: 0;
    max-width: none;
    justify-content: space-between;
    padding: 5px;
  }

  .dock-step, .dock .key-hint, .dock-sep { display: none; }
  .dock-item { min-width: 0; flex: 1 1 0; padding: 7px 4px 6px; font-size: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}
