:root {
  --bg: #071013;
  --bg-grid: rgba(94, 234, 212, 0.055);
  --surface: rgba(12, 25, 30, 0.92);
  --surface-strong: #0f2025;
  --surface-soft: rgba(16, 36, 40, 0.78);
  --ink: #e9fffb;
  --muted: #91aaa9;
  --line: rgba(129, 240, 224, 0.18);
  --line-strong: rgba(129, 240, 224, 0.38);
  --accent: #5eead4;
  --accent-dark: #15b8a6;
  --amber: #f3c969;
  --green: #7ddc8a;
  --red: #ff7b72;
  --code-bg: #050b0e;
  --code-ink: #d7fff8;
  --glow: rgba(94, 234, 212, 0.18);
  color-scheme: dark;
  font-family: "Segoe UI", "Microsoft YaHei", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    linear-gradient(var(--bg-grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--bg-grid) 1px, transparent 1px),
    var(--bg);
  background-size: 28px 28px;
  color: var(--ink);
}

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

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  padding: 16px;
}

.topbar {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 18px;
  justify-content: space-between;
  margin: 0 auto 16px;
  max-width: 1720px;
  padding: 4px 2px 14px;
}

.eyebrow {
  color: var(--accent);
  font-size: 12px;
  font-weight: 850;
  letter-spacing: 0;
  margin: 0 0 4px;
}

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

h1 {
  font-size: 28px;
  line-height: 1.18;
  margin-bottom: 0;
  text-shadow: 0 0 18px rgba(94, 234, 212, 0.22);
}

h2 {
  font-size: 17px;
  line-height: 1.3;
  margin-bottom: 10px;
}

h3 {
  font-size: 15px;
  line-height: 1.35;
  margin-bottom: 8px;
}

.topbar__status {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.runtime-pill,
.summary-pill,
.count-pill,
.meta-pill {
  align-items: center;
  background: rgba(8, 18, 22, 0.82);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  display: inline-flex;
  font-size: 13px;
  font-weight: 780;
  min-height: 30px;
  padding: 0 10px;
}

.runtime-pill.ready {
  color: var(--green);
}

.runtime-pill.loading {
  color: var(--amber);
}

.layout {
  display: grid;
  gap: 16px;
  grid-template-columns: 286px minmax(0, 1fr);
  margin: 0 auto;
  max-width: 1720px;
}

.sidebar,
.workspace {
  min-width: 0;
}

.sidebar {
  align-content: start;
  display: grid;
  gap: 12px;
}

.panel,
.question-panel,
.code-panel,
.results-panel {
  animation: panelIn 260ms ease both;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04), 0 18px 55px rgba(0, 0, 0, 0.25);
}

.panel {
  padding: 13px;
}

.panel__header {
  align-items: center;
  display: flex;
  gap: 10px;
  justify-content: space-between;
  margin-bottom: 10px;
}

.panel__header h2 {
  color: var(--ink);
  margin-bottom: 0;
}

label {
  color: var(--muted);
  display: grid;
  font-size: 13px;
  font-weight: 720;
  gap: 6px;
  margin-bottom: 10px;
}

select,
input,
textarea {
  background: rgba(5, 13, 16, 0.78);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  outline: none;
  width: 100%;
}

select,
input {
  min-height: 38px;
  padding: 0 10px;
}

textarea {
  padding: 12px;
  resize: vertical;
}

select:focus,
input:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(94, 234, 212, 0.14), 0 0 22px rgba(94, 234, 212, 0.08);
}

.question-list-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  max-height: calc(100vh - 250px);
  overflow: hidden;
}

.question-list {
  display: grid;
  gap: 0;
  overflow: auto;
  padding-right: 2px;
}

.question-item {
  background: transparent;
  border: 0;
  border-bottom: 1px solid rgba(129, 240, 224, 0.12);
  border-left: 2px solid transparent;
  border-radius: 0;
  color: var(--ink);
  padding: 12px 8px 12px 12px;
  position: relative;
  text-align: left;
  transition: background 160ms ease, border-color 160ms ease, transform 160ms ease;
  width: 100%;
}

.question-item:hover {
  background: rgba(94, 234, 212, 0.06);
  border-left-color: rgba(94, 234, 212, 0.6);
  transform: translateX(2px);
}

.question-item.active {
  background: rgba(94, 234, 212, 0.1);
  border-left-color: var(--accent);
}

