/**
 * Student Homework Interface Styles
 * Mobile-first, minimalist design
 * Inspired by LingoLugo style guide
 */

/* ========================================
   CSS VARIABLES & BASE
   ======================================== */

:root {
  --base-font-size: 16px;

  /* Colors from style guide */
  --purple-primary: #502f77;
  --purple-deep: #511774;
  --blue-light: rgb(155, 225, 255);
  --blue-lightest: #d9f2fd;
  --text-dark: #4a4a4a;
  --text-muted: #666;
  --white: #ffffff;
  --gray-light: #f5f5f5;
  --gray-border: #e0e0e0;

  /* Feedback colors */
  --green-success: #4caf50;
  --green-bg: #e8f5e9;
  --orange-warning: #ff9800;
  --orange-bg: #fff3e0;
  --red-error: #f44336;
  --red-bg: #ffebee;
  --blue-info: #2196f3;
  --blue-bg: #e3f2fd;

  /* Spacing */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;

  /* Border radius */
  --radius-sm: 5px;
  --radius-md: 10px;
  --radius-lg: 15px;
  --radius-round: 50px;
}

/* ========================================
   CONTAINER & LAYOUT (MOBILE FIRST)
   ======================================== */

.student-homework {
  min-height: 100vh;
  background-color: var(--blue-lightest);
  padding: var(--space-md);
  font-size: var(--base-font-size);
  font-family: "Lexend Deca", "Noto Sans", Helvetica, sans-serif;
  color: var(--text-dark);
}

.student-homework .container {
  max-width: 1200px;
  margin: 0 auto;
}

/* ========================================
   TYPOGRAPHY
   ======================================== */

.student-homework h1 {
  color: var(--purple-primary);
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: var(--space-lg);
  text-align: center;
}

/* ========================================
   TABS
   ======================================== */

.homework-tabs {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  margin-bottom: var(--space-lg);
}

.tab-btn {
  background: var(--white);
  border: 2px solid var(--gray-border);
  color: var(--text-dark);
  padding: 0.75rem var(--space-md);
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
}

.tab-btn:active {
  transform: scale(0.98);
}

.tab-btn.active {
  background: var(--purple-primary);
  color: var(--white);
  border-color: var(--purple-primary);
}

.tab-btn .badge {
  background: var(--red-error);
  color: var(--white);
  border-radius: 50%;
  min-width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 600;
}

.tab-btn.active .badge {
  background: var(--white);
  color: var(--purple-primary);
}

/* ========================================
   HOMEWORK CARDS
   ======================================== */

.homework-cards {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.homework-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  overflow: hidden;
}

.homework-card.completed {
  border-left: 4px solid var(--green-success);
}

.homework-card.practice {
  border-left: 4px solid var(--blue-info);
}

.homework-card.late-submission {
  border-left: 4px solid var(--orange-warning);
}

.card-header {
  background: var(--purple-primary);
  color: var(--white);
  padding: var(--space-md);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.card-header h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.4;
}

.due-date,
.score-badge,
.level-badge {
  display: inline-block;
  background: rgba(255, 255, 255, 0.2);
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-round);
  font-size: 0.8rem;
  font-weight: 500;
  align-self: flex-start;
}

.due-date.overdue {
  background: var(--red-error);
}

.score-badge {
  background: var(--white);
  color: var(--purple-primary);
  font-weight: 600;
}

.card-body {
  padding: var(--space-md);
}

.card-body p {
  color: var(--text-muted);
  line-height: 1.5;
  margin: 0 0 var(--space-md) 0;
  font-size: 0.9rem;
}

.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-md);
  margin-bottom: var(--space-sm);
}

.card-meta span {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  color: var(--text-muted);
  font-size: 0.85rem;
}

.card-meta svg {
  color: var(--purple-primary);
  width: 16px;
  height: 16px;
}

.progress {
  color: var(--text-muted);
  font-size: 0.85rem;
  font-style: italic;
}

.completion-info {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  color: var(--text-muted);
  font-size: 0.85rem;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  margin-top: var(--space-md);
}

.tag-chip {
  background: var(--blue-lightest);
  color: var(--purple-primary);
  padding: 0.25rem 0.75rem;
  border-radius: var(--radius-round);
  font-size: 0.75rem;
  font-weight: 500;
}

/* Card Actions */
.card-actions {
  padding: var(--space-md);
  background: var(--gray-light);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.start-btn,
.view-results-btn,
.retry-btn {
  width: 100%;
  padding: 0.875rem var(--space-lg);
  border: none;
  border-radius: var(--radius-md);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  min-height: 48px; /* Touch-friendly */
}

.start-btn {
  background: var(--purple-primary);
  color: var(--blue-light);
}

.start-btn:active:not(:disabled) {
  transform: scale(0.98);
}

.start-btn:disabled {
  opacity: 0.7;
  cursor: wait;
}

.btn-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: var(--white);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.view-results-btn {
  background: var(--white);
  color: var(--purple-primary);
  border: 2px solid var(--purple-primary);
}

.retry-btn {
  background: var(--orange-warning);
  color: var(--white);
}

/* Print Button (on cards) */
.print-btn {
  background: var(--white);
  color: var(--purple-primary);
  border: 2px solid var(--gray-border);
  border-radius: var(--radius-md);
  padding: 0.5rem;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
}

.print-btn:hover {
  border-color: var(--purple-primary);
  background: var(--blue-lightest);
}

.print-btn:active {
  transform: scale(0.95);
}

.print-btn svg {
  width: 18px;
  height: 18px;
}

/* Print Exercise Button (on instructions screen) */
.print-exercise-btn {
  background: var(--white);
  color: var(--purple-primary);
  border: 2px solid var(--purple-primary);
  border-radius: var(--radius-md);
  padding: 0.75rem 1.25rem;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.print-exercise-btn:hover {
  background: var(--blue-lightest);
}

.print-exercise-btn:active {
  transform: scale(0.98);
}

.print-exercise-btn svg {
  width: 18px;
  height: 18px;
}

/* Instructions Actions Container */
.instructions-actions {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  margin-top: var(--space-lg);
  align-items: center;
}

@media (min-width: 480px) {
  .instructions-actions {
    flex-direction: row;
    justify-content: center;
  }
}

/* Exercise item actions (in modal) */
.exercise-item-actions {
  display: flex;
  gap: var(--space-sm);
  align-items: center;
  margin-top: var(--space-md);
}

.exercise-item-actions .print-btn {
  padding: 0.4rem;
  min-width: 36px;
  min-height: 36px;
}

.exercise-item-actions .print-btn svg {
  width: 16px;
  height: 16px;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: var(--space-xl);
  color: var(--text-muted);
}

.empty-state svg {
  margin-bottom: var(--space-md);
  opacity: 0.5;
  color: var(--purple-primary);
}

.empty-state p {
  font-size: 1rem;
}

/* Practice Info */
.practice-info {
  background: var(--blue-bg);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  margin-bottom: var(--space-md);
  color: var(--text-dark);
  text-align: center;
  font-size: 0.9rem;
}

/* Multi-Exercise Info */
.multi-exercise-info {
  background: var(--gray-light);
  padding: var(--space-md);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-md);
  border-left: 3px solid var(--purple-primary);
}

.exercise-progress-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-sm);
}

