/* Quiz Results Option Highlighting */
.option-result {
  padding: 0.75rem 1rem;
  border-radius: 6px;
  border: 2px solid var(--stroke);
  margin-bottom: 0.5rem;
  background: var(--bg-1);
  color: var(--text-primary);
  font-size: 1rem;
  transition: background 0.2s, border 0.2s, color 0.2s;
}
.option-result.option-correct {
  background: rgba(34, 197, 94, 0.12);
  border-color: var(--success);
  color: var(--success);
  font-weight: 600;
}
.option-result.option-incorrect {
  background: rgba(239, 68, 68, 0.12);
  border-color: #ef4444;
  color: #ef4444;
  font-weight: 600;
}
.options-list-results {
  margin-bottom: 1rem;
}
.welcome-rotator {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 12px;
}
.rotating-shape {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: conic-gradient(
    #38bdf8 0deg 90deg,
    #6366f1 90deg 180deg,
    #f472b6 180deg 270deg,
    #facc15 270deg 360deg
  );
  box-shadow: 0 2px 12px 0 #38bdf8, 0 0 0 2px #6366f1;
  animation: rotateShape 1.6s linear infinite;
}

@keyframes rotateShape {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}
.chat-empty-welcome {
  color: var(--muted);
  font-size: 15px;
  text-align: center;
  padding: 32px 0 16px 0;
  opacity: 0;
  transform: scale(0.96) translateY(16px);
  animation: popIn 0.7s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
  position: relative;
  background: var(--card-overlay); /* translucent same as other panels */
  border-radius: 18px;
  box-shadow: none; /* Remove blue shadow */
  overflow: hidden;
}

.chat-empty-welcome span {
  display: inline-block;
}


@keyframes popIn {
  0% {
    opacity: 0;
    transform: scale(0.96) translateY(16px);
  }
  100% {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}
/* Welcome animation for quiz chat pane */
.chat-empty-welcome {
  color: var(--muted);
  font-size: 15px;
  text-align: center;
  padding: 32px 0 16px 0;
  opacity: 0;
  transform: scale(0.96) translateY(16px);
  animation: popIn 0.7s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes popIn {
  0% {
    opacity: 0;
    transform: scale(0.96) translateY(16px);
  }
  100% {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}
/* Seamless scrollbar styling for quiz chat thread – match sidebar so the
   feel is consistent between history and quiz panes */
#quizChatThread::-webkit-scrollbar {
  width: 6px;
}
#quizChatThread::-webkit-scrollbar-track {
  background: var(--bg-1);
}
#quizChatThread::-webkit-scrollbar-thumb {
  background: var(--text-secondary);
  opacity: 0.6;
  border-radius: 3px;
}
#quizChatThread::-webkit-scrollbar-thumb:hover {
  opacity: 0.8;
}

/* Firefox */
#quizChatThread {
  scrollbar-width: thin;
  scrollbar-color: rgba(176, 181, 188, 0.12) transparent;
}
#exportQuizBtn.disabled,
#exportQuizBtn:disabled {
  opacity: 0.5;
  filter: grayscale(0.5);
  cursor: not-allowed !important;
  pointer-events: none;
}
/* earlier responsive rules removed, see later unified definitions */
@media (max-width: 900px) {
  /* handled by later media queries and base fixed positioning */
}
@media (min-width: 900px) {
  /* handled by later media queries and base fixed positioning */
}
  .quiz-bottom-row {
    width: 100%;
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    gap: 1rem;
  }
  #quizPdfUploadBtn,
  #quizGenerateBtn {
    flex: 0 0 auto;
    min-width: 120px;
    margin: 0;
  }

  /* shuffle button uses same sizing as other bottom-row controls */
  #quizShuffleBtn {
    flex: 0 0 auto;
    min-width: 120px;
    margin: 0;
  }

@media (max-width: 900px) {
  .quiz-resizer {
    display: none !important;
  }
}

/* remove border-radius for shuffle modal and its controls */

/* Quiz Page Layout for Chat Pane */
.quiz-page-layout {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  width: 100%;
  min-height: 100vh;
  height: 100vh;
  position: relative;
  /* content should sit under sidebar when it slides in */
  z-index: 1;
}

