@font-face {
  font-family: "KFQPC Uthman";
  src: url("./data/fonts/QCF2BSMLfonts/UthmanTN1%20Ver10.otf") format("opentype");
  font-display: swap;
}

@font-face {
  font-family: "KFQPC Uthman Bold";
  src: url("./data/fonts/QCF2BSMLfonts/UthmanTN1B%20Ver10.otf") format("opentype");
  font-display: swap;
}

@font-face {
  font-family: "KFQPC Surah";
  src: url("./data/fonts/arsura.ttf") format("truetype");
  font-display: swap;
}

:root {
  --bg: #f5efe2;
  --bg-strong: #e8dcc0;
  --paper: #fbf5e9;
  --paper-edge: #d6c1a4;
  --ink: #2e2418;
  --muted: #7c6a52;
  --accent: #1f6a52;
  --accent-soft: #d5e7dd;
  --shadow: 0 24px 60px rgba(71, 52, 28, 0.16);
  --line-height: 3.58rem;
  --line-count: 15;
  --mushaf-font: "KFQPC Uthman";
  --mushaf-content-width: 100%;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  background:
    radial-gradient(circle at top, rgba(255, 255, 255, 0.65), transparent 32%),
    linear-gradient(135deg, #efe6d0 0%, #f7f1e5 48%, #ece0c5 100%);
  color: var(--ink);
  font-family: "Segoe UI", Tahoma, sans-serif;
}

button,
input {
  font: inherit;
}

.app-shell {
  display: block;
  min-height: 100vh;
}

.sidebar {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(88vw, 360px);
  padding: 1.5rem 1.2rem;
  background: rgba(251, 245, 233, 0.88);
  backdrop-filter: blur(10px);
  border-left: 1px solid rgba(129, 104, 72, 0.15);
  overflow: auto;
  transform: translateX(100%);
  transition: transform 0.22s ease;
  z-index: 20;
}

.sidebar.open {
  transform: translateX(0);
}

.sidebar-header,
.topbar-group,
.page-toolbar,
.quick-actions {
  display: flex;
}

.sidebar-header,
.topbar {
  justify-content: space-between;
}

.eyebrow {
  margin: 0 0 0.35rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.sidebar-header h1,
.topbar h2 {
  margin: 0;
  font-size: 1.35rem;
}

.sidebar-header h1,
.topbar h2,
#surahName,
.surah-item strong {
  font-family: "KFQPC Surah", "Segoe UI", Tahoma, sans-serif;
}

.search-box,
.field-box {
  display: grid;
  gap: 0.45rem;
}

.search-box {
  margin: 1.25rem 0 1rem;
}

.search-box span,
.field-box span,
.status-card span {
  color: var(--muted);
  font-size: 0.85rem;
}

.search-box input,
.field-box input {
  width: 100%;
  padding: 0.85rem 1rem;
  border-radius: 16px;
  border: 1px solid rgba(113, 87, 53, 0.18);
  background: rgba(255, 255, 255, 0.75);
  color: var(--ink);
}

.quick-actions {
  gap: 0.55rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.action-chip,
.nav-button,
.icon-button,
.primary-button {
  border: none;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.action-chip,
.nav-button {
  border-radius: 999px;
  padding: 0.75rem 1rem;
  background: rgba(31, 106, 82, 0.08);
  color: var(--accent);
}

.action-chip:hover,
.nav-button:hover,
.icon-button:hover,
.primary-button:hover,
.surah-item:hover {
  transform: translateY(-1px);
}

.surah-list {
  display: grid;
  gap: 0.6rem;
}

.surah-item {
  width: 100%;
  text-align: right;
  padding: 0.95rem 1rem;
  border-radius: 20px;
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.55);
  cursor: pointer;
}

.surah-item strong,
.status-card strong {
  display: block;
}

.surah-item small {
  color: var(--muted);
}

.surah-item.active {
  border-color: rgba(31, 106, 82, 0.18);
  background: var(--accent-soft);
}

.surah-item.verse-result {
  border-color: rgba(31, 106, 82, 0.12);
  background: rgba(213, 231, 221, 0.4);
}

.reader-layout {
  padding: 1.6rem;
  display: grid;
  gap: 1rem;
  align-content: start;
}

.topbar {
  width: min(100%, 760px);
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 1rem;
  align-items: end;
}

.topbar-group {
  align-items: end;
  gap: 0.85rem;
}

.topbar-group.compact {
  align-items: center;
  justify-self: start;
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 46px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink);
  box-shadow: 0 12px 28px rgba(77, 57, 31, 0.08);
  text-decoration: none;
}

.primary-button {
  border-radius: 16px;
  padding: 0.9rem 1.2rem;
  background: var(--accent);
  color: #fff;
}

.status-grid {
  width: min(100%, 760px);
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.status-card {
  min-width: 0;
  padding: 1rem 1.15rem;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.64);
  box-shadow: 0 10px 26px rgba(67, 50, 27, 0.06);
  display: grid;
  align-content: start;
  gap: 0.4rem;
}

.mushaf-stage {
  display: grid;
  gap: 1rem;
  align-content: start;
}

.page-toolbar {
  width: min(100%, 760px);
  margin: 0 auto;
  justify-content: space-between;
  gap: 1rem;
}

.mushaf-page {
  width: min(100%, 760px);
  margin: 0 auto;
}

.mushaf-frame {
  background: linear-gradient(180deg, #fdf8ee 0%, #fbf3e3 100%);
  border: 1px solid rgba(154, 129, 93, 0.32);
  border-radius: 32px;
  padding: 0.35rem;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}

.mushaf-frame::before,
.mushaf-frame::after {
  content: "";
  position: absolute;
  inset: 12px;
  border-radius: 24px;
  pointer-events: none;
}

.mushaf-frame::before {
  border: 2px solid rgba(144, 118, 81, 0.18);
}

.mushaf-frame::after {
  inset: 14px;
  border: 1px solid rgba(144, 118, 81, 0.16);
}

.page-meta,
.page-footer {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--muted);
  padding: 0.2rem 0.32rem;
}

.page-meta {
  font-size: 0.92rem;
  font-family: "KFQPC Surah", "Segoe UI", Tahoma, sans-serif;
  grid-template-columns: 1fr auto 1fr;
  display: grid;
  align-items: center;
}

#metaRight {
  justify-self: end;
}

#metaCenter {
  justify-self: center;
}

