/* ===== Fonts ===== */
@font-face {
  font-family: 'Uthmanic Hafs';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../fonts/UthmanicHafs.woff2') format('woff2');
}
@font-face {
  font-family: 'Amiri Quran';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../fonts/AmiriQuran-arabic.woff2') format('woff2');
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC;
}
@font-face {
  font-family: 'Amiri Quran';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../fonts/AmiriQuran-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+2000-206F, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('../fonts/Inter-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('../fonts/Inter-cyrillic.woff2') format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

/* ===== Theme variables ===== */
:root {
  --bg: #f5f2e9;
  --surface: #fffdf7;
  --paper: #fffdf6;
  --text: #1d2a24;
  --muted: #7c8779;
  --accent: #0c5943;
  --accent-2: #0a4a38;
  --accent-soft: #e6f0e9;
  --gold: #c2a14d;
  --gold-soft: #ecdcb2;
  --border: #e7e0cd;
  --highlight: #fdf3cf;
  --memorized: #e8f3e9;
  --shadow: 0 1px 2px rgba(35, 42, 32, .05), 0 6px 20px -6px rgba(35, 42, 32, .12);
  --shadow-lg: 0 2px 6px rgba(35, 42, 32, .07), 0 16px 40px -12px rgba(35, 42, 32, .22);
  --r: 16px;
  --r-lg: 22px;
  --ar-size: 2.0rem;
  --ar-font: 'Uthmanic Hafs', 'Amiri Quran', serif;
}
[data-theme="sepia"] {
  --bg: #efe3c8;
  --surface: #f9f0da;
  --paper: #fbf4e0;
  --text: #3c2f1a;
  --muted: #8d7c58;
  --accent: #745720;
  --accent-2: #5f4718;
  --accent-soft: #f0e4c4;
  --gold: #a8842e;
  --gold-soft: #e3cf9c;
  --border: #dcc99e;
  --highlight: #f4dfa4;
  --memorized: #e6ecd0;
}
[data-theme="dark"] {
  --bg: #0c110f;
  --surface: #161d1a;
  --paper: #1a2520;
  --text: #e9ece7;
  --muted: #8f9c92;
  --accent: #4cc296;
  --accent-2: #0d5c46;
  --accent-soft: #17342a;
  --gold: #d8ba70;
  --gold-soft: #43391f;
  --border: #263029;
  --highlight: #3b3512;
  --memorized: #1b3a2c;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px -6px rgba(0, 0, 0, .5);
  --shadow-lg: 0 2px 6px rgba(0, 0, 0, .45), 0 18px 48px -12px rgba(0, 0, 0, .6);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-optical-sizing: auto;
  letter-spacing: -0.011em;
  min-height: 100vh;
  padding-bottom: 120px;
}
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: .85rem; letter-spacing: 0; }
a { color: var(--accent); }
button, input, select { font-family: inherit; }
.view { animation: view-in .22s ease; }
@keyframes view-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

/* ===== Tajweed colors — Dar al-Maarifah mushaf palette (sampled 1:1) ===== */
tj { font-style: normal; }
/* grey: idgham + what is not pronounced */
.tj-h, .tj-s, .tj-l, .tj-u, .tj-d, .tj-b { color: #969791; }
/* green: ikhfa + ghunnah positions (incl. iqlab, idgham w/ ghunnah) */
.tj-g, .tj-f, .tj-c, .tj-i, .tj-a, .tj-w { color: #018a44; }
/* cyan: qalqalah */
.tj-q { color: #12adc3; }
/* maddas */
.tj-m { color: #c0007a; }          /* madd 6 (lazim) */
.tj-o { color: #e31289; }          /* madd wajib 4-5 (muttasil) */
.tj-j { color: #bb7e25; }          /* madd jaiz 2/4/6 (munfasil) */
.tj-n, .tj-p { color: #c8aa50; }   /* natural madd, 2 harakat */
[data-theme="dark"] .view:not(#view-reader) .tj-m,
[data-theme="dark"] .ayah-block .tj-m { color: #ff4fb0; }
body.tajweed-off tj { color: inherit !important; }

/* ===== Top bar ===== */
#topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: .6rem;
  color: #f2eeda;
  background:
    radial-gradient(140% 180% at 100% 0%, rgba(233, 200, 106, .12), transparent 50%),
    linear-gradient(150deg, #0a4534, #0c5943 70%, #0f6b50);
  padding: .8rem 1.1rem;
  padding-top: calc(.8rem + env(safe-area-inset-top));
  box-shadow: 0 1px 0 rgba(255, 255, 255, .06) inset, 0 4px 24px -8px rgba(8, 40, 30, .5);
}
#logo { flex: none; filter: drop-shadow(0 1px 2px rgba(0,0,0,.3)); }
#topbar h1 {
  font-size: 1.15rem; font-weight: 650; flex: 1;
  letter-spacing: -0.01em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.top-actions { display: flex; gap: .15rem; align-items: center; }
.icon-btn {
  background: none; border: none; color: inherit;
  font-size: 1.2rem; cursor: pointer;
  width: 40px; height: 40px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 12px; position: relative;
  transition: background .18s, transform .12s;
}
.icon-btn:hover { background: rgba(255, 255, 255, .12); }
.icon-btn:active { transform: scale(.92); }
.icon-btn svg { width: 21px; height: 21px; }
.tool-btn svg { width: 20px; height: 20px; }
.play-btn svg { width: 26px; height: 26px; }
#player-controls .icon-btn svg { width: 24px; height: 24px; }
.badge {
  position: absolute; top: 0; right: 0;
  background: #e0533c; color: #fff;
  font-size: .62rem; font-weight: 700;
  border-radius: 9px; padding: 1px 5px; min-width: 16px;
}

/* ===== Views ===== */
.view { max-width: 800px; margin: 0 auto; padding: 1rem; }

/* ===== Home hero ===== */
#hero {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  color: #f2eeda;
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='64' height='64' viewBox='0 0 64 64'%3E%3Cpath d='M32 6l7 19h19L42.5 37l6 19L32 44 15.5 56l6-19L6 25h19z' fill='none' stroke='%23ffffff' stroke-opacity='.08' stroke-width='1.4'/%3E%3C/svg%3E"),
    radial-gradient(150% 200% at 100% 0%, rgba(233, 200, 106, .18), transparent 55%),
    linear-gradient(140deg, #0a4534, #0c5943 60%, #12735a);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  padding: 1.15rem 1.3rem;
  margin-bottom: 1rem;
  overflow: hidden;
}
.hero-title { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.02em; }
.hero-sub { font-size: .85rem; opacity: .82; margin-top: .2rem; }
.hero-book { width: 108px; flex: none; filter: drop-shadow(0 4px 10px rgba(0, 0, 0, .3)); }

/* faint arabesque on the app background */
body {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='96' height='96' viewBox='0 0 96 96'%3E%3Cpath d='M48 10l10 28h28L63 55l9 28-24-17-24 17 9-28L10 38h28z' fill='none' stroke='%23c2a14d' stroke-opacity='.055' stroke-width='1.3'/%3E%3C/svg%3E");
}
[data-theme="dark"] body { background-image: none; }

/* ===== Home ===== */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); box-shadow: var(--shadow);
  padding: 1rem 1.15rem; margin-bottom: 1rem;
  display: flex; align-items: center; justify-content: space-between; gap: .8rem;
}
#resume-card {
  background:
    radial-gradient(120% 240% at 100% 0%, rgba(194, 161, 77, .10), transparent 50%),
    var(--surface);
}
.resume-title { font-weight: 650; }
#search {
  width: 100%; padding: .75rem 1rem .75rem 2.6rem; margin-bottom: 1rem;
  border: 1px solid var(--border); border-radius: 999px;
  background:
    url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="%237c8779" stroke-width="2.2" stroke-linecap="round"><circle cx="11" cy="11" r="7"/><line x1="21" y1="21" x2="16.5" y2="16.5"/></svg>') no-repeat 1rem 50%,
    var(--surface);
  color: var(--text); font-size: .95rem;
  box-shadow: var(--shadow);
  transition: box-shadow .18s, border-color .18s;
}
#search:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent), var(--shadow);
}
.surah-row {
  display: flex; align-items: center; gap: .85rem;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); padding: .7rem .95rem; margin-bottom: .55rem;
  cursor: pointer;
  transition: transform .15s, border-color .15s, box-shadow .15s;
}
.surah-row:hover {
  border-color: color-mix(in srgb, var(--gold) 55%, var(--border));
  transform: translateY(-1px);
  box-shadow: var(--shadow-lg);
}
.surah-row:active { transform: scale(.99); }
.surah-num {
  width: 38px; height: 38px; flex: none;
  display: flex; align-items: center; justify-content: center;
  color: var(--accent); font-weight: 700; font-size: .8rem;
  background:
    conic-gradient(from 45deg, var(--gold-soft), var(--accent-soft), var(--gold-soft), var(--accent-soft), var(--gold-soft));
  clip-path: polygon(50% 0%, 66% 9%, 84% 9%, 91% 25%, 100% 34%, 97% 52%, 100% 69%, 89% 80%, 82% 96%, 63% 94%, 50% 100%, 37% 94%, 18% 96%, 11% 80%, 0% 69%, 3% 52%, 0% 34%, 9% 25%, 16% 9%, 34% 9%);
}
.surah-mid { flex: 1; min-width: 0; }
.surah-en { font-weight: 650; }
.surah-meta { font-size: .75rem; color: var(--muted); margin-top: 1px; }
.surah-ar { font-family: var(--ar-font); font-size: 1.5rem; color: var(--accent); flex: none; line-height: 1.6; }
.surah-prog {
  height: 4px; border-radius: 2px; background: var(--border);
  margin-top: .4rem; overflow: hidden;
}
.surah-prog > div { height: 100%; background: linear-gradient(90deg, var(--accent), var(--gold)); border-radius: 2px; }

/* ===== Reader toolbar (sticky under the top bar) ===== */
#reader-sticky {
  position: sticky;
  top: var(--topbar-h, 64px);
  z-index: 15;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  margin: -1rem -1rem .6rem;
  padding: .7rem 1rem .55rem;
}
#reader-toolbar {
  display: flex; align-items: center; gap: .5rem; flex-wrap: wrap;
}
.seg {
  display: flex; gap: 3px;
  border: 1px solid var(--border); border-radius: 999px;
  padding: 3px; background: var(--surface);
  box-shadow: var(--shadow);
}
.seg button {
  background: transparent; color: var(--muted); border: none;
  padding: .45rem 1rem; cursor: pointer; font-size: .87rem; font-weight: 550;
  border-radius: 999px;
  transition: background .18s, color .18s;
}
.seg button.active { background: var(--accent); color: #fdfaf1; box-shadow: 0 2px 8px -2px rgba(12, 89, 67, .5); }
.tool-btn {
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
  border-radius: 12px; width: 42px; height: 42px;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 1rem;
  box-shadow: var(--shadow);
  transition: border-color .15s, transform .12s;
}
.tool-btn:hover { border-color: color-mix(in srgb, var(--gold) 55%, var(--border)); }
.tool-btn:active { transform: scale(.93); }
.tool-btn.active { background: var(--accent); color: #fdfaf1; border-color: var(--accent); }
#hide-controls {
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
  background: var(--accent-soft); border: 1px dashed var(--accent);
  border-radius: 11px;
  padding: .55rem .9rem; margin-top: .55rem; font-size: .85rem;
}
#hide-controls label { display: flex; align-items: center; gap: .35rem; cursor: pointer; }

/* ===== Mushaf page ===== */
#quran-container {
  background: var(--paper);
  border: 1px solid var(--gold);
  border-radius: 6px;
  box-shadow:
    inset 0 0 0 4px var(--paper),
    inset 0 0 0 5px var(--gold),
    inset 0 0 0 12px var(--paper),
    inset 0 0 0 13px var(--gold-soft),
    var(--shadow);
  padding: 2rem 1.8rem;
}

.surah-header {
  position: relative;
  text-align: center;
  margin: 0 auto .6rem;
  padding: .7rem 1rem .55rem;
  color: var(--accent);
  border: 1.5px solid var(--gold);
  border-radius: 14px;
  background:
    radial-gradient(90% 130% at 50% 0%, var(--gold-soft) 0%, transparent 55%),
    var(--paper);
}
.surah-header::before, .surah-header::after {
  content: "❁";
  position: absolute; top: 50%;
  transform: translateY(-50%);
  color: var(--gold); font-size: 1rem;
}
.surah-header::before { right: .8rem; }
.surah-header::after { left: .8rem; }
.surah-header .ar { font-family: var(--ar-font); font-size: 1.9rem; line-height: 1.9; }
.surah-header .sub { font-size: .74rem; color: var(--muted); direction: ltr; margin-top: .1rem; }

.bismillah {
  font-family: var(--ar-font);
  text-align: center;
  font-size: calc(var(--ar-size) * 0.98);
  color: var(--text);
  margin: .8rem 0 1.1rem;
  line-height: 2.3;
}

.mushaf-text {
  font-family: var(--ar-font);
  font-size: var(--ar-size);
  line-height: 2.55;
  text-align: justify;
}
.ayah {
  cursor: pointer;
  border-radius: 8px;
  transition: background .25s;
}
.ayah:hover { background: var(--accent-soft); }
.ayah.playing { background: var(--highlight); box-shadow: 0 0 0 3px var(--highlight); }
.ayah.memorized-mark { background: var(--memorized); }
.ayah.playing.memorized-mark { background: var(--highlight); }
.ayah-num {
  color: var(--gold);
  font-size: calc(var(--ar-size) * 0.92);
  user-select: none;
  white-space: nowrap;
}
[data-theme="light"] .ayah-num { color: #a8842e; }
.page-marker {
  display: flex; align-items: center; gap: .8rem;
  color: var(--muted); font-size: .72rem;
  margin: 1rem 0; direction: ltr;
  font-family: system-ui, sans-serif;
  user-select: none;
}
.page-marker::before, .page-marker::after {
  content: ""; flex: 1; height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
}
.juz-marker {
  display: inline-block;
  background: linear-gradient(120deg, var(--accent-2), var(--accent));
  color: #f4efdf;
  font-size: .68rem; font-family: system-ui, sans-serif;
  border-radius: 999px; padding: 3px 10px; margin: 0 .35rem;
  vertical-align: middle; user-select: none;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .2);
}

/* ===== Mushaf paged view — Dar al-Maarifah style ===== */
#quran-container.paged {
  background: #fdfad2;                 /* pale yellow canvas like the original */
  border: none;
  box-shadow: none;
  border-radius: 10px;
  padding: 14px 10px 8px;
}
[data-theme="dark"] #quran-container.paged { background: #262b1c; }

.m-outer {
  max-width: 620px;
  margin: 0 auto;
  padding: 8px;
  border: 2px solid #1f8fa0;
  border-radius: 4px;
  background:
    repeating-linear-gradient(45deg,
      #e9d491 0 6px, #c8a44b 6px 8px, #e9d491 8px 12px, #a67c22 12px 14px);
  box-shadow: 0 4px 18px rgba(90, 70, 20, .25);
}
.m-page {
  background: #fffef8;
  border: 2px solid #1f8fa0;
  padding: .5rem .8rem .55rem;
}
.m-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: .35rem;
}
.m-tab {
  font-family: var(--ar-font);
  font-size: .95rem;
  color: #0b4c40;
  background: linear-gradient(180deg, #fdf6dd, #f2e2b0);
  border: 1px solid #1f8fa0;
  border-radius: 4px;
  padding: 0 .6rem;
  line-height: 1.9;
}

.m-body {
  direction: rtl;
  font-family: var(--ar-font);
  color: #1c1c1c;
  /* font scales with page width so 15 authentic lines always fit */
  font-size: clamp(15px, calc((min(100vw, 640px) - 90px) / 19), 33px);
  font-feature-settings: "calt" 1, "liga" 1, "rlig" 1;
  text-rendering: optimizeLegibility;
}
/* pages 1-2 are the short ornate opening pages: narrow centered text block,
   never stretch-justified — words sit next to each other */
.m-body.m-opening { max-width: 80%; margin: 0 auto; }
.m-body.m-opening .m-line { justify-content: center; gap: .4em; }
.m-line {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: .12em;              /* minimum breathing room on full lines */
  line-height: 2.35;
  white-space: nowrap;
}
.m-line.m-center, .m-line.m-loose { justify-content: center; gap: .4em; }
.m-line .word { cursor: pointer; border-radius: 4px; }
.m-line .word.playing, .m-line .ayah-num.playing { background: var(--highlight); }
.m-line .word.memorized-mark { background: var(--memorized); }
.m-line .word.playing.memorized-mark { background: var(--highlight); }
.m-page .ayah-num {
  color: #8a6c1f;
  cursor: pointer;
  font-size: .95em;
  margin: 0 .1em;
}
.hide-mode .m-line .word.word-hidden { filter: blur(8px); user-select: none; }

.m-suraheader {
  display: flex; justify-content: center; align-items: center; gap: 1rem;
  font-family: var(--ar-font);
  color: #0b4c40;
  border: 1.5px solid #1f8fa0;
  border-radius: 6px;
  background:
    radial-gradient(120% 200% at 50% 0%, #f6ebc8 0%, #fdf8e4 60%);
  margin: .2rem 0;
  line-height: 2.1;
  font-size: 1.1em;
}
.m-suraheader .msh-count { font-size: .55em; color: #7a6a35; }
.m-bismillah {
  direction: rtl;
  text-align: center;
  font-family: var(--ar-font);
  font-size: .95em;
  line-height: 2.1;
  color: #1c1c1c;
}

.m-legend {
  direction: rtl;
  display: flex; flex-wrap: wrap;
  gap: .15rem .8rem;
  justify-content: center;
  border: 1px solid #1f8fa0;
  border-radius: 3px;
  margin-top: .45rem;
  padding: .3rem .5rem;
  font-family: system-ui, sans-serif;
  font-size: .62rem;
  color: #333;
  background: #fffef8;
}
.m-key { display: inline-flex; align-items: center; gap: .3rem; white-space: nowrap; }
.m-key i {
  width: .62rem; height: .62rem; border-radius: 50%;
  display: inline-block; flex: none;
}

.m-nav {
  display: flex; align-items: center; justify-content: center;
  gap: 1.4rem; margin-top: .5rem;
}
.m-navbtn {
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: 50%;
  width: 44px; height: 44px; font-size: 1.5rem; line-height: 1;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: border-color .15s, transform .12s, box-shadow .18s;
}
.m-navbtn:hover { border-color: var(--gold); box-shadow: var(--shadow-lg); }
.m-navbtn:active { transform: scale(.9); }
.m-pageno { font-family: var(--ar-font); font-size: 1.15rem; min-width: 3rem; text-align: center; }

/* ===== List mode ===== */
.ayah-block {
  border-bottom: 1px solid var(--border);
  padding: 1rem .4rem;
  cursor: pointer;
  border-radius: 10px;
  transition: background .2s;
}
.ayah-block:hover { background: var(--accent-soft); }
.ayah-block.playing { background: var(--highlight); }
.ayah-block.memorized-mark { border-inline-start: 3px solid var(--accent); padding-inline-start: .7rem; }
.ayah-block .ar-line {
  font-family: var(--ar-font);
  font-size: var(--ar-size); line-height: 2.3;
  text-align: right;
}
.ayah-block .tr-line {
  direction: ltr; text-align: left;
  font-size: .9rem; color: var(--muted);
  margin-top: .5rem; line-height: 1.55;
}

/* ===== Hide / self-test ===== */
.hide-mode .ayah-text-hidden { filter: blur(9px); user-select: none; }
.hide-mode .word-hidden { filter: blur(9px); user-select: none; }
.hide-mode .ayah:hover .ayah-text-hidden { filter: blur(7px); }

/* ===== Translation card (mushaf mode, in flow below the page) ===== */
#tr-strip {
  max-width: 620px;
  margin: .7rem auto 0;
  background: var(--surface);
  border: 1px solid var(--gold-soft);
  border-inline-start: 3px solid var(--gold);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: .65rem 1rem;
  font-size: .9rem; line-height: 1.55; color: var(--text);
  animation: tr-in .25s ease;
}
@keyframes tr-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}

/* ===== Review ===== */
.review-item {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; padding: .85rem 1rem; margin-bottom: .6rem;
  display: flex; align-items: center; justify-content: space-between; gap: .6rem;
}
.review-item .info { flex: 1; }
.review-item .info .muted { font-family: var(--ar-font); font-size: 1.1rem; }
.review-actions { display: flex; gap: .4rem; }

/* ===== Player ===== */
#player {
  position: fixed; bottom: 12px; left: 12px; right: 12px; z-index: 30;
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  -webkit-backdrop-filter: blur(14px) saturate(1.4);
  backdrop-filter: blur(14px) saturate(1.4);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  padding: .6rem 1.1rem calc(.6rem + env(safe-area-inset-bottom));
  max-width: 780px; margin: 0 auto;
  border-radius: var(--r-lg);
}
#player-info {
  display: flex; justify-content: space-between; align-items: center;
  font-size: .8rem; margin-bottom: .35rem;
}
#player-controls { display: flex; align-items: center; gap: .65rem; justify-content: center; }
.play-btn {
  width: 56px; height: 56px; border-radius: 50%;
  background: linear-gradient(140deg, var(--accent), var(--accent-2));
  color: #f4efdf; border: 2px solid var(--gold);
  font-size: 1.35rem; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 16px -2px rgba(10, 60, 45, .5);
  transition: transform .12s, box-shadow .18s;
}
.play-btn:hover { box-shadow: 0 6px 22px -2px rgba(10, 60, 45, .55); }
.play-btn:active { transform: scale(.92); }
#player-controls .icon-btn { color: var(--text); font-size: 1.3rem; }
#player select {
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: 9px; padding: .32rem;
}

