/* Modular CSS slice extracted from style.css (7905-8616) */
[data-theme="dark"] .ai-step-item.completed {
  background: rgba(16, 185, 129, 0.14);
  border-color: rgba(52, 211, 153, 0.35);
}
[data-theme="dark"] .ai-step-item.failed {
  background: rgba(239, 68, 68, 0.16);
  border-color: rgba(248, 113, 113, 0.4);
}
[data-theme="dark"] .ai-step-name { color: #f8fafc; }
[data-theme="dark"] .ai-step-status { color: #cbd5e1; }

@keyframes pulse-badge {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

.ai-step-item.completed .ai-step-badge {
  background: #dcfce7;
  color: #15803d;
}

.ai-step-item.pending .ai-step-badge {
  background: #f1f5f9;
  color: #94a3b8;
}

.ai-step-item.failed {
  background: #fef2f2;
  border-color: #fecaca;
}

.ai-step-item.failed .ai-step-badge {
  background: #fee2e2;
  color: #b91c1c;
}

@media (max-width: 480px) {
  #ai-progress-error-box > div:last-child {
    flex-direction: column-reverse;
  }
  #ai-progress-error-box button {
    width: 100%;
    min-height: 42px;
    justify-content: center;
  }
}

/* Mobile & Tablet Responsive Queries */
@media (max-width: 1024px) {
  .rubric-q-meta-grid {
    grid-template-columns: 1fr 1fr;
  }
  .rubric-q-detail {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .rubric-mode-tabs {
    flex-wrap: wrap;
  }
  .rubric-tab-btn {
    flex: 1 1 45%;
    font-size: 0.74rem;
    padding: 0.4rem;
  }
  .rubric-q-meta-grid {
    grid-template-columns: 1fr;
  }
  #modal-rubric-studio .rubric-studio-modal-content,
  #modal-rubric-studio .modal-content,
  .rubric-studio-modal-content {
    width: 100vw !important;
    height: 100vh !important;
    height: 100dvh !important;
    max-width: 100vw !important;
    max-height: 100dvh !important;
    border-radius: 0 !important;
    padding: 0.75rem !important;
    margin: 0 !important;
  }
  .rubric-studio-header {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
  }
  .rubric-studio-actions {
    justify-content: flex-end;
  }
  .rubric-studio-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
  }
  .rubric-studio-toolbar-right {
    margin-left: 0;
    width: 100%;
    justify-content: space-between;
  }
}

/* ==========================================================================
   SEGMENTED QUICK SELECT & LIVE SUBMISSION CARD STYLES
   High-contrast, Accessible & Touch-friendly
   ========================================================================== */
.segmented-button-group {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  background: #e2e8f0;
  padding: 6px;
  border-radius: 14px;
  border: 2px solid #cbd5e1;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.06);
}

.segmented-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0.75rem 1rem;
  min-height: 48px;
  border-radius: 10px;
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  user-select: none;
  border: 2px solid #cbd5e1;
  background: #ffffff;
  color: #475569;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  position: relative;
  outline: none;
}

.segmented-btn:hover:not(.active) {
  color: #0f172a;
  background: #f8fafc;
  border-color: #94a3b8;
  transform: translateY(-1px);
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.08);
}

.segmented-btn:focus-visible {
  outline: 3px solid #818cf8;
  outline-offset: 2px;
}

.segmented-btn.active {
  background: linear-gradient(135deg, #4338ca 0%, #312e81 100%) !important;
  color: #ffffff !important;
  font-weight: 800;
  border-color: #312e81 !important;
  box-shadow: 0 4px 14px rgba(67, 56, 202, 0.4), 0 2px 4px rgba(0, 0, 0, 0.1) !important;
  transform: scale(1.02);
  z-index: 2;
}

.segmented-btn .seg-icon {
  font-size: 1.15rem;
  line-height: 1;
}

.segmented-btn .seg-label {
  letter-spacing: -0.01em;
}

.segmented-btn .seg-status-badge {
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  letter-spacing: 0.02em;
  transition: all 0.2s ease;
}

.segmented-btn.active .seg-status-badge {
  background: rgba(255, 255, 255, 0.22);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.45);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
}

.segmented-btn:not(.active) .seg-status-badge {
  display: none;
}

@media (max-width: 480px) {
  .segmented-button-group {
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 6px;
  }

  .segmented-btn {
    width: 100%;
    min-height: 50px;
    padding: 0.8rem 1rem;
    font-size: 0.95rem;
  }
}