.progress-text {
  font-size: 0.9rem;
  color: var(--text-dark);
}

.passed-count {
  color: var(--green-success);
  font-weight: 500;
  font-size: 0.9rem;
}

.aggregate-score {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.score-badge-small {
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-round);
  font-size: 0.8rem;
  font-weight: 600;
}

/* ========================================
   EXERCISE VIEW
   ======================================== */

.exercise-container {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  overflow: hidden;
  max-width: 900px;
  margin: 0 auto;
}

.exercise-header {
  background: var(--purple-primary);
  padding: var(--space-md);
  color: var(--white);
}

.back-link {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.9);
  cursor: pointer;
  font-size: 0.9rem;
  padding: var(--space-sm);
  margin: calc(-1 * var(--space-sm));
  margin-bottom: var(--space-sm);
  display: inline-block;
  transition: color 0.2s;
}

.back-link:active {
  color: var(--white);
}

.progress-bar {
  background: rgba(255, 255, 255, 0.2);
  height: 6px;
  border-radius: 3px;
  margin-bottom: var(--space-md);
  overflow: hidden;
}

.progress-fill {
  background: var(--white);
  height: 100%;
  border-radius: 3px;
  transition: width 0.3s ease;
}

.exercise-requirements {
  background: var(--white);
  border-radius: var(--radius-sm);
  padding: var(--space-sm) var(--space-md);
  margin-bottom: var(--space-md);
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-md);
  font-size: 0.85rem;
  color: var(--text-dark);
}

/* Controls Bar */
.exercise-controls-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-sm) var(--space-md);
  color: var(--white);
  font-size: 0.9rem;
}

.question-counter {
  font-weight: 600;
}

.timer-display {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  font-variant-numeric: tabular-nums;
}

.feedback-toggle-inline {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-left: auto;
}

.toggle-label {
  font-size: 0.8rem;
}

.toggle-switch {
  position: relative;
  width: 44px;
  height: 24px;
  cursor: pointer;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 12px;
  transition: background 0.2s;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  left: 3px;
  top: 3px;
  background: var(--white);
  border-radius: 50%;
  transition: transform 0.2s;
}

.toggle-switch input:checked + .toggle-slider {
  background: rgba(255, 255, 255, 0.5);
}

.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(20px);
}

.settings-button-inline {
  background: rgba(255, 255, 255, 0.15);
  border: none;
  border-radius: var(--radius-sm);
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s;
}

.settings-button-inline:active {
  background: rgba(255, 255, 255, 0.25);
}

.settings-button-inline svg {
  width: 18px;
  height: 18px;
  color: var(--white);
}

/* Question Progress Bar */
.question-progress-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding-top: var(--space-md);
  margin-top: var(--space-sm);
  border-top: 1px solid rgba(255, 255, 255, 0.2);
}

.question-badge {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.2);
  color: var(--white);
  border: 2px solid transparent;
}

.question-badge.correct {
  background: var(--green-success);
}

.question-badge.incorrect {
  background: var(--red-error);
}

.question-badge.current {
  border-color: var(--white);
  transform: scale(1.1);
}

/* Cyclical Progress */
.cyclical-progress {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  background: rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-sm);
  margin-top: var(--space-sm);
  font-size: 0.85rem;
}

.cycle-badge {
  background: var(--white);
  color: var(--purple-primary);
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-round);
  font-size: 0.8rem;
}

/* ========================================
   EXERCISE CONTENT
   ======================================== */

.exercise-content {
  padding: var(--space-md);
  min-height: 300px;
}

.instructions {
  text-align: center;
  padding: var(--space-lg) 0;
}

.instructions h2 {
  color: var(--purple-primary);
  margin-bottom: var(--space-md);
  font-size: 1.25rem;
}

.instructions p {
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: var(--space-lg);
}

.teacher-message {
  background: var(--blue-bg);
  border-left: 3px solid var(--blue-info);
  border-radius: var(--radius-sm);
  padding: var(--space-md);
  margin-bottom: var(--space-lg);
  text-align: left;
}

.teacher-message p {
  color: var(--text-dark);
  margin: 0;
  white-space: pre-wrap;
}

.continue-btn {
  background: var(--purple-primary);
  color: var(--blue-light);
  padding: var(--space-md) var(--space-xl);
  border: none;
  border-radius: var(--radius-md);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  min-height: 48px;
}

.reading-text {
  background: var(--gray-light);
  padding: var(--space-md);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-lg);
  border-left: 3px solid var(--purple-primary);
}

.reading-text h3 {
  color: var(--purple-primary);
  margin-bottom: var(--space-sm);
  font-size: 1rem;
}

.question-container {
  margin-top: var(--space-md);
}

.question-text {
  color: var(--text-dark);
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: var(--space-lg);
  line-height: 1.6;
}

.original-text-context {
  color: var(--text-muted);
  font-size: 0.9rem;
  font-style: italic;
  margin-bottom: var(--space-md);
  padding: var(--space-md);
  background: var(--gray-light);
  border-left: 3px solid var(--purple-primary);
  border-radius: var(--radius-sm);
  line-height: 1.5;
}

