/* ─── PROGRAM STUDIO ──────────────────────────────────── */

.studio {
  background: var(--paper-soft);
  min-height: calc(100vh - 64px);
  display: flex; flex-direction: column;
}

.studio-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0 24px;
  height: 64px;
  background: #fff;
  border-bottom: 1px solid var(--hairline);
  gap: 16px;
  flex-wrap: nowrap;
  min-width: 0;
}
.studio-head-left {
  display: flex; align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
  overflow: hidden;
}
.studio-head-left .muted.text-13 { display: none; }

.studio-body {
  flex: 1;
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 0;
  min-height: 0;
}

/* Inspector (left) */
.studio-inspector {
  padding: 18px;
  background: var(--paper-soft);
  border-right: 1px solid var(--hairline);
  overflow-y: auto;
  max-height: calc(100vh - 64px - 80px);
}
.inspector-head {
  padding: 18px 18px 16px;
  color: #fff;
}
.inspector-cat { font-size: 10px; font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase; color: rgba(255,255,255,0.75); }
.inspector-step { font-size: 10px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: rgba(255,255,255,0.16); }
.inspector-name { font-family: var(--font-serif); font-size: 22px; line-height: 1.1; }
.inspector-src { font-size: 12px; color: rgba(255,255,255,0.7); margin-top: 6px; }

.toggle { position: relative; width: 36px; height: 20px; cursor: pointer; }
.toggle input { opacity: 0; position: absolute; }
.toggle-slider { display: block; width: 100%; height: 100%; background: var(--hairline); border-radius: 999px; transition: background .15s; position: relative; }
.toggle-slider::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; background: #fff; border-radius: 50%; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,0.15); }
.toggle input:checked + .toggle-slider { background: var(--brand-teal); }
.toggle input:checked + .toggle-slider::after { transform: translateX(16px); }

.range-vis { margin-top: 10px; }
.range-track { height: 6px; background: var(--hairline); border-radius: 999px; position: relative; }
.range-fill { position: absolute; top: 0; bottom: 0; background: var(--brand-teal); border-radius: 999px; }

