@font-face {
  font-family: "Gill Sans Ruqiya";
  src: url("assets/fonts/gill-sans-regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Gill Sans Ruqiya";
  src: url("assets/fonts/gill-sans-medium.ttf") format("truetype");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Gill Sans Ruqiya";
  src: url("assets/fonts/gill-sans-bold.ttf") format("truetype");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Gill Sans Ruqiya";
  src: url("assets/fonts/gill-sans-light.ttf") format("truetype");
  font-weight: 300;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Amiri Ruqiya";
  src: url("assets/fonts/amiri-regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  --navy: #1d3567;
  --navy-deep: #15294f;
  --paper: #ffffff;
  --canvas: #f2f2f2;
  --text: #202020;
  --muted: #858585;
  --line: #e2e2e2;
  --bookmark: #de4437;
  --panel: #f5f5f7;
  --action-panel: #d5d5da;
  --shadow: 0 8px 24px rgba(20, 34, 64, 0.08);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html, body { min-height: 100%; margin: 0; }
body {
  background: #d8dce4;
  color: var(--text);
  font-family: "Gill Sans Ruqiya", "Segoe UI", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
button, input { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }

.app-shell {
  width: min(100%, 620px);
  color: var(--text);
  min-height: 100dvh;
  margin: 0 auto;
  background: var(--canvas);
  position: relative;
  overflow-x: hidden;
  box-shadow: 0 0 48px rgba(0,0,0,.18);
}

.app-shell.is-dark {
  --paper: #393939;
  --canvas: #0a0a0a;
  --text: #eeeeee;
  --muted: #bdbdbd;
  --line: #565656;
  --panel: #303030;
  --action-panel: #252525;
  --shadow: none;
}

.screen {
  min-height: 100dvh;
  color: var(--text);
  padding-bottom: calc(92px + var(--safe-bottom));
  background: var(--canvas);
}
.screen.start-screen { padding-bottom: 0; }

.start-screen {
  background: #fff;
  color: #1d3567;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: calc(40px + var(--safe-top)) 30px 56px;
  text-align: center;
}
.start-logo-small {
  display: none;
}
.start-copy { width: 100%; }
.start-kicker {
  margin: 0 0 8px;
  font-size: 28px;
  line-height: 1.1;
  font-weight: 700;
  letter-spacing: .02em;
}
.start-subtitle {
  margin: 0 auto;
  max-width: 485px;
  font-size: clamp(25px, 6vw, 34px);
  line-height: 1.45;
  font-weight: 400;
}
.start-logo-large {
  width: clamp(240px, 62vw, 360px);
  margin: 52px auto 42px;
  object-fit: contain;
}
.start-author {
  margin: auto 0 52px;
  font-size: clamp(22px, 5vw, 30px);
  line-height: 1.3;
}
.enter-button {
  width: min(100%, 420px);
  margin-bottom: max(10px, var(--safe-bottom));
  min-height: 72px;
  border: 0;
  border-radius: 14px;
  background: var(--navy);
  color: white;
  font-size: 30px;
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(29,53,103,.18);
}
.enter-button:active { transform: translateY(1px); }

.topbar {
  min-height: calc(96px + var(--safe-top));
  padding: calc(20px + var(--safe-top)) 18px 20px;
  background: var(--navy);
  color: #fff;
  border-radius: 0 0 32px 32px;
  display: grid;
  grid-template-columns: 52px 1fr 92px;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 40;
}
.topbar.no-back { grid-template-columns: 52px 1fr 92px; }
.topbar-title {
  margin: 0;
  text-align: center;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: .02em;
}
.icon-button {
  width: 46px;
  height: 46px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: currentColor;
  display: inline-grid;
  place-items: center;
  cursor: pointer;
}
.icon-button svg { width: 28px; height: 28px; }
.topbar-actions { display: flex; justify-content: flex-end; align-items: center; }
.topbar-spacer { width: 46px; height: 46px; }

.hero-image {
  width: 100%;
  height: 184px;
  object-fit: cover;
  display: block;
  margin-top: -4px;
}

.content-wrap { padding: 18px 16px 24px; }
.section-list { display: grid; gap: 16px; }
.article-card,
.ruqiya-card,
.recite-card {
  border: 0;
  width: 100%;
  text-align: left;
  background: var(--paper);
  color: var(--text);
  border-radius: 10px;
  box-shadow: var(--shadow);
  cursor: pointer;
}
.article-card {
  min-height: 112px;
  padding: 22px 18px;
}
.card-title {
  color: var(--navy);
  font-size: 19px;
  line-height: 1.15;
  font-weight: 700;
  margin: 0 0 5px;
}
.is-dark .card-title { color: #dbe4ff; }
.card-snippet {
  margin: 0;
  font-size: 18px;
  line-height: 1.13;
  color: var(--text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.ruqiya-card {
  min-height: 118px;
  padding: 20px 16px;
  display: flex;
  align-items: center;
}
.ruqiya-card .card-title { margin: 0; }

.recite-list { display: grid; gap: 14px; padding: 16px; }
.recite-row-wrap {
  position: relative;
  min-height: 108px;
  overflow: hidden;
  border-radius: 8px;
  touch-action: pan-y;
}
.recite-actions {
  position: absolute;
  inset: 0 0 0 auto;
  width: 184px;
  background: var(--action-panel);
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: stretch;
}
.recite-action {
  border: 0;
  background: transparent;
  color: var(--navy);
  cursor: pointer;
  display: grid;
  place-items: center;
}
.recite-action svg { width: 34px; height: 34px; }
.recite-action[aria-pressed="true"] svg { fill: currentColor; }
.recite-card {
  min-height: 108px;
  padding: 17px 20px;
  display: grid;
  grid-template-columns: 58px 1fr 34px;
  gap: 14px;
  align-items: center;
  position: relative;
  transform: translateX(0);
  transition: transform .2s ease, background-color .2s ease;
  z-index: 2;
}
.recite-row-wrap.open .recite-card { transform: translateX(-184px); }
.recite-row-wrap.bookmarked .recite-card {
  background: var(--bookmark);
  color: rgba(255,255,255,.95);
}
.recite-row-wrap.bookmarked .number-circle { border-color: #fff; color: #fff; }
.recite-row-wrap.bookmarked .row-title { color: rgba(255,255,255,.72); }
.number-circle {
  width: 48px;
  height: 48px;
  border: 3px solid var(--navy);
  color: var(--navy);
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 17px;
  line-height: 1;
  background: transparent;
}
.is-dark .number-circle { border-color: #dce4ff; color: #dce4ff; }
.row-title {
  margin: 0;
  font-weight: 700;
  font-size: 21px;
  line-height: 1.15;
  color: #4a4a4a;
}
.is-dark .row-title { color: var(--text); }
.more-actions-hint {
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 24px;
  min-width: 34px;
  min-height: 44px;
}

.detail-card {
  margin: -15px 16px 20px;
  color: var(--text);
  min-height: calc(100dvh - 184px);
  background: var(--paper);
  border-radius: 30px 30px 0 0;
  padding: 42px 22px 40px;
  position: relative;
  z-index: 2;
  box-shadow: var(--shadow);
  touch-action: pan-y;
}
.detail-count {
  margin: 0 0 38px;
  text-align: center;
  color: var(--muted);
  font-size: 29px;
  font-weight: 300;
}
.detail-title {
  margin: 0 0 22px;
  text-align: center;
  font-size: 28px;
  font-weight: 400;
  color: var(--navy);
}
.is-dark .detail-title { color: #f0f3ff; }
.audio-progress {
  width: 100%;
  accent-color: var(--navy);
  cursor: pointer;
  margin: 0;
}
.time-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
  font-size: 16px;
}
.player-controls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 24px;
  margin: -6px 0 35px;
}
.player-button {
  border: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  cursor: pointer;
}
.player-button svg { width: 31px; height: 31px; }
.repeat-button {
  width: 62px;
  height: 62px;
  background: #dce0e9;
  color: #fff;
}
.repeat-button.active { background: var(--navy); }
.play-button {
  width: 48px;
  height: 48px;
  background: #dce0e9;
  color: var(--navy);
}
.is-dark .repeat-button,
.is-dark .play-button { background: #5a5a5a; color: #e5e9f4; }
.is-dark .repeat-button.active { background: #dce4ff; color: var(--navy); }
.detail-section { margin-top: 30px; }
.detail-section h2 {
  margin: 0 0 18px;
  font-size: 26px;
  font-weight: 400;
  color: var(--text);
}
.detail-section p {
  margin: 0;
  font-size: 22px;
  line-height: 1.28;
  color: var(--text);
}
.arabic-text {
  direction: rtl;
  text-align: right;
  font-family: "Amiri Ruqiya", "Noto Naskh Arabic", "Traditional Arabic", serif;
  font-size: 34px !important;
  line-height: 1.85 !important;
  letter-spacing: 0;
  word-spacing: 0.03em;
  font-feature-settings: "liga" 1, "calt" 1;
}
.prototype-note {
  border: 1px dashed var(--line);
  border-radius: 10px;
  padding: 15px;
  color: var(--muted);
  line-height: 1.35;
  font-size: 16px;
}

.article-detail-hero {
  width: 100%;
  height: 190px;
  object-fit: cover;
  display: block;
}
.reading-card {
  margin: -16px 12px 18px;
  color: var(--text);
  min-height: 520px;
  padding: 24px 28px 48px;
  border-radius: 20px 20px 0 0;
  background: var(--paper);
  position: relative;
  z-index: 2;
}
.reading-card h1 {
  font-size: 24px;
  font-weight: 400;
  text-align: center;
  margin: 0 0 24px;
}
.reading-card h2 {
  font-size: 22px;
  margin: 26px 0 12px;
}
.reading-card p,
.reading-card li {
  font-size: 20px;
  line-height: 1.28;
}
.reading-card p { margin: 0 0 22px; }
.reading-card ol { padding-left: 26px; }

.bottom-nav {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: min(100%, 620px);
  min-height: calc(92px + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: var(--paper);
  border-top: 1px solid var(--line);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  z-index: 60;
}
.nav-button {
  border: 0;
  background: transparent;
  color: #8d8d8d;
  min-width: 0;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 4px;
  padding: 10px 2px 8px;
  cursor: pointer;
}
.nav-button.active {
  background: var(--navy);
  color: #fff;
}
.nav-button svg { width: 32px; height: 32px; }
.nav-label { font-size: 15px; line-height: 1; }

.menu-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0,0,0,.44);
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: calc(80px + var(--safe-top)) 18px 20px;
}
.menu-panel {
  width: min(100%, 420px);
  background: var(--paper);
  color: var(--text);
  border-radius: 14px;
  padding: 12px;
  box-shadow: 0 18px 50px rgba(0,0,0,.28);
}
.menu-title {
  margin: 6px 8px 8px;
  font-size: 20px;
  color: var(--navy);
}
.is-dark .menu-title { color: #dce4ff; }
.menu-item {
  width: 100%;
  min-height: 50px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: inherit;
  text-align: left;
  padding: 10px 12px;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}
.menu-item:hover, .menu-item:focus-visible { background: var(--panel); }
.switch {
  width: 52px;
  height: 30px;
  border-radius: 999px;
  background: #cfcfcf;
  padding: 3px;
  transition: background .2s ease;
}
.switch::after {
  content: "";
  display: block;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #fff;
  transition: transform .2s ease;
  box-shadow: 0 1px 4px rgba(0,0,0,.25);
}
.switch.on { background: #35c765; }
.switch.on::after { transform: translateX(22px); }
.menu-separator { height: 1px; background: var(--line); margin: 6px 8px; }
.menu-note { margin: 8px 12px 4px; color: var(--muted); font-size: 14px; line-height: 1.3; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(108px + var(--safe-bottom));
  transform: translateX(-50%);
  width: min(calc(100% - 32px), 520px);
  background: #17213a;
  color: #fff;
  padding: 14px 18px;
  border-radius: 12px;
  z-index: 130;
  box-shadow: 0 12px 34px rgba(0,0,0,.3);
  font-size: 17px;
  text-align: center;
  animation: toast-in .18s ease-out;
}
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 10px); } }

.empty-state {
  padding: 44px 24px;
  text-align: center;
  color: var(--muted);
  font-size: 20px;
}

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

@media (min-width: 621px) {
  .topbar { position: relative; }
  .bottom-nav { border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
}

@media (max-width: 390px) {
  .start-logo-large { margin: 35px auto 30px; }
  .start-author { margin-bottom: 38px; }
  .topbar-title { font-size: 18px; }
  .row-title { font-size: 18px; }
  .detail-card { padding-left: 18px; padding-right: 18px; }
  .detail-section p { font-size: 20px; }
  .arabic-text { font-size: 31px !important; line-height: 1.8 !important; }
}

/* v0.2.1 complete-content refinements */
.player-line {
  display: grid;
  grid-template-columns: minmax(72px, 1fr) auto minmax(72px, 1fr);
  align-items: center;
  gap: 10px;
  margin: 8px 0 34px;
  font-size: 16px;
}
.player-line > span:last-child { text-align: right; }
.player-line .player-controls {
  margin: 0;
  gap: 18px;
}
.reference-text {
  margin: 24px 0 0;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 17px;
  line-height: 1.35;
}
.text-block {
  white-space: normal;
  overflow-wrap: anywhere;
}
.text-block.arabic-block {
  font-family: "Amiri Ruqiya", "Noto Naskh Arabic", "Traditional Arabic", serif;
  text-align: right;
  font-size: 29px;
  line-height: 1.9;
  letter-spacing: 0;
}
.external-links {
  display: grid;
  gap: 12px;
  margin-top: 28px;
}
.external-links a {
  display: block;
  padding: 14px 16px;
  border-radius: 10px;
  background: var(--navy);
  color: #fff;
  text-decoration: none;
  text-align: center;
  font-size: 18px;
}
.recite-row-wrap { min-height: 112px; }
.recite-card { min-height: 112px; }
.number-circle { flex-shrink: 0; font-size: 16px; }
.reading-card { overflow-wrap: anywhere; }
.reading-card .text-block { margin-bottom: 22px; }
.is-dark .external-links a { background: #dce4ff; color: var(--navy); }

@media (max-width: 390px) {
  .player-line { grid-template-columns: 74px auto 74px; font-size: 14px; }
  .player-line .player-controls { gap: 12px; }
  .repeat-button { width: 56px; height: 56px; }
  .play-button { width: 46px; height: 46px; }
  .reading-card { padding-left: 20px; padding-right: 20px; }
}
