:root {
  --bg: #f7f9fa;
  --card: #ffffff;
  --teal: #1A8C7F;
  --teal-soft: #e3f2f0;
  --gold: #b58a2e;
  --gold-soft: #f6eedc;
  --text: #1f2d2b;
  --muted: #6b7b79;
  --faint: #9aa8a6;
  --line: #e7edee;
  color-scheme: light;
}
/* An element with the hidden attribute is never rendered, whatever display a class gives it.
   (Bug fix: .toast { display:flex } overrode [hidden] and left an empty white pill on screen.) */
[hidden] { display: none !important; }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); overscroll-behavior-y: contain; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", "SamsungOne", "Noto Sans Arabic", Tahoma, sans-serif;
  font-size: 16px; line-height: 1.4; min-height: 100vh; overflow-x: hidden;
  padding-bottom: env(safe-area-inset-bottom);
}
button { font: inherit; cursor: pointer; }
.ltr { direction: ltr; unicode-bidi: isolate; }

/* ---------- top bar ---------- */
.top {
  position: sticky; top: 0; z-index: 5;
  background: var(--teal); color: #fff;
  padding: calc(12px + env(safe-area-inset-top)) 18px 12px;
  box-shadow: 0 2px 12px rgba(26, 140, 127, .22);
}
.top-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.top h1 { margin: 0; font-size: 20px; font-weight: 700; }
.updated { font-size: 13px; opacity: .92; margin-top: 2px; }
.icon-btn {
  border: 0; background: rgba(255,255,255,.16); color: inherit;
  width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center; flex: none;
}
.icon-btn:active { background: rgba(255,255,255,.3); }
.icon-btn.spinning svg { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.ptr { height: 0; overflow: hidden; display: grid; place-items: center; transition: height .2s; }
.ptr-spin { width: 22px; height: 22px; border: 3px solid var(--teal-soft); border-top-color: var(--teal); border-radius: 50%; }
.ptr.active .ptr-spin { animation: spin .8s linear infinite; }

.notice {
  margin: 12px 16px 0; padding: 9px 12px; border-radius: 12px;
  background: var(--gold-soft); color: #7a5b16; font-size: 13px; border: 1px solid #ead9b0;
}

main { padding: 16px 16px 40px; max-width: 640px; margin: 0 auto; }

/* ---------- active currency ---------- */
.from-label { font-size: 13px; font-weight: 600; color: var(--teal); margin: 0 4px 8px; }
.divider { border: 0; height: 1px; background: var(--line); margin: 18px 6px; }

/* ---------- cards ---------- */
.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.card {
  position: relative; background: var(--card); border-radius: 18px;
  box-shadow: 0 1px 2px rgba(20, 60, 55, .05), 0 4px 14px rgba(20, 60, 55, .06);
  display: flex; align-items: center; gap: 12px;
  padding: 14px 14px 14px 10px;
  touch-action: pan-y;
  transition: transform .18s ease, opacity .18s ease, box-shadow .18s;
}
.card.active-card { box-shadow: 0 0 0 1.5px var(--teal-soft), 0 6px 18px rgba(26, 140, 127, .12); padding: 16px 16px 16px 14px; }
.card.dragging { z-index: 3; box-shadow: 0 10px 28px rgba(20,60,55,.18); transition: none; }
.card.swiping { transition: none; }

/* right side (first in RTL): flag + code + Arabic name */
.cur { display: flex; align-items: center; gap: 10px; flex: 1 1 0; min-width: 0; user-select: none; -webkit-user-select: none; }
.flag {
  flex: none; width: 40px; height: 40px; border-radius: 50%; display: block;
  object-fit: cover; background: #eef3f4;
  border: 1px solid #e1e8e9;   /* thin light ring so white flags keep their edge */
}
.cur-text { min-width: 0; }
.code { font-size: 19px; font-weight: 800; letter-spacing: .3px; direction: ltr; unicode-bidi: isolate; }
.name { font-size: 12.5px; color: var(--muted); line-height: 1.35; white-space: normal; overflow-wrap: anywhere; }

/* left side (last in RTL): amount + arrow line, left-aligned */
.val { flex: 0 1 auto; max-width: 58%; min-width: 0; display: flex; flex-direction: column; align-items: flex-end; }
.amt, .amount {
  direction: ltr; unicode-bidi: isolate; text-align: left;
  font-weight: 800; color: var(--text); font-variant-numeric: tabular-nums;
  font-size: 26px; line-height: 1.2; white-space: nowrap; max-width: 100%;
}
.amt { padding: 2px 0; border-bottom: 2px solid transparent; cursor: pointer; -webkit-touch-callout: none; user-select: none; -webkit-user-select: none; }
.amount {
  width: 100%; min-width: 0; border: 0; border-bottom: 2px solid transparent; border-radius: 0;
  background: transparent; padding: 2px 0; margin: 0; outline: none; -webkit-touch-callout: none;
}
.amount:focus { border-bottom-color: var(--teal); }
.active-card .val { flex: 1 1 0; max-width: 58%; }
.rate { margin-top: 3px; font-size: 12px; color: var(--faint); direction: ltr; unicode-bidi: isolate; white-space: nowrap; text-align: left; }
.rate b { color: var(--gold); font-weight: 600; }
.handle {
  flex: none; align-self: stretch; width: 22px; margin: -6px -4px -6px 0; border: 0; background: none;
  color: #c3ccca; display: grid; place-items: center; touch-action: none; font-size: 16px; padding: 0;
  cursor: grab; user-select: none; -webkit-user-select: none;
}
.card.dragging .handle { cursor: grabbing; color: var(--teal); }

.add-btn {
  margin-top: 16px; width: 100%; padding: 14px; border-radius: 16px;
  border: 1.5px dashed var(--teal); background: var(--teal-soft); color: var(--teal);
  font-weight: 700; font-size: 16px;
}
.hint { color: var(--faint); font-size: 12px; text-align: center; margin: 16px 4px 0; line-height: 1.6; }

/* ---------- add sheet ---------- */
.sheet { position: fixed; inset: 0; z-index: 20; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(31, 45, 43, .35); }
.sheet-panel {
  position: absolute; inset: auto 0 0 0; max-height: 82vh; display: flex; flex-direction: column;
  background: var(--card); border-radius: 20px 20px 0 0; padding-bottom: env(safe-area-inset-bottom);
  animation: up .2s ease;
}
@keyframes up { from { transform: translateY(40px); opacity: .4; } }
.sheet-head { display: flex; gap: 8px; padding: 14px 14px 8px; align-items: center; }
.sheet-head input {
  flex: 1; min-width: 0; padding: 11px 12px; font-size: 16px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--bg);
}
.sheet-head input:focus { outline: none; border-color: var(--teal); }
.sheet-head .close { background: var(--bg); color: var(--muted); }
.results { list-style: none; margin: 0; padding: 0 6px 12px; overflow-y: auto; }
.results li button {
  width: 100%; display: flex; align-items: center; gap: 10px; text-align: right;
  border: 0; background: none; padding: 10px 8px; border-radius: 12px; color: var(--text);
}
.results li button:active { background: var(--teal-soft); }
.results .flag { width: 34px; height: 34px; }
.results .r-name { font-weight: 600; font-size: 15px; }
.results .en { color: var(--muted); font-size: 12px; }
.results .empty { padding: 20px; text-align: center; color: var(--muted); }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(22px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: #ffffff; color: var(--text); border: 1px solid var(--line);
  box-shadow: 0 6px 20px rgba(20,60,55,.15); border-radius: 12px;
  padding: 10px 14px; font-size: 14px; z-index: 30; display: flex; gap: 12px; align-items: center;
  max-width: calc(100vw - 32px);
}
.toast button { border: 0; background: none; color: var(--teal); font-weight: 700; padding: 0; }

