/* ── Design tokens ────────────────────────────────────────────────────────── */
:root {
  color-scheme: light;
  --bg:           #f1f5f9;
  --panel:        #ffffff;
  --panel-raised: #ffffff;
  --ink:          #0f172a;
  --ink-2:        #334155;
  --muted:        #64748b;
  --line:         #e2e8f0;
  --line-strong:  #cbd5e1;
  --brand:        #0f766e;
  --brand-mid:    #0e6b63;
  --brand-strong: #0c5a53;
  --brand-tint:   #f0fdfa;
  --accent:       #b45309;
  --accent-tint:  #fffbeb;
  --warning:      #dc2626;
  --success:      #16a34a;
  --shadow-xs:    0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-sm:    0 1px 3px rgba(15, 23, 42, 0.07), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md:    0 4px 12px rgba(15, 23, 42, 0.08), 0 1px 3px rgba(15, 23, 42, 0.05);
  --radius:       8px;
  --radius-lg:    10px;
  --font:         "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
}

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

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

body { padding: 20px; }

button, input, select, textarea { font: inherit; }

/* ── App shell ────────────────────────────────────────────────────────────── */
.app-shell {
  max-width: 1760px;
  margin: 0 auto;
  display: grid;
  gap: 16px;
}

/* ── Hero (top navigation bar) ────────────────────────────────────────────── */
.hero {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--panel);
  box-shadow: var(--shadow-sm);
  padding: 20px 24px;
}

/* ── Panels ───────────────────────────────────────────────────────────────── */
.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--panel);
  box-shadow: var(--shadow-sm);
}

/* ── Flex utility rows ────────────────────────────────────────────────────── */
.hero-top,
.panel-title,
.question-tile-top,
.question-badges,
.runtime-question-top,
.summary-grid,
.preview-toolbar,
.runtime-footer,
.hero-actions,
.mode-switch,
.inline-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.inline-actions { justify-content: flex-start; }

/* ── Typography ───────────────────────────────────────────────────────────── */
.eyebrow {
  margin: 0 0 4px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--muted);
}

.hero h1,
.panel-title h2,
.panel-title h3,
.editor-card h3,
.runtime-card h3,
.summary-card h3 {
  margin: 0;
  font-family: var(--font);
}

.hero h1 {
  font-size: clamp(1.25rem, 2.5vw, 1.6rem);
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.01em;
}

.panel-title h2 { font-size: 0.9rem; font-weight: 600; color: var(--ink); }
.panel-title h3 { font-size: 0.85rem; font-weight: 600; color: var(--ink); }

.editor-card h3  { font-size: 0.85rem; font-weight: 600; color: var(--ink-2); }
.summary-card h3 { font-size: 0.85rem; font-weight: 600; color: var(--ink); }

.hero p,
.panel-title p,
.helper-text,
.section-description,
.question-description,
.empty-state p {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.55;
}

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.pill-button,
.ghost-button,
.primary-button,
.secondary-button,
.icon-button {
  border-radius: var(--radius);
  border: 1px solid transparent;
  padding: 7px 14px;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background 120ms ease, border-color 120ms ease, box-shadow 120ms ease;
  line-height: 1.4;
}

/* Segmented-control style for pill buttons */
.mode-switch {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 2px);
  padding: 3px;
  flex-wrap: nowrap;
}

.pill-button {
  background: transparent;
  color: var(--muted);
  border-color: transparent;
  border-radius: 6px;
  padding: 5px 12px;
}

.pill-button.is-active {
  background: var(--panel);
  color: var(--ink);
  border-color: var(--line);
  box-shadow: var(--shadow-xs);
}

.pill-button:hover:not(.is-active) {
  background: rgba(255, 255, 255, 0.7);
  color: var(--ink-2);
}

.ghost-button {
  background: transparent;
  border-color: var(--line);
  color: var(--ink-2);
}

