:root,
html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0e1015;
  --bg-2: #14161d;
  --surface: #171a22;
  --panel: #1b1e27;
  --panel-strong: #21252f;
  --panel-soft: rgba(255, 255, 255, 0.045);
  --ink: #d8dce3;
  --muted: #8b93a1;
  --quiet: #5f6776;
  --line: rgba(255, 255, 255, 0.09);
  --line-strong: rgba(255, 255, 255, 0.17);
  --accent: #4c8dff;
  --accent-2: #3ddc84;
  --bad: #ff5c52;
  --warn: #ffce5e;
  --code: #0f1117;
  --code-top: #171a22;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
}

html[data-theme="light"] {
  color-scheme: light;
  --bg: #e1e5ec;
  --bg-2: #eef1f5;
  --surface: #f4f6f9;
  --panel: #f4f6f9;
  --panel-strong: #fafbfd;
  --panel-soft: rgba(15, 23, 42, 0.05);
  --ink: #1f2937;
  --muted: #5b6675;
  --quiet: #94a3b8;
  --line: rgba(15, 23, 42, 0.14);
  --line-strong: rgba(15, 23, 42, 0.20);
  --accent: #2563eb;
  --accent-2: #16a34a;
  --bad: #dc2626;
  --warn: #b45309;
  --code: #f4f5f7;
  --code-top: #e9edf3;
  --shadow: 0 10px 30px rgba(15, 23, 42, 0.10);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  transition: background 160ms ease, color 160ms ease;
  letter-spacing: 0;
  overflow: hidden;
}

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

.app-shell {
  display: grid;
  grid-template-columns: minmax(280px, 340px) minmax(0, 1fr);
  height: 100vh;
  overflow: hidden;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  border-right: 1px solid var(--line);
  background: var(--surface);
  backdrop-filter: blur(28px) saturate(1.25);
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-width: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.19), rgba(255, 255, 255, 0.05));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.22);
  color: #fff;
  font-weight: 800;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 17px;
  line-height: 1.15;
  font-weight: 760;
}

.brand p,
.muted,
#shortcutHint,
#durationLabel {
  color: var(--muted);
}

#serverState {
  margin-top: 4px;
  font-size: 12px;
}

.search-wrap {
  display: grid;
  gap: 7px;
  color: var(--quiet);
  font-size: 12px;
  font-weight: 650;
}

.filter-panel {
  display: grid;
  gap: 10px;
  margin-top: -8px;
}

.filter-panel label {
  display: grid;
  gap: 7px;
  color: var(--quiet);
  font-size: 12px;
  font-weight: 650;
}

.filter-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 9px;
}

.filter-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
  min-height: 34px;
}

#resultCount {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#clearFiltersButton {
  padding: 7px 10px;
  font-size: 12px;
  line-height: 1;
  flex: 0 0 auto;
}

.search-wrap input,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  color: var(--ink);
  outline: 0;
  padding: 11px 12px;
  transition: border-color 150ms ease, background 150ms ease, box-shadow 150ms ease;
}

.search-wrap input::placeholder {
  color: #7c7c82;
}

.search-wrap input:focus,
select:focus {
  border-color: rgba(41, 151, 255, 0.82);
  background: rgba(255, 255, 255, 0.11);
  box-shadow: 0 0 0 4px rgba(41, 151, 255, 0.16);
}

select {
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position:
    calc(100% - 18px) 50%,
    calc(100% - 12px) 50%;
  background-size: 6px 6px;
  background-repeat: no-repeat;
  padding-right: 34px;
}

select option {
  background: #1d1d1f;
  color: var(--ink);
}

.problem-list {
  display: grid;
  gap: 9px;
  overflow: auto;
  padding-right: 2px;
  min-height: 0;
  flex: 1 1 auto;
  align-content: start;
  grid-auto-rows: max-content;
}

.problem-list.few-results {
  padding-top: 4px;
}

.empty-state {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  padding: 14px;
  color: var(--muted);
}

.empty-state strong {
  display: block;
  color: var(--ink);
  margin-bottom: 5px;
}

.empty-state span {
  font-size: 12px;
  line-height: 1.35;
}

.problem-list::-webkit-scrollbar,
.file-tree::-webkit-scrollbar,
#codeEditor::-webkit-scrollbar,
.diagnostics-panel::-webkit-scrollbar,
.prompt-pane::-webkit-scrollbar,
.results-pane::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

.problem-list::-webkit-scrollbar-thumb,
.file-tree::-webkit-scrollbar-thumb,
#codeEditor::-webkit-scrollbar-thumb,
.diagnostics-panel::-webkit-scrollbar-thumb,
.prompt-pane::-webkit-scrollbar-thumb,
.results-pane::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.18);
  border: 3px solid transparent;
  border-radius: 8px;
  background-clip: padding-box;
}

.problem-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  color: var(--ink);
  padding: 12px;
  cursor: pointer;
  text-align: left;
  transition: transform 150ms ease, border-color 150ms ease, background 150ms ease;
}

.problem-card:hover {
  transform: translateY(-1px);
  border-color: rgba(255, 255, 255, 0.28);
  background: var(--panel-soft);
}

.problem-card.active {
  border-color: rgba(41, 151, 255, 0.82);
  background: rgba(41, 151, 255, 0.16);
}

.problem-card strong {
  display: block;
  font-size: 14px;
  line-height: 1.25;
  font-weight: 720;
}

.problem-card span {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.workspace {
  min-width: 0;
  height: 100vh;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) minmax(150px, 30vh);
  gap: 16px;
  padding: 24px;
}

.split,
.prompt-pane,
.editor-pane,
.results-pane {
  min-width: 0;
}

.problem-header,
.results-header,
.editor-top,
.toolbar,
.meta-row {
  display: flex;
  align-items: center;
}

.problem-header {
  justify-content: space-between;
  gap: 18px;
  padding: 2px 2px 0;
}

.problem-header h2 {
  font-size: 34px;
  line-height: 1.06;
  font-weight: 780;
  max-width: 980px;
}

.eyebrow {
  min-height: 18px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 760;
  letter-spacing: 0;
  text-transform: uppercase;
}

.toolbar {
  gap: 9px;
  flex: 0 0 auto;
}

.toolbar select {
  min-width: 144px;
}

button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  color: var(--ink);
  padding: 10px 15px;
  cursor: pointer;
  font-weight: 720;
  transition: transform 150ms ease, border-color 150ms ease, background 150ms ease, box-shadow 150ms ease;
}

button:hover {
  transform: translateY(-1px);
  border-color: rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.12);
}

#runButton {
  border-color: transparent;
  background: var(--accent);
  color: #fff;
  box-shadow: 0 12px 28px rgba(41, 151, 255, 0.25);
}

#runButton:hover {
  background: #46a6ff;
}

button:disabled {
  cursor: wait;
  opacity: 0.62;
  transform: none;
}

.split {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(280px, 0.4fr) minmax(420px, 0.6fr);
  gap: 16px;
}

.prompt-pane,
.editor-pane,
.results-pane {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(26px) saturate(1.2);
}

.prompt-pane {
  overflow: auto;
  padding: 20px;
}

.prompt-markdown {
  line-height: 1.58;
  color: #e8e8ed;
  font-size: 14px;
}

.prompt-markdown > *:first-child {
  margin-top: 0;
}

.prompt-markdown > *:last-child {
  margin-bottom: 0;
}

.prompt-markdown h1,
.prompt-markdown h2,
.prompt-markdown h3,
.prompt-markdown h4 {
  color: #f5f5f7;
  font-weight: 760;
  line-height: 1.18;
  margin: 20px 0 8px;
}

.prompt-markdown h1 {
  font-size: 22px;
}

.prompt-markdown h2 {
  font-size: 17px;
}

.prompt-markdown h3,
.prompt-markdown h4 {
  font-size: 15px;
}

.prompt-markdown p {
  margin: 0 0 12px;
}

.prompt-markdown ul,
.prompt-markdown ol {
  margin: 0 0 14px 18px;
  padding: 0;
}

.prompt-markdown li {
  margin: 5px 0;
}

.prompt-markdown code {
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 6px;
  background: var(--panel-soft);
  color: #f5f5f7;
  font-family: 'JetBrains Mono', 'SF Mono', 'Cascadia Code', Consolas, monospace;
  font-size: 0.92em;
  padding: 1px 5px;
}

.prompt-markdown pre {
  margin: 9px 0 15px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.3);
  overflow: auto;
  padding: 12px 13px;
}

.prompt-markdown pre code {
  display: block;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: #f5f5f7;
  font-size: 12.5px;
  line-height: 1.55;
  padding: 0;
  white-space: pre;
}

.muted-line {
  color: var(--quiet);
}

.error-line {
  color: #ffb0aa;
}

.meta-row {
  flex-wrap: wrap;
  gap: 8px;
  margin: 18px 0 20px;
}

.tag {
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  color: #d8ecff;
  background: rgba(41, 151, 255, 0.13);
  padding: 5px 9px;
  font-size: 11px;
  font-weight: 720;
}

.prompt-pane h3,
.results-pane h3 {
  font-size: 14px;
  font-weight: 760;
}

.test-list,
.result-tests {
  display: grid;
  gap: 8px;
  margin-top: 11px;
}

.test-case,
.result-case {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px;
  background: var(--panel-soft);
}

