*, *::before, *::after {
  box-sizing: border-box;
  font-family: Calibri, 'Segoe UI', Candara, Segoe, Optima, Arial, sans-serif;
}
input, button, select, textarea {
  font-family: inherit;
}

body {
  background: #f4f6fb;
  margin: 0;
  padding: 2rem;
  color: #1f2430;
  font-family: Calibri, 'Segoe UI', Candara, Segoe, Optima, Arial, sans-serif;
}

.container {
  max-width: 780px;
  margin: auto;
  background: #fff;
  padding: 2rem 2.5rem;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, .08);
}

.header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

h1 { margin: 0; font-size: 1.7rem; color: #0f172a; }

.progress-badge {
  background: #e8f0fe;
  color: #0b57d0;
  font-weight: 600;
  font-size: 0.95rem;
  padding: 4px 14px;
  border-radius: 20px;
  border: 1px solid #d2e3fc;
  user-select: none;
}

/* Start Card & User Registration */
.start-card {
  margin-top: 1.5rem;
  padding: 1.75rem 2rem;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.start-card h2 {
  margin: 0 0 0.5rem;
  font-size: 1.35rem;
  color: #0f172a;
}

.start-desc {
  margin: 0 0 1.25rem;
  color: #64748b;
  font-size: 0.95rem;
  line-height: 1.5;
}

.form-group {
  margin-bottom: 1.2rem;
}

.form-group label {
  display: block;
  font-weight: 600;
  font-size: 0.95rem;
  color: #334155;
  margin-bottom: 0.4rem;
}

.form-group .req {
  color: #ef4444;
}

.form-group input {
  width: 100%;
  padding: 0.65rem 0.85rem;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 1rem;
  color: #0f172a;
  background: #fff;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-group input:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.start-error {
  background: #fef2f2;
  border: 1px solid #fca5a5;
  color: #dc2626;
  padding: 0.6rem 0.85rem;
  border-radius: 6px;
  font-size: 0.9rem;
  margin-bottom: 1rem;
  font-weight: 500;
}

.start-btn {
  padding: 0.7rem 1.5rem;
  font-size: 1.05rem;
  font-weight: 600;
  color: #fff;
  background: #2563eb;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.05s;
}

.start-btn:hover {
  background: #1d4ed8;
}

.start-btn:active {
  transform: translateY(1px);
}

/* User Info Bar (Active session banner during quiz) */
.user-info-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 0.55rem 1rem;
  margin-bottom: 1.5rem;
  font-size: 0.95rem;
  color: #475569;
}

.user-info-bar strong {
  color: #0f172a;
}

/* ========================================================================= */
/* Question Cards (Show All Questions, 1 Active Moving Input Widget)        */
/* ========================================================================= */

.question {
  margin-bottom: 1.75rem;
  padding: 1.5rem;
  border: 1.5px solid #e2e8f0;
  border-radius: 10px;
  background: #ffffff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .03);
  transition: border-color .2s ease, box-shadow .2s ease, background-color .2s ease;
  scroll-margin-top: 1.5rem;
}

.question.current {
  border-color: #3b82f6;
  box-shadow: 0 4px 16px rgba(59, 130, 246, .12);
  background: #ffffff;
}

.question.pending {
  border-color: #e2e8f0;
  background: #f8fafc;
  opacity: 0.85;
}

.question.pending .prompt {
  margin-bottom: 0;
}

.question.answered {
  border-color: #cbd5e1;
  background: #ffffff;
}

.active-input-widget {
  animation: fadeInWidget 0.2s ease-in-out;
}

@keyframes fadeInWidget {
  from {
    opacity: 0;
    transform: translateY(3px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.prompt {
  font-weight: 600;
  font-size: 1.15rem;
  margin-bottom: .85rem;
  color: #1e293b;
  line-height: 1.4;
  transition: margin-bottom .15s ease;
}

/* ========================================================================= */
/* Description / Instructions Card (Student View)                            */
/* ========================================================================= */

.quiz-description-card {
  margin-bottom: 1.75rem;
  padding: 1.25rem 1.5rem;
  border: 1px solid #cbd5e1;
  border-left: 5px solid #0b57d0;
  border-radius: 10px;
  background: #f8fafc;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .03);
  scroll-margin-top: 1.5rem;
}

.quiz-description-card .desc-badge {
  display: inline-block;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #1e40af;
  background: #dbeafe;
  padding: 3px 10px;
  border-radius: 4px;
  margin-bottom: 0.75rem;
}

.quiz-description-card .desc-content {
  font-size: 1.05rem;
  color: #334155;
  line-height: 1.6;
  white-space: pre-wrap;
}

/* ========================================================================= */
/* Toolbar (Google Sheets / Microsoft Word Style)                            */
/* ========================================================================= */

.toolbar {
  display: flex;
  align-items: center;
  gap: 3px;
  margin-bottom: .5rem;
  background: #f8f9fa;
  padding: 4px 6px;
  border-radius: 6px;
  border: 1px solid #dadce0;
  width: fit-content;
}

.toolbar button {
  border: 1.5px solid transparent;
  background: transparent;
  color: #444746;
  border-radius: 4px;
  padding: 4px 8px;
  cursor: pointer;
  font-size: 15px;
  font-weight: 600;
  transition: all .1s ease;
  user-select: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  line-height: 1;
}

.toolbar button:hover {
  background: #eaecef;
  color: #1f1f1f;
}

/* Distinct Google Docs / Word Active Button Highlighting */
.toolbar button.active {
  background: #c2e7ff !important;
  color: #001d35 !important;
  border-color: #0b57d0 !important;
  box-shadow: 0 1px 3px rgba(11, 87, 208, 0.25) !important;
}

.toolbar button.active b,
.toolbar button.active strong,
.toolbar button.active i,
.toolbar button.active em,
.toolbar button.active u {
  color: #001d35 !important;
  text-decoration-color: #001d35 !important;
}

.toolbar button svg {
  display: block;
}

/* ========================================================================= */
/* Formatted Text (Google Sheets / Word Style)                               */
/* ========================================================================= */

.answer {
  min-height: 48px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: .65rem .85rem;
  background: #fff;
  outline: none;
  font-size: 1.15rem;
  line-height: 1.6;
  color: #0f172a;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, .04);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.answer:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

b, strong {
  font-weight: bold;
}

i, em {
  font-style: italic;
}

u {
  text-decoration: underline;
  text-underline-offset: 2.5px;
  text-decoration-thickness: 1.2px;
  color: inherit;
  background: transparent;
  padding: 0;
}

.correct {
  border-color: #22c55e !important;
  background: #f0fdf4 !important;
}
.wrong {
  border-color: #ef4444 !important;
  background: #fef2f2 !important;
}

.answer.locked {
  cursor: default;
  user-select: text;
}
.answer.locked:focus {
  box-shadow: none !important;
}

/* ========================================================================= */
/* Question Action Row (Check Answer Button)                                 */
/* ========================================================================= */

.question-actions {
  margin-top: .85rem;
  display: flex;
  align-items: center;
  gap: 12px;
}

.nav-btn {
  padding: .6rem 1.3rem;
  font-size: 1rem;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
  transition: all .15s ease;
  user-select: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.nav-btn.check-btn {
  background: #e8f0fe;
  color: #0b57d0;
  border: 1.5px solid #0b57d0;
}
.nav-btn.check-btn:hover:not(:disabled) {
  background: #d2e3fc;
}
.nav-btn.check-btn:disabled {
  opacity: .6;
  cursor: not-allowed;
}

/* ========================================================================= */
/* Feedback & Comparison Box                                                 */
/* ========================================================================= */

.feedback {
  margin-top: .85rem;
  font-size: 1rem;
}
.feedback-msg {
  padding: .85rem 1.15rem;
  border-radius: 8px;
}
.feedback-msg.ok {
  background: #dcfce7;
  color: #15803d;
  font-weight: 600;
  border: 1px solid #bbf7d0;
}
.feedback-msg.no {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
}
.feedback-header {
  font-weight: 700;
  font-size: 1.05rem;
  margin-bottom: .5rem;
}

/* Comparison Box */
.diff-box {
  margin-top: 0.65rem;
  background: #ffffff;
  border: 1px solid #fed7aa;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.diff-row {
  padding: 0.85rem 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.diff-row:not(:last-child) {
  border-bottom: 1px solid #f1f5f9;
}

.diff-label {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.diff-label.user-label {
  color: #b91c1c;
}

.diff-label.expected-label {
  color: #15803d;
}

.diff-content {
  font-size: 1.15rem;
  line-height: 1.6;
  color: #1e293b;
  word-break: break-word;
}

.accepted-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.accepted-citation {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-left: 3.5px solid #16a34a;
  border-radius: 6px;
  padding: 0.55rem 0.85rem;
  font-size: 1.15rem;
  line-height: 1.6;
  color: #14532d;
}

/* ========================================================================= */
/* Explanation Screenshot (Reasoning for Correct Answers)                    */
/* ========================================================================= */

.explanation-box {
  margin-top: 1rem;
  padding-top: 0.85rem;
  border-top: 1px dashed #fca5a5;
  width: 100%;
}

.explanation-header {
  font-weight: 700;
  font-size: 0.95rem;
  color: #991b1b;
  margin-bottom: 0.65rem;
  text-align: left;
}

.explanation-img-container {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  margin: 0.25rem 0;
  text-align: center;
}

.explanation-img-wrap {
  display: inline-flex;
  justify-content: center;
  max-width: 100%;
}

.explanation-img {
  display: block;
  max-width: 100%;
  max-height: 480px;
  height: auto;
  margin: 0 auto;
  border-radius: 8px;
  border: 1px solid #cbd5e1;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  cursor: zoom-in;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  background: #fff;
}

.explanation-img:hover {
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.15);
}

/* ========================================================================= */
/* Final Quiz Submission Container                                           */
/* ========================================================================= */

.quiz-submit-container {
  margin-top: 1.5rem;
  padding: 1.25rem;
  background: #f8fafc;
  border: 1px dashed #cbd5e1;
  border-radius: 10px;
  display: flex;
  justify-content: center;
  align-items: center;
  scroll-margin-top: 1.5rem;
}

.nav-btn.submit-btn {
  background: #16a34a;
  color: #fff;
  border: 1px solid #16a34a;
  padding: .75rem 2rem;
  font-size: 1.1rem;
}
.nav-btn.submit-btn:hover:not(:disabled) {
  background: #15803d;
}
.nav-btn.submit-btn:disabled {
  opacity: .6;
  cursor: not-allowed;
}

/* ========================================================================= */
/* Final Score / Results Container                                           */
/* ========================================================================= */

#score-box {
  margin-top: 1.5rem;
  padding: 1.5rem;
  border-radius: 12px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
}
.score-header {
  font-size: 1.5rem;
  font-weight: 700;
  color: #1e40af;
  text-align: center;
  margin-bottom: 1rem;
}
.results-summary {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}
.result-card {
  background: #fff;
  padding: 1.25rem;
  border-radius: 8px;
  border: 1px solid #e2e6ef;
}
.result-card.ok {
  border-left: 5px solid #16a34a;
}
.result-card.no {
  border-left: 5px solid #ef4444;
}

.retake-btn {
  display: block;
  margin: 1.5rem auto 0;
  background: #0b57d0;
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: .7rem 1.5rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}
.retake-btn:hover {
  background: #0842a0;
}

.hidden { display: none !important; }