/* Eval Studio base styles: the shell and the shared components in ui.mjs.
   Colors come only from tokens.css. View styles live in their own files with a view prefix. */

/* ------------------------------------------------------------------ reset */
*, *::before, *::after { box-sizing: border-box; }

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

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font: 400 var(--text-sm)/1.5 var(--font-sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body:has(dialog[open]) { overflow: hidden; }

#app {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

img, svg, video, canvas, audio { max-width: 100%; }
img, video { height: auto; }
button, input, select, textarea { font: inherit; color: inherit; }
p { margin: 0 0 var(--space-3); }
p:last-child { margin-bottom: 0; }
ul, ol { margin: 0 0 var(--space-3); padding-left: 1.4em; }
hr { border: 0; border-top: 1px solid var(--line); margin: var(--space-5) 0; }
::selection { background: var(--accent-soft); color: var(--ink); }

/* ------------------------------------------------------------------ type */
h1, h2, h3, h4, h5, h6 { margin: 0; color: var(--ink); font-family: var(--font-sans); }
h1 { font-size: var(--text-xl); line-height: 1.2; font-weight: 600; letter-spacing: -0.015em; }
h2 { font-size: var(--text-lg); line-height: 1.3; font-weight: 600; letter-spacing: -0.01em; }
h3 { font-size: var(--text-md); line-height: 1.4; font-weight: 600; }
h4, h5, h6 { font-size: var(--text-sm); line-height: 1.4; font-weight: 600; }

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}
a:hover { text-decoration-thickness: 2px; }

code, pre, kbd, samp { font-family: var(--font-mono); }
code { font-size: 0.92em; background: var(--surface-2); padding: 1px 5px; border-radius: 5px; }
pre {
  margin: 0;
  font-size: var(--text-xs);
  line-height: 1.55;
  background: var(--surface-2);
  padding: var(--space-3);
  border-radius: 8px;
  overflow: auto;
  max-width: 100%;
}
pre code { background: none; padding: 0; font-size: inherit; }

.display { font-family: var(--font-serif); font-style: italic; font-weight: 400; letter-spacing: -0.01em; }
.muted { color: var(--ink-3); }
.soft { color: var(--ink-2); }
.small { font-size: var(--text-xs); }
.mono { font-family: var(--font-mono); }
/* Form fields and chips set their own font; .mono on them still means code, prompts, and data. */
:is(.input, .textarea, .select, .chip).mono { font-family: var(--font-mono); }
.num { font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }

/* ------------------------------------------------------------------ focus and a11y */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.main:focus, .main:focus-visible { outline: none; }

.sr-only {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: var(--space-2);
  top: -48px;
  z-index: 100;
  padding: 8px 12px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 600;
  cursor: pointer;
}
.skip-link:focus { top: var(--space-2); }

/* ------------------------------------------------------------------ layout helpers */
.page {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: var(--space-6) var(--space-5) var(--space-7);
}
.page-narrow { max-width: 760px; }
.page-title { margin-bottom: var(--space-2); }
.page-lead { color: var(--ink-2); font-size: var(--text-md); max-width: 62ch; }

.stack { display: grid; gap: var(--space-3); align-content: start; min-width: 0; }
.stack-lg { display: grid; gap: var(--space-5); align-content: start; min-width: 0; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); min-width: 0; }
.row-between { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-2); }
.grow { flex: 1 1 auto; min-width: 0; }

.card {
  background: var(--surface);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: var(--space-4);
  min-width: 0;
}
.card-flat { box-shadow: none; border-color: var(--line); }

.section-title {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--ink-3);
  letter-spacing: 0.02em;
  margin: 0 0 var(--space-2);
}

.divider { height: 1px; background: var(--line); border: 0; margin: var(--space-4) 0; }

