:root {
  --bg: #f8fafc;
  --bg-deep: #eef3f8;
  --panel: rgba(255, 255, 255, 0.92);
  --panel-strong: #ffffff;
  --line: rgba(74, 85, 104, 0.12);
  --text: #1f2937;
  --muted: #64748b;
  --primary: #2563eb;
  --primary-deep: #1d4ed8;
  --success: #15803d;
  --danger: #dc2626;
  --warning: #b7791f;
  --shadow: 0 18px 50px rgba(148, 163, 184, 0.14);
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --ui-font: "Microsoft YaHei UI", "PingFang SC", "Segoe UI", sans-serif;
  --code-font: Consolas, "Cascadia Code", "Courier New", monospace;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.96), transparent 34%),
    linear-gradient(135deg, #ffffff, var(--bg) 42%, var(--bg-deep));
  color: var(--text);
  font-family: var(--ui-font);
}

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

button,
select,
input,
textarea {
  touch-action: manipulation;
}

.backdrop {
  position: fixed;
  inset: auto;
  border-radius: 999px;
  filter: blur(18px);
  pointer-events: none;
  opacity: 0.45;
}

.backdrop-a {
  top: -80px;
  right: 8%;
  width: 320px;
  height: 320px;
  background: rgba(37, 99, 235, 0.08);
}

.backdrop-b {
  bottom: -120px;
  left: -30px;
  width: 260px;
  height: 260px;
  background: rgba(148, 163, 184, 0.1);
}

.app-shell {
  position: relative;
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 18px;
  padding: 18px;
  max-width: 1440px;
  margin: 0 auto;
}

.sidebar,
.main-content {
  min-width: 0;
}

.sidebar {
  align-self: start;
}

.brand-card,
.panel,
.question-card,
.empty-state {
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.hero-strip h2,
.question-heading h3,
.empty-state h3 {
  margin: 0;
  font-family: var(--ui-font);
  font-weight: 700;
}

.hero-copy,
.empty-state p {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.5;
  font-size: 14px;
}

.panel {
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 14px;
}

.panel h2 {
  margin: 0 0 16px;
  font-size: 17px;
}

.field {
  display: block;
  margin-bottom: 12px;
}

.field span {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
}

select,
textarea,
input[type="text"] {
  width: 100%;
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.96);
  padding: 12px 14px;
  color: var(--text);
  outline: none;
  transition: border-color 180ms ease, transform 180ms ease, box-shadow 180ms ease;
}

select:focus,
textarea:focus,
input[type="text"]:focus {
  border-color: rgba(198, 93, 50, 0.65);
  box-shadow: 0 0 0 4px rgba(198, 93, 50, 0.1);
}

.action-row,
.hero-actions,
.question-actions,
.short-answer-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

button {
  border: 0;
  border-radius: 999px;
  padding: 12px 18px;
  cursor: pointer;
  transition: transform 180ms ease, box-shadow 180ms ease, background 180ms ease, opacity 180ms ease;
}

