/* ===========================================================================
   RATAN-PBind - design preview
   ===========================================================================
   Light by default and it stays light: a lab tool gets compared against printed
   figures, so it does not follow the OS colour scheme.

   Motion lives in app.js. CSS transitions can't be grabbed and reversed
   mid-flight, so anything interruptible is spring-driven; transitions here are
   only for discrete states nobody interrupts (hover, press, focus).
   =========================================================================== */

:root {
  /* Neutrals are very slightly warm and blue-tinted rather than pure grey -
     flat #F5F5F7 on #FFF is what makes an interface read as a default. */
  --bg: #F7F8FA;
  --surface: #FFFFFF;
  --surface-sunken: #FAFBFC;

  --ink: #15161A;
  --ink-secondary: #5F6269;
  --ink-tertiary: #93969E;

  --hairline: rgba(18, 20, 28, 0.07);
  --hairline-strong: rgba(18, 20, 28, 0.13);

  --accent: #0A6CFF;
  --accent-deep: #0A50C8;
  --accent-wash: rgba(10, 108, 255, 0.09);

  --positive: #11835A;
  --positive-wash: rgba(17, 131, 90, 0.1);
  --negative: #C0352B;
  --negative-wash: rgba(192, 53, 43, 0.09);
  --caution: #96630A;
  --caution-wash: rgba(150, 99, 10, 0.1);

  --radius-xs: 8px;
  --radius-sm: 12px;
  --radius: 18px;
  --radius-lg: 24px;

  /* Three layers per surface: a hairline edge, a tight contact shadow, and a
     wide soft lift. One blur radius reads flat no matter how dark you make it. */
  --shadow-card:
    0 0 0 1px rgba(18, 20, 28, 0.04),
    0 1px 2px rgba(18, 20, 28, 0.04),
    0 10px 28px -12px rgba(18, 20, 28, 0.14);
  --shadow-lifted:
    0 0 0 1px rgba(18, 20, 28, 0.05),
    0 2px 8px rgba(18, 20, 28, 0.07),
    0 32px 64px -20px rgba(18, 20, 28, 0.28);
  --shadow-accent:
    0 1px 2px rgba(10, 60, 150, 0.2),
    0 8px 20px -6px rgba(10, 80, 200, 0.35);

  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, sans-serif;
  --mono: "SF Mono", ui-monospace, "JetBrains Mono", "Fira Code", Menlo, monospace;

  /* Apple's system palette, light variants - shared with BBB-TransAI and
     ToxBench so the three tools read as one family. Used for the background
     wash, the headline and accents ONLY. Data keeps neutral ink: see the
     "Tinted neutrals" note below for why a number must not change colour. */
  --c-blue:   #007aff;
  --c-indigo: #5856d6;
  --c-purple: #af52de;
  --c-pink:   #ff2d55;
  --c-orange: #ff9500;
  --c-green:  #34c759;
  --c-mint:   #00a99d;
  --c-cyan:   #1d9bd8;

  --radius-pill: 999px;

  /* The built-in CSS easings are too weak to read as intentional. Motion that
     can be interrupted still belongs in spring.js; these are for the discrete
     states only. */
  --ease-out:    cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);

  /* 780px was a reading measure for a one-column form. The result panels are
     tables and trajectories, and BBB-TransAI sits at 61rem, so the family
     matches and the batch table stops wrapping. */
  --shell: 61rem;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

/* `hidden` is a UA display:none, so any class setting `display` beats it on
   specificity -- which silently un-hides every panel and empty result card.
   This keeps the attribute authoritative. */
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: var(--font);
  /* 17px, matching BBB-TransAI and ToxBench. At 15px this app read a size
     smaller than the other two side by side. */
  font-size: 1.0625rem;
  line-height: 1.55;
  color: var(--ink);
  background: var(--bg);
  /* No -webkit-font-smoothing: antialiased. It drops subpixel rendering and
     makes every weight read a step lighter, which is what turns small UI text
     thin and washy on Windows - where this is presented. */
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

h1, h2, h3 { margin: 0; font-weight: 600; }

.shell { max-width: var(--shell); margin: 0 auto; padding-inline: 20px; }

/* A very soft wash of colour behind everything. Large, slow and low-contrast,
   so it gives the page depth without ever competing with content. */
/* Six stops around the edges rather than two at the top, so the colour reaches
   the bottom of a long result page instead of fading out above the fold. It is
   fixed and never animates, so it costs nothing after first paint and cannot
   induce motion sickness.

   inset:0 rather than a measured height: the old rule capped the wash at 70svh
   and the Design tab, which is the longest page in the app, ran off the bottom
   of it onto flat canvas. */
.aurora {
  --wash: 24%;
  --accent-strength: 16%;
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    /* The tab's own accent, first so it sits over the fixed family colours.
       .aurora is a child of body, so it inherits body[data-tab]'s --accent
       and this layer changes with the tab. */
    radial-gradient(44vmax 54vmax at 16% -2%, color-mix(in srgb, var(--accent) var(--accent-strength), transparent) 0%, transparent 70%),
    radial-gradient(48vmax 38vmax at  6%  -6%, color-mix(in srgb, var(--c-purple) var(--wash), transparent) 0%, transparent 68%),
    radial-gradient(52vmax 38vmax at 34% -10%, color-mix(in srgb, var(--c-indigo) var(--wash), transparent) 0%, transparent 70%),
    radial-gradient(54vmax 40vmax at 72%  -4%, color-mix(in srgb, var(--c-cyan)   var(--wash), transparent) 0%, transparent 70%),
    radial-gradient(44vmax 34vmax at 102%  8%, color-mix(in srgb, var(--c-pink)   var(--wash), transparent) 0%, transparent 68%),
    radial-gradient(46vmax 36vmax at -8%  72%, color-mix(in srgb, var(--c-mint)   var(--wash), transparent) 0%, transparent 70%),
    radial-gradient(50vmax 38vmax at 108% 88%, color-mix(in srgb, var(--c-orange) var(--wash), transparent) 0%, transparent 70%);
  filter: saturate(135%);
}
@media (prefers-reduced-transparency: reduce) { .aurora { --wash: 10%; } }

/* --------------------------------------------------------------------------
   Chrome
   -------------------------------------------------------------------------- */

.chrome {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(247, 248, 250, 0.72);
  backdrop-filter: blur(28px) saturate(180%);
  -webkit-backdrop-filter: blur(28px) saturate(180%);
  border-bottom: 1px solid var(--hairline);
}

.chrome-inner {
  padding-block: 13px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.wordmark { display: flex; align-items: center; gap: 10px; min-width: 0; }

/* The ring inherits `color`, so the mark reverses by setting colour on a parent:
   on a blue or dark surface give .mark `color:#fff` and add .mark--reversed,
   otherwise the blue ring disappears into the background and only the dot is
   left. The ligand dot shifts to a pale tint there for the same reason. */
.mark { width: 24px; height: 24px; color: var(--accent); flex: none; }
.mark svg { width: 100%; height: 100%; display: block; overflow: visible; }
.mark--reversed { color: #fff; }
.mark--reversed .mark svg rect:not([fill="#000"]) { fill: rgba(255, 255, 255, 0.66); }
.mark--reversed .mark-ridges { stroke: var(--accent-deep); opacity: 0.45; }

/* The helical ridges are the first detail to go below ~20px, where they read as
   dirt rather than turns. The only inline use is the 24px header mark, so they
   stay here; the favicon is a separate, ridgeless copy. */

.wordmark-text { display: flex; flex-direction: column; min-width: 0; }

.wordmark-name { font-size: 15px; font-weight: 600; letter-spacing: -0.012em; }

.wordmark-sub {
  font-size: 11px;
  color: var(--ink-tertiary);
  letter-spacing: 0.012em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.status {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 12.5px; color: var(--ink-secondary); white-space: nowrap;
}

.status-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--ink-tertiary);
  transition: background-color 220ms ease, box-shadow 220ms ease;
}

.status[data-state="busy"] .status-dot {
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-wash);
}
.status[data-state="done"] .status-dot { background: var(--positive); }
.status[data-state="error"] .status-dot { background: var(--negative); }

/* Segmented control - the indicator is positioned by a spring in app.js */

.tabs { border-top: 1px solid transparent; }
.tabs-inner { padding-bottom: 10px; overflow-x: auto; scrollbar-width: none; }
.tabs-inner::-webkit-scrollbar { display: none; }

.segmented {
  position: relative;
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  background: rgba(18, 20, 28, 0.05);
  border-radius: var(--radius-pill);
  isolation: isolate;
}

.segmented.inline { display: flex; width: 100%; }
.segmented.inline button { flex: 1; }

.segmented button {
  position: relative;
  z-index: 1;
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: -0.004em;
  color: var(--ink-secondary);
  background: none;
  border: none;
  border-radius: 9px;
  padding: 7px 14px;
  cursor: pointer;
  white-space: nowrap;
  transition: color 180ms ease;
}

.segmented button[aria-selected="true"] { color: var(--ink); font-weight: 600; }

.segmented-indicator {
  position: absolute;
  z-index: 0;
  top: 3px;
  left: 0;
  height: calc(100% - 6px);
  border-radius: var(--radius-pill);
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(18, 20, 28, 0.1), 0 2px 8px -2px rgba(18, 20, 28, 0.12);
  /* width/transform set by the spring */
}

