/* =================================================================================
 * Quiz Page Stylesheet (from quiz.css)
 * ================================================================================= */
@keyframes shake-red {

  0%,
  100% {
    transform: translateX(0);
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0)
  }

  10%,
  30%,
  50%,
  70%,
  90% {
    transform: translateX(-5px)
  }

  20%,
  40%,
  60%,
  80% {
    transform: translateX(5px)
  }

  12.5%,
  37.5%,
  62.5%,
  87.5% {
    box-shadow: 0 0 12px 2px rgba(239, 68, 68, .5)
  }
}

@keyframes pulse-green {

  0%,
  100% {
    padding: 6px 8px;
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0)
  }

  50% {
    transform: scale(1.01);
    box-shadow: 0 0 12px 2px rgba(34, 197, 94, .4)
  }
}

@keyframes confetti-burst {
  0% {
    transform: scale(0) rotate(0);
    opacity: 0
  }

  50% {
    opacity: 1
  }

  100% {
    transform: scale(2.5) rotate(360deg);
    opacity: 0
  }
}

@keyframes pulse-feedback {
  0% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.15);
  }

  100% {
    transform: scale(1);
  }
}

/* ----------------------------------------------------------------------------
 * Modern shell navigation (GitHub-inspired)
 * ---------------------------------------------------------------------------- */
body.shell-nav-ready {
  margin: 0;
  padding-top: 64px;
}

@media (max-width: 640px) {
  body.shell-nav-ready {
    padding-top: 56px;
  }
}

.shell-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1200;
  /* Use left/right instead of width:100% to avoid scrollbar overflow */
  max-width: 100%;
  /* Semi-transparent for blur effect in light mode */
  background: rgba(255, 255, 255, 0.85);
  border-bottom: none;
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

[data-theme="dark"] .shell-header {
  background: rgba(24, 24, 27, 0.7);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.shell-header__bar {
  max-width: 1280px;
  margin: 0 auto;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 20px;
}

.shell-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--text-primary);
}

.shell-logo__img {
  width: 38px;
  height: 38px;
}

.shell-logo__text {
  display: none;
}

.shell-nav {
  display: flex;
  align-items: center;
  gap: 10px;
}

.shell-nav__link,
.shell-menu__section {
  padding: 0;
  border-top: none;
}

.shell-menu__section-toggle {
  width: 100%;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: none;
  border: none;
  cursor: pointer;
  font-weight: 700;
  color: inherit;
  text-align: left;
}

.shell-menu__section-content {
  display: none;
  padding: 4px 0 8px;
}

.shell-menu__section.is-open .shell-menu__section-content {
  display: block;
}

.shell-menu__section .shell-menu__chevron {
  transition: transform 0.2s ease;
  transform: rotate(-90deg);
}

.shell-menu__section.is-open .shell-menu__chevron {
  transform: rotate(0deg);
}

.shell-menu__item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  color: inherit;
  text-decoration: none;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  cursor: pointer;
}

.shell-menu__item:hover {
  background: #f9fafb;
}

.shell-user__identity {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.shell-user__name {
  font-size: 15px;
  line-height: 1.2;
  white-space: nowrap;
}

.shell-signout-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 4px;
  border: 1px solid transparent;
  background: transparent;
  color: #111827;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
  padding: 0;
  margin-left: 2px;
}

.shell-signout-btn:hover {
  background: #eef2ff;
  border-color: #c7d2fe;
}

.shell-user__quick {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  color: inherit;
  text-decoration: none;
  font-weight: 600;
}

.shell-user__quick:hover {
  text-decoration: underline;
}

.shell-menu {
  position: relative;
}

.shell-menu__trigger {
  cursor: pointer;
}

.shell-menu__chevron {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.shell-menu__dropdown {
  position: absolute;
  top: calc(100% + 12px);
  left: 0;
  min-width: 280px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  padding: 14px;
  display: none;
  z-index: 1300;
}

.shell-menu--right .shell-menu__dropdown {
  left: auto;
  right: 0;
}

.shell-menu.is-open .shell-menu__dropdown {
  display: block;
}

.shell-menu__section {
  display: grid;
  gap: 8px;
}

.shell-menu__section+.shell-menu__section {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border-color);
}

.shell-menu__label {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
  font-weight: 700;
}