.ghost-button:hover {
  background: var(--bg);
  border-color: var(--line-strong);
}

.primary-button {
  background: var(--brand);
  color: #ffffff;
  border-color: var(--brand-mid);
  box-shadow: var(--shadow-xs);
}

.primary-button:hover { background: var(--brand-mid); }

.secondary-button {
  background: var(--panel);
  border-color: var(--line-strong);
  color: var(--ink-2);
  box-shadow: var(--shadow-xs);
}

.secondary-button:hover {
  background: var(--bg);
  border-color: var(--ink);
  color: var(--ink);
}

.icon-button {
  min-width: 32px;
  padding: 6px 10px;
  background: var(--panel);
  border-color: var(--line);
  color: var(--muted);
  font-size: 0.8rem;
}

.icon-button:hover {
  background: var(--bg);
  color: var(--ink);
}

button[disabled] {
  cursor: not-allowed;
  opacity: 0.42;
  pointer-events: none;
}

/* ── Hero metrics ─────────────────────────────────────────────────────────── */
.metrics {
  margin-top: 16px;
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}

.metric-card,
.question-tile,
.editor-card,
.runtime-card,
.response-card,
.summary-card,
.preview-summary,
.section-card,
.result-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.metric-card {
  padding: 16px 18px;
}

.metric-card strong {
  display: block;
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1;
  color: var(--ink);
  margin-bottom: 4px;
}

.metric-card span {
  font-size: 0.78rem;
  color: var(--muted);
}

/* ── Layout grids ─────────────────────────────────────────────────────────── */
.studio-grid,
.workspace-grid,
.submission-grid,
.results-grid,
.results-metrics,
.results-controls-grid,
.results-filter-grid,
.analytics-overview-grid,
.public-feature-grid {
  display: grid;
  gap: 16px;
}

.studio-grid {
  grid-template-columns: minmax(240px, 0.75fr) minmax(340px, 1fr) minmax(320px, 1fr);
}

.flow-studio-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.7fr);
  align-items: start;
}

.flow-canvas-panel            { grid-column: 1 / -1; }
.flow-canvas-panel .panel-inner { padding-bottom: 20px; }

.flow-editor-stack,
.flow-preview-stack {
  display: grid;
  gap: 16px;
}

