/* ==========================================
   PENJANA KERTAS PEPERIKSAAN SPM 5401/1
   ========================================== */
:root {
  --bg-main: #0f172a;
  --bg-surface: #1e293b;
  --bg-surface-hover: #334155;
  --bg-input: #0f172a;
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent: #6366f1;
  --accent-hover: #818cf8;
  --accent-glow: rgba(99, 102, 241, 0.3);
  --border: #334155;
  --border-focus: #6366f1;
  --success: #22c55e;
  --success-bg: rgba(34, 197, 94, 0.15);
  --sidebar-width: 380px;
  --toolbar-height: 60px;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

@media (max-width: 1200px) {
  :root {
    --sidebar-width: 300px;
  }
}

@media (max-width: 1024px) {
  :root {
    --sidebar-width: 260px;
  }
}

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

body {
  font-family:
    "Inter",
    -apple-system,
    BlinkMacSystemFont,
    sans-serif;
  background: var(--bg-main);
  color: var(--text-primary);
  overflow-x: hidden;
  min-height: 100vh;
}

/* ── Arabic ── */
.arabic-select {
  font-family: "Noto Naskh Arabic", serif;
  direction: rtl;
  text-align: right;
}

/* ============ SIDEBAR ============ */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: var(--transition);
  overflow: hidden;
}

.sidebar-header {
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.1), transparent);
  flex-shrink: 0;
}

/* Scrollable middle area */
.sidebar-body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-body::-webkit-scrollbar {
  width: 4px;
}

.sidebar-body::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar-body::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 10px;
}

.sidebar-title {
  font-size: 1.2rem;
  font-weight: 800;
  background: linear-gradient(135deg, #818cf8, #6366f1);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.sidebar-subtitle {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

.sidebar-section {
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
}

.section-label {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 8px;
}

/* ── Toggle Switches ── */
.toggle-switch {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  padding: 4px 0;
  user-select: none;
}

.toggle-switch input[type="checkbox"] {
  display: none;
}

.toggle-slider {
  position: relative;
  width: 34px;
  height: 18px;
  background: var(--border);
  border-radius: 999px;
  transition: var(--transition);
  flex-shrink: 0;
}

.toggle-slider::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  background: white;
  border-radius: 50%;
  transition: var(--transition);
}

.toggle-switch input:checked+.toggle-slider {
  background: var(--accent);
}

.toggle-switch input:checked+.toggle-slider::after {
  left: 18px;
}

.toggle-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

/* ── Global Controls (always visible) ── */
.sidebar-global {
  padding: 8px 20px;
  border-bottom: 1px solid var(--border);
  background: rgba(99, 102, 241, 0.05);
  flex-shrink: 0;
}

.sidebar-global .toggle-switch {
  padding: 3px 0;
}

/* ── Accordion ── */
.accordion-item {
  border-bottom: 1px solid var(--border);
}

.accordion-divider {
  padding: 6px 16px;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.03);
  border-bottom: 1px solid var(--border);
  user-select: none;
  display: flex;
  align-items: center;
  gap: 8px;
}

.accordion-divider span {
  font-family: "Noto Naskh Arabic", serif;
  font-size: 0.9rem;
  opacity: 0.5;
}

.accordion-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  cursor: pointer;
  user-select: none;
  transition: var(--transition);
}

.accordion-header:hover {
  background: var(--bg-surface-hover);
}

.accordion-item.active>.accordion-header {
  background: rgba(99, 102, 241, 0.08);
}

.accordion-icon {
  font-family: "Noto Naskh Arabic", serif;
  font-size: 1.1rem;
  font-weight: 700;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  background: rgba(99, 102, 241, 0.15);
  color: var(--accent-hover);
  flex-shrink: 0;
}

/* Color-coded icons per section */
.accordion-item[data-section="cover"] .accordion-icon {
  background: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
}

.accordion-item[data-section="alif"] .accordion-icon {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
}

.accordion-item[data-section="soal1"] .accordion-icon {
  background: rgba(34, 197, 94, 0.15);
  color: #4ade80;
}

.accordion-item[data-section="soal2"] .accordion-icon {
  background: rgba(168, 85, 247, 0.15);
  color: #c084fc;
}

.accordion-item[data-section="soal3"] .accordion-icon {
  background: rgba(236, 72, 153, 0.15);
  color: #f472b6;
}

.accordion-item[data-section="soal4"] .accordion-icon {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
}

.accordion-title {
  flex: 1;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-primary);
}

.accordion-subtitle {
  font-family: "Noto Naskh Arabic", serif;
  font-size: 0.7rem;
  font-weight: 400;
  color: var(--text-muted);
  margin-left: 4px;
}

.accordion-badge {
  font-size: 0.6rem;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--bg-input);
  color: var(--text-muted);
  border: 1px solid var(--border);
  min-width: 20px;
  text-align: center;
}

