/* ============================================================
   SQL Simulator — dark theme
   ============================================================ */

:root {
  --bg0: #0a0c0f;
  --bg1: #10141a;
  --bg2: #151b23;
  --bg3: #1c2430;
  --bg-editor: #0d1117;
  --border: #232c38;
  --border-soft: #1b222c;
  --text: #dfe7f1;
  --text-dim: #93a1b3;
  --text-faint: #5d6b7d;
  --accent: #57a0ff;
  --accent-soft: rgba(87, 160, 255, 0.12);
  --green: #34c07c;
  --green-soft: rgba(52, 192, 124, 0.12);
  --orange: #e8a33d;
  --orange-soft: rgba(232, 163, 61, 0.12);
  --red: #e8564d;
  --red-soft: rgba(232, 86, 77, 0.12);
  --font-ui: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", Consolas, "Courier New", monospace;
  --radius: 12px;
  --radius-sm: 8px;
  --topbar-h: 52px;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background:
    radial-gradient(1100px 380px at 72% -8%, rgba(87, 160, 255, 0.06), transparent 70%),
    var(--bg0);
  -webkit-font-smoothing: antialiased;
}

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

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: #273140;
  border-radius: 6px;
  border: 2px solid var(--bg0);
}
::-webkit-scrollbar-thumb:hover { background: #334052; }

/* ---------- top bar ---------- */

.topbar {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  border-bottom: 1px solid var(--border-soft);
  background: rgba(10, 12, 15, 0.85);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 50;
}

.brand {
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
}
.brand:hover { text-decoration: none; }
.brand .brand-sql { color: var(--accent); }
.brand .brand-cursor {
  display: inline-block;
  width: 7px;
  height: 15px;
  margin-left: 3px;
  background: var(--accent);
  vertical-align: -2px;
  animation: blink 1.2s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

.topbar-nav { display: flex; align-items: center; gap: 14px; }
.topbar-nav a {
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 500;
}
.topbar-nav a:hover { color: var(--text); text-decoration: none; }

/* ---------- shared bits ---------- */

.dots { display: inline-flex; gap: 3px; align-items: center; }
.dots i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--bg3);
}
.dots.d1 i:nth-child(-n+1) { background: var(--green); }
.dots.d2 i:nth-child(-n+2) { background: var(--orange); }
.dots.d3 i:nth-child(-n+3) { background: var(--red); }

.chip {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1;
  padding: 5px 9px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg2);
  color: var(--text-dim);
  white-space: nowrap;
}
.chip.db-chip { color: var(--accent); border-color: rgba(87, 160, 255, 0.3); }

.btn {
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.01em;
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg2);
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.btn:hover { background: var(--bg3); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn.btn-run {
  border-color: rgba(87, 160, 255, 0.4);
  color: var(--accent);
}
.btn.btn-run:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.btn.btn-submit {
  background: #1d7a4f;
  border-color: #249964;
  color: #eafff4;
}
.btn.btn-submit:hover {
  background: #229059;
  box-shadow: 0 0 18px rgba(52, 192, 124, 0.25);
}

.btn.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-faint);
  padding: 6px 10px;
}
.btn.btn-ghost:hover { color: var(--text-dim); background: var(--bg2); }

.kbd {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-faint);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 1px 5px;
  background: var(--bg1);
}

/* ---------- task page layout ---------- */

.task-layout {
  display: grid;
  grid-template-columns: minmax(290px, 350px) minmax(460px, 1fr) minmax(300px, 400px);
  gap: 14px;
  padding: 14px;
  height: calc(100dvh - var(--topbar-h));
}

.panel {
  background: var(--bg1);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  min-height: 0;
  display: flex;
  flex-direction: column;
}

/* ---------- panel splitters & collapse ---------- */

.split {
  border-radius: 4px;
  position: relative;
  z-index: 5;
  transition: background 0.12s;
}
.split::after {
  content: '';
  position: absolute;
  background: var(--border);
  border-radius: 2px;
  transition: background 0.12s;
}
.split-col { cursor: col-resize; touch-action: none; }
.split-col::after {
  left: 2px;
  right: 2px;
  top: calc(50% - 16px);
  height: 32px;
}
.split-row { cursor: row-resize; height: 7px; flex: none; touch-action: none; }
.split-row::after {
  top: 2px;
  bottom: 2px;
  left: calc(50% - 16px);
  width: 32px;
}
.split:hover, .split.active { background: var(--accent-soft); }
.split:hover::after, .split.active::after { background: var(--accent); }
.split.disabled { pointer-events: none; }
.split.disabled::after { opacity: 0.3; }

