/* hsk-review.css - HSK Review System Styles */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --primary-color: #3498db;
  --success-color: #27ae60;
  --danger-color: #e74c3c;
  --warning-color: #f39c12;
  --dark-bg: #2c3e50;
  --light-bg: #ecf0f1;
  --text-dark: #2c3e50;
  --text-light: #7f8c8d;
  --border-color: #bdc3c7;
  --shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.15);
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Utility Classes */
.hidden {
  display: none !important;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  color: var(--text-dark);
}

/* Header */
.review-header {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 1000;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.back-btn {
  color: var(--primary-color);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 500;
  transition: var(--transition);
}

.back-btn:hover {
  color: var(--dark-bg);
  transform: translateX(-3px);
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.header-logo {
  height: 32px;
  width: auto;
}

.header-title {
  font-size: 1.5rem;
  font-weight: 700;
  background: linear-gradient(135deg, #667eea, #764ba2);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin: 0;
}

.header-right {
  display: flex;
  gap: 1.5rem;
  align-items: center;
}

.timer-display,
.score-display {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: var(--light-bg);
  border-radius: 50px;
  font-weight: 600;
}

.timer-display i {
  color: var(--primary-color);
}

.score-display i {
  color: var(--warning-color);
}

/* Progress Bar */
.progress-bar-container {
  position: relative;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.5rem 1rem;
}

.progress-bar {
  width: 100%;
  height: 8px;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 50px;
  overflow: hidden;
  position: relative;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, 
    #e74c3c 0%, 
    #f39c12 25%, 
    #f1c40f 50%, 
    #27ae60 75%, 
    #2ecc71 100%);
  transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  box-shadow: 0 0 10px rgba(231, 76, 60, 0.6);
}

.fire-effect {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 12px;
  height: 14px;
  background: radial-gradient(circle, #ff6b35 0%, #f7931e 50%, transparent 70%);
  border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
  animation: fireFlicker 0.3s ease-in-out infinite alternate;
  opacity: 0.9;
}

@keyframes fireFlicker {
  0% { 
    transform: scale(1) rotate(-1deg);
    opacity: 0.9;
  }
  50% { 
    transform: scale(1.1) rotate(1deg);
    opacity: 1;
  }
  100% { 
    transform: scale(0.95) rotate(-0.5deg);
    opacity: 0.8;
  }
}

.progress-text {
  text-align: center;
  margin-top: 0.5rem;
  font-size: 0.9rem;
  color: rgba(255, 255, 255, 0.9);
  font-weight: 500;
}

/* Main Container */
.review-container {
  max-width: 1200px;
  margin: 2rem auto;
  padding: 0 1.5rem 2rem;
}

.screen {
  animation: fadeIn 0.5s ease-out;
}

.screen.hidden {
  display: none;
}

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

/* Mode Selection */
.mode-selection-card {
  background: rgba(255, 255, 255, 0.95);
  border-radius: 20px;
  padding: 2.5rem;
  box-shadow: var(--shadow-lg);
}

.screen-title {
  font-size: 2rem;
  font-weight: 700;
  text-align: center;
  margin-bottom: 2rem;
  color: var(--dark-bg);
}

.exam-info {
  display: flex;
  gap: 0.9rem;
  flex-wrap: wrap;
  margin: 0.6rem 0 1rem;
  padding: 0.55rem 0.7rem;
  background: var(--light-bg);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  justify-content: center;
}

.info-item {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-size: clamp(0.65rem, 0.9vw, 0.75rem);
  background: #fff;
  padding: 0.35rem 0.55rem;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
}

.info-label {
  font-size: inherit;
  color: #444;
  font-weight: 600;
}

.info-value {
  font-size: inherit;
  font-weight: 500;
  color: #222;
}

@media (max-width: 600px) {
  .exam-info { justify-content: center; }
  .exam-info .info-item { flex: 1 1 calc(33% - 0.9rem); min-width: 90px; justify-content: center; }
}

@media (max-width: 440px) {
  .exam-info .info-item { flex: 1 1 calc(50% - 0.9rem); }
}

/* (cleaned) */

.modes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
}

.mode-card {
  background: white;
  border: 2px solid var(--border-color);
  border-radius: 15px;
  padding: 2rem;
  text-align: center;
  transition: var(--transition);
  cursor: pointer;
}

.mode-card:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow-lg);
  border-color: var(--primary-color);
}

.mode-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
  background: linear-gradient(135deg, #667eea, #764ba2);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.mode-title {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
  color: var(--dark-bg);
}

.mode-description {
  color: var(--text-light);
  margin-bottom: 1.5rem;
  line-height: 1.6;
}

.select-mode-btn {
  width: 100%;
  padding: 0.875rem 1.5rem;
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: #333;
  border: none;
  border-radius: 50px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.select-mode-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

/* Section Selection */
.section-selection-card {
  background: rgba(255, 255, 255, 0.95);
  border-radius: 20px;
  padding: 2.5rem;
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(10px);
}

.back-to-mode {
  margin-bottom: 2rem;
}

.back-btn {
  background: none;
  border: none;
  color: var(--primary-color);
  font-size: 1rem;
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 8px;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.back-btn:hover {
  background: rgba(52, 152, 219, 0.1);
}

.sections-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.5rem;
  margin-top: 2rem;
}

.section-card {
  background: white;
  border: 2px solid var(--border-color);
  border-radius: 15px;
  padding: 2rem;
  cursor: pointer;
  transition: var(--transition);
  text-align: center;
}

.section-card:hover {
  border-color: var(--primary-color);
  transform: translateY(-5px);
  box-shadow: var(--shadow);
}

.section-card.completed {
  border-color: var(--success-color);
  background: rgba(39, 174, 96, 0.05);
}

.section-icon {
  font-size: 3rem;
  color: var(--primary-color);
  margin-bottom: 1rem;
}

.section-card.completed .section-icon {
  color: var(--success-color);
}

.section-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  color: var(--text-dark);
}

.section-stats {
  color: var(--text-light);
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

.section-progress {
  width: 100%;
  height: 8px;
  background: var(--light-bg);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 1rem;
}

.section-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary-color), var(--success-color));
  transition: width 0.3s ease;
}

/* Full Exam Mode */
.full-exam-container {
  max-width: 100%;
}

.exam-header {
  background: white;
  border-radius: 15px;
  padding: 1.5rem;
  margin-bottom: 2rem;
  text-align: center;
  box-shadow: var(--shadow);
}