.shell-menu__item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 10px;
  border-radius: 10px;
  text-decoration: none;
  color: var(--text-primary);
  background: transparent;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.shell-menu__item:hover {
  background: var(--bg-tertiary);
  color: var(--brand-primary);
}

.shell-menu__meta {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.shell-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--bg-tertiary);
  color: var(--brand-primary);
  font-weight: 700;
  font-size: 0.75rem;
}

.shell-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.shell-icon-btn {
  height: 38px;
  width: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  background: var(--bg-secondary);
  color: var(--text-primary);
  cursor: pointer;
  transition: background-color 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.shell-icon-btn:hover {
  border-color: var(--brand-primary);
  background: var(--bg-tertiary);
  transform: translateY(-1px);
}

.shell-icon--sun {
  display: var(--sun-display);
}

.shell-icon--moon {
  display: var(--moon-display);
}

.shell-user-slot {
  min-width: 0;
}

.shell-user {
  position: relative;
}


.shell-user__button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px;
  border-radius: 999px;
  border: 1px solid var(--border-color);
  background: var(--bg-secondary);
  cursor: pointer;
  transition: border-color 0.2s ease, background-color 0.2s ease;
}

.shell-user__button:hover {
  border-color: var(--brand-primary);
  background: var(--bg-tertiary);
}

.shell-avatar {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  object-fit: cover;
  border: 2px solid var(--border-color);
}

.shell-user__meta {
  display: none;
}

.shell-user__details {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 6px;
}

.shell-user__name {
  font-weight: 800;
  font-size: 0.95rem;
  color: var(--text-primary);
}

.shell-user__email {
  font-size: 0.82rem;
  color: var(--text-secondary);
  word-break: break-all;
}

.shell-user__menu {
  position: absolute;
  right: 0;
  top: calc(100% + 12px);
  min-width: 220px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  padding: 10px;
  display: none;
  z-index: 1300;
}

.shell-user.is-open .shell-user__menu {
  display: block;
}

.shell-user__menu a,
.shell-user__menu button {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: none;
  background: transparent;
  color: var(--text-primary);
  text-decoration: none;
  border-radius: 10px;
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.shell-user__menu a:hover,
.shell-user__menu button:hover {
  background: var(--bg-tertiary);
  color: var(--brand-primary);
}

.shell-mobile-toggle {
  display: none;
}

.shell-mobile-panel {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  transform: translateY(-120%);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.3s ease, opacity 0.25s ease;
  z-index: 1199;
}

.shell-mobile-panel__inner {
  margin-top: 76px;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
  box-shadow: var(--shadow-lg);
  padding: 16px;
  max-height: calc(100vh - 76px);
  overflow-y: auto;
}

.shell-mobile-group {
  display: grid;
  gap: 10px;
}

.shell-mobile-group+.shell-mobile-group {
  margin-top: 14px;
}

.shell-mobile-group--bordered {
  padding-top: 12px;
  border-top: 1px solid var(--border-color);
}

.shell-mobile-link,
.shell-mobile-action {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: 10px;
  text-decoration: none;
  color: var(--text-primary);
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  font-weight: 700;
}

.shell-mobile-link:hover,
.shell-mobile-action:hover {
  border-color: var(--brand-primary);
  color: var(--brand-primary);
}

.shell-mobile-open .shell-mobile-panel {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
}

body.shell-mobile-open::before {
  content: '';
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 1198;
  backdrop-filter: blur(2px);
}

@media (max-width: 960px) {
  .shell-nav {
    display: none;
  }

  .shell-mobile-toggle {
    display: inline-flex;
  }

  .shell-header__bar {
    height: 70px;
  }

  .shell-mobile-panel__inner {
    margin-top: 70px;
    max-height: calc(100vh - 70px);
  }
}

.animate-shake-red {
  animation: shake-red .6s ease-in-out
}

.animate-pulse-green {
  animation: pulse-green .8s ease-in-out
}

/* ----------------------------------------------------------------------------
 * Smart Search Styles
 * ---------------------------------------------------------------------------- */

/* Desktop Search Container */
.shell-search.shell-search--desktop {
  position: relative;
  display: flex;
  align-items: center;
}

.shell-search__input-wrap {
  position: relative;
  display: flex;
  align-items: center;
  width: 240px;
  height: 38px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 0 10px;
  transition: all 0.2s ease;
  color: var(--text-secondary);
}

.shell-search__input-wrap:focus-within {
  border-color: var(--brand-primary);
  background: var(--bg-primary);
  box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.1);
  color: var(--brand-primary);
  width: 300px;
}