/* Options */
.options-container {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.options-container.true-false {
  flex-direction: row;
  gap: var(--space-md);
}

.option-label {
  display: flex;
  align-items: center;
  padding: var(--space-md);
  border: 2px solid var(--gray-border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s ease;
  min-height: 48px;
}

.option-label:active {
  transform: scale(0.99);
}

.option-label.selected {
  border-color: var(--purple-primary);
  background: rgba(80, 47, 119, 0.05);
}

.option-label.correct {
  border-color: var(--green-success);
  background: var(--green-bg);
}

.option-label.incorrect {
  border-color: var(--red-error);
  background: var(--red-bg);
}

.option-label input[type="radio"] {
  margin-right: var(--space-md);
  width: 20px;
  height: 20px;
  cursor: pointer;
  flex-shrink: 0;
}

.option-text {
  flex: 1;
  color: var(--text-dark);
  line-height: 1.5;
}

.feedback-icon {
  margin-left: var(--space-sm);
  font-size: 1.1rem;
  font-weight: 700;
  flex-shrink: 0;
}

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

.feedback-icon.incorrect {
  color: var(--red-error);
}

/* Feedback Container */
.feedback-container {
  margin-top: var(--space-lg);
  padding: var(--space-md);
  border-radius: var(--radius-md);
  border-left: 4px solid;
}

.feedback-container.correct {
  background: var(--green-bg);
  border-color: var(--green-success);
  color: #2e7d32;
}

.feedback-container.incorrect {
  background: var(--red-bg);
  border-color: var(--red-error);
  color: #c62828;
}

.feedback-container p:first-child {
  font-weight: 600;
  margin-bottom: var(--space-sm);
}

/* ========================================
   FILL IN BLANKS & GAP FILL
   ======================================== */

.fill-in-blanks-container,
.fill-gap-multiple-container,
.word-formation-container {
  margin: var(--space-lg) 0;
}

.gap-fill-question {
  font-size: 1rem;
  line-height: 1.8;
  color: var(--text-dark);
}

.gap-fill-input {
  display: inline-block;
  min-width: 80px;
  max-width: 180px;
  padding: 0.4rem 0.6rem;
  border: 2px solid var(--gray-border);
  border-radius: var(--radius-sm);
  font-size: inherit;
  font-family: inherit;
  transition: border-color 0.2s;
  vertical-align: baseline;
}

.gap-fill-input:focus {
  outline: none;
  border-color: var(--purple-primary);
}

.gap-fill-input.correct {
  border-color: var(--green-success);
  background: var(--green-bg);
}

.gap-fill-input.incorrect {
  border-color: var(--red-error);
  background: var(--red-bg);
}

.gap-fill-input:disabled {
  background: var(--gray-light);
  cursor: not-allowed;
}

.hint-text {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-top: var(--space-sm);
  font-style: italic;
}

/* Transformation */
.transformation-container {
  margin: var(--space-lg) 0;
}

.transformation-container .original-sentence,
.transformation-container .transform-instruction {
  padding: var(--space-md);
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-md);
}

.transformation-container .original-sentence {
  background: var(--gray-light);
  border-left: 3px solid var(--purple-primary);
}

.transformation-container .transform-instruction {
  background: var(--blue-bg);
  border-left: 3px solid var(--blue-info);
}

.transformation-container .text-input {
  width: 100%;
  padding: var(--space-md);
  border: 2px solid var(--gray-border);
  border-radius: var(--radius-md);
  font-size: 1rem;
  font-family: inherit;
  resize: vertical;
  min-height: 80px;
  transition: border-color 0.2s;
}

.transformation-container .text-input:focus {
  outline: none;
  border-color: var(--purple-primary);
}

.transformation-container .text-input.correct {
  border-color: var(--green-success);
  background: var(--green-bg);
}

.transformation-container .text-input.incorrect {
  border-color: var(--red-error);
  background: var(--red-bg);
}

/* Description (info box) */
.description-container .info-box {
  background: var(--blue-bg) !important;
  border: 2px solid var(--blue-info) !important;
  border-radius: var(--radius-md) !important;
  padding: var(--space-lg) !important;
}

/* ========================================
   MATCHING QUESTION
   ======================================== */

.matching-container {
  margin: var(--space-lg) 0;
}

.matching-instructions {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: var(--space-lg);
  font-style: italic;
}

.matching-columns {
  display: grid;
  grid-template-columns: 1fr 2rem 1fr;
  gap: var(--space-md);
  position: relative;
  min-height: 300px;
  align-items: center;
}

.matching-column {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.matching-item {
  background: var(--white);
  border: 2px solid var(--gray-border);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  display: flex;
  align-items: center;
  min-height: 44px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.matching-item:active {
  transform: scale(0.98);
}

.matching-item.selected {
  border-color: var(--purple-primary);
  background: rgba(80, 47, 119, 0.05);
}

.matching-item.connected {
  border-color: var(--green-success);
  background: var(--green-bg);
}

.left-item {
  justify-content: space-between;
}

.right-item {
  justify-content: flex-start;
}

.item-text {
  color: var(--text-dark);
  font-size: 0.9rem;
  line-height: 1.4;
  flex: 1;
}

.match-connector {
  width: 10px;
  height: 10px;
  background: var(--purple-primary);
  border-radius: 50%;
  flex-shrink: 0;
}

.left-item .match-connector {
  margin-left: var(--space-sm);
}

.right-item .match-connector {
  margin-right: var(--space-sm);
}

.matching-svg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
  grid-column: 1 / -1;
  grid-row: 1;
}

.connection-line {
  stroke-width: 2;
  fill: none;
}

/* ========================================
   NAVIGATION
   ======================================== */

.exercise-navigation {
  padding: var(--space-md);
  background: var(--gray-light);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.nav-btn {
  width: 100%;
  padding: var(--space-md);
  border: none;
  border-radius: var(--radius-md);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  min-height: 48px;
}

.prev-btn {
  background: var(--white);
  color: var(--purple-primary);
  border: 2px solid var(--purple-primary);
}

.next-btn,
.submit-btn {
  background: var(--purple-primary);
  color: var(--blue-light);
}

.nav-btn:active:not(:disabled) {
  transform: scale(0.98);
}

.nav-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ========================================
   RESULTS VIEW
   ======================================== */

.results-container {
  max-width: 900px;
  margin: 0 auto;
}

.results-container .container {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.results-container h1 {
  color: var(--purple-primary);
  text-align: center;
  margin-bottom: var(--space-lg);
  font-size: 1.5rem;
}

.score-display {
  text-align: center;
  margin-bottom: var(--space-xl);
}

.score-circle {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto var(--space-md);
  border: 6px solid;
}

.score-number {
  font-size: 2rem;
  font-weight: 700;
}

.score-text {
  color: var(--text-muted);
  font-size: 1rem;
}

.score-breakdown {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-top: var(--space-sm);
  font-style: italic;
}

/* Score Badge Colors */
.badge-bright-green,
.score-circle.badge-bright-green {
  background: var(--green-bg);
  border-color: var(--green-success);
  color: #2e7d32;
}

.badge-light-green,
.score-circle.badge-light-green {
  background: #f1f8e9;
  border-color: #8bc34a;
  color: #558b2f;
}

.badge-light-orange,
.score-circle.badge-light-orange {
  background: var(--orange-bg);
  border-color: var(--orange-warning);
  color: #e65100;
}

.badge-light-red,
.score-circle.badge-light-red {
  background: var(--red-bg);
  border-color: var(--red-error);
  color: #c62828;
}

.badge-gray {
  background: var(--gray-light);
  border-color: #9e9e9e;
  color: #616161;
}

/* Completion Alerts */
.completion-alert {
  margin: var(--space-lg) 0;
}

.alert {
  padding: var(--space-md);
  border-radius: var(--radius-md);
  border-left: 4px solid;
  margin-bottom: var(--space-md);
  font-size: 0.9rem;
  line-height: 1.5;
}

.alert-success {
  background: var(--green-bg);
  border-color: var(--green-success);
  color: #155724;
}

.alert-warning {
  background: var(--orange-bg);
  border-color: var(--orange-warning);
  color: #856404;
}

.alert-info {
  background: var(--blue-bg);
  border-color: var(--blue-info);
  color: #0c5460;
}

/* Question Review */
.incorrect-questions {
  margin-top: var(--space-xl);
}

.incorrect-questions h3 {
  color: var(--purple-primary);
  margin-bottom: var(--space-lg);
  font-size: 1.1rem;
}

.review-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.review-item {
  background: var(--gray-light);
  padding: var(--space-md);
  border-radius: var(--radius-md);
  border-left: 4px solid var(--red-error);
}

.review-item.correct-review {
  border-color: var(--green-success);
  background: var(--green-bg);
}

.review-item.incorrect-review {
  border-color: var(--red-error);
  background: var(--red-bg);
}

.review-item h4 {
  color: var(--purple-primary);
  margin-bottom: var(--space-sm);
  font-size: 0.95rem;
}

.review-item .question-text {
  font-weight: 500;
  margin-bottom: var(--space-md);
}

.your-answer {
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
}

.your-answer.correct-display {
  background: rgba(76, 175, 80, 0.15);
  color: #2e7d32;
}

.your-answer.incorrect-display {
  background: rgba(244, 67, 54, 0.15);
  color: #c62828;
}

/* Perfect Score */
.perfect-score {
  text-align: center;
  padding: var(--space-lg);
  background: var(--green-bg);
  border-radius: var(--radius-md);
  margin-top: var(--space-lg);
}

.perfect-score svg {
  color: var(--green-success);
  margin-bottom: var(--space-sm);
}

.perfect-score h3 {
  color: #2e7d32;
  margin-bottom: var(--space-sm);
}

.perfect-score p {
  color: #388e3c;
}

/* Results Actions */
.results-actions {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  margin-top: var(--space-xl);
}

.btn {
  width: 100%;
  padding: var(--space-md);
  border: none;
  border-radius: var(--radius-md);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  min-height: 48px;
}

.btn-primary {
  background: var(--purple-primary);
  color: var(--blue-light);
}

.btn-secondary {
  background: var(--white);
  color: var(--purple-primary);
  border: 2px solid var(--purple-primary);
}

/* Cyclical Results */
.cyclical-results {
  text-align: center;
}

.cyclical-results .main-result {
  font-size: 1rem;
  color: var(--text-dark);
  margin: var(--space-md) 0;
}

.cycle-breakdown {
  margin-top: var(--space-lg);
  text-align: left;
  background: var(--gray-light);
  border-radius: var(--radius-md);
  padding: var(--space-md);
}

.cycle-breakdown summary {
  cursor: pointer;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.breakdown-content {
  margin-top: var(--space-md);
  padding-top: var(--space-md);
  border-top: 1px solid var(--gray-border);
}

.breakdown-intro {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: var(--space-md);
}

.cycle-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.cycle-item {
  display: flex;
  justify-content: space-between;
  font-size: 0.9rem;
  padding: var(--space-xs) 0;
}

.breakdown-total {
  margin-top: var(--space-md);
  padding-top: var(--space-sm);
  border-top: 1px solid var(--gray-border);
  font-size: 0.9rem;
}

.cyclical-results .encouragement {
  margin-top: var(--space-md);
  font-size: 0.9rem;
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-sm);
}

.cyclical-results .encouragement.success {
  background: var(--green-bg);
  color: #2e7d32;
}

.cyclical-results .encouragement.good {
  background: var(--orange-bg);
  color: #e65100;
}

.cyclical-results .encouragement.keep-going {
  background: var(--blue-bg);
  color: #1565c0;
}

/* ========================================
   MODALS
   ======================================== */

.modal,
.settings-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: var(--space-md);
}

.modal-content,
.settings-modal-content {
  background: var(--white);
  border-radius: var(--radius-lg);
  max-width: 500px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.exercise-selection-modal {
  max-width: 800px;
}

.modal-header {
  background: var(--purple-primary);
  color: var(--white);
  padding: var(--space-md) var(--space-lg);
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.modal-header h3 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
}

.close-btn {
  background: none;
  border: none;
  color: var(--white);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  padding: var(--space-sm);
  margin: calc(-1 * var(--space-sm));
  border-radius: var(--radius-sm);
}

.modal-body {
  padding: var(--space-lg);
}

/* Exercise List */
.exercise-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.exercise-item {
  background: var(--gray-light);
  border: 2px solid var(--gray-border);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  transition: border-color 0.2s;
}

.exercise-item:active {
  border-color: var(--purple-primary);
}

.exercise-item-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-sm);
}

.exercise-number {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--purple-primary);
}

.exercise-item-header h4 {
  flex: 1;
  margin: 0;
  font-size: 1rem;
  min-width: 0;
}

.status-badge {
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-round);
  font-size: 0.75rem;
  font-weight: 600;
}

