/* ============================================================
   exams.design — App Stylesheet v3
   Matches React design reference. Indigo accent, cool grays.
   ============================================================ */

:root {
  --bg: #f6f7f9;
  --sidebar-bg: #12151c;
  --sidebar-hover: #1c2029;
  --sidebar-active: #252a35;
  --card: #ffffff;
  --border: #e2e5eb;
  --border-light: #eef0f4;
  --text: #1a1d26;
  --text-muted: #6b7186;
  --text-faint: #9ca3b8;
  --accent: #4f5de6;
  --accent-light: #eef0ff;
  --accent-dark: #3d49c7;
  --green: #15803d;
  --green-bg: #e6f9ed;
  --amber: #b45309;
  --amber-bg: #fef3e2;
  --blue: #1a56db;
  --blue-bg: #e8f0fe;
  --purple: #7c3aed;
  --purple-bg: #f3e8ff;
  --danger: #ef4444;
  --danger-bg: #fef2f2;
  --radius: 10px;
  --radius-lg: 14px;
  --font: 'DM Sans', 'Segoe UI', sans-serif;
  --font-display: 'DM Sans', 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'DM Mono', 'Fira Code', monospace;
  --shadow-xs: 0 1px 2px rgba(0,0,0,0.04);
  --shadow-card: 0 1px 3px rgba(0,0,0,0.04), 0 4px 12px rgba(0,0,0,0.02);
  --shadow-lg: 0 4px 20px rgba(0,0,0,0.1);
  --transition: 0.15s ease;
}

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  height: 100vh;
}

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.12); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,0.2); }

/* ── LAYOUT ── */
.app-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  grid-template-rows: 1fr;
  height: 100vh;
}
.app-layout.preview-mode {
  grid-template-columns: 1fr;
}

/* ── TOPBAR ── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 28px;
  border-bottom: 1px solid var(--border-light);
  background: #fff;
  flex-shrink: 0;
  gap: 12px;
}
.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.topbar-logo {
  display: none;
}
.topbar-sep { display: none; }
.topbar-title { display: none; }
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* ── VIEW TOGGLE ── */
.view-toggle {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--bg);
  border-radius: var(--radius);
  padding: 3px;
}
.view-toggle .tab {
  padding: 7px 16px;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
  background: transparent;
  font-family: var(--font);
  white-space: nowrap;
}
.view-toggle .tab:hover { background: var(--accent-light); }
.view-toggle .tab.active {
  background: var(--accent);
  color: #fff;
  box-shadow: none;
}

/* ── BUTTONS ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  transition: all var(--transition);
  cursor: pointer;
  border: 1px solid var(--border);
  font-family: var(--font);
  white-space: nowrap;
  background: #fff;
  color: var(--text);
  box-shadow: var(--shadow-xs);
}
.btn svg { flex-shrink: 0; }
.btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-xs { padding: 3px 8px; font-size: 11px; border-radius: 6px; }
.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: #fff;
  border: none;
  box-shadow: 0 2px 8px rgba(79,93,230,0.3);
  padding: 8px 18px;
}
.btn-primary:hover {
  box-shadow: 0 4px 14px rgba(79,93,230,0.4);
  transform: translateY(-1px);
  color: #fff;
}
.btn-secondary {
  background: #fff;
  color: var(--text);
  border-color: var(--border);
}
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }
.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: transparent;
  box-shadow: none;
}
.btn-ghost:hover { background: var(--accent-light); color: var(--accent); }
.btn-success { background: var(--green); color: #fff; border-color: var(--green); }
.btn-sidebar {
  background: rgba(255,255,255,0.05);
  color: var(--text-faint);
  border: 1px solid rgba(255,255,255,0.08);
  width: 100%;
  justify-content: center;
  font-size: 12px;
  box-shadow: none;
}
.btn-sidebar:hover { background: rgba(255,255,255,0.1); color: #fff; }

/* ── SIDEBAR ── */
.sidebar {
  grid-row: 1 / -1;
  background: var(--sidebar-bg);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  height: 100vh;
  border-right: 1px solid rgba(255,255,255,0.06);
}

