:root {
  color-scheme: light;
  --bg: #eaf8ff;
  --bg-soft: #d9f0ff;
  --card: rgba(255, 255, 255, 0.84);
  --card-strong: rgba(255, 255, 255, 0.96);
  --line: rgba(58, 134, 180, 0.18);
  --line-strong: rgba(48, 125, 178, 0.34);
  --text: #12344f;
  --muted: #5e7890;
  --accent: #7ccafa;
  --accent-strong: #168ed7;
  --accent-deep: #0b6ead;
  --success: #25a978;
  --success-bg: rgba(37, 169, 120, 0.13);
  --danger: #df5f7a;
  --danger-bg: rgba(223, 95, 122, 0.12);
  --shadow: 0 24px 70px rgba(56, 128, 178, 0.2);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  min-height: 100vh;
  margin: 0;
  font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 12% 8%, rgba(255, 255, 255, 0.92), transparent 18rem),
    radial-gradient(circle at 80% 12%, rgba(179, 229, 255, 0.95), transparent 24rem),
    radial-gradient(circle at 20% 86%, rgba(205, 244, 255, 0.86), transparent 26rem),
    linear-gradient(145deg, #f8fdff 0%, #dff4ff 42%, #cfefff 100%);
}

button {
  font: inherit;
}

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 34px 0;
}

.hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 22px;
}

.hero h1 {
  max-width: 760px;
  margin: 0;
  font-size: clamp(2rem, 4vw, 4.2rem);
  line-height: 0.98;
  letter-spacing: 0;
  color: #0d3958;
  text-shadow: 0 10px 34px rgba(85, 173, 226, 0.2);
}

.hero-text {
  max-width: 620px;
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 1.03rem;
  line-height: 1.7;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--accent-deep);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.study-layout {
  position: relative;
  display: block;
  align-items: start;
}

.question-map-panel,
.quiz-card,
.summary-card {
  border: 1px solid var(--line);
  border-radius: 28px;
  background: var(--card);
  box-shadow: var(--shadow);
  backdrop-filter: blur(20px);
}

.question-map-panel {
  position: absolute;
  top: 64px;
  left: 0;
  z-index: 20;
  width: min(330px, 100%);
  max-height: min(70vh, 620px);
  overflow: auto;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-8px) scale(0.98);
  transform-origin: top left;
  scrollbar-color: rgba(58, 159, 224, 0.45) transparent;
  scrollbar-width: thin;
  transition:
    opacity 180ms ease,
    transform 180ms ease;
}

.question-map-panel::-webkit-scrollbar {
  width: 6px;
}

.question-map-panel::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(58, 159, 224, 0.42);
}

.question-map-panel.open {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

.study-topbar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 12px;
}

.map-toggle-button {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 46px;
  padding: 0 12px 0 14px;
  border: 1px solid rgba(70, 161, 224, 0.28);
  border-radius: 999px;
  color: var(--text);
  background: linear-gradient(145deg, rgba(199, 237, 255, 0.96), rgba(255, 255, 255, 0.78));
  box-shadow: 0 16px 44px rgba(74, 150, 206, 0.18);
  cursor: pointer;
  font-weight: 800;
  transition:
    transform 160ms ease,
    border-color 160ms ease,
    background 160ms ease;
}

.map-toggle-button:hover,
.map-toggle-button[aria-expanded="true"] {
  transform: translateY(-2px);
  border-color: rgba(38, 141, 211, 0.5);
  background: linear-gradient(145deg, rgba(177, 229, 255, 0.98), rgba(255, 255, 255, 0.92));
}