/* ------------------------------------------------------------------ shell: top bar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.topbar-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: 52px;
  padding: 6px var(--space-5);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--ink);
  text-decoration: none;
  flex: none;
  border-radius: 6px;
}
.brand:hover { text-decoration: none; }
.brand-mark { flex: none; }
.brand-mark rect { fill: var(--accent); }
.brand-name { font-weight: 700; font-size: var(--text-md); letter-spacing: -0.01em; }
.brand-product { color: var(--ink-3); font-weight: 500; }

.topbar-divider { width: 1px; height: 20px; background: var(--line); flex: none; }

.project-switch {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-width: 0;
  flex: 0 1 auto;
}
.project-switch .menu-button { max-width: 100%; }
.project-switch .btn-label {
  max-width: 32ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
  color: var(--ink);
}
.sample-badge { flex: none; }

.topbar-end {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: var(--space-1);
  flex: none;
}

.save {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-right: var(--space-2);
  padding: 4px 6px;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--ink-3);
  font-size: var(--text-xs);
  white-space: nowrap;
}
button.save { cursor: pointer; color: var(--bad); }
button.save:hover { background: var(--bad-soft); }
.save-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex: none;
  background: var(--good);
}
.save-dot.is-saving { background: var(--accent); animation: pulse 1s var(--ease) infinite alternate; }
.save-dot.is-error { background: var(--bad); }
.save-dot.is-readonly { background: transparent; box-shadow: inset 0 0 0 1.5px var(--ink-3); }

.theme-toggle .btn-label { min-width: 4ch; text-align: left; }

/* Numbered step tabs */
.navtabs {
  padding: 0 var(--space-4);
  overflow-x: auto;
  scrollbar-width: none;
}
.navtabs::-webkit-scrollbar { display: none; }
.navtabs-list {
  display: flex;
  align-items: stretch;
  gap: 2px;
  margin: 0;
  padding: 0;
  list-style: none;
  min-height: 44px;
}
.navtabs-list > li { display: flex; }
.navtab {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 0 10px;
  color: var(--ink-2);
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  border-radius: 6px 6px 0 0;
  transition: color var(--dur-fast) var(--ease), background-color var(--dur-fast) var(--ease);
}
.navtab:hover { color: var(--ink); text-decoration: none; background: var(--surface-2); }
.navtab:focus-visible { outline-offset: -2px; }
.navtab-num {
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  padding: 0 4px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font: 500 var(--text-xs)/1 var(--font-mono);
  color: var(--ink-3);
  background: var(--surface);
}
.navtab.is-active { color: var(--ink); }
.navtab.is-active::after {
  content: "";
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 0;
  height: 2px;
  border-radius: 2px 2px 0 0;
  background: var(--accent);
}
.navtab.is-active .navtab-num { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.navtab.is-disabled { opacity: 0.45; cursor: not-allowed; }
.navtab.is-disabled:hover { background: none; color: var(--ink-2); }

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

/* Banners under the top bar */
.banner {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px var(--space-5);
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
  color: var(--ink-2);
}
.banner > .icon { margin-top: 3px; color: var(--ink-3); }
.banner p { margin: 0; flex: 1; min-width: 0; }
.banner strong { color: var(--ink); font-weight: 600; }
.banner .btn { margin: -4px 0; }
.banner-bad { background: var(--bad-soft); color: var(--ink); }
.banner-bad > .icon { color: var(--bad); }
.banner-warn { background: var(--warn-soft); color: var(--ink); }
.banner-warn > .icon { color: var(--warn); }

/* Loading and start-up errors */
.boot {
  flex: 1;
  min-height: 60vh;
  display: grid;
  place-items: center;
  padding: var(--space-5);
}
.boot-line { color: var(--ink-3); margin: 0; }
.boot-error { max-width: 440px; text-align: center; display: grid; gap: var(--space-3); justify-items: center; }
.boot-error h1 { font-size: var(--text-lg); }

/* ------------------------------------------------------------------ icons, badges, keys */
.icon { flex: none; display: inline-block; vertical-align: middle; }

.badge {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 7px;
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  color: var(--ink-2);
  font: 500 var(--text-xs)/1 var(--font-sans);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.navtab.is-active .badge { background: var(--accent-soft); color: var(--accent); }

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

/* ------------------------------------------------------------------ buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 8px;
  font: 500 var(--text-sm)/1 var(--font-sans);
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  transition: background-color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease),
    color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.btn:hover { text-decoration: none; }
.btn:active:not(:disabled) { transform: translateY(0.5px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; }
.btn-label { min-width: 0; }

.btn-sm { height: 28px; padding: 0 10px; font-size: var(--text-xs); border-radius: 7px; gap: 5px; }
.btn-lg { height: 42px; padding: 0 18px; font-size: var(--text-md); border-radius: 9px; gap: 8px; }
.btn-icon { width: 34px; padding: 0; }
.btn-sm.btn-icon { width: 28px; }
.btn-lg.btn-icon { width: 42px; }

.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover:not(:disabled) { background: color-mix(in srgb, var(--accent) 86%, var(--ink)); }

.btn-secondary { background: var(--surface); color: var(--ink); border-color: var(--line); }
.btn-secondary:hover:not(:disabled) { background: var(--surface-2); }

.btn-ghost { background: transparent; color: var(--ink-2); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); color: var(--ink); }
.btn-ghost[aria-expanded="true"] { background: var(--surface-2); color: var(--ink); }

.btn-good { background: var(--good-soft); color: var(--good); border-color: color-mix(in srgb, var(--good) 30%, transparent); }
.btn-good:hover:not(:disabled) { border-color: var(--good); }
.btn-good[aria-pressed="true"], .btn-good.is-active { background: var(--good); border-color: var(--good); color: var(--on-good); }

.btn-bad { background: var(--bad-soft); color: var(--bad); border-color: color-mix(in srgb, var(--bad) 30%, transparent); }
.btn-bad:hover:not(:disabled) { border-color: var(--bad); }
.btn-bad[aria-pressed="true"], .btn-bad.is-active { background: var(--bad); border-color: var(--bad); color: var(--on-bad); }

.btn .kbd { height: 18px; min-width: 18px; padding: 0 4px; border-bottom-width: 1px; background: transparent; border-color: currentColor; color: inherit; opacity: 0.7; }

/* ------------------------------------------------------------------ chips */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 24px;
  max-width: 100%;
  padding: 2px 10px;
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  color: var(--ink-2);
  font: 500 var(--text-xs)/1.3 var(--font-sans);
  text-align: left;
  vertical-align: middle;
}
.chip-button { cursor: pointer; transition: border-color var(--dur-fast) var(--ease), background-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease); }
.chip-button:hover { color: var(--ink); border-color: color-mix(in srgb, var(--ink-3) 45%, transparent); }

