/* =====================================================================
   SYMCA TXC Toolkit — design system
   Hand-rolled, no build step. Sectioned: tokens -> reset -> base elements
   -> layout shell -> components -> page-specific -> utilities -> responsive.
   Every colour in the app should come from a token below — no new hex
   literals in templates.
   ===================================================================== */

/* --- tokens ----------------------------------------------------------- */

:root {
  /* surface + line */
  --color-canvas:        #f4f5f7;
  --color-surface:       #ffffff;
  --color-surface-2:     #fafbfc;
  --color-surface-hover: #f2f4f7;
  --color-border:        #e4e7ec;
  --color-border-strong: #d0d5dd;

  /* text */
  --color-text:          #101828;
  --color-text-muted:    #667085;
  --color-text-subtle:   #98a2b3;

  /* accent */
  --color-accent:        #2563eb;
  --color-accent-hover:  #1d4ed8;
  --color-accent-weak:   #eff4ff;
  --color-accent-text:   #ffffff;

  /* semantic (flash categories: success / warning / error) */
  --color-success: #067647; --color-success-bg: #ecfdf3; --color-success-border: #abefc6;
  --color-warning: #b54708; --color-warning-bg: #fffaeb; --color-warning-border: #fedf89;
  --color-danger:  #b42318; --color-danger-bg:  #fef3f2; --color-danger-border:  #fecdca;

  /* domain */
  --color-timing:      #f59e0b;
  --color-stop:        #2563eb;
  --color-stop-nearby: #9ca3af;

  /* categorical, for service-version chips on the calendar */
  --cat-1: #93c5fd; --cat-2: #fcd34d; --cat-3: #86efac; --cat-4: #f9a8d4;
  --cat-5: #c4b5fd; --cat-6: #fdba74; --cat-7: #67e8f9; --cat-8: #d9f99d;

  /* type — 14px base for admin density */
  --font-sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --text-xs: 0.75rem; --text-sm: 0.8125rem; --text-md: 0.875rem;
  --text-lg: 1rem; --text-xl: 1.25rem; --text-2xl: 1.5rem;

  /* space — 4px scale */
  --sp-1: .25rem; --sp-2: .5rem;  --sp-3: .75rem; --sp-4: 1rem;
  --sp-5: 1.25rem; --sp-6: 1.5rem; --sp-8: 2rem;  --sp-10: 2.5rem;

  --radius-sm: 4px; --radius: 6px; --radius-lg: 10px;
  --shadow-sm: 0 1px 2px rgba(16,24,40,.05);
  --shadow-md: 0 4px 8px -2px rgba(16,24,40,.10);
  --focus-ring: 0 0 0 3px rgba(37,99,235,.35);

  --sidebar-w: 248px;
  --header-h: 60px;
}

/* --- reset -------------------------------------------------------------- */

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--text-md);
  line-height: 1.5;
  color: var(--color-text);
  background: var(--color-canvas);
  -webkit-font-smoothing: antialiased;
}
img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--color-accent); text-decoration: none; }
a:hover { text-decoration: underline; }
ul, ol { margin: 0; padding: 0; list-style: none; }
p { margin: 0 0 var(--sp-3); }

/* --- base elements -------------------------------------------------- */

h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 var(--sp-3); font-weight: 600; }
h1 { font-size: var(--text-2xl); }
h2 { font-size: var(--text-xl); margin-top: var(--sp-8); }
h3 { font-size: var(--text-lg); margin-top: var(--sp-6); }
h4 { font-size: var(--text-md); margin-top: var(--sp-5); }

code, .code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 0.1em 0.4em;
  color: var(--color-text);
}

.muted { color: var(--color-text-muted); font-size: var(--text-sm); }

.icon { width: 20px; height: 20px; flex-shrink: 0; }

:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
  border-radius: var(--radius-sm);
}

form.inline { display: inline; }

/* =====================================================================
   layout shell
   ===================================================================== */

.app { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  align-self: flex-start;
  height: 100vh;
  overflow-y: auto;
}

.sidebar__disclosure { display: contents; }
.sidebar__disclosure > summary { list-style: none; cursor: pointer; }
.sidebar__disclosure > summary::-webkit-details-marker { display: none; }
.sidebar__disclosure > summary::marker { content: ""; }

.sidebar__brand {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-4) var(--sp-5);
  font-weight: 700;
  font-size: var(--text-md);
  color: var(--color-text);
  border-bottom: 1px solid var(--color-border);
}
.sidebar__brand .icon { color: var(--color-accent); }

