*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

/* ─── Dark mode (default) ────────────────────────────────── */
:root {
  --bg-0: #121212;
  --bg-1: #1a1a1a;
  --bg-2: #222222;
  --bg-3: #2c2c2c;
  --border: #333333;
  --border-light: #444444;
  --text-1: #f0ede8;
  --text-2: #888880;
  --text-3: #505048;
  --green: #4ade80;
  --green-dim: rgba(74,222,128,0.1);
  --purple: #c084fc;
  --purple-dim: rgba(192,132,252,0.1);
  --amber: #fbbf24;
  --red: #f87171;
  --send-bg: #e8e4dc;
  --send-color: #111111;
  --code-bg: #0e0e0e;
  --code-text: #e8e4dc;
  --code-line-bg: #0e0e0e;
  --code-line-text: #505048;
  --icon-btn-bg: #222222;
  --logo-color: #f0ede8;
  --tag-bg: rgba(240,237,232,0.07);
  --tag-color: #c8c4bc;
  --tag-border: rgba(240,237,232,0.12);
  --agent-av-bg: rgba(74,222,128,0.1);
  --agent-av-color: #4ade80;
  --user-av-bg: rgba(240,237,232,0.07);
  --user-av-color: #c8c4bc;
  --obs-av-bg: rgba(192,132,252,0.1);
  --obs-av-color: #c084fc;
  --bubble-bg: #1e1e1e;
  --bubble-border: #333333;
  --candidate-bubble-bg: #242424;
  --candidate-bubble-border: #3a3a3a;
  --obs-bubble-bg: rgba(192,132,252,0.07);
  --obs-bubble-border: rgba(192,132,252,0.18);
  --toast-bg: #1e1e1e;
  --shadow: rgba(0,0,0,0.55);
  --handle-bg: #282828;
  --handle-hover: #444444;
}

/* ─── Light mode ─────────────────────────────────────────── */
[data-theme="light"] {
  --bg-0: #f5f4f0;
  --bg-1: #ffffff;
  --bg-2: #f0ede8;
  --bg-3: #e8e5e0;
  --border: #ddd9d2;
  --border-light: #ccc8c0;
  --text-1: #1a1814;
  --text-2: #6a6660;
  --text-3: #a09890;
  --green: #16a34a;
  --green-dim: rgba(22,163,74,0.1);
  --purple: #7c3aed;
  --purple-dim: rgba(124,58,237,0.1);
  --amber: #b45309;
  --red: #dc2626;
  --send-bg: #1a1814;
  --send-color: #f5f4f0;
  --code-bg: #fafaf8;
  --code-text: #1a1814;
  --code-line-bg: #f0ede8;
  --code-line-text: #a09890;
  --icon-btn-bg: #f0ede8;
  --logo-color: #1a1814;
  --tag-bg: rgba(26,24,20,0.06);
  --tag-color: #3a3830;
  --tag-border: rgba(26,24,20,0.12);
  --agent-av-bg: rgba(22,163,74,0.1);
  --agent-av-color: #16a34a;
  --user-av-bg: rgba(26,24,20,0.06);
  --user-av-color: #3a3830;
  --obs-av-bg: rgba(124,58,237,0.1);
  --obs-av-color: #7c3aed;
  --bubble-bg: #ffffff;
  --bubble-border: #ddd9d2;
  --candidate-bubble-bg: #f5f4f0;
  --candidate-bubble-border: #ccc8c0;
  --obs-bubble-bg: rgba(124,58,237,0.05);
  --obs-bubble-border: rgba(124,58,237,0.16);
  --toast-bg: #ffffff;
  --shadow: rgba(0,0,0,0.1);
  --handle-bg: #e0ddd8;
  --handle-hover: #c8c4bc;
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Inter', sans-serif;
  background: var(--bg-0);
  color: var(--text-1);
  font-size: 13px;
  line-height: 1.5;
  overflow: hidden;
  transition: background 0.2s, color 0.2s;
}