.accordion-item.active .accordion-badge {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.accordion-chevron {
  flex-shrink: 0;
  color: var(--text-muted);
  transition: transform 0.25s ease;
}

.accordion-item.active>.accordion-header .accordion-chevron {
  transform: rotate(180deg);
}

.accordion-body {
  display: none;
  padding: 0 16px;
}

.accordion-item.active>.accordion-body {
  display: block;
  overflow-y: auto;
  padding: 8px 16px 12px;
  max-height: 500px;
}

.accordion-body::-webkit-scrollbar {
  width: 4px;
}

.accordion-body::-webkit-scrollbar-track {
  background: transparent;
}

.accordion-body::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 10px;
}

/* Soal-specific filters inside accordion */
.soal-filters {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 8px;
}

.soal-filters .input-field {
  margin-bottom: 0;
  font-size: 0.75rem;
  padding: 5px 8px;
}

.soal-questions-list {
  max-height: 300px;
  overflow-y: auto;
}

/* ── Inputs ── */
.input-field {
  width: 100%;
  padding: 7px 10px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.8rem;
  transition: var(--transition);
  margin-bottom: 6px;
  outline: none;
}

.input-field:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.input-field::placeholder {
  color: var(--text-muted);
}

select.input-field {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  padding-right: 28px;
}

.input-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

/* ── Questions List ── */
.questions-list-section {
  overflow: hidden;
  display: flex;
  flex-direction: column;
  border-bottom: none;
  min-height: 150px;
}

.questions-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.badge {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--bg-input);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.badge-accent {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.questions-list {
  flex: 1;
  overflow-y: auto;
  padding-right: 4px;
}

.questions-list::-webkit-scrollbar {
  width: 4px;
}

.questions-list::-webkit-scrollbar-track {
  background: transparent;
}

.questions-list::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 10px;
}

.question-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  margin-bottom: 3px;
  border: 1px solid transparent;
}

.question-item:hover {
  background: var(--bg-surface-hover);
  border-color: var(--border);
}

.question-item.selected {
  background: var(--success-bg);
  border-color: var(--success);
}

.question-item input[type="checkbox"] {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  margin-top: 4px;
  accent-color: var(--success);
  cursor: pointer;
}

.question-item-content {
  flex: 1;
  min-width: 0;
}

.question-item-text {
  font-family: "Noto Naskh Arabic", serif;
  direction: rtl;
  text-align: right;
  font-size: 0.85rem;
  line-height: 1.5;
  color: var(--text-primary);
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.question-item-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 3px;
  font-size: 0.65rem;
  color: var(--text-muted);
}

.question-item-topic {
  font-family: "Noto Naskh Arabic", serif;
  direction: rtl;
  font-size: 0.65rem;
  color: var(--accent-hover);
}

.question-item-controls {
  display: none;
  margin-top: 5px;
  gap: 4px;
  align-items: center;
  flex-wrap: wrap;
}

.question-item.selected .question-item-controls {
  display: flex;
}

.control-select {
  padding: 2px 4px;
  background: var(--bg-input);
  border: 1px solid var(--accent);
  border-radius: 3px;
  color: var(--accent-hover);
  font-family: "Noto Naskh Arabic", serif;
  font-size: 0.7rem;
  cursor: pointer;
  direction: rtl;
  outline: none;
}

.control-label {
  font-size: 0.6rem;
  color: var(--text-muted);
}

/* ── Sidebar Footer ── */
.sidebar-footer {
  padding: 10px 20px;
  border-top: 1px solid var(--border);
  background: var(--bg-surface);
}

.selected-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.btn-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-top: 6px;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 14px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}

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

.btn-primary {
  width: 100%;
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  color: white;
  box-shadow: 0 2px 10px var(--accent-glow);
  margin-bottom: 6px;
}

.btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, #818cf8, #6366f1);
  transform: translateY(-1px);
}