.test-case code {
  display: block;
  margin-top: 7px;
  white-space: pre-wrap;
  color: #c9c9d1;
  font-family: 'JetBrains Mono', 'SF Mono', 'Cascadia Code', Consolas, monospace;
  font-size: 12px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.editor-pane {
  min-height: 430px;
  overflow: hidden;
  background: var(--code);
}

.editor-body {
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
}

.editor-pane.multi-file .editor-body {
  grid-template-columns: minmax(184px, 0.26fr) minmax(0, 1fr);
}

.editor-main {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
}
/* Pin each child to a row so the optional stale-draft banner can't steal the editor's 1fr row. */
.editor-main > .editor-top { grid-row: 1; }
.editor-main > #staleDraftBanner { grid-row: 2; }
.editor-main > #codeEditor { grid-row: 3; }
.editor-main > #diagnosticsPanel { grid-row: 4; }

.context-files {
  min-width: 0;
  overflow: hidden;
  border-right: 1px solid #24262d;
  background: #111217;
}

.context-files-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 35px;
  padding: 0 12px;
  border-bottom: 1px solid #24262d;
  color: #aeb0b8;
  font-size: 11px;
  font-weight: 760;
  text-transform: uppercase;
}

.context-files-top span:last-child {
  color: #757780;
  font-weight: 650;
}

.file-tree {
  display: grid;
  align-content: start;
  max-height: none;
  overflow: auto;
  padding: 6px 0 10px;
}

.file-tree-dir {
  color: #8f929b;
  font-size: 11px;
  font-weight: 760;
  overflow: hidden;
  padding: 9px 12px 5px;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.file-tree-item {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 25px;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  color: #d4d4d8;
  font-size: 12px;
  font-weight: 560;
  padding: 3px 12px 3px 23px;
  text-align: left;
}

.file-tree-item::before {
  content: "";
  width: 6px;
  height: 6px;
  margin-right: 8px;
  border: 1px solid #747782;
  border-radius: 2px;
  flex: 0 0 auto;
}

.file-tree-item:hover {
  transform: none;
  background: #1c1d22;
}

.file-tree-item.active {
  background: #25262d;
  color: #f5f5f7;
}

.file-tree-item.active::before {
  border-color: var(--accent);
  background: var(--accent);
}

.file-tree-item span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.editor-top {
  justify-content: space-between;
  min-height: 36px;
  padding: 0;
  border-bottom: 1px solid #24262d;
  background: #111217;
  color: #d7d7de;
  font-size: 12px;
}

.editor-tabs {
  display: flex;
  min-width: 0;
  height: 100%;
}

.editor-tab {
  display: flex;
  align-items: center;
  min-width: 110px;
  max-width: min(460px, 48vw);
  height: 36px;
  border-right: 1px solid #24262d;
  border-top: 2px solid var(--accent);
  background: var(--code);
  color: #f5f5f7;
  overflow: hidden;
  padding: 0 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: 'JetBrains Mono', 'SF Mono', 'Cascadia Code', Consolas, monospace;
  font-size: 12px;
  font-weight: 650;
}

#shortcutHint {
  flex: 0 0 auto;
  padding: 0 12px;
  color: #8f929b;
}

#codeEditor {
  width: 100%;
  height: 100%;
  min-height: 0;
  resize: none;
  border: 0;
  outline: 0;
  padding: 18px;
  background: var(--code);
  color: #f5f5f7;
  font-family: 'JetBrains Mono', 'SF Mono', 'Cascadia Code', Consolas, monospace;
  font-size: 14px;
  line-height: 1.55;
  tab-size: 4;
  caret-color: var(--accent);
}

/* Monaco editor mount: it draws its own chrome, so strip the textarea padding/bg. */
#codeEditor.monaco-mount {
  padding: 0;
  overflow: hidden;
}
.monaco-editor,
.monaco-editor .overflow-guard {
  border-radius: 0;
}

.diagnostics-panel {
  max-height: 112px;
  min-height: 40px;
  overflow: auto;
  border-top: 1px solid rgba(255, 255, 255, 0.09);
  background: var(--panel-soft);
  color: var(--muted);
  padding: 10px 14px;
  white-space: pre-wrap;
  font-family: 'JetBrains Mono', 'SF Mono', 'Cascadia Code', Consolas, monospace;
  font-size: 12px;
  line-height: 1.45;
}

.diagnostics-panel.clean {
  color: #9ff4b4;
}

.diagnostics-panel.pending {
  color: #d7d7de;
}

.diagnostics-panel.warn {
  color: #ffe58a;
  background: rgba(255, 214, 10, 0.08);
}

.diagnostics-panel.fail {
  color: #ffb0aa;
  background: rgba(255, 69, 58, 0.09);
}

.results-pane {
  padding: 15px;
  min-height: 0;
  overflow: auto;
}

.results-header {
  justify-content: space-between;
  gap: 12px;
}

.custom-runner {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(160px, 0.42fr);
  gap: 10px;
  margin-top: 10px;
}

.custom-runner label {
  display: grid;
  gap: 6px;
  color: var(--quiet);
  font-size: 12px;
  font-weight: 650;
}

.custom-runner textarea,
.custom-runner input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  color: var(--ink);
  outline: 0;
  padding: 10px 11px;
  font-family: 'JetBrains Mono', 'SF Mono', 'Cascadia Code', Consolas, monospace;
  font-size: 12px;
}

.custom-runner textarea {
  min-height: 72px;
  max-height: 130px;
  resize: vertical;
}

.custom-runner textarea:focus,
.custom-runner input:focus {
  border-color: rgba(41, 151, 255, 0.82);
  box-shadow: 0 0 0 4px rgba(41, 151, 255, 0.16);
}

.result-summary {
  margin-top: 9px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  color: var(--muted);
}

.result-summary.pass {
  border-color: rgba(48, 209, 88, 0.34);
  color: #9ff4b4;
  background: rgba(48, 209, 88, 0.11);
}

.result-summary.fail {
  border-color: rgba(255, 69, 58, 0.34);
  color: #ffb0aa;
  background: rgba(255, 69, 58, 0.1);
}

.result-case {
  display: grid;
  gap: 5px;
}

.result-case.pass {
  border-color: rgba(48, 209, 88, 0.34);
}

.result-case.fail {
  border-color: rgba(255, 69, 58, 0.34);
}

.result-case.neutral {
  border-color: rgba(41, 151, 255, 0.3);
}

.result-case strong {
  font-size: 13px;
}

.result-case span {
  color: #c7c7cc;
  font-family: 'JetBrains Mono', 'SF Mono', 'Cascadia Code', Consolas, monospace;
  font-size: 12px;
  overflow-wrap: anywhere;
}

#outputPanel {
  display: none;
  margin: 12px 0 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: #e8e8ed;
  padding: 12px;
  white-space: pre-wrap;
  overflow: auto;
}

@media (max-width: 980px) {
  body {
    overflow: auto;
  }

  .app-shell {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 100vh;
    overflow: visible;
  }

  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .problem-list {
    grid-auto-flow: column;
    grid-auto-columns: minmax(230px, 1fr);
    overflow-x: auto;
    max-width: 100%;
  }

  .filter-panel {
    grid-template-columns: minmax(220px, 1fr) minmax(220px, 1fr);
    align-items: end;
  }

  .filter-panel > label,
  .filter-grid,
  .filter-footer {
    min-width: 0;
  }

  .filter-footer {
    justify-content: flex-start;
  }

  .workspace {
    grid-template-rows: auto auto auto;
    height: auto;
    overflow: visible;
    padding: 18px;
  }

  .problem-header,
  .split {
    grid-template-columns: 1fr;
  }

  .problem-header {
    align-items: stretch;
    display: grid;
  }

  .problem-header h2 {
    font-size: 28px;
  }

  .toolbar {
    flex-wrap: wrap;
  }

  .toolbar select {
    flex: 1 1 100%;
  }

  .toolbar button {
    flex: 1 1 calc(50% - 5px);
  }

  .editor-pane {
    min-height: 56vh;
  }

  .editor-pane.multi-file .editor-body {
    grid-template-columns: minmax(158px, 0.34fr) minmax(0, 1fr);
  }

  .editor-pane.multi-file .context-files {
    border-right: 1px solid #24262d;
  }

  .results-pane {
    max-height: none;
  }
}

@media (max-width: 560px) {
  .app-shell,
  .sidebar,
  .workspace {
    width: 100%;
    max-width: 100vw;
  }

  .sidebar,
  .workspace {
    padding: 14px;
  }

  .problem-header h2 {
    font-size: 24px;
  }

  .problem-list {
    grid-auto-columns: minmax(210px, 72vw);
  }

  .filter-panel,
  .filter-grid {
    grid-template-columns: 1fr;
  }

  .toolbar {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .toolbar select {
    grid-column: 1 / -1;
    min-width: 0;
  }

  .toolbar button {
    min-width: 0;
  }

  .custom-runner {
    grid-template-columns: 1fr;
  }

  #shortcutHint {
    display: none;
  }
}

/* Interview-library visual refresh */
:root {
  color-scheme: light;
  --bg: #f6f8fb;
  --bg-2: #eef3f8;
  --panel: #f4f6f9;
  --panel-strong: #fafbfd;
  --panel-soft: #f1f5f9;
  --ink: #172033;
  --muted: #5f6d82;
  --quiet: #7d899b;
  --line: #dce3ec;
  --line-strong: #c4cedb;
  --accent: #1769e0;
  --accent-2: #0f8a5f;
  --bad: #c8332a;
  --warn: #a05a00;
  --code: #0e1624;
  --code-top: #182235;
  --shadow: 0 18px 50px rgba(25, 34, 49, 0.08);
}

