/* ---------------------------------------------------------------------------
   Design tokens, modelled on DataLemur's question index
   (Kumbh Sans headings, Chakra gray/blue palette, zebra table rows, 24px cell
   padding) with a matching dark scheme and a header toggle.
   --------------------------------------------------------------------------- */

:root,
:root[data-theme="light"] {
  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
  --font-heading: "Kumbh Sans", var(--font-body);
  --font-mono: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;

  --bg: #ffffff;
  --bg-subtle: #f7fafc;
  --bg-muted: #edf2f7;
  --bg-zebra: #f5f5f5;
  --surface: #ffffff;
  --surface-raised: #ffffff;

  --border: #e2e8f0;
  --border-strong: #cbd5e0;

  --text: #1a202c;
  --text-strong: #171923;
  --subtle: #4a5568;
  --muted: #718096;

  --link: #2b6cb0;
  --link-hover: #2c5282;
  --primary: #3182ce;
  --primary-hover: #2b6cb0;

  --easy: #2f855a;
  --medium: #c05621;
  --hard: #c53030;
  --star: #b7791f;
  --premium: #b7791f;

  --pass-bg: #f0fff4;
  --pass-border: #9ae6b4;
  --fail-bg: #fff5f5;
  --fail-border: #feb2b2;
  --warn-bg: #fffaf0;
  --warn-border: #fbd38d;
  --info-bg: #ebf8ff;
  --info-border: #bee3f8;

  --editor-bg: #ffffff;
  --editor-gutter: #f7fafc;
  --editor-fg: #1a202c;
  --code-bg: #f7fafc;

  --syntax-keyword: #cf222e;
  --syntax-string: #0a3069;
  --syntax-number: #0550ae;
  --syntax-comment: #6e7781;
  --syntax-function: #8250df;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-base: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
  --ring: 0 0 0 3px rgba(66, 153, 225, 0.45);
}