/* Sidebar logo block */
.sidebar-brand {
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  display: flex;
  align-items: center;
  gap: 10px;
}
.sidebar-brand-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  flex-shrink: 0;
}
.sidebar-brand-text {
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.2;
}
.sidebar-brand-sub {
  color: var(--text-faint);
  font-size: 11px;
  margin-top: 1px;
}

.sidebar-section { padding: 12px 12px 4px; }
.sidebar-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--text-faint);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 8px 12px;
  margin-bottom: 4px;
}
.sidebar-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--text-faint);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.12s;
  user-select: none;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
  font-family: var(--font);
}
.sidebar-item:hover { background: var(--sidebar-hover); color: #fff; }
.sidebar-item.active { background: var(--sidebar-active); color: #fff; }
.sidebar-item .item-icon {
  width: 16px; height: 16px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; opacity: 0.6;
}
.sidebar-item.active .item-icon { opacity: 1; }
.sidebar-item .item-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-item .item-count {
  background: rgba(255,255,255,0.08);
  color: var(--text-faint);
  font-size: 11px;
  font-weight: 600;
  padding: 1px 8px;
  border-radius: 99px;
  font-family: var(--font-mono);
}
.sidebar-item .item-actions { display: none; gap: 2px; }
.sidebar-item:hover .item-actions { display: flex; }
.sidebar-item:hover .item-count { display: none; }
.sidebar-item .item-action-btn {
  background: none; border: none;
  color: rgba(255,255,255,0.3);
  cursor: pointer; padding: 2px 3px;
  border-radius: 3px; display: flex; align-items: center;
}
.sidebar-item .item-action-btn:hover { color: #fff; background: rgba(255,255,255,0.12); }
.sidebar-fill { flex: 1; }
.sidebar-footer {
  padding: 10px;
  border-top: 1px solid rgba(255,255,255,0.06);
}

/* ── SIDEBAR QUESTIONS ── */
.section-questions { padding: 0 12px 4px 20px; }
.q-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px 6px 12px;
  border-radius: 6px;
  border-left: 2px solid transparent;
  color: rgba(255,255,255,0.6);
  cursor: pointer;
  font-size: 12px;
  transition: all 0.12s;
  border-top: none; border-right: none; border-bottom: none;
  background: none;
  width: 100%;
  text-align: left;
  font-family: var(--font);
}
.q-item:hover {
  background: var(--sidebar-hover);
  border-left-color: var(--accent);
  color: rgba(255,255,255,0.85);
}
.q-item.active {
  background: rgba(79,93,230,0.15);
  border-left-color: var(--accent);
  color: #fff;
}
.q-item .q-num {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-faint);
  min-width: 18px;
}
.q-item .q-type {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.03em;
  line-height: 20px;
  white-space: nowrap;
  font-family: var(--font);
  flex-shrink: 0;
}
/* Type badge colors - set via JS data attributes */
.q-type-mc { background: var(--blue-bg); color: var(--blue); }
.q-type-multi { background: var(--blue-bg); color: var(--blue); }
.q-type-tf { background: var(--amber-bg); color: var(--amber); }
.q-type-short { background: var(--green-bg); color: var(--green); }
.q-type-essay { background: var(--purple-bg); color: var(--purple); }
.q-type-fill { background: var(--amber-bg); color: var(--amber); }
.q-type-matching { background: var(--green-bg); color: var(--green); }
.q-type-ordering { background: var(--green-bg); color: var(--green); }
.q-type-diagram { background: var(--purple-bg); color: var(--purple); }
.q-type-math { background: var(--blue-bg); color: var(--blue); }
.q-type-calculation { background: var(--blue-bg); color: var(--blue); }

.q-item .q-text {
  flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ── MAIN CONTENT ── */
.main-wrapper {
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}
.preview-mode .main-wrapper {
  grid-column: 1;
}
.main {
  flex: 1;
  overflow-y: auto;
  padding: 24px 32px 40px;
  background: var(--bg);
}

/* ── PANELS / CARDS ── */
.panel {
  background: var(--card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-light);
  padding: 24px 28px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-card);
}
.panel-header {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0;
  border-bottom: none;
}
.panel-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}
.panel-body { padding: 0; }
.panel-body-flush { padding: 0; }

