/* Online judge surface. Uses the book's palette variables so it follows the
   light/dark switch; the editor itself stays dark in both modes, like an IDE. */
.oj-app {
  --oj-bg: var(--cw-surface, #f4f6f4);
  --oj-line: var(--cw-line, #dfe6e3);
  --oj-ink: var(--cw-ink, #101b26);
  --oj-muted: var(--cw-muted, #5b6b73);
  --oj-teal: var(--cw-teal, #0f5f63);
  --oj-amber: var(--cw-amber, #a8631a);
  font-family: inherit;
  border: 1px solid var(--oj-line);
  border-radius: 8px;
  overflow: hidden;
  margin: 1.4rem 0 2rem;
}

.oj-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.6rem 1rem;
  padding: 0.9rem 1.1rem;
  border-bottom: 1px solid var(--oj-line);
  background: var(--oj-bg);
}
.oj-head h2 { margin: 0; font-size: 1.1rem; border: 0; }
.oj-head #oj-meta { font-size: 0.83rem; color: var(--oj-muted); margin: 0; }
.oj-status { font-size: 0.83rem; color: var(--oj-muted); margin-left: auto; }
.oj-good { color: var(--oj-teal) !important; }
.oj-bad { color: var(--oj-amber) !important; }

.oj-grid {
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr) 310px;
  min-height: 520px;
}
.oj-problems {
  border-right: 1px solid var(--oj-line);
  padding: 0.6rem;
  overflow-y: auto;
  max-height: 620px;
  background: var(--oj-bg);
}
.oj-problem {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 0.45rem;
  padding: 0.5rem 0.55rem;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--oj-ink);
  text-align: left;
  font: inherit;
  font-size: 0.83rem;
  cursor: pointer;
}
.oj-problem:hover { background: rgba(127, 127, 127, 0.10); }
.oj-problem.active { background: rgba(15, 95, 99, 0.14); font-weight: 650; }
.oj-num {
  font-family: var(--bs-font-monospace, monospace);
  font-size: 0.75rem;
  color: var(--oj-muted);
}
.oj-name { flex: 1; line-height: 1.3; }
.oj-badge {
  font-family: var(--bs-font-monospace, monospace);
  font-size: 0.72rem;
  color: var(--oj-muted);
}
.oj-badge.done { color: var(--oj-teal); font-weight: 700; }

.oj-editor { min-width: 0; background: #0d1622; display: flex; flex-direction: column; }
.oj-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 0.7rem;
  background: #16253a;
  border-bottom: 1px solid #29405a;
}
.oj-bar button {
  border: 1px solid #3ee0c8;
  background: transparent;
  color: #3ee0c8;
  border-radius: 4px;
  padding: 0.3rem 0.8rem;
  font: inherit;
  font-size: 0.82rem;
  cursor: pointer;
}
.oj-bar button:hover { background: rgba(62, 224, 200, 0.12); }
.oj-bar button:disabled { opacity: 0.45; cursor: wait; }
.oj-bar .oj-secondary { border-color: #5c7186; color: #a9bccf; }
.oj-bar .oj-score { margin-left: auto; color: #f5be5c; font-size: 0.8rem; }
.oj-editor textarea {
  width: 100%;
  flex: 1;
  min-height: 470px;
  border: 0;
  padding: 0.9rem;
  background: #0d1622;
  color: #d8e2ed;
  font-family: "JetBrains Mono", "SFMono-Regular", Consolas, monospace;
  font-size: 0.86rem;
  line-height: 1.55;
  resize: vertical;
  tab-size: 4;
}
.oj-editor .CodeMirror {
  height: 470px;
  font-size: 0.86rem;
  background: #0d1622;
  color: #d8e2ed;
}
.oj-editor .CodeMirror-gutters { background: #0d1622; border-right: 1px solid #29405a; }
.oj-editor .CodeMirror-linenumber { color: #5b7186; }
.oj-editor .CodeMirror-cursor { border-left-color: #3ee0c8; }
.oj-editor .cm-s-oj-dark .cm-keyword { color: #f5be5c; }
.oj-editor .cm-s-oj-dark .cm-string { color: #3ee0c8; }
.oj-editor .cm-s-oj-dark .cm-comment { color: #7188a1; font-style: italic; }
.oj-editor .cm-s-oj-dark .cm-def { color: #9fc4ff; }
.oj-editor .cm-s-oj-dark .cm-number { color: #e59ad0; }

.oj-results {
  border-left: 1px solid var(--oj-line);
  padding: 0.7rem;
  max-height: 620px;
  overflow-y: auto;
  background: var(--oj-bg);
}
.oj-hint { font-size: 0.84rem; color: var(--oj-muted); }
.oj-case {
  border: 1px solid var(--oj-line);
  border-left: 3px solid var(--oj-line);
  border-radius: 4px;
  padding: 0.5rem 0.6rem;
  margin-bottom: 0.5rem;
  font-size: 0.8rem;
}
.oj-case.pass { border-left-color: var(--oj-teal); }
.oj-case.fail { border-left-color: var(--oj-amber); }
.oj-case-head { display: flex; gap: 0.5rem; align-items: baseline; font-weight: 600; }
.oj-mark { font-family: monospace; }
.oj-pass .oj-mark, .oj-case.pass .oj-mark { color: var(--oj-teal); }
.oj-case.fail .oj-mark { color: var(--oj-amber); }
.oj-got { color: var(--oj-muted); }
.oj-fail-detail { margin-top: 0.4rem; color: var(--oj-muted); line-height: 1.5; }
.oj-fail-detail code { font-size: 0.75rem; word-break: break-all; }
.oj-error { color: var(--oj-amber); font-family: monospace; font-size: 0.75rem; }
.oj-fail-detail pre {
  margin: 0.4rem 0 0;
  white-space: pre-wrap;
  font-size: 0.75rem;
  color: var(--oj-muted);
}

.oj-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
  padding: 0.65rem 1rem;
  border-top: 1px solid var(--oj-line);
  background: var(--oj-bg);
  font-size: 0.8rem;
  color: var(--oj-muted);
}
.oj-foot button, .oj-foot label {
  border: 1px solid var(--oj-line);
  border-radius: 4px;
  padding: 0.25rem 0.65rem;
  color: var(--oj-ink);
  background: transparent;
  font: inherit;
  font-size: 0.8rem;
  cursor: pointer;
}
.oj-foot input[type=file] { display: none; }
.oj-foot #oj-saved { margin-left: auto; }

@media (max-width: 1100px) {
  .oj-grid { grid-template-columns: 190px minmax(0, 1fr); }
  .oj-results { grid-column: 1 / -1; border-left: 0; border-top: 1px solid var(--oj-line); max-height: 340px; }
}
@media (max-width: 720px) {
  .oj-grid { grid-template-columns: 1fr; }
  .oj-problems { max-height: 230px; border-right: 0; border-bottom: 1px solid var(--oj-line); }
}
