:root {
  --emerald-950: #0b1c3f;
  --emerald-900: #122d66;
  --emerald-800: #1d4ed8;
  --emerald-700: #2563eb;
  --emerald-50: #eff6ff;
  --gold-600: #a67c24;
  --gold-500: #c89b3c;
  --gold-300: #e5c985;
  --gold-100: #fbf3de;
  --paper: #f4f7fc;
  --surface: #ffffff;
  --border: #dbeafe;
  --border-strong: #93c5fd;
  --ink: #0f172a;
  --ink-muted: #475569;
  --highlight-bg: #ffe793;
  --highlight-border: #d9a01b;
  --shadow-sm: 0 2px 10px rgba(29, 78, 216, 0.06);
  --shadow-md: 0 10px 30px rgba(29, 78, 216, 0.10);
  --shadow-lg: 0 20px 55px rgba(15, 23, 42, 0.14);
  --radius-md: 14px;
  --radius-lg: 22px;
  --font-ui: "Segoe UI", "Cairo", Tahoma, Arial, sans-serif;
  --font-quran: "Amiri", "Traditional Arabic", "Sakkal Majalla", "Simplified Arabic", "Segoe UI", serif;
}

*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background-color: var(--paper);
  color: var(--ink);
  font-family: var(--font-ui);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

