:root {
  --tg-bg: var(--tg-theme-bg-color, #ffffff);
  --tg-secondary-bg: var(--tg-theme-secondary-bg-color, #efeff4);
  --tg-text: var(--tg-theme-text-color, #000000);
  --tg-hint: var(--tg-theme-hint-color, #8e8e93);
  --tg-button: #0098ea;
  --tg-button-text: #ffffff;

  /* Same floating glass dock tokens as cube_zeus_bot's own tabbar. */
  --dock-glass: rgba(242, 242, 242, .6);
  --dock-glass-shadow: 0 2px 10px rgba(0, 0, 0, .08), 0 1px 3px rgba(0, 0, 0, .04);
  --dock-glass-rim: inset 0 1px 0 rgba(255, 255, 255, .5), inset 0 0 0 .8px rgba(255, 255, 255, .35), inset 0 0 0 1.6px rgba(0, 0, 0, .02);
  --dock-selection: rgba(0, 0, 0, .05);
  --dock-label: #1a1a1a;
  --dock-accent: #0098ea;
  --dock-h: calc(78px + max(25px, env(safe-area-inset-bottom, 0px)));
}

/* --tg-bg/--tg-secondary-bg/--tg-text/--tg-hint are left alone here on
   purpose: inside Telegram, telegram-web-app.js itself keeps the
   --tg-theme-*-color custom properties on :root live (set on load and
   again on every themeChanged), so the var()-with-fallback above already
   tracks the system theme with no JS of ours needed — hardcoding them here
   would freeze the app on these fixed hex values instead. Only the dock's
   own glass tokens (no Telegram-supplied equivalent) need a dark variant. */
:root[data-theme="dark"] {
  --dock-glass: rgba(29, 29, 29, .6);
  --dock-glass-shadow: 0 2px 10px rgba(0, 0, 0, .28), 0 1px 3px rgba(0, 0, 0, .16);
  --dock-glass-rim: inset 0 1px 0 rgba(255, 255, 255, .08), inset 0 0 0 .8px rgba(255, 255, 255, .08);
  --dock-selection: rgba(255, 255, 255, .1);
  --dock-label: #f5f5f5;
}

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

button {
  transition: transform 0.15s ease;
}
button:active {
  transform: scale(1.1);
}
.tab:active {
  transform: none;
}
#dockAddBtn:active {
  transform: scale(0.97);
}

html, body {
  margin: 0;
  overflow: hidden;
  background: var(--tg-secondary-bg);
  color: var(--tg-text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  touch-action: pan-x pan-y;
}

#pages {
  position: fixed;
  inset: 0;
  overflow: hidden;
}

.placeholder {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  padding: 0 32px;
}

.placeholder__icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 14px;
  border-radius: 18px;
  background: rgba(118, 118, 128, 0.12);
  color: var(--tg-link, var(--dock-accent));
  display: flex;
  align-items: center;
  justify-content: center;
}

.placeholder__icon svg {
  width: 28px;
  height: 28px;
}

.placeholder__title {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 6px;
}

.placeholder__text {
  font-size: 15px;
  color: var(--tg-hint);
}

/* --- Bottom dock: ported 1:1 from @cube_zeus_bot's .tabbar/.tab/.searchbtn --- */

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 16px 25px max(25px, env(safe-area-inset-bottom, 0px));
  pointer-events: none;
}

.tabbar__pill {
  position: relative;
  flex: 1;
  display: flex;
  padding: 3px 4px;
  border-radius: 31px;
  overflow: hidden;
  background: var(--dock-glass);
  -webkit-backdrop-filter: blur(18px) saturate(1.7);
  backdrop-filter: blur(18px) saturate(1.7);
  box-shadow: var(--dock-glass-shadow), var(--dock-glass-rim);
  pointer-events: auto;
}

.tabbar__sel {
  position: absolute;
  top: 4px;
  left: 0;
  height: 54px;
  border-radius: 28px;
  background: var(--dock-selection);
  transition: transform .3s cubic-bezier(.4, 0, .2, 1), width .3s cubic-bezier(.4, 0, .2, 1);
}

.tab {
  position: relative;
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  padding: 6.5px 3px;
  border: none;
  background: none;
  color: var(--dock-label);
  cursor: pointer;
  transition: color .2s;
}

.tab + .tab {
  margin-left: -12px;
}

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

.tab__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 30px;
}

.tab__icon svg {
  width: 25px;
  height: 25px;
  display: block;
}

.tab__label {
  max-width: 100%;
  font-size: 9.5px;
  font-weight: 700;
  line-height: 12px;
  letter-spacing: -0.1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 374px) {
  .tab {
    padding-left: 2px;
    padding-right: 2px;
  }
}

.tabbar__search {
  flex: none;
  padding: 4px;
  pointer-events: auto;
}

.searchbtn {
  position: relative;
  width: 50px;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: var(--tg-button);
  color: var(--tg-button-text);
  box-shadow: var(--dock-glass-shadow), var(--dock-glass-rim), inset 0 0 0 0.5px rgba(255, 255, 255, 0.35);
  cursor: pointer;
}

.searchbtn__icon {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.searchbtn svg {
  display: block;
}

.searchbtn__sel {
  position: absolute;
  top: 4px;
  right: 4px;
  bottom: 4px;
  left: 4px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.22);
  opacity: 0;
  transition: opacity .2s;
}

.searchbtn--active .searchbtn__sel {
  opacity: 1;
}
