/* ==========================================================================
   Anu Astra Quantum Studio — Modern Light Theme Design System
   ========================================================================== */

:root,
[data-theme="light"] {
  --bg-app: #f5f7fa;
  --bg-frame: #ffffff;
  --bg-subtle: #f8f9fb;
  --bg-elevated: #ffffff;
  --bg-hover: #f0f2f5;
  --bg-editor: #fafbfc;
  --bg-gutter: #f8f9fb;
  --bg-codebox: #f8f9fb;

  --border-color: #e2e5ea;
  --border-medium: #d1d5dc;
  --border-focus: #3b82f6;

  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --accent-purple: #8b5cf6;
  --accent-green: #10b981;
  --accent-amber: #f59e0b;
  --accent-rose: #f43f5e;
  --accent-cyan: #06b6d4;

  --text-main: #1a1d26;
  --text-muted: #5b6178;
  --text-light: #8891a5;
  --text-dim: #b0b8c9;

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
  --font-heading: 'Space Grotesk', var(--font-sans);

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
  --shadow-frame: 0 4px 24px -2px rgba(0, 0, 0, 0.08), 0 0 0 1px rgba(0,0,0,0.04);
  --shadow-glow-blue: 0 0 16px rgba(59, 130, 246, 0.12);
  --shadow-glow-purple: 0 0 16px rgba(139, 92, 246, 0.12);
  --radius: 10px;
  --radius-sm: 6px;
  --radius-xs: 4px;

  --circuit-bg: #fafbfc;
  --circuit-wire: #c1c7d0;
  --circuit-gate: #ffffff;
  --circuit-text: #1a1d26;
  --circuit-ctrl: #8b5cf6;
}

[data-theme="dark"] {
  --bg-app: transparent;
  --bg-frame: rgba(7, 14, 19, 0.7);
  --bg-subtle: rgba(255, 255, 255, 0.05);
  --bg-elevated: rgba(30, 41, 59, 0.9);
  --bg-hover: rgba(255, 255, 255, 0.1);
  --bg-editor: rgba(0, 0, 0, 0.4);
  --bg-gutter: rgba(0, 0, 0, 0.6);
  --bg-codebox: rgba(0, 0, 0, 0.5);

  --border-color: rgba(255, 255, 255, 0.15);
  --border-medium: rgba(255, 255, 255, 0.25);
  --border-focus: #72f1ff;

  --primary: #72f1ff;
  --primary-hover: #9fffc1;
  --accent-purple: #b69cff;
  --accent-green: #9fffc1;
  --accent-amber: #ffd166;
  --accent-rose: #ff7a90;
  --accent-cyan: #72f1ff;

  --text-main: #f8fbff;
  --text-muted: #b7c5cf;
  --text-light: #8891a5;
  --text-dim: #5b6178;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.5);
  --shadow-frame: 0 4px 24px -2px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255,255,255,0.05);

  --circuit-bg: rgba(0, 0, 0, 0.4);
  --circuit-wire: #5b6178;
  --circuit-gate: rgba(255, 255, 255, 0.1);
  --circuit-text: #f8fbff;
  --circuit-ctrl: #b69cff;
}

/* Global Reset */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100vh;
  background-color: transparent;
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* Navbar */
.navbar {
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  background: var(--bg-frame);
  border-bottom: 1px solid var(--border-color);
  z-index: 20;
}

.nav-brand {
  display: flex;
  align-items: center;
}

.nav-title-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.nav-title {
  font-family: var(--font-heading);
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--primary);
  line-height: 1.2;
}

.nav-tag {
  font-size: 0.6rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 2px 8px;
  background: rgba(59, 130, 246, 0.08);
  color: var(--primary);
  border: 1px solid rgba(59, 130, 246, 0.18);
  border-radius: 20px;
  white-space: nowrap;
}

