/* =========================================================
   GH System v4 — style.css
   ========================================================= */

:root {
  --font: "Inter", "Tajawal", -apple-system, "SF Pro Text", system-ui, sans-serif;
  --blue: #007AFF; --green: #34C759; --orange: #FF9500;
  --red: #FF3B30; --purple: #AF52DE; --pink: #FF2D55;
  --teal: #5AC8FA; --indigo: #5856D6;
  --r-s: 14px; --r-m: 22px; --r-l: 28px;
  --ease: cubic-bezier(.32, .72, 0, 1);
  --hw: 76px; --label: 72px; --ruler-h: 34px;
  --sidebar-w: 250px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
[data-theme="light"] {
  color-scheme: light;
  --bg: #F2F2F7; --surface: #FFFFFF; --surface-2: #F2F2F7;
  --text: #1C1C1E; --text-2: rgba(60, 60, 67, .62); --text-3: rgba(60, 60, 67, .38);
  --line: rgba(60, 60, 67, .14); --line-soft: rgba(60, 60, 67, .07);
  --fill: rgba(118, 118, 128, .12);
  --glass: rgba(255, 255, 255, .72); --seg-active: #FFFFFF;
  --shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 8px 24px rgba(0, 0, 0, .06);
}
[data-theme="dark"] {
  color-scheme: dark;
  --bg: #000; --surface: #1C1C1E; --surface-2: #2C2C2E;
  --text: #FFFFFF; --text-2: rgba(235, 235, 245, .6); --text-3: rgba(235, 235, 245, .35);
  --line: rgba(84, 84, 88, .55); --line-soft: rgba(84, 84, 88, .28);
  --fill: rgba(118, 118, 128, .24);
  --glass: rgba(28, 28, 30, .72); --seg-active: #636366;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; scrollbar-width: none; -ms-overflow-style: none; }
*::-webkit-scrollbar { display: none; width: 0; height: 0; background: transparent; }
@media (hover: hover) {
  .tl-scroll { scrollbar-width: thin; scrollbar-color: var(--text-3) transparent; }
  .tl-scroll::-webkit-scrollbar { display: block; height: 8px; }
  .tl-scroll::-webkit-scrollbar-thumb { background: var(--text-3); border-radius: 4px; }
}
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--font);
  background: var(--bg); color: var(--text);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  transition: background .3s var(--ease), color .3s var(--ease);
}
body.is-dragging { cursor: grabbing; user-select: none; -webkit-user-select: none; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; padding: 0; }
input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 5px; }
.ic { width: 30px; height: 30px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ============ الهيكل ============ */
.app { min-height: 100dvh; }
.sidebar {
  position: fixed; inset-block: 0; inset-inline-start: 0;
  width: var(--sidebar-w); padding: 35px 25px;
  display: flex; flex-direction: column; gap: 35px;
  background: var(--glass);
  -webkit-backdrop-filter: blur(24px) saturate(150%);
  backdrop-filter: blur(24px) saturate(150%);
  border-inline-end: 5px solid var(--line);
  z-index: 30; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 0 15px; }
.brand-mark {
  height: 40px;
  width: auto;
  display: block;
  object-fit: contain;
  padding: 0;
  box-sizing: border-box;
  margin: 0;
  flex: none;
}
.brand-name { font-size: 20px; font-weight: 700; letter-spacing: -.01em; }

.nav { display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  height: 44px; padding: 0 12px; border-radius: 12px;
  font-weight: 500; font-size: 15px; text-align: start;
  transition: background .2s var(--ease), color .2s var(--ease);
}
.nav-item.active { background: rgba(0, 122, 255, .12); color: var(--blue); font-weight: 700; }
@media (hover: hover) { .nav-item:not(.active):hover { background: var(--fill); } }

.main {
  margin-inline-start: var(--sidebar-w);
  padding: 30px 32px 48px; min-width: 0;
}

/* ============ Topbar ============ */
.topbar {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 16px; margin-bottom: 22px;
}
.topbar h1 { margin: 0; font-size: 34px; font-weight: 800; letter-spacing: -.01em; line-height: 1.15; }
.sub { margin: 4px 0 0; color: var(--text-2); font-size: 14px; }
.actions { display: flex; align-items: center; gap: 10px; flex: none; }

.icon-btn {
  width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--surface); box-shadow: var(--shadow);
  transition: transform .2s var(--ease);
}
.icon-btn:active { transform: scale(.92); }
[data-theme="light"] .ic-sun { display: none; }
[data-theme="dark"] .ic-moon { display: none; }

.btn-primary {
  height: 40px; padding: 0 18px; border-radius: 20px;
  background: var(--blue); color: #fff; font-weight: 600; font-size: 15px;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  transition: transform .2s var(--ease), filter .2s;
}
.btn-primary:active { transform: scale(.96); filter: brightness(.92); }
.btn-primary .ic { width: 20px; height: 20px; stroke-width: 2.2; }
.btn-primary.wide { width: 100%; height: 48px; border-radius: var(--r-s); }

.btn-soft {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 34px; padding: 0 16px; border-radius: 17px;
  background: rgba(0, 122, 255, .12); color: var(--blue);
  font-weight: 600; font-size: 14px; cursor: pointer; flex: none;
}
.btn-soft:disabled { opacity: .5; cursor: default; }

.btn-ghost {
  display: inline-flex; align-items: center; justify-content: center;
  height: 40px; padding: 0 20px; border-radius: 20px;
  background: var(--fill); color: var(--text);
  font-weight: 600; font-size: 14px;
}

/* ============ الفلاتر ============ */
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: -6px 0 18px; }
.search { position: relative; flex: 1 1 220px; min-width: 180px; }
.search .ic {
  position: absolute; inset-inline-start: 12px; top: 50%; transform: translateY(-50%);
  width: 18px; height: 18px; color: var(--text-2); pointer-events: none;
}
.search input {
  width: 100%; height: 40px; padding: 0 14px; padding-inline-start: 38px;
  border: 0; border-radius: 12px; background: var(--fill); outline: none;
}
.search input:focus { box-shadow: 0 0 0 3px rgba(0, 122, 255, .25); }
.pill-select {
  height: 40px; padding: 0 14px; border: 0; border-radius: 12px;
  background: var(--fill); font-size: 14px; font-weight: 500; cursor: pointer;
  appearance: none; -webkit-appearance: none; outline: none;
}
.pill-select.on { background: rgba(0, 122, 255, .14); color: var(--blue); font-weight: 700; }