.question-item.active::after {
  animation: pulseLine 1.8s ease-in-out infinite;
  background: var(--accent);
  content: "";
  height: 26px;
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 2px;
}

.question-item strong {
  color: var(--ink);
  display: block;
  font-size: 14px;
  line-height: 1.38;
  margin-bottom: 4px;
}

.question-item span {
  color: var(--muted);
  font-size: 12px;
}

.workspace {
  display: grid;
  gap: 12px;
  grid-template-rows: minmax(0, auto) auto;
}

.workspace__main {
  display: grid;
  gap: 14px;
  grid-template-columns: minmax(360px, 0.72fr) minmax(640px, 1.28fr);
  min-width: 0;
}

.workspace__main.theory-mode {
  grid-template-columns: minmax(0, 1fr);
}

.question-panel,
.code-panel,
.results-panel {
  padding: 20px;
}

.question-panel {
  display: grid;
  gap: 14px;
}

.question-meta,
.tag-row,
.actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.question-meta {
  margin-bottom: -2px;
}

#questionTitle {
  animation: fadeSlide 240ms ease both;
  color: var(--ink);
  font-size: 25px;
  line-height: 1.28;
  margin-bottom: -4px;
}

.question-stem {
  animation: fadeSlide 260ms ease both;
  color: #d9f8f3;
  font-size: 17px;
  line-height: 1.78;
  margin-bottom: 0;
  white-space: pre-wrap;
}

.tag {
  align-items: center;
  background: rgba(94, 234, 212, 0.09);
  border: 1px solid rgba(94, 234, 212, 0.16);
  border-radius: 8px;
  color: #bdfbf3;
  display: inline-flex;
  font-size: 12px;
  font-weight: 820;
  min-height: 26px;
  padding: 0 8px;
}

.section-label {
  color: var(--amber);
  display: block;
  font-size: 12px;
  font-weight: 850;
  letter-spacing: 0;
  margin-bottom: 4px;
}

.disclosure {
  border-top: 1px solid var(--line);
  color: var(--ink);
}

.disclosure > summary {
  align-items: center;
  cursor: pointer;
  display: grid;
  gap: 3px;
  grid-template-columns: minmax(0, 1fr) auto;
  list-style: none;
  min-height: 56px;
  padding: 12px 0;
}

.disclosure > summary::-webkit-details-marker {
  display: none;
}

.disclosure > summary::after {
  align-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  color: var(--accent);
  content: "+";
  display: inline-flex;
  font-size: 18px;
  height: 32px;
  justify-content: center;
  transition: transform 180ms ease, box-shadow 180ms ease, background 180ms ease;
  width: 32px;
}

.disclosure[open] > summary::after {
  background: rgba(94, 234, 212, 0.12);
  box-shadow: 0 0 18px var(--glow);
  content: "-";
  transform: rotate(180deg);
}

.disclosure > summary strong {
  font-size: 16px;
  grid-column: 1;
}

.disclosure > summary small {
  color: var(--muted);
  display: block;
  font-size: 13px;
  grid-column: 1;
  line-height: 1.5;
}

.disclosure[open] > :not(summary) {
  animation: expandIn 220ms ease both;
}

.study-panel {
  background: rgba(12, 28, 31, 0.72);
  border: 1px solid rgba(243, 201, 105, 0.2);
  border-left: 3px solid var(--amber);
  padding: 0 16px 14px;
}

.study-points {
  display: grid;
  gap: 8px;
}

.study-point {
  border-top: 1px solid rgba(243, 201, 105, 0.16);
  padding-top: 8px;
}

.study-point:first-child {
  border-top: 0;
  padding-top: 0;
}

.study-point strong {
  color: #ffe3a6;
  display: block;
  font-size: 14px;
  margin-bottom: 2px;
}

.study-point p {
  color: #c7d5d1;
  line-height: 1.6;
  margin: 0;
}

.actions-row {
  margin: 0;
}

.primary-button,
.secondary-button,
.status-button,
.icon-button {
  border: 1px solid transparent;
  border-radius: 8px;
  font-weight: 820;
  min-height: 38px;
  padding: 0 12px;
  transition: transform 140ms ease, box-shadow 160ms ease, background 160ms ease, border-color 160ms ease;
}

.primary-button {
  background: var(--accent-dark);
  border-color: rgba(94, 234, 212, 0.42);
  color: #ecfffb;
}