.noselect {
  -webkit-user-select: none;
  user-select: none;
  cursor: default;
}

/* ─── Header ─────────────────────────────────────────────── */
.header {
  height: 54px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  background: var(--bg-1);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  transition: background 0.2s, border-color 0.2s;
}

.header-center {
  position: fixed;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  height: 54px;
  display: flex;
  align-items: center;
  z-index: 200;
  pointer-events: none;
}

.header-left { display: flex; align-items: center; gap: 14px; }

.logo { font-size: 15px; font-weight: 700; color: var(--logo-color); letter-spacing: -0.3px; }

.problem-title {
  font-size: 12px;
  color: var(--text-2);
  padding-left: 14px;
  border-left: 1px solid var(--border-light);
  /* Stop before the centred header slot (candidate name + countdown); full title on hover. */
  max-width: max(120px, calc(50vw - 400px));
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}


.header-right { display: flex; align-items: center; gap: 10px; justify-content: flex-end; }

.candidate-name { font-size: 12px; color: var(--text-2); }
.candidate-identity { font-size: 13px; font-weight: 500; color: var(--text-1); }
.countdown { font-variant-numeric: tabular-nums; color: var(--amber); }
.countdown.countdown-low { color: var(--red); }

.back-link {
  font-size: 12px;
  color: var(--text-2);
  text-decoration: none;
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-2);
}
.back-link:hover { color: var(--text-1); background: var(--bg-3); }

.status-badge {
  font-size: 11px;
  font-weight: 500;
  padding: 3px 10px;
  border-radius: 20px;
  background: var(--green-dim);
  color: var(--green);
  border: 1px solid rgba(74,222,128,0.2);
}

[data-theme="light"] .status-badge { border-color: rgba(22,163,74,0.2); }

.lang-select {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-3);
  font-size: 11px;
  font-family: inherit;
  padding: 5px 10px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.2s;
}

.lang-select:focus { outline: none; border-color: var(--border-light); }

.lang-select.has-value { color: var(--text-2); }

.lang-select option {
  color: var(--text-1);
  background: var(--bg-2);
}

.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  color: var(--text-2);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.2s;
  flex-shrink: 0;
}

.theme-toggle:hover { background: var(--bg-3); color: var(--text-1); }
.theme-toggle .icon-moon,
.theme-toggle .icon-sun { display: none; }
:root .theme-toggle .icon-moon { display: block; }
[data-theme="light"] .theme-toggle .icon-sun { display: block; }
[data-theme="light"] .theme-toggle .icon-moon { display: none; }

/* ─── Main layout ────────────────────────────────────────── */
.main-layout {
  display: flex;
  height: calc(100vh - 54px);
  overflow: hidden;
}

/* ─── Resize handle (horizontal) ────────────────────────── */
.resize-handle {
  width: 4px;
  flex-shrink: 0;
  background: var(--handle-bg);
  cursor: col-resize;
  position: relative;
  transition: background 0.15s;
  z-index: 10;
}

.resize-handle::after {
  content: '';
  position: absolute;
  inset: 0 -4px;
}

.resize-handle:hover,
.resize-handle.dragging { background: var(--handle-hover); }

.resize-handle::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 2px;
  height: 24px;
  border-radius: 2px;
  background: var(--border-light);
  opacity: 0;
  transition: opacity 0.15s;
}

.resize-handle:hover::before,
.resize-handle.dragging::before { opacity: 1; }

/* ─── Panel Header (shared by problem + chat panels) ────── */
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px 0 16px;
  height: 44px;
  background: var(--bg-1);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  transition: background 0.2s, border-color 0.2s;
}

.panel-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-3);
}

.panel-toggle-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 5px;
  background: none;
  border: 1px solid var(--border);
  color: var(--text-2);
  cursor: pointer;
  font-size: 12px;
  line-height: 1;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
  flex-shrink: 0;
}

