/* ==========================================================================
   AUTOGRADING - QUICK SINGLE-ITEM ASSESSMENT WORKBENCH & HISTORY DRAWER
   Focused 100%-Width Workbench + Recent Session Strip + On-Demand Drawer
   Strictly <= 350 LOC, Responsive (320px -> 1440px+), Light & Dark Mode
   ========================================================================== */

/* 1. Restore 2-Column Studio Grid for Audit / Rubric / OCR Tabs */
.studio-grid-2col {
  display: grid;
  grid-template-columns: minmax(350px, 450px) minmax(0, 1fr);
  gap: 1.15rem;
  align-items: start;
}

@media (max-width: 1024px) {
  .studio-grid-2col {
    grid-template-columns: 1fr;
  }
}

/* 2. Focused Single-Column Workbench Container (#panel-studio-quick) */
#panel-studio-quick {
  padding-bottom: 4.5rem; /* Clearance for floating Support Assistant FAB & Mobile Dock */
}

.quick-workbench-stack {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  width: 100%;
}

/* 3. Upload Card Header & Collapsed Summary Bar */
.quick-upload-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-bottom: 0.75rem;
}

.quick-upload-header.is-collapsed {
  margin-bottom: 0;
  align-items: center;
}

.quick-upload-header-actions {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.quick-history-trigger-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.36rem 0.7rem;
  border-radius: 999px;
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  color: #1e293b;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.16s ease;
}

.quick-history-trigger-btn:hover {
  border-color: #6366f1;
  background: #eef2ff;
  color: #3730a3;
}

.quick-history-count-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.1rem 0.48rem;
  border-radius: 999px;
  background: #e0e7ff;
  color: #3730a3;
  font-size: 0.7rem;
  font-weight: 800;
}

.quick-upload-collapsed-bar {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
  flex-wrap: wrap;
  margin-top: 0.65rem;
  padding: 0.6rem 0.85rem;
  border-radius: 10px;
  background: linear-gradient(135deg, #f8fafc 0%, #eef2ff 100%);
  border: 1px dashed #a5b4fc;
}

.quick-upload-collapsed-bar.is-visible {
  display: flex;
}

/* 4. Mode Cards & Compact Upload Controls */
.quick-mode-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.6rem;
  margin-bottom: 0.75rem;
}

.quick-mode-card {
  text-align: left;
  padding: 0.68rem 0.85rem;
  border-radius: 10px;
  border: 1.5px solid #cbd5e1;
  background: #ffffff;
  cursor: pointer;
  transition: all 0.16s ease;
}

.quick-mode-card:hover {
  border-color: #818cf8;
}

.quick-mode-card.active {
  border: 2px solid #4f46e5;
  background: #eef2ff;
  box-shadow: 0 2px 8px rgba(79, 70, 229, 0.08);
}

.quick-metadata-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.6rem;
  margin-bottom: 0.65rem;
}

/* 5. Compact 1-Line Recent Sessions Strip (Replaces bulky in-page archive) */
.quick-recent-strip {
  display: none;
  align-items: center;
  gap: 0.5rem;
  padding: 0.48rem 0.75rem;
  border-radius: 12px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.03);
}

.quick-recent-strip.is-visible {
  display: flex;
}

.quick-recent-label {
  font-size: 0.75rem;
  font-weight: 800;
  color: #475569;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  flex-shrink: 0;
}

.quick-recent-chips-scroll {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  overflow-x: auto;
  flex: 1;
  min-width: 0;
  scrollbar-width: none;
  padding: 2px 0;
}

.quick-recent-chips-scroll::-webkit-scrollbar {
  display: none;
}

.quick-recent-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.22rem 0.35rem 0.22rem 0.6rem;
  border-radius: 999px;
  border: 1px solid #e2e8f0;
  background: #f8fafc;
  color: #334155;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.quick-recent-chip-content {
  display: inline-flex;
  align-items: center;
  gap: 0.38rem;
  cursor: pointer;
}

.quick-recent-chip:hover {
  border-color: #818cf8;
  background: #f5f7ff;
}

