:root {
  --bg: #0a1122;
  --text: #f3f6ff;
  --muted: #a7b3d1;
  --blue: #7cc4ff;
  --red: #ff4d3d;
  --card: rgba(110, 150, 230, .11);
  --line: rgba(160, 190, 255, .17);
  --btn: linear-gradient(160deg, #2f7ae5, #1b4b9f);
  --btn-soft: rgba(47, 112, 214, .32);
  --btn-line: rgba(124, 180, 255, .5);
  --digits: Montserrat, "IBM Plex Sans Arabic", system-ui, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
body { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
input, textarea { -webkit-user-select: text; user-select: text; }
html, body { height: 100%; overflow: hidden; overscroll-behavior: none; }
body { background: var(--bg); color: var(--text); font-family: "IBM Plex Sans Arabic", system-ui, sans-serif; font-variant-numeric: tabular-nums; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; }
button:disabled { opacity: .6; cursor: wait; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
[hidden] { display: none !important; }
svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

#sky { position: fixed; inset: 0; width: 100%; height: 100%; }
#app {
  position: relative; display: flex; flex-direction: column;
  height: 100vh; height: 100dvh; max-width: 480px; margin: 0 auto;
}
.page { flex: 1; min-height: 0; display: flex; flex-direction: column; }
/* خارج السبحة تبقى السماء ظاهرة لكن أهدأ */
body:not([data-view=home]) #sky { opacity: .4; }

.top {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: calc(env(safe-area-inset-top) + 8px) 14px 0;
}
.icon { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 50%; flex: none; }
.icon svg { width: 26px; height: 26px; }
.today {
  background: var(--card); border: 1px solid var(--line); border-radius: 99px;
  padding: 6px 16px; font-size: .85rem; color: var(--muted);
}
#cats { display: flex; justify-content: center; gap: 6px; padding: 8px 10px 0; }
#cats button { white-space: nowrap; font-size: .8rem; padding: 6px 11px; border-radius: 99px; border: 1px solid var(--line); background: rgba(10, 17, 34, .5); color: var(--muted); }
#cats button[aria-pressed=true] { background: linear-gradient(135deg, #2f6fd6, #c8322c); border-color: transparent; color: #fff; font-weight: 700; }

#stage {
  flex: 1; min-height: 0; display: flex; flex-direction: column; align-items: center;
  user-select: none; -webkit-user-select: none; touch-action: none; cursor: pointer;
}
.words { width: 100%; padding: calc(8px + 1vh) 22px 0; text-align: center; text-shadow: 0 2px 14px rgba(0, 0, 0, .65); }
h1 { font-family: Amiri, serif; font-weight: 400; font-size: clamp(2.3rem, 7vh, 3.4rem); line-height: 1.75; text-wrap: balance; }
h1.mid { font-size: clamp(1.6rem, 4.4vh, 2.2rem); }
h1.long { font-size: clamp(1.25rem, 3.1vh, 1.55rem); }
h1.huge { font-size: clamp(1rem, 2.2vh, 1.15rem); }
.divider { position: relative; width: 190px; height: 12px; margin: 2px auto 6px; }
.divider::before { content: ""; position: absolute; top: 50%; inset-inline: 0; height: 1px; background: linear-gradient(90deg, transparent, rgba(255,255,255,.55), transparent); }
.divider span { position: absolute; top: 2px; left: calc(50% - 4px); width: 8px; height: 8px; background: var(--red); transform: rotate(45deg); box-shadow: 0 0 10px var(--red); }
#virtue { font-size: .92rem; line-height: 1.6; max-width: 36ch; margin: 0 auto; }
#source { font-size: .74rem; color: var(--muted); margin-top: 2px; }

#beadsBox { position: relative; width: 100%; flex: 1; min-height: 90px; max-height: 210px; margin-top: auto; }
#beads { position: absolute; inset: 0; width: 100%; height: 100%; }
#plus { position: absolute; left: calc(50% + 30px); top: calc(66% - 70px); color: #ff6a5a; font-weight: 800; font-size: 1.15rem; opacity: 0; pointer-events: none; }
#plus.go { animation: rise .6s ease-out; }
@keyframes rise { from { opacity: 1; transform: translateY(8px); } to { opacity: 0; transform: translateY(-20px); } }

.counter { display: flex; align-items: center; gap: 26px; margin-top: 2px; }
.ring { position: relative; width: 112px; height: 112px; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.ring svg { position: absolute; inset: 0; transform: rotate(-90deg); }
.ring circle { stroke-width: 5; }
.ring .track { stroke: var(--line); fill: rgba(8, 14, 30, .62); }
.ring .bar { stroke: url(#grad); transition: stroke-dasharray .25s; }
.ring.done .track { stroke: rgba(255, 77, 61, .45); }
#count { position: relative; font-size: 2.5rem; font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; }
#count.wide { font-size: 1.75rem; }
#target { position: relative; font-size: .8rem; color: var(--muted); }
.mini { width: 56px; height: 56px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; border-radius: 50%; background: var(--card); border: 1px solid var(--line); }
.mini svg { width: 20px; height: 20px; }
.mini small { font-size: .65rem; color: var(--muted); }
.hint { height: 96px; flex: none; display: flex; align-items: flex-end; padding-bottom: 10px; font-size: .88rem; font-weight: 500; text-shadow: 0 1px 8px #000; }

.tabs {
  flex: none; display: grid; grid-template-columns: repeat(4, 1fr);
  background: rgba(9, 15, 32, .9); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line); padding: 0 6px calc(env(safe-area-inset-bottom) + 6px);
}
.tabs button { position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 10px 0 4px; font-size: .74rem; color: var(--muted); }
.tabs button.active { color: var(--blue); font-weight: 700; }
.tabs button.active::before { content: ""; position: absolute; top: 0; width: 34px; height: 3px; border-radius: 0 0 4px 4px; background: var(--red); }
.tabs svg { width: 23px; height: 23px; }

/* مساحات قصيرة */
@media (max-height: 720px) {
  .words { padding-top: 12px; }
  h1 { line-height: 1.55; }
  h1.huge { line-height: 1.45; }
  #virtue { font-size: .8rem; line-height: 1.45; }
  .hint { height: 62px; padding-bottom: 4px; }
  .ring { width: 96px; height: 96px; }
  #count { font-size: 2rem; }
  #beadsBox { min-height: 76px; }
}

/* الصفحات الداخلية */
.head { padding: calc(env(safe-area-inset-top) + 18px) 22px 12px; border-bottom: 1px solid var(--line); }
.head h2 { font-size: 1.6rem; font-weight: 800; }
.head p { color: var(--muted); font-size: .88rem; margin-top: 4px; }
.scroll { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 16px 16px 24px; display: flex; flex-direction: column; gap: 14px; }
.scroll > * { flex: none; }
h2 { font-size: 1.2rem; }
h3 { font-size: .95rem; }
.group { display: flex; flex-direction: column; gap: 8px; }
.group > h3, .note { color: var(--muted); padding: 0 6px; }
.note { font-size: .78rem; line-height: 1.7; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 20px; padding: 14px; }
.card.selected { border-color: var(--blue); }
.card.goal.done { border-color: rgba(255, 77, 61, .7); }
.card.list { padding: 6px; }
.item { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 13px 12px; border-radius: 12px; text-align: start; color: var(--text); font-size: 1rem; }
.item + .item { border-top: 1px solid var(--line); }
a.item { text-decoration: none; }
.item small { overflow-wrap: anywhere; }
.item > span { display: flex; flex-direction: column; gap: 3px; }
.item b { font-weight: 500; }
.item small { font-size: .78rem; color: var(--muted); }
.item em { font-style: normal; color: var(--muted); white-space: nowrap; }
.item.on { background: rgba(124, 196, 255, .14); }
.item.on b, .item.on em { color: var(--blue); font-weight: 700; }
.item.custom { flex-direction: row; }
.custom input { width: 110px; margin-inline-start: auto; text-align: center; }
.fields { display: flex; flex-direction: column; gap: 12px; padding: 10px 8px; }

.next { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 20px; background: linear-gradient(135deg, rgba(47, 111, 214, .45), rgba(200, 50, 44, .4)); }
.next small { color: #dbe6ff; }
.next strong { font-size: 2.2rem; font-weight: 800; }
.next span { font-size: 1.2rem; }
.next output { margin-top: 6px; font-variant-numeric: tabular-nums; color: #ffe1dd; }

.pick { width: 100%; display: flex; flex-direction: column; gap: 2px; text-align: start; }
.dhikr { font-family: Amiri, serif; font-size: 1.25rem; line-height: 1.8; overflow-wrap: anywhere; }
.pick small { color: var(--muted); font-size: .8rem; }
.progress { height: 6px; margin: 10px 0 4px; border-radius: 9px; background: var(--line); overflow: hidden; }
.progress i { display: block; height: 100%; border-radius: 9px; background: linear-gradient(to left, var(--blue), var(--red)); }
.link { font-size: .85rem; padding: 6px; }
.accent { color: var(--blue); font-weight: 700; }
.danger { color: #ff8478; }
form { display: flex; flex-direction: column; gap: 12px; }
label:not(.item) { display: flex; flex-direction: column; gap: 6px; font-size: .85rem; color: var(--muted); }
input.numin, select, textarea { width: 100%; background: #0b1430; border: 1px solid var(--line); border-radius: 12px; padding: 9px 12px; font-size: 1rem; color: var(--text); }
textarea { font-family: Amiri, serif; font-size: 1.25rem; resize: vertical; }

input[role=switch] { appearance: none; -webkit-appearance: none; flex: none; position: relative; width: 52px; height: 30px; border-radius: 99px; background: #3a4666; cursor: pointer; transition: .2s; }
input[role=switch]::after { content: ""; position: absolute; top: 3px; inset-inline-start: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: .2s; }
input[role=switch]:checked { background: #2f7ae5; }
input[role=switch]:checked::after { inset-inline-start: 25px; }

.primary { background: linear-gradient(135deg, #2f6fd6, #c8322c); border-radius: 14px; padding: 12px; font-weight: 700; color: #fff; }
.secondary { border: 1px solid var(--blue); color: var(--blue); border-radius: 12px; padding: 10px; font-weight: 700; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stats div { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 12px 4px; display: flex; flex-direction: column; align-items: center; }
.stats strong { font-size: 1.5rem; color: var(--blue); }
.stats span { font-size: .72rem; color: var(--muted); }
.week { display: grid; grid-template-columns: repeat(7, 1fr); align-items: end; text-align: center; }
.week div { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.week b { font-size: .7rem; font-weight: 500; }
.week i { width: 14px; border-radius: 7px; background: #4a82d8; }
.week i.done { background: var(--red); }
.week span { font-size: .65rem; color: var(--muted); }

#scrim { position: fixed; z-index: 3; inset: 0; background: rgba(0, 0, 0, .55); }
#sheet {
  position: fixed; z-index: 3; bottom: 0; left: 0; right: 0; max-width: 480px; margin: 0 auto;
  max-height: 90vh; max-height: 90dvh; display: flex; flex-direction: column;
  background: #0e1834; border: 1px solid var(--line); border-bottom: 0;
  border-radius: 28px 28px 0 0; animation: up .25s ease-out;
}
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px 8px 12px; padding-inline-start: 22px; border-bottom: 1px solid var(--line); }
.prose h3 { font-size: 1.1rem; margin: 20px 0 6px; }
.prose p { line-height: 1.9; color: #d3dcf3; font-size: .95rem; }

#toast {
  position: fixed; top: calc(env(safe-area-inset-top) + 64px); left: 50%; transform: translate(-50%, -8px);
  width: max-content; max-width: calc(100% - 32px); text-align: center; z-index: 4;
  background: #f3f6ff; color: #0a1122; border-radius: 99px; padding: 9px 18px; font-weight: 700; font-size: .88rem;
  opacity: 0; pointer-events: none; transition: .25s;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

.chip { font-size: .76rem; font-weight: 700; color: var(--blue); background: rgba(10, 17, 34, .6); border: 1px solid rgba(124, 196, 255, .45); border-radius: 99px; padding: 5px 12px; white-space: nowrap; text-shadow: none; }
#look { align-self: center; margin-top: 8px; }
#pickDhikr { margin-bottom: 10px; }
.gallery { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.gallery .card { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 4px; }
.gallery .card[aria-pressed=true] { border: 2px solid var(--red); background: rgba(255, 77, 61, .14); }
#thirds { display: flex; justify-content: center; gap: 9px; }
#thirds i { width: 7px; height: 7px; transform: rotate(45deg); border: 1px solid var(--muted); }
#thirds i.on { background: var(--red); border-color: var(--red); box-shadow: 0 0 8px var(--red); }

/* السبحة العمودية: الخيط في جهة، والذكر والعدّاد في الجهة الأخرى */
#stage[data-shape=vertical] {
  display: grid; grid-template-columns: minmax(0, 1fr) 40%;
  grid-template-rows: auto 1fr auto auto auto 1fr auto;
  grid-template-areas: ". beads" ". beads" "words beads" "thirds beads" "counter beads" ". beads" "hint beads";
}

[data-shape=vertical] .words { grid-area: words; padding: 0; padding-inline-start: 12px; }
[data-shape=vertical] #thirds { grid-area: thirds; margin: 12px 0; }
[data-shape=vertical] .counter { grid-area: counter; display: grid; grid-template-columns: auto auto; justify-content: center; gap: 10px 20px; }
[data-shape=vertical] .ring { order: -1; grid-column: 1 / -1; justify-self: center; width: 136px; height: 136px; }
[data-shape=vertical] #count { font-size: 3.1rem; }
[data-shape=vertical] #count.wide { font-size: 2.1rem; }
[data-shape=vertical] .mini { width: 52px; height: 52px; }
[data-shape=vertical] #beadsBox { grid-area: beads; max-height: none; height: 100%; min-height: 0; margin: 0; }
#stage[data-shape=vertical][data-col=first] {
  grid-template-columns: 40% minmax(0, 1fr);
  grid-template-areas: "beads ." "beads ." "beads words" "beads thirds" "beads counter" "beads ." "beads hint";
}
[data-shape=vertical][data-col=first] .words { padding-inline-start: 0; padding-inline-end: 12px; }
[data-shape=vertical] #plus { top: calc(50% - 60px); }
[data-shape=vertical][data-side=right] #plus { left: calc(40% + 34px); }
[data-shape=vertical][data-side=left] #plus { left: calc(60% + 34px); }
.segment { display: flex; flex: none; gap: 3px; padding: 3px; border-radius: 99px; background: rgba(8, 14, 30, .55); border: 1px solid var(--btn-line); }
.segment button { padding: 6px 14px; border-radius: 99px; font-size: .85rem; color: #cfe0ff; }
.segment button[aria-pressed=true] { background: var(--btn); color: #fff; font-weight: 700; }
[data-shape=vertical] .chip { z-index: 1; }
[data-shape=vertical] .hint { grid-area: hint; height: 70px; justify-content: center; }
[data-shape=vertical] h1 { font-size: clamp(2rem, 5.4vh, 2.7rem); }
[data-shape=vertical] h1.mid { font-size: clamp(1.45rem, 3.6vh, 1.85rem); }
[data-shape=vertical] h1.long { font-size: clamp(1.15rem, 2.7vh, 1.4rem); }
[data-shape=vertical] h1.huge { font-size: clamp(.95rem, 2vh, 1.1rem); line-height: 1.7; }
[data-shape=vertical] .divider { width: 150px; }
[data-shape=vertical] #virtue { font-size: .84rem; }
@media (max-height: 720px) {
  [data-shape=vertical] #thirds { margin: 6px 0; }
  [data-shape=vertical] .ring { width: 100px; height: 100px; }
  [data-shape=vertical] #count { font-size: 2.2rem; }
  [data-shape=vertical] .mini { width: 46px; height: 46px; }
  [data-shape=vertical] .hint { height: 36px; }
  [data-shape=vertical] #virtue { font-size: .74rem; }
  [data-shape=vertical] h1.huge { font-size: .9rem; line-height: 1.55; }
}

/* ---------- الأزرار الزرقاء ---------- */
button:disabled { cursor: default; opacity: .45; }
.icon, .mini, .today, .chip, #cats button, .preset, .tool { background: var(--btn-soft); border: 1px solid var(--btn-line); color: #fff; }
.mini small { color: #d5e6ff; }
.today { font-weight: 500; }
.chip { color: #fff; font-weight: 600; }
#cats button[aria-pressed=true], .preset[aria-pressed=true] { background: var(--btn); border-color: #8cc2ff; color: #fff; font-weight: 700; box-shadow: 0 2px 14px rgba(47, 122, 229, .55); }
.primary, .small { background: var(--btn); color: #fff; font-weight: 700; border-radius: 14px; }
.small { flex: none; padding: 8px 18px; font-size: .9rem; border: 1px solid var(--btn-line); border-radius: 99px; }
.secondary { background: var(--btn-soft); border: 1px solid var(--btn-line); color: #fff; }
.tabs button { border-radius: 14px; }
.tabs button.active { background: var(--btn-soft); color: #fff; }
.tabs { gap: 4px; }
.item.on { background: var(--btn-soft); }

/* ---------- الأرقام والخطوط ---------- */
#count, #plus, .stats strong, .next span, .next output, .item em, .week b, .preset, input.numin { font-family: var(--digits); }
#count { font-weight: 700; letter-spacing: -.02em; }
h2, h3, .next strong { letter-spacing: 0; font-weight: 700; }
#translit { font-weight: 700; font-size: .98rem; }
#meaning { font-size: .86rem; color: #cddaf5; margin-bottom: 4px; }
#translit:empty, #meaning:empty, #virtue:empty { display: none; }
[data-shape=vertical] #translit { font-size: .9rem; }
html[dir=ltr] #virtue { font-size: .76rem; color: var(--muted); }

/* ---------- تخصيص الأذكار ---------- */
#sheetSub { color: var(--muted); font-size: .8rem; }
#sheetSub:empty { display: none; }
.dhikr-row { display: flex; flex-direction: column; gap: 10px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.dhikr-row.selected { background: rgba(47, 112, 214, .16); border-radius: 16px; padding: 10px; }
.dhikr-row.muted .head-line > canvas, .dhikr-row.muted .pick { opacity: .45; }
.head-line { display: flex; align-items: center; gap: 10px; }
.head-line .pick { flex: 1; min-width: 0; }
.head-line .dhikr { font-family: "IBM Plex Sans Arabic", sans-serif; font-size: 1.02rem; line-height: 1.8; text-align: right; }
html[dir=ltr] .dhikr { text-align: left; }
.tool { flex: none; width: 40px; height: 40px; display: grid; place-items: center; border-radius: 12px; }
.tool svg { width: 20px; height: 20px; }
.tool.eye[aria-pressed=false] { background: transparent; color: var(--muted); }
.tool.trash.sure { background: #c8322c; border-color: #ff8478; }
.goal-line { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: .85rem; }
.goal-line input.numin { width: 84px; text-align: center; font-weight: 700; }
.preset { min-width: 48px; padding: 6px 10px; border-radius: 99px; font-size: .84rem; }
.adder textarea { font-family: "IBM Plex Sans Arabic", sans-serif; font-size: 1rem; resize: none; }
.adder-line { display: flex; gap: 8px; align-items: center; }
.adder-line select { flex: 1; min-width: 0; }
.adder-line input.numin { width: 84px; text-align: center; }

@media (max-height: 720px) {
  #look { margin-top: 5px; }
  #pickDhikr { margin-bottom: 4px; padding-block: 3px; }
  html[dir=ltr] [data-shape=vertical] h1.mid { font-size: 1.15rem; }
  html[dir=ltr] [data-shape=vertical] #translit { font-size: .74rem; line-height: 1.35; }
  html[dir=ltr] [data-shape=vertical] #meaning { font-size: .72rem; line-height: 1.35; margin: 0; }
  html[dir=ltr] #source { font-size: .66rem; }
  html[dir=ltr] [data-shape=vertical] .ring { width: 86px; height: 86px; }
  html[dir=ltr] [data-shape=vertical] .mini { width: 42px; height: 42px; }
  html[dir=ltr] [data-shape=vertical] .mini small { display: none; }
}

/* أصغر الجوالات */
@media (max-height: 600px) and (orientation: portrait) {
  .top { padding-top: calc(env(safe-area-inset-top) + 4px); }
  .icon { width: 38px; height: 38px; }
  #cats { padding-top: 4px; gap: 4px; }
  #cats button { font-size: .72rem; padding: 4px 8px; }
  #look { margin-top: 3px; }
  .chip { font-size: .68rem; padding: 2px 10px; }
  #pickDhikr { margin-bottom: 2px; }
  .words { padding-top: 2px; }
  #virtue, #source, #thirds, .hint, html[dir=ltr] #source { display: none; }
  [data-shape=vertical] .divider, .divider { margin: 0 auto 2px; height: 8px; }
  .divider span { top: 0; }
  [data-shape=vertical] h1.mid, html[dir=ltr] [data-shape=vertical] h1.mid { font-size: 1.05rem; line-height: 1.5; }
  [data-shape=vertical] h1.long { font-size: .92rem; line-height: 1.5; }
  [data-shape=vertical] h1.huge { font-size: .74rem; line-height: 1.45; }
  [data-shape=vertical] h1 { font-size: 1.6rem; line-height: 1.5; }
  html[dir=ltr] [data-shape=vertical] #translit { display: none; }
  html[dir=ltr] [data-shape=vertical] #meaning { font-size: .66rem; }
  [data-shape=vertical] .ring, html[dir=ltr] [data-shape=vertical] .ring { width: 74px; height: 74px; }
  [data-shape=vertical] #count { font-size: 1.6rem; }
  [data-shape=vertical] .counter { gap: 4px 14px; padding-bottom: 4px; }
  [data-shape=vertical] .mini, html[dir=ltr] [data-shape=vertical] .mini { width: 36px; height: 36px; }
  .mini small { display: none; }
  .tabs button { padding: 6px 0 2px; }
}

/* التطبيق مصمم للوضع الطولي */
@media (orientation: landscape) and (max-height: 500px) {
  body::after {
    content: "أدر جوالك للوضع الطولي"; position: fixed; inset: 0; z-index: 10;
    display: grid; place-items: center; background: var(--bg); font-size: 1.1rem; font-weight: 700;
  }
  html[dir=ltr] body::after { content: "Rotate your phone to portrait"; }
}

/* القبلة */
.why { color: var(--muted); font-size: .76rem; text-align: center; margin-top: -4px; }
.qibla { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 18px; }
.qibla strong { font-size: 1.15rem; }
.qibla small { color: var(--muted); font-size: .8rem; text-align: center; }
.qibla .primary { width: 100%; }
#dial { position: relative; width: 170px; height: 170px; border-radius: 50%; border: 2px solid var(--btn-line); background: rgba(8, 14, 30, .6); direction: ltr; }
#dial > * { position: absolute; left: 50%; top: 50%; }
#dial b { z-index: 1; color: var(--text); text-shadow: 0 0 6px #000; transform: translate(-50%, -50%) rotate(var(--north, 0deg)) translateY(-46px) rotate(calc(-1 * var(--north, 0deg))); }
#dial i { width: 4px; height: 56px; margin: -56px 0 0 -2px; border-radius: 4px; background: linear-gradient(to top, var(--blue), var(--red)); transform-origin: 50% 100%; transform: rotate(var(--qibla, 0deg)); }
#dial span { width: 24px; height: 24px; border-radius: 4px; border: 1px solid rgba(255,255,255,.5); background: linear-gradient(#111 0 24%, #e3b23c 24% 38%, #111 38%); transform: translate(-50%, -50%) rotate(var(--qibla, 0deg)) translateY(-68px) rotate(calc(-1 * var(--qibla, 0deg))); }
#dial.aligned { border-color: var(--red); box-shadow: 0 0 22px var(--red); }

/* العدّاد وتحته أزرار التراجع والتصفير والصوت */
.counter { display: grid; grid-template-columns: auto auto auto; justify-content: center; gap: 10px 18px; }
.counter .ring { order: -1; grid-column: 1 / -1; justify-self: center; }
[data-shape=vertical] .counter { grid-template-columns: auto auto auto; }
.top { justify-content: center; min-height: 52px; }
#mic.live { background: linear-gradient(135deg, #c8322c, #ff4d3d); border-color: #ff8478; animation: listen 1.4s ease-in-out infinite; }
@keyframes listen { 50% { box-shadow: 0 0 0 10px rgba(255, 77, 61, .18); } }
#heard { grid-column: 1 / -1; max-width: 240px; margin: 0 auto; text-align: center; font-size: .78rem; line-height: 1.5; color: #ffd6d1; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
#heard[hidden] { display: none; }

/* تصفير الذكر الحالي داخل نافذة الأذكار */
.today-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; }
.today-row > span { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.today-row small { color: var(--muted); font-size: .78rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.today-row .secondary { flex: none; padding: 8px 16px; }

/* ---------- الوضع الفاتح ---------- */
html[data-theme=light] {
  --bg: #eef3fb; --text: #101b34; --muted: #55627f; --blue: #2463c9;
  --card: rgba(255, 255, 255, .74); --line: rgba(30, 60, 120, .16);
  --btn-soft: rgba(47, 112, 214, .12); --btn-line: rgba(47, 112, 214, .32);
  color-scheme: light;
}
html[data-theme=light] .words, html[data-theme=light] .hint { text-shadow: none; }
html[data-theme=light] .icon, html[data-theme=light] .mini, html[data-theme=light] .today, html[data-theme=light] .chip,
html[data-theme=light] #cats button, html[data-theme=light] .preset, html[data-theme=light] .tool, html[data-theme=light] .secondary { color: var(--text); background: rgba(255, 255, 255, .7); }
html[data-theme=light] #cats button[aria-pressed=true], html[data-theme=light] .preset[aria-pressed=true] { color: #fff; background: var(--btn); }
html[data-theme=light] .chip { color: var(--blue); }
html[data-theme=light] .mini small, html[data-theme=light] .segment button, html[data-theme=light] #meaning, html[data-theme=light] .prose p, html[data-theme=light] .next small { color: #33415f; }
html[data-theme=light] .segment, html[data-theme=light] #dial { background: rgba(255, 255, 255, .72); }
html[data-theme=light] .segment button[aria-pressed=true] { color: #fff; }
html[data-theme=light] .ring .track { fill: rgba(255, 255, 255, .78); }
html[data-theme=light] .tabs { background: rgba(255, 255, 255, .9); }
html[data-theme=light] .tabs button.active { color: var(--blue); }
html[data-theme=light] input.numin, html[data-theme=light] select, html[data-theme=light] textarea { background: #fff; }
html[data-theme=light] #sheet { background: #f6f9ff; }
html[data-theme=light] .next output, html[data-theme=light] #heard { color: #b3261e; }
html[data-theme=light] #dial b { text-shadow: none; }
html[data-theme=light] #toast { background: #101b34; color: #fff; }
html[data-theme=light] #mic.live { color: #fff; }

/* بطاقة الإنجاز */
#cardBtn { width: 100%; }
.card-preview { display: grid; place-items: center; min-height: 200px; }
.card-preview img { width: min(100%, 320px); border-radius: 18px; box-shadow: 0 12px 40px rgba(0, 0, 0, .45); }
.card-actions { display: flex; gap: 10px; }
.card-actions > * { flex: 1; }

/* صف الأقسام وزر تغيير الذكر في سطر واحد */
#cats { flex-wrap: nowrap; gap: 4px; padding-inline: 8px; }
#cats button { font-size: .74rem; padding: 6px 9px; }
#cats .chip { display: inline-flex; align-items: center; gap: 4px; flex: none; margin: 0; padding: 6px 9px; color: #fff; }
#cats .chip svg { width: 15px; height: 15px; }
html[data-theme=light] #cats .chip { color: var(--blue); }
@media (max-width: 372px) { #cats .chip span { display: none; } #cats .chip { padding: 6px 10px; } }
.top { min-height: 44px; }
#stage { padding-bottom: 16px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