.exam-header h2 {
  color: var(--primary-color);
  margin-bottom: 0.5rem;
}

.exam-instructions {
  color: var(--text-light);
  font-size: 0.9rem;
}

/* Question Navigator Sidebar - New Structure */
.question-navigator-sidebar {
  position: fixed;
  left: 0;
  top: 160px; /* Below header */
  bottom: 0;
  width: 280px;
  background: white;
  box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.question-navigator-sidebar.hidden {
  display: none;
}

.question-navigator-sidebar .navigator-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem;
  border-bottom: 2px solid var(--light-bg);
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.05), rgba(118, 75, 162, 0.05));
}

.question-navigator-sidebar .navigator-title {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--dark-bg);
  margin: 0;
}

.question-navigator-sidebar .navigator-close {
  width: 36px;
  height: 36px;
  border: none;
  background: var(--light-bg);
  border-radius: 50%;
  cursor: pointer;
  display: none; /* Hidden on desktop */
  align-items: center;
  justify-content: center;
  font-size: 1.125rem;
  color: var(--text-dark);
  transition: var(--transition);
}

.question-navigator-sidebar .navigator-close:hover {
  background: var(--border-color);
  transform: rotate(90deg);
}

.navigator-body {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
}

#navigator-toggle-btn {
  position: fixed;
  bottom: 2rem;
  left: 2rem;
  width: 56px;
  height: 56px;
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: white;
  border: none;
  border-radius: 50%;
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
  cursor: pointer;
  display: none; /* Hidden on desktop */
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  z-index: 1500;
  transition: var(--transition);
}

#navigator-toggle-btn.hidden {
  display: none !important;
}

#navigator-toggle-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 16px rgba(102, 126, 234, 0.6);
}

#navigator-toggle-btn:active {
  transform: scale(0.95);
}

/* Adjust main content when sidebar is visible */
body:has(.question-navigator-sidebar:not(.hidden)) .review-container {
  margin-left: 280px;
  transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Old question navigator styles (deprecated - for backward compatibility) */
.question-navigator {
  background: white;
  border-radius: 15px;
  padding: 1.5rem;
  margin-bottom: 2rem;
  box-shadow: var(--shadow);
  position: sticky;
  top: 120px;
  z-index: 100;
  transition: var(--transition);
}

.question-navigator.collapsed {
  display: none;
}

.navigator-header {
  display: none;
}

.navigator-toggle {
  position: fixed;
  bottom: 2rem;
  left: 2rem;
  width: 56px;
  height: 56px;
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: white;
  border: none;
  border-radius: 50%;
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  z-index: 1500;
  transition: var(--transition);
}

.navigator-toggle:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 16px rgba(102, 126, 234, 0.6);
}

.navigator-toggle:active {
  transform: scale(0.95);
}

.navigator-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--dark-bg);
  margin: 0;
}

.navigator-close {
  width: 40px;
  height: 40px;
  border: none;
  background: var(--light-bg);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  color: var(--text-dark);
  transition: var(--transition);
}

.navigator-close:hover {
  background: var(--border-color);
  transform: rotate(90deg);
}

