:root {
  --ink: #f4efe6;
  --ink-2: rgba(244, 239, 230, .62);
  --ink-3: rgba(244, 239, 230, .34);
  --line: rgba(244, 239, 230, .12);
  --top: #070a14; --bottom: #18203a; --accent: #a9c1ff;
  --serif: "Instrument Serif", "Iowan Old Style", Georgia, serif;
  --sans: "Geist", -apple-system, "SF Pro Text", system-ui, sans-serif;
  --arabic: "Amiri", "Geeza Pro", serif;
  --tabh: 64px;
  color-scheme: dark;
}
/* The sky follows the current prayer. */
body[data-phase="fajr"]    { --top: #10142b; --bottom: #4a3f6e; --accent: #cdbdff; }
body[data-phase="morning"] { --top: #0d2336; --bottom: #3f7896; --accent: #ffd98a; }
body[data-phase="dhuhr"]   { --top: #0f2a40; --bottom: #4d86a2; --accent: #fff0b8; }
body[data-phase="asr"]     { --top: #221b2b; --bottom: #9d633e; --accent: #ffc27a; }
body[data-phase="maghrib"] { --top: #1d1226; --bottom: #a54d57; --accent: #ffb5a3; }
body[data-phase="isha"]    { --top: #060912; --bottom: #18203a; --accent: #a9c1ff; }

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  min-height: 100dvh;
  background: var(--top);
  color: var(--ink);
  font: 400 16px/1.4 var(--sans);
  font-feature-settings: "tnum" 1;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}
.sky {
  position: fixed; inset: 0; z-index: -1;
  background:
    radial-gradient(120% 60% at 50% 112%, color-mix(in srgb, var(--accent) 22%, transparent), transparent 70%),
    linear-gradient(180deg, var(--top) 0%, var(--top) 30%, var(--bottom) 100%);
  transition: background 1.2s ease;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
svg { fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

main {
  max-width: 460px; margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 18px) 22px calc(var(--tabh) + env(safe-area-inset-bottom) + 24px);
}

/* Header */
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 36px; }
.place { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 500; color: var(--ink); padding: 6px 0; }
.place svg { width: 16px; height: 16px; color: var(--accent); }
.place.busy span { opacity: .5; }
.hijri { font-size: 13px; color: var(--ink-2); text-align: right; }

/* Hero */
.hero { padding: 4vh 0 4.5vh; }
@media (min-height: 900px) { .hero { padding: 9vh 0 6vh; } }
.eyebrow { font-size: 12px; letter-spacing: .14em; text-transform: uppercase; color: var(--accent); font-weight: 500; }
.next-name {
  font: 400 clamp(76px, 24vw, 104px)/.9 var(--serif);
  letter-spacing: -.02em; margin: 14px 0 16px;
  display: flex; align-items: baseline; gap: 16px; flex-wrap: wrap;
}
.next-name .ar { font: 400 30px/1 var(--arabic); color: var(--ink-2); letter-spacing: 0; }
.countdown { font-size: 17px; color: var(--ink-2); display: flex; gap: 8px; }
.countdown #countdown { color: var(--ink); font-weight: 500; }
.countdown .dot { color: var(--ink-3); }

/* List */
.list { list-style: none; border-top: 1px solid var(--line); }
.row {
  position: relative;
  display: grid; grid-template-columns: 1fr auto; align-items: baseline;
  padding: 15px 0; border-bottom: 1px solid var(--line);
  transition: opacity .4s;
}
.row .nm { font-size: 19px; font-weight: 500; display: flex; align-items: baseline; gap: 10px; }
.row .nm .ar { font: 400 17px/1 var(--arabic); color: var(--ink-3); font-weight: 400; }
.row .tm { font-size: 19px; font-weight: 500; }
.row .tm small { font-size: 12px; font-weight: 500; color: var(--ink-2); margin-left: 3px; letter-spacing: .04em; }
.row.minor .nm, .row.minor .tm { font-size: 15px; font-weight: 400; color: var(--ink-2); }
.row.past { opacity: .42; }
.row.now::before {
  content: ""; position: absolute; left: -22px; top: 50%; translate: 0 -50%;
  width: 3px; height: 26px; border-radius: 0 3px 3px 0; background: var(--accent);
}
.row.now .nm, .row.now .tm { color: var(--accent); }
.row .tag { font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--accent); font-weight: 500; }

.daynav { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; }
.daynav button { padding: 10px; color: var(--ink-2); }
.daynav button svg { width: 20px; height: 20px; display: block; }
.daynav .daylabel { font-size: 14px; color: var(--ink); font-weight: 500; }
.method { display: block; margin: 14px auto 0; font-size: 12px; color: var(--ink-3); letter-spacing: .04em; padding: 8px; }

/* Qibla */
#view-qibla { padding-top: 7vh; }
.compass { position: relative; width: min(84vw, 340px); aspect-ratio: 1; margin: 0 auto; }
.dial { position: absolute; inset: 0; will-change: transform; transition: transform .18s linear; }
.dial svg { width: 100%; height: 100%; stroke: none; overflow: visible; }
.pointer {
  position: absolute; left: 50%; top: -18px; translate: -50% 0; z-index: 2;
  width: 0; height: 0; border-left: 8px solid transparent; border-right: 8px solid transparent;
  border-top: 12px solid var(--ink);
}
.center { position: absolute; left: 50%; top: 50%; width: 10px; height: 10px; translate: -50% -50%; border-radius: 50%; background: var(--ink); }
.compass.aligned .pointer { border-top-color: var(--accent); }
.compass.aligned .ring-glow { opacity: 1; }
.ring-glow { opacity: 0; transition: opacity .3s; }
.qread { text-align: center; margin-top: 38px; }
.qbig { font: 400 64px/1 var(--serif); }
.qsub { color: var(--ink-2); margin-top: 8px; font-size: 15px; }
.compass.aligned + .qread .qbig { color: var(--accent); }
.cta {
  margin-top: 26px; padding: 13px 26px; border-radius: 999px;
  background: var(--ink); color: var(--top); font-weight: 600; font-size: 15px;
}
.cta[hidden] { display: none; }
.qnote { margin-top: 18px; font-size: 12.5px; color: var(--ink-3); max-width: 300px; margin-inline: auto; }

/* Tabs */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  display: flex; justify-content: center; gap: 8px;
  padding: 8px 0 calc(env(safe-area-inset-bottom) + 8px);
  background: color-mix(in srgb, var(--top) 55%, transparent);
  backdrop-filter: blur(18px) saturate(1.3); -webkit-backdrop-filter: blur(18px) saturate(1.3);
  border-top: 1px solid var(--line);
}
.tab { display: flex; flex-direction: column; align-items: center; gap: 3px; width: 96px; padding: 6px 0; color: var(--ink-3); font-size: 11.5px; font-weight: 500; letter-spacing: .03em; }
.tab svg { width: 24px; height: 24px; }
.tab.on { color: var(--ink); }

/* Settings sheet */
.sheet {
  margin: auto auto 0; width: 100%; max-width: 460px; border: 0;
  border-radius: 22px 22px 0 0; background: #12151f; color: var(--ink);
  padding: 26px 22px calc(env(safe-area-inset-bottom) + 20px);
}
.sheet::backdrop { background: rgba(0,0,0,.5); }
.sheet h2 { font: 400 30px/1 var(--serif); margin-bottom: 18px; }
.sheet fieldset { border: 0; margin-bottom: 20px; }
.sheet legend { font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-2); margin-bottom: 6px; }
.sheet label { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line); font-size: 16px; }
.sheet label small { margin-left: auto; color: var(--ink-3); font-size: 13px; }
.sheet input { accent-color: var(--accent); width: 18px; height: 18px; }
.sheet .done { width: 100%; padding: 14px; border-radius: 14px; background: var(--ink); color: #12151f; font-weight: 600; }


/* Tappable rows */
.row.tap { cursor: pointer; }
.row.tap:active { background: rgba(255,255,255,.04); }
.row.tap:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.hint { text-align: center; font-size: 12px; color: var(--ink-3); margin-top: 10px; }

/* Prayer detail sheet */
.detail { max-height: 90dvh; overflow-y: auto; overscroll-behavior: contain; padding-top: 0; }
.d-head { position: sticky; top: 0; z-index: 1; background: #12151f; display: flex; align-items: flex-start; justify-content: space-between; padding: 22px 0 14px; }
.d-head h2 { margin: 6px 0 0; display: flex; align-items: baseline; gap: 12px; font: 400 44px/1 var(--serif); }
.d-head h2 .ar { font: 400 22px/1 var(--arabic); color: var(--ink-2); }
.x { width: 36px; height: 36px; border-radius: 50%; background: rgba(255,255,255,.08); display: grid; place-items: center; flex: none; }
.x svg { width: 16px; height: 16px; }
.d-total { font-size: 15px; color: var(--ink-2); }
.d-total b { color: var(--ink); font-weight: 600; }
.bar { display: flex; gap: 3px; height: 8px; margin: 14px 0 6px; }
.bar span { border-radius: 2px; }
.t-fard  { --tc: var(--accent); }
.t-wajib { --tc: var(--accent); }
.t-sm    { --tc: rgba(244,239,230,.62); }
.t-sg    { --tc: rgba(244,239,230,.36); }
.t-nafl  { --tc: rgba(244,239,230,.18); }
.bar span { background: var(--tc); }
.bar .t-wajib { background: repeating-linear-gradient(135deg, var(--accent) 0 3px, transparent 3px 5px); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; color: var(--ink-2); margin: 14px 0 6px; }
.legend i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; background: var(--tc); margin-right: 6px; vertical-align: 0; }

.key { display: flex; flex-wrap: wrap; gap: 8px; margin: 18px 0 4px; font-size: 12.5px; color: var(--ink-2); align-items: center; }
.plus, .only { font-style: normal; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.plus { background: var(--accent); color: #12151f; }
.only { border: 1px solid var(--ink-3); color: var(--ink-2); }

.units { list-style: none; margin-top: 10px; }
.unit { border-top: 1px solid var(--line); }
.unit summary { list-style: none; display: grid; grid-template-columns: 44px 1fr auto; gap: 12px; align-items: center; padding: 14px 0; cursor: pointer; }
.unit summary::-webkit-details-marker { display: none; }
.u-n { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; font: 400 26px/1 var(--serif); border: 1.5px solid var(--tc); color: var(--ink); }
.t-fard .u-n { background: var(--accent); color: #12151f; border-color: transparent; }
.u-t b { display: block; font-size: 16px; font-weight: 600; }
.u-t small { display: block; font-size: 12.5px; color: var(--ink-2); margin-top: 1px; }
.u-t .u-s { color: var(--accent); }
.chev { width: 18px; height: 18px; color: var(--ink-3); transition: rotate .2s; }
details[open] .chev { rotate: 180deg; }
.u-note { font-size: 13px; color: var(--ink-2); margin: -4px 0 10px 56px; }
.rk { list-style: none; margin: 0 0 16px 56px; border-left: 1px solid var(--line); }
.rk li { position: relative; padding: 7px 0 7px 18px; font-size: 14.5px; }
.rk li::before { content: attr(data-n); position: absolute; left: -11px; top: 7px; width: 21px; height: 21px; border-radius: 50%; background: #12151f; border: 1px solid var(--ink-3); font-size: 11px; font-weight: 600; display: grid; place-items: center; color: var(--ink-2); }
.rk .say { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.rk .sit { display: block; font-size: 13px; color: var(--accent); margin-top: 5px; }
.rk .sit::before { content: "\21B3  "; }
.rk .q { display: block; font-size: 13px; color: var(--ink); margin-top: 5px; }
.d-note { font-size: 13.5px; color: var(--ink-2); padding: 16px 0 6px; border-top: 1px solid var(--line); }
.d-actions { display: flex; gap: 10px; margin-top: 16px; }
.d-actions button { flex: 1; padding: 13px; border-radius: 14px; font-weight: 600; font-size: 15px; }
.d-actions .pri { background: var(--ink); color: #12151f; }
.d-actions .sec { background: rgba(255,255,255,.08); }

/* Guide */
.guide { padding-top: 4vh; }
.g-title { font: 400 56px/1 var(--serif); letter-spacing: -.01em; }
.g-lead { color: var(--ink-2); margin: 10px 0 22px; font-size: 15px; }
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; margin: 0 -22px; padding: 0 22px 4px; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; padding: 9px 15px; border-radius: 999px; font-size: 14px; font-weight: 500; background: rgba(255,255,255,.07); color: var(--ink-2); }
.chip.on { background: var(--ink); color: #12151f; }
.g-plan { margin-top: 18px; padding: 18px; border-radius: 18px; background: rgba(255,255,255,.05); border: 1px solid var(--line); }
.g-plan h3 { font: 400 30px/1 var(--serif); display: flex; justify-content: space-between; align-items: baseline; }
.g-plan h3 small { font: 500 13px/1 var(--sans); color: var(--ink-2); }
.g-plan ol { list-style: none; margin-top: 14px; counter-reset: s; }
.g-plan li { counter-increment: s; display: grid; grid-template-columns: 22px 1fr; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); font-size: 14.5px; }
.g-plan li::before { content: counter(s); color: var(--ink-3); font-size: 13px; padding-top: 1px; }
.g-plan li small { display: block; color: var(--ink-2); font-size: 12.5px; margin-top: 2px; }
.g-plan .note { font-size: 13px; color: var(--ink-2); margin-top: 10px; }
.g-plan .d-actions { margin-top: 14px; }
.g-sec { margin-top: 40px; }
.g-sec h2 { font: 400 32px/1.05 var(--serif); margin-bottom: 12px; }
.g-sec > p, .g-sec li { font-size: 15px; color: var(--ink); }
.g-sec > p { color: var(--ink-2); margin-bottom: 10px; }
.steps { list-style: none; counter-reset: s; }
.steps li { counter-increment: s; display: grid; grid-template-columns: 34px 1fr; gap: 10px; padding: 13px 0; border-top: 1px solid var(--line); }
.steps li::before { content: counter(s); font: 400 24px/1 var(--serif); color: var(--accent); }
.steps li b { font-weight: 600; }
.steps li .m { display: block; color: var(--ink-2); font-size: 13.5px; margin-top: 3px; }
.bullets { list-style: none; }
.bullets li { padding: 10px 0 10px 18px; border-top: 1px solid var(--line); position: relative; }
.bullets li::before { content: ""; position: absolute; left: 2px; top: 19px; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.pattern { padding: 14px 0 2px; border-top: 1px solid var(--line); }
.pattern h3 { font-size: 16px; font-weight: 600; }
.pattern h3 small { font-weight: 400; color: var(--ink-2); font-size: 13px; margin-left: 6px; }
.pattern .rk { margin: 10px 0 12px 12px; }
.word { border-top: 1px solid var(--line); }
.word summary { list-style: none; display: flex; justify-content: space-between; align-items: center; padding: 14px 0; cursor: pointer; font-weight: 600; }
.word summary::-webkit-details-marker { display: none; }
.word .when { font-size: 13px; color: var(--ink-2); margin-bottom: 10px; }
.word .tr { font: 400 20px/1.35 var(--serif); margin-bottom: 10px; }
.word .en { font-size: 14px; color: var(--ink-2); padding-bottom: 16px; }

@media (prefers-reduced-motion: reduce) { .dial, .sky { transition: none; } }
