@font-face { font-family: 'Amiri Quran'; src: url(fonts/AmiriQuran-Regular.ttf) format('truetype'); font-display: swap; }
@font-face { font-family: 'Scheherazade New'; src: url(fonts/ScheherazadeNew-Regular.ttf) format('truetype'); font-display: swap; }

:root {
  --bg: #f6f3ec; --card: #ffffff; --text: #1d2422; --muted: #6b7471; --line: #e3ddd0;
  --accent: #0f5c4d; --accent2: #c8962e; --accent-soft: #e4f0ec; --danger: #b3261e; --ok: #1b7a3a;
  --ar-size: 30px; --radius: 14px; --shadow: 0 1px 3px rgba(0,0,0,.08);
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #111615; --card: #1b2220; --text: #e7ece9; --muted: #98a39f; --line: #2c3633;
  --accent: #4fc3a1; --accent2: #e0b354; --accent-soft: #1f3a33; --danger: #ff8a80; --ok: #7ed39a;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--text); overflow-x: hidden; }
body { font: 16px/1.5 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif; padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
a { color: var(--accent); }
button { font: inherit; color: inherit; cursor: pointer; }
input, select, textarea { font: inherit; color: var(--text); background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; max-width: 100%; }

header#top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 8px; padding: 10px 16px; padding-top: calc(10px + env(safe-area-inset-top));
  background: var(--accent); color: #fff; }
:root[data-theme="dark"] header#top { background: #0c2a24; }
header h1 { flex: 1; margin: 0; font-size: 18px; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon { background: none; border: 0; font-size: 20px; padding: 6px 8px; border-radius: 10px; line-height: 1; }
header .icon { color: #fff; font-size: 28px; padding: 0 8px; }
.chip { border: 1px solid currentColor; background: transparent; border-radius: 999px; padding: 3px 11px; font-size: 13px; font-weight: 600; }
header .chip { color: #fff; }

main { max-width: 860px; margin: 0 auto; padding: 14px 16px 24px; outline: none; }
h2 { font-size: 20px; margin: 18px 0 10px; } h3 { font-size: 17px; margin: 16px 0 8px; }
.muted { color: var(--muted); } .small { font-size: 13px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin: 10px 0; box-shadow: var(--shadow); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.tile { display: block; text-decoration: none; color: inherit; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); }
.tile b { display: block; font-size: 16px; } .tile .muted { font-size: 13px; }
.tile .em { font-size: 26px; float: right; }
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--accent); background: var(--accent); color: #fff; padding: 9px 14px; border-radius: 10px; text-decoration: none; font-weight: 600; }
:root[data-theme="dark"] .btn { color: #0b1a16; }
.btn.ghost { background: transparent; color: var(--accent); }
.btn.small { padding: 5px 10px; font-size: 14px; }
.btn:disabled { opacity: .5; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px; }
.stat { background: var(--accent-soft); border-radius: 12px; padding: 10px; } .stat b { font-size: 22px; display: block; color: var(--accent); }
.bar { height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; } .bar i { display: block; height: 100%; background: var(--accent); }
.note { background: #fff7e3; border: 1px solid #ecd9a6; color: #5b4a17; border-radius: 12px; padding: 10px 12px; font-size: 14px; margin: 10px 0; }
:root[data-theme="dark"] .note { background: #2b2614; border-color: #4d4220; color: #e9d79e; }

.ar { font-family: 'Amiri Quran', 'Scheherazade New', 'Traditional Arabic', serif; direction: rtl; text-align: right; font-size: var(--ar-size); line-height: 2.15; }
.ar-s { font-family: 'Scheherazade New', 'Amiri Quran', serif; direction: rtl; font-size: 22px; line-height: 1.9; }

/* список сур */
.surah-list { list-style: none; padding: 0; margin: 0; }
.surah-list a { display: grid; grid-template-columns: 44px 1fr auto; align-items: center; gap: 10px; padding: 10px 6px; border-bottom: 1px solid var(--line); text-decoration: none; color: inherit; }
.num { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 14px; }
.surah-list .ar-s { font-size: 22px; }
.filter { width: 100%; margin: 6px 0 10px; }

/* чтение */
.surah-head { text-align: center; padding: 10px 0 4px; }
.surah-head .ar { text-align: center; font-size: 36px; line-height: 1.6; }
.bism { text-align: center; font-size: calc(var(--ar-size) * 1.05); margin: 6px 0 12px; }
.ayah { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; margin: 10px 0; scroll-margin-top: 70px; }
.ayah.playing { border-color: var(--accent2); box-shadow: 0 0 0 2px var(--accent2) inset; }
.ayah .tools { display: flex; gap: 2px; align-items: center; flex-wrap: wrap; border-bottom: 1px dashed var(--line); padding-bottom: 6px; margin-bottom: 4px; }
.ayah .tools .num { width: 32px; height: 32px; font-size: 13px; margin-right: 6px; }
.ayah .tools .icon { font-size: 18px; }
.ayah .tools .icon.on { color: var(--accent2); }
.ayah .tools [data-act=bm] { opacity: .3; filter: grayscale(1); } .ayah .tools [data-act=bm].on { opacity: 1; filter: none; }
.ayah .tools .spacer { flex: 1; }
.ayah .tl { color: var(--muted); font-style: italic; margin-top: 4px; }
.ayah .tr { margin-top: 6px; }
.ayah .badge { font-size: 12px; padding: 2px 7px; border-radius: 99px; background: var(--accent-soft); color: var(--accent); border: 0; }
.end-ayah { font-family: 'Amiri Quran', serif; color: var(--accent2); font-size: .8em; }
.reader-bar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 4px 0 10px; }
.pager { display: flex; justify-content: space-between; margin: 18px 0; }

/* таджвид */
.tj-h, .tj-s, .tj-l { color: #AAAAAA; } .tj-n { color: #537FFF; } .tj-p { color: #4050FF; } .tj-m { color: #000EBC; }
.tj-q { color: #DD0008; } .tj-o { color: #2144C1; } .tj-c { color: #D500B7; } .tj-f { color: #9400A8; } .tj-w { color: #58B800; }
.tj-i { color: #26BFFD; } .tj-a { color: #169777; } .tj-u { color: #169200; } .tj-d, .tj-b { color: #A1A1A1; } .tj-g { color: #FF7E1E; }
:root[data-theme="dark"] .tj-m { color: #7d86ff; } :root[data-theme="dark"] .tj-o { color: #6f8cf0; } :root[data-theme="dark"] .tj-p { color: #7f8bff; }
.swatch { display: inline-block; width: 14px; height: 14px; border-radius: 4px; vertical-align: -2px; margin-right: 6px; }

/* нижняя навигация */
nav#tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); background: var(--card); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
nav#tabs a { display: flex; flex-direction: column; align-items: center; padding: 6px 0 7px; text-decoration: none; color: var(--muted); font-size: 11px; }
nav#tabs a span { font-size: 19px; line-height: 1.2; } nav#tabs a b { font-weight: 600; }
nav#tabs a.active { color: var(--accent); }

/* плеер */
#player, #narr { position: fixed; left: 8px; right: 8px; bottom: calc(66px + env(safe-area-inset-bottom)); z-index: 25; max-width: 600px; margin: 0 auto; display: flex; align-items: center; gap: 4px;
  background: var(--accent); color: #fff; border-radius: 16px; padding: 6px 8px 6px 14px; box-shadow: 0 6px 20px rgba(0,0,0,.25); }
#player .icon, #narr .icon { color: #fff; } #player .big, #narr .big { font-size: 26px; }
.pl-info { flex: 1; min-width: 0; } .pl-info b, .pl-info small { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } .pl-info small { opacity: .85; }
:root[data-theme="dark"] #player, :root[data-theme="dark"] #narr { background: #0c2a24; }

/* нижняя шторка */
#sheet { position: fixed; inset: 0; z-index: 40; background: rgba(0,0,0,.45); display: flex; align-items: flex-end; justify-content: center; }
.sheet-box { position: relative; background: var(--bg); width: 100%; max-width: 860px; max-height: 86vh; overflow: auto; border-radius: 18px 18px 0 0; padding: 18px 16px calc(24px + env(safe-area-inset-bottom)); }
.sheet-x { position: sticky; top: 0; float: right; background: var(--card); border: 1px solid var(--line); }
.tafsir-text { line-height: 1.7; } .tafsir-text h2, .tafsir-text h3 { font-size: 16px; } .tafsir-text[dir=rtl] { font-family: 'Scheherazade New', serif; font-size: 21px; }
.src { font-size: 13px; color: var(--muted); border-top: 1px solid var(--line); margin-top: 12px; padding-top: 8px; }
.hadith-ar { font-family: 'Scheherazade New', serif; direction: rtl; font-size: 21px; line-height: 1.9; }
.tag { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 99px; background: var(--accent-soft); color: var(--accent); margin: 2px 4px 2px 0; }
.tag.good { background: #e3f4e8; color: var(--ok); } :root[data-theme="dark"] .tag.good { background: #1d3a26; }

#toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(140px + env(safe-area-inset-bottom)); z-index: 50; background: #222; color: #fff; padding: 9px 16px; border-radius: 99px; font-size: 14px; }

/* обучение */
.letters { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; }
.letter { background: var(--card); border: 1px solid var(--line); border-radius: 12px; text-align: center; padding: 6px 4px; }
.letter .ar-s { font-size: 40px; line-height: 1.5; display: block; } .letter small { color: var(--muted); }
.forms { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; text-align: center; }
.forms div { background: var(--accent-soft); border-radius: 10px; padding: 6px 2px; } .forms .ar-s { font-size: 40px; display: block; }
.choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; margin-top: 10px; }
.choice { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px; text-align: center; }
.choice.ar-s { font-size: 22px; }
.choice.right { border-color: var(--ok); background: #e3f4e8; } .choice.bad { border-color: var(--danger); background: #fde7e6; }
:root[data-theme="dark"] .choice.right { background: #1d3a26; } :root[data-theme="dark"] .choice.bad { background: #3d1f1d; }
.hidden-word { display: inline-block; background: var(--line); color: transparent; border-radius: 6px; cursor: pointer; user-select: none; }
.seg { display: flex; flex-wrap: wrap; gap: 6px; } .seg button { border: 1px solid var(--line); background: var(--card); border-radius: 99px; padding: 6px 12px; }
.seg button.on { background: var(--accent); color: #fff; border-color: var(--accent); }
label.line { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
label.line select { max-width: 60%; }
mark { background: #ffe58a; color: inherit; border-radius: 3px; } :root[data-theme="dark"] mark { background: #6b5a1a; }
.list-item { display: block; padding: 10px 4px; border-bottom: 1px solid var(--line); text-decoration: none; color: inherit; }
@media (max-width: 520px) { :root { --ar-size: 26px; } main { padding: 10px 12px 24px; } .ayah { padding: 10px 11px; } }

/* озвучка хадисов */
#narr { background: #6b4a12; } .narr-on { outline: 2px solid var(--accent2); outline-offset: 2px; border-radius: 10px; background: var(--accent-soft); }

/* раздел «Сунна»: оформление рассказа */
.sunna-hero { text-align: center; padding: 18px 10px 14px; margin: 4px 0 10px; border-radius: 18px; color: #fbeec8;
  background: radial-gradient(circle at 50% 30%, #1b7d68, #0b4a3e 70%); border: 1px solid #c9a356; }
.sunna-hero h2 { margin: 4px 0; color: #fff; } .sunna-hero .orn { font-size: 38px; color: #e3b65a; line-height: 1; }
.sunna-hero .ar-s { font-size: 26px; color: #e9c779; } .sunna-hero .muted { color: #d9e6df; }
.sunna-tile { border-color: #e4d3a6; } .sunna-tile b { margin-top: 4px; }
.story { position: relative; background: var(--card); border: 1px solid #e4d3a6; border-radius: 18px; padding: 18px 16px 14px; margin: 16px 0;
  box-shadow: 0 2px 10px rgba(120, 90, 30, .08); background-image: linear-gradient(180deg, rgba(227,182,90,.08), transparent 120px); }
:root[data-theme="dark"] .story { border-color: #4d4220; }
.story-n { position: absolute; top: -14px; right: 16px; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
  background: #c9a356; color: #fff; font-family: 'Amiri Quran', serif; font-size: 18px; box-shadow: 0 0 0 3px var(--bg); }
.story-t { margin: 0 0 8px; font-family: Georgia, 'Times New Roman', serif; font-size: 19px; color: var(--accent); }
.story-intro { font-style: italic; color: var(--muted); margin: 4px 0; }
.story-q { margin: 8px 0 12px; padding: 12px 16px; border-left: 4px solid var(--accent2); background: var(--accent-soft); border-radius: 0 12px 12px 0;
  font-family: Georgia, 'Times New Roman', serif; font-size: 18px; line-height: 1.6; }
.story-q::before { content: '❝ '; color: var(--accent2); } .story-q::after { content: ' ❞'; color: var(--accent2); }
.cmp { display: grid; grid-template-columns: 1fr 1.4fr; gap: 10px; margin: 10px 0; }
.cmp > div { border-radius: 12px; padding: 10px 12px; } .cmp b { display: block; margin-bottom: 6px; }
.cmp-h { background: #f3ecdc; } .cmp-s { background: #e7f3ec; } .cmp ul { margin: 0; padding-left: 18px; } .cmp li { margin: 3px 0; }
:root[data-theme="dark"] .cmp-h { background: #2b2614; } :root[data-theme="dark"] .cmp-s { background: #1d3a2e; }
.story details { margin: 6px 0; } .story summary { cursor: pointer; color: var(--accent); font-weight: 600; }
@media (max-width: 600px) { .cmp { grid-template-columns: 1fr; } nav#tabs a { font-size: 10px; } }.story-say { margin: 0 0 8px; }

/* курс арабского */
.wchips { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.wchip { display: flex; flex-direction: column; align-items: center; min-width: 74px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); }
.wchip .ar-s { font-size: 30px; line-height: 1.6; } .wchip small { direction: ltr; font-size: 12px; line-height: 1.3; }
.wchip.on { border-color: var(--accent2); background: var(--accent-soft); box-shadow: 0 0 0 2px var(--accent2) inset; }
.hide-tl .wchip small { visibility: hidden; } .hide-tl .wchip.on small { visibility: visible; }
.syl { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.syl .letter { display: grid; grid-template-columns: repeat(3, 1fr); align-items: center; padding: 6px; }
.syl .letter .ar-s { font-size: 30px; } .syl .letter small { grid-row: 2; }

/* слушать Коран */
.rec-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 6px; margin-top: 8px; }
.rec { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 12px; cursor: pointer; }
.rec span { flex: 1; } .rec.on { border-color: var(--accent); background: var(--accent-soft); }
.now-ayah .ar { font-size: calc(var(--ar-size) * 1.2); }

/* главная страница */
.hero-home { position: relative; overflow: hidden; text-align: center; color: #fff; margin: -14px -16px 14px; padding: 22px 16px 22px;
  background: radial-gradient(circle at 50% 0%, #1f8a72 0%, #0f5c4d 45%, #08382f 100%); border-bottom: 3px solid #c9a356; }
.hero-home::before { content: ''; position: absolute; inset: 0; opacity: .09; pointer-events: none;
  background-image: repeating-linear-gradient(45deg, #fff 0 1px, transparent 1px 22px), repeating-linear-gradient(-45deg, #fff 0 1px, transparent 1px 22px); }
.hero-home > * { position: relative; }
.hero-logo { width: 74px; height: 74px; border-radius: 18px; box-shadow: 0 6px 18px rgba(0,0,0,.3); }
.hero-greet { font-size: 22px; font-weight: 700; margin-top: 10px; color: #fbeec8; }
.hero-date { font-size: 13px; opacity: .85; margin-top: 2px; }
.hero-bism { font-family: 'Amiri Quran', serif; font-size: 30px; line-height: 2; color: #f3d68f; direction: rtl; margin: 6px 0 10px; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.btn.gold { background: linear-gradient(180deg, #f0cf7c, #c9973a); border-color: #b8862f; color: #2b2109; }
.btn.glass { background: rgba(255,255,255,.12); border-color: rgba(255,255,255,.45); color: #fff; }
.quick { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin: 4px 0 14px; }
.qt { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 2px; text-decoration: none; color: var(--text);
  background: var(--card); border: 1px solid var(--line); border-radius: 16px; font-size: 12px; font-weight: 600; text-align: center; box-shadow: var(--shadow); min-width: 0; overflow-wrap: anywhere; }
.qt-ic { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; font-size: 22px;
  background: linear-gradient(180deg, var(--accent-soft), transparent); border: 1px solid #e4d3a6; }
.qt-ic .ar-s { font-size: 26px; color: var(--accent); }
.ayah-day { background: var(--card); border: 1px solid #e4d3a6; border-radius: 20px; padding: 16px; margin: 12px 0; text-align: center; box-shadow: 0 2px 12px rgba(120,90,30,.08);
  background-image: linear-gradient(180deg, rgba(227,182,90,.10), transparent 90px); }
:root[data-theme="dark"] .ayah-day { border-color: #4d4220; }
.ad-head { color: var(--accent2); font-weight: 700; letter-spacing: .5px; text-transform: uppercase; font-size: 13px; }
.ad-head span { margin: 0 6px; }
.ad-ar { text-align: center; margin: 6px 0; }
.ad-tr { font-family: Georgia, 'Times New Roman', serif; font-size: 17px; line-height: 1.6; }
.ad-ref { font-size: 13px; margin-top: 8px; }
.ad-btns { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-top: 10px; }
.prog { display: flex; align-items: center; gap: 14px; }
.ring { width: 92px; height: 92px; flex: none; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 8; } .ring-bg { stroke: var(--line); } .ring-fg { stroke: var(--accent); stroke-linecap: round; }
.ring text { transform: rotate(90deg); transform-origin: 40px 40px; font-size: 15px; font-weight: 700; fill: var(--accent); }
.prog-stats { flex: 1; display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px; }
.prog-stats b { display: block; font-size: 19px; color: var(--accent); } .prog-stats span { font-size: 12px; color: var(--muted); }
.home-foot { text-align: center; font-size: 12px; color: var(--muted); }
@media (max-width: 520px) { .hero-home { margin: -10px -12px 14px; } }
@media (max-width: 400px) { .qt { font-size: 11px; } .qt-ic { width: 38px; height: 38px; font-size: 19px; } .hero-actions .btn { width: 100%; justify-content: center; } }
@media (min-width: 700px) { .hero-home { margin: 0 0 14px; border-radius: 22px; border: 1px solid #c9a356; } .quick { grid-template-columns: repeat(8, 1fr); } }

/* ---------- поделиться ---------- */
.share-card { display: flex; align-items: center; gap: 14px; margin-top: 16px; padding: 16px; border-radius: 18px; color: #fff;
  background: radial-gradient(circle at 15% 0, #1d6b52, #0b3d2e 75%); box-shadow: 0 6px 18px #0b3d2e33; }
.share-card .sc-ic { font-size: 30px; flex: none; }
.share-card .sc-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.share-card .sc-txt span { font-size: 13px; opacity: .85; }
.share-card .btn { flex: none; }
.share-url { font-family: ui-monospace, Consolas, monospace; font-size: 14px; padding: 10px 12px; border-radius: 10px; background: var(--bg2, #0001); word-break: break-all; margin: 8px 0 12px; }
.share-btns { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.share-btns .btn { justify-content: center; width: 100%; }
.share-btns #sh-sys { grid-column: 1 / -1; }
.btn.sh-wa { background: #1fa855; color: #fff; }
.btn.sh-tg { background: #2a9ed8; color: #fff; }
.share-qr { display: block; width: 210px; max-width: 70%; margin: 8px auto 0; border-radius: 12px; }
.inst-bar { display: flex; align-items: center; gap: 12px; margin: 0 0 14px; padding: 14px; border-radius: 18px;
  background: linear-gradient(135deg, #fff8e6, #f3e3b5); color: #3b2f12; border: 1px solid #d9b65c; box-shadow: 0 6px 18px #b8933a33;
  animation: ib-in .4s ease-out; }
.inst-bar .ib-ic { width: 48px; height: 48px; border-radius: 12px; flex: none; }
.inst-bar .ib-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.inst-bar .ib-txt span { font-size: 13px; opacity: .8; }
.inst-bar .ib-btns { display: flex; flex-direction: column; gap: 6px; flex: none; }
.inst-bar .ib-later { color: #6b5a2c; justify-content: center; }
.inst-steps { padding-left: 22px; line-height: 1.55; } .inst-steps li { margin: 6px 0; }
@keyframes ib-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }
@media (max-width: 400px) { .inst-bar { flex-wrap: wrap; } .inst-bar .ib-btns { width: 100%; flex-direction: row; } .inst-bar .ib-btns .btn { flex: 1; justify-content: center; } }
@media (max-width: 400px) { .share-card { flex-wrap: wrap; } .share-card .btn { width: 100%; justify-content: center; } }