/* =================== preview additions (branding, contact bar, share, install sheet) =================== */
:root { --bar-h: 112px; }
body { padding-bottom: calc(var(--bar-h) + env(safe-area-inset-bottom)); }
main { padding-bottom: 28px; }

.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-logo {
  flex: none; width: 48px; height: 48px; border-radius: 14px; background: #ffffff;
  display: grid; place-items: center; box-shadow: 0 1px 4px rgba(0,0,0,.08);
}
.brand-logo img { width: 40px; height: 40px; display: block; }
.brand-text { min-width: 0; }
.agency { font-size: 12.5px; font-weight: 600; opacity: .95; line-height: 1.3; }
.top h1 { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; line-height: 1.3; }
.badge {
  font-size: 11.5px; font-weight: 800; color: #5c4410; background: #f3dfa6;
  border: 1px solid #e6c873; border-radius: 999px; padding: 1px 9px; line-height: 1.6;
}
.updated { margin-top: 8px; }

.disclaimer { color: var(--muted); font-size: 12.5px; text-align: center; margin: 14px 6px 0; line-height: 1.7; }
.extras { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-top: 16px; }
.share-btn {
  display: inline-flex; align-items: center; gap: 8px; border: 1.5px solid var(--gold);
  background: var(--gold-soft); color: #7a5b16; font-weight: 700; font-size: 15px;
  padding: 10px 22px; border-radius: 999px;
}
.share-btn:active { background: #efe0bd; }
.link-btn { border: 0; background: none; color: var(--teal); font-weight: 700; font-size: 14px; text-decoration: underline; text-underline-offset: 4px; padding: 4px 8px; }

/* fixed contact bar */
.contact-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  background: #ffffff; border-top: 1px solid var(--line);
  box-shadow: 0 -4px 18px rgba(20,60,55,.08);
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
}
.contact-inner { max-width: 640px; margin: 0 auto; }
.contact-title { font-size: 13.5px; font-weight: 700; color: var(--text); text-align: center; margin-bottom: 8px; }
.contact-title .num { color: var(--teal); font-weight: 800; margin-inline-start: 4px; font-variant-numeric: tabular-nums; }
.contact-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.cbtn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  height: 46px; border-radius: 14px; font-weight: 800; font-size: 16px; text-decoration: none;
}
.cbtn.wa { background: var(--teal); color: #fff; }
.cbtn.call { background: var(--gold-soft); color: #7a5b16; border: 1.5px solid var(--gold); }
.cbtn:active { filter: brightness(.95); }

.toast { bottom: calc(var(--bar-h) + 12px + env(safe-area-inset-bottom)); }

/* install sheet */
.install-panel { padding: 0 0 calc(16px + env(safe-area-inset-bottom)); }
.install-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 16px 8px; }
.install-head h2 { margin: 0; font-size: 18px; }
.tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin: 4px 16px 6px; background: var(--bg); padding: 4px; border-radius: 14px; }
.tabs button { border: 0; background: none; padding: 10px 6px; border-radius: 10px; font-weight: 700; color: var(--muted); font-size: 14.5px; }
.tabs button[aria-selected="true"] { background: #fff; color: var(--teal); box-shadow: 0 1px 4px rgba(20,60,55,.1); }
.panes { overflow-y: auto; }
.steps { list-style: none; margin: 0; padding: 8px 16px 4px; counter-reset: s; }
.steps li { display: flex; gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); counter-increment: s; }
.steps li:last-child { border-bottom: 0; }
.steps .ico { flex: none; width: 52px; height: 52px; position: relative; }
.steps .ico svg { width: 52px; height: 52px; display: block; }
.steps .ico::after {
  content: counter(s); position: absolute; top: -4px; inset-inline-start: -4px;
  width: 20px; height: 20px; border-radius: 50%; background: var(--gold); color: #fff;
  font-size: 12px; font-weight: 800; display: grid; place-items: center;
}
.steps b { display: block; font-size: 15px; margin-bottom: 2px; }
.steps span:not(.ico) { color: var(--muted); font-size: 13px; line-height: 1.6; }

