/* ============================================================
   Aurora — liquid glass design system
   Palette   ink #0A0B14 · violet #7C5CFF · teal #2DD4BF
             male #3B82F6 · female #F472B6 · rose #FF6B81
   Type      Bricolage Grotesque (display) / Figtree (body)
   Signature the discovery map: a breathing radius aura with
             gender-haloed avatar pucks that settle into place
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Bricolage+Grotesque:opsz,wght@12..96,500;12..96,700&family=Figtree:wght@400;500;600;700&display=swap');

:root {
  --ink: #0A0B14;
  --ink-soft: #12141F;
  --glass: rgba(255, 255, 255, .055);
  --glass-hi: rgba(255, 255, 255, .10);
  --glass-lo: rgba(255, 255, 255, .03);
  --line: rgba(255, 255, 255, .11);
  --line-hi: rgba(255, 255, 255, .2);
  --text: #EDEEF5;
  --muted: #98A0B8;
  --faint: #666E85;
  --violet: #7C5CFF;
  --teal: #2DD4BF;
  --male: #3B82F6;
  --female: #F472B6;
  --neutral: #A78BFA;
  --rose: #FF6B81;
  --amber: #FBBF24;

  --r-xs: 10px; --r-sm: 14px; --r-md: 20px; --r-lg: 28px; --r-xl: 36px;
  --blur: blur(28px) saturate(160%);
  --shadow: 0 18px 50px rgba(0, 0, 0, .45);
  --ease: cubic-bezier(.22, 1, .36, 1);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bot: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: var(--ink); color: var(--text);
  font-family: Figtree, ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-size: 16px; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

body::before {
  content: ''; position: fixed; inset: -20%; z-index: -2; pointer-events: none;
  background:
    radial-gradient(46% 38% at 12% 4%, rgba(124, 92, 255, .34), transparent 62%),
    radial-gradient(40% 34% at 92% 12%, rgba(45, 212, 191, .20), transparent 60%),
    radial-gradient(52% 44% at 60% 104%, rgba(244, 114, 182, .16), transparent 62%);
  filter: blur(28px);
  animation: drift 34s var(--ease) infinite alternate;
}
@keyframes drift {
  0%   { transform: translate3d(0, 0, 0) scale(1); }
  50%  { transform: translate3d(-3%, 2%, 0) scale(1.06); }
  100% { transform: translate3d(2%, -3%, 0) scale(1.02); }
}

h1, h2, h3, .display {
  font-family: 'Bricolage Grotesque', Figtree, system-ui, sans-serif;
  font-weight: 700; letter-spacing: -.02em; margin: 0;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; }
a { color: var(--violet); text-decoration: none; }
::-webkit-scrollbar { width: 0; height: 0; }

/* ---------------------------------------------------------- primitives */

.glass {
  background: var(--glass);
  border: 1px solid var(--line);
  backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
  border-radius: var(--r-lg);
}
.muted { color: var(--muted); }
.faint { color: var(--faint); font-size: 13px; }
.center { display: grid; place-items: center; }
.row { display: flex; align-items: center; gap: 12px; }
.grow { flex: 1; min-width: 0; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hidden { display: none !important; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 13px 20px; border-radius: var(--r-md); font-weight: 600; font-size: 15px;
  background: var(--glass-hi); border: 1px solid var(--line);
  transition: transform .16s var(--ease), background .18s, opacity .18s;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; pointer-events: none; }
.btn.primary {
  background: linear-gradient(135deg, var(--violet), #9F7BFF 55%, var(--teal));
  color: #08090F; border: 0; box-shadow: 0 10px 26px rgba(124, 92, 255, .35);
}
.btn.ghost { background: transparent; }
.btn.danger { background: rgba(255, 107, 129, .14); border-color: rgba(255, 107, 129, .4); color: #FFA3B0; }
.btn.wide { width: 100%; }
.btn.sm { padding: 8px 14px; font-size: 13px; border-radius: var(--r-sm); }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 6px; letter-spacing: .01em; }
.input, textarea.input, select.input {
  width: 100%; padding: 14px 16px; border-radius: var(--r-md);
  background: var(--glass-lo); border: 1px solid var(--line); outline: none;
  transition: border-color .18s, box-shadow .18s, background .18s;
}
.input:focus, textarea.input:focus, select.input:focus {
  border-color: var(--violet); background: var(--glass);
  box-shadow: 0 0 0 3px rgba(124, 92, 255, .22);
}
.input::placeholder { color: var(--faint); }
:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 13px; border-radius: 999px; font-size: 13px; font-weight: 500;
  background: var(--glass); border: 1px solid var(--line);
  transition: all .18s var(--ease);
}
.pill.on { background: rgba(124, 92, 255, .22); border-color: rgba(124, 92, 255, .55); color: #D8CDFF; }
.pill:active { transform: scale(.95); }

.badge {
  min-width: 19px; height: 19px; padding: 0 6px; border-radius: 999px;
  background: var(--rose); color: #12040A; font-size: 11px; font-weight: 700;
  display: grid; place-items: center;
}

/* ------------------------------------------------------------- avatars */

.av { position: relative; flex: none; border-radius: 50%; overflow: hidden; background: var(--glass-hi); }
.av img { width: 100%; height: 100%; object-fit: cover; display: block; }
.av .initials {
  width: 100%; height: 100%; display: grid; place-items: center;
  font-weight: 700; font-family: 'Bricolage Grotesque', sans-serif; color: #0B0C14;
}
.av-wrap { position: relative; flex: none; }
.av-wrap .dot {
  position: absolute; right: -1px; bottom: -1px; width: 13px; height: 13px;
  border-radius: 50%; background: var(--teal); border: 2.5px solid var(--ink);
}
.av-wrap .dot.off { background: var(--faint); }
.gender-male { --g: var(--male); }
.gender-female { --g: var(--female); }
.gender-other { --g: var(--neutral); }
.ringed { box-shadow: 0 0 0 2.5px var(--g, var(--neutral)), 0 0 18px -2px var(--g, var(--neutral)); }

/* --------------------------------------------------------------- shell */

#splash {
  position: fixed; inset: 0; z-index: 200; display: grid; place-items: center;
  background: var(--ink); transition: opacity .5s var(--ease), visibility .5s;
}
#splash.gone { opacity: 0; visibility: hidden; }
#splash .inner { text-align: center; animation: rise .8s var(--ease) both; }
#splash .mark {
  width: 96px; height: 96px; margin: 0 auto 22px; border-radius: 30px;
  background: linear-gradient(140deg, var(--violet), var(--teal));
  display: grid; place-items: center; font-size: 44px;
  box-shadow: 0 20px 60px rgba(124, 92, 255, .45);
  animation: breathe 3.2s var(--ease) infinite;
}
#splash .mark img { width: 100%; height: 100%; object-fit: cover; border-radius: 30px; }
#splash h1 { font-size: 34px; }
#splash .tag { color: var(--muted); margin-top: 6px; font-size: 15px; }
#splash .by { position: fixed; bottom: calc(34px + var(--safe-bot)); left: 0; right: 0; text-align: center;
  color: var(--faint); font-size: 12.5px; letter-spacing: .06em; text-transform: uppercase; }