body {
  background:
    linear-gradient(180deg, #ffffff 0, var(--bg) 380px),
    var(--bg);
  color: var(--ink);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 0 28px;
  border-bottom: 1px solid rgba(220, 227, 236, 0.9);
  background: var(--surface);
  backdrop-filter: blur(18px);
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.topbar-brand > div:last-child {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.topbar-brand strong {
  font-size: 15px;
  line-height: 1.1;
}

.topbar-brand span {
  color: var(--muted);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-nav {
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar-nav span {
  padding: 9px 12px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.topbar-nav span.active {
  color: var(--accent);
  background: #e9f2ff;
}

.app-shell {
  grid-template-columns: minmax(280px, 344px) minmax(0, 1fr);
  height: calc(100vh - 68px);
  max-width: 1480px;
  margin: 0 auto;
}

.sidebar {
  top: 68px;
  height: calc(100vh - 68px);
  border-right: 1px solid var(--line);
  background: var(--surface);
  backdrop-filter: none;
  padding: 24px 22px;
  gap: 18px;
}

.brand {
  align-items: flex-start;
}

.brand-mark {
  width: 40px;
  height: 40px;
  border: 0;
  background: var(--ink);
  box-shadow: none;
  color: #fff;
}

h1 {
  color: var(--ink);
}

.brand p,
.muted,
#shortcutHint,
#durationLabel {
  color: var(--muted);
}

.brand p {
  margin-top: 5px;
  max-width: 230px;
  font-size: 12px;
  line-height: 1.4;
}

.search-wrap,
.filter-panel label {
  color: var(--muted);
  font-weight: 760;
}

.search-wrap input,
select,
.custom-runner input,
.custom-runner textarea {
  border-color: var(--line);
  background: var(--panel);
  color: var(--ink);
}

.search-wrap input:focus,
select:focus,
.custom-runner input:focus,
.custom-runner textarea:focus {
  border-color: rgba(23, 105, 224, 0.72);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(23, 105, 224, 0.12);
}

select option {
  background: #fff;
  color: var(--ink);
}

.filter-panel {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

#clearFiltersButton,
button {
  border-color: var(--line);
  background: var(--panel);
  color: var(--ink);
  box-shadow: none;
}

button:hover {
  border-color: var(--line-strong);
  background: #f8fbff;
}

.problem-card {
  border-color: var(--line);
  background: var(--panel);
  box-shadow: 0 10px 26px rgba(25, 34, 49, 0.05);
}

.problem-card:hover,
.problem-card.active {
  border-color: rgba(23, 105, 224, 0.36);
  background: #f8fbff;
  box-shadow: var(--shadow);
}

.problem-card.active {
  box-shadow: inset 4px 0 0 var(--accent), var(--shadow);
}

.problem-card strong,
.empty-state strong {
  color: var(--ink);
}

.problem-card span,
.empty-state,
.empty-state span {
  color: var(--muted);
}

.empty-state {
  border-color: var(--line);
  background: var(--surface);
}

.workspace {
  height: calc(100vh - 68px);
  padding: 26px;
  gap: 16px;
}

.problem-header {
  padding: 24px 26px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.problem-header h2 {
  color: var(--ink);
  font-size: 31px;
}

.eyebrow {
  color: var(--accent);
}

.toolbar select {
  background-color: var(--panel-soft);
}

#runButton {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 12px 28px rgba(23, 105, 224, 0.22);
}

#runButton:hover {
  background: #1f75ee;
}

.prompt-pane,
.editor-pane,
.results-pane {
  border-color: var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: none;
}

.prompt-markdown {
  color: #263247;
}

.prompt-markdown h1,
.prompt-markdown h2,
.prompt-markdown h3,
.prompt-markdown h4,
.prompt-pane h3,
.results-header h3 {
  color: var(--ink);
}

.prompt-markdown code,
.test-case code,
.result-test code {
  background: var(--panel-soft);
  color: #172033;
}

.tag {
  border-color: transparent;
  background: var(--panel-soft);
  color: var(--muted);
}

.test-case,
.result-summary,
.result-test,
.diagnostics-panel {
  border-color: var(--line);
  background: var(--panel-soft);
  color: var(--ink);
}

.result-summary.pass,
.result-test.pass,
.diagnostics-panel.clean {
  border-color: rgba(15, 138, 95, 0.3);
  background: #e7f7f0;
  color: #075f40;
}

.result-summary.fail,
.result-test.fail,
.diagnostics-panel.fail {
  border-color: rgba(200, 51, 42, 0.28);
  background: #fff0ef;
  color: #98241d;
}

.editor-pane {
  background: #101827;
}

.editor-top,
.context-files-top {
  background: #182235;
  color: #dbe8ff;
}

.editor-body,
.editor-main,
#codeEditor,
.diagnostics-panel {
  background: #0e1624;
}

#codeEditor {
  color: #dbe8ff;
}

.editor-tab {
  background: #0e1624;
  color: #fff;
}

.context-files {
  background: #101827;
  border-right-color: #25324a;
}

.file-entry {
  color: #cbd7eb;
}

.file-entry:hover,
.file-entry.active {
  background: #1d2a41;
  color: #fff;
}

.custom-runner label span {
  color: var(--muted);
}

#outputPanel {
  background: #0e1624;
  color: #dbe8ff;
}

.problem-list::-webkit-scrollbar-thumb,
.file-tree::-webkit-scrollbar-thumb,
#codeEditor::-webkit-scrollbar-thumb,
.diagnostics-panel::-webkit-scrollbar-thumb,
.prompt-pane::-webkit-scrollbar-thumb,
.results-pane::-webkit-scrollbar-thumb {
  background: rgba(23, 32, 51, 0.22);
}

@media (max-width: 900px) {
  .topbar {
    position: static;
  }

  .app-shell,
  .workspace,
  .sidebar {
    height: auto;
  }
}

@media (max-width: 560px) {
  .topbar {
    align-items: stretch;
    height: auto;
    padding: 14px;
    flex-direction: column;
  }

  .topbar-nav {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
  }

  .topbar-nav span {
    text-align: center;
  }
}

/* Theme tokens: comfortable dark (default) + light. Switcher sets html[data-theme]. */
:root,
html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0e1015;
  --bg-2: #14161d;
  --surface: #171a22;
  --panel: #1b1e27;
  --panel-strong: #21252f;
  --panel-soft: rgba(255, 255, 255, 0.05);
  --ink: #d8dce3;
  --muted: #8b93a1;
  --quiet: #606a78;
  --line: rgba(255, 255, 255, 0.10);
  --line-strong: rgba(255, 255, 255, 0.18);
  --accent: #5b9bff;
  --accent-2: #3ddc84;
  --bad: #ff6b61;
  --warn: #ffce5e;
  --code: #0f1117;
  --code-top: #171a22;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.42);
}

html[data-theme="light"] {
  color-scheme: light;
  --bg: #e1e5ec;
  --bg-2: #eef1f5;
  --surface: #f4f6f9;
  --panel: #f4f6f9;
  --panel-strong: #fafbfd;
  --panel-soft: rgba(15, 23, 42, 0.05);
  --ink: #1f2937;
  --muted: #5b6675;
  --quiet: #94a3b8;
  --line: rgba(15, 23, 42, 0.14);
  --line-strong: rgba(15, 23, 42, 0.20);
  --accent: #2563eb;
  --accent-2: #16a34a;
  --bad: #dc2626;
  --warn: #b45309;
  --code: #f4f5f7;
  --code-top: #e9edf3;
  --shadow: 0 10px 30px rgba(15, 23, 42, 0.10);
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: 'Inter', ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
}

.topbar {
  background: var(--surface);
  border-bottom-color: var(--line);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.14);
}

.topbar-brand strong,
h1,
.problem-card strong,
.problem-header h2,
.prompt-markdown h1,
.prompt-markdown h2,
.prompt-markdown h3,
.prompt-markdown h4,
.prompt-pane h3,
.results-header h3 {
  color: var(--ink);
}

.topbar-brand span,
.topbar-nav span,
.brand p,
.muted,
#shortcutHint,
#durationLabel,
.problem-card span,
.empty-state,
.empty-state span {
  color: var(--muted);
}

.topbar-nav span.active {
  color: #dbeafe;
  background: rgba(96, 165, 250, 0.16);
}

.brand-mark {
  background: linear-gradient(135deg, #2563eb, #14b8a6);
  color: #fff;
}

.sidebar {
  background: var(--surface);
  border-right-color: var(--line);
}

.quick-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.quick-stats div {
  min-width: 0;
  padding: 12px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.quick-stats strong {
  display: block;
  color: var(--ink);
  font-size: 20px;
  line-height: 1;
}

.quick-stats span {
  display: block;
  margin-top: 6px;
  color: var(--quiet);
  font-size: 11px;
  font-weight: 760;
}

.filter-panel,
.problem-header,
.prompt-pane,
.editor-pane,
.results-pane {
  background: var(--panel);
  border-color: var(--line);
  box-shadow: var(--shadow);
}

.search-wrap,
.filter-panel label,
.custom-runner label,
.custom-runner label span {
  color: var(--muted);
}

.search-wrap input,
select,
.custom-runner input,
.custom-runner textarea {
  background: var(--panel-soft);
  border-color: var(--line);
  color: var(--ink);
}

.search-wrap input::placeholder,
.custom-runner textarea::placeholder,
.custom-runner input::placeholder {
  color: var(--quiet);
}

.search-wrap input:focus,
select:focus,
.custom-runner input:focus,
.custom-runner textarea:focus {
  background: var(--panel-soft);
  border-color: rgba(96, 165, 250, 0.84);
  box-shadow: 0 0 0 4px rgba(96, 165, 250, 0.16);
}

select option {
  background: #111827;
  color: var(--ink);
}

select {
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  background-color: rgba(255, 255, 255, 0.06);
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%23cbd5e1' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 18px 18px;
  padding-right: 42px;
}

button,
#clearFiltersButton {
  background: var(--panel-soft);
  border-color: var(--line);
  color: var(--ink);
}

button:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--line-strong);
}

