/* BioStudio AI — Analysis Advisor.
 *
 * Every colour resolves through the studio shell's --st-* tokens so the app
 * inherits whichever desktop theme is active. Each one carries a literal
 * fallback: some themes leave --st-accent undefined, and a primary button
 * painted with an undefined accent is invisible rather than merely off-brand.
 */

.adv-root {
  --adv-accent: var(--st-accent, #2f6bd4);
  --adv-ink: var(--st-ink, #1b1d21);
  --adv-ink-soft: var(--st-ink-soft, #6b7280);
  --adv-line: var(--st-line, rgba(128, 132, 140, 0.28));
  --adv-panel: var(--st-panel, rgba(255, 255, 255, 0.72));
  --adv-good: #0f7a52;
  --adv-warn: #9a6100;
  --adv-bad: #b42318;
  color: var(--adv-ink);
}

/* ---- stage frame --------------------------------------------------------- */

.adv-stage-head { margin: 0 0 14px; }
.adv-stage-title { margin: 0; font-size: 18px; font-weight: 650; letter-spacing: -0.01em; }
.adv-stage-hint { margin: 3px 0 0; font-size: 12.5px; color: var(--adv-ink-soft); }

.adv-stack { display: flex; flex-direction: column; gap: 14px; }
.adv-two-col { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 14px; align-items: start; }
@media (max-width: 1080px) { .adv-two-col { grid-template-columns: minmax(0, 1fr); } }

.adv-card {
  border: 1px solid var(--adv-line);
  border-radius: 12px;
  background: var(--adv-panel);
  padding: 14px 16px;
}
.adv-card-title { margin: 0 0 10px; font-size: 13.5px; font-weight: 650; letter-spacing: 0.01em; }

.adv-lead { margin: 0 0 8px; font-size: 14px; line-height: 1.5; font-weight: 550; }
.adv-body { margin: 4px 0 0; font-size: 13px; line-height: 1.55; color: var(--adv-ink); }

/* ---- notes --------------------------------------------------------------- */

.adv-note {
  margin: 8px 0 0;
  padding: 8px 10px;
  border-radius: 8px;
  border-left: 3px solid var(--adv-line);
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--adv-ink-soft);
  background: color-mix(in srgb, var(--adv-ink) 4%, transparent);
}
.adv-note-good { border-left-color: var(--adv-good); color: var(--adv-ink); }
.adv-note-warn { border-left-color: var(--adv-warn); color: var(--adv-ink); }
.adv-note-bad { border-left-color: var(--adv-bad); color: var(--adv-ink); }

/* ---- form ---------------------------------------------------------------- */

.adv-field { display: block; margin: 0 0 12px; }
.adv-field-label { display: block; font-size: 12px; font-weight: 600; margin-bottom: 5px; }
.adv-field-hint { display: block; font-size: 11.5px; color: var(--adv-ink-soft); margin-top: 4px; line-height: 1.45; }

.adv-input {
  width: 100%;
  box-sizing: border-box;
  padding: 8px 10px;
  border: 1px solid var(--adv-line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--adv-panel) 60%, transparent);
  color: var(--adv-ink);
  font: inherit;
  font-size: 13px;
}
.adv-input:focus-visible { outline: 2px solid var(--adv-accent); outline-offset: 1px; }
.adv-textarea { resize: vertical; line-height: 1.5; }

/* A three-up row that collapses rather than overflowing. Setting a width on a
 * bare `select` is what broke the toolbars in Clarity's report workspace, so
 * the width lives on the grid, never on the control. */
.adv-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; }

.adv-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.adv-chip {
  padding: 5px 10px;
  border: 1px solid var(--adv-line);
  border-radius: 999px;
  background: transparent;
  color: var(--adv-ink-soft);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}
.adv-chip:hover { border-color: var(--adv-accent); color: var(--adv-ink); }
.adv-chip-on {
  background: color-mix(in srgb, var(--adv-accent) 16%, transparent);
  border-color: var(--adv-accent);
  color: var(--adv-ink);
  font-weight: 600;
}

