/* ===========================================================
   إنجاز — ورق وحرف يدوية
   =========================================================== */

*, *::before, *::after { box-sizing: border-box; }

:root{
  --bg:#F3EBDD;
  --bg-2:#EBE0CD;
  --card:#F8F1E4;
  --card-2:#F1E7D4;
  --sand:#E4D6BE;
  --track:#E0D2BA;
  --ink:#3A322B;
  --ink-2:#7A6A5B;
  --line:rgba(90,60,40,.13);
  --clay:#B85C38;
  --clay-deep:#9C4A2B;
  --olive:#6B7A4A;
  --olive-deep:#55633A;
  --gold:#D9A14A;
  --sage:#A8B79A;
  --cream:#FBF5EA;
  --danger:#A8462C;
  --shadow:0 12px 26px -18px rgba(90,60,40,.55);
  --shadow-sm:0 6px 14px -10px rgba(90,60,40,.55);
  --r:20px;
  --r-sm:14px;
  --nav:#F7EFE0;
  color-scheme: light;
}

[data-theme="dark"]{
  --bg:#1F1A16;
  --bg-2:#191410;
  --card:#2A231E;
  --card-2:#332B24;
  --sand:#3A312A;
  --track:#3B322A;
  --ink:#EFE4D4;
  --ink-2:#B7A793;
  --line:rgba(239,228,212,.11);
  --clay:#C0683F;
  --clay-deep:#A85632;
  --olive:#8A9A62;
  --olive-deep:#9DAD74;
  --gold:#E0B15E;
  --sage:#7E8F72;
  --cream:#241E19;
  --danger:#D2745A;
  --shadow:0 14px 30px -20px rgba(0,0,0,.9);
  --shadow-sm:0 8px 16px -12px rgba(0,0,0,.9);
  --nav:#221C17;
  color-scheme: dark;
}

html{ -webkit-text-size-adjust:100%; }

body{
  margin:0;
  min-height:100vh;
  background-color:var(--bg);
  background-image:
    radial-gradient(120% 70% at 100% 0%, rgba(217,161,74,.15), transparent 62%),
    radial-gradient(100% 60% at 0% 6%, rgba(168,183,154,.18), transparent 60%);
  background-attachment:fixed;
  color:var(--ink);
  font-family:'IBM Plex Sans Arabic', system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size:16px;
  line-height:1.6;
  -webkit-font-smoothing:antialiased;
  -webkit-tap-highlight-color:transparent;
  overscroll-behavior-y:contain;
}

body::after{
  content:'';
  position:fixed;
  inset:0;
  pointer-events:none;
  z-index:900;
  opacity:.045;
  background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)'/%3E%3C/svg%3E");
}

h1,h2,h3,h4{
  font-family:'Tajawal', 'IBM Plex Sans Arabic', system-ui, sans-serif;
  font-weight:700;
  margin:0;
  line-height:1.3;
}

p{ margin:0; }
ul{ margin:0; padding:0; list-style:none; }
button{ font-family:inherit; font-size:inherit; cursor:pointer; border:0; background:none; color:inherit; }
input, select{ font-family:inherit; font-size:16px; color:inherit; }
button, .tab, .check, .row-switch, .icon-btn{ user-select:none; -webkit-user-select:none; }

:focus-visible{
  outline:2.5px solid var(--clay);
  outline-offset:2px;
  border-radius:8px;
}

.hidden{ display:none !important; }

/* ---------- الهيكل ---------- */
.app-shell{
  max-width:640px;
  margin:0 auto;
  padding:0 16px 112px;
}

.topbar{
  position:sticky;
  top:0;
  z-index:40;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  margin:0 -16px;
  padding:14px 16px 10px;
  background:var(--bg);
  border-bottom:1px solid transparent;
  transition:border-color .25s ease, background .25s ease;
}
.topbar.is-stuck{ border-bottom-color:var(--line); }

.brand{ display:flex; align-items:center; gap:10px; min-width:0; }
.brand-mark{
  display:grid; place-items:center;
  width:40px; height:40px;
  border-radius:14px;
  background:var(--sand);
  color:var(--olive);
  border:1px solid var(--line);
  box-shadow:var(--shadow-sm);
  flex:0 0 auto;
}
.brand-mark svg{ width:22px; height:22px; }
.brand-text h1{ font-size:19px; letter-spacing:0; }
.brand-text p{ font-size:11.5px; color:var(--ink-2); line-height:1.3; }