#runButton {
  background: linear-gradient(135deg, #2563eb, #0ea5e9);
  color: #fff;
  box-shadow: 0 14px 30px rgba(37, 99, 235, 0.26);
}

#runButton:hover {
  background: linear-gradient(135deg, #2f72ff, #19b4f9);
}

.workspace-tabs {
  display: none;
  gap: 8px;
  min-width: 0;
}

.workspace-tabs button {
  flex: 1 1 0;
  min-height: 40px;
  padding: 9px 10px;
}

.workspace-tabs button.active {
  border-color: rgba(96, 165, 250, 0.46);
  background: rgba(96, 165, 250, 0.16);
  color: #dbeafe;
}

.problem-card {
  display: grid;
  gap: 8px;
  border-color: var(--line);
  background: var(--panel-soft);
  box-shadow: none;
}

.problem-card:hover,
.problem-card.active {
  background: rgba(96, 165, 250, 0.095);
  border-color: rgba(96, 165, 250, 0.42);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.22);
}

.problem-card.active {
  box-shadow: inset 4px 0 0 var(--accent), 0 12px 28px rgba(0, 0, 0, 0.22);
}

.card-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--quiet);
  font-size: 11px;
  font-weight: 760;
}

.difficulty-pill,
.mini-tag {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  border-radius: 999px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.difficulty-pill {
  padding: 4px 8px;
  background: rgba(52, 211, 153, 0.13);
  color: #9ff4cf;
}

.card-path {
  display: block;
  min-height: 16px;
  overflow: hidden;
  color: var(--quiet);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  min-height: 22px;
}

.mini-tag,
.tag {
  padding: 4px 7px;
  border: 1px solid rgba(148, 163, 184, 0.14);
  background: rgba(148, 163, 184, 0.12);
  color: #cbd5e1;
  font-size: 11px;
  font-weight: 720;
}

.prompt-markdown {
  color: #dbe6f6;
  font-size: 14px;
}

.prompt-markdown a {
  color: #93c5fd;
  text-decoration: none;
}

.prompt-markdown a:hover {
  text-decoration: underline;
}

.prompt-markdown blockquote {
  margin: 12px 0 16px;
  padding: 10px 14px;
  border-left: 3px solid var(--accent);
  background: rgba(96, 165, 250, 0.09);
  color: #cbd5e1;
}

.prompt-markdown hr {
  height: 1px;
  border: 0;
  background: var(--line);
  margin: 18px 0;
}

.prompt-markdown table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0 16px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 13px;
}

.prompt-markdown th,
.prompt-markdown td {
  border-bottom: 1px solid var(--line);
  padding: 9px 10px;
  text-align: left;
  vertical-align: top;
}

.prompt-markdown th {
  background: var(--panel-soft);
  color: var(--ink);
}

.prompt-markdown tr:last-child td {
  border-bottom: 0;
}

.prompt-markdown code,
.test-case code,
.result-test code {
  background: var(--panel-soft);
  border-color: rgba(148, 163, 184, 0.18);
  color: #f8fafc;
}

.test-case,
.result-summary,
.result-test,
.diagnostics-panel {
  background: var(--panel-soft);
  border-color: var(--line);
  color: var(--ink);
}

.result-summary.pass,
.result-test.pass,
.diagnostics-panel.clean {
  border-color: rgba(52, 211, 153, 0.32);
  background: rgba(52, 211, 153, 0.1);
  color: #9ff4cf;
}

.result-summary.fail,
.result-test.fail,
.diagnostics-panel.fail {
  border-color: rgba(251, 113, 133, 0.34);
  background: rgba(251, 113, 133, 0.1);
  color: #fecdd3;
}

.editor-pane,
.editor-body,
.editor-main,
#codeEditor,
.diagnostics-panel,
#outputPanel {
  background: var(--code);
}

.editor-top,
.context-files-top {
  background: var(--code-top);
  color: #dbeafe;
}

.context-files {
  background: #0b1220;
  border-right-color: var(--line);
}

.file-tree-item {
  color: #cbd5e1;
}

.file-tree-item:hover,
.file-tree-item.active {
  background: rgba(96, 165, 250, 0.12);
  color: #fff;
}

.editor-tab {
  background: var(--code);
  color: #f8fafc;
}

#codeEditor {
  color: #f8fafc;
}

@media (min-width: 1280px) {
  .split {
    grid-template-columns: minmax(320px, 0.42fr) minmax(520px, 0.58fr);
  }
}

@media (max-width: 1120px) {
  .app-shell {
    grid-template-columns: minmax(250px, 300px) minmax(0, 1fr);
  }

  .split {
    grid-template-columns: minmax(260px, 0.44fr) minmax(360px, 0.56fr);
  }

  .problem-header {
    display: grid;
    align-items: stretch;
  }

  .toolbar {
    justify-content: start;
    flex-wrap: wrap;
  }
}

@media (max-width: 820px) {
  body {
    overflow: auto;
  }

  .topbar {
    position: static;
  }

  .app-shell {
    grid-template-columns: 1fr;
    height: auto;
    overflow: visible;
  }

  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .problem-list {
    grid-auto-flow: column;
    grid-auto-columns: minmax(230px, 78vw);
    overflow-x: auto;
  }

  .workspace {
    height: auto;
    min-height: 72vh;
    overflow: visible;
    grid-template-rows: auto auto minmax(0, 1fr) auto;
  }

  .workspace-tabs {
    display: flex;
    position: sticky;
    top: 0;
    z-index: 8;
    padding: 8px 0;
    background: linear-gradient(180deg, var(--bg), rgba(7, 9, 15, 0.72));
  }

  .split {
    display: block;
  }

  .workspace[data-panel="prompt"] .editor-pane,
  .workspace[data-panel="prompt"] .results-pane,
  .workspace[data-panel="editor"] .prompt-pane,
  .workspace[data-panel="editor"] .results-pane,
  .workspace[data-panel="results"] .split {
    display: none;
  }

  .workspace[data-panel="editor"] .editor-pane,
  .workspace[data-panel="prompt"] .prompt-pane,
  .workspace[data-panel="results"] .results-pane {
    display: block;
  }

  .prompt-pane,
  .editor-pane {
    min-height: 58vh;
  }

  .results-pane {
    min-height: 46vh;
  }
}

