/* Ahillh — «ليل» (night) and «ورق» (paper), the app's two appearances. Tokens from Shared/Design/Palette.swift. */
@font-face { font-family: "Amiri Quran"; src: url("../fonts/AmiriQuran-Regular.ttf") format("truetype"); font-display: swap; }

:root {
  color-scheme: light;
  --ink-top: #FBF8F2; --ink-bottom: #F0E9DB;
  --surface: #FFFFFF; --raised: #F4EEE2;
  --text: #1B1E27; --text2: rgba(27,30,39,.68); --text3: rgba(27,30,39,.52);
  --gold: #A67B2B; --gold-deep: #73531A; --hl: #886420; --hl-ink: #FFFBF2;
  --hair: rgba(27,30,39,.10); --veil: rgba(27,30,39,.06); --veil2: rgba(27,30,39,.10);
  --shadow: 0 10px 30px rgba(91,74,44,.12);
  --mint: #1F8A64; --orange: #BF6A14; --pink: #C0483C; --purple: #4F5FC4;
  --parch: #F2E9D5; --parch2: #E5D8BE; --parch-ink: #1E180E;
  --gold-grad: linear-gradient(180deg, #B58A35, #94702A 55%, #7A591C);
  --m0a: #F6CE6B; --m0b: #E2A632; --m0c: #B87A16; --m1a: #C9D3EA; --m1b: #8E9FC9; --m2a: #6FD3F7; --m2b: #1E93DA;
  --radius: 24px;
  --body: -apple-system, BlinkMacSystemFont, "SF Arabic", "Segoe UI", "Noto Sans Arabic", Tahoma, sans-serif;
  --display: "Amiri Quran", "Amiri", serif;
}
:root.en { --display: ui-serif, "New York", Georgia, "Times New Roman", serif; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --ink-top: #27282B; --ink-bottom: #1F2023; --surface: #2E2F33; --raised: #37383D;
    --text: #E6DAC2; --text2: rgba(230,218,194,.70); --text3: rgba(230,218,194,.48);
    --gold: #E3BF7A; --gold-deep: #B48C48; --hl: #F0DCAE; --hl-ink: #1E180E;
    --hair: rgba(255,255,255,.08); --veil: rgba(255,255,255,.05); --veil2: rgba(255,255,255,.09);
    --shadow: 0 12px 34px rgba(0,0,0,.45);
    --mint: #7FD4B0; --orange: #F0A860; --pink: #EE8F85; --purple: #9EABF2;
    --gold-grad: linear-gradient(180deg, #F0DCAE, #E3BF7A 55%, #B48C48);
    --m0a: #FFF4CC; --m0b: #F3CB6C; --m0c: #C99230; --m1a: #FFFFFF; --m1b: #DCE8FF; --m2a: #A6F0FF; --m2b: #4FC3F7;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --ink-top: #27282B; --ink-bottom: #1F2023; --surface: #2E2F33; --raised: #37383D;
  --text: #E6DAC2; --text2: rgba(230,218,194,.70); --text3: rgba(230,218,194,.48);
  --gold: #E3BF7A; --gold-deep: #B48C48; --hl: #F0DCAE; --hl-ink: #1E180E;
  --hair: rgba(255,255,255,.08); --veil: rgba(255,255,255,.05); --veil2: rgba(255,255,255,.09);
  --shadow: 0 12px 34px rgba(0,0,0,.45);
  --mint: #7FD4B0; --orange: #F0A860; --pink: #EE8F85; --purple: #9EABF2;
  --gold-grad: linear-gradient(180deg, #F0DCAE, #E3BF7A 55%, #B48C48);
  --m0a: #FFF4CC; --m0b: #F3CB6C; --m0c: #C99230; --m1a: #FFFFFF; --m1b: #DCE8FF; --m2a: #A6F0FF; --m2b: #4FC3F7;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; font-family: var(--body); color: var(--text); line-height: 1.7;
  background: var(--ink-bottom) linear-gradient(var(--ink-top), var(--ink-bottom)) fixed;
  padding-bottom: calc(96px + env(safe-area-inset-bottom));
}
@media (min-width: 900px) { body { padding-bottom: 0; } }
a { color: var(--gold); }
button, input, select { font: inherit; color: inherit; }
.num { font-variant-numeric: tabular-nums; }
.display { font-family: var(--display); font-weight: 400; line-height: 1.15; }
.muted { color: var(--text2); } .faint { color: var(--text3); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- header ---------- */
.top { max-width: 1080px; margin: 0 auto; padding: 14px 16px; display: flex; align-items: center; gap: 12px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); }
.brand svg { width: 34px; height: 34px; }
.brand b { font-family: "Amiri Quran", serif; font-weight: 400; font-size: 1.55rem; line-height: 1; padding-top: 4px; }
:root.en .brand b { font-family: ui-serif, Georgia, serif; font-size: 1.3rem; padding-top: 0; }
.top nav { display: none; gap: 4px; margin-inline-start: 18px; }
.top nav a { text-decoration: none; color: var(--text2); padding: 6px 14px; border-radius: 999px; font-size: .95rem; }
.top nav a[aria-current="page"] { background: var(--gold-grad); color: var(--hl-ink); font-weight: 600; }
.top nav a:hover:not([aria-current]) { background: var(--veil); color: var(--text); }
@media (min-width: 900px) { .top nav { display: flex; } }
.top .tools { margin-inline-start: auto; display: flex; gap: 8px; }
.icon-btn { width: 40px; height: 40px; border-radius: 999px; border: 1px solid var(--hair); background: var(--surface); display: grid; place-items: center; cursor: pointer; padding: 0; }
.icon-btn svg { width: 19px; height: 19px; stroke: var(--gold); fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.lang-btn { width: auto; padding: 0 14px; font-size: .9rem; font-weight: 600; color: var(--gold); }

/* ---------- dock (phones) ---------- */
.dock {
  position: fixed; inset-inline: 0; bottom: calc(12px + env(safe-area-inset-bottom)); margin: 0 auto; width: min(440px, calc(100% - 24px));
  display: flex; justify-content: space-between; padding: 6px; border-radius: 999px; z-index: 20;
  background: color-mix(in srgb, var(--surface) 78%, transparent); border: 1px solid var(--hair);
  -webkit-backdrop-filter: blur(20px) saturate(1.4); backdrop-filter: blur(20px) saturate(1.4); box-shadow: var(--shadow);
}
.dock a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 6px 0 5px; border-radius: 999px; text-decoration: none; color: var(--text2); font-size: .68rem; min-width: 0; }
.dock a svg { width: 21px; height: 21px; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.dock a[aria-current="page"] { background: var(--gold-grad); color: var(--hl-ink); font-weight: 600; }
@media (min-width: 900px) { .dock { display: none; } }

/* ---------- layout ---------- */
main { max-width: 1080px; margin: 0 auto; padding: 4px 16px 40px; }
.col { max-width: 720px; margin: 0 auto; }
.panel { background: var(--surface); border: 1px solid var(--hair); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); }
.panel + .panel, .stack > * + * { margin-top: 14px; }
.section-h { display: flex; align-items: center; gap: 10px; margin: 26px 4px 10px; font-size: 1.05rem; font-weight: 700; }
.section-h::before { content: ""; width: 4px; height: 18px; border-radius: 3px; background: var(--gold-grad); }
h1.page { font-family: var(--display); font-weight: 400; font-size: 2.3rem; margin: 10px 4px 4px; line-height: 1.3; }
:root.en h1.page { font-size: 2rem; }
.lead { margin: 0 4px 14px; color: var(--text2); }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.spacer { flex: 1; }
.grid2 { display: grid; gap: 14px; }
.grid2 > *, .stack > * { min-width: 0; }
@media (min-width: 860px) { .grid2 { grid-template-columns: 1fr 1fr; align-items: start; } }

/* ---------- buttons / chips ---------- */
.btn { display: inline-flex; align-items: center; gap: 8px; border: 0; border-radius: 999px; padding: 10px 20px; cursor: pointer; text-decoration: none; font-weight: 600; background: var(--gold-grad); color: var(--hl-ink); }
.btn.ghost { background: var(--veil); color: var(--text); border: 1px solid var(--hair); font-weight: 500; }
.btn svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.btn.small { padding: 6px 14px; font-size: .9rem; }
.chip { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--hair); border-radius: 999px; padding: 7px 14px; background: var(--surface); cursor: pointer; color: var(--text); font-size: .95rem; max-width: 100%; }
.chip svg { width: 16px; height: 16px; stroke: var(--gold); fill: none; stroke-width: 1.8; flex: none; }
.chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
select, input[type="text"], input[type="search"], input[type="date"], input[type="number"] {
  background: var(--raised); border: 1px solid var(--hair); border-radius: 14px; padding: 9px 12px; min-height: 42px; max-width: 100%;
}
label.field { display: grid; gap: 6px; font-size: .9rem; color: var(--text2); }
.seg { display: inline-flex; max-width: 100%; background: var(--veil); border: 1px solid var(--hair); border-radius: 999px; padding: 3px; }
.seg button { flex: 1 1 auto; min-width: 0; border: 0; background: none; border-radius: 999px; padding: 6px 14px; cursor: pointer; color: var(--text2); }
.seg button[aria-pressed="true"] { background: var(--gold-grad); color: var(--hl-ink); font-weight: 600; }

/* ---------- sky window (home) ---------- */
.sky {
  position: relative; overflow: hidden; color: #F4EFE6; border-radius: 210px 210px 30px 30px / 150px 150px 30px 30px;
  min-height: 350px; padding: 118px 22px 24px; text-align: center; box-shadow: var(--shadow); isolation: isolate;
}
.sky .bg { position: absolute; inset: 0; z-index: -1; width: 100%; height: 100%; }
.sky .hijri { font-family: var(--display); font-size: clamp(2.4rem, 9vw, 3.6rem); line-height: 1.25; margin: 0; text-shadow: 0 2px 18px rgba(0,0,0,.35); }
.sky .greg { opacity: .82; margin: 2px 0 14px; }
.pill { display: inline-flex; flex-wrap: wrap; justify-content: center; align-items: center; column-gap: 10px; row-gap: 2px; max-width: 100%; padding: 9px 18px; border-radius: 999px; background: rgba(10,12,20,.42); border: 1px solid rgba(255,255,255,.16); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); }
.pill b { color: #F0DCAE; font-weight: 600; white-space: nowrap; }
.pill > span { white-space: nowrap; }
.sky .place { margin-top: 14px; background: rgba(10,12,20,.32); border-color: rgba(255,255,255,.16); color: #F4EFE6; }
.sky .place svg { stroke: #F0DCAE; }

/* ---------- today strip ---------- */
.times { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
@media (min-width: 560px) { .times { grid-template-columns: repeat(6, 1fr); } }
.time { background: var(--raised); border: 1px solid var(--hair); border-radius: 18px; padding: 10px 8px; text-align: center; }
.time small { display: block; color: var(--text2); font-size: .82rem; }
.time b { font-size: clamp(1rem, 4.6vw, 1.2rem); font-weight: 600; white-space: nowrap; }
.time.next { background: var(--gold-grad); color: var(--hl-ink); border-color: transparent; }
.time.next small { color: inherit; opacity: .8; }
.time.past b { color: var(--text3); }

/* ---------- tiles ---------- */
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
@media (min-width: 700px) { .tiles { grid-template-columns: repeat(6, 1fr); } }
.tile { text-decoration: none; color: var(--text); display: grid; justify-items: center; gap: 6px; font-size: .9rem; text-align: center; }
.tile i { width: 100%; aspect-ratio: 1; max-width: 104px; border-radius: 24px; display: grid; place-items: center; box-shadow: var(--shadow); transition: transform .2s; }
.tile:hover i { transform: scale(.96); }
.tile i svg { width: 56%; height: 56%; }

/* ---------- ayah ---------- */
.ayah { background: linear-gradient(var(--parch), var(--parch2)); color: var(--parch-ink); border-radius: var(--radius); padding: 20px; text-align: center; }
.ayah p { font-family: "Amiri Quran", serif; font-size: 1.6rem; line-height: 2.1; margin: 0; direction: rtl; }
.ayah small { opacity: .7; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; margin: 0 -6px; }
table.tt { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: .92rem; }
table.tt th { font-weight: 600; color: var(--text2); font-size: .82rem; padding: 8px 6px; border-bottom: 1px solid var(--hair); white-space: nowrap; }
table.tt td { padding: 7px 6px; text-align: center; border-bottom: 1px solid var(--hair); white-space: nowrap; }
table.tt td:first-child, table.tt th:first-child { text-align: start; }
table.tt tr.today td { background: var(--veil2); font-weight: 600; }
table.tt tr.today td:first-child { box-shadow: inset -3px 0 0 var(--gold); }
:root.en table.tt tr.today td:first-child { box-shadow: inset 3px 0 0 var(--gold); }
table.tt tr.fri td:first-child { color: var(--gold); }

/* ---------- calendar ---------- */
.cal-head { display: flex; align-items: center; gap: 8px; }
.cal-head h2 { flex: 1; text-align: center; margin: 0; font-family: var(--display); font-weight: 400; font-size: clamp(1.25rem, 5.6vw, 1.7rem); line-height: 1.4; }
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; margin-top: 12px; }
.cal .wd { text-align: center; font-size: .72rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text3); padding: 4px 0; }
.cal .d { aspect-ratio: 1 / 1.05; border-radius: 14px; background: var(--raised); border: 1px solid transparent; display: grid; align-content: center; justify-items: center; gap: 0; cursor: default; position: relative; padding: 2px; }
.cal .d b { font-size: 1.15rem; font-weight: 600; line-height: 1.2; }
.cal .d small { font-size: .62rem; white-space: nowrap; overflow: hidden; max-width: 100%; color: var(--text3); line-height: 1.2; }
.cal .d.today { background: var(--gold-grad); color: var(--hl-ink); }
.cal .d.today small { color: inherit; opacity: .75; }
.cal .d.ev::after { content: ""; position: absolute; bottom: 5px; width: 5px; height: 5px; border-radius: 50%; background: var(--mint); }
.cal .d.white { border-color: var(--hair); }
.events { list-style: none; padding: 0; margin: 12px 0 0; display: grid; gap: 6px; }
.events li { display: flex; gap: 10px; align-items: baseline; }
.events li::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--mint); flex: none; transform: translateY(-2px); }

/* ---------- qibla ---------- */
.compass { width: min(340px, 82vw); aspect-ratio: 1; margin: 6px auto 0; position: relative; }
.compass svg { width: 100%; height: 100%; display: block; }
.dial { transition: transform .25s ease-out; transform-origin: 50% 50%; }
.big-num { font-family: var(--display); font-size: 3rem; line-height: 1.2; }

/* ---------- map ---------- */
.map { width: 100%; height: min(62vh, 560px); min-height: 360px; border: 0; border-radius: var(--radius); display: block; background: var(--raised); }

/* ---------- moon ---------- */
.moon-figure { width: min(240px, 60vw); margin: 4px auto 8px; display: block; }
.stat { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; text-align: center; }
.stat div { background: var(--raised); border-radius: 18px; padding: 10px 6px; }
.stat b { display: block; font-size: 1.2rem; }
.stat small { color: var(--text2); font-size: .8rem; }
.list { list-style: none; padding: 0; margin: 0; }
.list li { display: flex; justify-content: space-between; gap: 10px; padding: 10px 2px; border-bottom: 1px solid var(--hair); }
.list li:last-child { border-bottom: 0; }

/* ---------- dialog ---------- */
dialog { border: 1px solid var(--hair); border-radius: 26px; background: var(--surface); color: var(--text); padding: 0; width: min(520px, calc(100% - 24px)); max-height: min(80vh, 640px); box-shadow: 0 30px 80px rgba(0,0,0,.4); }
dialog::backdrop { background: rgba(5,6,10,.55); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
dialog .dh { display: flex; align-items: center; gap: 10px; padding: 16px 18px 8px; }
dialog .dh h3 { margin: 0; flex: 1; font-size: 1.1rem; }
dialog .db { padding: 6px 18px 18px; display: grid; gap: 12px; }
dialog .results { list-style: none; margin: 0; padding: 0; max-height: 46vh; overflow: auto; }
dialog .results button { width: 100%; text-align: start; background: none; border: 0; border-bottom: 1px solid var(--hair); padding: 10px 4px; cursor: pointer; display: flex; justify-content: space-between; gap: 10px; }
dialog .results button:hover { background: var(--veil); }
dialog .results small { color: var(--text3); }

/* ---------- footer ---------- */
footer { max-width: 1080px; margin: 30px auto 0; padding: 20px 16px 30px; color: var(--text3); font-size: .85rem; border-top: 1px solid var(--hair); }
footer .row a { color: var(--text2); text-decoration: none; }
footer .row a:hover { color: var(--gold); }
footer p { margin: 8px 0 0; }
.store { display: inline-flex; align-items: center; gap: 10px; }
.store svg { width: 20px; height: 20px; fill: currentColor; }
.note { font-size: .86rem; color: var(--text2); margin: 10px 4px 0; }
.err { color: var(--pink); }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
@media print {
  .top, .dock, footer, .noprint { display: none !important; }
  body { background: #fff; color: #000; padding: 0; }
  .panel { box-shadow: none; border: 0; }
}

/* ---------- mosques ---------- */
.mosque-row { width: 100%; display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 4px; background: none; border: 0; color: inherit; font: inherit; text-align: start; cursor: pointer; border-radius: 12px; }
.mosque-row > span { display: flex; align-items: center; gap: 10px; min-width: 0; }
.mosque-row svg { width: 20px; height: 20px; flex: none; color: var(--gold); }
.mosque-row .mname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mosque-row small { color: var(--text3); flex: none; }
.mosque-row:hover, .mosque-row[aria-current="true"] { background: var(--veil); }
