/* FreetCode — Interview Prep Platform */
:root {
  --bg-app: #0f0f0f;
  --bg-sidebar: #161616;
  --bg-editor: #1e1e1e;
  --bg-panel: #141414;
  --bg-header: #1a1a1a;
  --bg-hover: rgba(255,255,255,0.05);
  --bg-active: rgba(99,102,241,0.12);
  --bg-input: #252525;


  --fg-primary: #e0e0e0;
  --fg-secondary: #888;
  --fg-muted: #555;
  --fg-strong: #fff;

  --accent: #6366f1;
  --accent-hover: #818cf8;
  --accent-soft: rgba(99,102,241,0.15);

  --easy: #22c55e;
  --medium: #f59e0b;
  --hard: #ef4444;

  --border: #222;
  --border-strong: #333;
  --radius: 6px;
  --radius-lg: 10px;

  --font-ui: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Cascadia Code', 'SF Mono', Menlo, Consolas, monospace;

  --sidebar-width: 280px;

  --header-height: 48px;
  --toolbar-height: 38px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; background: var(--bg-app); color: var(--fg-primary); font-family: var(--font-ui); font-size: 13px; overflow: hidden; -webkit-font-smoothing: antialiased; }

/* ═══ Layout ═══ */
.app {
  display: grid;
  grid-template-rows: var(--header-height) 1fr;
  grid-template-columns: var(--sidebar-width) 1fr 48px;
  height: 100vh;
}
.app.sidebar-collapsed {
  grid-template-columns: 0px 1fr 48px;
}

/* ═══ Right tool rail ═══ */
.rail {
  grid-row: 2; grid-column: -2 / -1;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 10px 0; background: var(--bg-header);
  border-left: 1px solid var(--border); z-index: 9;
}
.rail-btn {
  width: 36px; height: 36px; display: flex; align-items: center; justify-content: center;
  background: transparent; border: 1px solid transparent; border-radius: var(--radius, 7px);
  color: var(--fg-secondary); font-size: 16px; line-height: 1; cursor: pointer;
  font-family: inherit; transition: background .12s, color .12s, border-color .12s;
}
.rail-btn:hover { background: var(--bg-hover); color: var(--fg-primary); }
.rail-btn.active { color: var(--accent); background: var(--accent-soft); border-color: var(--accent-soft); }
.rail-sep { width: 22px; height: 1px; background: var(--border); margin: 4px 0; }

/* ═══ Header ═══ */
.header {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 16px;
  background: var(--bg-header);
  border-bottom: 1px solid var(--border);
  z-index: 10;
}
/* Logo is brand-locked: identical across every theme. Only the wordmark
   text color follows --fg-strong so it stays legible on light skins. */
.logo {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--fg-strong);
  display: flex;
  align-items: center;
  gap: 8px;
}
.logo-mark {
  width: 24px;
  height: 24px;
  background: linear-gradient(135deg, #6366f1, #a78bfa) !important;
  border-radius: 6px !important;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  font-weight: 700;
  color: #fff !important;
  box-shadow: 0 2px 10px rgba(99,102,241,0.4), 0 1px 0 rgba(255,255,255,0.25) inset;
}
.header-spacer { flex: 1; }
.header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ═══ Buttons (shared) ═══ */
.btn {
  font-family: var(--font-ui);
  font-size: 12px;
  border: 1px solid var(--border-strong);
  background: transparent;
  color: var(--fg-primary);
  padding: 6px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background 0.12s, border-color 0.12s;
  white-space: nowrap;
}
.btn:hover { background: var(--bg-hover); }
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-ghost { border-color: transparent; }
.btn-icon {
  width: 32px;
  height: 32px;
  padding: 0;
  justify-content: center;
  border: none;
  border-radius: var(--radius);
  background: transparent;
  color: var(--fg-secondary);
  cursor: pointer;
  font-size: 16px;
}
.btn-icon:hover { background: var(--bg-hover); color: var(--fg-strong); }

kbd {
  font-family: var(--font-mono);
  font-size: 10px;
  background: rgba(255,255,255,0.06);
  border-radius: 3px;
  padding: 2px 5px;
}

/* ═══ Sidebar ═══ */
.sidebar {
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width 0.2s;
}
.sidebar-collapsed .sidebar { width: 0; overflow: hidden; }

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.sidebar-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--fg-secondary);
}
.sidebar-search {
  padding: 8px 10px;
  flex-shrink: 0;
}
.sidebar-search input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 7px 10px;
  color: var(--fg-primary);
  font-family: var(--font-ui);
  font-size: 12px;
  outline: none;
  transition: border-color 0.15s;
}
.sidebar-search input:focus { border-color: var(--accent); }
.sidebar-search input::placeholder { color: var(--fg-muted); }