.panel-collapse {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 6;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg2);
  color: var(--text-faint);
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}
.panel-collapse:hover { color: var(--text); background: var(--bg3); }
.panel-collapse.pc-inline { position: static; flex: none; }

.collapsed-tab {
  display: none;
  writing-mode: vertical-rl;
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.14em;
  color: var(--text-faint);
  margin: 12px auto 0;
  user-select: none;
}

.panel.collapsed { cursor: pointer; overflow: hidden; }
.panel.collapsed:hover { border-color: var(--accent); }
.panel.collapsed:hover .collapsed-tab { color: var(--accent); }

.task-desc.collapsed { padding: 10px 4px; }
.task-desc.collapsed > *:not(.collapsed-tab):not(.panel-collapse) { display: none; }
.task-desc.collapsed .collapsed-tab { display: block; }
.task-desc.collapsed .panel-collapse { position: static; margin: 0 auto; transform: rotate(180deg); }

.schema-panel.collapsed > *:not(.collapsed-tab) { display: none; }
.schema-panel.collapsed .collapsed-tab { display: block; }
.schema-panel.collapsed { background-image: none; }

.tabs-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding-right: 8px;
  border-bottom: 1px solid var(--border-soft);
  flex: none;
}
.results-card.collapsed { flex: none; min-height: 0; }
.results-card.collapsed .result-pane { display: none; }
.results-card.collapsed .tabs-row { border-bottom: none; }
.results-card.collapsed .panel-collapse { transform: rotate(180deg); }
.editor-card.grow { flex: 1; min-height: 0; }
.editor-card.grow .editor-box { height: auto !important; flex: 1; min-height: 0; }

/* left: description */

.task-desc {
  overflow-y: auto;
  padding: 20px;
  position: relative;
}

.task-desc .task-num {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-faint);
}

.task-desc h1 {
  font-size: 20px;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.01em;
  margin: 6px 0 10px;
}

.task-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}

.fav-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 16px;
  color: var(--text-faint);
  padding: 2px 4px;
  line-height: 1;
  transition: color 0.15s, transform 0.15s;
}
.fav-btn:hover { color: var(--orange); transform: scale(1.15); }
.fav-btn.active { color: var(--orange); }

.task-body { color: var(--text-dim); font-size: 13.5px; }
.task-body p { margin: 0 0 12px; }
.task-body strong { color: var(--text); font-weight: 600; }
.task-body code {
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--bg2);
  border: 1px solid var(--border-soft);
  border-radius: 4px;
  padding: 1px 5px;
  color: #9ecbff;
}
.task-body pre {
  background: var(--bg-editor);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 12px;
  overflow-x: auto;
}
.task-body pre code { background: none; border: none; padding: 0; }
.task-body ul { margin: 0 0 12px; padding-left: 20px; }
.task-body li { margin-bottom: 4px; }

.result-fields {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px dashed var(--border);
}
.result-fields .rf-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-faint);
  margin-bottom: 8px;
}
.result-fields .rf-value {
  font-family: var(--font-mono);
  font-size: 12px;
  color: #9ecbff;
  background: var(--bg2);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  word-break: break-all;
}

/* center: workbench */

.workbench {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
  min-height: 0;
}

.editor-card {
  flex: none;
  display: flex;
  flex-direction: column;
}

.editor-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-soft);
}

.toolbar-left {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  position: relative;
}

.dialect-badge {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid rgba(87, 160, 255, 0.25);
  border-radius: 4px;
  padding: 3px 7px;
  cursor: pointer;
  transition: all 0.12s;
}
.dialect-badge:hover { border-color: var(--accent); }
.dialect-badge.tsql {
  color: var(--orange);
  background: var(--orange-soft);
  border-color: rgba(232, 163, 61, 0.35);
}
.dialect-badge.tsql:hover { border-color: var(--orange); }

.dialect-info-btn {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg2);
  color: var(--text-faint);
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}
.dialect-info-btn:hover { color: var(--text); border-color: var(--text-faint); }

.dialect-popover {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 30;
  width: 340px;
  max-width: 70vw;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.5);
  padding: 12px 14px;
  font-size: 12px;
  line-height: 1.55;
  color: var(--text-dim);
}
.dialect-popover b { color: var(--text); }
.dialect-popover code {
  font-family: var(--font-mono);
  font-size: 10.5px;
  background: var(--bg-editor);
  border: 1px solid var(--border-soft);
  border-radius: 3px;
  padding: 0 4px;
  color: #9ecbff;
}

