.telegram-home-add[hidden] {
  display: none;
}

.telegram-home-offer {
  margin-block: 12px;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--paper);
}

.telegram-home-offer p {
  margin: 0 0 8px;
}

.telegram-home-offer div {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  align-items: center;
}

.telegram-home-offer button {
  min-height: 44px;
}

.telegram-switch-indicator {
  display: flex;
  align-items: center;
  flex: none;
  width: 42px;
  height: 24px;
  padding: 3px;
  border-radius: 20px;
  background: var(--muted);
}

.telegram-switch-indicator::before {
  content: "";
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--paper);
}

.telegram-fullscreen-switch[aria-checked="true"] .telegram-switch-indicator {
  justify-content: flex-end;
  background: var(--olive);
}

/* Telegram's device and content insets are additive. The browser may report
   the same device inset, so use the larger clearance from the two sources. */
:root {
  --app-safe-top: max(env(safe-area-inset-top, 0px), var(--telegram-safe-top, calc(var(--tg-safe-area-inset-top, 0px) + var(--tg-content-safe-area-inset-top, 0px))));
  --app-safe-right: max(env(safe-area-inset-right, 0px), var(--telegram-safe-right, calc(var(--tg-safe-area-inset-right, 0px) + var(--tg-content-safe-area-inset-right, 0px))));
  --app-safe-bottom: max(env(safe-area-inset-bottom, 0px), var(--telegram-safe-bottom, calc(var(--tg-safe-area-inset-bottom, 0px) + var(--tg-content-safe-area-inset-bottom, 0px))));
  --app-safe-left: max(env(safe-area-inset-left, 0px), var(--telegram-safe-left, calc(var(--tg-safe-area-inset-left, 0px) + var(--tg-content-safe-area-inset-left, 0px))));
  --dock-bottom: calc(8px + var(--app-safe-bottom));
  --dialog-safe-height: calc(100dvh - var(--app-safe-top) - var(--app-safe-bottom) - 16px);
}

.app-shell {
  --shell-gutter: 32px;
  padding-top: var(--app-safe-top);
  padding-left: calc(var(--shell-gutter) + var(--app-safe-left));
  padding-right: calc(var(--shell-gutter) + var(--app-safe-right));
}

@media (max-width: 650px) {
  .app-shell { --shell-gutter: 16px; }
}

.brand { flex-wrap: wrap; gap: 10px; }

/* Keep the kitchen, shop and marketplace docks on the same 72px baseline. */
html body .bottom-dock.has-shop,
html body .bottom-dock:not(.has-shop) .bottom-nav,
html body .context-dock {
  left: max(calc(8px + var(--app-safe-left)), calc(50% - 330px)) !important;
  right: max(calc(8px + var(--app-safe-right)), calc(50% - 330px)) !important;
  bottom: var(--dock-bottom) !important;
  width: auto !important;
  max-width: none;
  min-width: 0;
  padding-bottom: 0;
  margin-inline: auto;
  transform: none !important;
}

html body .context-dock {
  height: 72px;
}

.final-context button > span:last-child {
  max-width: 100%;
  white-space: normal;
  overflow-wrap: anywhere;
  text-align: center;
}

.free-bar {
  bottom: calc(var(--nav-h, 76px) + var(--dock-bottom));
  left: var(--app-safe-left);
  right: var(--app-safe-right);
}

.sticky-actions {
  bottom: calc(88px + var(--dock-bottom));
  left: max(12px, calc(8px + var(--app-safe-left)));
  right: max(12px, calc(8px + var(--app-safe-right)));
  max-width: 660px;
  margin-inline: auto;
}

dialog[open] {
  inset: var(--app-safe-top) var(--app-safe-right) var(--app-safe-bottom) var(--app-safe-left);
  max-width: min(460px, calc(100% - var(--app-safe-left) - var(--app-safe-right) - 30px));
  max-height: min(85dvh, var(--dialog-safe-height));
}

.dialog-heading .round { flex: none; }
.dialog-heading h2 { min-width: 0; overflow-wrap: anywhere; }

/* The mode switch must stay inside its card at large text sizes. */
.settings-item.color-switch {
  flex-wrap: wrap;
  row-gap: 8px;
}

.settings-item.color-switch .color-opts {
  display: flex;
  flex: 1 1 auto;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 4px;
  min-width: 0;
  max-width: 100%;
}

.settings-item.color-switch .color-opts .chip {
  min-height: 44px;
  padding-inline: 12px;
}

/* After the first three days the help button is just a round «?». */
.header-howto.howto-compact { font-size: 0; gap: 0; padding: 6px; border-radius: 50%; min-width: 44px; min-height: 44px; justify-content: center; }
.header-howto.howto-compact::before { width: 22px; height: 22px; font-size: .8125rem; }

/* The three mode buttons explain themselves: no label, one row. */
.settings-item.color-switch > span { display: none; }
.settings-item.color-switch .color-opts { flex-wrap: nowrap; justify-content: stretch; width: 100%; }
.settings-item.color-switch .color-opts .chip {
  flex: 1 1 0;
  min-width: 0;
  padding-inline: 6px;
  white-space: normal;
  overflow-wrap: anywhere;
}

/* No square outline around the shop icon. */
html body .calm-navigation .shop-launch .nav-symbol { border: 0 !important; box-shadow: none !important; }
