:root {
  --page-bg: #f2f4f8;
  --card-bg: rgba(249, 251, 255, 0.9);
  --text-main: #273041;
  --text-muted: #778196;
  --brand: #3478f6;
  --brand-soft: #e9f1ff;
  --correct: #32a467;
  --wrong: #ea5757;
  --line: #d6dfec;
  --shadow: 0 18px 50px rgba(69, 93, 138, 0.1);
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  min-height: 100vh;
  font-family: 'PingFang SC', 'Microsoft YaHei', 'Noto Sans SC', sans-serif;
  background:
    radial-gradient(circle at top left, rgba(79, 138, 255, 0.08), transparent 28%),
    linear-gradient(180deg, #f8fbff, #edf2f8 58%, #eef2f7);
  color: var(--text-main);
  overflow-x: hidden;
}

.hidden {
  display: none !important;
}

.app {
  position: relative;
  width: min(100%, 960px);
  margin: 0 auto;
  min-height: 100vh;
  padding: 18px 16px calc(132px + env(safe-area-inset-bottom, 0px));
  overflow: hidden;
}

.watermark {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.11;
  background-image:
    repeating-linear-gradient(
      -32deg,
      transparent 0,
      transparent 86px,
      rgba(66, 79, 102, 0.1) 86px,
      rgba(66, 79, 102, 0.1) 90px,
      transparent 90px,
      transparent 180px
    );
}

.topbar,
.question-panel,
.bottom-bar {
  position: relative;
  z-index: 1;
}

.topbar-stack {
  display: grid;
  gap: 14px;
}

.mode-switch {
  display: inline-flex;
  max-width: 100%;
  width: fit-content;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 10px 28px rgba(59, 92, 142, 0.08);
}

.mode-btn {
  border: 0;
  min-height: 44px;
  padding: 10px 18px;
  font-size: 18px;
  line-height: 1;
  color: #316ed8;
  background: transparent;
  cursor: pointer;
}

.mode-btn.active {
  background: var(--brand);
  color: #fff;
}

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

.filter-field {
  display: grid;
  gap: 8px;
}

.filter-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
}

.filter-select {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  font-size: 18px;
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 12px 30px rgba(67, 92, 130, 0.06);
}

.question-panel {
  margin-top: 20px;
  padding: 22px 20px 24px;
  border: 1px solid rgba(214, 223, 236, 0.8);
  border-radius: 24px;
  background: var(--card-bg);
  box-shadow: var(--shadow);
  backdrop-filter: blur(6px);
}

.progress {
  margin: 0;
  font-size: 28px;
  font-weight: 700;
}