:root[data-theme="dark"] {
  --bg: #1a202c;
  --bg-subtle: #171923;
  --bg-muted: #2d3748;
  --bg-zebra: rgba(255, 255, 255, 0.03);
  --surface: #232c3b;
  --surface-raised: #2d3748;

  --border: rgba(255, 255, 255, 0.16);
  --border-strong: rgba(255, 255, 255, 0.28);

  --text: #f7fafc;
  --text-strong: #ffffff;
  --subtle: #cbd5e0;
  --muted: #a0aec0;

  --link: #63b3ed;
  --link-hover: #90cdf4;
  --primary: #3182ce;
  --primary-hover: #4299e1;

  --easy: #68d391;
  --medium: #f6ad55;
  --hard: #fc8181;
  --star: #ecc94b;
  --premium: #f6ad55;

  --pass-bg: rgba(56, 161, 105, 0.16);
  --pass-border: rgba(104, 211, 145, 0.45);
  --fail-bg: rgba(229, 62, 62, 0.16);
  --fail-border: rgba(252, 129, 129, 0.45);
  --warn-bg: rgba(214, 158, 46, 0.16);
  --warn-border: rgba(246, 173, 85, 0.45);
  --info-bg: rgba(49, 130, 206, 0.18);
  --info-border: rgba(99, 179, 237, 0.45);

  --editor-bg: #0f141c;
  --editor-gutter: #151b26;
  --editor-fg: #e2e8f0;
  --code-bg: #0f141c;

  --syntax-keyword: #ff7b72;
  --syntax-string: #a5d6ff;
  --syntax-number: #79c0ff;
  --syntax-comment: #8b949e;
  --syntax-function: #d2a8ff;

  --shadow-sm: none;
  --shadow-base: none;
  --ring: 0 0 0 3px rgba(66, 153, 225, 0.5);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { font-family: var(--font-heading); font-weight: 700; line-height: 1.25; margin: 0 0 .4rem; }
p { margin: .5rem 0; }
a { color: var(--link); }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.hint, .transfer-status { font-size: .78rem; color: var(--muted); }

/* ---------------------------------------------------------------- header --- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.site-header-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 24px;
  min-height: 64px;
  display: flex;
  align-items: center;
  gap: 24px;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; }
.brand-mark {
  background: var(--primary);
  color: #fff;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: .78rem;
  letter-spacing: .04em;
  padding: 4px 7px;
  border-radius: 6px;
}
.brand-name { font-family: var(--font-heading); font-weight: 700; font-size: 1.02rem; color: var(--text-strong); }
.site-nav { display: flex; align-items: center; gap: 18px; flex: 1; min-width: 0; }
.site-nav-link { color: var(--subtle); text-decoration: none; font-weight: 600; font-size: .9rem; }
.site-nav-link:hover, .site-nav-link.is-active { color: var(--link); }
.site-nav-note { color: var(--muted); font-size: .82rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.site-header-actions { display: flex; align-items: center; gap: 10px; margin-left: auto; }

/* --------------------------------------------------------- buttons/inputs --- */

.btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  border-radius: 6px;
  padding: 7px 14px;
  font: inherit;
  font-size: .85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .12s ease, border-color .12s ease, color .12s ease;
}
.btn:hover { background: var(--bg-muted); }
.btn:disabled { opacity: .55; cursor: default; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-ghost { background: transparent; }
.btn-ghost:hover { background: var(--bg-muted); }
.btn:focus-visible, select:focus-visible, input:focus-visible, .theme-toggle:focus-visible, .status-icon:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  border-radius: 6px;
  padding: 6px 12px;
  font: inherit;
  font-size: .82rem;
  font-weight: 600;
  cursor: pointer;
}
.theme-toggle:hover { background: var(--bg-muted); }
.theme-icon { color: var(--star); }
.theme-icon-moon { color: var(--link); }
:root[data-theme="light"] .theme-icon-sun { display: none; }
:root[data-theme="dark"] .theme-icon-moon { display: none; }
:root[data-theme="dark"] .theme-label::after { content: ""; }
.theme-label { font-size: .82rem; }

.link-btn {
  background: none;
  border: none;
  color: var(--link);
  font: inherit;
  font-size: .85rem;
  font-weight: 600;
  padding: 8px 4px;
  cursor: pointer;
}
.link-btn:hover { text-decoration: underline; color: var(--link-hover); }

/* ---------------------------------------------------------------- layout --- */

.page { max-width: 1280px; margin: 0 auto; padding: 28px 24px 72px; }
.page-head h1 { font-size: 1.9rem; letter-spacing: -.01em; color: var(--text-strong); }
.page-sub { color: var(--subtle); max-width: 820px; }

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px 14px;
  margin: 22px 0 18px;
}
.field { display: grid; gap: 4px; }
.field > span {
  font-family: var(--font-heading);
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
}
.field-search { min-width: 260px; flex: 1; }
select, input[type="search"] {
  font: inherit;
  font-size: .88rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  padding: 7px 10px;
  min-width: 130px;
}
input[type="search"] { min-width: 0; width: 100%; }
input::placeholder { color: var(--muted); }

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: .76rem;
  font-weight: 600;
  color: var(--subtle);
  cursor: pointer;
  margin-bottom: 2px;
}
.filter-chip .chip-x { color: var(--muted); }

.question-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 24px;
  align-items: start;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow-sm);
  padding: 18px 20px;
}
.card-title { font-size: .95rem; color: var(--text-strong); margin-bottom: 12px; }
.table-card { padding: 0; overflow: hidden; }
.tags-card { margin-top: 24px; }

/* ------------------------------------------------------------- questions --- */

