/* ============================================================
   THRONE OF ANHU · ABASID 1841
   GLOBAL STYLES - MOBILE-FIRST RESPONSIVE
   ============================================================ */

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

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

html,
body {
  height: 100%;
  min-height: 100dvh;
  min-height: -webkit-fill-available;
}

body {
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  background: radial-gradient(circle at top, #020617 0%, #020617 40%, #000 100%);
  color: #f5f5f5;
  overflow-x: hidden;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  padding-bottom: env(safe-area-inset-bottom, 0);
}

/* Typography scaling with clamp */
:root {
  --font-xs: clamp(0.65rem, 1.5vw, 0.75rem);
  --font-sm: clamp(0.75rem, 2vw, 0.875rem);
  --font-base: clamp(0.875rem, 2.5vw, 1rem);
  --font-lg: clamp(1rem, 3vw, 1.125rem);
  --font-xl: clamp(1.125rem, 3.5vw, 1.25rem);
  --font-2xl: clamp(1.25rem, 4vw, 1.5rem);
}

/* When modals open */
body.modal-open {
  overflow: hidden;
}

/* ---------------- MODE COLORS ---------------- */
.mode-ra {
  --throne-accent: #facc15;
  --throne-accent-soft: #fef9c3;
  --throne-accent-deep: #b45309;
  --throne-bg: #020617;
  --throne-txt: #e5e7eb;
}

.mode-dzi {
  --throne-accent: #38bdf8;
  --throne-accent-soft: #e0f2fe;
  --throne-accent-deep: #1d4ed8;
  --throne-bg: #020617;
  --throne-txt: #e0f2fe;
}

.mode-ma {
  --throne-accent: #e879f9;
  --throne-accent-soft: #fae8ff;
  --throne-accent-deep: #7e22ce;
  --throne-bg: #0b0213;
  --throne-txt: #fdf2ff;
}

/* ============================================================
   HEADER
   ============================================================ */

.throne-header {
  min-height: 56px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: radial-gradient(
    ellipse at top,
    #1f2937 0%,
    #020617 55%,
    #000 100%
  );
  padding: 8px 12px;
  padding-top: max(8px, env(safe-area-inset-top, 8px));
  border-bottom: 1px solid rgba(250, 204, 21, 0.6);
  position: sticky;
  top: 0;
  z-index: 2000;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.8);
  flex-shrink: 0;
}

@media (max-width: 480px) {
  .throne-header {
    min-height: 50px;
    padding: 6px 8px;
    padding-top: max(6px, env(safe-area-inset-top, 6px));
  }
}

.throne-header.persona-transition {
  transition: box-shadow 0.25s ease, border-color 0.25s ease,
    background 0.25s ease;
}

.throne-header.persona-ra {
  box-shadow: 0 0 26px rgba(250, 204, 21, 0.4);
}

.throne-header.persona-dzi {
  box-shadow: 0 0 26px rgba(56, 189, 248, 0.4);
}

.throne-header.persona-ma {
  box-shadow: 0 0 26px rgba(232, 121, 249, 0.4);
}

.brand-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.avatar-ring {
  width: clamp(36px, 8vw, 44px);
  height: clamp(36px, 8vw, 44px);
  border-radius: 999px;
  border: 2px solid rgba(250, 204, 21, 0.9);
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  box-shadow: 0 0 14px rgba(250, 204, 21, 0.5);
  background: radial-gradient(
    circle at 30% 0%,
    #fef9c3 0%,
    #facc15 45%,
    #b45309 100%
  );
  flex-shrink: 0;
}

.avatar-ring img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

.main-title {
  font-size: var(--font-lg);
  font-weight: 800;
  color: #f9fafb;
  letter-spacing: 0.08em;
  line-height: 1.2;
}

.subtitle-line {
  font-size: var(--font-xs);
  opacity: 0.88;
  color: var(--throne-accent-soft);
  letter-spacing: 0.06em;
  white-space: nowrap;
}

@media (max-width: 380px) {
  .subtitle-line {
    max-width: 120px;
  }
}

