:root {
  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-strong: #ffffff;
  --text: #18243a;
  --muted: #63718a;
  --primary: #3156d3;
  --primary-soft: rgba(49, 86, 211, 0.1);
  --success: #14845b;
  --danger: #c43d52;
  --warning: #e6a12a;
  --purple: #7650c9;
  --border: #e3e9f2;
  --shadow: 0 12px 32px rgba(26, 43, 76, 0.07);
  --bs-primary: #3156d3;
  --bs-primary-rgb: 49, 86, 211;
}

body.dark {
  --bg: #0b1220;
  --surface: #111c2e;
  --surface-strong: #152238;
  --text: #e7edf7;
  --muted: #a3b0c5;
  --primary: #91aaff;
  --primary-soft: rgba(145, 170, 255, 0.14);
  --success: #54d5a3;
  --danger: #ff8294;
  --warning: #ffc65c;
  --purple: #c1a1ff;
  --border: #26364f;
  --shadow: 0 16px 36px rgba(0, 0, 0, 0.2);
  --bs-primary: #91aaff;
  --bs-primary-rgb: 145, 170, 255;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: Inter, "Nirmala UI", Mangal, sans-serif;
  background:
    radial-gradient(ellipse at 90% 0%, rgba(49, 86, 211, 0.07), transparent 28rem),
    var(--bg);
  line-height: 1.65;
  transition: background-color 0.25s ease, color 0.25s ease;
}

body.dark {
  background:
    radial-gradient(ellipse at 90% 0%, rgba(75, 105, 205, 0.12), transparent 28rem),
    var(--bg);
}

.page-shell {
  min-height: 100vh;
}

.hero-section {
  position: relative;
  overflow: hidden;
  padding-block: 3.25rem !important;
  color: #fff;
  background:
    radial-gradient(ellipse at 88% 15%, rgba(96, 142, 255, 0.28), transparent 32rem),
    linear-gradient(125deg, #101a32 0%, #172a50 58%, #1a3561 100%);
}

.hero-section::after {
  position: absolute;
  right: -8rem;
  bottom: -16rem;
  width: 34rem;
  height: 34rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 50%;
  box-shadow: 0 0 0 3rem rgba(255, 255, 255, 0.025), 0 0 0 6rem rgba(255, 255, 255, 0.02);
  content: "";
  pointer-events: none;
}

.hero-section > .container-xl {
  position: relative;
  z-index: 1;
}

.hero-title {
  margin: 0;
  font-size: clamp(1.8rem, 3.8vw, 2.8rem);
  font-weight: 800;
  letter-spacing: -0.035em;
  line-height: 1.2;
}

.eyebrow {
  margin-bottom: 0.35rem;
  color: var(--primary);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.hero-section .eyebrow {
  color: #b8c9ff;
}

.hero-card {
  border: 1px solid rgba(255, 255, 255, 0.17);
  border-radius: 1.5rem;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.11), rgba(255, 255, 255, 0.045));
  backdrop-filter: blur(12px);
}

.hero-card h2 {
  max-width: 48rem;
  font-size: clamp(1.35rem, 2.6vw, 2rem);
  font-weight: 700;
  line-height: 1.4;
}

.hero-text {
  max-width: 48rem;
  color: rgba(244, 247, 255, 0.82);
  font-size: 1.03rem;
  line-height: 1.8;
}

.card-glow {
  box-shadow: 0 24px 60px rgba(6, 14, 32, 0.24);
}

.pattern-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.8rem;
}

.pattern-card,
.info-card,
.card-soft,
.paper-card,
.summary-card,
.question-card,
.review-card {
  border: 1px solid var(--border);
  border-radius: 1.15rem;
  background: var(--surface);
  box-shadow: var(--shadow);
  color: var(--text);
}

.pattern-card {
  min-height: 6.2rem;
  padding: 1rem 1.1rem;
  border-color: rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.09);
  color: #fff;
}

.pattern-card span {
  display: block;
  color: rgba(255, 255, 255, 0.76);
  font-size: 0.82rem;
}

.pattern-card strong {
  display: block;
  margin-top: 0.35rem;
  font-size: 1.08rem;
}

.info-card {
  height: 100%;
  padding: 1.35rem;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.info-card:hover,
.paper-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 18px 36px rgba(26, 43, 76, 0.12);
}

.info-card h3,
.section-title {
  margin-bottom: 0.55rem;
  font-size: 1.25rem;
  font-weight: 750;
  letter-spacing: -0.02em;
}

.info-card p,
.result-subtext,
.review-card p,
.question-card p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.75;
}

