@font-face {
  font-family: "Vazirmatn";
  src: url("../fonts/Vazirmatn-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Vazirmatn";
  src: url("../fonts/Vazirmatn-Bold.ttf") format("truetype");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #f4ecdf;
  --panel: rgba(255, 251, 245, 0.9);
  --panel-strong: #fffaf1;
  --border: rgba(104, 72, 45, 0.16);
  --text: #20150d;
  --muted: #695648;
  --accent: #0f766e;
  --accent-strong: #0a5c56;
  --accent-soft: rgba(15, 118, 110, 0.12);
  --shadow: 0 18px 40px rgba(73, 46, 22, 0.08);
  --radius-xl: 24px;
  --radius-lg: 18px;
  --radius-md: 14px;
  --content-width: 1180px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Instrument Sans", system-ui, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.6), transparent 32%),
    linear-gradient(180deg, #efe4d2 0%, #f8f2e7 45%, #f4ecdf 100%);
}

.app-launch-screen {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.62), transparent 34%),
    linear-gradient(180deg, #efe4d2 0%, #f8f2e7 45%, #f4ecdf 100%);
  transition:
    opacity 0.24s ease,
    visibility 0.24s ease;
}

.app-launch-screen.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.app-launch-card {
  width: min(100%, 320px);
  padding: 28px 24px;
  border: 1px solid var(--border);
  border-radius: 28px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.7), rgba(255, 248, 240, 0.94)),
    var(--panel);
  box-shadow: var(--shadow);
  text-align: center;
}

.app-launch-mark {
  width: 72px;
  height: 72px;
  margin: 0 auto 16px;
  display: block;
}

.app-launch-title,
.app-launch-copy {
  margin: 0;
}

.app-launch-title {
  font-size: 1.18rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.app-launch-copy {
  margin-top: 8px;
  color: var(--muted);
}

button,
input,
select {
  font: inherit;
}

.page-shell {
  max-width: var(--content-width);
  margin: 0 auto;
  padding: 20px 16px 40px;
}

.topbar {
  display: grid;
  gap: 18px;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: 28px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.64), rgba(255, 248, 240, 0.92)),
    var(--panel);
  box-shadow: var(--shadow);
}

.eyebrow,
.section-kicker {
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.74rem;
  color: var(--accent);
  font-weight: 700;
}

.subtitle,
.surah-meta,
.reader-status,
.search-hint,
.search-feedback,
.result-meta,
.result-snippet {
  color: var(--muted);
}

#app-title,
.panel-header h2 {
  margin: 0;
}

.subtitle {
  margin: 10px 0 0;
  max-width: 34rem;
  line-height: 1.55;
}

.language-picker {
  display: grid;
  gap: 8px;
  width: fit-content;
}

.language-picker span {
  font-size: 0.88rem;
  font-weight: 600;
}

.language-picker select,
.search-field input,
.ghost-button,
.audio-button,
.search-submit {
  border-radius: 999px;
  border: 1px solid var(--border);
}

.language-picker select,
.search-field input {
  min-height: 48px;
  padding: 0 16px;
  background: #fffdf8;
}

.layout {
  display: grid;
  gap: 18px;
  margin-top: 18px;
}

.panel-reader {
  scroll-margin-top: 20px;
}

.panel-list {
  scroll-margin-top: 20px;
}