.collection-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  padding: 0 10px 8px;
  flex-shrink: 0;
}
.collection-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 9px;
  color: var(--fg-secondary);
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  white-space: nowrap;
}
.collection-pill:hover { border-color: var(--accent); color: var(--fg-primary); }
.collection-pill.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.collection-pill-count {
  font-size: 10px;
  opacity: 0.65;
  font-variant-numeric: tabular-nums;
}
.collection-pill.active .collection-pill-count { opacity: 0.9; }

.problem-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 0;
}
.problem-list::-webkit-scrollbar { width: 6px; }
.problem-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 3px; }

.category-group { margin-bottom: 4px; }
.category-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  font-size: 11px;
  font-weight: 600;
  color: var(--fg-secondary);
  cursor: pointer;
  user-select: none;
}
.category-header:hover { color: var(--fg-primary); }
.category-chevron {
  font-size: 10px;
  transition: transform 0.15s;
}
.category-header.collapsed .category-chevron { transform: rotate(-90deg); }
.category-count {
  margin-left: auto;
  font-size: 10px;
  color: var(--fg-muted);
  font-weight: 400;
}

.problem-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px 6px 28px;
  cursor: pointer;
  border-left: 2px solid transparent;
  transition: background 0.1s;
}
.problem-item:hover { background: var(--bg-hover); }
.problem-item.active {
  background: var(--bg-active);
  border-left-color: var(--accent);
}
.problem-num {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--fg-muted);
  min-width: 28px;
}
.problem-title {
  font-size: 12px;
  color: var(--fg-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}
.problem-item.active .problem-title { color: var(--fg-strong); }
.difficulty-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}
.difficulty-dot.easy { background: var(--easy); }
.difficulty-dot.medium { background: var(--medium); }
.difficulty-dot.hard { background: var(--hard); }
.difficulty-dot.learn { background: var(--accent); }
.pill.learn { background: rgba(99,102,241,0.15); color: var(--accent); }

.problem-item .solved-check {
  font-size: 12px;
  color: var(--easy);
  margin-left: auto;
  display: none;
}
.problem-item.solved .solved-check { display: inline; }

/* ═══ Main Area ═══ */
.main {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Toolbar */
.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  background: var(--bg-editor);
  border-bottom: 1px solid var(--border);
  height: var(--toolbar-height);
  flex-shrink: 0;
}
.toolbar-problem-info {
  display: flex;
  align-items: center;
  gap: 10px;
}
.toolbar-problem-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--fg-strong);
}
.pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}
.pill.easy { background: rgba(34,197,94,0.15); color: var(--easy); }
.pill.medium { background: rgba(245,158,11,0.15); color: var(--medium); }
.pill.hard { background: rgba(239,68,68,0.15); color: var(--hard); }

.toolbar-spacer { flex: 1; }

/* Solution Picker */
.solution-picker {
  position: relative;
  display: inline-flex;
  align-items: center;
}
.solution-picker-arrow {
  padding: 6px 4px;
  margin-left: -4px;
  font-size: 10px;
  border-color: transparent;
}
.solution-dropdown {
  display: none;
  position: fixed;
  min-width: 220px;
  background: #1f1f1f;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  z-index: 200;
}
.solution-dropdown.show { display: block; }
.solution-dropdown-item {
  display: block;
  padding: 10px 14px;
  font-size: 13px;
  color: var(--fg-primary);
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  font-family: var(--font-ui);
  text-align: left;
  line-height: 1.4;
}
.solution-dropdown-item:hover { background: var(--bg-hover); }
.solution-dropdown-item.active {
  background: var(--bg-active);
  color: var(--accent);
}
.toolbar-tags {
  display: flex;
  gap: 4px;
}
.tag {
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 3px;
  background: var(--bg-hover);
  color: var(--fg-secondary);
}

