@font-face {
  font-family: 'Vazirmatn';
  src: url('/vendor/vazirmatn.woff2') format('woff2');
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --font: 'Vazirmatn', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --radius: 18px;
  --radius-sm: 12px;
  --panel-w: 400px;
  --gap: 14px;
  --ease: cubic-bezier(.2, .8, .2, 1);
}
:root[data-theme="dark"] {
  --bg: #0b0f14;
  --glass: rgba(14, 19, 26, .78);
  --glass-strong: rgba(17, 23, 31, .94);
  --surface: rgba(255, 255, 255, .06);
  --surface-2: rgba(255, 255, 255, .1);
  --line: rgba(255, 255, 255, .09);
  --text: #eef3f7;
  --muted: #8d99a6;
  --accent: #38f0b0;
  --accent-ink: #03150e;
  --accent-soft: rgba(56, 240, 176, .14);
  --danger: #ff5d73;
  --shadow: 0 18px 50px rgba(0, 0, 0, .55), 0 2px 8px rgba(0, 0, 0, .4);
  --glow: 0 0 0 1px rgba(56, 240, 176, .35), 0 0 22px rgba(56, 240, 176, .25);
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #eef1f5;
  --glass: rgba(255, 255, 255, .8);
  --glass-strong: rgba(255, 255, 255, .96);
  --surface: rgba(15, 30, 50, .05);
  --surface-2: rgba(15, 30, 50, .09);
  --line: rgba(15, 30, 50, .1);
  --text: #121821;
  --muted: #5e6b78;
  --accent: #0aa36f;
  --accent-ink: #ffffff;
  --accent-soft: rgba(10, 163, 111, .12);
  --danger: #e0324d;
  --shadow: 0 18px 50px rgba(30, 45, 70, .16), 0 2px 8px rgba(30, 45, 70, .08);
  --glow: 0 0 0 1px rgba(10, 163, 111, .35), 0 0 18px rgba(10, 163, 111, .18);
  color-scheme: light;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--text); font: 15px/1.5 var(--font); }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
