/* Zajel — shared tokens + primitives. RTL-first: logical properties only. */
:root {
  --ink: #1E1433;
  --ink-2: #3A2F52;
  --ink-3: #6B6380;
  --ink-4: #9C95AD;
  --paper: #F7F6FB;
  --card: #FFFFFF;
  --line: #E6E2EF;
  --line-2: #D6D0E3;
  --violet: #5B3DF5;
  --violet-2: #4A2FD9;
  --violet-soft: #ECE8FE;
  --green: #12B886;
  --green-2: #0C9A70;
  --green-soft: #E0F6EE;
  --amber: #FF8A3D;
  --amber-soft: #FFF0E5;
  --rose: #E5484D;
  --rose-soft: #FDECEC;
  --trail: linear-gradient(90deg, #5B3DF5, #12B886);

  --r-sheet: 26px;
  --r-card: 16px;
  --r-ctl: 12px;
  --r-pill: 999px;

  --shadow-1: 0 1px 2px rgba(30, 20, 51, .06), 0 2px 8px rgba(30, 20, 51, .05);
  --shadow-2: 0 8px 28px rgba(30, 20, 51, .14);
  --shadow-sheet: 0 -10px 40px rgba(30, 20, 51, .16);

  --font: 'Alexandria', 'IBM Plex Sans Arabic', system-ui, sans-serif;
  --t-xs: 13px;
  --t-sm: 14px;
  --t-md: 16px;
  --t-lg: 19px;
  --t-xl: 24px;
  --t-2xl: 32px;
  --ease: cubic-bezier(.2, .8, .2, 1);
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
:lang(ar), :lang(ar) * { letter-spacing: normal; }
html, body { margin: 0; }
body {
  font-family: var(--font);
  font-size: var(--t-md);
  line-height: 1.6;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
img { display: block; max-inline-size: 100%; }
.num, bdi.num { font-variant-numeric: tabular-nums; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--violet) 55%, transparent); outline-offset: 2px; border-radius: 6px; }
.sr-only { position: absolute; inline-size: 1px; block-size: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-block-size: 48px; padding-inline: 20px; border-radius: var(--r-ctl);
  font-weight: 600; font-size: var(--t-md); line-height: 1.3;
  transition: transform .12s var(--ease), background-color .15s, box-shadow .15s, opacity .15s;
  user-select: none;
}
.btn:active { transform: scale(.98); }
.btn[disabled] { opacity: .45; pointer-events: none; }
.btn-primary { background: var(--violet); color: #fff; box-shadow: 0 6px 18px rgba(91, 61, 245, .28); }
.btn-primary:hover { background: var(--violet-2); }
.btn-go { background: var(--green); color: #fff; box-shadow: 0 6px 18px rgba(18, 184, 134, .28); }
.btn-go:hover { background: var(--green-2); }
.btn-ghost { background: var(--card); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line-2); }
.btn-ghost:hover { background: var(--paper); }
.btn-quiet { background: transparent; color: var(--ink-3); }
.btn-danger { background: var(--rose-soft); color: var(--rose); }
.btn-block { inline-size: 100%; }
.btn-sm { min-block-size: 36px; padding-inline: 14px; font-size: var(--t-sm); border-radius: 10px; }

/* chips + status */
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: var(--r-pill);
  font-size: var(--t-xs); font-weight: 500; line-height: 1.5; white-space: nowrap;
  background: var(--paper); color: var(--ink-2); box-shadow: inset 0 0 0 1px var(--line);
}
.chip.violet { background: var(--violet-soft); color: var(--violet-2); box-shadow: none; }
.chip.green { background: var(--green-soft); color: var(--green-2); box-shadow: none; }
.chip.amber { background: var(--amber-soft); color: #B4541A; box-shadow: none; }
.chip.rose { background: var(--rose-soft); color: var(--rose); box-shadow: none; }
.chip.ink { background: var(--ink); color: #fff; box-shadow: none; }
.dot { inline-size: 8px; block-size: 8px; border-radius: 50%; background: currentColor; flex: none; }
.live-dot { inline-size: 8px; block-size: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 0 rgba(18, 184, 134, .6); animation: livepulse 1.8s infinite; flex: none; }
@keyframes livepulse { 0% { box-shadow: 0 0 0 0 rgba(18, 184, 134, .55); } 70% { box-shadow: 0 0 0 8px rgba(18, 184, 134, 0); } 100% { box-shadow: 0 0 0 0 rgba(18, 184, 134, 0); } }

/* toast */
.toasts { position: fixed; inset-block-start: 14px; inset-inline: 0; display: grid; justify-items: center; gap: 8px; z-index: 1000; pointer-events: none; padding-inline: 14px; }
.toast {
  pointer-events: auto; max-inline-size: 420px; padding: 11px 16px; border-radius: 14px;
  background: var(--ink); color: #fff; font-size: var(--t-sm); line-height: 1.5; box-shadow: var(--shadow-2);
  display: flex; gap: 10px; align-items: center; animation: toastin .35s var(--ease);
}
.toast.ok::before { content: ''; inline-size: 8px; block-size: 8px; border-radius: 50%; background: var(--green); flex: none; }
.toast.warn::before { content: ''; inline-size: 8px; block-size: 8px; border-radius: 50%; background: var(--amber); flex: none; }
.toast.out { opacity: 0; transform: translateY(-8px); transition: .3s; }
@keyframes toastin { from { opacity: 0; transform: translateY(-10px) scale(.97); } }

/* map markers (MapLibre HTML markers) */
.mk-courier { inline-size: 38px; block-size: 38px; display: grid; place-items: center; will-change: transform; }
.mk-courier .car { inline-size: 34px; block-size: 34px; border-radius: 50%; background: var(--ink); display: grid; place-items: center; box-shadow: 0 4px 12px rgba(30, 20, 51, .35), 0 0 0 3px #fff; transition: transform .45s linear; }
.mk-courier .car svg { inline-size: 18px; block-size: 18px; }
.mk-courier.mine .car { background: var(--violet); }
.mk-courier.active .car { background: var(--green); }
.mk-courier.idle .car { background: #fff; box-shadow: 0 2px 8px rgba(30, 20, 51, .25), 0 0 0 2px var(--line-2); }
.mk-courier.idle .car svg path { fill: var(--ink-3); }
.mk-courier .tag { position: absolute; inset-block-end: 42px; white-space: nowrap; background: #fff; color: var(--ink); font-size: 12px; font-weight: 600; line-height: 1.4; padding: 2px 8px; border-radius: 8px; box-shadow: var(--shadow-1); }
.mk-pin { display: grid; place-items: center; inline-size: 36px; block-size: 36px; border-radius: 12px; background: #fff; box-shadow: var(--shadow-2), 0 0 0 2px #fff; overflow: hidden; }
.mk-pin img { inline-size: 100%; block-size: 100%; object-fit: cover; }
.mk-home { inline-size: 30px; block-size: 30px; border-radius: 50%; background: var(--green); display: grid; place-items: center; box-shadow: 0 0 0 4px rgba(18, 184, 134, .25), var(--shadow-1); }
.mk-home svg { inline-size: 16px; block-size: 16px; }
.maplibregl-ctrl-attrib { font-size: 10px !important; }
.maplibregl-ctrl-bottom-right, .maplibregl-ctrl-bottom-left { opacity: .7; }

/* demo bar: switch between the three apps when opened outside the stage */
html.standalone { --demo-h: 40px; }
html.standalone body { padding-block-start: var(--demo-h); }
.zswitch {
  position: fixed; inset-block-start: 0; inset-inline: 0; block-size: var(--demo-h); z-index: 900;
  display: flex; align-items: center; justify-content: space-between; gap: 8px; padding-inline: 12px;
  background: var(--ink); color: #fff;
}
.zswitch .brand { display: flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 700; white-space: nowrap; }
.zswitch .brand img { inline-size: 20px; block-size: 20px; }
.zswitch .apps { display: flex; gap: 2px; background: rgba(255, 255, 255, .08); border-radius: var(--r-pill); padding: 3px; }
.zswitch a { color: #CFC8E6; text-decoration: none; font-size: 13px; font-weight: 600; padding: 2px 11px; border-radius: var(--r-pill); line-height: 1.6; }
.zswitch a.on { background: #fff; color: var(--ink); }
.toasts { inset-block-start: calc(var(--demo-h, 0px) + 14px); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