/* Description Panel */
.complexity-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 16px;
  background: rgba(99,102,241,0.08);
  border-bottom: 1px solid rgba(99,102,241,0.18);
  font-family: var(--font-ui);
  font-size: 12px;
  flex-shrink: 0;
}
.complexity-item {
  display: flex;
  align-items: center;
  gap: 6px;
}
.complexity-label {
  color: var(--fg-muted);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 10px;
  letter-spacing: 0.5px;
}
.complexity-item span:not(.complexity-label) {
  color: var(--accent-hover);
  font-family: var(--font-mono, 'SF Mono', 'Fira Code', monospace);
  font-weight: 500;
}
.complexity-sep {
  color: var(--fg-muted);
  opacity: 0.4;
}

.desc-panel {
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  max-height: 45%;
  min-height: 0;
}
.desc-header {
  display: flex;
  align-items: center;
  height: 30px;
  border-bottom: 1px solid var(--border);
  padding: 0 12px;
  flex-shrink: 0;
  gap: 12px;
}
.desc-tab {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.4px;
  color: var(--fg-strong);
}
.desc-header .btn-icon { margin-left: auto; }
.desc-content {
  flex: 1;
  overflow-y: auto;
  padding: 14px 18px;
  font-family: var(--font-ui);
  font-size: 13px;
  line-height: 1.7;
  color: var(--fg-primary);
}
.desc-content::-webkit-scrollbar { width: 6px; }
.desc-content::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 3px; }
.desc-content strong { color: var(--fg-strong); }
.desc-content code {
  font-family: var(--font-mono);
  font-size: 11.5px;
  background: rgba(255,255,255,0.06);
  padding: 1px 5px;
  border-radius: 3px;
  color: #c9b4f7;
}
.desc-content pre {
  background: rgba(0,0,0,0.3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  margin: 8px 0;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--fg-primary);
}
.desc-content pre code {
  background: none;
  padding: 0;
  color: inherit;
}
.desc-content p { margin: 6px 0; }
.desc-content ol, .desc-content ul { margin: 6px 0; padding-left: 20px; }
.desc-content li { margin: 3px 0; }

/* Editor */
.editor-container {
  background: var(--bg-editor);
  overflow: hidden;
  position: relative;
  flex: 1;
  min-height: 120px;
}
#editor { width: 100%; height: 100%; }

/* Resizer */
.resizer {
  background: var(--border);
  cursor: ns-resize;
  transition: background 0.15s;
  height: 6px;
  flex-shrink: 0;
}
.resizer:hover, .resizer.dragging { background: var(--accent); }

/* Output Panel */
.output-panel {
  background: var(--bg-panel);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  height: 180px;
  flex-shrink: 0;
}
.output-header {
  display: flex;
  align-items: center;
  height: 30px;
  border-bottom: 1px solid var(--border);
  padding: 0 12px;
  flex-shrink: 0;
  gap: 12px;
}
.output-tab {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.4px;
  color: var(--fg-strong);
}
.output-actions {
  margin-left: auto;
  display: flex;
  gap: 4px;
}
.output-content {
  flex: 1;
  overflow: auto;
  padding: 10px 14px;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}
