/* Nearby Mini App. Colours follow the user's Telegram theme; the fallbacks are used in a plain browser. */

@font-face { font-family: 'Elms Sans'; font-style: normal; font-display: swap; font-weight: 100 900;
  src: url(fonts/elms-sans-vietnamese-wght-normal.woff2) format('woff2');
  unicode-range: U+0102-0103,U+0110-0111,U+0128-0129,U+0168-0169,U+01A0-01A1,U+01AF-01B0,U+0300-0301,U+0303-0304,U+0308-0309,U+0323,U+0329,U+1EA0-1EF9,U+20AB; }
@font-face { font-family: 'Elms Sans'; font-style: normal; font-display: swap; font-weight: 100 900;
  src: url(fonts/elms-sans-latin-ext-wght-normal.woff2) format('woff2');
  unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF; }
@font-face { font-family: 'Elms Sans'; font-style: normal; font-display: swap; font-weight: 100 900;
  src: url(fonts/elms-sans-latin-wght-normal.woff2) format('woff2');
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; }

:root {
  --bg: var(--tg-theme-secondary-bg-color, #f4f5f8);
  --card: var(--tg-theme-section-bg-color, var(--tg-theme-bg-color, #ffffff));
  --text: var(--tg-theme-text-color, #0f1419);
  --hint: var(--tg-theme-hint-color, #56616b);
  --accent: var(--tg-theme-button-color, #1a6fb5);
  --on-accent: var(--tg-theme-button-text-color, #ffffff);
  --link: var(--tg-theme-link-color, #1a6fb5);
  --danger: var(--tg-theme-destructive-text-color, #c0392b);
  --chip: color-mix(in srgb, var(--accent) 14%, var(--card));
  --line: color-mix(in srgb, var(--text) 13%, transparent);
  --bg2: color-mix(in srgb, var(--text) 8%, var(--bg));
  --glass: color-mix(in srgb, var(--card) 88%, transparent);
  /* Set from Telegram's safe-area values in tg.js. In fullscreen, --csa-top is the strip that holds Telegram's own buttons. */
  --sa-top: 0px; --csa-top: 0px; --sa-bottom: 0px;
  --top: calc(var(--sa-top) + var(--csa-top));
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: var(--tg-theme-secondary-bg-color, #111a23);
    --card: var(--tg-theme-section-bg-color, var(--tg-theme-bg-color, #1b2632));
    --text: var(--tg-theme-text-color, #f5f5f5);
    --hint: var(--tg-theme-hint-color, #a3b3c2);
    --accent: var(--tg-theme-button-color, #3a76b0);
    --link: var(--tg-theme-link-color, #7dbdf5);
    --danger: var(--tg-theme-destructive-text-color, #ff8a7a);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; overscroll-behavior: none; }
body { background: var(--bg); color: var(--text); font-family: 'Elms Sans', 'Inter', -apple-system, 'Segoe UI', Roboto, sans-serif; font-size: 15px; font-weight: 400; line-height: 1.42; -webkit-font-smoothing: antialiased; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
button:disabled { opacity: .5; cursor: default; }
h1, h2, p { margin: 0; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; }

#app { position: relative; height: var(--tg-viewport-stable-height, 100dvh); display: flex; flex-direction: column; max-width: 560px; margin: 0 auto; }
#view { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.screen { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.boot { margin: auto; color: var(--hint); }

/* ---- Top bar ------------------------------------------------------------ */
/* Normal mode: a plain header row under Telegram's own header. */
#topbar { flex: none; height: 48px; padding: 0 12px; display: flex; align-items: center; justify-content: center; position: relative; }
#title { font-size: 16px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: calc(100% - 180px); }
#back { position: absolute; left: 12px; height: 44px; display: flex; align-items: center; gap: 2px; color: var(--link); font-weight: 500; }
/* Fullscreen: Telegram draws Close/Back on the left and its menu on the right of the --csa-top strip.
   Our title sits centred between them, and nothing else is placed in that strip. */
body.fs #topbar { position: absolute; z-index: 5; top: var(--sa-top); left: 0; right: 0; height: var(--csa-top); pointer-events: none; }
body.fs #title { max-width: calc(100% - 230px); }
body.fs #view { padding-top: var(--top); }
body.fs #view.bleed { padding-top: 0; }

/* ---- Layout pieces ------------------------------------------------------ */
.scroll { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 12px 16px 20px; display: flex; flex-direction: column; gap: 14px; }
.scroll.tabbed { padding-bottom: calc(110px + var(--sa-bottom)); }
.cta { flex: none; padding: 12px 16px calc(16px + var(--sa-bottom)); display: flex; flex-direction: column; gap: 8px; }
.cta.line { border-top: 1px solid var(--line); background: var(--bg); }
.big { font-size: 30px; line-height: 1.12; font-weight: 600; letter-spacing: -0.02em; }
.h2 { font-size: 18px; font-weight: 600; }
.label { font-size: 13px; font-weight: 500; color: var(--hint); }
.hint { color: var(--hint); font-size: 14px; }
.small { font-size: 13px; color: var(--hint); }
.center { text-align: center; }
.row { display: flex; align-items: center; gap: 12px; }
.col { display: flex; flex-direction: column; gap: 8px; }
.grow { flex: 1; min-width: 0; }
.wrap { display: flex; flex-wrap: wrap; gap: 8px; }
.card { background: var(--card); border-radius: 20px; padding: 14px 16px; }

.btn { height: 54px; border-radius: 16px; background: var(--accent); color: var(--on-accent); font-size: 16px; font-weight: 500; width: 100%; display: flex; align-items: center; justify-content: center; }
.btn.ghost { background: none; color: var(--link); height: 48px; }
.btn.soft { background: var(--chip); color: var(--link); height: 44px; width: auto; padding: 0 20px; border-radius: 22px; font-size: 15px; }
.btn.danger { background: none; color: var(--danger); height: 48px; }
.chipbtn { height: 44px; padding: 0 16px; border-radius: 22px; background: var(--card); font-weight: 500; }
.chipbtn[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); }
.field { width: 100%; height: 50px; padding: 0 14px; border-radius: 14px; border: 1px solid var(--line); background: var(--card); font-size: 16px; }
textarea.field { height: auto; padding: 14px 16px; border-radius: 20px; resize: none; }
.option { text-align: left; background: var(--card); border: 2px solid transparent; border-radius: 20px; padding: 12px 16px; min-height: 58px; display: flex; align-items: center; gap: 12px; width: 100%; }
.option[aria-pressed="true"] { border-color: var(--accent); }
.switch { text-align: left; background: var(--card); border-radius: 20px; padding: 12px 16px; min-height: 68px; display: flex; align-items: center; gap: 12px; width: 100%; }
.switch i { flex: none; width: 50px; height: 30px; border-radius: 15px; background: var(--hint); position: relative; transition: background .15s; }
.switch i::after { content: ''; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 12px; background: #fff; transition: left .15s; }
.switch[aria-checked="true"] i { background: var(--accent); }
.switch[aria-checked="true"] i::after { left: 23px; }
.badge { padding: 4px 11px; border-radius: 13px; font-size: 12px; font-weight: 500; background: var(--bg2); color: var(--hint); flex: none; }
.badge.strong { background: var(--accent); color: var(--on-accent); }
.badge.tint { background: var(--chip); color: var(--link); }
.note { padding: 12px 16px; border-radius: 20px; background: var(--chip); font-size: 14px; }
.avatar { flex: none; border-radius: 50%; object-fit: cover; display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 600; overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.verified { color: var(--link); flex: none; }
.icon-tile { flex: none; width: 44px; height: 44px; border-radius: 14px; background: var(--chip); color: var(--link); display: flex; align-items: center; justify-content: center; }

/* ---- Nearby ------------------------------------------------------------- */
.seg { flex: 1; display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; border-radius: 26px; background: var(--bg2); }
.seg button { height: 44px; border-radius: 22px; font-weight: 500; color: var(--hint); }
.seg button[aria-pressed="true"] { background: var(--card); color: var(--text); }
.round { flex: none; width: 52px; height: 52px; border-radius: 26px; background: var(--card); display: flex; align-items: center; justify-content: center; }
.dots { display: flex; gap: 5px; justify-content: flex-end; }
.dots span { width: 10px; height: 10px; border-radius: 5px; background: var(--line); }
.dots span.on { background: var(--accent); }
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.person { position: relative; height: 230px; border-radius: 22px; overflow: hidden; color: #fff; text-align: left; display: flex; flex-direction: column; justify-content: flex-end; }
.person img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.person .initial { position: absolute; top: 34px; left: 0; right: 0; text-align: center; font-size: 84px; font-weight: 600; color: rgba(255,255,255,.28); }
.person .dist { position: absolute; top: 10px; left: 10px; padding: 4px 10px; border-radius: 12px; background: rgba(0,0,0,.5); font-size: 12px; font-weight: 500; }
.person .meta { position: relative; padding: 36px 12px 12px; background: linear-gradient(rgba(0,0,0,0), rgba(0,0,0,.62)); }
.person .name { font-size: 17px; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.person .sub { font-size: 13px; }
.person .verified { color: #fff; }

/* ---- Profile ------------------------------------------------------------ */
.hero { position: relative; height: min(420px, 58vh); flex: none; color: #fff; }
.hero .photos { position: absolute; inset: 0; display: flex; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; }
.hero .photos::-webkit-scrollbar { display: none; }
.hero .photos > * { flex: none; width: 100%; height: 100%; scroll-snap-align: start; object-fit: cover; display: flex; align-items: center; justify-content: center; font-size: 150px; font-weight: 600; color: rgba(255,255,255,.28); }
.hero .meta { position: absolute; left: 0; right: 0; bottom: 0; padding: 60px 20px 34px; background: linear-gradient(rgba(0,0,0,0), rgba(0,0,0,.65)); pointer-events: none; }
.hero .count { position: absolute; right: 16px; bottom: 34px; padding: 3px 10px; border-radius: 12px; background: rgba(0,0,0,.5); font-size: 12px; }
.hero .count { bottom: 86px; }
.hero-more { position: absolute; right: 16px; bottom: 34px; width: 44px; height: 44px; border-radius: 22px; background: rgba(255,255,255,.22); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); color: #fff; display: flex; align-items: center; justify-content: center; }
.chat-more { width: 44px; height: 32px; border-radius: 16px; background: var(--bg2); color: var(--hint); display: flex; align-items: center; justify-content: center; }
.sheet { position: relative; margin-top: -20px; padding: 22px 20px 20px; border-radius: 24px 24px 0 0; background: var(--bg); display: flex; flex-direction: column; gap: 18px; }
.tag { padding: 7px 14px; border-radius: 18px; background: var(--card); font-size: 14px; }
.locked { padding: 14px 16px; border-radius: 20px; border: 1px dashed var(--line); display: flex; align-items: center; gap: 10px; color: var(--hint); font-size: 14px; }

/* ---- Chat --------------------------------------------------------------- */
.chatrow { width: 100%; min-height: 80px; padding: 12px 14px; border-radius: 22px; background: var(--card); text-align: left; display: flex; align-items: center; gap: 12px; }
.chatrow .preview { font-size: 14px; color: var(--hint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chatrow.unread .preview { color: var(--text); font-weight: 500; }
.msgs { gap: 8px; }
.msg { max-width: 78%; padding: 10px 14px; border-radius: 20px; background: var(--card); align-self: flex-start; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.mine { background: var(--accent); color: var(--on-accent); align-self: flex-end; }
.composer { flex: none; padding: 10px 14px calc(14px + var(--sa-bottom)); display: flex; align-items: flex-end; gap: 8px; }
.composer textarea { flex: 1; min-height: 48px; max-height: 120px; padding: 12px 16px; border-radius: 24px; border: 1px solid var(--line); background: var(--card); font-size: 16px; resize: none; }
.send { flex: none; width: 48px; height: 48px; border-radius: 24px; background: var(--accent); color: var(--on-accent); display: flex; align-items: center; justify-content: center; }

/* ---- Tabs, toast, misc -------------------------------------------------- */
#tabs { position: absolute; z-index: 4; left: 16px; right: 16px; bottom: calc(14px + var(--sa-bottom)); height: 66px; padding: 0 6px; border-radius: 33px; background: var(--glass); -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px); box-shadow: 0 6px 24px rgba(0,0,0,.14); display: grid; grid-template-columns: repeat(4, 1fr); align-items: center; }
#tabs button { height: 54px; border-radius: 27px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 11px; font-weight: 500; color: var(--hint); position: relative; }
#tabs button[aria-current="page"] { background: var(--chip); color: var(--link); }
#tabs .pip { position: absolute; top: 8px; right: calc(50% - 20px); min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px; background: var(--accent); color: var(--on-accent); font-size: 10px; line-height: 16px; }
#toast { position: absolute; z-index: 9; left: 20px; right: 20px; bottom: calc(100px + var(--sa-bottom)); pointer-events: none; padding: 12px 16px; border-radius: 16px; background: var(--text); color: var(--bg); text-align: center; font-size: 14px; }
.photo-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.photo-grid .slot { position: relative; height: 130px; border-radius: 16px; overflow: hidden; background: var(--card); }
.photo-grid img { width: 100%; height: 100%; object-fit: cover; }
.photo-grid .add { border: 2px dashed var(--line); background: none; display: flex; align-items: center; justify-content: center; color: var(--hint); width: 100%; }
.photo-grid .main-badge { position: absolute; left: 6px; bottom: 6px; padding: 3px 10px; border-radius: 10px; background: var(--accent); color: var(--on-accent); font-size: 12px; font-weight: 500; }
.photo-grid .main-btn { position: absolute; left: 0; right: 0; bottom: 0; min-height: 36px; padding: 0 6px; background: rgba(0,0,0,.62); color: #fff; font-size: 12px; font-weight: 500; }
.photo-grid .del { position: absolute; top: 6px; right: 6px; width: 30px; height: 30px; border-radius: 15px; background: rgba(0,0,0,.6); color: #fff; display: flex; align-items: center; justify-content: center; }
.list { background: var(--card); border-radius: 20px; }
.list > * { min-height: 56px; padding: 0 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; text-align: left; font-weight: 500; }
.list > * + * { border-top: 1px solid var(--line); }
.empty { padding: 28px 20px; border-radius: 22px; background: var(--card); display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; }
.illus { flex: 1; min-height: 160px; display: flex; align-items: center; justify-content: center; }
.oval { width: 190px; height: 250px; border-radius: 50%; border: 3px dashed var(--accent); background: var(--card); display: flex; align-items: center; justify-content: center; color: var(--hint); overflow: hidden; }
.oval img { width: 100%; height: 100%; object-fit: cover; }
.send.soft { background: var(--card); color: var(--link); border: 1px solid var(--line); }
.giftmsg { align-self: center; max-width: 92%; padding: 12px 16px; border-radius: 20px; background: var(--chip); display: flex; align-items: center; gap: 12px; }
.giftmsg .emoji { font-size: 40px; line-height: 1; }
.emoji { font-family: 'Apple Color Emoji', 'Segoe UI Emoji', 'Noto Color Emoji', sans-serif; }
.dia { display: inline-flex; align-items: center; gap: 3px; font-weight: 600; color: var(--link); white-space: nowrap; }
.dia svg { width: 15px; height: 15px; flex: none; }
.gift-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; max-height: 46vh; overflow-y: auto; }
.gift-item { min-height: 112px; padding: 10px 4px; border-radius: 18px; background: var(--card); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; }
.gift-item .emoji { font-size: 40px; line-height: 1.1; }
.backdrop { position: absolute; inset: 0; z-index: 8; background: rgba(0,0,0,.5); display: flex; align-items: flex-end; }
.gsheet { width: 100%; padding: 22px 16px calc(12px + var(--sa-bottom)); border-radius: 24px 24px 0 0; background: var(--bg); display: flex; flex-direction: column; gap: 10px; }
.gallery { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px; border-radius: 14px; overflow: hidden; }
.gallery button { display: block; aspect-ratio: 1; overflow: hidden; }
.gallery img { display: block; width: 100%; height: 100%; object-fit: cover; }
.gallery.n1 { grid-template-columns: 1fr; }
.gallery.n1 button { aspect-ratio: auto; max-height: 420px; }
.gallery.n3 button:first-child { grid-column: span 2; aspect-ratio: 2 / 1; }
.post-photos { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.post-photos .slot { position: relative; aspect-ratio: 1; border-radius: 14px; overflow: hidden; background: var(--card); }
.post-photos img { width: 100%; height: 100%; object-fit: cover; display: block; }
.post-photos .add { border: 2px dashed var(--line); background: none; display: flex; align-items: center; justify-content: center; color: var(--hint); cursor: pointer; }
.post-photos .del { position: absolute; top: 4px; right: 4px; width: 28px; height: 28px; border-radius: 14px; background: rgba(0,0,0,.6); color: #fff; display: flex; align-items: center; justify-content: center; }
.viewer { position: absolute; inset: 0; z-index: 10; background: rgba(0,0,0,.92); display: flex; align-items: center; justify-content: center; width: 100%; }
.viewer img { max-width: 100%; max-height: 100%; object-fit: contain; }
/* Selects draw their own arrow, so it sits 10 px inside the right edge instead of touching it. */
select { -webkit-appearance: none; appearance: none; background-repeat: no-repeat; background-position: right 10px center; background-size: 12px 12px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%237a8794' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); }
select.mini { border: 0; background-color: var(--chip); color: var(--link); border-radius: 14px; height: 30px; padding: 0 30px 0 12px; font-size: 12px; font-weight: 500; }
select.field { padding-right: 38px; background-position: right 14px center; }