.brand-right {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

/* Hourglass */
.hourglass {
  font-size: 20px;
}

.hourglass.thinking {
  animation: hourglass-spin 1s linear infinite;
}

@keyframes hourglass-spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

/* ============================================================
   TOP CONTROLS
   ============================================================ */

.top-controls {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 6px 10px;
  background: #020617;
  border-bottom: 1px solid rgba(15, 23, 42, 0.9);
  position: sticky;
  top: 0;
  z-index: 1500;
  flex-shrink: 0;
}

.controls-row-1 {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.controls-row-2 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}

.row2-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

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

.pdf-button-compact {
  padding: 6px 12px;
  background: #1e293b;
  color: #facc15;
  border: 1px solid #facc15;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-decoration: none;
  transition: transform 0.15s ease, background 0.15s ease;
}

.pdf-button-compact:hover {
  background: #334155;
  transform: translateY(-1px);
}

.social-circle {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.social-circle:hover {
  transform: scale(1.1);
}

.social-circle svg {
  width: 100%;
  height: 100%;
}

.social-circle.social-telegram svg {
  fill: #0088cc;
}

.social-circle.social-telegram svg .paper {
  fill: #fff;
}

.social-circle.social-whatsapp svg {
  fill: #25d366;
}

.social-circle.social-whatsapp svg .phone {
  fill: #fff;
}

.scrolls-button-compact {
  padding: 6px 12px;
  background: radial-gradient(circle at 20% 0%, #fef9c3 0%, #facc15 40%, #b45309 100%);
  color: #020617;
  border: 1px solid rgba(250, 250, 250, 0.9);
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.scrolls-button-compact:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(250, 204, 21, 0.4);
}

@media (max-width: 640px) {
  .top-controls {
    padding: 4px 8px;
    gap: 4px;
  }
}

@media (max-width: 480px) {
  .controls-row-1,
  .controls-row-2 {
    justify-content: center;
  }
}

.top-left {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.language-label {
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: #9ca3af;
}

.language-select {
  background: radial-gradient(circle at top, #020617 0%, #020617 60%, #000 100%);
  color: #e5e7eb;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.9);
  font-size: 12px;
}

/* MODE BUTTONS */

.mode-buttons {
  display: flex;
  gap: 6px;
  flex: 1;
  justify-content: center;
}

.mode-btn {
  padding: 6px 10px;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(55, 65, 81, 0.9);
  color: #e5e7eb;
  border-radius: 999px;
  font-size: 11px;
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease,
    box-shadow 0.18s ease, transform 0.18s ease;
}

.mode-btn:hover {
  background: rgba(31, 41, 55, 0.95);
}

/* Active colour per persona (Outer/Inner/Holy) */
body.mode-ra .mode-buttons .mode-btn:nth-child(1),
body.mode-dzi .mode-buttons .mode-btn:nth-child(2),
body.mode-ma .mode-buttons .mode-btn:nth-child(3) {
  background: radial-gradient(
    circle at 20% 0%,
    var(--throne-accent-soft) 0%,
    var(--throne-accent) 40%,
    var(--throne-accent-deep) 100%
  );
  color: #020617;
  border-color: rgba(250, 250, 250, 0.9);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.7),
    0 0 16px rgba(250, 250, 250, 0.35);
  transform: translateY(-1px);
}

/* Top-right controls */
.top-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;         /* keep Telegram · WhatsApp · View Scrolls in one row */
  justify-content: flex-end;
  max-width: 100%;
  position: relative;
}

@media (max-width: 640px) {
  .top-right {
    flex-wrap: nowrap;
    width: auto;
    justify-content: flex-end;
    flex-shrink: 1;
    overflow: hidden;
  }
  
  .social-btn span,
  .scrolls-button {
    font-size: 9px;
    padding: 4px 8px;
  }
  
  .social-btn {
    padding: 0.3rem 0.5rem;
  }
}

/* Glowy gold pill buttons */

.scrolls-button,
.scroll-search-btn,
.scroll-preview-btn.primary,
.vault-search-btn,
.pin-chip {
  border-radius: 999px;
  border: 1px solid rgba(250, 204, 21, 0.95);
  background: radial-gradient(
    circle at 20% 0%,
    var(--throne-accent-soft) 0%,
    var(--throne-accent) 40%,
    var(--throne-accent-deep) 100%
  );
  color: #111827;
  font-weight: 600;
  font-size: 10px;
  padding: 5px 12px;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(250, 204, 21, 0.35),
    0 0 0 1px rgba(255, 255, 255, 0.06);
  text-transform: uppercase;
  letter-spacing: 0.09em;
  transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.12s ease;
}

.scrolls-button:hover,
.scroll-search-btn:hover,
.scroll-preview-btn.primary:hover,
.vault-search-btn:hover,
.pin-chip:hover {
  filter: brightness(1.06);
  transform: translateY(-1px);
  box-shadow: 0 14px 30px rgba(250, 204, 21, 0.45),
    0 0 0 1px rgba(255, 255, 255, 0.1);
}

.scrolls-button:active,
.scroll-search-btn:active,
.scroll-preview-btn.primary:active,
.vault-search-btn:active,
.pin-chip:active {
  transform: translateY(1px) scale(0.98);
  box-shadow: 0 4px 10px rgba(250, 204, 21, 0.3);
}

/* ============================================================
   CHAT WINDOW
   ============================================================ */

.throne-main {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  padding-right: 60px; /* space for persona rail */
}

@media (max-width: 480px) {
  .throne-main {
    padding-right: 50px;
  }
}

.chat-window {
  flex: 1;
  overflow-y: auto;
  padding: 10px 12px 20px;
  -webkit-overflow-scrolling: touch;
}

.messages {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* Message animation */

.message-block {
  animation: fadeIn 0.25s ease;
}

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

.message-meta {
  font-size: 11px;
  opacity: 0.72;
  margin-bottom: 3px;
}

.user-meta {
  text-align: right;
  color: #9ca3af;
}

.throne-meta {
  text-align: left;
  color: var(--throne-accent-soft);
}

.message {
  padding: 11px 14px;
  border-radius: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-wrap: break-word;
}

/* USER Messages */
.message.user {
  background: radial-gradient(circle at top, #1d4ed8 0%, #020617 65%);
  color: #dbeafe;
  margin-left: auto;
  max-width: 78%;
  box-shadow: 0 10px 20px rgba(30, 64, 175, 0.45);
}

/* THRONE Messages */
.message.throne {
  background: #020617;
  border-left: 3px solid var(--throne-accent);
  max-width: 88%;
  box-shadow: 0 8px 16px rgba(15, 23, 42, 0.9);
}

/* Throne persona colours */
.throne-ra {
  border-left-color: #facc15;
}

.throne-dzi {
  border-left-color: #38bdf8;
}

.throne-ma {
  border-left-color: #e879f9;
}

/* ============================================================
   TYPING INDICATOR
   ============================================================ */

.typing-indicator {
  padding: 8px 12px;
  background: #020617;
  border-top: 1px solid #111827;
  display: flex;
  align-items: center;
  gap: 6px;
  position: relative;
  z-index: 1550;
}

.typing-label {
  font-size: 12px;
  opacity: 0.82;
}

.typing-indicator .dot {
  width: 6px;
  height: 6px;
  background: var(--throne-accent);
  border-radius: 50%;
  animation: blink 1.2s infinite ease-in-out;
}

.typing-indicator .dot:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-indicator .dot:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes blink {
  0%,
  80% {
    opacity: 0.2;
  }
  40% {
    opacity: 1;
  }
}

.hidden {
  display: none !important;
}

/* ============================================================
   INPUT BAR
   ============================================================ */

.chat-input-bar {
  background: #020617;
  padding: 8px 10px;
  padding-bottom: max(8px, env(safe-area-inset-bottom, 8px));
  padding-right: 65px; /* space for persona rail */
  border-top: 1px solid #111827;
  display: flex;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
}

@media (max-width: 480px) {
  .chat-input-bar {
    padding: 6px 8px;
    padding-bottom: max(6px, env(safe-area-inset-bottom, 6px));
    padding-right: 55px;
  }
}

.chat-input {
  flex: 1;
  background: radial-gradient(circle at top, #020617 0%, #020617 60%, #000 100%);
  border-radius: 999px;
  border: 1px solid #1f2937;
  padding: 10px 14px;
  color: #e5e7eb;
  resize: none;
  max-height: 120px;
  font-size: 14px;
}

/* Send button */

.send-button {
  width: 46px;
  height: 46px;
  min-width: 46px;
  border-radius: 999px;
  border: 1px solid rgba(250, 204, 21, 0.95);
  background: radial-gradient(
    circle at 20% 0%,
    var(--throne-accent-soft) 0%,
    var(--throne-accent) 40%,
    var(--throne-accent-deep) 100%
  );
  color: #111827;
  font-weight: 800;
  font-size: 20px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(250, 204, 21, 0.35),
    0 0 0 1px rgba(255, 255, 255, 0.08);
  transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.12s ease;
}

.send-button:hover {
  filter: brightness(1.06);
  transform: translateY(-1px);
  box-shadow: 0 16px 32px rgba(250, 204, 21, 0.45),
    0 0 0 1px rgba(255, 255, 255, 0.12);
}

.send-button:active {
  transform: translateY(1px) scale(0.97);
  box-shadow: 0 5px 12px rgba(250, 204, 21, 0.3);
}

/* ============================================================
   PIN BAR
   ============================================================ */

.pin-bar {
  background: #020617;
  border-bottom: 1px solid #111827;
  padding: 6px 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  position: relative;
  z-index: 1600;
}

.pin-clear {
  background: #0f172a;
  border: 1px solid #1f2937;
  color: #e5e7eb;
  padding: 4px 8px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 11px;
}

/* ============================================================
   SCROLL LIBRARY MODAL
   ============================================================ */

.scroll-modal {
  position: fixed;
  inset: 0;
  display: flex;
  z-index: 4000;
}

.scroll-modal.hidden {
  display: none;
}

.scroll-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(2px);
}

.scroll-modal-content {
  position: relative;
  margin: 20px auto;
  width: min(520px, 92%);
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: #020617;
  border: 2px solid var(--throne-accent);
  border-radius: 14px;
  padding: 16px;
  color: #fff;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.9);
}

.scroll-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.scroll-modal-close {
  background: none;
  border: none;
  font-size: 22px;
  color: var(--throne-accent);
  cursor: pointer;
}

.scroll-modal-intro {
  margin: 12px 0;
  font-size: 14px;
  color: #d1d5db;
}

.scroll-search-row {
  display: flex;
  gap: 8px;
  margin: 10px 0;
}

.scroll-search-input {
  flex: 1;
  padding: 8px;
  background: #020617;
  border: 1px solid #374151;
  border-radius: 999px;
  color: #e5e7eb;
}

.scroll-section-title {
  margin-top: 18px;
  margin-bottom: 6px;
  color: var(--throne-accent);
  font-weight: 700;
  border-bottom: 1px solid #374151;
  padding-bottom: 2px;
}

.scroll-list ul {
  list-style: none;
  padding-left: 0;
}

.scroll-list li {
  padding: 6px 4px;
  cursor: pointer;
  color: #f9fafb;
  border-bottom: 1px solid #111827;
}

.scroll-list li:hover {
  background: #020617;
}

/* ============================================================
   SCROLL PREVIEW MODAL
   ============================================================ */

.scroll-preview-modal {
  position: fixed;
  inset: 0;
  z-index: 5000;
}

.scroll-preview-modal.hidden {
  display: none;
}

.scroll-preview-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(3px);
}

.scroll-preview-card {
  position: relative;
  margin: 20px auto;
  width: min(520px, 92%);
  max-height: calc(100vh - 40px);
  overflow: hidden;
  background: #020617;
  border: 2px solid var(--throne-accent);
  border-radius: 14px;
  padding: 16px;
}

.scroll-preview-title {
  font-size: 20px;
  font-weight: 700;
}

.scroll-preview-series {
  font-size: 13px;
  opacity: 0.8;
}

.scroll-preview-close {
  background: none;
  border: none;
  color: var(--throne-accent);
  font-size: 22px;
  cursor: pointer;
}

.scroll-preview-body {
  background: #000;
  padding: 12px;
  border-radius: 8px;
  max-height: 50vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  margin-top: 12px;
  white-space: pre-wrap;
}

.scroll-preview-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 12px;
}

.scroll-preview-btn.ghost {
  background: #111827;
  color: #e5e7eb;
  border: 1px solid #374151;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12px;
}

/* ============================================================
   ANI VAULT (SLIDE PANEL)
   ============================================================ */

.vault-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: min(520px, 90%);
  height: 100vh;
  background: #020617;
  border-left: 2px solid var(--throne-accent);
  transform: translateX(100%);
  transition: transform 0.35s ease;
  z-index: 6000;
  padding: 14px;
  display: flex;
  flex-direction: column;
}

.vault-panel.hidden {
  transform: translateX(100%);
}

.vault-panel:not(.hidden) {
  transform: translateX(0);
}

.vault-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--throne-accent);
}