/* --------------------------------------------------------------------------
   Layout
   -------------------------------------------------------------------------- */

main { padding-block: 10px 80px; }

.panel { display: flex; flex-direction: column; gap: 18px; }

.hero { padding: 24px 2px 2px; }

.hero h1 {
  /* Same ramp as BBB-TransAI and ToxBench: 32px up to 52px. */
  font-size: clamp(2rem, 1.35rem + 2.9vw, 3.25rem);
  line-height: 1.06;
  letter-spacing: -0.023em;  /* large text needs negative tracking */
  font-weight: 650;
  margin-bottom: 11px;
}

/* One word per headline carries the family's colour. Gradient text needs a
   fallback: in forced-contrast mode transparent fill would erase the word
   entirely, so the colour is dropped rather than the text. */
.gradient-text {
  background: linear-gradient(104deg,
      var(--c-indigo) 0%, var(--c-purple) 26%, var(--c-pink) 50%,
      var(--c-orange) 72%, var(--c-cyan) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
}
@media (prefers-contrast: more) {
  .gradient-text {
    background: none;
    color: var(--ink);
    -webkit-text-fill-color: var(--ink);
  }
}

.hero p {
  margin: 0;
  max-width: 56ch;
  color: var(--ink-secondary);
  font-size: 15.5px;
  line-height: 1.6;
}

.card {
  position: relative;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 26px;
}

/* A bright inner edge along the top - the way light catches a raised surface.
   It is what stops a white card reading as a plain rectangle. */
.card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 50%;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  background: linear-gradient(rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0));
  pointer-events: none;
  opacity: 0.6;
}

.card > * { position: relative; }

.card-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 12px; margin-bottom: 15px;
}

.card-head h3 { font-size: 16.5px; letter-spacing: -0.014em; }

.muted { font-size: 12.5px; color: var(--ink-tertiary); }
.hint { font-size: 11.5px; color: var(--ink-tertiary); }

.body { margin: 0; color: var(--ink-secondary); font-size: 14.5px; line-height: 1.68; }
.body strong { color: var(--ink); font-weight: 600; }

.tag {
  font-size: 11px; font-weight: 600; color: var(--accent);
  background: var(--accent-wash); padding: 3px 9px; border-radius: 7px;
  white-space: nowrap;
}

.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* --------------------------------------------------------------------------
   Form controls
   -------------------------------------------------------------------------- */

.composer { display: flex; flex-direction: column; gap: 18px; }

.field { display: flex; flex-direction: column; gap: 9px; }

.field-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }

label, .field-label {
  font-size: 13px; font-weight: 600; color: var(--ink); letter-spacing: -0.004em;
}

.counter {
  font-size: 12px; font-variant-numeric: tabular-nums;
  color: var(--ink-tertiary); transition: color 220ms ease;
}
.counter[data-state="invalid"] { color: var(--negative); }
.counter[data-state="ok"] { color: var(--positive); }

textarea, .stepper input, #chat-input, .params input {
  font-family: var(--font);
  font-size: 14px;
  color: var(--ink);
  background: var(--surface-sunken);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  padding: 13px 15px;
  width: 100%;
  transition: border-color 170ms ease, box-shadow 170ms ease, background-color 170ms ease;
}

textarea {
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.8;
  letter-spacing: 0.02em;
  min-height: 108px;
  resize: vertical;
  word-break: break-all;
}

/* A file is being dragged over the library box. Outline rather than border, so
   the box does not grow by 1px and shove the layout as the pointer crosses it. */
#batch-input.is-over {
  outline: 2px dashed var(--accent);
  outline-offset: 2px;
  background: var(--accent-wash);
}

/* --------------------------------------------------------------------------
   in-page charts
   -------------------------------------------------------------------------- */

/* The cards whose text comes from the model. The tint marks them as written
   rather than measured, which is worth signalling on a page where everything
   else is a number the ensemble produced. */
.ai-tag {
  border: 0;
  color: #ffffff;
  background: linear-gradient(104deg, #5856d6 0%, #af52de 45%, #1d9bd8 100%);
}
#analysis-card, #batch-summary-card, #mutate-advice-card, #design-analysis-card {
  background:
    linear-gradient(180deg,
      color-mix(in srgb, #af52de 7%, transparent) 0%,
      transparent 120px),
    var(--tint-surface);
}

.shap-chart { display: flex; flex-direction: column; gap: 9px; }

.shap-row {
  display: grid;
  grid-template-columns: minmax(0, 15rem) 1fr 4.5rem;
  align-items: center;
  gap: 12px;
}
.shap-name {
  font-size: 12.5px;
  color: var(--ink-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.shap-name[data-imputed="true"]::after {
  content: " (median)";
  color: var(--ink-tertiary);
}
/* The centre of the track is zero. The hairline marks it, so a bar's direction
   is readable without reading its number. */
.shap-track {
  position: relative;
  height: 10px;
  border-radius: 100px;
  background: var(--tint-sunken);
  overflow: hidden;
}
.shap-track::before {
  content: "";
  position: absolute;
  left: 50%; top: 0; bottom: 0;
  width: 1px;
  background: var(--hairline-strong);
}
.shap-fill {
  position: absolute;
  top: 0; bottom: 0;
  width: 0;
  border-radius: 100px;
}
.shap-row[data-sign="pos"] .shap-fill { left: 50%; background: var(--accent); }
.shap-row[data-sign="neg"] .shap-fill { right: 50%; background: var(--negative); }
.shap-value {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--ink-secondary);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.traj-chart svg { width: 100%; height: auto; display: block; }

@media (max-width: 640px) {
  .shap-row { grid-template-columns: minmax(0, 8rem) 1fr 3.6rem; gap: 8px; }
  .shap-name { font-size: 11.5px; }
}

textarea::placeholder, #chat-input::placeholder { color: #B9BCC4; }

textarea:focus, .stepper input:focus, #chat-input:focus, .params input:focus {
  outline: none;
  background: var(--surface);
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-wash);
}

.notice { font-size: 12.5px; color: var(--negative); overflow: hidden; }

/* Examples */

/* A grid, not flex-wrap: every chip the same width so the rows line up. With
   flex-wrap each chip sized to its own label and the result read as ragged. */
.examples {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
  gap: 8px;
  align-items: stretch;
}

.example {
  font: inherit;
  color: var(--ink);
  text-align: left;
  background: var(--surface-sunken);
  border: 1px solid var(--hairline);
  border-radius: 13px;
  padding: 8px 12px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 1px;
  transition: border-color 150ms ease, background-color 150ms ease;
}


.example-name {
  font-size: 12.5px; font-weight: 600; letter-spacing: -0.004em;
  /* Explicit, because iOS Safari paints <button> text in its own accent blue
     whenever colour is left to inherit -- `font: inherit` does not carry it. */
  color: var(--ink);
}

.example-meta {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--ink-tertiary);
}

/* Picker */

.picker {
  font: inherit; font-size: 14.5px; color: var(--ink);
  background: var(--surface-sunken);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  padding: 12px 15px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  cursor: pointer; width: 100%; text-align: left;
  transition: border-color 170ms ease, background-color 170ms ease;
}

.picker.compact { width: auto; flex: 1; min-width: 190px; padding: 10px 13px; }
.picker:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-wash); }

.picker-value { font-family: var(--mono); font-size: 13px; }
.picker-chevron { width: 12px; height: 12px; color: var(--ink-tertiary); flex: none; }

.stepper {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--ink-secondary); font-weight: 500;
}
.stepper input { width: 72px; padding: 10px 11px; text-align: center; font-variant-numeric: tabular-nums; }

/* Buttons */

.run {
  position: relative;
  font: inherit; font-size: 15.5px; font-weight: 600; letter-spacing: -0.008em;
  color: #FFFFFF;
  /* A gentle vertical gradient plus an inner top highlight: a flat fill is the
     single biggest tell of a default button. */
  background: linear-gradient(var(--accent), var(--accent-deep));
  border: none;
  border-radius: var(--radius);
  padding: 15px 20px;
  cursor: pointer;
  overflow: hidden;
  box-shadow: var(--shadow-accent);
  transition: filter 150ms ease;
}

.run::before {
  content: "";
  position: absolute; inset: 0 0 auto; height: 50%;
  background: linear-gradient(rgba(255, 255, 255, 0.22), rgba(255, 255, 255, 0));
  pointer-events: none;
}

.run:disabled { cursor: progress; }
.run:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.run-label { position: relative; z-index: 1; }

.run-progress {
  position: absolute; inset: 0;
  background: linear-gradient(100deg, transparent 20%, rgba(255,255,255,0.3) 50%, transparent 80%);
  transform: translateX(-100%);
  opacity: 0;
}