.quiz-main {
  flex: 1 1 0;
  min-width: 0;
  /* subtract variable width, clamp at min width if necessary */
  max-width: calc(100vw - var(--quiz-chat-width));
  /* reserve space for chat pane so content doesn't underlap */
  margin-right: var(--quiz-chat-width);
  /* prevent content from being obscured by fixed input island */
  padding-bottom: calc(7rem + max(env(safe-area-inset-bottom, 0px), var(--mobile-bottom-offset, 0px)));
}

@media (max-width: 900px) {
  .quiz-main {
    width: 100vw;
    max-width: 100vw;
    margin: 0;
    padding: 0;
  }
  /* allow input area and container to stretch fully */
  .quiz-input-section,
  .quiz-container {
    width: 100vw;
    padding: 0;
  }
  /* ensure input doesn't float above sidebar when open */
  .quiz-input-section {
    position: relative;
    z-index: 0;
  }
}

.quiz-chat-pane {
  width: var(--quiz-chat-width);
  min-width: 240px; /* ensure content remains readable */
  /* match the translucent overlay used by the main card so chat pane feels joined
     with saved‐messages pane (using --card-overlay variable which changes with theme) */
  background: var(--card-overlay);
  border-left: 1px solid var(--stroke);
  display: flex;
  flex-direction: column;
  padding: 1.5rem 1rem;
  box-sizing: border-box;
  min-height: 100vh;
  height: 100vh;
  position: fixed;
  top: 0;
  right: 0;
  z-index: 10;
  font-size: 13px; /* Reduced font size */
  transition: transform 220ms ease, opacity 180ms ease;
}

/* light‑theme override (sidebar already does this via variables, but be
   explicit here for clarity) */
:root[data-theme="light"] .quiz-chat-pane {
  background: var(--card-overlay) !important;
  border-left-color: var(--stroke);
}

/* the background is now intentionally set to the main content color above */

/* resizer for quiz chat pane - mimic sidebar resizer */
.quiz-resizer {
  width: 4px;
  background: var(--stroke);
  cursor: col-resize;
  /* fixed on left edge of chat pane */
  position: fixed;
  top: 0;
  right: var(--quiz-chat-width);
  height: 100vh;
  z-index: 11;
  transition: background 160ms ease;
}

.quiz-chat-toggle {
  position: fixed;
  top: 20px;
  right: calc(var(--quiz-chat-width) + 8px);
  transform: none;
  z-index: 12;
  border: 1px solid var(--stroke);
  background: color-mix(in srgb, var(--card) 92%, transparent);
  color: var(--text);
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 8px;
  cursor: pointer;
  font-size: 18px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: right 220ms ease, background 160ms ease, border-color 160ms ease, transform 160ms ease;
}

.quiz-chat-toggle:hover {
  background: color-mix(in srgb, var(--dock-item-hover) 90%, transparent);
  border-color: color-mix(in srgb, var(--accent) 45%, var(--stroke));
}

.quiz-page-layout.chat-collapsed .quiz-chat-pane {
  transform: translateX(100%);
  opacity: 0;
  pointer-events: none;
}

.quiz-page-layout.chat-collapsed .quiz-resizer {
  display: none;
}

.quiz-page-layout.chat-collapsed .quiz-main {
  margin-right: 0;
  max-width: 100vw;
}

.quiz-page-layout.chat-collapsed #quizInputIsland {
  right: 0 !important;
}

.quiz-page-layout.chat-collapsed .quiz-chat-toggle {
  right: 8px;
}

/* explicit open state so mobile slide-over can reuse chat-collapsed flag */
.quiz-page-layout:not(.chat-collapsed) .quiz-chat-pane {
  transform: translateX(0);
  opacity: 1;
  pointer-events: auto;
}

@media (max-width: 900px) {
  .quiz-chat-pane {
    width: min(92vw, 420px);
    min-width: 0;
    max-width: 100vw;
    z-index: 10005;
    box-shadow: -10px 0 28px rgba(0, 0, 0, 0.34);
    transform: translateX(100%);
  }

  .quiz-chat-toggle {
    top: 20px;
    right: 20px;
    z-index: 10006;
    background: var(--card);
    border-color: var(--stroke);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    font-size: 20px;
  }

  .quiz-page-layout.chat-collapsed .quiz-chat-toggle,
  .quiz-page-layout:not(.chat-collapsed) .quiz-chat-toggle {
    right: 20px;
  }
}