.workspace-grid             { grid-template-columns: minmax(0, 1.35fr) minmax(280px, 0.65fr); }
.results-metrics            { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.results-grid               { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.results-controls-grid      { grid-template-columns: minmax(300px, 1.15fr) minmax(260px, 0.85fr); align-items: start; }
.results-filter-grid        { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.analytics-overview-grid    { grid-template-columns: 1fr; }
.public-feature-grid        { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }

/* ── Panel inner & cards ──────────────────────────────────────────────────── */
.panel-inner,
.runtime-card,
.response-card,
.summary-card,
.editor-card,
.section-card,
.result-card {
  padding: 20px;
}

.panel-title {
  margin-bottom: 16px;
  align-items: flex-start;
}

/* ── Survey map & editor stacks ───────────────────────────────────────────── */
.survey-map,
.editor-stack,
.form-grid,
.question-options,
.logic-grid,
.runtime-form,
.tree-node-stack,
.tree-test-stack {
  display: grid;
  gap: 12px;
}

.section-questions { display: grid; gap: 6px; }

/* ── Question tile ────────────────────────────────────────────────────────── */
.question-tile {
  padding: 10px 12px;
  text-align: left;
  cursor: default;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

.question-tile:hover {
  border-color: var(--line-strong);
  box-shadow: var(--shadow-xs);
}

.question-tile.is-active {
  border-color: var(--brand);
  background: var(--brand-tint);
  box-shadow: 0 0 0 1px var(--brand);
}

.question-tile-top { align-items: flex-start; }

.question-tile-top strong {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--ink);
  line-height: 1.4;
}

.question-badges { gap: 4px; margin-top: 6px; }

/* Drag handle — subtle, hover-reveal */
.builder-drag-handle {
  cursor: grab;
  color: var(--muted);
  opacity: 0;
  transition: opacity 150ms ease;
  font-size: 0.85rem;
  letter-spacing: 0.04em;
}

.section-card:hover .builder-drag-handle,
.question-tile:hover .builder-drag-handle {
  opacity: 0.5;
}

.builder-drag-handle:hover { opacity: 1 !important; }

/* ── Drop zones ───────────────────────────────────────────────────────────── */
.drop-zone {
  padding: 8px 12px;
  border: 1.5px dashed var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  font-size: 0.76rem;
  text-align: center;
  opacity: 0.45;
  transition: opacity 150ms ease, border-color 150ms ease;
}

.drop-zone:hover,
.drop-zone.drag-over {
  opacity: 1;
  border-color: var(--brand);
}

/* ── Section card ─────────────────────────────────────────────────────────── */
.section-card {
  background: var(--bg);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
}

/* ── Chips / badges ───────────────────────────────────────────────────────── */
.type-chip,
.logic-chip,
.muted-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border-radius: 4px;
  padding: 2px 7px;
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.type-chip {
  background: var(--brand-tint);
  color: var(--brand-strong);
  border: 1px solid rgba(15, 118, 110, 0.15);
}

.logic-chip {
  background: var(--accent-tint);
  color: var(--accent);
  border: 1px solid rgba(180, 83, 9, 0.15);
}

.muted-chip {
  background: var(--bg);
  color: var(--muted);
  border: 1px solid var(--line);
}

/* Status chips */
.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  border: 1px solid transparent;
}

.status-chip-success {
  background: rgba(22, 163, 74, 0.08);
  border-color: rgba(22, 163, 74, 0.2);
  color: #15803d;
}

.status-chip-warning {
  background: var(--accent-tint);
  border-color: rgba(180, 83, 9, 0.2);
  color: var(--accent);
}

.status-chip-muted {
  background: var(--bg);
  border-color: var(--line);
  color: var(--muted);
}

/* ── Form grid ────────────────────────────────────────────────────────────── */
.form-grid.two-up,
.option-row {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.option-editor {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
}

.option-row {
  grid-template-columns: 1fr 1fr auto;
  align-items: end;
}

.option-rule-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(200px, 0.85fr) minmax(0, 1.15fr);
  align-items: end;
}

/* ── Logic rule card ──────────────────────────────────────────────────────── */
.logic-rule-card,
.tree-layer-card {
  display: grid;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
}

.condition-row {
  display: grid;
  gap: 10px;
}

.condition-mode-row {
  justify-content: flex-start;
  gap: 8px;
  padding: 8px 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

/* ── Tree ─────────────────────────────────────────────────────────────────── */
.tree-node-meta {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.tree-path-preview {
  min-height: 40px;
  display: flex;
  align-items: center;
  padding: 10px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--muted);
  font-size: 0.82rem;
}

/* ── Fields ───────────────────────────────────────────────────────────────── */
.field { display: grid; gap: 6px; }

.field label {
  font-weight: 500;
  font-size: 0.8rem;
  color: var(--ink-2);
}

.field input,
.field textarea,
.field select {
  width: 100%;
  border-radius: var(--radius);
  border: 1px solid var(--line-strong);
  padding: 8px 11px;
  background: var(--panel);
  color: var(--ink);
  font-size: 0.85rem;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

.field input:focus,
.field textarea:focus,
.field select:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.1);
}

.field textarea {
  min-height: 96px;
  resize: vertical;
}

.field-inline {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  color: var(--ink-2);
}

/* ── Flow canvas ──────────────────────────────────────────────────────────── */
.flow-toolbar,
.flow-node-summary,
.flow-selection-card {
  display: grid;
  gap: 12px;
}

.preview-panel {
  position: sticky;
  top: 20px;
}

.flow-canvas-shell {
  overflow: auto;
  min-height: 66vh;
  max-height: 80vh;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background:
    linear-gradient(180deg, #ffffff, #f8fafc),
    repeating-linear-gradient(90deg, rgba(15, 118, 110, 0.035) 0px, transparent 1px, transparent 32px),
    repeating-linear-gradient(0deg,  rgba(15, 118, 110, 0.035) 0px, transparent 1px, transparent 32px);
}

.flow-canvas-viewport {
  position: relative;
  min-width: 100%;
}

.flow-canvas {
  position: relative;
  min-width: 100%;
  transform-origin: top left;
}

.flow-canvas-edges {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.flow-edge              { fill: none; stroke-width: 2; }
.flow-edge-sequence     { stroke: var(--line-strong); }
.flow-edge-display      { stroke: var(--brand); stroke-dasharray: 8 5; opacity: 0.75; }
.flow-edge-skip         { stroke: var(--accent); opacity: 0.85; }

.flow-edge-label {
  fill: var(--muted);
  font-size: 0.72rem;
  font-weight: 600;
  text-anchor: middle;
}

.flow-marker-sequence { fill: var(--line-strong); }
.flow-marker-display  { fill: var(--brand); }
.flow-marker-skip     { fill: var(--accent); }

.flow-node {
  position: absolute;
  width: 236px;
  min-height: 126px;
  padding: 14px 16px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line-strong);
  background: var(--panel);
  box-shadow: var(--shadow-sm);
  text-align: left;
  display: grid;
  gap: 8px;
  touch-action: none;
  transition: box-shadow 150ms ease, border-color 150ms ease;
}

.flow-node.is-selected {
  border-color: var(--brand);
  box-shadow: var(--shadow-md), 0 0 0 2px rgba(15, 118, 110, 0.12);
}

.flow-node strong,
.flow-node p,
.flow-selection-card h3 { margin: 0; }

.flow-node strong { font-size: 0.82rem; font-weight: 600; }
.flow-node p      { color: var(--muted); font-size: 0.78rem; }

.flow-node-top {
  display: flex;
  justify-content: space-between;
  gap: 6px;
  align-items: flex-start;
}

.flow-node-summary span {
  display: block;
  padding: 6px 8px;
  border-radius: 5px;
  background: var(--bg);
  color: var(--muted);
  font-size: 0.76rem;
}

.flow-selection-card {
  padding: 16px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  background: var(--panel);
}

.flow-zoom-controls {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.flow-legend {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 500;
}

.flow-legend::before {
  content: "";
  width: 20px;
  height: 0;
  border-top: 2px solid currentColor;
}

.flow-legend-display::before { border-top-style: dashed; }
.flow-legend-sequence { color: var(--line-strong); }
.flow-legend-display  { color: var(--brand); }
.flow-legend-skip     { color: var(--accent); }

/* ── Runtime shell ────────────────────────────────────────────────────────── */
.runtime-shell,
.progress-wrap,
.workspace-shell {
  display: grid;
  gap: 16px;
}

/* ── Public hero ──────────────────────────────────────────────────────────── */
.public-hero,
.public-copy,
.bar-list,
.text-list,
.library-grid,
.constant-sum-stack,
.template-section,
.template-group,
.logic-directory,
.logic-workbench,
.logic-summary-list,
.filter-chip-row {
  display: grid;
  gap: 16px;
}

.library-grid        { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }

.template-grid,
.logic-insight-grid {
  display: grid;
  gap: 12px;
}

.template-grid      { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.logic-insight-grid { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }

/* ── Survey library card ──────────────────────────────────────────────────── */
.survey-library-card {
  display: grid;
  gap: 14px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--panel);
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

.survey-library-card.is-active {
  border-color: var(--brand);
  box-shadow: 0 0 0 1px var(--brand), var(--shadow-sm);
}

.survey-library-card:not(.is-active):hover {
  border-color: var(--line-strong);
  box-shadow: var(--shadow-xs);
}

.library-card-footer { display: grid; gap: 10px; }

/* ── Template / logic list cards ──────────────────────────────────────────── */
.template-card,
.logic-list-card {
  display: grid;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

.logic-list-card {
  width: 100%;
  text-align: left;
  cursor: pointer;
}

.logic-list-card:hover { border-color: var(--line-strong); box-shadow: var(--shadow-xs); }

.logic-list-card.is-active {
  border-color: var(--brand);
  background: var(--brand-tint);
  box-shadow: 0 0 0 1px var(--brand);
}

/* ── Logic center ─────────────────────────────────────────────────────────── */
.logic-center-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(300px, 0.65fr) minmax(0, 1.35fr);
  align-items: start;
}

/* ── Theme studio ─────────────────────────────────────────────────────────── */
.theme-studio-grid,
.theme-preview-grid,
.theme-preset-grid,
.theme-token-grid {
  display: grid;
  gap: 16px;
}

.theme-studio-grid  { grid-template-columns: minmax(300px, 0.72fr) minmax(0, 1.28fr); align-items: start; }
.theme-preview-grid { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.theme-preset-grid  { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.theme-token-grid   { grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); }

.theme-preset-card {
  display: grid;
  gap: 12px;
  width: 100%;
  text-align: left;
  padding: 16px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--panel);
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

.theme-preset-card:hover { border-color: var(--line-strong); box-shadow: var(--shadow-xs); }

.theme-preset-card.is-active {
  border-color: var(--brand);
  box-shadow: 0 0 0 1px var(--brand);
}

.theme-swatch-row {
  display: grid;
  gap: 6px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.theme-swatch-row span {
  height: 18px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.6);
  box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.08);
}

.theme-token-grid input[type="color"] {
  inline-size: 100%;
  block-size: 44px;
  padding: 4px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--panel);
}

.theme-preview-surface {
  padding: 20px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.54), rgba(255, 255, 255, 0.16)),
    linear-gradient(135deg, var(--survey-canvas-solid), var(--survey-hero-end));
  box-shadow: var(--survey-panel-shadow, var(--shadow-md));
}

.theme-preview-hero {
  display: grid;
  gap: 16px;
  padding: 20px;
  border-radius: var(--radius);
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.5), rgba(255, 255, 255, 0.14)),
    linear-gradient(135deg, var(--survey-hero-start), var(--survey-hero-end));
  border: 1px solid var(--line);
}