.vault-close-btn {
  background: none;
  border: none;
  font-size: 22px;
  color: var(--throne-accent);
  cursor: pointer;
}

.vault-search-row {
  margin: 12px 0;
  display: flex;
  gap: 8px;
}

.vault-search-input {
  flex: 1;
  padding: 8px;
  background: #020617;
  border: 1px solid #374151;
  color: #e5e7eb;
  border-radius: 999px;
}

.vault-body {
  flex: 1;
  display: flex;
  gap: 10px;
  overflow: hidden;
}

.vault-list {
  width: 45%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  border-right: 1px solid #111827;
}

.vault-item {
  padding: 8px;
  border-bottom: 1px solid #111827;
  cursor: pointer;
}

.vault-item-active {
  background: #020617;
}

.vault-detail {
  flex: 1;
  padding: 8px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.vault-detail-title {
  color: var(--throne-accent);
  font-weight: 700;
  font-size: 16px;
}

.vault-detail-meta {
  font-size: 12px;
  opacity: 0.8;
}

.vault-detail-text {
  margin-top: 8px;
  white-space: pre-wrap;
  font-size: 13px;
}

/* ============================================================
   SOCIAL GATES (Telegram + WhatsApp)
   ============================================================ */

.top-social-gates {
  display: flex;
  gap: 6px;
  flex-wrap: nowrap;
  flex-shrink: 1;
}

.social-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.35rem 0.8rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  text-decoration: none;
  color: #ffffff;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.18);
  border: none;
  white-space: nowrap;
  transition: transform 0.12s ease, box-shadow 0.12s ease, opacity 0.12s ease;
}

