/* Ghostmode migration layer.
   This file deliberately owns the product shell so legacy RUH experiments
   cannot override the map-first layout. Core component rules remain in
   styles.css until the incremental migration is complete. */

:root {
  --gm-bg: #f5f8fc;
  --gm-surface: rgba(255, 255, 255, 0.88);
  --gm-surface-solid: #ffffff;
  --gm-surface-muted: #edf3fa;
  --gm-text: #0c1526;
  --gm-muted: #667187;
  --gm-line: rgba(54, 79, 117, 0.18);
  --gm-blue: #4f7ff4;
  --gm-blue-strong: #3568ec;
  --gm-blue-soft: rgba(79, 127, 244, 0.14);
  --gm-danger: #e95f6a;
  --gm-shadow: 0 18px 60px rgba(28, 48, 82, 0.16);
  --gm-glow: 0 0 0 1px rgba(79, 127, 244, 0.25), 0 12px 36px rgba(79, 127, 244, 0.2);
  --gm-radius: 22px;
  --topbar-height: calc(72px + var(--safe-top));
  --font-body: "Cairo", system-ui, sans-serif;
  --font-display: "Cairo", system-ui, sans-serif;
}

html[data-theme="dark"] {
  --gm-bg: #070b14;
  --gm-surface: rgba(14, 21, 36, 0.86);
  --gm-surface-solid: #0e1524;
  --gm-surface-muted: #151e30;
  --gm-text: #f3f6fc;
  --gm-muted: #98a4b9;
  --gm-line: rgba(174, 194, 230, 0.18);
  --gm-blue: #6190ff;
  --gm-blue-strong: #78a0ff;
  --gm-blue-soft: rgba(86, 135, 255, 0.16);
  --gm-shadow: 0 22px 70px rgba(0, 0, 0, 0.5);
  --gm-glow: 0 0 0 1px rgba(91, 140, 255, 0.42), 0 0 30px rgba(67, 119, 255, 0.24);
}

* { box-sizing: border-box; }

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

html, body { min-height: 100%; background: var(--gm-bg); color: var(--gm-text); }

body {
  margin: 0;
  font-family: var(--font-body);
  font-weight: 500;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

body.modal-open { overflow: hidden; }

button, input, textarea, select { font: inherit; }
button { color: inherit; }

.noise { opacity: 0.025; }
.app-shell { width: 100%; min-height: 100dvh; background: var(--gm-bg); }

.topbar {
  height: var(--topbar-height);
  padding: var(--safe-top) max(20px, var(--safe-right)) 0 max(20px, var(--safe-left));
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  background: color-mix(in srgb, var(--gm-surface-solid) 90%, transparent);
  border-bottom: 1px solid var(--gm-line);
  backdrop-filter: blur(22px) saturate(1.25);
  -webkit-backdrop-filter: blur(22px) saturate(1.25);
  z-index: 80;
  /* Header controls keep fixed physical positions in LTR and RTL locales. */
  direction: ltr;
}

/* Use the safe-area env values directly. Some embedded browsers invalidate
   the older custom-property max() shorthand and otherwise drop all padding. */
.topbar {
  padding-left: max(20px, env(safe-area-inset-left, 0px));
  padding-right: max(20px, env(safe-area-inset-right, 0px));
}

.brand { grid-column:2; justify-self:center; display:block; width:clamp(132px,14vw,188px); color:var(--gm-text); text-decoration:none; }
.brand-logo { display:block; width:100%; height:auto; }
html[data-theme="dark"] .brand-logo { filter:brightness(0) invert(1); }
.brand-mark, .onboarding-logo {
  width: 42px;
  height: 42px;
  border: 1px solid var(--gm-line);
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--gm-text);
  color: var(--gm-surface-solid);
  box-shadow: 0 8px 20px rgba(26, 43, 74, 0.18);
  font: 600 23px/1 "Kanit", sans-serif;
  font-style: normal;
  transform: none;
}

