/* Academic Paper Lab — Zimex cyber / neon */
:root {
  --rp-cyan: #7af6ff;
  --rp-mint: #39ff9a;
  --rp-amber: #ffd166;
  --rp-ink: #0a0f18;
  --rp-panel: rgba(12, 18, 32, 0.88);
  --rp-line: rgba(122, 246, 255, 0.28);
  --rp-paper: #f7f4ee;
  --rp-paper-ink: #1a2230;
}

.rp-page {
  min-height: 100vh;
  background:
    radial-gradient(ellipse 80% 50% at 10% 0%, rgba(0, 196, 255, 0.14), transparent 55%),
    radial-gradient(ellipse 60% 40% at 90% 20%, rgba(57, 255, 154, 0.08), transparent 50%),
    linear-gradient(180deg, #070b14 0%, #0d1524 45%, #0a101c 100%);
  color: #e8f0ff;
}

.rp-shell {
  width: min(96rem, calc(100% - 2rem));
  max-width: 96rem;
  margin: 0 auto;
  padding: 18px 0 110px;
  box-sizing: border-box;
}

.rp-hero {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.rp-kicker {
  display: inline-block;
  font-family: "Orbitron", "Cairo", sans-serif;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 0.72rem;
  color: var(--rp-cyan);
  margin-bottom: 8px;
}

.rp-title {
  margin: 0;
  font-family: "Cairo", Tahoma, sans-serif;
  font-weight: 800;
  font-size: clamp(1.6rem, 3vw, 2.2rem);
  line-height: 1.25;
}

.rp-lead {
  margin: 8px 0 0;
  max-width: 52ch;
  color: rgba(220, 232, 255, 0.78);
  font-size: 0.98rem;
}

.rp-grid {
  display: grid;
  grid-template-columns: minmax(280px, 0.95fr) minmax(320px, 1.15fr);
  gap: 20px;
  align-items: start;
}

.rp-panel {
  background: var(--rp-panel);
  border: 1px solid var(--rp-line);
  border-radius: 18px;
  padding: 18px;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35), 0 18px 40px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(10px);
}

.rp-panel h2 {
  margin: 0 0 14px;
  font-size: 1.05rem;
  color: var(--rp-cyan);
  font-family: "Cairo", sans-serif;
}

.rp-form {
  display: grid;
  gap: 12px;
}

.rp-field label {
  display: block;
  margin-bottom: 5px;
  font-size: 0.82rem;
  color: rgba(200, 220, 255, 0.75);
}

.rp-field input,
.rp-field select,
.rp-field textarea {
  width: 100%;
  box-sizing: border-box;
  background: rgba(6, 10, 18, 0.85);
  border: 1px solid rgba(122, 246, 255, 0.22);
  border-radius: 10px;
  color: #eef6ff;
  padding: 10px 12px;
  font-family: "Cairo", Tahoma, sans-serif;
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.rp-field input:focus,
.rp-field select:focus,
.rp-field textarea:focus {
  border-color: var(--rp-cyan);
  box-shadow: 0 0 0 3px rgba(122, 246, 255, 0.15);
}

.rp-field textarea {
  min-height: 90px;
  resize: vertical;
}

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

.rp-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 6px;
}

.rp-btn {
  appearance: none;
  border: 0;
  border-radius: 12px;
  padding: 12px 16px;
  font-family: "Cairo", sans-serif;
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  transition: transform 0.15s, filter 0.15s, opacity 0.15s;
}

.rp-btn:hover {
  transform: translateY(-1px);
  filter: brightness(1.08);
}

.rp-btn:disabled {
  opacity: 0.55;
  cursor: wait;
  transform: none;
}

.rp-btn-primary {
  background: linear-gradient(120deg, #00c4ff, #39ff9a);
  color: #041018;
  flex: 1;
  min-width: 160px;
}

.rp-btn-ghost {
  background: transparent;
  border: 1px solid var(--rp-line);
  color: var(--rp-cyan);
}

.rp-status {
  min-height: 1.2em;
  font-size: 0.85rem;
  color: rgba(200, 220, 255, 0.7);
}

.rp-status.is-err {
  color: #ff8a9b;
}

.rp-preview-wrap {
  position: relative;
}

.rp-a4-scroll {
  max-height: min(78vh, 920px);
  overflow: auto;
  border-radius: 14px;
  border: 1px solid rgba(122, 246, 255, 0.2);
  background: rgba(4, 8, 14, 0.55);
  padding: 14px;
}

.rp-a4 {
  width: min(100%, 210mm);
  margin: 0 auto;
  background: var(--rp-paper);
  color: var(--rp-paper-ink);
  min-height: 297mm;
  padding: 18mm 16mm 22mm;
  box-sizing: border-box;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  font-family: "Amiri", "Traditional Arabic", "Times New Roman", serif;
  position: relative;
}

.rp-a4-header {
  display: grid;
  grid-template-columns: 64px 1fr 64px;
  gap: 10px;
  align-items: center;
  border-bottom: 2px solid #1a2230;
  padding-bottom: 10px;
  margin-bottom: 14px;
}

.rp-logo {
  width: 56px;
  height: 56px;
  object-fit: contain;
}

.rp-uni-meta {
  text-align: center;
}

.rp-uni-meta strong {
  display: block;
  font-size: 1.05rem;
  font-family: "Cairo", sans-serif;
}

.rp-uni-meta span {
  display: block;
  font-size: 0.82rem;
  opacity: 0.85;
}

.rp-stamp {
  text-align: center;
  font-size: 0.68rem;
  font-family: "Cairo", sans-serif;
  color: #445;
  line-height: 1.35;
}

.rp-cover-title {
  margin: 18px 0 8px;
  text-align: center;
  font-size: 1.35rem;
  font-weight: 700;
  font-family: "Cairo", sans-serif;
  line-height: 1.4;
}

.rp-domain {
  text-align: center;
  font-size: 0.9rem;
  color: #334;
  margin-bottom: 16px;
  font-family: "Cairo", sans-serif;
}

.rp-student-block {
  display: grid;
  gap: 4px;
  margin: 18px auto 22px;
  max-width: 420px;
  font-family: "Cairo", sans-serif;
  font-size: 0.92rem;
  border: 1px solid #c8d0dc;
  padding: 12px 14px;
  background: #fffef9;
}

.rp-sec {
  margin: 18px 0;
}

.rp-sec h3 {
  margin: 0 0 8px;
  font-family: "Cairo", sans-serif;
  font-size: 1.05rem;
  border-right: 3px solid #00a8c8;
  padding-right: 8px;
}

.rp-sec p,
.rp-sec li {
  font-size: 0.95rem;
  line-height: 1.75;
  margin: 0 0 8px;
}

.rp-formula {
  direction: ltr;
  text-align: center;
  margin: 12px 0;
  padding: 10px;
  background: #eef3f8;
  border-radius: 8px;
  font-family: "Cambria Math", "Times New Roman", serif;
  overflow-x: auto;
}

.rp-table-wrap {
  overflow-x: auto;
  margin: 10px 0;
}

.rp-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
  font-family: "Cairo", sans-serif;
}

.rp-table th,
.rp-table td {
  border: 1px solid #b8c2d0;
  padding: 6px 8px;
  vertical-align: top;
}

.rp-table th {
  background: #e4ebf3;
}

.rp-mermaid {
  direction: ltr;
  text-align: left;
  white-space: pre-wrap;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 0.75rem;
  background: #eef3f8;
  padding: 10px;
  border-radius: 8px;
  overflow-x: auto;
}

.rp-mermaid-live {
  direction: ltr;
  text-align: center;
  background: #f3f6fa;
  border: 1px solid #c8d0dc;
  border-radius: 10px;
  padding: 12px;
  margin: 12px 0;
  overflow-x: auto;
}

.rp-mermaid-live svg {
  max-width: 100%;
  height: auto;
}

.rp-sec-heading {
  font-family: "Cairo", sans-serif;
  font-size: 1.08rem;
  margin: 8px 0 12px;
  border-bottom: 1px solid #c8d0dc;
  padding-bottom: 6px;
}

.rp-pdf-page {
  page-break-after: always;
  break-after: page;
}

.rp-pdf-page:last-child {
  page-break-after: auto;
  break-after: auto;
}

/* Dedicated export host — never capture the live scroller */
#pdf-export-container.rp-export-root,
.rp-export-root {
  position: fixed;
  left: 0;
  top: 0;
  width: 210mm;
  background: var(--rp-paper);
  color: var(--rp-paper-ink);
  z-index: -1;
  opacity: 0;
  pointer-events: none;
  overflow: visible;
  direction: rtl;
}

#pdf-export-container .rp-pdf-page {
  width: 210mm;
  min-height: 297mm;
  box-sizing: border-box;
  background: var(--rp-paper);
  color: var(--rp-paper-ink);
  padding: 14mm 16mm;
  margin: 0;
}