.nav-desc {
  font-size: 0.72rem;
  color: var(--text-light);
  line-height: 1.3;
  margin-top: 2px;
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.status-pill {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 0.73rem;
  font-weight: 600;
  padding: 6px 14px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  color: var(--text-muted);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--accent-green);
  animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4); }
  50% { box-shadow: 0 0 0 5px rgba(16, 185, 129, 0.1); }
}

/* Main Unified Frame */
.workspace-frame {
  height: calc(100vh - 56px);
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--bg-app);
  padding: 14px 18px;
  gap: 16px;
}

@media (max-width: 960px) {
  .workspace-frame {
    grid-template-columns: 1fr;
    height: auto;
    overflow-y: auto;
  }
}

/* Frame Columns */
.frame-col {
  display: flex;
  flex-direction: column;
  background: var(--bg-frame);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  box-shadow: var(--shadow-frame);
  overflow: hidden;
  height: 100%;
}

.col-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border-color);
  min-height: 50px;
}

.col-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.col-icon { font-size: 1.1rem; }

.col-title h2 {
  font-family: var(--font-heading);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-main);
}

.select-box {
  background: var(--bg-frame);
  border: 1px solid var(--border-medium);
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 0.82rem;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  outline: none;
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.select-box:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.select-box option {
  background: var(--bg-frame);
  color: var(--text-main);
}

/* Editor Subbar */
.editor-subbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border-color);
}

.editor-info-tags {
  display: flex;
  align-items: center;
  gap: 10px;
}

.tag-badge {
  font-size: 0.73rem;
  font-family: var(--font-mono);
  color: var(--text-light);
}

.tag-status {
  font-size: 0.68rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 20px;
}

.tag-status.valid {
  background: rgba(16, 185, 129, 0.08);
  color: var(--accent-green);
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.tag-status.invalid {
  background: rgba(244, 63, 94, 0.08);
  color: var(--accent-rose);
  border: 1px solid rgba(244, 63, 94, 0.2);
}

.editor-quick-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.btn-icon-text {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-light);
  font-size: 0.74rem;
  font-weight: 500;
  padding: 4px 8px;
  border-radius: var(--radius-xs);
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-icon-text:hover {
  background: var(--bg-hover);
  border-color: var(--border-color);
  color: var(--text-main);
}

/* Editor Body */
.editor-body {
  position: relative;
  display: flex;
  flex: 1;
  background: var(--bg-editor);
  overflow: hidden;
}

.line-gutter {
  width: 42px;
  padding: 12px 8px 12px 4px;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  line-height: 1.65;
  text-align: right;
  color: var(--text-dim);
  user-select: none;
  background: var(--bg-gutter);
  border-right: 1px solid var(--border-color);
  overflow: hidden;
}

.editor-textarea {
  flex: 1;
  width: 100%;
  height: 100%;
  padding: 12px 16px;
  background: transparent;
  color: var(--text-main);
  font-family: var(--font-mono);
  font-size: 0.86rem;
  line-height: 1.65;
  border: none;
  outline: none;
  resize: none;
  white-space: pre;
  tab-size: 2;
}

.editor-textarea::placeholder {
  color: var(--text-dim);
}

/* Mode Tabs */
.mode-tabs {
  display: flex;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-subtle);
}

.mode-tab {
  flex: 1;
  padding: 10px 14px;
  font-family: var(--font-sans);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-light);
  background: transparent;
  border: none;
  cursor: pointer;
  position: relative;
  transition: color 0.2s, background 0.2s;
}

.mode-tab:hover {
  color: var(--text-main);
  background: var(--bg-hover);
}

.mode-tab.active {
  color: var(--primary);
  background: var(--bg-frame);
}

.mode-tab.active::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--primary);
}

.mode-view {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
}

/* Circuit Builder */
.builder-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border-color);
}

.builder-qubit-ctrl {
  display: flex;
  align-items: center;
  gap: 8px;
}