.sidebar__nav { padding: var(--sp-3); flex: 1; }
.sidebar__group { margin-bottom: var(--sp-4); }
.sidebar__group-label {
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--color-text-subtle);
  padding: var(--sp-2) var(--sp-3);
}
.sidebar__link {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--radius);
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  font-weight: 500;
}
.sidebar__link:hover { background: var(--color-surface-hover); color: var(--color-text); text-decoration: none; }
.sidebar__link .icon { flex-shrink: 0; width: 18px; height: 18px; color: var(--color-text-subtle); }
.sidebar__link--active { background: var(--color-accent-weak); color: var(--color-accent-hover); }
.sidebar__link--active .icon { color: var(--color-accent); }

.sidebar__footer {
  padding: var(--sp-3);
  border-top: 1px solid var(--color-border);
}

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.page-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  padding: var(--sp-4) var(--sp-8);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sp-4);
  flex-wrap: wrap;
}
.page-header__text { min-width: 0; }
.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-1);
  font-size: var(--text-xs);
  color: var(--color-text-subtle);
  margin-bottom: var(--sp-1);
}
.breadcrumb a { color: var(--color-text-muted); }
.breadcrumb__sep { color: var(--color-border-strong); }
.page-title { margin: 0; font-size: var(--text-xl); display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }
.page-subtitle { margin: var(--sp-1) 0 0; color: var(--color-text-muted); font-size: var(--text-sm); }
.page-actions { display: flex; gap: var(--sp-2); flex-wrap: wrap; flex-shrink: 0; }

.page-body { padding: var(--sp-6) var(--sp-8) var(--sp-10); flex: 1; min-width: 0; }
.page-body > h2:first-child, .page-body > .flash-region + h2 { margin-top: 0; }

.flash-region { display: flex; flex-direction: column; gap: var(--sp-2); margin-bottom: var(--sp-4); }
.flash-region:empty { display: none; margin: 0; }

.app-footer { padding: var(--sp-4) var(--sp-8); }

/* =====================================================================
   components
   ===================================================================== */

/* card */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  margin-bottom: var(--sp-6);
}
.card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--color-border);
}
.card__title { margin: 0; font-size: var(--text-md); font-weight: 600; }
.card__body { padding: var(--sp-5); }
.card__footer { padding: var(--sp-4) var(--sp-5); border-top: 1px solid var(--color-border); background: var(--color-surface-2); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
.card--flush .card__body { padding: 0; }
.card--danger { border-color: var(--color-danger-border); }
.card--danger .card__header { background: var(--color-danger-bg); border-color: var(--color-danger-border); }
.card--danger .card__title { color: var(--color-danger); }

/* table */
.table-scroll { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.table th, .table td { text-align: left; padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--color-border); vertical-align: middle; }
.table th {
  background: var(--color-surface-2);
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .03em;
  color: var(--color-text-muted);
  position: sticky;
  top: 0;
}
.table tbody tr:hover { background: var(--color-surface-hover); }
.table tbody tr:last-child td { border-bottom: none; }
.table--dense th, .table--dense td { padding: var(--sp-2) var(--sp-3); }
.table__num { font-variant-numeric: tabular-nums; text-align: right; }
.table__actions { display: flex; gap: var(--sp-2); align-items: center; justify-content: flex-end; }
.card--flush .table { margin: 0; }
.card--flush .table th:first-child, .card--flush .table td:first-child { padding-left: var(--sp-5); }
.card--flush .table th:last-child, .card--flush .table td:last-child { padding-right: var(--sp-5); }

/* legacy bare <table> outside .table (kept only where not yet migrated) */
table { border-collapse: collapse; width: 100%; margin: var(--sp-4) 0; font-size: var(--text-sm); }
th, td { text-align: left; padding: var(--sp-2) var(--sp-3); border-bottom: 1px solid var(--color-border); }
th { background: var(--color-surface-2); }

/* button */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  font-size: var(--text-sm);
  font-weight: 600;
  padding: var(--sp-2) var(--sp-4);
  border-radius: var(--radius);
  border: 1px solid var(--color-border-strong);
  background: var(--color-surface);
  color: var(--color-text);
  cursor: pointer;
  line-height: 1.2;
  white-space: nowrap;
}
.btn:hover { background: var(--color-surface-hover); text-decoration: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn--primary { background: var(--color-accent); border-color: var(--color-accent); color: var(--color-accent-text); }
.btn--primary:hover { background: var(--color-accent-hover); border-color: var(--color-accent-hover); }
.btn--secondary { background: var(--color-surface); border-color: var(--color-border-strong); color: var(--color-text); }
.btn--ghost { background: transparent; border-color: transparent; color: var(--color-text-muted); }
.btn--ghost:hover { background: var(--color-surface-hover); color: var(--color-text); }
.btn--danger { background: var(--color-danger-bg); border-color: var(--color-danger-border); color: var(--color-danger); }
.btn--danger:hover { background: var(--color-danger-border); }
.btn--sm { padding: var(--sp-1) var(--sp-3); font-size: var(--text-xs); }
.btn--icon { padding: var(--sp-1); width: 28px; height: 28px; }
.btn--icon .icon { width: 16px; height: 16px; }
.btn--sm .icon { width: 14px; height: 14px; }

/* form */
.field { margin-bottom: var(--sp-4); }
.field:last-child { margin-bottom: 0; }
.label { display: block; font-size: var(--text-sm); font-weight: 600; margin-bottom: var(--sp-1); }
.hint { display: block; font-size: var(--text-xs); color: var(--color-text-muted); margin-top: var(--sp-1); }
.input, .select, .textarea {
  display: block;
  width: 100%;
  padding: var(--sp-2) var(--sp-3);
  font-size: var(--text-md);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius);
  background: var(--color-surface);
  color: var(--color-text);
}
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--color-accent); box-shadow: var(--focus-ring); }
.textarea { resize: vertical; }
.checkbox { display: inline-flex; align-items: center; gap: var(--sp-2); font-size: var(--text-sm); font-weight: 500; }
.checkbox input { width: 16px; height: 16px; }
.checkbox-row { display: flex; flex-wrap: wrap; gap: var(--sp-1) var(--sp-4); }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--sp-4) var(--sp-5); }
.form-grid .field--full { grid-column: 1 / -1; }
.form-actions { display: flex; gap: var(--sp-2); margin-top: var(--sp-5); }