.status-not-started {
  background: var(--gray-light);
  color: #616161;
}

.status-passed {
  background: var(--green-bg);
  color: #2e7d32;
}

.status-passed-late {
  background: var(--orange-bg);
  color: #e65100;
}

.status-max-attempts,
.status-max-late {
  background: var(--red-bg);
  color: #c62828;
}

.status-in-progress {
  background: var(--blue-bg);
  color: #1565c0;
}

.exercise-description {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin: 0 0 var(--space-sm) 0;
  line-height: 1.4;
}

.exercise-item-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-md);
  margin-bottom: var(--space-md);
  font-size: 0.85rem;
  color: var(--text-muted);
}

.exercise-item-meta .best-score {
  color: var(--green-success);
  font-weight: 500;
}

.exercise-item-actions button {
  width: 100%;
  padding: 0.75rem var(--space-lg);
  background: var(--purple-primary);
  color: var(--blue-light);
  border: none;
  border-radius: var(--radius-md);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  min-height: 44px;
}

.exercise-item-actions button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Settings Modal */
.settings-modal-content {
  padding: var(--space-lg);
}

.settings-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-lg);
  padding-bottom: var(--space-md);
  border-bottom: 2px solid var(--gray-light);
}

.settings-modal-header h2 {
  margin: 0;
  color: var(--text-dark);
  font-size: 1.25rem;
}