.table-wrap { overflow-x: auto; }
.question-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.question-table thead th {
  font-family: var(--font-heading);
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  text-align: left;
  color: var(--muted);
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border);
  padding: 12px 20px;
  white-space: nowrap;
}
.question-table th:nth-child(1) { width: 130px; }
.question-table th:nth-child(2) { width: auto; }
.question-table th:nth-child(3) { width: 108px; }
.question-table th:nth-child(4) { width: 78px; }
.question-table tbody tr { border-bottom: 1px solid var(--border); cursor: pointer; transition: background .12s ease; }
.question-table tbody tr:nth-child(even) { background: var(--bg-zebra); }
.question-table tbody tr:hover { background: var(--bg-muted); }
.question-table tbody tr.is-active { background: var(--info-bg); box-shadow: inset 3px 0 0 var(--primary); }
.question-table tbody tr:last-child { border-bottom: none; }
.question-table td { padding: 13px 20px; vertical-align: middle; font-size: .9rem; }
.cell-title { overflow: hidden; }
.title-wrap { display: flex; align-items: center; gap: 8px; min-width: 0; }
.title-wrap .title-link { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.title-link { color: var(--link); font-weight: 500; text-decoration: none; }
.title-link:hover { text-decoration: underline; color: var(--link-hover); }
.cell-status { text-align: center; }

.source-pill {
  display: inline-block;
  background: var(--bg-muted);
  color: var(--subtle);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: .72rem;
  font-weight: 600;
  white-space: nowrap;
}
.pill {
  display: inline-block;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .02em;
  border: 1px solid var(--border);
  color: var(--subtle);
  background: var(--bg-subtle);
  vertical-align: middle;
}
.pill-premium { color: var(--premium); border-color: var(--warn-border); background: var(--warn-bg); }

.diff { font-weight: 600; font-size: .85rem; }
.diff-easy { color: var(--easy); }
.diff-medium { color: var(--medium); }
.diff-hard { color: var(--hard); }

.status-icon {
  background: none;
  border: none;
  padding: 0;
  font-size: 1.05rem;
  line-height: 1;
  color: var(--border-strong);
  cursor: pointer;
}
.status-icon.is-solved { color: var(--easy); }
.status-icon.is-starred { color: var(--star); }

.table-foot {
  margin: 0;
  padding: 12px 24px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: .8rem;
  background: var(--bg-subtle);
}
.empty { padding: 18px 24px; color: var(--muted); font-size: .88rem; }

/* -------------------------------------------------------- progress/tags --- */

.progress-track { height: 8px; border-radius: 999px; background: var(--bg-muted); overflow: hidden; }
.progress-fill { height: 100%; width: 0; background: var(--easy); border-radius: 999px; transition: width .3s ease; }
.stats { margin-top: 12px; display: grid; gap: 6px; font-size: .85rem; color: var(--subtle); }
.stat-total { display: flex; align-items: baseline; gap: 6px; }
.stat-value { font-family: var(--font-heading); font-weight: 700; font-size: 1.3rem; color: var(--text-strong); }
.stat-label { font-size: .8rem; color: var(--muted); }
.stat-breakdown { display: grid; gap: 2px; }
.stat-part { display: flex; justify-content: space-between; font-size: .82rem; }
.stat-easy .stat-value { color: var(--easy); }
.stat-medium .stat-value { color: var(--medium); }
.stat-hard .stat-value { color: var(--hard); }
.stat-starred { color: var(--star); font-size: .8rem; }

.tag-cloud { display: flex; flex-wrap: wrap; gap: 10px 20px; }
.tag {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  font-size: .85rem;
  color: var(--link);
  cursor: pointer;
}
.tag:hover { text-decoration: underline; color: var(--link-hover); }
.tag.is-active { font-weight: 700; text-decoration: underline; }
.tag-count { font-weight: 700; margin-left: 4px; color: var(--text-strong); }

/* ------------------------------------------------------------------ header --- */

.btn-danger { background: transparent; border-color: var(--fail-border); color: var(--hard); }
.btn-danger:hover { background: var(--fail-bg); }
.server-stopped {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: baseline;
  margin-bottom: 16px;
  padding: 12px 16px;
  border: 1px solid var(--warn-border);
  background: var(--warn-bg);
  color: var(--medium);
  border-radius: 8px;
  font-size: .9rem;
}
.sync-status { font-size: .74rem; color: var(--muted); white-space: nowrap; border-left: 1px solid var(--border); padding-left: 10px; }
.sync-status:empty { border-left: 0; padding-left: 0; }
.sync-status.sync-server { color: var(--easy); }
.sync-status.sync-local { color: var(--medium); }
.sync-status.sync-checking { color: var(--muted); }

/* ------------------------------------------------------------ detail view --- */

.detail-view { display: grid; gap: 16px; }
.back-link { display: inline-flex; align-items: center; gap: 6px; color: var(--link); text-decoration: none; font-size: .88rem; font-weight: 600; }
.back-link:hover { text-decoration: underline; }
.problem-head { display: flex; justify-content: space-between; gap: 20px; align-items: flex-start; }
.problem-headline h1 { font-size: 1.5rem; color: var(--text-strong); }
.chips { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.chip {
  display: inline-block;
  border-radius: 999px;
  padding: 2px 10px;
  font-size: .72rem;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--bg-subtle);
  color: var(--subtle);
}
.chip-easy { color: var(--easy); border-color: var(--pass-border); background: var(--pass-bg); }
.chip-medium { color: var(--medium); border-color: var(--warn-border); background: var(--warn-bg); }
.chip-hard { color: var(--hard); border-color: var(--fail-border); background: var(--fail-bg); }
.chip-source { color: var(--subtle); }
.chip-premium { color: var(--premium); border-color: var(--warn-border); background: var(--warn-bg); }
.chip-solved { color: var(--easy); border-color: var(--pass-border); background: var(--pass-bg); }
.problem-actions { display: flex; align-items: center; gap: 8px; }
.star-btn.is-starred { border-color: var(--star); color: var(--star); }

.description-text { white-space: pre-wrap; max-width: 860px; color: var(--text); }
.schema-block { margin-top: 18px; }
.schema-block h3, .workbench h3, .results h3 { font-size: .9rem; color: var(--text-strong); }
.schema-tables { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; margin-top: 8px; }
.schema-table { background: var(--bg-subtle); border: 1px solid var(--border); border-radius: 6px; padding: 12px 14px; }
.schema-table h4 { margin: 0 0 6px; font-family: var(--font-mono); font-size: .82rem; color: var(--text-strong); }
.schema-cols { width: 100%; border-collapse: collapse; font-family: var(--font-mono); font-size: .78rem; }
.schema-cols th { text-align: left; color: var(--muted); font-weight: 500; padding: 2px 4px; border-bottom: 1px solid var(--border); }
.schema-cols td { padding: 2px 4px; border-bottom: 1px solid var(--border); }
.seed-block { margin-top: 18px; }
.seed-block summary { cursor: pointer; color: var(--link); font-weight: 600; font-size: .88rem; }
.seed-body { display: grid; gap: 14px; margin-top: 12px; }
.seed-table h4 { font-family: var(--font-mono); font-size: .82rem; color: var(--text-strong); }

.workbench-head { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; }
.db-status { font-size: .78rem; }
#sql-editor, .plain-editor {
  width: 100%;
  margin-top: 10px;
  padding: 10px;
  font-family: var(--font-mono);
  font-size: .85rem;
  color: var(--editor-fg);
  background: var(--editor-bg);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
}
.plain-editor { min-height: 200px; resize: vertical; }
.actions { display: flex; align-items: center; gap: 10px; margin-top: 12px; flex-wrap: wrap; }