.output-content::-webkit-scrollbar { width: 6px; }
.output-content::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 3px; }
.output-placeholder { color: var(--fg-muted); font-style: italic; font-family: var(--font-ui); }
.out-line { color: var(--fg-primary); }
.out-err { color: #f87171; }
.out-meta { color: var(--fg-muted); font-size: 11px; font-family: var(--font-ui); margin-top: 6px; padding-top: 6px; border-top: 1px dashed var(--border-strong); }

/* ═══ Benchmark Results ═══ */
.benchmark-card {
  margin-top: 10px;
  padding: 10px 14px;
  background: rgba(99,102,241,0.06);
  border: 1px solid rgba(99,102,241,0.2);
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.8;
}
.benchmark-card .pass { color: var(--easy); }
.benchmark-card .fail { color: var(--hard); }
.benchmark-card .stat { color: var(--fg-primary); }
.benchmark-card .percentile { color: var(--accent); font-weight: 600; }

/* ═══ Submit verdict card ═══ */
.verdict-card {
  margin-top: 10px;
  padding: 12px 14px;
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.6;
  border: 1px solid var(--border-strong);
}
.verdict-card.v-pass { background: color-mix(in srgb, var(--easy) 10%, transparent); border-color: color-mix(in srgb, var(--easy) 45%, transparent); }
.verdict-card.v-fail { background: color-mix(in srgb, var(--hard) 9%, transparent); border-color: color-mix(in srgb, var(--hard) 45%, transparent); }
.verdict-card.v-neutral { background: rgba(99,102,241,0.06); border-color: rgba(99,102,241,0.2); }
.verdict-head { font-weight: 700; font-size: 13px; letter-spacing: .2px; }
.verdict-head.v-pass-text { color: var(--easy); }
.verdict-head.v-fail-text { color: var(--hard); }
.verdict-err { margin: 8px 0 0; padding: 8px 10px; background: rgba(0,0,0,0.18); border-radius: 6px; color: #f87171; white-space: pre-wrap; word-break: break-word; font-size: 11px; }
.case-row { display: flex; gap: 8px; margin-top: 7px; align-items: flex-start; }
.case-row.case-ok .case-mark { color: var(--easy); }
.case-row.case-bad .case-mark { color: var(--hard); }
.case-mark { font-weight: 700; }
.case-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.case-in { color: var(--fg-secondary); word-break: break-word; }
.case-diff { color: var(--fg-muted); font-size: 11px; word-break: break-word; }
.case-diff b { color: var(--fg-primary); font-weight: 600; }

/* ═══ Folded-in benchmark card ═══ */
.bench-card {
  margin-top: 8px;
  padding: 10px 14px;
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.7;
  border: 1px solid var(--border-strong);
  background: rgba(255,255,255,0.02);
}
.bench-card.b-good { border-color: color-mix(in srgb, var(--easy) 40%, transparent); }
.bench-card.b-mid  { border-color: color-mix(in srgb, var(--medium) 45%, transparent); }
.bench-card.b-bad  { border-color: color-mix(in srgb, var(--hard) 45%, transparent); background: color-mix(in srgb, var(--hard) 7%, transparent); }
.bench-card.b-info { border-color: rgba(99,102,241,0.2); background: rgba(99,102,241,0.05); }
.bench-band { font-weight: 700; }
.bench-card.b-good .bench-band { color: var(--easy); }
.bench-card.b-mid  .bench-band { color: var(--medium); }
.bench-card.b-bad  .bench-band { color: var(--hard); }
.bench-stat { color: var(--fg-secondary); }
.bench-pct { color: var(--accent); font-weight: 600; margin-top: 2px; }
.bench-est { color: var(--fg-muted); font-weight: 400; font-style: italic; }
.bench-live { color: var(--easy); font-weight: 600; }
.bench-note { color: var(--fg-secondary); }
.bench-growth { font-weight: 600; margin-top: 2px; }
.bench-growth.b-good { color: var(--easy); }
.bench-growth.b-bad { color: var(--hard); }
.bench-space { margin-top: 2px; color: var(--fg-secondary); }
.bench-space.b-bad { color: var(--hard); }
.bench-space.b-mid { color: var(--medium); }
.board-bd { color: var(--fg-muted); font-size: 10px; margin-left: 4px; }

/* ═══ Rank + unlock meter ═══ */
.rank-card {
  margin-top: 8px; padding: 10px 14px; border-radius: var(--radius);
  border: 1px solid rgba(99,102,241,0.25); background: rgba(99,102,241,0.06);
  font-family: var(--font-mono); font-size: 11px; line-height: 1.7;
}
.rank-line { color: var(--fg-primary); }
.rank-line b { color: var(--accent); font-size: 13px; }
.unlock-meter { height: 6px; border-radius: 3px; background: rgba(255,255,255,0.08); overflow: hidden; margin: 6px 0 4px; }
.unlock-fill { height: 100%; background: var(--accent); border-radius: 3px; transition: width .4s ease; }
.unlock-note { color: var(--fg-muted); }
.unlock-note b { color: var(--accent); }

/* ═══ Arcade board ═══ */
.board {
  margin-top: 8px; padding: 10px 14px; border-radius: var(--radius);
  border: 1px solid var(--border-strong); background: rgba(255,255,255,0.02);
  font-family: var(--font-mono); font-size: 11px;
}
.board-title { color: var(--fg-strong); font-weight: 700; margin-bottom: 6px; }
.board-empty { color: var(--fg-muted); font-style: italic; }
.board-row { display: flex; align-items: center; gap: 10px; padding: 2px 0; color: var(--fg-secondary); }
.board-row.hot { color: var(--accent); font-weight: 700; }
.board-rank { width: 22px; text-align: right; color: var(--fg-muted); }
.board-ini { width: 44px; letter-spacing: 2px; font-weight: 600; color: var(--fg-primary); }
.board-row.hot .board-ini { color: var(--accent); }
.board-ratio { color: var(--fg-secondary); }

/* ═══ Arcade initials entry ═══ */
.arcade-entry {
  margin-top: 8px; padding: 12px 14px; border-radius: var(--radius);
  border: 1px solid color-mix(in srgb, var(--accent) 50%, transparent);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  font-family: var(--font-mono); font-size: 12px;
}
.arcade-title { font-weight: 700; color: var(--accent); margin-bottom: 8px; }
.arcade-row { display: flex; gap: 8px; align-items: center; }
.arcade-input {
  width: 86px; padding: 8px 10px; font-family: var(--font-mono); font-size: 20px;
  letter-spacing: 8px; text-align: center; text-transform: uppercase; font-weight: 700;
  background: var(--bg-elevated, rgba(0,0,0,0.25)); color: var(--fg-strong);
  border: 1px solid var(--border-strong); border-radius: 8px; outline: none;
}
.arcade-input:focus { border-color: var(--accent); }
.arcade-msg { margin-top: 6px; color: var(--fg-muted); min-height: 14px; }

/* ═══ Saved Solution Indicator ═══ */
.problem-item .saved-indicator {
  font-size: 11px;
  color: var(--accent);
  margin-left: auto;
  display: none;
}
.problem-item.has-saved .saved-indicator { display: inline; }
.problem-item.has-saved.solved .saved-indicator { display: none; } /* solved check takes priority */

/* ═══ Settings Data Management ═══ */
.settings-actions-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 16px;
}
.settings-actions-grid .btn {
  justify-content: center;
  font-size: 12px;
  padding: 10px 12px;
}
.settings-danger {
  color: var(--hard) !important;
  border-color: rgba(239,68,68,0.3) !important;
}
.settings-danger:hover {
  background: rgba(239,68,68,0.1) !important;
}

/* ═══ Visualizer Modal ═══ */
.viz-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.viz-overlay.show { display: flex; }
.viz-container {
  width: 100%;
  max-width: 1100px;
  height: 100%;
  max-height: 700px;
  background: var(--bg-app);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.viz-header {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  gap: 12px;
  flex-shrink: 0;
}
.viz-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--fg-strong);
}
.viz-close {
  margin-left: auto;
}
.viz-body {
  flex: 1;
  overflow: hidden;
  position: relative;
}
.viz-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.viz-controls .speed-slider {
  width: 80px;
  accent-color: var(--accent);
}
.viz-step-label {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--fg-secondary);
  margin-left: auto;
}