.quiz-resizer:hover {
  background: rgba(176, 181, 188, 0.5);
}

.quiz-resizer::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: -4px;
  right: -4px;
}


.chat-pane-title {
  font-size: 1.2rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: var(--text-primary);
}

#quizChatThread {
  margin-top: 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  position: relative;
  flex: 1 1 0;
  overflow-y: auto;
}

.quiz-chat-pane .chat-empty {
  color: var(--muted);
  font-size: 13px;
  padding: 8px 0;
}


.quiz-chat-pane .chat-msg.user {
  display: flex;
  justify-content: flex-end;
}

.quiz-chat-pane .chat-msg.assistant {
  display: flex;
  justify-content: flex-start;
}

.quiz-chat-pane .chat-msg {
  display: flex;
  gap: 4px;
}

.quiz-chat-pane .chat-bubble {
  max-width: min(560px, 100%);
  padding: 10px 14px;
  border: 1px solid var(--stroke);
  background: var(--bubble-bg);
  line-height: 1.6;
  border-radius: 18px;
  font-size: 13px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
  margin-bottom: 2px;
  word-break: break-word;
  transition: background 0.2s;
}

.quiz-chat-pane .chat-msg.user .chat-bubble {
  background: var(--bubble-user-bg);
  border-color: rgba(96, 165, 250, 0.5);
  color: var(--text-primary);
  border-bottom-right-radius: 6px;
  border-bottom-left-radius: 18px;
  border-top-left-radius: 18px;
  border-top-right-radius: 18px;
  align-self: flex-end;
}

.quiz-chat-pane .chat-msg.assistant .chat-bubble {
  background: var(--bubble-bg);
  color: var(--text-primary);
  border-bottom-left-radius: 6px;
  border-bottom-right-radius: 18px;
  border-top-left-radius: 18px;
  border-top-right-radius: 18px;
  align-self: flex-start;
}

.quiz-chat-pane .chat-content {
  margin: 0;
  padding: 0;
  font-size: 13px;
}

.quiz-chat-pane .chat-input-row {
  display: flex;
  gap: 8px;
  margin-top: 0;
  margin-bottom: 0;
  position: sticky;
  bottom: 0;
  background: var(--bg-secondary);
  padding-top: 12px;
}

#quizChatInput {
  width: 100%;
  min-height: 48px;
  max-height: 160px;
  padding: 14px 44px 14px 14px;
  border-radius: 0;
  border: 1px solid var(--stroke);
  background: var(--input-bg);
  color: var(--text);
  font-size: 13px;
  line-height: 1.2;
  font-family: "Segoe UI", "Arial", sans-serif;
  outline: none;
  resize: vertical;
  transition: border 200ms ease, box-shadow 200ms ease, transform 200ms ease;
}

#quizChatInput:focus {
  border-color: rgba(176, 181, 188, 0.7);
  box-shadow: 0 0 0 2px rgba(176, 181, 188, 0.2);
  transform: translateY(-1px);
}

#quizChatSendBtn {
  height: 48px;
  padding: 0 20px;
  border-radius: 0;
  border: 1px solid var(--accent);
  color: var(--button-text);
  background: var(--accent);
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease, filter 160ms ease;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.25);
  position: relative;
  overflow: hidden;
  will-change: transform;

  /* center label text vertically/horizontally */
  display: flex;
  align-items: center;
  justify-content: center;

  /* match site typography */
  font-family: inherit;
  font-weight: 500;
  font-size: 1rem;
  line-height: normal;
}

#quizChatSendBtn:disabled {
  cursor: not-allowed;
  filter: grayscale(0.3);
  opacity: 0.7;
}

#quizChatSendBtn:hover:not(:disabled) {
  transform: translateY(-1px) scale(1.01);
  box-shadow: 0 16px 30px rgba(96, 165, 250, 0.35);
}

/* Quiz Component Styles */