.shell-search__input {
  flex: 1;
  border: none;
  background: transparent;
  padding: 0 8px;
  font-size: 0.9rem;
  color: var(--text-primary);
  outline: none;
  width: 100%;
}

.shell-search__input::placeholder {
  color: var(--text-secondary);
  opacity: 0.7;
}

/* Mobile Search Trigger */
.shell-search--mobile-trigger {
  display: none; /* Hidden by default, shown in media query */
}

/* Search Dropdown (Portal) */
.shell-search__dropdown {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  box-shadow: var(--shadow-xl);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.shell-search__status {
  padding: 16px;
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.shell-search__results {
  overflow-y: auto;
  max-height: 100%;
  padding: 6px;
}

.shell-search__item {
  display: block;
  padding: 10px 12px;
  border-radius: 8px;
  text-decoration: none;
  color: var(--text-primary);
  transition: background-color 0.15s ease;
  cursor: pointer;
}

.shell-search__item:hover,
.shell-search__item.is-highlighted {
  background-color: var(--bg-tertiary);
}

.shell-search__item-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 2px;
}

.shell-search__item-badge {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  background: var(--border-color);
  color: var(--text-secondary);
  padding: 1px 5px;
  border-radius: 4px;
  flex-shrink: 0;
}

.shell-search__item-title {
  font-weight: 600;
  font-size: 0.92rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.shell-search__item-section {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 4px;
  padding-left: 2px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.shell-search__item-section::before {
  content: '›';
  font-size: 1.1em;
  line-height: 0.8;
}

.shell-search__item-snippet {
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  opacity: 0.85;
}

/* Mobile Overlay */
.shell-search-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-primary);
  z-index: 2000;
  display: flex;
  flex-direction: column;
}

.shell-search-overlay__header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
  height: 60px;
}

.shell-search-overlay__input-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-secondary);
  border-radius: 8px;
  padding: 0 12px;
  height: 40px;
  border: 1px solid transparent;
  color: var(--text-secondary);
}

.shell-search-overlay__input-wrap:focus-within {
  border-color: var(--brand-primary);
  color: var(--brand-primary);
}

.shell-search-overlay__input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 1rem;
  color: var(--text-primary);
  outline: none;
  width: 100%;
}

.shell-search-overlay__close {
  background: none;
  border: none;
  color: var(--text-secondary);
  padding: 4px;
  cursor: pointer;
}

.shell-search-overlay__body {
  flex: 1;
  overflow-y: auto;
  padding: 12px 0;
}

.shell-search-overlay__body .shell-search__item {
  border-radius: 0;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-color);
}

/* Responsive visibility */
@media (max-width: 768px) {
  .shell-search.shell-search--desktop {
    display: none;
  }
  
  .shell-search--mobile-trigger {
    display: inline-flex;
  }
}

.animate-feedback-pulse {
  animation: pulse-feedback 0.5s ease-in-out;
}

.main_div {
  max-width: 900px;
  margin: 2rem auto 40px;
  padding: 0 20px
}

.page-title {
  font-size: 3rem;
  font-weight: 700;
  text-align: center;
  margin-bottom: 1.5rem;
  color: var(--text-primary)
}

.section-nav-custom {
  position: relative;
  width: 100%;
  max-width: 500px;
  margin: 0 auto 2rem
}

.section-nav-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .75rem;
  width: 100%;
  padding: .75rem 1rem;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-weight: 600;
  font-size: 1.05rem;
  cursor: pointer;
  transition: all .2s;
  text-align: center;
  box-shadow: var(--shadow-sm)
}

.section-nav-btn:hover {
  border-color: var(--brand-primary);
  box-shadow: var(--shadow-md)
}

.section-nav-btn .arrow-down {
  transition: transform .2s ease
}

.section-nav-custom.open .section-nav-btn .arrow-down {
  transform: rotate(180deg)
}

.section-nav-menu {
  display: none;
  position: absolute;
  top: 105%;
  left: 0;
  width: 100%;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  z-index: 100;
  max-height: 350px;
  overflow-y: auto;
  padding: 8px
}