/* ── Survey theme scope ───────────────────────────────────────────────────── */
.survey-theme-scope.panel,
.survey-theme-scope .summary-card,
.survey-theme-scope .preview-summary,
.survey-theme-scope .runtime-card,
.survey-theme-scope .response-card,
.survey-theme-scope .result-card {
  box-shadow: var(--survey-panel-shadow, var(--shadow-md));
}

.survey-theme-scope.panel {
  border-radius: var(--radius-lg);
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.5), rgba(255, 255, 255, 0.1)),
    linear-gradient(135deg, var(--survey-canvas-solid), var(--survey-hero-end));
}

.survey-theme-scope .summary-card,
.survey-theme-scope .preview-summary,
.survey-theme-scope .runtime-card,
.survey-theme-scope .response-card,
.survey-theme-scope .result-card {
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.72);
}

/* ── Runtime inputs ───────────────────────────────────────────────────────── */
.ranking-list,
.card-sort-grid,
.compact-list,
.matrix-grid {
  display: grid;
  gap: 8px;
}

.matrix-header,
.matrix-row {
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(200px, 1.3fr) repeat(auto-fit, minmax(110px, 1fr));
  align-items: stretch;
}

.matrix-header {
  padding: 0 4px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 600;
}

.matrix-row {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}

.matrix-cell {
  display: grid;
  gap: 6px;
  justify-items: center;
  text-align: center;
  padding: 8px 6px;
  border-radius: 6px;
  background: var(--bg);
}