.settings-close-btn {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--text-muted);
  cursor: pointer;
  padding: var(--space-sm);
  margin: calc(-1 * var(--space-sm));
}

.settings-section {
  margin-bottom: var(--space-lg);
}

.settings-section h3 {
  color: var(--purple-primary);
  font-size: 1rem;
  margin: 0 0 var(--space-md) 0;
}

.font-size-controls {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-sm);
}

.font-size-btn {
  padding: 0.75rem;
  border: 2px solid var(--gray-border);
  background: var(--white);
  border-radius: var(--radius-md);
  cursor: pointer;
  font-weight: 500;
  transition: all 0.2s;
  text-align: center;
  min-height: 44px;
}

.font-size-btn.active {
  border-color: var(--purple-primary);
  background: var(--purple-primary);
  color: var(--white);
}

.dark-mode-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md);
  background: var(--gray-light);
  border-radius: var(--radius-md);
}

.dark-mode-toggle.dark-mode-disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.theme-options {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.theme-option {
  display: flex;
  align-items: center;
  padding: var(--space-md);
  border: 2px solid var(--gray-border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s;
}

.theme-option.disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background: var(--gray-light);
}

.theme-option.active {
  border-color: var(--purple-primary);
}

.theme-option input[type="radio"] {
  margin-right: var(--space-md);
  width: 20px;
  height: 20px;
}

.theme-option-label {
  flex: 1;
  font-weight: 500;
}

.coming-soon-badge {
  background: #ffd93d;
  color: #333;
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-round);
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
}

/* Cycle Transition Overlay */
.cycle-transition {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.3s ease-out;
}

.cycle-message {
  background: var(--white);
  padding: var(--space-xl);
  border-radius: var(--radius-lg);
  text-align: center;
  animation: scaleIn 0.3s ease-out;
}

.cycle-message .transition-icon {
  font-size: 2.5rem;
  margin-bottom: var(--space-sm);
}

.cycle-message h3 {
  font-size: 1.25rem;
  margin: 0 0 var(--space-sm) 0;
  color: var(--text-dark);
}

.cycle-message .transition-detail {
  color: var(--text-muted);
  margin: 0;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* ========================================
   WRITING CORRECTION
   ======================================== */

.writing-correction-container {
  position: relative;
  background: var(--white);
  border: 2px solid var(--blue-info);
  border-radius: var(--radius-lg);
  padding: var(--space-md);
  margin: var(--space-md) 0;
}

.wc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  margin-bottom: var(--space-md);
  padding-bottom: var(--space-md);
  border-bottom: 1px solid var(--gray-border);
}

.wc-header-info {
  flex: 1;
  min-width: 0;
}

.wc-title {
  margin: 0 0 var(--space-xs) 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-dark);
}

.wc-date {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.wc-progress-circle {
  position: relative;
  width: 50px;
  height: 50px;
  flex-shrink: 0;
}

.wc-progress-ring {
  position: absolute;
  width: 100%;
  height: 100%;
}

.wc-progress-bar {
  transition: stroke-dasharray 0.3s ease;
}

.wc-progress-text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-dark);
}

.wc-dim-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 90;
}

.wc-text-container {
  font-size: 1rem;
  line-height: 1.8;
  color: var(--text-dark);
}

.wc-highlighted-text {
  white-space: pre-wrap;
}

.wc-span {
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 3px;
  transition: all 0.2s;
}

.wc-mistake-span {
  background-color: rgba(255, 180, 180, 0.6);
  border-bottom: 2px solid var(--red-error);
}

.wc-mistake-corrected {
  background-color: rgba(180, 255, 180, 0.6);
  border-bottom: 2px solid var(--green-success);
  cursor: default;
}

.wc-tip-span {
  background-color: rgba(180, 255, 180, 0.5);
  border-bottom: 2px dashed var(--green-success);
}

.wc-span-active {
  position: relative;
  z-index: 95;
  background-color: #ffcdd2 !important;
  box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.9), 0 0 12px rgba(0, 0, 0, 0.3);
}

.wc-input-tooltip {
  position: absolute;
  z-index: 100;
  background: var(--white);
  border: 2px solid var(--blue-info);
  border-radius: var(--radius-md);
  padding: var(--space-sm);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  left: var(--space-sm);
  right: var(--space-sm);
}

.wc-input-tooltip::after {
  content: '';
  position: absolute;
  bottom: -10px;
  left: 20px;
  border-left: 10px solid transparent;
  border-right: 10px solid transparent;
  border-top: 10px solid var(--white);
}

.wc-input-tooltip::before {
  content: '';
  position: absolute;
  bottom: -13px;
  left: 18px;
  border-left: 12px solid transparent;
  border-right: 12px solid transparent;
  border-top: 12px solid var(--blue-info);
}

.wc-input-field {
  flex: 1;
  min-width: 0;
  padding: 0.6rem 0.8rem;
  border: 2px solid var(--gray-border);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s;
}

.wc-input-field:focus {
  border-color: var(--blue-info);
}

.wc-input-field.wc-input-error {
  animation: shake 0.5s ease;
  border-color: var(--red-error);
  background: var(--red-bg);
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-5px); }
  40%, 80% { transform: translateX(5px); }
}

