/* ═══════════ نبض — Design tokens ═══════════ */
:root {
  --bg: #05070d;
  --bg-2: #0a0e18;
  --surface: rgba(255, 255, 255, .045);
  --surface-2: rgba(255, 255, 255, .075);
  --border: rgba(255, 255, 255, .09);
  --border-strong: rgba(255, 255, 255, .18);
  --text: #f2f5fa;
  --muted: #8b94a8;
  --accent: #34e0c0;          /* أكوا هادئ */
  --accent-soft: rgba(52, 224, 192, .14);
  --accent-2: #6ea8ff;        /* نيون ثانوي */
  --accent-grad: linear-gradient(135deg, #34e0c0, #6ea8ff);
  --ok: #4ade80; --warn: #fbbf24; --danger: #f87171; --violet: #a78bfa;
  --r-sm: 10px; --r: 16px; --r-lg: 22px;
  --shadow: 0 6px 26px rgba(0, 0, 0, .45);
  --shadow-lg: 0 16px 50px rgba(0, 0, 0, .55);
  --ease: cubic-bezier(.22, .61, .36, 1);
  font-family: 'IBM Plex Sans Arabic', ui-sans-serif, system-ui, -apple-system, sans-serif;
  color-scheme: dark;
}

/* وضع الامتحان: لمسة حمراء دافئة */
:root[data-mode="exam"] { --accent: #ff9d6e; --accent-2: #fbbf24; --accent-soft: rgba(255, 157, 110, .15); --accent-grad: linear-gradient(135deg, #ff9d6e, #fbbf24); }
/* وضع التعافي: لمسة باردة */
:root[data-mode="recovery"] { --accent: #8ab4ff; --accent-2: #a78bfa; --accent-soft: rgba(138, 180, 255, .15); --accent-grad: linear-gradient(135deg, #8ab4ff, #a78bfa); }
/* وضع التمرين */
:root[data-mode="training"] { --accent: #34e0c0; --accent-2: #4ade80; }

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--bg); color: var(--text); line-height: 1.65;
  -webkit-font-smoothing: antialiased; overscroll-behavior-y: none;
  padding-bottom: calc(74px + env(safe-area-inset-bottom));
}
.glow {
  position: fixed; inset: -30% -20% auto -20%; height: 62vh; pointer-events: none; z-index: 0;
  background: radial-gradient(ellipse at 50% 0%, var(--accent-soft), transparent 62%);
  transition: background .6s var(--ease);
}
button { font-family: inherit; color: inherit; background: none; border: none; cursor: pointer; }
input, select, textarea { font-family: inherit; }
h1, h2, h3, h4 { line-height: 1.35; letter-spacing: -.01em; }
::selection { background: var(--accent); color: #04120f; }

/* ═══════════ Shell: topbar / mode bar / view / tabbar ═══════════ */
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center;
  justify-content: space-between; gap: .75rem; padding: .85rem 1rem .7rem;
  padding-top: calc(.85rem + env(safe-area-inset-top));
  background: rgba(5, 7, 13, .78); backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: .6rem; }
.brand-mark {
  display: grid; place-items: center; width: 34px; height: 34px; border-radius: 11px;
  background: var(--accent-soft); color: var(--accent);
}
.brand-name { font-size: 1.05rem; font-weight: 700; }
.brand-sub { font-size: .68rem; color: var(--muted); letter-spacing: .04em; }
.topbar-actions { display: flex; gap: .4rem; }
.icon-btn {
  display: grid; place-items: center; width: 38px; height: 38px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
  transition: transform .18s var(--ease), background .18s, box-shadow .18s;
}
.icon-btn:hover { transform: translateY(-2px); background: var(--surface-2); box-shadow: var(--shadow); }

.mode-bar {
  display: flex; align-items: center; gap: .55rem; margin: .8rem .9rem 0;
  padding: .7rem .9rem; border-radius: var(--r); font-size: .8rem;
  background: var(--accent-soft); border: 1px solid var(--border); color: var(--text);
  position: relative; z-index: 1; animation: fadeUp .4s var(--ease) both;
}
.mode-bar b { color: var(--accent); }

.view { padding: .9rem .9rem 1.4rem; position: relative; z-index: 1; max-width: 720px; margin: 0 auto; }

.tabbar {
  position: fixed; inset-inline: 0; bottom: 0; z-index: 30; display: flex;
  background: rgba(8, 11, 20, .9); backdrop-filter: blur(18px);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab-btn {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: .25rem;
  padding: .6rem .2rem; color: var(--muted); transition: color .2s, transform .2s var(--ease);
}
.tab-btn em { font-size: .66rem; font-style: normal; font-weight: 600; }
.tab-btn:hover { color: var(--text); transform: translateY(-2px); }
.tab-btn.active { color: var(--accent); }
.tab-btn.active svg { filter: drop-shadow(0 0 8px var(--accent-soft)); }

/* ═══════════ Cards & primitives ═══════════ */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r);
  backdrop-filter: blur(12px); box-shadow: var(--shadow); padding: 1rem;
  transition: transform .2s var(--ease), box-shadow .2s var(--ease), border-color .2s;
}
.card.lift:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: var(--border-strong); }
.card.hero-card { border-radius: var(--r-lg); background: linear-gradient(160deg, var(--surface-2), var(--surface)); }
.stack { display: flex; flex-direction: column; gap: .75rem; }
.row { display: flex; align-items: center; gap: .6rem; }
.row.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); }
.tiny { font-size: .72rem; }
.small { font-size: .82rem; }
.big { font-size: 1.6rem; font-weight: 700; letter-spacing: -.02em; }
.sec-title { display: flex; align-items: center; justify-content: space-between; margin: 1.2rem .2rem .6rem; }
.sec-title h3 { font-size: .98rem; }
.hint { font-size: .75rem; color: var(--muted); }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.divider { border: none; border-top: 1px solid var(--border); margin: .8rem 0; }
.empty {
  display: grid; place-items: center; gap: .5rem; text-align: center; padding: 1.6rem 1rem;
  border: 1px dashed var(--border-strong); border-radius: var(--r); color: var(--muted); font-size: .85rem;
}

