:root {
  --bg: #f4efe6;
  --paper: #fffdf8;
  --paper-strong: #fffaf0;
  --ink: #1f2430;
  --muted: #60697a;
  --line: #d8d0c0;
  --accent: #0d5c63;
  --accent-soft: #dff2ef;
  --danger: #b33a3a;
  --danger-soft: #fae4e4;
  --success: #1f7a57;
  --success-soft: #e4f6ee;
  --gold-soft: #f3ead5;
  --shadow: 0 14px 32px rgba(31, 36, 48, 0.09);
  --radius: 20px;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  position: relative;
  min-height: 100vh;
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(circle at top left, rgba(13, 92, 99, 0.14), transparent 28%),
    radial-gradient(circle at right, rgba(179, 58, 58, 0.1), transparent 20%),
    var(--bg);
}

button,
input {
  font: inherit;
}

a {
  color: inherit;
}

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

.hidden {
  display: none !important;
}

.page-shell {
  max-width: 1480px;
  margin: 0 auto;
  padding: 24px;
}

.page-shell-centered {
  max-width: 980px;
  min-height: 100vh;
  display: grid;
  align-items: center;
}

.error-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(260px, 0.8fr);
  gap: 24px;
  align-items: stretch;
}

.error-panel {
  background: var(--paper);
  border: 1px solid rgba(216, 208, 192, 0.8);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px;
}

.error-code {
  margin: 0 0 10px;
  font-size: 0.82rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--danger);
  font-weight: 800;
}

.error-title {
  max-width: 12ch;
}

.error-copy {
  max-width: 54ch;
  color: var(--muted);
  line-height: 1.65;
}

.error-actions {
  margin-top: 24px;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.error-card {
  background: linear-gradient(165deg, #0d5c63, #15444b);
  color: white;
}

.error-card .metric-label,
.error-card .metric-subtle {
  color: rgba(255, 255, 255, 0.76);
}

.error-card .metric-value {
  margin-bottom: 12px;
}

.site-footer {
  margin-top: 36px;
  padding: 22px 24px 8px;
  color: var(--muted);
  text-align: center;
}

.site-footer-links {
  margin: 0 0 34px;
  display: flex;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
}

.site-footer-links a {
  color: rgba(13, 92, 99, 0.8);
  text-decoration: none;
  font-weight: 600;
}

.site-footer-links a:hover {
  text-decoration: underline;
}

.site-footer-credit,
.site-footer-guided,
.site-footer-status,
.site-footer-note {
  margin: 0;
  line-height: 1.6;
}

.site-footer-credit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--ink);
  font-weight: 400;
}

.site-footer-guided,
.site-footer-status {
  font-size: 0.95rem;
}

.site-footer-guided a {
  color: rgba(13, 92, 99, 0.72);
  text-decoration: none;
}

.site-footer-guided a:hover {
  text-decoration: underline;
}

.site-footer-status {
  margin-top: 18px;
  margin-bottom: 18px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}

.site-footer-note {
  margin: 0 auto 0;
  max-width: 760px;
  font-size: 0.95rem;
}

.legal-layout {
  display: grid;
  gap: 22px;
}

.legal-card {
  background: var(--paper);
  border: 1px solid rgba(216, 208, 192, 0.8);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
}

.legal-card h2,
.legal-card h3 {
  margin-bottom: 12px;
}

.legal-card p,
.legal-card li {
  color: var(--muted);
  line-height: 1.65;
}

.legal-card ul {
  margin: 0;
  padding-left: 20px;
}

.legal-card a {
  color: var(--accent);
}

.footer-heart {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  color: rgba(13, 92, 99, 0.72);
}