.wc-tooltip-buttons {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.wc-hint-btn {
  background: var(--gray-light);
  border: none;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s;
  color: var(--text-muted);
}

.wc-hint-btn:active {
  background: var(--gray-border);
}

.wc-info-icon {
  font-family: Georgia, serif;
  font-style: italic;
  font-weight: bold;
  font-size: 16px;
}

.wc-info-tooltip {
  position: absolute;
  bottom: calc(100% + 10px);
  left: 0;
  right: 0;
  background: #333;
  color: var(--white);
  border-radius: var(--radius-md);
  padding: 0.6rem 0.8rem;
  font-size: 0.9rem;
  line-height: 1.4;
  z-index: 110;
}

.wc-info-tooltip::after {
  content: '';
  position: absolute;
  bottom: -8px;
  left: 50%;
  transform: translateX(-50%);
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-top: 8px solid #333;
}

.wc-tip-tooltip {
  position: absolute;
  z-index: 100;
  background: #333;
  color: var(--white);
  border-radius: var(--radius-md);
  padding: 0.75rem var(--space-md);
  max-width: 280px;
  font-size: 0.9rem;
  line-height: 1.5;
}

.wc-tip-tooltip::before {
  content: '';
  position: absolute;
  top: -8px;
  left: 20px;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-bottom: 8px solid #333;
}

.wc-tip-tooltip p {
  margin: 0;
}

.wc-completion-message {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  background: var(--green-bg);
  border: 2px solid var(--green-success);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  margin-top: var(--space-lg);
  color: #155724;
  font-weight: 500;
}

.wc-completion-message svg {
  color: var(--green-success);
  flex-shrink: 0;
}

/* Hidden answers */
.wc-hidden-answer {
  background: rgba(255, 255, 255, 0.2);
  padding: 0 4px;
  border-radius: 3px;
}

/* Tip span tooltips for desktop */
.wc-tip-span[data-tip-text]::after {
  content: attr(data-tip-text);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  background: #333;
  color: var(--white);
  padding: 0.6rem var(--space-md);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  line-height: 1.4;
  min-width: 150px;
  max-width: 250px;
  width: max-content;
  white-space: normal;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s, visibility 0.2s;
  z-index: 200;
  pointer-events: none;
}

.wc-tip-span[data-tip-text]::before {
  content: '';
  position: absolute;
  bottom: calc(100% + 2px);
  left: 10px;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 6px solid #333;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s, visibility 0.2s;
  z-index: 200;
}

@media (hover: hover) {
  .wc-tip-span[data-tip-text]:hover::after,
  .wc-tip-span[data-tip-text]:hover::before {
    opacity: 1;
    visibility: visible;
  }
}

/* ========================================
   UTILITY & MISC
   ======================================== */

[x-cloak] {
  display: none !important;
}

/* ========================================
   TABLET BREAKPOINT (min-width: 640px)
   ======================================== */

@media (min-width: 640px) {
  .student-homework {
    padding: var(--space-lg);
  }

  .student-homework h1 {
    font-size: 2rem;
  }

  .homework-tabs {
    flex-direction: row;
    justify-content: center;
  }

  .tab-btn {
    padding: 0.75rem var(--space-lg);
  }

  .homework-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: var(--space-lg);
  }

  .card-header {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }

  .due-date,
  .score-badge,
  .level-badge {
    align-self: auto;
  }

  .card-actions {
    flex-direction: row;
    justify-content: flex-end;
  }

  .start-btn,
  .view-results-btn,
  .retry-btn {
    width: auto;
    min-width: 140px;
  }

  .exercise-content {
    padding: var(--space-lg);
  }

  .exercise-navigation {
    flex-direction: row;
    justify-content: flex-end;
  }

  .nav-btn {
    width: auto;
    min-width: 140px;
  }

  .results-actions {
    flex-direction: row;
    justify-content: center;
  }

  .btn {
    width: auto;
    min-width: 180px;
  }

  .font-size-controls {
    grid-template-columns: repeat(4, 1fr);
  }

  .question-badge {
    width: 32px;
    height: 32px;
    font-size: 0.8rem;
  }

  .matching-columns {
    gap: var(--space-lg);
  }

  .score-circle {
    width: 140px;
    height: 140px;
  }

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

/* ========================================
   DESKTOP BREAKPOINT (min-width: 1024px)
   ======================================== */

@media (min-width: 1024px) {
  .homework-tabs {
    gap: var(--space-md);
  }

  .tab-btn {
    padding: 0.875rem var(--space-xl);
    font-size: 1rem;
  }

  .tab-btn:hover {
    background: rgba(80, 47, 119, 0.1);
    border-color: var(--purple-primary);
  }

  .tab-btn.active:hover {
    background: var(--purple-primary);
  }

  .homework-card:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    transform: translateY(-2px);
  }

  .start-btn:hover:not(:disabled) {
    background: var(--purple-deep);
  }

  .view-results-btn:hover {
    background: var(--purple-primary);
    color: var(--white);
  }

  .retry-btn:hover {
    background: #f57c00;
  }

  .option-label:hover {
    border-color: var(--purple-primary);
    background: rgba(80, 47, 119, 0.03);
  }

  .nav-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  }

  .btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  }

  .matching-item:hover {
    border-color: var(--purple-primary);
    box-shadow: 0 2px 8px rgba(80, 47, 119, 0.15);
  }

  .exercise-item:hover {
    border-color: var(--purple-primary);
    box-shadow: 0 2px 8px rgba(80, 47, 119, 0.1);
  }

  .font-size-btn:hover {
    border-color: var(--purple-primary);
    background: rgba(80, 47, 119, 0.05);
  }

  .settings-button-inline:hover {
    background: rgba(255, 255, 255, 0.25);
  }

  .settings-button-inline:hover svg {
    transform: rotate(90deg);
  }

  .wc-hint-btn:hover {
    background: var(--gray-border);
    color: var(--text-dark);
  }
}

/* ========================================
   DARK MODE (for future use)
   ======================================== */

.student-homework.dark-mode {
  background-color: #1a1a2e;
  color: #e0e0e0;
}

.student-homework.dark-mode .homework-card,
.student-homework.dark-mode .exercise-container,
.student-homework.dark-mode .results-container .container,
.student-homework.dark-mode .modal-content,
.student-homework.dark-mode .settings-modal-content {
  background: #2d3548;
  color: #e0e0e0;
}

.student-homework.dark-mode .card-body p,
.student-homework.dark-mode .option-text,
.student-homework.dark-mode .question-text {
  color: #e0e0e0;
}

.student-homework.dark-mode .gray-light,
.student-homework.dark-mode .card-actions,
.student-homework.dark-mode .exercise-navigation {
  background: #1a1a2e;
}

.student-homework.dark-mode .option-label {
  border-color: #404557;
  background: #1a1a2e;
}

.student-homework.dark-mode .option-label:hover {
  border-color: #667eea;
  background: #2d3548;
}

.student-homework.dark-mode .option-label.selected {
  background: rgba(102, 126, 234, 0.2);
}