.builder-label {
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--text-muted);
}

.select-sm {
  padding: 4px 10px;
  font-size: 0.78rem;
}

.builder-actions-bar {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Gate Palette */
.gate-palette {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-frame);
  flex-wrap: wrap;
}

.palette-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.gate-buttons {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}

.gate-btn {
  width: 34px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-main);
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xs);
  cursor: pointer;
  transition: all 0.15s ease;
}

.gate-btn:hover {
  background: rgba(59, 130, 246, 0.06);
  border-color: var(--primary);
  color: var(--primary);
}

.gate-btn.selected {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.25);
}

.gate-btn.gate-multi {
  width: 36px;
  color: var(--accent-purple);
  border-color: rgba(139, 92, 246, 0.25);
  background: rgba(139, 92, 246, 0.05);
}

.gate-btn.gate-multi:hover {
  background: rgba(139, 92, 246, 0.1);
  border-color: var(--accent-purple);
}

.gate-btn.gate-multi.selected {
  background: var(--accent-purple);
  color: #ffffff;
  border-color: var(--accent-purple);
  box-shadow: 0 2px 8px rgba(139, 92, 246, 0.25);
}

.gate-btn.gate-eraser {
  color: var(--accent-rose);
  border-color: rgba(244, 63, 94, 0.25);
  background: rgba(244, 63, 94, 0.05);
}

.gate-btn.gate-eraser:hover,
.gate-btn.gate-eraser.selected {
  background: var(--accent-rose);
  color: #ffffff;
  border-color: var(--accent-rose);
  box-shadow: 0 2px 8px rgba(244, 63, 94, 0.25);
}

.palette-divider {
  width: 1px;
  height: 22px;
  background: var(--border-color);
  margin: 0 4px;
}

/* Builder Status */
.builder-status {
  padding: 6px 14px;
  font-size: 0.7rem;
  color: var(--text-light);
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border-color);
}

.builder-status .status-pending {
  color: var(--accent-amber);
  font-weight: 600;
}

/* Builder Grid */
.builder-grid-wrap {
  flex: 1;
  overflow: auto;
  padding: 14px;
  background: var(--bg-editor);
}

.builder-grid {
  display: inline-block;
  min-width: 100%;
}

.builder-grid-table {
  border-collapse: separate;
  border-spacing: 2px 12px;
}

.builder-grid-table th {
  padding: 2px 4px;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--text-dim);
  text-align: center;
}

.builder-grid-table th.qubit-label-cell {
  text-align: right;
  padding-right: 10px;
  color: var(--text-muted);
  font-size: 0.74rem;
  min-width: 44px;
}

.builder-grid-table td { padding: 2px; }

.grid-cell {
  width: 44px;
  height: 40px;
  border: 1.5px dashed var(--border-color);
  border-radius: var(--radius-xs);
  background: var(--bg-frame);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  color: transparent;
  position: relative;
  transition: all 0.15s ease;
}

.grid-cell:hover {
  border-color: var(--primary);
  background: rgba(59, 130, 246, 0.04);
  border-style: solid;
}

.grid-cell.pending-target {
  border-color: var(--accent-amber);
  background: rgba(245, 158, 11, 0.06);
  border-style: solid;
  animation: pulse-amber 1.2s ease infinite;
}

@keyframes pulse-amber {
  0%, 100% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.15); }
  50% { box-shadow: 0 0 0 5px rgba(245, 158, 11, 0.05); }
}

.grid-cell.has-gate {
  border-style: solid;
  border-color: var(--primary);
  background: rgba(59, 130, 246, 0.08);
  color: var(--primary);
}

.grid-cell.has-gate.gate-type-multi {
  border-color: var(--accent-purple);
  color: var(--accent-purple);
  background: rgba(139, 92, 246, 0.08);
}

.grid-cell.has-gate.gate-ctrl {
  border-color: var(--accent-purple);
  color: var(--accent-purple);
}