.section-nav-custom.open .section-nav-menu {
  display: block
}

.section-nav-menu a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  text-decoration: none;
  color: var(--text-secondary);
  transition: all .2s;
  font-weight: 500;
  border-radius: 6px;
  margin-bottom: 6px;
}

.section-nav-menu .nav-item-emoji {
  min-width: 22px;
  text-align: left;
  font-size: 1.1rem;
  margin-right: 6px;
}

.section-nav-menu .nav-item-text {
  flex-grow: 1;
  text-align: left;
  font-size: 1rem;
  margin-left: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.section-nav-menu .progress-badge-nav,
.section-nav-menu .notification-badge {
  margin-left: auto;
  text-align: center;
}

.section-nav-menu a .nav-item-main {
  display: flex;
  flex-grow: 1;
  align-items: center;
  gap: 10px;
}

.section-nav-menu a .nav-item-badge {
  flex-shrink: 0;
}

.section-nav-menu a:hover,
.section-nav-menu a.active {
  background-color: var(--bg-tertiary);
  color: var(--brand-primary);
  font-weight: 600
}

.section-nav-menu a.active {
  background: rgba(79, 70, 229, .08)
}

.notification-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 7px;
  background-color: #ef4444;
  color: #fff;
  font-size: .8rem;
  font-weight: 700;
  border-radius: 11px;
  text-align: center;
  line-height: 1
}

#main-notification-badge {
  position: absolute;
  top: -8px;
  right: 8px;
  box-shadow: 0 0 0 2px var(--bg-secondary)
}

.section-nav-menu .notification-badge {
  box-shadow: none
}

.progress-badge-nav {
  font-size: .78rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 9999px;
  background-color: #e5e7eb;
  color: #374151;
  transition: background-color .3s, color .3s;
  flex-shrink: 0
}

[data-theme=dark] .progress-badge-nav {
  background-color: #4b5563;
  color: #f9fafb
}

.progress-badge-nav.complete {
  background-color: #22c55e;
  color: #fff
}

#quiz-status {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 1.5rem
}

/* Status bar typography (previously provided by Tailwind utility classes) */
#score {
  font-weight: 700;
  font-size: 1.125rem;
}

#progress-bar-container {
  position: relative;
  flex: 1
}

#progress-bar {
  height: 22px;
  background: var(--border-color);
  border-radius: 11px;
  overflow: hidden;
  position: relative
}

#progress-text {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  text-align: center;
  line-height: 22px;
  color: #fff;
  font-weight: 600;
  font-size: .8rem;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, .4)
}

#progress-fill {
  width: 0;
  height: 100%;
  background: var(--brand-primary);
  transition: width .4s cubic-bezier(.61, 1, .88, 1), background-color .4s ease
}

fieldset.question {
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 1.5rem 2rem;
  margin-bottom: 1.5rem;
  background: var(--bg-secondary);
  box-shadow: var(--shadow-md);
  position: relative;
  min-width: 0
}

/* Clinical stem styling - high specificity to override .quiz-card p */
.question-text,
p.question-text,
.quiz-card p.question-text,
fieldset .question-text,
.question-body .question-text {
  font-size: 1.35rem;
  font-weight: 500;
  line-height: 1.7;
  letter-spacing: -0.01em;
  margin-bottom: 1.75rem;
  color: var(--text-primary);
}

/* Dark mode text color for question stem */
[data-theme="dark"] .question-text,
[data-theme="dark"] p.question-text,
[data-theme="dark"] .quiz-card p.question-text,
[data-theme="dark"] fieldset .question-text,
[data-theme="dark"] .question-body .question-text {
  color: var(--text-primary);
}

label {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin-bottom: .75rem;
  padding: .85rem 1rem;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  cursor: pointer;
  transition: all .2s;
  color: var(--text-secondary)
}

.options-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
}

.option-container {
  display: contents;
}

.option-label {
  display: flex;
  align-items: center;
  padding: 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: 0.5rem;
  background-color: var(--bg-secondary);
  cursor: pointer;
  transition: all 0.2s ease-in-out;
  position: relative;
}

@media (hover: hover) {
  .option-label:hover {
    border-color: var(--brand-primary);
    background-color: var(--bg-tertiary);
  }
}

.option-label.selected {
  border-color: var(--brand-primary);
  background-color: var(--bg-tertiary);
  transform: scale(1.02);
}