/* Submitted Live Card Instant View */
.submitted-live-card {
  animation: slideDownFade 0.3s ease-out;
  border: 1px solid #bbf7d0;
  background: linear-gradient(180deg, #f0fdf4 0%, #ffffff 100%);
  border-radius: var(--radius-lg, 12px);
  padding: 1.25rem;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

@keyframes slideDownFade {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.submitted-live-thumbs {
  display: flex;
  gap: 0.75rem;
  overflow-x: auto;
  padding: 0.5rem 0.25rem;
  -webkit-overflow-scrolling: touch;
}

.submitted-live-thumb-item {
  position: relative;
  flex: 0 0 85px;
  height: 110px;
  border-radius: 6px;
  overflow: hidden;
  border: 2px solid #e2e8f0;
  background: #f8fafc;
  cursor: pointer;
  transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
}

.submitted-live-thumb-item:hover {
  transform: scale(1.05);
  border-color: #10b981;
  box-shadow: 0 4px 10px rgba(16, 185, 129, 0.2);
}

.submitted-live-thumb-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.submitted-live-thumb-item .thumb-page-badge {
  position: absolute;
  bottom: 4px;
  right: 4px;
  background: rgba(15, 23, 42, 0.8);
  color: #ffffff;
  font-size: 0.65rem;
  padding: 1px 5px;
  border-radius: 4px;
  font-weight: 700;
}

/* --- PDF & IMAGE THUMBNAIL CARDS (RESPONSIVE & SOPHISTICATED) --- */
.pdf-thumbnail-card {
  position: relative;
  width: 76px;
  height: 96px;
  border-radius: 8px;
  overflow: hidden;
  border: 1.5px solid #fca5a5;
  background: linear-gradient(145deg, #fff5f5 0%, #fef2f2 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(239, 68, 68, 0.08);
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.2s ease, border-color 0.2s ease;
  cursor: pointer;
  user-select: none;
  flex-shrink: 0;
}

.pdf-thumbnail-card:hover {
  transform: translateY(-2px);
  border-color: #ef4444;
  box-shadow: 0 6px 14px rgba(239, 68, 68, 0.18);
}

.pdf-thumbnail-card .pdf-icon-badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin-top: -6px;
}

.pdf-thumbnail-card .pdf-svg-icon {
  width: 28px;
  height: 28px;
  color: #dc2626;
}

.pdf-thumbnail-card .pdf-type-label {
  font-size: 0.65rem;
  font-weight: 900;
  color: #b91c1c;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  margin-top: 1px;
}

.pdf-thumbnail-card .pdf-filename-label {
  font-size: 0.58rem;
  color: #64748b;
  max-width: 66px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: center;
  padding: 0 3px;
  margin-top: 2px;
}

.pdf-thumbnail-card .pdf-page-tag {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(185, 28, 28, 0.9);
  color: #ffffff;
  font-size: 0.62rem;
  font-weight: 700;
  text-align: center;
  padding: 2px 0;
  line-height: 1.2;
}

/* --- WORD (.DOCX) THUMBNAIL CARDS --- */
.word-thumbnail-card {
  position: relative;
  width: 76px;
  height: 96px;
  border-radius: 8px;
  overflow: hidden;
  border: 1.5px solid #93c5fd;
  background: linear-gradient(145deg, #f0f7ff 0%, #e0effe 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.1);
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.2s ease, border-color 0.2s ease;
  cursor: pointer;
  user-select: none;
  flex-shrink: 0;
}

.word-thumbnail-card:hover {
  transform: translateY(-2px);
  border-color: #2563eb;
  box-shadow: 0 6px 14px rgba(37, 99, 235, 0.2);
}

.word-thumbnail-card .word-icon-badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin-top: -6px;
}

.word-thumbnail-card .word-svg-icon {
  width: 28px;
  height: 28px;
  color: #1d4ed8;
}

.word-thumbnail-card .word-type-label {
  font-size: 0.65rem;
  font-weight: 900;
  color: #1e40af;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  margin-top: 1px;
}

.word-thumbnail-card .word-filename-label {
  font-size: 0.58rem;
  color: #3b82f6;
  max-width: 66px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: center;
  padding: 0 3px;
  margin-top: 2px;
}

.word-thumbnail-card .word-page-tag {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(29, 78, 216, 0.9);
  color: #ffffff;
  font-size: 0.62rem;
  font-weight: 700;
  text-align: center;
  padding: 2px 0;
  line-height: 1.2;
}

/* --- WORD DOCUMENT CARD & DIGITIZED EXAM VIEWER --- */
.word-document-viewer-card {
  width: 100%;
  max-width: 780px;
  border-radius: var(--radius-md, 8px);
  border: 1.5px solid #bfdbfe;
  background: #ffffff;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.06);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  text-align: left;
}

.word-document-viewer-card:hover {
  border-color: #93c5fd;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.1);
}

.word-document-header {
  padding: 0.85rem 1.1rem;
  background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
  border-bottom: 1px solid #bfdbfe;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.word-document-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.word-document-icon-badge {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: #1d4ed8;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 1.1rem;
  box-shadow: 0 2px 6px rgba(29, 78, 216, 0.3);
  flex-shrink: 0;
}

.word-document-title {
  font-weight: 800;
  font-size: 0.92rem;
  color: #1e3a8a;
  word-break: break-all;
}

.word-document-subtitle {
  font-size: 0.75rem;
  color: #3b82f6;
  margin-top: 0.1rem;
}

.word-document-actions {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  flex-wrap: wrap;
}

.digitized-paper-sheet {
  width: 100%;
  max-width: 780px;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: var(--radius-md, 8px);
  padding: 1.5rem;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.7;
  color: #1e293b;
  text-align: left;
}

.digitized-paper-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 0.85rem;
  margin-bottom: 1rem;
  border-bottom: 1.5px solid #e2e8f0;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.digitized-paper-content {
  white-space: pre-wrap;
  font-size: 0.92rem;
  color: #0f172a;
  word-break: break-word;
}

.digitized-paper-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
  font-size: 0.85rem;
}

.digitized-paper-content th,
.digitized-paper-content td {
  border: 1px solid #cbd5e1;
  padding: 0.5rem 0.75rem;
}

.digitized-paper-content th {
  background: #f1f5f9;
  color: #1e293b;
  font-weight: 700;
}

.rubric-comprehensive-solution-box {
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  border-radius: var(--radius-md, 8px);
  padding: 1rem 1.25rem;
  margin-top: 1rem;
  text-align: left;
}

.image-thumbnail-card {
  position: relative;
  width: 76px;
  height: 96px;
  border-radius: 8px;
  overflow: hidden;
  border: 1.5px solid #cbd5e1;
  background: #f8fafc;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  flex-shrink: 0;
}

.image-thumbnail-card:hover {
  transform: translateY(-2px);
  border-color: #6366f1;
  box-shadow: 0 6px 14px rgba(99, 102, 241, 0.18);
}

.image-thumbnail-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.image-thumbnail-card .image-fallback-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  background: #f1f5f9;
  color: #64748b;
  font-size: 0.68rem;
  text-align: center;
  padding: 4px;
}

