:root {
  --bg: #F7F4FF;
  --bg2: #F3EEFF;
  --card: #FFFFFF;
  --card2: #F1EBFF;
  --line: #DDD0FB;
  --txt: #24124A;
  --mut: #5E4C86;
  --violet: #7C3AED;
  --violet2: #A78BFA;
  --violet-ink: #5B21B6;
  --lime: #B9F238;
  --lime2: #E6FBB8;
  --lime-line: #A3E635;
  --lime-ink: #3F6212;
  --amber-bg: #FFF3E0;
  --amber-line: #FDBA74;
  --amber-ink: #9A3412;
  --grad: linear-gradient(135deg, #7C3AED 0%, #A855F7 100%);
  --grad-pink: linear-gradient(135deg, #7C3AED, #A855F7);
  --grad-cyan: linear-gradient(135deg, #C6F432, #A3E635);
  --grad-lime: linear-gradient(135deg, #DCCBFF, #D9F99D);
  --shadow: 0 10px 28px -14px rgba(124, 58, 237, .35);
  --r: 22px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--txt); }
body {
  font-family: 'Baloo Bhaijaan 2', system-ui, -apple-system, 'Segoe UI', Tahoma, sans-serif;
  font-size: 17px; line-height: 1.45;
  min-height: 100vh;
  background:
    radial-gradient(520px 380px at 105% -8%, rgba(185, 242, 56, .45), transparent 62%),
    radial-gradient(520px 420px at -12% 28%, rgba(167, 139, 250, .28), transparent 62%),
    var(--bg);
  background-attachment: fixed;
  overscroll-behavior-y: none;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
h1, h2, h3, p { margin: 0; }
#view { max-width: 560px; margin: 0 auto; padding: calc(var(--safe-t) + 18px) 16px calc(var(--safe-b) + 110px); }
body.in-workout #view { padding-bottom: calc(var(--safe-b) + 140px); }

/* التنقل */
#nav {
  position: fixed; bottom: 0; inset-inline: 0; z-index: 20;
  display: flex; justify-content: space-around;
  padding: 8px 8px calc(var(--safe-b) + 8px);
  background: rgba(255, 255, 255, .94); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
}
#nav button { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 13px; color: var(--mut); padding: 4px 0; border-radius: 14px; }
#nav button span { font-size: 22px; line-height: 1; filter: grayscale(.5); opacity: .8; }
#nav button.on { color: var(--violet-ink); font-weight: 800; }
#nav button.on span { filter: none; opacity: 1; transform: scale(1.12); }
body.in-workout #nav { display: none; }

/* عناصر عامة */
.card { background: var(--card); border-radius: var(--r); padding: 16px; margin-bottom: 14px; border: 1px solid var(--line); box-shadow: var(--shadow); }
.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; padding: 16px 18px; border-radius: 18px;
  background: var(--grad); color: #fff; font-weight: 800; font-size: 21px;
  box-shadow: 0 10px 26px -8px rgba(124, 58, 237, .55);
  transition: transform .1s;
}
.btn:active { transform: scale(.97); }
.btn.alt { background: var(--card2); color: var(--violet-ink); box-shadow: none; font-size: 18px; }
.btn.small { width: auto; padding: 10px 16px; font-size: 16px; border-radius: 14px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 999px; background: var(--card2); color: var(--violet-ink); font-weight: 700; font-size: 15px; }
.row { display: flex; align-items: center; gap: 10px; }
.between { justify-content: space-between; }
.mut { color: var(--mut); }
.big-title { font-size: 30px; font-weight: 800; line-height: 1.2; }
.sec-title { font-size: 20px; font-weight: 800; margin: 22px 4px 10px; }
.grad-txt { background: linear-gradient(90deg, #7C3AED, #65A30D); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* الرئيسية */
.hello { margin-bottom: 18px; }
.hello .big-title { margin-top: 2px; }
.logo { font-size: 16px; font-weight: 800; letter-spacing: .5px; }
.week { display: flex; align-items: center; gap: 14px; }
.dots { display: flex; gap: 8px; flex: 1; }
.dot { flex: 1; height: 14px; border-radius: 999px; background: var(--card2); border: 1px solid var(--line); }
.dot.on { background: var(--lime); border-color: var(--lime-line); box-shadow: 0 0 12px rgba(163, 230, 53, .6); }
.flame { text-align: center; min-width: 72px; }
.flame b { display: block; font-size: 30px; line-height: 1; color: var(--violet-ink); }
.flame small { font-size: 13px; color: var(--mut); }
.next { position: relative; overflow: hidden; border: 0; padding: 20px; }
.next::before { content: ''; position: absolute; inset: 0; z-index: 0; }
.next > * { position: relative; z-index: 1; }
.theme-pink.next { color: #fff; }
.theme-pink.next::before { background: var(--grad-pink); }
.theme-cyan.next::before { background: var(--grad-cyan); }
.theme-lime.next::before { background: var(--grad-lime); }
.theme-cyan.next, .theme-lime.next { color: var(--txt); }
.next .tag { font-size: 15px; font-weight: 700; opacity: .9; }
.next h2 { font-size: 34px; font-weight: 800; line-height: 1.15; margin: 2px 0 8px; }
.next ul { margin: 0 0 16px; padding: 0; list-style: none; display: flex; flex-wrap: wrap; gap: 6px; }
.next li { font-size: 14px; background: rgba(255, 255, 255, .35); padding: 3px 10px; border-radius: 999px; }
.next .btn { background: #fff; color: var(--violet-ink); box-shadow: 0 8px 22px -8px rgba(36, 18, 74, .35); }
.day-pick { display: flex; gap: 8px; margin-bottom: 14px; }
.day-pick button { flex: 1; padding: 10px 6px; border-radius: 16px; background: var(--card); font-weight: 700; border: 2px solid var(--line); }
.day-pick button.on { border-color: var(--violet); background: var(--card2); color: var(--violet-ink); }
.banner { display: flex; gap: 12px; align-items: center; padding: 14px 16px; border-radius: 18px; margin-bottom: 14px; font-weight: 700; width: 100%; text-align: right; }
.banner.new { background: var(--card2); border: 1px solid var(--violet2); color: var(--violet-ink); }
.banner.resume { background: var(--grad); color: #fff; }
.banner.warn { background: var(--lime2); border: 1px solid var(--lime-line); color: var(--lime-ink); }
.banner .e { font-size: 28px; }
.motto { text-align: center; font-size: 18px; font-weight: 700; margin: 18px 0 6px; color: var(--violet-ink); }
.stats3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 12px; text-align: center; }
.stat b { display: block; font-size: 26px; font-weight: 800; line-height: 1.1; color: var(--violet-ink); }
.stat small { color: var(--mut); font-size: 13px; }

/* التمرين */
.wk-top {
  position: sticky; top: 0; z-index: 15; margin: calc(-18px - var(--safe-t)) -16px 12px; padding: calc(var(--safe-t) + 10px) 16px 10px;
  background: rgba(247, 244, 255, .95); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.wk-top .row { justify-content: space-between; }
.wk-top h2 { font-size: 22px; font-weight: 800; }
.wk-top .time { font-variant-numeric: tabular-nums; color: var(--mut); font-size: 15px; }
.icon-btn { width: 42px; height: 42px; border-radius: 14px; background: var(--card2); color: var(--violet-ink); font-size: 18px; display: grid; place-items: center; }
.bar { height: 10px; background: var(--card2); border-radius: 999px; overflow: hidden; margin-top: 10px; }
.bar i { display: block; height: 100%; background: linear-gradient(90deg, #A3E635, #7C3AED); border-radius: 999px; transition: width .4s; }
.check-card summary { list-style: none; display: flex; justify-content: space-between; align-items: center; font-weight: 800; font-size: 18px; cursor: pointer; }
.check-card summary::-webkit-details-marker { display: none; }
.check-card ul { list-style: none; padding: 0; margin: 12px 0 0; }
.check-card li { display: flex; gap: 12px; align-items: flex-start; padding: 8px 0; border-top: 1px solid #EEE7FF; font-size: 16px; }
.tick { flex: none; width: 28px; height: 28px; border-radius: 10px; border: 2px solid var(--line); display: grid; place-items: center; font-size: 16px; background: #fff; }
.tick.on { background: var(--lime); border-color: var(--lime-line); color: var(--lime-ink); font-weight: 800; }

.ex { padding: 0; overflow: hidden; }
.ex > header { display: flex; align-items: center; gap: 12px; padding: 14px 16px; cursor: pointer; }
.ex .num { flex: none; width: 36px; height: 36px; border-radius: 12px; background: var(--card2); color: var(--violet-ink); display: grid; place-items: center; font-weight: 800; }
.ex.done .num { background: var(--lime); color: var(--lime-ink); }
.ex .ttl { flex: 1; min-width: 0; }
.ex h3 { font-size: 19px; font-weight: 800; line-height: 1.25; }
.ex .ttl small { color: var(--mut); font-size: 14px; }
.ex .ttl small bdi { white-space: nowrap; }
.ex .cnt { font-weight: 800; font-size: 15px; color: var(--mut); }
.ex.done .cnt { color: var(--lime-ink); }
.ex .body { display: none; padding: 0 16px 16px; }
.ex.open .body { display: block; }
.ex.open { border-color: var(--violet2); box-shadow: 0 0 0 2px rgba(167, 139, 250, .35), 0 16px 36px -18px rgba(124, 58, 237, .55); }
.cue { font-size: 15px; background: var(--bg2); border-radius: 14px; padding: 10px 12px; margin-bottom: 10px; }
.last { font-size: 17px; margin-bottom: 8px; }
.last b { color: var(--violet-ink); }
.sug { display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 14px; font-weight: 800; font-size: 17px; margin-bottom: 12px; }
.sug.up { background: var(--lime2); color: var(--lime-ink); border: 1px solid var(--lime-line); }
.sug.same { background: var(--card2); color: var(--violet-ink); border: 1px solid var(--violet2); }
.sug.down { background: var(--amber-bg); color: var(--amber-ink); border: 1px solid var(--amber-line); }
.sug.first { background: var(--bg2); color: var(--violet-ink); border: 1px dashed var(--violet2); font-weight: 600; font-size: 15px; }
.set-head, .set { display: grid; grid-template-columns: 30px 1fr 1fr 52px; gap: 8px; align-items: center; }
.set-head.nw, .set.nw { grid-template-columns: 30px 1fr 52px; }
.set-head { font-size: 13px; color: var(--mut); text-align: center; margin-bottom: 6px; }
.set { margin-bottom: 8px; }
.set .n { font-weight: 800; text-align: center; color: var(--mut); }
.step { display: flex; align-items: center; background: var(--bg); border-radius: 14px; overflow: hidden; border: 1px solid var(--line); }
.step button { width: 38px; height: 48px; font-size: 22px; font-weight: 700; color: var(--violet); flex: none; }
.step button:active { background: var(--card2); }
.step input { width: 100%; min-width: 0; text-align: center; background: none; border: 0; font-size: 20px; font-weight: 800; height: 48px; padding: 0; font-variant-numeric: tabular-nums; outline: none; color: var(--txt); }
.chk { height: 48px; border-radius: 14px; background: #fff; font-size: 22px; font-weight: 800; color: var(--violet2); border: 2px solid var(--line); }
.set.done .chk { background: var(--lime); color: var(--lime-ink); border-color: var(--lime-line); }
.set.done .step { border-color: var(--lime-line); background: #F7FEE7; }
.ex-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.ex-actions button, .ex-actions a { padding: 8px 12px; border-radius: 12px; background: var(--card2); font-size: 14px; font-weight: 700; color: var(--violet-ink); text-decoration: none; }
.ex-actions .pain.on { background: var(--amber-bg); color: var(--amber-ink); }
.light-note { background: var(--amber-bg); border: 1px solid var(--amber-line); box-shadow: none; }
.link-btn { display: block; margin: 18px auto 0; color: var(--mut); text-decoration: underline; font-size: 15px; }

/* مؤقت الراحة */
#rest { position: fixed; z-index: 30; inset-inline: 12px; bottom: calc(var(--safe-b) + 12px); max-width: 536px; margin: 0 auto; border-radius: 22px; overflow: hidden; background: var(--grad); box-shadow: 0 16px 40px -10px rgba(124, 58, 237, .6); color: #fff; }
#rest[hidden] { display: none; }
.rest-in { display: flex; align-items: center; gap: 10px; padding: 12px 14px; }
.rest-lbl { font-weight: 700; font-size: 16px; }
#restT { flex: 1; font-size: 40px; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; text-align: center; }
#rest button { padding: 10px 12px; border-radius: 14px; background: rgba(255, 255, 255, .22); font-weight: 800; }
#rest button.ghost { background: rgba(0, 0, 0, .15); }
#restBar { display: block; height: 6px; background: var(--lime); transition: width .25s linear; }
#rest.go { background: var(--grad-cyan); color: var(--lime-ink); }

/* النافذة السفلية */
#sheet { position: fixed; inset: 0; z-index: 40; }
#sheet[hidden] { display: none; }
.sheet-bg { position: absolute; inset: 0; background: rgba(36, 18, 74, .45); }
.sheet-in { position: absolute; bottom: 0; inset-inline: 0; max-width: 560px; margin: 0 auto; max-height: 88vh; overflow: auto; background: #fff; border-radius: 28px 28px 0 0; padding: 20px 18px calc(var(--safe-b) + 22px); animation: up .25s ease-out; }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
.sheet-in h2 { font-size: 24px; font-weight: 800; margin-bottom: 14px; }
.faces { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.faces button { background: var(--bg2); border-radius: 18px; padding: 14px 10px; font-weight: 700; font-size: 16px; border: 2px solid transparent; }
.faces button span { display: block; font-size: 38px; line-height: 1.2; }
.faces button:active { border-color: var(--violet); }

/* النهاية */
.finish { text-align: center; padding-top: 30px; }
.finish .trophy { font-size: 86px; line-height: 1; animation: pop .6s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes pop { from { transform: scale(.2) rotate(-20deg); opacity: 0; } }
.finish h1 { font-size: 44px; font-weight: 800; margin: 8px 0 4px; }
.finish .stats3 { margin: 20px 0; }
.animal { font-size: 18px; font-weight: 700; margin: 6px 0 18px; color: var(--violet-ink); }
.pr { text-align: right; }
.pr li { margin: 6px 0; }

/* السجل والبرنامج */
.hist { cursor: pointer; }
.hist .day-badge { flex: none; width: 46px; height: 46px; border-radius: 15px; display: grid; place-items: center; font-weight: 800; font-size: 20px; }
.day-badge.theme-pink { background: var(--grad-pink); color: #fff; }
.day-badge.theme-cyan { background: var(--grad-cyan); color: var(--lime-ink); }
.day-badge.theme-lime { background: var(--grad-lime); color: var(--violet-ink); }
.hist .det { display: none; margin-top: 12px; border-top: 1px solid #EEE7FF; padding-top: 10px; font-size: 15px; }
.hist.open .det { display: block; }
.det p { margin: 4px 0; }
.prog-ex { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid #EEE7FF; cursor: pointer; }
.prog-ex:first-of-type { border-top: 0; }
.prog-ex small { color: var(--mut); }
.prog-ex .lw { font-weight: 800; color: var(--violet-ink); white-space: nowrap; }
.rules li { margin: 6px 0; }
.chart { width: 100%; height: 170px; display: block; margin: 6px 0 12px; }
.opt-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.opt-row button { padding: 9px 16px; border-radius: 14px; background: var(--card2); color: var(--violet-ink); font-weight: 700; border: 2px solid transparent; }
.opt-row button.on { border-color: var(--violet); background: var(--lime2); color: var(--lime-ink); }
.steps-list { padding-inline-start: 22px; margin: 8px 0 0; }
.steps-list li { margin: 6px 0; }
.empty { text-align: center; padding: 30px 10px; color: var(--mut); }
.empty b { display: block; font-size: 50px; }

#toast { position: fixed; z-index: 50; top: calc(var(--safe-t) + 14px); inset-inline: 16px; max-width: 520px; margin: 0 auto; background: var(--violet-ink); color: #fff; font-weight: 700; padding: 12px 16px; border-radius: 16px; text-align: center; box-shadow: 0 10px 30px rgba(36, 18, 74, .35); }
#toast[hidden] { display: none; }
#confetti { position: fixed; inset: 0; z-index: 45; pointer-events: none; width: 100%; height: 100%; }
#confetti[hidden] { display: none; }