/* ── FORMS ── */
.form-group { margin-bottom: 16px; }
.form-group:last-child { margin-bottom: 0; }
.form-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 6px;
}
.form-hint { font-size: 11px; color: var(--text-faint); margin-top: 4px; }
.form-row { display: flex; gap: 16px; margin-top: 16px; }
.form-row > * { flex: 1; min-width: 0; }
.form-row-3 { display: flex; gap: 16px; margin-top: 16px; }
.form-row-3 > * { flex: 1; min-width: 0; }

input[type="text"], input[type="number"], input[type="url"],
textarea, select {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: var(--font);
  color: var(--text);
  background: #fff;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
  line-height: 1.4;
}
input:focus, textarea:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}
input::placeholder, textarea::placeholder { color: var(--text-faint); }
textarea { resize: vertical; min-height: 72px; line-height: 1.6; }
select { cursor: pointer; }

/* ── RICH EDITOR ── */
.rich-editor {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.rich-editor:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}
.rich-content {
  min-height: 88px;
  padding: 12px 14px;
  outline: none;
  font-size: 14px;
  line-height: 1.6;
}
.rich-content[dir="rtl"] {
  direction: rtl; text-align: right;
  font-family: 'Amiri', 'Traditional Arabic', var(--font);
}
.rich-content:empty::before {
  content: attr(data-placeholder);
  color: var(--text-faint);
  pointer-events: none;
}

/* ── QUESTION TYPE PICKER ── */
.qtype-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(138px, 1fr));
  gap: 8px;
}
.qtype-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 14px 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--transition);
  background: #fff;
  text-align: center;
  font-family: var(--font);
}
.qtype-card:hover {
  border-color: var(--accent);
  background: var(--accent-light);
}
.qtype-icon {
  font-size: 11px;
  font-weight: 700;
  font-family: var(--font-mono);
  letter-spacing: 0.04em;
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 99px;
  line-height: 20px;
  margin-bottom: 4px;
}
.qtype-name { font-size: 12px; font-weight: 600; color: var(--text); line-height: 1.3; }
.qtype-desc { font-size: 10px; color: var(--text-faint); line-height: 1.3; }

/* ── OPTIONS LIST ── */
.options-list { display: flex; flex-direction: column; gap: 8px; }
.option-row { display: flex; align-items: center; gap: 10px; }
.option-letter {
  width: 28px; height: 28px; border-radius: 50%;
  border: 2px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; color: var(--text-faint);
  cursor: pointer; transition: all var(--transition); flex-shrink: 0;
}
.option-letter.correct {
  border-color: var(--accent);
  background: var(--accent-light);
  color: var(--accent);
}
.option-row input[type="text"] { flex: 1; }
.option-remove {
  background: none; border: none; color: var(--text-faint);
  cursor: pointer; padding: 4px; border-radius: 6px;
  display: flex; align-items: center; transition: all var(--transition);
}
.option-remove:hover { color: var(--danger); background: var(--danger-bg); }

/* ── MATCHING PAIRS ── */
.match-row {
  display: grid; grid-template-columns: 1fr auto 1fr auto;
  gap: 10px; align-items: center; margin-bottom: 8px;
}
.match-arrow { color: var(--text-faint); font-size: 14px; }