:root {
  /* chat pane width variable – can be adjusted via JS/resizer */
  --quiz-chat-width: 340px;

  --primary: var(--accent);
  --primary-dark: var(--accent-2);
  --text-primary: var(--text);
  --text-secondary: var(--muted);
  --bg-secondary: var(--card);
  --card: var(--card);
}

#quizPanel {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  height: auto;
}

#quizPanel.is-hidden {
  display: none !important;
  pointer-events: none;
}

.quiz-container {
  width: 100%;
  padding: 1.5rem;
  max-width: 900px;
  margin: 0 auto;
}

#quizInputSection {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  padding: 1.5rem;
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
}

#quizInputSection > div:first-child {
  border: 1px solid var(--stroke);
  background: var(--card);
  padding: 12px;
}

#quizInputSection label {
  display: inline-block;
  margin-bottom: 8px;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

#quizInputSection.is-hidden,
#quizContainer.is-hidden,
#submitQuizBtn.is-hidden,
#quizPdfUploadBtn.is-hidden,
#quizGenerateBtn.is-hidden,
#quizShuffleBtn.is-hidden,
#exportQuizBtn.is-hidden {
  display: none;
}

/* Quiz Status */
#quizStatus {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 1rem;
}

#quizStatus .dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--primary);
  animation: pulse 1.5s ease-in-out infinite;
}

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

/* Material Input */
#quizMaterial {
  width: 100%;
  min-height: 240px;
  max-height: none;
  padding: 14px;
  border: 1px solid var(--stroke);
  border-radius: 0;
  font-family: inherit;
  font-size: 15px;
  line-height: 1.45;
  resize: vertical;
  background-color: var(--input-bg);
  color: var(--text);
  overflow-y: auto;
  transition: border 200ms ease, box-shadow 200ms ease, transform 200ms ease;
}

#quizMaterial::placeholder {
  color: var(--muted);
}

#quizMaterial:focus {
  outline: none;
  border-color: rgba(176, 181, 188, 0.7);
  box-shadow: 0 0 0 2px rgba(176, 181, 188, 0.2);
  transform: translateY(-1px);
}

/* Question Count Input */
.quiz-options {
  display: flex;
  gap: 1rem;
  align-items: flex-end;
  flex-wrap: wrap;
}

.quiz-options > div {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.quiz-options label {
  font-size: 0.9rem;
  color: var(--text-secondary);
  font-weight: 500;
}

#quizQuestionCount {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--stroke);
  border-radius: 0;
  background-color: var(--input-bg);
  color: var(--text);
  font-size: 0.9rem;
  width: 80px;
}

#quizQuestionCount:focus {
  outline: none;
  border-color: rgba(176, 181, 188, 0.7);
  box-shadow: 0 0 0 2px rgba(176, 181, 188, 0.2);
}

/* Buttons */
.quiz-actions {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

/* persistent bottom bar for quiz pane – always fixed to viewport */
#quizInputIsland {
  position: fixed;
  left: var(--sidebar-layout-width, 324px);
  right: calc(var(--quiz-chat-width) + 4px);
  bottom: 0;
  width: auto;
  max-width: none;
  box-sizing: border-box;
  background: color-mix(in srgb, var(--card) 85%, transparent);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 0.5rem 1.5rem;
  z-index: 100;
  box-shadow: 0 -6px 20px rgba(0,0,0,0.06);
}


.quiz-bottom-row {
  display: flex;
  gap: 8px;
  width: 100%;
  padding: 0.25rem 0;
  min-height: unset;
  justify-content: flex-start;
  align-items: center;
  flex-wrap: wrap;
}

#quizPdfUploadBtn,
#quizGenerateBtn {
  flex: 0 0 auto;
}

/* Force fixed positioning for quiz input island on all screens */
@media (min-width: 900px) {
  /* keep input island fixed on wide screens and apply translucent backdrop */
  #quizInputIsland {
    position: fixed !important;
    left: var(--sidebar-layout-width, 324px);
    right: calc(var(--quiz-chat-width) + 4px);
    bottom: 0;
    background: color-mix(in srgb, var(--card) 85%, transparent);
    border-top: 1px solid color-mix(in srgb, var(--stroke) 80%, transparent);
    backdrop-filter: blur(6px) saturate(1.05);
    -webkit-backdrop-filter: blur(6px) saturate(1.05);
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.08);
    z-index: 100;
    display: flex;
    justify-content: center;
    align-items: center;
    width: auto;
    max-width: none;
  }
}

