:root {
  --bg: #f7f5ef;
  --surface: #ffffff;
  --surface-strong: #111827;
  --text: #17202f;
  --muted: #667085;
  --line: #d9dee8;
  --math: #2563eb;
  --logic: #0f766e;
  --accent: #c2410c;
  --shadow: 0 18px 55px rgba(17, 24, 39, 0.11);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  line-height: 1.5;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
select {
  font: inherit;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 16px clamp(18px, 4vw, 56px);
  background: rgba(247, 245, 239, 0.92);
  border-bottom: 1px solid rgba(217, 222, 232, 0.8);
  backdrop-filter: blur(14px);
}

.brand,
.top-nav,
.hero-actions,
.filter-bar,
.exam-controls {
  display: flex;
  align-items: center;
}

.brand {
  gap: 10px;
  font-weight: 800;
}

.brand-logo,
.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 8px;
}

.brand-logo {
  display: block;
  object-fit: contain;
}

.brand-mark {
  display: grid;
  place-items: center;
  color: #ffffff;
  background: var(--surface-strong);
}

.top-nav {
  gap: 22px;
  color: var(--muted);
  font-size: 0.94rem;
}

.top-nav a:hover,
.site-footer a:hover {
  color: var(--text);
}

.header-cta,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 700;
}

.button.primary,
.header-cta {
  color: #ffffff;
  background: var(--surface-strong);
}

.button.secondary {
  color: var(--text);
  background: #ffffff;
  border-color: var(--line);
}

.button.danger {
  color: #991b1b;
  background: #fff1f2;
  border-color: #fecdd3;
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.68;
}