.meta-row {
  margin-top: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.meta-badge {
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 16px;
  color: #4b607f;
  background: #eef4ff;
  overflow-wrap: anywhere;
}

.meta-badge.strong {
  color: #fff;
  background: linear-gradient(135deg, #2b72ee, #5ca0ff);
}

.stem {
  margin: 20px 0;
  font-size: 38px;
  line-height: 1.58;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.media-section {
  margin: 18px 0 0;
  display: grid;
  gap: 12px;
}

.media-title {
  margin: 0;
  font-size: 22px;
  color: #35507c;
}

.image-grid {
  display: grid;
  gap: 14px;
}

.image-card {
  display: block;
  border: 1px solid rgba(186, 204, 234, 0.9);
  border-radius: 18px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 12px 28px rgba(64, 90, 136, 0.08);
}

.image-card img {
  display: block;
  width: 100%;
  height: auto;
}

.options {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 12px;
}

.option-item {
  width: 100%;
  min-height: 56px;
  border: 1px solid transparent;
  border-radius: 18px;
  padding: 12px 14px;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  background: rgba(255, 255, 255, 0.64);
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, transform 0.2s;
}

.option-item:hover {
  border-color: #c2d6ff;
  background: #f4f8ff;
  transform: translateY(-1px);
}

.option-tag {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 2px solid #b4bcc9;
  color: #6b7486;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  font-weight: 700;
  flex: 0 0 auto;
}

.option-content {
  font-size: 30px;
  line-height: 1.5;
  text-align: left;
  overflow-wrap: anywhere;
}

.option-item.selected {
  border-color: rgba(52, 120, 246, 0.24);
  background: rgba(52, 120, 246, 0.08);
}

.option-item.selected .option-tag {
  border-color: var(--brand);
  background: var(--brand);
  color: #fff;
}

.option-item.correct {
  border-color: rgba(50, 164, 103, 0.35);
  background: rgba(50, 164, 103, 0.1);
}

.option-item.correct .option-tag {
  border-color: var(--correct);
  background: var(--correct);
  color: #fff;
}

.option-item.wrong {
  border-color: rgba(234, 87, 87, 0.32);
  background: rgba(234, 87, 87, 0.09);
}

.option-item.wrong .option-tag {
  border-color: var(--wrong);
  background: var(--wrong);
  color: #fff;
}

.text-answer {
  margin-top: 18px;
  display: grid;
  gap: 10px;
  padding: 16px 18px;
  border: 1px dashed #c8d5ea;
  border-radius: 18px;
  background: rgba(244, 248, 255, 0.88);
}

.blank-label {
  font-size: 16px;
  font-weight: 600;
  color: #4d6487;
}

.blank-input {
  width: 100%;
  min-height: 88px;
  border: 1px solid #c9d6ea;
  border-radius: 16px;
  padding: 14px 16px;
  font: inherit;
  font-size: 22px;
  line-height: 1.55;
  color: var(--text-main);
  background: #fff;
  resize: vertical;
}

.blank-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.reveal-btn {
  width: fit-content;
  min-height: 44px;
  border: 0;
  border-radius: 14px;
  padding: 11px 18px;
  font-size: 18px;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(135deg, #2f78f6, #6ea7ff);
  cursor: pointer;
}

.ghost-btn {
  width: fit-content;
  min-height: 44px;
  border: 1px solid #b8ccef;
  border-radius: 14px;
  padding: 11px 18px;
  font-size: 18px;
  font-weight: 600;
  color: #2f78f6;
  background: rgba(255, 255, 255, 0.92);
  cursor: pointer;
}

.blank-status {
  margin: 0;
  font-size: 16px;
  line-height: 1.5;
  color: var(--text-muted);
}

.blank-status.correct {
  color: var(--correct);
}

.blank-status.wrong {
  color: var(--wrong);
}

.text-answer-tip {
  margin: 0;
  font-size: 16px;
  color: var(--text-muted);
}

.result {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid #e0e7f2;
}

.answer-line {
  margin: 0;
  font-size: 28px;
  color: #ff582a;
  font-weight: 700;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.analysis-title {
  margin: 16px 0 8px;
  font-size: 26px;
}

.analysis-text {
  margin: 0;
  font-size: 22px;
  line-height: 1.65;
  color: #314156;
  overflow-wrap: anywhere;
}

.bottom-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  border-top: 1px solid #e4e9f1;
  background: rgba(247, 249, 253, 0.96);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
}

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

.tool-btn {
  border: 0;
  min-height: 40px;
  padding: 8px 12px;
  border-radius: 12px;
  background: transparent;
  color: #666d7b;
  font-size: 18px;
  cursor: pointer;
}

.nav {
  display: flex;
  gap: 12px;
}

.nav-btn {
  border: 2px solid #b9cff8;
  border-radius: 26px;
  min-height: 48px;
  padding: 10px 22px;
  font-size: 24px;
  color: #6c8fcf;
  background: #f2f7ff;
  cursor: pointer;
}

.nav-btn.primary {
  border-color: #63a0ff;
  color: #2f7df7;
  background: #edf5ff;
}

.nav-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

@media (max-width: 960px) {
  .app {
    width: 100%;
    padding: 14px 12px calc(124px + env(safe-area-inset-bottom, 0px));
  }

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

  .question-panel {
    padding: 18px 16px 22px;
    border-radius: 20px;
  }

  .mode-btn {
    font-size: 16px;
    padding: 10px 14px;
  }

  .filter-select {
    font-size: 16px;
  }

  .progress {
    font-size: 20px;
  }

  .meta-badge {
    font-size: 13px;
    padding: 6px 10px;
  }

  .stem {
    font-size: 26px;
    line-height: 1.55;
  }

  .image-grid {
    gap: 12px;
  }

  .option-tag {
    width: 34px;
    height: 34px;
    font-size: 18px;
  }

  .option-content {
    font-size: 21px;
  }

  .media-title {
    font-size: 18px;
  }

  .blank-input,
  .reveal-btn,
  .ghost-btn,
  .answer-line,
  .analysis-title,
  .analysis-text,
  .tool-btn,
  .nav-btn {
    font-size: 16px;
  }

  .blank-input {
    min-height: 72px;
  }

  .bottom-bar {
    align-items: flex-end;
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px));
  }

  .nav {
    gap: 8px;
  }
}

@media (max-width: 640px) {
  .app {
    padding: 12px 10px calc(176px + env(safe-area-inset-bottom, 0px));
  }

  .watermark {
    opacity: 0.08;
  }

  .topbar-stack {
    gap: 12px;
  }

  .mode-switch {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
  }

  .mode-btn {
    width: 100%;
    padding: 11px 12px;
    font-size: 15px;
  }

  .question-panel {
    margin-top: 14px;
    padding: 16px 14px 20px;
    border-radius: 18px;
  }

  .progress {
    font-size: 18px;
    line-height: 1.45;
  }

  .meta-row {
    gap: 8px;
  }

  .meta-badge {
    max-width: 100%;
    padding: 6px 10px;
    line-height: 1.4;
  }

  .stem {
    margin: 16px 0;
    font-size: 21px;
    line-height: 1.65;
  }

  .option-item {
    gap: 10px;
    padding: 12px;
    border-radius: 16px;
  }

  .option-tag {
    width: 30px;
    height: 30px;
    font-size: 16px;
  }

  .option-content {
    font-size: 17px;
    line-height: 1.6;
  }

  .media-title {
    font-size: 16px;
  }

  .text-answer {
    margin-top: 16px;
    padding: 14px;
    border-radius: 16px;
  }

  .blank-label,
  .blank-status,
  .text-answer-tip {
    font-size: 14px;
  }

  .blank-input {
    min-height: 112px;
    padding: 12px 14px;
    font-size: 16px;
  }

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

  .reveal-btn,
  .ghost-btn {
    width: 100%;
    justify-content: center;
    padding: 12px 14px;
    font-size: 16px;
  }

  .answer-line {
    font-size: 18px;
  }

  .analysis-title {
    margin-top: 14px;
    font-size: 18px;
  }

  .analysis-text {
    font-size: 16px;
    line-height: 1.75;
  }

  .bottom-bar {
    align-items: stretch;
    flex-wrap: wrap;
    gap: 10px;
    padding: 10px 10px calc(10px + env(safe-area-inset-bottom, 0px));
  }

  .tools,
  .nav {
    width: 100%;
  }

  .tools {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .tool-btn {
    width: 100%;
    padding: 10px 8px;
    font-size: 15px;
    text-align: center;
    background: rgba(255, 255, 255, 0.7);
  }

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

  .nav-btn {
    width: 100%;
    min-width: 0;
    padding: 12px 10px;
    font-size: 17px;
  }
}

@media (max-width: 420px) {
  .app {
    padding-inline: 8px;
    padding-bottom: calc(182px + env(safe-area-inset-bottom, 0px));
  }

  .question-panel {
    padding-inline: 12px;
  }

  .filter-label {
    font-size: 13px;
  }

  .filter-select {
    padding-inline: 12px;
    font-size: 16px;
  }

  .stem {
    font-size: 19px;
  }

  .option-content {
    font-size: 16px;
  }

  .answer-line,
  .analysis-title,
  .analysis-text,
  .tool-btn,
  .nav-btn {
    font-size: 15px;
  }

  .blank-actions {
    grid-template-columns: 1fr;
  }
}
