:root {
  color-scheme: light dark;
  --ink: #0f1b1f;
  --muted: #5b6b72;
  --paper: #f8f4ec;
  --panel: #ffffff;
  --accent: #c57a2b;
  --accent-2: #1f8a70;
  --accent-3: #e0b25f;
  --shadow: 0 24px 60px rgba(15, 27, 31, 0.14);
  --soft-shadow: 0 12px 30px rgba(15, 27, 31, 0.08);
  --radius: 18px;
}

.theme-dark {
  color-scheme: dark;
  --ink: #e6efef;
  --muted: #a5b3b8;
  --paper: #0c1214;
  --panel: #141c1f;
  --accent: #d89435;
  --accent-2: #3bb79d;
  --accent-3: #efc36c;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
  --soft-shadow: 0 12px 30px rgba(0, 0, 0, 0.32);
}

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

html,
body {
  margin: 0;
  padding: 0;
  font-family: "Manrope", "Segoe UI", system-ui, sans-serif;
  color: var(--ink);
  background: var(--paper);
}

body {
  min-height: 100vh;
  line-height: 1.6;
  position: relative;
  overflow-x: hidden;
}

.aurora {
  position: fixed;
  inset: -20% -10% auto -10%;
  height: 65vh;
  background: radial-gradient(
      circle at 20% 20%,
      rgba(224, 178, 95, 0.28),
      transparent 55%
    ),
    radial-gradient(
      circle at 80% 10%,
      rgba(31, 138, 112, 0.24),
      transparent 60%
    ),
    linear-gradient(135deg, rgba(197, 122, 43, 0.12), transparent 60%);
  filter: blur(10px);
  z-index: -1;
  animation: float 12s ease-in-out infinite alternate;
}

.ornaments {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -1;
}

.orb {
  position: absolute;
  border-radius: 999px;
  background: radial-gradient(
    circle,
    rgba(31, 138, 112, 0.25),
    transparent 65%
  );
  filter: blur(2px);
  animation: drift 16s ease-in-out infinite;
}

.orb-one {
  width: 180px;
  height: 180px;
  top: 12%;
  right: 12%;
}

.orb-two {
  width: 220px;
  height: 220px;
  bottom: 8%;
  left: 10%;
  animation-delay: -4s;
  background: radial-gradient(
    circle,
    rgba(197, 122, 43, 0.22),
    transparent 65%
  );
}

.orb-three {
  width: 140px;
  height: 140px;
  bottom: 28%;
  right: 22%;
  animation-delay: -8s;
}

@keyframes drift {
  0% {
    transform: translateY(0) scale(1);
  }
  50% {
    transform: translateY(-18px) scale(1.04);
  }
  100% {
    transform: translateY(12px) scale(0.98);
  }
}

@keyframes float {
  0% {
    transform: translateY(0) scale(1);
  }
  100% {
    transform: translateY(-30px) scale(1.02);
  }
}

h1,
h2,
h3,
h4 {
  font-family: "Cinzel", "Times New Roman", serif;
  letter-spacing: 0.02em;
  margin: 0 0 0.6rem 0;
}

p {
  margin: 0 0 1rem 0;
  color: var(--muted);
}

a {
  color: inherit;
  text-decoration: none;
}

.site-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem 6vw;
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(248, 244, 236, 0.92);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(15, 27, 31, 0.08);
}

.brand {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.logo {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--accent-2), var(--accent));
  color: #fff;
  font-weight: 700;
  letter-spacing: 0.08em;
  box-shadow: var(--soft-shadow);
}

.brand-text {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.brand-title {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--ink);
}

.brand-subtitle {
  font-size: 0.85rem;
  color: var(--muted);
}

.site-nav {
  display: flex;
  gap: 1.5rem;
  font-weight: 600;
  color: var(--muted);
}

.site-nav a {
  position: relative;
  padding-bottom: 0.2rem;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.8rem;
}

.theme-toggle {
  padding: 0.5rem 1rem;
  border-radius: 999px;
  border: 1px solid rgba(15, 27, 31, 0.2);
  background: rgba(31, 138, 112, 0.08);
  color: var(--ink);
  font-weight: 600;
  cursor: pointer;
}

.site-nav a::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  width: 0%;
  height: 2px;
  background: var(--accent);
  transition: width 0.25s ease;
}

.site-nav a:hover::after {
  width: 100%;
}

main {
  padding: 2rem 6vw 5rem;
  display: flex;
  flex-direction: column;
  gap: 3.5rem;
}