.topbar-actions{ display:flex; gap:8px; flex:0 0 auto; }
.icon-btn{
  display:grid; place-items:center;
  width:44px; height:44px;
  border-radius:14px;
  background:var(--card);
  border:1px solid var(--line);
  color:var(--ink);
  box-shadow:var(--shadow-sm);
  transition:transform .15s ease, background .2s ease;
}
.icon-btn svg{ width:20px; height:20px; }
.icon-btn:active{ transform:scale(.94); background:var(--card-2); }
.icon-sun{ display:none; }
[data-theme="dark"] .icon-sun{ display:block; }
[data-theme="dark"] .icon-moon{ display:none; }

.main{ padding-top:8px; }

/* ---------- الأقسام ---------- */
.view{ display:block; animation:viewIn .32s ease both; }
@keyframes viewIn{ from{ opacity:0; transform:translateY(6px); } to{ opacity:1; transform:none; } }

.greet{ padding:6px 2px 14px; }
.greet-hello{ font-size:26px; font-weight:800; }
.greet-date{ font-size:13px; color:var(--ink-2); margin-top:2px; }

.section-head{ padding:4px 2px 14px; }
.section-head h2{ font-size:25px; font-weight:800; }
.section-head p{ font-size:13.5px; color:var(--ink-2); margin-top:4px; }

/* ---------- البطاقات ---------- */
.card{
  background:var(--card);
  color:var(--ink);
  border:1px solid var(--line);
  border-radius:var(--r);
  padding:16px;
  box-shadow:var(--shadow);
}

.card-title{
  font-size:16px;
  font-weight:700;
  display:flex;
  align-items:center;
  gap:7px;
}
.card-title::before{
  content:'';
  width:8px; height:8px;
  border-radius:50% 50% 50% 20%;
  background:var(--clay);
  flex:0 0 auto;
  transform:rotate(-12deg);
}
.card-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  margin-bottom:10px;
}

.hint{ font-size:12.5px; color:var(--ink-2); line-height:1.55; }
.hint b{ color:var(--ink); font-weight:600; }
.center{ text-align:center; }

.pill{
  font-size:11.5px;
  font-weight:600;
  padding:4px 10px;
  border-radius:999px;
  background:var(--sand);
  color:var(--ink);
  white-space:nowrap;
  border:1px solid var(--line);
}

.mini-bar{ height:7px; border-radius:999px; background:var(--track); overflow:hidden; margin:8px 0 4px; }
.mini-bar > i{ display:block; height:100%; width:0; border-radius:999px; background:var(--olive); transition:width .5s cubic-bezier(.22,1,.36,1); }

