:root {
  color-scheme: light dark;
  --bg: #F2F2F7;
  --card: #FFFFFF;
  --card2: #F4F4F7;
  --text: #1C1C1E;
  --text2: #6C6C70;
  --text3: #AEAEB2;
  --sep: rgba(60, 60, 67, .13);
  --accent: #2F7A6B;
  --accent-ink: #FFFFFF;
  --tint: rgba(47, 122, 107, .11);
  --tint2: rgba(47, 122, 107, .2);
  --g0: #E2E2E7;
  --g1: rgba(47, 122, 107, .26);
  --g2: rgba(47, 122, 107, .56);
  --g3: #2F7A6B;
  --note: #F6F1E6;
  --note-ink: #6B5626;
  --shadow: 0 8px 30px rgba(0, 0, 0, .12);
  --r: 14px;
  --tabh: 58px;
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --card: #1C1C1E;
    --card2: #2A2A2D;
    --text: #F2F2F7;
    --text2: #9C9CA3;
    --text3: #5E5E64;
    --sep: rgba(84, 84, 88, .45);
    --accent: #5DB39F;
    --accent-ink: #07241E;
    --tint: rgba(93, 179, 159, .15);
    --tint2: rgba(93, 179, 159, .26);
    --g0: #2A2A2D;
    --g1: rgba(93, 179, 159, .28);
    --g2: rgba(93, 179, 159, .58);
    --g3: #5DB39F;
    --note: #2A261C;
    --note-ink: #D9C79A;
    --shadow: 0 8px 30px rgba(0, 0, 0, .5);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Arabic", "SF Pro Text", "Geeza Pro", "Segoe UI", Tahoma, sans-serif;
  font-size: 16px; line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; touch-action: manipulation; }
input, select, textarea { touch-action: manipulation; }

#app { max-width: 560px; margin: 0 auto; padding: calc(var(--sat) + 8px) 16px calc(var(--tabh) + var(--sab) + 24px); min-height: 100vh; }

/* العناوين */
.top { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; padding: 14px 4px 10px; }
.top h1 { margin: 0; font-size: 30px; font-weight: 700; letter-spacing: -.2px; line-height: 1.15; }
.top .sub { color: var(--text2); font-size: 14px; margin-top: 3px; }
.big-num { font-size: 34px; font-weight: 700; font-variant-numeric: tabular-nums; }
.of { font-size: 17px; color: var(--text2); font-weight: 500; }
.h2 { font-size: 13px; font-weight: 600; color: var(--text2); margin: 22px 8px 7px; }
.h2.row-h { display: flex; justify-content: space-between; align-items: center; }
.muted { color: var(--text2); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }

/* البطاقات والقوائم */
.card { background: var(--card); border-radius: var(--r); overflow: hidden; }
.card + .card { margin-top: 10px; }
.pad { padding: 14px 16px; }
.list > * + * { border-top: .5px solid var(--sep); }
.badges { display: flex; flex-wrap: wrap; gap: 6px; margin: 2px 4px 4px; }
.badge { font-size: 12.5px; padding: 3px 10px; border-radius: 99px; background: var(--card); color: var(--text2); }
.badge.acc { background: var(--tint); color: var(--accent); }