.editor-box {
  height: 210px;
  min-height: 110px;
  overflow: auto;
}
.editor-box .cm-editor { height: 100%; font-size: 13px; }
.editor-box .cm-editor.cm-focused { outline: none; }
.cm-editor, .cm-editor .cm-gutters {
  background: var(--bg-editor) !important;
  font-family: var(--font-mono) !important;
}
.cm-editor .cm-gutters { border-right: 1px solid var(--border-soft) !important; }

.editor-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-top: 1px solid var(--border-soft);
}
.editor-actions .spacer { flex: 1; }
.editor-actions .hint { font-size: 11.5px; color: var(--text-faint); }

/* results card */

.results-card { flex: 1; min-height: 0; }

.tabs {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 0 8px;
  overflow-x: auto;
  flex: 1;
  min-width: 0;
}
.tab {
  font-family: var(--font-ui);
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-faint);
  padding: 10px 12px 8px;
  border: none;
  background: none;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  transition: color 0.12s;
}
.tab:hover { color: var(--text-dim); }
.tab.active { color: var(--text); border-bottom-color: var(--accent); }
.tab.tab-result.active { border-bottom-color: var(--green); }
.tab .tab-icon { font-size: 10px; margin-right: 5px; opacity: 0.7; }

.result-pane {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 12px;
}

.empty-state {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--text-faint);
  font-size: 13px;
  text-align: center;
  padding: 24px;
}
.empty-state .es-icon { font-size: 26px; opacity: 0.5; }

/* verdict banners */

.verdict {
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-bottom: 12px;
  font-size: 13.5px;
  border: 1px solid;
  animation: verdict-in 0.25s ease-out;
}
@keyframes verdict-in {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: none; }
}
.verdict .v-title {
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 2px;
}
.verdict .v-msg { color: var(--text-dim); }
.verdict.v-correct { background: var(--green-soft); border-color: rgba(52, 192, 124, 0.35); }
.verdict.v-correct .v-title { color: var(--green); }
.verdict.v-wrong { background: var(--orange-soft); border-color: rgba(232, 163, 61, 0.35); }
.verdict.v-wrong .v-title { color: var(--orange); }
.verdict.v-error { background: var(--red-soft); border-color: rgba(232, 86, 77, 0.35); }
.verdict.v-error .v-title { color: var(--red); }
.verdict pre {
  font-family: var(--font-mono);
  font-size: 12px;
  color: #ffb3ad;
  margin: 8px 0 0;
  white-space: pre-wrap;
  word-break: break-word;
}
.verdict .v-next { margin-top: 6px; display: inline-block; font-weight: 600; }

/* result table */

.table-wrap { overflow: auto; max-width: 100%; }

.result-table {
  border-collapse: collapse;
  font-family: var(--font-mono);
  font-size: 12.5px;
  min-width: 100%;
}
.result-table th {
  text-align: left;
  font-weight: 600;
  color: var(--accent);
  background: var(--bg2);
  padding: 7px 12px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  white-space: nowrap;
}
.result-table td {
  padding: 6px 12px;
  border-bottom: 1px solid var(--border-soft);
  color: var(--text-dim);
  white-space: nowrap;
  max-width: 340px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.result-table tr:hover td { background: rgba(87, 160, 255, 0.04); color: var(--text); }
.result-table .null { color: var(--text-faint); font-style: italic; }

.row-count {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-faint);
  margin-top: 10px;
}
.row-count .truncated { color: var(--orange); }

/* right: schema panel */

.schema-panel {
  overflow: hidden;
  position: relative;
  background-color: var(--bg1);
  background-image: radial-gradient(circle, #1a2230 1px, transparent 1px);
  background-size: 22px 22px;
}

.schema-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-soft);
  background: var(--bg1);
  position: relative;
  z-index: 5;
}
.schema-head .sh-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-faint);
}
.schema-zoom { display: flex; gap: 4px; }
.schema-zoom button {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg2);
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
}
.schema-zoom button:hover { background: var(--bg3); color: var(--text); }

/* schema diagram */
.schema-viewport {
  flex: 1;
  position: relative;
  overflow: hidden;
  cursor: grab;
  touch-action: none;
}
.schema-viewport.panning { cursor: grabbing; }