/* =================== compact layout (preview v3, 2026-12-04) =================== */


/* header: one compact block */
.top { padding: calc(8px + env(safe-area-inset-top)) 12px 8px; }
.top-row { gap: 10px; align-items: center; justify-content: flex-start; }
.brand-logo { width: 40px; height: 40px; border-radius: 11px; }
.brand-logo img { width: 32px; height: 32px; }
.brand-text { flex: 1 1 auto; min-width: 0; }
.agency { font-size: 11px; line-height: 1.25; opacity: .9; }
.top h1 { font-size: 19px; line-height: 1.25; gap: 6px; }
.badge { font-size: 10px; padding: 0 7px; line-height: 1.6; }
.updated { font-size: 11px; line-height: 1.3; margin-top: 1px; opacity: .9; }
.icon-btn { width: 40px; height: 40px; }

main { padding: 10px 12px 20px; }
.from-label { font-size: 12px; margin: 0 4px 5px; }
.divider { margin: 10px 6px; }

/* cards */
.list { gap: 8px; }
.card { border-radius: 14px; gap: 10px; padding: 10px 12px 10px 8px; }
.card.active-card { padding: 11px 12px; }
.cur { gap: 9px; }
.flag { width: 33px; height: 33px; }
.active-card .flag { width: 36px; height: 36px; }
.code { font-size: 17px; line-height: 1.3; }
.name { font-size: 12.5px; line-height: 1.3; }
.amt, .amount { font-size: 24px; line-height: 1.2; }
.amount { font-size: 30px; }
.rate { font-size: 12px; margin-top: 2px; }
.handle { margin: -4px -2px -4px 0; }