.social-btn .social-icon {
  width: 18px;
  height: 18px;
}

/* Telegram colours */
.social-telegram {
  background: #229ed9;
}
.social-telegram .social-icon circle {
  fill: #229ed9;
}
.social-telegram .social-icon .paper {
  fill: #ffffff;
}

/* WhatsApp colours */
.social-whatsapp {
  background: #25d366;
}
.social-whatsapp .social-icon path:first-child {
  fill: #25d366;
}
.social-whatsapp .social-icon .phone {
  fill: #ffffff;
}
.social-whatsapp {
  margin-right: 120px; /* adjust size as desired */
}

.social-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.22);
  opacity: 0.96;
}

/* ============================================================
   PERSONA RAIL (RA · DZI · MA) + PDF + CLEAR
   ============================================================ */

/* PDF link – sits just under the SOURCES · HOUSE OF WISDOM bar */
.rail-pdf-link {
  position: fixed;
  right: 12px;
  top: 184px; /* lowered slightly so it doesn't touch the SOURCES border */
  font-size: 10px;
  text-decoration: none;
  color: #f97316;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid rgba(249, 115, 22, 0.8);
  background: radial-gradient(circle at 30% 0,
    #111827 0%, #020617 55%, #000 100%);
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.8);
  z-index: 2605;
  opacity: 0.96;
}