.btn-scheme {
  width: 100%;
  background: linear-gradient(135deg, #22c55e, #16a34a);
  color: white;
}

.btn-scheme:hover:not(:disabled) {
  background: linear-gradient(135deg, #4ade80, #22c55e);
  transform: translateY(-1px);
}

.btn-print {
  background: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.btn-print:hover:not(:disabled) {
  background: var(--bg-surface-hover);
  border-color: var(--accent);
}

.btn-pdf {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  color: white;
}

.btn-pdf:hover:not(:disabled) {
  background: linear-gradient(135deg, #f87171, #ef4444);
}

/* ── Toggle Sidebar (mobile) ── */
.toggle-sidebar-btn {
  display: none;
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 200;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--text-primary);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  box-shadow: var(--shadow);
}

/* ============ MAIN CONTENT ============ */
.main-content {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Sticky wrapper for both toolbars */
.toolbar-wrapper {
  position: sticky;
  top: 0;
  z-index: 50;
}

.toolbar {
  position: relative;
  z-index: 1;
  min-height: var(--toolbar-height);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 24px;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 8px;
}

.toolbar-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
}

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

.toolbar-select {
  padding: 5px 24px 5px 8px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.72rem;
  cursor: pointer;
  outline: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 6px center;
}

/* ============ PAPER ============ */
.paper-container {
  flex: 1;
  display: flex;
  justify-content: center;
  padding: 30px;
  background: var(--bg-main);
}

.paper {
  width: 210mm;
  min-height: 297mm;
  background: #fff;
  color: #000;
  box-shadow: 0 4px 40px rgba(0, 0, 0, 0.5);
  border-radius: 4px;
  overflow: hidden;
}

.paper-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 297mm;
  text-align: center;
  color: #aaa;
  gap: 12px;
  padding: 40px;
}

.paper-empty h3 {
  font-size: 1.2rem;
  font-weight: 700;
  color: #888;
}

.paper-empty p {
  font-size: 0.9rem;
  color: #aaa;
  max-width: 300px;
}

/* ============ COVER PAGE (Kulit Kertas) ============ */
.cover-page {
  padding: 10mm 15mm;
  min-height: 277mm;
  display: flex;
  flex-direction: column;
  page-break-after: always;
  break-after: page;
}

.cover-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 6mm;
}

.cover-sulit {
  font-size: 14pt;
  font-weight: 900;
  letter-spacing: 0.15em;
}

.cover-school-block {
  text-align: center;
  flex: 1;
  padding: 0 10mm;
}

.cover-school-name {
  font-size: 14pt;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.cover-school-sub {
  font-size: 10pt;
  font-weight: 600;
  text-transform: uppercase;
  margin-top: 2px;
}

/* IC and Angka Giliran boxes */
.cover-id-section {
  margin: 6mm 0;
}

.cover-id-row {
  display: flex;
  align-items: center;
  gap: 4mm;
  margin-bottom: 3mm;
  font-size: 10pt;
  font-weight: 600;
}

.cover-id-label {
  min-width: 45mm;
}

.cover-id-boxes {
  display: flex;
  gap: 0;
}

.cover-id-box {
  width: 8mm;
  height: 10mm;
  border: 1.5px solid #000;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12pt;
}

.cover-id-box+.cover-id-box {
  border-left: none;
}

.cover-id-sep {
  width: 3mm;
}

/* Exam info */
.cover-exam-info {
  margin: 6mm 0;
}

.cover-exam-title {
  font-size: 16pt;
  font-weight: 900;
  font-style: italic;
}

.cover-exam-subject {
  font-size: 12pt;
  font-weight: 700;
  text-transform: uppercase;
}

.cover-exam-code {
  font-size: 14pt;
  font-weight: 900;
  float: right;
  margin-top: -30px;
}

.cover-exam-detail {
  font-size: 10pt;
  margin-top: 2px;
}

/* Instructions */
.cover-warning {
  text-align: center;
  font-size: 10pt;
  font-weight: 900;
  font-style: italic;
  margin: 6mm 0 4mm;
  padding: 2mm 0;
  border-top: 2px solid #000;
  border-bottom: 2px solid #000;
  text-transform: uppercase;
}

.cover-instructions {
  font-size: 9pt;
  line-height: 1.8;
}

.cover-instructions ol {
  padding-left: 6mm;
}

.cover-instructions li {
  margin-bottom: 2mm;
}

.cover-footer {
  margin-top: auto;
  text-align: center;
  font-size: 8pt;
  border-top: 1px solid #999;
  padding-top: 3mm;
}

.cover-footer-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 2mm;
  font-size: 10pt;
  font-weight: 700;
}

/* ============ SPM PAPER FORMAT ============ */
.spm-page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8mm 15mm 4mm;
  font-size: 12pt;
  font-weight: 700;
  color: #000;
}

.spm-sulit {
  font-weight: 900;
  letter-spacing: 0.15em;
}

.spm-paper-code {
  font-weight: 900;
}

.spm-section-title {
  text-align: center;
  padding: 6mm 15mm 2mm;
  font-family: "Noto Naskh Arabic", serif;
  direction: rtl;
  page-break-after: avoid;
  break-after: avoid;
}

.spm-qism-label {
  font-size: 22pt;
  font-weight: 700;
}

.spm-total-marks {
  font-size: 14pt;
  font-weight: 600;
  margin-top: 2mm;
}

.spm-soal {
  padding: 6mm 15mm;
  page-break-inside: avoid;
}

.spm-soal-title {
  font-family: "Noto Naskh Arabic", serif;
  font-size: 16pt;
  font-weight: 700;
  direction: rtl;
  text-align: right;
  color: #000;
  margin-bottom: 4mm;
  padding-bottom: 2mm;
  /* No border-bottom — user requested removal */
}

.spm-sub-label {
  font-family: "Noto Naskh Arabic", serif;
  font-size: 14pt;
  font-weight: 700;
  direction: rtl;
  text-align: right;
  color: #000;
  margin: 4mm 5mm 3mm 0;
}

/* ── Question Row: RTL 3-col — [bhg-label RIGHT] [num] [text LEFT] ── */
.spm-question-row {
  display: flex;
  direction: rtl;
  align-items: flex-start;
  gap: 2mm;
  margin-bottom: 0;
  padding: 0;
  width: 100%;
  /* Force full width so flush-right anchors to page margin */
  page-break-inside: avoid;
  break-inside: avoid;
}

