@font-face { font-family: Plex; font-weight: 400; font-display: swap; src: url(fonts/ibm-plex-sans-arabic-arabic-400-normal.woff2) format("woff2"); unicode-range: U+0600-06FF, U+0750-077F, U+0870-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FEFC; }
@font-face { font-family: Plex; font-weight: 600; font-display: swap; src: url(fonts/ibm-plex-sans-arabic-arabic-600-normal.woff2) format("woff2"); unicode-range: U+0600-06FF, U+0750-077F, U+0870-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FEFC; }
@font-face { font-family: Plex; font-weight: 700; font-display: swap; src: url(fonts/ibm-plex-sans-arabic-arabic-700-normal.woff2) format("woff2"); unicode-range: U+0600-06FF, U+0750-077F, U+0870-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FEFC; }
@font-face { font-family: Plex; font-weight: 400; font-display: swap; src: url(fonts/ibm-plex-sans-arabic-latin-400-normal.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+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: Plex; font-weight: 600; font-display: swap; src: url(fonts/ibm-plex-sans-arabic-latin-600-normal.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+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: Plex; font-weight: 700; font-display: swap; src: url(fonts/ibm-plex-sans-arabic-latin-700-normal.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+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

@font-face { font-family: Amiri; font-weight: 400; font-display: swap; src: url(fonts/amiri-arabic-400-normal.woff2) format("woff2"); }
@font-face { font-family: Amiri; font-weight: 700; font-display: swap; src: url(fonts/amiri-arabic-700-normal.woff2) format("woff2"); }
/* two themes, chosen once on first open (html[data-theme]); every colour below is a variable */
:root, html[data-theme="dark"] {
  --bg: #000; --bg-top: #15110a; --card: #171717; --card2: #111; --edge: #2c2c2c; --line: #262626;
  --ink: #f2eee6; --ink-strong: #fff; --dim: #bdbdbd; --mute: #7c7c7c; --mute2: #555;
  --gold: #e8b04b; --gold-t: #e8b04b; --on-gold: #1a1206; --red: #c8231e; --ok: #5fd07a;
  --head1: #1c1810; --head2: #111; --track: #262626; --barbg: rgba(20, 18, 15, .94); --tab: #8a8a8a;
  --btn: #222; --dial: #101010; --sw-off: #333; --knob: #ddd; --needle2: #8b6a2a; --hub-edge: #4a3510;
  --gold-soft: rgba(232, 176, 75, .14); --gold-line: rgba(232, 176, 75, .35); --red-soft: rgba(200, 35, 30, .07);
  --page: #131210; --page-ink: #ebe5d8; --page-edge: #3a3123; --page-rule: rgba(232, 176, 75, .28);
  color-scheme: dark;
}
html[data-theme="light"] {
  --bg: #f6f1e7; --bg-top: #efe3cb; --card: #fff; --card2: #fbf8f2; --edge: #e3d8c5; --line: #e6dccb;
  --ink: #1f1b16; --ink-strong: #111; --dim: #6a6257; --mute: #8f877b; --mute2: #c3baab;
  --gold: #e0a63a; --gold-t: #8a5d0c; --on-gold: #1a1206; --red: #b3201b; --ok: #1f8a3c;
  --head1: #fbf1dc; --head2: #fff; --track: #ebe3d5; --barbg: rgba(255, 252, 246, .95); --tab: #8d857a;
  --btn: #f1ebe0; --dial: #fffaf0; --sw-off: #d6cdbf; --knob: #fff; --needle2: #c9a361; --hub-edge: #8a5d0c;
  --gold-soft: rgba(224, 166, 58, .18); --gold-line: rgba(160, 112, 20, .35); --red-soft: rgba(179, 32, 27, .06);
  --page: #fffaf0; --page-ink: #1c1712; --page-edge: #e2cfa6; --page-rule: rgba(160, 112, 20, .35);
  color-scheme: light;
}
:root { --bar-h: 76px; --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px); }
*, *::before, *::after { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; background: var(--bg); }
body {
  margin: 0; min-height: 100vh; min-height: 100dvh; color: var(--ink); overflow-x: hidden;
  font: 400 16px/1.6 Plex, system-ui, -apple-system, "Segoe UI", Tahoma, sans-serif;
  background: linear-gradient(var(--bg-top), var(--bg) 340px) no-repeat, var(--bg);
  -webkit-font-smoothing: antialiased; user-select: none; -webkit-user-select: none;
}
button { font: inherit; color: inherit; }
a { color: var(--gold-t); }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
[hidden] { display: none !important; }
.ltr { direction: ltr; unicode-bidi: isolate; }

main { max-width: 560px; margin: 0 auto; padding: calc(12px + var(--safe-t)) 16px calc(var(--bar-h) + 28px + var(--safe-b)); }
.page { animation: in .22s ease-out; }
@keyframes in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .page { animation: none; } }

.card { background: var(--card); border: 1px solid var(--edge); border-radius: 18px; padding: 14px 16px; }
.card + .card, .card + .sec, .sec + .card { margin-top: 12px; }
.head { text-align: center; background: linear-gradient(var(--head1), var(--head2)); }
.head .d1 { font-weight: 700; font-size: 17px; }
.head .d2 { color: var(--gold-t); font-weight: 700; font-size: 16px; }
.head .d3 { color: var(--dim); font-size: 13px; }
.head .ev { color: var(--gold-t); font-size: 14px; font-weight: 600; margin-top: 6px; border-top: 1px solid var(--edge); padding-top: 6px; white-space: pre-line; }

/* the dial */
.dial { display: block; width: min(300px, 78vw); height: auto; margin: 14px auto 6px; overflow: visible; }
.dial .track { fill: none; stroke: var(--track); stroke-width: 10; }
.dial .day { fill: none; stroke: var(--gold-line); stroke-width: 10; stroke-linecap: round; }
.dial .gone { fill: none; stroke: var(--red); stroke-width: 10; stroke-linecap: round; opacity: .85; }
.dial .mk { fill: var(--ink-strong); }
.dial .mk.dim { fill: var(--mute2); }
.dial .mk.next { fill: var(--gold); }
.dial .sun { fill: #ffd27a; filter: drop-shadow(0 0 8px #ffb52e); }
.dial .lab { fill: var(--dim); font-size: 11px; font-weight: 600; }
.dial .nm { fill: var(--ink); font-size: 18px; font-weight: 700; }
.dial .tm { fill: var(--ink-strong); font-size: 38px; font-weight: 700; }
.dial .cd { fill: var(--gold-t); font-size: 16px; font-weight: 600; }

.rows { list-style: none; margin: 8px 0 0; padding: 0; }
.rows li { display: flex; align-items: center; gap: 12px; padding: 9px 14px; border: 1px solid transparent; border-radius: 14px; position: relative; }
.rows li::before { content: ""; position: absolute; inset-inline-start: 4px; top: 0; bottom: 0; width: 2px; background: var(--line); }
.rows li:first-child::before { top: 50%; }
.rows li:last-child::before { bottom: 50%; }
.rows .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--mute2); flex: none; margin-inline-start: -14px; z-index: 1; }
.rows .ring .dot { width: 12px; height: 12px; background: var(--card); border: 2px solid var(--dim); }
.rows .nm { flex: 1 1 auto; min-width: 0; font-size: 17px; font-weight: 600; }
.rows .ring .nm::after { content: " 🔔"; font-size: 13px; }
.rows .t { flex: none; font-size: 22px; font-weight: 700; color: var(--ink-strong); }
.rows .past { opacity: .42; }
.rows .now { border-color: var(--red); background: var(--red-soft); }
.rows .now .dot { border-color: var(--gold); background: var(--gold); }
.ap { font-size: .62em; color: var(--dim); font-weight: 600; margin-inline-start: 3px; }

/* bottom bar */
.bar {
  position: fixed; z-index: 20; left: 50%; transform: translateX(-50%); bottom: calc(10px + var(--safe-b));
  width: min(528px, calc(100% - 24px)); height: var(--bar-h); display: grid; grid-template-columns: repeat(5, minmax(0, 1fr));
  background: var(--barbg); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--gold-line); border-radius: 24px; padding: 6px;
}
.bar a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; text-decoration: none; color: var(--tab); border-radius: 18px; min-width: 0; }
.bar a.on { color: var(--gold-t); background: var(--gold-soft); }
.bar svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.bar span { font-size: 12px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }

/* calendar */
.today { text-align: center; border-color: var(--gold); background: linear-gradient(var(--head1), var(--head2)); cursor: pointer; }
.today.chosen { border-color: var(--mute); }
.today .h { color: var(--gold-t); font-weight: 700; font-size: 20px; }
.today .g { color: var(--dim); font-size: 14px; }
.today .back { color: var(--mute); font-size: 13px; }
.today .evs { margin-top: 6px; }
.today .evs div { font-weight: 600; font-size: 15px; }
.mnav { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 14px 0 8px; }
.mnav .center { flex: 1 1 auto; min-width: 0; }
.mnav h2 { margin: 0; font-size: 19px; color: var(--gold-t); }
.circle { width: 44px; height: 44px; flex: none; border-radius: 50%; border: 1px solid var(--edge); background: var(--card); cursor: pointer; font-size: 20px; line-height: 1; }
.grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; background: var(--card2); border: 1px solid var(--edge); border-radius: 16px; padding: 8px; }
.grid .wd { text-align: center; color: var(--dim); font-size: 11px; padding-bottom: 4px; }
.cell { position: relative; min-height: 60px; border-radius: 12px; display: flex; flex-direction: column; align-items: center; justify-content: center; cursor: pointer; border: 1px solid transparent; background: none; padding: 2px 0; }
.cell .hd { font-size: 18px; font-weight: 700; line-height: 1.2; }
.cell .gd { font-size: 11px; color: var(--dim); line-height: 1.2; }
.cell .gm { font-size: 9px; color: var(--gold-t); line-height: 1.1; white-space: nowrap; }
.cell .ed { position: absolute; bottom: 4px; width: 5px; height: 5px; border-radius: 50%; }
.cell.is-today { background: var(--gold); color: var(--on-gold); }
.cell.is-today .gd, .cell.is-today .gm { color: #3a2a08; }
.cell.sel { border-color: var(--ink-strong); }
.ed.day { background: var(--ink-strong); } .ed.joy { background: var(--gold); } .ed.sad { background: var(--red); }
.cell.is-today .ed.joy, .cell.is-today .ed.day { background: var(--on-gold); }
.sec { margin: 18px 4px 8px; color: var(--gold-t); font-size: 15px; font-weight: 700; }
.evlist { list-style: none; padding: 0; margin: 0; }
.evlist li { display: flex; gap: 12px; align-items: center; padding: 10px 14px; background: var(--card); border: 1px solid var(--edge); border-radius: 14px; margin-bottom: 8px; font-weight: 600; font-size: 15px; }
.evlist .n { color: var(--gold-t); font-size: 18px; font-weight: 700; min-width: 26px; text-align: center; }

/* compass */
.compass { display: block; width: min(320px, 82vw); height: auto; margin: 6px auto 0; touch-action: manipulation; }
.compass.small { width: min(260px, 70vw); }
.compass .ring1 { fill: var(--dial); stroke: var(--gold-line); stroke-width: 1.2; }
.compass .ring2 { fill: none; stroke: var(--gold); stroke-width: 3; }
.compass .tick { stroke: var(--ink-strong); stroke-width: 2; }
.compass .tick.minor { stroke: var(--gold-line); stroke-width: 1; }
.compass .deg { fill: var(--dim); font-size: 11px; font-weight: 700; }
.compass .word { fill: var(--ink-strong); font-size: 15px; font-weight: 700; }
.compass .north { fill: var(--red); }
.compass .needle { fill: var(--gold); }
.compass .needle2 { fill: var(--needle2); }
.compass .hub { fill: var(--gold); stroke: var(--hub-edge); stroke-width: 2; }
.compass .badge { fill: var(--dial); stroke: var(--gold); stroke-width: 2.5; }
.compass .top { fill: var(--ink-strong); }
.compass.aligned .ring2 { stroke: var(--ok); }
.status { text-align: center; font-size: 19px; font-weight: 700; margin-top: 6px; }
.status.ok { color: var(--ok); }
.hint { text-align: center; color: var(--dim); font-size: 13px; }
.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 48px; padding: 0 20px; border-radius: 24px; border: 1px solid var(--edge); background: var(--btn); color: var(--ink); font-weight: 700; font-size: 16px; cursor: pointer; text-decoration: none; }
.btn.gold { background: var(--gold); color: var(--on-gold); border-color: var(--gold); }
.btn.wide { width: 100%; }
.center { text-align: center; }
.picker { display: flex; align-items: center; gap: 12px; cursor: pointer; text-align: start; width: 100%; }
.picker .pn { flex: 1 1 auto; min-width: 0; }
.picker .pn b { display: block; font-size: 17px; }
.picker .pn small { color: var(--dim); }
.picker .chg { color: var(--gold-t); font-weight: 700; flex: none; }
.map { height: 300px; border-radius: 16px; overflow: hidden; margin-top: 12px; border: 1px solid var(--edge); background: var(--card2); }
.mapbar { display: flex; gap: 8px; justify-content: center; margin-top: 8px; }
.leaflet-container { font-family: Plex, system-ui, sans-serif; background: var(--card2); }
.leaflet-control-attribution { font-size: 9px; background: rgba(0, 0, 0, .5) !important; color: #ccc; }
.leaflet-control-attribution a { color: #eee; }

/* sheet (place list) */
.sheet { position: fixed; inset: 0; z-index: 40; background: var(--bg); overflow-y: auto; padding: calc(12px + var(--safe-t)) 16px calc(24px + var(--safe-b)); }
.sheet .in { max-width: 560px; margin: 0 auto; }
.sheet h3 { color: var(--gold-t); margin: 18px 4px 8px; font-size: 15px; }
.sheet .row { display: flex; align-items: center; gap: 10px; width: 100%; text-align: start; padding: 12px 14px; background: var(--card); border: 1px solid var(--edge); border-radius: 14px; margin-bottom: 8px; cursor: pointer; }
.sheet .row.on { border-color: var(--gold); }
.sheet .row b { flex: 1 1 auto; min-width: 0; font-size: 16px; }
.sheet .row small { color: var(--dim); flex: none; }
.topline { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.topline h1 { margin: 0; font-size: 22px; color: var(--gold-t); flex: 1 1 auto; min-width: 0; text-align: center; }

/* duas */
.dl { display: block; width: 100%; text-align: start; padding: 14px 16px; background: var(--card); border: 1px solid var(--edge); border-radius: 16px; margin-bottom: 10px; cursor: pointer; color: inherit; text-decoration: none; }
.dl b { display: block; font-size: 18px; }
.dl small { color: var(--dim); font-size: 13px; }
.dl.hot { border-color: var(--gold-line); }
.dir { cursor: pointer; text-align: center; }
.dir .dt { font-weight: 700; font-size: 16px; }
.dir.ok .dt { color: var(--ok); }
.chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 12px; }
.chip { min-height: 44px; padding: 0 18px; border-radius: 22px; border: 1px solid var(--edge); background: var(--btn); color: var(--ink); font-weight: 700; font-size: 15px; cursor: pointer; }
.chip.on { background: var(--gold); color: var(--on-gold); border-color: var(--gold); }
.player { display: flex; align-items: center; gap: 12px; margin-top: 12px; }
.play { width: 56px; height: 56px; border-radius: 50%; border: 1px solid var(--edge); background: var(--btn); flex: none; cursor: pointer; display: grid; place-items: center; }
.play svg { width: 22px; height: 22px; fill: var(--ink-strong); }
.seek { flex: 1 1 auto; min-width: 0; accent-color: var(--gold); direction: ltr; height: 32px; }
.ptime { flex: none; color: var(--dim); font-size: 14px; min-width: 92px; text-align: center; }
.fontrow { display: flex; justify-content: center; gap: 10px; margin: 14px 0 4px; }
/* the reading page, like Khatma's: a book page in a naskh face, its own paper per theme */
.text {
  font-family: Amiri, "Traditional Arabic", "Noto Naskh Arabic", serif; font-size: var(--fs, 24px); line-height: 2.15;
  color: var(--page-ink); background: var(--page); border: 1px solid var(--page-edge); border-radius: 18px;
  box-shadow: inset 0 0 0 5px var(--page), inset 0 0 0 6px var(--page-rule); padding: 26px 22px 18px; margin-top: 8px;
  text-align: justify; text-align-last: center; word-spacing: .04em; user-select: text; -webkit-user-select: text;
  -webkit-font-smoothing: auto;
}
.text p { margin: 0 0 1em; }
.text p + p { border-top: 1px dashed var(--page-rule); padding-top: 1em; }
.text .note { font-family: Plex, system-ui, sans-serif; color: var(--gold-t); font-size: 15px; line-height: 1.8; text-align: center; text-align-last: center; }
.text .end { display: block; text-align: center; color: var(--gold); font-size: 22px; line-height: 1; margin-top: 4px; }

/* settings */
.set h2 { color: var(--gold-t); font-size: 15px; margin: 22px 4px 8px; }
.line { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.line:last-child { border-bottom: 0; }
.line .l { flex: 1 1 auto; min-width: 0; font-weight: 600; }
.line .l small { display: block; color: var(--dim); font-weight: 400; font-size: 13px; }
.line a { display: inline-flex; align-items: center; min-height: 40px; }
.step { display: flex; align-items: center; gap: 6px; flex: none; }
.step b { min-width: 64px; text-align: center; color: var(--gold-t); }
.step button { width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--edge); background: var(--btn); cursor: pointer; font-size: 18px; }
.step button:disabled { opacity: .35; cursor: default; }
.seg { display: flex; gap: 6px; flex: none; }
.sw { position: relative; width: 52px; height: 32px; flex: none; }
.sw input { opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; position: absolute; z-index: 1; }
.sw i { position: absolute; inset: 0; border-radius: 16px; background: var(--sw-off); transition: background .2s; }
.sw i::after { content: ""; position: absolute; top: 4px; inset-inline-start: 4px; width: 24px; height: 24px; border-radius: 50%; background: var(--knob); box-shadow: 0 1px 3px rgba(0, 0, 0, .3); transition: transform .2s; }
.sw input:checked + i { background: var(--gold); }
.sw input:checked + i::after { transform: translateX(-20px); background: #fff; }
.toast { position: fixed; z-index: 60; left: 50%; transform: translateX(-50%); bottom: calc(var(--bar-h) + 24px + var(--safe-b)); background: var(--card); color: var(--ink); border: 1px solid var(--edge); border-radius: 14px; padding: 10px 16px; font-weight: 600; max-width: calc(100% - 32px); text-align: center; box-shadow: 0 6px 24px rgba(0, 0, 0, .25); }
.loadline { text-align: center; color: var(--dim); padding: 40px 0; }

/* the one-time theme choice */
.pick-theme { position: fixed; inset: 0; z-index: 90; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px; padding: 24px 16px calc(24px + var(--safe-b)); background: #1b1813; color: #f2eee6; }
.pick-theme img { width: 96px; height: 96px; border-radius: 22px; }
.pick-theme h1 { margin: 0; font-size: 24px; }
.pick-theme .opts { display: flex; gap: 14px; width: min(420px, 100%); }
.pick-theme button { flex: 1 1 0; min-width: 0; border-radius: 20px; padding: 14px 12px 16px; cursor: pointer; border: 2px solid transparent; font: 700 18px/1.3 Plex, system-ui, sans-serif; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.pick-theme button:focus-visible, .pick-theme button:hover { border-color: #e8b04b; }
.pick-theme .dark { background: #000; color: #fff; }
.pick-theme .light { background: #f6f1e7; color: #1f1b16; }
.pick-theme .mini { width: 100%; aspect-ratio: 9 / 13; border-radius: 12px; padding: 10px 8px; display: flex; flex-direction: column; gap: 6px; }
.pick-theme .dark .mini { background: #111; border: 1px solid #2c2c2c; }
.pick-theme .light .mini { background: #fff; border: 1px solid #e3d8c5; }
.pick-theme .mini i { display: block; height: 10px; border-radius: 5px; }
.pick-theme .mini i.g { background: #e8b04b; width: 60%; margin: 0 auto 6px; }
.pick-theme .dark .mini i.r { background: #2a2a2a; }
.pick-theme .light .mini i.r { background: #ece4d6; }
.pick-theme .mini i.c { height: 54px; width: 54px; border-radius: 50%; margin: 2px auto 8px; border: 5px solid #c8231e; background: transparent; }