svg .fill { fill: currentColor; stroke: none; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
[dir="rtl"] .flip-rtl { transform: scaleX(-1); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

#map { position: fixed; inset: 0; }
.maplibregl-ctrl-attrib { font-size: 11px; background: var(--glass) !important; color: var(--muted); border-radius: 10px 0 0 0; }
.maplibregl-ctrl-attrib a { color: var(--muted) !important; }
.maplibregl-ctrl-bottom-right, .maplibregl-ctrl-bottom-left { z-index: 1; }

.glass {
  background: var(--glass);
  backdrop-filter: blur(22px) saturate(1.6);
  -webkit-backdrop-filter: blur(22px) saturate(1.6);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

/* ---------- Panel ---------- */
#panel {
  position: fixed; z-index: 5; top: var(--gap); inset-inline-start: var(--gap);
  width: var(--panel-w); max-height: calc(100% - 2 * var(--gap));
  border-radius: 24px; display: flex; flex-direction: column; overflow: hidden;
  transition: transform .35s var(--ease);
}
.sheet-handle { display: none; }
.brand { display: flex; align-items: center; gap: 12px; padding: 16px 16px 8px; }
.logo { border-radius: 10px; box-shadow: var(--glow); }
.brand-text { flex: 1; display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.brand-text strong { font-size: 19px; letter-spacing: .3px; }
.brand-text span { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.view { display: flex; flex-direction: column; min-height: 0; overflow: auto; padding: 4px 16px 16px; gap: 12px; }

.icon-btn { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; color: var(--text); transition: background .2s; }
.icon-btn:hover { background: var(--surface-2); }
.icon-btn.small { width: 32px; height: 32px; }
.icon-btn.small svg { width: 16px; height: 16px; }

.searchbox {
  display: flex; align-items: center; gap: 8px; height: 56px; padding: 0 6px 0 14px;
  border-radius: 18px; background: var(--surface); border: 1px solid var(--line);
  transition: border-color .2s, box-shadow .2s;
}
[dir="rtl"] .searchbox { padding: 0 14px 0 6px; }
.searchbox:focus-within { border-color: var(--accent); box-shadow: var(--glow); }
.searchbox .lead { color: var(--muted); }
.searchbox input { flex: 1; min-width: 0; border: 0; background: none; outline: none; font-size: 16px; }
.searchbox input::placeholder { color: var(--muted); }
input[type="search"]::-webkit-search-cancel-button { display: none; }
.go-btn { width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; background: var(--accent); color: var(--accent-ink); box-shadow: var(--glow); transition: transform .15s; }
.go-btn:active { transform: scale(.94); }
.go-btn svg { width: 22px; height: 22px; }

.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 999px; white-space: nowrap;
  background: var(--surface); border: 1px solid var(--line); font-size: 13.5px; transition: all .2s;
}
.chip svg { width: 16px; height: 16px; color: var(--c); }
.chip:hover { background: var(--surface-2); }
.chip.active { background: var(--accent-soft); border-color: var(--accent); }
.hint { margin: 0; font-size: 12.5px; color: var(--muted); }

.list { display: flex; flex-direction: column; gap: 4px; }
.list:empty { display: none; }
.list-title { font-size: 12px; color: var(--muted); margin: 6px 4px 2px; text-transform: uppercase; letter-spacing: .5px; }
.item {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px; border-radius: 14px; text-align: start;
  transition: background .15s;
}
.item:hover, .item.active { background: var(--surface-2); }
.item .badge { width: 40px; height: 40px; }
.item-body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.item-title, .item-sub { display: block; }
.item-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-sub { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-dist { font-size: 12.5px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.badge {
  width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: color-mix(in srgb, var(--c, var(--accent)) 18%, transparent); color: var(--c, var(--accent));
  border: 1px solid color-mix(in srgb, var(--c, var(--accent)) 40%, transparent);
}
.empty { padding: 14px 6px; color: var(--muted); font-size: 13.5px; }

/* ---------- Directions ---------- */
.dir-head { display: flex; align-items: center; gap: 6px; font-size: 17px; }
.dir-fields { display: flex; align-items: center; gap: 10px; }
.dots { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 0 2px; }
.dot { width: 14px; height: 14px; border-radius: 50%; }
.dot.start { border: 3px solid #4fa3ff; box-shadow: 0 0 10px rgba(79, 163, 255, .6); }
.dot.end { background: var(--accent); box-shadow: var(--glow); }
.dots .line { width: 2px; height: 26px; background: repeating-linear-gradient(var(--muted) 0 3px, transparent 3px 7px); }
.fields { flex: 1; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.field input {
  width: 100%; height: 46px; padding: 0 14px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface); outline: none;
}
.field input:focus { border-color: var(--accent); box-shadow: var(--glow); }

.routes { display: flex; flex-direction: column; gap: 8px; }
.route {
  display: flex; align-items: center; gap: 12px; padding: 14px; border-radius: 16px; text-align: start; width: 100%;
  background: var(--surface); border: 1px solid var(--line); transition: all .2s;
}
.route.active { border-color: var(--accent); background: var(--accent-soft); box-shadow: var(--glow); }
.route-time { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.route.active .route-time { color: var(--accent); }
.route-body { flex: 1; min-width: 0; }
.route-via { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.route-side { text-align: end; font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.route-side b { display: block; color: var(--text); font-size: 14px; }
.tag { display: inline-block; font-size: 11px; padding: 1px 8px; border-radius: 999px; background: var(--accent); color: var(--accent-ink); margin-inline-start: 6px; vertical-align: middle; font-weight: 600; }

.primary-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 48px; padding: 0 18px; border-radius: 14px;
  background: var(--accent); color: var(--accent-ink); font-weight: 700; box-shadow: var(--glow); transition: transform .15s, filter .2s;
}
.primary-btn:hover { filter: brightness(1.06); }
.primary-btn:active { transform: scale(.97); }
.ghost-btn { width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; background: var(--surface); border: 1px solid var(--line); }
.ghost-btn:hover { background: var(--surface-2); }
.ghost-btn.on { color: var(--accent); border-color: var(--accent); }

.steps { border-top: 1px solid var(--line); padding-top: 8px; }
.steps summary { cursor: pointer; font-weight: 600; padding: 6px 2px; list-style: none; display: flex; align-items: center; gap: 6px; }
.steps summary::before { content: '›'; display: inline-block; transition: transform .2s; font-size: 18px; color: var(--muted); }
[dir="rtl"] .steps summary::before { content: '‹'; }
.steps[open] summary::before { transform: rotate(90deg); }
[dir="rtl"] .steps[open] summary::before { transform: rotate(-90deg); }
.steps ol { list-style: none; margin: 4px 0 0; padding: 0; display: flex; flex-direction: column; }
.step { display: flex; gap: 12px; padding: 10px 4px; border-bottom: 1px solid var(--line); cursor: pointer; border-radius: 10px; }
.step:hover { background: var(--surface); }
.step:last-child { border-bottom: 0; }
.step .mvr { width: 26px; height: 26px; color: var(--accent); margin-top: 2px; }
.mvr.mirror { transform: scaleX(-1); }
.step-text { flex: 1; }
.step-len { font-size: 12px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }

/* ---------- Place card ---------- */
.card {
  position: fixed; z-index: 6; width: 360px; border-radius: 22px; padding: 18px;
  inset-inline-start: calc(var(--panel-w) + 2 * var(--gap)); bottom: calc(var(--gap) + 10px);
  animation: rise .35s var(--ease);
}
.corner { position: absolute; top: 10px; inset-inline-end: 10px; }
.card-head { display: flex; gap: 14px; align-items: center; padding-inline-end: 30px; }
.card h2 { margin: 0; font-size: 18px; line-height: 1.35; }
.card p { margin: 2px 0 0; font-size: 13px; }
.meta { display: flex; gap: 8px; flex-wrap: wrap; margin: 14px 0; }
.meta:empty { display: none; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 10px; border: 1px solid var(--line); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.pill svg { width: 15px; height: 15px; }
.card-actions { display: flex; gap: 8px; margin-top: 14px; }
.card-actions .primary-btn { flex: 1; }
@keyframes rise { from { opacity: 0; transform: translateY(14px) scale(.98); } }

/* ---------- Floating buttons ---------- */
.fabs { position: fixed; z-index: 4; inset-inline-end: var(--gap); bottom: 36px; display: flex; flex-direction: column; gap: 10px; align-items: center; }
.fab { width: 50px; height: 50px; border-radius: 50%; display: grid; place-items: center; transition: transform .15s; font-weight: 800; font-size: 14px; }
.fab:active { transform: scale(.92); }
.fab[aria-pressed="true"] { color: var(--accent); box-shadow: var(--shadow), var(--glow); }
.fab.tracking { color: #4fa3ff; }
.zoom { border-radius: 25px; display: flex; flex-direction: column; overflow: hidden; }
.fab-plain { width: 50px; height: 46px; display: grid; place-items: center; }
.fab-plain:hover { background: var(--surface-2); }

/* ---------- Markers ---------- */
.pin { position: relative; width: 44px; height: 54px; transform-origin: bottom center; animation: drop .45s var(--ease); cursor: pointer; }
.pin .head {
  position: absolute; top: 0; left: 2px; width: 40px; height: 40px; border-radius: 50% 50% 50% 4px; transform: rotate(-45deg);
  background: var(--c, var(--accent)); box-shadow: 0 0 0 4px color-mix(in srgb, var(--c, var(--accent)) 30%, transparent), 0 0 24px color-mix(in srgb, var(--c, var(--accent)) 70%, transparent);
}
.pin .ico { position: absolute; top: 9px; left: 12px; width: 20px; height: 20px; color: #fff; }
.pin .ico svg { width: 20px; height: 20px; }
@keyframes drop { from { transform: translateY(-24px) scale(.6); opacity: 0; } }
.poi-pin { display: flex; flex-direction: column; align-items: center; gap: 4px; cursor: pointer; animation: drop .4s var(--ease); }
.poi-pin .dotico {
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; color: #fff;
  background: var(--c); border: 2px solid rgba(255, 255, 255, .9); box-shadow: 0 4px 14px rgba(0, 0, 0, .35);
}
.poi-pin .dotico svg { width: 17px; height: 17px; }
.poi-pin .label {
  max-width: 140px; padding: 2px 8px; border-radius: 8px; font-size: 11.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  background: var(--glass-strong); border: 1px solid var(--line); color: var(--text); box-shadow: 0 2px 8px rgba(0, 0, 0, .25);
}
.poi-pin.active .dotico { transform: scale(1.18); box-shadow: 0 0 0 4px color-mix(in srgb, var(--c) 35%, transparent), 0 6px 18px rgba(0, 0, 0, .4); }
.me { width: 22px; height: 22px; border-radius: 50%; background: #4fa3ff; border: 3px solid #fff; box-shadow: 0 0 0 0 rgba(79, 163, 255, .6); animation: pulse 2s infinite; }
.me-cone { position: absolute; left: 50%; top: 50%; width: 80px; height: 80px; margin: -40px; background: conic-gradient(from -30deg, rgba(79,163,255,.35) 0 60deg, transparent 60deg); border-radius: 50%; pointer-events: none; }
@keyframes pulse { 70% { box-shadow: 0 0 0 18px rgba(79, 163, 255, 0); } 100% { box-shadow: 0 0 0 0 rgba(79, 163, 255, 0); } }
.start-ring { width: 22px; height: 22px; border-radius: 50%; background: #fff; border: 5px solid #4fa3ff; box-shadow: 0 0 14px rgba(79, 163, 255, .8); }

/* ---------- Menus, sheets, toast ---------- */
.menu { position: fixed; z-index: 9; min-width: 210px; padding: 6px; border-radius: 16px; animation: rise .2s var(--ease); }
.menu button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 12px; border-radius: 10px; text-align: start; }
.menu button:hover { background: var(--surface-2); }
.menu .coords { padding: 6px 12px 8px; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; direction: ltr; text-align: start; }
.backdrop { position: fixed; inset: 0; z-index: 8; background: rgba(0, 0, 0, .35); animation: fade .2s; }
@keyframes fade { from { opacity: 0; } }
.sheet {
  position: fixed; z-index: 9; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(420px, calc(100% - 32px));
  border-radius: 24px; padding: 20px; background: var(--glass-strong); animation: rise .25s var(--ease);
}
.sheet h3 { margin: 4px 0 10px; font-size: 15px; }
.share-preview { font-size: 13px; background: var(--surface); border-radius: 12px; padding: 10px 12px; word-break: break-word; }
.share-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 12px; }
.share-opt { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 4px; border-radius: 14px; font-size: 12px; text-decoration: none; color: var(--text); text-align: center; }
.share-opt:hover { background: var(--surface-2); }
.share-ico { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; color: #fff; font-size: 18px; }
.share-ico.wa { background: #25d366; } .share-ico.tg { background: #2aabee; } .share-ico.more { background: #6b7685; } .share-ico.copy { background: var(--accent); color: var(--accent-ink); }
.seg { display: flex; gap: 6px; background: var(--surface); padding: 4px; border-radius: 14px; margin-bottom: 10px; }
.seg button { flex: 1; padding: 9px; border-radius: 10px; }
.seg button.on { background: var(--accent); color: var(--accent-ink); font-weight: 700; }
.toast {
  position: fixed; z-index: 10; left: 50%; bottom: 28px; transform: translateX(-50%); padding: 10px 18px; border-radius: 14px;
  background: var(--glass-strong); border: 1px solid var(--line); box-shadow: var(--shadow); animation: rise .25s var(--ease); max-width: calc(100% - 32px);
}

/* ---------- Phones: bottom sheet ---------- */
@media (max-width: 760px) {
  :root { --gap: 10px; }
  #panel {
    top: auto; bottom: 0; inset-inline-start: 0; width: 100%; max-height: 72%;
    border-radius: 24px 24px 0 0; padding-bottom: env(safe-area-inset-bottom);
  }
  #panel.collapsed { transform: translateY(calc(100% - 178px)); }
  #panel.collapsed.dir-mode { transform: translateY(calc(100% - 260px)); }
  .sheet-handle { display: block; width: 100%; height: 22px; flex: none; position: relative; }
  .sheet-handle::after { content: ''; position: absolute; left: 50%; top: 8px; width: 44px; height: 5px; margin-left: -22px; border-radius: 3px; background: var(--muted); opacity: .5; }
  .brand { display: none; }
  .view { padding-top: 0; }
  .hint { display: none; }
  .card { inset-inline: 10px; width: auto; bottom: calc(190px + env(safe-area-inset-bottom)); }
  .fabs { bottom: auto; top: 12px; inset-inline-end: 10px; }
  .fab { width: 46px; height: 46px; }
  .zoom { display: none; }
  .toast { bottom: auto; top: 16px; }
}

/* ---------- Live layer ---------- */
.live-pin { position: relative; width: 38px; height: 38px; border: 0; padding: 0; background: none; cursor: pointer; animation: drop .4s var(--ease); }
.live-pin .ring { position: absolute; inset: -6px; border-radius: 50%; background: radial-gradient(circle, color-mix(in srgb, var(--c) 45%, transparent), transparent 70%); animation: halo 2.4s ease-in-out infinite; }
.live-pin .ico { position: absolute; inset: 0; border-radius: 50%; display: grid; place-items: center; color: #fff; background: var(--c);
  border: 2.5px solid rgba(255, 255, 255, .95); box-shadow: 0 4px 14px rgba(0, 0, 0, .4), 0 0 18px color-mix(in srgb, var(--c) 70%, transparent); }
.live-pin .ico svg { width: 18px; height: 18px; }
.live-pin .chip { position: absolute; top: -8px; inset-inline-end: -12px; padding: 0 6px; border-radius: 8px; font-size: 11px; font-weight: 800; background: var(--glass-strong); color: var(--text); border: 1px solid var(--line); }
@keyframes halo { 50% { transform: scale(1.25); opacity: .55; } }
.live-card { z-index: 7; }
.live-card .alert-body { margin: 12px 0 0; font-size: 14px; line-height: 1.6; }
.pill.official { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); font-weight: 700; }
.ghost-btn.wide { width: auto; padding: 0 16px; flex: 1; font-weight: 600; }
.report-fab { background: linear-gradient(135deg, #ff8a4c, #ff3b6b); color: #fff; border: 0; box-shadow: 0 8px 24px rgba(255, 59, 107, .45), 0 0 0 4px rgba(255, 59, 107, .15); }
.report-fab svg { width: 24px; height: 24px; }
.report-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.report-opt { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 12px 4px; border-radius: 18px; font-size: 12.5px; font-weight: 600; text-align: center; transition: background .15s, transform .15s; }
.report-opt:hover, .report-opt.active { background: var(--surface-2); }
.report-opt:active { transform: scale(.95); }
.report-opt .ico { width: 58px; height: 58px; border-radius: 50%; display: grid; place-items: center; color: #fff; background: var(--c); box-shadow: 0 6px 20px color-mix(in srgb, var(--c) 55%, transparent); }
.report-opt .ico svg { width: 28px; height: 28px; }
.wait-row { display: flex; align-items: center; gap: 10px; margin-top: 12px; }
.wait-row input { flex: 1; accent-color: var(--accent); }
.small { font-size: 12.5px; margin: 12px 0 0; }
.fld { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; font-size: 13px; color: var(--muted); }
.fld input, .fld select, .fld textarea { padding: 11px 13px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); color: var(--text); font: inherit; outline: none; }
.fld textarea { min-height: 80px; resize: vertical; }
.fld select option { background: var(--glass-strong); color: var(--text); }
.dlg-actions { display: flex; gap: 8px; }
.dlg-actions .primary-btn { flex: 1; }
.on-route { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 12.5px; margin-top: 2px; }
.on-route .chip { padding: 4px 9px; font-size: 12px; }
.on-route .chip svg { color: var(--c); }
.notice { position: fixed; z-index: 7; top: var(--gap); left: 50%; transform: translateX(-50%); max-width: min(560px, calc(100% - 2 * var(--gap) - 440px));
  display: flex; align-items: center; gap: 10px; padding: 10px 10px 10px 16px; border-radius: 16px; font-size: 14px; }
.notice.warning { border-color: #f7b955; } .notice.critical { border-color: #ff3b6b; }
@media (max-width: 760px) { .notice { max-width: calc(100% - 120px); top: 12px; left: 10px; transform: none; } .report-grid { grid-template-columns: repeat(4, 1fr); } .report-opt .ico { width: 50px; height: 50px; } }

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