/* Bahagian label (أ، ب، ج...) — inline with first question */
.spm-bhg-label {
  font-family: "Noto Naskh Arabic", serif;
  font-size: 14pt;
  font-weight: 700;
  width: 8mm;
  /* Explicit fixed width to match Tafsir exactly */
  flex-shrink: 0;
  line-height: 1.2;
  text-align: right;
  /* Keeps the letter flush right to the edge */
  margin-right: 0;
}

.spm-question-row.no-bhg .spm-bhg-label {
  visibility: hidden;
}

.spm-question-num {
  font-family: "Noto Naskh Arabic", serif;
  font-size: 13pt;
  font-weight: 600;
  flex-shrink: 0;
  line-height: 1.6;
  min-width: 8mm;
  text-align: center;
  direction: ltr;
  /* Keep parentheses correct: (١) not )١( */
  unicode-bidi: isolate;
}

.spm-question-text {
  flex: 1;
  font-family: "Noto Naskh Arabic", serif;
  font-size: 13pt;
  line-height: 1.15;
  color: #000;
  text-align: right;
  padding: 0;
}

.spm-question-translation {
  font-size: 9pt;
  font-style: italic;
  color: #555;
  text-align: left;
  direction: ltr;
  margin: 0 35mm 1mm 0;
}

.spm-answer-lines {
  /* 0mm (row padding) + 0mm (bhg margin) + 8mm (bhg width) + 2mm (gap) + 8mm (num) + 2mm (gap) = 20mm */
  padding: 0 20mm 0 0;
  margin-top: -2mm;
  page-break-inside: avoid;
  break-inside: avoid;
  page-break-before: avoid;
  break-before: avoid;
  position: relative;
}

.spm-answer-line {
  width: 100%;
  height: 7mm;
  border-bottom: 1px solid #333;
}

.spm-marks {
  text-align: left;
  direction: ltr;
  padding: 1mm 0 4mm;
  margin: 0;
  page-break-inside: avoid;
  break-inside: avoid;
  page-break-before: avoid;
  break-before: avoid;
}

/* ── Vocabulary Dropdown Inline Layout ── */
.spm-vocabulary-sublist {
  display: flex;
  flex-direction: column;
  gap: 5mm;
  margin-top: 2mm;
  /* (Row pad 13mm) + (Num 8mm) + (Gap 3mm) = 24mm */
  margin-right: 24mm;
}

.spm-vocabulary-subq {
  display: flex;
  direction: rtl;
  align-items: flex-end;
  /* Bottom align the text with the line and marks */
  page-break-inside: avoid;
  break-inside: avoid;
}

.spm-sub-alif {
  font-weight: 700;
  min-width: 8mm;
  /* Consistent width */
  text-align: right;
}

.spm-inline-word {
  font-weight: 700;
}

.spm-inline-colon {
  font-weight: 700;
  margin-left: 2mm;
}

.spm-answer-line-inline {
  flex: 1;
  /* Stretch the line between the word and the marks */
  border-bottom: 1px solid #333;
  height: 6mm;
  margin: 0 3mm;
}

.spm-marks-inline {
  flex-shrink: 0;
  text-align: left;
  direction: ltr;
}

/* ── Stimulus Box (Kotak Ayat) ── */
.spm-stimulus-container {
  padding: 2mm 0 0;
  direction: rtl;
  page-break-inside: avoid;
  break-inside: avoid;
}

.spm-stimulus-intro-top {
  font-family: "Noto Naskh Arabic", serif;
  font-size: 14pt;
  font-weight: 700;
  text-align: right;
  margin-bottom: 3mm;
  display: flex;
  direction: rtl;
  align-items: baseline;
  gap: 5mm;
  width: 100%;
  /* Force full width */
}

.spm-stimulus-intro-top .spm-bhg-label {
  font-size: 14pt;
  font-weight: 700;
  width: 8mm;
  /* Match fixed width */
  text-align: right;
  flex-shrink: 0;
}

.spm-stimulus-box {
  border: 2pt solid #000;
  padding: 5mm 6mm 3mm;
  margin: 0 13mm 3mm 0;
  /* 8mm (bhg label) + 5mm (gap) = 13mm aligned with قال */
  position: relative;
  min-height: 20mm;
}

.spm-stimulus-verse {
  font-family: "Amiri", "Traditional Arabic", "Scheherazade New", serif;
  font-size: 18pt;
  line-height: 1.9;
  text-align: justify;
  text-align-last: right;
  direction: rtl;
  color: #000;
}

.spm-verse-ref {
  text-align: left;
  font-family: "Noto Naskh Arabic", serif;
  font-size: 11pt;
  font-weight: 600;
  margin-top: 2mm;
  direction: ltr;
}

.spm-stimulus-intro-bottom {
  font-family: "Noto Naskh Arabic", serif;
  font-size: 13pt;
  font-weight: 500;
  text-align: right;
  margin-bottom: 4mm;
  margin-right: 0;
  padding-right: 13mm;
  /* aligned exactly with box right edge & قال */
  line-height: 1.6;
}

/* ── Tafsir question rows (inside spm-soal, no extra padding) ── */
.spm-question-row.tafsir-q {
  /* Box starts at 13mm exact (Aligned with Istinaadan pad 13mm) */
  padding-right: 13mm;
  margin-right: 0;
  gap: 3mm;
  width: auto;
}

