:root {
  --bg: #f3ecdf;
  --surface: #f8f2e7;
  --card: #fffdf8;
  --text: #2f2925;
  --muted: #7a7066;
  --green: #2f7b62;
  --green-dark: #245d4b;
  --gold: #d8bd80;
  --gold-deep: #c9aa66;
  --line: #e4d7bf;
  --shadow: 0 14px 34px rgba(42, 52, 44, 0.15);
}

:root[data-theme="dark"] {
  --bg: #1a0f07;
  --surface: #2b170c;
  --card: #3a2214;
  --text: #f2d9a6;
  --muted: #e8d7b5;
  --green: #2b170c;
  --green-dark: #1a0f07;
  --gold: #d4a84f;
  --gold-deep: #d4a84f;
  --line: #5a3620;
  --shadow: 0 16px 40px rgba(0, 0, 0, 0.33);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  position: relative;
  font-family: "Tajawal", sans-serif;
  color: var(--text);
  background: var(--bg);
  padding-bottom: 18px;
  overflow-x: hidden;
}

.pattern {
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  bottom: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 1;
  background: url("/assets/bg-islamic-mobile.svg") center top / cover no-repeat;
}

:root[data-theme="dark"] .pattern {
  opacity: 1;
  background: url("/assets/bg-islamic-mobile-dark.svg") center top / cover no-repeat;
}

.app {
  position: relative;
  z-index: 1;
  width: min(100%, 470px);
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 12px) 12px 16px;
}

.top-banner {
  position: relative;
  border-radius: 28px 28px 24px 24px;
  padding: 22px 16px 32px;
  background:
    linear-gradient(160deg, rgba(255, 255, 255, 0.08), transparent 45%),
    radial-gradient(circle at 20% 20%, rgba(255, 255, 255, 0.18), transparent 40%),
    var(--green);
  box-shadow: var(--shadow);
  border: 2px solid var(--gold-deep);
  overflow: hidden;
}

.top-banner::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.17;
  background-image:
    linear-gradient(30deg, rgba(255, 255, 255, 0.28) 8%, transparent 8.2%, transparent 92%, rgba(255, 255, 255, 0.28) 92.2%),
    linear-gradient(150deg, rgba(255, 255, 255, 0.24) 8%, transparent 8.2%, transparent 92%, rgba(255, 255, 255, 0.24) 92.2%);
  background-size: 28px 48px;
}

.menu-btn {
  position: absolute;
  top: 12px;
  inset-inline-end: 12px;
  z-index: 3;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 1px solid rgba(255, 250, 235, 0.55);
  background: rgba(255, 255, 255, 0.12);
  color: #fdf6e5;
  font-size: 1.45rem;
  line-height: 1;
  display: grid;
  place-items: center;
  cursor: pointer;
}

.theme-icon {
  font-size: 1.35rem;
  line-height: 1;
}

.brand {
  position: relative;
  z-index: 1;
  text-align: center;
}

.brand-icon {
  margin: 0;
  font-size: 1.5rem;
  line-height: 1;
}

h1 {
  margin: 5px 0 0;
  font-family: "Amiri", serif;
  color: #fef9ef;
  font-size: clamp(2.3rem, 9vw, 3rem);
  text-shadow: 0 4px 10px rgba(17, 47, 37, 0.45);
}

.banner-notch {
  position: absolute;
  left: 50%;
  bottom: -21px;
  width: 120px;
  height: 40px;
  transform: translateX(-50%);
  background: var(--green);
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  border-bottom: 3px solid var(--gold-deep);
}

.intro-section {
  margin-top: 34px;
  padding: 12px 14px;
  text-align: center;
}

.subtitle {
  margin: 0;
  font-size: 1.05rem;
  line-height: 1.7;
  color: var(--text);
  font-weight: 500;
}

.emotion-section {
  margin-top: 8px;
}