.option-letter-box {
  flex-shrink: 0;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  background-color: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  margin-right: 1rem;
  transition: all 0.2s ease-in-out;
}

.option-label.selected .option-letter-box {
  border-color: var(--brand-primary);
  color: var(--brand-primary);
}

.option-text-content {
  flex-grow: 1;
  color: var(--text-primary);
}

.option-feedback-icon {
  position: absolute;
  right: 1rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1.25rem;
}

/* Neutralize option feedback icon styling so it matches standard text and color in dark/light modes */
.option-feedback-icon {
  position: static !important;
  transform: none !important;
  display: inline-block;
  margin-left: 0.5rem;
  font-size: 1.15rem;
  color: var(--text-secondary);
}

/* Remove auto generated content for option feedback icons (✔ ✖) so it uses text content only */
.option-label.correct-answer .option-feedback-icon:after,
.option-label.incorrect-answer .option-feedback-icon:after {
  content: none !important;
}

.option-label.correct-answer {
  background-color: #e6ffed;
  border-color: #22c55e;
  color: #166534;
}

.option-label.correct-answer .option-letter-box {
  background-color: #22c55e;
  border-color: #22c55e;
  color: #fff;
}

.option-label.correct-answer .option-text-content {
  color: #166534;
  font-weight: 600;
}

.option-label.incorrect-answer {
  background-color: #ffeaea;
  border-color: #ef4444;
  color: #b91c1c;
}

.option-label.incorrect-answer .option-letter-box {
  background-color: #ef4444;
  border-color: #ef4444;
  color: #fff;
}

.option-label.incorrect-answer .option-text-content {
  color: #b91c1c;
  font-weight: 600;
}

/* Use text-based icons inserted into DOM and style via these rules. Removes reliance on pseudo-elements. */
.option-label.correct-answer .option-feedback-icon {
  color: #22c55e;
}

.option-label.incorrect-answer .option-feedback-icon {
  color: #ef4444;
}

[data-theme=dark] .option-label.correct-answer .option-feedback-icon {
  color: #bbf7d0;
}

[data-theme=dark] .option-label.incorrect-answer .option-feedback-icon {
  color: #fca5a5;
}

/* For dark mode, keep contrast high */
[data-theme=dark] .option-label.correct-answer {
  background-color: #166534;
  color: #bbf7d0;
}

[data-theme=dark] .option-label.correct-answer .option-text-content {
  color: #fefefe;
  text-shadow: 0 0 6px rgba(0, 0, 0, 0.35);
}

[data-theme=dark] .option-label.incorrect-answer {
  background-color: #991b1b;
  color: #fca5a5;
}

[data-theme=dark] .option-label.incorrect-answer .option-text-content {
  color: #fefefe;
  text-shadow: 0 0 6px rgba(0, 0, 0, 0.35);
}

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

@media (hover: hover) {
  label:hover {
    border-color: var(--brand-primary);
    color: var(--text-primary)
  }
}

input[type=radio]:checked+label,
label.selected {
  border-color: var(--brand-primary);
  color: var(--text-primary);
  transform: scale(1.02);
  box-shadow: var(--shadow-md)
}

input[type=radio] {
  width: 1.15em;
  height: 1.15em;
  accent-color: var(--brand-primary)
}

label.correct-answer {
  color: #166534;
  background-color: #dcfce7;
  border-color: #22c55e;
  font-weight: 600
}

label.incorrect-answer {
  color: #991b1b;
  background-color: #fee2e2;
  border-color: #ef4444;
  font-weight: 600
}

[data-theme=dark] label.correct-answer {
  color: #bbf7d0;
  background-color: rgba(34, 197, 94, .15);
  border-color: #4ade80
}

[data-theme=dark] label.incorrect-answer {
  color: #fca5a5;
  background-color: rgba(239, 68, 68, .15);
  border-color: #f87171
}

.explanation {
  display: none;
  opacity: 0;
  transition: opacity .3s;
  border-radius: 10px;
  padding: 1em 1.25em;
  margin-top: 1.5em;
  font-weight: 500;
  line-height: 1.7;
  background: #dcfce7;
  color: #166534;
  border: 1px solid #22c55e
}

[data-theme=dark] .explanation {
  background: rgba(34, 197, 94, .15);
  color: #bbf7d0;
  border: 1px solid #4ade80
}