.spm-question-row.tafsir-q .spm-question-num {
  text-align: right;
  min-width: 8mm;
  width: 8mm;
  margin-right: 0;
}

.spm-answer-lines.tafsir-q {
  /* 13mm (row pad) + 8mm (num box) + 3mm (gap) = 24mm */
  padding-right: 24mm;
  padding-left: 0;
  margin-top: -2mm;
}

.spm-marks.tafsir-q {
  padding-right: 0;
  padding-left: 0;
}

.spm-marks-badge {
  display: inline;
  font-family: "Noto Naskh Arabic", serif;
  font-size: 10pt;
  font-weight: 600;
  color: #000;
  direction: ltr;
  unicode-bidi: plaintext;
  /* No border — brackets only */
}

.spm-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6mm 15mm;
  font-size: 8pt;
  color: #666;
  border-top: 1px solid #ddd;
  margin-top: 10mm;
}

.spm-end-text {
  text-align: center;
  font-size: 11pt;
  font-weight: 900;
  padding: 6mm 0;
  margin-top: 10mm;
  text-transform: uppercase;
}

/* ============ ANSWER SCHEME ============ */
.scheme-header {
  text-align: center;
  padding: 10mm 15mm 6mm;
  border-bottom: 2px solid #000;
}

.scheme-title {
  font-size: 14pt;
  font-weight: 900;
  text-transform: uppercase;
}

.scheme-subtitle {
  font-size: 12pt;
  font-weight: 700;
  margin-top: 2mm;
}

.scheme-subtitle-arabic {
  font-family: "Noto Naskh Arabic", serif;
  font-size: 16pt;
  font-weight: 700;
  direction: rtl;
  margin-top: 2mm;
}

.scheme-soal {
  padding: 4mm 15mm;
}

.scheme-soal-title {
  font-family: "Noto Naskh Arabic", serif;
  font-size: 14pt;
  font-weight: 700;
  direction: rtl;
  text-align: right;
  margin-bottom: 3mm;
  padding-bottom: 2mm;
  border-bottom: 1px solid #ccc;
}

.scheme-sub-label {
  font-family: "Noto Naskh Arabic", serif;
  font-size: 12pt;
  font-weight: 700;
  direction: rtl;
  text-align: right;
  margin: 3mm 5mm 2mm 0;
}

.scheme-answer-row {
  display: flex;
  direction: rtl;
  gap: 3mm;
  padding: 2mm 5mm;
  margin-bottom: 2mm;
  border-bottom: 1px dotted #ddd;
}

.scheme-answer-num {
  font-family: "Noto Naskh Arabic", serif;
  font-size: 11pt;
  font-weight: 600;
  flex-shrink: 0;
  min-width: 28px;
  text-align: center;
}

.scheme-answer-text {
  font-family: "Noto Naskh Arabic", serif;
  font-size: 14px;
  font-weight: 500;
  direction: rtl;
  text-align: right;
  line-height: 1.8;
  flex: 1;
}

.scheme-answer-marks {
  font-family: "Noto Naskh Arabic", serif;
  font-size: 9pt;
  color: #666;
  flex-shrink: 0;
  min-width: 50px;
  text-align: left;
}

/* ============ QISM ALIF ============ */

/* Forced page break utility */
.page-break {
  page-break-before: always;
  break-before: page;
  display: block;
  height: 0;
}

/* Qism Alif container */
.qism-alif-wrapper {
  max-width: 100%;
  overflow: hidden;
  box-sizing: border-box;
}

.spm-group-header {
  text-align: right;
  font-size: 14pt;
  font-weight: 700;
  margin: 8mm 0 3mm;
  direction: rtl;
  font-family: "Noto Naskh Arabic", serif;
  padding: 0 15mm;
  page-break-after: avoid;
  break-after: avoid;
}

.spm-group-instruction {
  text-align: right;
  font-size: 12pt;
  margin-bottom: 4mm;
  direction: rtl;
  font-family: "Noto Naskh Arabic", serif;
  color: #333;
  padding: 0 15mm;
  page-break-after: avoid;
  break-after: avoid;
}

.spm-word-bank {
  width: calc(100% - 30mm);
  max-width: 100%;
  border-collapse: collapse;
  margin: 4mm 15mm 6mm;
  direction: rtl;
  box-sizing: border-box;
}

.spm-word-bank td {
  border: 1px solid #444;
  padding: 3mm 4mm;
  text-align: center;
  font-family: "Noto Naskh Arabic", serif;
  font-size: 12pt;
}

.spm-mcq-choices {
  text-align: center;
  font-family: "Noto Naskh Arabic", serif;
  font-size: 11pt;
  margin: -2mm 0 2mm;
  direction: rtl;
  color: #444;
}

.spm-tf-row {
  display: flex;
  align-items: flex-start;
  gap: 4mm;
}

.spm-tf-box {
  flex-shrink: 0;
  width: 15mm;
  height: 8mm;
  border: 1px solid #444;
  display: inline-block;
  margin-right: auto;
}

/* ============ AL-QURAN TAHRIRI ============ */
.tahriri-controls {
  display: flex;
  gap: 6px;
  margin-bottom: 6px;
}