.hero {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 2rem;
  align-items: center;
}

.hero-content {
  animation: rise 0.9s ease-out both;
}

@keyframes rise {
  0% {
    opacity: 0;
    transform: translateY(24px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.2em;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent-2);
}

.hero h1 {
  font-size: clamp(2.2rem, 3vw, 3.4rem);
  color: var(--ink);
}

.lead {
  font-size: 1.05rem;
}

.hero-actions {
  display: flex;
  gap: 1rem;
  margin: 1.5rem 0;
  flex-wrap: wrap;
}

.primary,
.ghost,
button.primary,
button.ghost {
  padding: 0.8rem 1.6rem;
  border-radius: 999px;
  border: none;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-3));
  color: #fff;
  box-shadow: var(--soft-shadow);
  background-size: 160% 160%;
  animation: glow 6s ease-in-out infinite;
}

.ghost {
  background: rgba(31, 138, 112, 0.1);
  color: var(--ink);
  border: 1px solid rgba(31, 138, 112, 0.25);
}

.primary:hover,
.ghost:hover,
button.primary:hover,
button.ghost:hover {
  transform: translateY(-2px);
}

@keyframes glow {
  0% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0% 50%;
  }
}

.hero-metrics {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.metric-value {
  display: block;
  font-weight: 700;
  color: var(--ink);
}

.metric-label {
  font-size: 0.85rem;
  color: var(--muted);
}

.hero-card {
  background: var(--panel);
  padding: 2rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid rgba(15, 27, 31, 0.08);
  animation: rise 0.9s ease-out 0.1s both;
}

.hero-card ul {
  padding-left: 1.2rem;
  margin: 1rem 0 2rem;
  color: var(--muted);
}

.hero-card-footer {
  font-size: 0.85rem;
  color: var(--muted);
  border-top: 1px solid rgba(15, 27, 31, 0.08);
  padding-top: 1rem;
}

.panel {
  background: var(--panel);
  padding: 2.5rem;
  border-radius: var(--radius);
  box-shadow: var(--soft-shadow);
  border: 1px solid rgba(15, 27, 31, 0.08);
  animation: panelReveal 0.7s ease-out both;
}

@keyframes panelReveal {
  0% {
    opacity: 0;
    transform: translateY(18px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

.panel-header {
  display: flex;
  justify-content: space-between;
  gap: 1.5rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}

.rate-limit {
  font-weight: 600;
  color: var(--accent-2);
  background: rgba(31, 138, 112, 0.08);
  padding: 0.6rem 1rem;
  border-radius: 999px;
  align-self: center;
}

.search-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.4rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-weight: 600;
  color: var(--ink);
}

.field.wide {
  grid-column: 1 / -1;
  position: relative;
}

.field.small {
  max-width: 180px;
}

label {
  font-weight: 600;
}

input,
select {
  padding: 0.8rem 0.9rem;
  border-radius: 12px;
  border: 1px solid rgba(15, 27, 31, 0.2);
  font-family: inherit;
  font-size: 0.95rem;
  background: var(--panel);
  color: var(--ink);
}

input:focus,
select:focus {
  outline: 2px solid rgba(197, 122, 43, 0.2);
  border-color: rgba(197, 122, 43, 0.5);
}

small {
  font-size: 0.75rem;
  color: var(--muted);
}

.actions {
  display: flex;
  gap: 1rem;
  align-items: flex-end;
  flex-wrap: wrap;
}

.filters {
  grid-column: 1 / -1;
  background: rgba(248, 244, 236, 0.6);
  border-radius: 14px;
  padding: 1rem 1.4rem;
  border: 1px dashed rgba(15, 27, 31, 0.15);
}

.filters summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--accent-2);
}

.filters-grid {
  margin-top: 1rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}

.checkbox {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 600;
  color: var(--muted);
}

.suggestions {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: #fff;
  border-radius: 14px;
  box-shadow: var(--soft-shadow);
  border: 1px solid rgba(15, 27, 31, 0.12);
  margin-top: 0.4rem;
  z-index: 5;
  display: none;
  max-height: 260px;
  overflow-y: auto;
}

.suggestions.active {
  display: block;
}

.suggestion-item {
  padding: 0.8rem 1rem;
  border-bottom: 1px solid rgba(15, 27, 31, 0.06);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.suggestion-item:last-child {
  border-bottom: none;
}

.suggestion-item strong {
  color: var(--ink);
  font-weight: 600;
}

.suggestion-item span {
  font-size: 0.8rem;
  color: var(--muted);
}

.results {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.results-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1.2rem;
  flex-wrap: wrap;
}

.status {
  padding: 0.6rem 1rem;
  border-radius: 999px;
  background: rgba(197, 122, 43, 0.1);
  color: var(--ink);
  font-weight: 600;
}

.status[data-tone="success"] {
  background: rgba(31, 138, 112, 0.15);
  color: var(--accent-2);
}

.status[data-tone="error"] {
  background: rgba(197, 44, 44, 0.12);
  color: #a32828;
}

.status[data-tone="warning"] {
  background: rgba(224, 178, 95, 0.2);
  color: #8a5a15;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.6rem;
  grid-auto-flow: dense;
  align-items: start;
}

.card {
  background: var(--panel);
  border-radius: var(--radius);
  padding: 1.6rem;
  box-shadow: var(--soft-shadow);
  border: 1px solid rgba(15, 27, 31, 0.08);
  display: flex;
  flex-direction: column;
  gap: 1rem;
  animation: cardRise 0.5s ease-out both;
  position: relative;
  overflow: hidden;
  align-self: start;
}

.card.wide {
  grid-column: span 2;
}

@keyframes cardRise {
  0% {
    opacity: 0;
    transform: translateY(16px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

.card::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(
    140deg,
    rgba(197, 122, 43, 0.08),
    transparent 45%,
    rgba(31, 138, 112, 0.08)
  );
  opacity: 0;
  transition: opacity 0.4s ease;
  pointer-events: none;
}

.card:hover::after {
  opacity: 1;
}

.hadith-text {
  position: relative;
  display: -webkit-box;
  -webkit-line-clamp: 7;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card.expanded .hadith-text {
  display: block;
  overflow: visible;
}

.fade-hint {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 2.2rem;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0), var(--panel));
  opacity: 0;
  transition: opacity 0.3s ease;
}

.card.clamped .fade-hint {
  opacity: 1;
}

.card.expanded .fade-hint {
  opacity: 0;
}

.expand-btn {
  align-self: flex-start;
  padding: 0.4rem 0.9rem;
  border-radius: 999px;
  border: 1px solid rgba(15, 27, 31, 0.12);
  background: #fff;
  cursor: pointer;
  font-weight: 600;
}

.card .meta {
  display: grid;
  gap: 0.4rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.6rem;
  border-radius: 999px;
  font-size: 0.75rem;
  background: rgba(31, 138, 112, 0.12);
  color: var(--accent-2);
  font-weight: 600;
}

.card-actions {
  display: flex;
  gap: 0.8rem;
  flex-wrap: wrap;
  margin-top: auto;
}

.card-actions button {
  padding: 0.5rem 1rem;
  border-radius: 999px;
  border: 1px solid rgba(15, 27, 31, 0.12);
  background: #fff;
  cursor: pointer;
  font-weight: 600;
}

.pagination {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  justify-content: center;
}

.pagination button {
  padding: 0.5rem 1rem;
  border-radius: 999px;
  border: none;
  background: rgba(15, 27, 31, 0.08);
  cursor: pointer;
  font-weight: 600;
}

.pagination-jump {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.pagination-jump input {
  width: 110px;
  padding: 0.45rem 0.6rem;
  border-radius: 999px;
  border: 1px solid rgba(15, 27, 31, 0.2);
  background: var(--panel);
  color: var(--ink);
}

.pagination-jump button {
  padding: 0.45rem 0.9rem;
}

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

.collections .collection-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.5rem;
}

.collection-card {
  background: rgba(248, 244, 236, 0.8);
  border-radius: 16px;
  padding: 1.5rem;
  border: 1px solid rgba(15, 27, 31, 0.08);
  display: flex;
  flex-direction: column;
  gap: 1rem;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.collection-card:hover {
  transform: translateY(-6px);
  box-shadow: var(--soft-shadow);
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }
}

.lookup-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  align-items: end;
  margin-bottom: 1.5rem;
}

.focus-card {
  padding: 1.5rem;
  border-radius: 16px;
  background: rgba(31, 138, 112, 0.08);
  border: 1px solid rgba(31, 138, 112, 0.2);
  min-height: 120px;
}

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

.site-footer {
  padding: 2.5rem 6vw 3rem;
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1.5rem;
  background: #f3eee5;
  border-top: 1px solid rgba(15, 27, 31, 0.08);
}

.focus-modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 50;
}

.focus-modal.active {
  display: flex;
}

.focus-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(12, 18, 20, 0.6);
}

