:root {
  --bg: #f8fafc;
  --panel: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --accent: #0f172a;
  --green: #15803d;
  --shadow: 0 18px 55px rgba(15, 23, 42, 0.08);
  --grammar-bg: #dbeafe;
  --grammar-border: #60a5fa;
  --grammar-text: #1d4ed8;
  --vocabulary-bg: #fef3c7;
  --vocabulary-border: #f59e0b;
  --vocabulary-text: #92400e;
  --spelling-bg: #ffedd5;
  --spelling-border: #fb923c;
  --spelling-text: #9a3412;
  --coherence-bg: #ede9fe;
  --coherence-border: #a78bfa;
  --coherence-text: #6d28d9;
  --task-bg: #cffafe;
  --task-border: #0891b2;
  --task-text: #0e7490;
  --style-bg: #f1f5f9;
  --style-border: #64748b;
  --style-text: #334155;
  --punctuation-bg: #cffafe;
  --punctuation-border: #06b6d4;
  --punctuation-text: #0e7490;
  --idea-bg: #fae8ff;
  --idea-border: #d946ef;
  --idea-text: #86198f;
  --student-text-size: 18px;
  --pasted-image-scale: 1;
  --sidebar-width: 320px;
  --workspace-resize-handle-width: 42px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  line-height: 1.5;
}

body.theme-dark {
  --bg: #0b1120;
  --panel: #111827;
  --ink: #e5e7eb;
  --muted: #cbd5e1;
  --line: #334155;
  --accent: #e5e7eb;
  --green: #22c55e;
  --shadow: 0 18px 55px rgba(0, 0, 0, 0.36);
  --grammar-bg: #172554;
  --grammar-border: #60a5fa;
  --grammar-text: #bfdbfe;
  --vocabulary-bg: #451a03;
  --vocabulary-border: #f59e0b;
  --vocabulary-text: #fde68a;
  --spelling-bg: #431407;
  --spelling-border: #fb923c;
  --spelling-text: #fed7aa;
  --coherence-bg: #2e1065;
  --coherence-border: #a78bfa;
  --coherence-text: #ddd6fe;
  --task-bg: #083344;
  --task-border: #22d3ee;
  --task-text: #a5f3fc;
  --style-bg: #1e293b;
  --style-border: #94a3b8;
  --style-text: #e2e8f0;
  --punctuation-bg: #083344;
  --punctuation-border: #22d3ee;
  --punctuation-text: #a5f3fc;
  --idea-bg: #4a044e;
  --idea-border: #e879f9;
  --idea-text: #f5d0fe;
}

body.theme-contrast {
  --bg: #000000;
  --panel: #ffffff;
  --ink: #000000;
  --muted: #111111;
  --line: #000000;
  --accent: #000000;
  --green: #006b2e;
  --shadow: none;
  --grammar-bg: #e0f2fe;
  --grammar-border: #004b93;
  --grammar-text: #000000;
  --vocabulary-bg: #fff7cc;
  --vocabulary-border: #7a3e00;
  --vocabulary-text: #000000;
  --spelling-bg: #ffe8d1;
  --spelling-border: #8a2500;
  --spelling-text: #000000;
  --coherence-bg: #ede3ff;
  --coherence-border: #4c1d95;
  --coherence-text: #000000;
  --task-bg: #d8fbff;
  --task-border: #005766;
  --task-text: #000000;
  --style-bg: #f3f4f6;
  --style-border: #111827;
  --style-text: #000000;
  --punctuation-bg: #d8fbff;
  --punctuation-border: #005766;
  --punctuation-text: #000000;
  --idea-bg: #fde2ff;
  --idea-border: #86198f;
  --idea-text: #000000;
}

/* Structured report overview: mirrors the student-facing result flow while
   keeping the annotation canvas as the teacher's primary work area. */