.panel-toggle-btn:hover { background: var(--bg-3); color: var(--text-1); }

/* ─── Problem Panel ──────────────────────────────────────── */
.problem-panel {
  width: 260px;
  min-width: 160px;
  flex-shrink: 0;
  background: var(--bg-1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: background 0.2s, width 180ms ease;
}

.panel-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

.panel-content::-webkit-scrollbar { width: 4px; }
.panel-content::-webkit-scrollbar-track { background: transparent; }
.panel-content::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 4px; }

.problem-body { display: flex; flex-direction: column; gap: 14px; }

.problem-tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 500;
  padding: 2px 10px;
  border-radius: 4px;
  background: var(--tag-bg);
  color: var(--tag-color);
  border: 1px solid var(--tag-border);
  width: fit-content;
}

.problem-heading { font-size: 15px; font-weight: 600; line-height: 1.4; }

.problem-desc { font-size: 12px; color: var(--text-2); line-height: 1.7; }
.problem-desc p { margin: 0 0 10px; }
.problem-desc p:last-child, .problem-desc ul:last-child, .problem-desc ol:last-child { margin-bottom: 0; }
.problem-desc ul, .problem-desc ol { margin: 0 0 10px; padding-left: 20px; }
.problem-desc li { margin-bottom: 4px; }
.problem-desc li:last-child { margin-bottom: 0; }
.problem-desc strong { color: var(--text-1); font-weight: 600; }
.problem-desc code { font-family: 'JetBrains Mono', monospace; font-size: 0.92em; background: var(--bg-1); padding: 1px 4px; border-radius: 3px; }
.problem-desc h1, .problem-desc h2, .problem-desc h3, .problem-desc h4 { color: var(--text-1); font-size: 13px; margin: 14px 0 6px; }
.problem-desc pre { background: var(--bg-1); padding: 10px; border-radius: 6px; overflow-x: auto; margin: 0 0 10px; }
/* KaTeX glyphs overhang their box by a few px; the padding keeps overflow-y: hidden from clipping them. */
.problem-desc .katex-display { overflow-x: auto; overflow-y: hidden; padding: 6px 0; margin: 4px 0; }
.problem-desc pre code { background: none; padding: 0; }

.section-block { display: flex; flex-direction: column; gap: 7px; }

.section-block h4 {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-3);
}

.section-block ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.section-block ul li {
  font-size: 12px;
  color: var(--text-2);
  padding-left: 13px;
  position: relative;
  line-height: 1.6;
}

.section-block ul li::before {
  content: '–';
  position: absolute;
  left: 0;
  color: var(--text-3);
}

/* Sample test cases in problem panel */
.tc-list { display: flex; flex-direction: column; gap: 7px; }

.tc-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.tc-io { display: flex; align-items: center; gap: 5px; }

.tc-key {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-3);
}

.tc-list code {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 11px;
  background: var(--bg-2);
  color: var(--text-1);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--border);
  user-select: none;
}

.tc-arrow { color: var(--text-3); font-size: 11px; }