/* Badges / chips */
.badge, .chip {
  display: inline-flex; align-items: center; gap: .3rem; font-size: .72rem; font-weight: 600;
  padding: .22rem .6rem; border-radius: 999px; background: var(--accent-soft); color: var(--accent);
  white-space: nowrap;
}
.badge.ok { background: rgba(74, 222, 128, .13); color: var(--ok); }
.badge.warn { background: rgba(251, 191, 36, .13); color: var(--warn); }
.badge.danger { background: rgba(248, 113, 113, .13); color: var(--danger); }
.badge.violet { background: rgba(167, 139, 250, .14); color: var(--violet); }
.chip { background: var(--surface-2); color: var(--muted); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  padding: .62rem 1.05rem; border-radius: 999px; font-size: .86rem; font-weight: 600;
  background: var(--accent-grad); color: #04120f; border: none;
  transition: transform .16s var(--ease), box-shadow .16s, opacity .2s;
}
.btn:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 10px 30px var(--accent-soft); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.ghost { background: transparent; border: 1.5px solid var(--border-strong); color: var(--text); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.soft { background: var(--surface-2); color: var(--text); }
.btn.danger { background: rgba(248, 113, 113, .16); color: var(--danger); border: 1px solid rgba(248, 113, 113, .3); }
.btn.block { width: 100%; }
.btn.sm { padding: .4rem .75rem; font-size: .76rem; }

/* ═══════════ Forms ═══════════ */
label.field { display: flex; flex-direction: column; gap: .35rem; font-size: .74rem; font-weight: 600; color: var(--muted); }
input, select, textarea {
  width: 100%; padding: .6rem .8rem; background: rgba(255, 255, 255, .05);
  border: 1px solid var(--border); border-radius: var(--r-sm); color: var(--text);
  font-size: .9rem; outline: none; transition: border-color .2s, box-shadow .2s;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input.err { border-color: var(--danger); }
.err-msg { color: var(--danger); font-size: .72rem; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.form-grid .full { grid-column: 1 / -1; }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(0% + 12px) center, calc(0% + 17px) center; background-size: 5px 5px; background-repeat: no-repeat; }

/* Segmented / tabs */
.seg { display: flex; gap: .2rem; background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: .22rem; }
.seg button { flex: 1; padding: .42rem .5rem; border-radius: 999px; font-size: .78rem; font-weight: 600; color: var(--muted); transition: all .2s var(--ease); }
.seg button.active { background: var(--accent-grad); color: #04120f; }

/* Progress */
.bar { height: 8px; border-radius: 999px; background: rgba(255, 255, 255, .08); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 999px; background: var(--accent-grad); transition: width .6s var(--ease); }
.bar.thin { height: 5px; }
.ring { position: relative; display: grid; place-items: center; }
.ring svg { transform: rotate(-90deg); }
.ring .val { position: absolute; text-align: center; }
.ring .val b { display: block; font-size: 1.35rem; font-weight: 700; }
.ring .val span { font-size: .62rem; color: var(--muted); }

/* Stat tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: .55rem; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); padding: .7rem .6rem; text-align: center; }
.tile b { display: block; font-size: 1.15rem; }
.tile span { font-size: .66rem; color: var(--muted); }

/* List rows */
.li {
  display: flex; align-items: center; gap: .7rem; padding: .7rem; border-radius: var(--r);
  background: var(--surface); border: 1px solid var(--border);
  transition: transform .18s var(--ease), border-color .18s;
}
.li:hover { transform: translateX(-3px); border-color: var(--border-strong); }
.dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.swipe-done { text-decoration: line-through; opacity: .5; }
.check { width: 22px; height: 22px; border-radius: 7px; border: 1.5px solid var(--border-strong); display: grid; place-items: center; flex: none; transition: all .2s; }
.check.on { background: var(--accent); border-color: var(--accent); color: #04120f; }

/* ═══════════ Plan / day cards / quiz / coach ═══════════ */
.day-card { border-radius: var(--r); border: 1px solid var(--border); background: var(--surface); padding: .75rem; }
.day-card.today { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.day-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: .5rem; }
.block {
  display: flex; align-items: center; gap: .5rem; padding: .45rem .55rem; border-radius: 10px;
  background: var(--surface-2); font-size: .8rem; margin-bottom: .3rem;
  border-inline-start: 3px solid var(--accent);
}
.block .hrs { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--accent); }
.alert-strip {
  display: flex; gap: .5rem; align-items: flex-start; padding: .7rem .8rem; border-radius: var(--r);
  font-size: .8rem; border: 1px solid rgba(251, 191, 36, .3); background: rgba(251, 191, 36, .1); color: #ffe6b8;
}
.alert-strip.danger { border-color: rgba(248, 113, 113, .35); background: rgba(248, 113, 113, .1); color: #ffd9d9; }

.coach-card { border-radius: var(--r); padding: .8rem; border: 1px solid var(--border); background: var(--surface); }
.coach-card.up { border-color: rgba(74, 222, 128, .35); background: rgba(74, 222, 128, .07); }
.coach-card.hold { border-color: rgba(110, 168, 255, .3); background: rgba(110, 168, 255, .06); }
.coach-card.down { border-color: rgba(248, 113, 113, .32); background: rgba(248, 113, 113, .07); }

.set-row { display: grid; grid-template-columns: 1fr 1fr 1fr auto; gap: .4rem; align-items: center; }
.set-row input { padding: .45rem .5rem; text-align: center; font-size: .82rem; }

.q-card { border-radius: var(--r); border: 1px solid var(--border); background: var(--surface); padding: .9rem; }
.opt {
  display: flex; align-items: center; gap: .5rem; width: 100%; text-align: start;
  padding: .6rem .7rem; border-radius: 12px; border: 1px solid var(--border);
  background: rgba(255, 255, 255, .03); font-size: .85rem; margin-bottom: .4rem;
  transition: all .18s var(--ease);
}
.opt:hover { border-color: var(--border-strong); transform: translateX(-3px); }
.opt.picked { border-color: var(--accent); background: var(--accent-soft); }
.opt.right { border-color: var(--ok); background: rgba(74, 222, 128, .12); }
.opt.wrong { border-color: var(--danger); background: rgba(248, 113, 113, .12); }

.kanban-col { border-radius: var(--r); border: 1px solid var(--border); background: var(--surface); padding: .6rem; }
.step { display: flex; gap: .5rem; align-items: center; font-size: .8rem; padding: .4rem 0; }
.spark { display: flex; align-items: flex-end; gap: 3px; height: 42px; }
.spark i { flex: 1; border-radius: 4px 4px 0 0; background: var(--accent-grad); opacity: .85; }

/* Timer */
.timer-face { font-size: 2.6rem; font-weight: 700; font-variant-numeric: tabular-nums; text-align: center; letter-spacing: .02em; }

/* ═══════════ Modal / toast / animations ═══════════ */
.sheet-wrap { position: fixed; inset: 0; z-index: 60; display: flex; align-items: flex-end; justify-content: center; background: rgba(0, 0, 0, .6); backdrop-filter: blur(5px); animation: fadeIn .2s var(--ease); }
.sheet {
  width: 100%; max-width: 640px; max-height: 88vh; overflow-y: auto;
  background: var(--bg-2); border: 1px solid var(--border-strong);
  border-radius: var(--r-lg) var(--r-lg) 0 0; padding: 1rem 1rem calc(1.2rem + env(safe-area-inset-bottom));
  animation: slideUp .32s var(--ease) both;
}
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: .7rem; }
.sheet-grab { width: 42px; height: 4px; border-radius: 99px; background: var(--border-strong); margin: 0 auto .7rem; }
.sheet-actions { display: flex; gap: .5rem; margin-top: .9rem; }
.sheet-actions .btn { flex: 1; }

.toast-wrap { position: fixed; bottom: calc(84px + env(safe-area-inset-bottom)); inset-inline: 1rem; z-index: 80; display: flex; flex-direction: column; gap: .45rem; pointer-events: none; }
.toast {
  padding: .7rem .9rem; border-radius: 14px; font-size: .82rem; font-weight: 500;
  box-shadow: var(--shadow-lg); animation: fadeUp .28s var(--ease) both;
  background: rgba(16, 22, 34, .96); border: 1px solid var(--border-strong);
}
.toast.ok { border-color: rgba(74, 222, 128, .4); color: #d6ffe6; }
.toast.err { border-color: rgba(248, 113, 113, .4); color: #ffdede; }
.toast.info { border-color: rgba(110, 168, 255, .4); color: #dfeaff; }

@keyframes fadeUp { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }
@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }
@keyframes slideUp { from { transform: translateY(28px); opacity: 0 } to { transform: none; opacity: 1 } }
@keyframes pulse { 0%, 100% { opacity: 1 } 50% { opacity: .45 } }
.fade-up { animation: fadeUp .45s var(--ease) both; }
.d1 { animation-delay: .06s } .d2 { animation-delay: .12s } .d3 { animation-delay: .18s } .d4 { animation-delay: .24s }
.pulse { animation: pulse 1.8s ease-in-out infinite; }
.skeleton { height: 62px; border-radius: var(--r); background: linear-gradient(90deg, rgba(255,255,255,.04) 25%, rgba(255,255,255,.09) 50%, rgba(255,255,255,.04) 75%); background-size: 200%; animation: shimmer 1.3s infinite; }
@keyframes shimmer { from { background-position: 200% 0 } to { background-position: -200% 0 } }

svg.ico { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
svg.ico.sm { width: 16px; height: 16px; }
svg.ico.lg { width: 26px; height: 26px; }

@media (min-width: 700px) {
  .view { padding: 1.2rem 1.4rem 2rem; }
  .cards-2 { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; align-items: start; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
@media print {
  .topbar, .tabbar, .glow, .toast-wrap, .mode-bar, .no-print { display: none !important; }
  body { background: #fff; color: #111; padding: 0; }
}

/* HTML5: إخفاء العناصر المخفية رغم قواعد العرض */
[hidden] { display: none !important; }