.primary-button:hover,
.secondary-button:hover,
.status-button:hover,
.icon-button:hover {
  box-shadow: 0 0 20px var(--glow);
  transform: translateY(-1px);
}

.primary-button:active,
.secondary-button:active,
.status-button:active,
.icon-button:active {
  transform: translateY(0);
}

.secondary-button,
.status-button,
.icon-button {
  background: rgba(10, 21, 25, 0.84);
  border-color: var(--line);
  color: #d7fff8;
}

.status-button.active {
  background: rgba(94, 234, 212, 0.12);
  border-color: var(--accent);
  color: var(--accent);
}

.theory-section,
.fill-blank-section {
  background: rgba(8, 20, 24, 0.72);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  padding: 16px;
}

.theory-section h3,
.fill-blank-section h3 {
  color: var(--ink);
  font-size: 22px;
}

.theory-options {
  display: grid;
  gap: 10px;
}

.theory-option {
  background: rgba(5, 13, 16, 0.72);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  color: var(--ink);
  line-height: 1.55;
  min-height: 60px;
  padding: 14px 16px;
  text-align: left;
  transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease, background 160ms ease;
  width: 100%;
}

.theory-option:hover {
  background: rgba(94, 234, 212, 0.08);
  border-color: var(--accent);
  box-shadow: 0 0 24px var(--glow);
  transform: translateX(3px);
}

.theory-option.selected {
  background: rgba(94, 234, 212, 0.14);
  border-color: var(--accent);
}

.theory-option strong {
  align-items: center;
  background: rgba(94, 234, 212, 0.14);
  border: 1px solid rgba(94, 234, 212, 0.2);
  border-radius: 8px;
  color: var(--accent);
  display: inline-flex;
  height: 30px;
  justify-content: center;
  margin-right: 10px;
  width: 30px;
}

.theory-feedback {
  color: var(--muted);
  font-weight: 700;
  line-height: 1.55;
  margin: 10px 0 0;
}

.blank-inputs {
  display: grid;
  gap: 12px;
}

.blank-field {
  margin-bottom: 0;
}

.blank-field span {
  color: var(--ink);
  font-size: 14px;
}

.blank-field input {
  font-size: 17px;
  min-height: 48px;
}

.blank-field input.blank-correct {
  background: rgba(125, 220, 138, 0.12);
  border-color: var(--green);
}

.blank-field input.blank-wrong {
  background: rgba(255, 123, 114, 0.1);
  border-color: var(--red);
}

.fill-blank-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.fill-blank-actions .theory-feedback {
  margin: 0;
}

.hint-section,
.answer-section,
.source-details {
  padding: 0;
}

.hint-list {
  display: grid;
  gap: 8px;
  padding-bottom: 12px;
}

.hint-disclosure {
  background: rgba(7, 17, 20, 0.72);
  border: 1px solid rgba(129, 240, 224, 0.14);
  border-radius: 8px;
  overflow: hidden;
}

.hint-disclosure summary {
  align-items: center;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  list-style: none;
  padding: 10px 12px;
}

.hint-disclosure summary::-webkit-details-marker {
  display: none;
}

.hint-disclosure summary strong {
  color: var(--ink);
}

.hint-disclosure summary span {
  color: var(--accent);
  font-size: 13px;
}

.hint-disclosure p {
  animation: expandIn 180ms ease both;
  border-top: 1px solid rgba(129, 240, 224, 0.12);
  color: #c7d5d1;
  line-height: 1.6;
  margin: 0;
  padding: 10px 12px;
}

.answer-header,
.code-toolbar,
.runbar {
  align-items: center;
  display: flex;
  gap: 10px;
  justify-content: space-between;
}

.answer-header {
  justify-content: flex-start;
  padding-bottom: 12px;
}

.answer-block,
.result-output {
  background: var(--code-bg);
  border: 1px solid rgba(129, 240, 224, 0.14);
  border-radius: 8px;
  color: var(--code-ink);
  line-height: 1.58;
  overflow: auto;
  padding: 12px;
  white-space: pre-wrap;
}

.source-details {
  color: var(--muted);
}

.source-details code {
  overflow-wrap: anywhere;
}

#sourceInfo {
  border-top: 1px solid rgba(129, 240, 224, 0.12);
  color: #c7d5d1;
  line-height: 1.58;
  padding: 12px 0;
}