.run[data-busy="true"] .run-progress {
  opacity: 1;
  animation: sweep 1.5s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

@keyframes sweep { to { transform: translateX(100%); } }

.ghost {
  font: inherit; font-size: 13px; font-weight: 500; color: var(--ink);
  background: var(--surface-sunken);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
  padding: 10px 14px; cursor: pointer;
  transition: background-color 150ms ease, border-color 150ms ease;
}

.params { border-top: 1px solid var(--hairline); padding-top: 14px; }
.params summary {
  font-size: 13px; font-weight: 600; cursor: pointer; color: var(--ink-secondary);
  list-style: none;
}
.params summary::-webkit-details-marker { display: none; }
.params summary::before { content: "▸ "; color: var(--ink-tertiary); }
.params[open] summary::before { content: "▾ "; }
.params-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px; margin-top: 14px;
}
.params-grid label {
  display: flex; flex-direction: column; gap: 6px;
  font-size: 12.5px; font-weight: 500; color: var(--ink-secondary);
}
.params-grid input { padding: 9px 11px; font-variant-numeric: tabular-nums; }

/* --------------------------------------------------------------------------
   Results
   -------------------------------------------------------------------------- */

.result { display: flex; flex-direction: column; gap: 18px; }

.verdict-card { padding: 28px 26px 12px; }

.verdict-head { display: flex; align-items: center; gap: 26px; flex-wrap: wrap; }

.gauge { position: relative; width: 136px; height: 136px; flex: none; }
.gauge svg { width: 100%; height: 100%; transform: rotate(-90deg); }

.gauge-track { fill: none; stroke: #EDEEF2; stroke-width: 9; }

.gauge-fill {
  fill: none; stroke: var(--accent); stroke-width: 9; stroke-linecap: round;
  stroke-dasharray: 326.73; stroke-dashoffset: 326.73;
}
.gauge-fill[data-verdict="binder"] { stroke: var(--positive); }

.gauge-threshold {
  stroke: var(--ink-tertiary); stroke-width: 2; stroke-linecap: round;
  opacity: 0.5; transform-origin: 60px 60px;
}

.gauge-centre { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; gap: 1px; }

.gauge-number {
  font-size: 31px; font-weight: 600; letter-spacing: -0.034em;
  font-variant-numeric: tabular-nums; line-height: 1;
}
.gauge-unit { font-size: 15px; font-weight: 500; color: var(--ink-secondary); }

.delta { width: 136px; flex: none; display: flex; align-items: baseline; justify-content: center; gap: 2px; }
.delta-value {
  font-size: 40px; font-weight: 600; letter-spacing: -0.038em;
  font-variant-numeric: tabular-nums; color: var(--positive);
}
.delta-value[data-sign="down"] { color: var(--negative); }
.delta-unit { font-size: 18px; font-weight: 500; color: var(--ink-secondary); }

.verdict-text { min-width: 210px; flex: 1; }

.pill {
  display: inline-block; font-size: 11px; font-weight: 600;
  letter-spacing: 0.04em; text-transform: uppercase;
  padding: 4px 10px; border-radius: 100px;
  background: rgba(18,20,28,0.06); color: var(--ink-secondary); margin-bottom: 9px;
}
.pill[data-verdict="binder"] { background: var(--positive-wash); color: var(--positive); }
.pill[data-verdict="non-binder"] { background: var(--negative-wash); color: var(--negative); }

.verdict-text h2 {
  font-size: 20px; letter-spacing: -0.02em; line-height: 1.24;
  font-family: var(--mono); font-weight: 600; word-break: break-all;
}

.verdict-text p { margin: 7px 0 0; font-size: 13.5px; color: var(--ink-secondary); }

.metrics {
  margin: 22px 0 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(8.5rem, 1fr));
  gap: 0.75rem;
}

/* Tile per metric, matching BBB-TransAI and ToxBench. The hue is on the tile,
   its rule and its caption, never on the number: see metric() in app.js. */
.metric {
  --tone: #007aff;
  position: relative;
  display: block;
  padding: 13px 14px;
  border: 0;
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--tone) 9%, var(--tint-sunken));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--tone) 16%, transparent);
  overflow: hidden;
}
.metric::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: var(--tone);
  opacity: 0.85;
}
.metric-name {
  display: block;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.055em;
  font-weight: 650;
  color: color-mix(in srgb, var(--tone) 55%, var(--ink-secondary));
}
.metric-value {
  display: block;
  margin-top: 5px;
  font-size: 20px;
  font-weight: 650;
  letter-spacing: -0.018em;
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
  color: var(--ink);
  word-break: break-word;
}
/* Confidence is a category, not a measurement, so it keeps its traffic light. */
.metric-value[data-level="High"] { color: var(--positive); }
.metric-value[data-level="Medium"] { color: var(--caution); }
.metric-value[data-level="Low"] { color: var(--negative); }

.prose { font-size: 14.5px; line-height: 1.72; color: #3C3F45; }
.prose strong { color: var(--ink); font-weight: 600; }
.prose table { width: 100%; border-collapse: collapse; margin: 10px 0; font-size: 13px; }
.prose th, .prose td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--hairline); }
.prose th { font-weight: 600; color: var(--ink-secondary); }

img#shap, img#design-traj { width: 100%; height: auto; display: block; border-radius: var(--radius-sm); }

/* Tables */

.table-wrap { overflow-x: auto; margin: 0 -6px; padding: 0 6px; }

table.data { width: 100%; border-collapse: collapse; font-size: 13px; }

table.data th {
  text-align: left; font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.04em; color: var(--ink-tertiary);
  padding: 0 12px 9px 0; white-space: nowrap;
}

table.data td {
  padding: 11px 12px 11px 0; border-top: 1px solid var(--hairline);
  font-variant-numeric: tabular-nums; vertical-align: middle;
}

table.data td.seq { font-family: var(--mono); font-size: 12px; word-break: break-all; min-width: 200px; }
table.data td.num { text-align: right; font-weight: 600; white-space: nowrap; }

.bar {
  /* It is a <span>, and height/min-width do nothing on an inline box. */
  display: block;
  position: relative; height: 5px; border-radius: 100px;
  background: #EDEEF2; min-width: 56px; overflow: hidden;
}
.bar span {
  position: absolute; inset: 0 auto 0 0; border-radius: 100px;
  background: var(--accent); width: 0;
}
.bar[data-binder="true"] span { background: var(--positive); }

/* Mutations */

.mutations { display: flex; flex-direction: column; gap: 2px; }

.mutation {
  display: grid;
  grid-template-columns: 76px 1fr auto;
  align-items: center;
  gap: 14px;
  padding: 12px 0;
  border-top: 1px solid var(--hairline);
}
.mutation:first-child { border-top: none; }

.mutation-code {
  font-family: var(--mono); font-size: 14px; font-weight: 600;
  color: var(--accent); letter-spacing: -0.01em;
}
.mutation-gain {
  font-size: 13.5px; font-weight: 600; font-variant-numeric: tabular-nums;
  color: var(--positive); white-space: nowrap;
}

/* Chat */

.chat-card { padding: 0; overflow: hidden; display: flex; flex-direction: column; }
.chat { padding: 22px; display: flex; flex-direction: column; gap: 14px;
        min-height: 240px; max-height: 56dvh; overflow-y: auto; overflow-x: hidden; }

.chat-empty { margin: auto; text-align: center; color: var(--ink-tertiary); }
.chat-empty p { font-size: 13px; margin: 0 0 12px; }
.chat-empty .examples { justify-content: center; }

.bubble {
  max-width: 86%;
  /* a flex child will not shrink below its content without this, which is how
     a wide table pushed the bubble past the card edge */
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 14.5px; line-height: 1.65;
}
.bubble.user {
  align-self: flex-end;
  background: linear-gradient(var(--accent), var(--accent-deep));
  color: #fff; padding: 11px 15px; border-radius: 18px 18px 5px 18px;
  box-shadow: var(--shadow-accent);
}
.bubble.assistant {
  align-self: flex-start; color: #3C3F45;
  background: var(--surface-sunken); border: 1px solid var(--hairline);
  padding: 13px 16px; border-radius: 18px 18px 18px 5px;
}
.bubble.assistant .table-scroll {
  max-width: 100%; overflow-x: auto; margin: 8px 0;
  overscroll-behavior-x: contain; -webkit-overflow-scrolling: touch;
}
.bubble.assistant table { border-collapse: collapse; font-size: 12.5px; min-width: 100%; }
/* break-word, not anywhere: `anywhere` lets a column shrink to nothing and
   then hyphenates mid-word, which is how "Typical range" became "Typi/cal/ran/ge".
   break-word only breaks a word that cannot fit on a line by itself. */
.bubble.assistant td, .bubble.assistant th { overflow-wrap: break-word; }
.bubble.assistant th, .bubble.assistant td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--hairline); }

.typing { display: inline-flex; gap: 4px; align-items: center; }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--ink-tertiary); opacity: 0.4; }

.composer-bar {
  display: flex; gap: 10px; padding: 14px;
  border-top: 1px solid var(--hairline);
  background: rgba(250, 251, 252, 0.8);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}
#chat-input { border-radius: 100px; }

.send {
  flex: none; width: 42px; height: 42px; border-radius: 50%;
  border: none; cursor: pointer; color: #fff;
  background: linear-gradient(var(--accent), var(--accent-deep));
  box-shadow: var(--shadow-accent);
  display: grid; place-items: center;
}
.send svg { width: 19px; height: 19px; }
.send:disabled { opacity: 0.45; cursor: default; box-shadow: none; }

/* About */