/* legacy bare form markup (pages not yet migrated to .field/.input) */
input[type=text], input[type=number], input[type=date], input[type=file], textarea, select {
  padding: var(--sp-2) var(--sp-3);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius);
  background: var(--color-surface);
  font-size: var(--text-md);
}
input[type=submit], input[type=file] { font-size: var(--text-sm); }
input[type=submit], button:not(.btn) {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--text-sm);
  font-weight: 600;
  padding: var(--sp-2) var(--sp-4);
  border-radius: var(--radius);
  border: 1px solid var(--color-border-strong);
  background: var(--color-surface);
  color: var(--color-text);
  cursor: pointer;
}
input[type=submit]:hover, button:not(.btn):hover { background: var(--color-surface-hover); }
.actions button, .actions input[type=submit] { margin-right: var(--sp-2); }

/* borderless inputs inside a table cell — a stop table reads as data,
   not as a wall of forms, until you actually interact with a cell */
.cell-form { display: inline-flex; gap: var(--sp-1); align-items: center; }
.cell-input {
  width: 5.5em;
  padding: var(--sp-1) var(--sp-2);
  border: 1px solid transparent;
  background: transparent;
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
}
.cell-input:hover { border-color: var(--color-border-strong); }
.cell-input:focus { border-color: var(--color-accent); background: var(--color-surface); box-shadow: var(--focus-ring); outline: none; }

/* badge */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  padding: 0.15em 0.55em;
  border-radius: 999px;
  font-size: var(--text-xs);
  font-weight: 600;
  background: var(--color-surface-2);
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
  white-space: nowrap;
}
.badge--neutral { background: var(--color-surface-2); color: var(--color-text-muted); border-color: var(--color-border); }
.badge--accent { background: var(--color-accent-weak); color: var(--color-accent-hover); border-color: var(--color-accent-weak); }
.badge--success { background: var(--color-success-bg); color: var(--color-success); border-color: var(--color-success-border); }
.badge--warning { background: var(--color-warning-bg); color: var(--color-warning); border-color: var(--color-warning-border); }
.badge--danger { background: var(--color-danger-bg); color: var(--color-danger); border-color: var(--color-danger-border); }
.badge--dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge .icon { width: 12px; height: 12px; }