.grid-cell .gate-label {
  font-size: 0.72rem;
  font-weight: 800;
  pointer-events: none;
}

.grid-cell .ctrl-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent-purple);
  pointer-events: none;
}

.grid-wire-cell { position: relative; }

.grid-wire-cell::after {
  content: "";
  position: absolute;
  left: 50%;
  top: -3px;
  bottom: -3px;
  width: 2px;
  background: var(--accent-purple);
  transform: translateX(-50%);
  border-radius: 1px;
}

/* Live QASM Panel */
.live-qasm-panel {
  display: flex;
  flex-direction: column;
  background: var(--bg-frame);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  box-shadow: var(--shadow-frame);
  max-height: 200px;
  min-height: 120px;
}

.live-qasm-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border-color);
  border-radius: var(--radius) var(--radius) 0 0;
}

.live-qasm-title {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.live-qasm-pre {
  flex: 1;
  overflow: auto;
  padding: 12px 16px;
  margin: 0;
  background: var(--bg-editor);
  color: var(--text-main);
  font-size: 0.82rem;
  line-height: 1.6;
  border-radius: 0 0 var(--radius) var(--radius);
}

/* Left Panel Footer */
.col-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  background: var(--bg-subtle);
  border-top: 1px solid var(--border-color);
}

.shortcut-tip {
  font-size: 0.74rem;
  color: var(--text-light);
}

kbd {
  display: inline-block;
  padding: 2px 6px;
  font-size: 0.68rem;
  font-family: var(--font-mono);
  background: var(--bg-frame);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-xs);
  color: var(--text-muted);
}

/* Run Group */
.run-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.shots-input-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.shots-label {
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
}

.shots-input {
  width: 74px;
  padding: 7px 10px;
  font-size: 0.82rem;
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--text-main);
  background: var(--bg-frame);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-sm);
  text-align: center;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.shots-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.shots-input::-webkit-inner-spin-button,
.shots-input::-webkit-outer-spin-button {
  opacity: 1;
}

/* Run Button */
.btn-run {
  background: var(--primary);
  color: #ffffff !important;
  border: none;
  padding: 9px 24px;
  font-size: 0.88rem;
  font-weight: 700;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.25);
  transition: all 0.2s ease;
}

.btn-run * {
  color: #ffffff !important;
}

.btn-run:hover {
  background: var(--primary-hover);
  box-shadow: 0 4px 16px rgba(59, 130, 246, 0.3);
  transform: translateY(-1px);
}

.btn-run:active {
  transform: translateY(0);
  box-shadow: 0 1px 4px rgba(59, 130, 246, 0.2);
}

.run-icon { font-size: 0.8rem; }

.btn-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Right Panel - Scrollable Outputs Container */
.output-scroll-container {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  scrollbar-width: thin;
  scrollbar-color: var(--border-medium) transparent;
}

.output-scroll-container::-webkit-scrollbar { width: 6px; }
.output-scroll-container::-webkit-scrollbar-track { background: transparent; }
.output-scroll-container::-webkit-scrollbar-thumb {
  background: var(--border-medium);
  border-radius: 3px;
}

/* Empty Placeholder */
.empty-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  margin: auto;
  padding: 48px 24px;
  max-width: 400px;
}

.empty-atom {
  font-size: 3rem;
  margin-bottom: 16px;
  animation: float 3s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

.empty-placeholder h3 {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text-main);
}

.empty-placeholder p {
  font-size: 0.82rem;
  color: var(--text-light);
  line-height: 1.6;
}

.empty-placeholder strong {
  color: var(--primary);
}

