/* ── Reset & base ──────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:       #0f1117;
  --surface:  #1a1d27;
  --border:   #2a2d3a;
  --text:     #e1e4eb;
  --text-dim: #8b8fa3;
  --accent:   #6c8cff;
  --accent-h: #8ba5ff;
  --green:    #4ade80;
  --red:      #f87171;
  --yellow:   #fbbf24;
  --radius:   8px;
  --font:     'Inter', -apple-system, sans-serif;
  --mono:     'JetBrains Mono', 'Fira Code', monospace;
}

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
}

/* ── Header ────────────────────────────────────────────────────── */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}

.header-left {
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.logo {
  height: 32px;
  width: 32px;
}

header h1 {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -0.02em;
}

.tagline {
  font-size: 0.82rem;
  color: var(--text-dim);
}

.version {
  font-size: 0.7rem;
  font-family: var(--mono);
  color: var(--text-dim);
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 2px 7px;
  border-radius: 4px;
}

nav { display: flex; gap: 4px; }

.nav-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-dim);
  font-family: var(--font);
  font-size: 0.85rem;
  font-weight: 500;
  padding: 6px 14px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.15s;
}

.nav-btn:hover { color: var(--text); background: rgba(108, 140, 255, 0.08); }
.nav-btn.active { color: var(--accent); border-color: var(--border); background: var(--bg); }

/* ── Toolbar ───────────────────────────────────────────────────── */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  gap: 16px;
  flex-shrink: 0;
  flex-wrap: wrap;
}

.toolbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.toolbar label {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-dim);
}

.toolbar select,
.toolbar input[type="text"] {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.82rem;
  padding: 5px 10px;
  border-radius: var(--radius);
  outline: none;
}

.toolbar select:focus,
.toolbar input:focus { border-color: var(--accent); }

#demo-select { min-width: 200px; }
#function-input { width: 140px; }
#mode-select { min-width: 180px; }
#z3-timeout { min-width: 60px; }

.new-btn {
  background: var(--bg);
  color: var(--text-dim);
  font-family: var(--font);
  font-size: 0.78rem;
  font-weight: 500;
  border: 1px solid var(--border);
  padding: 4px 10px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.new-btn:hover { color: var(--accent); border-color: var(--accent); }

.run-btn {
  background: var(--accent);
  color: #fff;
  font-family: var(--font);
  font-size: 0.85rem;
  font-weight: 600;
  border: none;
  padding: 8px 20px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
}

.run-btn:hover { background: var(--accent-h); }
.run-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.run-btn.running { background: var(--red); }

/* ── Playground layout: vertical flex fills viewport ──────────── */
#page-playground {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* ── Editors ───────────────────────────────────────────────────── */
.editors {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.editor-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  min-width: 0;
  min-height: 0;
}

.editor-pane:last-child { border-right: none; }

.pane-stubs { flex: 0 0 35%; }

.pane-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  flex-shrink: 0;
}

.pane-hint {
  font-weight: 400;
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--text-dim);
  opacity: 0.6;
}

.editor-container {
  flex: 1;
  min-height: 0;
}

/* ── Output: collapsible panel at bottom ──────────────────────── */
.output-section {
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  transition: height 0.3s ease;
  overflow: hidden;
}

/* Collapsed state: 25% of viewport height */
.output-section.collapsed {
  height: 25vh;
}

/* Expanded state: 50% of viewport height */
.output-section.expanded {
  height: 50vh;
}

.output-section .pane-header {
  cursor: pointer;
  user-select: none;
}

.output-status {
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 400;
}

.output-status.ok { color: var(--green); }
.output-status.leak { color: var(--red); }
.output-status.error { color: var(--yellow); }
.output-status.running { color: var(--accent); }

.output-text {
  padding: 14px 20px;
  font-family: var(--mono);
  font-size: 0.82rem;
  line-height: 1.6;
  background: var(--bg);
  color: var(--text);
  overflow: auto;
  flex: 1;
  min-height: 0;
  white-space: pre-wrap;
  word-break: break-word;
}

/* Highlight LEAK/OK/VIOLATION in output */
.output-text .hl-leak { color: var(--red); font-weight: 600; }
.output-text .hl-ok { color: var(--green); font-weight: 600; }
.output-text .hl-warn { color: var(--yellow); font-weight: 600; }
.output-text .hl-dim { color: var(--text-dim); }

/* ── Documentation pages ───────────────────────────────────────── */
.page-hidden { display: none !important; }

#page-tutorial, #page-docs, #page-about {
  flex: 1;
  overflow-y: auto;
}

.doc-content {
  max-width: 780px;
  margin: 0 auto;
  padding: 40px 24px;
  line-height: 1.7;
}

.doc-content h2 {
  font-size: 1.5rem;
  margin-bottom: 24px;
  color: var(--accent);
}

.doc-content h3 {
  font-size: 1.1rem;
  margin-top: 32px;
  margin-bottom: 12px;
  color: var(--text);
}

.doc-content p {
  margin-bottom: 14px;
  color: var(--text);
}

.doc-content ul, .doc-content ol {
  margin-bottom: 14px;
  padding-left: 24px;
}

.doc-content li {
  margin-bottom: 6px;
}

.doc-content code {
  font-family: var(--mono);
  font-size: 0.88em;
  background: var(--surface);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--accent-h);
}

.doc-content pre {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  margin-bottom: 14px;
  overflow-x: auto;
}

.doc-content pre code {
  background: transparent;
  padding: 0;
  font-size: 0.84rem;
  line-height: 1.6;
}

.doc-content table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 14px;
}

.doc-content td {
  padding: 6px 12px;
  border: 1px solid var(--border);
  font-size: 0.88rem;
}

.doc-content td:first-child {
  font-family: var(--mono);
  color: var(--accent-h);
  white-space: nowrap;
}

.doc-content strong { color: var(--text); }
.doc-content em { color: var(--text-dim); font-style: italic; }

/* ── Footer ────────────────────────────────────────────────────── */
footer {
  text-align: center;
  padding: 8px 24px;
  font-size: 0.72rem;
  color: var(--text-dim);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  line-height: 1.6;
}

footer strong { color: var(--text); font-weight: 600; }

footer a {
  color: var(--accent);
  text-decoration: none;
}

footer a:hover { text-decoration: underline; }

/* ── Responsive ────────────────────────────────────────────────── */
@media (max-width: 768px) {
  header { flex-direction: column; gap: 8px; }
  .header-left { flex-direction: column; align-items: flex-start; gap: 2px; }
  .editors { flex-direction: column; }
  .pane-stubs { flex: 1; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .toolbar-left { flex-direction: column; }
  .toolbar-right { display: flex; justify-content: stretch; }
  .run-btn { width: 100%; }
  .output-section.collapsed { height: 30vh; }
  .output-section.expanded { height: 50vh; }
}
