:root {
  color-scheme: light dark;
  --ink: #15202b; --muted: #5a6b7b; --faint: #8b98a5;
  --line: #dce3ea; --bg: #fff; --panel: #f7f9fb;
  --red: #d32f2f; --green: #1a7f37; --amber: #b26a00; --blue: #0b63c5;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --ink: #e6edf3; --muted: #93a3b1; --faint: #6b7885;
    --line: #253039; --bg: #0d1117; --panel: #131a22;
    --red: #f06f6f; --green: #4ac26b; --amber: #d9a441; --blue: #6cb6ff;
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  display: flex; flex-direction: column;
}

/* ---------------------------------------------------------------- header */
header {
  border-bottom: 1px solid var(--line); padding: .7rem 1rem;
  display: flex; align-items: baseline; gap: .8rem; flex-wrap: wrap;
}
header h1 { font-size: 1.05rem; margin: 0; letter-spacing: -.01em; }
header .up { color: var(--faint); text-decoration: none; font-size: .82rem; }
header .up:hover { color: var(--red); }
header .tabs { display: flex; gap: .4rem; margin-left: auto; }
header .tabs a {
  text-decoration: none; color: var(--muted); font-size: .84rem;
  padding: .25rem .6rem; border: 1px solid var(--line); border-radius: 999px;
}
header .tabs a.on { color: var(--bg); background: var(--ink); border-color: var(--ink); }
.status { font-size: .76rem; color: var(--faint); }
.status.loading, .status.busy { color: var(--amber); }
.status.ready { color: var(--green); }
.status.error { color: var(--red); }
.blurb { width: 100%; color: var(--muted); font-size: .85rem; margin: .15rem 0 0; }

/* ---------------------------------------------------------------- filters */
.filters {
  display: flex; gap: .5rem; flex-wrap: wrap; align-items: center;
  padding: .6rem 1rem; border-bottom: 1px solid var(--line); background: var(--panel);
}
.filters select, .filters input[type="search"] {
  font: inherit; font-size: .84rem; padding: .3rem .5rem; color: var(--ink);
  background: var(--bg); border: 1px solid var(--line); border-radius: 7px;
  max-width: 15rem;
}
.filters label { font-size: .82rem; color: var(--muted); display: flex; gap: .3rem;
  align-items: center; }
.filters .spacer { flex: 1; }
#count { font-size: .8rem; color: var(--faint); }

/* ---------------------------------------------------------------- layout */
main { flex: 1; display: flex; min-height: 0; }
#list-pane {
  width: 20rem; border-right: 1px solid var(--line); overflow-y: auto;
  padding: .5rem; flex-shrink: 0;
}
#problem-pane { flex: 1; overflow-y: auto; padding: 1.2rem 1.4rem 4rem; min-width: 0; }
#back { display: none; }

.item {
  display: block; width: 100%; text-align: left; cursor: pointer;
  background: none; border: 1px solid transparent; border-radius: 9px;
  padding: .5rem .6rem; margin-bottom: .15rem; color: inherit; font: inherit;
}
.item:hover { background: var(--panel); }
.item.active { border-color: var(--red); background: var(--panel); }
.item-top { display: flex; align-items: baseline; gap: .4rem; justify-content: space-between; }
.item-title { font-size: .89rem; font-weight: 550; }
.item.solved .item-title::after { content: ' ✓'; color: var(--green); }
.item-meta { display: block; font-size: .73rem; color: var(--faint); margin-top: .1rem; }
.empty { color: var(--faint); font-size: .85rem; padding: 1rem .6rem; }

/* ---------------------------------------------------------------- badges */
.diff { font-size: .68rem; text-transform: uppercase; letter-spacing: .04em;
  padding: .05rem .35rem; border-radius: 4px; font-weight: 650; flex-shrink: 0; }
.diff-easy { color: var(--green); background: color-mix(in srgb, var(--green) 12%, transparent); }
.diff-medium { color: var(--amber); background: color-mix(in srgb, var(--amber) 14%, transparent); }
.diff-hard { color: var(--red); background: color-mix(in srgb, var(--red) 12%, transparent); }
.chip {
  font-size: .72rem; color: var(--muted); border: 1px solid var(--line);
  border-radius: 999px; padding: .08rem .45rem;
}
.chip-co { cursor: pointer; background: none; font-family: inherit; }
.chip-co:hover { border-color: var(--red); color: var(--red); }

/* ---------------------------------------------------------------- problem */
.p-head h2 { margin: 0 0 .35rem; font-size: 1.3rem; letter-spacing: -.01em; }
.badges { display: flex; gap: .3rem; flex-wrap: wrap; align-items: center; }
.companies { display: flex; gap: .3rem; flex-wrap: wrap; align-items: center;
  margin: .7rem 0 .2rem; }
.companies-label { font-size: .72rem; color: var(--faint); text-transform: uppercase;
  letter-spacing: .06em; margin-right: .2rem; }
.preps { font-size: .84rem; color: var(--muted); margin: .5rem 0 0; }
.prompt { margin: .9rem 0; max-width: 42rem; }
.prompt code { font-family: var(--mono); font-size: .86em;
  background: var(--panel); padding: .05rem .25rem; border-radius: 4px; }