.panel {
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 18px;
  backdrop-filter: blur(10px);
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.search-field {
  display: block;
  flex: 1;
  position: relative;
}

.search-form {
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
}

.search-hint {
  margin: -4px 0 12px;
  font-size: 0.9rem;
  line-height: 1.5;
}

.last-read-chip {
  width: 100%;
  margin: 0 0 12px;
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid rgba(15, 118, 110, 0.18);
  background: rgba(15, 118, 110, 0.08);
  color: var(--accent-strong);
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  transition:
    border-color 0.18s ease,
    background-color 0.18s ease,
    transform 0.18s ease;
}

.last-read-chip:hover,
.last-read-chip:focus-visible {
  border-color: rgba(15, 118, 110, 0.34);
  background: rgba(15, 118, 110, 0.12);
  transform: translateY(-1px);
}

.search-feedback {
  margin-bottom: 12px;
  min-height: 1.3rem;
  font-size: 0.92rem;
}

.search-feedback.is-warning {
  color: #9a3412;
}

.search-field input {
  width: 100%;
  padding-right: 56px;
}

.search-clear-button {
  position: absolute;
  top: 50%;
  right: 10px;
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transform: translateY(-50%);
  border: 0;
  border-radius: 999px;
  background: rgba(104, 72, 45, 0.08);
  color: var(--muted);
  cursor: pointer;
  transition:
    background-color 0.18s ease,
    color 0.18s ease,
    transform 0.18s ease;
}

.search-clear-button:hover,
.search-clear-button:focus-visible {
  background: rgba(15, 118, 110, 0.12);
  color: var(--accent-strong);
  transform: translateY(-50%) scale(1.03);
}

.search-clear-button span {
  font-size: 1.2rem;
  line-height: 1;
}

.search-submit {
  min-height: 48px;
  padding: 0 18px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}

.search-submit.is-loading {
  opacity: 0.88;
  cursor: wait;
}

.surah-list,
.ayah-list,
.search-results {
  display: grid;
  gap: 12px;
}

.surah-card,
.ayah-card,
.search-result-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--panel-strong);
}

.surah-card {
  width: 100%;
  padding: 16px;
  text-align: left;
  cursor: pointer;
  transition:
    transform 160ms ease,
    border-color 160ms ease,
    box-shadow 160ms ease;
}

.surah-card:hover,
.surah-card:focus-visible {
  transform: translateY(-1px);
  border-color: rgba(15, 118, 110, 0.4);
  box-shadow: 0 10px 22px rgba(15, 118, 110, 0.12);
}

.surah-card.active {
  border-color: var(--accent);
  background: linear-gradient(180deg, #f9fffe 0%, #f1fbf9 100%);
}

.surah-card.is-loading {
  border-color: rgba(15, 118, 110, 0.42);
  background: linear-gradient(180deg, #f9fffe 0%, #eef9f7 100%);
  box-shadow: 0 10px 22px rgba(15, 118, 110, 0.14);
}

.surah-card.is-loading .surah-number {
  animation: surah-card-pulse 1s ease-in-out infinite;
}

.surah-card.unavailable {
  opacity: 0.78;
}

.surah-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.surah-number {
  width: 42px;
  height: 42px;
  display: inline-grid;
  place-items: center;
  border-radius: 14px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 700;
  flex-shrink: 0;
}

.surah-name-group {
  flex: 1;
  min-width: 0;
}

.surah-name-group h3 {
  margin: 0 0 4px;
  font-size: 1rem;
}

.surah-meta {
  margin: 0;
  font-size: 0.92rem;
}

.reader-status {
  padding: 16px;
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.55);
  border: 1px dashed rgba(104, 72, 45, 0.18);
}

.reader-status.is-warning {
  background: rgba(255, 248, 221, 0.9);
  border-style: solid;
}

.reader-status.is-loading {
  border-style: solid;
  border-color: rgba(15, 118, 110, 0.24);
  background: rgba(240, 251, 248, 0.92);
}

.reader-status:empty,
.ayah-list:empty {
  display: none;
}

.ayah-card {
  padding: 18px;
}

.ayah-card.is-target {
  border-color: rgba(15, 118, 110, 0.75);
  box-shadow: 0 0 0 4px rgba(15, 118, 110, 0.14);
}

.ayah-card.is-last-read {
  border-color: rgba(180, 83, 9, 0.45);
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.14);
}

.ayah-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.ayah-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
  min-width: 42px;
  height: 42px;
  padding: 0 12px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 700;
  flex-shrink: 0;
  white-space: nowrap;
}