fieldset.question.show-explanation .explanation {
  display: block;
  opacity: 1
}

.quiz-card-controls {
  display: none;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 1.5rem
}

.feedback-controls {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: .75rem;
  padding-top: 1rem;
  margin-top: 1rem;
  border-top: 1px dashed var(--border-color)
}

.feedback-controls-right {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: .75rem;
  padding-top: 1rem;
  margin-top: 1rem;
  border-top: 1px dashed var(--border-color)
}

fieldset.question.show-explanation .feedback-controls {
  display: flex
}

fieldset.question.show-explanation .feedback-controls-right {
  display: flex
}

.feedback-btn {
  display: flex;
  align-items: center;
  gap: .5rem;
  background: 0 0;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 6px 12px;
  font-size: .85rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all .2s
}

.feedback-btn:hover:not(:disabled) {
  background-color: var(--bg-tertiary);
  color: var(--text-primary)
}

.feedback-btn:disabled {
  cursor: not-allowed;
  opacity: .6;
  color: var(--text-secondary);
  background: 0 0
}

.feedback-btn .count {
  min-width: 16px;
  text-align: center
}

.quiz-button {
  padding: .85rem 1.5rem;
  border: 1px solid var(--brand-primary);
  border-radius: 10px;
  background: var(--brand-primary);
  color: var(--text-on-brand);
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  transition: all .2s;
  box-shadow: var(--shadow-sm);
  flex-grow: 1;
  display: block;
  width: 100%
}

.quiz-button:hover:not(:disabled) {
  background: var(--brand-secondary);
  border-color: var(--brand-secondary);
  transform: translateY(-2px)
}

.quiz-button.quiz-button-secondary {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border-color)
}

.quiz-button.quiz-button-secondary:hover:not(:disabled) {
  background: var(--bg-hover);
  border-color: var(--brand-primary);
  color: var(--text-primary)
}

.quiz-button:disabled {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  cursor: not-allowed;
  transform: none;
  border-color: var(--border-color)
}

/* Dark mode: primary quiz buttons use WHITE text for contrast on colored background */
[data-theme="dark"] .quiz-button:not(.quiz-button-secondary) {
  color: #ffffff;
}

.ai-save-btn-wrapper {
  display: flex;
  justify-content: center;
  margin-top: 1rem;
  /* Add some space above the button */
  max-width: 50%;
  /* Make the wrapper half width */
  margin-left: auto;
  /* Center the wrapper */
  margin-right: auto;
  /* Center the wrapper */
}

.summary-card-new {
  background: var(--bg-secondary);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border-color);
  padding: 2.5rem 2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  overflow: hidden;
  max-width: 500px;
  margin: 0 auto
}

.summary-chart-container {
  position: relative;
  width: 150px;
  height: 150px;
  margin-bottom: 1.5rem
}

.summary-chart-container svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg)
}

.donut-chart-bg {
  stroke: var(--border-color);
  fill: none;
  stroke-width: 10
}

.donut-chart-fg {
  fill: none;
  stroke-width: 10;
  stroke-linecap: round;
  transition: stroke-dashoffset 1s cubic-bezier(.6, .4, 0, 1), stroke .5s
}

.donut-chart-center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center
}

.donut-chart-percent {
  font-size: 2.25rem;
  font-weight: 700;
  color: var(--text-primary)
}

.donut-chart-label {
  font-size: .8rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: .5px
}

.summary-title {
  font-size: 1.75rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: .5rem
}

.summary-feedback {
  font-style: italic;
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
  max-width: 90%
}

.summary-score-details {
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 2rem
}

.summary-controls {
  display: flex;
  flex-direction: column;
  gap: .75rem;
  width: 100%;
  max-width: 400px
}

.confetti-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: hidden
}

.confetti {
  position: absolute;
  width: 10px;
  height: 10px;
  background-color: var(--brand-primary);
  opacity: 0;
  animation: confetti-burst .8s ease-out forwards
}

.gemini-controls,
.gemini-similar-q-controls {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px dashed var(--border-color);
  display: flex;
  flex-direction: column;
  gap: .75rem;
  align-items: stretch
}