/* ============ الجدول الزمني ============ */
.tl-card {
  position: relative; background: var(--surface);
  border-radius: var(--r-m); box-shadow: var(--shadow); overflow: hidden;
}
.tl-scroll { overflow-x: auto; direction: ltr; overscroll-behavior-x: contain; }
.tl-inner { position: relative; width: calc(var(--label) + 24 * var(--hw)); }
.tl-ruler { display: flex; height: var(--ruler-h); }
.tl-corner {
  position: sticky; left: 0; z-index: 5;
  width: var(--label); flex: none; background: var(--surface);
  border-right: 1px solid var(--line);
}
.tl-hours { position: relative; width: calc(24 * var(--hw)); flex: none; }
.tl-hours span {
  position: absolute; top: 10px; transform: translateX(6px);
  font-size: 11px; font-weight: 500; color: var(--text-2);
  font-variant-numeric: tabular-nums;
}
.tl-row { display: flex; position: relative; border-top: 1px solid var(--line); }
.tl-label {
  position: sticky; left: 0; z-index: 5;
  width: var(--label); flex: none;
  display: flex; align-items: center; justify-content: center;
  direction: rtl; background: var(--surface);
  border-right: 1px solid var(--line);
  font-size: 13px; font-weight: 600;
}
.tl-row.is-today .tl-label { color: var(--blue); }
.tl-row.is-today .tl-track { background-color: rgba(0, 122, 255, .05); }
.tl-row.drop-target .tl-track { background-color: rgba(0, 122, 255, .12); }
.tl-track {
  position: relative; flex: none; width: calc(24 * var(--hw));
  background-image:
    linear-gradient(to right, var(--line) 1px, transparent 1px),
    linear-gradient(to right, var(--line-soft) 1px, transparent 1px);
  background-size: var(--hw) 100%, calc(var(--hw) / 4) 100%;
  cursor: cell;
}
.tl-now {
  position: absolute; z-index: 4; pointer-events: none;
  top: calc(var(--ruler-h) - 4px); bottom: 0;
  left: calc(var(--label) + var(--m, 0) * 24 * var(--hw));
  width: 2px; margin-left: -1px; background: var(--red);
}
.tl-now::before {
  content: ""; position: absolute; top: -3px; left: -4px;
  width: 10px; height: 10px; border-radius: 50%; background: var(--red);
}
.tl-block {
  position: absolute; display: flex; align-items: center;
  min-width: 12px; border-radius: 10px;
  background: var(--c); color: #fff;
  overflow: hidden; cursor: grab; touch-action: none;
  user-select: none; -webkit-user-select: none;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .18), 0 4px 10px color-mix(in srgb, var(--c) 32%, transparent);
  transition: box-shadow .2s var(--ease), filter .2s, opacity .2s;
}
.tl-block:hover { filter: brightness(1.06); }
.tl-block.is-done { opacity: .45; }
.tl-block.is-active {
  z-index: 6; cursor: grabbing; transition: none;
  box-shadow: 0 2px 4px rgba(0, 0, 0, .2), 0 14px 28px color-mix(in srgb, var(--c) 45%, transparent);
}
.blk-body {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; gap: 1px;
  padding: 0 14px; direction: rtl; text-align: start;
  line-height: 1.25; pointer-events: none;
}
.blk-body b { font-size: 13px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.blk-body small { font-size: 11px; opacity: .88; white-space: nowrap; font-variant-numeric: tabular-nums; }
.tl-block.narrow .blk-body { padding: 0 8px; }
.tl-block.tiny .blk-body { display: none; }
.grip { position: absolute; top: 0; bottom: 0; width: 14px; cursor: ew-resize; z-index: 2; }
.grip-l { left: 0; } .grip-r { right: 0; }
.grip::after {
  content: ""; position: absolute; top: 50%; height: 40%; width: 3px;
  border-radius: 2px; background: rgba(255, 255, 255, .8);
  transform: translateY(-50%); opacity: 0; transition: opacity .15s;
}
.grip-l::after { left: 4px; } .grip-r::after { right: 4px; }
.tl-block:hover .grip::after, .tl-block.is-active .grip::after { opacity: 1; }
@media (hover: none) { .grip::after { opacity: .9; } }
.tl-empty {
  position: absolute; inset: var(--ruler-h) 0 0 0;
  display: grid; place-items: center;
  pointer-events: none; text-align: center; padding: 20px;
  color: var(--text-2); font-size: 15px;
}
.tl-empty span {
  background: var(--glass);
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
  padding: 12px 20px; border-radius: 20px;
}

/* ============ القوائم ============ */
.list { background: var(--surface); border-radius: var(--r-m); box-shadow: var(--shadow); overflow: hidden; }
.task-row {
  position: relative; display: flex; align-items: center; gap: 14px;
  width: 100%; padding: 14px 16px; text-align: start; cursor: pointer;
  transition: background .15s;
}
.task-row + .task-row::before {
  content: ""; position: absolute; top: 0; inset-inline: 16px; height: 1px; background: var(--line);
}
.task-row:active { background: var(--fill); }
@media (hover: hover) { .task-row:hover { background: var(--fill); } }
.check {
  width: 26px; height: 26px; border-radius: 50%; flex: none;
  border: 2px solid var(--text-2);
  display: grid; place-items: center; color: transparent;
  transition: background .2s var(--ease), border-color .2s var(--ease), color .2s var(--ease), transform .2s var(--ease);
}
.check .ic { width: 15px; height: 15px; stroke-width: 3; }
.check:active { transform: scale(.9); }
.check.on { background: var(--green); border-color: var(--green); color: #fff; }
.task-row.is-done .tr-main b { text-decoration: line-through; color: var(--text-2); }
.task-row.is-done .bar { opacity: .4; }
.bar { width: 5px; align-self: stretch; min-height: 34px; border-radius: 3px; background: var(--c); flex: none; }
.tr-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.tr-main b { font-size: 16px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tr-main small { display: flex; flex-wrap: wrap; gap: 4px 12px; color: var(--text-2); font-size: 13px; }
.tr-main .now-tag { color: var(--blue); font-weight: 600; }
.tr-progress { font-size: 11px; color: var(--text-2); font-weight: 600; }
.prio { flex: none; font-size: 12px; font-weight: 600; padding: 4px 11px; border-radius: 20px; }
.p-high { background: rgba(255, 59, 48, .12); color: var(--red); }
.p-mid { background: rgba(255, 149, 0, .14); color: var(--orange); }
.p-low { background: rgba(52, 199, 89, .14); color: var(--green); }
.empty { text-align: center; padding: 60px 24px; color: var(--text-2); }
.empty h3 { margin: 0 0 6px; font-size: 18px; color: var(--text); }
.empty p { margin: 0; font-size: 14px; }
.empty .btn-primary { margin-top: 18px; }
.empty .btn-soft { margin-top: 12px; }
.tag-chip {
  display: inline-flex; align-items: center;
  background: var(--fill); color: var(--text-2);
  font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 10px;
}

/* ============ العادات ============ */
.habits { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.habit {
  --c: var(--blue);
  background: var(--surface); border-radius: var(--r-m); box-shadow: var(--shadow);
  padding: 16px; display: flex; flex-direction: column; gap: 14px;
}
.habit-top { display: flex; align-items: center; gap: 12px; }
.habit .check.on { background: var(--c); border-color: var(--c); }
.habit-name {
  flex: 1; min-width: 0; text-align: start;
  font-size: 17px; font-weight: 700;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.streak { display: flex; align-items: center; gap: 4px; color: var(--orange); font-weight: 700; font-size: 14px; flex: none; }
.streak .ic { width: 18px; height: 18px; }
.streak.zero { color: var(--text-2); font-weight: 500; }
.habit-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.hwd { text-align: center; font-size: 11px; font-weight: 600; color: var(--text-2); }
.hcell {
  aspect-ratio: 1; border-radius: 9px; background: var(--fill);
  display: grid; place-items: center;
  font-size: 11px; font-weight: 600; color: var(--text-2);
  transition: background .2s var(--ease), color .2s var(--ease), transform .15s var(--ease);
}
.hcell:active:not(:disabled) { transform: scale(.9); }
.hcell.on { background: var(--c); color: #fff; }
.hcell.today { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--c); }
.hcell:disabled { opacity: .35; cursor: default; }
.habit-foot { font-size: 12px; color: var(--text-2); }
.habit-stacked {
  font-size: 11px; color: var(--text-2);
  display: inline-flex; align-items: center; gap: 4px;
}
.habit-stacked .ic { width: 14px; height: 14px; }
.habit-heatmap {
  display: grid; grid-auto-flow: column;
  grid-template-rows: repeat(7, auto);
  grid-template-columns: repeat(var(--weeks, 53), 1fr);
  gap: 3px; margin-top: 10px;
}
.hm-cell { aspect-ratio: 1; border-radius: 2px; background: var(--fill); }
.hm-cell.on { background: var(--c); }
.hm-cell.part { background: color-mix(in srgb, var(--c) 40%, var(--fill)); }
.hm-cell.empty { background: transparent; }

/* ============ أيزنهاور ============ */
.matrix { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.quad {
  display: flex; flex-direction: column; gap: 12px;
  min-height: 230px; padding: 16px;
  background: var(--surface); border-radius: var(--r-m); box-shadow: var(--shadow);
  border: 2px solid transparent;
  transition: border-color .2s, background .2s;
}
.quad.drop { border-color: var(--qc); background: color-mix(in srgb, var(--qc) 8%, var(--surface)); }
.quad header { display: flex; align-items: baseline; gap: 8px; }
.quad h3 { margin: 0; font-size: 17px; color: var(--qc); }
.quad header small { color: var(--text-2); font-size: 13px; }
.quad .count {
  margin-inline-start: auto; min-width: 24px; padding: 2px 8px; border-radius: 12px;
  background: var(--fill); font-size: 12px; font-weight: 700; text-align: center;
}
.q-list { display: flex; flex-direction: column; gap: 8px; }
.q-card {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px 10px 10px;
  border-radius: 14px; background: var(--surface-2);
  border-inline-start: 4px solid var(--c); cursor: pointer;
}
.q-card.dragging { opacity: .35; }
.q-handle { width: 24px; height: 30px; display: grid; place-items: center; color: var(--text-2); cursor: grab; touch-action: none; flex: none; }
.q-handle .ic { width: 18px; height: 18px; }
.q-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.q-main b { font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.q-main small { color: var(--text-2); font-size: 12px; }
.q-ghost {
  position: fixed; z-index: 300; pointer-events: none;
  background: var(--surface); box-shadow: 0 14px 34px rgba(0, 0, 0, .3);
}
.q-empty { color: var(--text-2); font-size: 13px; text-align: center; padding: 22px 4px; }

/* ============ بومودورو ============ */
.pomo-card {
  --pc: var(--blue);
  max-width: 460px; margin: 0 auto; padding: 26px 22px;
  display: flex; flex-direction: column; align-items: center; gap: 24px;
  background: var(--surface); border-radius: var(--r-l); box-shadow: var(--shadow);
}
.pomo-card.is-break { --pc: var(--green); }
.seg.two { grid-template-columns: 1fr 1fr; width: 100%; }
.seg-btn { height: 34px; border-radius: 9px; font-size: 14px; font-weight: 500; transition: background .25s var(--ease), box-shadow .25s var(--ease); }
.seg-btn.active { background: var(--seg-active); font-weight: 700; box-shadow: 0 1px 4px rgba(0, 0, 0, .14); }

.ring { position: relative; width: min(270px, 72vw); aspect-ratio: 1; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: var(--fill); stroke-width: 12; }
.ring-center { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; gap: 2px; }
.ring-time { direction: ltr; font-size: 56px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.ring-label { color: var(--text-2); font-size: 15px; }

.pomo-select {
  width: 100%; height: 46px;
  padding: 0 14px 0 44px;
  border: 0; border-radius: var(--r-s);
  background-color: var(--surface-2);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236E6E73' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='m6 9 6 6 6-6'/></svg>");
  background-repeat: no-repeat;
  background-position: 14px center;
  background-size: 18px;
  appearance: none; -webkit-appearance: none;
  outline: none; font-size: 15px; text-align: right;
}
.pomo-select:focus { box-shadow: 0 0 0 3px rgba(0, 122, 255, .2); }

.pomo-ctrl {
  display: flex; align-items: center; justify-content: center;
  gap: 24px; width: 100%;
}
.pomo-btn-circle {
  box-sizing: border-box;
  width: 52px; height: 52px;
  min-width: 52px; min-height: 52px;
  max-width: 52px; max-height: 52px;
  flex: 0 0 52px;
  border-radius: 50%;
  background: var(--fill);
  display: grid; place-items: center;
  padding: 0; border: 0;
  transition: transform .2s var(--ease);
}
.pomo-btn-circle:active { transform: scale(.92); }
.pomo-btn-circle .ic { width: 22px; height: 22px; }
.pomo-btn-main {
  width: 78px; height: 78px;
  min-width: 78px; min-height: 78px;
  max-width: 78px; max-height: 78px;
  flex: 0 0 78px;
  background: var(--pc);
  color: #fff;
}
.pomo-btn-main .ic { width: 30px; height: 30px; fill: currentColor; }

.pomo-today { text-align: center; color: var(--text-2); font-size: 13px; }
.pomo-today strong { color: var(--text); font-weight: 700; }
.sess-dots { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.sess-dots i { width: 14px; height: 14px; min-width: 14px; flex: 0 0 14px; border-radius: 50%; background: var(--fill); aspect-ratio: 1 / 1; }
.sess-dots i.on { background: var(--red); }

/* ============ التقويم ============ */
.cal-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.cal-title { flex: 1; margin: 0; font-size: 22px; font-weight: 700; }
.cal {
  display: grid; grid-template-columns: repeat(7, 1fr);
  background: var(--surface); border-radius: var(--r-m); box-shadow: var(--shadow); overflow: hidden;
}
.cal-wd { padding: 10px 0; text-align: center; font-size: 12px; font-weight: 600; color: var(--text-2); border-bottom: 1px solid var(--line); }
.cal-day {
  min-height: 108px; padding: 8px; min-width: 0;
  display: flex; flex-direction: column; gap: 6px; align-items: flex-start;
  text-align: start; overflow: hidden;
  border-bottom: 1px solid var(--line-soft); border-inline-start: 1px solid var(--line-soft);
  transition: background .15s;
}
@media (hover: hover) { .cal-day:hover { background: var(--fill); } }
.cal-day.other { opacity: .38; }
.cal-day .num { width: 26px; height: 26px; display: grid; place-items: center; border-radius: 50%; font-size: 14px; font-weight: 600; }
.cal-day.today .num { background: var(--blue); color: #fff; }
.pills { display: flex; flex-direction: column; gap: 3px; width: 100%; min-width: 0; }
.pill {
  font-style: normal; font-size: 11px; font-weight: 600;
  padding: 2px 7px; border-radius: 6px;
  background: color-mix(in srgb, var(--c) 18%, transparent); color: color-mix(in srgb, var(--c) 55%, var(--text));
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.pill-more { font-style: normal; font-size: 11px; color: var(--text-2); padding: 0 4px; }
.dots { display: none; flex-wrap: wrap; justify-content: center; gap: 3px; width: 100%; }
.dot { width: 6px; height: 6px; border-radius: 50%; background: var(--c); }

/* ============ اليوميات ============ */
.journal-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 18px;
  height: calc(100vh - 220px);
  min-height: 540px;
}
.journal-sidebar {
  background: var(--surface);
  border-radius: var(--r-m);
  box-shadow: var(--shadow);
  display: flex; flex-direction: column;
  overflow: hidden; min-height: 0;
}
.journal-sidebar-title {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 700; color: var(--text-2);
  flex: none;
}
.journal-sidebar-title .ic { width: 16px; height: 16px; }
.journal-sidebar-list {
  flex: 1; min-height: 0; overflow-y: auto;
  padding: 8px; display: flex; flex-direction: column; gap: 2px;
}
.journal-day-item {
  position: relative; display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 10px;
  text-align: start; cursor: pointer;
  transition: background .15s; width: 100%; flex: none;
}
@media (hover: hover) { .journal-day-item:hover { background: var(--fill); } }
.journal-day-item.active { background: rgba(0, 122, 255, .12); color: var(--blue); }
.journal-day-item.today .jdi-text b { font-weight: 800; }
.jdi-dot {
  width: 8px; height: 8px; min-width: 8px;
  border-radius: 50%; background: var(--fill); flex: none;
}
.journal-day-item.has-entry .jdi-dot {
  background: var(--green);
  box-shadow: 0 0 0 3px rgba(52, 199, 89, .18);
}
.journal-day-item.active .jdi-dot { background: var(--blue); box-shadow: 0 0 0 3px rgba(0, 122, 255, .18); }
.jdi-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.jdi-text b { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.jdi-text small { font-size: 11px; color: var(--text-2); }
.jdi-tag {
  font-size: 9px; font-weight: 700;
  padding: 2px 6px; border-radius: 6px;
  background: var(--blue); color: #fff; flex: none;
}

.journal-main {
  display: flex; flex-direction: column;
  gap: 14px; min-height: 0; overflow-y: auto; padding-bottom: 8px;
}

.journal-nav {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 12px 16px;
  background: var(--surface); border-radius: var(--r-m);
  box-shadow: var(--shadow); flex: none;
}
.journal-nav-btn {
  width: 42px; height: 42px; min-width: 42px;
  border-radius: 12px; background: var(--fill);
  display: grid; place-items: center;
  transition: transform .2s var(--ease), background .2s;
  flex: none;
}
.journal-nav-btn:active:not(:disabled) { transform: scale(.92); }
.journal-nav-btn:disabled { opacity: .3; cursor: not-allowed; }
.journal-nav-btn .ic { width: 20px; height: 20px; }
.journal-nav-title { flex: 1; text-align: center; }
.journal-nav-title h2 { margin: 0; font-size: 18px; font-weight: 800; color: var(--text); }
.journal-nav-title p { margin: 2px 0 0; font-size: 12px; color: var(--text-2); }

.journal-stats {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 10px; flex: none;
}
.jstat {
  background: var(--surface); border-radius: var(--r-s);
  padding: 14px; box-shadow: var(--shadow);
  display: flex; flex-direction: column;
  align-items: center; gap: 4px; text-align: center;
}
.jstat-ic { color: var(--blue); display: grid; place-items: center; }
.jstat-ic .ic { width: 18px; height: 18px; }
.jstat b { font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; }
.jstat small { font-size: 11px; color: var(--text-2); }
.journal-energy { display: flex; gap: 3px; }
.journal-energy i { width: 5px; height: 18px; border-radius: 2px; background: var(--fill); }
.journal-energy i.on { background: var(--orange); }

.journal-editor-wrap {
  flex: 1; min-height: 240px;
  display: flex; flex-direction: column;
  background: var(--surface); border-radius: var(--r-m);
  box-shadow: var(--shadow); padding: 18px; gap: 8px;
}
.journal-editor {
  flex: 1; min-height: 200px; width: 100%;
  padding: 16px; border: 1px solid transparent;
  border-radius: var(--r-s); background: var(--surface-2);
  outline: none; font-size: 15px; line-height: 1.8;
  resize: none; font-family: inherit;
  caret-color: var(--blue);
  transition: border-color .2s, box-shadow .2s;
}
.journal-editor:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(0, 122, 255, .15);
  background: var(--surface);
}
.journal-editor[readonly] { opacity: .85; cursor: default; }
.journal-status { font-size: 11px; color: var(--text-3); text-align: end; height: 14px; }

.journal-actions {
  display: flex; gap: 10px; justify-content: center;
  flex: none; padding-bottom: 8px;
}
.journal-actions .btn-soft { min-width: 120px; height: 40px; border-radius: 20px; font-size: 14px; }
.journal-actions .btn-soft:disabled { opacity: .35; cursor: not-allowed; }

/* ============ المراجعة ============ */
.review { display: flex; flex-direction: column; gap: 14px; }
.review-card {
  background: var(--surface); border-radius: var(--r-m); box-shadow: var(--shadow);
  padding: 20px;
}
.review-card h3 { margin: 0 0 14px; font-size: 17px; }
.review-num { font-size: 40px; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.review-num small { font-size: 14px; font-weight: 500; color: var(--text-2); }
.review-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.review-stat { padding: 14px; background: var(--surface-2); border-radius: var(--r-s); text-align: center; }
.review-stat .v { font-size: 24px; font-weight: 800; font-variant-numeric: tabular-nums; }
.review-stat .l { font-size: 12px; color: var(--text-2); margin-top: 4px; }
.review-input {
  width: 100%; min-height: 80px; padding: 12px;
  border: 1px solid transparent; border-radius: var(--r-s);
  background: var(--surface-2); outline: none;
  font-size: 14px; line-height: 1.6; resize: vertical;
  margin-top: 8px; caret-color: var(--blue);
}
.review-input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(0, 122, 255, .2); }
.review-tracks { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }
.review-track { display: grid; grid-template-columns: 80px 1fr 60px; align-items: center; gap: 10px; }
.review-track-name { font-size: 13px; font-weight: 600; }
.review-track-slider { width: 100%; }
.review-track-value { font-size: 13px; color: var(--text-2); text-align: end; font-variant-numeric: tabular-nums; }

/* ============ الإحصائيات ============ */
.stat-cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 14px; }
.stat { padding: 16px 18px; background: var(--surface); border-radius: var(--r-m); box-shadow: var(--shadow); }
.stat small { color: var(--text-2); font-size: 13px; }
.stat b { display: block; margin-top: 6px; font-size: 30px; font-weight: 800; font-variant-numeric: tabular-nums; }
.panels { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.panel { padding: 18px; margin-bottom: 14px; background: var(--surface); border-radius: var(--r-m); box-shadow: var(--shadow); }
.panel.full { grid-column: 1 / -1; }
.panel h3 { margin: 0 0 16px; font-size: 17px; }
.panel .note { margin: 12px 0 0; color: var(--text-2); font-size: 12px; }
.cols { display: flex; gap: 8px; align-items: flex-end; }
.col { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.col-bar { position: relative; width: 100%; max-width: 38px; height: 120px; }
.col-total, .col-fill { position: absolute; bottom: 0; inset-inline: 0; border-radius: 9px; }
.col-total { background: var(--fill); }
.col-fill { background: var(--c, var(--blue)); transition: height .5s var(--ease); }
.col b { font-size: 12px; font-variant-numeric: tabular-nums; }
.col small { font-size: 11px; color: var(--text-2); white-space: nowrap; }
.col.is-today small { color: var(--blue); font-weight: 700; }
.hbar { display: grid; grid-template-columns: 56px 1fr 44px; align-items: center; gap: 10px; margin-bottom: 12px; }
.hbar:last-child { margin-bottom: 0; }
.hb-l { font-size: 13px; font-weight: 600; }
.hb-track { height: 12px; border-radius: 6px; background: var(--fill); overflow: hidden; }
.hb-track i { display: block; height: 100%; border-radius: 6px; background: var(--c); transition: width .5s var(--ease); }
.hb-v { font-size: 13px; color: var(--text-2); text-align: end; font-variant-numeric: tabular-nums; }

/* ============ الشريط السفلي ============ */
.bottom-nav {
  display: none; position: fixed; inset-inline: 0; bottom: 0; z-index: 30;
  grid-template-columns: repeat(4, 1fr);
  padding: 8px 8px calc(8px + var(--safe-b));
  background: var(--glass);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  backdrop-filter: blur(24px) saturate(180%);
  border-top: 1px solid var(--line);
}
.bn-item {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 6px 0; font-size: 11px; font-weight: 500; color: var(--text-2);
  transition: color .2s;
}
.bn-item.active { color: var(--blue); font-weight: 700; }

/* ============ Overlays ============ */
.overlay {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  background: rgba(0, 0, 0, .35);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  opacity: 0; visibility: hidden;
  transition: opacity .28s var(--ease), visibility .28s;
}
.overlay.open { opacity: 1; visibility: visible; }
#confirm { z-index: 110; }
#voiceModal { z-index: 120; }
#paletteModal { z-index: 105; align-items: flex-start; padding-top: 12vh; }

.sheet {
  width: min(520px, 100%);
  max-height: min(90dvh, 800px);
  overflow-y: auto;
  background: var(--surface);
  border-radius: var(--r-l);
  box-shadow: 0 30px 80px rgba(0, 0, 0, .35);
  transform: translateY(24px) scale(.97);
  transition: transform .4s var(--ease);
}
.overlay.open .sheet { transform: none; }
.sheet-head {
  position: sticky; top: 0; z-index: 2;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 16px 18px;
  background: var(--glass);
  -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--line);
}
.sheet-head h2 { margin: 0; font-size: 17px; font-weight: 700; text-align: center; }
.link-btn { color: var(--blue); font-size: 17px; min-width: 48px; }
.link-btn.strong { font-weight: 700; text-align: end; }
.sheet-body { padding: 18px; display: flex; flex-direction: column; gap: 16px; }
.form { padding: 18px; display: flex; flex-direction: column; gap: 18px; }
.lbl { display: block; margin-bottom: 8px; font-size: 13px; font-weight: 500; color: var(--text-2); }
.hint { display: block; margin-top: 6px; font-size: 12px; color: var(--text-2); }
.input {
  width: 100%; height: 46px; padding: 0 14px;
  border: 1px solid transparent; border-radius: var(--r-s);
  background: var(--surface-2); outline: none;
  transition: border-color .2s, box-shadow .2s;
  caret-color: var(--blue);
}
.input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(0, 122, 255, .2); }
.area { height: auto; min-height: 84px; padding: 12px 14px; resize: vertical; }
select.input { appearance: none; -webkit-appearance: none; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.chip, .seg-item, .sw { position: relative; cursor: pointer; }
.chip input, .seg-item input, .sw input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip span {
  display: inline-flex; align-items: center; height: 36px; padding: 0 14px;
  border-radius: 18px; background: var(--surface-2);
  font-size: 14px; font-weight: 500;
  transition: background .2s var(--ease), color .2s var(--ease);
}
.chip input:checked + span { background: var(--blue); color: #fff; }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px; padding: 3px; border-radius: 12px; background: var(--surface-2); }
.seg-item span {
  display: grid; place-items: center; height: 34px; border-radius: 9px;
  font-size: 14px; font-weight: 500;
  transition: background .25s var(--ease), box-shadow .25s var(--ease);
}
.seg-item input:checked + span { background: var(--seg-active); font-weight: 700; box-shadow: 0 1px 4px rgba(0, 0, 0, .14); }
.swatches { display: flex; flex-wrap: wrap; gap: 14px; padding: 4px; }
.sw span {
  display: block; width: 32px; height: 32px; border-radius: 50%;
  background: var(--c); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .08);
  transition: box-shadow .2s var(--ease), transform .2s var(--ease);
}
.sw input:checked + span { box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px var(--c); transform: scale(1.05); }
.err { margin: 0; min-height: 18px; color: var(--red); font-size: 13px; }
.btn-danger {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; height: 48px; border-radius: var(--r-s);
  background: rgba(255, 59, 48, .12); color: var(--red); font-weight: 600;
}

.subtasks { display: flex; flex-direction: column; gap: 8px; }
.subtask {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; background: var(--surface-2); border-radius: 10px;
}
.subtask input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--blue); }
.subtask input[type="text"] { flex: 1; border: 0; background: none; outline: none; font-size: 14px; caret-color: var(--blue); }
.subtask .sub-remove {
  width: 24px; height: 24px; border-radius: 50%;
  display: grid; place-items: center; color: var(--text-2);
}
.subtask .sub-remove:hover { background: rgba(255, 59, 48, .12); color: var(--red); }

.set-list { background: var(--surface-2); border-radius: var(--r-s); overflow: hidden; }
.set-row { display: flex; align-items: center; gap: 12px; padding: 14px 16px; }
.set-row + .set-row { border-top: 1px solid var(--line); }
.set-row > .ic { color: var(--blue); }
.set-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.set-text b { font-size: 15px; font-weight: 600; }
.set-text small { color: var(--text-2); font-size: 12px; }
.energy-picker { display: flex; gap: 4px; }
.energy-picker button {
  width: 30px; height: 30px; border-radius: 8px;
  background: var(--surface); color: var(--text-2);
  font-weight: 700; font-size: 13px;
  transition: all .2s;
}
.energy-picker button.active { background: var(--orange); color: #fff; }

.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; padding: 18px; }
.tile {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 16px 6px; border-radius: var(--r-s);
  background: var(--surface-2); font-size: 13px; font-weight: 600;
  transition: transform .2s var(--ease);
}
.tile:active { transform: scale(.95); }
.tile .ic { width: 28px; height: 28px; }
.tile.active { color: var(--blue); background: rgba(0, 122, 255, .12); }

.alert {
  width: min(300px, 100%);
  -webkit-backdrop-filter: blur(30px) saturate(180%); backdrop-filter: blur(30px) saturate(180%);
  border-radius: var(--r-m); text-align: center; overflow: hidden;
  box-shadow: 0 30px 80px rgba(0, 0, 0, .35);
  transform: scale(1.06);
  transition: transform .35s var(--ease);
}
[data-theme="light"] .alert { background: rgba(255, 255, 255, .92); }
[data-theme="dark"] .alert { background: rgba(44, 44, 46, .94); }
.overlay.open .alert { transform: none; }
.alert h3 { margin: 0; padding: 20px 18px 6px; font-size: 17px; font-weight: 700; }
.alert p { margin: 0; padding: 0 18px 18px; font-size: 14px; color: var(--text-2); }
.alert-actions { display: grid; grid-template-columns: 1fr 1fr; border-top: 1px solid var(--line); }
.alert-actions button { height: 48px; font-size: 17px; color: var(--blue); }
.alert-actions button + button { border-inline-start: 1px solid var(--line); }
.alert-actions .danger { color: var(--red); font-weight: 700; }
.alert-actions .safe { color: var(--blue); font-weight: 700; }

.palette {
  width: min(600px, 100%);
  background: var(--surface);
  border-radius: var(--r-m);
  box-shadow: 0 30px 80px rgba(0, 0, 0, .35);
  overflow: hidden;
  transform: translateY(-20px) scale(.97);
  transition: transform .3s var(--ease);
}
.overlay.open .palette { transform: none; }
.palette-input {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 18px; border-bottom: 1px solid var(--line);
}
.palette-input .ic { width: 20px; height: 20px; color: var(--text-2); }
.palette-input input { flex: 1; border: 0; background: none; outline: none; font-size: 16px; caret-color: var(--blue); }
.palette-list { max-height: 400px; overflow-y: auto; padding: 8px; }
.palette-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 10px;
  cursor: pointer; font-size: 14px;
  transition: background .15s;
}
.palette-item:hover, .palette-item.sel { background: var(--fill); }
.palette-item .ic { width: 18px; height: 18px; color: var(--text-2); flex: none; }
.palette-item b { flex: 1; font-weight: 500; }
.palette-item small { color: var(--text-2); font-size: 12px; }
.palette-section { font-size: 11px; font-weight: 700; color: var(--text-2); padding: 8px 12px 4px; text-transform: uppercase; }

.voice-card {
  background: var(--surface); border-radius: var(--r-l);
  padding: 30px 26px; max-width: 380px; width: 100%;
  display: flex; flex-direction: column; align-items: center; gap: 16px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, .35);
}
.voice-pulse {
  width: 80px; height: 80px; border-radius: 50%;
  background: rgba(0, 122, 255, .15); color: var(--blue);
  display: grid; place-items: center;
  animation: pulse 1.4s infinite;
}
.voice-pulse .ic { width: 36px; height: 36px; stroke-width: 2.2; }
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(0, 122, 255, .5); }
  50% { box-shadow: 0 0 0 20px rgba(0, 122, 255, 0); }
}
.voice-text {
  font-size: 15px; text-align: center; min-height: 40px;
  color: var(--text); font-weight: 500;
}

.toast {
  position: fixed; inset-inline: 0; bottom: 28px; margin-inline: auto; z-index: 200;
  width: max-content; max-width: 90vw;
  padding: 12px 20px; border-radius: 22px;
  background: rgba(40, 40, 42, .94); color: #fff; font-size: 14px;
  opacity: 0; transform: translateY(16px); pointer-events: none;
  transition: opacity .3s var(--ease), transform .3s var(--ease);
}
.toast.show { opacity: 1; transform: none; }

/* ============ Responsive ============ */
@media (max-width: 899px) {
  :root { --hw: 64px; --label: 62px; }
  .only-desktop { display: none !important; }
  .sidebar { display: none; }
  .bottom-nav { display: grid; }
  .main { margin-inline-start: 0; padding: 20px 14px calc(96px + var(--safe-b)); }
  .topbar h1 { font-size: 30px; }
  .btn-primary { width: 40px; padding: 0; border-radius: 50%; }
  .btn-primary .label { display: none; }
  .empty .btn-primary, .btn-primary.wide { width: auto; padding: 0 18px; border-radius: 20px; }
  .btn-primary.wide { width: 100%; border-radius: var(--r-s); }
  .toast { bottom: calc(88px + var(--safe-b)); }
  .stat-cards { grid-template-columns: 1fr 1fr; }
  .panels { grid-template-columns: 1fr; }
  
  .palette { max-width: 100%; }
  .overlay { padding: 0; align-items: flex-end; }
  .overlay.center { align-items: center; padding: 20px; }
  .overlay#paletteModal { align-items: flex-start; padding: 0; }
  .overlay#paletteModal .palette { border-radius: 0 0 var(--r-m) var(--r-m); transform: none; }

  .journal-layout { grid-template-columns: 1fr; height: auto; min-height: 0; }
  .journal-sidebar { max-height: 130px; }
  .journal-sidebar-list { flex-direction: row; overflow-x: auto; overflow-y: hidden; padding: 8px; }
  .journal-day-item { min-width: 120px; flex-direction: column; align-items: flex-start; padding: 10px; gap: 2px; }
  .jdi-dot { display: none; }
  .jdi-tag { position: absolute; top: 6px; left: 6px; font-size: 8px; }
  .journal-nav-title h2 { font-size: 16px; }
  .jstat { padding: 10px 6px; }
  .jstat b { font-size: 18px; }
  .journal-actions .btn-soft { min-width: 0; flex: 1; font-size: 12px; padding: 0 8px; }
}

@media (max-width: 700px) {
  .sheet {
    width: 100%; max-height: 92dvh;
    border-radius: var(--r-l) var(--r-l) 0 0;
    padding-bottom: var(--safe-b);
    transform: translateY(100%);
  }
  .overlay.open .sheet { transform: none; }
  .matrix { grid-template-columns: 1fr; }
  .cal-day { min-height: 62px; padding: 6px 2px; align-items: center; gap: 4px; }
  .pills { display: none; }
  .dots { display: flex; }
  .habits { grid-template-columns: 1fr; }
  .row2 { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  .main { padding-inline: 10px; }
  .topbar {
    flex-wrap: wrap;
    align-items: center;
    row-gap: 12px;
  }
  .topbar h1 { font-size: 26px; }
  .actions { width: 100%; justify-content: flex-end; }
  .filters { margin-bottom: 14px; }
  .search { flex-basis: 100%; }
  .pill-select { flex: 1 1 calc(50% - 6px); min-width: 0; }
  .stat-cards { grid-template-columns: 1fr 1fr; }
  .btn-primary { height: 38px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; animation: none !important; }
}
/* ============ شاشة تسجيل الدخول ============ */
.login-screen {
  position: fixed; inset: 0; z-index: 9999;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
  padding: 20px;
}
.login-screen.hidden { display: none; }
.login-card {
  width: 100%; max-width: 380px;
  background: var(--surface);
  border-radius: var(--r-l);
  box-shadow: var(--shadow);
  padding: 40px 28px;
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  text-align: center;
}
.login-logo {
  width: 64px; height: 64px;
  border-radius: 18px;
  display: grid; place-items: center;
  margin-bottom: 8px;
  box-shadow: 0 8px 20px rgba(0, 122, 255, .3);
}
.login-title { margin: 0; font-size: 24px; font-weight: 800; }
.login-sub { margin: 0 0 16px; font-size: 14px; color: var(--text-2); }
.login-card form { width: 100%; display: flex; flex-direction: column; gap: 10px; }
.login-input {
  width: 100%; height: 46px; padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-s);
  background: var(--surface-2);
  outline: none; font-size: 15px;
  transition: border-color .2s, box-shadow .2s;
}
.login-input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(0, 122, 255, .2); }
.login-btn {
  width: 100%; height: 48px;
  background: var(--blue); color: #fff;
  border-radius: var(--r-s);
  font-size: 16px; font-weight: 700;
  margin-top: 8px;
  transition: transform .15s, filter .15s;
}
.login-btn:hover { filter: brightness(1.05); }
.login-btn:active { transform: scale(.97); }
.login-btn:disabled { opacity: .6; cursor: not-allowed; }
.login-error { margin: 0; min-height: 18px; color: var(--red); font-size: 13px; text-align: center; }

.login-google {
  width: 100%; height: 48px;
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--r-s);
  font-size: 15px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
  margin-top: 4px;
  transition: background .15s;
}
.login-google:hover { background: var(--fill); }
.login-google:active { transform: scale(.97); }
.login-google:disabled { opacity: .6; cursor: not-allowed; }

/* ============ زر الصوت ============ */
#soundBtn { transition: opacity .2s var(--ease), transform .2s var(--ease); }
#soundBtn:active { transform: scale(.92); }
#soundBtn .wave-off { display: none; }
#soundBtn[data-muted="true"] .wave-on { display: none; }
#soundBtn[data-muted="true"] .wave-off { display: block; }
#soundBtn[data-muted="true"] { opacity: .45; }


/* =========================================================
   v5: إضافات وإصلاحات
   ========================================================= */

/* شاشة انتظار الدخول */
.splash-logo {
  width: 50px;
  height: 50px;
  object-fit: contain;
}
.splash {
  position: fixed; inset: 0; z-index: 10000;
  display: grid; place-items: center; background: var(--bg);
  transition: opacity .25s var(--ease);
}
.splash.hidden { opacity: 0; visibility: hidden; pointer-events: none; }
.splash span {
  width: 64px; height: 64px; border-radius: 18px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--blue), var(--purple)); color: #fff;
  font-size: 22px; font-weight: 800; animation: splash-pulse 1.2s ease-in-out infinite;
}
@keyframes splash-pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.08); } }