.audio-button,
.ghost-button,
.last-read-button,
.copy-link-button {
  min-height: 42px;
  padding: 0 14px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
}

.ayah-toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid rgba(104, 72, 45, 0.1);
}

.scroll-top-button {
  position: fixed;
  right: 16px;
  bottom: 18px;
  width: 50px;
  height: 50px;
  border-radius: 999px;
  border: 1px solid rgba(15, 118, 110, 0.2);
  background: rgba(15, 118, 110, 0.94);
  color: #fff;
  box-shadow: 0 16px 30px rgba(15, 118, 110, 0.22);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 30;
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition:
    opacity 0.2s ease,
    transform 0.2s ease,
    background-color 0.2s ease;
}

.scroll-top-button span {
  font-size: 1.25rem;
  line-height: 1;
  font-weight: 700;
}

.scroll-top-button.is-visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.scroll-top-button:hover,
.scroll-top-button:focus-visible {
  background: var(--accent-strong);
}

.scroll-top-button:focus-visible {
  outline: 3px solid rgba(15, 118, 110, 0.22);
  outline-offset: 3px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translate(-50%, 12px);
  max-width: min(92vw, 420px);
  padding: 12px 16px;
  border-radius: 16px;
  background: rgba(32, 21, 13, 0.92);
  color: #fffdf8;
  font-size: 0.92rem;
  font-weight: 600;
  line-height: 1.45;
  box-shadow: 0 18px 34px rgba(32, 21, 13, 0.24);
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 0.22s ease,
    transform 0.22s ease;
  z-index: 40;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.audio-button {
  width: 42px;
  min-width: 42px;
  height: 42px;
  padding: 0;
  background: #f8fffd;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.last-read-button {
  min-width: 42px;
  width: 42px;
  height: 42px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: rgba(255, 250, 242, 0.42);
  border-color: rgba(180, 83, 9, 0.1);
  color: rgba(138, 75, 8, 0.64);
}

.copy-link-button {
  min-width: 42px;
  width: 42px;
  height: 42px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: rgba(239, 246, 255, 0.68);
  border-color: rgba(59, 130, 246, 0.1);
  color: rgba(37, 99, 235, 0.8);
}

.audio-button svg,
.last-read-button svg,
.copy-link-button svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.copy-link-button:hover,
.copy-link-button:focus-visible {
  background: rgba(219, 234, 254, 0.96);
}

.last-read-button.is-marked {
  background: rgba(245, 158, 11, 0.14);
  color: #b45309;
  border-color: rgba(180, 83, 9, 0.22);
}

.last-read-button:hover,
.last-read-button:focus-visible {
  background: rgba(255, 244, 222, 0.9);
}

.last-read-button.is-marked:hover,
.last-read-button.is-marked:focus-visible {
  background: rgba(245, 158, 11, 0.22);
}

.audio-spinner-track {
  fill: none;
  stroke: currentColor;
  stroke-width: 2.5;
  opacity: 0.22;
}

.audio-spinner-head {
  fill: none;
  stroke: currentColor;
  stroke-width: 2.5;
  stroke-linecap: round;
  animation: audio-spinner-spin 0.8s linear infinite;
  transform-origin: 12px 12px;
}

.audio-button.is-playing {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.audio-button.is-loading {
  background: rgba(15, 118, 110, 0.1);
  color: var(--accent-strong);
  border-color: rgba(15, 118, 110, 0.26);
  opacity: 1;
}

.audio-button.has-error {
  background: rgba(190, 24, 24, 0.08);
  color: #b91c1c;
  border-color: rgba(190, 24, 24, 0.24);
}

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

.audio-button.is-loading:disabled {
  opacity: 1;
}

.ayah-subtitle {
  margin: 0 0 14px;
  font-size: 0.98rem;
  font-weight: 700;
  color: var(--accent-strong);
  text-align: center;
  line-height: 1.55;
}

.translation-block {
  display: grid;
  gap: 16px;
}

.translation-block p {
  margin: 0;
}

.ayah-translation {
  font-size: 1.08rem;
  line-height: 1.8;
  color: var(--text);
}

.ayah-arabic {
  font-family: "Vazirmatn", "Amiri", "Noto Naskh Arabic", serif;
  font-size: clamp(1.55rem, 4.4vw, 2rem);
  font-weight: 700;
  line-height: 1.9;
  text-align: right;
  direction: rtl;
  color: rgba(32, 21, 13, 0.82);
}

.ayah-footnote {
  margin-top: 2px;
  font-size: 0.92rem;
  line-height: 1.65;
  color: var(--muted);
  opacity: 0.88;
  padding-top: 10px;
  border-top: 1px solid rgba(104, 72, 45, 0.12);
}

.ayah-footnote p {
  margin: 0 0 12px;
}

.ayah-footnote p:last-child {
  margin-bottom: 0;
}

.ayah-footnote-table-wrap {
  overflow-x: auto;
  margin: 8px 0 14px;
  padding-bottom: 4px;
}

.ayah-footnote table {
  max-width: 100%;
}

.search-results:empty {
  display: none;
}

.search-result-card {
  width: 100%;
  padding: 16px;
  text-align: left;
  cursor: pointer;
}

.search-result-card mark {
  background: rgba(245, 158, 11, 0.24);
  color: inherit;
  padding: 0 2px;
  border-radius: 4px;
}

.result-title {
  margin: 0 0 6px;
  font-size: 1rem;
}

.result-meta,
.result-snippet {
  margin: 0;
  line-height: 1.55;
}

.result-snippet-label {
  display: inline-block;
  margin-bottom: 6px;
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent);
  font-weight: 700;
}

.empty-state {
  padding: 16px;
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.55);
  color: var(--muted);
}

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