.rp-locked-zone {
  position: relative;
  margin-top: 8px;
}

.rp-locked-zone.is-locked .rp-locked-body {
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  opacity: 0.3;
  user-select: none;
  pointer-events: none;
  filter: blur(1.5px);
}

.rp-lock-overlay {
  position: absolute;
  inset: 12% 6% auto;
  z-index: 5;
  display: flex;
  justify-content: center;
  pointer-events: none;
}

.rp-lock-overlay[hidden] {
  display: none !important;
}

.rp-lock-card {
  pointer-events: auto;
  max-width: 420px;
  text-align: center;
  padding: 18px 16px;
  border-radius: 16px;
  background: linear-gradient(160deg, rgba(8, 14, 28, 0.96), rgba(12, 28, 42, 0.94));
  border: 1px solid rgba(122, 246, 255, 0.45);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.55), 0 0 24px rgba(0, 196, 255, 0.2);
  color: #eef6ff;
  font-family: "Cairo", sans-serif;
  animation: rp-float 3.2s ease-in-out infinite;
}

.rp-lock-card p {
  margin: 0 0 12px;
  font-size: 0.92rem;
  line-height: 1.5;
}

.rp-lock-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

@keyframes rp-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

.rp-empty {
  text-align: center;
  padding: 48px 16px;
  color: #667;
  font-family: "Cairo", sans-serif;
}