.rail-pdf-link:hover {
  opacity: 1;
  transform: translateY(-1px);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.9);
}

@media (max-width: 640px) {
  .rail-pdf-link {
    right: 8px;
    top: 184px;
  }
}

/* CLEAR CHAT – under the PDF, pushed to the right margin so it never covers text */
.rail-clear-btn {
  position: fixed;
  right: 12px;          /* move to the right edge, out of the text column */
  top: 218px;           /* just below the PDF chip */
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.7);
  background: radial-gradient(circle at 40% 0%,
    #111827 0%, #020617 60%, #000 100%);
  color: #e5e7eb;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.7);
  z-index: 2610;        /* above persona pills */
  opacity: 0.9;
}

.rail-clear-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.8);
  opacity: 1;
}

.rail-clear-btn:active {
  transform: translateY(1px) scale(0.97);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
}

@media (max-width: 640px) {
  .rail-clear-btn {
    right: 8px;
    top: 218px;
    font-size: 8px;
    padding: 3px 8px;
  }
}

/* Persona pills near the bottom */
.persona-rail {
  position: fixed;
  right: 10px;
  bottom: 78px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 2600;
  pointer-events: none;
}

.persona-pill {
  pointer-events: auto;
  width: 44px;
  height: 44px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  font-weight: 700;
  font-size: 0.8rem;
  color: #111827;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  text-shadow: 0 0 4px rgba(255, 255, 255, 0.85);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.7);
  transition: transform 0.12s ease, box-shadow 0.12s ease, opacity 0.12s ease;
}

/* RA */
.persona-pill-ra {
  background: radial-gradient(
    circle at 30% 0,
    #fff9c4 0%,
    #ffe082 30%,
    #ffca28 55%,
    #ffb300 75%,
    #ff8f00 100%
  );
}

/* DZI */
.persona-pill-dzi {
  background: radial-gradient(
    circle at 30% 0,
    #e0f7ff 0%,
    #81d4fa 30%,
    #29b6f6 55%,
    #0288d1 100%
  );
}