.quick-recent-chip.is-active {
  border-color: #4f46e5;
  background: #eef2ff;
  color: #312e81;
  font-weight: 700;
}

.quick-recent-chip-title {
  max-width: 175px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.quick-recent-chip-score {
  padding: 0.06rem 0.38rem;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 800;
  background: #dcfce7;
  color: #166534;
}

.quick-recent-chip-mode {
  padding: 0.06rem 0.38rem;
  border-radius: 999px;
  font-size: 0.66rem;
  font-weight: 700;
  background: #e0e7ff;
  color: #3730a3;
}

.quick-recent-chip-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.15rem;
  margin-left: 0.2rem;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.quick-recent-chip:hover .quick-recent-chip-actions,
.quick-recent-chip.is-active .quick-recent-chip-actions,
.quick-recent-chip:focus-within .quick-recent-chip-actions {
  opacity: 1;
}

.quick-recent-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.35rem;
  height: 1.35rem;
  padding: 0;
  border-radius: 999px;
  border: none;
  background: transparent;
  color: #94a3b8;
  font-size: 0.65rem;
  cursor: pointer;
  transition: all 0.15s ease;
}

.quick-recent-action-btn:hover {
  background: rgba(148, 163, 184, 0.2);
  color: #0f172a;
}

.quick-recent-action-btn.quick-recent-delete-btn:hover {
  background: #fee2e2;
  color: #e11d48;
}

.quick-record-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.quick-record-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.15rem 0.4rem;
  border-radius: 6px;
  border: 1px solid #e2e8f0;
  background: #f8fafc;
  color: #475569;
  font-size: 0.7rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.quick-record-action-btn:hover {
  border-color: #94a3b8;
  background: #ffffff;
  color: #0f172a;
}

.quick-record-action-btn.btn-record-delete:hover {
  border-color: #fecdd3;
  background: #fff1f2;
  color: #e11d48;
}

#modal-quick-rename-record.is-open {
  display: flex !important;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1050;
  align-items: center;
  justify-content: center;
}

#quick-rename-modal-backdrop.is-open {
  display: block !important;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1040;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(2px);
}

/* 6. Stage Stepper Readiness Indicator Dot (Preserves pure button textContent) */
.quick-stage-tablist {
  display: flex;
  gap: 0.45rem;
  overflow-x: auto;
  border-bottom: 1px solid #e2e8f0;
  padding-bottom: 0.6rem;
  margin-bottom: 0.9rem;
  scrollbar-width: none;
}

.quick-stage-tablist button[data-has-data="true"] {
  position: relative;
}

.quick-stage-tablist button[data-has-data="true"]::after {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-left: 6px;
  border-radius: 50%;
  background: #10b981;
  vertical-align: middle;
}

.quick-stage-tablist button.btn-primary[data-has-data="true"]::after {
  background: #a7f3d0;
}

/* 7. Slide-Over History Drawer (#quick-history-drawer) */
.quick-history-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.38);
  backdrop-filter: blur(2px);
  z-index: 10040;
}

.quick-history-backdrop.is-open {
  display: block;
}

.quick-history-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(420px, 92vw);
  background: #ffffff;
  border-left: 1px solid #e2e8f0;
  box-shadow: -12px 0 32px rgba(15, 23, 42, 0.14);
  z-index: 10050;
  display: flex;
  flex-direction: column;
  transform: translateX(104%);
  visibility: hidden;
  transition: transform 0.22s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.22s;
}

#quick-history-drawer select {
  font-size: 0.77rem !important;
  padding: 0.42rem 28px 0.42rem 0.65rem !important;
}

.quick-history-drawer.is-open {
  transform: translateX(0);
  visibility: visible;
}

.quick-history-drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 1rem 1.1rem 0.8rem;
  border-bottom: 1px solid #e2e8f0;
}

.quick-history-drawer-filters {
  padding: 0.75rem 1.1rem;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.quick-history-drawer-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.quick-record-item {
  padding: 0.7rem 0.8rem;
  border-radius: 10px;
  border: 1px solid #e2e8f0;
  background: #ffffff;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.quick-record-item:hover {
  border-color: #a5b4fc;
  background: #f8fafc;
}

.quick-record-item.is-selected {
  border: 1.5px solid #4f46e5;
  background: #f5f7ff;
}

.quick-history-drawer-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.65rem 1.1rem;
  border-top: 1px solid #e2e8f0;
  font-size: 0.75rem;
  color: #64748b;
  background: #ffffff;
}