.chip-good { background: var(--good-soft); color: var(--good); }
.chip-bad { background: var(--bad-soft); color: var(--bad); }
.chip-warn { background: var(--warn-soft); color: var(--warn); }
.chip-ai { background: var(--ai-soft); color: var(--ai); border: 1px dashed color-mix(in srgb, var(--ai) 65%, transparent); }

.chip.is-selected { background: var(--accent-soft); color: var(--accent); border-color: color-mix(in srgb, var(--accent) 50%, transparent); }
.chip-good.is-selected { background: var(--good); color: var(--on-good); border-color: var(--good); }
.chip-bad.is-selected { background: var(--bad); color: var(--on-bad); border-color: var(--bad); }

/* Stage chips are neutral: surface-2 fill, ink text, and the stage number. */
.stage-chip { background: var(--surface-2); color: var(--ink); padding-left: 3px; }
.stage-chip .stage-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stage-num {
  display: inline-grid;
  place-items: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--ink);
  font: 600 var(--text-xs)/1 var(--font-sans);
  font-variant-numeric: tabular-nums;
}
.stage-chip:not(:has(.stage-num)) { padding-left: 10px; }
.stage-chip.is-selected .stage-num { background: var(--accent); color: var(--on-accent); }

/* ------------------------------------------------------------------ forms */
.field { display: grid; gap: 6px; min-width: 0; }
.label { font: 600 var(--text-xs)/1.3 var(--font-sans); color: var(--ink-2); }
.hint { font-size: var(--text-xs); color: var(--ink-3); margin: 0; }
.error-text { font-size: var(--text-xs); color: var(--bad); margin: 0; }