.review-overview {
  margin: 18px 0 14px;
  padding: 20px 22px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
  box-shadow: var(--shadow);
}
.review-overview-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}
.eyebrow {
  margin: 0 0 3px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
}
.review-overview h2 { margin: 0; font-size: 20px; letter-spacing: -.02em; }
.review-overview-copy { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.overall-band-card {
  min-width: 128px;
  padding: 10px 14px;
  border: 1px solid #bfdbfe;
  border-radius: 14px;
  background: #eff6ff;
  text-align: center;
}
.overall-band-card span, .overall-band-card small { display: block; color: #1d4ed8; font-size: 11px; font-weight: 700; }
.overall-band-card strong { display: block; color: #1e3a8a; font-size: 28px; line-height: 1.1; }
.overall-band-card small { color: #64748b; font-weight: 600; }
.review-overview-grid { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(240px, .8fr); gap: 14px; }
.criterion-score-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.criterion-score-card {
  min-height: 78px; padding: 11px 12px; border: 1px solid var(--line); border-radius: 12px;
  background: color-mix(in srgb, var(--panel) 88%, var(--bg));
}
.criterion-score-card .criterion-name { display: block; color: var(--muted); font-size: 11px; font-weight: 700; line-height: 1.25; }
.criterion-score-card strong { display: block; margin-top: 5px; font-size: 23px; line-height: 1; }
.criterion-score-card.is-scored { border-color: #86efac; background: #f0fdf4; }
.criterion-score-card.is-scored strong { color: #166534; }
.review-checklist { padding: 11px 13px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); }
.review-checklist h3 { margin: 0 0 7px; font-size: 12px; }
.review-checklist label { display: flex; gap: 8px; align-items: flex-start; margin: 7px 0; color: var(--muted); font-size: 11px; line-height: 1.35; }
.review-checklist input { flex: 0 0 auto; margin-top: 2px; }
body.theme-dark .overall-band-card { border-color: #1d4ed8; background: #172554; }
body.theme-dark .overall-band-card span, body.theme-dark .overall-band-card strong { color: #bfdbfe; }
body.theme-dark .criterion-score-card.is-scored { border-color: #166534; background: #052e16; }
body.theme-dark .criterion-score-card.is-scored strong { color: #86efac; }
@media (max-width: 900px) {
  .review-overview-grid { grid-template-columns: 1fr; }
  .criterion-score-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
  .review-overview { padding: 15px; }
  .review-overview-head { flex-direction: column; }
  .overall-band-card { width: 100%; }
}

button, input, textarea, select {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 12px;
  padding: 7px 11px;
  cursor: pointer;
  min-height: 32px;
  transition: background 0.15s ease, border-color 0.15s ease;
}

button:hover { background: #f8fafc; border-color: #cbd5e1; }
button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}
button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
button.danger { color: #be123c; background: #fff1f2; border-color: #fecdd3; }
button.icon { width: 40px; padding: 8px; font-weight: 800; border-radius: 12px; }

input, textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--ink);
  background: #fff;
  padding: 7px 9px;
}

input[type="checkbox"] {
  width: auto;
  accent-color: var(--accent);
}

body.theme-dark button,
body.theme-dark input,
body.theme-dark textarea,
body.theme-dark select {
  background: #1e293b;
  color: #e5e7eb;
  border-color: #475569;
}

body.theme-dark button:hover {
  background: #334155;
  border-color: #64748b;
}

body.theme-dark button.primary,
body.theme-dark .mode-toggle button.active {
  background: #f8fafc;
  border-color: #f8fafc;
  color: #0f172a;
}

body.theme-dark #suggestingMode.active {
  background: #22c55e;
  color: #052e16;
}

body.theme-contrast button,
body.theme-contrast input,
body.theme-contrast textarea,
body.theme-contrast select {
  background: #fff;
  color: #000;
  border: 2px solid #000;
}

body.theme-contrast button:hover {
  background: #f3f4f6;
  border-color: #000;
}

body.theme-contrast button.primary,
body.theme-contrast .mode-toggle button.active,
body.theme-contrast #suggestingMode.active {
  background: #000;
  border-color: #000;
  color: #fff;
}

textarea { min-height: 64px; resize: vertical; }

.app-shell {
  min-height: 100vh;
}

header {
  background: transparent;
  position: static;
}

.topbar {
  width: calc(100% - 16px);
  max-width: none;
  margin: 8px auto 0;
  padding: 14px 18px;
  display: grid;
  gap: 12px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.title-row, .toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.title-row {
  gap: 14px;
}

.title-row .brand {
  margin-right: auto;
}

.title-row .back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 10px;
  background: #f1f5f9;
  color: #475569;
  text-decoration: none;
  font-size: 13px;
  font-weight: 700;
  transition: all 0.15s ease;
}

.title-row .back-link:hover {
  background: #e2e8f0;
  color: #0f172a;
}

.toolbar {
  padding-top: 4px;
}

.header-actions {
  justify-content: flex-start;
  align-items: stretch;
  gap: 8px;
}

.header-actions .toolbar-group {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 7px;
  gap: 6px;
}

.toolbar-label {
  align-self: center;
  padding: 0 4px;
  color: #475569;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.import-actions {
  background: #f8fafc;
  border-color: #dbe3ee;
}

.session-actions {
  background: #eef2ff;
  border-color: #c7d2fe;
}

.session-actions button {
  border-color: #a5b4fc;
}

.export-actions {
  background: #ecfdf5;
  border-color: #bbf7d0;
}

.export-actions button {
  border-color: #86efac;
  background: #f0fdf4;
}

.export-actions button.primary {
  background: #166534;
  border-color: #166534;
  color: #fff;
}

.editor-export-actions {
  margin-left: 0;
  padding: 6px 8px;
  border: 1px solid #bbf7d0;
  border-radius: 18px;
  gap: 8px;
}

.editor-export-actions .toolbar-label {
  color: #166534;
}

.readability-actions {
  background: #f8fafc;
  border-color: #dbe3ee;
}

.editor-readability-actions {
  margin-left: 0;
  padding: 10px;
  border: 1px solid #dbe3ee;
  border-radius: 20px;
  gap: 10px;
}

.readability-control {
  display: grid;
  grid-template-columns: auto minmax(84px, 112px) auto auto;
  align-items: center;
  gap: 6px;
  color: #334155;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.readability-control select {
  min-width: 112px;
  border-radius: 12px;
  padding: 6px 8px;
}

.readability-control input[type="range"] {
  width: 112px;
  min-height: 24px;
  padding: 0;
  border: 0;
  background: transparent;
  accent-color: var(--accent);
}

.readability-value {
  min-width: 42px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.default-size-btn {
  min-height: 28px;
  border-radius: 10px;
  padding: 4px 8px;
  color: #475569;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
}

.default-size-btn.is-default {
  background: #ecfdf5;
  border-color: #86efac;
  color: #166534;
}

.app-actions {
  background: #fff7ed;
  border-color: #fed7aa;
}

.app-actions button {
  background: #fffbeb;
  border-color: #fbbf24;
  color: #92400e;
  font-weight: 700;
}

.brand {
  font-size: clamp(24px, 3vw, 32px);
  line-height: 1.1;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-right: auto;
}

.brand::before {
  content: "Teacher Marking & Feedback Studio";
  display: table;
  width: fit-content;
  margin-bottom: 6px;
  border-radius: 999px;
  background: #f1f5f9;
  color: #475569;
  padding: 3px 9px;
  font-size: 12px;
  line-height: 1.4;
  font-weight: 700;
  letter-spacing: 0;
}

.brand::after {
  content: "Use Editing mode to format essays. Use Suggesting mode to track green teacher additions and red student deletions.";
  display: block;
  margin-top: 5px;
  max-width: 760px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.4;
  font-weight: 500;
  letter-spacing: 0;
}

body.theme-dark .topbar,
body.theme-dark .panel,
body.theme-dark .canvas,
body.theme-dark .feedback-reference,
body.theme-dark .feedback-popover,
body.theme-dark .instructions-card,
body.theme-dark .deletion-context-menu {
  background: #111827;
  border-color: #334155;
  color: #e5e7eb;
}

body.theme-dark .title-row .back-link {
  background: #1e293b;
  color: #cbd5e1;
}

body.theme-dark .title-row .back-link:hover {
  background: #334155;
  color: #fff;
}

body.theme-dark .import-actions,
body.theme-dark .session-actions,
body.theme-dark .export-actions,
body.theme-dark .app-actions,
body.theme-dark .readability-actions,
body.theme-dark .editor-export-actions,
body.theme-dark .editor-readability-actions,
body.theme-dark .editor-help,
body.theme-dark .comment-target,
body.theme-dark .image-preview,
body.theme-dark .instruction-step {
  background: #172033;
  border-color: #334155;
}

body.theme-dark .toolbar-label,
body.theme-dark .editor-export-actions .toolbar-label,
body.theme-dark .readability-control,
body.theme-dark .readability-value,
body.theme-dark .brand::after,
body.theme-dark .editor-help h2,
body.theme-dark .editor-help ol,
body.theme-dark .score-field,
body.theme-dark .comment-target,
body.theme-dark .instruction-step p,
body.theme-dark .instruction-step ul {
  color: #cbd5e1;
}

body.theme-dark .brand::before {
  background: #1e293b;
  color: #e2e8f0;
}

body.theme-dark .app-footer a {
  color: #93c5fd;
}

body.theme-contrast .topbar,
body.theme-contrast .panel,
body.theme-contrast .canvas,
body.theme-contrast .feedback-reference,
body.theme-contrast .feedback-popover,
body.theme-contrast .instructions-card,
body.theme-contrast .deletion-context-menu,
body.theme-contrast .import-actions,
body.theme-contrast .session-actions,
body.theme-contrast .export-actions,
body.theme-contrast .app-actions,
body.theme-contrast .readability-actions,
body.theme-contrast .editor-export-actions,
body.theme-contrast .editor-readability-actions,
body.theme-contrast .editor-help,
body.theme-contrast .comment-target,
body.theme-contrast .image-preview,
body.theme-contrast .instruction-step {
  background: #fff;
  border-color: #000;
  color: #000;
  box-shadow: none;
}

body.theme-contrast .toolbar-label,
body.theme-contrast .editor-export-actions .toolbar-label,
body.theme-contrast .readability-control,
body.theme-contrast .readability-value,
body.theme-contrast .brand::after,
body.theme-contrast .editor-help h2,
body.theme-contrast .editor-help ol,
body.theme-contrast .score-field,
body.theme-contrast .comment-target,
body.theme-contrast .instruction-step p,
body.theme-contrast .instruction-step ul {
  color: #000;
}

body.theme-contrast .brand::before {
  background: #000;
  color: #fff;
}

.mode-toggle {
  display: inline-grid;
  grid-template-columns: 1fr 1fr;
  border: 1px solid var(--line);
  border-radius: 18px;
  overflow-y: auto;
  overflow-x: hidden;
  background: #fff;
}

.mode-toggle button {
  border: 0;
  border-radius: 0;
  min-width: 128px;
  font-weight: 800;
}

.mode-toggle button.active {
  background: #0f172a;
  color: #fff;
}

#suggestingMode.active {
  background: var(--green);
}

.editor-mode-toggle button {
  min-width: 104px;
}

.clear-everything {
  font-weight: 800;
  white-space: nowrap;
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 6px;
  padding-right: 8px;
}
.toolbar-group:last-child { border-right: 0; }

main {
  max-width: none;
  width: 100%;
  margin: 0 auto;
  padding: 8px 8px 18px;
  display: grid;
  grid-template-columns:
    minmax(240px, var(--sidebar-width))
    var(--workspace-resize-handle-width)
    minmax(0, 1fr);
  column-gap: 0;
  row-gap: 10px;
}

.sidebar {
  display: grid;
  align-content: start;
  gap: 12px;
  min-width: 0;
}

.workspace-resize-handle {
  position: relative;
  align-self: stretch;
  min-height: 180px;
  margin: 0 5px;
  border: 1px dashed #93c5fd;
  border-radius: 16px;
  padding: 0;
  background: rgba(239, 246, 255, 0.82);
  cursor: col-resize;
  touch-action: none;
  z-index: 8;
  transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.workspace-resize-handle::before {
  content: "";
  position: absolute;
  top: 8px;
  bottom: 8px;
  left: 50%;
  width: 3px;
  transform: translateX(-50%);
  border-radius: 999px;
  background: #bfdbfe;
  box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.08);
}

.workspace-resize-grip {
  position: sticky;
  top: 18px;
  display: flex;
  width: 30px;
  min-height: 132px;
  margin: 18px auto;
  padding: 10px 5px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 2px solid #fff;
  border-radius: 999px;
  background: #2563eb;
  color: #fff;
  box-shadow: 0 7px 18px rgba(37, 99, 235, 0.3);
  pointer-events: none;
  transition: background 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.workspace-resize-arrows {
  font-size: 19px;
  font-weight: 900;
  line-height: 1;
}

.workspace-resize-label {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  color: #fff;
  font-size: 10px;
  font-weight: 900;
  line-height: 1;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  white-space: nowrap;
}

.workspace-resize-handle:hover::before,
.workspace-resize-handle:focus-visible::before,
.workspace-resize-handle.active::before {
  background: #60a5fa;
}

.workspace-resize-handle:hover,
.workspace-resize-handle:focus-visible,
.workspace-resize-handle.active {
  border-color: #2563eb;
  background: #dbeafe;
  box-shadow: inset 0 0 0 1px rgba(37, 99, 235, 0.12);
}

.workspace-resize-handle:hover .workspace-resize-grip,
.workspace-resize-handle:focus-visible .workspace-resize-grip,
.workspace-resize-handle.active .workspace-resize-grip {
  background: #1d4ed8;
  box-shadow: 0 9px 24px rgba(37, 99, 235, 0.42);
  transform: scale(1.06);
}

.workspace-resize-handle:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.32);
  outline-offset: 2px;
}

body.workspace-resizing,
body.workspace-resizing * {
  cursor: col-resize !important;
  user-select: none !important;
}

body.theme-dark .workspace-resize-handle {
  border-color: #3b82f6;
  background: rgba(30, 58, 138, 0.28);
}

body.theme-dark .workspace-resize-handle::before {
  background: #3b82f6;
}

body.theme-dark .workspace-resize-grip {
  border-color: #bfdbfe;
  background: #3b82f6;
}

body.theme-contrast .workspace-resize-handle {
  border: 2px solid #000;
  background: #fff;
  box-shadow: none;
}

body.theme-contrast .workspace-resize-handle::before {
  background: #000;
  box-shadow: none;
}

body.theme-contrast .workspace-resize-grip {
  border: 2px solid #fff;
  background: #000;
  color: #fff;
  box-shadow: 0 0 0 2px #000;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px;
  box-shadow: var(--shadow);
}

.panel h2 {
  font-size: 18px;
  margin: 0 0 12px;
  letter-spacing: 0;
}

.editor-help {
  flex: 1 1 100%;
  order: 2;
  margin: -2px 0 2px;
  padding: 8px 10px;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  background: #f8fafc;
}

.editor-help h2 {
  margin: 0 0 6px;
  color: #334155;
  font-size: 14px;
}

.editor-help ol {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px 18px;
  margin: 0;
  padding-left: 18px;
  color: #475569;
  font-size: 13px;
  line-height: 1.45;
}

.editor-tools > .toolbar-group,
.editor-tools > .statusbar {
  order: 3;
}

.app-footer {
  max-width: none;
  width: 100%;
  margin: 0 auto;
  padding: 0 10px 14px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
  text-align: center;
}

.app-footer p {
  margin: 0;
}

.app-footer .contact-line {
  margin-top: 4px;
}

.app-footer a {
  color: #1d4ed8;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.rating-scale-section {
  --rating-accent: #e31837;
  --rating-accent-dark: #991b1b;
  --rating-soft: #fff7f7;
  --rating-border: #fca5a5;
  grid-column: 1 / -1;
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--rating-border);
  border-radius: 18px;
  background: #fff;
  box-shadow: var(--shadow);
}

.rating-scale-heading {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #fff 0%, var(--rating-soft) 100%);
}

.rating-scale-heading > div:first-child {
  display: flex;
  align-items: baseline;
  gap: 14px;
  min-width: 0;
}

.rating-scale-heading h2 {
  margin: 0;
  font-size: 18px;
  white-space: nowrap;
}

.rating-scale-heading p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.rating-scale-summary {
  margin-left: auto;
  flex: 0 0 auto;
  border: 1px solid var(--rating-border);
  border-radius: 999px;
  background: #fff;
  color: var(--rating-accent-dark);
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.rating-scale-frame {
  display: block;
  width: 100%;
  height: 1040px;
  border: 0;
  background: #fff;
}

body.theme-dark .rating-scale-section,
body.theme-dark .rating-scale-heading {
  border-color: #475569;
  background: #111827;
}

body.theme-dark .rating-scale-summary {
  border-color: #7f1d1d;
  background: #450a0a;
  color: #fecaca;
}

body.theme-contrast .rating-scale-section,
body.theme-contrast .rating-scale-heading,
body.theme-contrast .rating-scale-summary {
  border: 2px solid #000;
  box-shadow: none;
}

@media (max-width: 980px) {
  .rating-scale-heading {
    align-items: flex-start;
    flex-direction: column;
  }
  .rating-scale-heading > div:first-child {
    align-items: flex-start;
    flex-direction: column;
    gap: 2px;
  }
  .rating-scale-heading h2 { white-space: normal; }
  .rating-scale-summary { margin-left: 0; white-space: normal; }
  .rating-scale-frame { height: 1120px; }
}

@media print {
  .rating-scale-section { display: none !important; }
}

.field { margin-bottom: 10px; }
.field label {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 4px;
}

.field-note {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.checkbox-field {
  display: flex;
  align-items: center;
  gap: 9px;
  color: #334155;
  font-size: 14px;
  font-weight: 700;
}

.image-preview {
  border: 1px dashed #aab3c1;
  border-radius: 14px;
  min-height: 104px;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: #fafafa;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  padding: 10px;
}

.image-preview img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 16px;
}

.workspace {
  min-width: 0;
  display: grid;
  gap: 12px;
  align-content: start;
}

.statusbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 14px;
  min-height: 28px;
  margin-left: auto;
  white-space: nowrap;
}

.canvas {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 14px;
  display: grid;
  gap: 12px;
}

.editor-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.editor-tools > .editor-export-actions {
  order: 0;
  margin-left: auto;
}

.editor-tools > .editor-readability-actions {
  order: 4;
  flex: 1 1 auto;
  justify-content: flex-start;
  margin-left: 0;
}

.writing-shell {
  display: grid;
  gap: 12px;
  align-items: start;
}

.feedback-reference {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #f8fafc;
  padding: 10px;
}

.feedback-reference h2 {
  margin: 0 0 7px;
  font-size: 15px;
}

.feedback-reference .legend {
  gap: 7px;
}

.teacher-comments {
  display: none;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  padding: 10px;
}

.comments-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.comments-head h2 {
  margin: 0;
  font-size: 15px;
}

.comments-head span {
  margin-left: auto;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.comment-list {
  display: grid;
  gap: 10px;
}

.empty-comments {
  margin: 0;
  border: 1px dashed #cbd5e1;
  border-radius: 14px;
  padding: 14px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.comment-card {
  border: 1px solid var(--line);
  border-left-width: 5px;
  border-radius: 16px;
  background: #fff;
  padding: 12px;
  display: grid;
  gap: 9px;
}

.comment-card.active {
  box-shadow: 0 0 0 3px rgba(15, 23, 42, 0.08);
}

.comment-card.type-grammar { border-style: dotted; background-color: var(--grammar-bg); color: var(--grammar-text); border-color: var(--grammar-border); }
.comment-card.type-vocabulary { border-style: solid; background-color: var(--vocabulary-bg); color: var(--vocabulary-text); border-color: var(--vocabulary-border); }
.comment-card.type-spelling { border-style: dashed; background-color: var(--spelling-bg); color: var(--spelling-text); border-color: var(--spelling-border); }
.comment-card.type-coherence { border-style: double; background-color: var(--coherence-bg); color: var(--coherence-text); border-color: var(--coherence-border); }
.comment-card.type-task { border-style: solid; border-width: 2px; background-color: var(--task-bg); color: var(--task-text); border-color: var(--task-border); }
.comment-card.type-style { border-style: dashed; background-color: var(--style-bg); color: var(--style-text); border-color: var(--style-border); }
.comment-card.type-punctuation { background-color: var(--punctuation-bg); color: var(--punctuation-text); border-color: var(--punctuation-border); }
.comment-card.type-idea { border-style: solid; background-color: var(--idea-bg); color: var(--idea-text); border-color: var(--idea-border); }

.comment-card-head {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.comment-index {
  width: 30px;
  min-height: 30px;
  padding: 0;
  border-radius: 999px;
  background: #f8fafc;
  font-size: 13px;
  font-weight: 800;
}

.comment-card select,
.comment-card textarea {
  border-radius: 12px;
  font-size: 13px;
}

.comment-card textarea {
  min-height: 72px;
  line-height: 1.45;
}

.comment-image-hint {
  margin: 6px 0 8px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.comment-images {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  min-height: 34px;
  color: var(--muted);
  font-size: 12px;
}

.comment-images.empty {
  border: 1px dashed #cbd5e1;
  border-radius: 12px;
  padding: 8px 10px;
  background: rgba(248, 250, 252, 0.72);
}

.comment-image-thumb {
  position: relative;
  width: 78px;
  height: 78px;
  overflow: hidden;
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  background: #fff;
}

.comment-image-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.comment-image-thumb button {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 24px;
  min-height: 24px;
  padding: 0;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.84);
  border-color: rgba(15, 23, 42, 0.84);
  color: #fff;
  font-size: 14px;
  line-height: 1;
}

.comment-card .comment-images {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  align-items: start;
  margin-top: 2px;
}

.comment-card .comment-image-thumb {
  width: 100%;
  height: auto;
  min-height: 150px;
  max-height: 300px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
}

.comment-card .comment-image-thumb img {
  width: 100%;
  height: auto;
  max-height: 286px;
  object-fit: contain;
}

.comment-target {
  color: #475569;
  font-size: 13px;
  line-height: 1.45;
  background: #f8fafc;
  border-radius: 12px;
  padding: 8px 10px;
}

.comment-remove {
  min-height: 30px;
  padding: 4px 9px;
  border-radius: 999px;
  color: #be123c;
  background: #fff1f2;
  border-color: #fecdd3;
  font-size: 12px;
  font-weight: 700;
}

.content-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.content-layout.with-image.image-left {
  grid-template-columns: var(--prompt-width, minmax(260px, 42%)) 12px minmax(0, 1fr);
  gap: 0;
}

.content-layout.with-image.image-top {
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
}

.prompt-splitter {
  position: relative;
  width: 12px;
  height: 100%;
  min-height: 280px;
  cursor: col-resize;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  touch-action: none;
  z-index: 10;
  transition: background-color 0.15s ease;
}

.prompt-splitter:hover,
.prompt-splitter.active {
  background-color: rgba(2, 132, 199, 0.08);
}

.prompt-splitter .splitter-grip {
  width: 4px;
  height: 48px;
  border-radius: 4px;
  background-color: #cbd5e1;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.prompt-splitter:hover .splitter-grip,
.prompt-splitter.active .splitter-grip {
  background-color: var(--primary, #0284c7);
  height: 72px;
  width: 5px;
  box-shadow: 0 0 8px rgba(2, 132, 199, 0.4);
}

body.prompt-resizing {
  cursor: col-resize !important;
  user-select: none !important;
}

body.prompt-resizing * {
  cursor: col-resize !important;
  user-select: none !important;
}

.prompt-image {
  position: relative;
  width: 100%;
}

.prompt-image img {
  width: 100%;
  display: block;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.task1-process-box {
  background: #ffffff;
  border-radius: 10px;
  border: 1px solid var(--line, #e2e8f0);
  padding: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  cursor: zoom-in;
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
  width: 100%;
}

.task1-process-box:hover {
  border-color: #94a3b8;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.09);
}

.task1-process-svg-wrap {
  width: 100%;
  overflow-x: auto;
  display: flex;
  justify-content: center;
  align-items: center;
}

.task1-process-svg-wrap svg {
  max-width: 100%;
  height: auto;
  max-height: 440px;
  display: block;
}

.chart-zoom-dialog .task1-process-svg-wrap svg {
  max-height: 76vh;
  width: auto;
  max-width: 100%;
}

body.theme-dark .task1-process-box,
body.theme-contrast .task1-process-box {
  background: #1e293b;
  border-color: #334155;
}

@media (max-width: 768px) {
  .content-layout.with-image.image-left {
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 16px !important;
  }
  .prompt-splitter {
    display: none !important;
  }
}

.editor {
  position: relative;
  isolation: isolate;
  width: 100%;
  justify-self: center;
  min-height: 300px;
  outline: 0;
  font-size: var(--student-text-size);
  line-height: 1.7;
  padding: 18px;
  overflow-wrap: anywhere;
  overflow: hidden;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 18px;
}

.editor > * {
  position: relative;
  z-index: 1;
}

.editor-image-wrap {
  position: relative;
  display: block;
  width: min(100%, calc(760px * var(--pasted-image-scale)));
  max-width: 100%;
  margin: 16px auto;
  text-align: center;
  line-height: 0;
}

.editor-image-wrap img {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  margin: 0 auto;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
}

.editor-image-wrap.image-selected {
  outline: 3px solid #2563eb;
  outline-offset: 4px;
  border-radius: 16px;
}

.image-resize-handle {
  position: absolute;
  right: -7px;
  bottom: -7px;
  width: 18px;
  height: 18px;
  min-height: 0;
  border: 2px solid #fff;
  border-radius: 6px;
  padding: 0;
  background:
    linear-gradient(135deg, transparent 0 45%, #0f172a 46% 54%, transparent 55%),
    #2563eb;
  box-shadow: 0 3px 10px rgba(15, 23, 42, 0.24);
  cursor: nwse-resize;
  opacity: 0;
  transition: opacity 0.15s ease, transform 0.15s ease;
  touch-action: none;
}

.editor-image-wrap:hover .image-resize-handle,
.editor-image-wrap:focus-within .image-resize-handle,
.editor-image-wrap.image-selected .image-resize-handle,
.editor-image-wrap.resizing .image-resize-handle {
  opacity: 1;
}

.editor-image-wrap.resizing .image-resize-handle {
  transform: scale(1.08);
}

.editor:focus {
  border-color: #cbd5e1;
  box-shadow: 0 0 0 3px rgba(148, 163, 184, 0.2);
}

body.suggesting-active .editor {
  border-color: #86efac;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.16);
}

body.theme-dark .editor {
  background: #0f172a;
  color: #f8fafc;
  border-color: #475569;
}

body.theme-dark .editor:focus {
  border-color: #94a3b8;
  box-shadow: 0 0 0 3px rgba(148, 163, 184, 0.22);
}

body.theme-dark .editor-image-wrap img {
  background: #172033;
  border-color: #475569;
}

body.theme-dark .editor:empty::before {
  color: #94a3b8;
}

body.theme-dark .suggest-delete {
  color: #fecaca;
  background: #4a1010;
}

body.theme-contrast .editor {
  background: #fff;
  color: #000;
  border: 3px solid #000;
  box-shadow: none;
}

body.theme-contrast .editor:focus,
body.theme-contrast.suggesting-active .editor {
  border-color: #000;
  box-shadow: 0 0 0 3px #facc15;
}

body.theme-contrast .editor-image-wrap img {
  background: #fff;
  border: 2px solid #000;
}

body.theme-contrast .feedback-node,
body.theme-contrast .legend span,
body.theme-contrast .comment-card {
  border-width: 2px;
  box-shadow: none;
}

body.theme-contrast .suggest-add {
  color: #006b2e;
  font-weight: 900;
}

body.theme-contrast .suggest-delete {
  color: #b00020;
  background: #fff;
  text-decoration-thickness: 3px;
}

.editor:empty::before {
  content: "Paste or type the student writing here.";
  color: #98a2b3;
}

.suggest-add {
  color: #16a34a;
  font-weight: 700;
  white-space: pre-wrap;
}

.suggest-add.composition-add {
  outline: 1px dotted #16a34a;
  outline-offset: 2px;
}

.suggest-delete {
  color: #dc2626;
  text-decoration: line-through;
  text-decoration-thickness: 2px;
  background: #fef2f2;
  white-space: pre-wrap;
}

.deletion-context-menu {
  position: fixed;
  z-index: 160;
  display: none;
  width: min(260px, calc(100vw - 24px));
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 18px 55px rgba(15, 23, 42, 0.18);
}

.deletion-context-menu.open {
  display: block;
}

.deletion-context-menu button {
  width: 100%;
  min-height: 36px;
  border: 0;
  border-radius: 10px;
  padding: 8px 10px;
  text-align: left;
  color: #0f172a;
  background: transparent;
  font-size: 14px;
  font-weight: 700;
}

.deletion-context-menu button:hover {
  background: #f8fafc;
}

.feedback-node {
  border: 1px solid currentColor;
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 1px 3px;
  cursor: pointer;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}

.feedback-node.comment-active {
  outline: 3px solid rgba(15, 23, 42, 0.18);
  outline-offset: 2px;
  box-shadow: 0 0 0 1px #fff, 0 2px 10px rgba(15, 23, 42, 0.16);
}

::highlight(pending-feedback-selection) {
  background: rgba(147, 197, 253, 0.58);
  color: inherit;
}

.feedback-node.fb-grammar { border-style: dotted; }
.feedback-node.fb-vocabulary { border-style: solid; }
.feedback-node.fb-spelling { border-style: dashed; }
.feedback-node.fb-coherence { border-style: double; }
.feedback-node.fb-task { border-style: solid; border-width: 2px; }
.feedback-node.fb-style { border-style: dashed; }
.feedback-node.fb-idea { border-style: solid; }

.comment-marker {
  display: inline-block;
  margin-left: 2px;
  color: currentColor;
  font-size: 0.64em;
  font-weight: 800;
  line-height: 1;
  vertical-align: super;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.legend .feedback-node {
  border: 1px solid currentColor;
  border-bottom-width: 3px;
  padding: 5px 9px;
  font-size: 13px;
  font-weight: 700;
}

.fb-grammar { background: var(--grammar-bg); color: var(--grammar-text); border-color: var(--grammar-border); }
.fb-vocabulary { background: var(--vocabulary-bg); color: var(--vocabulary-text); border-color: var(--vocabulary-border); }
.fb-spelling { background: var(--spelling-bg); color: var(--spelling-text); border-color: var(--spelling-border); }
.fb-coherence { background: var(--coherence-bg); color: var(--coherence-text); border-color: var(--coherence-border); }
.fb-task { background: var(--task-bg); color: var(--task-text); border-color: var(--task-border); }
.fb-style { background: var(--style-bg); color: var(--style-text); border-color: var(--style-border); }
.fb-punctuation { background: var(--punctuation-bg); color: var(--punctuation-text); border-color: var(--punctuation-border); }
.fb-idea { background: var(--idea-bg); color: var(--idea-text); border-color: var(--idea-border); }

.feedback-popover {
  position: fixed;
  width: min(560px, calc(100vw - 32px));
  min-width: 340px;
  height: min(560px, calc(100vh - 32px));
  min-height: 340px;
  max-width: calc(100vw - 24px);
  max-height: calc(100vh - 24px);
  /* Keep lower controls reachable when the popover is resized below the
     natural height of its fields. */
  overflow: auto;
  resize: both;
  background: var(--surface, #fff);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: 0 16px 36px -6px rgba(15, 23, 42, 0.18), 0 0 0 1px rgba(0, 0, 0, 0.04);
  padding: 12px;
  z-index: 120;
  display: none;
  flex-direction: column;
  transition: box-shadow 0.15s ease, border-color 0.15s ease;
}

.feedback-popover.open { display: flex; }

.feedback-popover-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: -4px -4px 10px -4px;
  padding: 8px 10px;
  border-radius: 14px;
  background: var(--surface-subtle, #f8fafc);
  border: 1px solid var(--line-light, #e2e8f0);
  cursor: grab;
  user-select: none;
  touch-action: none;
  flex: 0 0 auto;
  position: sticky;
  top: -4px;
  z-index: 10;
  transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.feedback-popover-header:hover {
  background: var(--surface-hover, #f1f5f9);
  border-color: var(--line, #cbd5e1);
}

.feedback-popover.is-dragging {
  user-select: none !important;
  cursor: grabbing !important;
  box-shadow: 0 24px 48px -12px rgba(15, 23, 42, 0.35), 0 0 0 2px var(--brand, #2563eb) !important;
  opacity: 0.98;
  z-index: 200 !important;
  transition: none !important;
}

.feedback-popover.is-dragging .feedback-popover-header {
  cursor: grabbing !important;
  background: var(--brand-light, #eff6ff);
  border-color: var(--brand, #3b82f6);
}

.feedback-popover-drag-title {
  display: flex;
  align-items: center;
  gap: 7px;
  flex: 1;
  min-width: 0;
  pointer-events: none;
}

.feedback-drag-grip-icon {
  flex-shrink: 0;
  color: var(--text-muted, #94a3b8);
  opacity: 0.85;
}

.feedback-popover-header:hover .feedback-drag-grip-icon {
  color: var(--brand, #3b82f6);
  opacity: 1;
}

.feedback-popover-header h3 {
  margin: 0;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text, #1e293b);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.feedback-drag-hint-badge {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted, #64748b);
  background: rgba(0, 0, 0, 0.05);
  padding: 1.5px 6px;
  border-radius: 9999px;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.feedback-popover-header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.feedback-popover-icon-btn,
.feedback-popover-close-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--text-muted, #64748b);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
  line-height: 1;
}

.feedback-popover-icon-btn:hover {
  background: rgba(0, 0, 0, 0.06);
  color: var(--text, #1e293b);
}

.feedback-popover-close-btn {
  font-size: 18px;
}

.feedback-popover-close-btn:hover {
  background: rgba(239, 68, 68, 0.12);
  color: #ef4444;
}

body.theme-dark .feedback-popover-header {
  background: #1e293b;
  border-color: #334155;
}

body.theme-dark .feedback-popover-header:hover {
  background: #273549;
  border-color: #475569;
}

body.theme-dark .feedback-popover.is-dragging .feedback-popover-header {
  background: rgba(37, 99, 235, 0.25);
  border-color: #3b82f6;
}

body.theme-dark .feedback-popover-header h3 {
  color: #f1f5f9;
}

body.theme-dark .feedback-drag-hint-badge {
  background: rgba(255, 255, 255, 0.08);
  color: #94a3b8;
}

body.theme-dark .feedback-popover-icon-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #f8fafc;
}

body.theme-dark .feedback-popover-close-btn {
  color: #94a3b8;
}

body.theme-contrast .feedback-popover-header {
  background: #fff;
  border: 1px solid #000;
}

body.theme-contrast .feedback-popover-header h3 {
  color: #000;
}

.feedback-popover::after {
  content: "↘ Drag corner to resize";
  position: absolute;
  right: 8px;
  bottom: 4px;
  display: block;
  width: max-content;
  color: var(--muted);
  font-size: 10px;
  pointer-events: none;
}
.feedback-popover > .field,
.feedback-popover > .quick-notes {
  flex: 0 0 auto;
}
.feedback-popover > .field:has(#feedbackNote) {
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.feedback-popover textarea {
  height: clamp(120px, 30vh, 260px);
  min-height: 90px;
  max-height: 320px;
  line-height: 1.5;
}
.feedback-popover .comment-images {
  max-height: 92px;
  overflow-y: auto;
}
.feedback-popover .popover-actions {
  flex: 0 0 auto;
  position: sticky;
  bottom: 0;
  z-index: 2;
  padding-top: 10px;
  padding-bottom: 18px;
  background: var(--surface, #fff);
}
@media (max-width: 560px) {
  .feedback-popover {
    width: calc(100vw - 24px);
    min-width: 0;
    height: min(620px, calc(100vh - 24px));
    min-height: 320px;
    resize: vertical;
  }
}
.quick-notes {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0;
}
.quick-notes button { font-size: 12px; min-height: 30px; }

.popover-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.popover-actions .danger {
  margin-left: auto;
}

.backup-links {
  display: none;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 13px;
  padding: 10px;
  border: 1px solid #bfdbfe;
  background: #eff6ff;
  border-radius: 16px;
}
.backup-links.open { display: flex; }

.instructions-modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: none;
  place-items: center;
  padding: 18px;
  background: rgba(15, 23, 42, 0.42);
}

.instructions-modal.open {
  display: grid;
}

.instructions-card {
  width: min(760px, 100%);
  max-height: min(760px, calc(100vh - 36px));
  overflow: auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.22);
  padding: 22px;
}

.instructions-head {
  display: flex;
  align-items: start;
  gap: 16px;
  margin-bottom: 16px;
}

.instructions-head h2 {
  margin: 0 0 4px;
  font-size: 24px;
  line-height: 1.2;
}

.instructions-head p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.instructions-close {
  margin-left: auto;
  min-width: 40px;
  padding: 6px 10px;
  border-radius: 999px;
  font-weight: 800;
}

.instructions-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.instruction-step {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #f8fafc;
  padding: 14px;
}

.instruction-step h3 {
  margin: 0 0 8px;
  font-size: 15px;
}

.instruction-step p,
.instruction-step ul {
  margin: 0;
  color: #475569;
  font-size: 14px;
  line-height: 1.5;
}

.instruction-step ul {
  padding-left: 18px;
}

.instruction-step li + li {
  margin-top: 4px;
}

.instruction-note {
  margin: 14px 0 0;
  border: 1px solid #fed7aa;
  border-radius: 16px;
  background: #fff7ed;
  color: #7c2d12;
  padding: 12px 14px;
  font-size: 14px;
  line-height: 1.5;
}

.hidden { display: none !important; }

@media (max-width: 980px) {
  main {
    grid-template-columns: 1fr;
    padding: 8px;
  }
  .workspace-resize-handle {
    display: none;
  }
  .topbar,
  .canvas,
  .panel {
    border-radius: 18px;
  }
  .title-row {
    align-items: stretch;
  }
  .title-row .brand {
    width: 100%;
    margin-left: 0;
    margin-right: 0;
  }
  .editor-readability-actions {
    justify-content: flex-start;
    display: grid;
    grid-template-columns: 1fr;
  }
  .readability-control {
    grid-template-columns: 54px minmax(0, 1fr) 44px auto;
    width: 100%;
    min-width: 0;
    white-space: normal;
  }
  .readability-control select {
    width: 100%;
    min-width: 0;
  }
  .readability-control input[type="range"] {
    width: 100%;
  }
  .canvas {
    min-width: 0;
    padding: 12px;
  }
  .editor-tools,
  .writing-shell,
  .content-layout,
  .feedback-reference,
  .editor-help {
    min-width: 0;
  }
  .editor-tools > .toolbar-group,
  .editor-tools > .statusbar {
    width: 100%;
    margin-left: 0;
  }
  .editor-tools > .editor-export-actions {
    width: 100%;
    margin-left: 0;
    justify-content: flex-start;
  }
  .editor-tools > .editor-readability-actions {
    width: 100%;
    margin-left: 0;
  }
  .editor-tools > .toolbar-group {
    flex-wrap: wrap;
  }
  .mode-toggle {
    width: 100%;
  }
  .mode-toggle button {
    min-width: 0;
  }
  .statusbar {
    justify-content: flex-start;
    white-space: normal;
  }
  .editor {
    width: 100%;
    min-height: 260px;
    padding: 14px;
    border-radius: 14px;
  }
  .content-layout.with-image.image-left { grid-template-columns: 1fr; }
  .sidebar { order: 2; }
  .editor-help ol { grid-template-columns: 1fr; }
  .instructions-grid { grid-template-columns: 1fr; }
}

/* ==========================================================================
   Student Submission Integration & Database Toolbar
   ========================================================================== */
.submission-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.save-feedback-btn {
  background: linear-gradient(135deg, #059669 0%, #047857 100%) !important;
  color: #ffffff !important;
  border: 1px solid #047857 !important;
  box-shadow: 0 4px 12px rgba(5, 150, 105, 0.25);
  font-weight: 600;
  transition: all 0.18s ease;
}

.save-feedback-btn:hover:not(:disabled) {
  background: linear-gradient(135deg, #047857 0%, #065f46 100%) !important;
  box-shadow: 0 6px 16px rgba(5, 150, 105, 0.35);
  transform: translateY(-1px);
}

.save-feedback-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

.active-submission-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 14px;
  padding: 10px 18px;
  margin-bottom: 14px;
  font-size: 13px;
  color: #166534;
  box-shadow: 0 4px 14px rgba(22, 101, 52, 0.06);
  animation: bannerSlideIn 0.25s ease-out;
}

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

.banner-info {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.banner-badge {
  background: #15803d;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 999px;
}

.banner-tag {
  background: #dcfce7;
  color: #166534;
  font-weight: 600;
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 6px;
  border: 1px solid #bbf7d0;
}

.banner-date {
  font-size: 12px;
  color: #4b5563;
}

.banner-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.banner-btn {
  height: 32px;
  padding: 0 12px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s ease;
}

.banner-btn.primary {
  background: #15803d;
  color: #fff;
  border-color: #15803d;
}

.banner-btn.primary:hover {
  background: #166534;
}

.banner-btn.secondary {
  background: #fff;
  color: #4b5563;
  border-color: #d1d5db;
}

.banner-btn.secondary:hover {
  background: #f3f4f6;
  color: #111827;
}

/* Studio Modals (Submissions & Passkey) */
.studio-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.studio-modal.hidden {
  display: none !important;
}

.studio-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.studio-modal-dialog {
  position: relative;
  z-index: 10;
  background: #ffffff;
  border-radius: 18px;
  box-shadow: 0 25px 60px rgba(15, 23, 42, 0.35);
  width: min(1000px, 96vw);
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--line);
  animation: modalScaleIn 0.2s ease-out;
}

@keyframes modalScaleIn {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

.studio-modal-sm {
  width: min(440px, 94vw);
}

.studio-modal-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #ffffff;
}

.studio-modal-title {
  font-size: 18px;
  font-weight: 700;
  margin: 0;
  color: var(--ink);
}

.studio-modal-subtitle {
  font-size: 13px;
  color: var(--muted);
  margin: 4px 0 0 0;
}

.studio-modal-body {
  padding: 20px 24px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 rgba(0, 0, 0, 0.04);
}

/* Custom Sleek Scrollbar / Slider */
.studio-modal-body::-webkit-scrollbar {
  width: 8px;
}

.studio-modal-body::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.04);
  border-radius: 999px;
}

.studio-modal-body::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
  transition: background-color 0.2s ease;
}

.studio-modal-body::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

body.theme-dark .studio-modal-body {
  scrollbar-color: #475569 rgba(255, 255, 255, 0.05);
}

body.theme-dark .studio-modal-body::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.05);
}

body.theme-dark .studio-modal-body::-webkit-scrollbar-thumb {
  background: #475569;
}

body.theme-dark .studio-modal-body::-webkit-scrollbar-thumb:hover {
  background: #64748b;
}

.studio-modal-footer {
  padding: 14px 24px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  background: #f8fafc;
}

.submissions-filters-bar {
  display: flex;
  gap: 12px;
  padding: 14px 24px;
  background: #f8fafc;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
  align-items: flex-end;
}

.submissions-filters-bar .filter-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.submissions-filters-bar label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.submissions-filters-bar select,
.submissions-filters-bar input {
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  font-size: 13px;
  background: #ffffff;
  color: var(--ink);
  outline: none;
  font-family: inherit;
}

.submissions-filters-bar select:focus,
.submissions-filters-bar input:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}

.submissions-filters-bar .search-grow {
  flex: 1;
  min-width: 200px;
}

.refresh-btn {
  height: 36px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
  transition: all 0.15s ease;
}

.refresh-btn:hover {
  background: #f1f5f9;
}

.submissions-table-wrap {
  flex: 1;
  overflow-y: auto;
  min-height: 280px;
  max-height: 520px;
}

.submissions-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  text-align: left;
}

.submissions-table th {
  position: sticky;
  top: 0;
  background: #f1f5f9;
  padding: 10px 16px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  z-index: 2;
}

.submissions-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
  color: var(--ink);
}

.submissions-table tbody tr:hover {
  background: #f8fafc;
}

.submissions-loading,
.submissions-empty {
  text-align: center;
  padding: 40px 16px;
  color: var(--muted);
  font-size: 14px;
}

.badge-pending {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fde68a;
}

.badge-reviewed {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  background: #dcfce7;
  color: #166534;
  border: 1px solid #bbf7d0;
}

.badge-flagged {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 700;
  background: #fff1f2;
  color: #be123c;
  border: 1px solid #fecdd3;
  letter-spacing: 0.02em;
}

body.theme-dark .badge-flagged {
  background: rgba(225, 29, 72, 0.15);
  color: #fda4af;
  border-color: rgba(225, 29, 72, 0.4);
}

tr.row-flagged {
  background-color: rgba(254, 242, 242, 0.5) !important;
}

body.theme-dark tr.row-flagged {
  background-color: rgba(225, 29, 72, 0.06) !important;
}

.banner-integrity-alert {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  padding: 8px 12px;
  border-radius: 8px;
  background: #fff1f2;
  border: 1px solid #fecdd3;
  color: #9f1239;
  font-size: 12px;
  line-height: 1.4;
  width: 100%;
}

body.theme-dark .banner-integrity-alert {
  background: rgba(225, 29, 72, 0.12);
  border-color: rgba(225, 29, 72, 0.35);
  color: #fecdd3;
}

.integrity-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 11px;
}

body.theme-dark .integrity-chip {
  color: #f8fafc;
}


.btn-table-load {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 12px;
  border-radius: 6px;
  border: 1px solid #059669;
  background: #ecfdf5;
  color: #047857;
  font-weight: 600;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-table-load:hover {
  background: #059669;
  color: #ffffff;
}

.btn-table-delete {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 5px 10px;
  border-radius: 6px;
  border: 1px solid #fecaca;
  background: #fef2f2;
  color: #dc2626;
  font-weight: 600;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-table-delete:hover {
  background: #dc2626;
  color: #ffffff;
  border-color: #dc2626;
}

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

/* Passkey Input */
.passkey-instruction {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 12px;
  line-height: 1.5;
}

.passkey-field input {
  width: 100%;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  font-size: 14px;
  box-sizing: border-box;
  font-family: inherit;
}

.passkey-field input:focus {
  border-color: #2563eb;
  outline: none;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}

.passkey-error {
  font-size: 12px;
  color: #dc2626;
  margin-top: 6px;
}

/* Dark theme overrides */
body.theme-dark .active-submission-banner {
  background: rgba(5, 150, 105, 0.12);
  border-color: rgba(5, 150, 105, 0.35);
  color: #6ee7b7;
}

body.theme-dark .banner-tag {
  background: rgba(5, 150, 105, 0.25);
  color: #a7f3d0;
  border-color: rgba(5, 150, 105, 0.4);
}

body.theme-dark .banner-date {
  color: #9ca3af;
}

body.theme-dark .banner-btn.secondary {
  background: #1e293b;
  color: #e2e8f0;
  border-color: #334155;
}

body.theme-dark .studio-modal-dialog {
  background: #0f172a;
  border-color: #334155;
}

body.theme-dark .studio-modal-header,
body.theme-dark .studio-modal-footer {
  background: #0f172a;
  border-color: #334155;
}

body.theme-dark .submissions-filters-bar {
  background: #1e293b;
  border-color: #334155;
}

body.theme-dark .submissions-filters-bar select,
body.theme-dark .submissions-filters-bar input,
body.theme-dark .refresh-btn,
body.theme-dark .passkey-field input {
  background: #0f172a;
  border-color: #334155;
  color: #f1f5f9;
}

body.theme-dark .submissions-table th {
  background: #1e293b;
  border-color: #334155;
  color: #94a3b8;
}

body.theme-dark .submissions-table td {
  border-color: #334155;
  color: #e2e8f0;
}

/* ==========================================================================
   AI Writing Assistant Styles
   ========================================================================== */

.ai-assistant-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: linear-gradient(135deg, #7c3aed 0%, #4f46e5 100%) !important;
  color: #ffffff !important;
  border: none !important;
  padding: 6px 13px;
  font-size: 13px;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(124, 58, 237, 0.25);
  transition: all 0.2s ease;
}

.ai-assistant-btn:hover {
  filter: brightness(1.1);
  box-shadow: 0 4px 12px rgba(124, 58, 237, 0.4);
  transform: translateY(-1px);
}

.studio-modal-lg {
  max-width: 900px;
  width: 94vw;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
}

.ai-modal-header-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.ai-modal-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #7c3aed;
  background: #f5f3ff;
  border: 1px solid #ddd6fe;
  padding: 2px 8px;
  border-radius: 9999px;
  width: fit-content;
  margin-bottom: 4px;
}

.ai-modal-body {
  overflow-y: auto;
  padding: 18px 24px;
  flex: 1;
}

/* AI Ready / Launch State */
.ai-ready-state {
  display: block;
}

.ai-ready-card {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.ai-ready-hero {
  background: linear-gradient(135deg, rgba(124, 58, 237, 0.06) 0%, rgba(79, 70, 229, 0.04) 100%);
  border: 1px solid rgba(124, 58, 237, 0.15);
  border-radius: 12px;
  padding: 18px 20px;
  position: relative;
}

.ai-ready-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #ecfdf5;
  color: #065f46;
  border: 1px solid #a7f3d0;
  border-radius: 9999px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  padding: 3px 10px;
  margin-bottom: 8px;
}

.ai-pulse-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 0 rgba(16, 185, 129, 0.4);
  animation: pulseDot 2s infinite;
}

@keyframes pulseDot {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.ai-ready-headline {
  font-size: 17px;
  font-weight: 800;
  color: #0f172a;
  margin: 0 0 6px;
}

.ai-ready-desc {
  font-size: 13px;
  line-height: 1.5;
  color: #475569;
  margin: 0;
}

/* Essay Snapshot */
.ai-essay-snapshot {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  background: var(--surface, #f8fafc);
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 10px;
  padding: 14px 16px;
}

.ai-snapshot-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ai-snapshot-prompt-row {
  grid-column: 1 / -1;
  border-top: 1px dashed var(--border, #e2e8f0);
  padding-top: 10px;
  margin-top: 2px;
}

.ai-snapshot-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--muted, #64748b);
}

.ai-snapshot-val {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  font-weight: 600;
  color: #0f172a;
}

.ai-task-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 800;
  background: #ede9fe;
  color: #6d28d9;
  border: 1px solid #ddd6fe;
}

.ai-task-pill.task1 {
  background: #cffafe;
  color: #0891b2;
  border-color: #a5f3fc;
}

.ai-doc-title-trunc {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 200px;
  font-size: 13px;
  font-weight: 600;
  color: #475569;
}

.ai-word-status-pill {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 9999px;
  background: #ecfdf5;
  color: #047857;
  border: 1px solid #a7f3d0;
}

.ai-word-status-pill.under-threshold {
  background: #fffbeb;
  color: #b45309;
  border-color: #fde68a;
}

.ai-prompt-preview-text {
  font-size: 12.5px;
  line-height: 1.45;
  color: #334155;
  margin: 0;
  font-style: italic;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Model Selection in Ready View */
.ai-ready-model-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ai-ready-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.ai-ready-section-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 700;
  color: #0f172a;
}

.ai-ready-section-hint {
  font-size: 11.5px;
  color: var(--muted, #64748b);
}

.ai-ready-models-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

@media (max-width: 600px) {
  .ai-ready-models-grid {
    grid-template-columns: 1fr;
  }
}

.ai-ready-model-card {
  background: var(--surface, #ffffff);
  border: 2px solid var(--border, #e2e8f0);
  border-radius: 10px;
  padding: 12px 14px;
  cursor: pointer;
  transition: all 0.18s ease;
  user-select: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: relative;
}

.ai-ready-model-card:hover {
  border-color: #a78bfa;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(124, 58, 237, 0.08);
}

.ai-ready-model-card.is-selected {
  border-color: #7c3aed;
  background: linear-gradient(135deg, rgba(124, 58, 237, 0.05) 0%, rgba(255, 255, 255, 0.95) 100%);
  box-shadow: 0 0 0 1px #7c3aed, 0 4px 14px rgba(124, 58, 237, 0.14);
}

.ready-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.ready-card-rank {
  font-size: 10px;
  font-weight: 800;
  background: #e2e8f0;
  color: #475569;
  border-radius: 4px;
  padding: 1px 5px;
}

.priority-lite .ready-card-rank {
  background: #059669;
  color: #ffffff;
}

.priority-groq .ready-card-rank {
  background: #ea580c;
  color: #ffffff;
}

.priority-flash .ready-card-rank {
  background: #7c3aed;
  color: #ffffff;
}

.ready-card-badge {
  font-size: 10.5px;
  font-weight: 700;
  border-radius: 9999px;
  padding: 2px 7px;
}

.ready-card-badge.lite {
  background: #d1fae5;
  color: #065f46;
}

.ready-card-badge.flash {
  background: #ede9fe;
  color: #6d28d9;
}

.ready-card-badge.groq {
  background: #ffedd5;
  color: #c2410c;
}

.ready-card-title {
  font-size: 13.5px;
  font-weight: 700;
  color: #0f172a;
  margin: 2px 0 0;
}

.ready-card-desc {
  font-size: 11.5px;
  line-height: 1.35;
  color: #64748b;
  margin: 0;
}

/* Key Selection in Ready View */
.ai-ready-key-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ai-ready-keys-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

@media (max-width: 900px) {
  .ai-ready-keys-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 600px) {
  .ai-ready-keys-grid {
    grid-template-columns: 1fr;
  }
}

.ai-ready-key-card {
  background: var(--surface, #ffffff);
  border: 2px solid var(--border, #e2e8f0);
  border-radius: 10px;
  padding: 12px 14px;
  cursor: pointer;
  transition: all 0.18s ease;
  user-select: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
}

.ai-ready-key-card:hover {
  border-color: #3b82f6;
  background: #f8fafc;
  transform: translateY(-1px);
}

.ai-ready-key-card.is-selected {
  border-color: #2563eb !important;
  background: #eff6ff !important;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.ai-ready-key-card[data-tier="free"].is-selected {
  border-color: #059669 !important;
  background: #ecfdf5 !important;
  box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.15);
}

.ai-ready-key-card[data-tier="cerebras"].is-selected {
  border-color: #f1592a !important;
  background: #fff7ed !important;
  box-shadow: 0 0 0 3px rgba(241, 89, 42, 0.15);
}

.ai-ready-key-card[data-tier="groq"].is-selected {
  border-color: #ea580c !important;
  background: #fff7ed !important;
  box-shadow: 0 0 0 3px rgba(234, 88, 12, 0.15);
}

.ai-ready-key-card[data-tier="mistral"].is-selected {
  border-color: #f25c05 !important;
  background: #fff7ed !important;
  box-shadow: 0 0 0 3px rgba(242, 92, 5, 0.15);
}

.ai-ready-key-card[data-tier="openai"].is-selected {
  border-color: #10a37f !important;
  background: #f0fdf4 !important;
  box-shadow: 0 0 0 3px rgba(16, 163, 127, 0.15);
}

.ai-ready-key-card[data-tier="paid"].is-selected {
  border-color: #7c3aed !important;
  background: #f5f3ff !important;
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.15);
}

.ready-key-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.ready-key-badge {
  font-size: 10.5px;
  font-weight: 700;
  border-radius: 9999px;
  padding: 2px 7px;
}

.ready-key-badge.free {
  background: #d1fae5;
  color: #065f46;
}

.ready-key-badge.cerebras {
  background: #ffedd5;
  color: #c2410c;
}

.ready-key-badge.groq {
  background: #ffedd5;
  color: #c2410c;
}

.ready-key-badge.mistral {
  background: #ffedd5;
  color: #c2410c;
}

.ready-key-badge.openai {
  background: #dcfce7;
  color: #15803d;
}

.ready-key-badge.paid {
  background: #ede9fe;
  color: #6d28d9;
}

.ready-key-badge.failover {
  background: #fef3c7;
  color: #92400e;
}

.ready-key-status {
  font-size: 10px;
  font-weight: 700;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.ready-key-status.is-ready {
  color: #059669;
}

.ready-key-status.not-set {
  color: #e11d48;
}

.ready-key-main {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.ready-key-icon {
  font-size: 18px;
  line-height: 1;
  flex-shrink: 0;
  margin-top: 2px;
}

.ready-key-text {
  flex: 1;
  min-width: 0;
}

.ready-key-title {
  font-size: 13px;
  font-weight: 700;
  color: #0f172a;
  margin: 0 0 2px;
}

.ready-key-desc {
  font-size: 11px;
  line-height: 1.35;
  color: #64748b;
  margin: 0;
}

body.theme-dark .ai-ready-key-card {
  background: #1e293b;
  border-color: #334155;
}

body.theme-dark .ai-ready-key-card:hover {
  background: #243047;
}

body.theme-dark .ai-ready-key-card.is-selected {
  border-color: #3b82f6 !important;
  background: rgba(37, 99, 235, 0.18) !important;
}

body.theme-dark .ai-ready-key-card[data-tier="free"].is-selected {
  border-color: #10b981 !important;
  background: rgba(16, 185, 129, 0.18) !important;
}

body.theme-dark .ai-ready-key-card[data-tier="cerebras"].is-selected {
  border-color: #f97316 !important;
  background: rgba(241, 89, 42, 0.18) !important;
}

body.theme-dark .ai-ready-key-card[data-tier="groq"].is-selected {
  border-color: #f97316 !important;
  background: rgba(249, 115, 22, 0.18) !important;
}

body.theme-dark .ai-ready-key-card[data-tier="mistral"].is-selected {
  border-color: #f97316 !important;
  background: rgba(249, 115, 22, 0.18) !important;
}

body.theme-dark .ai-ready-key-card[data-tier="openai"].is-selected {
  border-color: #10b981 !important;
  background: rgba(16, 185, 129, 0.18) !important;
}

body.theme-dark .ai-ready-key-card[data-tier="paid"].is-selected {
  border-color: #8b5cf6 !important;
  background: rgba(139, 92, 246, 0.18) !important;
}

body.theme-dark .ready-key-badge.cerebras {
  background: rgba(241, 89, 42, 0.25);
  color: #fdba74;
}

body.theme-dark .ready-key-badge.mistral {
  background: rgba(249, 115, 22, 0.25);
  color: #fdba74;
}

body.theme-dark .ready-key-badge.openai {
  background: rgba(16, 185, 129, 0.25);
  color: #86efac;
}

body.theme-dark .ai-ready-key-card .ready-key-title {
  color: #f8fafc;
}

body.theme-dark .ai-ready-key-card .ready-key-desc {
  color: #94a3b8;
}

/* CTA Wrap */
.ai-ready-cta-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-top: 4px;
}

.btn-start-ai-analysis {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  width: 100%;
  padding: 14px 22px;
  font-size: 15px;
  font-weight: 700;
  color: #ffffff !important;
  background: linear-gradient(135deg, #7c3aed 0%, #4f46e5 100%) !important;
  border: none !important;
  border-radius: 10px !important;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(124, 58, 237, 0.35);
  transition: all 0.2s ease;
}

.btn-start-ai-analysis:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(124, 58, 237, 0.45);
  background: linear-gradient(135deg, #6d28d9 0%, #4338ca 100%) !important;
}

.btn-start-ai-analysis:active {
  transform: translateY(0);
}

.ai-ready-actions-secondary {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted, #64748b);
}

.ai-link-btn {
  background: none;
  border: none;
  color: #7c3aed;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 6px;
  border-radius: 6px;
  transition: all 0.15s ease;
}

.ai-link-btn:hover {
  background: rgba(124, 58, 237, 0.08);
  text-decoration: underline;
}

/* Dark Mode Adaptations for Ready State */
body.theme-dark .ai-ready-hero {
  background: linear-gradient(135deg, rgba(124, 58, 237, 0.15) 0%, rgba(79, 70, 229, 0.1) 100%);
  border-color: rgba(167, 139, 250, 0.25);
}

body.theme-dark .ai-ready-headline {
  color: #f8fafc;
}

body.theme-dark .ai-ready-desc {
  color: #cbd5e1;
}

body.theme-dark .ai-essay-snapshot {
  background: #1e293b;
  border-color: #334155;
}

body.theme-dark .ai-snapshot-prompt-row {
  border-top-color: #334155;
}

body.theme-dark .ai-snapshot-val {
  color: #f8fafc;
}

body.theme-dark .ai-doc-title-trunc {
  color: #cbd5e1;
}

body.theme-dark .ai-prompt-preview-text {
  color: #cbd5e1;
}

body.theme-dark .ai-ready-section-title {
  color: #f8fafc;
}

body.theme-dark .ai-ready-model-card {
  background: #1e293b;
  border-color: #334155;
}

body.theme-dark .ai-ready-model-card:hover {
  border-color: #a78bfa;
}

body.theme-dark .ai-ready-model-card.is-selected {
  border-color: #a78bfa;
  background: linear-gradient(135deg, rgba(124, 58, 237, 0.25) 0%, #1e293b 100%);
  box-shadow: 0 0 0 1px #a78bfa, 0 4px 14px rgba(124, 58, 237, 0.3);
}

body.theme-dark .ready-card-title {
  color: #f8fafc;
}

body.theme-dark .ready-card-desc {
  color: #94a3b8;
}

body.theme-dark .ai-link-btn {
  color: #c084fc;
}

body.theme-dark .ai-link-btn:hover {
  background: rgba(167, 139, 250, 0.15);
}

/* Loading & Spinner */
.ai-loading-state {
  text-align: center;
  padding: 40px 20px;
}

.ai-spinner {
  width: 44px;
  height: 44px;
  margin: 0 auto 16px;
  border: 4px solid #ede9fe;
  border-top-color: #7c3aed;
  border-radius: 50%;
  animation: aiSpin 0.9s linear infinite;
}

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

.ai-loading-state h4 {
  font-size: 17px;
  font-weight: 700;
  color: var(--text, #1e293b);
  margin-bottom: 6px;
}

.ai-loading-state p {
  font-size: 14px;
  color: var(--muted, #64748b);
  max-width: 460px;
  margin: 0 auto;
}

/* AI Loading Background Execution Hint & Minimize */
.ai-loading-bg-hint {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(124, 58, 237, 0.08);
  border: 1px solid rgba(124, 58, 237, 0.2);
  border-radius: 9999px;
  padding: 6px 14px;
  font-size: 12.5px;
  color: #6d28d9;
  margin-top: 16px;
  max-width: 520px;
  line-height: 1.4;
  text-align: left;
}

body.theme-dark .ai-loading-bg-hint {
  background: rgba(167, 139, 250, 0.12);
  border-color: rgba(167, 139, 250, 0.25);
  color: #c4b5fd;
}

.ai-loading-actions-row {
  margin-top: 16px;
  display: flex;
  justify-content: center;
}

.ai-loading-minimize-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.ai-loading-minimize-btn:hover {
  background: #e2e8f0;
  color: #1e293b;
  transform: translateY(-1px);
}

.ai-loading-minimize-btn:active {
  transform: translateY(0);
}

body.theme-dark .ai-loading-minimize-btn {
  background: #1e293b;
  color: #cbd5e1;
  border-color: #334155;
}

body.theme-dark .ai-loading-minimize-btn:hover {
  background: #334155;
  color: #f8fafc;
}

/* Ambient AI Floating Status Pill */
.ai-floating-status-pill {
  position: fixed;
  bottom: 24px;
  right: 28px;
  z-index: 1050;
  transition: opacity 0.25s ease, transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  animation: aiPillPopIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes aiPillPopIn {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.ai-floating-status-pill.hidden {
  display: none !important;
}

.ai-pill-content {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(15, 23, 42, 0.94);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 9999px;
  box-shadow: 0 12px 28px -6px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(255, 255, 255, 0.05);
  padding: 8px 14px 8px 12px;
  color: #f8fafc;
  min-width: 250px;
  max-width: 440px;
}

.ai-pill-icon-wrap {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.08);
}

.ai-pill-spinner {
  width: 15px;
  height: 15px;
  border: 2.5px solid rgba(56, 189, 248, 0.25);
  border-top-color: #38bdf8;
  border-radius: 50%;
  animation: aiSpin 0.8s linear infinite;
}

.ai-pill-icon-wrap.is-completed {
  background: rgba(16, 185, 129, 0.18);
  color: #34d399;
}

.ai-pill-icon-wrap.is-error {
  background: rgba(239, 68, 68, 0.18);
  color: #f87171;
}

.ai-pill-text-wrap {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}

.ai-pill-title {
  font-size: 12.5px;
  font-weight: 600;
  color: #f8fafc;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: -0.01em;
}

.ai-pill-subtitle {
  font-size: 11px;
  color: #94a3b8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ai-pill-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.ai-pill-btn-action {
  background: rgba(56, 189, 248, 0.16);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.35);
  border-radius: 9999px;
  padding: 4px 12px;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.ai-pill-btn-action:hover {
  background: rgba(56, 189, 248, 0.26);
  color: #7dd3fc;
  border-color: rgba(56, 189, 248, 0.55);
  transform: translateY(-1px);
}

.ai-pill-btn-action.is-completed {
  background: rgba(16, 185, 129, 0.2);
  color: #34d399;
  border-color: rgba(16, 185, 129, 0.4);
}

.ai-pill-btn-action.is-completed:hover {
  background: rgba(16, 185, 129, 0.3);
  color: #6ee7b7;
  border-color: rgba(16, 185, 129, 0.6);
}

.ai-pill-btn-action.is-error {
  background: rgba(239, 68, 68, 0.2);
  color: #f87171;
  border-color: rgba(239, 68, 68, 0.4);
}

.ai-pill-btn-dismiss {
  background: transparent;
  border: none;
  color: #64748b;
  font-size: 16px;
  line-height: 1;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.ai-pill-btn-dismiss:hover {
  color: #cbd5e1;
  background: rgba(255, 255, 255, 0.1);
}

@media (prefers-reduced-motion: reduce) {
  .ai-floating-status-pill {
    animation: none !important;
    transition: none !important;
  }
  .ai-pill-spinner {
    animation-duration: 2s !important;
  }
}

/* Error State */
.ai-error-state {
  text-align: center;
  padding: 30px 20px;
}

.ai-error-icon {
  font-size: 36px;
  margin-bottom: 12px;
}

.ai-error-state h4 {
  font-size: 16px;
  font-weight: 700;
  color: #dc2626;
  margin-bottom: 8px;
}

.ai-error-state p {
  font-size: 14px;
  color: var(--muted, #64748b);
  margin-bottom: 16px;
}

/* AI Header Controls & Model Selector */
.ai-header-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.ai-model-selector-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface, #ffffff);
  border: 1px solid var(--border, #cbd5e1);
  padding: 4px 8px;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.ai-model-select-label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 700;
  color: #7c3aed;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  cursor: pointer;
}

.ai-model-select {
  border: none;
  background: transparent;
  font-size: 12px;
  font-weight: 600;
  color: var(--text, #0f172a);
  cursor: pointer;
  outline: none;
  padding-right: 4px;
}

.ai-model-select option {
  background: #ffffff;
  color: #0f172a;
}

.ai-key-selector-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface, #ffffff);
  border: 1px solid var(--border, #cbd5e1);
  padding: 4px 8px;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.ai-key-select-label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 700;
  color: #059669;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  cursor: pointer;
}

.ai-key-select {
  border: none;
  background: transparent;
  font-size: 12px;
  font-weight: 600;
  color: var(--text, #0f172a);
  cursor: pointer;
  outline: none;
  padding-right: 4px;
}

.ai-key-select option {
  background: #ffffff;
  color: #0f172a;
}

body.theme-dark .ai-model-selector-wrap {
  background: #1e293b;
  border-color: #334155;
}

body.theme-dark .ai-model-select-label {
  color: #a78bfa;
}

body.theme-dark .ai-model-select {
  color: #f1f5f9;
}

body.theme-dark .ai-model-select option {
  background: #0f172a;
  color: #f8fafc;
}

body.theme-dark .ai-key-selector-wrap {
  background: #1e293b;
  border-color: #334155;
}

body.theme-dark .ai-key-select-label {
  color: #34d399;
}

body.theme-dark .ai-key-select {
  color: #f1f5f9;
}

body.theme-dark .ai-key-select option {
  background: #0f172a;
  color: #f8fafc;
}

/* Audit Depth Selector Wrap & Segmented Toggle */
.ai-depth-selector-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface, #ffffff);
  border: 1px solid var(--border, #cbd5e1);
  padding: 3px 6px;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.ai-depth-select-label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 700;
  color: #0284c7;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  cursor: pointer;
  padding-left: 2px;
}

.ai-depth-toggle {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  background: rgba(148, 163, 184, 0.12);
  padding: 2px;
  border-radius: 6px;
}

.ai-depth-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border: none;
  background: transparent;
  color: var(--text-muted, #64748b);
  font-size: 11px;
  font-weight: 600;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
  white-space: nowrap;
}

.ai-depth-btn:hover {
  color: var(--text, #0f172a);
}

.ai-depth-btn:active {
  transform: scale(0.97);
}

.ai-depth-btn.active {
  background: #0f172a;
  color: #ffffff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

.ai-depth-btn[data-depth="exhaustive"].active {
  background: linear-gradient(135deg, #0284c7, #0369a1);
  color: #ffffff;
}

.ai-depth-btn[data-depth="standard"].active {
  background: #334155;
  color: #ffffff;
}

body.theme-dark .ai-depth-selector-wrap {
  background: #1e293b;
  border-color: #334155;
}

body.theme-dark .ai-depth-select-label {
  color: #38bdf8;
}

body.theme-dark .ai-depth-toggle {
  background: rgba(15, 23, 42, 0.6);
}

body.theme-dark .ai-depth-btn {
  color: #94a3b8;
}

body.theme-dark .ai-depth-btn:hover {
  color: #f1f5f9;
}

body.theme-dark .ai-depth-btn[data-depth="exhaustive"].active {
  background: linear-gradient(135deg, #0284c7, #0369a1);
  color: #ffffff;
  box-shadow: 0 1px 4px rgba(2, 132, 199, 0.4);
}

body.theme-dark .ai-depth-btn[data-depth="standard"].active {
  background: #475569;
  color: #f8fafc;
}

/* Learner-appropriate AI suggestion language control */
.ai-language-level-wrap {
  width: 178px;
  padding: 5px 9px 4px;
  background: var(--surface, #ffffff);
  border: 1px solid var(--border, #cbd5e1);
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.ai-language-level-label {
  display: flex;
  justify-content: space-between;
  gap: 6px;
  color: var(--text-muted, #64748b);
  font-size: 10px;
  line-height: 1.2;
  white-space: nowrap;
}

.ai-language-level-label strong {
  color: #059669;
  font-weight: 700;
}

.ai-language-level-wrap input[type="range"] {
  display: block;
  width: 100%;
  height: 14px;
  margin: 2px 0 0;
  accent-color: #059669;
  cursor: pointer;
}

.ai-language-level-scale {
  display: flex;
  justify-content: space-between;
  color: var(--text-muted, #64748b);
  font-size: 8px;
  line-height: 1;
}

body.theme-dark .ai-language-level-wrap {
  background: #1e293b;
  border-color: #334155;
}

body.theme-dark .ai-language-level-label strong {
  color: #34d399;
}

/* Overview Bar */
.ai-overview-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
}

.ai-stat-card {
  background: var(--surface, #f8fafc);
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 8px;
  padding: 10px 16px;
  display: flex;
  flex-direction: column;
  min-width: 100px;
}

.ai-stat-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--muted, #64748b);
  letter-spacing: 0.04em;
}

.ai-stat-val {
  font-size: 22px;
  font-weight: 800;
  line-height: 1.2;
}

.stat-band .ai-stat-val { color: #059669; }
.stat-task .ai-stat-val { color: #0891b2; }
.stat-coherence .ai-stat-val { color: #7c3aed; }
.stat-grammar .ai-stat-val { color: #2563eb; }
.stat-vocab .ai-stat-val { color: #d97706; }

.ai-criteria-chips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 220px;
}

.ai-criterion-chip {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 12px;
  color: #334155;
  display: flex;
  align-items: center;
  gap: 5px;
}

.ai-criterion-chip strong {
  color: #0f172a;
}

/* Examiner Notes Box */
.ai-examiner-notes-box {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 16px;
}

.ai-notes-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 700;
  color: #1e40af;
  margin-bottom: 6px;
}

.ai-notes-list {
  margin: 0;
  padding-left: 18px;
  font-size: 13px;
  color: #1e3a8a;
}

.ai-notes-list li {
  margin-bottom: 4px;
}

/* Filter & Action Bar */
.ai-filter-action-bar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border, #e2e8f0);
}

.ai-crit-tab-bar {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: thin;
}

.ai-crit-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: var(--surface, #ffffff);
  border: 1px solid var(--border, #cbd5e1);
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  color: #475569;
  cursor: pointer;
  transition: all 0.18s ease;
  white-space: nowrap;
  user-select: none;
}

.ai-crit-tab:hover {
  background: #f8fafc;
  color: #0f172a;
  border-color: #94a3b8;
  transform: translateY(-1px);
}

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

.ai-crit-tab.active {
  font-weight: 700;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.ai-crit-tab[data-crit="taskResponse"].active,
.ai-crit-tab[data-crit="taskAchievement"].active {
  background: #ecfeff;
  border-color: #0891b2;
  color: #0e7490;
}

.ai-crit-tab[data-crit="coherenceCohesion"].active {
  background: #f5f3ff;
  border-color: #7c3aed;
  color: #6d28d9;
}

.ai-crit-tab[data-crit="lexicalResource"].active {
  background: #fffbeb;
  border-color: #d97706;
  color: #b45309;
}

.ai-crit-tab[data-crit="grammaticalRange"].active {
  background: #eff6ff;
  border-color: #2563eb;
  color: #1d4ed8;
}

.ai-crit-tab[data-crit="referenceEssay"].active {
  background: #ecfdf5;
  border-color: #059669;
  color: #047857;
}

.ai-crit-tab-label {
  line-height: 1;
}

.ai-crit-tab-band {
  font-size: 11px;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 9999px;
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #cbd5e1;
  transition: all 0.15s ease;
}

.ai-crit-tab[data-crit="taskResponse"].active .ai-crit-tab-band,
.ai-crit-tab[data-crit="taskAchievement"].active .ai-crit-tab-band {
  background: #0891b2;
  color: #ffffff;
  border-color: #0891b2;
}

.ai-crit-tab[data-crit="coherenceCohesion"].active .ai-crit-tab-band {
  background: #7c3aed;
  color: #ffffff;
  border-color: #7c3aed;
}

.ai-crit-tab[data-crit="lexicalResource"].active .ai-crit-tab-band {
  background: #d97706;
  color: #ffffff;
  border-color: #d97706;
}

.ai-crit-tab[data-crit="grammaticalRange"].active .ai-crit-tab-band {
  background: #2563eb;
  color: #ffffff;
  border-color: #2563eb;
}

.ai-crit-tab[data-crit="referenceEssay"].active .ai-crit-tab-band {
  background: #059669;
  color: #ffffff;
  border-color: #059669;
}

body.theme-dark .ai-crit-tab {
  background: #1e293b;
  border-color: #334155;
  color: #94a3b8;
}

body.theme-dark .ai-crit-tab:hover {
  background: #334155;
  color: #f1f5f9;
}

body.theme-dark .ai-crit-tab-band {
  background: #0f172a;
  border-color: #334155;
  color: #94a3b8;
}

/* Inline Diff styling for issues */
.ai-issue-diff {
  font-size: 13.5px;
  line-height: 1.6;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 8px 12px;
  color: #1e293b;
}

.diff-del {
  color: #dc2626;
  background: rgba(239, 68, 68, 0.12);
  text-decoration: line-through;
  padding: 1px 4px;
  border-radius: 3px;
  font-weight: 500;
}

.diff-ins {
  color: #15803d;
  background: rgba(34, 197, 94, 0.14);
  text-decoration: none;
  padding: 1px 4px;
  border-radius: 3px;
  font-weight: 700;
}

body.theme-dark .ai-issue-diff {
  background: #0f172a;
  border-color: #334155;
  color: #f1f5f9;
}

body.theme-dark .diff-del {
  color: #f87171;
  background: rgba(239, 68, 68, 0.22);
}

body.theme-dark .diff-ins {
  color: #4ade80;
  background: rgba(34, 197, 94, 0.22);
}

/* Reference Corrected Essay View in Studio */
.ai-reference-essay-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.ai-ref-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border, #e2e8f0);
}

.ai-ref-title {
  font-size: 15px;
  font-weight: 700;
  color: #0f172a;
}

.ai-ref-body {
  font-size: 14px;
  line-height: 1.7;
  color: #1e293b;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 14px 16px;
  white-space: pre-wrap;
}

.ai-ref-marker {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 800;
  color: #ffffff;
  background: #059669;
  border-radius: 4px;
  padding: 0 4px;
  margin: 0 2px;
  vertical-align: baseline;
}

.ai-ref-guide-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ai-ref-guide-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-left: 3px solid #059669;
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 12.5px;
}

.ai-ref-guide-head {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
}

.ai-ref-guide-replacement {
  color: #059669;
  font-weight: 700;
}

.ai-ref-guide-exp {
  color: #475569;
  font-size: 12px;
  line-height: 1.4;
}

/* Legacy tabs retained for compatibility */
.ai-tabs {
  display: flex;
  gap: 6px;
}

.ai-tab-btn {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted, #64748b);
  cursor: pointer;
  transition: all 0.15s ease;
}

.ai-tab-btn:hover {
  background: #f1f5f9;
  color: #1e293b;
}

.ai-tab-btn.active {
  background: #f5f3ff;
  border-color: #ddd6fe;
  color: #7c3aed;
}

.btn-apply-all {
  background: linear-gradient(135deg, #059669 0%, #0d9488 100%) !important;
  color: #ffffff !important;
  border: none !important;
  padding: 7px 14px !important;
  font-size: 13px !important;
  font-weight: 700 !important;
  border-radius: 6px !important;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(5, 150, 105, 0.25);
  transition: all 0.15s ease;
}

.btn-apply-all:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(5, 150, 105, 0.35);
}

.btn-apply-matrix {
  background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%) !important;
  color: #ffffff !important;
  border: none !important;
  padding: 7px 12px !important;
  font-size: 12.5px !important;
  font-weight: 700 !important;
  border-radius: 6px !important;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(124, 58, 237, 0.25);
  transition: all 0.15s ease;
}

.btn-apply-matrix:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(124, 58, 237, 0.35);
}

.btn-apply-highlights {
  background: #ffffff !important;
  border: 1px solid #cbd5e1 !important;
  color: #334155 !important;
  padding: 7px 12px !important;
  font-size: 12.5px !important;
  font-weight: 600 !important;
  border-radius: 6px !important;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-apply-highlights:hover {
  background: #f1f5f9 !important;
  color: #0f172a !important;
}

/* AI Criteria Diagnostics Grid */
.ai-criteria-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.ai-criterion-card {
  background: var(--surface, #ffffff);
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 10px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: relative;
  transition: all 0.2s ease;
  border-top: 4px solid #64748b;
}

.ai-criterion-card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
  transform: translateY(-1px);
}

.ai-criterion-card.crit-tr { border-top-color: #0891b2; }
.ai-criterion-card.crit-cc { border-top-color: #8b5cf6; }
.ai-criterion-card.crit-lr { border-top-color: #d97706; }
.ai-criterion-card.crit-gra { border-top-color: #2563eb; }

.ai-criterion-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.ai-criterion-title {
  font-size: 13.5px;
  font-weight: 700;
  color: #0f172a;
  display: flex;
  align-items: center;
  gap: 6px;
}

.ai-criterion-band-badge {
  font-size: 12px;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 9999px;
  background: #f1f5f9;
  color: #0f172a;
  border: 1px solid #cbd5e1;
}

.crit-tr .ai-criterion-band-badge { background: #cffafe; color: #0891b2; border-color: #a5f3fc; }
.crit-cc .ai-criterion-band-badge { background: #ede9fe; color: #7c3aed; border-color: #ddd6fe; }
.crit-lr .ai-criterion-band-badge { background: #fef3c7; color: #b45309; border-color: #fde68a; }
.crit-gra .ai-criterion-band-badge { background: #dbeafe; color: #1d4ed8; border-color: #bfdbfe; }

.ai-criterion-summary {
  font-size: 12px;
  line-height: 1.45;
  color: #334155;
  font-weight: 500;
}

.ai-criterion-block {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ai-criterion-block-title {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  color: #64748b;
  display: flex;
  align-items: center;
  gap: 4px;
}

.ai-criterion-bullets {
  margin: 0;
  padding-left: 16px;
  font-size: 11.5px;
  line-height: 1.4;
  color: #475569;
}

.ai-criterion-bullets li {
  margin-bottom: 2px;
}

.ai-criterion-bullets.is-strength li::marker { color: #10b981; }
.ai-criterion-bullets.is-weakness li::marker { color: #ef4444; }

.ai-criterion-justification {
  font-size: 11px;
  line-height: 1.4;
  color: #64748b;
  background: #f8fafc;
  border-radius: 6px;
  padding: 6px 10px;
  border-left: 3px solid #94a3b8;
  font-style: italic;
}

.ai-criterion-upgrade {
  font-size: 11.5px;
  line-height: 1.4;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 6px;
  padding: 7px 10px;
  color: #166534;
}

.ai-criterion-upgrade strong {
  color: #14532d;
}

/* AI Examiner Verification Accordion */
.ai-verification-accordion {
  margin-top: 4px;
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 8px;
  background: #f8fafc;
  overflow: hidden;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.ai-verification-accordion[open] {
  background: #ffffff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
  border-color: #cbd5e1;
}

.crit-tr .ai-verification-accordion[open] { border-color: #a5f3fc; }
.crit-cc .ai-verification-accordion[open] { border-color: #ddd6fe; }
.crit-lr .ai-verification-accordion[open] { border-color: #fde68a; }
.crit-gra .ai-verification-accordion[open] { border-color: #bfdbfe; }

.ai-verification-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 10px;
  font-size: 11px;
  font-weight: 600;
  color: #475569;
  cursor: pointer;
  user-select: none;
  background: #f1f5f9;
  transition: background 0.15s ease, color 0.15s ease;
  list-style: none;
}

.ai-verification-summary::-webkit-details-marker {
  display: none;
}

.ai-verification-summary:hover {
  background: #e2e8f0;
  color: #1e293b;
}

.ai-verification-summary-left {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #334155;
}

.crit-tr .ai-verification-summary-left svg { color: #0891b2; }
.crit-cc .ai-verification-summary-left svg { color: #8b5cf6; }
.crit-lr .ai-verification-summary-left svg { color: #d97706; }
.crit-gra .ai-verification-summary-left svg { color: #2563eb; }

.ai-verification-chevron {
  font-size: 11px;
  color: #64748b;
  transition: transform 0.2s ease;
}

.ai-verification-accordion[open] .ai-verification-chevron {
  transform: rotate(180deg);
}

.ai-verification-content {
  padding: 9px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 11px;
  line-height: 1.45;
  color: #334155;
  border-top: 1px solid #e2e8f0;
  background: #ffffff;
}

.ai-audit-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 5px 8px;
  border-radius: 6px;
  background: #f8fafc;
  border-left: 2px solid #cbd5e1;
}

.ai-audit-item.badge-highlight {
  background: #eff6ff;
  border-left-color: #3b82f6;
}

.crit-tr .ai-audit-item.badge-highlight {
  background: #ecfeff;
  border-left-color: #0891b2;
}

.crit-cc .ai-audit-item.badge-highlight {
  background: #f5f3ff;
  border-left-color: #8b5cf6;
}

.crit-lr .ai-audit-item.badge-highlight {
  background: #fffbeb;
  border-left-color: #d97706;
}

.ai-audit-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  color: #64748b;
}

.ai-audit-item.badge-highlight .ai-audit-label {
  color: #1e40af;
}
.crit-tr .ai-audit-item.badge-highlight .ai-audit-label { color: #0e7490; }
.crit-cc .ai-audit-item.badge-highlight .ai-audit-label { color: #6d28d9; }
.crit-lr .ai-audit-item.badge-highlight .ai-audit-label { color: #b45309; }

.ai-audit-val {
  font-size: 11.5px;
  color: #1e293b;
  font-weight: 500;
}

/* Issues Cards */
.ai-issues-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ai-issue-card {
  background: var(--surface, #ffffff);
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 8px;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: box-shadow 0.15s ease;
}

.ai-issue-card:hover {
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.05);
}

.ai-issue-card.issue-type-task {
  border-left: 4px solid #0891b2;
}

.ai-issue-card.issue-type-coherence {
  border-left: 4px solid #7c3aed;
}

.ai-issue-card.issue-type-grammar {
  border-left: 4px solid #2563eb;
}

.ai-issue-card.issue-type-vocabulary {
  border-left: 4px solid #d97706;
}

.ai-issue-card.applied {
  opacity: 0.65;
  background: #f8fafc;
}

.ai-issue-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.ai-issue-badges {
  display: flex;
  align-items: center;
  gap: 6px;
}

.ai-badge {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 4px;
}

.badge-task {
  background: #ecfeff;
  color: #0e7490;
  border: 1px solid #a5f3fc;
}

.badge-coherence {
  background: #f5f3ff;
  color: #6d28d9;
  border: 1px solid #ddd6fe;
}

.badge-grammar {
  background: #eff6ff;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
}

.badge-vocabulary {
  background: #fffbeb;
  color: #b45309;
  border: 1px solid #fde68a;
}

.ai-badge-subtype {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted, #64748b);
}

.ai-issue-actions {
  display: flex;
  gap: 6px;
}

.btn-card-action {
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 5px;
  border: 1px solid var(--border, #cbd5e1);
  background: #ffffff;
  color: #334155;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-card-action:hover {
  background: #f1f5f9;
  border-color: #94a3b8;
}

.btn-card-action.btn-highlight {
  background: #f0fdf4;
  border-color: #86efac;
  color: #15803d;
}

.btn-card-action.btn-highlight:hover {
  background: #dcfce7;
}

.btn-card-action.is-applied {
  background: #e2e8f0 !important;
  color: #64748b !important;
  border-color: #cbd5e1 !important;
  cursor: default;
}

.ai-issue-quote {
  font-size: 13px;
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.ai-quote-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: #94a3b8;
}

.ai-quote-text {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12.5px;
  background: #f1f5f9;
  padding: 2px 7px;
  border-radius: 4px;
  color: #0f172a;
  border: 1px solid #e2e8f0;
}

.ai-issue-explanation {
  font-size: 13px;
  color: #334155;
  line-height: 1.45;
}

.ai-issue-suggestion {
  font-size: 13px;
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 6px 10px;
  background: #f8fafc;
  border-radius: 6px;
  border: 1px dashed #cbd5e1;
}

.ai-sugg-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: #059669;
}

.ai-sugg-text {
  font-weight: 600;
  color: #0f172a;
}

/* Improved Example Callout & Contrast Styles */
.ai-improved-example-box {
  margin-top: 6px;
  background: #f0fdfa;
  border: 1px solid #99f6e4;
  border-left: 3px solid #0d9488;
  border-radius: 6px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ai-improved-example-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.ai-improved-example-badge {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: #0f766e;
  letter-spacing: 0.3px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.btn-copy-example {
  background: #ffffff;
  border: 1px solid #99f6e4;
  border-radius: 4px;
  padding: 2px 7px;
  font-size: 11px;
  font-weight: 600;
  color: #0f766e;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-copy-example:hover {
  background: #ccfbf1;
  border-color: #5eead4;
}

.btn-copy-example.copied {
  background: #0d9488;
  color: #ffffff;
  border-color: #0d9488;
}

.ai-improved-example-text {
  font-size: 13px;
  font-weight: 500;
  color: #134e4a;
  line-height: 1.5;
  font-style: italic;
}

body.theme-dark .ai-improved-example-box {
  background: rgba(13, 148, 136, 0.1);
  border-color: rgba(94, 234, 212, 0.25);
  border-left-color: #14b8a6;
}

body.theme-dark .ai-improved-example-badge {
  color: #5eead4;
}

body.theme-dark .btn-copy-example {
  background: #0f172a;
  border-color: rgba(94, 234, 212, 0.3);
  color: #5eead4;
}

body.theme-dark .btn-copy-example:hover {
  background: rgba(13, 148, 136, 0.25);
}

body.theme-dark .ai-improved-example-text {
  color: #ccfbf1;
}

/* Dark Mode Overrides */
body.theme-dark .ai-modal-badge {
  background: #2e1065;
  border-color: #581c87;
  color: #c084fc;
}

body.theme-dark .ai-stat-card {
  background: #1e293b;
  border-color: #334155;
}

body.theme-dark .ai-criterion-chip {
  background: #1e293b;
  border-color: #334155;
  color: #cbd5e1;
}

body.theme-dark .ai-criterion-chip strong {
  color: #f1f5f9;
}

body.theme-dark .ai-examiner-notes-box {
  background: #1e293b;
  border-color: #3b82f6;
}

body.theme-dark .ai-notes-title {
  color: #60a5fa;
}

body.theme-dark .ai-notes-list {
  color: #93c5fd;
}

body.theme-dark .ai-tab-btn:hover {
  background: #334155;
  color: #f8fafc;
}

body.theme-dark .ai-tab-btn.active {
  background: #2e1065;
  border-color: #581c87;
  color: #c084fc;
}

body.theme-dark .ai-issue-card {
  background: #1e293b;
  border-color: #334155;
}

body.theme-dark .ai-quote-text {
  background: #0f172a;
  border-color: #334155;
  color: #f8fafc;
}

body.theme-dark .ai-issue-explanation {
  color: #cbd5e1;
}

body.theme-dark .ai-issue-suggestion {
  background: #0f172a;
  border-color: #334155;
}

body.theme-dark .ai-sugg-text {
  color: #f1f5f9;
}

body.theme-dark .btn-card-action {
  background: #334155;
  border-color: #475569;
  color: #f1f5f9;
}

body.theme-dark .btn-card-action.btn-highlight {
  background: #064e3b;
  border-color: #059669;
  color: #6ee7b7;
}

/* Key Configuration Panel */
.ai-key-config-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: transparent;
  border: 1px solid var(--border, #cbd5e1);
  color: var(--muted, #64748b);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.ai-key-config-btn:hover {
  background: #f1f5f9;
  color: #1e293b;
}

.ai-footer-main-actions {
  display: flex;
  gap: 8px;
}

.ai-key-config-panel {
  margin-top: 16px;
  padding: 14px 16px;
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  animation: fadeIn 0.2s ease-in-out;
}

.ai-key-panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.ai-key-panel-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 700;
  color: #1e293b;
}

.ai-key-status-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 9999px;
  background: #eff6ff;
  color: #2563eb;
  border: 1px solid #bfdbfe;
}

.ai-key-status-badge.is-custom {
  background: #ecfdf5;
  color: #059669;
  border-color: #a7f3d0;
}

.ai-key-desc {
  font-size: 12.5px;
  color: var(--muted, #64748b);
  margin-bottom: 10px;
  line-height: 1.4;
}

.ai-key-input-group {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  width: 100%;
}

.ai-key-input-group input {
  flex: 1 1 auto;
  min-width: 0;
  width: 100%;
  padding: 8px 12px;
  font-size: 13px;
  border: 1px solid var(--border, #cbd5e1);
  border-radius: 6px;
  background: #ffffff;
  color: var(--text, #0f172a);
  box-sizing: border-box;
  font-family: inherit;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.ai-key-input-group input:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}

.ai-key-input-group button {
  flex-shrink: 0;
  padding: 7px 14px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.ai-key-input-group button.primary {
  background: #2563eb;
  color: #ffffff;
  border: 1px solid #1d4ed8;
}

.ai-key-input-group button.primary:hover:not(:disabled) {
  background: #1d4ed8;
}

.ai-key-input-group button.primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.ai-key-input-group button.secondary {
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #cbd5e1;
}

.ai-key-input-group button.secondary:hover {
  background: #e2e8f0;
  color: #1e293b;
}

/* Dual Key Settings & Mode Tabs */
.ai-key-tier-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 10px 0 14px;
}

.ai-tier-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface, #ffffff);
  border: 1px solid var(--border, #cbd5e1);
  color: #475569;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.ai-tier-tab:hover {
  background: #f1f5f9;
  color: #0f172a;
  border-color: #94a3b8;
}

.ai-tier-tab.is-active {
  background: #1e293b;
  color: #ffffff;
  border-color: #1e293b;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.ai-tier-tab[data-tier="free"].is-active {
  background: #059669;
  border-color: #059669;
}

.ai-tier-tab[data-tier="free"].is-active {
  background: #059669;
  border-color: #059669;
}

.ai-tier-tab[data-tier="groq"].is-active {
  background: #ea580c;
  border-color: #ea580c;
}

.ai-tier-tab[data-tier="paid"].is-active {
  background: #7c3aed;
  border-color: #7c3aed;
}

.ai-tier-tab[data-tier="auto_failover"].is-active {
  background: #d97706;
  border-color: #d97706;
}

.ai-dual-key-grid,
.ai-key-slots-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
  margin-bottom: 8px;
}

@media (max-width: 700px) {
  .ai-dual-key-grid,
  .ai-key-slots-grid {
    grid-template-columns: 1fr;
  }
}

.ai-key-slot-card {
  background: var(--surface, #ffffff);
  border: 1px solid var(--border, #cbd5e1);
  border-radius: 8px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ai-slot-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.ai-slot-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: #0f172a;
}

.ai-slot-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.ai-slot-dot.free {
  background: #10b981;
}

.ai-slot-dot.cerebras {
  background: #f1592a;
}

.ai-slot-dot.groq {
  background: #f97316;
}

.ai-slot-dot.mistral {
  background: #f25c05;
}

.ai-slot-dot.openai {
  background: #10a37f;
}

.ai-slot-dot.paid {
  background: #8b5cf6;
}

.ai-slot-pill {
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 9999px;
  text-transform: uppercase;
}

.ai-slot-pill.default {
  background: #d1fae5;
  color: #065f46;
}

.ai-slot-pill.cerebras {
  background: #ffedd5;
  color: #c2410c;
}

.ai-slot-pill.groq {
  background: #ffedd5;
  color: #c2410c;
}

.ai-slot-pill.mistral {
  background: #ffedd5;
  color: #c2410c;
}

.ai-slot-pill.openai {
  background: #dcfce7;
  color: #15803d;
}

.ai-slot-pill.paid {
  background: #ede9fe;
  color: #6d28d9;
}

.ai-slot-status {
  font-size: 10.5px;
  font-weight: 700;
  color: #94a3b8;
}

.ai-slot-status.is-configured {
  color: #059669;
}

.ai-slot-status.not-set {
  color: #e11d48;
}

.ai-input-wrapper {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
}

.ai-input-wrapper input {
  width: 100%;
  padding-right: 32px;
}

.btn-toggle-eye {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 2px 5px;
  font-size: 13px;
  opacity: 0.6;
  transition: opacity 0.15s ease;
}

.btn-toggle-eye:hover {
  opacity: 1;
}

.ai-key-hint {
  display: block;
  font-size: 11.5px;
  color: var(--muted, #94a3b8);
}

.ai-key-hint a {
  color: #7c3aed;
  text-decoration: underline;
}

.ai-key-test-feedback {
  font-size: 11.5px;
  line-height: 1.4;
  padding: 6px 10px;
  border-radius: 6px;
  margin-top: 4px;
  transition: all 0.2s ease;
}

.ai-key-test-feedback.is-testing {
  background: rgba(59, 130, 246, 0.08);
  border: 1px solid rgba(59, 130, 246, 0.25);
  color: #1d4ed8;
}

.ai-key-test-feedback.is-success {
  background: rgba(16, 185, 129, 0.08);
  border: 1px solid rgba(16, 185, 129, 0.25);
  color: #065f46;
}

.ai-key-test-feedback.is-error {
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.25);
  color: #b91c1c;
}

.btn-fill-default-key {
  background: none;
  border: none;
  color: #2563eb;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  padding: 2px 4px;
  text-decoration: underline;
  transition: opacity 0.15s;
}

.btn-fill-default-key:hover {
  opacity: 0.8;
}

body.theme-dark .ai-key-config-panel {
  background: #0f172a;
  border-color: #334155;
}

body.theme-dark .ai-key-panel-title {
  color: #f8fafc;
}

body.theme-dark .ai-key-input-group input {
  background: #1e293b;
  border-color: #475569;
  color: #f8fafc;
}

body.theme-dark .ai-key-input-group button.secondary {
  background: #1e293b;
  color: #cbd5e1;
  border-color: #475569;
}

body.theme-dark .ai-key-input-group button.secondary:hover {
  background: #334155;
  color: #ffffff;
}

body.theme-dark .ai-key-config-btn:hover {
  background: #334155;
  color: #f8fafc;
}

body.theme-dark .ai-tier-tab {
  background: #1e293b;
  border-color: #334155;
  color: #cbd5e1;
}

body.theme-dark .ai-tier-tab:hover {
  background: #2d3748;
  color: #ffffff;
}

body.theme-dark .ai-key-slot-card {
  background: #1e293b;
  border-color: #334155;
}

body.theme-dark .ai-slot-label {
  color: #f8fafc;
}

/* Supported Models Cascade Grid */
.ai-supported-models-wrap {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px dashed var(--border, #cbd5e1);
}

.ai-supported-models-title {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--muted, #64748b);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.ai-models-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 8px;
}

.ai-model-pill {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 10px;
  border-radius: 6px;
  text-decoration: none;
  font-size: 12px;
  font-weight: 600;
  transition: all 0.15s ease;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: #1e293b;
}

.ai-model-pill:hover {
  transform: translateY(-1px);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.08);
}

.ai-model-pill .pill-rank {
  font-size: 10px;
  font-weight: 800;
  padding: 1px 5px;
  border-radius: 4px;
  background: #e2e8f0;
  color: #475569;
}

.ai-model-pill .pill-name {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ai-model-pill .pill-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 9999px;
}

.ai-model-pill.priority-lite {
  border-color: #a7f3d0;
  background: #f0fdf4;
}

.ai-model-pill.priority-lite:hover {
  border-color: #34d399;
  background: #ecfdf5;
}

.ai-model-pill.priority-lite .pill-rank {
  background: #10b981;
  color: #ffffff;
}

.ai-model-pill.priority-lite .pill-badge {
  background: #d1fae5;
  color: #047857;
}

.ai-model-pill.priority-flash {
  border-color: #ddd6fe;
  background: #faf5ff;
}

.ai-model-pill.priority-flash:hover {
  border-color: #a78bfa;
  background: #f5f3ff;
}

.ai-model-pill.priority-flash .pill-rank {
  background: #8b5cf6;
  color: #ffffff;
}

.ai-model-pill.priority-flash .pill-badge {
  background: #ede9fe;
  color: #6d28d9;
}

.ai-model-pill.priority-cerebras {
  border-color: #fdba74;
  background: #fff7ed;
}

.ai-model-pill.priority-cerebras:hover {
  border-color: #f97316;
  background: #ffedd5;
}

.ai-model-pill.priority-cerebras .pill-rank {
  background: #f1592a;
  color: #ffffff;
}

.ai-model-pill.priority-cerebras .pill-badge {
  background: #ffedd5;
  color: #c2410c;
}

.ai-model-pill.priority-groq {
  border-color: #fed7aa;
  background: #fff7ed;
}

.ai-model-pill.priority-groq:hover {
  border-color: #fb923c;
  background: #ffedd5;
}

.ai-model-pill.priority-groq .pill-rank {
  background: #ea580c;
  color: #ffffff;
}

.ai-model-pill.priority-groq .pill-badge {
  background: #ffedd5;
  color: #c2410c;
}

.ai-model-pill.priority-mistral {
  border-color: #fdba74;
  background: #fff7ed;
}

.ai-model-pill.priority-mistral:hover {
  border-color: #f97316;
  background: #ffedd5;
}

.ai-model-pill.priority-mistral .pill-rank {
  background: #ea580c;
  color: #ffffff;
}

.ai-model-pill.priority-mistral .pill-badge {
  background: #ffedd5;
  color: #c2410c;
}

.ai-model-pill.priority-openai {
  border-color: #86efac;
  background: #f0fdf4;
}

.ai-model-pill.priority-openai:hover {
  border-color: #22c55e;
  background: #dcfce7;
}

.ai-model-pill.priority-openai .pill-rank {
  background: #10a37f;
  color: #ffffff;
}

.ai-model-pill.priority-openai .pill-badge {
  background: #dcfce7;
  color: #15803d;
}

.ready-key-badge.groq {
  background: #ffedd5;
  color: #c2410c;
}

body.theme-dark .ready-key-badge.groq {
  background: rgba(234, 88, 12, 0.25);
  color: #fdba74;
}

body.theme-dark .ai-supported-models-wrap {
  border-top-color: #334155;
}

body.theme-dark .ai-supported-models-title {
  color: #94a3b8;
}

body.theme-dark .ai-model-pill {
  background: #1e293b;
  border-color: #334155;
  color: #f1f5f9;
}

body.theme-dark .ai-model-pill.priority-lite {
  background: #064e3b;
  border-color: #059669;
}

body.theme-dark .ai-model-pill.priority-lite .pill-badge {
  background: #022c22;
  color: #6ee7b7;
}

body.theme-dark .ai-model-pill.priority-flash {
  background: #3b0764;
  border-color: #7c3aed;
}

body.theme-dark .ai-model-pill.priority-flash .pill-badge {
  background: #2e1065;
  color: #c084fc;
}

body.theme-dark .ai-model-pill.priority-cerebras {
  background: #431407;
  border-color: #f1592a;
}

body.theme-dark .ai-model-pill.priority-cerebras .pill-badge {
  background: #270d03;
  color: #fdba74;
}

body.theme-dark .ai-model-pill.priority-groq {
  background: #431407;
  border-color: #ea580c;
}

body.theme-dark .ai-model-pill.priority-groq .pill-badge {
  background: #270d03;
  color: #fdba74;
}

body.theme-dark .ai-model-pill.priority-mistral {
  background: #431407;
  border-color: #ea580c;
}

body.theme-dark .ai-model-pill.priority-mistral .pill-badge {
  background: #270d03;
  color: #fdba74;
}

body.theme-dark .ai-model-pill.priority-openai {
  background: #064e3b;
  border-color: #10b981;
}

body.theme-dark .ai-model-pill.priority-openai .pill-badge {
  background: #022c22;
  color: #86efac;
}

.stat-model {
  min-width: 140px;
}

.stat-model .ai-active-model-val {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 700;
  color: #7c3aed;
  margin-top: 5px;
}

.ai-model-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 6px rgba(16, 185, 129, 0.6);
  display: inline-block;
  flex-shrink: 0;
}

body.theme-dark .stat-model .ai-active-model-val {
  color: #c084fc;
}

.ai-model-pill {
  cursor: pointer;
  user-select: none;
}

.ai-model-pill.is-selected {
  outline: 2px solid #7c3aed;
  outline-offset: 2px;
  box-shadow: 0 0 10px rgba(124, 58, 237, 0.3);
}

body.theme-dark .ai-model-pill.is-selected {
  outline-color: #a78bfa;
  box-shadow: 0 0 10px rgba(167, 139, 250, 0.4);
}

/* ==========================================
 * TASK 1 VISUAL PROMPT & CATALOG LIGHTBOX
 * ========================================== */
.panel-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.panel-header-row h2 {
  margin: 0;
}

.visual-source-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  font-size: 11px;
  font-weight: 700;
  border-radius: 9999px;
  background: rgba(14, 165, 233, 0.12);
  color: #0284c7;
  border: 1px solid rgba(14, 165, 233, 0.3);
}

body.theme-dark .visual-source-badge {
  background: rgba(14, 165, 233, 0.2);
  color: #38bdf8;
  border-color: rgba(56, 189, 248, 0.4);
}

.visual-tools-bar {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
}

.visual-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
  border: 1px solid transparent;
}

.visual-action-btn.primary {
  background: #0284c7;
  color: #fff;
}

.visual-action-btn.primary:hover {
  background: #0369a1;
}

.visual-action-btn.secondary {
  background: var(--surface-subtle, #f1f5f9);
  color: var(--text, #334155);
  border-color: var(--line, #cbd5e1);
}

.visual-action-btn.secondary:hover {
  background: var(--surface-hover, #e2e8f0);
}

/* Task 1 Selector Modal */
.task1-modal-dialog {
  max-width: 960px;
  width: 92vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}

.task1-modal-controls {
  padding: 12px 20px;
  border-bottom: 1px solid var(--line, #e2e8f0);
  background: var(--surface-subtle, #f8fafc);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.task1-curriculum-tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.task1-curriculum-tabs .tab-btn {
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 6px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--muted, #64748b);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.task1-curriculum-tabs .tab-btn:hover {
  color: var(--text, #1e293b);
  background: rgba(0, 0, 0, 0.04);
}

.task1-curriculum-tabs .tab-btn.active {
  background: #fff;
  color: #0284c7;
  border-color: var(--line, #cbd5e1);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

body.theme-dark .task1-curriculum-tabs .tab-btn.active {
  background: #1e293b;
  color: #38bdf8;
  border-color: #334155;
}

.task1-filter-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.task1-search-wrap {
  position: relative;
  flex: 1;
  min-width: 220px;
}

.task1-search-wrap svg {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted, #94a3b8);
  pointer-events: none;
}

.task1-search-wrap input {
  width: 100%;
  padding: 6px 10px 6px 30px;
  font-size: 13px;
  border-radius: 8px;
  border: 1px solid var(--line, #cbd5e1);
  background: #fff;
  color: var(--text, #1e293b);
  outline: none;
}

body.theme-dark .task1-search-wrap input {
  background: #0f172a;
  border-color: #334155;
}

.task1-format-pills {
  display: flex;
  gap: 4px;
  overflow-x: auto;
}

.task1-format-pills .format-pill {
  padding: 4px 9px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 9999px;
  background: transparent;
  border: 1px solid var(--line, #cbd5e1);
  color: var(--muted, #64748b);
  cursor: pointer;
  white-space: nowrap;
}

.task1-format-pills .format-pill.active {
  background: #0284c7;
  color: #fff;
  border-color: #0284c7;
}

.task1-modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  max-height: 55vh;
}

.task1-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}

.task1-card {
  border: 1px solid var(--line, #e2e8f0);
  border-radius: 10px;
  background: #fff;
  padding: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

body.theme-dark .task1-card {
  background: #1e293b;
  border-color: #334155;
}

.task1-card:hover {
  transform: translateY(-2px);
  border-color: #0284c7;
  box-shadow: 0 6px 16px rgba(2, 132, 199, 0.12);
}

.task1-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.task1-card-source {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 2px 6px;
  border-radius: 4px;
}

.task1-card-source.source-wh {
  background: rgba(99, 102, 241, 0.12);
  color: #6366f1;
}

.task1-card-source.source-expert {
  background: rgba(16, 185, 129, 0.12);
  color: #059669;
}

.task1-card-source.source-mindset {
  background: rgba(168, 85, 247, 0.12);
  color: #9333ea;
}

.task1-card-format {
  font-size: 10px;
  font-weight: 600;
  color: var(--muted, #64748b);
}

.task1-card-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text, #0f172a);
  margin: 0 0 6px 0;
  line-height: 1.35;
}

.task1-card-prompt {
  font-size: 11px;
  color: var(--muted, #64748b);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 10px;
}

.task1-card-action {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  font-weight: 600;
  color: #0284c7;
  padding-top: 8px;
  border-top: 1px dashed var(--line, #e2e8f0);
}

.task1-empty-state {
  text-align: center;
  padding: 30px 20px;
  color: var(--muted, #64748b);
  font-size: 13px;
}

/* Chart Zoom Modal */
.chart-zoom-backdrop {
  z-index: 1000;
}

.chart-zoom-dialog {
  max-width: 1100px;
  width: 95vw;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
}

.zoom-badge-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}

.chart-zoom-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(2, 132, 199, 0.15);
  color: #0284c7;
}

.chart-zoom-source {
  font-size: 11px;
  color: var(--muted, #64748b);
}

.chart-zoom-body {
  flex: 1;
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: var(--surface-subtle, #f8fafc);
  min-height: 420px;
}

body.theme-dark .chart-zoom-body {
  background: #0f172a;
}

.chart-zoom-body img {
  max-width: 100%;
  max-height: 70vh;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.chart-zoom-body canvas {
  max-width: 100%;
  max-height: 65vh;
}

.chart-zoom-body table {
  background: #fff;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 4px 15px rgba(0,0,0,0.08);
}

body.theme-dark .chart-zoom-body table {
  background: #1e293b;
}

.chart-zoom-hint {
  font-size: 11px;
  color: var(--muted, #64748b);
}

.chart-zoom-hint kbd {
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--surface-subtle, #e2e8f0);
  border: 1px solid var(--line, #cbd5e1);
  font-family: monospace;
}

/* Batch Auto-Highlight Feature Styles */
.badge-draft-highlighted {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2.5px 7.5px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  background: #e0f2fe;
  color: #0369a1;
  border: 1px solid #bae6fd;
}

body.theme-dark .badge-draft-highlighted {
  background: rgba(14, 165, 233, 0.15);
  color: #38bdf8;
  border-color: rgba(56, 189, 248, 0.3);
}

.batch-highlight-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 13px;
  background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(2, 132, 199, 0.25);
  transition: all 0.15s ease;
}

.batch-highlight-btn:hover {
  background: linear-gradient(135deg, #0369a1 0%, #075985 100%);
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(2, 132, 199, 0.35);
}

.batch-highlight-btn svg {
  color: #fbbf24;
}

/* Batch Modal Layout */
.batch-view-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.batch-notice-box {
  display: flex;
  gap: 12px;
  padding: 14px 16px;
  background: #f0f9ff;
  border: 1px solid #bae6fd;
  border-radius: 8px;
  color: #0c4a6e;
  font-size: 13px;
  line-height: 1.5;
}

body.theme-dark .batch-notice-box {
  background: rgba(14, 165, 233, 0.1);
  border-color: rgba(14, 165, 233, 0.25);
  color: #bae6fd;
}

.batch-notice-icon {
  flex-shrink: 0;
  color: #0284c7;
}

.batch-notice-content strong {
  display: block;
  margin-bottom: 4px;
  font-size: 13.5px;
}

.batch-notice-content p {
  margin: 0;
}

.batch-config-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

@media (max-width: 640px) {
  .batch-config-grid {
    grid-template-columns: 1fr;
  }
}

.batch-config-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.batch-config-card label {
  font-size: 12px;
  font-weight: 600;
  color: var(--foreground);
}

.batch-input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13.5px;
  background: var(--surface-secondary, #fff);
  color: var(--foreground);
}

.batch-hint {
  font-size: 11px;
  color: var(--muted);
}

.batch-options-card {
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.batch-checkbox-label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  cursor: pointer;
  user-select: none;
}

.batch-stats-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 12px 16px;
  background: var(--surface-muted, #f8fafc);
  border: 1px solid var(--border);
  border-radius: 8px;
}

body.theme-dark .batch-stats-banner {
  background: rgba(255, 255, 255, 0.03);
}

.batch-stat-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

.batch-stat-val {
  font-size: 15px;
  color: var(--primary);
}

.batch-criteria-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.batch-card-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--foreground);
}

.batch-criteria-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

@media (max-width: 640px) {
  .batch-criteria-grid {
    grid-template-columns: 1fr;
  }
}

.batch-criterion-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: var(--surface-secondary, #f8fafc);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  user-select: none;
  transition: all 0.15s ease;
}

.batch-criterion-toggle:hover {
  background: var(--surface-hover, #f1f5f9);
  border-color: #94a3b8;
}

.batch-criterion-toggle input[type="checkbox"] {
  cursor: pointer;
  width: 15px;
  height: 15px;
  accent-color: var(--primary, #0284c7);
  flex-shrink: 0;
}

.criterion-chip-body {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.criterion-badge {
  font-size: 10.5px;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  flex-shrink: 0;
}

.criterion-badge.gra {
  background: #dbeafe;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
}

.criterion-badge.lr {
  background: #fef3c7;
  color: #b45309;
  border: 1px solid #fde68a;
}

.criterion-badge.cc {
  background: #ede9fe;
  color: #7c3aed;
  border: 1px solid #ddd6fe;
}

.criterion-badge.tr {
  background: #cffafe;
  color: #0891b2;
  border: 1px solid #a5f3fc;
}

.criterion-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.criterion-info strong {
  font-size: 12px;
  font-weight: 700;
  color: var(--foreground, #0f172a);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.criterion-info small {
  font-size: 10.5px;
  color: var(--muted, #64748b);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.batch-criterion-toggle:has(input:checked) {
  background: var(--surface, #ffffff);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.batch-criterion-toggle.gra:has(input:checked) {
  border-color: #93c5fd;
  background: rgba(37, 99, 235, 0.04);
}

.batch-criterion-toggle.lr:has(input:checked) {
  border-color: #fde68a;
  background: rgba(217, 119, 6, 0.04);
}

.batch-criterion-toggle.cc:has(input:checked) {
  border-color: #ddd6fe;
  background: rgba(124, 58, 237, 0.04);
}

.batch-criterion-toggle.tr:has(input:checked) {
  border-color: #a5f3fc;
  background: rgba(8, 145, 178, 0.04);
}

body.theme-dark .batch-criteria-card {
  background: #1e293b;
  border-color: #334155;
}

body.theme-dark .batch-criterion-toggle {
  background: #0f172a;
  border-color: #334155;
}

body.theme-dark .batch-criterion-toggle:hover {
  background: #1e293b;
}

body.theme-dark .criterion-info strong {
  color: #f8fafc;
}

body.theme-dark .criterion-info small {
  color: #94a3b8;
}

body.theme-dark .batch-criterion-toggle.gra:has(input:checked) {
  border-color: #3b82f6;
  background: rgba(59, 130, 246, 0.12);
}

body.theme-dark .batch-criterion-toggle.lr:has(input:checked) {
  border-color: #d97706;
  background: rgba(217, 119, 6, 0.12);
}

body.theme-dark .batch-criterion-toggle.cc:has(input:checked) {
  border-color: #8b5cf6;
  background: rgba(139, 92, 246, 0.12);
}

body.theme-dark .batch-criterion-toggle.tr:has(input:checked) {
  border-color: #06b6d4;
  background: rgba(6, 182, 212, 0.12);
}

.batch-scope-pill {
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
}

.batch-scope-pill.gra {
  background: rgba(37, 99, 235, 0.12);
  color: #2563eb;
  border: 1px solid rgba(37, 99, 235, 0.25);
}

.batch-scope-pill.lr {
  background: rgba(217, 119, 6, 0.12);
  color: #d97706;
  border: 1px solid rgba(217, 119, 6, 0.25);
}

.batch-scope-pill.cc {
  background: rgba(124, 58, 237, 0.12);
  color: #7c3aed;
  border: 1px solid rgba(124, 58, 237, 0.25);
}

.batch-scope-pill.tr {
  background: rgba(8, 145, 178, 0.12);
  color: #0891b2;
  border: 1px solid rgba(8, 145, 178, 0.25);
}

body.theme-dark .batch-scope-pill.gra {
  color: #60a5fa;
}

body.theme-dark .batch-scope-pill.lr {
  color: #fbbf24;
}

body.theme-dark .batch-scope-pill.cc {
  color: #a78bfa;
}

body.theme-dark .batch-scope-pill.tr {
  color: #38bdf8;
}

#batchHighlightModal .studio-modal-dialog {
  max-width: 860px;
  max-height: 90vh;
}

.batch-actions-bar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 12px;
  padding-bottom: 4px;
  border-top: 1px solid var(--border);
  position: sticky;
  bottom: 0;
  background: var(--surface, #ffffff);
  z-index: 5;
}

body.theme-dark .batch-actions-bar {
  background: #0f172a;
}

.batch-start-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* Progress View */
.batch-progress-box {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.batch-progress-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.batch-progress-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 14px;
}

.batch-spinner-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--primary);
  animation: pulse-dot 1.2s infinite ease-in-out;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 0.3; transform: scale(0.85); }
  50% { opacity: 1; transform: scale(1.15); }
}

.batch-progress-pct {
  font-weight: 700;
  font-size: 15px;
  color: var(--primary);
}

.batch-progress-bar-wrap {
  width: 100%;
  height: 8px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
}

.batch-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #0284c7, #10b981);
  border-radius: 999px;
  transition: width 0.3s ease;
}

.batch-current-essay-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.batch-essay-icon {
  font-size: 22px;
}

.batch-essay-student {
  font-weight: 600;
  font-size: 13.5px;
  color: var(--foreground);
}

.batch-essay-subtext {
  font-size: 12px;
  color: var(--muted);
}

.batch-live-metrics-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

@media (max-width: 640px) {
  .batch-live-metrics-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.batch-metric-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 12px 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  text-align: center;
}

.batch-metric-box .metric-val {
  font-size: 20px;
  font-weight: 700;
  color: var(--primary);
}

.batch-metric-box .metric-lbl {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
}

.batch-control-actions {
  display: flex;
  justify-content: flex-end;
  padding-top: 10px;
}

/* Complete View */
.batch-complete-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 24px 16px;
  gap: 12px;
}

.batch-complete-icon {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: #dcfce7;
  color: #166534;
  font-size: 26px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

body.theme-dark .batch-complete-icon {
  background: rgba(16, 185, 129, 0.2);
  color: #34d399;
}

.batch-complete-stats {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  justify-content: center;
  margin: 12px 0;
}

@media print {
  header, .sidebar, .workspace-resize-handle, .editor-tools, .feedback-reference, .feedback-popover, .instructions-modal, .studio-modal, .active-submission-banner, .app-footer { display: none !important; }
  main { display: block; padding: 0; }
  .canvas { border: 0; box-shadow: none; }
}