/* ── TAGS ── */
.tag {
  display: inline-flex; align-items: center;
  padding: 2px 10px; border-radius: 99px;
  font-size: 11px; font-weight: 600; letter-spacing: 0.02em;
}
.tag-easy { background: var(--green-bg); color: var(--green); }
.tag-medium { background: var(--amber-bg); color: var(--amber); }
.tag-hard { background: var(--danger-bg); color: var(--danger); }
.tag-bloom { color: #fff; }

/* ── BLOOM'S BAR ── */
.bloom-bar {
  display: flex; height: 8px; border-radius: 6px; overflow: hidden;
  background: rgba(255,255,255,0.06); margin-top: 8px;
}
.bloom-bar .bloom-seg { transition: width 0.3s; }
.bloom-remember { background: #4f5de6; }
.bloom-understand { background: #22c55e; }
.bloom-apply { background: #f59e0b; }
.bloom-analyze { background: #f97316; }
.bloom-evaluate { background: #ef4444; }
.bloom-create { background: #a855f7; }
.bloom-legend { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 8px; }
.bloom-legend-item { display: flex; align-items: center; gap: 4px; font-size: 10px; color: var(--text-faint); }
.bloom-legend-dot { width: 6px; height: 6px; border-radius: 2px; }

/* ── SIDEBAR STATS ── */
.sidebar-stats-grid {
  display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin-bottom: 16px;
}
.sidebar-stat-card {
  background: rgba(255,255,255,0.04);
  border-radius: 8px; padding: 10px 8px; text-align: center;
}
.sidebar-stat-value {
  color: #fff; font-size: 18px; font-weight: 700;
  font-family: var(--font-mono); line-height: 1;
}
.sidebar-stat-label {
  color: var(--text-faint); font-size: 10px; margin-top: 4px; font-weight: 500;
}

/* ── UPLOAD ZONES ── */
.img-upload-zone {
  border: 1.5px dashed var(--border);
  border-radius: var(--radius);
  padding: 20px; text-align: center;
  cursor: pointer; transition: all var(--transition);
  color: var(--text-muted); font-size: 13px;
}
.img-upload-zone:hover { border-color: var(--accent); background: var(--accent-light); }
.img-upload-zone.has-image { border-style: solid; border-color: var(--green); }
.img-upload-zone img { max-width: 100%; max-height: 180px; border-radius: 8px; }
.upload-placeholder {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  color: var(--text-muted);
}

/* ── LaTeX ── */
.katex-inline {
  background: var(--accent-light);
  padding: 2px 6px; border-radius: 4px; font-size: 0.92em;
}

/* ── DRAG HANDLE ── */
.drag-handle { cursor: grab; color: var(--text-faint); opacity: 0.5; padding: 3px 2px; }

/* ── TOAST ── */
.toast {
  position: fixed; bottom: 20px; right: 20px;
  background: var(--sidebar-bg); color: #fff;
  padding: 10px 16px; border-radius: 10px;
  font-size: 13px; box-shadow: var(--shadow-lg);
  z-index: 300; transform: translateY(60px); opacity: 0;
  transition: all 0.25s ease;
}
.toast.show { transform: translateY(0); opacity: 1; }

/* ── MODAL ── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.35);
  z-index: 200; display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none; transition: opacity 0.2s;
  backdrop-filter: blur(2px);
}
.modal-overlay.open { opacity: 1; pointer-events: auto; }
.modal {
  background: var(--card); border-radius: 16px;
  box-shadow: var(--shadow-lg); max-width: 540px; width: 92%;
  max-height: 85vh; overflow-y: auto;
  transform: translateY(6px) scale(0.98); transition: transform 0.2s;
}
.modal-overlay.open .modal { transform: translateY(0) scale(1); }
.modal-header {
  padding: 16px 24px; border-bottom: 1px solid var(--border-light);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-header h3 { font-size: 16px; font-weight: 700; }
.modal-body { padding: 24px; }
.modal-footer {
  padding: 14px 24px; border-top: 1px solid var(--border-light);
  display: flex; align-items: center; justify-content: flex-end; gap: 8px;
}

/* ── EQUATION MODAL ── */
.eq-preview {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; text-align: center;
  min-height: 56px; display: flex; align-items: center; justify-content: center;
  margin-bottom: 12px; font-size: 1.2rem;
}
.eq-input { font-family: var(--font-mono); font-size: 13px; }
.eq-shortcuts { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.eq-shortcut {
  padding: 4px 8px; border: 1px solid var(--border); border-radius: 6px;
  font-family: var(--font-mono); font-size: 12px; cursor: pointer;
  background: #fff; color: var(--text-muted); transition: all var(--transition);
}
.eq-shortcut:hover { background: var(--accent-light); border-color: var(--accent); color: var(--accent); }

/* ── PREVIEW / EXAM SHEET ── */
.preview-container { max-width: 860px; margin: 0 auto; }
.exam-preview {
  background: #fff; box-shadow: var(--shadow-lg);
  padding: 56px 60px; min-height: 1056px;
  font-size: 11pt; line-height: 1.5;
  font-family: 'Times New Roman', 'Amiri', serif;
  color: #000; border-radius: 4px;
}
.exam-preview .exam-header-block { text-align: center; margin-bottom: 22px; padding-bottom: 14px; border-bottom: 1.5px solid #000; }
.exam-preview .exam-institution { font-size: 13pt; font-weight: 700; margin-bottom: 1px; }
.exam-preview .exam-dept { font-size: 10pt; color: #333; margin-bottom: 8px; }
.exam-preview .exam-title-main { font-size: 15pt; font-weight: 700; margin-bottom: 3px; }
.exam-preview .exam-meta-row { display: flex; justify-content: space-between; font-size: 9.5pt; margin-top: 8px; color: #444; }
.exam-preview .exam-student-info { display: grid; grid-template-columns: 1fr 1fr; gap: 5px 20px; margin: 12px 0; font-size: 10pt; }
.exam-preview .info-field { display: flex; gap: 4px; }
.exam-preview .info-field-label { font-weight: 700; white-space: nowrap; }
.exam-preview .info-field-line { flex: 1; border-bottom: 1px solid #999; min-width: 100px; }
.exam-preview .exam-instructions { background: #f8f8f5; border: 1px solid #ddd; border-radius: 4px; padding: 8px 12px; margin: 12px 0; font-size: 9.5pt; line-height: 1.5; }
.exam-preview .exam-instructions strong { display: block; margin-bottom: 3px; }
.exam-preview .section-header { font-size: 12pt; font-weight: 700; margin: 20px 0 8px; padding-bottom: 3px; border-bottom: 1px solid #ccc; }
.exam-preview .section-desc { font-size: 9.5pt; color: #555; font-style: italic; margin-bottom: 8px; }
.exam-preview .question-block { margin-bottom: 14px; page-break-inside: avoid; }
.exam-preview .q-stem { font-weight: 500; margin-bottom: 5px; }
.exam-preview .q-stem .q-number { font-weight: 700; }
.exam-preview .q-stem .q-points { float: right; font-size: 9pt; color: #666; font-weight: 400; }
.exam-preview .q-options { padding-left: 22px; margin-top: 3px; }
.exam-preview .q-option { margin-bottom: 2px; display: flex; gap: 5px; }
.exam-preview .q-option-letter { font-weight: 700; min-width: 16px; }
.exam-preview .q-answer-lines { margin-top: 6px; margin-left: 20px; }
.exam-preview .answer-line { border-bottom: 1px solid #ccc; height: 26px; margin-bottom: 1px; }
.exam-preview .q-match-table { width: 100%; border-collapse: collapse; margin-top: 5px; font-size: 10pt; }
.exam-preview .q-match-table th, .exam-preview .q-match-table td { border: 1px solid #aaa; padding: 4px 8px; text-align: left; }
.exam-preview .q-match-table th { background: #f0f0ea; font-weight: 700; }
.exam-preview .q-ordering-list { list-style: none; padding: 0; margin-top: 5px; }
.exam-preview .q-ordering-list li { padding: 4px 10px; border: 1px solid #ccc; margin-bottom: 2px; background: #fafaf8; font-size: 10pt; }
.exam-preview .q-tf-options { padding-left: 22px; margin-top: 3px; }

/* ── ANSWER KEY ── */
.answer-key .ak-item { margin-bottom: 8px; padding-bottom: 6px; border-bottom: 1px dotted #ddd; }
.answer-key .ak-item:last-child { border-bottom: none; }
.answer-key .ak-num { font-weight: 700; }
.answer-key .ak-answer { color: var(--green); font-weight: 600; }
.answer-key .ak-explanation { font-size: 9.5pt; color: #555; margin-top: 3px; display: flex; align-items: flex-start; gap: 5px; }
.answer-key .ak-explanation svg { flex-shrink: 0; margin-top: 2px; opacity: 0.45; }

/* ── PRINT ── */
@media print {
  body { overflow: visible; height: auto; background: #fff; }
  .app-layout { display: block; }
  .topbar, .sidebar { display: none !important; }
  .main-wrapper { display: block; }
  .main { padding: 0; overflow: visible; }
  .preview-container { max-width: none; }
  .exam-preview { box-shadow: none; padding: 0.5in 0.65in; min-height: auto; border-radius: 0; }
  .exam-preview .question-block { page-break-inside: avoid; }
  .no-print { display: none !important; }
  /* Bubble sheet print */
  .bs-layout { display: block; }
  .bs-controls { display: none !important; }
  .bs-preview-wrap > *:not(.bubble-sheet) { display: none !important; }
  .bubble-sheet { box-shadow: none; width: 100%; padding: .4in .5in; border-radius: 0; }
  /* Hide page headers when printing bubble or exam */
  .main > h1, .main > p, .main > div:not(.preview-container):not(.bs-layout) { display: none !important; }
}

/* ── RESPONSIVE ── */
@media (max-width: 900px) {
  .app-layout { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .main { padding: 16px; }
  .exam-preview { padding: 24px 20px; }
  .form-row, .form-row-3 { flex-direction: column; }
}

/* ── AD SLOTS ── */
.ad-banner {
  padding: 8px 28px;
  background: #fff;
  border-bottom: 1px solid var(--border-light);
  text-align: center;
  flex-shrink: 0;
}
.ad-sidebar {
  padding: 8px 10px;
}

/* ── BUBBLE SHEET (integrated) ── */
.bs-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 32px;
  align-items: start;
}
.bs-controls {
  overflow-y: auto;
  max-height: calc(100vh - 160px);
  padding-right: 4px;
}
.bs-controls .panel {
  padding: 20px 24px;
}
.bs-controls .panel-header {
  margin-bottom: 16px;
}
.bs-controls .form-group {
  margin-bottom: 12px;
}
.bs-group-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 10px;
  background: var(--bg);
  transition: border-color 0.15s;
}
.bs-group-card:hover {
  border-color: var(--accent);
}
.bs-group-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.bs-group-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}
.bs-preview-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: sticky;
  top: 0;
}
.bubble-sheet {
  background: #fff;
  width: 7.5in;
  min-height: 10in;
  padding: .5in .6in;
  font-family: 'Courier New', monospace;
  font-size: 9pt;
  box-shadow: 0 4px 24px rgba(0,0,0,.08);
  border-radius: 4px;
  transform-origin: top center;
}
.bs-header { text-align: center; border-bottom: 2px solid #000; padding-bottom: 10px; margin-bottom: 12px; }
.bs-title { font-size: 14pt; font-weight: 700; }
.bs-subtitle { font-size: 9pt; color: #555; margin-top: 2px; }
.bs-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 20px; margin: 10px 0; font-size: 9pt; }
.bs-field { display: flex; gap: 4px; align-items: baseline; }
.bs-field-label { font-weight: 700; white-space: nowrap; }
.bs-field-line { flex: 1; border-bottom: 1px solid #999; min-width: 100px; }
.bs-instructions { font-size: 8pt; color: #555; margin: 8px 0 12px; padding: 6px 8px; border: 1px solid #ddd; background: #fafaf8; border-radius: 3px; }
.bs-grid { display: flex; flex-wrap: wrap; gap: 0; }
.bs-column { flex: 1; min-width: 0; }
.bs-question { display: flex; align-items: center; gap: 4px; margin-bottom: 3px; padding: 1px 0; }
.bs-qnum { width: 24px; text-align: right; font-size: 8pt; font-weight: 700; color: #333; }
.bs-bubbles { display: flex; gap: 3px; }
.bs-bubble { width: 14px; height: 14px; border: 1.5px solid #333; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 6.5pt; font-weight: 700; color: #333; }
.bs-bubble.square { border-radius: 2px; }
.bs-separator { width: 1px; background: #ddd; margin: 0 8px; align-self: stretch; }
.bs-footer { text-align: center; font-size: 7pt; color: #999; margin-top: 12px; padding-top: 8px; border-top: 1px solid #ddd; }
.bs-bubble-tf { width: 20px; font-size: 7pt; }

/* Scale bubble sheet preview to fit */
@media (max-width: 1600px) {
  .bubble-sheet { transform: scale(0.85); }
}
@media (max-width: 1300px) {
  .bubble-sheet { transform: scale(0.7); }
}
@media (max-width: 1100px) {
  .bs-layout { grid-template-columns: 1fr; }
  .bs-controls { max-height: none; }
  .bubble-sheet { transform: none; }
}

/* ── AI GENERATION ── */
.ai-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  align-items: start;
}
.ai-left, .ai-right { min-width: 0; }
.ai-upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 32px 24px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
}
.ai-upload-zone:hover, .ai-upload-zone.dragover {
  border-color: var(--accent);
  background: var(--accent-light);
}
.ai-upload-prompt { color: var(--text-faint); }
.ai-file-loaded { color: var(--text); }
.ai-spinner {
  display: inline-block;
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: ai-spin 0.6s linear infinite;
}
@keyframes ai-spin { to { transform: rotate(360deg); } }

@media (max-width: 1000px) {
  .ai-layout { grid-template-columns: 1fr; }
}

/* ── AUTH / PROFILE / PRICING ── */
.auth-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 12px; font-weight: 700;
  flex-shrink: 0;
}
.profile-avatar {
  width: 64px; height: 64px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 28px; font-weight: 700;
  flex-shrink: 0;
}
.profile-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
.stat-row {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 10px 0; border-bottom: 1px solid var(--border-light);
  font-size: 13px; color: var(--text-muted);
}
.stat-row:last-child { border-bottom: none; }
.stat-row b { color: var(--text); font-weight: 700; font-family: var(--font-mono); font-size: 14px; }

.tier-badge {
  display: inline-block; padding: 3px 12px; border-radius: 99px;
  font-size: 11px; font-weight: 700; letter-spacing: 0.04em;
}
.tier-free { background: var(--border-light); color: var(--text-muted); }
.tier-pro { background: var(--accent-light); color: var(--accent); }
.tier-premium { background: linear-gradient(135deg, #fde68a, #f59e0b); color: #78350f; }

.progress-bar {
  height: 8px; background: var(--border-light); border-radius: 99px;
  overflow: hidden;
}
.progress-fill {
  height: 100%; transition: width 0.3s, background 0.3s;
  border-radius: 99px;
}

.pricing-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}
.pricing-card {
  background: var(--card);
  border: 1px solid var(--border-light);
  border-radius: 16px;
  padding: 32px 24px;
  position: relative;
  transition: transform 0.2s, box-shadow 0.2s;
}
.pricing-card.featured {
  border: 2px solid var(--accent);
  box-shadow: 0 8px 32px rgba(79,93,230,0.12);
  transform: translateY(-4px);
}
.pricing-card.current {
  border-color: var(--green);
  background: #f0fdf4;
}
.pricing-badge {
  position: absolute; top: -12px; left: 50%; transform: translateX(-50%);
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: #fff; font-size: 11px; font-weight: 700;
  padding: 4px 14px; border-radius: 99px;
  letter-spacing: 0.04em;
}
.pricing-name {
  font-size: 18px; font-weight: 700; color: var(--text);
  margin-bottom: 8px;
}
.pricing-price {
  display: flex; align-items: baseline; gap: 2px;
  margin-bottom: 4px;
}
.pricing-currency { font-size: 18px; color: var(--text-muted); font-weight: 600; }
.pricing-amount { font-size: 42px; font-weight: 800; color: var(--text); line-height: 1; font-family: var(--font); }
.pricing-period { font-size: 14px; color: var(--text-muted); margin-left: 4px; }
.pricing-yearly { font-size: 12px; color: var(--text-faint); margin-bottom: 20px; min-height: 16px; }
.pricing-features {
  list-style: none; padding: 20px 0; margin: 0;
  border-top: 1px solid var(--border-light);
}
.pricing-features li {
  display: flex; align-items: flex-start; gap: 8px;
  padding: 6px 0; font-size: 13px; color: var(--text); line-height: 1.5;
}
.pricing-features li svg { flex-shrink: 0; margin-top: 3px; }
.pricing-cta { margin-top: 20px; }

@media (max-width: 900px) {
  .pricing-grid { grid-template-columns: 1fr; }
  .profile-grid { grid-template-columns: 1fr; }
}

/* ── MULTI-PDF UPLOAD LIST ── */
.ai-file-list {
  display: flex; flex-direction: column; gap: 8px;
  margin-top: 12px;
}
.ai-file-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; background: var(--bg);
  border: 1px solid var(--border-light); border-radius: 10px;
}
.ai-file-item-icon {
  width: 32px; height: 32px; border-radius: 8px;
  background: var(--accent-light); color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.ai-file-item-info { flex: 1; min-width: 0; }
.ai-file-item-name { font-size: 13px; font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ai-file-item-meta { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