.navigator-sections {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.navigator-section {
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 1rem;
}

.navigator-section:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.navigator-section-title {
  font-weight: 600;
  color: var(--text-dark);
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
}

.navigator-questions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.question-nav-btn {
  width: 35px;
  height: 35px;
  border: 2px solid var(--border-color);
  background: white;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
}

.question-nav-btn:hover {
  border-color: var(--primary-color);
  background: rgba(52, 152, 219, 0.1);
}

.question-nav-btn.answered {
  background: var(--success-color);
  border-color: var(--success-color);
  color: #333;
}

.question-nav-btn.current {
  background: var(--primary-color);
  border-color: var(--primary-color);
  color: #333;
  transform: scale(1.1);
}

.all-questions-container {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.question-section {
  background: white;
  border-radius: 15px;
  padding: 2rem;
  box-shadow: var(--shadow);
  transition: var(--transition);
  border: 2px solid transparent;
}

.question-section.active {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.section-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 2px solid var(--light-bg);
}

.section-badge {
  background: linear-gradient(135deg, var(--primary-color), #5a9fd4);
  color: #333;
  padding: 0.5rem 1rem;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
}

.section-title {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text-dark);
}

.question-group-content {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.full-mode-question {
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1.5rem;
  background: rgba(249, 249, 249, 0.5);
}

.question-number-label {
  background: var(--primary-color);
  color: #333;
  padding: 0.25rem 0.75rem;
  border-radius: 15px;
  font-size: 0.8rem;
  font-weight: 600;
  display: inline-block;
  margin-bottom: 1rem;
}

.question-options {
  margin-top: 1rem;
}

.full-exam-actions {
  text-align: center;
  margin-top: 3rem;
  padding: 2rem;
}

.submit-exam-btn {
  background: linear-gradient(135deg, var(--success-color), #27ae60);
  color: #333;
  border: none;
  padding: 1rem 3rem;
  border-radius: 50px;
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.submit-exam-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 5px 15px rgba(39, 174, 96, 0.4);
}

/* Question Screen */
.question-container {
  background: rgba(255, 255, 255, 0.95);
  border-radius: 20px;
  padding: 2.5rem;
  box-shadow: var(--shadow-lg);
  min-height: 500px;
  display: flex;
  flex-direction: column;
}

.part-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  margin-bottom: 1rem;
  padding-bottom: .5rem;
  border-bottom: 1px solid var(--border-color);
  flex-wrap: wrap;
}

.part-badge {
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: #fff;
  padding: .35rem .9rem;
  border-radius: 999px;
  font-weight: 700;
  font-size: .9rem;
  box-shadow: 0 2px 6px rgba(118,75,162,.2);
}

.question-number {
  color: #555;
  font-weight: 600;
  font-size: .9rem;
  background: var(--light-bg);
  padding: .3rem .65rem;
  border-radius: 999px;
}

@media (max-width: 600px){
  .part-header {justify-content: center;}
}

.question-content {
  margin-bottom: 2rem;
  flex-grow: 1;
}

/* Audio Player for Listening Questions */
.audio-player {
  text-align: center;
  margin: 2rem 0;
  padding: 2rem;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 20px;
  box-shadow: 0 8px 24px rgba(102, 126, 234, 0.3);
}

.play-audio-btn {
  background: white;
  color: #667eea;
  border: none;
  padding: 1rem 2rem;
  border-radius: 50px;
  font-size: 1.125rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.play-audio-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
  background: #f8f9ff;
}

.play-audio-btn:active {
  transform: translateY(0);
}

.play-audio-btn i {
  font-size: 1.25rem;
}

audio {
  display: none;
}

.question-text p {
  font-size: 1.125rem;
  line-height: 1.8;
  margin-bottom: 1rem;
  color: var(--text-dark);
}

.question-image {
  text-align: center;
  margin: 1.5rem 0;
}

.question-image img {
  max-width: 100%;
  max-height: 400px;
  border-radius: 15px;
  box-shadow: var(--shadow);
}

.question-pinyin {
  font-style: italic;
  color: var(--text-light);
  margin-top: 1rem;
  font-size: 1rem;
}

/* Answer Options */
.image-options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.image-option {
  position: relative;
  border: 3px solid var(--border-color);
  border-radius: 15px;
  padding: 1rem;
  cursor: pointer;
  transition: var(--transition);
  background: white;
}

.image-option:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow);
  border-color: var(--primary-color);
}

.image-option.selected {
  border-color: var(--primary-color);
  background: rgba(52, 152, 219, 0.1);
}

.image-option.correct {
  border-color: var(--success-color);
  background: rgba(39, 174, 96, 0.1);
  animation: pulseCorrect 0.6s ease-out;
}

.image-option.incorrect {
  border-color: var(--danger-color);
  background: rgba(231, 76, 60, 0.1);
  animation: shakeWrong 0.5s ease-out;
}

.image-option.disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.image-option.disabled:hover {
  transform: none;
  border-color: var(--border-color);
  background: white;
}

@keyframes pulseCorrect {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

@keyframes shakeWrong {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

.image-option img {
  width: 100%;
  height: auto;
  border-radius: 10px;
  margin-bottom: 0.5rem;
}

.option-label {
  display: block;
  text-align: center;
  font-weight: 700;
  font-size: 1.125rem;
  color: var(--dark-bg);
}

/* Text Options */
.text-options {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 2rem;
}

.text-option {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.25rem;
  border: 2px solid var(--border-color);
  border-radius: 15px;
  cursor: pointer;
  transition: var(--transition);
  background: white;
  position: relative;
}

.text-option:hover {
  border-color: var(--primary-color);
  background: rgba(52, 152, 219, 0.05);
  transform: translateX(5px);
}

.text-option.selected {
  border-color: var(--primary-color);
  background: rgba(52, 152, 219, 0.1);
}

.text-option.correct {
  border-color: var(--success-color);
  background: rgba(39, 174, 96, 0.1);
}

.text-option.incorrect {
  border-color: var(--danger-color);
  background: rgba(231, 76, 60, 0.1);
}

.text-option.disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.text-option.disabled:hover {
  transform: none;
  border-color: var(--border-color);
  background: white;
}

.text-option .option-label {
  width: 40px;
  height: 40px;
  background: var(--light-bg);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.125rem;
  flex-shrink: 0;
}

.text-option.selected .option-label {
  background: var(--primary-color);
  color: #333;
}

.text-option.correct .option-label {
  background: var(--success-color);
  color: #333;
}

.text-option.incorrect .option-label {
  background: var(--danger-color);
  color: #333;
}

.text-option .option-text {
  flex-grow: 1;
  font-size: 1.125rem;
  line-height: 1.6;
}

.option-check {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--primary-color);
  color: #333;
  display: none;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.text-option.selected .option-check,
.text-option.correct .option-check {
  display: flex;
}

.text-option.correct .option-check {
  background: var(--success-color);
}

/* True/False Options */
.tf-options {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 2rem;
}

.tf-option {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.25rem;
  border: 2px solid var(--border-color);
  border-radius: 15px;
  cursor: pointer;
  transition: var(--transition);
  background: white;
  position: relative;
  font-size: 1.125rem;
  font-weight: 500;
}

.tf-option:hover {
  border-color: var(--primary-color);
  background: rgba(52, 152, 219, 0.05);
  transform: translateX(5px);
}

.tf-option.selected {
  border-color: var(--primary-color);
  background: rgba(52, 152, 219, 0.1);
}

.tf-option.correct {
  border-color: var(--success-color);
  background: rgba(39, 174, 96, 0.1);
}

.tf-option.incorrect {
  border-color: var(--danger-color);
  background: rgba(231, 76, 60, 0.1);
}

.tf-option i {
  font-size: 1.5rem;
  width: 30px;
  text-align: center;
}

.tf-option.selected i,
.tf-option.correct i {
  color: var(--success-color);
}

.tf-option.incorrect i {
  color: var(--danger-color);
}

.tf-option.disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.tf-option.disabled:hover {
  transform: none;
  border-color: var(--border-color);
  background: white;
}

/* Text Input */
.text-input-container {
  margin-bottom: 2rem;
}

.text-answer-input {
  width: 100%;
  padding: 1rem;
  border: 2px solid var(--border-color);
  border-radius: 15px;
  font-size: 1rem;
  font-family: inherit;
  resize: vertical;
  transition: var(--transition);
}

.text-answer-input:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

/* Fill-in-the-blank inline elements */
.fill-blank-question {
  font-size: 1.125rem;
  line-height: 2;
}

.fill-blank-line {
  margin-bottom: 1rem;
}

.inline-select {
  display: inline-block;
  padding: 0.4rem 0.8rem;
  margin: 0 0.3rem;
  border: 2px solid var(--primary-color);
  border-radius: 8px;
  background: white;
  font-size: 1rem;
  font-family: inherit;
  color: var(--text-dark);
  cursor: pointer;
  transition: var(--transition);
  min-width: 120px;
}

.inline-select:hover {
  background: var(--light-bg);
  border-color: #2980b9;
}

.inline-select:focus {
  outline: none;
  border-color: #2980b9;
  box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.2);
}

.inline-input {
  display: inline-block;
  padding: 0.4rem 0.8rem;
  margin: 0 0.3rem;
  border: 2px solid var(--primary-color);
  border-radius: 8px;
  background: white;
  font-size: 1rem;
  font-family: inherit;
  color: var(--text-dark);
  transition: var(--transition);
  min-width: 150px;
}

.inline-input:hover {
  border-color: #2980b9;
}

.inline-input:focus {
  outline: none;
  border-color: #2980b9;
  box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.2);
}

.inline-input::placeholder {
  color: var(--text-light);
  font-style: italic;
}

/* Feedback */
.feedback {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  margin: 0;
  padding: 1.25rem 1.5rem;
  border-radius: 20px 20px 0 0;
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  animation: slideUp 0.3s ease-out;
  z-index: 100;
  max-height: 60vh;
  overflow-y: auto;
  box-shadow: 0 -4px 20px rgba(0,0,0,0.15);
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(100%);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.feedback.correct {
  background: rgba(39, 174, 96, 0.1);
  border: 2px solid var(--success-color);
}

.feedback.incorrect {
  background: rgba(231, 76, 60, 0.1);
  border: 2px solid var(--danger-color);
}

.feedback-content {
  display: flex;
  align-items: center;
  gap: 1rem;
  width: 100%;
}

.feedback-icon {
  font-size: 2.5rem;
  flex-shrink: 0;
}

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

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

.feedback-text {
  flex-grow: 1;
}

.feedback-title {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

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

.feedback.incorrect .feedback-title {
  color: var(--danger-color);
}

.feedback-explanation {
  color: var(--text-light);
  font-size: 1rem;
}

/* Detailed explanation sections */
.feedback-explanation .score-badge {
  display: inline-block;
  background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%);
  color: white;
  padding: 0.5rem 1rem;
  border-radius: 20px;
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 0.75rem;
}

.feedback-explanation .correct-answer-display {
  background: #fff3e0;
  border-left: 4px solid #ff9800;
  padding: 0.75rem 1rem;
  margin: 0.75rem 0;
  border-radius: 4px;
}

.feedback-explanation .correct-answer-display .answer-text {
  color: #e65100;
  font-weight: 600;
  font-size: 1.05rem;
}

.feedback-explanation .detailed-explanation {
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px dashed rgba(0,0,0,0.1);
}

.feedback-explanation .explanation-section {
  background: #f8f9fa;
  border-radius: 8px;
  padding: 0.75rem 1rem;
  margin-bottom: 0.65rem;
}

.feedback-explanation .explanation-section:last-child {
  margin-bottom: 0;
}

.feedback-explanation .explanation-section strong {
  display: block;
  color: #333;
  font-size: 0.9rem;
  margin-bottom: 0.4rem;
}

.feedback-explanation .explanation-section p {
  margin: 0;
  color: #555;
  font-size: 0.9rem;
  line-height: 1.5;
}

.feedback-explanation .pattern-section {
  background: linear-gradient(135deg, #e3f2fd 0%, #f5f9ff 100%);
  border-left: 3px solid #2196F3;
}

.feedback-explanation .tip-section {
  background: linear-gradient(135deg, #fff9e6 0%, #fffef5 100%);
  border-left: 3px solid #ffc107;
}

.feedback-explanation .chinese-section {
  background: linear-gradient(135deg, #fff3e0 0%, #fffaf5 100%);
  border-left: 3px solid #ff6f00;
}

.feedback-explanation .chinese-section .chinese-text {
  font-size: 1.15rem;
  font-weight: 500;
  color: #bf360c;
  line-height: 1.6;
}

.feedback-explanation .translation-section {
  background: linear-gradient(135deg, #e8f5e9 0%, #f5fdf5 100%);
  border-left: 3px solid #4CAF50;
}

.feedback-explanation .pinyin-section {
  background: linear-gradient(135deg, #fce4ec 0%, #fff5f8 100%);
  border-left: 3px solid #e91e63;
}

/* Responsive */
@media (max-width: 600px) {
  .feedback-explanation .score-badge {
    font-size: 0.85rem;
    padding: 0.4rem 0.85rem;
  }
  
  .feedback-explanation .explanation-section {
    padding: 0.6rem 0.85rem;
  }
  
  .feedback-explanation .explanation-section strong {
    font-size: 0.85rem;
  }
  
  .feedback-explanation .explanation-section p {
    font-size: 0.85rem;
  }
}

/* Navigation */
.question-navigation {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: auto;
  padding-top: 1.5rem;
  border-top: 2px solid var(--light-bg);
}

.nav-btn {
  padding: 0.875rem 1.75rem;
  border: none;
  border-radius: 50px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.prev-btn,
.answer-sheet-btn {
  background: var(--light-bg);
  color: var(--dark-bg);
}

.prev-btn:hover,
.answer-sheet-btn:hover {
  background: var(--border-color);
  transform: translateY(-2px);
}

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

.prev-btn:disabled:hover {
  transform: none;
}

.next-btn {
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: #333;
  margin-left: auto;
}

.next-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

/* Results Screen */
.results-container {
  background: rgba(255, 255, 255, 0.95);
  border-radius: 20px;
  padding: 2.5rem;
  box-shadow: var(--shadow-lg);
}

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

.results-icon {
  font-size: 4rem;
  background: linear-gradient(135deg, #667eea, #764ba2);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 1rem;
}

.results-title {
  font-size: 2rem;
  font-weight: 700;
  color: var(--dark-bg);
}

.score-summary {
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: #333;
  border-radius: 20px;
  padding: 2rem;
  margin-bottom: 2rem;
}

.total-score {
  text-align: center;
  margin-bottom: 2rem;
}

.total-score .score-label {
  display: block;
  font-size: 1rem;
  opacity: 0.9;
  margin-bottom: 0.5rem;
}

.total-score .score-value {
  display: block;
  font-size: 4rem;
  font-weight: 700;
}

.score-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 1.5rem;
}

.stat-item {
  text-align: center;
}

.stat-item i {
  font-size: 2rem;
  margin-bottom: 0.5rem;
}

.stat-value {
  display: block;
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.stat-label {
  display: block;
  font-size: 0.9rem;
  opacity: 0.9;
}

.section-breakdown {
  margin-bottom: 2rem;
}

.breakdown-title {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 1rem;
  color: var(--dark-bg);
}

.sections-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.section-score-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
  background: var(--light-bg);
  border-radius: 10px;
}

.section-name {
  font-weight: 600;
  color: var(--dark-bg);
}

.section-score {
  font-weight: 700;
  color: var(--primary-color);
  font-size: 1.125rem;
}

.question-details {
  margin-bottom: 2rem;
}

.questions-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-height: 400px;
  overflow-y: auto;
  padding-right: 0.5rem;
}

.question-result-item {
  padding: 1rem;
  border-radius: 10px;
  border: 2px solid var(--border-color);
  transition: var(--transition);
}

.question-result-item.correct {
  background: rgba(39, 174, 96, 0.05);
  border-color: var(--success-color);
}

.question-result-item.incorrect {
  background: rgba(231, 76, 60, 0.05);
  border-color: var(--danger-color);
}

.question-result-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.question-result-number {
  font-weight: 600;
  color: var(--dark-bg);
}

.question-result-status i {
  font-size: 1.25rem;
}

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

.question-result-item.incorrect .question-result-status {
  color: var(--danger-color);
}

.question-result-body {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.result-answer {
  display: flex;
  gap: 0.5rem;
  font-size: 0.95rem;
}

.answer-label {
  font-weight: 600;
  color: var(--text-light);
}

.answer-value {
  color: var(--text-dark);
}

.result-answer.correct-answer .answer-value {
  color: var(--success-color);
  font-weight: 600;
}

.results-actions {
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
}

.action-btn {
  padding: 0.875rem 2rem;
  border: none;
  border-radius: 50px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.action-btn.primary {
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: #333;
}

.action-btn.primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.action-btn.secondary {
  background: var(--light-bg);
  color: var(--dark-bg);
}

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

/* Answer Sheet Modal */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.3s ease-out;
}

.modal.hidden {
  display: none;
}

.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(5px);
}

.modal-content {
  position: relative;
  background: white;
  border-radius: 20px;
  max-width: 600px;
  width: 90%;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.3s ease-out;
}

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

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem;
  border-bottom: 2px solid var(--light-bg);
}

.modal-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--dark-bg);
}

.modal-close {
  width: 40px;
  height: 40px;
  border: none;
  background: var(--light-bg);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  color: var(--text-dark);
  transition: var(--transition);
}

.modal-close:hover {
  background: var(--border-color);
  transform: rotate(90deg);
}

.modal-body {
  padding: 1.5rem;
  overflow-y: auto;
}

.answer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
  gap: 0.75rem;
}

.answer-cell {
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  border: 2px solid var(--border-color);
  border-radius: 10px;
  cursor: pointer;
  transition: var(--transition);
  background: white;
}

.answer-cell:hover {
  transform: scale(1.05);
  box-shadow: var(--shadow);
  border-color: var(--primary-color);
}

.answer-cell.answered {
  background: rgba(52, 152, 219, 0.1);
  border-color: var(--primary-color);
}

.cell-number {
  font-weight: 700;
  color: var(--dark-bg);
}

.answer-cell i {
  font-size: 0.75rem;
  color: var(--primary-color);
}

/* Loading Overlay */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(5px);
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.loading-overlay.hidden {
  display: none;
}

.loading-spinner {
  text-align: center;
  color: #333;
}

.loading-spinner i {
  font-size: 3rem;
  margin-bottom: 1rem;
}

.loading-spinner p {
  font-size: 1.125rem;
  font-weight: 600;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  background: white;
  padding: 1rem 1.5rem;
  border-radius: 50px;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  z-index: 4000;
  animation: slideInRight 0.3s ease-out;
}

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(100px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.toast.hidden {
  display: none;
}

.toast.success {
  background: var(--success-color);
  color: #333;
}

.toast.error {
  background: var(--danger-color);
  color: #333;
}

.toast.warning {
  background: var(--warning-color);
  color: #333;
}

.toast i {
  font-size: 1.25rem;
}

/* Responsive Design */
@media (max-width: 768px) {
  /* Navigator Sidebar - Mobile */
  .question-navigator-sidebar {
    top: 0;
    width: 85%;
    max-width: 320px;
    transform: translateX(-100%);
    box-shadow: none;
  }

  .question-navigator-sidebar.open {
    transform: translateX(0);
    box-shadow: 2px 0 20px rgba(0, 0, 0, 0.3);
  }

  .question-navigator-sidebar .navigator-close {
    display: flex;
  }

  #navigator-toggle-btn {
    display: flex;
  }

  #navigator-toggle-btn.hidden {
    display: none !important;
  }

  /* No margin adjustment on mobile */
  body:has(.question-navigator-sidebar:not(.hidden)) .review-container {
    margin-left: 0;
  }

  /* Other responsive styles */
  .header-content {
    flex-direction: column;
    align-items: stretch;
  }

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

  .header-right {
    justify-content: space-around;
  }

  .screen-title {
    font-size: 1.5rem;
  }

  .modes-grid {
    grid-template-columns: 1fr;
  }

  .question-container {
    padding: 1.5rem;
  }

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

  .nav-btn {
    width: 100%;
    justify-content: center;
  }

  .next-btn {
    margin-left: 0;
  }

  .answer-grid {
    grid-template-columns: repeat(auto-fill, minmax(50px, 1fr));
  }

  .toast {
    bottom: 1rem;
    right: 1rem;
    left: 1rem;
  }

  .results-container {
    padding: 1.5rem;
  }

  .total-score .score-value {
    font-size: 3rem;
  }

  .results-actions {
    flex-direction: column;
  }

  .action-btn {
    width: 100%;
    justify-content: center;
  }

  /* Navigator responsive */
  .question-navigator {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    max-height: 100vh;
    overflow-y: auto;
    border-radius: 0;
    margin: 0;
    z-index: 2500;
    padding: 2rem 1.5rem;
    animation: slideInLeft 0.3s ease-out;
  }

  @keyframes slideInLeft {
    from {
      transform: translateX(-100%);
    }
    to {
      transform: translateX(0);
    }
  }

  .question-navigator.collapsed {
    display: none;
  }

  .navigator-toggle {
    display: flex;
  }

  .navigator-header {
    display: flex !important;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--light-bg);
  }
}

@media (max-width: 480px) {
  .image-options {
    grid-template-columns: repeat(2, 1fr);
  }

  .score-stats {
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
  }

  .stat-item i {
    font-size: 1.5rem;
  }

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

/* Footer Styles */
.footer {
  background: var(--dark-bg);
  color: #333;
  margin-top: 4rem;
}

.footer-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 3rem 1.5rem;
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 2rem;
}

.footer-section h3,
.footer-section h4 {
  margin-bottom: 1rem;
  color: #333;
}

.footer-section h3 {
  font-size: 1.5rem;
  background: linear-gradient(135deg, #667eea, #764ba2);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.footer-section p {
  color: var(--text-light);
  margin-bottom: 1rem;
  line-height: 1.6;
}

.footer-section ul {
  list-style: none;
  padding: 0;
}

.footer-section ul li {
  margin-bottom: 0.5rem;
}

.footer-section ul li a {
  color: var(--text-light);
  text-decoration: none;
  transition: var(--transition);
}

.footer-section ul li a:hover {
  color: var(--primary-color);
}

.social-links {
  display: flex;
  gap: 1rem;
}

.social-links a {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  color: #333;
  text-decoration: none;
  transition: var(--transition);
}

.social-links a:hover {
  background: var(--primary-color);
  transform: translateY(-2px);
}

.footer-bottom {
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  padding: 1.5rem 0;
}

.footer-bottom-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.footer-links {
  display: flex;
  gap: 2rem;
}

.footer-links a {
  color: var(--text-light);
  text-decoration: none;
  transition: var(--transition);
}

.footer-links a:hover {
  color: var(--primary-color);
}

/* Footer responsive */
@media (max-width: 768px) {
  .footer-content {
    grid-template-columns: 1fr;
    gap: 2rem;
  }
  
  .footer-bottom-content {
    flex-direction: column;
    text-align: center;
  }
}

/* Toggle Navigation Button */
.toggle-nav-btn {
  background: var(--primary-color);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 0.5rem;
  cursor: pointer;
  transition: var(--transition);
  margin-right: 1rem;
  font-size: 1rem;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.toggle-nav-btn:hover {
  background: #2980b9;
  transform: scale(1.05);
}

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

/* Navigation Hidden State */
body.nav-hidden .main-header,
body.nav-hidden .main-sidebar,
body.nav-hidden footer {
  display: none !important;
}

body.nav-hidden .review-header {
  top: 0;
}

body.nav-hidden .main-content {
  padding-top: 0;
}

/* Ensure page content adjusts when header-sidebar is present */
body:not(.nav-hidden) .review-header {
  top: 70px; /* Adjust for header-sidebar height */
}

body:not(.nav-hidden) .main-content {
  padding-top: 140px; /* header-sidebar + review-header */
}

/* ==========================================
   DRAG AND REORDER (DR Format)
   ========================================== */
.drag-reorder-container {
  margin: 1rem 0;
}

.drag-instruction {
  padding: 0.75rem 1rem;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border-radius: 8px;
  margin-bottom: 1rem;
  font-size: 0.9rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.drag-instruction i {
  font-size: 1.1rem;
}

.drag-items {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.drag-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem;
  background: white;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  cursor: move;
  transition: var(--transition);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
  user-select: none;
  -webkit-user-select: none;
  position: relative;
}

.drag-item::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 8px 0 0 8px;
  opacity: 0;
  transition: opacity 0.3s;
}

.drag-item:hover::before,
.drag-item.dragging::before {
  opacity: 1;
}

.drag-item:hover {
  border-color: var(--primary-color);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.15);
  transform: translateY(-2px);
}

.drag-item.dragging {
  opacity: 0.5;
  transform: rotate(2deg);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
}

.drag-item.drag-over {
  border-color: #667eea;
  background: linear-gradient(to right, rgba(102, 126, 234, 0.1), transparent);
  border-width: 3px;
}

.drag-handle {
  color: #999;
  font-size: 1.2rem;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
}

.drag-handle:active {
  cursor: grabbing;
}

.drag-number {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border-radius: 50%;
  font-weight: 700;
  font-size: 0.9rem;
  flex-shrink: 0;
}

.drag-content {
  flex: 1;
  font-size: 1rem;
  line-height: 1.5;
  color: var(--text-dark);
}

/* ==========================================
   ARRANGE READING (AR Format)
   ========================================== */
.arrange-container {
  margin: 1rem 0;
}

.arrange-instruction {
  padding: 0.75rem 1rem;
  background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
  color: white;
  border-radius: 8px;
  margin-bottom: 1rem;
  font-size: 0.9rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.arrange-instruction i {
  font-size: 1.1rem;
}

.arrange-items {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.arrange-item {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  background: white;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  cursor: move;
  transition: var(--transition);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
  user-select: none;
  -webkit-user-select: none;
  position: relative;
}

.arrange-item::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
  border-radius: 8px 0 0 8px;
  opacity: 0;
  transition: opacity 0.3s;
}

.arrange-item:hover::before,
.arrange-item.dragging::before {
  opacity: 1;
}

.arrange-item:hover {
  border-color: #f5576c;
  box-shadow: 0 4px 12px rgba(245, 87, 108, 0.15);
  transform: translateY(-2px);
}

.arrange-item.dragging {
  opacity: 0.5;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
}

.arrange-item.drag-over {
  border-color: #f5576c;
  background: linear-gradient(to right, rgba(245, 87, 108, 0.1), transparent);
  border-width: 3px;
}

.arrange-handle {
  color: #999;
  font-size: 1.2rem;
  cursor: grab;
  margin-top: 0.25rem;
  user-select: none;
  -webkit-user-select: none;
}

.arrange-handle:active {
  cursor: grabbing;
}

.arrange-order {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
  color: white;
  border-radius: 50%;
  font-weight: 700;
  font-size: 1rem;
  flex-shrink: 0;
}

.arrange-text {
  flex: 1;
  font-size: 1rem;
  line-height: 1.6;
  color: var(--text-dark);
}

/* ==========================================
   WRITING INPUT (WI Format)
   ========================================== */
.writing-container {
  margin: 1rem 0;
}

.writing-instruction {
  padding: 0.75rem 1rem;
  background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
  color: white;
  border-radius: 8px;
  margin-bottom: 1rem;
  font-size: 0.9rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.writing-instruction i {
  font-size: 1.1rem;
}

.writing-input {
  width: 100%;
  min-height: 150px;
  padding: 1rem;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  font-size: 1rem;
  line-height: 1.6;
  font-family: inherit;
  resize: vertical;
  transition: var(--transition);
  background: white;
}

.writing-input:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.char-counter {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: #f8f9fa;
  border-radius: 6px;
  font-size: 0.85rem;
}

.char-count {
  font-weight: 700;
  color: var(--primary-color);
}

.char-min {
  color: #6c757d;
  font-size: 0.8rem;
}

/* ==========================================
   WRITING WITH REFERENCE (WR Format)
   ========================================== */
.writing-reference-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin: 1rem 0;
}

.reference-section {
  background: white;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  padding: 1.25rem;
  max-height: 500px;
  overflow-y: auto;
}

.reference-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  font-size: 1rem;
  color: var(--primary-color);
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 2px solid #e0e0e0;
}

.reference-title i {
  font-size: 1.1rem;
}

.reference-text {
  line-height: 1.8;
  color: var(--text-dark);
}

.reference-text p {
  margin-bottom: 0.75rem;
}

.writing-section {
  display: flex;
  flex-direction: column;
}

/* Responsive for writing with reference */
@media (max-width: 968px) {
  .writing-reference-container {
    grid-template-columns: 1fr;
  }
  
  .reference-section {
    max-height: 300px;
  }
}

/* ==========================================
   WRITING MULTIPLE PARTS (WM Format)
   ========================================== */
.writing-multiple-container {
  margin: 1rem 0;
}

.writing-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.writing-tab {
  padding: 0.75rem 1.25rem;
  background: #f8f9fa;
  border: 2px solid #e0e0e0;
  border-radius: 8px 8px 0 0;
  font-size: 0.9rem;
  font-weight: 600;
  color: #6c757d;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.writing-tab:hover {
  background: #e9ecef;
  border-color: #ced4da;
}

.writing-tab.active {
  background: white;
  border-color: var(--primary-color);
  border-bottom-color: white;
  color: var(--primary-color);
  margin-bottom: -2px;
}

.writing-tab i {
  font-size: 1rem;
}

.writing-parts {
  border: 2px solid var(--primary-color);
  border-radius: 0 8px 8px 8px;
  background: white;
  padding: 1.25rem;
}

.writing-part {
  display: none;
}

.writing-part.active {
  display: block;
}

/* ==========================================
   Responsive for Drag Items
   ========================================== */
@media (max-width: 768px) {
  .drag-item,
  .arrange-item {
    padding: 0.75rem;
  }
  
  .drag-content,
  .arrange-text {
    font-size: 0.9rem;
  }
  
  .drag-number,
  .arrange-order {
    width: 28px;
    height: 28px;
    font-size: 0.85rem;
  }
}

/* Touch device improvements */
@media (hover: none) and (pointer: coarse) {
  .drag-item,
  .arrange-item {
    cursor: pointer;
    touch-action: none; /* Prevent default touch behavior */
  }
  
  .drag-handle,
  .arrange-handle {
    font-size: 1.5rem;
    padding: 0.5rem;
    cursor: pointer;
  }
  
  .drag-item:active,
  .arrange-item:active {
    opacity: 0.7;
    transform: scale(1.02);
  }
}

/* ==========================================
   WRITING FEEDBACK STYLES
   ========================================== */
.writing-feedback {
  margin-top: 0.5rem;
}

.writing-feedback .score-line {
  font-weight: 700;
  font-size: 1.1rem;
  margin-bottom: 0.5rem;
  color: var(--primary-color);
}

.writing-feedback .feedback-line {
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--text-dark);
}

/* Improved feedback container for writing */
.feedback.correct .writing-feedback .score-line {
  color: var(--success-color);
}

.feedback.incorrect .writing-feedback .score-line {
  color: var(--warning-color);
}

/* ==========================================
   DR FORMAT - Word Bank & Click Mode UI
   ========================================== */

/* Mode toggle button */
.dr-mode-toggle {
  margin-left: 12px;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 600;
  border: 2px solid #667eea;
  border-radius: 20px;
  background: white;
  color: #667eea;
  cursor: pointer;
  transition: all 0.3s ease;
}

.dr-mode-toggle:hover {
  background: #667eea;
  color: white;
}

.dr-mode-toggle[data-mode="click"] {
  background: #667eea;
  color: white;
}

/* Word Bank - Original sequence display */
.dr-word-bank {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 16px;
  background: linear-gradient(135deg, #f0f4ff 0%, #e8f4ff 100%);
  border-radius: 12px;
  margin-bottom: 16px;
  border: 1px dashed #a0aec0;
}

.dr-word-bank .wb-item {
  padding: 6px 14px;
  background: white;
  border: 1px solid #cbd5e0;
  border-radius: 20px;
  font-size: 14px;
  color: #4a5568;
  transition: all 0.2s ease;
  cursor: default;
}

.dr-word-bank .wb-item.used {
  opacity: 0.4;
  background: #e2e8f0;
  text-decoration: line-through;
}

/* Click mode: make word bank items clickable */
.dr-mode-toggle[data-mode="click"] ~ .dr-word-bank .wb-item:not(.used) {
  cursor: pointer;
}

.dr-mode-toggle[data-mode="click"] ~ .dr-word-bank .wb-item:not(.used):hover {
  background: #667eea;
  color: white;
  border-color: #667eea;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

/* Mini word - base style */
.dr-mini-word {
  display: inline-block;
  padding: 8px 16px;
  background: white;
  border-radius: 8px;
  font-size: 15px;
  color: #2d3748;
  transition: all 0.2s ease;
}

.dr-mini-word.draggable {
  cursor: grab;
}

.dr-mini-word.draggable:active {
  cursor: grabbing;
}

/* Drag area - modern card layout */
.dr-drag-area {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px;
  background: linear-gradient(135deg, #ffffff 0%, #f7fafc 100%);
  border: 2px dashed #cbd5e0;
  border-radius: 12px;
  min-height: 120px;
  transition: all 0.3s ease;
}

.dr-drag-area.hidden {
  display: none;
}

.dr-drag-area:empty::before {
  content: '🎯 Kéo các từ vào đây để sắp xếp';
  display: block;
  text-align: center;
  color: #a0aec0;
  font-style: italic;
  padding: 40px;
}

/* Drag item lite - horizontal compact card */
.drag-item-lite {
  display: flex;
  align-items: center;
  padding: 12px 18px;
  background: white;
  border: 2px solid #e2e8f0;
  border-radius: 10px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  cursor: grab;
  transition: all 0.25s ease;
  position: relative;
}

.drag-item-lite::before {
  content: '☰';
  margin-right: 12px;
  color: #a0aec0;
  font-size: 16px;
}

.drag-item-lite:hover {
  border-color: #667eea;
  box-shadow: 0 4px 16px rgba(102, 126, 234, 0.2);
  transform: translateX(4px);
}

.drag-item-lite:active,
.drag-item-lite.dragging {
  cursor: grabbing;
  opacity: 0.7;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  transform: rotate(1deg) scale(1.02);
  background: #f0f4ff;
  border-color: #667eea;
  z-index: 100;
}

.drag-item-lite.drag-over-top {
  border-top: 3px solid #667eea;
}

.drag-item-lite.drag-over-bottom {
  border-bottom: 3px solid #667eea;
}

.drag-item-lite .dr-mini-word {
  background: transparent;
  padding: 0;
}

/* Click Assembly Area - shown in click mode */
.dr-click-assembly {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 16px;
  background: linear-gradient(135deg, #f0fff4 0%, #e6ffed 100%);
  border: 2px dashed #68d391;
  border-radius: 12px;
  min-height: 80px;
  transition: all 0.3s ease;
}

.dr-click-assembly.hidden {
  display: none;
}

.dr-click-assembly:empty::before {
  content: '👆 Click vào các từ ở trên để thêm vào đây';
  display: block;
  width: 100%;
  text-align: center;
  color: #68d391;
  font-style: italic;
  padding: 20px;
}

/* Click fragment - added items in assembly area */
.click-frag {
  display: inline-flex;
  align-items: center;
  padding: 8px 14px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  animation: popIn 0.3s ease;
}

.click-frag::after {
  content: '×';
  margin-left: 8px;
  font-size: 16px;
  opacity: 0.7;
  transition: opacity 0.2s;
}

.click-frag:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.click-frag:hover::after {
  opacity: 1;
}

@keyframes popIn {
  0% {
    transform: scale(0.8);
    opacity: 0;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

/* Preview area - shows current order */
.drag-preview {
  margin-top: 16px;
  padding: 14px 18px;
  background: linear-gradient(135deg, #faf5ff 0%, #f3e8ff 100%);
  border: 1px solid #d6bcfa;
  border-radius: 10px;
  font-size: 15px;
  color: #553c9a;
  font-weight: 500;
  line-height: 1.6;
}

.drag-preview:empty {
  display: none;
}

/* ==========================================
   DR/AR CHECK BUTTON & RESULT STATES
   ========================================== */

/* Check button container */
.dr-actions,
.ar-actions {
  margin-top: 16px;
  display: flex;
  justify-content: center;
}

/* Check button */
.dr-check-btn,
.ar-check-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 28px;
  font-size: 15px;
  font-weight: 600;
  color: white;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border: none;
  border-radius: 30px;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.dr-check-btn:hover,
.ar-check-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.dr-check-btn:active,
.ar-check-btn:active {
  transform: translateY(0);
}

.dr-check-btn:disabled,
.ar-check-btn:disabled {
  opacity: 0.7;
  cursor: not-allowed;
  transform: none;
}

.dr-check-btn i,
.ar-check-btn i {
  font-size: 16px;
}

/* Result states for drag items */
.drag-item-lite.result-correct,
.click-frag.result-correct {
  background: linear-gradient(135deg, #48bb78 0%, #38a169 100%) !important;
  border-color: #38a169 !important;
  color: white !important;
  animation: correctPulse 0.5s ease;
}

.drag-item-lite.result-correct .dr-mini-word,
.click-frag.result-correct {
  color: white !important;
}

.drag-item-lite.result-incorrect,
.click-frag.result-incorrect {
  background: linear-gradient(135deg, #fc8181 0%, #f56565 100%) !important;
  border-color: #f56565 !important;
  color: white !important;
  animation: incorrectShake 0.5s ease;
}

.drag-item-lite.result-incorrect .dr-mini-word,
.click-frag.result-incorrect {
  color: white !important;
}

/* Result states for arrange items */
.arrange-item.result-correct {
  background: linear-gradient(135deg, #c6f6d5 0%, #9ae6b4 100%) !important;
  border-color: #48bb78 !important;
  animation: correctPulse 0.5s ease;
}

.arrange-item.result-correct .arrange-order {
  background: linear-gradient(135deg, #48bb78 0%, #38a169 100%);
}

.arrange-item.result-incorrect {
  background: linear-gradient(135deg, #fed7d7 0%, #feb2b2 100%) !important;
  border-color: #f56565 !important;
  animation: incorrectShake 0.5s ease;
}

.arrange-item.result-incorrect .arrange-order {
  background: linear-gradient(135deg, #fc8181 0%, #f56565 100%);
}

/* Animations */
@keyframes correctPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.02); }
}

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

/* Correct order hint in feedback */
.correct-order-hint {
  margin-top: 8px;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  font-size: 14px;
}

.correct-order-hint strong {
  display: block;
  margin-bottom: 4px;
  color: inherit;
}

/* Score badge */
.score-badge {
  display: inline-block;
  padding: 4px 12px;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 20px;
  font-weight: 700;
}

/* ==========================================
   AR FORMAT - Enhanced Arrange Items
   ========================================== */

/* Mobile touch improvements for arrange items */
.arrange-items {
  touch-action: none;
}

.arrange-item {
  touch-action: none;
}

.arrange-item .arrange-handle {
  touch-action: none;
  padding: 8px;
  margin: -8px;
  margin-right: 4px;
}

/* Dragging states */
.arrange-item.dragging {
  z-index: 100;
  transform: rotate(2deg);
}

.arrange-item.drag-over-top {
  border-top: 3px solid #f5576c;
}

.arrange-item.drag-over-bottom {
  border-bottom: 3px solid #f5576c;
}

/* ==========================================
   Responsive for DR/AR formats
   ========================================== */
@media (max-width: 768px) {
  .dr-word-bank {
    gap: 6px;
    padding: 10px 12px;
  }
  
  .dr-word-bank .wb-item {
    padding: 5px 10px;
    font-size: 13px;
  }
  
  .drag-item-lite {
    padding: 10px 14px;
  }
  
  .drag-item-lite::before {
    margin-right: 8px;
  }
  
  .dr-click-assembly {
    padding: 12px;
    gap: 6px;
  }
  
  .click-frag {
    padding: 6px 12px;
    font-size: 13px;
  }
  
  .drag-preview {
    padding: 10px 14px;
    font-size: 14px;
  }
  
  .dr-mode-toggle {
    padding: 4px 10px;
    font-size: 11px;
  }
}

/* Touch device enhancements */
@media (hover: none) and (pointer: coarse) {
  .drag-item-lite {
    padding: 14px 18px;
  }
  
  .dr-word-bank .wb-item {
    padding: 8px 16px;
    font-size: 15px;
  }
  
  .click-frag {
    padding: 10px 16px;
    font-size: 15px;
  }
  
  .drag-item-lite:active {
    transform: scale(1.02);
  }
}

