:root {
  --bg: #f4eee2; --card: #fffdf8; --ink: #2a251e; --muted: #786d5d; --line: #e6decd;
  --accent: #b4532a; --accent-ink: #fff; --soft: #f3e3d6;
  --green: #4f6b2a; --green-soft: #e6eed8; --red: #b3261e; --red-soft: #f9e1dd; --amber: #b7791f;
  --top: 56px; --nav: 62px; --r: 16px;
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #171411; --card: #231f1a; --ink: #f0e8db; --muted: #a79c8a; --line: #3a332b;
    --accent: #e08a5b; --accent-ink: #1b130e; --soft: #3a2a20;
    --green: #9cc26b; --green-soft: #26301c; --red: #f2857c; --red-soft: #3b211e; --amber: #e6b450;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", "Noto Sans Arabic", "Geeza Pro", Tahoma, sans-serif;
  padding-top: calc(var(--top) + var(--safe-t));
}
body.in-trip { padding-bottom: calc(var(--nav) + var(--safe-b)); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; text-align: start; }
a { color: var(--accent); }
h1, h2, h3, p { margin: 0; }
small { color: var(--muted); font-size: .82rem; display: block; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); }
.center { text-align: center; padding: 18px 0; }
.fine { color: var(--muted); font-size: .82rem; text-align: center; padding: 4px 12px; }

/* header */
#top {
  position: fixed; inset: 0 0 auto 0; z-index: 20; height: calc(var(--top) + var(--safe-t));
  padding: var(--safe-t) 12px 0; display: flex; align-items: center; gap: 8px;
  background: var(--bg); border-bottom: 1px solid var(--line);
}
.trip-title { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; }
.trip-title b { display: block; font-size: 1.05rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.trip-title small { display: flex; align-items: center; gap: 6px; }
.logo { width: 36px; height: 36px; border-radius: 11px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; flex: none; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); display: inline-block; }
.dot.ok { background: var(--green); } .dot.wait { background: var(--amber); } .dot.bad { background: var(--red); }
.lang-btn { min-width: 44px; height: 40px; border: 1px solid var(--line); border-radius: 12px; text-align: center; font-weight: 700; background: var(--card); }

/* main */
#view { max-width: 640px; margin: 0 auto; padding: 14px 14px 28px; display: grid; gap: 14px; }
.sec { font-size: .92rem; color: var(--muted); font-weight: 600; margin: 4px 6px -6px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; display: grid; gap: 10px; }
.card.list { padding: 0; gap: 0; overflow: hidden; }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.card-h h2 { font-size: 1.02rem; }
.card-h code { font: 600 .95rem ui-monospace, Consolas, monospace; letter-spacing: .06em; background: var(--soft); padding: 4px 9px; border-radius: 8px; }
.link { color: var(--accent); font-weight: 600; padding: 6px 2px; }
.card.alert { border-color: var(--red); background: var(--red-soft); }
.card.good { border-color: var(--green); background: var(--green-soft); }
.okline { font-weight: 600; color: var(--green); }
.notice { background: var(--soft); border-radius: 12px; padding: 10px 12px; font-size: .92rem; }
.notice.warn { background: var(--red-soft); color: var(--red); }

/* hero */
.hero { background: var(--accent); color: var(--accent-ink); border-radius: 20px; padding: 18px; display: grid; gap: 8px; }
.hero h1 { font-size: 1.6rem; line-height: 1.2; }
.hero p { opacity: .9; }
.pill { justify-self: start; background: rgba(255,255,255,.2); border-radius: 999px; padding: 3px 11px; font-size: .82rem; font-weight: 600; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 6px; }
.stats.two { grid-template-columns: 1fr 1fr; margin: 0; }
.stats div { background: rgba(255,255,255,.16); border-radius: 13px; padding: 10px 6px; text-align: center; }
.stats b { display: block; font-size: 1.35rem; line-height: 1.2; }
.stats small { color: inherit; opacity: .88; }
.hero.slim .stats b { font-size: 1.12rem; }

