/* BioStudio AI — Studio suite design system.
   Shared look & feel for Stat Studio, Cytokine Studio, Report Studio and
   Assay Builder. Scoped under .studio so it never leaks into other apps. */

.studio {
  --st-bg: #f6f7fb;
  --st-panel: #ffffff;
  --st-line: rgba(20, 30, 50, 0.10);
  --st-line-soft: rgba(20, 30, 50, 0.06);
  --st-ink: #1b2230;
  --st-ink-soft: #5d6675;
  --st-accent: var(--accent, #2f6bff);
  --st-ai: #7c5cff;
  --st-ok: #1aa260;
  --st-warn: #e0950b;
  --st-bad: #df3b3b;
  --st-info: #2f6bff;
  --st-review: #8a5cf6;

  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: var(--st-bg);
  color: var(--st-ink);
  font-size: 13px;
  user-select: none;
}

.dark .studio {
  --st-bg: #14171d;
  --st-panel: #1b1f27;
  --st-line: rgba(255, 255, 255, 0.10);
  --st-line-soft: rgba(255, 255, 255, 0.06);
  --st-ink: #eef1f6;
  --st-ink-soft: #9aa3b2;
}

/* ---- Toolbar ---- */
.st-toolbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 12px;
  background: var(--st-panel);
  border-bottom: 1px solid var(--st-line);
  flex: 0 0 auto;
}
.st-brand { display: flex; align-items: center; gap: 8px; font-weight: 650; }
.st-project-wrap { display: flex; align-items: center; gap: 6px; }
.st-project-label { color: var(--st-ink-soft); font-size: 11px; text-transform: uppercase; letter-spacing: .04em; }
.st-project {
  border: 1px solid var(--st-line); border-radius: 6px; padding: 5px 8px;
  background: var(--st-bg); color: var(--st-ink); max-width: 230px;
}
.st-tbtns { display: flex; gap: 6px; flex-wrap: wrap; }
.st-spacer { flex: 1; }
.st-tbtn {
  border: 1px solid var(--st-line); border-radius: 6px; padding: 6px 11px;
  background: var(--st-panel); color: var(--st-ink); font-size: 12.5px;
  display: inline-flex; align-items: center; gap: 6px; transition: background .12s, border-color .12s;
}
.st-tbtn:hover { background: var(--st-line-soft); }
.st-tbtn.primary { background: var(--st-accent); color: #fff; border-color: transparent; }
.st-tbtn.primary:hover { filter: brightness(1.06); }
.st-tbtn.ai { border-color: color-mix(in srgb, var(--st-ai) 45%, transparent); }
.st-tbtn.ai.on { background: color-mix(in srgb, var(--st-ai) 14%, transparent); }

.st-ai-badge {
  font-size: 9.5px; font-weight: 800; letter-spacing: .06em;
  background: var(--st-ai); color: #fff; border-radius: 4px; padding: 1px 5px;
  line-height: 1.4;
}

/* ---- Body grid ---- */
.st-body { flex: 1; display: flex; min-height: 0; }
.st-sidebar {
  flex: 0 0 188px; width: 188px; background: var(--st-panel);
  border-right: 1px solid var(--st-line); overflow-y: auto; padding: 8px;
}
.st-nav { display: flex; flex-direction: column; gap: 2px; }
.st-nav-item {
  display: flex; align-items: center; gap: 9px; width: 100%;
  padding: 8px 10px; border-radius: 7px; text-align: left;
  color: var(--st-ink-soft); font-size: 13px;
}
.st-nav-item:hover { background: var(--st-line-soft); color: var(--st-ink); }
.st-nav-item.active { background: var(--st-accent); color: #fff; font-weight: 600; }
.st-nav-ico { width: 18px; text-align: center; flex: 0 0 auto; }

.st-center { flex: 1; display: flex; min-width: 0; }
.st-workspace { flex: 1; overflow: auto; padding: 16px; min-width: 0; }
.st-inspector {
  flex: 0 0 260px; width: 260px; background: var(--st-panel);
  border-left: 1px solid var(--st-line); overflow-y: auto; padding: 14px;
}
.st-ai {
  flex: 0 0 0; width: 0; overflow: hidden; background: var(--st-panel);
  border-left: 1px solid var(--st-line); display: flex; flex-direction: column;
  transition: width .18s ease, flex-basis .18s ease;
}
.studio.ai-open .st-ai { flex-basis: 300px; width: 300px; }
.st-ai-head {
  display: flex; align-items: center; gap: 8px; padding: 12px 14px;
  border-bottom: 1px solid var(--st-line); font-weight: 600;
}
.st-ai-head .st-ai-x { margin-left: auto; font-size: 18px; color: var(--st-ink-soft); line-height: 1; }
.st-ai-body { flex: 1; overflow-y: auto; padding: 12px 14px; }

.st-ai-msgs { display: flex; flex-direction: column; gap: 10px; }
.st-ai-msg {
  border: 1px solid var(--st-line); border-left: 3px solid var(--st-info);
  border-radius: 8px; padding: 9px 11px; background: var(--st-bg);
}
.st-ai-msg.warning { border-left-color: var(--st-warn); }
.st-ai-msg.passed { border-left-color: var(--st-ok); }
.st-ai-msg.failed { border-left-color: var(--st-bad); }
.st-ai-msg-title { display: flex; align-items: center; gap: 6px; font-weight: 650; margin-bottom: 4px; }
.st-ai-msg-body { color: var(--st-ink-soft); line-height: 1.5; }

/* ---- Cards & primitives ---- */
.st-card {
  background: var(--st-panel); border: 1px solid var(--st-line);
  border-radius: 10px; padding: 14px; margin-bottom: 14px;
}
.st-card-title { font-weight: 650; margin-bottom: 10px; font-size: 13.5px; }
.st-section-h { font-size: 15px; font-weight: 700; margin: 4px 0 12px; }
.st-muted { color: var(--st-ink-soft); }
.st-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.st-grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.st-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.st-field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; }
.st-field-label { font-size: 11.5px; color: var(--st-ink-soft); font-weight: 600; }
.st-field-hint { font-size: 11px; color: var(--st-ink-soft); }
.st-input {
  border: 1px solid var(--st-line); border-radius: 6px; padding: 7px 9px;
  background: var(--st-bg); color: var(--st-ink); font-size: 13px; width: 100%;
}
.st-input:focus { outline: 2px solid var(--st-accent-soft, rgba(47,107,255,.3)); border-color: var(--st-accent); }
textarea.st-input { resize: vertical; min-height: 70px; line-height: 1.5; }

.st-btn {
  border: 1px solid var(--st-line); border-radius: 6px; padding: 7px 12px;
  background: var(--st-panel); color: var(--st-ink); font-size: 12.5px;
}
.st-btn:hover { background: var(--st-line-soft); }
.st-btn.primary { background: var(--st-accent); color: #fff; border-color: transparent; }
.st-btn.ai { background: color-mix(in srgb, var(--st-ai) 12%, transparent); border-color: color-mix(in srgb, var(--st-ai) 40%, transparent); }
.st-btn.danger { color: var(--st-bad); }
.st-btn.small { padding: 4px 8px; font-size: 11.5px; }

/* ---- Status dots & pills ---- */
.st-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: #b8c0cc; }
.st-dot.ok { background: var(--st-ok); }
.st-dot.warn { background: var(--st-warn); }
.st-dot.bad { background: var(--st-bad); }
.st-dot.info { background: var(--st-info); }
.st-dot.review { background: var(--st-review); }
.st-dot.muted { background: #b8c0cc; }
.st-pill {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px;
  border-radius: 999px; font-size: 11px; font-weight: 600;
  background: var(--st-line-soft); color: var(--st-ink-soft);
}
.st-pill.ok { background: color-mix(in srgb, var(--st-ok) 16%, transparent); color: var(--st-ok); }
.st-pill.warn { background: color-mix(in srgb, var(--st-warn) 18%, transparent); color: var(--st-warn); }
.st-pill.bad { background: color-mix(in srgb, var(--st-bad) 16%, transparent); color: var(--st-bad); }
.st-pill.info { background: color-mix(in srgb, var(--st-info) 14%, transparent); color: var(--st-info); }

/* ---- Tables ---- */
.st-table-wrap { overflow: auto; border: 1px solid var(--st-line); border-radius: 8px; }
.st-table { border-collapse: collapse; width: 100%; font-size: 12.5px; }
.st-table th, .st-table td { padding: 6px 10px; border-bottom: 1px solid var(--st-line-soft); text-align: left; white-space: nowrap; }
.st-table th { background: var(--st-bg); font-weight: 650; position: sticky; top: 0; }
.st-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.st-table tbody tr:hover { background: var(--st-line-soft); }
.st-table-more { padding: 6px 10px; color: var(--st-ink-soft); font-size: 11.5px; }

/* ---- Empty state ---- */
.st-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 48px 24px; text-align: center; color: var(--st-ink-soft); height: 100%; }
.st-empty-ico { font-size: 40px; opacity: .8; }
.st-empty-title { font-size: 15px; font-weight: 650; color: var(--st-ink); }
.st-empty-sub { max-width: 360px; line-height: 1.5; }

/* ---- Plate map ---- */
.st-plate { display: inline-block; }
.st-plate-grid { border-collapse: separate; border-spacing: 3px; }
.st-plate-grid th { color: var(--st-ink-soft); font-weight: 600; font-size: 10px; padding: 1px; }
.st-well {
  width: 26px; height: 26px; border-radius: 50%; border: 1px solid var(--st-line);
  display: flex; align-items: center; justify-content: center; font-size: 8px; color: #fff;
  cursor: pointer; position: relative;
}
.st-well.empty { background: transparent; }
.st-well.sel { outline: 2px solid var(--st-accent); }
.st-legend { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.st-legend-item { display: flex; align-items: center; gap: 6px; font-size: 11.5px; }
.st-swatch { width: 12px; height: 12px; border-radius: 3px; }

/* ---- Heatmap ---- */
.st-heat { border-collapse: collapse; }
.st-heat th { font-size: 10.5px; font-weight: 600; padding: 3px 6px; color: var(--st-ink-soft); text-align: left; white-space: nowrap; }
.st-heat td { padding: 0; }
.st-heat-cell { width: 46px; height: 30px; text-align: center; font-size: 9.5px; color: #111; border: 1px solid rgba(255,255,255,.5); }

/* ---- Slides ---- */
.st-slide {
  background: var(--st-panel); border: 1px solid var(--st-line); border-radius: 8px;
  aspect-ratio: 16 / 9; padding: 16px; display: flex; flex-direction: column; gap: 8px;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
}
.st-slide-title { font-weight: 700; font-size: 14px; border-bottom: 2px solid var(--st-accent); padding-bottom: 6px; }
.st-slide-body { flex: 1; overflow: hidden; font-size: 12px; color: var(--st-ink-soft); line-height: 1.5; }
.st-slides-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }

/* ---- Assay Builder: graphical SVG plate ---- */
.ab-plate-scroll {
  overflow: auto; max-width: 100%; border-radius: 18px;
  background:
    radial-gradient(circle at 16% 12%, rgba(126, 173, 110, .18), transparent 30%),
    linear-gradient(135deg, rgba(245, 250, 240, .78), rgba(225, 237, 217, .34));
  padding: 12px;
}
.dark .ab-plate-scroll {
  background:
    radial-gradient(circle at 16% 12%, rgba(126, 173, 110, .12), transparent 30%),
    linear-gradient(135deg, rgba(34, 43, 34, .72), rgba(23, 31, 26, .42));
}
.ab-plate-svg { display: block; max-width: 100%; height: auto; margin: auto; }
.ab-plate-body { fill: url(#abPetriGradient); stroke: rgba(96, 126, 84, .24); stroke-width: 1.2; }
.ab-plate-leaf { fill: rgba(116, 160, 93, .18); stroke: rgba(83, 126, 76, .22); stroke-width: 1; }
.ab-plate-leaf.vein { fill: none; stroke: rgba(83, 126, 76, .26); stroke-linecap: round; }
.ab-plate-axis { fill: rgba(79, 99, 72, .72); font-size: 9px; font-weight: 700; }
.dark .ab-plate-axis { fill: rgba(210, 224, 202, .72); }
.ab-well { transition: filter .12s, stroke-width .12s, transform .12s; }
.ab-well:not(.empty), .ab-plate-svg.interactive .ab-well.empty { cursor: pointer; }
.ab-well:not(.empty):hover { filter: saturate(1.08) brightness(1.04); stroke: #3f8f68; stroke-width: 1.9; }
.ab-well.empty { fill: rgba(255,255,255,.28); }
.dark .ab-well.empty { fill: rgba(255,255,255,.04); }
.ab-well-gloss { pointer-events: none; opacity: .9; }
.ab-well-halo { pointer-events: none; }
.ab-well-label { font-size: 8px; font-weight: 700; pointer-events: none; }

/* Live preview pane (inspector) */
.ab-preview-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.ab-mini-plate {
  background:
    radial-gradient(circle at 18% 12%, rgba(129, 177, 106, .18), transparent 34%),
    linear-gradient(145deg, rgba(247, 251, 243, .92), rgba(226, 238, 218, .62));
  border: 1px solid rgba(96, 126, 84, .18);
  border-radius: 22px 14px 22px 14px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.72), 0 6px 18px rgba(83, 111, 69, .08);
  padding: 10px; margin-bottom: 12px; display: flex; justify-content: center;
}
.dark .ab-mini-plate { background: linear-gradient(145deg, rgba(33, 43, 34, .9), rgba(23, 31, 26, .7)); border-color: rgba(166, 191, 148, .16); }
.ab-mini-plate svg { width: 100%; height: auto; }
.ab-comp-mini { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.ab-comp-mini-item {
  display: flex; align-items: center; gap: 7px; font-size: 12px;
  background: color-mix(in srgb, #7fae68 8%, transparent);
  border: 1px solid rgba(96, 126, 84, .12);
  border-radius: 999px; padding: 5px 8px;
}
.ab-comp-mini-label { flex: 1; color: var(--st-ink-soft); }
.ab-comp-mini-val { font-weight: 700; font-variant-numeric: tabular-nums; }

/* Capacity bar */
.ab-cap { margin-bottom: 14px; }
.ab-cap-track {
  height: 12px; border-radius: 999px; background: rgba(122, 146, 112, .15); overflow: hidden;
  box-shadow: inset 0 1px 2px rgba(60, 76, 52, .1);
}
.ab-cap-fill {
  height: 100%;
  background: linear-gradient(90deg, #6aa66b, #9dc36b);
  border-radius: 999px; transition: width .2s ease;
}
.ab-cap-fill.high { background: linear-gradient(90deg, #c5a45a, #d8bd71); }
.ab-cap-fill.over { background: linear-gradient(90deg, #bf6f5e, #d98b77); }
.ab-cap-meta { display: flex; justify-content: space-between; font-size: 11px; color: var(--st-ink-soft); margin-top: 4px; }
.ab-cap-meta .over { color: var(--st-bad); font-weight: 700; }

/* Composition stacked bar */
.ab-stack {
  display: flex; height: 18px; border-radius: 999px; overflow: hidden;
  background: rgba(122, 146, 112, .14); margin-bottom: 10px;
  box-shadow: inset 0 1px 2px rgba(60, 76, 52, .1);
}
.ab-stack-seg { height: 100%; transition: width .2s ease; }
.ab-comp-legend { display: flex; flex-direction: column; gap: 5px; }
.ab-comp-legend-item { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--st-ink-soft); }

/* Workflow strip */
.ab-flow { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.ab-flow-step {
  flex: 1; min-width: 100px;
  background:
    radial-gradient(circle at 18% 8%, rgba(146, 190, 115, .22), transparent 36%),
    linear-gradient(145deg, var(--st-panel), color-mix(in srgb, #89b978 10%, var(--st-panel)));
  border: 1px solid rgba(96, 126, 84, .18);
  border-radius: 20px 10px 20px 10px; padding: 11px 9px; text-align: center;
  box-shadow: 0 4px 14px rgba(83, 111, 69, .06);
}
.ab-flow-icon { font-size: 21px; line-height: 1; margin-bottom: 5px; }
.ab-flow-label { font-weight: 700; font-size: 12px; color: color-mix(in srgb, #2f6f4e 62%, var(--st-ink)); }
.ab-flow-sub { font-size: 10.5px; color: var(--st-ink-soft); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ab-flow-arrow { display: flex; align-items: center; color: #75a66b; font-size: 17px; }

/* Interactive plate editor */
.ab-axis-click { cursor: pointer; }
.ab-axis-click:hover { fill: #3f8f68; }
.ab-marquee { fill: rgba(63, 143, 104, .14); stroke: #3f8f68; stroke-width: 1.2; pointer-events: none; }
.ab-well.manual { stroke-dasharray: 2 2; }
.ab-assign-bar { display: flex; flex-direction: column; gap: 8px; }
.ab-assign-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.ab-assign-chips { display: flex; flex-wrap: wrap; gap: 6px; max-height: 140px; overflow-y: auto; padding: 2px; }
.ab-assign-chip {
  display: inline-flex; align-items: center; gap: 6px; max-width: 220px;
  padding: 5px 9px; border-radius: 999px; border: 1px solid var(--st-line);
  background: var(--st-bg); font-size: 11.5px; cursor: pointer; text-align: left;
}
.ab-assign-chip:hover { border-color: var(--st-accent); }
.ab-assign-chip.active { border-color: #7c5cff; box-shadow: 0 0 0 1px #7c5cff inset; background: color-mix(in srgb, #7c5cff 8%, var(--st-bg)); }
.ab-assign-swatch { width: 12px; height: 12px; border-radius: 50%; flex: 0 0 auto; border: 1px solid rgba(0,0,0,.12); }
.ab-assign-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---- Misc ---- */
.st-tag-list { display: flex; flex-wrap: wrap; gap: 6px; }
.st-x { color: var(--st-ink-soft); font-size: 13px; padding: 0 4px; }
.st-x:hover { color: var(--st-bad); }
.st-list { display: flex; flex-direction: column; gap: 8px; }
.st-item {
  border: 1px solid var(--st-line); border-radius: 8px; padding: 9px 11px;
  display: flex; align-items: center; gap: 10px; background: var(--st-panel);
}
.st-item:hover { border-color: var(--st-accent); }
.st-item-main { flex: 1; min-width: 0; }
.st-item-title { font-weight: 600; }
.st-item-sub { font-size: 11.5px; color: var(--st-ink-soft); }
svg.st-chart { background: var(--st-panel); border: 1px solid var(--st-line); border-radius: 8px; max-width: 100%; }

/* Report Studio preview-first composer */
.rs-composer { display: flex; flex-direction: column; gap: 12px; align-items: center; }
.rs-preview-toolbar {
  position: sticky; top: -16px; z-index: 4; width: min(920px, 100%);
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 8px; background: color-mix(in srgb, var(--st-panel) 94%, transparent);
  border: 1px solid var(--st-line); border-radius: 8px; backdrop-filter: blur(10px);
}
.rs-page {
  width: min(920px, 100%); min-height: 1120px; box-sizing: border-box;
  background: #fff; color: #172033; padding: 54px 64px;
  box-shadow: 0 18px 50px rgba(26, 36, 64, .16);
  border: 1px solid rgba(20, 32, 60, .08);
}
.rs-page-head { border-bottom: 3px solid var(--st-accent); padding-bottom: 12px; margin-bottom: 20px; }
.rs-title-input {
  border: 0; outline: 0; width: 100%; background: transparent; color: #172033;
  font: 750 30px/1.2 "Segoe UI", system-ui, sans-serif; letter-spacing: 0;
}
.rs-page-meta { color: #667085; font-size: 13px; margin-top: 8px; }
.rs-block {
  position: relative; margin: 12px -12px; padding: 8px 12px;
  border: 1px solid transparent; border-radius: 8px; cursor: pointer;
}
.rs-block:hover { border-color: #d9e2f3; background: #fbfcff; }
.rs-block.selected { border-color: var(--st-accent); background: color-mix(in srgb, var(--st-accent) 6%, #fff); }
.rs-block h2 { color: #234fb6; font-size: 19px; margin: 18px 0 8px; }
.rs-block h3 { font-size: 15px; margin: 10px 0 7px; color: #172033; }
.rs-prose { line-height: 1.58; font-size: 14px; }
.rs-prose p { margin: 0 0 9px; }
.rs-prose.ai { background: #f5f0ff; border-left: 3px solid var(--st-ai); padding: 8px 12px; border-radius: 6px; }
.rs-figure svg { max-width: 100%; height: auto; }
.rs-block figcaption { color: #667085; font-size: 12.5px; line-height: 1.45; }
.rs-source { color: #667085; font-size: 11.5px; margin-top: 6px; }
.rs-block-grip {
  position: absolute; left: -36px; top: 8px; width: 24px; height: 24px; border-radius: 50%;
  border: 1px solid #d9e2f3; background: #fff; color: #667085; font-size: 11px;
}
.rs-issues { display: flex; flex-direction: column; gap: 6px; }
.rs-issue, .rs-issue-static {
  display: block; width: 100%; text-align: left; border: 1px solid var(--st-line);
  background: var(--st-panel); border-radius: 7px; padding: 6px 8px; color: var(--st-ink-soft);
  font-size: 12px; line-height: 1.35;
}
.rs-ready-line { font-weight: 700; margin-bottom: 8px; }
.rs-issue-mini { display: flex; flex-direction: column; gap: 4px; color: var(--st-ink-soft); font-size: 12px; }
.rs-ai-chat { display: flex; flex-direction: column; gap: 8px; margin: 10px 0; }
.rs-ai-msg { border: 1px solid var(--st-line); border-radius: 8px; padding: 8px 10px; line-height: 1.45; font-size: 12.5px; }
.rs-ai-msg.user { background: color-mix(in srgb, var(--st-accent) 9%, transparent); }
.rs-ai-msg.assistant { background: var(--st-panel); }
.rs-ai-msg.system { color: var(--st-ink-soft); background: var(--st-bg); }
.rs-ai-controls { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.rs-ai-controls .st-row { align-items: stretch; }
.rs-ai-controls input.st-input { flex: 1; min-width: 0; }
.rs-ai-suggestions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.rs-ai-action-card {
  border: 1px solid color-mix(in srgb, var(--st-ai) 38%, var(--st-line));
  background: color-mix(in srgb, var(--st-ai) 7%, transparent);
  border-radius: 8px; padding: 10px;
}
.rs-ai-action-card ul { margin: 6px 0 10px; padding-left: 18px; color: var(--st-ink-soft); }
.rs-ai-error { color: var(--st-bad); font-size: 12px; margin: 4px 0; }

@media (max-width: 900px) {
  .rs-page { padding: 34px 24px; min-height: 900px; }
  .rs-block-grip { display: none; }
}