@media (max-width: 560px) {
  .topbar {
    padding: 12px;
    gap: 12px;
  }

  .topbar-nav {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .quick-stats,
  .filter-grid,
  .filter-panel {
    grid-template-columns: 1fr;
  }

  .problem-header {
    padding: 18px;
  }

  .problem-header h2 {
    font-size: 24px;
  }

  .toolbar {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .toolbar select {
    grid-column: 1 / -1;
  }
}

/* Focused problem-browser workflow */
.topbar {
  justify-content: flex-start;
}

.sidebar {
  gap: 14px;
}

.brand p {
  display: none;
}

.section-label {
  color: var(--quiet);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.topic-panel {
  display: grid;
  gap: 9px;
}

.topic-rail {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.topic-chip {
  min-width: 0;
  min-height: 38px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 760;
  text-align: left;
}

.topic-chip span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topic-chip strong {
  flex: 0 0 auto;
  color: var(--quiet);
  font-size: 11px;
}

.topic-chip.active {
  border-color: rgba(96, 165, 250, 0.52);
  background: rgba(96, 165, 250, 0.18);
  color: #dbeafe;
}

.topic-chip.active strong {
  color: #bfdbfe;
}

.filter-panel {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.filter-panel > button {
  grid-column: 1 / -1;
}

.filter-grid {
  display: none;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

.problem-list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 28px;
  padding-top: 2px;
}

.problem-list-header strong {
  min-width: 0;
  overflow: hidden;
  color: var(--ink);
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.problem-list-header span {
  flex: 0 0 auto;
  color: var(--quiet);
  font-size: 12px;
  font-weight: 740;
}

.problem-list {
  overflow-y: scroll;
  overflow-x: hidden;
  scrollbar-gutter: stable both-edges;
  scrollbar-color: rgba(148, 163, 184, 0.55) rgba(255, 255, 255, 0.05);
  padding-right: 6px;
}

.problem-list::-webkit-scrollbar-track,
.file-tree::-webkit-scrollbar-track,
#codeEditor::-webkit-scrollbar-track,
.diagnostics-panel::-webkit-scrollbar-track,
.prompt-pane::-webkit-scrollbar-track,
.results-pane::-webkit-scrollbar-track {
  background: var(--panel-soft);
  border-radius: 8px;
}

.problem-list::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.55);
  border: 2px solid rgba(7, 9, 15, 0.92);
}

.problem-card {
  gap: 7px;
  padding: 10px 11px;
}

.problem-card strong {
  font-size: 13px;
}

.card-tags {
  min-height: 0;
}

.case-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.case-header strong {
  min-width: 0;
}

.case-run-button {
  flex: 0 0 auto;
  min-height: 28px;
  padding: 5px 9px;
  border-color: rgba(96, 165, 250, 0.36);
  background: rgba(96, 165, 250, 0.13);
  color: #dbeafe;
  font-size: 11px;
}

.result-case.pass {
  border-color: rgba(52, 211, 153, 0.32);
  background: rgba(52, 211, 153, 0.08);
}

.result-case.fail {
  border-color: rgba(251, 113, 133, 0.34);
  background: rgba(251, 113, 133, 0.1);
}

.result-case.neutral {
  border-color: rgba(96, 165, 250, 0.32);
  background: rgba(96, 165, 250, 0.08);
}

@media (max-width: 820px) {
  .problem-list {
    grid-auto-flow: row;
    grid-auto-columns: auto;
    max-height: min(52vh, 520px);
    overflow-y: scroll;
    overflow-x: hidden;
  }
}

@media (max-width: 560px) {
  .topic-rail,
  .filter-panel {
    grid-template-columns: 1fr;
  }
}

/* Wide coding workbench */
body {
  min-width: 0;
}

.topbar {
  height: 56px;
  padding: 0 18px;
}

.topbar-nav,
.quick-stats {
  display: none !important;
}

.app-shell {
  width: 100vw;
  max-width: none;
  height: calc(100vh - 56px);
  margin: 0;
  grid-template-columns: clamp(280px, 15vw, 330px) minmax(0, 1fr);
}

.sidebar {
  top: 56px;
  height: calc(100vh - 56px);
  padding: 16px 14px;
}

.workspace {
  width: 100%;
  height: calc(100vh - 56px);
  grid-template-rows: auto minmax(0, 1fr) minmax(104px, 18vh);
  gap: 12px;
  padding: 16px 18px;
}

.problem-header {
  padding: 14px 18px;
}

.problem-header h2 {
  font-size: clamp(24px, 1.8vw, 34px);
}

.split {
  grid-template-columns: minmax(340px, 0.34fr) minmax(680px, 0.66fr);
  gap: 12px;
}

.prompt-pane {
  padding: 18px;
}

.editor-pane {
  min-height: 0;
}

.editor-pane.multi-file .editor-body {
  grid-template-columns: minmax(148px, 180px) minmax(0, 1fr);
}

.context-files-top {
  padding: 0 9px;
}

.file-tree-item {
  padding-left: 14px;
  padding-right: 9px;
}

.editor-tab {
  max-width: min(620px, 42vw);
}

#codeEditor {
  padding: 16px 18px;
  font-size: 14px;
}

.results-pane {
  padding: 12px;
}

.custom-runner {
  grid-template-columns: minmax(320px, 1fr) minmax(220px, 0.35fr);
}

.custom-runner textarea {
  min-height: 52px;
  max-height: 84px;
}

.result-summary {
  margin-top: 8px;
  padding: 9px 11px;
}

@media (min-width: 1600px) {
  .app-shell {
    grid-template-columns: clamp(290px, 14vw, 340px) minmax(0, 1fr);
  }

  .split {
    grid-template-columns: minmax(380px, 0.3fr) minmax(900px, 0.7fr);
  }

  .editor-pane.multi-file .editor-body {
    grid-template-columns: minmax(150px, 190px) minmax(0, 1fr);
  }
}

@media (max-width: 1180px) {
  .app-shell {
    grid-template-columns: clamp(260px, 24vw, 310px) minmax(0, 1fr);
  }

  .split {
    grid-template-columns: minmax(300px, 0.38fr) minmax(420px, 0.62fr);
  }
}

/* Home, topic, and problem pages */
.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}
.topbar-home {
  min-height: 36px;
  padding: 8px 13px;
  border-color: rgba(96, 165, 250, 0.32);
  background: rgba(96, 165, 250, 0.13);
  color: #dbeafe;
}

.library-page {
  display: grid;
  min-height: 0;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 14px;
}

#homePane {
  grid-template-rows: auto auto auto minmax(0, 1fr);
  width: min(1180px, 100%);
  margin: 0 auto;
}

/* topic page also has a search row between the header and the grid */
#topicPane {
  grid-template-rows: auto auto minmax(0, 1fr);
}

.library-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.library-header h2 {
  margin-top: 4px;
  color: var(--ink);
  font-size: clamp(28px, 2.4vw, 44px);
  line-height: 1.05;
}

.library-header p {
  margin-top: 8px;
  max-width: 760px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.home-search {
  display: grid;
  gap: 9px;
  padding: 0 2px;
}

.home-search span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
}

.home-search input {
  min-height: 56px;
  border-radius: 8px;
  border-color: rgba(96, 165, 250, 0.32);
  background: var(--panel);
  color: var(--ink);
  font-size: 17px;
  padding: 14px 18px;
}

/* Search box on a topic page (filters problems within the selected topic). */
.topic-search {
  display: block;
  margin: 4px 0 14px;
}
.topic-search input {
  width: 100%;
  min-height: 44px;
  border-radius: 8px;
  border: 1px solid rgba(96, 165, 250, 0.32);
  background: var(--panel);
  color: var(--ink);
  font-size: 15px;
  padding: 10px 16px;
}
.topic-search input::placeholder { color: var(--muted); }