.survey-switcher {
  margin-top: 14px;
  display: grid;
  gap: 10px;
  max-width: 540px;
}

.progress-meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 0.8rem;
}

.progress-bar {
  height: 6px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--line);
}

.progress-fill {
  height: 100%;
  background: var(--brand);
  border-radius: 999px;
  transition: width 300ms ease;
}

.choice-group,
.likert-group {
  display: grid;
  gap: 8px;
}

.choice {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--panel);
  cursor: pointer;
  transition: border-color 120ms ease;
}

.choice:hover { border-color: var(--line-strong); }

.likert-group { grid-template-columns: repeat(auto-fit, minmax(80px, 1fr)); }

.likert-button {
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--panel);
  padding: 10px;
  text-align: center;
  font-size: 0.82rem;
  cursor: pointer;
  transition: border-color 120ms ease, background 120ms ease;
}

.likert-button.is-selected {
  background: var(--brand-tint);
  border-color: var(--brand);
  color: var(--brand-strong);
  font-weight: 500;
}

.validation {
  color: var(--warning);
  font-size: 0.8rem;
  font-weight: 500;
}

.response-card pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.6;
}

/* ── Bar charts (results) ─────────────────────────────────────────────────── */
.bar-row { display: grid; gap: 6px; }

.bar-label {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 0.8rem;
}

