:root {
  color-scheme: light;
  --ink: #13202f;
  --muted: #5b6676;
  --line: #d8dee8;
  --panel: #ffffff;
  --surface: #f5f7fa;
  --accent: #166d5c;
  --accent-strong: #0c5a4b;
  --blue: #2f6fed;
  --amber: #bf6b13;
  --red: #b42318;
  --shadow: 0 12px 28px rgba(19, 32, 47, 0.08);
  --mono: "JetBrains Mono", "Fira Code", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

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

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

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 20px clamp(16px, 4vw, 48px);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
}

.topbar h1 {
  font-size: clamp(23px, 3vw, 38px);
  line-height: 1.05;
  letter-spacing: 0;
}

.topbar p {
  margin-top: 7px;
  color: var(--muted);
  font-size: 14px;
}

.topbar code {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--accent-strong);
}

.stats {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.stats span {
  min-width: 86px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  text-align: center;
  color: var(--muted);
  font-size: 12px;
}

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

main {
  width: min(1360px, calc(100% - 28px));
  margin: 22px auto 72px;
}

.workspace {
  display: grid;
  grid-template-columns: 310px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.sidebar {
  position: sticky;
  top: 102px;
  display: grid;
  gap: 14px;
}

.panel, .question-card, .problem-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.panel {
  padding: 16px;
}

.panel h2 {
  font-size: 16px;
  margin-bottom: 12px;
}

.compact {
  display: grid;
  gap: 8px;
}

label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  text-transform: uppercase;
}

input, select {
  width: 100%;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 11px;
  background: #fff;
  color: var(--ink);
}

input:focus, select:focus, textarea:focus {
  outline: 2px solid rgba(22, 109, 92, 0.18);
  border-color: var(--accent);
}

.path-list {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 10px;
}

.path-list li {
  color: var(--muted);
  line-height: 1.35;
  font-size: 14px;
}

.path-list strong {
  display: block;
  color: var(--ink);
}

.content {
  min-width: 0;
}

.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.tab, button {
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 14px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font-weight: 750;
}

button:hover {
  border-color: var(--accent);
  background: #f2f8f6;
}

.tab.active, .primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.primary:hover {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
}

.view { display: none; }
.view.active { display: block; }
.hidden { display: none; }

.modebar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 12px;
}

#questionPosition {
  min-width: 100px;
  text-align: center;
  color: var(--muted);
  font-weight: 750;
}

.question-card, .problem-card {
  padding: clamp(18px, 3vw, 30px);
}

.meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 3px 10px;
  border-radius: 999px;
  background: #eef3fb;
  color: #34465f;
  font-size: 12px;
  font-weight: 750;
}

.easy { background: #dff4eb; color: #07533e; }
.medium { background: #fff0d8; color: #7a3d00; }
.hard { background: #fde9e7; color: #841b13; }

.question-card h2, .problem-card h2 {
  font-size: clamp(22px, 3vw, 34px);
  line-height: 1.15;
  letter-spacing: 0;
}

.choices {
  display: grid;
  gap: 10px;
  margin: 22px 0;
}

.choice {
  min-height: 48px;
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  line-height: 1.45;
}

.choice input {
  width: 16px;
  height: 16px;
  margin-top: 3px;
  flex: 0 0 auto;
}

.choice.correct { border-color: var(--accent); background: #edf8f4; }
.choice.incorrect { border-color: var(--red); background: #fff1ef; }

.answer {
  margin: 18px 0;
  padding: 16px 18px;
  border-left: 5px solid var(--accent);
  border-radius: 0 8px 8px 0;
  background: #edf8f4;
  line-height: 1.6;
  white-space: pre-line;
}

.actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 16px;
}

.question-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(245px, 1fr));
  gap: 12px;
  margin-top: 18px;
}

.mini-card {
  min-height: 116px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
  cursor: pointer;
}

.mini-card:hover { border-color: var(--accent); }
.mini-card.done { border-left: 4px solid var(--accent); }
.mini-card h3 { font-size: 14px; line-height: 1.35; }

.coding-shell {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  gap: 14px;
}

.problem-nav {
  display: grid;
  align-content: start;
  gap: 8px;
}

.problem-button {
  width: 100%;
  min-height: 46px;
  height: auto;
  text-align: left;
  white-space: normal;
  line-height: 1.25;
  padding: 10px 12px;
}

.problem-button.active {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}

.prompt {
  margin-top: 12px;
  color: var(--muted);
  line-height: 1.6;
}

.example, .test-output, .guide-box {
  overflow-x: auto;
  border-radius: 8px;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.45;
}

.example {
  margin: 16px 0;
  padding: 13px 14px;
  background: #f1f4f8;
  color: #233247;
}

#codeEditor {
  width: 100%;
  min-height: 330px;
  resize: vertical;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #101923;
  color: #eaf4ff;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.5;
  tab-size: 4;
}

.test-output {
  min-height: 126px;
  margin: 16px 0 0;
  padding: 14px;
  background: #101923;
  color: #d6e6f6;
  white-space: pre-wrap;
}

.guide-box {
  margin: 16px 0 0;
  padding: 14px;
  border: 1px solid #cfe5dc;
  background: #edf8f4;
  color: #163b33;
  white-space: pre-wrap;
}

.resource-grid, .design-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}

.resource-card, .design-card {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.resource-card h3 {
  font-size: 17px;
  margin-bottom: 8px;
}

.resource-card p, .design-card p {
  color: var(--muted);
  line-height: 1.55;
  font-size: 14px;
}

.design-card h2 {
  font-size: 20px;
  line-height: 1.2;
  margin-bottom: 8px;
}

.design-card h3 {
  margin: 16px 0 8px;
  font-size: 13px;
  text-transform: uppercase;
  color: var(--muted);
}

.design-card ul {
  margin: 0;
  padding-left: 18px;
  color: var(--ink);
  line-height: 1.5;
  font-size: 14px;
}

.resource-card a {
  display: inline-block;
  margin-top: 10px;
  color: var(--blue);
  font-weight: 750;
  text-decoration: none;
}

@media (max-width: 960px) {
  .topbar {
    position: static;
    align-items: flex-start;
    flex-direction: column;
  }

  .stats { width: 100%; }
  .stats span { flex: 1; }
  .workspace, .coding-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; }
  .problem-nav { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
}

@media (max-width: 620px) {
  main { width: min(100% - 20px, 1360px); }
  .question-card, .problem-card, .panel { padding: 14px; }
  .actions button { flex: 1 1 160px; }
  .stats span { min-width: 78px; }
}