.map-toggle-icon {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  color: #07314d;
  background: linear-gradient(135deg, #9fe0ff, #d8f5ff);
  font-size: 1.1rem;
  line-height: 1;
}

.map-toggle-meta {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  color: var(--muted);
  background: rgba(89, 174, 228, 0.1);
  font-size: 0.82rem;
}

.map-backdrop {
  position: fixed;
  inset: 0;
  z-index: 10;
  background: transparent;
}

.panel-heading,
.quiz-header,
.navigation-row,
.summary-actions,
.progress-copy {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.panel-heading h2,
.quiz-header h2,
.summary-card h2 {
  margin: 0;
}

.panel-heading h2 {
  font-size: 1.2rem;
}

.panel-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.panel-close-button {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--text);
  background: rgba(255, 255, 255, 0.7);
  cursor: pointer;
  font-size: 1.25rem;
  line-height: 1;
  transition:
    transform 160ms ease,
    border-color 160ms ease,
    background 160ms ease;
}

.panel-close-button:hover {
  transform: rotate(90deg);
  border-color: rgba(38, 141, 211, 0.42);
  background: rgba(226, 247, 255, 0.95);
}

.small-pill,
.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 6px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.65);
  font-size: 0.82rem;
  font-weight: 700;
  white-space: nowrap;
}

.status-pill.correct {
  border-color: rgba(68, 197, 133, 0.42);
  color: #0e7452;
  background: var(--success-bg);
}

.status-pill.wrong {
  border-color: rgba(240, 110, 124, 0.45);
  color: #a73951;
  background: var(--danger-bg);
}

.question-map {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  margin-top: 18px;
}

.map-item {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 15px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.58);
  cursor: pointer;
  transition:
    transform 160ms ease,
    border-color 160ms ease,
    background 160ms ease,
    color 160ms ease;
}

.map-item:hover {
  transform: translateY(-2px);
  border-color: var(--line-strong);
  color: var(--text);
  background: rgba(231, 248, 255, 0.96);
}

.map-item.current {
  border-color: var(--accent);
  color: var(--accent-deep);
  background: rgba(194, 235, 255, 0.96);
  box-shadow: inset 0 0 0 1px rgba(52, 152, 219, 0.22);
}

.map-item.correct {
  border-color: rgba(68, 197, 133, 0.42);
  color: #0d7651;
  background: var(--success-bg);
}

.map-item.wrong {
  border-color: rgba(240, 110, 124, 0.45);
  color: #a73951;
  background: var(--danger-bg);
}

.quiz-card {
  padding: clamp(22px, 4vw, 38px);
}

.quiz-header {
  align-items: flex-start;
}

.quiz-header h2 {
  max-width: 780px;
  font-size: clamp(1.35rem, 2.5vw, 2.25rem);
  line-height: 1.22;
}

.quiz-card .katex {
  color: inherit;
  font-size: 1.02em;
}

.quiz-card .katex-display {
  max-width: 100%;
  margin: 0.65rem 0 0;
  padding: 0.35rem 0.2rem 0.5rem;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-color: rgba(58, 159, 224, 0.45) transparent;
  scrollbar-width: thin;
}

.quiz-card .katex-display::-webkit-scrollbar {
  height: 6px;
}

.quiz-card .katex-display::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(58, 159, 224, 0.42);
}

.quiz-card .katex-display > .katex {
  display: inline-block;
  min-width: max-content;
}

.progress-copy {
  margin-top: 28px;
  color: var(--muted);
  font-size: 0.93rem;
  font-weight: 700;
}

.progress-track {
  height: 10px;
  margin-top: 10px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.7);
}

.progress-fill {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #55bdf3, #aee8ff, #dff8ff);
  transition: width 240ms ease;
}

.options-list {
  display: grid;
  gap: 14px;
  margin-top: 28px;
}

.option-button {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  width: 100%;
  min-height: 70px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 22px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.72);
  text-align: left;
  cursor: pointer;
  transition:
    transform 160ms ease,
    border-color 160ms ease,
    background 160ms ease,
    box-shadow 160ms ease;
}

.option-button:hover:not(:disabled) {
  transform: translateY(-2px);
  border-color: rgba(38, 141, 211, 0.42);
  background: rgba(235, 249, 255, 0.98);
}

.option-button:disabled {
  cursor: default;
}

.option-letter {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 14px;
  color: var(--accent-deep);
  background: rgba(152, 219, 255, 0.32);
  font-weight: 800;
}

.option-text {
  min-width: 0;
  overflow-wrap: anywhere;
}

.option-text .katex-display {
  margin: 0.2rem 0;
}