.dti-vis { margin-top: 10px; }
.dti-bar { display: flex; height: 24px; border-radius: 6px; overflow: hidden; }
.dti-zone { display: grid; place-items: center; font-size: 10px; font-weight: 700; letter-spacing: 0.08em; color: #fff; }
.dti-zone.safe { background: var(--brand-teal); }
.dti-zone.block { background: var(--warn); }

input[type=range].range, input[type=range] {
  appearance: none; -webkit-appearance: none;
  width: 100%; height: 24px; background: transparent;
}
input[type=range]::-webkit-slider-runnable-track { height: 4px; background: var(--hairline); border-radius: 999px; }
input[type=range]::-moz-range-track { height: 4px; background: var(--hairline); border-radius: 999px; }
input[type=range]::-webkit-slider-thumb { appearance: none; -webkit-appearance: none; width: 16px; height: 16px; border-radius: 50%; background: var(--brand-teal); margin-top: -6px; box-shadow: 0 1px 3px rgba(0,0,0,0.2); cursor: pointer; }
input[type=range]::-moz-range-thumb { width: 16px; height: 16px; border-radius: 50%; background: var(--brand-teal); border: 0; cursor: pointer; }

.choice-row { display: flex; gap: 6px; padding: 3px; background: var(--paper-warm); border-radius: 8px; }
.choice {
  flex: 1; padding: 7px 10px;
  border-radius: 6px;
  font-size: 12.5px; font-weight: 500;
  color: var(--muted);
}
.choice.active { background: #fff; color: var(--ink); box-shadow: var(--shadow-sm); font-weight: 600; }

.doc-pill { display: flex; gap: 8px; align-items: center; padding: 7px 10px; background: var(--paper-warm); border-radius: 8px; font-size: 12.5px; }

/* Pipeline (center) */
.studio-pipeline {
  padding: 24px 28px 60px;
  overflow-y: auto;
  max-height: calc(100vh - 64px - 80px);
}
.pipeline-head { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 22px; gap: 16px; }

.pipeline-canvas {
  background: #fff;
  border: 1px solid var(--hairline);
  border-radius: var(--r-md);
  padding: 28px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

.pipeline-source, .pipeline-output {
  width: 100%;
  display: flex; gap: 14px; align-items: center;
  padding: 14px 18px;
  background: var(--paper-warm);
  border: 1px dashed var(--hairline);
  border-radius: var(--r-md);
}
.ps-icon { width: 38px; height: 38px; border-radius: 10px; background: var(--brand-navy); color: #fff; display: grid; place-items: center; }

.pipeline-output { background: var(--paper-soft); padding: 8px; border-style: solid; gap: 8px; }
.po-side {
  flex: 1; display: flex; gap: 10px; align-items: center;
  padding: 12px 14px;
  border-radius: 10px;
  background: #fff;
  border: 1px solid var(--hairline);
}
.po-side.outcome-eligible { background: var(--ok-bg); color: var(--ok); border-color: rgba(27,65,73,0.2); }
.po-side.outcome-manual_review { background: var(--warn-bg); color: var(--warn); border-color: rgba(180,83,9,0.2); }
.po-side.outcome-rejected { background: var(--bad-bg); color: var(--bad); border-color: rgba(163,48,40,0.2); }

.pipeline-connector { width: 30px; height: 36px; flex-shrink: 0; align-self: center; }

/* Pipeline lanes */
.pipe-lane { width: 100%; margin-bottom: 18px; }
.pipe-lane-head {
  display: flex; align-items: center; gap: 6px;
  font-size: 11px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase;
  padding: 8px 4px;
}
.pipe-lane-dot { width: 8px; height: 8px; border-radius: 50%; }
.pipe-lane-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }

.pipe-node {
  position: relative; display: flex; flex-direction: column; gap: 4px;
  padding: 14px 14px 12px 20px;
  background: #fff;
  border: 1px solid var(--hairline);
  border-radius: var(--r-sm);
  text-align: left;
  transition: all .12s;
  overflow: hidden;
}
.pipe-node:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.pipe-node.selected { border-color: var(--brand-teal); box-shadow: 0 0 0 3px rgba(27,65,73,0.1); }
.pipe-node.disabled { opacity: 0.5; }
.pipe-node-bar { position: absolute; left: 0; top: 0; bottom: 0; width: 4px; }
.pipe-node-head { display: flex; align-items: center; gap: 6px; }
.pipe-node-title { font-size: 13.5px; font-weight: 600; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pipe-node-status {
  width: 18px; height: 18px; border-radius: 50%;
  display: grid; place-items: center;
  flex-shrink: 0;
}
.pipe-node-status.passed { background: var(--ok-bg); color: var(--ok); }
.pipe-node-status.warning { background: var(--warn-bg); color: var(--warn); }
.pipe-node-status.failed { background: var(--bad-bg); color: var(--bad); }
.pipe-node-source { font-size: 11px; color: var(--muted); }
.pipe-node-params { font-size: 12px; color: var(--ink-soft); margin-top: 4px; }
.pipe-node-sev { display: flex; gap: 4px; margin-top: 6px; }

/* Add rule */
.pipeline-add-lane { position: relative; width: 100%; display: flex; justify-content: center; margin: 14px 0; }
.add-rule-btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 18px;
  border: 1px dashed var(--muted-soft);
  border-radius: 999px;
  color: var(--muted);
  font-size: 13px; font-weight: 600;
  transition: all .15s;
}
.add-rule-btn:hover { background: var(--paper-warm); color: var(--ink); border-color: var(--ink); }

/* Rule library popover */
.rule-library {
  position: absolute; top: 50px; left: 50%; transform: translateX(-50%);
  width: 420px; max-height: 480px;
  background: #fff;
  border: 1px solid var(--hairline);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  padding: 16px;
  z-index: 20;
  overflow-y: auto;
}
.lib-section { margin-bottom: 14px; }
.lib-cat { display: flex; gap: 6px; align-items: center; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.14em; margin-bottom: 6px; }
.lib-item {
  display: flex; gap: 10px; align-items: center;
  padding: 9px 10px;
  background: var(--paper-soft);
  border-radius: 8px;
  transition: background .12s;
  text-align: left; width: 100%;
}
.lib-item:hover { background: var(--paper-warm); }
.lib-icon { width: 26px; height: 26px; border-radius: 6px; display: grid; place-items: center; flex-shrink: 0; }

/* Test panel (right) */
.studio-test {
  padding: 18px;
  background: var(--paper-soft);
  border-left: 1px solid var(--hairline);
  overflow-y: auto;
  max-height: calc(100vh - 64px - 80px);
}
.test-head {
  padding: 18px;
  background: linear-gradient(135deg, #1b4149, #2a5e68);
  color: #fff;
}
.test-head .label-eyebrow { color: rgba(255,255,255,0.65); }
.test-head .title { color: #fff; }
.pulse-dot {
  width: 8px; height: 8px; border-radius: 50%; background: #7bcfa1;
  animation: pulse 1.6s infinite;
}
.test-kpi-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 14px; }
.test-kpi {
  padding: 10px;
  background: rgba(255,255,255,0.08);
  border-radius: 8px;
  text-align: center;
  color: #fff;
}
.test-kpi-num { font-family: var(--font-serif); font-size: 24px; line-height: 1; }
.test-kpi.tone-ok { background: rgba(123,207,161,0.18); }
.test-kpi.tone-warn { background: rgba(240,178,113,0.18); }
.test-kpi.tone-bad { background: rgba(232,112,96,0.18); }

.test-persona-tabs {
  display: flex; flex-direction: column; gap: 4px;
  padding: 12px 14px 6px;
}
.test-tab {
  display: flex; gap: 10px; align-items: center;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--paper-soft);
  text-align: left;
  transition: all .12s;
}
.test-tab:hover { background: var(--paper-warm); }
.test-tab.active { background: var(--paper-warm); box-shadow: inset 0 0 0 1px var(--hairline); }

.test-citizen-summary { padding: 6px 14px 14px; }
.test-outcome-card { padding: 0 14px 14px; }
.test-outcome { display: flex; gap: 10px; align-items: center; padding: 14px; border-radius: 8px; }
.test-outcome.outcome-eligible { background: var(--ok-bg); color: var(--ok); }
.test-outcome.outcome-manual_review { background: var(--warn-bg); color: var(--warn); }
.test-outcome.outcome-rejected { background: var(--bad-bg); color: var(--bad); }

.test-trace-mini { border-top: 1px solid var(--hairline); }
.mini-trace-row {
  display: flex; gap: 8px; align-items: center;
  padding: 8px 14px;
  border-bottom: 1px solid var(--hairline-soft);
}
.mini-trace-row:last-child { border-bottom: 0; }
.mini-trace-pip {
  width: 18px; height: 18px; border-radius: 50%;
  display: grid; place-items: center;
  flex-shrink: 0;
}
.mini-trace-pip.status-passed { background: var(--ok-bg); color: var(--ok); }
.mini-trace-pip.status-warning { background: var(--warn-bg); color: var(--warn); }
.mini-trace-pip.status-failed { background: var(--bad-bg); color: var(--bad); }

.test-suggestion {
  margin: 14px;
  padding: 12px;
  background: linear-gradient(135deg, rgba(234,160,122,0.18), rgba(234,160,122,0.06));
  border: 1px solid rgba(234,160,122,0.3);
  border-radius: 10px;
}
.suggestion-rules { display: flex; flex-direction: column; gap: 4px; margin-top: 8px; }
.suggestion-rule {
  display: flex; gap: 6px; align-items: center;
  padding: 6px 10px;
  background: #fff;
  border-radius: 6px;
  font-size: 12px; font-weight: 500;
  color: var(--brand-copper-deep);
}

.test-foot { padding: 14px; border-top: 1px solid var(--hairline); }

/* RTL */
[dir="rtl"] .citizen-mode { text-align: right; }
[dir="rtl"] .citizen-subnav .row,
[dir="rtl"] .row { direction: rtl; }
[dir="rtl"] .arrow-flip { transform: scaleX(-1); }
[dir="rtl"] .hero-decision { border-left: 1px solid rgba(255,255,255,0.12); border-right: 4px solid var(--brand-copper); }
[dir="rtl"] .hero-decision.outcome-eligible { border-right-color: #7bcfa1; }
[dir="rtl"] .hero-decision.outcome-manual_review { border-right-color: #f0b271; }
[dir="rtl"] .hero-decision.outcome-rejected { border-right-color: #e87060; }

/* ─── Studio responsive ──────────────────────────────────── */

@media (max-width: 1280px) {
  .studio-body { grid-template-columns: 280px minmax(0, 1fr); }
}

@media (max-width: 1024px) {
  .studio-body { grid-template-columns: 260px minmax(0, 1fr); }
  .studio-copilot { display: none; }
}

@media (max-width: 768px) {
  .studio-head { flex-direction: column; align-items: flex-start; gap: 10px; padding: 12px 16px; }
  .studio-body { grid-template-columns: 1fr; }
  .studio-inspector { display: none; }
  .test-kpi-row { grid-template-columns: repeat(2, 1fr); }
}