/* ─── Question selector (inside problem panel) ───────────── */
.question-nav {
  display: flex;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.q-btn {
  flex: 1;
  background: none;
  border: none;
  border-right: 1px solid var(--border);
  color: var(--text-2);
  font-size: 12px;
  font-family: inherit;
  padding: 9px 0;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.q-btn:last-child { border-right: none; }
.q-btn:hover { background: var(--bg-2); color: var(--text-1); }
.q-btn.active { background: var(--bg-2); color: var(--text-1); font-weight: 600; }

#problemPanel.minimized .question-nav { display: none; }

.q-mini-badge {
  display: none;
  width: 24px;
  height: 24px;
  margin: 10px auto;
  font-size: 11px;
  font-weight: 600;
  flex-shrink: 0;
  cursor: default;
}

#problemPanel.minimized .q-mini-badge { display: flex; }

/* ─── Error banner ───────────────────────────────────────── */
.error-banner {
  position: fixed;
  top: 54px;
  left: 0;
  right: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 20px;
  background: rgba(248,113,113,0.1);
  border-bottom: 1px solid rgba(248,113,113,0.25);
  color: var(--red);
  font-size: 12px;
}

.error-banner-close {
  background: none;
  border: none;
  color: var(--red);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  padding: 0;
  margin-left: 12px;
  flex-shrink: 0;
  opacity: 0.7;
  transition: opacity 0.15s;
}

.error-banner-close:hover { opacity: 1; }

/* ─── Verdict bar (in test panel) ────────────────────────── */
.verdict-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  font-size: 11.5px;
  font-weight: 600;
  transition: background 0.2s, border-color 0.2s;
}

.verdict-bar.submitted {
  background: var(--bg-1);
  border-color: var(--border);
  color: var(--text-1);
}

/* Button disabled / loading / post-submit-locked states.
   .is-locked is used post-submit instead of the disabled attribute so the
   button still receives clicks (and editor.js can show the "code submitted"
   toast). disabled HTML buttons silently swallow click events. */
.btn-run:disabled,
.btn-submit:disabled,
.btn-run.is-locked,
.btn-submit.is-locked {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ─── Minimized panel state ──────────────────────────────── */
#problemPanel.minimized,
#chatPanel.minimized {
  width: 40px !important;
  min-width: 40px !important;
}

#problemPanel.minimized .panel-label,
#chatPanel.minimized .panel-label {
  display: none;
}

#problemPanel.minimized .panel-content,
#chatPanel.minimized .chat-body {
  display: none;
}

#problemPanel.minimized .panel-header,
#chatPanel.minimized .panel-header {
  justify-content: center;
  padding: 0;
  border-bottom: none;
}

/* ─── Output Panel (center) ──────────────────────────────── */
.output-panel {
  flex: 1;
  min-width: 220px;
  display: flex;
  flex-direction: column;
  background: var(--bg-0);
  overflow: hidden;
  transition: background 0.2s;
}

.editor-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-1);
  border-bottom: 1px solid var(--border);
  padding: 0 12px;
  height: 44px;
  flex-shrink: 0;
  transition: background 0.2s, border-color 0.2s;
}

.editor-header-left {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--text-2);
}

.editor-header-title {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-1);
}

.editor-header-actions { display: flex; align-items: center; gap: 6px; }

.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: var(--icon-btn-bg);
  border: 1px solid var(--border);
  color: var(--text-2);
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}

.icon-btn:hover { background: var(--bg-3); color: var(--text-1); }

.editor-area {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

#editor-container {
  flex: 1;
  height: 100%;
  width: 100%;
}

/* ─── Editor Footer (Run + Submit) ──────────────────────── */
.editor-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-top: 1px solid var(--border);
  background: var(--bg-1);
  flex-shrink: 0;
  transition: background 0.2s, border-color 0.2s;
}

.btn-run {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 16px;
  border-radius: 6px;
  background: var(--green);
  color: #000;
  border: none;
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
}

.btn-run:hover { opacity: 0.85; }
.btn-run:active { transform: scale(0.96); }