@media (max-width: 900px) {
  #quizInputIsland {
    position: fixed !important;
    left: var(--sidebar-layout-width, 0px) !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    background: var(--card);
    z-index: 100;
    box-shadow: 0 -2px 16px rgba(0,0,0,0.08);
    padding: 0.75rem 0.5rem 1.25rem 0.5rem;
    display: flex;
    justify-content: center;
  }
  .quiz-bottom-row {
    justify-content: center;
    flex-wrap: wrap;
    gap: 12px;
  }
  #quizPdfUploadBtn,
  #quizGenerateBtn {
    flex: 0 0 auto;
    min-width: 120px;
    margin: 0 auto;
    text-align: center;
  }
}

@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  #quizInputIsland {
    background: var(--card);
  }
}

#quizPdfUploadBtn,
#quizGenerateBtn,
#submitQuizBtn,
#exportQuizBtn {
  padding: 0.25rem 0.75rem;
  border: 1px solid var(--stroke);
  border-radius: 0;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  flex: 0 0 auto;
  min-width: 130px;
}

#quizGenerateBtn {
  background: transparent;
  color: var(--text);
  min-width: 160px;
}

#quizPdfUploadBtn {
  background: transparent;
  color: var(--text);
  min-width: 140px;
}

#exportQuizBtn {
  background: transparent;
  color: var(--text);
  min-width: 130px;
}

#quizPdfUploadBtn:hover:not(:disabled),
#quizGenerateBtn:hover:not(:disabled),
#exportQuizBtn:hover:not(:disabled) {
  background: var(--dock-item-hover);
  transform: none;
}

#submitQuizBtn {
  background-color: var(--primary);
  color: white;
  /* occupy only its min width */
  flex-grow: 0;
  min-width: 140px;
}

#submitQuizBtn:hover:not(:disabled) {
  background-color: var(--primary-dark);
  transform: translateY(-2px);
}

#quizGenerateBtn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Quiz Questions */
.quiz-question {
  margin-bottom: 2.5rem;
  padding: 1.5rem;
  background-color: var(--bg-secondary);
  border-radius: 8px;
  border-left: 4px solid var(--accent);
}

.quiz-attempt-view {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.quiz-question-card {
  margin-bottom: 0;
  border: 1px solid var(--stroke);
  border-left: 4px solid var(--accent);
  background: var(--card);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.12);
}

.quiz-question-card .question-header {
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--stroke);
}

.question-header {
  margin-bottom: 1.5rem;
}

.question-header h3 {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin: 0 0 0.5rem 0;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}

.question-text {
  font-size: 1.1rem;
  color: var(--text-primary);
  margin: 0;
  line-height: 1.5;
}

/* Options */
.options-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.option-label {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  border: 2px solid var(--stroke);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  background-color: var(--bg-1);
}

.option-label:hover {
  border-color: var(--stroke);
  background-color: var(--bg-1);
}

.option-input {
  width: 20px;
  height: 20px;
  cursor: pointer;
  accent-color: var(--primary);
}

.option-input:checked ~ .option-text {
  color: var(--primary);
  font-weight: 600;
}

.option-input:checked {
  accent-color: var(--primary);
}

.option-text {
  flex: 1;
  color: var(--text-primary);
  font-size: 1rem;
  margin: 0;
  transition: color 0.2s ease;
}

/* Quiz Results */
.quiz-results {
  padding: 1.5rem;
}

.results-header {
  text-align: center;
  margin-bottom: 2rem;
}

.results-header h2 {
  margin: 0 0 1.5rem 0;
  color: var(--text-primary);
}

.score-card {
  display: inline-block;
  padding: 2rem;
  border-radius: 12px;
  text-align: center;
  background: linear-gradient(135deg, rgba(0, 100, 200, 0.1), rgba(0, 150, 255, 0.1));
}

.score-card.excellent {
  background: linear-gradient(135deg, rgba(34, 197, 94, 0.1), rgba(74, 222, 128, 0.1));
}

.score-card.good {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.1), rgba(96, 165, 250, 0.1));
}

