/* ═══ 4. Components ═══ */
.page-head { display: flex; align-items: center; gap: 12px; margin: 6px 0 18px; min-height: 44px; }
.page-head h1 { flex: 1; min-width: 0; }
.section-title { display: flex; align-items: center; gap: 8px; margin: 26px 0 12px; font-size: 15.5px; font-weight: 700; }
.section-title .link { margin-inline-start: auto; font-size: 13px; font-weight: 400; color: var(--primary); display: flex; align-items: center; gap: 2px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-l); padding: 18px; box-shadow: var(--shadow-1); }
.card.flat { box-shadow: none; }
.card.tint { background: var(--surface-2); box-shadow: none; }
.card.click { cursor: pointer; transition: transform .18s var(--ease), box-shadow .18s; }
.card.click:hover { box-shadow: var(--shadow-2); }
.card.click:active { transform: scale(.985); }
.grid-2 { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); }
.grid-3 { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr)); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 0 18px; border-radius: 14px;
  background: var(--surface-3); color: var(--ink); font-weight: 700; font-size: 14.5px; white-space: nowrap;
  transition: transform .15s var(--spring), background .15s, opacity .15s;
}
.btn:hover { background: var(--hover); }
.btn:active { transform: scale(.96); }
.btn:disabled { opacity: .45; pointer-events: none; }
.btn.primary { background: var(--primary); color: var(--on-primary); }
.btn.primary:hover { background: var(--primary-2); }
.btn.soft { background: var(--primary-soft); color: var(--primary); }
.btn.ghost { background: transparent; color: var(--primary); }
.btn.ghost:hover { background: var(--primary-soft); }
.btn.danger { background: var(--danger-soft); color: var(--danger); }
.btn.line { background: var(--surface); border: 1px solid var(--line-2); }
.btn.block { width: 100%; }
.btn.sm { min-height: 36px; padding: 0 13px; font-size: 13px; border-radius: 11px; }
.btn .i { width: 18px; height: 18px; }

/* Chips & pills */
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 13px; border-radius: 999px; font-size: 13px;
  background: var(--surface-2); border: 1px solid var(--line); color: var(--ink-2); white-space: nowrap; transition: background .15s, color .15s;
}
.chip.on { background: var(--primary); color: var(--on-primary); border-color: transparent; font-weight: 700; }
.chip .i { width: 15px; height: 15px; }
.pill { display: inline-flex; align-items: center; gap: 5px; height: 26px; padding: 0 10px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; background: var(--surface-3); color: var(--ink-2); }
.pill .i { width: 14px; height: 14px; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.danger { background: var(--danger-soft); color: var(--danger); }
.pill.pri { background: var(--primary-soft); color: var(--primary); }
.pill.sky { background: var(--sky-soft); color: #3F7FA6; }
:root[data-tone="dark"] .pill.sky { color: var(--sky); }
.pill.live::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; animation: pulse 1.6s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .25; } }
.tag { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--ink-3); white-space: nowrap; }
.tag .i { width: 14px; height: 14px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c, var(--peri)); flex: none; }