.gemini-btn {
  background: linear-gradient(45deg, #4f46e5, #a855f7);
  color: #fff;
  padding: 10px 16px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  font-weight: 600;
  transition: transform .2s, box-shadow .2s;
  flex-shrink: 0;
  text-align: center
}

.gemini-btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md)
}

.gemini-btn:disabled {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  cursor: not-allowed
}

.language-selector {
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 10px 12px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color .2s;
  width: 100%
}

.language-selector:hover {
  border-color: var(--brand-primary)
}

.language-selector:focus {
  outline: 2px solid var(--brand-primary);
  outline-offset: 2px
}

.summary-card-new .gemini-controls {
  margin-bottom: 1.5rem;
  /* Breathing room below study tips controls */
}

.summary-card-new .language-selector {
  width: auto;
  /* Allow width to adjust to content */
  min-width: 180px;
  /* Increase min-width */
  flex-shrink: 0;
  /* Prevent shrinking */
}

.summary-ai-container {
  margin-bottom: 2rem;
}


.quiz-message-container {
  text-align: center;
  padding: 4rem 2rem;
  background-color: var(--bg-secondary);
  border-radius: 16px;
  margin-top: 2rem
}

.quiz-message-container h2 {
  font-size: 1.5rem;
  color: var(--text-primary);
  margin-bottom: .5rem
}

.quiz-message-container p {
  color: var(--text-secondary)
}

/* Enhanced Feedback Styles */
.feedback-container {
  margin-top: 1.5rem;
  border-top: 1px solid var(--border-color);
  padding-top: 1rem;
}

/* Explanation box styling aligned with correct answer colors */
.feedback-box {
  display: flex;
  align-items: center;
  gap: 1rem;
  background-color: #e6ffed;
  /* light mode match */
  color: #166534;
  border: 1px solid #22c55e;
  border-radius: 16px;
  padding: 1rem 1.25rem;
  line-height: 1.5;
  font-size: .95rem;
  box-shadow: var(--shadow-sm);
}

[data-theme=dark] .feedback-box {
  background-color: #166534 !important;
  /* dark mode match */
  color: #fefefe !important;
  border-color: #166534 !important;
  text-shadow: 0 0 6px rgba(0, 0, 0, 0.35);
}

[data-theme=dark] .feedback-content {
  color: #fefefe !important;
}

.feedback-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  margin: 0 0.25rem 0 0;
  min-width: 1.25rem;
  min-height: 1.25rem;
  border-radius: 0.25rem;
  background: transparent;
  box-shadow: none;
}

[data-theme=dark] .feedback-icon {
  background: transparent;
  box-shadow: none;
}

/* Donut chart text colors (use variables so dark mode works) */
.donut-chart-percent-text {
  fill: var(--text-primary);
}

.donut-chart-label-text {
  fill: var(--text-secondary);
}

.feedback-content {
  flex: 1;
}

.feedback-content p {
  color: #166534;
  font-size: 1rem;
  flex-grow: 1;
  margin-bottom: 1.5rem;
  margin-top: 1.5rem;
}

[data-theme=dark] .feedback-content p {
  color: #fefefe;
  font-size: 1rem;
  flex-grow: 1;
  margin-bottom: 1.5rem;
  margin-top: 1.5rem;
}

[data-theme=dark] .feedback-content li,
[data-theme=dark] .feedback-content strong,
[data-theme=dark] .feedback-content em {
  color: #fefefe;
}

/* Accessible variants retained for potential future differentiation */
.feedback-box.feedback-correct {}

.feedback-box.feedback-incorrect {}

.feedback-container.hidden {
  display: none;
}

.feedback-label {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.75rem;
  text-align: center;
}

.feedback-controls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  background: var(--bg-tertiary);
  border-radius: 12px;
  border: 1px solid var(--border-color);
}

.feedback-controls.hidden {
  display: none;
}

/* Make feedback buttons match letter circle size when in the right controls row */
.feedback-controls-right .feedback-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border: 1px solid var(--border-color);
  border-radius: 50%;
  background: var(--bg-secondary);
  color: var(--text-secondary);
  font-size: 1rem;
  cursor: pointer;
  transition: all .2s ease;
}

.feedback-controls-right .feedback-btn:hover:not(:disabled) {
  background: var(--bg-tertiary);
  border-color: var(--brand-primary);
  color: var(--text-primary);
}

.feedback-controls-right .feedback-btn:disabled {
  cursor: not-allowed;
  opacity: .6;
  background: var(--bg-tertiary);
}