.focus-modal-panel {
  position: relative;
  background: var(--panel);
  border-radius: 20px;
  padding: 1.5rem;
  width: min(920px, 92vw);
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
  border: 1px solid rgba(15, 27, 31, 0.1);
}

.focus-modal-close {
  position: sticky;
  top: 0;
  margin-left: auto;
  padding: 0.45rem 0.9rem;
  border-radius: 999px;
  border: 1px solid rgba(15, 27, 31, 0.2);
  background: rgba(31, 138, 112, 0.1);
  color: var(--ink);
  font-weight: 600;
  cursor: pointer;
}

.modal-open {
  overflow: hidden;
}

.footer-meta {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  font-size: 0.9rem;
  color: var(--muted);
}

.theme-dark body {
  background: var(--paper);
}

.theme-dark .aurora {
  background: radial-gradient(
      circle at 20% 20%,
      rgba(216, 148, 53, 0.2),
      transparent 55%
    ),
    radial-gradient(
      circle at 80% 10%,
      rgba(59, 183, 157, 0.2),
      transparent 60%
    ),
    linear-gradient(135deg, rgba(216, 148, 53, 0.14), transparent 60%);
}

.theme-dark .orb {
  background: radial-gradient(
    circle,
    rgba(59, 183, 157, 0.18),
    transparent 65%
  );
}