.add-btn { margin-top: 12px; padding: 11px; border-radius: 14px; font-size: 15px; }
.disclaimer { margin-top: 10px; font-size: 12px; }
.extras { margin-top: 12px; gap: 6px; }
.share-btn { min-height: 40px; padding: 8px 20px; font-size: 14px; }
.link-btn { min-height: 40px; }
.hint { margin-top: 10px; }

/* bottom contact bar: one row */
:root { --bar-h: 58px; }
.contact-bar { padding: 7px 10px calc(7px + env(safe-area-inset-bottom)); }
.contact-btns { gap: 8px; }
.cbtn { height: 44px; border-radius: 12px; font-size: 15px; gap: 6px; white-space: nowrap; }
.cbtn .num { font-variant-numeric: tabular-nums; font-weight: 800; }

/* =================== v5: bottom bar (booking-centre caption + licence line) and ☰ menu =================== */
.top-row { gap: 8px; }
main { padding-bottom: 16px; }

:root { --bar-h: 100px; }
.contact-bar { padding: 5px 10px calc(4px + env(safe-area-inset-bottom)); }
.contact-cap { font-size: 12px; font-weight: 700; color: var(--teal); text-align: center; line-height: 1.3; margin-bottom: 4px; }
.contact-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.cbtn { height: 42px; font-size: 14px; padding: 0 6px; }
.cbtn > span { white-space: nowrap; }
.lic {
  margin-top: 4px; text-align: center; color: var(--muted); font-size: 10.5px; line-height: 1.45; font-weight: 400;
  font-family: "SF Arabic", "Noto Sans Arabic", "SamsungOne", Arial, system-ui, sans-serif;
}
.lic-seg { display: inline-block; white-space: nowrap; }   /* wraps only at a « · » boundary, never clipped */