.feedback-btn.active {
  transform: scale(1.15);
  box-shadow: 0 4px 16px rgba(59, 130, 246, 0.4);
  border-width: 3px;
}

.feedback-btn[data-feedback-type="like"].active {
  background-color: #22c55e;
  border-color: #22c55e;
  color: white;
  box-shadow: 0 4px 16px rgba(34, 197, 94, 0.4);
}

.feedback-btn[data-feedback-type="dislike"].active {
  background-color: #ef4444;
  border-color: #ef4444;
  color: white;
  box-shadow: 0 4px 16px rgba(239, 68, 68, 0.4);
}

.feedback-btn[data-feedback-type="report"].active {
  background-color: #f59e0b;
  border-color: #f59e0b;
  color: white;
  box-shadow: 0 4px 16px rgba(245, 158, 11, 0.4);
}

/* Show feedback controls whenever question is answered */
fieldset.question.answered .feedback-container,
fieldset.quiz-card.answered .feedback-container {
  display: block;
}

fieldset.quiz-card.answered .feedback-controls,
fieldset.question.answered .feedback-controls {
  display: flex !important;
  visibility: visible !important;
  opacity: 1 !important;
}

/* Override any hidden class on feedback controls when question is answered */
fieldset.quiz-card.answered .feedback-controls.hidden,
fieldset.question.answered .feedback-controls.hidden {
  display: flex !important;
}

.feedback-btn {
  position: relative;
  /* For message positioning */
}

/* AI badge styling for similar question header */
.ai-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 9999px;
  font-weight: 700;
  font-size: 0.72rem;
  background: linear-gradient(135deg, #4f46e5, #a855f7);
  color: #fff;
  box-shadow: var(--shadow-sm);
  margin-right: 8px;
  vertical-align: middle;
}

@media (max-width: 640px) {
  .section-nav-menu a {
    padding: 10px 12px;
    gap: 8px;
  }

  .section-nav-menu .nav-item-emoji {
    font-size: 1.1rem;
    min-width: 24px;
  }

  .section-nav-menu .nav-item-text {
    font-size: 0.95rem;
    line-height: 1.25;
  }

  .progress-badge-nav {
    font-size: 0.75rem;
    padding: 2px 8px;
  }

  .feedback-btn {
    width: 48px;
    height: 48px;
    font-size: 1.3rem;
  }

  .feedback-controls {
    gap: 0.75rem;
    padding: 0.75rem;
  }

  .feedback-label {
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
  }
}

@media (max-width: 480px) {
  .section-nav-btn {
    font-size: 0.95rem;
    padding: 0.6rem 0.8rem;
  }

  .section-nav-menu a {
    padding: 9px 10px;
    gap: 8px;
  }

  .section-nav-menu .nav-item-text {
    font-size: 0.92rem;
    line-height: 1.2;
  }

  .section-nav-menu .nav-item-emoji {
    min-width: 22px;
  }

  .progress-badge-nav {
    font-size: 0.72rem;
    padding: 2px 8px;
  }
}

/* Feedback button animations */
.animate-pop {
  animation: pop 0.4s cubic-bezier(0.68, -0.55, 0.27, 1.55);
}

@keyframes pop {
  0% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.5);
    color: var(--brand-primary);
  }

  100% {
    transform: scale(1);
  }
}

@media (min-width:640px) {
  .gemini-controls {
    flex-direction: row;
    align-items: center;
    justify-content: flex-end;
  }

  .language-selector {
    width: auto
  }
}

@media (max-width:767px) {
  .main_div {
    padding: 0 15px
  }

  .page-title {
    font-size: 1.8rem
  }

  fieldset.question {
    padding: 1.5rem 1rem
  }

  .question-text,
  p.question-text,
  .quiz-card p.question-text,
  fieldset .question-text,
  .question-body .question-text {
    font-size: 1.2rem;
    line-height: 1.65;
  }
}

/* Homepage CTA button stack - centered, responsive */
.cta-stack {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
  width: 100%;
  max-width: 42rem;
  margin-inline: auto;
  justify-items: center;
}

@media (min-width: 640px) {
  .cta-stack {
    grid-template-columns: repeat(2, 1fr);
  }
}

.cta-stack>a {
  width: 100%;
  display: block;
}