.progress{ height:10px; border-radius:999px; background:var(--track); overflow:hidden; border:1px solid var(--line); }
.progress > i{ display:block; height:100%; width:0; border-radius:999px; background:linear-gradient(90deg, var(--clay), #D08A5E); transition:width .45s cubic-bezier(.22,1,.36,1); }
[data-theme="dark"] .progress > i{ background:linear-gradient(90deg, var(--clay), #B4795C); }
.progress.olive > i{ background:linear-gradient(90deg, var(--olive), var(--sage)); }

/* ---------- الأزرار ---------- */
.btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:6px;
  min-height:46px;
  padding:0 18px;
  border-radius:14px;
  font-family:'Tajawal', sans-serif;
  font-weight:700;
  font-size:15px;
  border:1px solid transparent;
  transition:transform .14s ease, background .2s ease, color .2s ease, box-shadow .2s ease;
}
.btn:active{ transform:scale(.96); }
.btn:disabled{ opacity:.5; cursor:not-allowed; }

.btn-primary{
  background:var(--clay);
  color:var(--cream);
  box-shadow:0 10px 18px -12px rgba(184,92,56,.85);
}
.btn-primary:hover{ background:var(--clay-deep); }

.btn-ghost{
  background:transparent;
  color:var(--ink);
  border-color:var(--line);
}
.btn-ghost:hover{ background:var(--card-2); }

.btn-sand{
  background:var(--sand);
  color:var(--ink);
  border-color:var(--line);
}
.btn-danger{
  background:transparent;
  color:var(--danger);
  border-color:var(--line);
}
.btn-danger:active{ background:var(--card-2); }

.btn-lg{ min-height:56px; padding:0 30px; font-size:17px; border-radius:18px; }
.btn-square{ width:48px; min-width:48px; padding:0; }
.btn-square svg{ width:20px; height:20px; }
.w-full{ width:100%; }

/* ---------- الحقول ---------- */
input[type="text"], input[type="time"]{
  width:100%;
  min-height:48px;
  padding:0 14px;
  border-radius:14px;
  background:var(--card-2);
  border:1px solid var(--line);
  color:var(--ink);
  outline:none;
  transition:border-color .2s ease, background .2s ease;
}
input[type="text"]::placeholder{ color:var(--ink-2); }
input[type="text"]:focus, input[type="time"]:focus{ border-color:var(--clay); background:var(--card); }

.add-row{ display:flex; gap:8px; align-items:center; margin-top:12px; }
.add-row input{ flex:1 1 auto; min-width:0; }
.add-row .btn{ flex:0 0 auto; }

/* ---------- لوحة التحكم ---------- */
.dash-grid{ display:grid; gap:14px; }

.level-card{
  display:grid;
  grid-template-columns:auto auto 1fr;
  align-items:center;
  gap:12px;
  padding:16px 14px;
}
.mascot-wrap{ width:52px; flex:0 0 auto; }
.mascot{ width:100%; height:auto; display:block; transform-origin:50% 92%; animation:breathe 4.5s ease-in-out infinite; }
.mascot-leaves{ transform-box:view-box; transform-origin:40px 44px; transition:transform .5s cubic-bezier(.34,1.56,.64,1); }
@keyframes breathe{ 0%,100%{ transform:scale(1); } 50%{ transform:scale(1.035); } }
.mascot.hop{ animation:hop .65s cubic-bezier(.34,1.56,.64,1); }
@keyframes hop{
  0%{ transform:translateY(0) rotate(0); }
  35%{ transform:translateY(-9px) rotate(-4deg) scale(1.05); }
  70%{ transform:translateY(1px) rotate(3deg) scale(.98); }
  100%{ transform:translateY(0) rotate(0) scale(1); }
}
body.no-mascot .mascot-wrap{ display:none; }
body.no-mascot .level-card{ grid-template-columns:auto 1fr; }

.level-ring{ position:relative; width:66px; height:66px; flex:0 0 auto; }
.level-ring svg{ width:100%; height:100%; display:block; }
.lvl-track{ stroke:var(--track); }
.lvl-progress{ stroke:var(--clay); transition:stroke-dashoffset .6s cubic-bezier(.22,1,.36,1); }
.level-ring-label{
  position:absolute; inset:0;
  display:flex; flex-direction:column;
  align-items:center; justify-content:center;
  line-height:1;
}
.level-ring-label strong{ font-family:'Tajawal'; font-size:20px; font-weight:800; }
.level-ring-label small{ font-size:8.5px; color:var(--ink-2); margin-top:2px; }

.level-meta{ min-width:0; }
.rank-name{ font-family:'Tajawal'; font-size:16px; display:block; }
.points-line{ font-size:11.5px; color:var(--ink-2); margin-top:4px; }
.points-line b{ color:var(--clay); font-weight:700; }

.countdown-card{ position:relative; overflow:hidden; }
.countdown-head{
  display:flex; align-items:center; gap:7px;
  font-size:12.5px; font-weight:600; color:var(--ink-2);
}
.live-dot{
  width:8px; height:8px; border-radius:50%;
  background:var(--olive);
  box-shadow:0 0 0 0 rgba(107,122,74,.5);
  animation:pulse 2s infinite;
  flex:0 0 auto;
}
@keyframes pulse{
  0%{ box-shadow:0 0 0 0 rgba(107,122,74,.45); }
  70%{ box-shadow:0 0 0 9px rgba(107,122,74,0); }
  100%{ box-shadow:0 0 0 0 rgba(107,122,74,0); }
}
.countdown-time{
  font-family:'Tajawal';
  font-weight:800;
  font-size:40px;
  line-height:1.15;
  letter-spacing:.02em;
  font-variant-numeric:tabular-nums;
  color:var(--clay);
  margin:4px 0 2px;
}

.tasks-card .progress{ margin-bottom:12px; }

.task-list{ display:flex; flex-direction:column; gap:2px; }
.task{
  display:flex;
  align-items:center;
  gap:10px;
  padding:6px 4px;
  border-radius:12px;
  transition:background .2s ease;
}
.task + .task{ border-top:1px dashed var(--line); }
.task-title{ flex:1 1 auto; font-size:14.5px; line-height:1.45; min-width:0; word-break:break-word; }
.task.is-done .task-title{ color:var(--ink-2); text-decoration:line-through; text-decoration-thickness:1.5px; text-decoration-color:var(--sage); }

.check{
  flex:0 0 auto;
  display:grid; place-items:center;
  width:28px; height:28px;
  border-radius:9px;
  border:2px solid var(--sage);
  background:transparent;
  color:transparent;
  transition:transform .16s ease, background .2s ease, border-color .2s ease, color .2s ease;
  position:relative;
}
.check::after{ content:''; position:absolute; inset:-9px; }
.check svg{ width:16px; height:16px; }
.check:active{ transform:scale(.9); }
.task.is-done .check, .subtask.done .check{ background:var(--olive); border-color:var(--olive); color:var(--cream); }

.del{
  flex:0 0 auto;
  display:grid; place-items:center;
  width:32px; height:32px;
  border-radius:9px;
  color:var(--ink-2);
  background:transparent;
  transition:background .2s ease, color .2s ease;
}
.del svg{ width:14px; height:14px; }
.del:active{ background:var(--card-2); color:var(--clay); }

.empty-row{
  font-size:13px;
  color:var(--ink-2);
  padding:12px 4px;
  text-align:center;
  border:1px dashed var(--line);
  border-radius:12px;
}

.mini-grid{ display:grid; grid-template-columns:1fr 1fr; gap:14px; }
.mini-card{ padding:14px; display:flex; flex-direction:column; gap:2px; }
.mini-label{ font-size:11.5px; color:var(--ink-2); }
.mini-value{ font-family:'Tajawal'; font-size:22px; font-weight:800; }
.mini-foot{ font-size:10.5px; color:var(--ink-2); }

/* ---------- التركيز ---------- */
.focus-card{ display:flex; flex-direction:column; align-items:center; gap:18px; padding:22px 16px; }
.focus-ring{ position:relative; width:min(260px, 68vw); aspect-ratio:1/1; }
.focus-ring svg{ width:100%; height:100%; display:block; }
.ring-track{ stroke:var(--track); }
.ring-progress{
  stroke:var(--clay);
  stroke-dasharray:653.45;
  stroke-dashoffset:0;
  transition:stroke-dashoffset .28s linear, stroke .45s ease;
}
.focus-card.is-break .ring-progress{ stroke:var(--olive); }
.focus-card.is-break{ background:color-mix(in srgb, var(--olive) 9%, var(--card)); }
.focus-center{
  position:absolute; inset:0;
  display:flex; flex-direction:column;
  align-items:center; justify-content:center;
  gap:2px;
}
.focus-phase{ font-family:'Tajawal'; font-size:14px; font-weight:700; color:var(--olive); letter-spacing:.01em; }
.focus-card.is-break .focus-phase{ color:var(--olive-deep); }
.focus-card:not(.is-break) .focus-phase{ color:var(--clay); }
.focus-time{
  font-family:'Tajawal';
  font-size:clamp(40px, 13vw, 54px);
  font-weight:800;
  line-height:1.05;
  font-variant-numeric:tabular-nums;
  letter-spacing:.01em;
  color:var(--ink);
}
.focus-cycle{ font-size:12px; color:var(--ink-2); }

.focus-actions{ display:flex; align-items:center; gap:8px; width:100%; justify-content:center; }
.focus-actions .btn-lg{ min-width:120px; }

.focus-stats{ display:grid; grid-template-columns:1fr 1fr; gap:8px; text-align:center; margin-top:14px; }
.focus-stats strong{ display:block; font-family:'Tajawal'; font-size:24px; font-weight:800; color:var(--olive); }
.focus-stats span{ font-size:11.5px; color:var(--ink-2); }
.focus-stats > div + div{ border-inline-start:1px dashed var(--line); }

/* ---------- العادات ---------- */
.icon-picker{ display:flex; flex-wrap:wrap; gap:8px; }
.icon-opt{
  width:42px; height:42px;
  border-radius:13px;
  display:grid; place-items:center;
  font-size:19px;
  background:var(--card-2);
  border:2px solid transparent;
  transition:transform .14s ease, border-color .2s ease, background .2s ease;
}
.icon-opt:active{ transform:scale(.92); }
.icon-opt.is-active{ border-color:var(--clay); background:var(--sand); }

.habit-list{ display:flex; flex-direction:column; gap:12px; margin-top:14px; }
.habit-card{
  background:var(--card);
  border:1px solid var(--line);
  border-radius:var(--r);
  padding:14px;
  box-shadow:var(--shadow);
}
.habit-head{ display:flex; align-items:center; gap:10px; }
.habit-icon{
  width:40px; height:40px;
  border-radius:48% 52% 45% 55% / 52% 47% 53% 48%;
  display:grid; place-items:center;
  font-size:19px;
  background:var(--sand);
  flex:0 0 auto;
}
.habit-name{ flex:1 1 auto; font-family:'Tajawal'; font-size:15.5px; font-weight:700; min-width:0; word-break:break-word; }
.streak{
  flex:0 0 auto;
  display:flex; align-items:center; gap:3px;
  font-size:12px; font-weight:700;
  padding:3px 9px;
  border-radius:999px;
  background:color-mix(in srgb, var(--gold) 20%, transparent);
  color:var(--ink);
}
.streak.is-zero{ background:var(--card-2); color:var(--ink-2); }

.habit-foot{ display:flex; align-items:center; gap:10px; margin-top:12px; }
.dots{ display:flex; gap:5px; flex:1 1 auto; }
.dot{
  width:16px; height:16px;
  border-radius:50%;
  background:var(--track);
  border:1px solid var(--line);
  flex:0 0 auto;
}
.dot.on{ background:var(--olive); border-color:var(--olive); }
.dot.today{ box-shadow:0 0 0 2px color-mix(in srgb, var(--clay) 45%, transparent); }

.habit-toggle{
  flex:0 0 auto;
  min-height:40px;
  padding:0 14px;
  border-radius:12px;
  font-family:'Tajawal';
  font-weight:700;
  font-size:13.5px;
  background:var(--card-2);
  border:1px solid var(--line);
  color:var(--ink);
  transition:transform .14s ease, background .2s ease, color .2s ease;
}
.habit-toggle:active{ transform:scale(.95); }
.habit-toggle.is-done{ background:var(--olive); color:var(--cream); border-color:transparent; }

.chart-card{ margin-top:14px; }
.chart svg{ width:100%; height:auto; display:block; }
.chart-empty{ font-size:12.5px; color:var(--ink-2); text-align:center; padding:18px 6px; border:1px dashed var(--line); border-radius:12px; }

.hm-0{ fill:var(--track); }
.hm-1{ fill:#CBD4BE; }
.hm-2{ fill:var(--sage); }
.hm-3{ fill:var(--olive); }
.hm-4{ fill:#4E5C36; }
[data-theme="dark"] .hm-1{ fill:#3E4A33; }
[data-theme="dark"] .hm-2{ fill:#5A6B44; }
[data-theme="dark"] .hm-3{ fill:#8A9A62; }
[data-theme="dark"] .hm-4{ fill:#B4C489; }

.legend{ display:flex; align-items:center; gap:5px; justify-content:flex-end; margin-top:8px; font-size:10.5px; color:var(--ink-2); }
.legend i{ width:12px; height:12px; border-radius:3px; display:block; }

/* ---------- الأهداف ---------- */
.goal-list{ display:flex; flex-direction:column; gap:14px; margin-top:14px; }
.goal-card{ transition:border-color .3s ease, background .3s ease; }
.goal-card.is-done{ border-color:var(--olive); background:color-mix(in srgb, var(--olive) 8%, var(--card)); }
.goal-head{ display:flex; align-items:flex-start; justify-content:space-between; gap:10px; margin-bottom:10px; }
.goal-head h3{ font-size:17px; font-weight:700; min-width:0; word-break:break-word; }
.goal-pct{ font-family:'Tajawal'; font-size:14px; font-weight:800; color:var(--clay); flex:0 0 auto; }

.subtask-list{ display:flex; flex-direction:column; gap:1px; margin-top:12px; }
.subtask{
  display:flex; align-items:center; gap:9px;
  padding:5px 2px;
  border-radius:10px;
}
.subtask span{ flex:1 1 auto; font-size:13.5px; min-width:0; word-break:break-word; }
.subtask.done span{ color:var(--ink-2); text-decoration:line-through; text-decoration-color:var(--sage); }
.subtask .check{ width:24px; height:24px; border-radius:8px; }
.subtask .check svg{ width:14px; height:14px; }
.subtask .del{ width:28px; height:28px; }

.add-row.sm{ margin-top:8px; }
.add-row.sm input{ min-height:40px; font-size:14px; border-radius:11px; }
.add-row.sm .btn{ min-height:40px; min-width:40px; padding:0; font-size:18px; }

.goal-foot{ display:flex; align-items:center; justify-content:space-between; gap:10px; margin-top:12px; }
.badge-done{
  font-size:11.5px; font-weight:700;
  padding:3px 10px;
  border-radius:999px;
  background:var(--olive);
  color:var(--cream);
}
.link-danger{ font-size:12.5px; color:var(--ink-2); padding:8px 2px; text-decoration:underline; text-underline-offset:3px; }
.link-danger:active{ color:var(--danger); }

/* ---------- المكافآت ---------- */
.points-card{ text-align:center; padding:22px 16px; }
.points-big{ display:flex; align-items:baseline; justify-content:center; gap:6px; }
.points-big strong{
  font-family:'Tajawal'; font-size:52px; font-weight:800; line-height:1;
  color:var(--clay);
  font-variant-numeric:tabular-nums;
}
.points-big span{ font-size:13px; color:var(--ink-2); }
.points-rank{ font-family:'Tajawal'; font-size:15px; font-weight:700; color:var(--olive); margin:6px 0 12px; }

.rank-list{ display:flex; flex-direction:column; gap:8px; margin-top:10px; }
.rank-item{
  display:flex; align-items:center; gap:10px;
  padding:10px 12px;
  border-radius:14px;
  background:var(--card-2);
  border:1px solid transparent;
}
.rank-item.is-active{ border-color:var(--clay); background:color-mix(in srgb, var(--clay) 10%, var(--card)); }
.rank-item .rank-icon{ font-size:18px; }
.rank-item .rank-txt{ flex:1 1 auto; font-size:13.5px; font-weight:600; }
.rank-item .rank-min{ font-size:11.5px; color:var(--ink-2); }
.rank-item.is-active .rank-min{ color:var(--clay); font-weight:700; }

.badge-grid{ display:grid; grid-template-columns:repeat(4, minmax(0,1fr)); gap:10px; margin-top:12px; }
.badge-item{
  display:flex; flex-direction:column; align-items:center; gap:4px;
  padding:10px 4px;
  border-radius:14px;
  background:var(--card-2);
  border:1px solid var(--line);
  text-align:center;
}
.badge-item .b-icon{ font-size:20px; filter:grayscale(1); opacity:.4; }
.badge-item .b-name{ font-size:10px; line-height:1.25; color:var(--ink-2); }
.badge-item.on{ background:color-mix(in srgb, var(--gold) 18%, var(--card)); border-color:color-mix(in srgb, var(--gold) 55%, transparent); }
.badge-item.on .b-icon{ filter:none; opacity:1; }
.badge-item.on .b-name{ color:var(--ink); font-weight:600; }

.earn-list{ display:flex; flex-direction:column; gap:8px; margin-top:12px; }
.earn-list li{ display:flex; align-items:center; gap:10px; font-size:13.5px; }
.earn-num{
  font-family:'Tajawal'; font-weight:800; font-size:12.5px;
  min-width:44px; text-align:center;
  padding:2px 8px; border-radius:999px;
  background:color-mix(in srgb, var(--olive) 18%, transparent);
  color:var(--olive-deep);
  flex:0 0 auto;
}

/* ---------- الإعدادات ---------- */
.row-switch{
  display:flex; align-items:center; justify-content:space-between; gap:12px;
  padding:11px 2px;
  cursor:pointer;
}
.row-switch + .row-switch{ border-top:1px dashed var(--line); }
.row-switch > span:first-child{ font-size:14.5px; }

.row-switch input[type="checkbox"]{
  appearance:none; -webkit-appearance:none;
  width:48px; height:28px;
  border-radius:999px;
  background:var(--track);
  border:1px solid var(--line);
  position:relative;
  flex:0 0 auto;
  cursor:pointer;
  transition:background .22s ease;
  margin:0;
}
.row-switch input[type="checkbox"]::after{
  content:'';
  position:absolute;
  top:3px; inset-inline-start:3px;
  width:20px; height:20px;
  border-radius:50%;
  background:#FBF5EA;
  box-shadow:0 1px 3px rgba(0,0,0,.25);
  transition:transform .22s cubic-bezier(.34,1.4,.64,1);
}
.row-switch input[type="checkbox"]:checked{ background:var(--olive); border-color:var(--olive); }
.row-switch input[type="checkbox"]:checked::after{ transform:translateX(-20px); }

.time-input{ width:132px !important; min-height:42px !important; text-align:center; direction:ltr; }

.status-line{
  background:var(--card-2);
  border-radius:12px;
  padding:9px 12px;
  margin:6px 0 4px;
  border:1px solid var(--line);
}

.range-row{
  display:flex; align-items:center; gap:12px;
  padding:12px 2px 6px;
  border-top:1px dashed var(--line);
  margin-top:6px;
}
.range-row > span{ font-size:14px; flex:0 0 auto; }
.range-row b{ font-family:'Tajawal'; font-size:13px; min-width:26px; text-align:center; color:var(--clay); }
input[type="range"]{
  appearance:none; -webkit-appearance:none;
  flex:1 1 auto;
  height:6px;
  border-radius:999px;
  background:var(--track);
  outline:none;
}
input[type="range"]::-webkit-slider-thumb{
  appearance:none; -webkit-appearance:none;
  width:22px; height:22px; border-radius:50%;
  background:var(--clay);
  border:2px solid var(--card);
  box-shadow:0 2px 5px rgba(90,60,40,.35);
  cursor:pointer;
}
input[type="range"]::-moz-range-thumb{
  width:20px; height:20px; border-radius:50%;
  background:var(--clay); border:2px solid var(--card); cursor:pointer;
}
#testSound{ margin-top:12px; }

.app-foot{ text-align:center; font-size:11.5px; color:var(--ink-2); padding:22px 0 6px; }

/* ---------- شريط التنقل ---------- */
.tabbar{
  position:fixed;
  inset-inline:0;
  bottom:0;
  z-index:50;
  margin-inline:auto;
  max-width:640px;
  display:grid;
  grid-template-columns:repeat(5, 1fr);
  gap:2px;
  padding:7px 8px 9px;
  background:var(--nav);
  border-top:1px solid var(--line);
  box-shadow:0 -8px 24px -18px rgba(90,60,40,.6);
  backdrop-filter:blur(10px);
}
.tab{
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  gap:2px;
  min-height:52px;
  padding:4px 2px;
  border-radius:14px;
  color:var(--ink-2);
  font-family:'Tajawal';
  font-size:10.5px;
  font-weight:700;
  transition:color .2s ease, background .2s ease, transform .15s ease;
}
.tab svg{ width:21px; height:21px; }
.tab:active{ transform:scale(.94); }
.tab.is-active{ color:var(--clay); background:color-mix(in srgb, var(--clay) 10%, transparent); }

/* ---------- التوست ---------- */
.toast-host{
  position:fixed;
  inset-inline:0;
  bottom:86px;
  z-index:120;
  display:flex;
  flex-direction:column;
  align-items:center;
  gap:8px;
  padding:0 16px;
  pointer-events:none;
}
.toast{
  display:flex;
  align-items:center;
  gap:10px;
  max-width:420px;
  width:100%;
  padding:11px 14px;
  border-radius:16px;
  background:var(--ink);
  color:var(--bg);
  box-shadow:0 16px 30px -18px rgba(0,0,0,.6);
  font-size:13.5px;
  line-height:1.4;
  transform-origin:50% 100%;
  animation:toastIn .34s cubic-bezier(.34,1.4,.64,1) both;
}
.toast.out{ animation:toastOut .26s ease forwards; }
.toast .t-ico{ font-size:17px; flex:0 0 auto; }
.toast .t-txt{ display:flex; flex-direction:column; min-width:0; }
.toast .t-txt strong{ font-family:'Tajawal'; font-size:13.5px; font-weight:700; }
.toast .t-txt span{ font-size:11.5px; opacity:.78; }
.toast.gold{ background:var(--gold); color:#3A2A10; }
.toast.olive{ background:var(--olive); color:#FBF5EA; }
.toast.clay{ background:var(--clay); color:#FBF5EA; }
@keyframes toastIn{ from{ opacity:0; transform:translateY(18px) scale(.94); } to{ opacity:1; transform:none; } }
@keyframes toastOut{ to{ opacity:0; transform:translateY(10px) scale(.96); } }

.confetti-host{ position:fixed; inset:0; pointer-events:none; z-index:110; overflow:hidden; }
.particle{ position:absolute; width:9px; height:9px; border-radius:2px; will-change:transform, opacity; }

/* ---------- النافذة ---------- */
.modal-host{ position:fixed; inset:0; z-index:200; display:grid; place-items:center; padding:22px; }
.modal-backdrop{ position:absolute; inset:0; background:rgba(31,26,22,.55); backdrop-filter:blur(3px); animation:fadeIn .22s ease both; }
@keyframes fadeIn{ from{ opacity:0; } to{ opacity:1; } }
.modal{
  position:relative;
  width:100%;
  max-width:360px;
  background:var(--card);
  color:var(--ink);
  border-radius:22px;
  padding:22px 20px 18px;
  border:1px solid var(--line);
  box-shadow:0 28px 60px -28px rgba(0,0,0,.6);
  animation:modalIn .3s cubic-bezier(.34,1.4,.64,1) both;
}
@keyframes modalIn{ from{ opacity:0; transform:translateY(14px) scale(.96); } to{ opacity:1; transform:none; } }
.modal h3{ font-size:18px; margin-bottom:6px; }
.modal p{ font-size:13.5px; color:var(--ink-2); line-height:1.6; }
.modal-actions{ display:flex; gap:8px; margin-top:18px; }
.modal-actions .btn{ flex:1 1 0; }
.modal-actions .btn-danger{ border-color:color-mix(in srgb, var(--danger) 45%, transparent); }

/* ---------- الاستجابة ---------- */
@media (min-width:560px){
  .dash-grid{ grid-template-columns:1fr 1fr; align-items:start; }
  .level-card, .tasks-card{ grid-column:1 / -1; }
  .countdown-card{ grid-column:1 / -1; }
  .mini-grid{ grid-column:1 / -1; }
  .level-card{ grid-template-columns:auto auto 1fr; }
}

@media (min-width:900px){
  .app-shell{ max-width:1000px; padding-inline:28px; }
  .tabbar{ max-width:1000px; }
  .dash-grid{ grid-template-columns:1.25fr .75fr; gap:18px; }
  .level-card{ grid-column:1 / 2; }
  .countdown-card{ grid-column:2 / 3; align-self:stretch; display:flex; flex-direction:column; justify-content:center; }
  .tasks-card{ grid-column:1 / 2; }
  .mini-grid{ grid-column:2 / 3; grid-template-columns:1fr; }
  #view-goals .goal-list{ display:grid; grid-template-columns:1fr 1fr; align-items:start; }
  #view-habits{ display:grid; grid-template-columns:1fr 1fr; gap:14px; align-items:start; }
  #view-habits.hidden{ display:none !important; }
  #view-habits .section-head{ grid-column:1 / -1; }
  #view-habits > .card:first-of-type{ grid-column:1 / -1; }
  #view-habits .habit-list{ grid-column:1 / 2; margin-top:0; }
  #view-habits .chart-card{ grid-column:2 / 3; margin-top:0; }
  #view-habits .chart-card:last-child{ grid-column:1 / -1; }
  #view-rewards{ display:grid; grid-template-columns:1fr 1fr; gap:14px; align-items:start; }
  #view-rewards.hidden{ display:none !important; }
  #view-rewards .section-head, #view-rewards .points-card, #view-rewards .card:nth-of-type(4){ grid-column:1 / -1; }
  .focus-card{ padding:30px 16px; }
  .focus-ring{ width:300px; }
}

@media (max-width:360px){
  .level-card{ grid-template-columns:auto 1fr; }
  .level-card .mascot-wrap{ display:none; }
  .countdown-time{ font-size:34px; }
  .badge-grid{ grid-template-columns:repeat(3, minmax(0,1fr)); }
}

@media (prefers-reduced-motion: reduce){
  *, *::before, *::after{
    animation-duration:.001ms !important;
    animation-iteration-count:1 !important;
    transition-duration:.001ms !important;
  }
  .mascot{ animation:none; }
}