.rp-hero-meter {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  font-family: "Cairo", sans-serif;
}

.rp-hero-meter strong,
.rp-hero-meter span {
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--rp-line);
  background: rgba(8, 14, 24, 0.65);
  font-size: 0.82rem;
}

.rp-hero-meter strong {
  color: var(--rp-mint);
}

.rp-bologna {
  margin: 4px 0 8px;
  padding: 12px;
  border-radius: 12px;
  border: 1px dashed rgba(122, 246, 255, 0.35);
  background: rgba(0, 196, 255, 0.06);
  font-family: "Cairo", sans-serif;
}

.rp-bolo-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  font-size: 0.8rem;
}

.rp-bolo-grid b {
  color: var(--rp-cyan);
  margin-left: 4px;
}

.rp-bolo-note {
  margin: 10px 0 0;
  font-size: 0.78rem;
  color: rgba(210, 225, 255, 0.75);
  line-height: 1.55;
}

.rp-slider-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 6px;
  font-size: 0.75rem;
  color: rgba(190, 210, 240, 0.7);
  font-family: "Cairo", sans-serif;
}

.rp-slider-hint {
  color: var(--rp-amber);
}

#rp-pages {
  width: 100%;
  accent-color: #00c4ff;
}

.rp-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.rp-chip {
  appearance: none;
  border: 1px solid rgba(122, 246, 255, 0.28);
  background: rgba(8, 16, 28, 0.8);
  color: #d8ecff;
  border-radius: 999px;
  padding: 6px 10px;
  font-family: "Cairo", sans-serif;
  font-size: 0.78rem;
  cursor: pointer;
}

.rp-chip:hover {
  border-color: var(--rp-cyan);
  color: #fff;
}

.rp-preview-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.rp-preview-head h2 {
  margin: 0;
}

.rp-page-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.rp-tab {
  appearance: none;
  border: 1px solid rgba(122, 246, 255, 0.25);
  background: rgba(6, 12, 22, 0.8);
  color: #cfe6ff;
  border-radius: 8px;
  padding: 5px 9px;
  font-size: 0.72rem;
  font-family: "Cairo", sans-serif;
  cursor: pointer;
}

.rp-tab.is-on {
  border-color: var(--rp-mint);
  color: var(--rp-mint);
}

.rp-logo-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: 0.58rem;
  font-family: "Cairo", sans-serif;
  color: #667;
}

.rp-page-badge {
  text-align: center;
  font-size: 0.72rem;
  font-family: "Cairo", sans-serif;
  color: #556;
  margin-bottom: 8px;
}

.rp-fig {
  margin: 12px 0;
  text-align: center;
}

.rp-fig img {
  max-width: 100%;
  border-radius: 8px;
  border: 1px solid #c5ceda;
  background: #fff;
}

.rp-fig figcaption {
  font-size: 0.75rem;
  color: #556;
  margin-top: 4px;
  font-family: "Cairo", sans-serif;
}

.rp-formula-inline {
  display: inline !important;
  padding: 2px 6px !important;
  margin: 0 2px;
}

.rp-cite {
  color: #0a6;
  font-size: 0.75em;
}

.rp-breakdown {
  margin: 14px 0;
  padding: 10px 12px;
  border: 1px solid #c8d0dc;
  background: #fffef9;
  font-family: "Cairo", sans-serif;
  font-size: 0.88rem;
}

.rp-breakdown h3 {
  margin: 0 0 6px;
  font-size: 0.95rem;
}

.rp-breakdown ol {
  margin: 0;
  padding-right: 18px;
}

.rp-refs {
  font-size: 0.85rem;
  font-family: "Cairo", sans-serif;
  line-height: 1.6;
}

.rp-bolo-inline {
  font-family: "Cairo", sans-serif;
  font-size: 0.85rem;
  color: #445;
}

.rp-svg-fallback {
  margin: 10px 0;
  padding: 8px;
  background: #eef3f8;
  border-radius: 8px;
}

.rp-svg-fallback svg {
  width: 100%;
  max-width: 420px;
  display: block;
  margin: 0 auto;
}

@media (max-width: 960px) {
  .rp-grid {
    grid-template-columns: 1fr;
  }
  .rp-row {
    grid-template-columns: 1fr;
  }
  .rp-bolo-grid {
    grid-template-columns: 1fr 1fr;
  }
  .rp-a4 {
    padding: 14mm 10mm 18mm;
    min-height: auto;
  }
}

@media print {
  body * { visibility: hidden !important; }
  .rp-a4, .rp-a4 * { visibility: visible !important; }
  .rp-a4 {
    position: absolute;
    left: 0;
    top: 0;
    width: 210mm;
    min-height: 297mm;
    margin: 0;
    box-shadow: none;
  }
  .rp-lock-overlay,
  .site-header,
  .zim-dock,
  .rp-panel:first-child,
  .rp-hero,
  .rp-actions,
  .rp-page-tabs { display: none !important; }
  .rp-page { background: #fff; }
}