/* ===== Sheets ===== */
.sheet {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
  background: var(--surface); border-radius: 24px 24px 0 0;
  box-shadow: 0 -12px 48px rgba(0, 0, 0, .35);
  padding: 1.5rem 1.3rem calc(1.3rem + env(safe-area-inset-bottom));
  max-width: 580px; margin: 0 auto;
  max-height: 85vh; overflow-y: auto;
  animation: sheet-in .28s cubic-bezier(.32, .72, .28, 1);
}
.sheet::before {
  content: "";
  position: absolute; top: 9px; left: 50%; transform: translateX(-50%);
  width: 42px; height: 4px; border-radius: 2px;
  background: var(--border);
}
@keyframes sheet-in {
  from { transform: translateY(40%); opacity: .4; }
  to { transform: none; opacity: 1; }
}
.sheet h3 { margin-bottom: 1rem; color: var(--accent); font-weight: 650; }
.rp-seg { margin-bottom: .6rem; }
.rp-seg button { flex: 1; }
#rp-mode-hint { margin-bottom: .9rem; line-height: 1.45; }
.form-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: .85rem; }
.form-row label { font-size: .9rem; flex: 1; }
.form-row input, .form-row select {
  background: var(--bg); color: var(--text);
  border: 1px solid var(--border); border-radius: 9px;
  padding: .48rem .6rem; width: 130px; font-size: .95rem;
}
.sheet-actions { display: flex; gap: .6rem; margin-top: 1.2rem; }
.primary-btn {
  background: linear-gradient(140deg, var(--accent), var(--accent-2));
  color: #f4efdf; border: none;
  border-radius: 12px; padding: .7rem 1.2rem; cursor: pointer;
  font-size: .95rem; font-weight: 650; flex: 1;
  box-shadow: 0 3px 12px -3px rgba(12, 89, 67, .55);
  transition: transform .12s, box-shadow .18s;
}
.primary-btn:hover { box-shadow: 0 5px 18px -3px rgba(12, 89, 67, .6); }
.primary-btn:active { transform: scale(.97); }
.secondary-btn {
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: 12px;
  padding: .7rem 1rem; cursor: pointer; font-size: .95rem; font-weight: 550;
  transition: border-color .15s, transform .12s;
}
.secondary-btn:hover { border-color: color-mix(in srgb, var(--accent) 40%, var(--border)); }
.secondary-btn:active { transform: scale(.97); }
#overlay {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(10, 15, 12, .4);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  animation: fade-in .2s ease;
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

