:root {
  --teal: #003F47;
  --teal-2: #0A5560;
  --orange: #EA6932;
  --ink: #0E2226;
  --muted: #5F6D70;
  --faint: #8A9699;
  --line: #E7ECED;
  --soft: #F4F7F7;
  --white: #FFFFFF;
  --shadow: 0 1px 2px rgba(0, 35, 40, .06), 0 12px 32px -8px rgba(0, 35, 40, .18);
  --shadow-sm: 0 1px 2px rgba(0, 35, 40, .08), 0 4px 14px -4px rgba(0, 35, 40, .16);
  --radius: 20px;
  --panel-w: 384px;
  --gap: 16px;
  --peek: 184px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --serif: "Fraunces", Georgia, "Times New Roman", serif;
  --arabic: "IBM Plex Sans Arabic", "Inter", system-ui, sans-serif;
  --ease: cubic-bezier(.22, .8, .24, 1);
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--white); }
body {
  font-family: var(--sans);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  overscroll-behavior: none;
}
html[lang="ar"] body { font-family: var(--arabic); }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
a { color: inherit; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
[hidden] { display: none !important; }
.ar { font-family: var(--arabic); }
:focus-visible { outline: 2px solid var(--orange); outline-offset: 2px; }

#map { position: fixed; inset: 0; background: var(--white); }

/* ───────── Pills & buttons ───────── */
.pill {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; padding: 0 14px;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--white); color: var(--teal);
  font-size: 13px; font-weight: 500; white-space: nowrap;
  transition: background .2s, border-color .2s;
}
.pill:hover { border-color: #cfd8d9; background: var(--soft); }
#langToggle { font-family: var(--arabic); }
html[lang="ar"] #langToggle { font-family: var(--sans); }

/* ───────── Top bar ───────── */
.topbar {
  position: fixed; z-index: 20;
  top: calc(var(--gap) + var(--safe-t)); inset-inline-end: var(--gap);
  display: flex; gap: 8px; align-items: center;
}
.seg {
  display: flex; padding: 4px; gap: 2px;
  background: var(--white); border-radius: 999px; box-shadow: var(--shadow-sm);
}
.seg button {
  border: 0; background: transparent; color: var(--muted);
  height: 32px; padding: 0 13px; border-radius: 999px;
  font-size: 13px; font-weight: 500;
  transition: background .25s var(--ease), color .25s;
}
.seg button:hover { color: var(--teal); }
.seg button[aria-checked="true"] { background: var(--teal); color: var(--white); }
.fly {
  display: inline-flex; align-items: center; gap: 8px;
  height: 40px; padding: 0 16px 0 14px; border: 0; border-radius: 999px;
  background: var(--orange); color: var(--white);
  font-size: 13.5px; font-weight: 600; letter-spacing: .01em;
  box-shadow: 0 6px 18px -6px rgba(234, 105, 50, .6);
  transition: transform .2s var(--ease), background .2s;
}
.fly:hover { background: #d95c27; }
.fly:active { transform: scale(.97); }
.fly circle { fill: currentColor; stroke: none; }

/* ───────── Panel (desktop) ───────── */
.panel {
  position: fixed; z-index: 15;
  top: var(--gap); bottom: var(--gap); inset-inline-start: var(--gap);
  width: var(--panel-w);
  display: flex; flex-direction: column;
  background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow);
  overflow: hidden;
}
.handle { display: none; }
.panel-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  padding: 22px 22px 6px;
}
.eyebrow {
  margin: 0 0 4px; font-size: 11px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase;
  color: var(--orange);
}
html[lang="ar"] .eyebrow { letter-spacing: 0; font-size: 12px; }
.panel-head h1 {
  margin: 0; font-family: var(--serif); font-weight: 500; font-size: 28px; line-height: 1.1;
  letter-spacing: -.01em; color: var(--teal); font-optical-sizing: auto;
}
html[lang="ar"] .panel-head h1 { font-family: var(--arabic); font-weight: 600; font-size: 25px; letter-spacing: 0; }