.adv-toggle { display: flex; align-items: center; gap: 8px; margin-top: 12px; font-size: 12.5px; cursor: pointer; }

/* ---- buttons ------------------------------------------------------------- */

.adv-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 12px; }
.adv-btn {
  padding: 8px 14px;
  border: 1px solid var(--adv-line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--adv-panel) 70%, transparent);
  color: var(--adv-ink);
  font: inherit;
  font-size: 13px;
  font-weight: 550;
  cursor: pointer;
}
.adv-btn:hover:not(:disabled) { border-color: var(--adv-accent); }
.adv-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.adv-btn-primary {
  background: var(--adv-accent);
  border-color: var(--adv-accent);
  color: #fff;
}
.adv-btn-primary:hover:not(:disabled) { filter: brightness(1.08); }

/* ---- file drop ----------------------------------------------------------- */

.adv-drop {
  border: 1.5px dashed var(--adv-line);
  border-radius: 12px;
  padding: 22px 16px;
  text-align: center;
  cursor: pointer;
  transition: border-color 120ms, background 120ms;
}
.adv-drop:hover, .adv-drop:focus-visible, .adv-drop-over {
  border-color: var(--adv-accent);
  background: color-mix(in srgb, var(--adv-accent) 7%, transparent);
  outline: none;
}
.adv-drop-icon { font-size: 22px; line-height: 1; }
.adv-drop-title { margin-top: 8px; font-size: 13.5px; font-weight: 600; }
.adv-drop-sub { margin-top: 6px; font-size: 11.5px; color: var(--adv-ink-soft); line-height: 1.5; }

.adv-file-summary { margin-top: 12px; }
.adv-file-name { font-size: 13px; font-weight: 600; word-break: break-all; }

/* ---- pills --------------------------------------------------------------- */

.adv-pills { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.adv-pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--adv-line);
  font-size: 11px;
  font-weight: 600;
  color: var(--adv-ink-soft);
  white-space: nowrap;
}
.adv-pill-good { color: var(--adv-good); border-color: color-mix(in srgb, var(--adv-good) 45%, transparent); }
.adv-pill-warn { color: var(--adv-warn); border-color: color-mix(in srgb, var(--adv-warn) 45%, transparent); }
.adv-pill-bad { color: var(--adv-bad); border-color: color-mix(in srgb, var(--adv-bad) 45%, transparent); }

/* ---- tables -------------------------------------------------------------- */

/* Wide result tables scroll inside their own box; the workspace never does. */
.adv-table-wrap { overflow-x: auto; margin-top: 10px; border: 1px solid var(--adv-line); border-radius: 8px; }
.adv-table { border-collapse: collapse; width: 100%; font-size: 12.5px; }
.adv-table th, .adv-table td {
  padding: 6px 10px;
  text-align: left;
  border-bottom: 1px solid var(--adv-line);
  /* Never let a long header collapse into one letter per line — a word-break
   * rule here is what turned Plasmid Studio's sidebar into vertical text. */
  white-space: nowrap;
}
.adv-table th { font-weight: 650; font-size: 11.5px; color: var(--adv-ink-soft); position: sticky; top: 0; background: var(--adv-panel); }
.adv-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.adv-table tr:last-child td { border-bottom: none; }
.adv-table-more { margin: 6px 10px; font-size: 11.5px; color: var(--adv-ink-soft); }

/* ---- plots --------------------------------------------------------------- */

.adv-plot-wrap { margin-top: 10px; overflow-x: auto; }
.adv-plot { width: 100%; height: auto; max-width: 100%; display: block; }
.adv-plot-grid { stroke: var(--adv-line); stroke-width: 1; }
.adv-plot-axis { stroke: var(--adv-line); stroke-width: 1; }
.adv-plot-tick { fill: var(--adv-ink-soft); font-size: 10px; }
.adv-plot-axis-label { fill: var(--adv-ink-soft); font-size: 11px; font-weight: 600; }
.adv-plot-legend-text { fill: var(--adv-ink-soft); font-size: 10.5px; }
.adv-plot-bar { }
.adv-plot-dot { stroke: var(--adv-panel); stroke-width: 2; }
.adv-plot-dot-solid { stroke: var(--adv-panel); stroke-width: 2; }
.adv-plot-crossbar { stroke-width: 2.5; stroke-linecap: round; }
.adv-plot-whisker { stroke-width: 2; stroke-linecap: round; opacity: 0.7; }
.adv-plot-fit { stroke-width: 2; stroke-dasharray: 5 4; }
.adv-plot-line { stroke-width: 2; stroke-linejoin: round; }