details { margin: .9rem 0; font-size: .88rem; }
details summary { cursor: pointer; font-weight: 600; color: var(--accent); padding: .2rem 0; }
details ul { list-style: none; margin: .5rem 0 0; padding: 0 .2rem; }
details li { padding: .22rem 0; }
details a { font-weight: 600; }

/* ===== Profile ===== */
#streak-chip {
  align-self: center;
  background: rgba(255, 255, 255, .16);
  border-radius: 999px;
  padding: .15rem .55rem;
  font-size: .8rem; font-weight: 700;
}
.p-stats { display: flex; gap: .6rem; margin-bottom: 1rem; }
.p-stat {
  flex: 1; text-align: center;
  background:
    radial-gradient(130% 160% at 50% 0%, color-mix(in srgb, var(--accent-soft) 65%, transparent), transparent 60%),
    var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r); padding: .95rem .4rem;
  box-shadow: var(--shadow);
}
.p-num { font-size: 1.45rem; font-weight: 700; letter-spacing: -0.02em; }
.p-lbl { font-size: .72rem; color: var(--muted); margin-top: .2rem; }
.p-progress {
  height: 10px; border-radius: 5px; background: var(--border);
  overflow: hidden; margin-bottom: .4rem;
}
.p-progress > div {
  height: 100%; border-radius: 5px;
  background: linear-gradient(90deg, var(--accent), var(--gold));
  transition: width .4s;
}
.p-wide { width: 100%; margin: .8rem 0; }
.p-h { margin: 1.2rem 0 .6rem; color: var(--accent); font-size: 1rem; }
.p-plan { display: block; }
.p-plan-row {
  display: flex; justify-content: space-between;
  padding: .25rem 0; font-size: .92rem;
}
.p-chip {
  background: var(--accent-soft); color: var(--accent);
  border: 1px solid var(--accent); border-radius: 999px;
  padding: .45rem .9rem; margin: 0 .35rem .5rem 0;
  font-size: .88rem; font-weight: 600; cursor: pointer;
}
.p-chip:hover { background: var(--accent); color: #fdfaf1; }
#view-profile .form-row input[type="date"],
#view-profile .form-row input[type="time"],
#view-profile .form-row select {
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: 9px;
  padding: .45rem .6rem; width: 170px; font-size: .92rem;
}