.code-panel {
  display: grid;
  grid-template-rows: auto minmax(460px, 1fr) auto auto;
}

.code-toolbar {
  align-items: flex-start;
  margin-bottom: 12px;
}

.code-toolbar h2 {
  color: var(--ink);
  font-size: 23px;
  margin-bottom: 4px;
}

.code-toolbar p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
  margin-bottom: 0;
}

#codeEditor {
  background: var(--code-bg);
  border-color: rgba(129, 240, 224, 0.24);
  color: var(--code-ink);
  font-family: Consolas, "Courier New", monospace;
  font-size: 15px;
  line-height: 1.62;
  min-height: 520px;
  tab-size: 4;
}

.input-row {
  margin-top: 12px;
}

#customInput {
  min-height: 86px;
}

.runbar {
  border-top: 1px solid var(--line);
  justify-content: flex-start;
  margin-top: 12px;
  padding-top: 12px;
}

.results-panel {
  padding: 16px 18px;
}

.results-list {
  display: grid;
  gap: 10px;
}

.result-card {
  background: rgba(5, 13, 16, 0.72);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.result-card.pass {
  border-color: rgba(125, 220, 138, 0.38);
}

.result-card.fail {
  border-color: rgba(255, 123, 114, 0.44);
}

.result-card h3 {
  display: flex;
  gap: 10px;
  justify-content: space-between;
  margin-bottom: 8px;
}

.result-card .pass-text {
  color: var(--green);
}

.result-card .fail-text {
  color: var(--red);
}

.empty-state {
  color: var(--muted);
  line-height: 1.6;
  margin: 0;
}

.dialog-backdrop {
  background: rgba(0, 0, 0, 0.68);
  display: grid;
  inset: 0;
  padding: 20px;
  place-items: center;
  position: fixed;
  z-index: 20;
}

.dialog {
  background: #0d1a1e;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  box-shadow: 0 0 50px rgba(94, 234, 212, 0.18);
  padding: 18px;
  width: min(460px, 100%);
}

.dialog p {
  color: var(--muted);
  line-height: 1.6;
}

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

[hidden] {
  display: none !important;
}

@keyframes panelIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeSlide {
  from {
    opacity: 0;
    transform: translateY(5px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes expandIn {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pulseLine {
  0%,
  100% {
    opacity: 0.42;
  }
  50% {
    opacity: 1;
  }
}

@media (min-width: 1280px) {
  .workspace__main.theory-mode .question-panel {
    grid-template-columns: minmax(360px, 0.72fr) minmax(520px, 1fr);
  }

  .workspace__main.theory-mode .question-meta,
  .workspace__main.theory-mode #questionTitle,
  .workspace__main.theory-mode .question-stem,
  .workspace__main.theory-mode .tag-row,
  .workspace__main.theory-mode .study-panel {
    grid-column: 1;
  }

  .workspace__main.theory-mode .theory-section,
  .workspace__main.theory-mode .fill-blank-section {
    align-self: start;
    grid-column: 2;
    grid-row: 1 / span 6;
  }

  .workspace__main.theory-mode .actions-row,
  .workspace__main.theory-mode .hint-section,
  .workspace__main.theory-mode .answer-section,
  .workspace__main.theory-mode .source-details {
    grid-column: 1 / -1;
  }
}

@media (max-width: 1180px) {
  .layout,
  .workspace__main {
    grid-template-columns: 1fr;
  }

  .sidebar {
    grid-template-columns: minmax(0, 0.9fr) minmax(260px, 1.1fr);
  }

  .question-list-panel {
    max-height: 340px;
  }
}

@media (max-width: 760px) {
  .app-shell {
    padding: 10px;
  }

  .topbar,
  .answer-header,
  .code-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar__status {
    justify-content: flex-start;
  }

  .sidebar {
    grid-template-columns: 1fr;
  }

  .question-panel,
  .code-panel,
  .results-panel {
    padding: 14px;
  }

  #questionTitle {
    font-size: 21px;
  }

  .question-stem {
    font-size: 16px;
  }

  .theory-section,
  .fill-blank-section {
    padding: 14px;
  }

  .disclosure > summary {
    grid-template-columns: minmax(0, 1fr) 32px;
  }

  .runbar {
    background: var(--surface);
    bottom: 0;
    position: sticky;
    z-index: 5;
  }

  #codeEditor {
    min-height: 420px;
  }
}