/* Language badges on problem cards (a single card can be solved in C / C++ / ...). */
.lang-badges {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
  margin-top: 2px;
}
.lang-badges-label {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  margin-right: 1px;
}
.lang-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 1px 8px;
  font-size: 11px;
  font-weight: 760;
  letter-spacing: 0.02em;
  border: 1px solid rgba(96, 165, 250, 0.35);
  background: rgba(96, 165, 250, 0.12);
  color: #bcd3ff;
}
.lang-badge.lang-c { border-color: rgba(120, 200, 255, 0.42); background: rgba(120, 200, 255, 0.13); color: #cfe8ff; }
.lang-badge.lang-cpp { border-color: rgba(180, 140, 255, 0.42); background: rgba(180, 140, 255, 0.15); color: #e4d6ff; }
.lang-badge.lang-python { border-color: rgba(255, 213, 102, 0.42); background: rgba(255, 213, 102, 0.13); color: #ffe9ad; }
.lang-badge.lang-java { border-color: rgba(255, 150, 120, 0.42); background: rgba(255, 150, 120, 0.13); color: #ffd2c2; }

.home-search input:focus {
  border-color: rgba(96, 165, 250, 0.72);
  box-shadow: 0 0 0 4px rgba(96, 165, 250, 0.14);
}

.page-actions {
  display: flex;
  gap: 8px;
  flex: 0 0 auto;
}

.topic-grid,
.topic-problem-grid {
  min-height: 0;
  overflow: auto;
  scrollbar-gutter: stable;
}

.topic-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
  align-content: start;
}

.topic-grid.search-results {
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
}

.topic-card,
.topic-problem-card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  text-align: left;
  box-shadow: var(--card-shadow);
}

.topic-card {
  display: grid;
  gap: 12px;
  min-height: 128px;
  padding: 16px;
}

.topic-card:hover,
.topic-problem-card:hover {
  border-color: rgba(96, 165, 250, 0.46);
  background: rgba(96, 165, 250, 0.095);
}

.topic-card-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.topic-card-top strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 17px;
}

.topic-card-top em {
  flex: 0 0 auto;
  color: var(--accent);
  font-style: normal;
  font-weight: 800;
}

.topic-card > span:last-child {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.topic-problem-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 4px;
  align-content: start;
}

/* Compact one-line "textbook row" per problem: status | name | tags | difficulty */
.topic-row {
  display: grid;
  grid-template-columns: 24px minmax(0, 1.6fr) minmax(0, 1.8fr) auto auto;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  padding: 9px 14px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel-soft);
  color: var(--ink);
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease;
}
.topic-row:hover { background: rgba(96, 165, 250, 0.10); border-color: rgba(96, 165, 250, 0.45); }
.topic-row.active { border-color: var(--accent); box-shadow: inset 3px 0 0 var(--accent); }
.topic-row .row-status { font-size: 14px; font-weight: 800; text-align: center; color: var(--muted); }
.topic-row.solved .row-status { color: #34d399; }
.topic-row.attempted .row-status { color: #fbbf24; }
.topic-row .row-name { font-weight: 650; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topic-row.solved .row-name { color: #cfeede; }
.topic-row .row-tags { display: flex; gap: 5px; flex-wrap: nowrap; overflow: hidden; }
.topic-row .row-tags .mini-tag { font-size: 11px; }
.topic-row .row-solved { font-size: 10.5px; color: #34d399; justify-self: end; white-space: nowrap; min-width: 70px; text-align: right; }
.topic-row .row-diff { font-size: 11px; color: var(--muted); justify-self: end; white-space: nowrap; }
@media (max-width: 760px) {
  .topic-row { grid-template-columns: 20px 1fr auto; }
  .topic-row .row-tags, .topic-row .row-solved { display: none; }
}

/* Top-bar streak / activity chip */
.streak-badge {
  font-size: 12px;
  font-weight: 650;
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid rgba(52, 211, 153, 0.4);
  background: rgba(52, 211, 153, 0.12);
  color: #6ee7b7;
  cursor: pointer;
  white-space: nowrap;
}
.streak-badge:hover { border-color: rgba(52, 211, 153, 0.7); background: rgba(52, 211, 153, 0.18); }
.stale-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin: 0 0 8px;
  padding: 9px 12px;
  border: 1px solid rgba(251, 191, 36, 0.45);
  background: rgba(251, 191, 36, 0.12);
  border-radius: 8px;
  font-size: 12.5px;
  color: var(--ink);
}
.stale-banner code { font-family: 'JetBrains Mono', monospace; font-size: 11.5px; }
.stale-banner-actions { display: flex; gap: 8px; flex: 0 0 auto; }
.stale-banner button {
  font-size: 12px;
  padding: 5px 12px;
  border-radius: 6px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  white-space: nowrap;
}
.stale-banner .stale-banner-dismiss { background: transparent; color: var(--muted); border-color: var(--line); }
.stale-banner .stale-banner-dismiss:hover { color: var(--ink); }

.topbar-settings {
  font-size: 15px;
  line-height: 1;
  padding: 6px 9px;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.topbar-settings:hover { color: var(--ink); border-color: var(--line-strong); }
.settings-dialog {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  color: var(--ink);
  max-width: 560px;
  width: 92vw;
  padding: 0;
}
.settings-dialog::backdrop { background: rgba(0, 0, 0, 0.55); }
.settings-dialog form { display: flex; flex-direction: column; max-height: 86vh; }
.settings-dialog header { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.settings-dialog header h2 { margin: 0; font-size: 15px; }
.settings-dialog header button { font-size: 12px; padding: 5px 12px; border-radius: 6px; border: 1px solid var(--line); background: transparent; color: var(--ink); cursor: pointer; }
.settings-body { padding: 16px 18px; overflow: auto; display: flex; flex-direction: column; gap: 18px; }
.settings-section h3 { margin: 0 0 10px; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.settings-tag { font-size: 10px; background: var(--panel-soft); border: 1px solid var(--line); border-radius: 999px; padding: 1px 7px; margin-left: 6px; color: var(--accent); letter-spacing: 0; text-transform: none; }
.settings-grid { display: grid; gap: 2px; }
.kv { display: flex; justify-content: space-between; gap: 14px; font-size: 13px; padding: 6px 0; border-bottom: 1px solid var(--panel-soft); }
.kv-k { color: var(--muted); }
.kv-v { color: var(--ink); font-weight: 600; text-align: right; }
.settings-actions { margin-top: 12px; }
#reset2faButton {
  font-size: 12.5px; padding: 7px 13px; border-radius: 7px; border: 1px solid var(--line-strong);
  background: var(--panel-soft); color: var(--ink); cursor: pointer;
}
#reset2faButton:hover { border-color: var(--accent); }
.reset2fa-result { margin-top: 12px; }
.reset2fa-warn { font-size: 12px; color: var(--warn); margin: 0 0 8px; font-weight: 600; }
.settings-field { display: grid; gap: 6px; margin-top: 14px; }
.settings-field > span:first-child { font-size: 12px; color: var(--muted); }
.settings-field-row { display: flex; gap: 8px; }
.settings-field-row input { flex: 1; min-width: 0; min-height: 34px; border-radius: 7px; border: 1px solid var(--line); background: var(--panel-soft); color: var(--ink); padding: 6px 10px; font-size: 13px; }
.settings-field-row button { font-size: 12.5px; padding: 6px 14px; border-radius: 7px; border: 1px solid var(--accent); background: var(--accent); color: #fff; cursor: pointer; }
.settings-msg { font-size: 12px; color: var(--muted); min-height: 14px; }
.settings-actions { margin-top: 14px; display: flex; gap: 8px; flex-wrap: wrap; }
#reset2faButton, #regenRecoveryButton {
  font-size: 12.5px; padding: 7px 13px; border-radius: 7px; border: 1px solid var(--line-strong);
  background: var(--panel-soft); color: var(--ink); cursor: pointer;
}
#reset2faButton:hover, #regenRecoveryButton:hover { border-color: var(--accent); }

.theme-select {
  font-size: 12px;
  padding: 5px 9px;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: var(--panel-soft);
  color: var(--muted);
  cursor: pointer;
}
.theme-select:hover { color: var(--ink); border-color: var(--line-strong); }
.auth-user { font-size: 12.5px; font-weight: 650; color: var(--ink); white-space: nowrap; }
.topbar-logout { font-size: 12px; padding: 5px 12px; border-radius: 7px; border: 1px solid var(--line); background: transparent; color: var(--muted); cursor: pointer; }
.topbar-logout:hover { color: var(--ink); border-color: rgba(96, 165, 250, 0.5); }
.login-toggle { margin-top: 4px; background: transparent; border: 0; color: var(--accent); font-size: 12.5px; cursor: pointer; padding: 4px; }
.login-toggle:hover { text-decoration: underline; }
.auth-view { display: flex; flex-direction: column; gap: 10px; }
.auth-view[hidden] { display: none; }
.totp-setup { display: flex; gap: 14px; align-items: center; justify-content: center; flex-wrap: wrap; margin: 4px 0; }
.qr-code { background: #fff; border-radius: 8px; padding: 6px; line-height: 0; }
.qr-code img, .qr-code canvas { display: block; }
.totp-secret { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.totp-secret-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.totp-secret code { font-family: 'JetBrains Mono', 'SF Mono', Consolas, monospace; font-size: 12.5px; word-break: break-all; color: var(--ink); background: var(--panel-soft); padding: 6px 8px; border-radius: 6px; }
.recovery-block { border: 1px solid rgba(251, 191, 36, 0.35); background: rgba(251, 191, 36, 0.07); border-radius: 8px; padding: 10px 12px; }
.recovery-block strong { font-size: 13px; }
.recovery-note { font-size: 11.5px; color: var(--muted); margin: 4px 0 8px; }
.recovery-list { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 14px; margin: 0; padding-left: 18px; }
.recovery-list li { font-family: 'JetBrains Mono', 'SF Mono', Consolas, monospace; font-size: 12.5px; }

/* ---- Activity heat map + 30-day solution history ---- */
.progress-panel {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-soft);
  padding: 14px 16px;
  margin-bottom: 4px;
}
.progress-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.progress-head h3 { margin: 0; font-size: 14px; }
.progress-summary { color: var(--muted); font-size: 12.5px; }
.progress-clear { font-size: 11.5px; padding: 4px 10px; border-radius: 6px; border: 1px solid var(--line); background: transparent; color: var(--muted); cursor: pointer; }
.progress-clear:hover { color: var(--ink); border-color: rgba(96, 165, 250, 0.4); }
.heatmap { overflow-x: auto; padding-bottom: 2px; }
.heat-months { display: grid; grid-auto-flow: column; grid-auto-columns: 15px; gap: 3px; margin-bottom: 3px; }
.heat-month { font-size: 9.5px; color: var(--muted); }
.heat-grid { display: grid; grid-auto-flow: column; grid-auto-columns: 15px; gap: 3px; width: max-content; }
.heat-col { display: grid; grid-template-rows: repeat(7, 12px); gap: 3px; }
.heat-cell { width: 12px; height: 12px; border-radius: 3px; border: 0; padding: 0; cursor: pointer; background: var(--panel-soft); }
.heat-cell.future { visibility: hidden; cursor: default; }
.heat-cell.l0 { background: var(--panel-soft); }
.heat-cell.l1 { background: rgba(52, 211, 153, 0.32); }
.heat-cell.l2 { background: rgba(52, 211, 153, 0.52); }
.heat-cell.l3 { background: rgba(52, 211, 153, 0.74); }
.heat-cell.l4 { background: rgba(52, 211, 153, 0.96); }
.heat-cell:hover { outline: 1.5px solid rgba(96, 165, 250, 0.75); }
.day-detail { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 10px; }
.day-detail-head { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--muted); margin-bottom: 6px; }
.day-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto auto; align-items: center; gap: 10px; padding: 5px 0; }
.day-row-name { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.day-row-lang { font-size: 10.5px; color: var(--muted); }
.day-view-code, .day-open { font-size: 11px; padding: 3px 9px; border-radius: 6px; border: 1px solid var(--line); background: transparent; color: var(--accent); cursor: pointer; }
.day-view-code:hover, .day-open:hover { border-color: rgba(96, 165, 250, 0.5); }
.solution-dialog { border: 1px solid var(--line); border-radius: 10px; background: var(--panel); color: var(--ink); max-width: 880px; width: 90vw; padding: 0; }
.solution-dialog::backdrop { background: rgba(0, 0, 0, 0.55); }
.solution-dialog form { display: flex; flex-direction: column; max-height: 80vh; }
.solution-dialog header { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.solution-dialog header h2 { margin: 0; font-size: 14px; }
.solution-dialog header button { font-size: 12px; padding: 4px 12px; border-radius: 6px; border: 1px solid var(--line); background: transparent; color: var(--ink); cursor: pointer; }
.solution-dialog pre { margin: 0; padding: 16px; overflow: auto; font-family: 'JetBrains Mono', 'SF Mono', Consolas, monospace; font-size: 13px; line-height: 1.5; white-space: pre; color: #e8e8ed; }

.topic-problem-card {
  display: grid;
  gap: 8px;
  min-height: 136px;
  padding: 13px;
}

.topic-problem-card.active {
  border-color: rgba(96, 165, 250, 0.6);
  box-shadow: inset 4px 0 0 var(--accent);
}

.topic-problem-card strong {
  font-size: 15px;
  line-height: 1.25;
}

.topic-problem-path {
  min-height: 17px;
  overflow: hidden;
  color: var(--quiet);
  font-family: 'JetBrains Mono', 'SF Mono', 'Cascadia Code', Consolas, monospace;
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.workspace[data-view="home"],
.workspace[data-view="topic"] {
  grid-template-rows: minmax(0, 1fr);
}

.workspace[data-view="home"] #topicPane,
.workspace[data-view="home"] .workspace-tabs,
.workspace[data-view="home"] .problem-header,
.workspace[data-view="home"] .split,
.workspace[data-view="home"] .results-pane,
.workspace[data-view="topic"] #homePane,
.workspace[data-view="topic"] .workspace-tabs,
.workspace[data-view="topic"] .problem-header,
.workspace[data-view="topic"] .split,
.workspace[data-view="topic"] .results-pane,
.workspace[data-view="problem"] #homePane,
.workspace[data-view="problem"] #topicPane {
  display: none;
}

.workspace[data-view="problem"] {
  grid-template-rows: auto minmax(0, 1fr) minmax(104px, 18vh);
}

body[data-view="home"] .app-shell {
  grid-template-columns: minmax(0, 1fr);
}

body[data-view="home"] .sidebar {
  display: none;
}

body[data-view="home"] .workspace {
  padding-inline: clamp(20px, 4vw, 56px);
}

@media (max-width: 820px) {
  .library-header {
    display: grid;
  }

  .topic-grid,
  .topic-problem-grid {
    max-height: none;
    overflow: visible;
  }
}

/* Foldable workspace edge controls */
.edge-toggle {
  width: 24px;
  height: 46px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(148, 163, 184, 0.24);
  border-radius: 7px;
  background: rgba(15, 23, 42, 0.92);
  color: #bfdbfe;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.28);
  z-index: 20;
}

.edge-toggle::before {
  content: "";
  width: 9px;
  height: 9px;
  border-top: 2px solid currentColor;
  border-right: 2px solid currentColor;
  transform: rotate(225deg);
}

.edge-toggle:hover {
  border-color: rgba(96, 165, 250, 0.54);
  background: rgba(30, 41, 59, 0.98);
  color: #eff6ff;
}

.edge-toggle:disabled {
  cursor: not-allowed;
  opacity: 0.28;
}

.edge-toggle:disabled::before {
  opacity: 0.5;
}

.sidebar-edge {
  position: fixed;
  top: calc(56px + 50vh - 23px);
  left: clamp(260px, 24vw, 340px);
  transform: translateX(-50%);
}

body[data-view="home"] .sidebar-edge {
  display: none;
}

body.sidebar-collapsed .app-shell {
  grid-template-columns: 0 minmax(0, 1fr);
}

body.sidebar-collapsed .sidebar {
  width: 0;
  min-width: 0;
  overflow: hidden;
  padding-left: 0;
  padding-right: 0;
  border-right: 0;
}

body.sidebar-collapsed .sidebar-edge {
  left: 12px;
}

body.sidebar-collapsed .sidebar-edge::before {
  transform: rotate(45deg);
}

.split {
  position: relative;
}

.workspace[data-view="problem"] .split {
  grid-template-columns: minmax(340px, 0.34fr) 0 minmax(680px, 0.66fr);
}

.workspace[data-view="problem"] .prompt-pane {
  grid-column: 1;
}

.workspace[data-view="problem"] .prompt-edge {
  grid-column: 2;
  align-self: center;
  justify-self: center;
  transform: translateX(-50%);
}

.workspace[data-view="problem"] .editor-pane {
  grid-column: 3;
}

.prompt-edge::before {
  transform: rotate(225deg);
}

.workspace.prompt-collapsed .split {
  grid-template-columns: 0 0 minmax(0, 1fr);
}

.workspace.prompt-collapsed .prompt-pane {
  display: none;
}

.workspace.prompt-collapsed .prompt-edge::before {
  transform: rotate(45deg);
}

.workspace.results-collapsed {
  grid-template-rows: auto minmax(0, 1fr) 0;
}

.results-pane {
  position: relative;
}

.results-edge {
  position: absolute;
  top: -14px;
  left: 50%;
  width: 46px;
  height: 24px;
  transform: translateX(-50%);
}

.results-edge::before {
  transform: rotate(135deg);
}

.workspace.results-collapsed .results-pane {
  min-height: 0;
  overflow: visible;
  padding: 0;
  border-color: transparent;
  background: transparent;
  box-shadow: none;
}

.workspace.results-collapsed .results-pane > :not(.results-edge) {
  display: none;
}

.workspace.results-collapsed .results-edge {
  top: -24px;
}

.workspace.results-collapsed .results-edge::before {
  transform: rotate(315deg);
}

.editor-body {
  position: relative;
}

.editor-pane.multi-file .editor-body {
  grid-template-columns: 0 minmax(148px, 180px) minmax(0, 1fr);
}

.explorer-edge {
  grid-column: 1;
  align-self: center;
  justify-self: center;
  transform: translateX(-50%);
}

.explorer-edge::before {
  transform: rotate(225deg);
}

.editor-pane:not(.multi-file) .explorer-edge {
  display: none;
}

.editor-pane.multi-file .context-files {
  grid-column: 2;
}

.editor-pane.multi-file .editor-main {
  grid-column: 3;
}

.editor-pane.explorer-collapsed .editor-body,
.editor-pane.multi-file.explorer-collapsed .editor-body {
  grid-template-columns: 0 minmax(0, 1fr);
}

.editor-pane.explorer-collapsed .context-files {
  display: none;
}

.editor-pane.explorer-collapsed .explorer-edge {
  grid-column: 1;
  transform: translateX(50%);
}

.editor-pane.explorer-collapsed .explorer-edge::before {
  transform: rotate(45deg);
}

.editor-pane.explorer-collapsed .editor-main {
  grid-column: 2;
}

body.sidebar-collapsed .topic-grid {
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}

@media (max-width: 820px) {
  body.sidebar-collapsed .app-shell {
    grid-template-columns: 1fr;
  }

  body.sidebar-collapsed .sidebar {
    display: none;
  }

  .edge-toggle {
    display: none;
  }
}

/* Repository navigation now lives on Home/topic pages, so the workbench is one column. */
.app-shell,
body[data-view="home"] .app-shell,
body.sidebar-collapsed .app-shell {
  grid-template-columns: minmax(0, 1fr);
}

.sidebar,
.sidebar-edge {
  display: none;
}

.workspace {
  width: 100%;
}

.workspace[data-view="problem"] {
  grid-template-rows: auto minmax(0, 1fr) 0;
  align-content: stretch;
}

.workspace[data-view="problem"]:not(.results-collapsed) {
  grid-template-rows: auto minmax(0, 1fr) minmax(140px, var(--results-height, 34vh));
}

.login-body {
  min-height: 100%;
  overflow: auto;
  background: radial-gradient(circle at 50% 0%, rgba(96, 165, 250, 0.16), transparent 34%), var(--bg);
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(420px, 100%);
  display: grid;
  gap: 16px;
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.9);
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.42);
}

.login-card h1 {
  color: #f8fafc;
  font-size: 28px;
}

.login-card p,
.login-message {
  color: #94a3b8;
}

.login-card label {
  display: grid;
  gap: 8px;
  color: #cbd5e1;
  font-size: 13px;
  font-weight: 760;
}

.login-card input {
  min-height: 44px;
  border-color: rgba(148, 163, 184, 0.26);
  background: rgba(2, 6, 23, 0.72);
  color: #f8fafc;
}

.login-card button {
  min-height: 42px;
  border-color: transparent;
  background: var(--accent);
  color: #fff;
}

.status-toggle,
.font-controls,
.timer-widget {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 36px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.status-toggle button,
.font-controls button,
.timer-widget button,
#shortcutHelpButton {
  min-height: 28px;
  padding: 5px 9px;
  font-size: 12px;
}

.status-toggle button.active {
  border-color: rgba(34, 197, 94, 0.5);
  background: rgba(34, 197, 94, 0.17);
  color: #bbf7d0;
}

#solvedButton.active {
  border-color: rgba(96, 165, 250, 0.58);
  background: rgba(96, 165, 250, 0.2);
  color: #dbeafe;
}

.timer-widget select {
  width: 72px;
  min-height: 28px;
  padding: 4px 24px 4px 8px;
  border-radius: 6px;
  font-size: 12px;
}

.timer-icon-button {
  position: relative;
  width: 30px;
  min-width: 30px;
  min-height: 28px;
  display: grid;
  place-items: center;
  padding: 0;
}

#timerStartButton::before {
  content: "";
  width: 0;
  height: 0;
  margin-left: 2px;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
  border-left: 10px solid currentColor;
}

#timerStartButton.is-running::before {
  width: 11px;
  height: 12px;
  margin-left: 0;
  border-top: 0;
  border-bottom: 0;
  border-left: 4px solid currentColor;
  border-right: 4px solid currentColor;
}

#timerResetButton::before {
  content: "";
  width: 13px;
  height: 13px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
}

#timerResetButton::after {
  content: "";
  position: absolute;
  top: 7px;
  right: 7px;
  width: 6px;
  height: 6px;
  border-top: 2px solid currentColor;
  border-right: 2px solid currentColor;
  transform: rotate(18deg);
}

#timerDisplay {
  min-width: 58px;
  padding: 0 7px;
}