.schema-world {
  position: absolute;
  left: 0;
  top: 0;
  transform-origin: 0 0;
}

.schema-edges {
  position: absolute;
  left: 0;
  top: 0;
  pointer-events: none;
  overflow: visible;
}
.schema-edges path {
  fill: none;
  stroke: rgba(87, 160, 255, 0.45);
  stroke-width: 1.5;
}
.schema-edges circle { fill: rgba(87, 160, 255, 0.8); }

.sd-card {
  position: absolute;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  font-family: var(--font-mono);
  font-size: 11.5px;
  user-select: none;
  padding-bottom: 4px;
  cursor: grab;
}
.sd-card.dragging {
  border-color: var(--accent);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.55);
  z-index: 10;
  cursor: grabbing;
}

.sd-head {
  padding: 7px 10px;
  margin-bottom: 4px;
  font-weight: 600;
  font-size: 12.5px;
  color: var(--text);
  background: var(--bg3);
  border-bottom: 1px solid var(--border);
  border-radius: 9px 9px 0 0;
  cursor: pointer;
}
.sd-head:hover { color: var(--accent); }

.sd-col {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  color: var(--text-dim);
  cursor: pointer;
  white-space: nowrap;
}
.sd-col:hover { background: var(--accent-soft); color: var(--text); }
.sd-col .sd-type { margin-left: auto; color: var(--text-faint); font-size: 10px; padding-left: 10px; }
.sd-key { color: var(--orange); font-size: 10px; width: 13px; flex: none; }
.sd-key.sd-fk { color: var(--accent); }

/* ---------- quiz mode ---------- */

.quiz-mode .schema-panel,
.quiz-mode .split { display: none !important; }
.quiz-mode .task-layout { grid-template-columns: minmax(290px, 380px) minmax(460px, 1fr) !important; }

.quiz-card {
  padding: 22px;
  overflow-y: auto;
  flex: 1;
}
.quiz-head {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-faint);
  margin-bottom: 14px;
}
.quiz-options { display: flex; flex-direction: column; gap: 10px; }
.quiz-option {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  text-align: left;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  color: var(--text-dim);
  font-family: var(--font-ui);
  font-size: 13.5px;
  line-height: 1.5;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
}
.quiz-option:hover { border-color: var(--text-faint); color: var(--text); }
.quiz-option.selected { border-color: var(--accent); background: var(--accent-soft); color: var(--text); }
.quiz-option.correct { border-color: var(--green); background: var(--green-soft); color: var(--text); }
.quiz-option.incorrect { border-color: var(--red); background: var(--red-soft); }
.qo-letter {
  flex: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px solid var(--border);
  display: grid;
  place-items: center;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
}
.quiz-option.selected .qo-letter { border-color: var(--accent); color: var(--accent); }
.quiz-option.correct .qo-letter { border-color: var(--green); color: var(--green); }
.quiz-option.incorrect .qo-letter { border-color: var(--red); color: var(--red); }
.qo-text { min-width: 0; }
.qo-text p { margin: 0; }
.qo-text pre { margin: 6px 0 0; }
.quiz-actions { margin: 16px 0; }
.quiz-explanation {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg2);
  border: 1px solid var(--border-soft);
  color: var(--text-dim);
  font-size: 13px;
}
.quiz-explanation p { margin: 4px 0 0; display: inline; }
.quiz-explanation b { color: var(--text); }

.chip.quiz-chip {
  color: #c792ea;
  border-color: rgba(199, 146, 234, 0.35);
}
.chip.exam-chip {
  color: var(--orange);
  border-color: rgba(232, 163, 61, 0.3);
}
.chip.exam-toggle.on {
  background: var(--orange-soft);
  border-color: rgba(232, 163, 61, 0.5);
  color: var(--orange);
}

/* ---------- task list page ---------- */

.list-wrap {
  max-width: 960px;
  margin: 0 auto;
  padding: 30px 18px 70px;
}

.list-header { margin-bottom: 20px; }
.list-header h1 {
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 0 0 4px;
}
.list-header .subtitle { color: var(--text-dim); font-size: 14px; margin: 0; }