/* Segmented */
.seg { display: inline-flex; padding: 4px; gap: 2px; background: var(--surface-3); border-radius: 14px; max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.seg::-webkit-scrollbar { display: none; }
.seg button { padding: 7px 14px; border-radius: 11px; font-size: 13.5px; color: var(--ink-2); white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; transition: background .2s var(--ease), color .2s; }
.seg button.on { background: var(--surface); color: var(--ink); font-weight: 700; box-shadow: var(--shadow-1); }
.seg.icons button { padding: 7px 12px; }
.scroller { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; margin-inline: -16px; padding-inline: 16px; scroll-padding-inline: 16px; }
.scroller::-webkit-scrollbar { display: none; }

/* Fields */
.field { display: grid; gap: 6px; }
.field > label, .label { font-size: 13px; font-weight: 700; color: var(--ink-2); }
.input, .select, .textarea {
  width: 100%; min-height: 48px; padding: 11px 14px; border-radius: 14px; border: 1px solid var(--line-2); background: var(--surface);
  font-size: 16px; transition: border-color .15s, box-shadow .15s; outline: none; -webkit-appearance: none; appearance: none;
}
.textarea { resize: vertical; min-height: 110px; line-height: 1.7; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--peri); box-shadow: 0 0 0 4px color-mix(in srgb, var(--peri) 22%, transparent); }
.select { background-image: none; padding-inline-end: 36px; }
.select-wrap { position: relative; }
.select-wrap .i { position: absolute; inset-inline-end: 12px; top: 50%; translate: 0 -50%; pointer-events: none; color: var(--ink-3); width: 18px; }
.input[type="date"], .input[type="time"], .input[type="datetime-local"] { direction: ltr; text-align: right; unicode-bidi: normal; }
.form-row { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; }
.hint { font-size: 12.5px; color: var(--ink-3); display: flex; align-items: center; gap: 6px; }
.hint .i { width: 15px; height: 15px; }
.error { color: var(--danger); font-size: 13px; }

/* Switch */
.switch { position: relative; width: 50px; height: 30px; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--line-2); transition: background .2s; }
.switch span::after { content: ""; position: absolute; top: 3px; inset-inline-start: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, .18); transition: transform .25s var(--spring); }
.switch input:checked + span { background: var(--primary); }
.switch input:checked + span::after { transform: translateX(-20px); }
[dir="ltr"] .switch input:checked + span::after { transform: translateX(20px); }

/* Swatches */
.swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.swatch { width: 36px; height: 36px; border-radius: 50%; background: var(--c); border: 3px solid var(--surface); box-shadow: 0 0 0 1.5px var(--line-2); transition: transform .15s var(--spring); }
.swatch.on { box-shadow: 0 0 0 2.5px var(--ink); transform: scale(1.06); }