.student-homework.dark-mode .settings-modal-header {
  border-bottom-color: #404557;
}

.student-homework.dark-mode .font-size-btn {
  background: #1a1a2e;
  border-color: #404557;
  color: #e0e0e0;
}

.student-homework.dark-mode .font-size-btn.active {
  background: var(--purple-primary);
  color: var(--white);
}

.student-homework.dark-mode .theme-option {
  background: #1a1a2e;
  border-color: #404557;
}

.student-homework.dark-mode .theme-option.active {
  border-color: #667eea;
}

/* ========================================
   TAG EXPLANATION CHIP & BOTTOM SHEET
   ======================================== */

/* Tag chip in feedback container */
.tag-explanation-trigger {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
}

.tag-chip-link {
  text-decoration: none;
  display: inline-block;
}

.tag-chip {
  display: inline-block;
  padding: 5px 14px;
  border-radius: 16px;
  background: var(--purple-primary, #502f77);
  color: white;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}

.tag-chip:hover {
  background: #3d2360;
  transform: scale(1.03);
}

.tag-chip:active {
  transform: scale(0.97);
}

/* Bottom sheet overlay */
.tag-sheet-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  z-index: 999;
}

/* Bottom sheet container */
.tag-sheet {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: white;
  border-radius: 16px 16px 0 0;
  z-index: 1000;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), height 0.3s ease;
  height: 55vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
}

.tag-sheet.open {
  transform: translateY(0);
}

.tag-sheet.full {
  height: 92vh;
}

/* Handle bar for swipe gesture */
.tag-sheet-handle {
  padding: 12px 0 4px;
  text-align: center;
  cursor: grab;
  flex-shrink: 0;
}

.tag-sheet-handle-bar {
  width: 40px;
  height: 4px;
  background: #d0d0d0;
  border-radius: 2px;
  margin: 0 auto;
}

/* Header */
.tag-sheet-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 16px 10px;
  flex-shrink: 0;
}

.tag-sheet-header h3 {
  font-size: 1.1rem;
  font-weight: 600;
  color: #333;
  margin: 0;
}

.tag-sheet-close {
  background: none;
  border: none;
  font-size: 1.6rem;
  color: #999;
  cursor: pointer;
  padding: 4px 8px;
  line-height: 1;
  border-radius: 8px;
  transition: background 0.15s;
}

.tag-sheet-close:hover {
  background: #f0f0f0;
  color: #333;
}

/* Spice level tabs */
.tag-sheet-tabs {
  display: flex;
  border-bottom: 1px solid #eee;
  flex-shrink: 0;
  padding: 0 16px;
}

.tag-sheet-tabs button {
  flex: 1;
  padding: 10px 8px;
  border: none;
  background: none;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  color: #888;
  border-bottom: 2px solid transparent;
  transition: color 0.2s, border-color 0.2s;
}

.tag-sheet-tabs button.active {
  border-bottom-color: var(--purple-primary, #502f77);
  color: var(--purple-primary, #502f77);
  font-weight: 600;
}

.tag-sheet-tabs button.unavailable {
  opacity: 0.35;
  cursor: default;
}

/* Content area */
.tag-sheet-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px 32px;
  line-height: 1.65;
  font-size: 0.92rem;
  color: #333;
  -webkit-overflow-scrolling: touch;
}

/* Markdown content styling inside the sheet */
.tag-sheet-content h2 {
  font-size: 1.15rem;
  font-weight: 700;
  margin: 20px 0 10px;
  color: #222;
}

.tag-sheet-content h3 {
  font-size: 1rem;
  font-weight: 600;
  margin: 16px 0 8px;
  color: #333;
}

.tag-sheet-content p {
  margin: 8px 0;
}

.tag-sheet-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0;
  font-size: 0.85rem;
  overflow-x: auto;
  display: block;
}

.tag-sheet-content th,
.tag-sheet-content td {
  border: 1px solid #e0e0e0;
  padding: 8px 10px;
  text-align: left;
}

.tag-sheet-content th {
  background: #f5f5f5;
  font-weight: 600;
}