/* sheets: drag handle + swipe down */
.grab { width: 40px; height: 4px; border-radius: 4px; background: #d5dfdd; margin: 8px auto 0; flex: none; }
.sheet-panel { transition: transform .2s ease; }
.sheet-panel.dragging { transition: none; }

/* ☰ menu */
.menu-panel { padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
.mlist { list-style: none; margin: 0; padding: 2px 10px 0; overflow-y: auto; }
.mlist > li + li { border-top: 1px solid var(--line); }
.mitem {
  width: 100%; min-height: 52px; display: flex; align-items: center; gap: 12px; text-align: right;
  border: 0; background: none; padding: 8px 6px; border-radius: 12px; color: var(--text); font-size: 15.5px; font-weight: 600;
}
.mitem:active { background: var(--teal-soft); }
.m-ico { flex: none; width: 38px; height: 38px; border-radius: 11px; background: var(--teal-soft); color: var(--teal); display: grid; place-items: center; }
.m-txt { flex: 1 1 auto; }
.m-chev { color: var(--faint); font-size: 20px; line-height: 1; }
.m-exp { transition: transform .15s; }
.mitem[aria-expanded="true"] .m-exp { transform: rotate(180deg); }
.mpanel { margin: 0 6px 12px; padding: 10px 12px; background: var(--bg); border-radius: 12px; font-size: 13.5px; line-height: 1.7; color: var(--text); }
.mpanel p { margin: 0; }
.mpanel p + p { margin-top: 6px; }
.mpanel .muted { color: var(--muted); font-size: 12.5px; }
.tips { list-style: none; }
.tips li { position: relative; padding-inline-start: 14px; }
.tips li::before { content: ""; position: absolute; inset-inline-start: 0; top: .72em; width: 6px; height: 6px; border-radius: 50%; background: var(--gold); }
.about { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 0; }
.about dt { color: var(--muted); font-size: 12.5px; }
.about dd { margin: 0; font-weight: 600; }
.about a { color: var(--teal); }

/* Licence line must stay visible at all times: sheets open ABOVE the contact bar, never over it. */
.contact-bar { z-index: 25; }
.sheet .sheet-panel { bottom: var(--bar-h); max-height: calc(100vh - var(--bar-h) - 48px); max-height: calc(100dvh - var(--bar-h) - 48px); border-radius: 20px 20px 0 0; box-shadow: 0 -6px 24px rgba(20,60,55,.12); }
.menu-panel, .install-panel { padding-bottom: 10px; }

/* =================== v7: lighter header, WhatsApp-only bar, guided tour =================== */
.top h1 { font-size: 20px; }
.updated { margin-top: 2px; }
.brand-text { padding-block: 2px; }

:root { --bar-h: 72px; }
.contact-bar { padding: 6px 10px calc(3px + env(safe-area-inset-bottom)); }
.cbtn.wide { width: 100%; height: 42px; font-size: 15px; gap: 8px; }
@media (max-width: 370px) { .cbtn.wide { font-size: 14.5px; } }
.lic { margin-top: 3px; }

/* ---- tour (coach marks) ---- */
.tour { position: fixed; inset: 0; z-index: 40; }
.tour-block { position: absolute; inset: 0; }                    /* swallows taps on the page while touring */
.tour-hole {
  position: fixed; border-radius: 14px; pointer-events: none;
  box-shadow: 0 0 0 3px var(--gold), 0 0 0 9999px rgba(31, 45, 43, .58);
  transition: top .22s ease, left .22s ease, width .22s ease, height .22s ease;
}
.tour-tip {
  position: fixed; width: min(320px, calc(100vw - 24px)); background: #fff; color: var(--text);
  border-radius: 16px; padding: 12px 14px 10px; box-shadow: 0 10px 30px rgba(20,60,55,.25);
  border-top: 3px solid var(--teal);
  transition: top .22s ease, left .22s ease, opacity .18s ease;
}
.tour-count { font-size: 11.5px; font-weight: 700; color: var(--gold); margin-bottom: 2px; }
.tour-tip p { margin: 0 0 10px; font-size: 15px; font-weight: 600; line-height: 1.6; }
.tour-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.tour-dots { display: flex; gap: 5px; }
.tour-dots i { width: 7px; height: 7px; border-radius: 50%; background: #d5dfdd; }
.tour-dots i.on { background: var(--teal); width: 18px; border-radius: 4px; }
.tour-btns { display: flex; gap: 6px; }
.tour-skip, .tour-next { min-height: 40px; border-radius: 12px; font-weight: 700; font-size: 14.5px; padding: 0 14px; }
.tour-skip { border: 0; background: none; color: var(--muted); }
.tour-next { border: 0; background: var(--teal); color: #fff; min-width: 84px; }
@media (prefers-reduced-motion: reduce) {
  .tour-hole, .tour-tip, .sheet-panel, .card { transition: none !important; }
  .sheet-panel { animation: none !important; }
}

/* =================== v8: SVG chevrons, scrollable sheets above the bar, fitted licence line =================== */
/* chevrons: one thin SVG, muted grey; link rows point left (forward in RTL), expanders point down and rotate */
.m-chev { flex: none; width: 18px; height: 18px; color: #9aa9ae; font-size: 0; }
.m-exp { transition: transform .2s ease; }
.mitem[aria-expanded="true"] .m-exp { transform: rotate(180deg); }

/* sheets sit above the bar (never under it) and scroll inside */
.sheet { z-index: 30; }
.sheet .sheet-panel {
  bottom: var(--bar-h); overflow: hidden;
  max-height: calc(100vh - var(--bar-h) - 64px);
  max-height: calc(100dvh - var(--bar-h) - 64px);
}
.mlist, .panes, .results { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.mlist { padding-bottom: calc(18px + env(safe-area-inset-bottom)); }
.panes { padding-bottom: calc(14px + env(safe-area-inset-bottom)); }
.menu-panel, .install-panel { padding-bottom: 0; }
.contact-bar { z-index: 25; }

/* tour: covers only the area above the bar; the bar (WhatsApp + licence) stays visible and undimmed */
.tour { bottom: var(--bar-h); overflow: hidden; }
.tour-hole, .tour-tip { position: absolute; }

/* licence line + WhatsApp label are fitted to one line by preview.js */
.lic { white-space: nowrap; }
.lic.wrap { white-space: normal; }
.cbtn.wide > span { white-space: nowrap; }

@media (prefers-reduced-motion: reduce) { .m-exp { transition: none !important; } }
/* the dimmed backdrop also stops at the bar, so the licence line is never dimmed or covered */
.sheet .sheet-backdrop { bottom: var(--bar-h); }
/* the sheet container itself is transparent: let taps reach the bar; only its backdrop and panel catch them */
.sheet { pointer-events: none; }
.sheet > * { pointer-events: auto; }