/* ═══ Hints Panel ═══ */
.hints-area {
  padding: 8px 12px;
  border-top: 1px solid var(--border);
  background: var(--bg-panel);
}
.hint-item {
  padding: 6px 10px;
  margin: 4px 0;
  background: rgba(245,158,11,0.06);
  border-left: 2px solid var(--medium);
  border-radius: 0 var(--radius) var(--radius) 0;
  font-size: 12px;
  line-height: 1.5;
  color: var(--fg-primary);
  display: none;
}
.hint-item.revealed { display: block; }

/* ═══ Settings/API Key Modal ═══ */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 500;
}
.modal-backdrop.show { display: flex; }
.modal {
  background: #1f1f1f;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 24px;
  min-width: 380px;
  max-width: 480px;
  box-shadow: 0 16px 50px rgba(0,0,0,0.5);
}
.modal h3 {
  font-size: 15px;
  font-weight: 600;
  color: var(--fg-strong);
  margin-bottom: 8px;
}
.modal p {
  font-size: 12.5px;
  color: var(--fg-secondary);
  line-height: 1.6;
  margin-bottom: 16px;
}
.modal input[type="text"], .modal input[type="password"] {
  width: 100%;
  padding: 8px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--fg-primary);
  font-family: var(--font-mono);
  font-size: 12px;
  margin-bottom: 16px;
  outline: none;
}
.modal input:focus { border-color: var(--accent); }
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* ═══ Progress Bar (sidebar footer) ═══ */
.sidebar-footer {
  padding: 12px 14px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.progress-label {
  font-size: 10px;
  color: var(--fg-secondary);
  margin-bottom: 6px;
  display: flex;
  justify-content: space-between;
}
.progress-bar {
  height: 4px;
  background: var(--bg-input);
  border-radius: 2px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.3s;
}

/* ═══ Responsive — Mobile ═══ */

/* Sidebar backdrop (mobile only, injected by JS) */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  top: var(--header-height);
  background: rgba(0,0,0,0.5);
  z-index: 49;
}
.sidebar-backdrop.show { display: block; }