.footer-heart svg {
  width: 100%;
  height: 100%;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.hero {
  display: grid;
  grid-template-columns: 1.6fr 0.7fr;
  gap: 20px;
  margin-bottom: 24px;
}

.hero-home {
  margin-bottom: 30px;
}

.hero-copy,
.hero-card,
.panel,
.question-card,
.navigator,
.result-summary,
.catalog-card {
  background: var(--paper);
  border: 1px solid rgba(216, 208, 192, 0.8);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.hero-copy {
  padding: 28px;
}

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

h1 {
  margin-bottom: 12px;
  font-size: clamp(2rem, 4vw, 3.5rem);
  line-height: 1.04;
}

h2 {
  margin-bottom: 10px;
}

.hero-text,
.panel-copy,
.metric-subtle,
.catalog-copy,
.section-copy {
  color: var(--muted);
  line-height: 1.55;
}

.hero-card {
  padding: 24px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  background: linear-gradient(165deg, #0d5c63, #15444b);
  color: white;
}

.metric-label {
  margin-bottom: 8px;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  opacity: 0.75;
}

.metric-value {
  margin: 0 0 8px;
  font-size: 2.4rem;
  font-weight: 800;
}

.hero-card .metric-subtle {
  color: rgba(247, 250, 248, 0.82);
}

.home-layout {
  display: grid;
  gap: 28px;
}

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

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

.subject-card {
  text-align: left;
  padding: 22px;
  background: var(--paper);
  border: 1px solid rgba(216, 208, 192, 0.8);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 18px;
  cursor: pointer;
  transition:
    transform 160ms ease,
    border-color 160ms ease,
    box-shadow 160ms ease,
    background 160ms ease;
  height: 100%;
  color: inherit;
  text-decoration: none;
}

.subject-card-top,
.semester-card-top {
  flex: 1;
}

.semester-card {
  text-align: left;
  padding: 20px;
  background: var(--paper);
  border: 1px solid rgba(216, 208, 192, 0.8);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 16px;
  cursor: pointer;
  color: inherit;
  text-decoration: none;
  transition:
    transform 160ms ease,
    border-color 160ms ease,
    box-shadow 160ms ease,
    background 160ms ease;
}

.semester-card:hover {
  transform: translateY(-2px);
  border-color: rgba(13, 92, 99, 0.35);
}

.semester-card-active {
  border: 2px solid var(--accent);
  background: linear-gradient(180deg, #f7fffd, var(--paper));
}

.semester-card-soon {
  background: linear-gradient(180deg, #fffdf8, #f8f4eb);
}

.subject-card:hover {
  transform: translateY(-2px);
  border-color: rgba(13, 92, 99, 0.35);
}

.subject-card-active {
  border: 2px solid var(--accent);
  background: linear-gradient(180deg, #f7fffd, var(--paper));
}

.subject-card-soon {
  background: linear-gradient(180deg, #fffdf8, #f8f4eb);
}

.subject-card-top h3 {
  margin-bottom: 10px;
}

.subject-card-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  color: var(--muted);
  font-size: 0.95rem;
}

.subject-card-meta strong {
  color: var(--ink);
  font-size: 0.95rem;
}

.catalog-section {
  display: grid;
  gap: 18px;
}

.section-heading {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 420px);
  gap: 18px;
  align-items: end;
}

.catalog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 18px;
}

#interactiveGrid.catalog-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.catalog-grid-compact {
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.subject-empty {
  padding: 24px;
  border-radius: var(--radius);
  border: 1px dashed rgba(13, 92, 99, 0.28);
  background: rgba(223, 242, 239, 0.46);
  color: var(--muted);
}

.subject-empty h3 {
  color: var(--ink);
  margin-bottom: 10px;
}

.catalog-card {
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.catalog-card-compact {
  gap: 14px;
}

.catalog-card-top h3 {
  margin-bottom: 10px;
}

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

.tag-chip {
  display: inline-flex;
  align-items: center;
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--gold-soft);
  color: #6b5731;
  font-size: 0.82rem;
  font-weight: 700;
}

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

.catalog-stat {
  padding: 14px 12px;
  border-radius: 16px;
  background: #fff;
  border: 1px solid var(--line);
}

.catalog-stat span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.85rem;
}

.catalog-stat strong {
  font-size: 1.15rem;
}

.catalog-actions,
.result-actions,
.hero-links {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.mode-stack {
  display: grid;
  gap: 8px;
}

.block-picker {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid rgba(216, 208, 192, 0.8);
}

.panel-heading-inline {
  align-items: center;
}

.panel-heading-inline h3 {
  margin: 0;
  font-size: 1.2rem;
}

.primary-btn,
.secondary-btn,
.ghost-btn,
.primary-link,
.ghost-link,
.back-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.15s ease, opacity 0.15s ease, background 0.15s ease;
}

.primary-btn:hover,
.secondary-btn:hover,
.ghost-btn:hover,
.primary-link:hover,
.ghost-link:hover,
.back-link:hover {
  transform: translateY(-1px);
}

.primary-btn,
.primary-link {
  padding: 12px 18px;
  background: var(--accent);
  color: white;
  font-weight: 700;
}

.secondary-btn {
  padding: 11px 16px;
  background: #ecf2f5;
  color: var(--ink);
  font-weight: 700;
}

.ghost-btn,
.ghost-link {
  padding: 10px 14px;
  background: transparent;
  color: var(--accent);
  border: 1px solid rgba(13, 92, 99, 0.25);
}

.back-link {
  margin-bottom: 18px;
  padding: 10px 14px;
  background: rgba(13, 92, 99, 0.08);
  color: var(--accent);
  width: fit-content;
}

.layout {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}

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

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.panel,
.result-summary,
.empty-state,
.navigator,
.question-card {
  padding: 22px;
}

.panel-accent {
  background: linear-gradient(180deg, #f8fcfb, #eef8f7);
}

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

.block-list {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.block-checkbox {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
}

.block-checkbox input {
  margin-top: 3px;
}

.block-meta strong {
  display: block;
  margin-bottom: 4px;
}

.block-meta span {
  color: var(--muted);
  font-size: 0.92rem;
}

.option-row {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 10px;
}

.empty-state {
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  padding: 6px 4px 0;
  background: transparent;
  border: none;
  box-shadow: none;
}

.sticky-topbar {
  position: sticky;
  top: 14px;
  z-index: 4;
  display: flex;
  gap: 18px;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  padding: 18px 20px;
  border-radius: var(--radius);
  background: rgba(255, 253, 248, 0.92);
  border: 1px solid rgba(216, 208, 192, 0.8);
  backdrop-filter: blur(16px);
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}

.topbar-label {
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 0.85rem;
}

.topbar-stats {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.stat-chip {
  padding: 10px 14px;
  border-radius: 999px;
  background: var(--accent-soft);
  display: flex;
  gap: 8px;
  align-items: center;
}

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

.progress-track {
  height: 12px;
  background: #e7dfd0;
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 18px;
}

.progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #0d5c63, #1f7a57);
  transition: width 0.25s ease;
}

.question-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
}

.block-badge,
.question-badge {
  display: inline-flex;
  align-items: center;
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 0.84rem;
  font-weight: 700;
}

.block-badge {
  background: var(--accent-soft);
  color: var(--accent);
}

.question-badge {
  background: #efe8dc;
  color: #735e38;
}

.question-text {
  font-size: clamp(1.1rem, 2vw, 1.45rem);
  line-height: 1.4;
  margin-bottom: 20px;
}

.options-container {
  display: grid;
  gap: 14px;
}

.option-card {
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 14px 16px;
  display: flex;
  gap: 14px;
  align-items: flex-start;
  background: #fff;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.option-card:hover {
  border-color: rgba(13, 92, 99, 0.5);
}

.option-card.is-correct {
  border-color: rgba(31, 122, 87, 0.5);
  background: var(--success-soft);
}

.option-card.is-wrong {
  border-color: rgba(179, 58, 58, 0.45);
  background: var(--danger-soft);
}

.option-card input {
  margin-top: 4px;
}

.option-letter {
  min-width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #f3ede1;
  color: #725a32;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}

.navigator {
  margin-top: 18px;
}

.study-feedback {
  margin-top: 18px;
  padding: 16px 18px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: #fffcf5;
}

.study-feedback.correct {
  border-color: rgba(31, 122, 87, 0.45);
  background: var(--success-soft);
}

.study-feedback.incorrect {
  border-color: rgba(179, 58, 58, 0.45);
  background: var(--danger-soft);
}

.study-explanation {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid rgba(31, 36, 48, 0.12);
}

.study-explanation-lead {
  font-weight: 700;
  color: var(--ink);
}

.study-tip {
  margin-top: 14px;
  padding: 14px 16px;
  border-radius: 16px;
  background: rgba(13, 92, 99, 0.08);
  border: 1px solid rgba(13, 92, 99, 0.16);
}

.study-tip span {
  display: block;
  margin-bottom: 6px;
  font-weight: 800;
  color: var(--accent);
  letter-spacing: 0.02em;
}

.study-tip p {
  margin: 0;
  line-height: 1.6;
  color: var(--ink);
}

.study-sources {
  margin-top: 12px;
}

.study-sources span {
  display: block;
  margin-bottom: 8px;
  font-weight: 700;
  color: var(--ink);
}

.study-sources ul {
  margin: 0;
  padding-left: 20px;
}

.study-sources li + li {
  margin-top: 6px;
}

.study-sources a {
  color: var(--accent);
  text-decoration: none;
}

.study-sources a:hover {
  text-decoration: underline;
}

.question-nav {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(52px, 1fr));
  gap: 10px;
}

.nav-chip {
  border: 1px solid var(--line);
  background: white;
  border-radius: 14px;
  height: 46px;
  cursor: pointer;
  font-weight: 700;
}

.nav-chip.is-current {
  background: var(--accent);
  color: #ffffff;
  border-color: var(--accent);
}

.nav-chip.is-answered {
  background: #f0faf4;
  border-color: rgba(31, 122, 87, 0.35);
}

.result-summary {
  margin-bottom: 20px;
  background: linear-gradient(135deg, #fffaf0, #fff);
}

.review-list {
  display: grid;
  gap: 14px;
}

.review-card {
  border: 1px solid var(--line);
  border-radius: 18px;
  overflow: hidden;
  background: #fff;
}

.review-header {
  padding: 16px 18px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  cursor: pointer;
  background: #fffcf5;
}

.review-header h3 {
  margin: 0;
  font-size: 1rem;
}

.review-status {
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 700;
}

.review-status.correct {
  background: var(--success-soft);
  color: var(--success);
}

.review-status.incorrect {
  background: var(--danger-soft);
  color: var(--danger);
}

.review-body {
  padding: 0 18px 18px;
}

.review-question {
  margin: 2px 0 16px;
  line-height: 1.5;
}

.review-option {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  margin-bottom: 10px;
  background: #fff;
}

.review-option.correct {
  border-color: rgba(31, 122, 87, 0.4);
  background: var(--success-soft);
}

.review-option.user-wrong {
  border-color: rgba(179, 58, 58, 0.4);
  background: var(--danger-soft);
}

.review-note {
  margin-top: 12px;
  color: var(--muted);
}

@media (max-width: 1080px) {
  .hero,
  .layout,
  .section-heading,
  .error-layout {
    grid-template-columns: 1fr;
  }

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

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

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

@media (max-width: 760px) {
  .page-shell {
    padding: 14px;
  }

  .error-panel {
    padding: 24px 18px;
  }

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

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

  #interactiveGrid.catalog-grid {
    grid-template-columns: 1fr;
  }

  .catalog-stats {
    grid-template-columns: 1fr;
  }

  .sticky-topbar {
    align-items: stretch;
  }

  .topbar-actions {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
  }

  .topbar-actions button {
    width: 100%;
  }
}