/* 8. Rich-Math Input, Pre-Flight Guard & Inline Formula Recovery */
.quick-math-input-stack {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.quick-math-input-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  align-items: flex-end;
}

.quick-math-input-main {
  flex: 1;
  min-width: 240px;
}

.quick-math-label-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.3rem;
}

.quick-math-input-label {
  font-size: 0.74rem;
  font-weight: 700;
  color: #475569;
  margin: 0;
}

.quick-math-chips-bar {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.28rem;
}

.quick-math-chip-btn {
  padding: 0.16rem 0.45rem;
  font-size: 0.7rem;
  font-weight: 700;
  font-family: var(--mono, ui-monospace, SFMono-Regular, Menlo, monospace);
  color: #4338ca;
  background: #eef2ff;
  border: 1px solid #c7d2fe;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.14s ease, border-color 0.14s ease;
}

.quick-math-chip-btn:hover {
  background: #e0e7ff;
  border-color: #818cf8;
}

.quick-math-textarea {
  font-size: 0.81rem;
  line-height: 1.5;
  min-height: 62px;
  resize: vertical;
}

.quick-submit-process-btn {
  font-weight: 800;
  padding: 0.65rem 1.2rem;
  white-space: nowrap;
}

.quick-math-live-preview {
  padding: 0.55rem 0.75rem;
  border-radius: 8px;
  border: 1px dashed #cbd5e1;
  background: #f8fafc;
}

.quick-math-live-preview-header {
  font-size: 0.71rem;
  font-weight: 700;
  color: #64748b;
  margin-bottom: 0.22rem;
}

.quick-math-live-preview-body {
  font-size: 0.84rem;
  line-height: 1.55;
  color: #0f172a;
  overflow-x: auto;
}

.quick-preflight-card {
  padding: 0.8rem 0.95rem;
  border-radius: 10px;
  border: 1.5px solid #fcd34d;
  background: #fffbeb;
  color: #78350f;
}

.quick-preflight-header {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
}

.quick-preflight-icon {
  font-size: 1.05rem;
  line-height: 1.2;
  flex-shrink: 0;
}

.quick-preflight-title {
  font-size: 0.82rem;
  font-weight: 800;
  color: #92400e;
  margin-bottom: 0.18rem;
}

.quick-preflight-desc {
  font-size: 0.77rem;
  line-height: 1.48;
  color: #78350f;
}

.quick-preflight-template {
  margin-top: 0.55rem;
  padding: 0.55rem 0.7rem;
  border-radius: 8px;
  background: #ffffff;
  border: 1px solid #fde68a;
  font-size: 0.78rem;
  color: #1e293b;
}

.quick-preflight-template-text {
  margin-top: 0.22rem;
  line-height: 1.55;
  overflow-x: auto;
}

.quick-preflight-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.65rem;
}

.quick-inline-recovery-card {
  margin-bottom: 0.9rem;
  padding: 0.85rem 0.95rem;
  border-radius: 10px;
  border: 1.5px solid #f59e0b;
  background: linear-gradient(180deg, #fffbeb 0%, #fef3c7 100%);
  box-shadow: 0 2px 8px rgba(245, 158, 11, 0.08);
}

.quick-inline-recovery-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.45rem;
}

.quick-inline-recovery-head strong {
  font-size: 0.83rem;
  color: #92400e;
}

.quick-inline-recovery-head span {
  font-size: 0.73rem;
  color: #b45309;
}

.quick-inline-recovery-input {
  font-size: 0.82rem;
  line-height: 1.5;
  background: #ffffff;
  border-color: #fcd34d;
  margin-bottom: 0.55rem;
}