.score-card.needs-work {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.1), rgba(248, 113, 113, 0.1));
}

.score-percentage {
  font-size: 3.5rem;
  font-weight: 700;
  color: var(--primary);
  line-height: 1;
  margin-bottom: 0.5rem;
}

.score-card.excellent .score-percentage {
  color: var(--success);
}

.score-card.good .score-percentage {
  color: #3b82f6;
}

.score-card.needs-work .score-percentage {
  color: #ef4444;
}

.score-text {
  font-size: 1.1rem;
  color: var(--text-secondary);
  margin: 0;
}

.score-message {
  font-size: 0.95rem;
  color: var(--text-secondary);
  margin-top: 0.75rem;
  font-weight: 500;
}

/* Results Summary */
.results-summary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 2.5rem;
}

.summary-stat {
  display: flex;
  gap: 1rem;
  padding: 1rem;
  border-radius: 8px;
  border: 2px solid var(--stroke);
  background-color: var(--card);
  align-items: flex-start;
}

.summary-stat.correct-stat {
  border-color: var(--success);
  background: rgba(34, 197, 94, 0.05);
}

.summary-stat.incorrect-stat {
  border-color: #ef4444;
  background: rgba(239, 68, 68, 0.05);
}

.stat-icon {
  font-size: 1.5rem;
  min-width: 32px;
  text-align: center;
  font-weight: bold;
  margin-top: 0.25rem;
}

.correct-stat .stat-icon {
  color: var(--success);
}

.incorrect-stat .stat-icon {
  color: #ef4444;
}

.stat-content {
  flex: 1;
}

.stat-label {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1;
  margin-bottom: 0.5rem;
}

.stat-questions {
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.4;
  word-break: break-word;
}

/* Results Details */
.details-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 1.5rem 0;
  padding: 0.5rem 0;
  border-bottom: 2px solid var(--stroke);
}