/* Lists */
.list { display: grid; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-l); overflow: hidden; }
.list > * + * { border-top: 1px solid var(--line); }
.li { display: flex; align-items: center; gap: 12px; padding: 13px 16px; min-height: 58px; }
button.li, a.li { width: 100%; text-align: start; transition: background .15s; }
button.li:hover, a.li:hover { background: var(--hover); }
.li__t { font-weight: 700; font-size: 14.5px; line-height: 1.45; }
.li__s { font-size: 12.5px; color: var(--ink-3); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 2px; }
.ico-tile { width: 42px; height: 42px; border-radius: 13px; display: grid; place-items: center; flex: none; background: color-mix(in srgb, var(--c, var(--peri)) 18%, var(--surface)); color: color-mix(in srgb, var(--c, var(--peri)) 72%, var(--ink)); }
:root[data-tone="dark"] .ico-tile { background: color-mix(in srgb, var(--c, var(--peri)) 22%, var(--surface)); color: color-mix(in srgb, var(--c, var(--peri)) 80%, #fff); }
.ico-tile.s { width: 34px; height: 34px; border-radius: 11px; }
.ico-tile.s .i { width: 18px; height: 18px; }

/* Check (tick) */
.check {
  width: 28px; height: 28px; border-radius: 50%; flex: none; display: grid; place-items: center; border: 2px solid color-mix(in srgb, var(--c, var(--peri)) 70%, var(--line-2));
  color: #fff; transition: background .2s, border-color .2s, transform .2s var(--spring);
}
.check .i { width: 16px; height: 16px; stroke-width: 3; opacity: 0; transform: scale(.4); transition: opacity .15s, transform .3s var(--spring); }
.check.on { background: var(--c, var(--peri)); border-color: var(--c, var(--peri)); }
.check.on .i { opacity: 1; transform: none; }
.check:active { transform: scale(.85); }
.is-done .li__t { color: var(--ink-3); text-decoration: line-through; text-decoration-color: var(--line-2); }

/* Progress ring */
.ring { position: relative; display: grid; place-items: center; flex: none; }
.ring svg { transform: rotate(-90deg); }
.ring circle { fill: none; stroke-linecap: round; }
.ring .track { stroke: var(--surface-3); }
.ring .bar { stroke: var(--c, var(--primary)); transition: stroke-dashoffset .8s var(--ease); }
.ring b { position: absolute; font-size: 13px; }

/* Empty state */
.empty { display: grid; justify-items: center; gap: 10px; padding: 44px 16px; text-align: center; color: var(--ink-3); }
.empty .art { width: 76px; height: 76px; border-radius: 24px; display: grid; place-items: center; background: var(--surface-2); color: var(--peri); }
.empty .art .i { width: 34px; height: 34px; }
.empty h3 { color: var(--ink); }

/* Sheet (bottom sheet on phone, dialog on desktop) */
.scrim { position: fixed; inset: 0; z-index: 90; background: rgba(20, 24, 44, .38); opacity: 0; transition: opacity .25s; }
.scrim.open { opacity: 1; }
.sheet {
  position: fixed; z-index: 91; inset-inline: 0; bottom: 0; max-height: 92dvh; display: flex; flex-direction: column;
  background: var(--surface); border-radius: 26px 26px 0 0; box-shadow: var(--shadow-3); transform: translateY(105%);
  transition: transform .38s var(--ease); padding-bottom: var(--safe-b);
}
.sheet.open { transform: none; }
.sheet__grab { width: 40px; height: 5px; border-radius: 9px; background: var(--line-2); margin: 9px auto 0; flex: none; }
.sheet__head { display: flex; align-items: center; gap: 10px; padding: 10px 18px 6px; flex: none; }
.sheet__head h2 { flex: 1; min-width: 0; }
.sheet__body { padding: 8px 18px 18px; overflow-y: auto; overscroll-behavior: contain; flex: 1; }
.sheet__foot { display: flex; gap: 10px; padding: 12px 18px 16px; border-top: 1px solid var(--line); flex: none; }
.sheet__foot .btn { flex: 1; }
@media (min-width: 720px) {
  .sheet { inset: auto; left: 50%; top: 50%; bottom: auto; width: min(560px, 92vw); max-height: 86dvh; border-radius: 26px; transform: translate(-50%, -46%) scale(.97); opacity: 0; transition: transform .3s var(--ease), opacity .25s; }
  .sheet.open { transform: translate(-50%, -50%); opacity: 1; }
  .sheet.wide { width: min(760px, 94vw); }
  .sheet__grab { display: none; }
  .sheet__head { padding-top: 18px; }}

/* Toast */
.toasts { position: fixed; z-index: 120; inset-inline: 0; bottom: calc(var(--tabbar) + var(--safe-b) + 14px); display: grid; justify-items: center; gap: 8px; pointer-events: none; padding: 0 16px; }
@media (min-width: 960px) { .toasts { bottom: 28px; }}
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 12px; padding: 11px 12px 11px 16px; min-height: 50px; border-radius: 16px; max-width: 460px;
  background: #262C48; color: #fff; box-shadow: var(--shadow-3); font-size: 14px; animation: toast-in .4s var(--spring);
}
:root[data-tone="dark"] .toast { background: #EEF0F8; color: #262C48; }
.toast button { color: var(--sky); font-weight: 700; padding: 6px 10px; border-radius: 10px; }
:root[data-tone="dark"] .toast button { color: var(--primary-2); color: #4A4A94; }
.toast.out { animation: toast-out .25s forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(16px) scale(.96); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(10px); } }

/* Popover menu */
.pop { position: fixed; z-index: 95; min-width: 200px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow-3); padding: 6px; animation: pop-in .18s var(--ease); }
.pop button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 12px; border-radius: 11px; font-size: 14px; text-align: start; }
.pop button:hover { background: var(--hover); }
.pop button.danger { color: var(--danger); }
@keyframes pop-in { from { opacity: 0; transform: scale(.96); } }