@keyframes rise { from { opacity: 0; transform: translateY(18px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes breathe { 0%,100% { transform: scale(1); } 50% { transform: scale(1.06); } }

#app { height: 100%; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 30; padding: calc(12px + var(--safe-top)) 16px 12px;
  display: flex; align-items: center; gap: 12px; min-height: 60px;
  background: linear-gradient(180deg, rgba(10, 11, 20, .92), rgba(10, 11, 20, .55));
  backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
  border-bottom: 1px solid var(--line);
}
.topbar h2 { font-size: 21px; }

.screen { flex: 1; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; }
.screen.pad { padding: 16px 16px calc(24px + var(--safe-bot)); }

.view { display: none; height: 100%; flex-direction: column; }
.view.active { display: flex; animation: fadeUp .3s var(--ease); }
@keyframes fadeUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* -------------------------------------------------------------- tabbar */

.tabbar {
  display: flex; padding: 8px 10px calc(8px + var(--safe-bot));
  background: rgba(12, 13, 22, .78); border-top: 1px solid var(--line);
  backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
}
.tab {
  flex: 1; padding: 8px 0 6px; display: grid; justify-items: center; gap: 3px;
  color: var(--faint); font-size: 10.5px; font-weight: 600; letter-spacing: .02em;
  position: relative; transition: color .2s;
}
.tab svg { width: 23px; height: 23px; stroke-width: 1.9; transition: transform .28s var(--ease); }
.tab.on { color: var(--text); }
.tab.on svg { transform: translateY(-2px) scale(1.08); stroke: var(--violet); }
.tab .badge { position: absolute; top: 2px; right: calc(50% - 22px); }

/* ---------------------------------------------------------- chat lists */

.list-item {
  display: flex; gap: 13px; align-items: center; padding: 12px 14px;
  border-radius: var(--r-md); transition: background .18s, transform .16s var(--ease);
}
.list-item:active { transform: scale(.985); background: var(--glass); }
.list-item .name { font-weight: 600; font-size: 15.5px; }
.list-item .snippet { color: var(--muted); font-size: 13.5px; }
.list-item .meta { text-align: right; display: grid; gap: 5px; justify-items: end; flex: none; }
.list-item .time { font-size: 11.5px; color: var(--faint); }

.empty { text-align: center; padding: 56px 28px; color: var(--muted); }
.empty .icon { font-size: 40px; margin-bottom: 14px; opacity: .85; }
.empty h3 { font-size: 17px; margin-bottom: 6px; color: var(--text); }

/* ---------------------------------------------------------- chat thread */

#thread { padding: 16px 12px 8px; display: flex; flex-direction: column; gap: 3px; }

.bubble-row { display: flex; margin-top: 8px; animation: pop .3s var(--ease) both; }
.bubble-row.mine { justify-content: flex-end; }
.bubble-row.tight { margin-top: 2px; }
@keyframes pop { from { opacity: 0; transform: translateY(12px) scale(.96); } to { opacity: 1; transform: none; } }

.bubble {
  position: relative; max-width: 78%; padding: 10px 14px 8px;
  border-radius: 22px; font-size: 15.5px; line-height: 1.42;
  border: 1px solid var(--line); background: var(--glass);
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  word-break: break-word; transition: transform .18s var(--ease);
  user-select: none;
}
.bubble.mine {
  background: linear-gradient(140deg, rgba(124, 92, 255, .46), rgba(45, 212, 191, .26));
  border-color: rgba(160, 130, 255, .42);
}
.bubble.held { transform: scale(1.04); }
.bubble .stamp { font-size: 10.5px; color: var(--faint); margin-top: 3px; text-align: right; }
.bubble.mine .stamp { color: rgba(255, 255, 255, .58); }
.bubble .tick { margin-left: 4px; letter-spacing: -2px; }
.bubble .tick.read { color: var(--teal); }
.bubble img.att { max-width: 100%; border-radius: 16px; display: block; margin-bottom: 4px; }
.bubble .locked { color: var(--amber); font-size: 13.5px; font-style: italic; }
.bubble .gone { color: var(--faint); font-style: italic; font-size: 14px; }

.reacts { display: flex; gap: 3px; margin: 4px 0 0; padding-left: 8px; }
.bubble-row.mine .reacts { justify-content: flex-end; padding: 0 8px 0 0; }
.react-chip {
  background: rgba(16, 17, 28, .9); border: 1px solid var(--line);
  border-radius: 999px; padding: 2px 8px; font-size: 13px;
  animation: pop .28s var(--ease) both;
}

.reactbar {
  position: fixed; z-index: 90; display: flex; gap: 4px; padding: 8px 10px;
  background: rgba(18, 19, 30, .93); border: 1px solid var(--line-hi);
  border-radius: 999px; box-shadow: var(--shadow);
  backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
  animation: reactIn .3s var(--ease) both;
}
@keyframes reactIn { from { opacity: 0; transform: translateY(10px) scale(.82); } to { opacity: 1; transform: none; } }
.reactbar button { font-size: 25px; padding: 3px 5px; transition: transform .16s var(--ease); }
.reactbar button:active { transform: scale(1.4) translateY(-4px); }

.composer {
  display: flex; align-items: flex-end; gap: 8px; padding: 10px 12px calc(10px + var(--safe-bot));
  background: rgba(12, 13, 22, .84); border-top: 1px solid var(--line);
  backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
}
.composer textarea {
  flex: 1; resize: none; max-height: 130px; padding: 12px 16px; border-radius: 24px;
  background: var(--glass-lo); border: 1px solid var(--line); outline: none; line-height: 1.4;
}
.composer textarea:focus { border-color: rgba(124, 92, 255, .55); }
.icon-btn {
  width: 44px; height: 44px; flex: none; border-radius: 50%; display: grid; place-items: center;
  background: var(--glass); border: 1px solid var(--line); transition: transform .16s var(--ease), background .18s;
}
.icon-btn:active { transform: scale(.9); }
.icon-btn.send { background: linear-gradient(135deg, var(--violet), var(--teal)); border: 0; color: #08090F; }
.icon-btn.rec { background: rgba(255, 107, 129, .2); border-color: rgba(255, 107, 129, .5); }
.icon-btn svg { width: 21px; height: 21px; }

.typing { display: flex; gap: 4px; padding: 12px 16px; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: bounce 1.3s infinite; }
.typing i:nth-child(2) { animation-delay: .18s; }
.typing i:nth-child(3) { animation-delay: .36s; }
@keyframes bounce { 0%, 60%, 100% { transform: none; opacity: .4; } 30% { transform: translateY(-6px); opacity: 1; } }

/* ----------------------------------------------------------------- map */

#map { position: absolute; inset: 0; background: #0C0E16; }
.map-wrap { position: relative; flex: 1; }
.leaflet-container { background: #0C0E16; font-family: Figtree, sans-serif; }
.leaflet-control-attribution {
  background: rgba(10, 11, 20, .75) !important; color: var(--faint) !important;
  border-radius: 8px 0 0 0; font-size: 10px !important;
}
.leaflet-control-attribution a { color: var(--muted) !important; }

.puck {
  width: 46px; height: 46px; border-radius: 50%; position: relative;
  background: rgba(16, 18, 28, .9); display: grid; place-items: center;
  box-shadow: 0 0 0 2.5px var(--g), 0 6px 22px rgba(0, 0, 0, .55), 0 0 22px -4px var(--g);
  animation: settle .5s var(--ease) both; overflow: visible;
}
@keyframes settle { from { opacity: 0; transform: translateY(-16px) scale(.5); } to { opacity: 1; transform: none; } }
.puck img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.puck .sym { font-size: 21px; line-height: 1; }
.puck.live::after {
  content: ''; position: absolute; inset: -7px; border-radius: 50%;
  border: 2px solid var(--g); animation: sonar 2.1s ease-out infinite;
}
@keyframes sonar { 0% { opacity: .8; transform: scale(.85); } 100% { opacity: 0; transform: scale(1.6); } }

.self-puck { width: 20px; height: 20px; border-radius: 50%; background: var(--teal);
  box-shadow: 0 0 0 4px rgba(45, 212, 191, .25), 0 0 24px rgba(45, 212, 191, .7); }

.map-panel {
  position: absolute; left: 12px; right: 12px; bottom: 16px; z-index: 500;
  padding: 16px 18px; border-radius: var(--r-lg);
  background: rgba(14, 15, 25, .8); border: 1px solid var(--line);
  backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur); box-shadow: var(--shadow);
  animation: fadeUp .35s var(--ease);
}
.map-top { position: absolute; left: 12px; right: 12px; top: calc(12px + var(--safe-top)); z-index: 500; display: flex; gap: 8px; }
.radius-row { display: flex; align-items: center; gap: 12px; margin-top: 12px; }
input[type=range] {
  -webkit-appearance: none; appearance: none; flex: 1; height: 5px; border-radius: 999px;
  background: linear-gradient(90deg, var(--violet), var(--teal)); outline: none;
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 24px; height: 24px; border-radius: 50%;
  background: #fff; box-shadow: 0 3px 12px rgba(0, 0, 0, .5); cursor: pointer;
}
input[type=range]::-moz-range-thumb { width: 24px; height: 24px; border: 0; border-radius: 50%; background: #fff; }

.ghost-banner {
  border-radius: var(--r-md); padding: 13px 16px; font-size: 13.5px;
  background: rgba(167, 139, 250, .14); border: 1px solid rgba(167, 139, 250, .38); color: #D6C9FF;
}

/* --------------------------------------------------------------- sheet */

.scrim {
  position: fixed; inset: 0; z-index: 100; background: rgba(4, 5, 10, .62);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  opacity: 0; pointer-events: none; transition: opacity .28s var(--ease);
}
.scrim.open { opacity: 1; pointer-events: auto; }

.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 110; max-height: 88vh;
  display: flex; flex-direction: column;
  padding: 10px 18px calc(22px + var(--safe-bot));
  background: rgba(15, 16, 26, .93); border: 1px solid var(--line); border-bottom: 0;
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
  box-shadow: 0 -20px 60px rgba(0, 0, 0, .55);
  transform: translateY(102%); transition: transform .38s var(--ease);
}
.sheet.open { transform: none; }
.sheet .grip { width: 42px; height: 4px; border-radius: 999px; background: var(--line-hi); margin: 4px auto 14px; flex: none; }
.sheet .sheet-body { overflow-y: auto; }
.sheet h3 { font-size: 19px; margin-bottom: 4px; }

.toast {
  position: fixed; left: 50%; bottom: calc(96px + var(--safe-bot)); z-index: 300;
  transform: translate(-50%, 24px); opacity: 0; pointer-events: none;
  padding: 12px 20px; border-radius: 999px; font-size: 14px; max-width: 88vw; text-align: center;
  background: rgba(20, 21, 33, .95); border: 1px solid var(--line-hi); box-shadow: var(--shadow);
  transition: all .32s var(--ease);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.bad { border-color: rgba(255, 107, 129, .55); color: #FFB3BD; }

/* -------------------------------------------------------------- status */

.story-strip { display: flex; gap: 14px; overflow-x: auto; padding: 4px 2px 14px; }
.story { display: grid; justify-items: center; gap: 6px; width: 74px; flex: none; font-size: 11.5px; }
.story .ring {
  width: 64px; height: 64px; border-radius: 50%; padding: 2.5px;
  background: linear-gradient(135deg, var(--violet), var(--teal));
}
.story .ring.seen { background: var(--line-hi); }
.story .ring .av { width: 100%; height: 100%; border: 2.5px solid var(--ink); }

.story-view { position: fixed; inset: 0; z-index: 150; background: #06070C; display: none; flex-direction: column; }
.story-view.open { display: flex; }
.story-progress { display: flex; gap: 4px; padding: calc(12px + var(--safe-top)) 14px 8px; }
.story-progress i { flex: 1; height: 2.5px; border-radius: 2px; background: rgba(255, 255, 255, .22); overflow: hidden; }
.story-progress i b { display: block; height: 100%; background: #fff; width: 0; }
.story-stage { flex: 1; display: grid; place-items: center; padding: 18px; text-align: center; }
.story-stage img { max-width: 100%; max-height: 100%; border-radius: var(--r-lg); }
.story-text { font-family: 'Bricolage Grotesque', sans-serif; font-size: 27px; line-height: 1.32; padding: 30px; }

/* ------------------------------------------------------------- profile */

.profile-hero { text-align: center; padding: 26px 18px 20px; }
.profile-hero .av { width: 112px; height: 112px; margin: 0 auto 14px; }
.profile-hero h2 { font-size: 25px; }
.profile-hero .handle { color: var(--muted); font-size: 14.5px; }
.verified { color: var(--teal); margin-left: 5px; }

.chip-wrap { display: flex; flex-wrap: wrap; gap: 8px; }
.section { margin-top: 22px; }
.section > .label {
  font-size: 11.5px; text-transform: uppercase; letter-spacing: .14em;
  color: var(--faint); margin-bottom: 10px; font-weight: 600;
}
.setting-row {
  display: flex; align-items: center; gap: 14px; padding: 15px 16px;
  border-bottom: 1px solid var(--line);
}
.setting-row:last-child { border-bottom: 0; }
.setting-row .sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }

.switch { width: 50px; height: 30px; border-radius: 999px; background: var(--glass-hi);
  border: 1px solid var(--line); position: relative; flex: none; transition: background .26s var(--ease); }
.switch b { position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%;
  background: #fff; transition: transform .28s var(--ease); }
.switch.on { background: linear-gradient(135deg, var(--violet), var(--teal)); border-color: transparent; }
.switch.on b { transform: translateX(20px); }

/* ---------------------------------------------------------- permission */

#gate { position: fixed; inset: 0; z-index: 180; display: none; place-items: center; padding: 26px;
  background: var(--ink); }
#gate.open { display: grid; }
#gate .card { max-width: 420px; padding: 30px 26px; text-align: center; }
#gate .perm { display: flex; gap: 14px; text-align: left; padding: 14px 0; border-top: 1px solid var(--line); }
#gate .perm .sym { font-size: 24px; flex: none; }

@media (min-width: 860px) {
  #app { max-width: 520px; margin: 0 auto; border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ============================================================
   v2 — light theme, chat effects, guest chrome, install prompt
   ============================================================ */

/* Light theme is a token swap, not a second stylesheet. The glass model
   inverts: dark translucency over a warm paper field instead of light
   translucency over ink. */
html[data-theme="light"] {
  --ink: #F4F3FA;
  --ink-soft: #FFFFFF;
  --glass: rgba(255, 255, 255, .72);
  --glass-hi: rgba(255, 255, 255, .92);
  --glass-lo: rgba(20, 22, 40, .035);
  --line: rgba(24, 26, 48, .11);
  --line-hi: rgba(24, 26, 48, .2);
  --text: #14162A;
  --muted: #565C78;
  --faint: #858BA5;
  --violet: #6541F2;
  --teal: #0E9E8C;
  --male: #2563EB;
  --female: #DB2777;
  --neutral: #7C3AED;
  --rose: #E11D48;
  --amber: #B45309;
  --shadow: 0 16px 40px rgba(30, 26, 70, .14);
}
html[data-theme="light"] body::before {
  background:
    radial-gradient(46% 38% at 12% 4%, rgba(124, 92, 255, .20), transparent 62%),
    radial-gradient(40% 34% at 92% 12%, rgba(45, 212, 191, .16), transparent 60%),
    radial-gradient(52% 44% at 60% 104%, rgba(244, 114, 182, .14), transparent 62%);
}
html[data-theme="light"] .topbar { background: linear-gradient(180deg, rgba(244,243,250,.94), rgba(244,243,250,.6)); }
html[data-theme="light"] .tabbar,
html[data-theme="light"] .composer { background: rgba(255, 255, 255, .82); }
html[data-theme="light"] .sheet { background: rgba(255, 255, 255, .96); }
html[data-theme="light"] .reactbar { background: rgba(255, 255, 255, .97); }
html[data-theme="light"] .react-chip { background: rgba(255, 255, 255, .95); }
html[data-theme="light"] .toast { background: rgba(24, 26, 48, .94); color: #F4F3FA; }
html[data-theme="light"] .btn.primary { color: #FFF; }
html[data-theme="light"] .bubble.mine {
  background: linear-gradient(140deg, rgba(101, 65, 242, .16), rgba(14, 158, 140, .13));
  border-color: rgba(101, 65, 242, .3);
}
html[data-theme="light"] .bubble.mine .stamp { color: var(--faint); }
html[data-theme="light"] .av-wrap .dot { border-color: var(--ink); }
html[data-theme="light"] .map, html[data-theme="light"] .leaflet-container { background: #E8E7F2; }
html[data-theme="light"] .map-panel,
html[data-theme="light"] .story-view { background: rgba(255, 255, 255, .9); }
html[data-theme="light"] .story-view { color: var(--text); }
html[data-theme="light"] #splash { background: var(--ink); }
html[data-theme="light"] .switch b { background: #FFF; box-shadow: 0 1px 4px rgba(0,0,0,.25); }

/* accent presets shown in the theme picker */
.accent-row { display: flex; gap: 10px; flex-wrap: wrap; }
.accent-dot {
  width: 38px; height: 38px; border-radius: 50%; flex: none; position: relative;
  border: 2px solid transparent; transition: transform .18s var(--ease);
}
.accent-dot.on { border-color: var(--text); transform: scale(1.08); }
.accent-dot:active { transform: scale(.92); }

.theme-seg { display: flex; gap: 6px; background: var(--glass-lo); padding: 4px;
  border-radius: 999px; border: 1px solid var(--line); }
.theme-seg button { flex: 1; padding: 9px 0; border-radius: 999px; font-size: 13px;
  font-weight: 600; color: var(--muted); transition: all .2s var(--ease); }
.theme-seg button.on { background: var(--glass-hi); color: var(--text); box-shadow: 0 2px 10px rgba(0,0,0,.18); }

/* ------------------------------------------------------- chat effects */

/* Rain of emoji over the thread. Purely decorative: pointer-events off so it
   never blocks a tap, and the layer removes itself when the burst finishes. */
#fxLayer {
  position: absolute; inset: 0; z-index: 70; pointer-events: none; overflow: hidden;
}
.fx-drop {
  position: absolute; top: -8%; font-size: 30px; will-change: transform, opacity;
  animation: fxFall var(--dur, 2.6s) cubic-bezier(.4, .05, .55, 1) var(--delay, 0s) both;
}
@keyframes fxFall {
  0%   { transform: translateY(-10vh) rotate(0deg) scale(.7); opacity: 0; }
  12%  { opacity: 1; }
  80%  { opacity: 1; }
  100% { transform: translateY(112vh) rotate(var(--spin, 220deg)) scale(1.1); opacity: 0; }
}
.fx-burst {
  position: absolute; left: 50%; top: 50%; font-size: 96px;
  transform: translate(-50%, -50%) scale(.2); opacity: 0;
  animation: fxPop 1.5s var(--ease) both;
}
@keyframes fxPop {
  0%   { transform: translate(-50%, -50%) scale(.2); opacity: 0; }
  22%  { transform: translate(-50%, -50%) scale(1.25); opacity: 1; }
  55%  { transform: translate(-50%, -50%) scale(1); opacity: 1; }
  100% { transform: translate(-50%, -54%) scale(1.5); opacity: 0; }
}
.fx-sender-hint {
  position: absolute; left: 50%; bottom: 14%; transform: translateX(-50%);
  padding: 7px 15px; border-radius: 999px; font-size: 12.5px; white-space: nowrap;
  background: rgba(18, 19, 30, .88); border: 1px solid var(--line-hi); color: var(--text);
  animation: fadeUp .4s var(--ease) both, fadeOut .5s var(--ease) 2s both;
}
@keyframes fadeOut { to { opacity: 0; } }

.fx-picker { display: flex; gap: 4px; padding: 8px 10px; overflow-x: auto; }
.fx-picker button {
  font-size: 27px; padding: 5px 7px; border-radius: 14px; flex: none;
  transition: transform .16s var(--ease), background .18s;
}
.fx-picker button:active { transform: scale(1.35) translateY(-4px); background: var(--glass-hi); }

/* --------------------------------------------------------- guest chrome */

.guest-strip {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px; font-size: 12.5px;
  background: rgba(251, 191, 36, .12); border-bottom: 1px solid rgba(251, 191, 36, .3);
  color: var(--amber);
}
.guest-strip b { color: var(--amber); }
.guest-tag {
  font-size: 10px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  padding: 2px 7px; border-radius: 999px; background: rgba(251, 191, 36, .18);
  color: var(--amber); border: 1px solid rgba(251, 191, 36, .35);
}

/* ------------------------------------------------------ install prompt */

#a2hs {
  position: fixed; left: 12px; right: 12px; bottom: calc(88px + var(--safe-bot)); z-index: 140;
  display: none; gap: 13px; align-items: center; padding: 14px 16px;
  border-radius: var(--r-lg); background: rgba(16, 17, 28, .95); border: 1px solid var(--line-hi);
  backdrop-filter: var(--blur); box-shadow: var(--shadow);
  animation: fadeUp .4s var(--ease) both;
}
#a2hs.show { display: flex; }
#a2hs .ico { width: 42px; height: 42px; border-radius: 13px; flex: none; display: grid; place-items: center;
  background: linear-gradient(140deg, var(--violet), var(--teal)); font-size: 21px; color: #08090F; }
#a2hs .txt { flex: 1; min-width: 0; font-size: 13px; line-height: 1.4; }
#a2hs .txt b { display: block; font-size: 14px; margin-bottom: 1px; }

/* ---------------------------------------------------------- tickets */

.ticket {
  display: flex; gap: 12px; align-items: center; padding: 13px 14px;
  border-radius: var(--r-md); border: 1px solid var(--line); background: var(--glass);
  margin-bottom: 9px; transition: transform .16s var(--ease);
}
.ticket:active { transform: scale(.985); }
.ticket .st { font-size: 10.5px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase;
  padding: 3px 9px; border-radius: 999px; flex: none; }
.st.open { background: rgba(124, 92, 255, .2); color: #C9BAFF; }
.st.waiting { background: rgba(251, 191, 36, .18); color: #FCD34D; }
.st.resolved, .st.closed { background: var(--glass-hi); color: var(--muted); }
html[data-theme="light"] .st.open { color: #4C29C9; }
html[data-theme="light"] .st.waiting { color: #92400E; }

.tmsg { max-width: 84%; padding: 11px 14px; border-radius: 20px; font-size: 14px;
  border: 1px solid var(--line); background: var(--glass); margin-bottom: 9px; line-height: 1.45; }
.tmsg.staff { background: linear-gradient(140deg, rgba(45, 212, 191, .2), rgba(124, 92, 255, .14));
  border-color: rgba(45, 212, 191, .3); margin-left: auto; }
.tmsg .who { font-size: 11px; color: var(--faint); margin-bottom: 4px; font-weight: 600; }

/* ============================================================
   v3 — refined glass, gradient depth, WhatsApp-grade chat list,
   professional icon sizing, navigation affordances
   ============================================================ */

/* Icons all sit on one 24px grid with a consistent stroke, so nothing looks
   heavier or lighter than its neighbour. */
.ico {
  width: 23px; height: 23px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.75;
  stroke-linecap: round; stroke-linejoin: round;
}
.ico.sm { width: 17px; height: 17px; stroke-width: 1.9; }
.ico.lg { width: 27px; height: 27px; stroke-width: 1.6; }

/* ---------------------------------------------------- glass, deepened */

/* Two-layer glass: a tinted pane plus a top-edge highlight, which is what
   stops large frosted panels reading as flat grey rectangles. */
.glass, .map-panel, .sheet, .reactbar, #a2hs, .ticket {
  position: relative;
  background:
    linear-gradient(160deg, rgba(255,255,255,.085), rgba(255,255,255,.028) 42%, rgba(255,255,255,.05));
  box-shadow:
    0 1px 0 rgba(255,255,255,.13) inset,
    0 -1px 0 rgba(0,0,0,.22) inset,
    var(--shadow);
}
html[data-theme="light"] .glass,
html[data-theme="light"] .map-panel,
html[data-theme="light"] .sheet,
html[data-theme="light"] .ticket {
  background: linear-gradient(160deg, rgba(255,255,255,.92), rgba(255,255,255,.72) 45%, rgba(255,255,255,.86));
  box-shadow: 0 1px 0 rgba(255,255,255,.9) inset, 0 -1px 0 rgba(20,22,42,.05) inset, var(--shadow);
}

.btn.primary {
  background: linear-gradient(135deg, var(--violet) 0%, #9B7BFF 42%, var(--teal) 100%);
  background-size: 160% 160%;
  box-shadow: 0 8px 24px -6px rgba(124,92,255,.55), 0 1px 0 rgba(255,255,255,.35) inset;
  transition: background-position .5s var(--ease), transform .16s var(--ease);
}
.btn.primary:active { background-position: 100% 0; }

/* ------------------------------------------------------------ top bar */

.topbar {
  background: linear-gradient(180deg, rgba(10,11,20,.94) 0%, rgba(10,11,20,.72) 70%, rgba(10,11,20,.42) 100%);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 1px 0 rgba(255,255,255,.05) inset;
}
html[data-theme="light"] .topbar {
  background: linear-gradient(180deg, rgba(244,243,250,.96), rgba(244,243,250,.7) 70%, rgba(244,243,250,.4));
}
.topbar h2, .topbar h3 { letter-spacing: -.025em; }

.nav-home {
  width: 38px; height: 38px;
  background: var(--glass-lo); border: 1px solid var(--line);
}
.nav-home:active { transform: scale(.9); }

/* ------------------------------------------------------------- tabbar */

.tabbar {
  background: linear-gradient(180deg, rgba(12,13,22,.7), rgba(9,10,18,.94));
  border-top: 1px solid var(--line);
  box-shadow: 0 -1px 0 rgba(255,255,255,.05) inset;
  padding: 6px 8px calc(8px + var(--safe-bot));
}
html[data-theme="light"] .tabbar { background: linear-gradient(180deg, rgba(255,255,255,.72), rgba(255,255,255,.95)); }

.tab {
  position: relative; flex: 1; display: grid; justify-items: center; gap: 2px;
  padding: 9px 0 5px; color: var(--faint); border-radius: 16px;
  font-size: 10px; font-weight: 600; letter-spacing: .015em;
  transition: color .22s var(--ease);
}
.tab span { transition: opacity .22s var(--ease); }
/* Active pill sits behind the icon — the cue is the shape, not just colour,
   so it still reads for anyone who cannot separate violet from grey. */
.tab::before {
  content: ''; position: absolute; top: 4px; left: 50%; width: 46px; height: 30px;
  transform: translateX(-50%) scale(.6); border-radius: 15px; opacity: 0;
  background: linear-gradient(135deg, rgba(124,92,255,.28), rgba(45,212,191,.18));
  transition: opacity .26s var(--ease), transform .3s var(--ease);
}
.tab.on::before { opacity: 1; transform: translateX(-50%) scale(1); }
.tab.on { color: var(--text); }
.tab.on .ico { stroke: var(--violet); }
.tab .ico { position: relative; transition: transform .3s var(--ease); }
.tab.on .ico { transform: translateY(-1px); }
.tab .badge { position: absolute; top: 1px; right: calc(50% - 23px); z-index: 2; font-style: normal; }

/* -------------------------------------------------- chat list, refined */

/* WhatsApp's proportions: large avatar, two tight text lines, right-aligned
   meta column, and a hairline that starts after the avatar. */
#chatList { padding: 4px 0 calc(24px + var(--safe-bot)); }
#chatList .list-item {
  padding: 11px 16px; border-radius: 0; gap: 14px; position: relative;
}
#chatList .list-item::after {
  content: ''; position: absolute; left: 76px; right: 0; bottom: 0;
  height: 1px; background: var(--line);
}
#chatList .list-item:last-child::after { display: none; }
#chatList .list-item:active { background: var(--glass); transform: none; }
#chatList .av { width: 54px; height: 54px; }
#chatList .name { font-size: 16px; font-weight: 600; letter-spacing: -.01em; }
#chatList .snippet { font-size: 13.5px; margin-top: 1px; }
#chatList .meta { gap: 6px; }
#chatList .time { font-size: 11.5px; }
#chatList .badge {
  background: linear-gradient(135deg, var(--violet), var(--teal));
  color: #08090F; min-width: 21px; height: 21px; font-size: 11.5px;
  box-shadow: 0 3px 10px -2px rgba(124,92,255,.6);
}

/* ------------------------------------------------------- chat bubbles */

.bubble {
  border-radius: 20px; box-shadow: 0 2px 10px -4px rgba(0,0,0,.45);
}
/* Tail on the last bubble of a run, like a native messenger. */
.brow:not(.tight) .bubble:not(.mine) { border-bottom-left-radius: 7px; }
.brow.mine:not(.tight) .bubble { border-bottom-right-radius: 7px; }
.bubble.mine {
  background: linear-gradient(140deg, rgba(124,92,255,.5), rgba(124,92,255,.34) 55%, rgba(45,212,191,.3));
  box-shadow: 0 3px 14px -5px rgba(124,92,255,.55), 0 1px 0 rgba(255,255,255,.14) inset;
}

.composer { gap: 9px; padding: 9px 12px calc(11px + var(--safe-bot)); }
.composer textarea {
  border-radius: 24px; padding: 12px 17px; font-size: 15px;
  background: var(--glass-lo); box-shadow: 0 1px 0 rgba(255,255,255,.06) inset;
}
.icon-btn.send {
  width: 47px; height: 47px;
  box-shadow: 0 6px 18px -5px rgba(124,92,255,.6), 0 1px 0 rgba(255,255,255,.3) inset;
}
.icon-btn.send .ico { stroke-width: 1.9; }
.icon-btn.rec.recording { animation: pulseRec 1.2s ease-in-out infinite; }
@keyframes pulseRec {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255,107,129,.5); }
  50% { box-shadow: 0 0 0 9px rgba(255,107,129,0); }
}

/* ------------------------------------------------------- empty states */

.empty-card {
  margin: 8px 0; padding: 22px 20px; border-radius: var(--r-lg);
  background: var(--glass); border: 1px solid var(--line); text-align: left;
}
.empty-card h4 { font-size: 15.5px; margin: 0 0 6px; font-family: 'Bricolage Grotesque', sans-serif; }
.empty-card p { margin: 0; color: var(--muted); font-size: 13.5px; line-height: 1.55; }
.empty-card .why {
  margin-top: 12px; padding: 11px 13px; border-radius: var(--r-sm);
  background: var(--glass-lo); border: 1px solid var(--line);
  font-size: 12.5px; color: var(--muted); line-height: 1.5;
}
.empty-card .btn { margin-top: 14px; }

.map-empty {
  position: absolute; left: 14px; right: 14px; top: 50%; z-index: 18;
  transform: translateY(-60%); pointer-events: auto;
}

/* ------------------------------------------------------------ profile */

.profile-hero { position: relative; }
.profile-hero::before {
  content: ''; position: absolute; left: 50%; top: 6px; width: 210px; height: 210px;
  transform: translateX(-50%); border-radius: 50%; z-index: -1; pointer-events: none;
  background: radial-gradient(circle, rgba(124,92,255,.28), transparent 68%);
  filter: blur(22px);
}

/* ============================================================
   v4 — messenger polish: wallpaper, bubble tails, day chips, FAB
   ============================================================ */

/* Chat wallpaper. A faint dot-and-arc field, not a photo: it gives the thread
   depth so bubbles read as floating, without competing with the text. */
#threadScroll {
  background-color: var(--ink);
  background-image:
    radial-gradient(circle at 18% 22%, rgba(124,92,255,.13), transparent 42%),
    radial-gradient(circle at 84% 74%, rgba(45,212,191,.10), transparent 40%),
    radial-gradient(rgba(255,255,255,.055) 1px, transparent 1px);
  background-size: 100% 100%, 100% 100%, 22px 22px;
  background-attachment: local, local, local;
}
html[data-theme="light"] #threadScroll {
  background-image:
    radial-gradient(circle at 18% 22%, rgba(124,92,255,.11), transparent 42%),
    radial-gradient(circle at 84% 74%, rgba(45,212,191,.09), transparent 40%),
    radial-gradient(rgba(20,22,42,.06) 1px, transparent 1px);
}

/* Bubble tails, drawn as a clipped wedge so they inherit the bubble's own
   gradient instead of needing a matching solid colour. */
.brow:not(.tight) .bubble::after {
  content: ''; position: absolute; bottom: 0; width: 13px; height: 15px;
  background: inherit; border: inherit; border-top: 0;
}
.brow:not(.tight) .bubble:not(.mine)::after {
  left: -6px; border-right: 0;
  clip-path: polygon(100% 0, 100% 100%, 0 100%);
  border-bottom-left-radius: 14px;
}
.brow.mine:not(.tight) .bubble::after {
  right: -6px; border-left: 0;
  clip-path: polygon(0 0, 100% 100%, 0 100%);
  border-bottom-right-radius: 14px;
}

/* Day separator chip */
.daysep {
  display: flex; justify-content: center; margin: 16px 0 6px;
  position: sticky; top: 6px; z-index: 5; pointer-events: none;
}
.daysep span {
  padding: 5px 14px; border-radius: 999px; font-size: 11.5px; font-weight: 600;
  letter-spacing: .03em; color: var(--muted);
  background: rgba(14,15,25,.82); border: 1px solid var(--line);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 3px 12px rgba(0,0,0,.3);
}
html[data-theme="light"] .daysep span { background: rgba(255,255,255,.88); }

/* Floating compose button on the chat list, the way a messenger opens a new
   conversation. */
.fab {
  position: absolute; right: 18px; bottom: calc(20px + var(--safe-bot)); z-index: 25;
  width: 58px; height: 58px; border-radius: 20px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--violet), #9B7BFF 45%, var(--teal));
  color: #08090F; border: 0;
  box-shadow: 0 12px 30px -8px rgba(124,92,255,.7), 0 1px 0 rgba(255,255,255,.35) inset;
  transition: transform .2s var(--ease), box-shadow .2s var(--ease);
}
.fab:active { transform: scale(.9) rotate(-6deg); }
.fab .ico { width: 26px; height: 26px; stroke-width: 2.1; }

.view[data-view="chats"] { position: relative; }

/* Thread header: avatar, name, live status — tighter than a generic top bar. */
#threadName { font-size: 16px; font-weight: 600; letter-spacing: -.015em; }
#threadStatus { font-size: 11.5px; color: var(--teal); }
#threadStatus:empty { display: none; }

/* Softer press feedback across interactive rows */
.list-item, .ticket, .btn, .pill, .icon-btn, .tab { -webkit-user-select: none; user-select: none; }

/* --------------------------------------------- chat list search pill */

.searchpill-wrap {
  padding: 10px 14px 6px; flex: none;
  background: linear-gradient(180deg, rgba(10,11,20,.72), transparent);
}
html[data-theme="light"] .searchpill-wrap { background: linear-gradient(180deg, rgba(244,243,250,.8), transparent); }
.searchpill {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 11px 16px; border-radius: 999px; color: var(--faint); font-size: 14px;
  background: var(--glass-lo); border: 1px solid var(--line);
  transition: transform .16s var(--ease), border-color .2s;
}
.searchpill:active { transform: scale(.985); border-color: var(--violet); }
.searchpill .ico { stroke: var(--faint); }

.chats-bar { padding-bottom: 6px; border-bottom: 0; }

/* Message-status ticks read at a glance, like a native messenger */
.bubble .tick { font-size: 11px; letter-spacing: -1.5px; opacity: .85; }
.bubble .tick.read { opacity: 1; }

/* Map controls sit clear of the notch and each other */
.map-top { gap: 8px; align-items: center; }
.map-top .icon-btn { width: 40px; height: 40px; }
#ghostToggle { display: inline-flex; align-items: center; gap: 6px; }