/* Results Wrapper */
.results-wrapper {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* Status Pill Success */
.status-pill-success {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 20px;
  background: rgba(16, 185, 129, 0.08);
  color: var(--accent-green);
  border: 1px solid rgba(16, 185, 129, 0.2);
  margin-right: 8px;
}

/* KPI Grid */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

@media (max-width: 600px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}

.kpi-card {
  background: var(--bg-frame);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.kpi-card:hover {
  border-color: var(--border-medium);
  box-shadow: var(--shadow-sm);
}

.kpi-label {
  font-size: 0.66rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-light);
}

.kpi-val {
  font-family: var(--font-heading);
  font-size: 1.2rem;
  font-weight: 700;
}

.highlight-blue { color: var(--primary); }
.highlight-purple { color: var(--accent-purple); }
.highlight-green { color: var(--accent-green); }
.highlight-amber { color: var(--accent-amber); }

.kpi-sub {
  font-size: 0.68rem;
  color: var(--text-dim);
}

/* Output Cards */
.out-card {
  background: var(--bg-frame);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: border-color 0.2s;
}

.out-card:hover {
  border-color: var(--border-medium);
}

.out-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.out-card-header h3 {
  font-family: var(--font-heading);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-main);
}

.badge-mini {
  font-size: 0.66rem;
  font-weight: 600;
  padding: 3px 8px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  color: var(--text-light);
}

/* State Chips */
.state-chips-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

@media (max-width: 600px) {
  .state-chips-row { grid-template-columns: repeat(2, 1fr); }
}

.state-chip {
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xs);
  padding: 8px 10px;
  font-size: 0.74rem;
  color: var(--text-muted);
}

.state-chip strong {
  color: var(--text-light);
  font-size: 0.66rem;
  display: block;
  margin-bottom: 2px;
}

.state-chip .mono {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--primary);
}

/* Measurement Lists */
.state-lists-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 10px;
}

.state-list-col {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg-frame);
}

.state-list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border-color);
  font-size: 0.72rem;
  color: var(--text-light);
}

.state-list-header strong {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.state-list-count {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--accent-purple);
  background: rgba(139, 92, 246, 0.08);
  padding: 2px 8px;
  border-radius: 20px;
}

.state-scroll-list {
  max-height: 150px;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: var(--border-medium) transparent;
}

.state-scroll-list::-webkit-scrollbar { width: 5px; }
.state-scroll-list::-webkit-scrollbar-track { background: transparent; }
.state-scroll-list::-webkit-scrollbar-thumb {
  background: var(--border-medium);
  border-radius: 3px;
}

.scroll-list-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 12px;
  font-size: 0.74rem;
  font-family: var(--font-mono);
  border-bottom: 1px solid var(--border-color);
  transition: background 0.1s;
}

.scroll-list-item:last-child { border-bottom: none; }
.scroll-list-item:nth-child(even) { background: rgba(0, 0, 0, 0.015); }
.scroll-list-item:hover { background: var(--bg-hover); }

.scroll-item-idx {
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--text-dim);
  min-width: 30px;
}

.scroll-item-val {
  font-weight: 700;
  color: var(--primary);
}

/* Probabilities */
.probabilities-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.histogram-chart {
  display: flex;
  align-items: stretch;
  gap: 0;
  min-height: 180px;
  max-height: 250px;
}

.histogram-y-axis {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 0 8px 22px 0;
  min-width: 38px;
}

.histogram-y-tick {
  font-size: 0.65rem;
  font-family: var(--font-mono);
  color: var(--text-dim);
  text-align: right;
  line-height: 1;
}

.histogram-bars-area {
  flex: 1;
  position: relative;
  border-left: 1.5px solid var(--border-medium);
  border-bottom: 1.5px solid var(--border-medium);
}

.histogram-grid {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.histogram-grid-line {
  position: absolute;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--border-color);
  opacity: 0.5;
}

.histogram-bars {
  display: flex;
  align-items: flex-end;
  justify-content: space-evenly;
  height: 100%;
  padding: 0 10px;
  position: relative;
  z-index: 1;
}

.histogram-bar-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  max-width: 64px;
  min-width: 28px;
  height: 100%;
  justify-content: flex-end;
  gap: 0;
}

