:root{
  /* динамический вьюпорт (надёжнее 100vh на iOS) */
  --vh-stable: 100dvh;

  /* safe-area */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);

  /* чистая высота таббара (без safe-area) */
  --tabbar-h: 64px;

  /* цвета */
  --muted:#9aa4b2; --fg:#fff; --chip-border:#2a3140; --primary:#2d7ff9;
  --border:#232a36; --card:#161a22; --tabbar-bg: rgba(22,26,34,.96);

  --fab-size: 55px;   /* диаметр круга */
  --fab-raise: 16px;  /* на сколько поднимать над панелью */
}

/* фолбэк для старых iOS */
@supports (padding: constant(safe-area-inset-bottom)) {
  :root{
    --safe-top: constant(safe-area-inset-top, 0px);
    --safe-bottom: constant(safe-area-inset-bottom, 0px);
    --safe-left: constant(safe-area-inset-left, 0px);
    --safe-right: constant(safe-area-inset-right, 0px);
  }
}

html, body { height: 100%; }
body {
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
}

/* Корневая оболочка приложения */
.app{
  position:fixed; inset:0;
  height:var(--vh-stable);
  display:flex; flex-direction:column;
  padding-top: 0;
  padding-left: var(--safe-left);
  padding-right: var(--safe-right);
  box-sizing: border-box;
}

.app-header{
  flex:0 0 auto;
  padding: calc(12px + var(--safe-top, env(safe-area-inset-top, 0px))) clamp(18px, 4vw, 28px) 12px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  position:relative;
  z-index:2;
}
.app-header__title{
  margin:0;
  font-size:22px;
  font-weight:700;
  line-height:1.2;
}

/* Контент: резерв под таббар + нижнюю safe-area */
.view{
  flex:1 1 auto;
  min-height:0;
  overflow:auto;
  padding:0;
  padding-bottom: calc(var(--tabbar-h) + var(--safe-bottom));
  overscroll-behavior: contain;
}

/* ================= TABBAR ================= */

/* Подложка: заливает низ + safe-area (без blur) — гапа нет */
.tabbar-wrap{
  position:fixed; left:0; right:0; bottom:0;
  height: calc(var(--tabbar-h) + var(--safe-bottom));
  background: var(--tabbar-bg);
  pointer-events: none; /* клики ловит .tabbar внутри */
  border-top: 1px solid var(--border);
}

/* Внутренняя панель: blur/бордер, фикс-высота, сетка 1fr | auto | 1fr */
.tabbar{
  position:absolute; left:0; right:0; bottom: var(--safe-bottom);
  height: var(--tabbar-h);

  display:grid;
  grid-template-columns: 1fr auto 1fr;
  align-items:center;
  justify-items:center;

  backdrop-filter: saturate(140%) blur(6px);

  /* небольшой верхний зазор, чтобы иконки не «липли» к границе */
  padding: 6px 10px 0 10px;
  box-sizing: border-box;

  pointer-events:auto;
}

/* Кнопка вкладки: колонка (иконка над текстом), жёсткая высота */
.tabbar__btn{
  appearance:none; border:0; background:transparent; color:var(--muted);

  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  gap:6px;

  /* 24 (иконка) + 6 (gap) + 12 (лейбл) = 42px контента → держим 46px */
  height:46px;
  min-width:82px;
  padding:0 10px;             /* вертикальные отступы = 0 */
  border-radius:14px;

  font:12px/12px system-ui,-apple-system,Segoe UI,Roboto,sans-serif;
  -webkit-tap-highlight-color: transparent;

  outline:none !important;
  border:0 !important;
  box-shadow:none !important;

  transition: color .15s ease, background .15s ease, transform .12s ease;
}

.tabbar__btn .label{
  font-size:12px;
  line-height:12px;
  display:block;
  font-weight:400;
}

/* Активный таб: без фона/рамок/теней — только белая иконка + жирный лейбл */
.tabbar__btn[aria-selected="true"]{
  color:#fff;
  background:transparent !important;
}
.tabbar__btn[aria-selected="true"] .label{
  font-weight:600;
}

/* Иконки стабильные 24x24, переключение filled/outline */
.tabbar__btn .ico{
  width:24px; height:24px; display:block; flex:none;
}
.tabbar__btn .ico--active{ display:none; }
.tabbar__btn[aria-selected="true"] .ico--active{ display:block; color:#fff; }
.tabbar__btn[aria-selected="true"] .ico--inactive{ display:none; }

/* Центральная кнопка (+) — плавающая */
.tabbar__btn--primary{
  /* СБРОС наследия от .tabbar__btn */
  min-width: 0;          /* важно! иначе 82px делает её овальной */
  padding: 0;            /* на всякий случай */
  border: 0;
  outline: 0;
  box-shadow: 0 8px 22px rgba(45,127,249,.38);

  /* КРУГ */
  width: var(--fab-size) !important;
  height: var(--fab-size) !important;
  border-radius: 50%;
  aspect-ratio: 1 / 1;   /* лишним не будет, но главные — width/height */

  display: grid;
  place-items: center;
  justify-self: center;  /* закрепим по центру колонки */

  background: var(--primary);
  color: #fff;

  /* поднимаем кнопку над панелью */
  transform: translateY(calc(-1 * var(--fab-raise)));
}

/* размер плюсика внутри круга */
.tabbar__btn--primary .ico{
  width: 22px;
  height: 22px;
  display: block;
}

html[data-platform="ios"] .tabbar{
  padding-top: 28px;            /* немного поднимаем верхнюю кромку для iOS */
}
html[data-platform="ios"] .tabbar__btn{
  height:46px;                  /* фиксируем корпус кнопки */
}
html[data-platform="ios"] .tabbar__btn--primary{
  transform: translateY(-10px); /* мягче подъём, чтобы не «выпирала» вверх */
}

/* вспомогательный класс доступности */
.visually-hidden{
  position:absolute!important; width:1px; height:1px; padding:0; margin:-1px;
  overflow:hidden; clip:rect(0 0 0 0); white-space:nowrap; border:0;
}