:where(input:not([type="checkbox"], [type="radio"], [type="file"], [type="range"], [type="color"]), textarea, select),
.input, .textarea, .select {
  width: 100%;
  min-height: 36px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font: 400 var(--text-sm)/1.45 var(--font-sans);
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
:where(textarea), .textarea { min-height: 96px; resize: vertical; line-height: 1.5; }
:where(input:not([type="checkbox"], [type="radio"], [type="file"], [type="range"], [type="color"]), textarea, select):hover,
.input:hover, .textarea:hover, .select:hover { border-color: color-mix(in srgb, var(--ink-3) 45%, var(--line)); }
:where(input:not([type="checkbox"], [type="radio"], [type="file"], [type="range"], [type="color"]), textarea, select):focus,
.input:focus, .textarea:focus, .select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
:where(input, textarea, select):disabled { opacity: 0.6; cursor: not-allowed; }
::placeholder { color: var(--ink-3); opacity: 1; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); width: 16px; height: 16px; margin: 0; }
.check-row { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }

/* ------------------------------------------------------------------ tables */
.table-wrap { width: 100%; overflow-x: auto; }
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}
.table th {
  text-align: left;
  font: 600 var(--text-xs)/1.3 var(--font-sans);
  color: var(--ink-3);
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  vertical-align: bottom;
}
.table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: color-mix(in srgb, var(--surface-2) 55%, transparent); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.th-button {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  color: inherit;
  cursor: pointer;
}
.th-button:hover { color: var(--ink); }

/* ------------------------------------------------------------------ tabs and segmented */
.tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--line);
  margin-bottom: var(--space-4);
  overflow-x: auto;
  scrollbar-width: none;
}
.tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 10px;
  border: 0;
  background: none;
  color: var(--ink-2);
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
}
.tab:hover { color: var(--ink); }
.tab:focus-visible { outline-offset: -2px; border-radius: 6px; }
.tab.is-active { color: var(--ink); }
.tab.is-active::after {
  content: "";
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: -1px;
  height: 2px;
  border-radius: 2px;
  background: var(--accent);
}

.segmented {
  display: inline-flex;
  gap: 2px;
  padding: 2px;
  border-radius: 9px;
  background: var(--surface-2);
  max-width: 100%;
  overflow-x: auto;
}
.segment {
  height: 28px;
  padding: 0 11px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--ink-2);
  font: 500 var(--text-xs)/1 var(--font-sans);
  white-space: nowrap;
  cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.segment:hover { color: var(--ink); }
.segment.is-active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 0 0 1px var(--card-border), 0 1px 2px rgba(0, 0, 0, 0.08);
}

/* ------------------------------------------------------------------ dialogs and drawers */
.modal, .drawer {
  padding: 0;
  border: 0;
  background: var(--surface);
  color: var(--ink);
  max-width: 100vw;
  max-height: 100dvh;
  overflow: hidden;
}
.modal::backdrop, .drawer::backdrop { background: var(--scrim, rgba(22, 25, 29, 0.32)); }

.modal {
  width: min(560px, calc(100vw - 32px));
  max-height: calc(100dvh - 48px);
  margin: auto;
  border: 1px solid var(--card-border);
  border-radius: 12px;
  box-shadow: var(--shadow-pop);
}
.modal[open] { animation: pop-in var(--dur-slow) var(--ease); }
.modal-box { display: flex; flex-direction: column; max-height: calc(100dvh - 48px); }

.drawer {
  position: fixed;
  inset: 0 0 0 auto;
  margin: 0;
  width: min(480px, 100vw);
  height: 100dvh;
  border-left: 1px solid var(--line);
  box-shadow: var(--shadow-pop);
}
.drawer-left { inset: 0 auto 0 0; border-left: 0; border-right: 1px solid var(--line); }
.drawer[open] { animation: slide-in-right var(--dur-slow) var(--ease); }
.drawer-left[open] { animation-name: slide-in-left; }
.drawer-box { display: flex; flex-direction: column; height: 100%; }