.histogram-count-label {
  font-size: 0.68rem;
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 4px;
  white-space: nowrap;
}

.histogram-bar {
  width: 72%;
  min-width: 18px;
  max-width: 48px;
  background: linear-gradient(180deg, var(--primary) 0%, var(--accent-purple) 100%);
  border-radius: 4px 4px 0 0;
  transition: height 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
  position: relative;
  cursor: default;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  box-shadow: 0 -1px 6px rgba(59, 130, 246, 0.1);
}

.histogram-bar:hover {
  filter: brightness(1.1);
  box-shadow: 0 -2px 12px rgba(59, 130, 246, 0.2);
}

.histogram-bar-pct {
  font-size: 0.6rem;
  font-family: var(--font-mono);
  font-weight: 700;
  color: #ffffff;
  padding: 2px 0 3px;
  text-align: center;
  display: none;
}

.histogram-bar[style*="height: 1"] .histogram-bar-pct,
.histogram-bar[style*="height: 2"] .histogram-bar-pct,
.histogram-bar[style*="height: 3"] .histogram-bar-pct,
.histogram-bar[style*="height: 4"] .histogram-bar-pct,
.histogram-bar[style*="height: 5"] .histogram-bar-pct,
.histogram-bar[style*="height: 6"] .histogram-bar-pct,
.histogram-bar[style*="height: 7"] .histogram-bar-pct,
.histogram-bar[style*="height: 8"] .histogram-bar-pct,
.histogram-bar[style*="height: 9"] .histogram-bar-pct {
  display: block;
}

.histogram-state-label {
  font-size: 0.72rem;
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--primary);
  margin-top: 6px;
  white-space: nowrap;
}

.histogram-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 4px 0;
  border-top: 1px solid var(--border-color);
  margin-top: 10px;
  font-size: 0.74rem;
  color: var(--text-light);
}

.histogram-summary .summary-shots { color: var(--text-main); }
.histogram-summary .summary-states { color: var(--text-dim); }

/* Counts Row */
.counts-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--border-color);
  font-size: 0.74rem;
}

.counts-label {
  font-weight: 600;
  color: var(--text-light);
}

.counts-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.counts-pill {
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xs);
  padding: 3px 8px;
  font-family: var(--font-mono);
  font-size: 0.74rem;
  transition: border-color 0.15s;
}

.counts-pill:hover { border-color: var(--border-medium); }
.counts-pill .state-key { font-weight: 700; color: var(--primary); }
.counts-pill .state-val { color: var(--text-muted); }

/* Circuit Visualizer */
.circuit-visualizer {
  background: var(--circuit-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 16px;
  overflow-x: auto;
  min-height: 120px;
  display: flex;
  align-items: center;
}

.circuit-svg { display: block; margin: 0 auto; }

.qubit-label {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  fill: var(--text-muted);
}

.wire-line { stroke: var(--circuit-wire); stroke-width: 1.5; }

.gate-box {
  fill: var(--circuit-gate);
  stroke: var(--primary);
  stroke-width: 1.5;
  rx: 5;
}

.gate-text {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  fill: var(--circuit-text);
  text-anchor: middle;
  dominant-baseline: central;
}

.ctrl-line { stroke: var(--circuit-ctrl); stroke-width: 2; }
.ctrl-dot { fill: var(--circuit-ctrl); }

/* Telemetry Grid */
.telemetry-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

@media (max-width: 600px) {
  .telemetry-grid { grid-template-columns: 1fr; }
}

.tele-item {
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: border-color 0.2s;
}

.tele-item:hover { border-color: var(--border-medium); }

.tele-title {
  font-size: 0.68rem;
  font-weight: 500;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.tele-number {
  font-family: var(--font-mono);
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-main);
}

/* Code Pre Blocks */
.code-view {
  background: var(--bg-editor);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  max-height: 200px;
  overflow: auto;
}

.mono-text {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  line-height: 1.6;
  color: var(--text-main);
  white-space: pre-wrap;
  word-break: break-all;
}

/* Proof Card */
.proof-card {
  border-left: 3px solid var(--accent-purple);
}

.verify-btn {
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--primary);
  text-decoration: none;
  padding: 4px 10px;
  border-radius: var(--radius-xs);
  background: rgba(59, 130, 246, 0.06);
  border: 1px solid rgba(59, 130, 246, 0.15);
  transition: background 0.15s;
}

