:root {
  --primary: #6300ff;
  --primary-2: #7d2cff;
  --primary-soft: #efe6ff;
  --bg: #f6f6fa;
  --surface: #ffffff;
  --surface-2: #f0f0f5;
  --text: #111116;
  --muted: #6e6e7a;
  --border: #e4e4eb;
  --success: #16a36a;
  --success-soft: #e7f8f0;
  --danger: #de3f50;
  --danger-soft: #fff0f2;
  --shadow: 0 18px 45px rgba(28, 20, 45, .08);
  --shadow-soft: 0 8px 24px rgba(24, 18, 38, .06);
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 17px;
  --safe-bottom: max(14px, env(safe-area-inset-bottom));
}

[data-theme="dark"] {
  --bg: #0f0f13;
  --surface: #18181e;
  --surface-2: #222229;
  --text: #f6f4fb;
  --muted: #aaa6b5;
  --border: #2f2e38;
  --primary-soft: #2a1748;
  --success-soft: #173329;
  --danger-soft: #351b21;
  --shadow: 0 18px 45px rgba(0, 0, 0, .24);
  --shadow-soft: 0 8px 24px rgba(0, 0, 0, .18);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Tajawal", system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; }
button { color: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid rgba(99, 0, 255, .25); outline-offset: 2px; }
svg { display: block; }

#app { min-height: 100vh; }
.app-shell { min-height: 100vh; padding-bottom: calc(96px + var(--safe-bottom)); }
.main-content { width: min(100%, 760px); margin: 0 auto; padding: 18px 18px 24px; }
.page { animation: pageIn .28s ease both; }
@keyframes pageIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.boot-screen {
  min-height: 100vh;
  display: grid;
  place-content: center;
  text-align: center;
  gap: 8px;
}
.boot-logo, .onboarding-logo {
  width: 82px;
  height: 82px;
  margin: 0 auto;
  border-radius: 25px;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 42px;
  font-weight: 900;
  background: linear-gradient(145deg, var(--primary), #8e4cff);
  box-shadow: 0 20px 45px rgba(99, 0, 255, .28);
}
.boot-screen h1 { margin: 12px 0 0; font-size: 30px; }
.boot-screen p { margin: 0; color: var(--muted); }
.boot-loader { width: 56px; height: 5px; background: var(--surface-2); border-radius: 99px; margin: 18px auto 0; overflow: hidden; }
.boot-loader::after { content: ""; display: block; width: 45%; height: 100%; border-radius: inherit; background: var(--primary); animation: loading 1s ease-in-out infinite alternate; }
@keyframes loading { from { transform: translateX(110%); } to { transform: translateX(-120%); } }

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: min(100%, 760px);
  margin: 0 auto;
  padding: max(13px, env(safe-area-inset-top)) 18px 12px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 14px; background: var(--primary); color: #fff; font-size: 22px; font-weight: 900; box-shadow: 0 8px 20px rgba(99, 0, 255, .23); }
.brand strong { display: block; font-size: 18px; }
.brand small { display: block; color: var(--muted); font-size: 11px; margin-top: 2px; }
.top-actions { display: flex; align-items: center; gap: 8px; }
.icon-btn, .more-btn {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 14px;
  display: grid;
  place-items: center;
  cursor: pointer;
}
.icon-btn { width: 42px; height: 42px; }
.icon-btn svg { width: 20px; height: 20px; }
.streak-pill { height: 42px; padding: 0 12px; border: 1px solid var(--border); background: var(--surface); border-radius: 14px; display: flex; align-items: center; gap: 6px; font-weight: 800; }
.streak-pill svg { width: 17px; color: #ef8b24; fill: rgba(239,139,36,.12); }

.page-title-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin: 10px 0 18px; }
.page-title-row h1 { margin: 4px 0 4px; font-size: clamp(27px, 6vw, 36px); line-height: 1.15; letter-spacing: -.5px; }
.page-title-row p { margin: 0; color: var(--muted); line-height: 1.6; }
.eyebrow { display: inline-block; color: var(--primary); font-size: 12px; font-weight: 800; letter-spacing: .2px; }
.day-score { min-width: 78px; padding: 13px 12px; border-radius: 20px; background: var(--surface); border: 1px solid var(--border); text-align: center; box-shadow: var(--shadow-soft); }
.day-score strong { display: block; font-size: 22px; }
.day-score small { color: var(--muted); }

.today-hero {
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 190px;
  padding: 24px;
  border-radius: var(--radius-xl);
  color: #fff;
  background:
    radial-gradient(circle at 8% 4%, rgba(255,255,255,.22), transparent 28%),
    radial-gradient(circle at 90% 110%, rgba(255,255,255,.18), transparent 34%),
    linear-gradient(135deg, #5300db, #7b24ff 60%, #8e48ff);
  box-shadow: 0 24px 50px rgba(99,0,255,.22);
}
.today-hero::after { content: ""; position: absolute; width: 180px; height: 180px; border: 1px solid rgba(255,255,255,.16); border-radius: 50%; left: -75px; top: -90px; }
.hero-copy { position: relative; z-index: 1; max-width: 410px; }
.hero-copy > span { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 800; color: rgba(255,255,255,.82); }
.hero-copy > span svg { width: 16px; }
.hero-copy h2 { margin: 12px 0 7px; font-size: clamp(25px, 6vw, 34px); }
.hero-copy p { margin: 0; color: rgba(255,255,255,.78); line-height: 1.7; }
.ring {
  --progress: 0deg;
  flex: 0 0 auto;
  width: 106px;
  height: 106px;
  border-radius: 50%;
  padding: 8px;
  background: conic-gradient(#fff var(--progress), rgba(255,255,255,.18) 0);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.08);
}
.ring > div { width: 100%; height: 100%; border-radius: 50%; display: grid; place-content: center; text-align: center; background: rgba(83,0,219,.88); backdrop-filter: blur(8px); }
.ring strong { font-size: 28px; line-height: 1; }
.ring small { margin-top: 4px; color: rgba(255,255,255,.72); }

.quick-start { display: grid; gap: 10px; margin: 16px 0 25px; }
.quick-start button {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 18px;
  padding: 13px 14px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  text-align: right;
  cursor: pointer;
  box-shadow: var(--shadow-soft);
}
.quick-start button > svg { width: 18px; color: var(--muted); transform: rotate(180deg); }
.step-number { width: 36px; height: 36px; border-radius: 12px; display: grid; place-items: center; color: var(--primary); background: var(--primary-soft); font-weight: 900; }
.quick-start strong, .quick-start small { display: block; }
.quick-start strong { font-size: 15px; }
.quick-start small { color: var(--muted); margin-top: 2px; }

.section-block { margin-top: 28px; scroll-margin-top: 84px; }
.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.section-head h2 { margin: 0 0 3px; font-size: 21px; }
.section-head p { margin: 0; color: var(--muted); font-size: 13px; }
.text-btn { border: 0; background: transparent; color: var(--primary); font-weight: 800; cursor: pointer; padding: 6px; }

.task-list, .goal-list { display: grid; gap: 11px; }
.task-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 19px;
  background: var(--surface);
  box-shadow: var(--shadow-soft);
  transition: transform .18s ease, opacity .18s ease, border-color .18s ease;
}
.task-card:active { transform: scale(.99); }
.task-card.done { opacity: .72; background: color-mix(in srgb, var(--success-soft) 42%, var(--surface)); border-color: color-mix(in srgb, var(--success) 24%, var(--border)); }
.task-card.done .task-copy strong { text-decoration: line-through; }
.task-check {
  position: relative;
  width: 48px;
  height: 48px;
  border-radius: 16px;
  border: 1px solid color-mix(in srgb, var(--primary) 28%, var(--border));
  background: color-mix(in srgb, var(--primary) 9%, var(--surface));
  color: var(--primary);
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, #fff 38%, transparent);
  transition: transform .18s ease, color .18s ease, background .18s ease, border-color .18s ease, box-shadow .18s ease;
}
.task-check:hover { transform: translateY(-1px); border-color: color-mix(in srgb, var(--primary) 55%, var(--border)); background: color-mix(in srgb, var(--primary) 14%, var(--surface)); }
.task-check:active { transform: scale(.94); }
.task-card.done .task-check { border-color: var(--success); background: var(--success); color: #fff; box-shadow: 0 7px 18px color-mix(in srgb, var(--success) 24%, transparent); }
.task-main-icon { display: grid; place-items: center; }
.task-main-icon svg { width: 23px; height: 23px; }
.task-check-hint {
  position: absolute;
  inset-inline-start: -4px;
  bottom: -4px;
  width: 19px;
  height: 19px;
  border: 3px solid var(--surface);
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: grid;
  place-items: center;
  font-family: Arial, sans-serif;
  font-size: 10px;
  font-weight: 900;
  line-height: 1;
  box-shadow: 0 3px 8px color-mix(in srgb, var(--primary) 24%, transparent);
}
.task-copy { min-width: 0; }
.task-copy strong { display: block; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.task-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 10px; margin-top: 6px; color: var(--muted); font-size: 11px; }
.task-meta span { display: inline-flex; align-items: center; gap: 3px; }
.task-meta svg { width: 13px; height: 13px; }
.task-status { color: var(--muted); font-size: 11px; font-weight: 700; }
.task-card.done .task-status { color: var(--success); }
.more-btn { width: 38px; height: 38px; }
.more-btn svg { width: 19px; }

.goal-card { padding: 17px; border-radius: 22px; border: 1px solid var(--border); background: var(--surface); box-shadow: var(--shadow-soft); }
.goal-card.complete { background: color-mix(in srgb, var(--success-soft) 35%, var(--surface)); }
.goal-top { display: grid; grid-template-columns: auto 1fr auto; gap: 11px; align-items: center; }
.goal-icon { width: 45px; height: 45px; display: grid; place-items: center; border-radius: 15px; background: var(--primary-soft); font-size: 21px; }
.goal-copy { min-width: 0; }
.goal-copy strong, .goal-copy small { display: block; }
.goal-copy strong { font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.goal-copy small { margin-top: 3px; color: var(--muted); }
.goal-percent { font-size: 18px; font-weight: 900; color: var(--primary); }
.progress-track { height: 10px; margin: 15px 0 13px; border-radius: 99px; overflow: hidden; background: var(--surface-2); }
.progress-track span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--primary), #9b5cff); transition: width .45s cubic-bezier(.2,.8,.2,1); }
.goal-bottom { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.quick-progress { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; }
.quick-progress > span { color: var(--muted); font-size: 12px; }
.quick-progress button { min-width: 42px; height: 35px; border: 0; border-radius: 11px; background: var(--primary-soft); color: var(--primary); font-weight: 900; cursor: pointer; }
.quick-progress .custom-progress { padding: 0 11px; color: var(--text); background: var(--surface-2); font-weight: 700; }
.goal-complete-message { display: flex; align-items: center; gap: 7px; color: var(--success); font-weight: 800; }
.goal-complete-message svg { width: 19px; }

.how-card { margin-top: 26px; padding: 15px; border: 1px dashed color-mix(in srgb, var(--primary) 35%, var(--border)); border-radius: 20px; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; background: color-mix(in srgb, var(--primary-soft) 36%, var(--surface)); }
.how-icon { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 14px; background: var(--primary); color: #fff; }
.how-card strong { display: block; }
.how-card p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }

.routine-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.routine-grid article { min-width: 0; padding: 15px; border: 1px solid var(--border); background: var(--surface); border-radius: 20px; box-shadow: var(--shadow-soft); }
.routine-icon, .setting-icon, .choice-icon { display: grid; place-items: center; border-radius: 14px; }
.routine-icon { width: 42px; height: 42px; margin-bottom: 13px; }
.purple { color: var(--primary); background: var(--primary-soft); }
.dark { color: var(--text); background: var(--surface-2); }
.green { color: var(--success); background: var(--success-soft); }
.routine-grid small, .routine-grid strong, .routine-grid em { display: block; }
.routine-grid small { color: var(--muted); }
.routine-grid strong { margin-top: 5px; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.routine-grid em { margin-top: 5px; color: var(--muted); font-style: normal; font-size: 11px; }

.stats-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.stats-grid article { padding: 16px; border: 1px solid var(--border); border-radius: 20px; background: var(--surface); box-shadow: var(--shadow-soft); }
.stats-grid article > span { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 12px; color: var(--primary); background: var(--primary-soft); }
.stats-grid article > span svg { width: 19px; }
.stats-grid strong { display: block; margin-top: 12px; font-size: 26px; }
.stats-grid small { color: var(--muted); }
.report-card { margin-top: 18px; padding: 18px; border: 1px solid var(--border); border-radius: 22px; background: var(--surface); box-shadow: var(--shadow-soft); }
.week-bars { height: 205px; display: grid; grid-template-columns: repeat(7, 1fr); align-items: end; gap: 8px; padding-top: 10px; }
.week-day { display: grid; grid-template-rows: 145px auto auto; gap: 5px; text-align: center; }
.week-bar { height: 145px; display: flex; align-items: flex-end; border-radius: 12px; overflow: hidden; background: var(--surface-2); }
.week-bar span { width: 100%; border-radius: 10px 10px 0 0; background: linear-gradient(180deg, #9e65ff, var(--primary)); }
.week-day small { font-weight: 700; }
.week-day em { color: var(--muted); font-style: normal; font-size: 10px; }

.settings-list { display: grid; gap: 9px; }
.settings-list > button, .choice-list > button {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface);
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 12px 13px;
  text-align: right;
  cursor: pointer;
  box-shadow: var(--shadow-soft);
}
.setting-icon, .choice-icon { width: 43px; height: 43px; }
.setting-icon svg, .choice-icon svg { width: 20px; }
.settings-list strong, .settings-list small, .choice-list strong, .choice-list small { display: block; }
.settings-list small, .choice-list small { color: var(--muted); margin-top: 3px; }
.settings-list > button > svg, .choice-list > button > svg { width: 18px; color: var(--muted); transform: rotate(180deg); }
.storage-card { display: flex; align-items: flex-start; gap: 12px; margin-top: 18px; padding: 15px; border-radius: 18px; color: var(--success); background: var(--success-soft); }
.storage-card > span { flex: 0 0 auto; }
.storage-card strong, .storage-card small { display: block; }
.storage-card small { margin-top: 3px; color: color-mix(in srgb, var(--success) 70%, var(--muted)); line-height: 1.5; }
.danger-link { display: block; margin: 22px auto 0; border: 0; background: transparent; color: var(--danger); cursor: pointer; }
.version { text-align: center; color: var(--muted); font-size: 11px; margin-top: 18px; }

.btn { min-height: 46px; padding: 0 16px; border-radius: 14px; border: 0; display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-weight: 800; cursor: pointer; }
.btn svg { width: 19px; }
.btn-primary { color: #fff; background: linear-gradient(135deg, var(--primary), var(--primary-2)); box-shadow: 0 12px 24px rgba(99,0,255,.22); }
.btn-surface { color: var(--text); background: var(--surface-2); border: 1px solid var(--border); box-shadow: none; }
.btn-danger { color: #fff; background: var(--danger); }
.btn-large { width: 100%; min-height: 54px; border-radius: 17px; font-size: 16px; }
.btn-small { min-height: 38px; padding: 0 12px; font-size: 12px; }
.btn-wide { width: 100%; margin-top: 11px; }

.empty-state { padding: 28px 18px; border: 1px dashed var(--border); border-radius: 22px; text-align: center; background: color-mix(in srgb, var(--surface) 65%, transparent); }
.empty-state > span { width: 50px; height: 50px; margin: 0 auto; display: grid; place-items: center; border-radius: 16px; color: var(--primary); background: var(--primary-soft); }
.empty-state h3 { margin: 13px 0 5px; }
.empty-state p { margin: 0 0 15px; color: var(--muted); }

.bottom-nav {
  position: fixed;
  z-index: 40;
  right: 50%;
  bottom: 0;
  transform: translateX(50%);
  width: min(100%, 760px);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  padding: 9px 12px var(--safe-bottom);
  border-top: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}
.nav-item { min-height: 56px; border: 0; background: transparent; color: var(--muted); display: grid; place-content: center; gap: 3px; cursor: pointer; }
.nav-item svg { width: 21px; margin: 0 auto; }
.nav-item span { font-size: 10px; font-weight: 700; }
.nav-item.active { color: var(--primary); }
.nav-item.active svg { stroke-width: 2.5; }
.fab { position: fixed; z-index: 45; right: max(18px, calc((100vw - 760px) / 2 + 18px)); bottom: calc(79px + var(--safe-bottom)); width: 58px; height: 58px; border: 4px solid var(--bg); border-radius: 20px; display: grid; place-items: center; color: #fff; background: linear-gradient(145deg, var(--primary), #8c40ff); box-shadow: 0 16px 32px rgba(99,0,255,.3); cursor: pointer; }
.fab svg { width: 26px; height: 26px; }

.modal-layer { position: fixed; z-index: 100; inset: 0; display: flex; align-items: flex-end; justify-content: center; padding: 16px 12px max(12px, env(safe-area-inset-bottom)); background: rgba(10, 8, 16, .48); backdrop-filter: blur(7px); opacity: 0; transition: opacity .2s ease; }
.modal-layer.visible { opacity: 1; }
.sheet { width: min(100%, 620px); max-height: min(90vh, 820px); overflow-y: auto; overscroll-behavior: contain; padding: 20px; border: 1px solid var(--border); border-radius: 28px; background: var(--surface); box-shadow: 0 30px 80px rgba(0,0,0,.28); animation: sheetUp .3s cubic-bezier(.2,.8,.2,1) both; }
@keyframes sheetUp { from { transform: translateY(24px); opacity: .5; } to { transform: none; opacity: 1; } }
.sheet-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 15px; margin-bottom: 18px; }
.sheet-head h2 { margin: 4px 0 3px; font-size: 25px; }
.sheet-head p { margin: 0; color: var(--muted); line-height: 1.5; }
.compact-sheet { max-width: 470px; }
.choice-list, .menu-list { display: grid; gap: 9px; }
.menu-list button { min-height: 50px; padding: 0 14px; display: flex; align-items: center; gap: 10px; border-radius: 14px; border: 1px solid var(--border); background: var(--surface-2); cursor: pointer; font-weight: 700; }
.menu-list button svg { width: 20px; }
.menu-list .danger { color: var(--danger); background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 20%, var(--border)); }

.form-stack { display: grid; gap: 14px; }
.field { display: grid; gap: 7px; }
.field > span, .field-label { font-size: 13px; font-weight: 800; }
.field em { font-style: normal; color: var(--muted); font-weight: 500; }
.field input:not([type="range"]), .field select {
  width: 100%;
  min-height: 50px;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 0 13px;
  color: var(--text);
  background: var(--surface-2);
}
.field input::placeholder { color: color-mix(in srgb, var(--muted) 75%, transparent); }
.field small { color: var(--muted); }
.time-wrap { width: 100%; min-width: 0; min-height: 50px; padding: 0 13px; border: 1px solid var(--border); border-radius: 14px; display: flex; align-items: center; background: var(--surface-2); }
.time-wrap input { width: 100%; min-width: 0; border: 0 !important; padding: 0 !important; background: transparent !important; color: var(--text); }
.two-col { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.form-section-title { display: flex; align-items: center; justify-content: space-between; margin-top: 3px; padding-top: 4px; }
.form-section-title small { color: var(--muted); }
.day-picker { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.day-chip { aspect-ratio: 1; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); color: var(--muted); cursor: pointer; font-weight: 800; }
.day-chip.active { border-color: var(--primary); color: #fff; background: var(--primary); }
.conditional { display: none; }
.conditional.show { display: block; }
.big-number input { min-height: 74px !important; text-align: center; font-size: 30px; font-weight: 900; color: var(--primary) !important; }
.template-row { display: flex; gap: 7px; overflow-x: auto; padding-bottom: 8px; margin-top: -4px; margin-bottom: 10px; scrollbar-width: none; }
.template-row::-webkit-scrollbar { display: none; }
.template-row button { flex: 0 0 auto; min-height: 39px; border: 1px solid var(--border); border-radius: 13px; padding: 0 12px; background: var(--surface-2); cursor: pointer; font-weight: 700; }

.switch-row { min-height: 66px; padding: 12px; border: 1px solid var(--border); border-radius: 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px; background: var(--surface-2); }
.switch-row strong, .switch-row small { display: block; }
.switch-row small { color: var(--muted); margin-top: 3px; }
.switch-row input { width: 48px; height: 27px; accent-color: var(--primary); }
.sound-list { display: grid; gap: 8px; }
.sound-option { min-height: 64px; display: grid; grid-template-columns: auto auto 1fr auto; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 16px; background: var(--surface-2); }
.sound-option.selected { border-color: var(--primary); background: var(--primary-soft); }
.sound-option > input { position: absolute; opacity: 0; pointer-events: none; }
.sound-dot { width: 18px; height: 18px; border: 2px solid var(--border); border-radius: 50%; }
.sound-option.selected .sound-dot { border: 5px solid var(--primary); }
.sound-option strong, .sound-option small { display: block; }
.sound-option small { color: var(--muted); }
.sound-option button { width: 40px; height: 40px; border: 0; border-radius: 12px; display: grid; place-items: center; color: var(--primary); background: var(--surface); cursor: pointer; }
.sound-option button svg { width: 18px; }

.guide-list { display: grid; gap: 10px; }
.guide-list article { display: grid; grid-template-columns: auto 1fr; gap: 12px; padding: 13px; border: 1px solid var(--border); border-radius: 17px; background: var(--surface-2); }
.guide-list article > span { font-size: 22px; }
.guide-list strong { display: block; }
.guide-list p { margin: 4px 0 0; color: var(--muted); line-height: 1.6; font-size: 13px; }
.guide-example { margin: 13px 0; padding: 14px; border-radius: 17px; color: var(--primary); background: var(--primary-soft); }
.guide-example strong { display: block; margin-bottom: 7px; }
.guide-example ol { margin: 0; padding-right: 21px; color: var(--text); line-height: 1.8; }
.confirm-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }

.onboarding-mode { background: linear-gradient(145deg, #f7f3ff, #fff 45%, #f3f5fa); }
[data-theme="dark"] .onboarding-mode { background: var(--bg); }
.onboarding { min-height: 100vh; padding: 22px 16px; display: grid; place-items: center; }
.onboarding-card { width: min(100%, 560px); padding: 26px; border: 1px solid rgba(99,0,255,.12); border-radius: 32px; background: var(--surface); box-shadow: 0 28px 70px rgba(65,35,110,.13); }
.onboarding-logo { width: 70px; height: 70px; margin: 0 0 20px; font-size: 36px; }
.onboarding-card h1 { margin: 5px 0 8px; font-size: clamp(29px, 7vw, 40px); line-height: 1.15; }
.onboarding-card > p { margin: 0 0 20px; color: var(--muted); line-height: 1.7; }
.privacy-note { text-align: center; color: var(--muted); }

.toast-host { position: fixed; z-index: 200; top: max(16px, env(safe-area-inset-top)); right: 50%; transform: translateX(50%); width: min(calc(100% - 28px), 440px); display: grid; gap: 8px; pointer-events: none; }
.toast { opacity: 0; transform: translateY(-12px) scale(.98); transition: .22s ease; padding: 12px; border: 1px solid var(--border); border-radius: 17px; display: grid; grid-template-columns: auto 1fr; gap: 10px; align-items: center; background: var(--surface); box-shadow: 0 18px 50px rgba(0,0,0,.18); }
.toast.show { opacity: 1; transform: none; }
.toast > span { width: 36px; height: 36px; border-radius: 12px; display: grid; place-items: center; color: var(--success); background: var(--success-soft); font-weight: 900; }
.toast.error > span { color: var(--danger); background: var(--danger-soft); }
.toast.info > span { color: var(--primary); background: var(--primary-soft); }
.toast svg { width: 18px; }
.toast strong, .toast small { display: block; }
.toast small { margin-top: 2px; color: var(--muted); }

.confetti-host { position: fixed; z-index: 190; inset: 0; pointer-events: none; overflow: hidden; display: none; }
.confetti-host.active { display: block; }
.confetti-host i { position: absolute; top: -20px; left: var(--x); width: var(--size); height: calc(var(--size) * 1.8); border-radius: 3px; background: hsl(calc(var(--x) * 3.6), 85%, 58%); transform: rotate(var(--rotate)); animation: confetti 1.5s var(--delay) cubic-bezier(.18,.75,.4,1) forwards; }
@keyframes confetti { to { transform: translateY(105vh) rotate(calc(var(--rotate) + 540deg)); opacity: .4; } }

.fatal { min-height: 100vh; display: grid; place-content: center; gap: 10px; padding: 24px; text-align: center; }
.fatal > span { width: 65px; height: 65px; margin: 0 auto; border-radius: 20px; display: grid; place-items: center; color: var(--danger); background: var(--danger-soft); font-size: 30px; font-weight: 900; }
.fatal h1 { margin: 7px 0 0; }
.fatal p { color: var(--muted); }

@media (max-width: 560px) {
  .main-content { padding-inline: 13px; }
  .topbar { padding-inline: 13px; }
  .today-hero { min-height: 176px; padding: 20px; }
  .ring { width: 88px; height: 88px; }
  .ring strong { font-size: 24px; }
  .hero-copy h2 { font-size: 25px; }
  .routine-grid { grid-template-columns: 1fr; }
  .routine-grid article { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 12px; }
  .routine-icon { margin: 0; }
  .how-card { grid-template-columns: auto 1fr; }
  .how-card .btn { grid-column: 1 / -1; }
  .goal-bottom { align-items: flex-end; }
  .quick-progress > span { flex-basis: 100%; }
}

@media (max-width: 390px) {
  .today-hero { align-items: flex-start; }
  .ring { width: 78px; height: 78px; padding: 6px; }
  .ring strong { font-size: 21px; }
  .ring small { font-size: 10px; }
  .two-col { grid-template-columns: 1fr; }
  .page-title-row h1 { font-size: 27px; }
  .task-status { display: none; }
  .task-card { grid-template-columns: auto 1fr; }
  .task-card .more-btn { grid-column: 2; grid-row: 1; justify-self: end; }
  .task-card .task-copy { grid-column: 2; }
  .goal-top { grid-template-columns: auto 1fr; }
  .goal-percent { grid-column: 2; justify-self: start; font-size: 15px; }
  .day-picker { gap: 3px; }
  .day-chip { border-radius: 9px; font-size: 11px; }
}

/* ===== خُطوة 4.0 — خريطة الرحلة والمراحل ===== */
.level-pill {
  min-width: 68px;
  height: 42px;
  padding: 0 10px;
  border: 1px solid color-mix(in srgb, var(--primary) 20%, var(--border));
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--primary);
  background: var(--primary-soft);
  cursor: pointer;
}
.level-pill b { width: 23px; height: 23px; border-radius: 8px; display: grid; place-items: center; color: #fff; background: var(--primary); font-size: 12px; }
.level-pill span { font-size: 10px; font-weight: 800; }
.journey-number svg { width: 18px; height: 18px; }

.goal-milestones {
  position: relative;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  align-items: start;
  margin: -2px 0 15px;
}
.goal-milestones::before {
  content: "";
  position: absolute;
  top: 8px;
  right: 10%;
  left: 10%;
  height: 2px;
  background: var(--border);
}
.goal-milestones > span { position: relative; z-index: 1; display: grid; justify-items: center; gap: 4px; color: var(--muted); }
.goal-milestones i {
  width: 17px;
  height: 17px;
  border: 2px solid var(--border);
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--surface);
  font-family: Arial, sans-serif;
  font-size: 9px;
  font-style: normal;
  font-weight: 900;
}
.goal-milestones small { font-size: 9px; font-weight: 700; }
.goal-milestones .done i { border-color: var(--primary); background: var(--primary); }
.goal-milestones .done { color: var(--primary); }
.goal-milestones .current i { box-shadow: 0 0 0 5px color-mix(in srgb, var(--primary) 13%, transparent); }

.journey-page { padding-bottom: 12px; }
.journey-hero {
  position: relative;
  overflow: hidden;
  min-height: 190px;
  padding: 24px;
  border-radius: 30px;
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 20px;
  color: #fff;
  background:
    radial-gradient(circle at 10% 0%, rgba(255,255,255,.21), transparent 30%),
    radial-gradient(circle at 100% 100%, rgba(255,255,255,.12), transparent 38%),
    linear-gradient(145deg, #130526, #4d00be 52%, #741cff);
  box-shadow: 0 24px 55px rgba(62,0,155,.24);
}
.journey-hero::after { content: ""; position: absolute; width: 260px; height: 260px; border: 1px solid rgba(255,255,255,.11); border-radius: 50%; left: -130px; top: -130px; }
.journey-level-orb {
  position: relative;
  z-index: 1;
  width: 108px;
  height: 108px;
  border: 1px solid rgba(255,255,255,.28);
  border-radius: 34px;
  display: grid;
  place-content: center;
  text-align: center;
  background: rgba(255,255,255,.13);
  box-shadow: inset 0 0 0 7px rgba(255,255,255,.05), 0 18px 38px rgba(0,0,0,.2);
  backdrop-filter: blur(12px);
}
.journey-level-orb span { font-size: 48px; font-weight: 900; line-height: .9; }
.journey-level-orb small { margin-top: 8px; font-size: 9px; font-weight: 900; letter-spacing: 2px; color: rgba(255,255,255,.7); }
.journey-level-copy { position: relative; z-index: 1; min-width: 0; }
.eyebrow-light { font-size: 11px; font-weight: 800; color: rgba(255,255,255,.65); }
.journey-level-copy h2 { margin: 5px 0 5px; font-size: clamp(25px, 6vw, 34px); }
.journey-level-copy p { margin: 0; color: rgba(255,255,255,.72); line-height: 1.55; }
.level-progress { height: 9px; margin: 16px 0 7px; overflow: hidden; border-radius: 99px; background: rgba(255,255,255,.16); }
.level-progress span { display: block; height: 100%; border-radius: inherit; background: #fff; box-shadow: 0 0 16px rgba(255,255,255,.45); }
.journey-level-copy > small { color: rgba(255,255,255,.72); font-weight: 700; }

.journey-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 13px 0 0; }
.journey-summary article {
  min-width: 0;
  padding: 15px 12px;
  border: 1px solid var(--border);
  border-radius: 19px;
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 7px 9px;
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}
.journey-summary article > span { grid-row: 1 / 3; width: 38px; height: 38px; border-radius: 13px; display: grid; place-items: center; color: var(--primary); background: var(--primary-soft); }
.journey-summary svg { width: 18px; }
.journey-summary strong { font-size: 20px; line-height: 1; }
.journey-summary small { color: var(--muted); font-size: 10px; }
.viz-badge-like { flex: 0 0 auto; padding: 6px 10px; border-radius: 99px; color: var(--primary); background: var(--primary-soft); font-size: 12px; font-weight: 900; }

.journey-map-section { overflow: hidden; }
.journey-map {
  position: relative;
  max-width: 620px;
  margin: 4px auto 0;
  padding: 18px 0 6px;
}
.journey-map::before {
  content: "";
  position: absolute;
  top: 42px;
  bottom: 54px;
  right: 50%;
  width: 4px;
  transform: translateX(50%);
  border-radius: 99px;
  background: repeating-linear-gradient(to bottom, color-mix(in srgb, var(--primary) 45%, var(--border)) 0 12px, transparent 12px 21px);
}
.journey-stop {
  position: relative;
  min-height: 136px;
  display: grid;
  grid-template-columns: 1fr 84px 1fr;
  align-items: center;
}
.journey-stop .journey-node { grid-column: 2; justify-self: center; }
.journey-stop.right .journey-stop-copy { grid-column: 1; grid-row: 1; text-align: left; padding-left: 14px; }
.journey-stop.left .journey-stop-copy { grid-column: 3; grid-row: 1; text-align: right; padding-right: 14px; }
.journey-node {
  position: relative;
  z-index: 2;
  width: 70px;
  height: 70px;
  border: 6px solid var(--bg);
  border-radius: 25px;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: transform .2s ease, box-shadow .2s ease;
}
.journey-node:active { transform: scale(.94); }
.journey-node > span { width: 100%; height: 100%; border-radius: 19px; display: grid; place-items: center; font-size: 26px; }
.journey-node svg { width: 25px; height: 25px; }
.journey-stop.completed .journey-node > span { color: #fff; background: var(--success); box-shadow: 0 10px 22px color-mix(in srgb, var(--success) 30%, transparent); }
.journey-stop.current .journey-node { animation: currentStagePulse 2.4s ease-in-out infinite; }
.journey-stop.current .journey-node > span { color: #fff; background: linear-gradient(145deg, var(--primary), #8f47ff); box-shadow: 0 14px 30px rgba(99,0,255,.32); }
.journey-stop.locked .journey-node > span { color: var(--muted); background: var(--surface-2); border: 1px solid var(--border); }
@keyframes currentStagePulse { 50% { transform: translateY(-4px); filter: drop-shadow(0 8px 11px rgba(99,0,255,.18)); } }
.journey-stop-copy { min-width: 0; }
.journey-stop-copy small, .journey-stop-copy strong { display: block; }
.journey-stop-copy > small { margin-bottom: 3px; color: var(--primary); font-size: 10px; font-weight: 900; }
.journey-stop-copy strong { font-size: 16px; }
.journey-stop-copy p { margin: 4px 0 6px; color: var(--muted); font-size: 12px; line-height: 1.5; }
.journey-stop-copy em { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); font-size: 10px; font-style: normal; font-weight: 700; }
.journey-stop-copy em svg { width: 12px; height: 12px; }
.journey-stop-copy .stage-done { color: var(--success); }
.mini-stage-progress { height: 6px; overflow: hidden; border-radius: 99px; background: var(--surface-2); }
.mini-stage-progress span { display: block; height: 100%; border-radius: inherit; background: var(--primary); }

.achievement-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.achievement-card {
  position: relative;
  min-width: 0;
  min-height: 126px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 20px;
  display: grid;
  grid-template-columns: auto 1fr;
  align-content: start;
  gap: 10px;
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}
.achievement-card.locked { opacity: .68; background: color-mix(in srgb, var(--surface-2) 55%, var(--surface)); }
.achievement-medal { width: 48px; height: 48px; border-radius: 16px; display: grid; place-items: center; font-size: 24px; color: var(--muted); background: var(--surface-2); }
.achievement-card.unlocked .achievement-medal { background: linear-gradient(145deg, #fff2b9, #ffd057); box-shadow: inset 0 0 0 1px rgba(151,102,0,.12); }
.achievement-medal svg { width: 20px; }
.achievement-card strong, .achievement-card small { display: block; }
.achievement-card strong { padding-top: 4px; font-size: 14px; }
.achievement-card small { margin-top: 3px; color: var(--muted); font-size: 11px; }
.achievement-status { position: absolute; left: 12px; bottom: 12px; padding: 5px 8px; border-radius: 99px; color: var(--success); background: var(--success-soft); font-size: 9px; font-weight: 900; }
.achievement-progress { grid-column: 1 / -1; height: 6px; overflow: hidden; border-radius: 99px; background: var(--surface-2); }
.achievement-progress span { display: block; height: 100%; border-radius: inherit; background: var(--primary); }
.achievement-card em { grid-column: 1 / -1; color: var(--muted); font-size: 9px; font-style: normal; text-align: left; }
.journey-report { margin-top: 28px; }
.next-mission-card { margin-top: 14px; padding: 15px; border: 1px solid color-mix(in srgb, var(--primary) 18%, var(--border)); border-radius: 20px; display: grid; grid-template-columns: auto 1fr; gap: 12px; align-items: center; background: var(--primary-soft); }
.next-mission-card > span { width: 48px; height: 48px; border-radius: 16px; display: grid; place-items: center; color: #fff; background: var(--primary); font-size: 22px; }
.next-mission-card small, .next-mission-card strong { display: block; }
.next-mission-card small { color: var(--primary); font-size: 10px; font-weight: 900; }
.next-mission-card strong { margin-top: 2px; }
.next-mission-card p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }

.stage-sheet { text-align: right; }
.stage-detail-icon { width: 92px; height: 92px; margin: 6px auto 19px; border-radius: 30px; display: grid; place-items: center; font-size: 40px; }
.stage-detail-icon svg { width: 34px; height: 34px; }
.stage-detail-icon.current { color: #fff; background: linear-gradient(145deg, var(--primary), #8e46ff); box-shadow: 0 18px 36px rgba(99,0,255,.25); }
.stage-detail-icon.completed { color: #fff; background: var(--success); box-shadow: 0 18px 36px color-mix(in srgb, var(--success) 25%, transparent); }
.stage-detail-icon.locked { color: var(--muted); background: var(--surface-2); border: 1px solid var(--border); }
.stage-detail-progress { padding: 14px; border: 1px solid var(--border); border-radius: 17px; background: var(--surface-2); }
.stage-detail-progress > div:first-child { display: flex; justify-content: space-between; gap: 10px; }
.stage-detail-progress span { color: var(--muted); font-size: 12px; }
.stage-detail-progress .progress-track { margin: 10px 0 0; background: var(--surface); }
.stage-reward { margin: 10px 0; padding: 13px; border-radius: 17px; display: flex; align-items: center; gap: 10px; color: #7a5200; background: #fff4ca; }
[data-theme="dark"] .stage-reward { color: #ffd976; background: #362d12; }
.stage-reward > span { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; background: rgba(255,255,255,.55); }
.stage-reward svg { width: 19px; }
.stage-reward small, .stage-reward strong { display: block; }
.stage-reward small { font-size: 10px; opacity: .7; }
.stage-help { margin: 12px 0 16px; color: var(--muted); line-height: 1.65; font-size: 13px; }

.achievement-unlock-sheet { position: relative; overflow: hidden; padding-top: 30px; text-align: center; }
.unlock-close { position: absolute; top: 14px; left: 14px; z-index: 3; }
.unlock-rays { position: relative; width: 126px; height: 126px; margin: 8px auto 18px; display: grid; place-items: center; }
.unlock-rays::before { content: ""; position: absolute; inset: -25px; border-radius: 50%; background: repeating-conic-gradient(from 0deg, color-mix(in srgb, var(--primary) 18%, transparent) 0 10deg, transparent 10deg 22deg); animation: raysSpin 12s linear infinite; }
.unlock-rays::after { content: ""; position: absolute; inset: 9px; border-radius: 37px; background: linear-gradient(145deg, #fff1b7, #ffd158); box-shadow: 0 22px 45px rgba(226,161,15,.25); }
.unlock-rays span { position: relative; z-index: 1; font-size: 58px; }
@keyframes raysSpin { to { transform: rotate(360deg); } }
.achievement-unlock-sheet h2 { margin: 5px 0 4px; font-size: 28px; }
.achievement-unlock-sheet > p { margin: 0; color: var(--muted); }
.unlock-xp { width: fit-content; margin: 15px auto 18px; padding: 8px 12px; border-radius: 99px; display: flex; align-items: center; gap: 6px; color: var(--primary); background: var(--primary-soft); font-size: 12px; font-weight: 800; }
.unlock-xp svg { width: 15px; }

@media (max-width: 560px) {
  .help-top { display: none; }
  .journey-hero { min-height: 170px; padding: 19px; gap: 14px; }
  .journey-level-orb { width: 88px; height: 88px; border-radius: 27px; }
  .journey-level-orb span { font-size: 39px; }
  .journey-level-copy h2 { font-size: 25px; }
  .journey-level-copy p { font-size: 12px; }
  .journey-summary article { display: block; text-align: center; padding: 12px 5px; }
  .journey-summary article > span { width: 34px; height: 34px; margin: 0 auto 7px; }
  .journey-summary strong, .journey-summary small { display: block; }
  .journey-summary strong { font-size: 18px; }
  .journey-stop { grid-template-columns: 1fr 72px 1fr; min-height: 127px; }
  .journey-node { width: 62px; height: 62px; border-radius: 22px; }
  .journey-node > span { border-radius: 16px; font-size: 23px; }
  .journey-stop.right .journey-stop-copy { padding-left: 7px; }
  .journey-stop.left .journey-stop-copy { padding-right: 7px; }
  .journey-stop-copy strong { font-size: 14px; }
  .journey-stop-copy p { font-size: 10px; }
}

@media (max-width: 390px) {
  .level-pill { min-width: 56px; padding-inline: 7px; }
  .level-pill span { display: none; }
  .journey-hero { grid-template-columns: 76px 1fr; padding: 16px; }
  .journey-level-orb { width: 76px; height: 76px; border-radius: 23px; }
  .journey-level-orb span { font-size: 33px; }
  .journey-level-orb small { font-size: 7px; }
  .journey-level-copy p { display: none; }
  .level-progress { margin-top: 10px; }
  .achievement-grid { grid-template-columns: 1fr; }
  .journey-stop { grid-template-columns: 1fr 64px 1fr; }
  .journey-node { width: 56px; height: 56px; border-width: 5px; }
  .journey-stop-copy p { display: none; }
}