.live-pill { display: none !important; }
.city-reveal { grid-column:1; justify-self:start; min-width:0; min-height:44px; padding:4px 0; gap:8px; color:var(--gm-text); border:0; border-radius:0; background:transparent; box-shadow:none; }
.city-locator { order:2; width:30px; height:30px; background:transparent; color:var(--gm-blue); }
.city-copy { order:1; }
.city-copy b { max-width:clamp(88px,15vw,180px); font-size:14px; letter-spacing:.7px; }
.header-settings { position: relative; grid-column: 3; justify-self: end; direction: ltr; }
html[dir="rtl"] .topbar { direction: ltr; }
html[dir="rtl"] .header-settings { grid-column: 3; justify-self: end; }
.header-settings-button {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 1px solid var(--gm-line);
  border-radius: 14px;
  background: var(--gm-surface);
  color: var(--gm-text);
  box-shadow: 0 8px 24px rgba(28, 48, 82, .1);
}
.header-settings-button svg { width: 21px; fill: none; stroke: currentColor; stroke-width: 1.65; }
.header-settings-button[aria-expanded="true"] { border-color: var(--gm-blue); color: var(--gm-blue); background: var(--gm-blue-soft); box-shadow: var(--gm-glow); }
.map-settings-popover {
  position: fixed;
  z-index: 1000;
  top: calc(var(--topbar-height) - 2px);
  /* The cog is physically right-aligned in every locale, so the card must
     grow inward from that same edge instead of following RTL flow. */
  right: max(20px, env(safe-area-inset-right, 0px)) !important;
  left: auto !important;
  width: min(330px, calc(100vw - 24px));
  padding: 14px;
  border: 1px solid var(--gm-line);
  border-radius: 20px;
  background: color-mix(in srgb, var(--gm-surface-solid) 96%, transparent);
  color: var(--gm-text);
  box-shadow: var(--gm-shadow);
  backdrop-filter: blur(24px) saturate(1.2);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(-8px) scale(.98);
  transform-origin: top right;
  transition: opacity .18s ease, transform .18s cubic-bezier(.2,.8,.2,1), visibility .18s;
}
.map-settings-popover.is-open { opacity: 1; visibility: visible; pointer-events: auto; transform: translateY(0) scale(1); }
html[dir="rtl"] .map-settings-popover { direction: rtl; text-align: right; }
.map-settings-head { display: flex; align-items: center; justify-content: space-between; padding: 2px 2px 12px; font-weight: 800; }
.map-settings-head > button { width: 32px; height: 32px; border: 0; border-radius: 10px; background: var(--gm-surface-muted); color: var(--gm-text); }
.map-settings-group { padding: 12px 0; border-top: 1px solid var(--gm-line); border-bottom: 1px solid var(--gm-line); }
.map-settings-group > small { display: block; margin: 0 2px 9px; color: var(--gm-muted); font-size: 9px; font-weight: 700; letter-spacing: 1.4px; }
.map-language-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; direction: ltr !important; }
.map-language-options button { min-height: 56px; display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 8px; padding: 9px 11px; border: 1px solid var(--gm-line); border-radius: 14px; background: var(--gm-surface-muted); color: var(--gm-muted); text-align: left; }
.map-language-options button[data-map-language="en"] { grid-column: 1; direction: ltr; }
.map-language-options button[data-map-language="ar"] { grid-column: 2; direction: rtl; text-align: right; }
.map-language-options button.is-active { border-color: var(--gm-blue); background: var(--gm-blue-soft); color: var(--gm-blue-strong); }
.map-language-options b { font-size: 16px; }
.map-language-options span { font-size: 12px; }
.map-theme-row { width: 100%; min-height: 64px; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 11px; padding: 11px 4px 0; border: 0; background: transparent; color: var(--gm-text); text-align: left; }
.map-theme-icon { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 12px; background: var(--gm-blue-soft); color: var(--gm-blue); }
.map-theme-icon svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.map-theme-row b, .map-theme-row small { display: block; }
.map-theme-row b { font-size: 13px; }
.map-theme-row small { margin-top: 2px; color: var(--gm-muted); font-size: 10px; }

.view { background: var(--gm-bg); }
.map-view.is-active { display: block; height: calc(100dvh - var(--topbar-height)); min-height: 560px; padding: 0; }
.map-stage { position: relative; width: 100%; height: 100%; min-height: 560px; overflow: hidden; background: var(--gm-bg); border: 0; }
.nearby-panel { display: none !important; }
.mapbox-map, .mapbox-fallback { inset: 0; width: 100%; height: 100%; filter: none !important; }
.mapbox-map { transition: opacity .22s ease; }
.map-entry-reveal { position:absolute; inset:0; z-index:12; width:100%; height:100%; opacity:0; pointer-events:none; }
.map-entry-reveal.is-active { opacity:1; }
.map-stage.map-style-switching .mapbox-map { opacity: .72; }
html[data-theme="dark"] .mapbox-map::before,
html[data-theme="dark"] .mapbox-map::after {
  opacity: 0 !important;
  background: none !important;
  backdrop-filter: none !important;
}

.drop-pin {
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  appearance: none;
}
body.post-mode .drop-pin .drop-head { pointer-events: auto; cursor: pointer; }
.drop-pin:focus-visible .drop-pin-svg { filter: drop-shadow(0 0 9px var(--gm-blue)); }

.map-location-loader { background: var(--gm-bg); color: var(--gm-text); }
.map-location-loader small { color: var(--gm-muted); }
.map-loading-ring { border-color: var(--gm-line); border-top-color: var(--gm-blue); }

/* The Mapbox marker element remains fixed to the GPS coordinate. Only the
   artwork inside it floats, so the visual motion never changes its position. */