/* ---------------------------------------------------- editor (CodeMirror) --- */

.CodeMirror {
  height: 250px;
  margin-top: 10px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--editor-bg);
  color: var(--editor-fg);
  font-family: var(--font-mono);
  font-size: .85rem;
}
.CodeMirror-gutters { background: var(--editor-gutter); border-right: 1px solid var(--border); }
.CodeMirror-linenumber { color: var(--muted); }
.CodeMirror-cursor { border-left: 2px solid var(--link); }
.CodeMirror-selected { background: rgba(49, 130, 206, .22) !important; }
.CodeMirror-focused .CodeMirror-selected { background: rgba(49, 130, 206, .3) !important; }
.cm-s-default .cm-keyword { color: var(--syntax-keyword); }
.cm-s-default .cm-string, .cm-s-default .cm-string-2 { color: var(--syntax-string); }
.cm-s-default .cm-number { color: var(--syntax-number); }
.cm-s-default .cm-comment { color: var(--syntax-comment); font-style: italic; }
.cm-s-default .cm-builtin, .cm-s-default .cm-def, .cm-s-default .cm-variable-2 { color: var(--syntax-function); }
.cm-s-default .cm-operator, .cm-s-default .cm-punctuation { color: var(--editor-fg); }
.CodeMirror-hints { background: var(--surface); color: var(--text); border: 1px solid var(--border-strong); border-radius: 6px; box-shadow: var(--shadow-base); font-family: var(--font-mono); font-size: .82rem; }
.CodeMirror-hint-active { background: var(--info-bg); color: var(--text-strong); }