.quick-inline-recovery-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.quick-inline-recovery-right {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

/* 9. Responsive Breakpoints & Dark Mode */
@media (max-width: 900px) {
  .quick-mode-grid { grid-template-columns: 1fr; }
  .quick-metadata-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 600px) {
  .quick-metadata-grid {
    grid-template-columns: 1fr;
  }
  .quick-stage-tablist button {
    font-size: 0.76rem;
    padding: 0.38rem 0.62rem;
  }
  .quick-submit-process-btn {
    width: 100%;
    justify-content: center;
    white-space: normal;
    text-align: center;
  }
  .quick-inline-recovery-actions,
  .quick-inline-recovery-right,
  .quick-preflight-actions {
    width: 100%;
  }
  .quick-inline-recovery-right .btn,
  .quick-preflight-actions .btn {
    width: 100%;
    justify-content: center;
    white-space: normal;
  }
}

[data-theme="dark"] .quick-recent-strip,
[data-theme="dark"] .quick-history-drawer,
[data-theme="dark"] .quick-history-drawer-footer,
[data-theme="dark"] .quick-record-item,
[data-theme="dark"] .quick-math-live-preview {
  background: #0f172a;
  border-color: rgba(255, 255, 255, 0.12);
  color: #f8fafc;
}

[data-theme="dark"] .quick-math-live-preview-body {
  color: #f1f5f9;
}

[data-theme="dark"] .quick-preflight-card,
[data-theme="dark"] .quick-inline-recovery-card {
  background: rgba(120, 53, 15, 0.28);
  border-color: rgba(251, 191, 36, 0.45);
  color: #fef3c7;
}

[data-theme="dark"] .quick-preflight-title,
[data-theme="dark"] .quick-inline-recovery-head strong {
  color: #fde68a;
}

[data-theme="dark"] .quick-preflight-desc,
[data-theme="dark"] .quick-inline-recovery-head span {
  color: #fcd34d;
}

[data-theme="dark"] .quick-preflight-template,
[data-theme="dark"] .quick-inline-recovery-input {
  background: #0f172a;
  border-color: rgba(251, 191, 36, 0.35);
  color: #f8fafc;
}

[data-theme="dark"] .quick-history-drawer-filters,
[data-theme="dark"] .quick-history-trigger-btn,
[data-theme="dark"] .quick-recent-chip,
[data-theme="dark"] .quick-mode-card {
  background: #1e293b;
  border-color: rgba(255, 255, 255, 0.14);
  color: #e2e8f0;
}

[data-theme="dark"] .quick-mode-card.active,
[data-theme="dark"] .quick-recent-chip.is-active,
[data-theme="dark"] .quick-record-item.is-selected,
[data-theme="dark"] .quick-upload-collapsed-bar {
  background: rgba(79, 70, 229, 0.22);
  border-color: #818cf8;
  color: #f8fafc;
}

.quick-parametric-valid-badge {
  margin-top: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  background: #ecfdf5;
  border: 1px solid #6ee7b7;
  color: #065f46;
  font-size: 0.78rem;
  line-height: 1.45;
}

.quick-inline-recovery-card--parametric { background: #f0fdf4; border-color: #6ee7b7; }
.quick-inline-recovery-card--parametric .quick-inline-recovery-head strong { color: #065f46; }
.quick-inline-recovery-card--parametric .quick-inline-recovery-head span { color: #047857; }

.quick-inline-custom-formula-details {
  margin-top: 6px;
  border-top: 1px dashed rgba(16, 185, 129, 0.35);
  padding-top: 8px;
}
.quick-inline-custom-formula-details summary {
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 600;
  color: #047857;
  user-select: none;
}
.quick-inline-custom-formula-body {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

[data-theme="dark"] .quick-parametric-valid-badge,
[data-theme="dark"] .quick-inline-recovery-card--parametric {
  background: rgba(6, 78, 59, 0.32);
  border-color: rgba(52, 211, 153, 0.45);
  color: #d1fae5;
}
[data-theme="dark"] .quick-inline-recovery-card--parametric .quick-inline-recovery-head strong,
[data-theme="dark"] .quick-inline-custom-formula-details summary { color: #a7f3d0; }
[data-theme="dark"] .quick-inline-recovery-card--parametric .quick-inline-recovery-head span { color: #6ee7b7; }