.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.stat { padding: 20px; display: flex; flex-direction: column; gap: 3px; }
.stat-value { font-size: 27px; font-weight: 600; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.stat-label { font-size: 12.5px; color: var(--ink-tertiary); }

.target-cloud { display: flex; flex-wrap: wrap; gap: 6px; }
.target-chip {
  font-family: var(--mono); font-size: 12px; color: var(--ink-secondary);
  background: var(--surface-sunken); border: 1px solid var(--hairline);
  border-radius: 8px; padding: 5px 9px; cursor: pointer;
  transition: border-color 150ms ease, color 150ms ease;
}

.domain-scale { display: flex; gap: 8px; margin-top: 18px; }
.domain-band { flex: 1; display: flex; flex-direction: column; gap: 6px; }
.domain-band i { height: 5px; border-radius: 100px; display: block; }
.domain-band b { font-size: 12px; font-weight: 600; }
.domain-band span { font-size: 11.5px; color: var(--ink-tertiary); line-height: 1.45; }

.error-card { border-left: 3px solid var(--negative); }
.error-card h3 { font-size: 15px; margin-bottom: 5px; }
.error-card p { margin: 0; font-size: 13.5px; color: var(--ink-secondary); }

footer { padding-block: 0 44px; font-size: 12px; color: var(--ink-tertiary); }

/* --------------------------------------------------------------------------
   Target picker surface
   -------------------------------------------------------------------------- */

.scrim { position: fixed; inset: 0; z-index: 50; background: rgba(10, 12, 18, 0.26); opacity: 0; -webkit-tap-highlight-color: transparent; }

.sheet {
  position: fixed; z-index: 60;
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(32px) saturate(185%);
  -webkit-backdrop-filter: blur(32px) saturate(185%);
  box-shadow: var(--shadow-lifted);
  display: flex; flex-direction: column; overflow: hidden;
  border-top: 1px solid rgba(255, 255, 255, 0.65);
}

@media (max-width: 680px) {
  .sheet { left: 0; right: 0; bottom: 0; max-height: 78dvh; border-radius: 24px 24px 0 0; padding-bottom: env(safe-area-inset-bottom); }
  .sheet-grab { display: flex; }
}

@media (min-width: 681px) {
  .sheet {
    width: 340px; max-height: 380px; border-radius: var(--radius);
    border: 1px solid var(--hairline);
    /* Denser than the mobile sheet: this one floats over the saturated primary
       button, and a thinner material let that blue bleed behind the text. */
    background: rgba(255, 255, 255, 0.95);
  }
  .sheet-grab { display: none; }
}

.sheet-grab { justify-content: center; padding: 9px 0 3px; cursor: grab; touch-action: none; flex: none; }
.sheet-grab:active { cursor: grabbing; }
.sheet-grab span { width: 38px; height: 5px; border-radius: 100px; background: rgba(18,20,28,0.18); }

.sheet-head { padding: 10px 14px; flex: none; }
.sheet-head h3 { font-size: 12.5px; color: var(--ink-secondary); margin-bottom: 8px; }

#target-search {
  font: inherit; font-size: 14px; width: 100%; padding: 9px 12px;
  border: 1px solid var(--hairline); border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.9); color: var(--ink);
  -webkit-appearance: none; appearance: none;
}
#target-search:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-wash); }

.sheet-list { overflow-y: auto; overscroll-behavior: contain; padding: 4px 8px 10px; -webkit-overflow-scrolling: touch; }

.option {
  font: inherit; font-family: var(--mono); font-size: 13.5px; color: var(--ink);
  background: none; border: none; border-radius: var(--radius-sm);
  padding: 10px 11px; width: 100%; text-align: left; cursor: pointer;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  transition: background-color 110ms ease;
}
.option[aria-selected="true"] { color: var(--accent); font-weight: 600; }
.option-check { width: 13px; height: 13px; flex: none; opacity: 0; }
.option[aria-selected="true"] .option-check { opacity: 1; }
.option-empty { padding: 14px 11px; font-size: 13px; color: var(--ink-tertiary); font-family: var(--font); }

/* --------------------------------------------------------------------------
   Preferences
   -------------------------------------------------------------------------- */

@media (prefers-reduced-transparency: reduce) {
  .chrome, .composer-bar { background: var(--bg); backdrop-filter: none; -webkit-backdrop-filter: none; }
  .sheet { background: var(--surface); backdrop-filter: none; -webkit-backdrop-filter: none; }
  .aurora { display: none; }
}

@media (prefers-contrast: more) {
  :root { --hairline: rgba(18,20,28,0.3); --ink-secondary: #3C3F45; --ink-tertiary: #55585F; }
  .sheet { background: var(--surface); border: 1px solid var(--hairline-strong); }
  .card::before, .run::before { display: none; }
  .aurora { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .run[data-busy="true"] .run-progress { animation: none; opacity: 0.18; transform: none; }
  * { scroll-behavior: auto !important; }
}

/* --------------------------------------------------------------------------
   PDF export
   -------------------------------------------------------------------------- */

.card-actions {
  display: flex; justify-content: flex-end; gap: 8px;
  margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--hairline);
}

.card-head .export { margin-left: auto; }

.export {
  display: inline-flex; align-items: center; gap: 7px;
  font: inherit; font-size: 12.5px; font-weight: 600; letter-spacing: -0.004em;
  color: var(--ink-secondary);
  background: var(--surface-sunken);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
  padding: 8px 13px; cursor: pointer;
  transition: color 150ms ease, border-color 150ms ease, background-color 150ms ease;
}

.export svg { width: 14px; height: 14px; flex: none; }
.export:disabled { opacity: 0.55; cursor: progress; }
.export:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-wash); }

/* ===========================================================================
   Per-tab colour identity
   ===========================================================================
   Each section carries its own hue, the way Apple colour-codes the panes of
   Settings or Health. The accent drives the primary button, the gauge, focus
   rings and the background wash, so a tab is recognisable before you read it.
   The brand mark keeps its own fixed colour and does not follow the tab. */