@media (max-width: 768px) {
  /* ── Layout ── */
  .app {
    grid-template-columns: 1fr 48px !important;
  }

  /* ── Header ── */
  .header { padding: 0 8px; gap: 8px; }
  .logo span { font-size: 14px; }
  .header-actions { gap: 2px; }
  .header-actions .btn { padding: 6px 8px; font-size: 11px; }
  .header-actions .btn-text { display: none; } /* hide text labels, keep emoji */
  .header-actions kbd { display: none; }

  /* ── Sidebar: slide-over with backdrop ── */
  .sidebar {
    position: fixed;
    left: 0;
    top: var(--header-height);
    bottom: 0;
    width: min(var(--sidebar-width), 85vw);
    z-index: 50;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
  }
  .sidebar.mobile-open { transform: translateX(0); }

  /* ── Toolbar: wrap + compact ── */
  .toolbar {
    flex-wrap: wrap;
    padding: 4px 8px;
    gap: 4px;
    height: auto;
    min-height: var(--toolbar-height);
  }
  .toolbar-problem-info { flex: 1 1 100%; min-width: 0; }
  .toolbar-problem-title { font-size: 12px; }
  .toolbar-tags { display: none; } /* hide tags on mobile — saves space */
  .toolbar-spacer { display: none; }
  .toolbar .btn { padding: 5px 8px; font-size: 11px; }
  .toolbar .btn kbd { display: none; }

  /* ── Main area: more editor, less output ── */
  .resizer { display: none; } /* disable drag-resize on mobile */
  .output-panel { height: 120px; }

  /* ── Editor ── */
  .editor-container { min-height: 200px; }

  /* ── Description panel ── */
  .desc-panel { max-height: 40%; }
  .desc-content { padding: 10px 14px; font-size: 12px; }

  /* ── Output ── */
  .output-content { padding: 8px 10px; font-size: 11px; }

  /* ── Visualizer: tighter padding ── */
  .viz-overlay { padding: 8px; }
  .viz-container { max-width: 100%; max-height: 100%; border-radius: 8px; }
  .viz-header { padding: 8px 12px; }
  .viz-controls { padding: 8px 12px; gap: 6px; flex-wrap: wrap; }
  .viz-controls .speed-slider { width: 60px; }

  /* ── Modals: full-width ── */
  .modal { min-width: auto; max-width: calc(100vw - 32px); }

  /* ── Touch targets: min 44px ── */
  .btn-icon { width: 40px; height: 40px; font-size: 18px; }
  .problem-item { padding: 10px 14px 10px 24px; }
  .category-header { padding: 10px 14px; }
  .sidebar-search input { font-size: 16px; padding: 10px 12px; }

  /* ── Hide keyboard hints ── */
  kbd { display: none; }
}

/* ═══ Responsive — Small phones ═══ */
@media (max-width: 400px) {
  .header { --header-height: 42px; }
  .logo-mark { width: 18px; height: 18px; font-size: 10px; }
  .logo span { font-size: 13px; }
  .toolbar-problem-title { font-size: 11px; }
  .pill { font-size: 9px; padding: 1px 6px; }
  .output-panel { height: 100px; }
}
