:root {
  --bg: #f4f6f5; --card: #ffffff; --text: #17211d; --muted: #6b7a74; --line: #e3e9e6;
  --accent: #0f5c4d; --accent-2: #e8c15a; --accent-text: #ffffff; --danger: #c0392b;
  --shadow: 0 1px 3px rgba(15, 40, 32, .08), 0 4px 14px rgba(15, 40, 32, .05);
}
:root[data-theme="dark"] {
  --bg: #0e1513; --card: #17211e; --text: #e8efec; --muted: #8fa19a; --line: #24312d;
  --accent: #2fa88f; --accent-2: #e8c15a; --accent-text: #06201a; --danger: #ef6b5b;
  --shadow: 0 1px 3px rgba(0, 0, 0, .4);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
body { padding-bottom: calc(66px + env(safe-area-inset-bottom)); }
main { max-width: 640px; margin: 0 auto; padding: 14px 14px 24px; }
h1 { font-size: 20px; margin: 4px 0 12px; }
h2 { font-size: 16px; margin: 18px 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.center { text-align: center; }
.ar { font-family: "Amiri", "Noto Naskh Arabic", "Traditional Arabic", serif; direction: rtl; }

.tabs { position: fixed; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: repeat(4, 1fr); background: var(--card);
  border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); z-index: 5; }
.tabs button { background: none; border: 0; color: var(--muted); padding: 8px 0 7px; font-size: 11.5px; display: flex; flex-direction: column; align-items: center; gap: 1px; }
.tabs button span { font-size: 20px; }
.tabs button.active { color: var(--accent); font-weight: 600; }

.card { background: var(--card); border-radius: 14px; padding: 14px; box-shadow: var(--shadow); margin-bottom: 12px; }
.row { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; background: var(--card); border: 0; color: inherit;
  padding: 12px 14px; border-radius: 12px; box-shadow: var(--shadow); margin-bottom: 8px; font: inherit; }
.row .num { width: 34px; height: 34px; border-radius: 50%; background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent);
  display: grid; place-items: center; font-weight: 700; font-size: 13px; flex: none; }
.row .grow { flex: 1; min-width: 0; }
.row .title { font-weight: 600; }
.row .ar-name { font-size: 22px; color: var(--accent); }
.row .preview { color: var(--muted); font-size: 13.5px; margin-top: 2px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

input[type=text], input[type=search], input[type=number] { width: 100%; padding: 11px 13px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--card); color: var(--text); font: inherit; outline: none; }
input:focus { border-color: var(--accent); }
.search { position: sticky; top: 0; z-index: 3; background: var(--bg); padding: 4px 0 10px; }

.btn { border: 0; border-radius: 12px; padding: 11px 16px; font: inherit; font-weight: 600; background: var(--accent); color: var(--accent-text); }
.btn.ghost { background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--accent); }
.btn.block { display: block; width: 100%; }
.btn:disabled { opacity: .5; }
.btn:active { transform: scale(.98); }
.btns { display: flex; gap: 8px; flex-wrap: wrap; }
.btns .btn { flex: 1; min-width: 90px; }

.verse { padding: 14px 10px; border-bottom: 1px solid var(--line); cursor: pointer; border-radius: 12px; transition: background .2s; }
.verse.cur { background: color-mix(in srgb, var(--accent) 9%, transparent); }
.verse.cur .uz { color: var(--text); }
.verse .ar { font-size: 27px; line-height: 2; text-align: right; }
.verse .uz { margin-top: 4px; color: var(--muted); }
.verse .n { display: inline-block; min-width: 26px; height: 26px; line-height: 26px; text-align: center; border-radius: 50%; background: color-mix(in srgb, var(--accent-2) 30%, transparent); font-size: 12px; margin-right: 8px; }
.w { border-radius: 8px; padding: 0 3px; transition: background .12s, color .12s; }
.w.read { color: var(--accent); }
.w.on { background: var(--accent-2); color: #1c1c1c; }
.reciters { margin: 0 0 8px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.reciters::-webkit-scrollbar { display: none; }
.reciters .pill { flex: none; white-space: nowrap; padding: 8px 14px; font-size: 13px; }
.player { position: sticky; top: 0; z-index: 3; background: var(--bg); padding: 6px 0 10px; }
audio { width: 100%; }
.back { background: none; border: 0; color: var(--accent); font: inherit; font-weight: 600; padding: 4px 0 10px; }

.sheet { position: fixed; inset: 0; background: rgba(0, 0, 0, .45); z-index: 20; display: flex; align-items: flex-end; }
.sheet[hidden] { display: none; }
.sheet .panel { background: var(--card); width: 100%; max-height: 82vh; overflow: auto; border-radius: 18px 18px 0 0; padding: 16px 16px calc(18px + env(safe-area-inset-bottom)); }
.sheet .panel .text { white-space: pre-wrap; margin: 8px 0 14px; }

.toast { position: fixed; left: 50%; bottom: calc(80px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: #17211d; color: #fff;
  padding: 9px 16px; border-radius: 22px; z-index: 30; font-size: 14px; max-width: 88%; text-align: center; box-shadow: var(--shadow); }
.toast[hidden] { display: none; }

.segmented { display: grid; grid-template-columns: 1fr 1fr; background: color-mix(in srgb, var(--accent) 10%, transparent); border-radius: 12px; padding: 3px; margin-bottom: 14px; }
.segmented button { border: 0; background: none; padding: 9px; border-radius: 10px; font: inherit; color: var(--muted); font-weight: 600; }
.segmented button.on { background: var(--card); color: var(--accent); box-shadow: var(--shadow); }
.fields { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.fields.two { grid-template-columns: 1fr 1fr; }
.field label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 4px; }
.pillrow { display: flex; gap: 8px; margin: 6px 0 12px; }
.pill { flex: 1; text-align: center; padding: 10px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); color: var(--text); font: inherit; }
.pill.on { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--accent); font-weight: 600; }
.switch { display: flex; align-items: center; justify-content: space-between; padding: 6px 0; }

.ring { width: 132px; height: 132px; flex: none; }
.ring circle { fill: none; stroke-width: 11; }
.ring .bg { stroke: var(--line); }
.ring .fg { stroke: var(--accent); stroke-linecap: round; transition: stroke-dashoffset .5s; transform: rotate(-90deg); transform-origin: 50% 50%; }
.ring text { fill: var(--text); font-size: 26px; font-weight: 700; text-anchor: middle; dominant-baseline: central; }
.hero { display: flex; align-items: center; gap: 16px; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 4px; }
.stat b { display: block; font-size: 18px; }
.prayer { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--line); }
.prayer:last-child { border-bottom: 0; }
.prayer .left { font-size: 20px; font-weight: 700; }
.prayer .done { color: var(--accent); }
.minus { width: 44px; height: 38px; border-radius: 10px; border: 0; background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); font-size: 20px; font-weight: 700; margin-left: 10px; }

.compass { position: relative; width: min(78vw, 320px); aspect-ratio: 1; margin: 8px auto 4px; }
.compass svg { width: 100%; height: 100%; }
#dial { transition: transform .15s linear; }
.compass .ptr { position: absolute; top: -6px; left: 50%; transform: translateX(-50%); font-size: 26px; color: var(--accent-2); }
.aligned .ring-outer { stroke: var(--accent); stroke-width: 5; }
.big { font-size: 34px; font-weight: 700; color: var(--accent); }
.empty { padding: 30px 10px; }
.spinner { text-align: center; padding: 40px; color: var(--muted); }