:root { --brand: #0A6CFF; }

body[data-tab="batch"] {
  --accent: #5E5CE6; --accent-deep: #4341C4; --accent-wash: rgba(94, 92, 230, 0.1);
}
body[data-tab="mutate"] {
  --accent: #E8590C; --accent-deep: #C2410C; --accent-wash: rgba(232, 89, 12, 0.1);
}
body[data-tab="design"] {
  --accent: #0D9488; --accent-deep: #0B7A70; --accent-wash: rgba(13, 148, 136, 0.1);
}
body[data-tab="assistant"] {
  --accent: #9333EA; --accent-deep: #7A28C4; --accent-wash: rgba(147, 51, 234, 0.1);
}
body[data-tab="about"] {
  --accent: #52525B; --accent-deep: #3F3F46; --accent-wash: rgba(82, 82, 91, 0.1);
}

/* The accent moves between tabs, so everything keyed to it needs to ease
   rather than snap. These are discrete state changes, not gesture-driven, so a
   transition is the right tool here. */
.run, .send, .bubble.user, .segmented-indicator, .aurora {
  transition: background-color 420ms ease, background-image 420ms ease,
              box-shadow 420ms ease, opacity 420ms ease;
}

.mark { color: var(--brand); }

/* Background wash picks up the tab hue */
/* The per-tab accent is now the first layer of the single .aurora rule near
   the top of this file, so it composites over the family wash instead of
   replacing it. Two later rules used to re-declare `background` wholesale and
   the last one silently won. */

/* Tab icons */

.segmented button { display: inline-flex; align-items: center; gap: 6px; }
.tab-icon { width: 14px; height: 14px; flex: none; opacity: 0.55; transition: opacity 180ms ease; }
.segmented button[aria-selected="true"] .tab-icon { opacity: 1; color: var(--accent); }

@media (max-width: 620px) {
  /* Labels stay. Six icons alone are a guessing game, so the bar scrolls
     sideways instead -- the standard phone pattern -- and app.js keeps the
     selected tab in view. */
  .segmented button { padding: 7px 11px; font-size: 12.5px; gap: 5px; }
  .tab-icon { width: 14px; height: 14px; }
  /* The strip is widened past the shell so the row can reach the screen edges
     and a half-visible tab signals there is more. `clip` on the parent keeps
     that overflow from becoming a horizontal scrollbar on the whole page,
     without turning .tabs into a scroll container itself. */
  .tabs { overflow-x: clip; }
  .tabs-inner {
    margin-inline: -16px; padding-inline: 16px;
    scroll-padding-inline: 16px;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
  }
  .segmented { scroll-snap-type: x proximity; }
  .segmented button { scroll-snap-align: center; }
}

/* ===========================================================================
   Residue-coloured sequence
   ===========================================================================
   Coloured by side-chain chemistry, which is the axis the model's
   physicochemical features actually run along -- so the colour says something
   rather than just decorating. */

.seqview {
  display: flex; flex-wrap: wrap;
  /* Row gap must clear the position tick, which is drawn 12px above its own
     row. With a single `gap: 2px` the tick on a wrapped row landed on top of
     the residues above it. Column and row gaps are therefore separate. */
  column-gap: 2px;
  row-gap: 17px;
  font-family: var(--mono); font-size: 12.5px; line-height: 1;
}

.res {
  width: 19px; height: 23px;
  display: grid; place-items: center;
  border-radius: 5px;
  font-weight: 600;
  position: relative;
}

.res[data-class="hydrophobic"] { background: rgba(255, 149, 10, 0.16); color: #B45309; }
.res[data-class="polar"]       { background: rgba(16, 163, 127, 0.15); color: #0F766E; }
.res[data-class="positive"]    { background: rgba(10, 132, 255, 0.15); color: #1D4ED8; }
.res[data-class="negative"]    { background: rgba(255, 55, 95, 0.14);  color: #BE123C; }
.res[data-class="special"]     { background: rgba(175, 82, 222, 0.15); color: #7E22CE; }

/* A tick every tenth residue, so positions can be counted off the view */
.res[data-tick]::after {
  content: attr(data-tick);
  position: absolute; top: -12px; left: 50%; transform: translateX(-50%);
  font-size: 8.5px; font-weight: 500; color: var(--ink-tertiary);
}

.seqview-wrap { padding-top: 13px; }

.legend { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 16px;
          padding-top: 13px; border-top: 1px solid var(--hairline); }
.legend span { display: inline-flex; align-items: center; gap: 6px;
               font-size: 11.5px; color: var(--ink-secondary); }
.legend i { width: 10px; height: 10px; border-radius: 3px; flex: none; }

/* About stat cards, one hue each */

.stat { border-top: 3px solid var(--stat-hue, var(--accent)); }
.stat-value { color: var(--stat-hue, var(--ink)); }
.stat:nth-child(1) { --stat-hue: #0A6CFF; }
.stat:nth-child(2) { --stat-hue: #0D9488; }
.stat:nth-child(3) { --stat-hue: #9333EA; }
.stat:nth-child(4) { --stat-hue: #E8590C; }

/* ===========================================================================
   Tinted neutrals
   ===========================================================================
   Rather than colouring controls and leaving everything else grey, the whole
   neutral ramp is mixed with a few percent of the tab accent: canvas, card
   surfaces, sunken fields, hairlines, secondary text and even the shadows.

   The mixes are deliberately tiny (1.5-5%). At that strength you do not read
   it as "a blue page", you read it as a page that feels different from the
   next tab. Data values stay neutral ink on purpose - a number that changes
   colour between tabs would imply something about the number.             */

/* Declared on `body`, not `:root`: the accent override lives on
   `body[data-tab=...]`, and a custom property declared on :root resolves
   against :root's own --accent -- so the tints would never move off blue. */
body {
  --tint-canvas:  color-mix(in srgb, var(--accent) 5%,   #F7F8FA);
  /* Translucent, not solid white: an opaque card would hide the wash behind it
     and the page would go back to looking flat everywhere a card sits - which
     is most of it. The blur goes on .card below. */
  --tint-surface: color-mix(in srgb, var(--accent) 2%, rgba(255, 255, 255, 0.72));
  --tint-sunken:  color-mix(in srgb, var(--accent) 4.5%, #FAFBFC);
  --tint-line:    color-mix(in srgb, var(--accent) 18%,  rgba(18, 20, 28, 0.07));
  --tint-line-2:  color-mix(in srgb, var(--accent) 20%,  rgba(18, 20, 28, 0.13));
  --tint-soft:    color-mix(in srgb, var(--accent) 26%,  #93969E);
  --tint-shadow:  color-mix(in srgb, var(--accent) 22%,  rgba(18, 20, 28, 1));

  /* The primary button's glow was hardcoded blue, so an orange button sat on a
     blue shadow. Derived from the accent instead. */
  --shadow-accent:
    0 1px 2px color-mix(in srgb, var(--accent-deep) 24%, transparent),
    0 8px 20px -6px color-mix(in srgb, var(--accent) 40%, transparent);
}

body {
  background: var(--tint-canvas);
  transition: background-color 420ms ease;
}

.chrome {
  background: color-mix(in srgb, var(--accent) 5%, rgba(247, 248, 250, 0.72));
  border-bottom-color: var(--tint-line);
}

.card, .sheet {
  background: var(--tint-surface);
  /* Safe here: #scrim and #sheet are top-level siblings, not descendants of a
     card. A backdrop-filter creates a containing block for fixed children, so
     a fixed element inside a card would be trapped and stop covering the
     viewport. Check that again before adding this to any other container. */
  -webkit-backdrop-filter: saturate(170%) blur(26px);
  backdrop-filter: saturate(170%) blur(26px);
  box-shadow:
    0 0 0 1px color-mix(in srgb, var(--tint-shadow) 5%, transparent),
    0 1px 2px color-mix(in srgb, var(--tint-shadow) 5%, transparent),
    0 10px 28px -12px color-mix(in srgb, var(--tint-shadow) 16%, transparent);
}

/* Sunken surfaces: fields, chips, secondary buttons */
textarea, .picker, .ghost, .export, .example, .target-chip,
.stepper input, #chat-input, .params input, .bubble.assistant {
  background: var(--tint-sunken);
  border-color: var(--tint-line);
}


/* Every hairline follows the tab */
.metric, .card-actions, .legend, .params, .mutation,
table.data td, .composer-bar, .sheet-head + .sheet-list,
.sizes, .segmented { border-color: var(--tint-line); }

table.data th { border-bottom-color: var(--tint-line-2); }

.segmented { background: color-mix(in srgb, var(--accent) 9%, rgba(18, 20, 28, 0.045)); }

/* Secondary text picks up a trace of the hue; primary ink stays neutral so
   the actual numbers never shift colour. */
.muted, .hint, .counter[data-state="empty"], .wordmark-sub,
.example-meta, .stat-label, footer, .legend span, figcaption,
table.data th, .sheet-head h3 { color: var(--tint-soft); }

.gauge-track, .bar { background: color-mix(in srgb, var(--accent) 10%, #EDEEF2); }
.gauge-track { stroke: color-mix(in srgb, var(--accent) 10%, #EDEEF2); fill: none; }

.pill { background: color-mix(in srgb, var(--accent) 10%, rgba(18, 20, 28, 0.05)); }

/* The tab's own hue, raised a little so switching tabs still reads as a change
   of colour. --accent-strength is consumed by the .aurora rule at the top of
   the file; redeclaring `background` here would throw the family wash away. */
.aurora { --accent-strength: 20%; }

/* Reduced transparency / high contrast want the tint gone, not just the blur */
@media (prefers-reduced-transparency: reduce) {
  .chrome { background: var(--tint-canvas); }
}

@media (prefers-contrast: more) {
  body {
    --tint-canvas: #FFFFFF; --tint-surface: #FFFFFF; --tint-sunken: #F4F4F6;
    --tint-line: rgba(18, 20, 28, 0.3); --tint-line-2: rgba(18, 20, 28, 0.4);
    --tint-soft: #55585F;
  }
}

/* ===========================================================================
   Mutation scan progress
   ===========================================================================
   The scan is the slowest operation in the app, so it gets a representation of
   the work rather than a spinner: the sequence itself, with a highlight walking
   it position by position. The counts and the elapsed clock are real. The sweep
   is paced from a measured per-residue rate and is a visualisation, not a
   reading of server state -- so it never claims to be finished, it eases to a
   hold just short of the end and waits for the actual response. */

.scanning .seqview .res {
  opacity: 0.32;
  transition: opacity 140ms ease, transform 140ms ease;
}

.scanning .seqview .res[data-scanning] {
  opacity: 1;
  transform: translateY(-2px) scale(1.08);
  box-shadow: 0 2px 8px -2px rgba(18, 20, 28, 0.22);
}

.scanning .seqview .res[data-done] { opacity: 0.85; }

.scan-foot {
  display: flex; align-items: center; gap: 14px;
  margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--tint-line);
}

.scan-bar {
  flex: 1; height: 4px; border-radius: 100px; overflow: hidden;
  background: color-mix(in srgb, var(--accent) 14%, #EDEEF2);
}

.scan-bar span {
  display: block; height: 100%; width: 0; border-radius: 100px;
  background: linear-gradient(90deg, var(--accent), var(--accent-deep));
}

.scan-time {
  font-size: 12.5px; font-variant-numeric: tabular-nums; color: var(--ink-secondary);
  min-width: 46px; text-align: right;
}

/* Reduced motion: keep the information, drop the travel. */
@media (prefers-reduced-motion: reduce) {
  .scanning .seqview .res { opacity: 0.6; transition: none; }
  .scanning .seqview .res[data-scanning] { transform: none; opacity: 1; }
}

/* Run time, shown in Korean time so the screen and the exported report agree. */
.ran-at { margin: 4px 0 0; font-size: 12px; color: var(--tint-soft); }

/* ===========================================================================
   Progress visuals, one per tab
   ===========================================================================
   Each shows the shape of the work that tab is doing rather than a generic
   spinner. Counts and elapsed time are real; the pacing is an estimate, which
   is why every bar holds short of full until the response actually lands. */

/* Prediction: the pipeline, stage by stage */
.stages { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 16px; }

.stage {
  font-size: 11.5px; font-weight: 500;
  color: var(--tint-soft);
  background: var(--tint-sunken);
  border: 1px solid var(--tint-line);
  border-radius: 100px; padding: 5px 11px;
  display: inline-flex; align-items: center; gap: 6px;
  transition: color 220ms ease, border-color 220ms ease, background-color 220ms ease;
}

.stage::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%;
  background: currentColor; opacity: 0.4;
  transition: opacity 220ms ease, transform 220ms ease;
}

.stage[data-state="active"] {
  color: var(--accent); border-color: var(--accent);
  background: var(--accent-wash); font-weight: 600;
}
.stage[data-state="active"]::before { opacity: 1; transform: scale(1.3); }
.stage[data-state="done"] { color: var(--positive); border-color: transparent; }
.stage[data-state="done"]::before { opacity: 1; }

/* Batch: a queue of candidates */
.queue { display: flex; flex-direction: column; gap: 6px; }

.queue-row {
  position: relative; overflow: hidden;
  display: flex; align-items: center; gap: 12px;
  padding: 8px 10px; border-radius: var(--radius-sm);
  background: var(--tint-sunken);
  /* opacity is driven per frame, so no transition here: a CSS transition would
     fight the animation loop and produce the stepping it is meant to remove */
}

/* Continuous fill behind the row. scaleX on a composited layer rather than an
   animated width, so it never triggers layout. */
.queue-fill {
  position: absolute; inset: 0; transform-origin: left center; transform: scaleX(0);
  background: var(--accent-wash);
  will-change: transform;
}

/* A soft sheen travelling across whichever row is being worked. */
.queue-row[data-state="active"]::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(100deg, transparent 20%,
              color-mix(in srgb, var(--accent) 16%, transparent) 50%, transparent 80%);
  animation: queue-sheen 1.1s linear infinite;
}

@keyframes queue-sheen {
  from { transform: translateX(-100%); }
  to   { transform: translateX(100%); }
}

@media (prefers-reduced-motion: reduce) {
  .queue-row[data-state="active"]::after { animation: none; }
}

.queue-row .seq {
  font-family: var(--mono); font-size: 11.5px; color: var(--ink-secondary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1;
}
.queue-row .tick { width: 13px; height: 13px; flex: none; opacity: 0; color: var(--positive); }
.queue-row[data-state="done"] .tick { opacity: 1; }

/* Design: a population under selection */
.population {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(26px, 1fr));
  gap: 5px;
}

.individual {
  height: 26px; border-radius: 6px;
  background: color-mix(in srgb, var(--accent) 16%, var(--tint-sunken));
  display: grid; place-items: center;
  font-family: var(--mono); font-size: 11px; font-weight: 600;
  color: color-mix(in srgb, var(--accent) 70%, var(--ink));
  transition: background-color 260ms ease, transform 260ms ease;
}
.individual[data-elite] {
  background: var(--accent); color: #fff; transform: translateY(-2px) scale(1.06);
}

@media (prefers-reduced-motion: reduce) {
  .individual, .stage, .queue-row { transition: none; }
  .individual[data-elite] { transform: none; }
}

/* The secondary button was shrinking inside the flex row until its label wrapped
   to three lines and collided with the picker beside it. It should keep its
   intrinsic width and let the picker take whatever is left. */
.row .ghost { flex: 0 0 auto; white-space: nowrap; }
.row .stepper { flex: 0 0 auto; white-space: nowrap; }
.row .picker.compact { flex: 1 1 190px; min-width: 0; }
.row .picker.compact .picker-value { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Imputed-feature notice. Amber rather than red: the prediction is valid, but a
   reader who sees "ESMFold pLDDT" among the drivers must know it was not
   measured for their sequence. */
.imputed-note {
  margin: 14px 0 0; padding: 10px 12px;
  font-size: 12.5px; line-height: 1.5; color: #6B4A08;
  background: rgba(232, 149, 12, 0.09);
  border-left: 2px solid var(--caution);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.imputed-note code {
  font-family: var(--mono); font-size: 11.5px;
  background: rgba(232, 149, 12, 0.14); padding: 1px 5px; border-radius: 4px;
}


/* ===========================================================================
   Mobile
   ===========================================================================
   Touch has no hover, so a browser fakes one: the first tap applies :hover and
   leaves it stuck until the user taps elsewhere. Every hover style therefore
   lives behind a capability query. Both conditions matter -- (hover: hover)
   means the primary input can hover, (pointer: fine) rules out styluses and
   Android devices that claim hover support. Touch users get :active instead. */
@media (hover: hover) and (pointer: fine) {
  .example:hover { background: var(--surface); border-color: var(--hairline-strong); }
  .picker:hover { border-color: var(--hairline-strong); background: var(--surface); }
  .run:hover { filter: saturate(1.08) brightness(1.04); }
  .ghost:hover { background: var(--surface); border-color: var(--hairline-strong); }
  .target-chip:hover { color: var(--accent); border-color: var(--accent); }
  .option:hover { background: rgba(18,20,28,0.045); }
  .export:hover { color: var(--accent); border-color: var(--accent); background: var(--surface); }
  .picker:hover, .ghost:hover, .example:hover, .export:hover { border-color: var(--tint-line-2); }
}

/* The browser paints a grey box over anything tappable. It is the loudest
   "this is a website" tell, and it fights the press feedback we already draw. */
html { -webkit-tap-highlight-color: transparent; }

/* Pull-to-refresh and the whole-page rubber band belong to documents, not to an
   app with its own scrolling panes. `contain` on the inner panes keeps their own
   bounce but stops the page behind them moving. */
html, body { overscroll-behavior: none; }
.chat, .sheet-list, .table-wrap { overscroll-behavior: contain; }

/* Controls: fire click immediately rather than waiting out the double-tap-zoom
   delay, and stop a long press selecting a button's label or popping the iOS
   callout. Never on body -- users copy sequences and error messages. */
button, a, [role="button"], .example, .target-chip, .res, .segmented button {
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

/* The sequence itself is content, not a control: it must stay selectable. */
textarea, .seqbox, .prose, .body, table.data td, .mono, #seqview {
  user-select: text;
  -webkit-user-select: text;
}

/* iOS zooms the page when focus lands on an input under 16px and does not zoom
   back out. Fixing the font size is the fix; disabling zoom is not. Scoped to
   coarse pointers so desktop typography is untouched. */
@media (pointer: coarse) {
  textarea, input, select, #chat-input, #target-search,
  .stepper input, .params input { font-size: 16px; }
  /* the picker is a button, not an input, but it sits in the same row */
  .picker-value { font-size: 14px; }
}

/* Press feedback for touch, where :hover never fires. The spring engine already
   scales these on pointerdown; this covers the rest. */
.example:active, .ghost:active, .export:active, .target-chip:active,
.option:active, .segmented button:active { opacity: 0.72; }

/* Safe areas. viewport-fit=cover lets the page under the notch; env() pads the
   content back out. Without the meta tag these all resolve to 0px. */
.chrome { padding-top: env(safe-area-inset-top, 0px); }
main, footer { padding-left: max(20px, env(safe-area-inset-left, 0px));
               padding-right: max(20px, env(safe-area-inset-right, 0px)); }
.composer-bar { padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px)); }

@media (max-width: 680px) {
  /* Phone layout: tighter gutters, and the hero stops shouting. */
  .shell { padding-inline: 16px; }
  .hero { padding-top: 18px; }
  .hero h1 { font-size: clamp(26px, 7.6vw, 34px); }
  .hero p { font-size: 15px; }
  .card { padding: 18px; border-radius: 20px; }
  .verdict-card { padding: 20px 18px 8px; }
  .verdict-head { gap: 18px; }
  .metrics { grid-template-columns: 1fr; gap: 0; }
  .card-head { flex-wrap: wrap; }
  .stat-row { grid-template-columns: repeat(2, 1fr); }
  .domain-scale { flex-direction: column; gap: 12px; }
  /* a 24-item target list is a wall on a phone */
  .sheet-list { max-height: 60svh; }
}


/* ===========================================================================
   Status indicator
   ===========================================================================
   One 16px glyph that changes state rather than a dot that changes colour:
   a resting dot, an arc that orbits while work is in flight, and a tick or a
   cross that draws itself on the result. The tick is a stroke being drawn, not
   an icon being swapped, so the transition carries from one state to the next.
   Everything animates transform / stroke-dashoffset / opacity only. */

.status-icon { width: 16px; height: 16px; flex: none; display: block; }
.status-icon svg { width: 100%; height: 100%; overflow: visible; }

.status-icon circle, .status-icon path {
  fill: none;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: opacity 240ms ease, stroke 240ms ease;
}

.s-track { stroke: currentColor; opacity: 0; }
.s-arc   { stroke: currentColor; opacity: 0;
           stroke-dasharray: 10 28; transform-origin: 8px 8px; }
.s-dot   { fill: currentColor; stroke: none; opacity: 1;
           transform-origin: 8px 8px; transition: opacity 200ms ease, transform 320ms var(--spring, cubic-bezier(.34,1.3,.5,1)); }

/* 37.7 is the circumference at r=6; the tick and cross are drawn from nothing */
.s-check { stroke: currentColor; stroke-dasharray: 11; stroke-dashoffset: 11; opacity: 0; }
.s-cross { stroke: currentColor; stroke-dasharray: 15; stroke-dashoffset: 15; opacity: 0; }

.status { color: var(--tint-soft); transition: color 260ms ease; }

/* idle: just the dot */
.status[data-state="idle"] .s-dot { opacity: 1; transform: scale(1); }

/* busy: the dot shrinks away and an arc orbits */
.status[data-state="busy"] { color: var(--accent); }
.status[data-state="busy"] .s-dot { opacity: 0; transform: scale(0.3); }
.status[data-state="busy"] .s-track { opacity: 0.22; }
.status[data-state="busy"] .s-arc {
  opacity: 1;
  animation: status-orbit 900ms linear infinite;
}

@keyframes status-orbit { to { transform: rotate(360deg); } }

/* done: the arc completes, then the tick draws */
.status[data-state="done"] { color: var(--positive); }
.status[data-state="done"] .s-dot { opacity: 0; transform: scale(0.3); }
.status[data-state="done"] .s-track { opacity: 0.22; }
.status[data-state="done"] .s-check {
  opacity: 1; stroke-dashoffset: 0;
  transition: stroke-dashoffset 420ms cubic-bezier(.2,.8,.3,1) 60ms, opacity 120ms ease;
}

/* error: same idea, drawn as a cross */
.status[data-state="error"] { color: var(--negative); }
.status[data-state="error"] .s-dot { opacity: 0; transform: scale(0.3); }
.status[data-state="error"] .s-track { opacity: 0.22; }
.status[data-state="error"] .s-cross {
  opacity: 1; stroke-dashoffset: 0;
  transition: stroke-dashoffset 300ms cubic-bezier(.2,.8,.3,1), opacity 120ms ease;
}

/* The label swaps with a short rise so the two read as one change. */
.status-text { display: inline-block; }
.status-text.swapping { opacity: 0; transform: translateY(3px); }
.status-text { transition: opacity 160ms ease, transform 160ms ease; }

@media (prefers-reduced-motion: reduce) {
  .status[data-state="busy"] .s-arc { animation: none; opacity: 0.8; }
  .status-icon circle, .status-icon path, .status-text { transition: none; }
  .s-check, .s-cross { transition: none !important; }
}


/* iOS Safari gives any <button> its accent colour unless one is set. Every
   control here inherits deliberately; the two filled buttons keep white. */
button { color: inherit; }
.run, .run-label, .send { color: #fff; }

@media (max-width: 680px) {
  /* Two even columns on a phone, and long names wrap rather than being clipped. */
  .examples { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }
  .example { padding: 9px 11px; }
  .example-name { font-size: 12px; line-height: 1.3; }
  .example-meta { font-size: 10px; word-break: break-all; }
  /* The chat suggestions read better full width than squeezed into two. */
  #chat-suggestions { grid-template-columns: 1fr; }
}


@media (max-width: 680px) {
  /* Reading room: a 14% gutter is a lot of wasted width on a phone. */
  .chat { padding: 14px; }
  .bubble { max-width: 94%; font-size: 14px; }
  .bubble.assistant { padding: 11px 13px; }
  .bubble.assistant table { font-size: 11.5px; }
  .bubble.assistant td, .bubble.assistant th { padding: 5px 7px; }
}


@media (max-width: 680px) {
  /* A two-column definition table has nowhere to go at 390px: the prose column
     wins and the label column is crushed. Stack each row instead -- label above
     value -- which is how the same content reads on a phone anyway. */
  .bubble.assistant .table-scroll { overflow-x: visible; }
  .bubble.assistant table,
  .bubble.assistant tbody,
  .bubble.assistant tr,
  .bubble.assistant td { display: block; width: auto; min-width: 0; }
  .bubble.assistant thead { display: none; }
  .bubble.assistant tr {
    padding: 9px 0;
    border-bottom: 1px solid var(--hairline);
  }
  .bubble.assistant tr:last-child { border-bottom: none; }
  .bubble.assistant td { padding: 0; border: none; }
  .bubble.assistant td:first-child {
    font-weight: 600; color: var(--ink); margin-bottom: 3px;
  }
}

/* --------------------------------------------------------------------------
   matching BBB-TransAI and ToxBench: buttons and coloured fills
   --------------------------------------------------------------------------
   Pill buttons with a diagonal multi-hue gradient and an instant press, as in
   the other two apps. The tab's accent stays in the middle stop, so the button
   still changes hue between tabs - that is this app's own idea and worth
   keeping; what it gains is the depth a single flat colour never has. */

.run {
  border-radius: var(--radius-pill);
  background: linear-gradient(118deg,
      color-mix(in srgb, var(--accent) 62%, #5856d6) 0%,
      var(--accent) 52%,
      color-mix(in srgb, var(--accent) 58%, #1d9bd8) 100%);
  transition: transform 100ms var(--ease-out), filter 160ms ease;
  will-change: transform;
}
/* Feedback on the press, not the release. */
.run:active:not([disabled]) { transform: scale(0.972); }
.run[disabled] { cursor: default; opacity: 0.55; transform: none; }
@media (hover: hover) and (pointer: fine) {
  .run:hover:not([disabled]) { filter: brightness(1.06); }
}

/* Secondary buttons: pill, quiet, same press. Hover is gated because on a
   touch screen it sticks after a tap. */
.ghost, .export, .picker, .segmented button {
  border-radius: var(--radius-pill);
  transition: transform 100ms var(--ease-out), background-color 150ms ease,
              border-color 150ms ease, color 150ms ease;
}
.ghost:active, .export:active { transform: scale(0.972); }
@media (hover: hover) and (pointer: fine) {
  .ghost:hover, .export:hover { color: var(--ink); }
}

/* Colour on the moving parts. These animated fills were a single flat accent;
   a gradient gives the motion something to reveal. */
.bar span, .queue-fill, .shap-fill {
  background-image: linear-gradient(90deg,
      color-mix(in srgb, var(--accent) 70%, #5856d6) 0%,
      var(--accent) 60%,
      color-mix(in srgb, var(--accent) 62%, #1d9bd8) 100%);
}
.shap-row[data-sign="neg"] .shap-fill {
  background-image: linear-gradient(270deg,
      color-mix(in srgb, var(--negative) 76%, #ff9500) 0%,
      var(--negative) 70%);
}
.queue-fill { opacity: 0.28; }

/* --------------------------------------------------------------------------
   the AI cards' prose, and the design population
   --------------------------------------------------------------------------
   Colour inside the model-written cards only. It marks a passage as
   interpretation rather than measurement, and it is scoped to .prose inside
   those four cards so it can never reach a measured number elsewhere. */

#analysis-card .prose,
#batch-summary-card .prose,
#mutate-advice-card .prose,
#design-analysis-card .prose { color: #3A3D47; }

#analysis-card .prose h1, #analysis-card .prose h2,
#analysis-card .prose h3, #analysis-card .prose h4,
#batch-summary-card .prose h1, #batch-summary-card .prose h2,
#batch-summary-card .prose h3, #batch-summary-card .prose h4,
#mutate-advice-card .prose h1, #mutate-advice-card .prose h2,
#mutate-advice-card .prose h3, #mutate-advice-card .prose h4,
#design-analysis-card .prose h1, #design-analysis-card .prose h2,
#design-analysis-card .prose h3, #design-analysis-card .prose h4 {
  background: linear-gradient(104deg, #5856d6 0%, #af52de 46%, #1d9bd8 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
  font-size: 14px;
  letter-spacing: -0.008em;
  margin: 16px 0 6px;
}

/* Bold carries the finding, so it takes the tab's accent rather than plain
   black; inline code is a feature name, so it gets its own tint. */
#analysis-card .prose strong,
#batch-summary-card .prose strong,
#mutate-advice-card .prose strong,
#design-analysis-card .prose strong {
  color: color-mix(in srgb, var(--accent) 72%, var(--ink));
  font-weight: 650;
}
#analysis-card .prose code,
#batch-summary-card .prose code,
#mutate-advice-card .prose code,
#design-analysis-card .prose code {
  font-family: var(--mono);
  font-size: 0.86em;
  padding: 1px 6px;
  border-radius: 6px;
  background: color-mix(in srgb, #af52de 11%, transparent);
  color: #7A3FA8;
}
/* The bullet itself, not the text after it. */
#analysis-card .prose li::marker,
#batch-summary-card .prose li::marker,
#mutate-advice-card .prose li::marker,
#design-analysis-card .prose li::marker { color: #af52de; }

/* The design population was one hue at two strengths, which read as a grey
   mosaic next to the rest of the app. Each cell now takes a colour from the
   family palette by position, so a generation looks like a population rather
   than a progress bar in squares. The elite still separates itself by lifting
   and going solid, so the colour never carries the meaning on its own. */
.individual:nth-child(6n+1) { --ind: #5856d6; }
.individual:nth-child(6n+2) { --ind: #1d9bd8; }
.individual:nth-child(6n+3) { --ind: #00a99d; }
.individual:nth-child(6n+4) { --ind: #af52de; }
.individual:nth-child(6n+5) { --ind: #ff9500; }
.individual:nth-child(6n)   { --ind: #34c759; }
.individual {
  --ind: var(--accent);
  background: color-mix(in srgb, var(--ind) 20%, var(--tint-sunken));
  color: color-mix(in srgb, var(--ind) 72%, var(--ink));
}
.individual[data-elite] {
  background: linear-gradient(135deg,
      color-mix(in srgb, var(--ind) 86%, #ffffff) 0%, var(--ind) 100%);
  color: #fff;
  box-shadow: 0 4px 12px -4px color-mix(in srgb, var(--ind) 60%, transparent);
}

/* The model writes its section labels as a paragraph holding nothing but bold
   text - <p><strong>Mechanistic Interpretation</strong></p> - rather than as a
   markdown heading, so the h1-h4 rule above never matched anything. This is
   what it actually emits. `:only-child` keeps inline bold inside a sentence on
   the accent colour and lifts only a label standing on its own line. */
#analysis-card .prose p > strong:only-child,
#batch-summary-card .prose p > strong:only-child,
#mutate-advice-card .prose p > strong:only-child,
#design-analysis-card .prose p > strong:only-child {
  display: inline-block;
  margin-top: 4px;
  font-size: 13.5px;
  font-weight: 700;
  letter-spacing: 0.01em;
  background: linear-gradient(104deg, #5856d6 0%, #af52de 46%, #1d9bd8 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
}
@media (prefers-contrast: more) {
  #analysis-card .prose p > strong:only-child,
  #batch-summary-card .prose p > strong:only-child,
  #mutate-advice-card .prose p > strong:only-child,
  #design-analysis-card .prose p > strong:only-child {
    background: none;
    color: var(--ink);
    -webkit-text-fill-color: var(--ink);
  }
}

/* --------------------------------------------------------------------------
   measured against BBB-TransAI
   --------------------------------------------------------------------------
   These are the differences left after comparing computed styles of the two
   apps side by side at the same width, rather than by eye. */

/* The lede was 15.5px in a 468px column against BBB's 19px in 693px, which is
   what made this page read as the smaller, denser one even once the headline
   and body matched. */
.hero p {
  font-size: 19px;
  line-height: 1.5;
  color: #3C3C44;
  max-width: 44rem;
}

/* radius 22 not 24, padding 28 not 26, and the hairline edge BBB puts on every
   card - without it a translucent card has no defined boundary where it
   crosses a pale part of the wash. */
.card {
  border-radius: 22px;
  padding: 28px;
  border: 1px solid rgba(0, 0, 0, 0.055);
}

/* BBB's canvas is a neutral #f2f2f4; this one mixed the accent into a bluer
   #F7F8FA, so the two pages sat at different temperatures. */
body { --tint-canvas: color-mix(in srgb, var(--accent) 4%, #F2F2F4); }

/* ===========================================================================
   Dark
   ===========================================================================
   The attribute is set by an inline script in <head> from
   prefers-color-scheme, so everything dark lives under one selector rather
   than being written once for the attribute and once for a media query.

   The tint system mixes the tab accent into hardcoded LIGHT bases - #FFFFFF,
   #FAFBFC, rgba(18,20,28,...). Overriding the plain tokens alone would leave
   every card and field still mixing toward white, so the tint variables are
   redefined here too, against dark bases. That is the part a naive dark mode
   misses. */

:root[data-theme="dark"] {
  color-scheme: dark;

  --bg: #000000;
  --surface: rgba(28, 28, 30, 0.68);
  --surface-sunken: rgba(120, 120, 128, 0.18);

  --ink: #F5F5F7;
  --ink-secondary: #B6B6BD;
  --ink-tertiary: #97979F;

  --hairline: rgba(255, 255, 255, 0.07);
  --hairline-strong: rgba(255, 255, 255, 0.13);

  --accent: #3D9BFF;
  --accent-deep: #1E6FD9;
  --accent-wash: rgba(61, 155, 255, 0.16);

  --positive: #30D158;
  --positive-wash: rgba(48, 209, 88, 0.16);
  --negative: #FF6B60;
  --negative-wash: rgba(255, 107, 96, 0.16);
  --caution: #FFD60A;
  --caution-wash: rgba(255, 214, 10, 0.16);
}

/* Per-tab accents, brightened for a dark canvas. The light values are too
   deep to read against black. */
:root[data-theme="dark"] body[data-tab="batch"] {
  --accent: #8A88FF; --accent-deep: #5E5CE6; --accent-wash: rgba(138, 136, 255, 0.16);
}

:root[data-theme="dark"] body {
  --tint-canvas:  color-mix(in srgb, var(--accent) 7%,  #0B0B0D);
  --tint-surface: color-mix(in srgb, var(--accent) 4%,  rgba(28, 28, 30, 0.68));
  --tint-sunken:  color-mix(in srgb, var(--accent) 8%,  rgba(120, 120, 128, 0.18));
  --tint-line:    color-mix(in srgb, var(--accent) 22%, rgba(255, 255, 255, 0.09));
  --tint-line-2:  color-mix(in srgb, var(--accent) 24%, rgba(255, 255, 255, 0.16));
  --tint-soft:    color-mix(in srgb, var(--accent) 26%, #97979F);
  --tint-shadow:  color-mix(in srgb, var(--accent) 18%, rgba(0, 0, 0, 1));
}

:root[data-theme="dark"] .chrome {
  background: color-mix(in srgb, var(--accent) 6%, rgba(10, 10, 11, 0.62));
}
:root[data-theme="dark"] .card {
  border-color: rgba(255, 255, 255, 0.07);
}
/* The wash has to work harder against black or the page reads as flat. */
:root[data-theme="dark"] .aurora { --wash: 32%; --accent-strength: 26%; }

:root[data-theme="dark"] .hero p { color: #B6B6BD; }
:root[data-theme="dark"] .prose { color: #C9C9D1; }
:root[data-theme="dark"] textarea::placeholder,
:root[data-theme="dark"] #chat-input::placeholder { color: #6E6E78; }
:root[data-theme="dark"] .bar,
:root[data-theme="dark"] .gauge-track { background: rgba(120, 120, 128, 0.22); }
:root[data-theme="dark"] .gauge-track { stroke: rgba(120, 120, 128, 0.3); }
:root[data-theme="dark"] .shap-track::before { background: rgba(255, 255, 255, 0.18); }
:root[data-theme="dark"] .individual { color: color-mix(in srgb, var(--ind) 40%, #F5F5F7); }
:root[data-theme="dark"] .run { color: #06121F; }
/* The AI cards' purple wash is far too strong on black. */
:root[data-theme="dark"] #analysis-card,
:root[data-theme="dark"] #batch-summary-card,
:root[data-theme="dark"] #mutate-advice-card,
:root[data-theme="dark"] #design-analysis-card {
  background:
    linear-gradient(180deg,
      color-mix(in srgb, #af52de 13%, transparent) 0%,
      transparent 120px),
    var(--tint-surface);
}
:root[data-theme="dark"] #analysis-card .prose code,
:root[data-theme="dark"] #batch-summary-card .prose code,
:root[data-theme="dark"] #mutate-advice-card .prose code,
:root[data-theme="dark"] #design-analysis-card .prose code {
  background: color-mix(in srgb, #af52de 22%, transparent);
  color: #D9A9F5;
}

/* Chart colours as tokens, because an SVG presentation attribute cannot read a
   custom property - app.js resolves these with getComputedStyle at draw time
   and writes literal values into the markup. */
:root { --chart-grid: #E6E8EF; --chart-dot: #FFFFFF; }
:root[data-theme="dark"] { --chart-grid: rgba(255,255,255,0.12); --chart-dot: #1C1C1E; }

/* Matched to BBB-TransAI's .importance-row: the name takes the flexible
   column, the bar is a fixed width and the value closes the row. Its bar is
   8px, pill, on a sunken track with a gradient fill, the name 14px secondary
   ink and the value 12px mono tertiary.

   The track stays wider than BBB's 8rem because these bars diverge from a
   centre line rather than growing from the left - a signed SHAP value needs
   half the width per side, so 8rem would halve the resolution. */
.shap-row {
  grid-template-columns: minmax(0, 1fr) 15rem 3.5rem;
  gap: 0.75rem;
}
.shap-name { font-size: 14px; color: var(--ink-secondary); }
.shap-track { height: 8px; }
.shap-value {
  font: 500 12px/1 var(--mono);
  color: var(--ink-tertiary);
}
@media (max-width: 760px) {
  .shap-row { grid-template-columns: minmax(0, 1fr) 7.5rem 3rem; gap: 0.5rem; }
  .shap-name { font-size: 12.5px; }
}

/* Theme toggle. One glyph swaps for the other: the sun when the page is light
   and the moon when it is dark, so the icon shows the current state rather
   than the action - which is the convention in the other two apps. */
.theme-toggle {
  margin-left: auto;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  flex: none;
  border: 1px solid var(--tint-line);
  border-radius: var(--radius-pill);
  background: var(--tint-sunken);
  color: var(--ink-secondary);
  cursor: pointer;
  transition: transform 100ms var(--ease-out), color 150ms ease,
              background-color 150ms ease;
}
.theme-toggle svg { width: 17px; height: 17px; }
.theme-toggle:active { transform: scale(0.94); }
@media (hover: hover) and (pointer: fine) {
  .theme-toggle:hover { color: var(--ink); }
}
.theme-toggle .t-moon { display: none; }
:root[data-theme="dark"] .theme-toggle .t-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .t-moon { display: block; }
/* The status block sat hard right; the toggle now takes that slot. */
.chrome-inner .status { margin-left: 12px; }