button:hover {
  transform: translateY(-1px);
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.primary-button {
  background: linear-gradient(135deg, var(--primary), #60a5fa);
  color: #ffffff;
  box-shadow: 0 12px 22px rgba(37, 99, 235, 0.18);
}

.secondary-button {
  background: #f8fbff;
  color: var(--primary-deep);
  border: 1px solid rgba(37, 99, 235, 0.16);
}

.ghost-button {
  background: transparent;
  color: var(--muted);
  border: 1px solid rgba(148, 163, 184, 0.22);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.stat-card {
  padding: 12px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(148, 163, 184, 0.14);
}

.stat-label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
}

.stat-card strong {
  font-size: 28px;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.question-nav {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  max-height: 320px;
  overflow: auto;
  padding-right: 4px;
}

.nav-button {
  min-height: 42px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.94);
  color: var(--muted);
  border: 1px solid rgba(148, 163, 184, 0.16);
  font-weight: 700;
}

.nav-button.is-current {
  background: linear-gradient(135deg, #2563eb, #60a5fa);
  color: #ffffff;
}

.nav-button.is-correct {
  background: rgba(47, 122, 80, 0.14);
  color: var(--success);
  border-color: rgba(47, 122, 80, 0.2);
}

.nav-button.is-wrong {
  background: rgba(182, 70, 70, 0.13);
  color: var(--danger);
  border-color: rgba(182, 70, 70, 0.18);
}

.main-content {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.hero-actions {
  flex-shrink: 0;
}

.hero-actions button {
  min-width: 96px;
}

.hero-strip {
  padding: 6px 2px 2px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  background: transparent;
  border: 0;
  box-shadow: none;
  backdrop-filter: none;
}

.hero-strip h2 {
  font-size: clamp(18px, 2vw, 24px);
}

.question-card,
.empty-state {
  border-radius: var(--radius-xl);
  padding: 22px;
}

.question-meta,
.question-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.question-heading {
  margin-top: 14px;
}

.meta-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.badge,
.record-badge {
  display: inline-flex;
  align-items: center;
  padding: 7px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
}

.badge-paper {
  background: rgba(37, 99, 235, 0.1);
  color: #1e40af;
}

.badge-type {
  background: rgba(14, 165, 233, 0.1);
  color: var(--primary-deep);
}

.badge-score {
  background: rgba(245, 158, 11, 0.12);
  color: var(--warning);
}

.record-badge {
  background: rgba(148, 163, 184, 0.12);
  color: var(--muted);
}

.record-badge.correct {
  background: rgba(47, 122, 80, 0.15);
  color: var(--success);
}

.record-badge.wrong {
  background: rgba(182, 70, 70, 0.14);
  color: var(--danger);
}

.question-prompt,
.feedback-panel pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: inherit;
}

.question-prompt {
  margin-top: 16px;
  padding: 16px;
  border-radius: 20px;
  background: rgba(248, 250, 252, 0.98);
  border: 1px solid rgba(148, 163, 184, 0.14);
  line-height: 1.72;
  font-size: 16px;
}

.rich-content {
  display: grid;
  gap: 10px;
}

.rich-paragraph {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.72;
}

.inline-code {
  display: inline-block;
  padding: 1px 6px;
  margin: 0 2px;
  border-radius: 8px;
  background: #eff6ff;
  border: 1px solid rgba(37, 99, 235, 0.12);
  color: #1d4ed8;
  font-family: var(--code-font);
  font-size: 0.95em;
}

.code-block {
  margin: 0;
  padding: 14px 16px;
  border-radius: 16px;
  background: #f8fafc;
  border: 1px solid rgba(148, 163, 184, 0.2);
  overflow-x: auto;
}

.code-block code {
  display: block;
  white-space: pre;
  word-break: normal;
  line-height: 1.65;
  font-family: var(--code-font);
  font-size: 14px;
  color: #0f172a;
}

.answer-area {
  margin-top: 18px;
  display: grid;
  gap: 10px;
}

.option-button {
  width: 100%;
  text-align: left;
  border-radius: 16px;
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.98);
  border: 1px solid rgba(148, 163, 184, 0.16);
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.option-content {
  min-width: 0;
  flex: 1;
}

.option-content .code-block {
  background: rgba(255, 255, 255, 0.96);
}

.option-button .option-key {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(37, 99, 235, 0.1);
  color: var(--primary-deep);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  font-weight: 800;
}

.option-button:hover,
.option-button.selected {
  border-color: rgba(37, 99, 235, 0.34);
  background: #f8fbff;
}

.option-button.correct {
  border-color: rgba(47, 122, 80, 0.38);
  background: rgba(47, 122, 80, 0.12);
}

.option-button.wrong {
  border-color: rgba(182, 70, 70, 0.28);
  background: rgba(182, 70, 70, 0.1);
}

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

.blank-row {
  display: grid;
  gap: 8px;
}

.blank-row label {
  font-size: 14px;
  color: var(--muted);
  font-weight: 700;
}

.short-answer-box {
  display: grid;
  gap: 14px;
}

.short-answer-box textarea {
  min-height: 180px;
  resize: vertical;
}

.question-actions {
  margin-top: 18px;
}

.question-actions button,
.short-answer-actions button {
  min-height: 44px;
}

.feedback-panel {
  margin-top: 22px;
  padding: 20px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(148, 163, 184, 0.16);
  animation: rise-in 180ms ease;
}

.feedback-panel.correct {
  border-color: rgba(47, 122, 80, 0.2);
}

.feedback-panel.wrong {
  border-color: rgba(182, 70, 70, 0.18);
}

.feedback-title {
  margin: 0 0 12px;
  font-size: 18px;
}

.feedback-title.correct {
  color: var(--success);
}

.feedback-title.wrong {
  color: var(--danger);
}

.feedback-section + .feedback-section {
  margin-top: 14px;
}

.feedback-section h4 {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 14px;
}

.feedback-section p,
.feedback-section pre {
  margin: 0;
  line-height: 1.72;
}

.feedback-section > div {
  display: grid;
  gap: 10px;
}

.navigator-panel {
  position: sticky;
  top: 18px;
}

.blank-row input,
.short-answer-box textarea {
  font-size: 16px;
}

.hidden {
  display: none !important;
}

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

@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .main-content {
    order: 1;
  }

  .sidebar {
    order: 2;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    align-items: start;
  }

  .panel {
    margin-bottom: 0;
  }

  .navigator-panel {
    grid-column: 1 / -1;
  }

  .navigator-panel {
    position: static;
  }

  .hero-strip {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (max-width: 720px) {
  body {
    background: linear-gradient(180deg, #ffffff, var(--bg) 42%, var(--bg-deep));
  }

  .app-shell {
    padding: 10px;
    gap: 10px;
  }

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

  .brand-card,
  .panel,
  .question-card,
  .empty-state {
    padding: 14px;
    border-radius: 18px;
  }

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

  .field span,
  .stat-label,
  .hero-copy,
  .feedback-section h4,
  .blank-row label {
    font-size: 13px;
  }

  .stats-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
  }

  .stat-card {
    padding: 10px;
    border-radius: 14px;
  }

  .stat-card strong {
    font-size: 20px;
  }

  .hero-strip {
    position: sticky;
    top: 0;
    z-index: 10;
    gap: 12px;
    padding: calc(10px + env(safe-area-inset-top, 0px)) 2px 2px;
    background: rgba(248, 250, 252, 0.96);
    backdrop-filter: blur(10px);
  }

  .hero-strip h2 {
    font-size: 20px;
  }

  .hero-actions {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .hero-actions button,
  .question-actions button,
  .short-answer-actions button {
    width: 100%;
    min-height: 46px;
  }

  .question-card,
  .empty-state {
    padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  }

  .question-nav {
    grid-template-columns: repeat(6, minmax(0, 1fr));
    max-height: none;
  }

  .question-prompt {
    margin-top: 14px;
    padding: 14px;
    font-size: 15px;
    line-height: 1.68;
  }

  .rich-content {
    gap: 8px;
  }

  .code-block {
    padding: 12px;
    border-radius: 14px;
  }

  .code-block code {
    font-size: 13px;
  }

  .option-button {
    padding: 12px 14px;
    gap: 10px;
    border-radius: 14px;
  }

  .option-button .option-key {
    width: 28px;
    height: 28px;
    font-size: 13px;
  }

  .question-actions,
  .short-answer-actions {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .question-meta,
  .question-heading {
    flex-direction: column;
    align-items: flex-start;
  }

  .blank-grid,
  .short-answer-box,
  .feedback-section > div {
    gap: 8px;
  }

  .short-answer-box textarea {
    min-height: 150px;
  }

  .feedback-panel {
    margin-top: 18px;
    padding: 16px;
    border-radius: 18px;
  }
}

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

  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .question-nav {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .meta-badges {
    gap: 6px;
  }

  .badge,
  .record-badge {
    padding: 6px 10px;
    font-size: 12px;
  }
}