.paper-card {
  height: 100%;
  padding: 1.35rem;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.paper-title {
  margin-bottom: 0.4rem;
  font-size: 1.1rem;
  font-weight: 700;
}

.paper-card ul {
  padding-left: 1.15rem;
  color: var(--muted);
  line-height: 1.8;
}

.chip,
.timer-pill,
.progress-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  border: 1px solid rgba(49, 86, 211, 0.1);
  border-radius: 999px;
  padding: 0.55rem 0.9rem;
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 700;
  white-space: nowrap;
}

.quiz-toolbar {
  position: sticky;
  top: 0.75rem;
  z-index: 5;
  border-radius: 1.15rem;
  background: var(--surface);
  backdrop-filter: blur(14px);
}

.question-card {
  padding: 1.35rem;
  box-shadow: none;
  background: var(--bg);
}

.question-card h4 {
  font-size: 1.2rem;
  font-weight: 650;
  line-height: 1.7;
}

.options-grid {
  display: grid;
  gap: 0.75rem;
}

.option-btn {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 0.85rem;
  padding: 0.9rem 1rem;
  background: var(--surface);
  color: var(--text);
  text-align: left;
  line-height: 1.6;
  transition: border-color 0.18s ease, background-color 0.18s ease, box-shadow 0.18s ease;
}

.option-btn:hover {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.option-btn.selected {
  border-color: var(--primary);
  box-shadow: inset 0 0 0 1px var(--primary);
}

.option-btn.correct {
  border-color: var(--success);
  background: rgba(20, 132, 91, 0.1);
  color: var(--success);
}

.option-btn.wrong {
  border-color: var(--danger);
  background: rgba(196, 61, 82, 0.1);
  color: var(--danger);
}

.palette-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.55rem;
}

.palette-btn {
  min-height: 2.75rem;
  border: 1px solid transparent;
  border-radius: 0.7rem;
  color: #fff;
  font-weight: 700;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.palette-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(20, 31, 54, 0.18);
}