.verify-btn:hover { background: rgba(59, 130, 246, 0.12); }

.proof-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.proof-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 0.76rem;
}

.proof-k {
  width: 128px;
  color: var(--text-light);
  flex-shrink: 0;
  font-weight: 500;
}

.proof-v {
  color: var(--text-muted);
  word-break: break-all;
}

.proof-v.mono {
  font-family: var(--font-mono);
  font-size: 0.74rem;
}

.badge-service {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.72rem;
  padding: 2px 7px;
  background: rgba(59, 130, 246, 0.06);
  color: var(--primary);
  border: 1px solid rgba(59, 130, 246, 0.15);
  border-radius: var(--radius-xs);
}

.sig-box {
  background: var(--bg-subtle);
  padding: 5px 10px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
}

.link-text { color: var(--primary); }

/* Error Banner */
.error-banner {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
  padding: 12px 14px;
  background: rgba(244, 63, 94, 0.06);
  border: 1px solid rgba(244, 63, 94, 0.18);
  border-radius: var(--radius-sm);
  color: #be123c;
}

.error-icon { font-size: 1.1rem; }
.error-body { flex: 1; }
.error-title { font-weight: 700; font-size: 0.84rem; }

.error-desc {
  font-size: 0.76rem;
  font-family: var(--font-mono);
  word-break: break-all;
}

/* Generic Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: var(--font-sans);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
  color: inherit;
}

.btn-secondary {
  background: var(--bg-subtle);
  border: 1px solid var(--border-medium);
  color: var(--text-main);
}

.btn-secondary:hover {
  background: var(--bg-hover);
  border-color: var(--text-dim);
}

.btn-sm { padding: 5px 12px; font-size: 0.78rem; }

.btn-xs {
  padding: 3px 10px;
  font-size: 0.72rem;
  border-radius: var(--radius-xs);
}

.btn-close-sm {
  background: transparent;
  border: none;
  color: var(--text-light);
  font-size: 0.9rem;
  width: 26px;
  height: 26px;
  border-radius: var(--radius-xs);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
}

.btn-close-sm:hover {
  background: var(--bg-hover);
  color: var(--text-main);
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 120;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-box {
  width: 440px;
  max-width: 90vw;
  background: var(--bg-frame);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
  font-family: var(--font-heading);
  font-size: 0.96rem;
  color: var(--text-main);
}

.modal-body {
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.form-item {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.form-item label {
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--text-muted);
}

.form-field {
  width: 100%;
  background: var(--bg-editor);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  color: var(--text-main);
  font-family: var(--font-mono);
  font-size: 0.82rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-field:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.input-wrap .form-field { padding-right: 40px; }

.btn-eye {
  position: absolute;
  right: 8px;
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--text-light);
  transition: color 0.15s;
}

.btn-eye:hover { color: var(--text-main); }

.form-note {
  font-size: 0.7rem;
  color: var(--text-dim);
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 18px;
  background: var(--bg-subtle);
  border-top: 1px solid var(--border-color);
}

/* Toast */
.toast-popup {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 10px 18px;
  background: var(--bg-frame);
  color: var(--text-main);
  border: 1px solid var(--border-medium);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 600;
  z-index: 150;
  transform: translateY(60px);
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.toast-popup.show {
  transform: translateY(0);
  opacity: 1;
}