.dialog-head {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 12px 12px 12px 20px;
  border-bottom: 1px solid var(--line);
  flex: none;
}
.dialog-title { flex: 1; min-width: 0; font-size: var(--text-md); line-height: 1.3; }
.dialog-body { flex: 1 1 auto; min-height: 0; overflow: auto; padding: var(--space-4) 20px 20px; }
.dialog-foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: var(--space-2);
  padding: 12px 20px;
  border-top: 1px solid var(--line);
  flex: none;
}

/* ------------------------------------------------------------------ menu (popover) */
.menu-wrap { display: inline-flex; min-width: 0; max-width: 100%; }
.menu-button .icon:last-child { color: var(--ink-3); }
.menu {
  position: fixed;
  inset: auto;
  margin: 0;
  padding: 4px;
  min-width: 240px;
  max-width: min(360px, calc(100vw - 16px));
  max-height: min(440px, calc(100dvh - 96px));
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-pop);
}
.menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--ink);
  font: 500 var(--text-sm)/1.3 var(--font-sans);
  text-align: left;
  cursor: pointer;
}
.menu-item:hover { background: var(--surface-2); }
.menu-item:focus-visible { outline: none; background: var(--surface-2); box-shadow: inset 0 0 0 2px var(--accent); }
.menu-item:disabled { opacity: 0.5; cursor: not-allowed; }
.menu-item > .icon:first-child { color: var(--ink-3); }
.menu-item.is-selected > .icon:last-child { color: var(--accent); }
.menu-item.is-danger { color: var(--bad); }
.menu-item-text { flex: 1; min-width: 0; display: grid; gap: 1px; }
.menu-item-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-item-hint { font-size: var(--text-xs); font-weight: 400; color: var(--ink-3); }
.menu-divider { height: 1px; margin: 4px 6px; background: var(--line); }

/* ------------------------------------------------------------------ empty state, progress, spark */
.empty {
  display: grid;
  justify-items: center;
  gap: var(--space-2);
  max-width: 520px;
  margin: var(--space-5) auto;
  padding: var(--space-7) var(--space-5);
  text-align: center;
}
.empty-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin-bottom: var(--space-1);
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--ink-2);
}
.empty-title { font-size: var(--text-lg); }
.empty-body { margin: 0; max-width: 46ch; color: var(--ink-2); }
.empty-action { margin-top: var(--space-3); }

.progress {
  height: 6px;
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  overflow: hidden;
}
.progress-fill {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width var(--dur-slow) var(--ease);
}

.spark { color: var(--ink-2); vertical-align: middle; flex: none; }
.tooltip { text-decoration: underline dotted var(--ink-3); text-underline-offset: 3px; cursor: help; }