.hidden {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

/* ==================== SCREENS ==================== */
.screen {
  display: none;
  min-height: 100vh;
}

.screen--active {
  display: block;
  animation: fadeIn 0.28s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ==================== WELCOME SCREEN ==================== */
#welcomeScreen.screen--active {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px 18px;
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(circle at 15% 15%, rgba(200, 155, 60, 0.16), transparent 42%),
    radial-gradient(circle at 85% 85%, rgba(29, 78, 216, 0.14), transparent 45%),
    linear-gradient(160deg, #f8fafc 0%, #e2ecff 100%);
}

.welcome-card {
  position: relative;
  width: 100%;
  max-width: 680px;
  background: var(--surface);
  border: 1.5px solid var(--border-strong);
  border-radius: 28px;
  padding: 46px 40px 38px;
  text-align: center;
  box-shadow: var(--shadow-lg);
}

.welcome-card::before {
  content: "";
  position: absolute;
  inset: 10px;
  border: 1px solid rgba(200, 155, 60, 0.35);
  border-radius: 20px;
  pointer-events: none;
}

.emblem {
  margin-bottom: 14px;
}

.bismillah {
  font-family: var(--font-quran);
  font-size: 32px;
  color: var(--emerald-900);
  margin: 0 0 12px;
  font-weight: 700;
}

.welcome-title {
  margin: 0 0 14px;
  font-size: 32px;
  font-weight: 800;
  color: var(--emerald-950);
  letter-spacing: -0.01em;
}

.welcome-subtitle {
  margin: 0 auto 28px;
  max-width: 540px;
  font-size: 17px;
  color: var(--ink-muted);
  line-height: 1.85;
}

.welcome-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 30px;
}

.stat-pill {
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 10px;
}

.stat-num {
  display: block;
  font-size: 22px;
  font-weight: 800;
  color: var(--emerald-900);
}

.stat-label {
  display: block;
  font-size: 13px;
  color: var(--ink-muted);
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: linear-gradient(135deg, var(--emerald-900), var(--emerald-700));
  color: #ffffff;
  border: none;
  border-radius: 16px;
  font-family: var(--font-ui);
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(29, 78, 216, 0.28);
  transition: transform 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 30px rgba(29, 78, 216, 0.36);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-enter {
  padding: 16px 56px;
  font-size: 21px;
}

.welcome-sources {
  margin: 26px 0 0;
  font-size: 12.5px;
  color: var(--ink-muted);
  border-top: 1px solid var(--border);
  padding-top: 16px;
}

/* ==================== TOP BAR ==================== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgba(29, 78, 216, 0.97);
  color: #ffffff;
  border-bottom: 2px solid var(--gold-500);
  backdrop-filter: blur(8px);
}

.topbar-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 13px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  font-size: 28px;
  color: var(--gold-300);
  line-height: 1;
}

.brand-title {
  font-size: 19px;
  font-weight: 800;
  line-height: 1.3;
}

.brand-sub {
  font-size: 12.5px;
  color: rgba(255, 255, 255, 0.8);
}

.btn-ghost {
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 10px;
  padding: 8px 16px;
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease;
}

.btn-ghost:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.22);
}

.btn-ghost:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-gold-outline {
  background: rgba(200, 155, 60, 0.16);
  color: #fbe6b0;
  border: 1px solid var(--gold-500);
  border-radius: 10px;
  padding: 8px 16px;
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease;
}

.btn-gold-outline:hover {
  background: rgba(200, 155, 60, 0.3);
}

.btn-back {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--gold-500);
  color: var(--emerald-950);
  border: none;
  border-radius: 10px;
  padding: 9px 18px;
  font-family: var(--font-ui);
  font-size: 14.5px;
  font-weight: 700;
  cursor: pointer;
  transition: filter 0.15s ease;
}

.btn-back:hover {
  filter: brightness(1.07);
}

.detail-nav-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* ==================== SEARCH AREA ==================== */
.search-container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 28px 22px 48px;
}

.search-box-wrap {
  margin-bottom: 22px;
}

.search-input-shell {
  position: relative;
  display: flex;
  align-items: center;
  background: var(--surface);
  border: 2.5px solid var(--emerald-800);
  border-radius: 18px;
  box-shadow: var(--shadow-md);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.search-input-shell:focus-within {
  border-color: var(--gold-500);
  box-shadow: 0 0 0 4px rgba(200, 155, 60, 0.22), var(--shadow-md);
}

.search-icon {
  margin-right: 18px;
  color: var(--emerald-800);
  flex-shrink: 0;
}

.search-input {
  width: 100%;
  border: none;
  outline: none;
  background: transparent;
  padding: 18px 14px 18px 50px;
  font-family: var(--font-ui);
  font-size: 22px;
  font-weight: 600;
  color: var(--ink);
}

.search-input::placeholder {
  color: #8b9a94;
  font-weight: 400;
}

.btn-clear {
  position: absolute;
  left: 14px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  background: #edf1ef;
  color: var(--ink);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-clear:hover {
  background: #dce4e0;
}

.search-hint {
  margin: 10px 6px 0;
  font-size: 13.5px;
  color: var(--ink-muted);
}

/* ==================== RESULTS PANEL ==================== */
.results-panel {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 22px;
  padding: 22px;
  min-height: 440px;
  box-shadow: var(--shadow-sm);
}

.results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding-bottom: 16px;
  margin-bottom: 18px;
  border-bottom: 1.5px solid var(--border);
}

.results-summary {
  font-size: 17px;
  font-weight: 700;
  color: var(--emerald-900);
}

.results-tip {
  font-size: 13.5px;
  color: var(--gold-600);
  background: var(--gold-100);
  padding: 5px 12px;
  border-radius: 999px;
  font-weight: 600;
}

.empty-prompt, .no-results {
  text-align: center;
  padding: 56px 18px;
}

.empty-ornament, .no-results-icon {
  font-size: 40px;
  color: var(--gold-500);
  margin-bottom: 10px;
}

.empty-prompt h2, .no-results h3 {
  margin: 0 0 8px;
  font-size: 22px;
  color: var(--emerald-950);
}

.empty-prompt p, .no-results p {
  margin: 0 0 22px;
  color: var(--ink-muted);
  font-size: 16px;
}

.quick-examples {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
}

.examples-label {
  font-size: 14px;
  color: var(--ink-muted);
  font-weight: 600;
}

.chip {
  background: var(--emerald-50);
  color: var(--emerald-900);
  border: 1px solid rgba(29, 78, 216, 0.22);
  border-radius: 999px;
  padding: 7px 18px;
  font-family: var(--font-ui);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.12s ease;
}

.chip:hover {
  background: var(--emerald-900);
  color: #ffffff;
  transform: translateY(-1px);
}

.results-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.result-card {
  display: block;
  width: 100%;
  text-align: right;
  text-decoration: none;
  color: inherit;
  background: #fdfcf9;
  border: 1.5px solid var(--border);
  border-right: 5px solid var(--emerald-800);
  border-radius: 16px;
  padding: 18px 22px;
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.14s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.result-card:hover, .result-card:focus-visible {
  outline: none;
  background: #ffffff;
  border-color: var(--gold-500);
  border-right-color: var(--gold-500);
  transform: translateY(-2px);
  box-shadow: 0 8px 22px rgba(29, 78, 216, 0.10);
}

.result-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.result-ref {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 800;
  color: var(--emerald-900);
}

.result-submeta {
  font-size: 12.5px;
  color: var(--ink-muted);
  font-weight: 600;
}

.result-link-cta {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--emerald-700);
  background: var(--emerald-50);
  padding: 4px 12px;
  border-radius: 999px;
}

.result-card:hover .result-link-cta {
  background: var(--emerald-900);
  color: #ffffff;
}

.result-ayah-text {
  font-family: var(--font-quran);
  font-size: 27px;
  line-height: 2.05;
  color: var(--ink);
  margin: 0;
}

.result-ayah-num {
  display: inline-block;
  font-family: var(--font-ui);
  font-size: 15px;
  font-weight: 700;
  color: var(--gold-600);
  margin-right: 6px;
}

mark.hl {
  background: var(--highlight-bg);
  color: #102a1f;
  padding: 0 4px;
  border-radius: 6px;
  border-bottom: 2px solid var(--highlight-border);
}

.load-more-wrap {
  text-align: center;
  margin-top: 22px;
}

.btn-secondary {
  background: var(--emerald-50);
  color: var(--emerald-900);
  border: 1.5px solid var(--emerald-800);
  border-radius: 12px;
  padding: 12px 30px;
  font-family: var(--font-ui);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
}

.btn-secondary:hover {
  background: var(--emerald-900);
  color: #ffffff;
}

/* ==================== DETAIL SCREEN ==================== */
.detail-container {
  max-width: 1020px;
  margin: 0 auto;
  padding: 28px 22px 60px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.ayah-hero-card {
  background: linear-gradient(180deg, #ffffff 0%, #fcf9f1 100%);
  border: 2px solid var(--border-strong);
  border-radius: 22px;
  padding: 26px 28px 30px;
  box-shadow: var(--shadow-md);
}

.ayah-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 20px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.ayah-badges {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.badge {
  display: inline-block;
  padding: 5px 14px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 700;
}

.badge--emerald {
  background: var(--emerald-900);
  color: #ffffff;
}

.badge--gold {
  background: var(--gold-100);
  color: var(--gold-600);
  border: 1px solid var(--gold-300);
}

.badge--soft {
  background: var(--paper);
  color: var(--ink-muted);
  border: 1px solid var(--border);
}

.script-toggle {
  display: inline-flex;
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 3px;
}

.toggle-btn {
  border: none;
  background: transparent;
  color: var(--ink-muted);
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
}

.toggle-btn--active {
  background: var(--emerald-900);
  color: #ffffff;
}

.detail-ayah-text {
  font-family: var(--font-quran);
  font-size: 35px;
  line-height: 2.2;
  color: var(--emerald-950);
  text-align: center;
  padding: 8px 6px;
}

.info-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 20px;
  padding: 24px 26px;
  box-shadow: var(--shadow-sm);
}

.info-card--meanings {
  border-top: 4px solid var(--gold-500);
}

.info-card--tafsir {
  border-top: 4px solid var(--emerald-800);
}

.info-card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.info-card-header--wrap {
  justify-content: space-between;
  flex-wrap: wrap;
}

.info-header-title {
  display: flex;
  align-items: center;
  gap: 12px;
}

.info-icon {
  font-size: 26px;
}

.info-card-header h2 {
  margin: 0;
  font-size: 21px;
  font-weight: 800;
  color: var(--emerald-950);
}

.info-source {
  margin: 2px 0 0;
  font-size: 13px;
  color: var(--ink-muted);
}

.info-body {
  font-size: 18px;
  line-height: 2;
  color: var(--ink);
  white-space: pre-line;
}

.tafsir-tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.tab-btn {
  border: 1px solid var(--border-strong);
  background: var(--paper);
  color: var(--ink);
  border-radius: 999px;
  padding: 6px 14px;
  font-family: var(--font-ui);
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
}

.tab-btn--active {
  background: var(--emerald-900);
  color: #ffffff;
  border-color: var(--emerald-900);
}

.tafsir-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.tafsir-block {
  background: #fdfcf8;
  border: 1px solid var(--border);
  border-right: 4px solid var(--emerald-700);
  border-radius: 14px;
  padding: 16px 20px;
}

.tafsir-block-title {
  font-size: 16px;
  font-weight: 800;
  color: var(--emerald-900);
  margin: 0 0 8px;
}

.tafsir-block-text {
  margin: 0;
  font-size: 17.5px;
  line-height: 2;
  color: var(--ink);
  white-space: pre-line;
}

/* ==================== TOAST ==================== */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--emerald-950);
  color: #ffffff;
  padding: 12px 24px;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  z-index: 99;
}

@media (max-width: 640px) {
  .welcome-card { padding: 32px 20px 28px; }
  .welcome-title { font-size: 25px; }
  .welcome-stats { grid-template-columns: 1fr; }
  .search-input { font-size: 18px; }
  .result-ayah-text { font-size: 22px; }
  .detail-ayah-text { font-size: 26px; }
}