.bar-track {
  height: 8px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--line);
}

.bar-fill {
  height: 100%;
  background: var(--brand);
  border-radius: 999px;
}

/* ── Ranking / card sort ──────────────────────────────────────────────────── */
.rank-item,
.card-sort-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  transition: border-color 120ms ease;
}

.rank-item.is-dragging {
  opacity: 0.5;
  border-color: var(--brand);
}

.ranking-handle {
  cursor: grab;
  color: var(--muted);
  font-size: 0.85rem;
  opacity: 0.45;
  transition: opacity 150ms ease;
}

.rank-item:hover .ranking-handle { opacity: 1; }
.rank-item.is-dragging .ranking-handle { cursor: grabbing; }

.rank-item-main { display: grid; gap: 4px; }

.card-sort-row select { min-width: 200px; }

/* ── Text responses ───────────────────────────────────────────────────────── */
.text-response {
  display: block;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.55;
}

/* ── Empty state ──────────────────────────────────────────────────────────── */
.empty-state {
  padding: 40px 24px;
  text-align: center;
}

.empty-state h2, .empty-state h3 {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--ink-2);
  margin: 0 0 6px;
}

/* ── Divider ──────────────────────────────────────────────────────────────── */
.keyline {
  height: 1px;
  background: var(--line);
}

/* ── Public library / hero ────────────────────────────────────────────────── */
.public-hero {
  grid-template-columns: 1fr auto;
  align-items: start;
  gap: 24px;
}

/* ── Hero layout ──────────────────────────────────────────────────────────── */
.hero-layout {
  display: grid;
  gap: 20px;
  grid-template-columns: minmax(0, 1fr) minmax(240px, auto);
  align-items: start;
}

.hero-identity {
  display: grid;
  gap: 2px;
}

.hero-survey-name {
  margin: 6px 0 2px;
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--ink);
}

.hero-survey-desc {
  margin: 0;
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.5;
}

.hero-controls {
  display: grid;
  gap: 10px;
  min-width: 220px;
}

.hero-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  flex-wrap: wrap;
}

/* Compact stat strip */
.hero-stats {
  display: flex;
  gap: 0;
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.hero-stat {
  flex: 1;
  padding: 10px 16px;
  border-right: 1px solid var(--line);
  display: grid;
  gap: 1px;
}

.hero-stat:last-child { border-right: none; }

.hero-stat strong {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink);
  line-height: 1;
}

.hero-stat span {
  font-size: 0.72rem;
  color: var(--muted);
}