/* baseline picker */
.bl-grid {
  display: grid; grid-template-columns: repeat(6, 1fr);
  gap: .45rem; margin: .8rem 0;
}
.bl-cell {
  aspect-ratio: 1; border-radius: 10px;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--border);
  font-size: .95rem; font-weight: 600; cursor: pointer;
}
.bl-cell.done { background: var(--accent); color: #fdfaf1; border-color: var(--accent); }
.bl-list { max-height: 45vh; overflow-y: auto; margin: .8rem 0; }
.bl-row {
  display: flex; align-items: center; gap: .6rem;
  padding: .45rem .2rem; border-bottom: 1px solid var(--border);
  cursor: pointer; font-size: .92rem;
}
.bl-row .bl-ar { margin-inline-start: auto; font-family: var(--ar-font); color: var(--accent); }

/* ===== Toast ===== */
#toast {
  position: fixed; bottom: 120px; left: 50%; transform: translateX(-50%);
  background: color-mix(in srgb, var(--text) 92%, transparent);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  color: var(--bg);
  border-radius: 999px; padding: .6rem 1.2rem; font-size: .88rem; font-weight: 550;
  z-index: 60; box-shadow: var(--shadow-lg);
  max-width: 90vw; text-align: center;
  animation: toast-in .22s cubic-bezier(.32, .72, .28, 1);
}
@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 8px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

@media (max-width: 480px) {
  .view { padding: .7rem; }
  #quran-container { padding: 1.3rem .95rem; }
  #tr-strip { left: 6px; right: 6px; }
}