.editor {
  width: 100%; max-width: 42rem; min-height: 15rem; resize: vertical;
  font-family: var(--mono); font-size: 13px; line-height: 1.5;
  padding: .7rem .8rem; border: 1px solid var(--line); border-radius: 9px;
  background: var(--panel); color: var(--ink); tab-size: 4;
}
.editor:focus { outline: 2px solid var(--blue); outline-offset: -1px; }

.actions { display: flex; gap: .45rem; align-items: center; flex-wrap: wrap;
  margin: .6rem 0 .2rem; }
.btn {
  font: inherit; font-size: .85rem; padding: .35rem .75rem; cursor: pointer;
  border: 1px solid var(--line); border-radius: 8px; background: var(--bg);
  color: var(--ink);
}
.btn:hover:not(:disabled) { border-color: var(--red); }
.btn:disabled { opacity: .45; cursor: default; }
.btn-primary { background: var(--ink); color: var(--bg); border-color: var(--ink);
  font-weight: 600; }
.btn-primary:hover:not(:disabled) { opacity: .85; border-color: var(--ink); }
.btn-quiet { color: var(--muted); }
.kbd-hint { font-size: .74rem; color: var(--faint); }

/* ---------------------------------------------------------------- hints */
.hint {
  display: block; margin: .5rem 0; padding: .55rem .7rem; max-width: 42rem;
  border-left: 3px solid var(--amber);
  background: color-mix(in srgb, var(--amber) 8%, transparent); border-radius: 0 7px 7px 0;
}
.hint-n { display: block; font-size: .7rem; text-transform: uppercase;
  letter-spacing: .06em; color: var(--amber); font-weight: 650; }
.hint-text { font-size: .89rem; }
.hint-text code, .sol-note code { font-family: var(--mono); font-size: .86em; }
.solution { margin: 1rem 0; max-width: 42rem; }
.solution h3 { font-size: .95rem; margin: 0 0 .4rem; }
pre.code {
  font-family: var(--mono); font-size: 12.5px; line-height: 1.5; overflow-x: auto;
  background: var(--panel); border: 1px solid var(--line); border-radius: 9px;
  padding: .7rem .8rem; margin: 0 0 .5rem;
}
.sol-note { font-size: .86rem; color: var(--muted); margin: 0 0 .5rem; }

/* ---------------------------------------------------------------- results */
.results { margin-top: 1rem; max-width: 42rem; }
.summary { font-weight: 650; font-size: .92rem; padding: .5rem .7rem; border-radius: 8px; }
.summary.all-pass { color: var(--green);
  background: color-mix(in srgb, var(--green) 11%, transparent); }
.summary.some-fail { color: var(--red);
  background: color-mix(in srgb, var(--red) 10%, transparent); }
.run-error { color: var(--red); font-size: .88rem; margin-bottom: .6rem; }
.run-error pre { font-family: var(--mono); font-size: 12px; white-space: pre-wrap;
  background: var(--panel); padding: .6rem; border-radius: 8px; overflow-x: auto; }
.stdout { margin: .6rem 0; }
.stdout-label { font-size: .7rem; text-transform: uppercase; letter-spacing: .06em;
  color: var(--faint); }
.stdout pre { font-family: var(--mono); font-size: 12px; background: var(--panel);
  padding: .5rem .6rem; border-radius: 8px; margin: .2rem 0 0; overflow-x: auto; }
.results-table { border-collapse: collapse; width: 100%; margin-top: .7rem;
  font-size: 12.5px; }
.results-table th { text-align: left; font-size: .7rem; text-transform: uppercase;
  letter-spacing: .05em; color: var(--faint); font-weight: 600;
  border-bottom: 1px solid var(--line); padding: .25rem .4rem; }
.results-table td { padding: .3rem .4rem; border-bottom: 1px solid var(--line);
  vertical-align: top; }
.results-table td.mono { font-family: var(--mono); word-break: break-word; }
.results-table .mark { width: 1.4rem; font-weight: 700; }
.results-table tr.pass .mark { color: var(--green); }
.results-table tr.fail .mark { color: var(--red); }
.results-table tr.fail td { background: color-mix(in srgb, var(--red) 6%, transparent); }
.source-link { font-size: .8rem; color: var(--faint); margin-top: 1.5rem; }
.source-link a { color: var(--muted); }

/* ---------------------------------------------------------------- mobile */
@media (max-width: 760px) {
  main { display: block; }
  #list-pane { width: auto; border-right: none; max-height: none; overflow: visible; }
  #problem-pane { display: none; padding: 1rem 1rem 3rem; }
  body.showing-problem #list-pane { display: none; }
  body.showing-problem #problem-pane { display: block; }
  #back { display: none; }
  body.showing-problem #back {
    display: inline-block; background: none; border: none; color: var(--muted);
    font: inherit; font-size: .84rem; cursor: pointer; padding: 0 0 .6rem;
  }
  .editor { min-height: 12rem; font-size: 12.5px; }
  .filters select, .filters input[type="search"] { max-width: 9.5rem; }
}