/* alert / flash */
.alert, .flash {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--radius);
  border: 1px solid var(--color-border);
  background: var(--color-surface-2);
  font-size: var(--text-sm);
}
.alert--success, .flash-success { background: var(--color-success-bg); border-color: var(--color-success-border); color: var(--color-success); }
.alert--warning, .flash-warning { background: var(--color-warning-bg); border-color: var(--color-warning-border); color: var(--color-warning); }
.alert--error, .alert--danger, .flash-error { background: var(--color-danger-bg); border-color: var(--color-danger-border); color: var(--color-danger); }
.alert--info { background: var(--color-accent-weak); border-color: var(--color-accent-weak); color: var(--color-accent-hover); }
.alert--floating { position: absolute; top: var(--sp-3); left: 50%; transform: translateX(-50%); max-width: 90%; z-index: 5; box-shadow: var(--shadow-md); }

/* empty state */
.empty-state {
  text-align: center;
  padding: var(--sp-10) var(--sp-6);
  color: var(--color-text-muted);
}
.empty-state .icon { width: 32px; height: 32px; margin: 0 auto var(--sp-3); color: var(--color-text-subtle); }
.empty-state__title { font-size: var(--text-md); font-weight: 600; color: var(--color-text); margin-bottom: var(--sp-1); }
.empty-state__desc { font-size: var(--text-sm); max-width: 40em; margin: 0 auto var(--sp-4); }

/* stat grid */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: var(--sp-4); margin-bottom: var(--sp-6); }
.stat { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg); padding: var(--sp-5); box-shadow: var(--shadow-sm); }
.stat__value { font-size: var(--text-2xl); font-weight: 700; }
.stat__label { font-size: var(--text-sm); color: var(--color-text-muted); margin-top: var(--sp-1); }

/* toolbar (filter bars on list pages) */
.toolbar {
  display: flex;
  align-items: flex-end;
  gap: var(--sp-4);
  flex-wrap: wrap;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--sp-4) var(--sp-5);
  margin-bottom: var(--sp-6);
}
.toolbar .field { margin-bottom: 0; min-width: 10em; }

/* tabs (anchor-based, no JS) */
.tabs { display: flex; gap: var(--sp-1); border-bottom: 1px solid var(--color-border); margin-bottom: var(--sp-5); }
.tab {
  padding: var(--sp-2) var(--sp-3);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tab:hover { color: var(--color-text); text-decoration: none; }
.tab--active { color: var(--color-accent); border-bottom-color: var(--color-accent); }

/* disclosure (styled <details>, used for "add a direction" etc. forms) */
.disclosure { border: 1px solid var(--color-border); border-radius: var(--radius); margin: var(--sp-3) 0; background: var(--color-surface); }
.disclosure > summary { cursor: pointer; padding: var(--sp-3) var(--sp-4); font-size: var(--text-sm); font-weight: 600; color: var(--color-text-muted); list-style: none; }
.disclosure > summary::-webkit-details-marker { display: none; }
.disclosure > summary::before { content: "▸"; display: inline-block; width: 1em; }
.disclosure[open] > summary::before { content: "▾"; }
.disclosure__body { padding: 0 var(--sp-4) var(--sp-4); }

/* a row inside a card representing one sub-item (a route/direction under
   a version, a version under a service) with its own inline actions */
.item-row { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); flex-wrap: wrap; padding: var(--sp-3) var(--sp-5); border-top: 1px solid var(--color-border); }
.item-row:first-child { border-top: none; }
.item-row__main { display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap; min-width: 0; }
.item-row__actions { display: flex; align-items: center; gap: var(--sp-2); flex-shrink: 0; }
.item-row__full { flex: 1 1 100%; min-width: 0; }

/* split (two-pane layout: map page, route stops tab) */
.split { display: flex; gap: var(--sp-5); align-items: flex-start; }
.split__main { flex: 2 1 480px; min-width: 0; }
.split__aside { flex: 1 1 320px; min-width: 280px; position: sticky; top: calc(var(--header-h) + var(--sp-4)); }

/* utilities */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
.stack { display: flex; flex-direction: column; gap: var(--sp-3); }
.cluster { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }
.cluster--lg { gap: var(--sp-6); }

/* =====================================================================
   page-specific
   ===================================================================== */