/* ----------------------------------------------------------- results/verdict --- */

.verdict-host:empty { display: none; }
.verdict {
  margin-top: 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  padding: 10px 14px;
  font-size: .88rem;
}
.verdict p { margin: 0; }
.verdict-pass { background: var(--pass-bg); border-color: var(--pass-border); color: var(--easy); }
.verdict-fail, .verdict-error { background: var(--fail-bg); border-color: var(--fail-border); color: var(--hard); }
.verdict-warn { background: var(--warn-bg); border-color: var(--warn-border); color: var(--medium); }
.verdict-info { background: var(--info-bg); border-color: var(--info-border); color: var(--link); }
.verdict-message { font-weight: 600; }
.diff { margin-top: 8px; }
.diff summary { cursor: pointer; font-weight: 600; }
.diff-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 10px; }
.diff-grid h4 { font-family: var(--font-heading); font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 14px; }
.tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 8px 12px;
  font: inherit;
  font-size: .88rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
}
.tab:hover { color: var(--link); }
.tab.active { color: var(--link); border-bottom-color: var(--primary); }

.result-block { display: grid; gap: 8px; }
.row-count { margin: 0; font-size: .78rem; color: var(--muted); }
.results .table-wrap { overflow: auto; max-height: 420px; border: 1px solid var(--border); border-radius: 6px; }
.result-table { border-collapse: collapse; min-width: 100%; font-family: var(--font-mono); font-size: .8rem; }
.result-table th, .result-table td { text-align: left; padding: 6px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.result-table thead th { position: sticky; top: 0; background: var(--bg-subtle); color: var(--subtle); font-weight: 700; }
.result-table tbody tr:nth-child(even) { background: var(--bg-zebra); }
.cell-null { color: var(--muted); font-style: italic; }
.cell-number { color: var(--syntax-number); }
.cell-json { color: var(--syntax-string); }

.error-box, .code {
  margin: 0;
  padding: 12px 14px;
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: .8rem;
  white-space: pre-wrap;
  overflow-x: auto;
}
.error-box { background: var(--fail-bg); border: 1px solid var(--fail-border); color: var(--hard); }
.code { background: var(--code-bg); border: 1px solid var(--border); color: var(--text); }
.solution-block, .spoiler { display: grid; gap: 10px; justify-items: start; }

@media (max-width: 1080px) {
  .question-grid { grid-template-columns: minmax(0, 1fr); }
  .diff-grid { grid-template-columns: 1fr; }
  .site-nav-note { display: none; }
}
@media (max-width: 720px) {
  .site-header-inner { gap: 12px; }
  .page { padding: 20px 16px 56px; }
}

/* ------------------------------------------------------- test cases / sync --- */

.chip-cases { color: var(--link); border-color: var(--info-border); background: var(--info-bg); }
.case-bar { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-top: 12px; }
.field-case { display: grid; gap: 4px; }
.field-case > span {
  font-family: var(--font-heading);
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
}
.field-case select { min-width: 200px; font-size: .85rem; }
.case-badges { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.case-badge { font-family: var(--font-mono); font-size: .74rem; border-radius: 999px; padding: 1px 8px; border: 1px solid var(--border); background: var(--bg-subtle); color: var(--muted); }
.case-badge.case-pass { color: var(--easy); border-color: var(--pass-border); background: var(--pass-bg); }
.case-badge.case-fail { color: var(--hard); border-color: var(--fail-border); background: var(--fail-bg); }

.btn-reset { background: transparent; border-color: var(--fail-border); color: var(--hard); }
.btn-reset:hover { background: var(--fail-bg); }
.btn-star { color: var(--star); }
.btn-star.is-active { border-color: var(--star); background: var(--warn-bg); }
.stat-link { background: none; border: none; padding: 0; font: inherit; color: var(--star); text-align: left; cursor: pointer; }
.stat-link:hover { text-decoration: underline; }

.submissions { list-style: none; margin: 0 0 8px; padding: 0; display: grid; gap: 6px; }
.submission {
  display: grid;
  grid-template-columns: 1.1rem minmax(11rem, auto) 1fr;
  align-items: baseline;
  gap: 10px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-subtle);
  font-size: .84rem;
}
.submission.is-pass { border-color: var(--pass-border); background: var(--pass-bg); }
.submission.is-fail { border-color: var(--fail-border); background: var(--fail-bg); }
.submission-verdict { font-weight: 700; text-align: center; }
.submission.is-pass .submission-verdict { color: var(--easy); }
.submission.is-fail .submission-verdict { color: var(--hard); }
.submission-time { font-family: var(--font-mono); font-size: .78rem; color: var(--text-strong); white-space: nowrap; }
.submission-detail { font-size: .8rem; min-width: 0; }
.submission-query { grid-column: 2 / -1; margin-top: 2px; font-size: .8rem; }
.submission-query > summary { cursor: pointer; color: var(--link); font-weight: 600; }
.submission-query > summary:hover { text-decoration: underline; }
.submission-query .code { margin: 8px 0; max-height: 220px; overflow: auto; }
.submission-query .btn { margin-bottom: 2px; }

/* ------------------------------------------------------------ orientation --- */
/* The card stack below is vertical-first, so it already works in portrait; these
   rules cover landscape (wider question table, larger editor) and small screens. */

@media (min-width: 1181px) {
  .page { max-width: 1320px; }
  .CodeMirror { height: 260px; }
}

@media (max-width: 1180px) {
  .question-grid { grid-template-columns: minmax(0, 1fr); }
  .side-col { order: -1; }
  .diff-grid { grid-template-columns: 1fr; }
  .site-nav-note { display: none; }
}

@media (max-width: 720px) {
  .site-header-inner { gap: 12px; flex-wrap: wrap; padding: 8px 16px; }
  .site-header-actions { flex-wrap: wrap; gap: 8px; }
  .transfer-status { display: none; }
  .page { padding: 20px 14px 56px; }
  .page-head h1 { font-size: 1.5rem; }
  .problem-headline h1 { font-size: 1.3rem; }
  .problem-head { flex-direction: column; }
  .case-bar { flex-direction: column; align-items: stretch; }
  .field-case select { min-width: 0; width: 100%; }
  .filter-bar { gap: 10px; }
  .filter-bar .field { flex: 1 1 45%; }
  .field-search { min-width: 0; }
  .CodeMirror { height: 200px; }
  .submission { grid-template-columns: 1.1rem 1fr; }
  .submission-detail { grid-column: 1 / -1; }
  .question-table td, .question-table thead th { padding-left: 14px; padding-right: 14px; }
}