.btn-submit {
  display: flex;
  align-items: center;
  padding: 6px 16px;
  border-radius: 6px;
  background: var(--bg-3);
  color: var(--text-1);
  border: 1px solid var(--border-light);
  font-size: 12px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.btn-submit:hover { background: var(--border-light); }

/* Footer opener — one link-styled line that reveals the test panel (#36) */
.panel-opener {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 2px;
  font-size: 12px;
  font-weight: 500;
  color: var(--green);
  cursor: pointer;
  user-select: none;
}
.panel-opener-text { text-decoration: underline; text-underline-offset: 2px; }
.panel-opener:hover { opacity: 0.82; }
.panel-opener:focus-visible { outline: 2px solid var(--green); outline-offset: 3px; border-radius: 3px; }

/* ─── Test Panel ─────────────────────────────────────────── */
.test-panel {
  height: 220px;
  min-height: 80px;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  background: var(--bg-0);
  border-top: 1px solid var(--border);
  overflow: hidden;
  transition: background 0.2s;
}

.test-panel.hidden { display: none; }

.test-resize-handle {
  height: 4px;
  flex-shrink: 0;
  background: var(--handle-bg);
  cursor: ns-resize;
  position: relative;
  transition: background 0.15s;
}

.test-resize-handle::after {
  content: '';
  position: absolute;
  inset: -4px 0;
}

.test-resize-handle:hover,
.test-resize-handle.dragging { background: var(--handle-hover); }

.test-resize-handle::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  height: 2px;
  width: 24px;
  border-radius: 2px;
  background: var(--border-light);
  opacity: 0;
  transition: opacity 0.15s;
}

.test-resize-handle:hover::before,
.test-resize-handle.dragging::before { opacity: 1; }

.test-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  height: 38px;
  background: var(--bg-1);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  transition: background 0.2s, border-color 0.2s;
}

.test-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.test-header-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-2);
}

.test-body {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.test-body::-webkit-scrollbar { width: 4px; }
.test-body::-webkit-scrollbar-track { background: transparent; }
.test-body::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 4px; }

.test-case-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 12px 6px;
}

.test-case-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  border-left-width: 3px;
  border-left-color: var(--border-light);
  background: var(--bg-2);
  transition: background 0.2s, border-color 0.2s;
}

.test-case-item.pass { border-left-color: var(--green); }
.test-case-item.fail { border-left-color: var(--red); }
.test-case-item.running { border-left-color: var(--amber); }

.tci-details { flex: 1; display: flex; flex-direction: column; gap: 2px; }

.tci-row {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  color: var(--text-2);
}

.tci-key {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-3);
  min-width: 52px;
}

.tci-row code {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 11px;
  color: var(--text-1);
}

.tci-badge {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 2px 8px;
  border-radius: 4px;
  flex-shrink: 0;
  min-width: 44px;
  text-align: center;
  box-sizing: border-box;
}

.tci-badge.pass    { color: var(--green);  background: var(--green-dim); }
.tci-badge.fail    { color: var(--red);    background: rgba(248,113,113,0.1); }
.tci-badge.running { color: var(--amber);  background: rgba(251,191,36,0.1); }

.tci-delete-btn {
  background: none;
  border: none;
  color: var(--text-3);
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  padding: 0 2px;
  flex-shrink: 0;
  transition: color 0.15s;
}

.tci-delete-btn:hover { color: var(--red); }

/* Custom test section */
.custom-test-area {
  padding: 8px 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.custom-run-result {
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-2);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 11.5px;
}

.crr-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.crr-label {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-3);
  font-family: inherit;
}

.crr-value {
  color: var(--text-1);
  white-space: pre-wrap;
  word-break: break-all;
  line-height: 1.5;
}

.crr-value.crr-stderr  { color: var(--red); }
.crr-value.crr-compile { color: var(--amber); }

.crr-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-top: 4px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}

.crr-status {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 2px 8px;
  border-radius: 4px;
  min-width: 44px;
  text-align: center;
  box-sizing: border-box;
}

.crr-status.pass { color: var(--green); background: var(--green-dim); }
.crr-status.fail { color: var(--red);   background: rgba(248,113,113,0.1); }
.crr-status.neutral { color: var(--text-2); background: var(--bg-3); }

.crr-timing {
  font-size: 10.5px;
  color: var(--text-3);
}

.link-btn {
  background: none;
  border: none;
  color: var(--text-2);
  font-size: 11.5px;
  font-family: inherit;
  cursor: pointer;
  padding: 0;
  text-align: left;
  transition: color 0.15s;
}