.avatar { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; flex: none; background: color-mix(in srgb, var(--c, var(--peri)) 24%, var(--surface)); color: color-mix(in srgb, var(--c, var(--peri)) 70%, var(--ink)); }
.badge { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--danger); color: #fff; font-size: 11px; font-weight: 700; display: inline-grid; place-items: center; }

/* ═══ 1.10 · the bell: important things in one place ═══ */
.bell-btn { position: relative; }
.bell { display: grid; gap: 8px; }
.bell__i { display: flex; align-items: center; gap: 6px; padding: 4px 6px 4px 4px; border-radius: 16px; background: color-mix(in srgb, var(--c) 8%, var(--surface)); border: 1px solid color-mix(in srgb, var(--c) 20%, var(--line)); transition: opacity .18s, transform .18s; }
.bell__i.gone { opacity: 0; transform: translateX(-12px); }
.bell__go { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; padding: 8px; border: 0; background: none; color: var(--ink); font: inherit; text-align: start; cursor: pointer; }
.bell__go .grow { display: grid; gap: 2px; min-width: 0; }
.bell__go b { font-size: 14px; line-height: 1.5; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }

/* 1.13 — the date field and our own Gregorian chooser */
.dp-btn { display: flex; align-items: center; gap: 8px; width: 100%; text-align: start; cursor: pointer; font: inherit; color: var(--ink); }
.dp-btn .i { color: var(--primary); flex: none; }
.dp-btn span { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dp-btn.empty span { color: var(--ink-3); }
.dp-scrim { position: fixed; inset: 0; z-index: 130; background: rgba(20, 24, 44, .3); }
.dp { position: fixed; z-index: 131; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(340px, calc(100vw - 24px)); padding: 14px; border-radius: 22px; background: var(--surface); box-shadow: var(--shadow-3); border: 1px solid var(--line); display: grid; gap: 10px; animation: pop-in .16s var(--ease); }
.dp__head { display: flex; align-items: center; justify-content: space-between; }
.dp__head b { font-size: 16px; }
.dp__wd, .dp__grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; text-align: center; }
.dp__wd span { font-size: 10.5px; color: var(--ink-3); }
.dp__d { aspect-ratio: 1; border-radius: 50%; border: 0; background: none; font: inherit; font-size: 14px; color: var(--ink); cursor: pointer; }
.dp__d:hover { background: var(--hover); }
.dp__d.today { box-shadow: inset 0 0 0 1.5px var(--primary); color: var(--primary); }
.dp__d.on { background: var(--primary); color: var(--on-primary); box-shadow: none; }
.dp__hijri { text-align: center; }
.dp__time { display: flex; align-items: center; gap: 8px; }
.dp__time label { font-size: 13px; color: var(--ink-2); }
.dp__time select { min-height: 38px; padding: 0 10px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2); font: inherit; color: var(--ink); }
.dp__foot { display: flex; align-items: center; gap: 6px; }
/* 1.14 — date and time fields: one calm height, never stretched by their neighbours */
.field { align-content: start; }
.dp-btn, .input[type="time"] { height: 48px; min-height: 48px; padding-block: 0; font-size: 15px; line-height: 48px; }
.dp-btn { line-height: normal; }
.input[type="time"]::-webkit-datetime-edit { padding: 0; }
/* 1.19 · the time reads hour:minute (left to right) with ص / م on its left, as on any Arabic clock */
.dp__time { flex-wrap: nowrap; }
.dp__hm { display: inline-flex; align-items: center; gap: 4px; direction: ltr; }
/* iPhone / iPad: the system time field shows «5:00 م»; read right to left so ص / م sits on the left (the digits keep their order) */
@supports (-webkit-touch-callout: none) { html input[type="time"], html .input[type="time"] { direction: rtl; text-align: right; } }