.tag-sheet-content blockquote {
  border-left: 3px solid var(--purple-primary, #502f77);
  padding: 12px 14px 12px 38px;
  margin: 14px 0;
  background: linear-gradient(135deg, #f9f7fc 0%, #f0ebfa 100%);
  color: #4a4a4a;
  font-size: 0.88rem;
  border-radius: 0 10px 10px 0;
  position: relative;
}

.tag-sheet-content blockquote::before {
  content: '\1F4AC';
  position: absolute;
  left: 10px;
  top: 12px;
  font-size: 0.85rem;
  opacity: 0.6;
}

/* Color-coded correction table columns */
.tag-sheet-content th.col-wrong,
.tag-sheet-content td.col-wrong {
  background: #fff5f5 !important;
  color: #b71c1c;
}

.tag-sheet-content th.col-correct,
.tag-sheet-content td.col-correct {
  background: #e8f5e9 !important;
  color: #2e7d32;
}

.tag-sheet-content hr {
  border: none;
  border-top: 1px solid #eee;
  margin: 20px 0;
}

.tag-sheet-content code {
  background: #f5f5f5;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.85em;
}

.tag-sheet-content ul,
.tag-sheet-content ol {
  padding-left: 20px;
  margin: 8px 0;
}

.tag-sheet-content li {
  margin: 4px 0;
}

/* Subtitle above accordions */
.tag-sheet-subtitle {
  margin: 0 0 12px;
  font-size: 0.92rem;
  color: #666;
}

/* ---- Bottom Sheet Accordions ---- */
.tag-sheet-accordions {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.tag-sheet-accordion {
  border: 1px solid #e0e0e0;
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
  transition: border-color 0.25s, box-shadow 0.25s;
}

.tag-sheet-accordion[open] {
  border-color: #c9b3e8;
  box-shadow: 0 2px 10px rgba(80, 47, 119, 0.07);
}

.tag-sheet-accordion > summary {
  padding: 12px 16px;
  background: #f8f4ff;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
  color: #502f77;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background 0.25s;
  list-style: none;
  user-select: none;
}

.tag-sheet-accordion > summary::-webkit-details-marker { display: none; }

.tag-sheet-accordion > summary::before {
  content: '';
  display: inline-block;
  width: 7px;
  height: 7px;
  border-right: 2px solid #502f77;
  border-bottom: 2px solid #502f77;
  transform: rotate(-45deg);
  transition: transform 0.25s;
  flex-shrink: 0;
}

.tag-sheet-accordion[open] > summary::before {
  transform: rotate(45deg);
}

.tag-sheet-accordion > summary:hover {
  background: #efe8ff;
}

.tag-sheet-accordion[open] > summary {
  background: #efe8ff;
  border-bottom: 1px solid #e0e0e0;
}

.tag-sheet-accordion-body {
  padding: 14px 16px;
  background: #fff;
  animation: tag-sheet-slide-in 0.25s ease-out;
}

@keyframes tag-sheet-slide-in {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Sub-accordions (In The Wild) */
.tag-sheet-sub-accordion {
  border: 1px solid #eee;
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 4px;
}

.tag-sheet-sub-accordion > summary {
  padding: 8px 14px;
  background: #fafafa;
  cursor: pointer;
  font-weight: 500;
  font-size: 0.85rem;
  color: #4a4a4a;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: background 0.2s;
  list-style: none;
  user-select: none;
}

.tag-sheet-sub-accordion > summary::-webkit-details-marker { display: none; }

.tag-sheet-sub-accordion > summary::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  border-right: 2px solid #888;
  border-bottom: 2px solid #888;
  transform: rotate(-45deg);
  transition: transform 0.25s;
  flex-shrink: 0;
}

.tag-sheet-sub-accordion[open] > summary::before {
  transform: rotate(45deg);
}

.tag-sheet-sub-accordion > summary:hover {
  background: #f0f0f0;
}

.tag-sheet-sub-accordion[open] > summary {
  border-bottom: 1px solid #eee;
}

.tag-sheet-sub-body {
  padding: 12px 14px;
  background: #fff;
  animation: tag-sheet-slide-in 0.2s ease-out;
}

/* Loading state */
.tag-sheet-loading {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: #999;
}

.tag-sheet-spinner {
  width: 28px;
  height: 28px;
  border: 3px solid #e0e0e0;
  border-top-color: var(--purple-primary, #502f77);
  border-radius: 50%;
  animation: tag-spin 0.7s linear infinite;
}

@keyframes tag-spin {
  to { transform: rotate(360deg); }
}

.tag-sheet-related-label {
  font-size: 0.7rem;
  letter-spacing: 0.05em;
  color: #888;
  margin: 0 0 10px;
  font-weight: 600;
}

.tag-sheet-related {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
}

.tag-sheet-related-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: #f8f4ff;
  border: 1px solid #e0e0e0;
  border-radius: 20px;
  font-size: 0.82rem;
  color: #502f77;
  text-decoration: none;
  font-weight: 500;
  transition: all 0.2s;
}

a.tag-sheet-related-link:hover {
  background: #efe8ff;
  border-color: #502f77;
}

.tag-sheet-related-note {
  font-size: 0.75rem;
  color: #999;
  font-weight: 400;
}

.student-homework.dark-mode .tag-sheet-related-label {
  color: #aaa;
}

.student-homework.dark-mode .tag-sheet-related-link {
  background: #2a2a3a;
  border-color: #444;
  color: #c4a8e8;
}

.student-homework.dark-mode a.tag-sheet-related-link:hover {
  background: #3a2a4a;
  border-color: #7a5fa0;
}

.student-homework.dark-mode .tag-sheet-related-note {
  color: #888;
}

/* Desktop: side panel instead of bottom sheet */
@media (min-width: 768px) {
  .tag-sheet {
    width: 480px;
    right: 0;
    left: auto;
    height: 100vh;
    border-radius: 0;
    transform: translateX(100%);
  }

  .tag-sheet.open {
    transform: translateX(0);
  }

  .tag-sheet.full {
    width: 680px;
    height: 100vh;
  }

  .tag-sheet-handle {
    display: none;
  }
}

/* Dark mode support */
.student-homework.dark-mode .tag-sheet {
  background: #1a1a2e;
}

.student-homework.dark-mode .tag-sheet-header h3 {
  color: #e0e0e0;
}

.student-homework.dark-mode .tag-sheet-close {
  color: #888;
}

.student-homework.dark-mode .tag-sheet-close:hover {
  background: #2a2a3e;
  color: #e0e0e0;
}

.student-homework.dark-mode .tag-sheet-tabs {
  border-bottom-color: #333;
}

.student-homework.dark-mode .tag-sheet-tabs button {
  color: #888;
}

.student-homework.dark-mode .tag-sheet-tabs button.active {
  color: #a78bfa;
  border-bottom-color: #a78bfa;
}

.student-homework.dark-mode .tag-sheet-content {
  color: #d0d0d0;
}

.student-homework.dark-mode .tag-sheet-content h2,
.student-homework.dark-mode .tag-sheet-content h3 {
  color: #e0e0e0;
}

.student-homework.dark-mode .tag-sheet-content th {
  background: #2a2a3e;
}

.student-homework.dark-mode .tag-sheet-content th,
.student-homework.dark-mode .tag-sheet-content td {
  border-color: #404557;
}

.student-homework.dark-mode .tag-sheet-content blockquote {
  background: #1e1e32;
  border-left-color: #a78bfa;
  color: #b0b0b0;
}

.student-homework.dark-mode .tag-sheet-content code {
  background: #2a2a3e;
}

.student-homework.dark-mode .tag-sheet-accordion {
  border-color: #444;
  background: #1e1e2e;
}

.student-homework.dark-mode .tag-sheet-accordion[open] {
  border-color: #6a4f9a;
}

.student-homework.dark-mode .tag-sheet-accordion > summary {
  background: #2a2a3e;
  color: #c4a8e8;
}

.student-homework.dark-mode .tag-sheet-accordion > summary::before {
  border-color: #c4a8e8;
}

.student-homework.dark-mode .tag-sheet-accordion > summary:hover,
.student-homework.dark-mode .tag-sheet-accordion[open] > summary {
  background: #332e4a;
}

.student-homework.dark-mode .tag-sheet-accordion-body,
.student-homework.dark-mode .tag-sheet-sub-body {
  background: #1e1e2e;
}

.student-homework.dark-mode .tag-sheet-sub-accordion {
  border-color: #3a3a4a;
}

.student-homework.dark-mode .tag-sheet-sub-accordion > summary {
  background: #252535;
  color: #ccc;
}

.student-homework.dark-mode .tag-sheet-sub-accordion > summary:hover {
  background: #2e2e3e;
}

.student-homework.dark-mode .tag-sheet-overlay {
  background: rgba(0, 0, 0, 0.55);
}