/* radio */
.freqs { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.freq { border: 1px solid var(--line); border-radius: 13px; padding: 10px 12px; }
.freq.main { border-color: var(--accent); background: var(--soft); }
.freq b { font: 700 1.45rem/1.25 ui-monospace, Consolas, monospace; display: block; unicode-bidi: plaintext; }
[dir=rtl] .freq b { text-align: right; }
.nw { white-space: nowrap; }
#map .leaflet-top.leaflet-right { top: 52px; }
.freq b i { font: 600 .72rem system-ui, sans-serif; color: var(--muted); margin-inline-start: 5px; font-style: normal; }

/* rows */
.list.flush { margin: 0 -14px; }
.row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; width: 100%; text-decoration: none; color: inherit; border-top: 1px solid var(--line); min-height: 56px; }
.card.list > .row:first-child, .card.list > .item:first-child { border-top: 0; }
.row b { font-weight: 600; }
.row strong { white-space: nowrap; }
.chev { color: var(--muted); font-size: 1.4rem; }
[dir=rtl] .chev { transform: scaleX(-1); }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--c, var(--muted)); color: #fff; display: grid; place-items: center; font-weight: 700; flex: none; }
.avatar.plus { background: var(--soft); color: var(--accent); }
.tag { font-style: normal; font-size: .72rem; background: var(--soft); color: var(--accent); border-radius: 999px; padding: 1px 8px; margin-inline-start: 4px; }
.count { min-width: 28px; height: 28px; padding: 0 8px; border-radius: 999px; background: var(--soft); display: grid; place-items: center; font-weight: 700; font-size: .88rem; }
.count.ok { background: var(--green-soft); color: var(--green); }
.count.bad { background: var(--red-soft); color: var(--red); }
.gicon { font-size: 1.3rem; width: 32px; text-align: center; flex: none; }
.who { display: inline-flex; align-items: center; gap: 5px; font-size: .82rem; font-weight: 600; white-space: nowrap; }
.who::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: var(--c, var(--muted)); }
.who.none { color: var(--muted); font-weight: 400; }
.who.none::before { display: none; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 46px; padding: 0 16px; border-radius: 13px; border: 1px solid var(--line); background: var(--card); font-weight: 600; text-decoration: none; color: var(--ink); text-align: center; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.small { min-height: 40px; padding: 0 13px; font-size: .92rem; justify-self: start; }
.btn.big { min-height: 54px; width: 100%; font-size: 1.05rem; }
.btn.danger { color: var(--red); border-color: var(--red); background: transparent; }
.btn.danger.armed { background: var(--red); color: #fff; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; }
.actions > * { flex: 1 1 140px; }
.actions.tight > * { flex: 1 1 120px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 6px 13px; font-size: .88rem; font-weight: 600; white-space: nowrap; }
.chip.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.chip.bad { background: var(--card); color: var(--red); border-color: var(--red); }
.chip.take { color: var(--accent); border-color: var(--accent); }
.chip b { background: var(--red); color: #fff; border-radius: 999px; padding: 0 6px; font-size: .75rem; margin-inline-start: 3px; }
.bar { height: 8px; background: var(--soft); border-radius: 99px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--green); border-radius: 99px; }
.empty { text-align: center; display: grid; gap: 12px; padding: 18px 10px; color: var(--muted); justify-items: center; }

/* landing */
.landing { display: grid; gap: 14px; padding-top: 12px; }
.brand { text-align: center; display: grid; gap: 8px; justify-items: center; padding: 18px 0 8px; }
.brand-mark { width: 76px; height: 76px; border-radius: 24px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; }
.brand-mark svg { width: 42px; height: 42px; }
.brand h1 { font-size: 2rem; }
.brand p { color: var(--muted); max-width: 30ch; }

/* schedule */
.day.today { border-color: var(--accent); box-shadow: 0 0 0 2px var(--soft); }
.daynum { font-weight: 700; color: var(--accent); margin-inline-end: 8px; }
.date { color: var(--muted); font-size: .9rem; }
.day h3 { font-size: 1.1rem; }
.plan { white-space: pre-line; }
.sub { font-size: .8rem; font-weight: 700; color: var(--muted); border-top: 1px dashed var(--line); padding-top: 10px; }
.stop { display: flex; align-items: stretch; gap: 8px; border: 1px solid var(--line); border-radius: 13px; overflow: hidden; }
.stop-main { flex: 1; min-width: 0; display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; }
.stop-main small { overflow-wrap: anywhere; }
.pin { font-size: 1.35rem; line-height: 1.3; flex: none; }
.note-line { color: var(--ink); opacity: .85; margin-top: 2px; }
.go { flex: none; width: 62px; display: grid; place-items: center; align-content: center; gap: 2px; background: var(--soft); color: var(--accent); text-decoration: none; font-size: .72rem; font-weight: 700; }

/* supplies */
.item { display: flex; align-items: center; gap: 10px; padding: 8px 14px; border-top: 1px solid var(--line); min-height: 54px; }
.item-main { flex: 1; min-width: 0; padding: 4px 0; }
.item.done .item-main b { text-decoration: line-through; color: var(--muted); font-weight: 400; }
.check { display: grid; place-items: center; width: 34px; height: 34px; flex: none; cursor: pointer; }
.check input { position: absolute; opacity: 0; pointer-events: none; }
.check span { width: 26px; height: 26px; border-radius: 8px; border: 2px solid var(--muted); display: grid; place-items: center; }
.check input:checked + span { background: var(--green); border-color: var(--green); }
.check input:checked + span::after { content: "✓"; color: #fff; font-weight: 800; font-size: .95rem; }
.check input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

/* qatta */
.pay { display: flex; gap: 10px; align-items: center; padding: 10px 12px; background: var(--soft); border-radius: 12px; }
.net { font-size: .85rem; font-weight: 700; white-space: nowrap; color: var(--muted); }
.net.pos { color: var(--green); } .net.neg { color: var(--red); }

/* tabs */
#tabs { position: fixed; inset: auto 0 0 0; z-index: 20; height: calc(var(--nav) + var(--safe-b)); padding-bottom: var(--safe-b); display: grid; grid-template-columns: repeat(6, 1fr); background: var(--card); border-top: 1px solid var(--line); }
#tabs button { display: grid; justify-items: center; align-content: center; gap: 2px; color: var(--muted); font-size: .68rem; font-weight: 600; text-align: center; }
#tabs button.on { color: var(--accent); }

/* map */
#mapview { position: fixed; inset: calc(var(--top) + var(--safe-t)) 0 calc(var(--nav) + var(--safe-b)) 0; isolation: isolate; }
#map { position: absolute; inset: 0; background: var(--soft); z-index: 0; }
#map.picking { cursor: crosshair; }
#mapMsg { position: absolute; inset: 40% 20px auto; text-align: center; color: var(--muted); z-index: 1; }
.map-top { position: absolute; inset: 10px 10px auto 10px; z-index: 2; display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding-bottom: 4px; }
.map-top .chip { box-shadow: 0 1px 4px rgba(0,0,0,.2); flex: none; }
.map-bottom { position: absolute; inset: auto 12px 26px 12px; z-index: 2; display: flex; gap: 10px; align-items: center; pointer-events: none; }
.map-bottom > * { pointer-events: auto; box-shadow: 0 2px 8px rgba(0,0,0,.25); }
.map-bottom .btn { min-height: 48px; }
.round { width: 48px; height: 48px; border-radius: 50%; background: var(--card); display: grid; place-items: center; border: 1px solid var(--line); }
.banner { flex: 1; background: var(--ink); color: var(--bg); border-radius: 13px; padding: 10px 14px; display: flex; justify-content: space-between; align-items: center; gap: 10px; font-weight: 600; }
.banner .link { color: inherit; text-decoration: underline; }
.mk { width: 36px; height: 36px; border-radius: 50%; background: #fff; border: 3px solid var(--c, #b4532a); display: grid; place-items: center; font-size: 17px; box-shadow: 0 1px 5px rgba(0,0,0,.35); }
.mk.origin { width: 26px; height: 26px; background: var(--c); color: #fff; border-color: #fff; font: 700 12px system-ui, sans-serif; }
.pop { display: grid; gap: 3px; min-width: 170px; font: 14px/1.4 system-ui, sans-serif; color: #2a251e; }
.pop small { color: #786d5d; }
.pop p { margin: 2px 0; }
.pop-btns { display: flex; gap: 8px; margin-top: 6px; }
.pop-btns > * { flex: 1; text-align: center; padding: 8px 6px; border-radius: 9px; font-weight: 700; text-decoration: none; border: 1px solid #b4532a; color: #b4532a; background: #fff; font-size: 13px; }
.pop-btns a { background: #b4532a; color: #fff; }

/* sheet */
dialog#sheet { margin: auto auto 0; width: 100%; max-width: 560px; max-height: 92dvh; border: 0; padding: 0; border-radius: 22px 22px 0 0; background: var(--card); color: var(--ink); overflow: hidden; }
dialog#sheet::backdrop { background: rgba(0,0,0,.5); }
@media (min-width: 640px) { dialog#sheet { margin: auto; border-radius: 22px; } }
.sheet-form { display: flex; flex-direction: column; max-height: 92dvh; }
.sheet-form header { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 16px 16px 8px; }
.sheet-form h2 { font-size: 1.15rem; }
.x { width: 40px; height: 40px; border-radius: 50%; background: var(--soft); text-align: center; flex: none; }
.sheet-body { padding: 6px 16px 12px; overflow-y: auto; display: grid; gap: 12px; }
.sheet-form footer { display: flex; gap: 10px; padding: 10px 16px calc(14px + var(--safe-b)); border-top: 1px solid var(--line); }
.sheet-toast { display: none; margin: 0 16px 8px; padding: 9px 12px; border-radius: 11px; background: var(--red-soft); color: var(--red); font-size: .9rem; font-weight: 600; }
.sheet-toast.show { display: block; }
.field { display: grid; gap: 5px; }
.field > span, legend { font-size: .86rem; font-weight: 600; color: var(--muted); padding: 0; }
input:not([type=checkbox]):not([type=radio]), select, textarea { width: 100%; min-height: 46px; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; background: var(--bg); font-size: 16px; }
select.btn { width: auto; background: var(--card); font-weight: 600; }
textarea { resize: vertical; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; align-items: end; }
fieldset { border: 0; margin: 0; padding: 0; display: grid; gap: 8px; min-width: 0; }
.seg label, .choice { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; min-height: 48px; cursor: pointer; }
.seg label:has(input:checked), .choice:has(input:checked) { border-color: var(--accent); background: var(--soft); }
.seg label:has(input:disabled) { opacity: .5; }
.choice.inline { border: 0; padding: 4px 0; background: none !important; }
.choices { display: grid; gap: 8px; }
input[type=checkbox], input[type=radio] { width: 20px; height: 20px; accent-color: var(--accent); flex: none; margin: 0; }

/* toast */
#toast { position: fixed; inset: auto 16px calc(var(--nav) + var(--safe-b) + 14px) 16px; z-index: 40; margin: 0 auto; max-width: 420px; background: var(--ink); color: var(--bg); padding: 11px 14px; border-radius: 13px; text-align: center; font-weight: 600; opacity: 0; transform: translateY(8px); pointer-events: none; transition: opacity .2s, transform .2s; }
#toast.show { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) { #toast { transition: none; } }