#fontSizeLabel {
  min-width: 52px;
  padding: 0 6px;
  text-align: center;
}

#fontSizeLabel {
  color: #dbeafe;
  font-family: 'JetBrains Mono', 'SF Mono', 'Cascadia Code', Consolas, monospace;
  font-size: 12px;
  font-weight: 760;
}

#timerDisplay {
  color: #dbeafe;
  font-family: 'JetBrains Mono', 'SF Mono', 'Cascadia Code', Consolas, monospace;
  font-size: 12px;
  font-weight: 760;
}

#timerDisplay.expired {
  color: #fecaca;
}

#shortcutHelpButton {
  width: 36px;
  padding-inline: 0;
  font-weight: 850;
}

.solve-badge {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  padding: 2px 7px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.12);
  color: #cbd5e1;
  font-size: 11px;
  font-weight: 800;
}

.solve-badge.attempted {
  border-color: rgba(34, 197, 94, 0.34);
  background: rgba(34, 197, 94, 0.13);
  color: #bbf7d0;
}

.solve-badge.solved {
  border-color: rgba(96, 165, 250, 0.42);
  background: rgba(96, 165, 250, 0.16);
  color: #dbeafe;
}

.workspace[data-view="problem"] .split {
  grid-template-columns: minmax(280px, var(--prompt-width, 32%)) 10px minmax(520px, 1fr) 10px minmax(220px, 0.18fr);
  height: 100%;
  min-height: 0;
  align-items: stretch;
  align-content: stretch;
  grid-auto-rows: minmax(0, 1fr);
}