/* ---- plan ---------------------------------------------------------------- */

.adv-list { margin: 0; padding-left: 18px; font-size: 13px; line-height: 1.6; }
.adv-list li { margin-bottom: 6px; }
.adv-assumption { font-weight: 550; }
.adv-assumption-impact { color: var(--adv-ink-soft); }

.adv-steps { margin: 0; padding-left: 20px; }
.adv-step { margin-bottom: 10px; font-size: 13px; }
.adv-step-title { font-weight: 600; }

.adv-question { border: 1px solid var(--adv-line); border-radius: 10px; padding: 10px 12px; margin-bottom: 10px; }
.adv-question-head { display: flex; align-items: baseline; gap: 8px; }
.adv-question-text { font-size: 13.5px; font-weight: 600; }

.adv-target { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.adv-target-main { flex: 1 1 260px; }

.adv-candidates { margin-top: 14px; display: flex; flex-direction: column; gap: 6px; }
.adv-candidate {
  display: flex; flex-direction: column; gap: 2px;
  text-align: left; padding: 8px 10px;
  border: 1px solid var(--adv-line); border-radius: 8px;
  background: transparent; color: inherit; font: inherit; cursor: pointer;
}
.adv-candidate:hover { border-color: var(--adv-accent); }
.adv-candidate-on { border-color: var(--adv-accent); background: color-mix(in srgb, var(--adv-accent) 10%, transparent); }
.adv-candidate-name { font-size: 13px; font-weight: 600; }
.adv-candidate-why { font-size: 11.5px; color: var(--adv-ink-soft); }

/* ---- results ------------------------------------------------------------- */

.adv-result-body { display: block; }
.adv-interpretation p { margin: 0 0 8px; }

.adv-followup { display: block; }
.adv-turn { margin-bottom: 10px; }
.adv-turn-role { font-size: 11px; font-weight: 650; color: var(--adv-ink-soft); text-transform: uppercase; letter-spacing: 0.04em; }
.adv-turn-user .adv-body { font-weight: 550; }
.adv-ask { display: flex; gap: 8px; margin-top: 10px; }
.adv-ask .adv-input { flex: 1 1 auto; }

/* ---- payload disclosure -------------------------------------------------- */

.adv-payload { margin-top: 8px; border: 1px solid var(--adv-line); border-radius: 8px; padding: 8px 10px; }
.adv-payload > summary { cursor: pointer; font-size: 12px; font-weight: 600; color: var(--adv-ink-soft); }
.adv-pre {
  margin: 8px 0 0;
  padding: 10px;
  border-radius: 6px;
  background: color-mix(in srgb, var(--adv-ink) 6%, transparent);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11.5px;
  line-height: 1.5;
  white-space: pre;
  overflow-x: auto;
}

/* ---- sessions ------------------------------------------------------------ */

.adv-sessions { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.adv-session {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  border: 1px solid var(--adv-line); border-radius: 10px; padding: 10px 12px;
}
.adv-session-main { min-width: 0; }
.adv-session-title { font-size: 13px; font-weight: 600; }
.adv-session-actions { display: flex; gap: 6px; flex: 0 0 auto; }

/* ---- misc ---------------------------------------------------------------- */

.adv-empty { text-align: center; padding: 48px 20px; }
.adv-empty-icon { font-size: 30px; opacity: 0.55; }
.adv-empty-title { margin: 10px 0 4px; font-size: 15px; font-weight: 650; }
.adv-empty-sub { margin: 0 auto 14px; max-width: 460px; font-size: 13px; color: var(--adv-ink-soft); line-height: 1.55; }

.adv-busy { display: flex; align-items: center; gap: 9px; font-size: 13px; color: var(--adv-ink-soft); }
.adv-busy-dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--adv-accent);
  animation: adv-pulse 1s ease-in-out infinite;
}
@keyframes adv-pulse { 0%, 100% { opacity: 0.35; } 50% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .adv-busy-dot { animation: none; opacity: 0.8; } }