#metaLeft {
  justify-self: start;
}

.page-footer {
  justify-content: center;
  font-size: 1.1rem;
  font-family: "KFQPC Surah", "Segoe UI", Tahoma, sans-serif;
}

.page-content-shell {
  position: relative;
  z-index: 1;
  padding: 0.45rem 1.15rem 0.18rem;
}

.page-content {
  direction: rtl;
  unicode-bidi: isolate;
  text-align: justify;
  text-align-last: justify;
  color: #2f2412;
  font-family: var(--mushaf-font), "KFQPC Uthman", serif;
  height: calc(var(--line-height) * var(--line-count));
  min-height: calc(var(--line-height) * var(--line-count));
  max-height: calc(var(--line-height) * var(--line-count));
  line-height: var(--line-height);
  font-size: 2rem;
  overflow: visible;
  white-space: normal;
  word-break: normal;
  border-radius: 22px;
  padding: 0 0.6rem 0 0.75rem;
  width: 100%;
  max-width: 100%;
  margin: 0 auto;
  font-feature-settings: normal;
  letter-spacing: 0;
  word-spacing: 0;
  text-rendering: geometricPrecision;
  -webkit-font-smoothing: auto;
  writing-mode: horizontal-tb;
}

.page-content .surah-divider {
  display: block;
  color: var(--accent);
  font-weight: 700;
  font-family: "KFQPC Surah", "Segoe UI", Tahoma, sans-serif;
  text-align: center !important;
  text-align-last: center !important;
  font-size: 1.15rem;
  margin: 0.15rem 0 0.28rem;
  width: 100%;
  max-width: 100%;
  white-space: normal;
}

.page-content .basmala {
  display: block;
  text-align: center !important;
  text-align-last: center !important;
  direction: rtl;
  unicode-bidi: isolate;
  font-family: "KFQPC Uthman", serif;
  font-size: 1.08em;
  line-height: 1.8;
  margin: 0 0 0.42rem;
  width: 100%;
  max-width: 100%;
  white-space: normal;
}

.page-content .qcf-run {
  direction: rtl;
  unicode-bidi: bidi-override;
  display: block;
  width: var(--mushaf-content-width);
  max-width: var(--mushaf-content-width);
  margin: 0 auto;
  white-space: normal;
  text-align: justify;
  text-align-last: right;
  overflow: visible;
  padding-left: 0.18rem;
  padding-right: 0.08rem;
}

.page-content .qcf-ayah {
  display: inline;
  cursor: copy;
}

.page-content .qcf-run.surah-end-run {
  width: fit-content;
  max-width: 100%;
  margin-right: 0;
  margin-left: auto;
  text-align: right;
  text-align-last: right;
  padding-left: 0.28rem;
}

.page-content.special-opening-page {
  text-align: center;
  text-align-last: center;
}

.page-content.special-opening-page .surah-divider,
.page-content.special-opening-page .basmala {
  margin-left: auto;
  margin-right: auto;
}

.page-content.special-opening-page .qcf-run {
  width: min(62%, 24rem);
  max-width: min(62%, 24rem);
  text-align: center;
  text-align-last: center;
  line-height: 1.95;
}

.page-content.special-opening-page .qcf-run + .qcf-run {
  margin-top: 0.2rem;
}

.page-content.fatiha-page .qcf-run {
  margin-left: auto;
  margin-right: auto;
}

.measure {
  position: fixed;
  inset: auto;
  visibility: hidden;
  pointer-events: none;
  width: min(calc(100vw - 5rem), 770px);
  top: -9999px;
  right: -9999px;
}

.mail-button {
  font-size: 1.15rem;
}

.mobile-only {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.overlay {
  display: none;
}

@media (max-width: 1080px) {
  .overlay.visible {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(28, 22, 12, 0.34);
    z-index: 10;
  }
}

@media (max-width: 720px) {
  :root {
    --line-height: 3.18rem;
  }

  .reader-layout {
    padding: 1rem;
  }

  .page-toolbar,
  .topbar {
    width: 100%;
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .status-grid {
    width: 100%;
    grid-template-columns: 1fr;
  }

  .topbar-group.compact {
    width: 100%;
    justify-self: stretch;
  }

  .field-box {
    flex: 1;
  }

  .page-toolbar {
    flex-direction: column;
  }

  .mushaf-frame {
    border-radius: 24px;
    padding: 0.22rem;
  }

  .page-content {
    font-size: 1.65rem;
    padding: 0 0.34rem 0 0.5rem;
  }
}