/* ------------------------------------------------------------------ file drop and downloads */
.filedrop {
  display: grid;
  justify-items: center;
  gap: 6px;
  padding: 28px 20px;
  border: 1.5px dashed var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink-2);
  text-align: center;
  cursor: pointer;
  transition: border-color var(--dur-fast) var(--ease), background-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.filedrop:hover, .filedrop.is-over { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.filedrop:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.filedrop-label { font-weight: 600; color: var(--ink); }
.filedrop-hint { font-size: var(--text-xs); color: var(--ink-3); }

.download { display: grid; justify-items: start; gap: 4px; min-width: 0; }

/* ------------------------------------------------------------------ toasts */
.toaster {
  position: fixed;
  inset: auto 0 var(--space-4) 0;
  z-index: 60;
  display: grid;
  gap: var(--space-2);
  width: min(460px, calc(100vw - 32px));
  height: auto;
  margin: 0 auto;
  padding: 0;
  border: 0;
  background: transparent;
  overflow: visible;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 8px 6px 8px 14px;
  border-radius: var(--radius);
  background: var(--ink);
  color: var(--bg);
  box-shadow: var(--shadow-pop);
  pointer-events: auto;
  animation: toast-in var(--dur-slow) var(--ease);
}
.toast-text { flex: 1; min-width: 0; line-height: 1.4; }
.toast-bad, .toast-good { border-left: 3px solid var(--bad); padding-left: 11px; }
.toast-good { border-left-color: var(--good); }
.toast .btn-secondary { background: transparent; color: var(--bg); border-color: color-mix(in srgb, var(--bg) 35%, transparent); }
.toast .btn-secondary:hover { background: color-mix(in srgb, var(--bg) 14%, transparent); }
.toast .btn-ghost { color: color-mix(in srgb, var(--bg) 70%, transparent); }
.toast .btn-ghost:hover { background: color-mix(in srgb, var(--bg) 14%, transparent); color: var(--bg); }
.toast :focus-visible { outline-color: var(--bg); }

/* ------------------------------------------------------------------ help drawer */
.help-panel { padding-top: var(--space-1); }
.help-group + .help-group { margin-top: var(--space-5); }
.help-group-title { font-size: var(--text-xs); font-weight: 600; color: var(--ink-3); margin-bottom: var(--space-2); }
.help-list { margin: 0; }
.help-row {
  display: grid;
  grid-template-columns: minmax(112px, max-content) 1fr;
  align-items: center;
  gap: var(--space-3);
  padding: 7px 0;
  border-bottom: 1px solid var(--line);
}
.help-row dt { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.help-row dd { margin: 0; color: var(--ink-2); }
.key-combo { display: inline-flex; gap: 3px; }
.help-or { font-size: var(--text-xs); color: var(--ink-3); }
.help-keys > .hint { margin-top: var(--space-4); }

.glossary { margin: 0; }
.glossary-row { padding: 12px 0; border-bottom: 1px solid var(--line); }
.glossary-row:first-child { padding-top: 4px; }
.glossary-row dt { font-weight: 600; color: var(--ink); }
.glossary-row dd { margin: 4px 0 0; display: grid; gap: 4px; }
.glossary-def { color: var(--ink-2); }
.glossary-term { font-size: var(--text-xs); color: var(--ink-3); }
.glossary-note {
  font-size: var(--text-xs);
  color: var(--ink-3);
  padding-left: 10px;
  border-left: 2px solid var(--line);
}

/* ------------------------------------------------------------------ trace view frame (renderers/index.mjs) */
.trace-view { display: grid; gap: var(--space-4); min-width: 0; }
.rv-notice, .rv-loading {
  margin: 0;
  padding: 8px 12px;
  border-radius: 8px;
  background: var(--warn-soft);
  color: var(--ink);
  font-size: var(--text-xs);
}
.rv-loading { background: var(--surface-2); color: var(--ink-2); }
.rv-fallback { display: grid; gap: var(--space-3); min-width: 0; }
.rv-broken {
  display: grid;
  gap: 4px;
  padding: 12px 14px;
  border-radius: 8px;
  background: var(--bad-soft);
  color: var(--ink);
}

/* ------------------------------------------------------------------ motion */
@keyframes pulse { from { opacity: 1; } to { opacity: 0.35; } }
@keyframes pop-in { from { opacity: 0; transform: translateY(6px) scale(0.985); } to { opacity: 1; transform: none; } }
@keyframes slide-in-right { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes slide-in-left { from { transform: translateX(-24px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ------------------------------------------------------------------ responsive */
@media (max-width: 899px) {
  .topbar-row { padding: 6px var(--space-3); gap: var(--space-2); }
  .navtabs { padding: 0 var(--space-2); }
  .banner { padding: 10px var(--space-4); }
  .page { padding: var(--space-5) var(--space-4) var(--space-6); }
  .project-switch .btn-label { max-width: 22ch; }
}

@media (max-width: 640px) {
  .brand-product, .topbar-divider, .theme-toggle .btn-label { display: none; }
  .theme-toggle { width: 28px; padding: 0; }
  .save { margin-right: 0; padding: 4px; }
  .save-text {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }
  .project-switch .btn-label { max-width: 14ch; }
  .drawer { width: 100vw; border-left: 0; }
  .dialog-body { padding: var(--space-4); }
  .help-row { grid-template-columns: 1fr; gap: 4px; }
}

@media (max-width: 480px) {
  .sample-badge { display: none; }
  .navtab { padding: 0 8px; }
}