/* --- map --- */
#map { width: 100%; height: 70vh; min-height: 420px; border-radius: var(--radius-lg); border: 1px solid var(--color-border); }
.map-legend { display: flex; gap: var(--sp-5); align-items: center; margin: 0 0 var(--sp-3); font-size: var(--text-sm); color: var(--color-text-muted); }
.map-legend .swatch { display: inline-block; width: 0.8em; height: 0.8em; border-radius: 50%; margin-right: 0.35em; vertical-align: middle; }
.swatch--stop { background: var(--color-stop); }
.swatch--timing { background: var(--color-timing); }
.swatch--nearby { background: var(--color-stop-nearby); }
.map-hint { font-size: var(--text-sm); color: var(--color-text-muted); margin-top: var(--sp-2); }
.map-container { position: relative; }
.maplibregl-popup-content { font-family: var(--font-sans); font-size: var(--text-sm); }
.nearby-stop-marker { width: 24px; height: 24px; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.nearby-stop-dot {
  width: 9px; height: 9px; border-radius: 50%; background: var(--color-stop-nearby);
  border: 1px solid white; box-shadow: 0 0 2px rgba(0,0,0,0.5); transition: width 0.12s ease, height 0.12s ease;
}
.nearby-stop-marker:hover .nearby-stop-dot { width: 16px; height: 16px; }
.popup-actions button { margin-top: 0.4em; margin-right: 0.3em; }
.map-page-layout { display: flex; gap: var(--sp-5); align-items: flex-start; }
.map-stop-list { flex: 1 1 360px; max-width: 480px; max-height: 80vh; overflow-y: auto; }
.map-stop-list .table { margin-top: 0; }
.map-pane { flex: 2 1 480px; min-width: 0; }
.map-pane.hidden { display: none; }
.map-page-layout.map-hidden .map-stop-list { max-width: none; }
#map-warning { display: none; }

/* --- service calendar --- */
.cal-legend { display: flex; flex-wrap: wrap; gap: var(--sp-5); align-items: center; margin: var(--sp-2) 0 var(--sp-4); font-size: var(--text-sm); color: var(--color-text-muted); }
.cal-swatch { display: inline-block; width: 0.9em; height: 0.9em; border-radius: 3px; margin-right: 0.35em; vertical-align: middle; }
.cal-swatch-overlap { background: var(--color-surface); border: 2px solid var(--color-danger); box-sizing: border-box; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-dow { font-size: var(--text-xs); color: var(--color-text-subtle); text-align: center; padding-bottom: var(--sp-1); }
.cal-day { position: relative; min-height: 3.2em; border-radius: var(--radius-sm); padding: var(--sp-1) var(--sp-2); font-size: var(--text-xs); background: var(--color-surface-2); }
.cal-day.out-of-month { opacity: 0.35; }
.cal-day.is-today { outline: 2px solid var(--color-text); outline-offset: -2px; }
.cal-day.has-overlap { outline: 2px solid var(--color-danger); outline-offset: -2px; }
.cal-day-num { font-weight: 600; }
.cal-day-versions { margin-top: 0.15em; display: flex; flex-direction: column; gap: 2px; }
.cal-version-chip { border-radius: 3px; padding: 0 0.25em; color: var(--color-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* --- route detail: stop table --- */
.timing-point { background: color-mix(in srgb, var(--color-warning-bg) 55%, transparent); }
.direction-warning { color: var(--color-danger); font-weight: bold; margin-left: 0.5em; cursor: help; }
tr.link-row td { background: var(--color-surface-2); font-size: var(--text-xs); }
tr.link-row td:first-child { border-left: 3px solid var(--color-border-strong); }

/* =====================================================================
   responsive
   ===================================================================== */

@media (min-width: 900px) {
  .sidebar__disclosure > summary { pointer-events: none; }
  .sidebar__disclosure .sidebar__nav { display: block !important; }
}

@media (max-width: 899px) {
  .app { flex-direction: column; }
  .sidebar {
    width: 100%;
    height: auto;
    position: sticky;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
  }
  .sidebar__disclosure { display: block; position: relative; flex: 1; }
  .sidebar__brand { border-bottom: none; padding: var(--sp-3) var(--sp-4); }
  .sidebar__nav {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
    box-shadow: var(--shadow-md);
    z-index: 20;
    max-height: 70vh;
    overflow-y: auto;
  }
  .sidebar__footer { border-top: none; padding: 0 var(--sp-3) var(--sp-3); }
  .page-header, .page-body { padding-left: var(--sp-4); padding-right: var(--sp-4); }
  .form-grid { grid-template-columns: 1fr; }
  .split { flex-direction: column; }
  .split__aside { position: static; width: 100%; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 480px) {
  .stat-grid { grid-template-columns: 1fr; }
}

/* --- interpolation tool --- */
.interp-warnings { margin-bottom: var(--sp-5); }