.back {
  display: flex; align-items: center; gap: 6px;
  margin: 8px 22px 0; padding: 8px 0;
  font-size: 13px; font-weight: 500; color: var(--teal); text-decoration: none;
  border-bottom: 1px solid transparent; width: max-content;
}
.back:hover { color: var(--orange); }
.back svg { width: 16px; height: 16px; }
[dir="rtl"] .back svg { transform: scaleX(-1); }

.search {
  position: relative; display: block; margin: 10px 22px 12px;
}
.search svg { position: absolute; top: 50%; inset-inline-start: 14px; transform: translateY(-50%); color: var(--faint); }
.search input {
  width: 100%; height: 44px; padding: 0 16px; padding-inline-start: 42px;
  border: 1px solid var(--line); border-radius: 14px; background: var(--soft);
  font-size: 15px; outline: none; transition: border-color .2s, background .2s, box-shadow .2s;
  -webkit-appearance: none; appearance: none;
}
.search input::placeholder { color: var(--faint); }
.search input:focus { background: var(--white); border-color: var(--teal); box-shadow: 0 0 0 3px rgba(0, 63, 71, .08); }

.filters {
  display: flex; flex-wrap: wrap; gap: 6px; padding: 0 22px 12px;
}
.chip {
  display: inline-flex; align-items: center; gap: 7px;
  height: 32px; padding: 0 12px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--white); color: var(--ink);
  font-size: 12.5px; font-weight: 500; white-space: nowrap;
  transition: background .2s, color .2s, border-color .2s;
}
.chip:hover { border-color: #cdd6d7; }
.chip i { width: 8px; height: 8px; border-radius: 50%; background: var(--c); flex: none; }
.chip b { font-weight: 500; color: var(--faint); font-size: 11.5px; }
.chip[aria-pressed="true"] { background: var(--teal); border-color: var(--teal); color: var(--white); }
.chip[aria-pressed="true"] b { color: rgba(255, 255, 255, .7); }
.chip[aria-pressed="true"] i { box-shadow: 0 0 0 2px rgba(255, 255, 255, .9); }

.count {
  margin: 0; padding: 8px 22px; font-size: 11.5px; font-weight: 600; letter-spacing: .08em;
  text-transform: uppercase; color: var(--faint); border-top: 1px solid var(--line);
}
html[lang="ar"] .count { letter-spacing: 0; font-size: 12px; }

.list {
  list-style: none; margin: 0; padding: 0 10px 16px; overflow-y: auto; flex: 1; min-height: 0;
  overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
}
.item {
  width: 100%; display: grid; grid-template-columns: 52px 1fr auto; gap: 12px; align-items: center;
  padding: 9px 12px; border: 0; border-radius: 14px; background: transparent; text-align: start;
  transition: background .15s;
}
.item:hover { background: var(--soft); }
.item[aria-current="true"] { background: #EEF4F4; }
.thumb {
  position: relative; width: 52px; height: 52px; border-radius: 12px; overflow: hidden;
  background: color-mix(in srgb, var(--c) 12%, white);
  display: grid; place-items: center;
}
.thumb::after { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--c); }
.thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: 1; }
.item-text { min-width: 0; }
.item-name {
  display: block; font-size: 14.5px; font-weight: 500; color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.item-sub {
  display: block; margin-top: 2px; font-size: 12.5px; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.star {
  width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center;
  background: rgba(234, 105, 50, .12); color: var(--orange);
}
.star svg { width: 12px; height: 12px; fill: currentColor; stroke: none; }
.empty { padding: 28px 16px; text-align: center; color: var(--muted); font-size: 14px; }

/* ───────── Card ───────── */
.card {
  position: fixed; z-index: 25;
  top: calc(var(--gap) + 56px + var(--safe-t)); inset-inline-end: var(--gap);
  width: 380px; max-height: calc(100dvh - 88px - var(--gap));
  overflow-y: auto; overscroll-behavior: contain;
  background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow);
  animation: rise .45s var(--ease);
}
@keyframes rise { from { opacity: 0; transform: translateY(10px) scale(.985); } to { opacity: 1; transform: none; } }
.card-close {
  position: absolute; top: 12px; inset-inline-end: 12px; z-index: 2;
  width: 34px; height: 34px; border-radius: 50%; border: 0;
  background: rgba(255, 255, 255, .94); color: var(--teal); display: grid; place-items: center;
  box-shadow: var(--shadow-sm);
}
.card-media {
  position: relative; aspect-ratio: 16 / 10; background: color-mix(in srgb, var(--c, var(--teal)) 10%, white);
  overflow: hidden;
}
.card-media img { width: 100%; height: 100%; object-fit: cover; display: block; animation: fade .5s ease; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.card-media.noimg {
  aspect-ratio: auto; height: 92px;
  background:
    radial-gradient(120% 140% at 0% 0%, color-mix(in srgb, var(--c) 22%, white) 0%, transparent 60%),
    radial-gradient(90% 120% at 100% 100%, color-mix(in srgb, var(--c) 14%, white) 0%, white 70%);
}
.card-body { padding: 18px 22px 22px; }
.meta { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.tag {
  display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600; background: var(--soft); color: var(--teal);
}
.tag i { width: 7px; height: 7px; border-radius: 50%; background: var(--c); }
.tag.feat { background: rgba(234, 105, 50, .12); color: #C4521F; }
.card h2 {
  margin: 0; font-family: var(--serif); font-weight: 500; font-size: 25px; line-height: 1.15;
  letter-spacing: -.01em; color: var(--teal);
}
html[lang="ar"] .card h2.ar { font-family: var(--arabic); font-weight: 600; font-size: 23px; letter-spacing: 0; }
.card .alt { margin: 6px 0 0; font-size: 16px; color: var(--muted); }
.card .alt.ar { font-size: 17px; }
.card .alt.en { font-family: var(--serif); font-size: 16px; }
.card .sub { margin: 12px 0 0; font-size: 13.5px; font-weight: 500; color: var(--teal-2); }
.card .desc { margin: 10px 0 0; font-size: 14.5px; line-height: 1.6; color: #3B4A4D; }
.card .hours { display: flex; gap: 8px; align-items: center; margin: 12px 0 0; font-size: 13px; color: var(--muted); }
.card .hours svg { width: 15px; height: 15px; color: var(--faint); }
.card .menu { display: inline-block; margin-top: 10px; font-size: 13px; font-weight: 500; color: var(--teal); }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 18px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 46px; padding: 0 14px; border-radius: 14px; text-decoration: none;
  font-size: 14px; font-weight: 600; border: 1px solid transparent; transition: background .2s, border-color .2s;
}
.btn svg { width: 17px; height: 17px; }
.btn-primary { grid-column: 1 / -1; background: var(--teal); color: var(--white); }
.btn-primary:hover { background: #00525C; }
.btn-outline { background: var(--white); border-color: var(--line); color: var(--teal); }
.btn-outline:hover { border-color: var(--teal); }
.btn-accent { background: var(--orange); color: var(--white); }
.btn-accent:hover { background: #d95c27; }
.actions .btn:only-of-type, .actions .btn-outline:last-child:nth-child(2) { grid-column: 1 / -1; }
[dir="rtl"] .flip { transform: scaleX(-1); }

/* ───────── Tour caption ───────── */
.tour {
  position: fixed; z-index: 22; bottom: calc(28px + var(--safe-b));
  left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 18px;
  padding: 12px 12px 12px 22px; padding-inline-start: 22px; padding-inline-end: 12px;
  background: var(--white); border-radius: 999px; box-shadow: var(--shadow);
  animation: rise .5s var(--ease); max-width: calc(100vw - 24px);
}
.tour-text { display: flex; flex-direction: column; min-width: 0; }
.tour-step { font-size: 11px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--orange); }
html[lang="ar"] .tour-step { letter-spacing: 0; }
.tour-name {
  font-family: var(--serif); font-weight: 500; font-size: 18px; color: var(--teal);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
html[lang="ar"] .tour-name { font-family: var(--arabic); font-weight: 600; }

.notice {
  position: fixed; z-index: 40; top: 50%; left: 50%; transform: translate(-50%, -50%);
  max-width: 340px; padding: 20px 22px; border-radius: 16px; background: var(--white); box-shadow: var(--shadow);
  font-size: 14px; color: var(--muted); text-align: center;
}

/* ───────── Map overrides ───────── */
.mapboxgl-ctrl-group { border-radius: 14px !important; box-shadow: var(--shadow-sm) !important; overflow: hidden; }
.mapboxgl-ctrl-group button { width: 36px !important; height: 36px !important; }
.mapboxgl-canvas-container.mapboxgl-interactive, .mapboxgl-canvas { cursor: grab; }

@media (min-width: 768px) {
  [dir="ltr"] .mapboxgl-ctrl-bottom-left { left: calc(var(--panel-w) + var(--gap)); }
  [dir="rtl"] .mapboxgl-ctrl-bottom-right { right: calc(var(--panel-w) + var(--gap)); }
  .tour { left: calc(50% + (var(--panel-w) + var(--gap)) / 2); }
  [dir="rtl"] .tour { left: calc(50% - (var(--panel-w) + var(--gap)) / 2); }
}

/* ───────── Mobile: bottom sheet ───────── */
@media (max-width: 767px) {
  :root { --gap: 10px; }
  .topbar { inset-inline: var(--gap); justify-content: space-between; }
  .seg { padding: 3px; }
  .seg button { height: 32px; padding: 0 10px; font-size: 12.5px; }
  .fly { height: 38px; padding: 0 14px 0 12px; font-size: 13px; }

  .panel {
    top: auto; bottom: 0; inset-inline: 0; width: auto;
    height: calc(90dvh - var(--safe-t));
    border-radius: 22px 22px 0 0;
    box-shadow: 0 -10px 40px -12px rgba(0, 35, 40, .25);
    transition: transform .42s var(--ease);
    will-change: transform;
    padding-bottom: var(--safe-b);
  }
  .panel[data-state="peek"] { transform: translateY(calc(100% - var(--peek) - var(--safe-b))); }
  .panel[data-state="half"] { transform: translateY(45%); }
  .panel[data-state="full"] { transform: translateY(0); }
  .panel.dragging { transition: none; }
  body.touring .panel, body.card-open .panel { transform: translateY(calc(100% + 20px)); }

  .grab { touch-action: none; cursor: grab; }
  .handle { display: flex; justify-content: center; padding: 10px 0 2px; }
  .handle span { width: 38px; height: 4px; border-radius: 4px; background: #D6DDDE; }
  .panel-head { padding: 6px 18px 0; }
  .panel-head h1 { font-size: 24px; }
  html[lang="ar"] .panel-head h1 { font-size: 22px; }
  .back { margin: 4px 18px 0; padding: 6px 0; }
  .search { margin: 6px 16px 12px; }
  .filters { flex-wrap: nowrap; overflow-x: auto; padding: 0 16px 12px; scrollbar-width: none; }
  .filters::-webkit-scrollbar { display: none; }
  .count { padding: 8px 18px; }
  .list { padding: 0 6px 24px; }

  .card {
    top: auto; bottom: calc(8px + var(--safe-b)); inset-inline: 8px; width: auto;
    max-height: min(74dvh, 640px); border-radius: 22px;
    animation: sheet .45s var(--ease);
  }
  @keyframes sheet { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
  .card-media { aspect-ratio: 16 / 9; }
  .card-body { padding: 16px 18px 18px; }
  .card h2 { font-size: 22px; }

  .tour { bottom: calc(16px + var(--safe-b)); gap: 12px; padding-inline-start: 18px; width: max-content; }
  .tour-name { font-size: 16px; }

  .mapboxgl-ctrl-bottom-left, .mapboxgl-ctrl-bottom-right { bottom: calc(var(--peek) + var(--safe-b)); transition: bottom .3s; }
  body.card-open .mapboxgl-ctrl-bottom-left, body.card-open .mapboxgl-ctrl-bottom-right,
  body.touring .mapboxgl-ctrl-bottom-left, body.touring .mapboxgl-ctrl-bottom-right { bottom: calc(0px + var(--safe-b)); }
  .mapboxgl-ctrl-top-right, .mapboxgl-ctrl-bottom-right .mapboxgl-ctrl-group { display: none; }
}

@media (max-width: 380px) {
  .seg button { padding: 0 8px; font-size: 12px; }
  .fly span { display: none; }
  .fly { width: 38px; padding: 0; justify-content: center; }
}

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