@keyframes audio-spinner-spin {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
}

@keyframes surah-card-pulse {
  0%,
  100% {
    transform: scale(1);
    box-shadow: inset 0 0 0 0 rgba(15, 118, 110, 0.12);
  }

  50% {
    transform: scale(1.03);
    box-shadow: inset 0 0 0 6px rgba(15, 118, 110, 0.06);
  }
}

@media (max-width: 859px) {
  .search-form {
    grid-template-columns: 1fr;
  }

  .layout.is-mobile-list-view .panel-reader {
    display: none;
  }

  .layout.is-mobile-reader-view .panel-list {
    display: none;
  }

  .layout.is-mobile-reader-view .panel-reader,
  .layout.is-mobile-list-view .panel-list {
    display: block;
  }

  .panel-reader .ghost-button {
    width: 100%;
    justify-content: center;
  }

  .panel-reader .panel-header {
    align-items: stretch;
    flex-direction: column;
  }

  .ayah-head {
    align-items: flex-start;
  }

  .ayah-actions {
    gap: 8px;
  }

  .last-read-button {
    min-height: 40px;
    width: 40px;
    min-width: 40px;
  }

  .scroll-top-button {
    right: 14px;
    bottom: 16px;
    width: 52px;
    height: 52px;
  }

  .toast {
    bottom: 84px;
    max-width: calc(100vw - 28px);
  }
}

@media (min-width: 860px) {
  .page-shell {
    padding: 28px 24px 52px;
  }

  .topbar {
    grid-template-columns: 1fr auto;
    align-items: end;
    padding: 28px;
  }

  .layout {
    grid-template-columns: minmax(320px, 0.95fr) minmax(0, 1.35fr);
    align-items: start;
  }

  .panel {
    padding: 22px;
  }

  .search-form {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
  }

  .panel-list {
    position: sticky;
    top: 24px;
    max-height: calc(100vh - 48px);
    overflow: auto;
  }

  .panel-reader .ghost-button[hidden] {
    display: none;
  }

  .scroll-top-button {
    right: 26px;
    bottom: 24px;
  }

  .toast {
    bottom: 28px;
  }
}