.option-button.correct {
  border-color: rgba(68, 197, 133, 0.62);
  background: var(--success-bg);
  box-shadow: 0 0 0 1px rgba(68, 197, 133, 0.18);
}

.option-button.correct .option-letter {
  color: #0d7651;
  background: rgba(68, 197, 133, 0.24);
}

.option-button.wrong {
  border-color: rgba(240, 110, 124, 0.62);
  background: var(--danger-bg);
  box-shadow: 0 0 0 1px rgba(240, 110, 124, 0.16);
}

.option-button.wrong .option-letter {
  color: #a73951;
  background: rgba(240, 110, 124, 0.24);
}

.explanation-card {
  margin-top: 24px;
  padding: 22px;
  border: 1px solid rgba(52, 152, 219, 0.24);
  border-radius: 24px;
  background: linear-gradient(145deg, rgba(197, 236, 255, 0.86), rgba(255, 255, 255, 0.72));
}

.explanation-card p:last-child {
  margin: 0;
  color: #2d526f;
  line-height: 1.75;
}

.navigation-row {
  margin-top: 26px;
}

.primary-button,
.secondary-button,
.ghost-button {
  min-height: 48px;
  padding: 0 18px;
  border-radius: 16px;
  font-weight: 800;
  cursor: pointer;
  transition:
    transform 160ms ease,
    border-color 160ms ease,
    background 160ms ease,
    opacity 160ms ease;
}

.primary-button {
  border: 0;
  color: #07314d;
  background: linear-gradient(135deg, #77ccfb, #c6f0ff);
  box-shadow: 0 12px 28px rgba(58, 159, 224, 0.24);
}

.secondary-button,
.ghost-button {
  border: 1px solid var(--line);
  color: var(--text);
  background: rgba(255, 255, 255, 0.72);
}

.ghost-button {
  margin-top: 6px;
}

.primary-button:hover,
.secondary-button:hover,
.ghost-button:hover {
  transform: translateY(-2px);
}

.primary-button:disabled,
.secondary-button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.summary-card {
  width: min(760px, 100%);
  margin: 34px auto 0;
  padding: clamp(24px, 5vw, 42px);
  text-align: center;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin: 26px 0;
}

.summary-grid div {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.68);
}

.summary-grid span {
  display: block;
  font-size: clamp(2rem, 5vw, 3.1rem);
  font-weight: 800;
}

.summary-grid p,
.motivation {
  margin: 8px 0 0;
  color: var(--muted);
}

.summary-actions {
  justify-content: center;
  flex-wrap: wrap;
}

@media (max-width: 900px) {
  body.map-open {
    overflow: hidden;
  }

  .hero {
    display: block;
  }

  .ghost-button {
    margin-top: 18px;
  }

  .question-map-panel {
    position: fixed;
    top: auto;
    right: 12px;
    bottom: 12px;
    left: 12px;
    z-index: 30;
    width: auto;
    max-height: min(72vh, 560px);
    overflow: auto;
    transform: translateY(22px) scale(0.98);
    transform-origin: bottom center;
  }

  .question-map-panel.open {
    transform: translateY(0) scale(1);
  }

  .map-backdrop {
    background: rgba(36, 103, 147, 0.22);
    backdrop-filter: blur(4px);
  }

  .question-map {
    grid-template-columns: repeat(8, minmax(38px, 1fr));
  }
}

@media (max-width: 620px) {
  .app-shell {
    width: min(100% - 20px, 1180px);
    padding: 18px 0;
  }

  .hero h1 {
    font-size: 2.35rem;
  }

  .question-map-panel,
  .quiz-card,
  .summary-card {
    border-radius: 22px;
  }

  .study-topbar {
    position: sticky;
    top: 10px;
    z-index: 9;
    justify-content: stretch;
  }

  .map-toggle-button {
    width: 100%;
    justify-content: space-between;
  }

  .quiz-header,
  .navigation-row,
  .progress-copy {
    align-items: stretch;
    flex-direction: column;
  }

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

  .map-item {
    min-height: 48px;
    border-radius: 16px;
  }

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

  .primary-button,
  .secondary-button,
  .ghost-button {
    width: 100%;
  }
}