/* MA */
.persona-pill-ma {
  background: radial-gradient(
    circle at 30% 0,
    #f3e5f5 0%,
    #ce93d8 35%,
    #ab47bc 65%,
    #8e24aa 100%
  );
}

.persona-pill.active {
  transform: translateY(-1px);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.6),
    0 10px 24px rgba(0, 0, 0, 0.9);
}

@media (max-width: 640px) {
  .persona-rail {
    right: 6px;
    bottom: 72px;
    gap: 6px;
  }
  .persona-pill {
    width: 40px;
    height: 40px;
    font-size: 0.72rem;
  }
}

/* ============================================================
   HOUSE OF WISDOM · SOURCES
   ============================================================ */

/* Toggle bar just above chat window */
.witness-toggle-bar {
  background: #020617;
  border-bottom: 1px solid #111827;
  padding: 4px 10px;
  display: flex;
  justify-content: flex-end;
  position: relative;
  z-index: 1580;
}

.witness-toggle-bar.hidden {
  display: none;
}

.witness-toggle-btn {
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.9);
  background: radial-gradient(circle at 10% 0%, #0f172a 0%, #020617 70%);
  color: #e5e7eb;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  padding: 4px 10px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 6px 14px rgba(15, 23, 42, 0.7);
  transition: background 0.15s ease, transform 0.12s ease, box-shadow 0.12s ease;
}

.witness-toggle-btn:hover {
  background: radial-gradient(circle at 10% 0%, #111827 0%, #020617 70%);
  transform: translateY(-1px);
  box-shadow: 0 10px 20px rgba(15, 23, 42, 0.9);
}

/* Slide-up panel */
.witness-panel {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: 55vh;
  background: #020617;
  border-top: 2px solid var(--throne-accent);
  box-shadow: 0 -18px 40px rgba(0, 0, 0, 0.9);
  z-index: 6100;
  transform: translateY(100%);
  transition: transform 0.25s ease-out;
  padding: 10px 12px 12px;
  display: flex;
  flex-direction: column;
}

.witness-panel.hidden {
  transform: translateY(100%);
}

.witness-panel:not(.hidden) {
  transform: translateY(0);
}

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

.witness-title {
  font-size: 13px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--throne-accent-soft);
}

.witness-close-btn {
  background: none;
  border: none;
  color: var(--throne-accent);
  font-size: 20px;
  cursor: pointer;
}

.witness-content {
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-wrap;
  border-radius: 8px;
  border: 1px solid #111827;
  background: #000;
  padding: 8px 10px;
  max-height: 42vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* ================= HEADER / CONTROLS GLOW BY PERSONA =============== */

body.mode-ra .throne-header,
body.mode-ra .top-controls {
  border-color: rgba(250, 204, 21, 0.85);
  box-shadow: 0 0 20px rgba(250, 204, 21, 0.35);
}

body.mode-dzi .throne-header,
body.mode-dzi .top-controls {
  border-color: rgba(56, 189, 248, 0.9);
  box-shadow: 0 0 20px rgba(56, 189, 248, 0.35);
}

body.mode-ma .throne-header,
body.mode-ma .top-controls {
  border-color: rgba(232, 121, 249, 0.9);
  box-shadow: 0 0 20px rgba(232, 121, 249, 0.35);
}

/* Clear Chat button – legacy inline style (not used for rail) */
.clear-chat-button {
  border-radius: 999px;
  border: 1px solid #374151;
  background: #020617;
  color: #e5e7eb;
  font-size: 10px;
  padding: 5px 10px;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  cursor: pointer;
}

.clear-chat-button:hover {
  background: #111827;
}

/* ============================================================
   AUTH CONTAINER & BUTTONS
   ============================================================ */

.auth-container {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-right: 8px;
}

.auth-btn {
  padding: 6px 12px;
  border-radius: 6px;
  font-size: var(--font-xs);
  text-decoration: none;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  cursor: pointer;
  transition: all 0.15s ease;
}

.login-btn {
  background: transparent;
  color: var(--throne-accent);
  border: none;
  padding: 4px 6px;
  font-size: 0.65rem;
  font-weight: 600;
}

.login-btn:hover {
  text-decoration: underline;
}

.logout-btn {
  background: transparent;
  border: 1px solid #475569;
  color: #94a3b8;
}

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

.user-menu {
  display: flex;
  align-items: center;
  gap: 8px;
}

.user-menu.hidden {
  display: none;
}

.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid var(--throne-accent);
  object-fit: cover;
}