/* ---- stage header status -------------------------------------------------- */

.adv-stage-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.adv-stage-heading { min-width: 0; }
.adv-status { display: flex; align-items: center; gap: 10px; flex: 0 0 auto; padding-top: 2px; }
.adv-status-busy { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; color: var(--adv-ink-soft); }
.adv-status-usage { font-size: 11.5px; color: var(--adv-ink-soft); font-variant-numeric: tabular-nums; }
.adv-btn-small { padding: 4px 9px; font-size: 11.5px; }

/* ---- worked examples ------------------------------------------------------ */

.adv-examples { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.adv-example {
  display: flex; flex-direction: column; gap: 3px;
  text-align: left; padding: 10px 12px;
  border: 1px solid var(--adv-line); border-radius: 10px;
  background: transparent; color: inherit; font: inherit; cursor: pointer;
}
.adv-example:hover { border-color: var(--adv-accent); background: color-mix(in srgb, var(--adv-accent) 7%, transparent); }
.adv-example-name { font-size: 13px; font-weight: 600; }
.adv-example-summary { font-size: 12px; color: var(--adv-ink-soft); line-height: 1.45; }
.adv-example-teaches { font-size: 11.5px; color: var(--adv-ink-soft); font-style: italic; }

/* ---- header row picker ---------------------------------------------------- */

.adv-header-rows { display: flex; flex-direction: column; gap: 4px; margin-top: 8px; }
.adv-header-row {
  display: flex; align-items: baseline; gap: 10px;
  text-align: left; padding: 6px 9px;
  border: 1px solid var(--adv-line); border-radius: 7px;
  background: transparent; color: inherit; font: inherit; font-size: 12px; cursor: pointer;
}
.adv-header-row:hover { border-color: var(--adv-accent); }
.adv-header-row-on { border-color: var(--adv-accent); background: color-mix(in srgb, var(--adv-accent) 10%, transparent); font-weight: 600; }
.adv-header-row-n { flex: 0 0 auto; color: var(--adv-ink-soft); font-variant-numeric: tabular-nums; }
.adv-header-row-cells { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---- column role editor --------------------------------------------------- */

.adv-col-list { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.adv-col-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px 14px;
  align-items: center;
  padding: 9px 11px;
  border: 1px solid var(--adv-line);
  border-radius: 9px;
}
@media (max-width: 780px) { .adv-col-row { grid-template-columns: minmax(0, 1fr); } }
.adv-col-excluded { opacity: 0.5; }
.adv-col-main { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.adv-col-name { font-size: 13px; font-weight: 600; word-break: break-word; }
.adv-col-meta { font-size: 11.5px; color: var(--adv-ink-soft); }
.adv-col-detail { font-size: 11.5px; color: var(--adv-ink-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.adv-col-controls { display: flex; align-items: center; gap: 7px; flex: 0 0 auto; }
/* Width belongs to the control here, not to a bare `select` rule — a global
   select{width:100%} is what broke the report-workspace toolbars. */
.adv-col-role { width: 190px; padding: 5px 8px; font-size: 12px; }
.adv-col-flag { grid-column: 1 / -1; font-size: 11.5px; color: var(--adv-good); font-weight: 600; }
.adv-col-flag-unsure { color: var(--adv-warn); font-weight: 500; }

/* ---- results ------------------------------------------------------------- */

.adv-card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; }

/* ---- history -------------------------------------------------------------- */

.adv-history-tools { display: flex; align-items: center; gap: 12px; margin: 10px 0 4px; }
.adv-history-tools .adv-status-usage { flex: 0 0 auto; white-space: nowrap; }
.adv-history-tools .adv-input { flex: 1 1 auto; }
.adv-session-current { border-color: var(--adv-accent); background: color-mix(in srgb, var(--adv-accent) 6%, transparent); }
.adv-session-objective {
  margin: 4px 0 0; font-size: 12px; color: var(--adv-ink-soft); line-height: 1.45;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.adv-session-actions .adv-btn { padding: 5px 10px; font-size: 12px; }

/* ---- error bar ------------------------------------------------------------
 * An error lives above the section rather than inside one: the action that
 * failed is often not on the page you end up on. It is dismissible, because an
 * error you cannot clear reads as damage rather than as a message. */

.adv-error {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin: 0 0 14px;
  padding: 9px 12px;
  border: 1px solid color-mix(in srgb, var(--adv-bad) 40%, transparent);
  border-left-width: 3px;
  border-radius: 9px;
  background: color-mix(in srgb, var(--adv-bad) 8%, transparent);
}
.adv-error-text { font-size: 12.5px; line-height: 1.5; color: var(--adv-ink); min-width: 0; }
.adv-error .adv-btn { flex: 0 0 auto; }

/* ---- brief readiness ------------------------------------------------------ */

.adv-readiness { flex: 1 1 200px; max-width: 420px; min-width: 180px; }
.adv-meter {
  height: 4px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--adv-ink) 10%, transparent);
  overflow: hidden;
}
.adv-meter-fill {
  height: 100%;
  background: var(--adv-accent);
  border-radius: 999px;
  transition: width 160ms ease;
}
@media (prefers-reduced-motion: reduce) { .adv-meter-fill { transition: none; } }
.adv-readiness-text { display: block; margin-top: 6px; font-size: 11.5px; color: var(--adv-ink-soft); line-height: 1.45; }
.adv-readiness-done { margin-top: 0; }
.adv-readiness-done::before { content: "✓ "; color: var(--adv-good); font-weight: 700; }

/* ---- plan questions ------------------------------------------------------- */

/* The "why" behind a question is a caption, not a finding: as a full note block
 * it was a grey slab under every question and drowned the question itself. */
.adv-question-why { margin: 5px 0 8px; font-size: 12px; color: var(--adv-ink-soft); line-height: 1.5; }
.adv-question-answered { border-color: color-mix(in srgb, var(--adv-good) 45%, transparent); }
.adv-question-or { font-size: 11.5px; color: var(--adv-ink-soft); align-self: center; }
.adv-question .adv-chips { align-items: center; }
.adv-question .adv-chips .adv-input { flex: 1 1 140px; min-width: 120px; width: auto; }

.adv-hint { margin: 5px 0 0; font-size: 11.5px; color: var(--adv-ink-soft); line-height: 1.45; }

/* ---- result card tools ---------------------------------------------------- */

/* Two small buttons, revealed on hover or focus so they do not compete with the
 * result. `visibility` rather than `display` keeps the header height stable. */
.adv-result-tools { display: flex; gap: 6px; flex: 0 0 auto; opacity: 0; transition: opacity 120ms; }
.adv-card:hover .adv-result-tools,
.adv-result-tools:focus-within { opacity: 1; }
@media (prefers-reduced-motion: reduce) { .adv-result-tools { transition: none; } }
@media (hover: none) { .adv-result-tools { opacity: 1; } }

/* Numeric headers align with the numbers beneath them. Left-aligned headers
 * over right-aligned values read as two unrelated columns. */
.adv-table th.num { text-align: right; }
.adv-result-why { margin: 0 0 8px; font-size: 12px; color: var(--adv-ink-soft); line-height: 1.5; font-style: italic; }
.adv-table-foot { display: flex; align-items: center; gap: 12px; margin-top: 6px; flex-wrap: wrap; }
.adv-table-foot .adv-table-more { margin: 0; }

/* The one action this whole step exists for. It sat at the foot of a column
 * two screens tall, so on a real brief nobody ever saw it — nor the readiness
 * line next to it that says what is still missing. */
.adv-consult-action {
  position: sticky;
  bottom: 0;
  z-index: 2;
  margin-top: 16px;
  padding: 12px 14px;
  border: 1px solid var(--adv-line);
  border-radius: 12px;
  background: var(--st-bg, var(--adv-panel));
  backdrop-filter: blur(8px);
}