.theme-dark .orb-two {
  background: radial-gradient(
    circle,
    rgba(216, 148, 53, 0.18),
    transparent 65%
  );
}

.theme-dark .site-header {
  background: rgba(12, 18, 20, 0.9);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.theme-dark .panel,
.theme-dark .hero-card,
.theme-dark .card,
.theme-dark .collection-card,
.theme-dark .focus-card {
  border-color: rgba(255, 255, 255, 0.08);
}

.theme-dark .filters {
  background: rgba(20, 28, 31, 0.6);
  border-color: rgba(255, 255, 255, 0.08);
}

.theme-dark .collection-card {
  background: rgba(20, 28, 31, 0.8);
}

.theme-dark input,
.theme-dark select {
  border-color: rgba(255, 255, 255, 0.14);
}

.theme-dark .suggestions {
  background: var(--panel);
  border-color: rgba(255, 255, 255, 0.12);
}

.theme-dark .suggestion-item {
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.theme-dark .card-actions button,
.theme-dark .expand-btn,
.theme-dark .pagination button {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.12);
  color: var(--ink);
}

.theme-dark .pagination-jump input,
.theme-dark .focus-modal-panel,
.theme-dark .focus-modal-close {
  border-color: rgba(255, 255, 255, 0.12);
}

.theme-dark h1,
.theme-dark h2,
.theme-dark h3,
.theme-dark h4 {
  color: #f4fbfb;
}

.theme-dark .site-footer {
  background: #0f1619;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.theme-dark .theme-toggle {
  background: rgba(59, 183, 157, 0.12);
  border-color: rgba(255, 255, 255, 0.18);
  color: var(--ink);
}

.chat-float {
  position: fixed;
  right: 2rem;
  bottom: 2rem;
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.85rem 1.4rem;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--accent-2), var(--accent));
  color: #fff;
  font-weight: 700;
  letter-spacing: 0.02em;
  box-shadow: 0 18px 40px rgba(15, 27, 31, 0.25);
  z-index: 20;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  animation: floatPulse 4.5s ease-in-out infinite;
}

.chat-float:hover {
  transform: translateY(-3px) scale(1.02);
  box-shadow: 0 22px 48px rgba(15, 27, 31, 0.32);
}

.chat-float-icon {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 0 0 6px rgba(255, 255, 255, 0.2);
}

@keyframes floatPulse {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-4px);
  }
}

@media (max-width: 800px) {
  .site-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }

  .site-nav {
    flex-wrap: wrap;
    gap: 1rem;
  }

  .card.wide {
    grid-column: auto;
  }
}

@media (max-width: 600px) {
  main {
    padding: 1.5rem 5vw 4rem;
  }

  .panel {
    padding: 1.8rem;
  }

  .actions {
    width: 100%;
  }

  .primary,
  .ghost,
  button.primary,
  button.ghost {
    width: 100%;
    justify-content: center;
  }

  .chat-float {
    right: 1.2rem;
    bottom: 1.2rem;
    padding: 0.75rem 1.1rem;
  }
}