.emotion-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.emotion-grid button {
  border: 1px solid #d6c9b1;
  border-radius: 18px;
  background: linear-gradient(180deg, #fffefb, #f1ede4);
  box-shadow: 0 8px 20px rgba(105, 92, 68, 0.16);
  color: var(--text);
  padding: 10px 8px 9px;
  min-height: 88px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-size: 1.02rem;
  font-weight: 600;
}

:root[data-theme="dark"] .emotion-grid button {
  background: linear-gradient(180deg, var(--card), var(--surface));
  border-color: var(--line);
  color: var(--text);
}

.emotion-grid .emo {
  font-size: 2.05rem;
  line-height: 1;
}

.emotion-grid button.active {
  border-color: var(--gold-deep);
  box-shadow: 0 10px 24px rgba(47, 123, 98, 0.25);
  transform: translateY(-1px);
}

.primary-action {
  margin-top: 14px;
}

.random-cta {
  width: 100%;
  border: 2px solid var(--gold-deep);
  border-radius: 999px;
  padding: 12px 18px;
  background:
    linear-gradient(160deg, rgba(255, 255, 255, 0.1), transparent 40%),
    var(--green);
  color: #f8f2e7;
  font-size: 1.8rem;
  font-family: "Amiri", serif;
  line-height: 1.2;
  box-shadow: 0 10px 24px rgba(28, 76, 60, 0.28);
}

.inline-actions {
  margin-top: 10px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.inline-btn {
  border: 1px solid var(--gold-deep);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--green-dark);
  font-size: 1.2rem;
  font-family: "Amiri", serif;
  line-height: 1.2;
  padding: 10px 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.inline-badge {
  min-width: 20px;
  height: 20px;
  border-radius: 999px;
  background: var(--green);
  color: #fff;
  font-size: 0.74rem;
  font-family: "Tajawal", sans-serif;
  font-weight: 700;
  display: grid;
  place-items: center;
}

:root[data-theme="dark"] .inline-btn {
  background: linear-gradient(180deg, var(--card), var(--surface));
  color: var(--text);
  border-color: var(--gold);
}

:root[data-theme="dark"] .inline-badge {
  background: var(--gold);
  color: #2b170c;
}

.verse-card {
  margin-top: 14px;
  position: relative;
  border-radius: 20px;
  background: linear-gradient(180deg, var(--card), #f9f5ed);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  padding: 16px 12px 0;
  overflow: hidden;
}

:root[data-theme="dark"] .verse-card {
  background: linear-gradient(180deg, var(--card), var(--surface));
}

.verse-card::before,
.verse-card::after {
  content: "";
  position: absolute;
  width: 112px;
  height: 62px;
  border: 2px solid rgba(201, 170, 102, 0.36);
  pointer-events: none;
}

.verse-card::before {
  top: 8px;
  inset-inline-start: 8px;
  border-inline-end: none;
  border-bottom: none;
  border-radius: 12px 0 0 0;
}

.verse-card::after {
  top: 8px;
  inset-inline-end: 8px;
  border-inline-start: none;
  border-bottom: none;
  border-radius: 0 12px 0 0;
}

.verse-card.reveal {
  animation: reveal 0.45s ease;
}

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

.source-label {
  margin: 0;
  text-align: center;
  color: var(--gold-deep);
  font-size: 0.92rem;
}

.verse-text {
  margin: 10px 0 4px;
  text-align: center;
}

.verse-prefix,
.verse-body,
.verse-suffix {
  margin: 0;
  font-family: "Amiri", serif;
}

.verse-prefix,
.verse-suffix {
  color: var(--gold-deep);
  font-size: clamp(1.1rem, 4.2vw, 1.35rem);
  line-height: 1.8;
}

.verse-body {
  font-size: clamp(1.9rem, 8vw, 2.45rem);
  line-height: 1.95;
  color: var(--text);
}

.verse-prefix {
  margin-bottom: 4px;
}

.verse-suffix {
  margin-top: 6px;
}

.verse-meta {
  margin: 0;
  text-align: center;
  color: var(--green);
  font-size: 1.05rem;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
}

.card-actions {
  margin-top: 14px;
  border-top: 1px solid var(--line);
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.card-actions button {
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--green);
  font-size: 1.22rem;
  font-family: "Amiri", serif;
  padding: 11px 6px;
}

.card-actions button + button {
  border-inline-start: 1px solid var(--line);
}

:root[data-theme="dark"] .card-actions {
  border-top-color: #6a4328;
  background: linear-gradient(180deg, #3a2214, #2b170c);
}

:root[data-theme="dark"] .card-actions button {
  background: rgba(255, 255, 255, 0.02);
  color: var(--text);
}

:root[data-theme="dark"] .card-actions button + button {
  border-inline-start-color: #6a4328;
}

:root[data-theme="dark"] #shareBtn {
  color: var(--muted);
}

:root[data-theme="dark"] #saveBtn {
  color: var(--gold);
}

:root[data-theme="dark"] #copyBtn {
  color: var(--text);
}

:root[data-theme="dark"] .card-actions button:hover {
  background: rgba(212, 168, 79, 0.12);
}

.favorites {
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  padding: 12px;
}

.favorites h2 {
  margin: 0 0 10px;
  font-size: 1.06rem;
}

#favoritesList {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 8px;
}

#favoritesList li {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 9px;
  background: var(--card);
}

#favoritesList .mini-text {
  margin: 0;
  font-family: "Amiri", serif;
  font-size: 1.1rem;
  line-height: 1.8;
}

#favoritesList .mini-meta {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.84rem;
}

.empty {
  margin: 0;
  text-align: center;
  color: var(--muted);
}

footer {
  margin-top: 14px;
  text-align: center;
  color: var(--muted);
  font-size: 0.8rem;
}

footer p {
  margin: 8px 0 0;
}

.visit-counter {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 148px;
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.72);
  box-shadow: 0 10px 24px rgba(77, 63, 45, 0.1);
}

.visit-label {
  font-size: 0.82rem;
}

.visit-value {
  color: var(--green);
  font-size: 0.96rem;
  font-weight: 700;
}

:root[data-theme="dark"] .visit-counter {
  background: linear-gradient(180deg, rgba(58, 34, 20, 0.92), rgba(43, 23, 12, 0.92));
  border-color: var(--line);
  box-shadow: 0 12px 26px rgba(0, 0, 0, 0.24);
}

:root[data-theme="dark"] .visit-value {
  color: var(--gold);
}

footer a {
  color: var(--green);
}

button {
  cursor: pointer;
  transition: transform 0.16s ease, filter 0.16s ease;
}

button:active {
  transform: scale(0.98);
}

button:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

.toast {
  position: fixed;
  left: 50%;
  transform: translateX(-50%) translateY(120%);
  bottom: calc(12px + env(safe-area-inset-bottom));
  background: rgba(22, 34, 29, 0.95);
  color: #f7f2e7;
  border-radius: 999px;
  padding: 10px 14px;
  font-size: 0.84rem;
  box-shadow: var(--shadow);
  z-index: 20;
  transition: transform 0.24s ease;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
}

.status-strip,
.status-pill,
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

@media (min-width: 520px) {
  .app {
    padding-top: 16px;
  }
}