.results-details {
  margin-top: 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.result-item {
  padding: 1.5rem;
  border-radius: 8px;
  border-left: 4px solid var(--stroke);
  background-color: var(--bg-secondary);
}

.result-item.correct {
  border-left-color: var(--success);
  background: rgba(34, 197, 94, 0.05);
}

.result-item.incorrect {
  border-left-color: #ef4444;
  background: rgba(239, 68, 68, 0.05);
}

.result-question h4 {
  margin: 0 0 0.5rem 0;
  color: var(--text-secondary);
  text-transform: uppercase;
  font-size: 0.85rem;
  letter-spacing: 0.5px;
}

.result-question p {
  margin: 0;
  color: var(--text-primary);
  font-size: 1rem;
  line-height: 1.5;
}

.result-answer {
  margin-top: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.result-answer p {
  margin: 0;
  font-size: 0.95rem;
  color: var(--text-secondary);
}

.correct-answer {
  color: var(--success);
  font-weight: 500;
}

.explanation {
  color: var(--text-secondary);
  font-style: italic;
  border-left: 2px solid var(--accent);
  padding-left: 0.75rem;
  margin-top: 0.5rem;
}

.result-item.correct .result-answer {
  color: var(--success);
}

.result-item.incorrect .result-answer {
  color: #ef4444;
}

/* Result Item Details */
.result-item-header {
  display: flex;
  gap: 1rem;
  margin-bottom: 1rem;
}

.result-status-icon {
  font-size: 2rem;
  min-width: 2.5rem;
  text-align: center;
  line-height: 1;
  font-weight: bold;
}

.result-item.correct .result-status-icon {
  color: var(--success);
}

.result-item.incorrect .result-status-icon {
  color: #ef4444;
}

.user-answer {
  margin-top: 0.75rem;
  padding: 0.75rem;
  border-radius: 6px;
  background-color: var(--card);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.answer-label {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  font-weight: 600;
}

.answer-text {
  font-size: 0.95rem;
  color: var(--text-primary);
  margin: 0;
  padding: 0;
}

.user-answer.incorrect {
  border-left: 3px solid #ef4444;
  padding-left: 1rem;
}

.user-answer.correct {
  border-left: 3px solid var(--success);
  padding-left: 1rem;
}

/* Results Actions */
.results-actions {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 1rem;
  padding-top: 0.5rem;
  border-top: 2px solid var(--stroke);
}

.results-actions button {
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
  font-size: 0.95rem;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.results-actions .retake-btn {
  background-color: var(--primary);
  color: white;
}

.results-actions .retake-btn:hover {
  background-color: var(--primary-dark);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.results-actions .new-quiz-btn {
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  border: 2px solid var(--stroke);
}

.results-actions .new-quiz-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
  background-color: var(--card);
}

/* Quiz History */
.quiz-history-tabs {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 2rem;
  flex-wrap: wrap;
  border-bottom: 2px solid var(--stroke);
  padding-bottom: 1rem;
}

.history-tab {
  padding: 0.75rem 1rem;
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  color: var(--muted);
  cursor: pointer;
  font-weight: 500;
  font-size: 0.9rem;
  transition: all 0.2s ease;
}

.history-tab:hover {
  color: var(--text-primary);
}

.history-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.quiz-history {
  padding: 1.5rem;
}

.quiz-history h2 {
  margin: 0 0 1.5rem 0;
  color: var(--text-primary);
}

.history-sessions {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.history-item {
  padding: 1.5rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background-color: var(--bg-secondary);
}

.history-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.history-header h4 {
  margin: 0;
  color: var(--text-primary);
}

.attempt-date {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-left: auto;
}

.attempt-score {
  padding: 0.25rem 0.75rem;
  border-radius: 4px;
  background-color: var(--primary);
  color: white;
  font-weight: 600;
  font-size: 0.9rem;
}

.history-questions {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.history-question {
  padding: 1rem;
  border-radius: 6px;
  border-left: 3px solid var(--stroke);
}

.history-question.correct {
  border-left-color: var(--success);
  background: rgba(34, 197, 94, 0.05);
}

.history-question.incorrect {
  border-left-color: #ef4444;
  background: rgba(239, 68, 68, 0.05);
}

.history-question p {
  margin: 0.5rem 0;
  font-size: 0.95rem;
}

.history-question p:first-child {
  margin-top: 0;
}

.history-question .correct-answer {
  color: var(--success);
}

/* Buttons */
#retakeQuizBtn,
.primary-btn,
.secondary-btn {
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 6px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-top: 1.5rem;
}

.primary-btn {
  background-color: var(--primary);
  color: white;
}

.primary-btn:hover:not(:disabled) {
  background-color: var(--primary-dark);
  transform: translateY(-2px);
}

.primary-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

#retakeQuizBtn {
  background-color: var(--primary);
  color: white;
}

#retakeQuizBtn:hover {
  background-color: var(--primary-dark);
  transform: translateY(-2px);
}

.secondary-btn {
  background-color: var(--border);
  color: var(--text-primary);
  margin-top: 1.5rem;
}

.secondary-btn:hover {
  background-color: var(--primary);
  color: white;
  transform: translateY(-2px);
}

#backToGeneratorBtn {
  background-color: var(--border);
  color: var(--text-primary);
}

#backToGeneratorBtn:hover {
  background-color: var(--primary);
  color: white;
}

/* Responsive */
@media (max-width: 768px) {
  #quizInputSection {
    padding: 1rem;
  }

  .quiz-container {
    padding: 1rem;
  }

  .quiz-question {
    padding: 1rem;
    margin-bottom: 1.5rem;
  }

  .question-text {
    font-size: 1rem;
  }

  .option-label {
    padding: 0.75rem;
    gap: 0.75rem;
  }

  .score-percentage {
    font-size: 2.5rem;
  }

  .quiz-options {
    gap: 0.75rem;
  }

  .quiz-actions {
    gap: 0.75rem;
  }

  .results-summary {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

  .summary-stat {
    padding: 0.75rem;
  }

  .stat-value {
    font-size: 1.5rem;
  }

  #quizPdfUploadBtn,
  #quizGenerateBtn,
  #submitQuizBtn {
    padding: 0.65rem 1rem;
    font-size: 0.9rem;
  }

  .history-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  .attempt-date {
    margin-left: 0;
  }

  .result-item-header {
    flex-direction: column;
    gap: 0.5rem;
  }

  .results-actions button {
    padding: 0.75rem;
    font-size: 0.9rem;
  }
}