/* الأزرار */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 0 16px; border-radius: 12px; font-weight: 600; font-size: 15px; background: var(--tint); color: var(--accent); }
.btn.fill { background: var(--accent); color: var(--accent-ink); }
.btn.plain { background: var(--card2); color: var(--text); font-weight: 500; }
.btn.ghost { background: none; color: var(--accent); padding: 0 8px; }
.btn.block { width: 100%; }
.btn.sm { min-height: 36px; padding: 0 12px; font-size: 14px; border-radius: 10px; }
.btn.on { background: var(--accent); color: var(--accent-ink); }
.btn:active { opacity: .7; }
.btn[disabled] { opacity: .4; }
.btns { display: flex; flex-wrap: wrap; gap: 8px; }
.btns.two > * { flex: 1 1 0; }
.danger { color: #B4543F; }

/* بطاقة ملخص اليوم */
.summary { padding: 14px 16px; }
.summary .line { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.bar { height: 6px; border-radius: 3px; background: var(--g0); overflow: hidden; margin-top: 10px; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 3px; transition: width .3s ease; }
.success-note { margin-top: 10px; padding: 10px 12px; border-radius: 10px; background: var(--tint); color: var(--accent); font-size: 14.5px; font-weight: 500; }

.hard-btn { display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%; padding: 13px 16px; text-align: start; }
.hard-btn .t { font-weight: 600; }
.hard-btn .d { color: var(--text2); font-size: 13px; }
.switch { width: 46px; height: 28px; border-radius: 14px; background: var(--g0); position: relative; flex: none; transition: background .2s; }
.switch::after { content: ""; position: absolute; top: 2px; inset-inline-start: 2px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: inset-inline-start .2s; }
.switch.on { background: var(--accent); }
.switch.on::after { inset-inline-start: 20px; }

/* التنبيهات الهادئة */
.notice { background: var(--note); color: var(--note-ink); border-radius: var(--r); padding: 12px 14px; font-size: 14.5px; margin-top: 10px; }
.notice.acc { background: var(--tint); color: var(--text); }
.notice b { font-weight: 600; }
.notice .btns { margin-top: 10px; }

/* الصلوات */
.prayers { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; padding: 12px; }
.pr { min-height: 58px; border-radius: 12px; background: var(--card2); display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 14px; font-weight: 500; gap: 2px; }
.pr small { font-size: 11px; color: var(--text2); font-weight: 400; min-height: 14px; }
.pr.on { background: var(--tint2); color: var(--accent); }
.pr.on small { color: var(--accent); }
.pr.m { background: var(--accent); color: var(--accent-ink); }
.pr.m small { color: var(--accent-ink); opacity: .85; }

/* صفوف المهام */
.task { }
.trow { display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 16px; min-height: 60px; text-align: start; }
.trow .ic { flex: none; width: 28px; height: 28px; }
.trow .tx { flex: 1; min-width: 0; }
.trow .tt { font-weight: 600; font-size: 16px; }
.trow .ts { font-size: 13px; color: var(--text2); margin-top: 1px; }
.trow .tv { flex: none; font-size: 14px; color: var(--text2); font-variant-numeric: tabular-nums; }
.trow .tv.done { color: var(--accent); font-weight: 600; }
.slot { font-size: 11.5px; color: var(--text3); padding: 8px 16px 0; font-weight: 600; }
.panel { padding: 2px 16px 16px; display: grid; gap: 12px; }
.cue { font-size: 13px; color: var(--text2); background: var(--card2); border-radius: 10px; padding: 8px 11px; }
.cue b { color: var(--text); font-weight: 600; }
.lvlhint { font-size: 13px; color: var(--accent); }
.choice { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.choice .btn { min-height: 56px; flex-direction: column; gap: 0; line-height: 1.25; padding: 6px 10px; }
.choice .btn small { font-weight: 400; font-size: 12.5px; opacity: .85; }
.numrow { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.num { width: 92px; min-height: 44px; border-radius: 12px; border: 0; background: var(--card2); text-align: center; font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { min-height: 38px; padding: 0 14px; border-radius: 99px; background: var(--card2); font-size: 14px; display: inline-flex; align-items: center; gap: 6px; }
.chip.on { background: var(--accent); color: var(--accent-ink); }
.chip.soft.on { background: var(--tint2); color: var(--accent); }
.lec { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px; border-radius: 12px; background: var(--card2); width: 100%; text-align: start; min-height: 48px; }
.lec.on { background: var(--tint2); color: var(--accent); font-weight: 600; }
.tas { display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 8px; }
.tas .tap { min-height: 52px; border-radius: 12px; background: var(--card2); display: flex; justify-content: space-between; align-items: center; padding: 0 14px; text-align: start; }
.tas .tap.on { background: var(--tint2); color: var(--accent); }
.tas .cnt { font-variant-numeric: tabular-nums; font-weight: 600; }
.course { background: var(--card2); border-radius: 12px; padding: 10px 12px; }
.course .n { font-weight: 600; font-size: 14px; direction: ltr; text-align: right; }
textarea.note, .field input, .field select, .field textarea { width: 100%; border: 0; border-radius: 12px; background: var(--card2); padding: 11px 12px; min-height: 44px; font-size: 16px; }
textarea.note { min-height: 70px; resize: vertical; }

/* المكافأة */
.bonus { border: 1px dashed var(--g2); background: transparent; }
.locked { color: var(--text2); font-size: 14px; padding: 14px 16px; text-align: center; }

/* الشبكة */
.grid300 { display: grid; grid-template-columns: repeat(15, 1fr); gap: 4px; padding: 14px; direction: rtl; }
.cell { aspect-ratio: 1; border-radius: 5px; background: var(--g0); }
.cell.partial { background: var(--g1); }
.cell.min { background: var(--g2); }
.cell.full { background: var(--g3); }
.cell.future { background: transparent; box-shadow: inset 0 0 0 1px var(--sep); }
.cell.today { box-shadow: 0 0 0 2px var(--bg), 0 0 0 3.5px var(--text2); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; padding: 0 16px 14px; font-size: 12.5px; color: var(--text2); }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }

.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat { background: var(--card); border-radius: var(--r); padding: 12px 14px; }
.stat .v { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat .l { font-size: 13px; color: var(--text2); }

.journey { padding: 12px 16px; }
.journey .hd { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.journey .hd b { font-weight: 600; }
.track { display: flex; gap: 3px; margin: 10px 0 6px; }
.track i { flex: 1; height: 6px; border-radius: 3px; background: var(--g0); }
.track i.on { background: var(--g2); }
.track i.cur { background: var(--accent); }
.jlabels { display: flex; justify-content: space-between; font-size: 12px; color: var(--text2); }

.week { display: flex; justify-content: space-between; align-items: center; padding: 11px 16px; gap: 10px; }
.dots { display: flex; gap: 3px; }
.dots i { width: 10px; height: 10px; border-radius: 3px; background: var(--g0); }
.dots i.partial { background: var(--g1); } .dots i.min { background: var(--g2); } .dots i.full { background: var(--g3); }

/* الخطة */
.prow { display: flex; align-items: center; gap: 10px; padding: 12px 16px; min-height: 56px; width: 100%; text-align: start; }
.prow .tx { flex: 1; min-width: 0; }
.prow .tt { font-weight: 500; }
.prow .ts { font-size: 13px; color: var(--text2); }
.chev { color: var(--text3); flex: none; }
.days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.days .chip { padding: 0; justify-content: center; font-size: 12.5px; min-height: 36px; border-radius: 10px; }
.field { display: grid; gap: 6px; }
.field > label, .flabel { font-size: 13px; color: var(--text2); font-weight: 500; }
.form { display: grid; gap: 14px; }
.seg { display: flex; background: var(--card2); border-radius: 10px; padding: 2px; gap: 2px; }
.seg button { flex: 1; min-height: 36px; border-radius: 8px; font-size: 14px; color: var(--text); }
.seg button.on { background: var(--card); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); font-weight: 600; }
@media (prefers-color-scheme: dark) { .seg button.on { background: #48484d; } }
.inline { display: flex; gap: 8px; align-items: center; }
.inline > * { flex: 1; }
.subrow { display: grid; gap: 8px; padding: 12px 16px; }

/* شريط التبويب */
.tabbar { position: fixed; inset-inline: 0; bottom: 0; z-index: 20; background: var(--card); background: color-mix(in srgb, var(--card) 88%, transparent); -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px); border-top: .5px solid var(--sep); padding-bottom: var(--sab); }
.tabbar nav { max-width: 560px; margin: 0 auto; display: grid; grid-template-columns: repeat(4, 1fr); height: var(--tabh); }
.tab { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 11px; color: var(--text3); font-weight: 500; }
.tab svg { width: 25px; height: 25px; }
.tab.on { color: var(--accent); }

/* الورقة السفلية */
.sheet-wrap { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, .32); animation: fade .2s ease; }
.sheet { position: relative; width: 100%; max-width: 560px; max-height: 92vh; overflow: auto; -webkit-overflow-scrolling: touch; background: var(--bg); border-radius: 16px 16px 0 0; padding: 8px 16px calc(var(--sab) + 20px); animation: up .25s ease; }
.sheet .grab { width: 36px; height: 5px; border-radius: 3px; background: var(--text3); margin: 2px auto 8px; opacity: .6; }
.sheet h3 { margin: 4px 0 12px; font-size: 20px; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; position: sticky; top: -8px; background: var(--bg); padding: 6px 0; z-index: 2; }
@keyframes up { from { transform: translateY(30px); opacity: .6; } to { transform: none; opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.review-item { padding: 12px 16px; display: grid; gap: 8px; }
.review-item .hd { display: flex; justify-content: space-between; gap: 8px; }
.review-item .why { font-size: 13px; color: var(--text2); }

/* الإشعار المؤقت */
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--tabh) + var(--sab) + 14px); z-index: 60; max-width: calc(100% - 40px); width: max-content; background: var(--text); color: var(--bg); padding: 11px 16px; border-radius: 14px; font-size: 14.5px; box-shadow: var(--shadow); animation: fade .2s ease; text-align: center; }

.center { text-align: center; }
.mt { margin-top: 10px; }
.mt2 { margin-top: 18px; }
.hide { display: none !important; }
.ltr { direction: ltr; unicode-bidi: isolate; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* الحقول داخل الورقة السفلية تحتاج تباينًا مع خلفيتها */
.sheet .field input, .sheet .field select, .sheet .field textarea, .sheet .seg, .sheet .btn.plain { background: var(--card); }
.sheet .seg button.on { background: var(--tint2); color: var(--accent); box-shadow: none; }