.tahriri-controls .input-field {
  flex: 1;
  margin-bottom: 0;
}

.btn-fetch {
  padding: 7px 12px;
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #000;
  font-weight: 700;
  font-size: 0.75rem;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  white-space: nowrap;
  transition: var(--transition);
}

.btn-fetch:hover {
  background: linear-gradient(135deg, #fbbf24, #f59e0b);
  transform: translateY(-1px);
}

.ayat-list {
  max-height: 180px;
  overflow-y: auto;
  padding-right: 4px;
}

.ayat-list::-webkit-scrollbar {
  width: 4px;
}

.ayat-list::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 10px;
}

.ayat-placeholder {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-align: center;
  padding: 10px 0;
}

.ayat-item {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  padding: 5px 4px;
  border-radius: 4px;
  cursor: pointer;
  transition: var(--transition);
  margin-bottom: 2px;
  border: 1px solid transparent;
  font-size: 0.8rem;
}

.ayat-item:hover {
  background: var(--bg-surface-hover);
  border-color: var(--border);
}

.ayat-item.selected {
  background: rgba(245, 158, 11, 0.15);
  border-color: #f59e0b;
}

.ayat-item input[type="checkbox"] {
  flex-shrink: 0;
  width: 14px;
  height: 14px;
  margin-top: 4px;
  accent-color: #f59e0b;
  cursor: pointer;
}

.ayat-item-num {
  font-size: 0.65rem;
  color: var(--text-muted);
  flex-shrink: 0;
  min-width: 24px;
  padding-top: 3px;
}

.ayat-item-text {
  font-family: "Noto Naskh Arabic", serif;
  direction: rtl;
  text-align: right;
  font-size: 0.8rem;
  line-height: 1.6;
  color: var(--text-primary);
  flex: 1;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

/* ============ LOADING ============ */
.loading-spinner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 30px;
  gap: 10px;
  color: var(--text-muted);
  font-size: 0.8rem;
}

.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ============ RESPONSIVE ============ */

/* Medium laptops: sidebar shrinks, content adjusts */
@media (max-width: 1200px) {
  .sidebar-header {
    padding: 12px 14px 10px;
  }

  .sidebar-section {
    padding: 10px 14px;
  }

  .sidebar-footer {
    padding: 8px 14px;
  }

  .sidebar-title {
    font-size: 1.05rem;
  }

  .paper-container {
    padding: 20px 16px;
  }

  .paper {
    width: 100%;
    max-width: 210mm;
  }
}

/* Small laptops: sidebar even narrower, paper scales down */
@media (max-width: 1024px) {
  .sidebar-header {
    padding: 10px 12px 8px;
  }

  .sidebar-section {
    padding: 8px 12px;
  }

  .sidebar-footer {
    padding: 8px 12px;
  }

  .sidebar-title {
    font-size: 0.95rem;
  }

  .sidebar-subtitle {
    font-size: 0.68rem;
  }

  .section-label {
    font-size: 0.6rem;
  }

  .input-field {
    font-size: 0.75rem;
    padding: 6px 8px;
  }

  .btn {
    font-size: 0.75rem;
    padding: 8px 10px;
  }

  .toggle-label {
    font-size: 0.7rem;
  }

  .toolbar {
    padding: 0 16px;
  }

  .toolbar-title {
    font-size: 0.9rem;
  }

  .paper-container {
    padding: 14px 12px;
    overflow-x: auto;
  }

  .paper {
    width: 210mm;
    min-width: 210mm;
  }
}

/* Mobile/small screens: sidebar slides out */
@media (max-width: 900px) {
  .sidebar {
    transform: translateX(-100%);
    width: 320px;
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: 10px 0 40px rgba(0, 0, 0, 0.5);
  }

  .toggle-sidebar-btn {
    display: flex;
  }

  .main-content {
    margin-left: 0;
  }

  .paper-container {
    padding: 16px;
    overflow-x: auto;
  }

  .paper {
    width: 210mm;
    min-width: 210mm;
    min-height: auto;
  }
}

/* ============ EDITOR TOOLBAR ============ */
.editor-toolbar {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: center;
  padding: 8px 16px;
  background: rgba(15, 23, 42, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  animation: slideDown 0.25s ease;
}

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

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.editor-toolbar-inner {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  justify-content: center;
}

.etool-btn {
  width: 34px;
  height: 34px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-surface);
  color: var(--text-primary);
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.etool-btn:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  transform: translateY(-1px);
}

.etool-btn:active {
  transform: translateY(0);
  background: var(--accent-hover);
}

.etool-btn-done {
  width: auto;
  padding: 0 12px;
  background: linear-gradient(135deg, #22c55e, #16a34a);
  color: #fff;
  border-color: #22c55e;
  font-size: 0.8rem;
}

.etool-btn-done:hover {
  background: linear-gradient(135deg, #16a34a, #15803d);
  border-color: #16a34a;
}

.etool-divider {
  width: 1px;
  height: 22px;
  background: var(--border);
  margin: 0 6px;
}

.etool-color-label {
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  font-size: 0.85rem;
  padding: 4px 6px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg-surface);
  transition: all 0.15s ease;
}

.etool-color-label:hover {
  border-color: var(--accent);
}

.etool-color-input {
  width: 22px;
  height: 22px;
  padding: 0;
  border: none;
  cursor: pointer;
  background: transparent;
}

.etool-select {
  padding: 5px 8px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-primary);
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.15s ease;
}