.workspace[data-view="problem"] .prompt-pane,
.workspace[data-view="problem"] .split-resizer,
.workspace[data-view="problem"] .prompt-edge,
.workspace[data-view="problem"] .editor-pane,
.workspace[data-view="problem"] .notes-edge,
.workspace[data-view="problem"] .notes-pane {
  grid-row: 1;
}

.workspace[data-view="problem"] .prompt-edge,
.workspace[data-view="problem"] .split-resizer {
  grid-column: 2;
}

.split-resizer {
  min-width: 10px;
  min-height: 100%;
  align-self: stretch;
  cursor: col-resize;
  border: 0;
  border-radius: 8px;
  background: linear-gradient(90deg, transparent 0 4px, rgba(96, 165, 250, 0.32) 4px 6px, transparent 6px 10px);
}

.split-resizer:hover,
body.resizing-split .split-resizer {
  background: linear-gradient(90deg, transparent 0 3px, rgba(96, 165, 250, 0.72) 3px 7px, transparent 7px 10px);
}

body.resizing-split {
  cursor: col-resize;
  user-select: none;
}

/* Horizontal (row) resizer that lives at the top edge of the results pane and
   drags the results height up/down, shrinking/growing the editor+prompt split. */
.results-pane > .split-resizer.horizontal {
  position: absolute;
  top: -13px;
  left: 8px;
  right: 8px;
  width: auto;
  min-width: 0;
  min-height: 10px;
  height: 11px;
  cursor: row-resize;
  z-index: 6;
  background: linear-gradient(180deg, transparent 0 4px, rgba(96, 165, 250, 0.32) 4px 7px, transparent 7px 11px);
}

.results-pane > .split-resizer.horizontal:hover,
body.resizing-results .results-pane > .split-resizer.horizontal {
  background: linear-gradient(180deg, transparent 0 3px, rgba(96, 165, 250, 0.78) 3px 8px, transparent 8px 11px);
}

.workspace.results-collapsed .results-pane > .split-resizer.horizontal {
  display: none;
}

body.resizing-results {
  cursor: row-resize;
  user-select: none;
}

.workspace[data-view="problem"] .editor-pane {
  grid-column: 3;
  height: 100%;
  min-height: 0;
  align-self: stretch;
}

.workspace[data-view="problem"] .notes-edge {
  grid-column: 4;
  align-self: center;
  justify-self: center;
  transform: translateX(-50%);
}

.notes-edge::before {
  transform: rotate(45deg);
}

.notes-pane {
  grid-column: 5;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-width: 0;
  min-height: 0;
  height: 100%;
  align-self: stretch;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.notes-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 42px;
  padding: 0 12px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-soft);
}

.notes-header h3 {
  color: var(--ink);
  font-size: 14px;
  font-weight: 800;
}

.notes-header span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 720;
}

#problemNotes {
  width: 100%;
  height: 100%;
  min-height: 0;
  resize: none;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  padding: 13px;
  line-height: 1.5;
  font-size: 13px;
}

.results-pane {
  max-height: min(220px, 24vh);
}

.results-pane:has(#outputPanel:not(:empty)),
.results-pane:has(.result-tests:not(:empty)) {
  max-height: min(360px, 38vh);
}

.workspace.prompt-collapsed .split {
  grid-template-columns: 0 10px minmax(0, 1fr) 10px minmax(220px, 0.18fr);
}

.workspace.notes-collapsed .split {
  grid-template-columns: minmax(280px, var(--prompt-width, 32%)) 10px minmax(0, 1fr) 10px 0;
}

.workspace.prompt-collapsed.notes-collapsed .split {
  grid-template-columns: 0 10px minmax(0, 1fr) 10px 0;
}

.workspace[data-view="problem"] .prompt-pane {
  height: 100%;
  min-height: 0;
  align-self: stretch;
}

.workspace[data-view="problem"] .editor-body,
.workspace[data-view="problem"] .editor-main,
.workspace[data-view="problem"] #codeEditor {
  min-height: 0;
}

.workspace[data-view="problem"] .editor-pane.multi-file .editor-body {
  grid-template-columns: 0 clamp(220px, 18vw, 310px) minmax(0, 1fr);
}

.workspace[data-view="problem"] .context-files {
  min-width: 0;
  overflow: hidden;
}

.workspace[data-view="problem"] .context-files-top {
  min-height: 40px;
  padding: 0 12px;
  gap: 10px;
}

.workspace[data-view="problem"] .context-files-top span:first-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.workspace[data-view="problem"] .context-files-top span:last-child {
  flex: 0 0 auto;
}

.workspace[data-view="problem"] .file-tree {
  padding-block: 8px 12px;
}

.workspace[data-view="problem"] .file-tree-dir {
  padding: 10px 12px 6px;
  font-size: 10px;
}

.workspace[data-view="problem"] .file-tree-item {
  min-height: 30px;
  padding: 5px 12px 5px 16px;
  gap: 8px;
  font-size: 12px;
  line-height: 1.25;
}

.workspace[data-view="problem"] .file-tree-item::before {
  margin-right: 0;
}

.workspace[data-view="problem"] .file-tree-item span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.workspace[data-view="problem"] .file-tree-item.active {
  box-shadow: inset 3px 0 0 var(--accent);
}

.workspace[data-view="problem"] .editor-pane.multi-file.explorer-collapsed .editor-body {
  grid-template-columns: 0 minmax(0, 1fr);
}

.workspace.notes-collapsed .notes-pane {
  display: none;
}

.workspace.notes-collapsed .notes-edge {
  transform: translateX(50%);
}

.workspace.notes-collapsed .notes-edge::before {
  transform: rotate(225deg);
}

.shortcut-dialog {
  width: min(560px, calc(100vw - 32px));
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0f172a;
  color: #e5e7eb;
  padding: 0;
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.55);
}

.shortcut-dialog::backdrop {
  background: rgba(0, 0, 0, 0.58);
}

.shortcut-dialog form {
  margin: 0;
}

.shortcut-dialog header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.shortcut-dialog h2 {
  font-size: 18px;
}

.shortcut-dialog dl {
  display: grid;
  grid-template-columns: minmax(150px, 0.45fr) minmax(0, 1fr);
  gap: 10px 16px;
  margin: 0;
  padding: 16px;
}

.shortcut-dialog dt {
  color: #bfdbfe;
  font-family: 'JetBrains Mono', 'SF Mono', 'Cascadia Code', Consolas, monospace;
  font-size: 12px;
  font-weight: 800;
}

.shortcut-dialog dd {
  margin: 0;
  color: #cbd5e1;
  font-size: 13px;
}

@media (max-width: 1280px) {
  .workspace[data-view="problem"] .split {
    grid-template-columns: minmax(280px, var(--prompt-width, 32%)) 10px minmax(420px, 1fr) 10px 0;
  }

  .notes-pane {
    display: grid;
    grid-column: 1 / -1;
    min-height: 190px;
  }

  .workspace.notes-collapsed .notes-pane {
    display: none;
  }
}

@media (max-width: 900px) {
  .status-toggle,
  .font-controls,
  .timer-widget {
    width: 100%;
    justify-content: center;
  }

  .workspace[data-view="problem"] .split,
  .workspace.prompt-collapsed .split {
    grid-template-columns: 1fr;
  }

  .split-resizer,
  .prompt-edge {
    display: none;
  }
}

/* card elevation per theme */
:root, html[data-theme="dark"] { --card-shadow: 0 1px 2px rgba(0, 0, 0, 0.25); }
html[data-theme="light"] { --card-shadow: 0 1px 3px rgba(15, 23, 42, 0.08); }