.link-btn:hover { color: var(--text-1); }

.custom-test-form {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.custom-test-form.hidden { display: none; }

.custom-test-inputs {
  display: flex;
  gap: 6px;
}

.custom-test-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.custom-test-inputs textarea {
  flex: 1;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 7px 10px;
  color: var(--text-1);
  font-size: 11.5px;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  resize: none;
  transition: border-color 0.15s, background 0.2s;
}

.custom-test-inputs textarea::placeholder { color: var(--text-3); }
.custom-test-inputs textarea:focus { outline: none; border-color: var(--border-light); }

.btn-run-sm {
  align-self: flex-start;
  padding: 5px 14px;
  border-radius: 5px;
  background: var(--green);
  color: #000;
  border: none;
  font-size: 11px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: opacity 0.15s;
}

.btn-run-sm:hover { opacity: 0.85; }

.btn-cancel-sm {
  padding: 5px 14px;
  border-radius: 5px;
  background: transparent;
  color: var(--text-2);
  border: 1px solid var(--border);
  font-size: 11px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

.btn-cancel-sm:hover { color: var(--text-1); border-color: var(--border-light); }

/* ─── Chat Panel ─────────────────────────────────────────── */
.chat-panel {
  width: 360px;
  min-width: 260px;
  flex-shrink: 0;
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-0);
  transition: background 0.2s, width 180ms ease;
}

.chat-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}

.chat-messages::-webkit-scrollbar { width: 4px; }
.chat-messages::-webkit-scrollbar-track { background: transparent; }
.chat-messages::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 4px; }

/* ─── Messages ───────────────────────────────────────────── */
.message { display: flex; gap: 10px; align-items: flex-start; }

.avatar {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  flex-shrink: 0;
}

.av-agent { background: var(--agent-av-bg); color: var(--agent-av-color); border: 1px solid rgba(74,222,128,0.18); }
.av-user  { background: var(--user-av-bg);  color: var(--user-av-color);  border: 1px solid var(--border); }
.av-obs   { background: var(--obs-av-bg);   color: var(--obs-av-color);   border: 1px solid rgba(192,132,252,0.18); }

[data-theme="light"] .av-agent { border-color: rgba(22,163,74,0.18); }
[data-theme="light"] .av-obs   { border-color: rgba(124,58,237,0.18); }

.bubble {
  flex: 1;
  padding: 10px 13px;
  border-radius: 10px;
  border: 1px solid var(--bubble-border);
  background: var(--bubble-bg);
  transition: background 0.2s, border-color 0.2s;
}

.candidate-msg .bubble {
  background: var(--candidate-bubble-bg);
  border-color: var(--candidate-bubble-border);
}

.observer-msg .bubble {
  background: var(--obs-bubble-bg);
  border-color: var(--obs-bubble-border);
}

.msg-label {
  display: block;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-bottom: 5px;
}

.agent-msg .msg-label     { color: var(--green); }
.candidate-msg .msg-label { color: var(--text-2); }
.observer-msg .msg-label  { color: var(--purple); }

.bubble p { font-size: 12.5px; line-height: 1.65; color: var(--text-1); }

/* Editor gate — overlays the editor until the candidate picks a language. */
.editor-area { position: relative; }
.editor-gate {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
  background: var(--bg-1);
}
.editor-gate-inner { max-width: 440px; text-align: left; }
.editor-gate-title { font-size: 15px; font-weight: 600; color: var(--text-1); margin-bottom: 6px; }
.editor-gate-sub { font-size: 12.5px; color: var(--text-2); line-height: 1.5; }
.editor-gate-instructions {
  font-size: 12.5px;
  color: var(--text-2);
  line-height: 1.55;
  margin-bottom: 22px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border);
}
.editor-gate-list { margin: 0; padding-left: 18px; }
.editor-gate-list li { margin-bottom: 7px; }
.editor-gate-list li:last-child { margin-bottom: 0; }
.editor-gate-agentnote { margin-top: 14px; font-size: 12px; color: var(--text-3); }
.editor-gate-picker { margin-top: 18px; }
.editor-gate-picker .lang-select { min-width: 220px; }
.lang-home { display: inline-flex; align-items: center; }