.etool-select:hover {
  border-color: var(--accent);
}

/* Edit mode button in toolbar */
.btn-edit-mode {
  padding: 6px 14px;
  font-size: 0.8rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text-primary);
  border-radius: 6px;
  transition: all 0.2s ease;
}

.btn-edit-mode:hover:not(:disabled) {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.btn-edit-mode.active {
  background: linear-gradient(135deg, #22c55e, #16a34a);
  color: #fff;
  border-color: #22c55e;
}

/* Paper editing visual hint */
.paper.editing {
  outline: 2px solid rgba(99, 102, 241, 0.5);
  outline-offset: 2px;
  box-shadow:
    0 0 20px rgba(99, 102, 241, 0.15),
    0 8px 32px rgba(0, 0, 0, 0.12);
  cursor: text;
}

/* ============ PRINT ============ */
@media print {
  * {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  body {
    background: white !important;
    color: #000 !important;
  }

  .sidebar,
  .toggle-sidebar-btn,
  .toolbar-wrapper,
  .toolbar,
  .editor-toolbar,
  .paper-empty {
    display: none !important;
  }

  .main-content {
    margin-left: 0 !important;
  }

  .paper-container {
    padding: 0 !important;
    background: white !important;
    overflow: visible !important;
  }

  .paper {
    width: 100% !important;
    min-width: unset !important;
    max-width: 100% !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    margin: 0 !important;
    overflow: visible !important;
  }

  /* Cover page — fits exactly one printable page (10mm margins = 277mm printable, 10mm top/bottom pad = 257mm content) */
  .cover-page {
    min-height: 0 !important;
    height: 257mm !important;
    overflow: hidden !important;
    page-break-after: always !important;
    break-after: page !important;
  }

  /* ── Page breaks ── */
  .page-break {
    page-break-before: always !important;
    break-before: page !important;
  }

  .spm-soal {
    page-break-inside: avoid;
    break-inside: avoid;
  }

  .spm-question-row {
    page-break-inside: avoid;
    break-inside: avoid;
  }

  .spm-answer-lines {
    page-break-inside: avoid;
    break-inside: avoid;
    page-break-before: avoid;
    break-before: avoid;
  }

  .spm-marks {
    page-break-before: avoid;
    break-before: avoid;
    page-break-inside: avoid;
    break-inside: avoid;
  }

  .spm-section-title {
    page-break-after: avoid !important;
    break-after: avoid !important;
  }

  .spm-sub-label {
    page-break-after: avoid;
    break-after: avoid;
  }

  .spm-group-header {
    page-break-after: avoid;
    break-after: avoid;
  }

  .spm-group-instruction {
    page-break-after: avoid;
    break-after: avoid;
  }

  .spm-word-bank {
    page-break-inside: avoid;
    break-inside: avoid;
  }

  .scheme-answer-row {
    page-break-inside: avoid;
    break-inside: avoid;
  }

  .scheme-soal {
    page-break-inside: avoid;
    break-inside: avoid;
  }

  .alif-input {
    border: none !important;
    background: transparent !important;
    box-shadow: none !important;
  }

  .alif-share-btns {
    display: none !important;
  }

  @page {
    size: A4 portrait;
    margin: 10mm;
  }
}

/* ── Editable Qism Alif ── */
.alif-input {
  width: 100%;
  border: none;
  border-bottom: 1px dashed #999;
  background: transparent;
  font-size: inherit;
  font-family: inherit;
  padding: 2px 4px;
  direction: rtl;
  text-align: right;
  outline: none;
  color: #000;
  box-sizing: border-box;
}

.alif-input:focus {
  border-bottom-color: #2563eb;
  border-bottom-style: solid;
  background: rgba(37, 99, 235, 0.04);
}

.alif-input::placeholder {
  color: #bbb;
  font-size: 0.85em;
}

/* Word bank editable cells */
.spm-word-bank .alif-input {
  text-align: center;
  font-size: 14pt;
  min-height: 28px;
}

/* MCQ choice inputs */
.alif-mcq-row .alif-input {
  display: inline-block;
  width: 120px;
  text-align: center;
  border-bottom: 1px dashed #999;
  margin: 0 2px;
}

/* ── Share Buttons ── */
.alif-share-btns {
  display: flex;
  gap: 6px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.alif-share-btns .btn {
  flex: 1;
  min-width: 80px;
  padding: 6px 10px;
  font-size: 0.8rem;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  font-weight: 600;
  transition:
    transform 0.1s,
    opacity 0.15s;
}

.alif-share-btns .btn:hover {
  transform: scale(1.03);
  opacity: 0.9;
}

.save-feedback {
  font-size: 0.75rem;
  color: var(--success);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.btn-save-alif {
  background: #6366f1;
  color: #fff;
}

.btn-wa {
  background: #25d366;
  color: #fff;
}

.btn-email {
  background: #3b82f6;
  color: #fff;
}

/* ── Stimulus Diagram (Cloud/Awan) ── */
.stimulus-diagram {
  direction: rtl;
  text-align: center;
  margin: 2mm auto;
  max-width: 160mm;
}

.stimulus-main-cloud {
  background: #f5f5f5;
  border: 1.5px solid #333;
  border-radius: 50% / 40%;
  padding: 4mm 10mm;
  margin: 0 auto;
  max-width: 130mm;
}

.stimulus-main-cloud .alif-input {
  text-align: center;
  font-size: 14pt;
  font-weight: 600;
  border-bottom: none;
}

.stimulus-lines {
  display: flex;
  justify-content: center;
  gap: 30mm;
  height: 10mm;
}

.stim-line {
  width: 1.5px;
  background: #333;
  height: 100%;
}

.stim-line:first-child {
  transform: rotate(25deg);
  transform-origin: top center;
}

.stim-line:last-child {
  transform: rotate(-25deg);
  transform-origin: top center;
}

.stimulus-sub-clouds {
  display: flex;
  justify-content: center;
  gap: 8mm;
  flex-direction: row-reverse;
}

.stimulus-cloud {
  background: #f9f9f9;
  border: 1.5px solid #333;
  border-radius: 50% / 45%;
  padding: 3mm 6mm;
  min-width: 30mm;
  min-height: 14mm;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.stimulus-cloud span {
  font-weight: 700;
  font-size: 14pt;
  margin-bottom: 2px;
}

.stimulus-cloud .alif-input {
  text-align: center;
  font-size: 10pt;
  width: 90%;
  border-bottom-style: dashed;
}

/* ── Verse Table (الآيات) ── */
.stimulus-verse-table {
  width: 90%;
  max-width: 150mm;
  margin: 2mm auto;
  border-collapse: collapse;
  direction: rtl;
}

.stimulus-verse-table th {
  background: #000;
  color: #fff;
  padding: 3mm 4mm;
  font-size: 14pt;
  font-weight: 700;
  text-align: center;
}

.stimulus-verse-table td {
  border: 1px solid #333;
  padding: 2mm 3mm;
  text-align: right;
  direction: rtl;
  font-size: 12pt;
}

.verse-label-cell {
  line-height: 1.6;
}

.verse-label-cell .alif-input {
  font-size: 16pt;
  text-align: center;
  margin: 2mm 0;
  border-bottom: 1px dashed #999;
}

/* ============ TAFSIR BUILDER & MODAL ============ */
.section-desc {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.tafsir-builder-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

.tafsir-card {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px;
  position: relative;
  transition: var(--transition);
}

.tafsir-card:hover {
  border-color: var(--accent);
}

.tafsir-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.tafsir-card-letter {
  font-family: "Noto Naskh Arabic", serif;
  font-weight: 700;
  color: var(--accent-hover);
  font-size: 1rem;
}

.tafsir-card-title {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-primary);
}

.tafsir-card-meta {
  font-size: 0.65rem;
  color: var(--text-muted);
  font-family: "Noto Naskh Arabic", serif;
}

.tafsir-card-actions {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}

/* Modal */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.modal-content {
  background: var(--bg-surface);
  margin: 5vh auto;
  width: 90%;
  max-width: 650px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  max-height: 90vh;
}

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 {
  font-size: 1rem;
  font-weight: 700;
}

.close-modal {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--text-secondary);
  cursor: pointer;
  line-height: 1;
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

.modal-section {
  margin-bottom: 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  padding-bottom: 16px;
}

.modal-section:last-child {
  border-bottom: none;
}

.modal-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--accent-hover);
  margin-bottom: 10px;
}

.modal-sublabel {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.range-group {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
}

.small-input {
  width: 60px !important;
  text-align: center;
}

.ayat-preview-box {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin-top: 10px;
  font-family: "Amiri", serif;
  direction: rtl;
  text-align: right;
  font-size: 1.1rem;
  min-height: 60px;
  color: var(--success);
}

.placeholder-text {
  font-family: "Inter", sans-serif;
  direction: ltr;
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: center;
}

.patterns-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.pattern-item {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  background: rgba(255, 255, 255, 0.03);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  transition: var(--transition);
  cursor: pointer;
}

.pattern-item:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--accent);
}

.pattern-item.active {
  border-color: var(--success);
  background: var(--success-bg);
}

.pattern-item-header {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
}

.pattern-arabic {
  font-family: "Noto Naskh Arabic", serif;
  font-size: 0.85rem;
  flex: 1;
  text-align: right;
}

.custom-questions-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

.custom-q-item {
  display: flex;
  gap: 8px;
  align-items: flex-start;
}

.btn-outline {
  background: transparent;
  border: 1px dashed var(--border);
  color: var(--text-secondary);
}

.btn-outline:hover {
  border-color: var(--accent);
  color: var(--accent-hover);
}

.btn-full {
  width: 100%;
}

.btn-small {
  padding: 5px 10px;
  font-size: 0.7rem;
}

.modal-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}