:root {
  --ink: #1a1d2a;
  --soft-ink: #3b4254;
  --cream: #f6f3ed;
  --card: #ffffff;
  --accent: #2457d6;
  --accent-dark: #1f45aa;
  --shadow: 0 18px 40px rgba(26, 29, 42, 0.12);
  --border: #d7dfee;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Avenir Next", "Avenir", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: linear-gradient(135deg, #f4f5f8 0%, #eef3ff 55%, #f7f1ea 100%);
}

.bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
}

.blob {
  position: absolute;
  border-radius: 999px;
  opacity: 0.35;
  animation: float 8s ease-in-out infinite;
}

.blob-a {
  width: 320px;
  height: 320px;
  background: radial-gradient(circle at 30% 30%, #d9e2ff, #b8c8f6);
  top: -80px;
  left: -60px;
}

.blob-b {
  width: 260px;
  height: 260px;
  background: radial-gradient(circle at 70% 40%, #d4efe9, #a8d6cd);
  bottom: -120px;
  right: 10%;
  animation-delay: 1s;
}

.blob-c {
  width: 190px;
  height: 190px;
  background: radial-gradient(circle at 40% 40%, #e7dfd2, #c9b79f);
  top: 30%;
  right: -60px;
  animation-delay: 2s;
}

@keyframes float {
  0%,
  100% {
    transform: translateY(0px);
  }
  50% {
    transform: translateY(18px);
  }
}

.app {
  max-width: 1100px;
  margin: 0 auto;
  padding: 32px 20px 60px;
}

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

.topbar-title {
  min-width: 0;
}

.topbar-title h1 {
  margin: 0 0 10px;
  font-size: clamp(1.75rem, 2.2vw + 1rem, 2.4rem);
}

.topbar-title .subhead {
  margin-bottom: 0;
}

.topbar-title .test-badge {
  margin-top: 10px;
}

.menu {
  position: relative;
  flex: 0 0 auto;
}

.menu-summary {
  list-style: none;
  cursor: pointer;
  border: 2px solid #c8d2e7;
  background: rgba(255, 255, 255, 0.72);
  color: var(--soft-ink);
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 0.95rem;
  font-weight: 800;
}

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

.menu-summary::marker {
  content: "";
}

.menu[open] > .menu-summary {
  background: #e9efff;
  border-color: #9eb4ef;
  color: #1b3f9b;
}

.menu-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 10px);
  width: min(420px, calc(100vw - 40px));
  max-height: min(74vh, 680px);
  overflow: auto;
  padding: 16px;
  border-radius: 18px;
  border: 2px solid #e3e8f4;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  z-index: 10;
}

.menu-panel .details {
  margin-top: 10px;
}

.menu-panel .score {
  margin-top: 10px;
}

.menu-panel .tip {
  margin-top: 14px;
}

.menu-panel .module-switch,
.menu-panel .mode-switch,
.menu-panel .phase-switch {
  margin-bottom: 12px;
}

.menu-panel .voice-toggle {
  margin-bottom: 12px;
}

.menu-panel .bullets {
  margin-bottom: 0;
}

.menu-panel .terms {
  margin-bottom: 0;
}

.menu-panel .plan-text {
  margin-bottom: 10px;
}

.menu-title {
  margin: 12px 0 10px;
  font-weight: 900;
  color: var(--ink);
  font-size: 0.95rem;
}

.menu-title:first-child {
  margin-top: 0;
}

.layout-single {
  grid-template-columns: 1fr;
}

.visual {
  border: 2px solid #e3e8f4;
  background: linear-gradient(135deg, rgba(233, 239, 255, 0.8), rgba(246, 243, 237, 0.7));
  border-radius: 18px;
  padding: 14px 14px 10px;
  margin-bottom: 14px;
  overflow: hidden;
}

.visual-inner {
  width: 100%;
  max-height: 260px;
}

.visual svg {
  width: 100%;
  height: auto;
  max-height: 260px;
  display: block;
}

.visual img {
  width: 100%;
  height: auto;
  max-height: 260px;
  object-fit: contain;
  display: block;
  border-radius: 12px;
}

.visual .spin {
  transform-origin: 50% 50%;
  animation: none;
}

.visual .bob {
  transform-origin: 50% 50%;
  animation: none;
}

.visual .pulse {
  transform-origin: 50% 50%;
  animation: none;
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

@keyframes bob {
  0%,
  100% {
    transform: translateY(0px);
  }
  50% {
    transform: translateY(-4px);
  }
}

@keyframes pulse {
  0%,
  100% {
    opacity: 0.7;
  }
  50% {
    opacity: 1;
  }
}

@media (max-width: 640px) {
  .topbar {
    flex-direction: column;
    align-items: stretch;
  }

  .menu-panel {
    left: 0;
    right: 0;
    width: auto;
  }
}

.hero {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 24px;
  align-items: center;
  margin-bottom: 32px;
}

.hero-text h1 {
  margin: 0 0 12px;
  font-size: clamp(2rem, 3vw + 1rem, 3rem);
}

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

.subhead {
  font-size: 1.05rem;
  color: var(--soft-ink);
  line-height: 1.5;
  margin: 0 0 20px;
}

.test-badge {
  display: inline-block;
  margin: 0 0 14px;
  padding: 6px 10px;
  border-radius: 999px;
  background: #fff3d6;
  border: 2px solid #f2d08d;
  color: #6b4d10;
  font-weight: 700;
  font-size: 0.9rem;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

.module-switch,
.mode-switch {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

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

.reset-controls {
  margin-bottom: 10px;
}

.reset-note {
  margin: 8px 0 0;
  color: #6a1111;
  font-size: 0.85rem;
  line-height: 1.35;
}

.voice-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 14px;
  border: 2px solid #e3e8f4;
  background: rgba(255, 255, 255, 0.7);
}

.voice-label {
  font-size: 0.95rem;
  color: var(--soft-ink);
  font-weight: 700;
}

.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 26px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #d7dfee;
  transition: 0.2s;
  border-radius: 999px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: 0.2s;
  border-radius: 999px;
  box-shadow: 0 8px 18px rgba(26, 29, 42, 0.16);
}

.switch input:checked + .slider {
  background-color: #b7c8ff;
}

.switch input:checked + .slider:before {
  transform: translateX(18px);
}

.module-btn,
.mode-btn {
  border: 2px solid #c8d2e7;
  background: transparent;
  color: var(--soft-ink);
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 0.95rem;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.module-btn:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.module-btn.active,
.mode-btn.active {
  background: #e9efff;
  border-color: #9eb4ef;
  color: #1b3f9b;
  font-weight: 700;
}

.danger-btn {
  border-color: #f1a4a4;
  color: #6a1111;
  background: #fff0f0;
}

.danger-btn:hover {
  background: #ffdede;
  border-color: #ea8d8d;
}

.hero-card {
  background: var(--card);
  border-radius: 18px;
  padding: 20px;
  box-shadow: var(--shadow);
}

.score {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  text-align: center;
}

.score .label {
  font-size: 0.8rem;
  margin: 0;
  color: var(--soft-ink);
}

.score .value {
  margin: 4px 0 0;
  font-size: 1.6rem;
  font-weight: 700;
}

.tip {
  margin-top: 20px;
  background: var(--cream);
  border-radius: 14px;
  padding: 14px 16px;
}

.tip-title {
  margin: 0 0 6px;
  font-weight: 700;
}

.tip-text {
  margin: 0;
  color: var(--soft-ink);
  line-height: 1.5;
}

.layout {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 24px;
}

.card {
  background: var(--card);
  border-radius: 20px;
  padding: 24px;
  box-shadow: var(--shadow);
}

.card h2 {
  margin: 0 0 12px;
}

.plan-text {
  margin: 0 0 14px;
  color: var(--soft-ink);
  line-height: 1.55;
}

.plan-text:last-child {
  margin-bottom: 0;
}

.bullets {
  padding-left: 20px;
  color: var(--soft-ink);
  margin: 0 0 16px;
  line-height: 1.55;
}

.details > summary {
  cursor: pointer;
  font-weight: 700;
  color: #1b3f9b;
  list-style: none;
  padding: 10px 12px;
  border: 2px solid #e3e8f4;
  border-radius: 14px;
}

.details[open] > summary {
  border-color: #c4d0f4;
  background: #f4f7ff;
}

.terms {
  margin: 12px 0 0;
  padding-left: 18px;
  color: var(--soft-ink);
  line-height: 1.55;
}

.formula-sheet {
  margin-top: 12px;
  display: grid;
  gap: 10px;
}

.formula-group {
  border: 2px solid #e3e8f4;
  border-radius: 12px;
  background: #fbfcff;
  padding: 10px 12px;
}

.formula-group-title {
  margin: 0 0 8px;
  font-weight: 800;
  color: #1a1d2a;
  font-size: 0.92rem;
}

.formula-list {
  margin: 0;
  padding-left: 16px;
  color: var(--soft-ink);
  line-height: 1.45;
}

.formula-list li + li {
  margin-top: 6px;
}

.formula-line {
  font-family: "Avenir Next", "Avenir", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  letter-spacing: 0.01em;
}

.formula-frac {
  display: inline-grid;
  grid-template-rows: auto auto;
  text-align: center;
  vertical-align: middle;
  margin: 0 0.2em;
}

.formula-frac .num {
  border-bottom: 2px solid #2457d6;
  padding: 0 0.15em 0.05em;
  line-height: 1.05;
}

.formula-frac .den {
  padding: 0.05em 0.15em 0;
  line-height: 1.05;
}

.formula-empty {
  margin: 10px 0 0;
  color: var(--soft-ink);
}

.terms a {
  color: #1b3f9b;
  text-decoration: none;
}

.terms a:hover {
  text-decoration: underline;
}

.recommended-list {
  list-style: decimal;
}

.question {
  font-size: 1.05rem;
  margin: 0 0 12px;
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 8px;
}

.phase-badge,
.objective-badge {
  margin: 0;
  padding: 5px 10px;
  border-radius: 999px;
  border: 2px solid #d7dfee;
  font-size: 0.82rem;
  font-weight: 700;
  color: #1b3f9b;
  background: #f4f7ff;
}

.worked-example {
  margin: 0 0 12px;
  padding: 12px 14px;
  border: 2px solid #d8e4ff;
  border-radius: 14px;
  background: #f6f9ff;
  color: var(--soft-ink);
  line-height: 1.5;
}

.worked-example strong {
  color: #1b3f9b;
}

.parabola-coach {
  margin: 0 0 12px;
  padding: 14px;
  border: 2px solid #d8e4ff;
  border-radius: 14px;
  background: #f8fbff;
}

.parabola-coach h3 {
  margin: 0 0 8px;
  font-size: 1rem;
  color: #1b3f9b;
}

.parabola-subhead {
  margin: 0 0 10px;
  color: var(--soft-ink);
}

.parabola-formula-edit {
  display: grid;
  grid-template-columns: 120px 1fr auto;
  gap: 8px;
  align-items: center;
  margin: 0 0 12px;
}

.parabola-formula-edit label {
  color: var(--soft-ink);
  font-weight: 700;
  font-size: 0.9rem;
}

.parabola-formula-edit input {
  width: 100%;
  padding: 8px 10px;
  border-radius: 10px;
  border: 2px solid #d7dfee;
  background: #fff;
  font-size: 0.95rem;
}

.parabola-formula-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 0 0 12px;
}

.parabola-steps {
  margin: 0 0 12px;
  padding-left: 20px;
  color: var(--soft-ink);
  line-height: 1.45;
}

.parabola-table-wrap {
  overflow-x: auto;
  margin: 0 0 12px;
}

.parabola-table {
  border-collapse: collapse;
  min-width: 520px;
  width: 100%;
  background: #fff;
  border: 2px solid #d7dfee;
  border-radius: 12px;
}

.parabola-table th,
.parabola-table td {
  border: 1px solid #dfe5f5;
  text-align: center;
  padding: 6px 8px;
}

.parabola-table th {
  font-weight: 800;
  color: #1a1d2a;
  background: #f2f6ff;
}

.parabola-table input {
  width: 64px;
  padding: 6px 8px;
  border: 2px solid #d7dfee;
  border-radius: 10px;
  text-align: center;
  font-size: 0.95rem;
}

.parabola-checks {
  display: grid;
  grid-template-columns: minmax(150px, 1.4fr) minmax(90px, 1fr) minmax(150px, 1.4fr) minmax(110px, 1fr);
  gap: 8px;
  align-items: center;
  margin: 0 0 12px;
}

.parabola-checks label {
  color: var(--soft-ink);
  font-weight: 700;
  font-size: 0.9rem;
}

.parabola-checks input,
.parabola-checks select {
  width: 100%;
  padding: 8px 10px;
  border-radius: 10px;
  border: 2px solid #d7dfee;
  background: #fff;
  font-size: 0.95rem;
}

.parabola-coach-feedback {
  margin: 8px 0 0;
  padding: 10px 12px;
  border-radius: 12px;
  border: 2px solid;
  line-height: 1.45;
}

.parabola-coach-feedback p {
  margin: 0;
}

.parabola-coach-feedback ul {
  margin: 8px 0 0;
  padding-left: 18px;
}

.parabola-coach-feedback.good {
  background: #e7f8ef;
  border-color: #8ad5a8;
  color: #0f4a2b;
}

.parabola-coach-feedback.bad {
  background: #fff0f0;
  border-color: #f1a4a4;
  color: #6a1111;
}

.parabola-point-check {
  margin: 0 0 12px;
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.parabola-point-prompt {
  margin: 0;
  color: var(--soft-ink);
  font-weight: 700;
}

.parabola-point-check label {
  color: var(--soft-ink);
  font-size: 0.9rem;
  font-weight: 700;
}

.parabola-point-check input,
.parabola-point-check select {
  min-width: 140px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 2px solid #d7dfee;
  background: #fff;
  font-size: 0.95rem;
}

.parabola-preview {
  margin: 12px 0 0;
  border: 2px solid #d7dfee;
  border-radius: 12px;
  background: #ffffff;
  padding: 10px;
}

.parabola-preview-title {
  margin: 0 0 8px;
  color: var(--soft-ink);
  font-size: 0.9rem;
  font-weight: 700;
}

.parabola-preview svg {
  width: 100%;
  height: auto;
  display: block;
}

@media (max-width: 900px) {
  .parabola-formula-edit {
    grid-template-columns: 1fr;
  }

  .parabola-checks {
    grid-template-columns: 1fr 1fr;
  }
}

.mcq {
  display: grid;
  gap: 10px;
  margin-bottom: 14px;
}

.option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border: 2px solid var(--border);
  border-radius: 14px;
  cursor: pointer;
  background: #fff;
}

.option input {
  margin-top: 3px;
}

.option:hover {
  border-color: #b8c8f6;
}

.input input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 14px;
  border: 2px solid var(--border);
  font-size: 1rem;
}

.feedback {
  margin: 12px 0 0;
  padding: 12px 14px;
  border-radius: 14px;
  border: 2px solid;
  line-height: 1.5;
}

.feedback.good {
  background: #e7f8ef;
  border-color: #8ad5a8;
  color: #0f4a2b;
}

.feedback.bad {
  background: #fff0f0;
  border-color: #f1a4a4;
  color: #6a1111;
}

.error-loop {
  margin: 10px 0 0;
  padding: 12px 14px;
  border-radius: 14px;
  border: 2px solid #f2d08d;
  background: #fff7e6;
  color: #6b4d10;
  line-height: 1.45;
  white-space: pre-line;
}

.source-evidence {
  margin: 10px 0 0;
  padding: 12px 14px;
  border-radius: 14px;
  border: 2px solid #d7dfee;
  background: #f8f9fd;
  color: var(--soft-ink);
  line-height: 1.45;
}

.source-evidence a {
  color: #1b3f9b;
}

.calc-widget {
  margin: 12px 0 0;
  padding: 12px 14px;
  border-radius: 14px;
  border: 2px solid #c9d7f7;
  background: #f4f7ff;
}

.calc-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.calc-title {
  margin: 0;
  font-weight: 800;
  color: #1b3f9b;
}

.calc-clear {
  appearance: none;
  border: 2px solid #c9d7f7;
  background: #ffffff;
  color: #1b3f9b;
  border-radius: 10px;
  padding: 6px 10px;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
}

.calc-clear:hover {
  background: #eef2fb;
}

.calc-input {
  width: 100%;
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 2px solid #d7dfee;
  background: #fff;
  font-size: 1rem;
}

.calc-result {
  margin: 10px 0 0;
  font-weight: 700;
  color: #1a1d2a;
}

.calc-result.bad {
  color: #8a1f1f;
}

.calc-hint {
  margin: 6px 0 0;
  color: var(--soft-ink);
  font-size: 0.9rem;
}

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

.btn {
  appearance: none;
  border: none;
  background: var(--accent);
  color: #fff;
  border-radius: 14px;
  padding: 12px 16px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.05s ease, background 0.2s ease;
}

.btn:hover {
  background: var(--accent-dark);
}

.btn:active {
  transform: translateY(1px);
}

.btn.secondary {
  background: #eef2fb;
  color: #1b3f9b;
  border: 2px solid #c9d7f7;
}

.btn.secondary:hover {
  background: #e3ebff;
}

.btn.ghost {
  background: transparent;
  border: 2px solid #c9d7f7;
  color: #1b3f9b;
}

.btn.ghost:hover {
  background: #f4f7ff;
}

.card-face {
  margin: 0;
  padding: 16px 18px;
  border-radius: 16px;
  border: 2px solid var(--border);
  background: #fff;
  min-height: 110px;
  display: flex;
  align-items: center;
  line-height: 1.5;
  font-size: 1.05rem;
}

.card-face.back {
  background: #f4f7ff;
}

.card-explain {
  margin-top: 12px;
  color: var(--soft-ink);
  line-height: 1.5;
}

.footer {
  margin-top: 28px;
  color: var(--soft-ink);
  text-align: center;
}

.footer code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 0.92rem;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