.image-thumbnail-card .thumbnail-page-tag {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(15, 23, 42, 0.85);
  color: #ffffff;
  font-size: 0.62rem;
  font-weight: 700;
  text-align: center;
  padding: 2px 0;
  line-height: 1.2;
}

.thumbnail-remove-btn {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(239, 68, 68, 0.9);
  color: #ffffff;
  border: none;
  font-size: 10px;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  z-index: 3;
  transition: transform 0.15s, background-color 0.15s;
}

.thumbnail-remove-btn:hover {
  transform: scale(1.15);
  background: #dc2626;
}

/* ==========================================================================
   ENHANCED PEDAGOGICAL RUBRIC & GEMINI 3.8 FLASH DISPLAY SYSTEM
   Responsive across mobile, tablet, and high-res desktop screens
   ========================================================================== */

.rubric-viewer-card {
  background: var(--surface-card, #ffffff);
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: var(--radius-md, 10px);
  padding: 1rem;
  box-shadow: var(--shadow-sm, 0 1px 3px rgba(0,0,0,0.05));
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.rubric-viewer-card:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.07);
  border-color: #cbd5e1;
}

.rubric-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  border-bottom: 1px solid #f1f5f9;
  padding-bottom: 0.5rem;
  margin-bottom: 0.65rem;
}

.rubric-card-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 0.85rem;
}

@media (max-width: 768px) {
  .rubric-card-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 0.65rem;
  }
}

.rubric-box-section {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 0.65rem 0.75rem;
  display: flex;
  flex-direction: column;
}

.rubric-box-header {
  font-weight: 700;
  font-size: 0.78rem;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-bottom: 0.4rem;
}

.rubric-box-header.criteria-header {
  color: #166534;
}

.rubric-box-header.solution-header {
  color: #1d4ed8;
}

.rubric-box-content {
  font-size: 0.82rem;
  line-height: 1.5;
  color: #334155;
  white-space: pre-wrap;
  word-break: break-word;
}

.pedagogical-ai-badge,