.user-name {
  color: #e5e7eb;
  font-size: var(--font-xs);
  max-width: 100px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 480px) {
  .auth-container {
    margin-right: 4px;
  }
  .auth-btn {
    padding: 4px 8px;
    font-size: 0.6rem;
  }
  .user-name {
    display: none;
  }
  .user-avatar {
    width: 24px;
    height: 24px;
  }
}

/* ============================================================
   CHAT HISTORY SIDEBAR
   ============================================================ */

.history-toggle-btn {
  position: fixed;
  left: 12px;
  top: 70px;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid #374151;
  background: #0f172a;
  color: #e5e7eb;
  cursor: pointer;
  z-index: 1800;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.history-toggle-btn.hidden {
  display: none;
}

.history-toggle-btn:hover {
  background: #1e293b;
  border-color: var(--throne-accent);
}

.history-toggle-btn svg {
  width: 18px;
  height: 18px;
}

.history-sidebar {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: 260px;
  max-width: 80vw;
  background: #0a0f1a;
  border-right: 1px solid #1e293b;
  z-index: 7000;
  display: flex;
  flex-direction: column;
  transform: translateX(-100%);
  transition: transform 0.25s ease;
  padding-top: max(12px, env(safe-area-inset-top, 12px));
}

.history-sidebar.hidden {
  transform: translateX(-100%);
}

.history-sidebar:not(.hidden) {
  transform: translateX(0);
}

.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid #1e293b;
}

.history-title {
  font-size: var(--font-sm);
  color: var(--throne-accent);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.history-close-btn {
  background: none;
  border: none;
  color: #94a3b8;
  font-size: 20px;
  cursor: pointer;
  padding: 4px;
}

.history-close-btn:hover {
  color: var(--throne-accent);
}

.new-chat-btn {
  margin: 12px 16px;
  padding: 10px;
  border-radius: 8px;
  border: 1px dashed #374151;
  background: transparent;
  color: #94a3b8;
  font-size: var(--font-sm);
  cursor: pointer;
  transition: all 0.15s ease;
}

.new-chat-btn:hover {
  border-color: var(--throne-accent);
  color: var(--throne-accent);
  background: rgba(250, 204, 21, 0.05);
}

.history-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.history-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  border-radius: 6px;
  margin-bottom: 4px;
  cursor: pointer;
  transition: background 0.12s ease;
}

.history-item:hover {
  background: #1e293b;
}

.history-item.active {
  background: rgba(250, 204, 21, 0.1);
  border-left: 3px solid var(--throne-accent);
}

.history-item-title {
  font-size: var(--font-sm);
  color: #e5e7eb;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-item-date {
  font-size: var(--font-xs);
  color: #64748b;
}

.history-item-delete {
  background: none;
  border: none;
  color: #64748b;
  font-size: 14px;
  cursor: pointer;
  padding: 4px;
  opacity: 0;
  transition: opacity 0.12s ease;
}

.history-item:hover .history-item-delete {
  opacity: 1;
}

.history-item-delete:hover {
  color: #ef4444;
}

/* History overlay for mobile */
.history-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 6900;
}

.history-overlay.active {
  display: block;
}

@media (max-width: 640px) {
  .history-toggle-btn {
    top: auto;
    bottom: 80px;
    left: 8px;
    width: 32px;
    height: 32px;
  }
  
  .history-sidebar {
    width: 85vw;
  }
}

/* ============================================================
   PRICING MODAL
   ============================================================ */

.pricing-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9000;
  padding: 16px;
}

.pricing-modal.hidden {
  display: none;
}

.pricing-modal-content {
  background: linear-gradient(180deg, #1a1a2e 0%, #0d0d1a 100%);
  border: 1px solid rgba(212, 175, 55, 0.3);
  border-radius: 16px;
  max-width: 700px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 24px;
}

.pricing-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.pricing-title {
  color: #d4af37;
  font-size: var(--font-2xl);
  font-weight: 700;
  margin: 0;
}

.pricing-close-btn {
  background: none;
  border: none;
  color: #94a3b8;
  font-size: 28px;
  cursor: pointer;
  padding: 4px 8px;
  line-height: 1;
}

.pricing-close-btn:hover {
  color: #fff;
}

.pricing-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 20px;
  margin-bottom: 20px;
}

.pricing-card {
  background: rgba(30, 41, 59, 0.5);
  border: 1px solid #334155;
  border-radius: 12px;
  padding: 24px;
  position: relative;
}

.pricing-card.featured {
  border-color: #d4af37;
  background: rgba(212, 175, 55, 0.08);
}