.status-counts {
  display: flex;
  gap: 10px;
  margin: 20px 0 14px;
}
.status-btn {
  flex: 1;
  max-width: 180px;
  background: var(--bg1);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 10px 16px;
  text-align: left;
  cursor: pointer;
  color: var(--text-dim);
  font-family: var(--font-ui);
  transition: border-color 0.15s, background 0.15s;
}
.status-btn .sc-num {
  display: block;
  font-family: var(--font-mono);
  font-size: 20px;
  font-weight: 600;
  color: var(--text);
}
.status-btn .sc-label { font-size: 12px; }
.status-btn:hover { border-color: var(--border); background: var(--bg2); }
.status-btn.on { border-color: var(--accent); background: var(--accent-soft); }
.status-btn.on .sc-num, .status-btn.on .sc-label { color: var(--accent); }
.status-btn[data-status="solved"].on { border-color: var(--green); background: var(--green-soft); }
.status-btn[data-status="solved"].on .sc-num, .status-btn[data-status="solved"].on .sc-label { color: var(--green); }
.status-btn[data-status="favorites"].on { border-color: var(--orange); background: var(--orange-soft); }
.status-btn[data-status="favorites"].on .sc-num, .status-btn[data-status="favorites"].on .sc-label { color: var(--orange); }

.filters-card {
  background: var(--bg1);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 14px 16px;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
  margin-bottom: 10px;
}
.chip-row:last-child { margin-bottom: 0; }
.chip-row .cr-label {
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-faint);
  min-width: 74px;
}

.chip.filter { cursor: pointer; user-select: none; transition: all 0.12s; background: var(--bg2); }
.chip.filter:hover { border-color: var(--text-faint); color: var(--text); }
.chip.filter.on {
  background: var(--accent-soft);
  border-color: rgba(87, 160, 255, 0.5);
  color: var(--accent);
}
.chip.filter .cnt { opacity: 0.55; margin-left: 4px; }
.chip.filter .dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  margin-right: 5px;
  vertical-align: 1px;
}
.chip.more-toggle { border-style: dashed; }

.search-row {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed var(--border-soft);
}
.search-input {
  flex: 1;
  background: var(--bg-editor);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 13.5px;
  outline: none;
  transition: border-color 0.15s;
}
.search-input::placeholder { color: var(--text-faint); }
.search-input:focus { border-color: var(--accent); }

.sort-toggle.on { color: var(--accent); border-color: rgba(87, 160, 255, 0.4); background: var(--accent-soft); }

.task-list {
  margin-top: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.task-row {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--bg1);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 12px 16px;
  color: inherit;
  transition: border-color 0.12s, background 0.12s;
}
.task-row:hover {
  text-decoration: none;
  border-color: var(--border);
  background: var(--bg2);
}

.row-check {
  flex: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  display: grid;
  place-items: center;
  font-size: 11px;
  color: transparent;
}
.row-check.solved {
  border-color: var(--green);
  color: var(--green);
  background: var(--green-soft);
}

.row-main { min-width: 0; }
.row-title { font-weight: 600; font-size: 14.5px; color: var(--text); }
.row-title .row-num { color: var(--text-faint); font-family: var(--font-mono); font-size: 12.5px; margin-right: 6px; }
.row-tags { display: flex; gap: 6px; margin-top: 5px; flex-wrap: wrap; }

.row-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 14px;
  flex: none;
}

.empty-list {
  margin-top: 18px;
  background: var(--bg1);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 48px 20px;
  text-align: center;
  color: var(--text-faint);
}
.empty-list a { font-weight: 600; }

@media (max-width: 640px) {
  .status-counts { flex-direction: row; }
  .status-btn { padding: 8px 10px; }
  .row-tags { display: none; }
  .chip-row .cr-label { min-width: 100%; }
}

/* ---------- responsive ---------- */

.schema-toggle { display: none; }

@media (max-width: 1250px) {
  .task-layout {
    grid-template-columns: minmax(280px, 330px) minmax(420px, 1fr);
  }
  .split-col, #reset-layout, #collapse-task, #collapse-schema { display: none; }
  .panel.collapsed > * { display: revert; }
  .panel .collapsed-tab { display: none !important; }
  .schema-panel {
    display: none;
    position: fixed;
    right: 14px;
    top: calc(var(--topbar-h) + 14px);
    bottom: 14px;
    width: min(400px, calc(100vw - 28px));
    z-index: 40;
    box-shadow: -12px 0 40px rgba(0, 0, 0, 0.5);
  }
  .schema-panel.open { display: flex; }
  .schema-toggle { display: inline-block; }
}

@media (max-width: 900px) {
  .task-layout {
    grid-template-columns: 1fr;
    height: auto;
  }
  .task-desc { max-height: 40vh; }
  .results-card { min-height: 320px; }
  body { overflow-y: auto; }
}