.section {
  width: min(1160px, calc(100% - 36px));
  margin: 0 auto;
  padding: 78px 0;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(330px, 430px);
  gap: clamp(28px, 5vw, 68px);
  align-items: center;
  min-height: calc(100vh - 74px);
  padding-top: 46px;
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1 {
  max-width: 860px;
  margin-bottom: 20px;
  font-size: clamp(2.35rem, 6vw, 5.35rem);
  line-height: 0.98;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 14px;
  font-size: clamp(1.75rem, 3vw, 3rem);
  line-height: 1.08;
  letter-spacing: 0;
}

h3 {
  margin-bottom: 8px;
  line-height: 1.2;
}

.hero-text,
.section-copy {
  max-width: 690px;
  color: var(--muted);
  font-size: 1.06rem;
}

.hero-actions {
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 30px;
}

.hero-mascot {
  position: relative;
  display: grid;
  align-items: end;
  min-height: 560px;
}

.hero-logo-face {
  width: min(100%, 520px);
  justify-self: center;
  filter: drop-shadow(0 22px 32px rgba(17, 24, 39, 0.16));
}

.speech-bubble {
  position: relative;
  z-index: 1;
  max-width: 390px;
  margin: 0 0 -34px;
  padding: 18px 20px;
  color: var(--text);
  background: #ffffff;
  border: 2px solid var(--surface-strong);
  border-radius: 8px;
  box-shadow: var(--shadow);
  font-size: 1.02rem;
  font-weight: 700;
}

.speech-bubble::before {
  position: absolute;
  right: 54px;
  bottom: -18px;
  width: 32px;
  height: 32px;
  content: "";
  background: #ffffff;
  border-right: 2px solid var(--surface-strong);
  border-bottom: 2px solid var(--surface-strong);
  transform: rotate(45deg);
}

.status-panel,
.package-card,
.question-card,
.exam-panel,
.disclaimer,
.topic-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.status-panel {
  padding: 24px;
  box-shadow: var(--shadow);
}

.panel-topline,
.meter-row,
.exam-header,
.package-topline,
.row-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.panel-topline {
  margin-bottom: 28px;
}

.panel-topline span,
.meter-row span,
.exam-header span,
.question-meta,
.topic-card small,
.site-footer {
  color: var(--muted);
  font-size: 0.88rem;
}

.meter-row {
  margin-top: 18px;
}

.meter {
  height: 10px;
  margin-top: 8px;
  overflow: hidden;
  background: #e8ecf3;
  border-radius: 999px;
}

.meter span {
  display: block;
  height: 100%;
  background: var(--math);
}

.meter.logic span {
  background: var(--logic);
}

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

.mini-grid div {
  padding: 14px;
  background: #f6f8fb;
  border-radius: 8px;
}

.mini-grid strong,
.mini-grid span {
  display: block;
}

.mini-grid strong {
  font-size: 1.35rem;
}

.mini-grid span {
  color: var(--muted);
  font-size: 0.84rem;
}

.section-heading {
  max-width: 820px;
  margin-bottom: 28px;
}

.package-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

.package-card {
  display: flex;
  flex-direction: column;
  min-height: 410px;
  padding: 24px;
}

.package-card.featured {
  border-color: rgba(194, 65, 12, 0.5);
  box-shadow: var(--shadow);
}

.package-topline span {
  padding: 5px 8px;
  color: #7c2d12;
  background: #ffedd5;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 800;
}

.package-card p,
.package-card li {
  color: var(--muted);
}

.price {
  margin: 4px 0 18px;
  font-size: 1.75rem;
}

.package-card ul {
  display: grid;
  gap: 10px;
  margin: 0 0 24px;
  padding-left: 18px;
}

.package-card .button {
  margin-top: auto;
}

.split-section {
  display: grid;
  grid-template-columns: minmax(280px, 0.75fr) minmax(0, 1.25fr);
  gap: 32px;
}

.segmented {
  display: inline-flex;
  padding: 4px;
  background: #e8ecf3;
  border-radius: 8px;
}

.segment {
  min-width: 92px;
  min-height: 38px;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 800;
}

.segment.active {
  color: var(--text);
  background: #ffffff;
}

.topic-list {
  display: grid;
  gap: 12px;
}

.topic-card {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  gap: 16px;
  padding: 18px;
}

.topic-number {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  color: #ffffff;
  background: var(--math);
  border-radius: 8px;
  font-weight: 900;
}

.topic-card.logic .topic-number {
  background: var(--logic);
}

.topic-card p {
  color: var(--muted);
}

.lesson-detail {
  margin-top: 12px;
}

.lesson-detail summary {
  color: var(--math);
  cursor: pointer;
  font-weight: 800;
}

.topic-card.logic .lesson-detail summary {
  color: var(--logic);
}

.lesson-body {
  margin-top: 12px;
  color: var(--text);
}

.rich-text {
  color: var(--text);
}

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

.rich-text p,
.rich-text ul,
.rich-text ol,
.rich-text table,
.rich-text pre,
.rich-text blockquote {
  margin: 0 0 14px;
}

.rich-text ul,
.rich-text ol {
  padding-left: 1.35rem;
}

.rich-text img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 18px 0;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.rich-text table {
  display: block;
  width: 100%;
  overflow-x: auto;
  border-collapse: collapse;
}

.rich-text th,
.rich-text td {
  padding: 10px 12px;
  text-align: left;
  vertical-align: top;
  border: 1px solid var(--line);
}

.rich-text th {
  background: #f0f3f8;
  font-weight: 900;
}

.rich-text blockquote {
  padding: 12px 14px;
  color: var(--muted);
  background: #f8fafc;
  border-left: 4px solid var(--accent);
  border-radius: 6px;
}

.rich-text code {
  padding: 2px 5px;
  background: #eef2f7;
  border-radius: 5px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 0.92em;
}

.rich-text pre {
  padding: 14px;
  overflow-x: auto;
  background: #111827;
  border-radius: 8px;
}

.rich-text pre code {
  padding: 0;
  color: #f8fafc;
  background: transparent;
}

.question-prompt {
  font-size: 1.08rem;
  font-weight: 700;
}

.filter-bar {
  gap: 10px;
}

select {
  min-height: 42px;
  padding: 0 36px 0 12px;
  color: var(--text);
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

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

.question-card {
  padding: 20px;
}

.math-inline,
.katex {
  max-width: 100%;
}

.katex {
  white-space: normal;
}

.katex-html {
  overflow-wrap: anywhere;
}

.question-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.question-meta span {
  padding: 4px 8px;
  background: #f0f3f8;
  border-radius: 999px;
}

.choices,
.exam-question > div {
  display: grid;
  gap: 8px;
}

.choice,
.exam-choice {
  width: 100%;
  padding: 11px 12px;
  text-align: left;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.solution-toggle {
  margin-top: 14px;
  padding: 0;
  color: var(--math);
  background: transparent;
  border: 0;
  cursor: pointer;
  font-weight: 800;
}

.solution {
  margin: 12px 0 0;
  padding: 14px;
  background: #f8fafc;
  border-left: 4px solid var(--math);
  border-radius: 6px;
}

.solution.pending,
.open-answer-preview {
  color: var(--muted);
  background: #fff7ed;
  border-color: #fed7aa;
}

.paywall-box,
.notice {
  display: grid;
  gap: 8px;
  margin-top: 14px;
  padding: 14px;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.paywall-box span,
.notice {
  color: var(--muted);
}

.paywall-box .button {
  width: fit-content;
  margin-top: 4px;
}

.paywall-box.full-span {
  grid-column: 1 / -1;
}

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

.notice.error {
  color: #991b1b;
  background: #fff1f2;
  border-color: #fecdd3;
}

.simulator-section {
  display: grid;
  grid-template-columns: minmax(280px, 0.7fr) minmax(0, 1.3fr);
  gap: 28px;
}

.exam-controls {
  gap: 10px;
  margin-top: 24px;
}

.exam-panel {
  min-height: 360px;
  padding: 20px;
}

.empty-state {
  display: grid;
  min-height: 180px;
  place-content: center;
  gap: 8px;
  color: var(--muted);
  text-align: center;
}

.empty-state strong {
  color: var(--text);
}

.exam-header {
  margin-bottom: 18px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.exam-header strong,
.exam-header span {
  display: block;
}

.exam-questions,
.exam-review {
  display: grid;
  gap: 14px;
}

.exam-question,
.review-card {
  padding: 16px;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.exam-question > span,
.review-card > span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
  text-transform: uppercase;
}

.exam-choice {
  display: flex;
  gap: 10px;
  cursor: pointer;
}

.full-width {
  width: 100%;
  margin-top: 16px;
}

.review-card.correct {
  border-color: rgba(15, 118, 110, 0.35);
}

.review-card.incorrect {
  border-color: rgba(194, 65, 12, 0.35);
}

.disclaimer {
  padding: 28px;
}

.confirmation-section {
  min-height: calc(100vh - 74px);
  align-content: center;
}

.disclaimer p:last-child {
  margin-bottom: 0;
  color: var(--muted);
}

.site-footer {
  display: flex;
  justify-content: center;
  gap: 18px;
  padding: 30px 18px 44px;
}

.admin-hero {
  min-height: auto;
  padding-bottom: 36px;
}

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

.admin-grid {
  display: grid;
  grid-template-columns: minmax(280px, 0.8fr) minmax(0, 1.2fr);
  gap: 24px;
  align-items: start;
  padding-top: 28px;
}

.admin-list,
.admin-form {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.admin-list {
  position: sticky;
  top: 88px;
  display: grid;
  gap: 12px;
  max-height: calc(100vh - 120px);
  padding: 18px;
  overflow: auto;
}

.admin-list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.admin-list-header h2,
.admin-form h2 {
  margin-bottom: 0;
  font-size: 1.35rem;
}

.admin-items {
  display: grid;
  gap: 8px;
}

.admin-item {
  display: grid;
  gap: 4px;
  width: 100%;
  padding: 12px;
  color: var(--text);
  text-align: left;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
}

.admin-item.active {
  border-color: var(--accent);
  box-shadow: inset 4px 0 0 var(--accent);
}

.admin-item span,
.admin-item small {
  color: var(--muted);
}

.admin-item span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-form {
  display: grid;
  gap: 16px;
  padding: 22px;
}

.admin-form label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
}

.dashboard-shell {
  width: min(1280px, calc(100% - 36px));
  margin: 0 auto;
  padding: 34px 0 78px;
}

.dashboard-loading,
.dashboard-locked,
.login-section {
  min-height: calc(100vh - 74px);
  align-content: center;
}

.dashboard-top {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  padding: 26px 0 18px;
}

.dashboard-top h1 {
  margin-bottom: 0;
  font-size: clamp(2rem, 4vw, 3.8rem);
}

.access-pill {
  padding: 8px 12px;
  color: #064e3b;
  background: #d1fae5;
  border: 1px solid #a7f3d0;
  border-radius: 999px;
  font-weight: 900;
}

.dashboard-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 18px;
  padding: 6px;
  background: #e8ecf3;
  border-radius: 8px;
}

.dashboard-tab {
  min-height: 42px;
  padding: 0 16px;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 900;
}

.dashboard-tab.active {
  color: var(--text);
  background: #ffffff;
}

.dashboard-panel {
  min-height: 560px;
}

.learning-layout {
  display: grid;
  grid-template-columns: minmax(250px, 320px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.course-outline,
.lesson-reader,
.login-card,
.exam-placeholder {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.course-outline {
  position: sticky;
  top: 92px;
  display: grid;
  gap: 16px;
  max-height: calc(100vh - 116px);
  padding: 16px;
  overflow: auto;
}

.outline-group {
  display: grid;
  gap: 8px;
}

.outline-group > span,
.lesson-kicker,
.answer-label,
.pending-solution {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 900;
  text-transform: uppercase;
}

.outline-item {
  display: grid;
  gap: 4px;
  width: 100%;
  padding: 12px;
  color: var(--text);
  text-align: left;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
}

.outline-item.active {
  border-color: var(--accent);
  box-shadow: inset 4px 0 0 var(--accent);
}

.outline-item small,
.lesson-summary {
  color: var(--muted);
}

.lesson-reader {
  padding: clamp(18px, 3vw, 32px);
}

.lesson-reader h2 {
  font-size: clamp(1.65rem, 2.4vw, 2.65rem);
}

.lesson-body {
  margin-top: 18px;
  padding: 18px;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.lesson-exercises {
  display: grid;
  gap: 14px;
  margin-top: 34px;
}

.question-workspace {
  display: grid;
  gap: 18px;
}

.dashboard-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.dashboard-question-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.practice-card {
  display: grid;
  gap: 12px;
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.practice-card.compact {
  background: #ffffff;
}

.answer-label {
  margin-bottom: -4px;
}

.answer-input {
  min-height: 76px;
}

.symbol-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.symbol-button {
  min-width: 36px;
  min-height: 34px;
  padding: 0 9px;
  color: var(--text);
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
  font-weight: 800;
}

.symbol-button:hover,
.outline-item:hover,
.choice:hover {
  border-color: var(--accent);
}

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

.pending-solution {
  text-transform: none;
}

.attempt-count {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 800;
}

.answer-feedback {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-weight: 900;
}

.answer-feedback.correct {
  color: #065f46;
  background: #d1fae5;
  border-color: #a7f3d0;
}

.answer-feedback.incorrect {
  color: #991b1b;
  background: #fff1f2;
  border-color: #fecdd3;
}

.answer-feedback.neutral {
  color: var(--muted);
  background: #f8fafc;
}

.answer-explanation {
  border-left-color: var(--logic);
}

.exam-placeholder {
  min-height: 420px;
  padding: clamp(22px, 4vw, 46px);
  align-content: center;
}

.login-card {
  display: grid;
  gap: 14px;
  max-width: 520px;
  margin-top: 28px;
  padding: 22px;
}

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

.login-card label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-weight: 900;
}

.login-card p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.field {
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  color: var(--text);
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
  font-weight: 500;
}

textarea.field {
  resize: vertical;
}

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

.checkbox-row {
  display: flex !important;
  grid-template-columns: none !important;
  align-items: center;
  gap: 10px !important;
  color: var(--text) !important;
}

.checkbox-row input {
  width: 18px;
  height: 18px;
}

@media (max-width: 900px) {
  .site-header {
    align-items: flex-start;
  }

  .top-nav {
    display: none;
  }

  .hero,
  .split-section,
  .simulator-section,
  .admin-grid,
  .learning-layout {
    grid-template-columns: 1fr;
  }

  .admin-list,
  .course-outline {
    position: static;
    max-height: none;
  }

  .package-grid,
  .question-bank,
  .dashboard-question-list {
    grid-template-columns: 1fr;
  }

  .row-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .dashboard-filters {
    justify-content: flex-start;
  }
}

@media (max-width: 560px) {
  .site-header {
    padding: 12px 16px;
  }

  .header-cta {
    display: none;
  }

  .section {
    width: min(100% - 28px, 1160px);
    padding: 54px 0;
  }

  .hero {
    min-height: auto;
    padding-top: 34px;
  }

  .hero-mascot {
    min-height: auto;
  }

  .speech-bubble {
    margin-bottom: -18px;
  }

  .filter-bar,
  .exam-controls,
  .hero-actions,
  .admin-actions,
  .form-row,
  .dashboard-tabs,
  .dashboard-filters,
  .answer-actions {
    align-items: stretch;
    grid-template-columns: 1fr;
    flex-direction: column;
    width: 100%;
  }

  .dashboard-shell {
    width: min(100% - 28px, 1280px);
    padding-top: 22px;
  }

  .dashboard-top {
    align-items: flex-start;
    flex-direction: column;
  }

  select,
  .button,
  .dashboard-tab {
    width: 100%;
  }

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