.featured-badge {
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(135deg, #d4af37, #b8860b);
  color: #000;
  font-size: 11px;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: 12px;
  text-transform: uppercase;
}

.pricing-card-header {
  text-align: center;
  margin-bottom: 20px;
}

.pricing-card-header h3 {
  color: #f5f5f5;
  font-size: var(--font-xl);
  margin: 0 0 8px 0;
}

.pricing-price {
  color: #d4af37;
  font-size: 36px;
  font-weight: 700;
}

.pricing-price span {
  font-size: 14px;
  font-weight: 400;
  color: #94a3b8;
}

.pricing-features {
  list-style: none;
  padding: 0;
  margin: 0 0 24px 0;
}

.pricing-features li {
  padding: 8px 0;
  color: #e5e7eb;
  font-size: var(--font-sm);
  display: flex;
  align-items: center;
  gap: 8px;
}

.pricing-features li::before {
  content: "✓";
  color: #22c55e;
  font-weight: bold;
}

.pricing-card-footer {
  text-align: center;
}

.current-plan-badge {
  display: inline-block;
  background: rgba(100, 116, 139, 0.3);
  color: #94a3b8;
  font-size: 12px;
  padding: 8px 16px;
  border-radius: 6px;
}

.subscribe-btn {
  background: linear-gradient(135deg, #d4af37, #b8860b);
  color: #000;
  border: none;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: var(--font-base);
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
  width: 100%;
}

.subscribe-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(212, 175, 55, 0.4);
}

.subscribe-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.manage-billing-btn {
  background: transparent;
  color: #d4af37;
  border: 1px solid #d4af37;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: var(--font-base);
  font-weight: 600;
  cursor: pointer;
  width: 100%;
}

.manage-billing-btn:hover {
  background: rgba(212, 175, 55, 0.1);
}

.manage-billing-btn.hidden {
  display: none;
}

.pricing-note {
  text-align: center;
  color: #64748b;
  font-size: var(--font-xs);
  margin: 0;
}

.upgrade-btn, .billing-btn {
  background: linear-gradient(135deg, #d4af37, #b8860b);
  color: #000 !important;
  font-weight: 600;
  padding: 3px 6px;
  border-radius: 3px;
  font-size: 9px;
  border: none;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}

.upgrade-btn:hover, .billing-btn:hover {
  opacity: 0.9;
}

.upgrade-btn.hidden, .billing-btn.hidden {
  display: none;
}

/* ============================================================
   WELCOME MESSAGE MODAL
   ============================================================ */

.welcome-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 20px;
}

.welcome-modal {
  background: linear-gradient(180deg, #1a1a2e 0%, #0d0d1a 100%);
  border: 2px solid #d4af37;
  border-radius: 16px;
  padding: 32px;
  text-align: center;
  max-width: 400px;
  width: 100%;
  box-shadow: 0 0 40px rgba(212, 175, 55, 0.3);
}

.welcome-logo {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  border: 3px solid #d4af37;
  margin-bottom: 16px;
}

.welcome-title {
  color: #d4af37;
  font-size: 1.75rem;
  font-weight: 700;
  margin: 0 0 16px 0;
}

.welcome-text {
  color: #e5e7eb;
  font-size: 1rem;
  line-height: 1.6;
  margin: 0 0 12px 0;
}

.welcome-subtitle {
  color: #94a3b8;
  font-size: 0.875rem;
  font-style: italic;
  margin: 0 0 24px 0;
}

.welcome-btn {
  background: linear-gradient(135deg, #d4af37, #b8860b);
  color: #000;
  border: none;
  padding: 14px 32px;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.welcome-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(212, 175, 55, 0.5);
}

/* Upgrade Prompt Modal */
.upgrade-prompt {
  max-width: 420px;
}

.upgrade-benefits {
  list-style: none;
  padding: 0;
  margin: 16px 0;
  text-align: left;
}

.upgrade-benefits li {
  color: #e5e7eb;
  font-size: 0.95rem;
  padding: 8px 0;
  padding-left: 28px;
  position: relative;
}

.upgrade-benefits li::before {
  content: "✦";
  color: #d4af37;
  position: absolute;
  left: 0;
  font-size: 0.85rem;
}

.upgrade-prompt-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 8px;
}

.upgrade-later-btn {
  background: transparent;
  color: #94a3b8;
  border: 1px solid #374151;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.15s ease;
}

.upgrade-later-btn:hover {
  border-color: #d4af37;
  color: #d4af37;
}