.muted { color: var(--text-2); font-size: 14px; }
.note-line { margin: 0 0 12px; }
.mt { margin-top: 18px !important; }
.sec-title { margin: 22px 0 10px; font-size: 15px; font-weight: 700; color: var(--text-2); display: flex; align-items: baseline; gap: 8px; }
.sec-title small { font-weight: 500; font-size: 12px; }
.sec-title.late { color: var(--red); }
.sec-title:first-child { margin-top: 0; }

/* التنقل بين الأسابيع / الأيام */
.tl-nav { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.tl-nav-title { flex: 1; font-size: 17px; font-weight: 700; text-align: center; }
.tl-nav .icon-btn:disabled { opacity: .35; cursor: default; }

/* الجدول: تسمية اليوم + التاريخ */
.tl-label { flex-direction: column; gap: 2px; }
.tl-label small { font-size: 11px; font-weight: 500; color: var(--text-2); font-variant-numeric: tabular-nums; }
.tl-row.is-today .tl-label small { color: var(--blue); }

/* زر الإنجاز داخل البلوك */
.blk-check {
  flex: none; width: 24px; height: 24px; margin-inline-end: 6px;
  border-radius: 50%; border: 2px solid rgba(255, 255, 255, .8);
  display: grid; place-items: center; color: transparent; z-index: 3;
}
.blk-check .ic { width: 13px; height: 13px; stroke-width: 3; }
.blk-check.on { background: rgba(255, 255, 255, .95); color: var(--c); border-color: transparent; }

/* بلوكات الصلاة (ثابتة) */
.tl-block.is-fixed, .dt-block.is-fixed {
  cursor: default; touch-action: auto; min-width: 46px;
  background-image: repeating-linear-gradient(135deg, rgba(255,255,255,.18) 0 6px, transparent 6px 12px);
  box-shadow: none;
}
.tl-block.is-fixed .blk-body { padding: 0 6px; }

/* الجدول على الجوال: يوم عمودي */
.dt-card { padding: 0; }
.dt { position: relative; display: flex; }
.dt-ruler { position: relative; width: 48px; flex: none; border-inline-end: 1px solid var(--line); }
.dt-ruler span { position: absolute; inset-inline-end: 6px; transform: translateY(-50%); font-size: 11px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.dt-ruler span:first-child { transform: none; }
.dt-track {
  position: relative; flex: 1; min-width: 0;
  background-image: repeating-linear-gradient(to bottom, var(--line) 0 1px, transparent 1px 56px);
}
.dt-block {
  position: absolute; display: flex; align-items: center; gap: 6px;
  padding: 4px 8px; border-radius: 10px; background: var(--c); color: #fff; overflow: hidden;
  box-shadow: 0 1px 2px rgba(0,0,0,.18);
}
.dt-block.is-done { opacity: .45; }
.dt-text, .dt-block.is-fixed { min-width: 0; }
.dt-text { flex: 1; display: flex; flex-direction: column; }
.dt-block b { font-size: 13px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dt-block small { font-size: 11px; opacity: .9; }
.dt-block.is-fixed { flex-direction: column; align-items: flex-start; justify-content: center; gap: 0; }
.dt-now { position: absolute; inset-inline: 0; height: 2px; background: var(--red); z-index: 4; pointer-events: none; }
.dt-now::before { content: ""; position: absolute; inset-inline-start: -4px; top: -4px; width: 10px; height: 10px; border-radius: 50%; background: var(--red); }

/* لوحة اليوم */
.today-top { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 6px; }
.today-card { margin-bottom: 0; }
.today-card h3 { font-size: 15px; margin-bottom: 12px; }
.track-rings { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; text-align: center; }
.track-ring { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.track-ring small { font-size: 12px; font-weight: 700; }
.tr-ring { position: relative; width: 56px; height: 56px; }
.tr-ring span { position: absolute; inset: 0; display: grid; place-items: center; font-size: 11px; font-weight: 700; font-variant-numeric: tabular-nums; }
.mini-ring { width: 100%; height: 100%; transform: rotate(-90deg); }
.mr-bg { fill: none; stroke: var(--fill); stroke-width: 6; }
.mr-fg { fill: none; stroke-width: 6; stroke-linecap: round; transition: stroke-dasharray .5s var(--ease); }
.prayer-strip { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); text-align: center; }
.prayer-strip span { display: flex; flex-direction: column; gap: 2px; padding: 6px 0; border-radius: 10px; }
.prayer-strip small { font-size: 11px; color: var(--text-2); }
.prayer-strip b { font-size: 13px; font-variant-numeric: tabular-nums; }
.prayer-strip .next { background: rgba(88, 86, 214, .14); }
.prayer-strip .next small, .prayer-strip .next b { color: var(--indigo); }
.energy-picker.big { gap: 8px; }
.energy-picker.big button { flex: 1; height: 42px; border-radius: 12px; font-size: 16px; background: var(--surface-2); }
.energy-picker.big button.active { background: var(--orange); color: #fff; }

.habit-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.habit-chip {
  --c: var(--blue);
  display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 4px 12px 4px 14px;
  border-radius: 20px; background: var(--surface-2); font-size: 14px;
  transition: background .2s var(--ease), opacity .2s;
}
.habit-chip.on { background: color-mix(in srgb, var(--c) 18%, var(--surface-2)); }
.habit-chip.waiting { opacity: .55; }
.hc-dot { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--text-2); display: grid; place-items: center; color: transparent; flex: none; }
.hc-dot .ic { width: 12px; height: 12px; stroke-width: 3; }
.habit-chip.on .hc-dot { background: var(--c); border-color: var(--c); color: #fff; }
.hc-main { display: flex; flex-direction: column; line-height: 1.25; text-align: start; }
.hc-main b { font-weight: 600; }
.hc-main small { font-size: 11px; color: var(--text-2); }
.hc-after { color: var(--text-2); }
.habit-chip.count { padding: 4px; gap: 4px; }
.habit-chip.count .hc-main { padding: 0 6px; min-width: 64px; align-items: center; }
.hc-step { width: 32px; height: 32px; border-radius: 50%; background: var(--surface); font-size: 18px; font-weight: 700; display: grid; place-items: center; }
.hc-step:active { transform: scale(.9); }

/* المهام: فرعية وروابط ومتأخرة */
.sub-list { display: flex; flex-direction: column; gap: 2px; margin-top: 6px; }
.sub-item { display: flex; align-items: center; gap: 8px; padding: 4px 0; text-align: start; font-size: 14px; color: var(--text-2); }
.sub-item .ic { width: 16px; height: 16px; border-radius: 50%; border: 1.5px solid var(--text-2); padding: 2px; color: transparent; stroke-width: 3; flex: none; }
.sub-item.on { text-decoration: line-through; }
.sub-item.on .ic { background: var(--green); border-color: var(--green); color: #fff; }
.dep-chip { display: inline-flex; align-items: center; gap: 4px; color: var(--orange); font-weight: 600; }
.dep-chip .ic { width: 13px; height: 13px; }
.late-chip { color: var(--red); font-weight: 700; }
.late-text { color: var(--red); }

/* العادات */
.count-ctl { display: flex; align-items: center; gap: 4px; background: var(--surface-2); border-radius: 20px; padding: 3px; flex: none; }
.count-ctl > span { min-width: 64px; text-align: center; font-size: 13px; color: var(--text-2); }
.count-ctl b { color: var(--text); font-size: 15px; }
.habit-meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.track-chip { font-size: 11px; font-weight: 700; padding: 2px 9px; border-radius: 10px; background: color-mix(in srgb, var(--c) 16%, transparent); color: color-mix(in srgb, var(--c) 60%, var(--text)); }
.hcell.part { background: color-mix(in srgb, var(--c) 35%, var(--fill)); color: var(--text); }

/* نافذة المهمة */
.seg.two-seg { grid-template-columns: 1fr 1fr; }
.hint { display: block; margin-top: 6px; font-size: 12px; color: var(--text-2); }

/* المراجعة: رادار */
.review-tracks-card { display: grid; grid-template-columns: minmax(220px, 300px) 1fr; gap: 20px; align-items: center; }
.radar-wrap { text-align: center; }
.radar { width: 100%; max-width: 300px; overflow: visible; }
.rd-ring, .rd-axis { fill: none; stroke: var(--line); stroke-width: 1; }
.rd-cur { fill: rgba(0, 122, 255, .22); stroke: var(--blue); stroke-width: 2; stroke-linejoin: round; }
.rd-prev { fill: none; stroke: var(--text-3); stroke-width: 1.5; stroke-dasharray: 4 4; }
.rd-label { font-size: 12px; font-weight: 700; }
.radar-wrap .note { margin: 6px 0 0; font-size: 12px; color: var(--text-2); }
.review-track-name small { display: block; font-size: 11px; font-weight: 500; color: var(--text-2); }
.rv-delta { font-size: 12px; font-weight: 700; margin-inline-start: 4px; }
.rv-delta.up { color: var(--green); }
.rv-delta.down { color: var(--red); }
.review .tl-nav { margin-bottom: 0; }
.hbar.wide { grid-template-columns: 90px 1fr 56px; }
.journal-page { display: flex; flex-direction: column; gap: 14px; flex: 1; min-height: 0; }

/* الإعدادات */
.set-group-title { font-size: 12px; font-weight: 700; color: var(--text-2); margin: 8px 6px -6px; }
.set-group-title:first-child { margin-top: 0; }
.set-row.col { flex-direction: column; align-items: stretch; }
.set-row .switch { flex: none; width: 46px; height: 28px; appearance: none; -webkit-appearance: none; border-radius: 14px; background: var(--fill); position: relative; cursor: pointer; transition: background .2s var(--ease); }
.set-row .switch::after { content: ""; position: absolute; top: 2px; inset-inline-start: 2px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.3); transition: transform .2s var(--ease); }
.set-row .switch:checked { background: var(--green); }
.set-row .switch:checked::after { transform: translateX(-18px); }
.btn-soft.danger { background: rgba(255, 59, 48, .12); color: var(--red); }
.uid { font-size: 11px; word-break: break-all; user-select: all; }
.set-row .lbl { margin-bottom: 6px; }

/* لوحة الأوامر والصوت */
.pal-bar { width: 4px; height: 18px; border-radius: 2px; flex: none; }
.voice-hint { margin: 0; font-size: 12px; color: var(--text-2); text-align: center; line-height: 1.6; }

@media (max-width: 899px) {
  .today-top { grid-template-columns: 1fr; }
  .review-tracks-card { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .track-rings { gap: 4px; }
  .tr-ring { width: 48px; height: 48px; }
  .tl-nav-title { font-size: 15px; }
}