.user-location {
  --gm-user-ghost: #090d16;
  z-index: 2147483000 !important;
  width: 72px;
  height: 76px;
  filter: drop-shadow(0 8px 13px rgba(30, 58, 116, .22));
  isolation: isolate;
}
.mapboxgl-marker.user-location { z-index: 2147483000 !important; }
html[data-theme="dark"] .user-location { --gm-user-ghost: #f8fbff; }
.user-location > span {
  width: 50px;
  height: 53px;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}
.user-location > span::after {
  content: "";
  position: absolute;
  inset: 0;
  width: auto;
  height: auto;
  border-radius: 0;
  background: var(--gm-user-ghost);
  transform: none;
  -webkit-mask: url("assets/ghostmode-user.svg") center / contain no-repeat;
  mask: url("assets/ghostmode-user.svg") center / contain no-repeat;
  animation: ghost-user-float 4.2s ease-in-out infinite;
  filter: drop-shadow(0 4px 8px rgba(53, 104, 236, .34));
}
.user-location > i {
  inset: 7px 5px 3px;
  border-color: color-mix(in srgb, var(--gm-blue) 42%, transparent);
  animation-duration: 3.4s;
}
.user-location > em {
  top: calc(100% - 2px);
  border-width: 1px;
  border-color: var(--gm-line);
  background: var(--gm-surface-solid);
  color: var(--gm-text);
  box-shadow: 0 5px 14px rgba(21, 37, 72, .16);
}
.user-location.is-tapped > span { animation: self-core-shake .42s ease; }
.user-location.is-tapped > span::after { animation: none; }
@keyframes ghost-user-float {
  0%, 100% { transform: translateY(2px); }
  50% { transform: translateY(-5px); }
}

.mode-switch {
  top: 22px;
  left: 50%;
  width: min(370px, calc(100% - 32px));
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
  transform: translateX(-50%);
  border: 1px solid var(--gm-line);
  border-radius: 20px;
  padding: 5px;
  background: var(--gm-surface);
  box-shadow: var(--gm-shadow);
  backdrop-filter: blur(18px);
}
.mode-button { width: 100%; min-width: 0; min-height: 58px; justify-content: center; border-radius: 15px; color: var(--gm-muted); }
.mode-button.is-active { color: white; background: var(--gm-blue); box-shadow: 0 10px 26px rgba(53,104,236,.28); }
.mode-button small { color: currentColor; opacity: .66; letter-spacing: 1.1px; }
.mode-icon { font-size: 20px; }

.mode-icon svg { width:20px; height:20px; fill:none; stroke:currentColor; stroke-width:1.8; stroke-linecap:round; }

.map-actions { right: max(18px, var(--safe-right)); bottom: calc(102px + var(--safe-bottom)); border: 1px solid var(--gm-line); border-radius: 17px; overflow: hidden; background: var(--gm-surface); box-shadow: var(--gm-shadow); }
.round-button { border: 0; border-bottom: 1px solid var(--gm-line); border-radius: 0; background: transparent; color: var(--gm-text); box-shadow: none; }
.round-button:last-child { border-bottom: 0; }
.place-button { bottom: calc(104px + var(--safe-bottom)); border: 1px solid var(--gm-blue); border-radius: 999px; background: var(--gm-surface); color: var(--gm-blue-strong); box-shadow: var(--gm-glow); }

.bottom-nav {
  width: min(410px, calc(100vw - 28px - var(--safe-left) - var(--safe-right)));
  justify-content: stretch;
  bottom: calc(16px + var(--safe-bottom));
  gap: 4px;
  padding: 6px;
  border: 1px solid var(--gm-line);
  border-radius: 24px;
  background: var(--gm-surface);
  box-shadow: var(--gm-shadow);
  backdrop-filter: blur(22px) saturate(1.3);
}
.nav-button { flex: 1; min-width: 0; min-height: 58px; border-radius: 18px; color: var(--gm-muted); }
.nav-button.is-active { background: var(--gm-blue-soft); color: var(--gm-blue-strong); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--gm-blue) 55%, transparent), 0 8px 24px rgba(55,100,214,.16); }
.nav-button.map-button { min-width: 0; }
.nav-button svg { width: 22px; height: 22px; }