/* Assistant gate — overlays the chat panel until a language is picked */
.chat-gate {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
  background: var(--bg-0);
}
.chat-gate-inner { font-size: 13px; color: var(--text-2); max-width: 220px; line-height: 1.5; }

/* Typing dots */
.dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
  animation: blink 1.2s infinite;
  display: inline-block;
}

.dot:nth-child(2) { animation-delay: 0.2s; }
.dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes blink {
  0%, 80%, 100% { opacity: 0.25; transform: scale(0.85); }
  40%           { opacity: 1;    transform: scale(1); }
}

/* ─── Chat Input Row ─────────────────────────────────────── */
.chat-input-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  background: var(--bg-1);
  flex-shrink: 0;
  transition: background 0.2s, border-color 0.2s;
}

.chat-input-row textarea {
  flex: 1;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--text-1);
  font-size: 12.5px;
  resize: none;
  font-family: inherit;
  line-height: 1.5;
  height: 40px;
  max-height: 100px;
  overflow-y: hidden;
  transition: border-color 0.15s, background 0.2s, color 0.2s;
}

.chat-input-row textarea::placeholder { color: var(--text-3); }
.chat-input-row textarea:focus { outline: none; border-color: var(--border-light); }

.send-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--send-bg);
  color: var(--send-color);
  border: none;
  cursor: pointer;
  flex-shrink: 0;
  transition: opacity 0.15s, transform 0.1s;
}

.send-btn:hover { opacity: 0.82; }
.send-btn:active { transform: scale(0.94); }

/* ─── Toast Notifications ────────────────────────────────── */
.toast-container {
  position: fixed;
  top: 66px;
  right: 16px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--border-light);
  background: var(--toast-bg);
  box-shadow: 0 8px 32px var(--shadow);
  min-width: 260px;
  max-width: 320px;
  animation: slideIn 0.25s ease;
  pointer-events: all;
  transition: background 0.2s;
}

.toast.toast-observer { border-color: rgba(192,132,252,0.28); }
[data-theme="light"] .toast.toast-observer { border-color: rgba(124,58,237,0.22); }

.toast-icon {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
}

.toast-observer .toast-icon { background: var(--purple-dim); color: var(--purple); }
.toast-agent .toast-icon    { background: var(--green-dim);  color: var(--green); }

.toast-body { flex: 1; }

.toast-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 3px;
}

.toast-observer .toast-title { color: var(--purple); }
.toast-agent .toast-title    { color: var(--green); }

.toast-text {
  font-size: 12px;
  color: var(--text-2);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.toast-dismiss {
  background: none;
  border: none;
  color: var(--text-3);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 0;
  transition: color 0.15s;
}

.toast-dismiss:hover { color: var(--text-1); }

@keyframes slideIn {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes slideOut {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(20px); }
}

.toast.removing { animation: slideOut 0.2s ease forwards; }

.hidden { display: none !important; }

/* ─── Reconnect indicator + disconnected affordances (#30) ─────────────────── */
.reconnect-indicator {
  display: none;
  position: fixed;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  font-size: 12px;
  color: var(--text-1);
  background: var(--bg-2);
  border: 1px solid var(--red);
  border-radius: 999px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
}
body.socket-down .reconnect-indicator { display: flex; }
.reconnect-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--red);
  animation: reconnect-pulse 1s ease-in-out infinite;
}
@keyframes reconnect-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.25; } }
/* While disconnected, dim the chat composer so the candidate isn't typing into the void. */
body.socket-down .chat-input-row { opacity: 0.5; pointer-events: none; }