/* Legacy hero classes — keep for compatibility */
.hero-top { align-items: flex-start; }
.hero-copy { flex: 1 1 auto; min-width: 0; }
.hero-actions { margin-top: 14px; justify-content: flex-start; }

/* ── Builder controls — reduce chip clutter ───────────────────────────────── */
/* The summary-grid chips below studio tabs are purely decorative labels */
.workspace-shell > .panel .summary-grid {
  margin-top: 6px;
}

.workspace-shell > .panel .summary-grid .muted-chip,
.workspace-shell > .panel .summary-grid .type-chip,
.workspace-shell > .panel .summary-grid .logic-chip {
  font-size: 0.67rem;
  padding: 1px 6px;
  opacity: 0.7;
}

/* ── Panel title size tuning ──────────────────────────────────────────────── */
.panel-inner > .panel-title h2 {
  font-size: 0.95rem;
}

/* Survey map section header */
.section-card > .panel-title h3 {
  font-size: 0.88rem;
  font-weight: 600;
}

/* Tighten workspace shell gap */
.workspace-shell {
  gap: 12px;
}

/* ── Editor card header ────────────────────────────────────────────────────── */
.editor-card > h3 {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink-2);
  margin-bottom: 4px;
}

.editor-card > p {
  font-size: 0.78rem;
  color: var(--muted);
  margin: 0 0 14px;
}

/* ── Question tile refinements ─────────────────────────────────────────────── */
.question-tile-top strong {
  font-size: 0.83rem;
  line-height: 1.35;
}

/* ── Logic list card text ──────────────────────────────────────────────────── */
.logic-summary-list .text-response {
  font-size: 0.78rem;
  padding: 8px 10px;
  background: var(--bg);
  border-color: transparent;
}

/* ── Library card titles ───────────────────────────────────────────────────── */
.survey-library-card h3 {
  font-size: 0.9rem;
  font-weight: 600;
  margin: 0;
  color: var(--ink);
}

.survey-library-card p {
  font-size: 0.8rem;
  color: var(--muted);
  margin: 0;
}

/* ── Result card ───────────────────────────────────────────────────────────── */
.result-card h3 {
  font-size: 0.88rem;
  font-weight: 600;
  margin: 0 0 4px;
}

/* ── Summary card compact ──────────────────────────────────────────────────── */
.summary-card {
  padding: 16px;
}

.summary-card h3 {
  margin-bottom: 4px;
}

.summary-card p {
  font-size: 0.8rem;
  color: var(--muted);
  margin: 0;
  line-height: 1.5;
}

/* ── Section card add-question button alignment ────────────────────────────── */
.section-card > .panel-title {
  margin-bottom: 10px;
}

/* ── Reduce .form-grid default gap ─────────────────────────────────────────── */
.form-grid { gap: 10px; }

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 1180px) {
  .studio-grid,
  .flow-studio-grid,
  .logic-center-grid,
  .theme-studio-grid,
  .workspace-grid,
  .submission-grid,
  .results-grid,
  .results-controls-grid {
    grid-template-columns: 1fr;
  }

  .preview-panel { position: static; }
}

@media (max-width: 760px) {
  body { padding: 12px; }

  .hero,
  .panel-inner,
  .runtime-card,
  .summary-card,
  .response-card,
  .editor-card,
  .section-card,
  .result-card {
    padding: 16px;
  }

  .form-grid.two-up,
  .option-row,
  .option-rule-grid { grid-template-columns: 1fr; }

  .hero-top,
  .panel-title,
  .runtime-footer { flex-direction: column; align-items: stretch; }

  .hero-actions { justify-content: flex-start; align-self: stretch; }

  .rank-item,
  .card-sort-row { flex-direction: column; align-items: stretch; }

  .matrix-header,
  .matrix-row { grid-template-columns: 1fr; }

  .flow-canvas-shell { min-height: 55vh; max-height: 70vh; }

  .public-hero { grid-template-columns: 1fr; }
}
