/* Theme tokens follow Telegram's --tg-theme-* variables with fallbacks for the browser. */
:root {
  --bg: var(--tg-theme-bg-color, #ffffff);
  --bg2: var(--tg-theme-secondary-bg-color, #f2f3f5);
  --text: var(--tg-theme-text-color, #111111);
  --hint: var(--tg-theme-hint-color, #8a8f98);
  --link: var(--tg-theme-link-color, #2481cc);
  --accent: var(--tg-theme-button-color, #2481cc);
  --accent-text: var(--tg-theme-button-text-color, #ffffff);
  --danger: var(--tg-theme-destructive-text-color, #e53935);
  --section: var(--tg-theme-section-bg-color, var(--bg));
  --separator: var(--tg-theme-section-separator-color, rgba(0, 0, 0, 0.08));
  --radius: 14px;
  --gap: 12px;
  --tabs-h: 58px;
  --safe-top: var(--tg-content-safe-area-inset-top, env(safe-area-inset-top, 0px));
  --safe-bottom: var(--tg-safe-area-inset-bottom, env(safe-area-inset-bottom, 0px));
  color-scheme: light;
}

:root[data-theme='dark'] {
  --bg: var(--tg-theme-bg-color, #17212b);
  --bg2: var(--tg-theme-secondary-bg-color, #0e1621);
  --text: var(--tg-theme-text-color, #f5f5f5);
  --hint: var(--tg-theme-hint-color, #7d8b99);
  --separator: var(--tg-theme-section-separator-color, rgba(255, 255, 255, 0.08));
  color-scheme: dark;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg2);
  color: var(--text);
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

body {
  overflow: hidden;
}

/* Components set display themselves (e.g. .tabs is flex), which would beat the hidden attribute. */
[hidden] {
  display: none !important;
}

#app {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  padding-top: var(--safe-top);
}

/* The layer host (js/core/layers.js): the tab root and the pushed screens above it fill it. */
.layers {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.screen {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: calc(var(--gap) * 2);
  background: var(--bg2);
}

/* A root under a pushed screen stays mounted and keeps its size (the map does not resize). */
.screen.layer-off {
  visibility: hidden;
}

.screen[data-screen='map'] {
  overflow: hidden;
  padding-bottom: 0;
}

h1,
h2,
h3 {
  margin: 0 0 8px;
  line-height: 1.25;
}

h1 {
  font-size: 22px;
}

h2 {
  font-size: 18px;
}

h3 {
  font-size: 16px;
}

p {
  margin: 0 0 8px;
}

a {
  color: var(--link);
}

img {
  display: block;
  max-width: 100%;
}

.hint {
  color: var(--hint);
  font-size: 13px;
}

.pad {
  padding: var(--gap);
}

.row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.row-wrap {
  flex-wrap: wrap;
}

.grow {
  flex: 1;
  min-width: 0;
}

.tabs {
  display: flex;
  height: calc(var(--tabs-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: var(--bg);
  border-top: 1px solid var(--separator);
  flex-shrink: 0;
}

/* Pushed screens and a MainButton on the top layer hide the tab bar (js/core/layers.js). */
body.tabs-off .tabs {
  display: none;
}

.tab {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 0 2px;
  border: 0;
  background: none;
  color: var(--hint);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}

/* The active tab: an accent pill behind the emoji and a bold label. */
.tab-pill {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 30px;
  border-radius: 15px;
}

.tab-emoji {
  font-size: 20px;
  line-height: 1;
}

.tab-label {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tab-badge {
  position: absolute;
  top: -3px;
  right: 4px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
}

.tab-active {
  color: var(--accent);
}

.tab-active .tab-pill {
  background: rgba(36, 129, 204, 0.14);
  background: color-mix(in srgb, var(--accent) 16%, transparent);
}

.tab-active .tab-label {
  font-weight: 700;
}