.palette-btn.answered { background: var(--success); }
.palette-btn.not-answered { background: var(--danger); }
.palette-btn.not-visited { background: #66758c; }
.palette-btn.marked { background: var(--purple); }
.palette-btn.current { background: var(--warning); color: #241a08; }

.status-list {
  display: grid;
  gap: 0.65rem;
  margin: 0;
  padding: 0;
  color: var(--muted);
  list-style: none;
}

.dot {
  display: inline-block;
  width: 0.72rem;
  height: 0.72rem;
  margin-right: 0.5rem;
  border-radius: 50%;
  vertical-align: 0.02em;
}

.dot.green { background: var(--success); }
.dot.red { background: var(--danger); }
.dot.gray { background: #66758c; }
.dot.purple { background: var(--purple); }
.dot.orange { background: var(--warning); }

.summary-card {
  min-height: 7.4rem;
  padding: 1.3rem;
  border: 0;
  border-radius: 1rem;
  color: #fff;
}

.summary-card.primary { background: linear-gradient(135deg, #3156d3, #5477ed); }
.summary-card.success { background: linear-gradient(135deg, #14845b, #22a879); }
.summary-card.danger { background: linear-gradient(135deg, #c43d52, #e46072); }

.summary-card span {
  display: block;
  opacity: 0.9;
  font-size: 0.92rem;
}

.summary-card strong {
  display: block;
  margin-top: 0.4rem;
  font-size: 1.55rem;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.8rem;
}

.summary-item {
  padding: 0.9rem 1rem;
  border: 1px solid var(--border);
  border-radius: 0.85rem;
  background: var(--surface-strong);
}

.summary-item strong {
  display: block;
  margin-top: 0.35rem;
  font-size: 1.12rem;
}

.progress-bar-wrap {
  margin-top: 0.7rem;
}

.progress-bar,
.meter-bar {
  width: 100%;
  height: 0.7rem;
  overflow: hidden;
  border-radius: 999px;
  background: var(--primary-soft);
}

.progress-fill,
.meter-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--primary), #58b9d6);
  transition: width 0.25s ease;
}

.meter-card {
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 0.95rem;
  background: var(--surface-strong);
}

.topic-item {
  margin-bottom: 0.9rem;
}

.topic-item .topic-label {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.35rem;
  font-weight: 600;
}

.topic-item .progress-bar {
  height: 0.55rem;
}

.review-card {
  margin-bottom: 1rem;
  padding: 1.1rem 1.2rem;
}

.review-card .review-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 0.8rem;
}

.review-card .status-badge {
  border-radius: 999px;
  padding: 0.4rem 0.7rem;
  font-size: 0.8rem;
  font-weight: 700;
  white-space: nowrap;
}

.status-badge.correct { background: rgba(20, 132, 91, 0.12); color: var(--success); }
.status-badge.wrong { background: rgba(196, 61, 82, 0.12); color: var(--danger); }
.status-badge.skipped { background: rgba(102, 117, 140, 0.14); color: var(--muted); }
.status-badge.flagged { background: rgba(118, 80, 201, 0.12); color: var(--purple); }

.answer-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin: 0.45rem 0;
}

.answer-pill {
  padding: 0.45rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-strong);
}

.answer-pill.correct {
  border-color: rgba(20, 132, 91, 0.25);
  color: var(--success);
}

.answer-pill.wrong {
  border-color: rgba(196, 61, 82, 0.25);
  color: var(--danger);
}

.filter-btn {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.55rem 0.85rem;
  background: var(--surface-strong);
  color: var(--text);
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.filter-btn.active {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}

.theme-toggle {
  display: inline-grid;
  width: 2.8rem;
  height: 2.8rem;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  transition: background-color 0.2s ease, transform 0.2s ease;
}

.theme-toggle:hover {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.2);
}

.btn {
  border-radius: 0.7rem;
  font-weight: 600;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn-primary {
  border-color: var(--primary);
  background: var(--primary);
}

.btn-success {
  border-color: var(--success);
  background: var(--success);
}

.btn-outline-warning {
  color: var(--warning);
  border-color: var(--warning);
}

:focus-visible {
  outline: 3px solid rgba(79, 131, 255, 0.65);
  outline-offset: 3px;
}

@media (max-width: 768px) {
  .hero-section {
    padding-block: 2rem !important;
  }

  .hero-section .container-xl > .d-flex {
    align-items: flex-start !important;
    gap: 1rem;
  }

  .hero-card {
    padding: 1.35rem !important;
  }

  .pattern-grid,
  .summary-grid {
    grid-template-columns: 1fr;
  }

  .pattern-card {
    min-height: auto;
  }

  .palette-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .quiz-toolbar {
    position: static;
  }
}

@media (max-width: 480px) {
  .hero-title {
    font-size: 1.65rem;
  }

  .chip,
  .timer-pill,
  .progress-pill {
    padding: 0.45rem 0.65rem;
    font-size: 0.85rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}

@media print {
  .hero-section,
  .theme-toggle,
  .btn,
  .filter-btn,
  .quiz-toolbar {
    display: none !important;
  }

  body {
    background: #fff;
    color: #111;
  }

  .card-soft,
  .summary-card,
  .review-card,
  .question-card {
    box-shadow: none;
    border: 1px solid #ddd;
  }
}

.portal-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  color: #fff;
  text-decoration: none;
}

.portal-brand:hover {
  color: #fff;
}

.portal-brand-mark {
  display: grid;
  width: 2.75rem;
  height: 2.75rem;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 0.9rem;
  background: linear-gradient(145deg, #fff, #dfe8ff);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.16);
  color: #2448b6;
  font-size: 1.35rem;
  font-weight: 800;
}

.portal-brand-copy {
  display: grid;
  gap: 0.05rem;
  text-align: left;
}

.portal-brand-copy strong {
  font-size: 1.03rem;
  font-weight: 750;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.portal-brand-copy small {
  color: rgba(218, 228, 255, 0.75);
  font-size: 0.59rem;
  font-weight: 700;
  letter-spacing: 0.12em;
}

.hero-section {
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  background:
    radial-gradient(ellipse at 12% 100%, rgba(49, 86, 211, 0.27), transparent 34rem),
    radial-gradient(ellipse at 88% 15%, rgba(96, 142, 255, 0.3), transparent 32rem),
    linear-gradient(125deg, #0c1428 0%, #15294e 58%, #1b3767 100%);
}

.hero-title {
  margin-top: 1.05rem;
}

.hero-card {
  border-radius: 1.65rem;
  box-shadow: 0 26px 65px rgba(4, 12, 30, 0.3);
}

.hero-card .btn {
  min-height: 3rem;
  padding-inline: 1.2rem;
}

.hero-card .btn-primary {
  --bs-btn-bg: #5277f2;
  --bs-btn-border-color: #5277f2;
  --bs-btn-hover-bg: #3e63dc;
  --bs-btn-hover-border-color: #3e63dc;
  --bs-btn-active-bg: #3156c8;
  --bs-btn-active-border-color: #3156c8;
  box-shadow: 0 8px 20px rgba(16, 35, 100, 0.25);
}

main.container-xl {
  max-width: 1280px;
  padding-top: 2rem !important;
  padding-bottom: 3.5rem !important;
}

.info-card,
.paper-card,
.card-soft,
.review-card {
  border-radius: 1.2rem;
  box-shadow: 0 10px 30px rgba(26, 43, 76, 0.055);
}

.info-card {
  position: relative;
  overflow: hidden;
  border-top: 3px solid rgba(49, 86, 211, 0.48);
}

.info-card h3 {
  font-size: 1.05rem;
}

.info-card p,
.paper-card p,
.paper-card li {
  font-size: 0.92rem;
}

.paper-card {
  position: relative;
  overflow: hidden;
  padding: 1.5rem;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.paper-card:hover {
  border-color: rgba(49, 86, 211, 0.3);
}

.paper-title {
  font-size: 1.2rem;
  letter-spacing: -0.02em;
}

.section-title {
  font-size: clamp(1.35rem, 2.3vw, 1.65rem);
}

#papersSection,
#quizSection,
#resultSection,
#reviewSection {
  scroll-margin-top: 1rem;
}

.quiz-toolbar {
  box-shadow: 0 8px 24px rgba(26, 43, 76, 0.08);
}

.quiz-heading-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
}

.quiz-home-link {
  color: var(--primary);
  font-size: 0.82rem;
  font-weight: 700;
  text-decoration: none;
}

.quiz-home-link:hover {
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

.question-card {
  border-radius: 1rem;
}

.option-btn {
  min-height: 3.25rem;
  padding: 0.9rem 1.05rem;
}

.option-btn:focus-visible,
.palette-btn:focus-visible,
.filter-btn:focus-visible,
.theme-toggle:focus-visible {
  outline: 3px solid rgba(79, 131, 255, 0.72);
  outline-offset: 2px;
}

.portal-footer {
  border-top: 1px solid var(--border);
  padding: 1.35rem 0;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.86rem;
}

.portal-footer-brand {
  color: var(--text);
  font-weight: 750;
  text-decoration: none;
}

.portal-footer-brand:hover {
  color: var(--primary);
}

.portal-footer-brand span {
  color: var(--muted);
  font-weight: 500;
}

.btn-outline-primary {
  --bs-btn-color: var(--primary);
  --bs-btn-border-color: var(--primary);
  --bs-btn-hover-bg: var(--primary);
  --bs-btn-hover-border-color: var(--primary);
  --bs-btn-active-bg: var(--primary);
  --bs-btn-active-border-color: var(--primary);
}

body.dark .btn-outline-primary {
  --bs-btn-hover-color: #101827;
  --bs-btn-active-color: #101827;
}

body.dark .btn-outline-light {
  --bs-btn-color: #f4f7ff;
  --bs-btn-border-color: rgba(255, 255, 255, 0.45);
  --bs-btn-hover-bg: rgba(255, 255, 255, 0.14);
  --bs-btn-hover-border-color: rgba(255, 255, 255, 0.7);
  --bs-btn-hover-color: #fff;
}

body.dark .paper-card:hover,
body.dark .info-card:hover {
  box-shadow: 0 18px 36px rgba(0, 0, 0, 0.28);
}

@media (max-width: 768px) {
  main.container-xl {
    padding-top: 1.35rem !important;
    padding-bottom: 2.5rem !important;
  }

  .hero-title {
    margin-top: 0.8rem;
  }

  .portal-footer .container-xl {
    align-items: flex-start !important;
  }
}

@media (max-width: 480px) {
  .portal-brand-mark {
    width: 2.45rem;
    height: 2.45rem;
    border-radius: 0.75rem;
  }

  .portal-brand-copy strong {
    font-size: 0.94rem;
  }

  .portal-brand-copy small {
    font-size: 0.52rem;
    letter-spacing: 0.09em;
  }

  .hero-title {
    font-size: 1.5rem;
  }

  .hero-section .container-xl > .d-flex {
    gap: 0.75rem;
  }

  .hero-section .container-xl > .d-flex > .d-flex {
    flex-shrink: 0;
  }

  .hero-section .container-xl > .d-flex .btn {
    padding-inline: 0.7rem;
    font-size: 0.82rem;
  }

  .paper-card {
    padding: 1.2rem;
  }

  .portal-footer {
    font-size: 0.8rem;
  }
}

@media print {
  .portal-footer {
    display: none !important;
  }
}