.feed-view, .profile-view { min-height: calc(100dvh - var(--topbar-height)); padding: 54px max(24px, var(--safe-right)) 150px max(24px, var(--safe-left)); background: var(--gm-bg); }
.page-head, .feed-filters, .feed-grid, .profile-hero, .profile-stats, .profile-tools, .profile-layout { width: min(920px, 100%); margin-left: auto; margin-right: auto; }
.page-head h1, .profile-hero h1 { color: var(--gm-text); font-size: clamp(40px, 7vw, 68px); letter-spacing: -3px; }
.eyebrow { color: var(--gm-blue-strong); letter-spacing: 2.2px; }
.new-post, .next-button, .primary-button, .post-note-button, .unlock-button, .sign-button { border: 0; border-radius: 14px; background: var(--gm-blue); color: #fff; box-shadow: 0 10px 24px rgba(53,104,236,.24); }
.feed-filters { gap: 8px; border: 0; }
.filter { border: 1px solid var(--gm-line); border-radius: 999px; background: var(--gm-surface); color: var(--gm-muted); }
.filter.is-active { border-color: var(--gm-blue); background: var(--gm-blue); color: white; }
.feed-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.feed-card, .profile-hero, .profile-stats, .badge-card, .settings-card, .bookmark-item {
  border-color: var(--gm-line);
  border-radius: var(--gm-radius);
  background: var(--gm-surface-solid);
  color: var(--gm-text);
  box-shadow: 0 10px 34px rgba(28,48,82,.08);
}
.feed-card { overflow: hidden; }
.feed-card::after { box-shadow: none; }
.feed-card-head { background: var(--gm-surface-muted) !important; color: var(--gm-text) !important; border-bottom: 1px solid var(--gm-line); }
.feed-card p, .feed-card h3, .feed-card b, .feed-card span { text-shadow: none !important; }
.feed-actions, .note-stats { border-color: var(--gm-line); }
.place-tag, .note-place { color: var(--gm-muted); }

.profile-avatar, .identity-preview { border-color: var(--gm-blue); background: var(--gm-blue-soft); box-shadow: var(--gm-glow); }
.profile-stats { overflow: hidden; }
.profile-stats > div { border-color: var(--gm-line); }
.badge-card, .badge-card h3, .badge-card b, .badge-card p, .badge-card small,
.admin-dashboard-button, .highfive-list-button { color: var(--gm-text) !important; }
.badge-card { background: var(--gm-surface-solid); border-color: var(--gm-line); }
.profile-tools {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 28px;
}
.profile-tools .admin-dashboard-button { margin: 0; }
.profile-tools .highfive-people-list { grid-column: 1 / -1; margin-top: 0; }

/* Profile controls use explicit theme pairs so legacy paper/ink variables
   cannot create white-on-light or navy-on-navy combinations. */
.admin-dashboard-button,
.highfive-list-button {
  border: 1px solid var(--gm-line) !important;
  box-shadow: none !important;
}
.admin-dashboard-button {
  background: var(--gm-blue-soft) !important;
  color: var(--gm-blue-strong) !important;
}
.highfive-list-button { background: var(--gm-surface-solid) !important; }
.admin-dashboard-button b,
.highfive-list-button b {
  background: var(--gm-blue) !important;
  color: #fff !important;
}
.admin-dashboard-button i,
.highfive-list-button i { color: currentColor; }
.section-title button {
  border: 1px solid transparent;
  color: var(--gm-muted);
}
.section-title button.is-active {
  border-color: color-mix(in srgb, var(--gm-blue) 34%, transparent);
  background: var(--gm-blue-soft);
  color: var(--gm-blue-strong);
}
.trail-item { color: var(--gm-text); border-color: var(--gm-line); }
.trail-item small,
.trail-item div div { color: var(--gm-muted); }
.trail-map-button {
  border-color: var(--gm-blue);
  background: var(--gm-blue);
  color: #fff;
  box-shadow: 0 8px 20px rgba(53, 104, 236, .2);
}
.trail-map-button svg { color: currentColor; }
.trail-actions > button:not(.trail-map-button) {
  border-color: var(--gm-line);
  color: var(--gm-muted);
}
.trail-actions > button:not(.trail-map-button):hover {
  border-color: var(--gm-blue);
  background: var(--gm-blue-soft);
  color: var(--gm-blue-strong);
}

.modal-backdrop { background: rgba(2, 7, 18, .58); backdrop-filter: blur(8px); }
.modal[hidden] { display: none !important; }
.modal {
  --modal-enter-scale: 1;
  --modal-enter-y: 0px;
  top: 50%;
  left: 50%;
  width: min(560px, calc(100vw - 24px - var(--safe-left) - var(--safe-right)));
  max-height: calc(100dvh - 24px - var(--safe-top) - var(--safe-bottom));
  transform: translate(-50%, calc(-50% + var(--modal-enter-y))) scale(var(--modal-enter-scale));
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  scroll-padding-block: 24px;
}
.modal.is-open {
  transform: translate(-50%, calc(-50% + var(--modal-enter-y))) scale(var(--modal-enter-scale));
}
.modal, .comments-modal, .report-modal {
  border: 1px solid var(--gm-line);
  border-radius: 24px;
  background: var(--gm-surface-solid);
  color: var(--gm-text);
  box-shadow: var(--gm-shadow);
}
.composer {
  width: min(620px, calc(100vw - 24px));
  padding: 22px;
  overflow-y: hidden;
}
.composer h2 { font-size: 30px; }
.composer .eyebrow { margin-bottom: 4px; }
.composer-body textarea, .poll-builder input, .photo-caption-input, .comment-form input, .report-modal textarea, .report-modal select { background: var(--gm-surface-muted); border-color: var(--gm-line); color: var(--gm-text); }
.media-types { margin: 16px 0 12px; overflow-x: auto; justify-content: flex-start; scrollbar-width: none; }
.media-types::-webkit-scrollbar { display: none; }
.media-types button { flex: 1 0 72px; min-height: 64px; padding: 7px 4px; justify-content: center; gap: 5px; border-color: var(--gm-line); color: var(--gm-muted); background: var(--gm-surface-muted); }
.media-types button.is-active { background: var(--gm-blue); border-color: var(--gm-blue); color: white; }
.media-type-icon { width: 24px; height: 24px; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.composer .composer-body,
.composer .composer-state,
.composer .media-panel { min-height: 138px; }
.composer .composer-body textarea { height: 138px; }
.composer .composer-footer { margin-top: 12px; }
.media-types button:focus-visible { outline: 3px solid color-mix(in srgb, var(--gm-blue) 34%, transparent); outline-offset: 2px; }
.review-builder { display: grid; gap: 16px; }
.review-builder textarea { min-height: 130px; width: 100%; resize: vertical; padding: 14px; border: 1px solid var(--gm-line); border-radius: 14px; background: var(--gm-surface-muted); color: var(--gm-text); }
.review-stars { display: flex; justify-content: center; gap: 7px; }
.review-stars button { border: 0; background: transparent; color: var(--gm-line); font-size: 34px; line-height: 1; }
.review-stars button.is-selected { color: var(--gm-blue); text-shadow: 0 0 16px rgba(79,127,244,.38); }
.note-review-stars { margin: 14px 0; color: var(--gm-blue); font-size: 24px; letter-spacing: 4px; }

/* React composer: compact, theme-native media tools with no nested scroller. */
.react-composer-body { display: block; }
.react-composer-body > .media-panel { width: 100%; }
.react-doodle-panel { display: grid; grid-template-rows: auto 1fr; gap: 8px; }
.has-react-canvas { position: relative; overflow: hidden; }
.has-react-canvas canvas { display: block; width: 100%; height: 100%; touch-action: none; cursor: crosshair; }
.has-react-canvas .drag-draw-hint { pointer-events: none; }
.has-react-canvas:has(canvas:active) .drag-draw-hint { opacity: 0; }
.voice-recorder audio { width: min(100%, 340px); height: 34px; }
.voice-waveform { height: 22px; display: flex; align-items: center; justify-content: center; gap: 3px; }
.voice-waveform i { width: 3px; height: 5px; border-radius: 4px; background: var(--gm-blue); opacity: .38; transform-origin: center; }
.voice-waveform.is-live i { animation: gm-voice-wave .72s ease-in-out infinite alternate; opacity: .85; }
.voice-waveform i:nth-child(3n) { animation-delay: -.22s; }
.voice-waveform i:nth-child(4n) { animation-delay: -.44s; }
.photo-picker .media-type-icon { width: 32px; height: 32px; margin: 0 auto 8px; }
.photo-picker b, .photo-picker small { display: block; }
.photo-picker small { margin-top: 5px; color: var(--gm-muted); }
@keyframes gm-voice-wave { to { height: 20px; } }

.note-map-link { display: none; }
.stat-button, .vote, .translate-button { border-color: var(--gm-line); background: transparent; color: var(--gm-text); }

/* Shared voting and action icons: a fixed touch target keeps cards and modals aligned. */
.vote.vote-up,
.vote.vote-down {
  min-width: 42px;
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  border-radius: 12px;
  font-weight: 800;
  line-height: 1;
}
.vote.vote-up svg,
.vote.vote-down svg,
.feed-more-button svg,
.react-note-head-actions button svg,
.react-modal-close svg,
.note-delete-button svg,
.feed-delete-button svg,
.react-note-place svg,
.place-tag svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.25;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: 0 0 auto;
}
.vote.vote-up { color: var(--gm-blue-strong); border-color: color-mix(in srgb, var(--gm-blue) 54%, var(--gm-line)); }
.vote.vote-down { color: #d94a5b; border-color: color-mix(in srgb, #e6505f 48%, var(--gm-line)); }
.vote.vote-up.is-voted { background: var(--gm-blue); border-color: var(--gm-blue); color: #fff; box-shadow: 0 6px 16px color-mix(in srgb, var(--gm-blue) 35%, transparent); }
.vote.vote-down.is-voted { background: #df4f5e; border-color: #df4f5e; color: #fff; box-shadow: 0 6px 16px rgba(223,79,94,.28); }
.vote.vote-up:hover { background: color-mix(in srgb, var(--gm-blue) 13%, transparent); }
.vote.vote-down:hover { background: rgba(223,79,94,.11); }
.feed-more-button,
.react-note-head-actions button,
.react-modal-close,
.note-delete-button,
.feed-delete-button {
  display: inline-grid;
  place-items: center;
}
.feed-more-button svg { width: 19px; height: 19px; stroke: none; fill: currentColor; }
.react-note-head-actions button svg,
.react-modal-close svg { width: 18px; height: 18px; }
.note-delete-button,
.feed-delete-button { color: #df4f5e; }
.react-note-place,
.place-tag { display: inline-flex; align-items: center; gap: 5px; }
.react-note-place svg,
.place-tag svg { width: 13px; height: 13px; stroke-width: 2; }
.react-modal-close { font-size: 0; line-height: 0; }

.user-location { z-index: 2147483000 !important; filter: drop-shadow(0 0 7px rgba(79,127,244,.65)) drop-shadow(0 10px 15px rgba(31,74,181,.3)); }
.user-location > span { border: 0; border-radius: 0; background: transparent; box-shadow: none; }
.user-location > i { border: 0; background: radial-gradient(circle, rgba(95,145,255,.26), rgba(95,145,255,0) 68%); animation: location-wave 3.2s ease-out infinite; }
.user-location em { border-color: var(--gm-blue); background: var(--gm-surface-solid); color: var(--gm-blue-strong); }
.note-pin {
  width:auto;
  min-width:72px;
  max-width:190px;
  height:auto;
  min-height:42px;
  padding:5px 8px 5px 5px;
  gap:0;
  border:1px solid color-mix(in srgb, var(--gm-blue) 42%, var(--gm-line));
  border-radius:16px;
  background:color-mix(in srgb, var(--gm-surface-solid) 94%, transparent) !important;
  color:var(--gm-text) !important;
  box-shadow:0 8px 22px rgba(17,42,91,.18), inset 0 0 0 1px rgba(255,255,255,.34);
  filter:none;
  backdrop-filter:blur(12px);
}
.note-pin .pin-bounce { min-width:0; gap:7px; }
.note-type-icon { width:30px; height:30px; flex:0 0 auto; display:grid; place-items:center; border-radius:11px; background:var(--gm-blue-soft); color:var(--gm-blue-strong); }
.note-type-icon svg { width:18px; height:18px; fill:none; stroke:currentColor; stroke-width:1.8; stroke-linecap:round; stroke-linejoin:round; }
.note-pin-copy { min-width:0; max-width:112px; overflow:hidden; color:var(--gm-text); font:700 9px/1.25 "Cairo",sans-serif; text-align:start; text-overflow:ellipsis; white-space:nowrap; }
.note-pin-metrics { display:flex; align-items:center; gap:5px; flex:0 0 auto; color:var(--gm-muted); font:700 8px/1 "Cairo",sans-serif; }
.note-pin-metrics:empty { display:none; }
.note-pin-metrics b { font:inherit; }
.note-pin-metrics b + b::before { content:"·"; margin-inline-end:5px; opacity:.55; }
.note-pin.locked {
  min-width:72px;
  width:auto;
  height:auto;
  opacity:.68;
  filter:none !important;
  background:color-mix(in srgb, var(--gm-surface-solid) 90%, var(--gm-blue) 10%) !important;
  color:var(--gm-text) !important;
  border-color:color-mix(in srgb, var(--gm-blue) 58%, var(--gm-line)) !important;
}
.note-pin.locked .note-pin-copy { max-width:78px; }
.note-pin.locked .note-type-icon { background:color-mix(in srgb, var(--gm-blue-soft) 74%, transparent); color:var(--gm-blue-strong); }
.feed-card.visual { --note-color:var(--gm-surface-muted) !important; --note-ink:var(--gm-text) !important; }
.trail-pin svg, .avatar-bubble svg { width:20px; height:20px; fill:none; stroke:currentColor; stroke-width:1.8; stroke-linecap:round; stroke-linejoin:round; }

/* Launch/auth surface. The smoke canvas is a real WebGL layer mounted by
   ghost-smoke.js; the older ASCII canvas remains only as a graceful fallback. */
.launch-splash {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100dvh;
  padding: 0;
  z-index: 45;
  background: var(--gm-bg);
  color: var(--gm-text);
}
.launch-atmosphere, .launch-smoke, .launch-ascii { position: absolute; inset: 0; width: 100%; height: 100%; }
.launch-ascii { opacity: 0; }
.launch-atmosphere { z-index: 1; opacity: .72; pointer-events: none; }
.launch-smoke { z-index: 2; opacity: .9; touch-action: none; }
html[data-theme="dark"] .launch-atmosphere { opacity: .88; }
html[data-theme="dark"] .launch-smoke { opacity: 1; }
.launch-ascii-fallback { display: none; }
.launch-brand-lockup { position: absolute; z-index: 4; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; pointer-events: none; }
.launch-ghost-mark { width: 86px; height: 104px; display: grid; place-items: center; margin-bottom: 22px; border: 1px solid color-mix(in srgb, var(--gm-blue) 58%, transparent); border-radius: 50% 50% 50% 50% / 42% 42% 58% 58%; background: color-mix(in srgb, var(--gm-surface) 72%, transparent); color: var(--gm-text); box-shadow: var(--gm-glow); }
.launch-ghost-mark span { font: 600 38px/1 "Kanit", sans-serif; }
.launch-title { position: static; transform: none; font: 600 clamp(48px, 9vw, 78px)/1 "Kanit", sans-serif; letter-spacing: -3px; color: var(--gm-text); text-shadow: none; }
.launch-title::first-letter { color: var(--gm-blue); }
.launch-kicker { margin-top: 14px; color: var(--gm-blue-strong); font-size: 12px; font-weight: 700; letter-spacing: 4px; }
.launch-brand-lockup p { margin: 10px 0 0; color: var(--gm-muted); font-size: 14px; }
.launch-progress { z-index: 5; bottom: 74px; width: min(260px, 54vw); height: 3px; background: var(--gm-line); }
.launch-progress i { background: var(--gm-blue); box-shadow: 0 0 14px var(--gm-blue); }
.launch-status { z-index: 5; bottom: 94px; color: var(--gm-muted); }

/* Onboarding reuses the real Google host and profile persistence but adopts
   the supplied Ghostmode hierarchy and restrained glass treatment. */
.onboarding {
  width: min(560px, calc(100vw - 24px - var(--safe-left) - var(--safe-right)));
  min-height: 0;
  max-height: calc(100dvh - 24px - var(--safe-top) - var(--safe-bottom));
  padding: 28px;
  border-radius: 30px;
  background: var(--gm-surface);
  backdrop-filter: blur(28px) saturate(1.25);
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  box-sizing: border-box;
}
.onboarding-step { min-height: min(540px, calc(100dvh - 80px - var(--safe-top) - var(--safe-bottom))); gap: 12px; }
.onboarding-step h2 { color: var(--gm-text); font-size: clamp(35px, 7vw, 54px); line-height: 1.02; letter-spacing: -2.5px; }
.onboarding-step > p { color: var(--gm-muted); font-size: 14px; line-height: 1.7; }
.onboarding-logo { width: 72px; height: 72px; margin-bottom: 18px; font-size: 34px; }
.google-button { border: 1px solid var(--gm-line); border-radius: 14px; background: var(--gm-surface-solid); color: var(--gm-text); box-shadow: 0 12px 34px rgba(25,50,94,.14); }
.concept-deck { width: 100%; }
.concept-card { border: 1px solid var(--gm-line); border-radius: 18px; background: var(--gm-surface-muted); color: var(--gm-text); box-shadow: none; }
.concept-card.is-active { border-color: var(--gm-blue); background: var(--gm-blue-soft); box-shadow: var(--gm-glow); }
.concept-card b { color: var(--gm-blue-strong); font: 700 12px "Cairo", sans-serif; }
.concept-card small { color: var(--gm-muted); }
.onboarding-language-grid { display: grid; grid-template-columns: 1fr 1fr; direction: ltr !important; width: 100%; gap: 12px; margin: 24px 0; }
.onboarding-language-grid button { min-height: 112px; display: grid; place-items: center; gap: 4px; border: 1px solid var(--gm-line); border-radius: 18px; background: var(--gm-surface-muted); color: var(--gm-text); }
.onboarding-language-grid [data-onboarding-language="en"] { grid-column: 1; direction: ltr; }
.onboarding-language-grid [data-onboarding-language="ar"] { grid-column: 2; direction: rtl; }
.onboarding-language-grid button.is-active { border-color: var(--gm-blue); background: var(--gm-blue-soft); box-shadow: var(--gm-glow); }
.onboarding-language-grid b { color: var(--gm-blue-strong); font-size: 26px; }
.paper { background: #f7f3e9; color: #111827; }
.promise-step { max-width: 100%; min-height: 0; justify-content: flex-start; }
.signature-draw { border-color: rgba(59,96,169,.24); }
.signature-draw .draw-start { stroke: var(--gm-blue); }
.signature-draw .draw-end { fill: #78d8ff; }
.signature-clear,
.signature-footer span:first-child { color: var(--gm-blue-strong); }
.pen-flourish span { background: linear-gradient(90deg, #163fae, #2f7cff 62%, #78d8ff); }

body:has(.onboarding.is-open .auth-step.is-active) .onboarding {
  width: 100vw;
  max-width: none;
  min-height: 100dvh;
  max-height: 100dvh;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
  pointer-events: none !important;
}
body:has(.onboarding.is-open .auth-step.is-active) .modal-backdrop { background: transparent; backdrop-filter: none; }
body:has(.onboarding.is-open .auth-step.is-active) .launch-brand-lockup { opacity: 0; }
body:has(.onboarding.is-open .auth-step.is-active) .launch-status,
body:has(.onboarding.is-open .auth-step.is-active) .launch-progress { opacity: 0; }
body:has(.onboarding.is-open .auth-step.is-active) .auth-step {
  position: fixed;
  inset: auto 0 max(34px, calc(var(--safe-bottom) + 22px));
  width: 100%;
  min-height: 0;
  margin: 0;
  padding: 0 20px;
  display: block;
  pointer-events: none;
}
body.launch-active:has(.onboarding.is-open .auth-step.is-active) #reactOnboardingRoot {
  position: fixed;
  z-index: 106;
  inset: auto 0 calc(24px + var(--safe-bottom));
  width: 100%;
  pointer-events: none;
}
body.launch-active:has(.onboarding.is-open .auth-step.is-active) #reactOnboardingRoot .react-onboarding-auth {
  min-height: 0;
  width: 100%;
  padding: 0 20px;
  pointer-events: none;
}
body.launch-active:has(.onboarding.is-open .auth-step.is-active) #reactOnboardingRoot .react-auth-copy { pointer-events: none; }
body.launch-active:has(.onboarding.is-open .auth-step.is-active) #reactOnboardingRoot .react-google-button { pointer-events: auto; }
html[data-theme="dark"] .react-auth-copy strong { color: #edf5ff; }
html[data-theme="dark"] .react-auth-copy p { color: rgba(205,222,250,.68); }
body:has(.onboarding.is-open .auth-step.is-active) .auth-step button,
body:has(.onboarding.is-open .auth-step.is-active) .auth-step a,
body:has(.onboarding.is-open .auth-step.is-active) .auth-step input,
body:has(.onboarding.is-open .auth-step.is-active) .auth-step iframe { pointer-events: auto; }
body:has(.onboarding.is-open .auth-step.is-active) .auth-actions {
  width: min(390px, 100%);
  margin: 0 auto;
  display: grid;
  gap: 10px;
  justify-items: stretch;
  pointer-events: auto;
}
body:has(.onboarding.is-open .auth-step.is-active) .auth-actions > small {
  color: var(--gm-muted);
  text-align: center;
  font-size: 10px;
  letter-spacing: .08em;
  text-transform: uppercase;
  text-shadow: 0 1px 12px var(--gm-bg);
}
body:has(.onboarding.is-open .auth-step.is-active) .google-button,
body:has(.onboarding.is-open .auth-step.is-active) .google-button-host {
  width: 100%;
  min-height: 50px;
  border-radius: 16px;
  overflow: hidden;
}

/* The launch screen owns the full viewport. Only its compact preference
   controls remain above the smoke; normal app chrome arrives afterward. */
body.launch-active .topbar {
  position: fixed;
  inset: 0 0 auto;
  height: calc(62px + var(--safe-top));
  padding: var(--safe-top) max(18px, var(--safe-right)) 0 max(18px, var(--safe-left));
  border: 0;
  background: transparent;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  pointer-events: none;
  z-index: 90;
}
/* A transformed ancestor becomes the containing block for fixed children.
   Legacy view transitions transform `.view`, which used to offset the
   full-screen launch surface below the header on phones. */
body.launch-active #mapView {
  transform: none !important;
  animation: none !important;
}
body.launch-active #launchSplash {
  inset: 0 !important;
  height: 100dvh !important;
}
body.launch-active .topbar .brand,
body.launch-active .topbar .live-pill,
body.launch-active .topbar .city-reveal,
body.launch-active .topbar .header-settings { visibility: hidden; }
body.launch-active #onboarding.is-open {
  display: block;
  opacity: 1 !important;
  visibility: visible !important;
  pointer-events: none !important;
  z-index: 70;
}
body.launch-active #onboarding.is-open .close-button { display: none; }
body.launch-active #onboarding.is-open:not(:has(.auth-step.is-active)) {
  pointer-events: auto !important;
}
body.launch-active #onboarding.is-open:not(:has(.auth-step.is-active)) .onboarding-step,
body.launch-active #onboarding.is-open:not(:has(.auth-step.is-active)) .onboarding-step * {
  pointer-events: auto;
}
body.launch-active #onboarding.is-open .auth-actions,
body.launch-active #onboarding.is-open .auth-actions * { pointer-events: auto; }
body.launch-active .topbar { z-index: 100 !important; }

@media (max-width: 720px) {
  :root { --topbar-height: calc(64px + var(--safe-top)); }
  .topbar { grid-template-columns: auto minmax(0, 1fr) auto; padding-left: max(14px, env(safe-area-inset-left, 0px)); padding-right: max(14px, env(safe-area-inset-right, 0px)); }
  .brand { width:124px; }
  .city-reveal { max-width:128px; justify-self:start; }
  .city-copy b { max-width:82px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; font-size:12px; }
  .mode-switch { top: 14px; width: calc(100% - 28px); }
  .mode-button { min-height: 55px; }
  .map-actions { bottom: calc(100px + var(--safe-bottom)); right: max(12px, var(--safe-right)); }
  .place-button { bottom: calc(102px + var(--safe-bottom)); }
  .feed-view, .profile-view { padding: 34px max(18px, var(--safe-right)) calc(190px + var(--safe-bottom)) max(18px, var(--safe-left)); }
  .feed-grid { grid-template-columns: 1fr; gap: 16px; }
  .page-head h1, .profile-hero h1 { font-size: 46px; letter-spacing: -2.5px; }
  .page-head { align-items: flex-end; }
  .new-post { padding: 12px 14px; }
  .profile-tools { grid-template-columns: 1fr; gap: 10px; margin-bottom: 24px; }
  .profile-tools .highfive-people-list { grid-column: 1; }
  .modal {
    width: calc(100vw - 16px - var(--safe-left) - var(--safe-right));
    max-height: calc(100dvh - 16px - var(--safe-top) - var(--safe-bottom));
    border-radius: 22px;
  }
  .composer {
    padding: 18px 16px calc(18px + var(--safe-bottom));
    overflow-y: hidden;
  }
  .composer h2 { font-size: 27px; }
  .composer .media-types { margin: 12px 0 10px; }
  .composer .media-types button { flex-basis: 68px; min-height: 58px; }
  .composer .composer-body,
  .composer .composer-state,
  .composer .media-panel { min-height: 124px; }
  .composer .composer-body textarea { height: 124px; padding: 12px; }
  .onboarding { width: calc(100vw - 16px - var(--safe-left) - var(--safe-right)); max-height:calc(100dvh - 16px - var(--safe-top) - var(--safe-bottom)); padding: 20px 16px calc(24px + var(--safe-bottom)); }
  .onboarding-step { min-height: min(500px, calc(100dvh - 64px - var(--safe-top) - var(--safe-bottom))); justify-content: flex-start; padding-top: 28px; padding-bottom: 12px; }
  .onboarding-step .next-button,
  .promise-actions { position: sticky; bottom: 0; z-index: 12; }
  .onboarding-step .next-button { margin-top: 18px; }
  .promise-actions { width: 100%; padding: 12px 0 2px; background: linear-gradient(180deg, transparent, var(--gm-surface) 22%); }
  .onboarding-step h2 { font-size: 38px; }
  .onboarding-language-grid { gap: 10px; margin: 18px 0; }
  .onboarding-language-grid button { min-height: 96px; }
  .launch-title { font-size: 52px; letter-spacing: -2px; }
  .launch-brand-lockup p { font-size: 12px; }
  .header-settings-button { width: 38px; height: 38px; border-radius: 12px; }
  .map-settings-popover {
    position: fixed;
    top: calc(var(--topbar-height) - 4px);
    right: max(10px, env(safe-area-inset-right, 0px)) !important;
    left: auto !important;
    width: min(330px, calc(100vw - 20px - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px)));
  }
}

@media (max-height: 640px) {
  .composer { overflow-y: auto; }
}

@media (max-height: 760px) {
  .onboarding { padding-top: 18px; padding-bottom: calc(18px + var(--safe-bottom)); }
  .onboarding-step { min-height: 0; }
  .promise-heading { margin-bottom: 10px; }
  .promise-heading h2 { font-size: clamp(30px, 6vw, 42px); }
  .paper { padding-top: 24px; padding-bottom: 18px; }
  .promise-copy { margin: 12px auto; font-size: 16px; }
  .signature-draw { height: clamp(130px, 24dvh, 175px); }
  .promise-actions { padding-bottom: 2px; }
}

@media (prefers-reduced-motion: reduce) {
  .launch-atmosphere { opacity: .42; }
  .launch-smoke { display: none; }
  .user-location > span::after { animation: none; }
}

/* React onboarding owns the visible auth surface. The legacy Google button
   remains as a hidden bridge for the existing GSI callback, but its absolute
   positioning must not leak into the React button. */
#reactOnboardingRoot .react-google-button {
  position: static;
  inset: auto;
  z-index: auto;
  width: min(100%, 360px);
  height: 48px;
  min-height: 48px !important;
}

/* React owns the visible map controls. These legacy elements remain mounted
   only because app.js still listens to their IDs as command bridges. */

.react-map-actions { z-index: 22; }
.react-place-button { z-index: 22; }

/* The promise is now React-owned. Keep the old canvas step mounted as a
   compatibility bridge for app.js, but never render two ceremonies. */
.onboarding > .promise-step { display: none !important; }
.react-onboarding-promise { width: 100%; min-height: 0; display: flex; flex-direction: column; gap: 12px; justify-content: flex-start; }
.react-onboarding-promise .promise-heading { width: 100%; margin: 0 0 4px; }
.react-onboarding-promise .react-paper-roll { width: 100%; margin: 0 auto; opacity: 1; clip-path: none; }
.react-onboarding-promise .react-paper { position: relative; min-height: 380px; overflow: hidden; padding: 22px 24px 18px; border: 1px solid rgba(25,35,55,.16); box-shadow: 0 15px 30px rgba(25,35,55,.12); }
.react-onboarding-promise .paper-masthead { display: flex; justify-content: space-between; align-items: center; color: #6b7280; font: 600 8px var(--font-body); letter-spacing: 1px; text-transform: uppercase; }
.react-onboarding-promise .paper-emoji { font-size: 20px; }
.react-onboarding-promise .react-signature-stage { margin-top: 8px; }
.react-onboarding-promise .react-signature-draw { position: relative; height: 170px; border: 0; background: rgba(255,255,255,.42); }
.react-signature-canvas { display: block; width: 100%; height: 100%; cursor: crosshair; touch-action: none; }
.react-onboarding-promise .react-signature-draw .drag-draw-hint { pointer-events: none; }
.react-onboarding-promise .react-promise-actions { min-height: 50px; display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 10px; }
.react-onboarding-promise .react-promise-actions .promise-status { flex: 1 1 100%; text-align: center; }
.react-eula-overlay { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 18px; background: rgba(4,10,22,.54); backdrop-filter: blur(12px); }
.react-eula-card { position: relative; width: min(520px, 100%); max-height: min(620px, calc(100dvh - 36px)); overflow: auto; padding: 28px; border: 1px solid var(--gm-line); border-radius: 24px; background: var(--gm-surface-solid); color: var(--gm-text); box-shadow: var(--gm-shadow); }
.react-eula-card h2 { margin: 12px 0 18px; font-size: clamp(28px, 6vw, 42px); }
.react-eula-card p { color: var(--gm-muted); line-height: 1.7; }
html[dir="rtl"] .react-onboarding-promise .promise-heading,
html[dir="rtl"] .react-onboarding-promise .paper { direction: rtl; }
@media (max-width: 560px) {
  .react-onboarding-promise .react-paper { min-height: 360px; padding: 17px 14px 13px; }
  .react-onboarding-promise .promise-copy { font-size: 17px; line-height: 1.4; margin: 14px auto; }
  .react-onboarding-promise .react-signature-draw { height: 160px; }
  .react-eula-card { padding: 22px 18px; }
}
