/* Applied only inside Telegram. Ordinary browser layouts stay unchanged. */
html.in-telegram {
  --pocket-inset-top: calc(var(--tg-safe-area-inset-top, 0px) + var(--tg-content-safe-area-inset-top, 0px));
  --pocket-inset-bottom: max(env(safe-area-inset-bottom, 0px), var(--tg-safe-area-inset-bottom, 0px), var(--tg-content-safe-area-inset-bottom, 0px));
  --pocket-nav-height: calc(76px + var(--pocket-inset-bottom));
  --pocket-height: calc(var(--tg-viewport-stable-height, 100dvh) - var(--pocket-inset-top) - var(--pocket-nav-height));
  scroll-padding-bottom: var(--pocket-nav-height);
  background: #120c0a;
}
html.in-telegram body {
  display: block;
  box-sizing: border-box;
  min-height: var(--tg-viewport-stable-height, 100dvh);
  margin: 0;
  padding: var(--pocket-inset-top) max(env(safe-area-inset-right, 0px), var(--tg-safe-area-inset-right, 0px)) var(--pocket-nav-height) max(env(safe-area-inset-left, 0px), var(--tg-safe-area-inset-left, 0px));
  background: #120c0a;
}
html.in-telegram .app,
html.in-telegram #authored-psychologist-home .aph-device {
  width: 100%;
  max-width: 640px;
  min-height: var(--pocket-height);
  height: auto;
  margin: 0 auto;
  border: 0;
  border-radius: 0;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  box-shadow: none;
}
html.in-telegram .topbar {
  min-height: 60px;
  padding-top: 0;
  border-radius: 0;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}
html.in-telegram #authored-psychologist-home {
  min-height: var(--pocket-height);
  padding: 0;
}
html.in-telegram #authored-psychologist-home .aph-device {
  display: flex;
  flex-direction: column;
}
html.in-telegram #authored-psychologist-home .aph-safe { display: none; }
html.in-telegram #authored-psychologist-home .aph-chooser { margin-bottom: 24px; }
html.in-telegram #authored-psychologist-home .aph-bottom-nav {
  display: none;
}
html.in-telegram #authored-psychologist-home .aph-author { padding-top: 20px; }
html.in-telegram #authored-psychologist-home .aph-author__name { font-size: 13px; }
html.in-telegram #authored-psychologist-home .aph-author__role { font-size: 13px; }
html.in-telegram #authored-psychologist-home .aph-monogram { width: 36px; height: 36px; font-size: 13px; }
html.in-telegram #authored-psychologist-home .aph-hero h1 { font-size: clamp(32px, 8.6vw, 38px); line-height: 1.12; }
html.in-telegram #authored-psychologist-home .aph-intro { max-width: none; font-size: 16px; line-height: 1.55; }
html.in-telegram #authored-psychologist-home .aph-section-label { font-size: 12px; }
html.in-telegram #authored-psychologist-home .aph-route { min-height: 102px; padding: 18px 0; }
html.in-telegram #authored-psychologist-home .aph-route__number { font-size: 14px; }
html.in-telegram #authored-psychologist-home .aph-route__title { font-size: 20px; line-height: 1.25; }
html.in-telegram #authored-psychologist-home .aph-route__copy { max-width: none; font-size: 15px; line-height: 1.45; color: #baada2; }
html.in-telegram #authored-psychologist-home .aph-chooser h2 { font-size: 20px; }
html.in-telegram #authored-psychologist-home .aph-chooser p { max-width: none; font-size: 16px; line-height: 1.5; color: #baada2; }
html.in-telegram #authored-psychologist-home .aph-match { min-height: 48px; font-size: 16px; white-space: normal; }
html.in-telegram .pocket-bottom-nav {
  position: fixed;
  z-index: 30;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  box-sizing: border-box;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  width: min(100%, 640px);
  height: var(--pocket-nav-height);
  padding: 6px max(8px, var(--tg-safe-area-inset-right, 0px)) calc(6px + var(--pocket-inset-bottom)) max(8px, var(--tg-safe-area-inset-left, 0px));
  border-top: 1px solid #3b3028;
  background: #140e0b;
  font-family: system-ui, sans-serif;
}
html.in-telegram .pocket-bottom-nav :is(a, button) {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 56px;
  min-width: 0;
  padding: 0 4px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: #c3b5aa;
  font: inherit;
  font-size: 13px;
  line-height: 1.15;
  text-decoration: none;
  touch-action: manipulation;
  cursor: pointer;
}
html.in-telegram .pocket-bottom-nav [aria-current="page"] { color: #f0d58d; background: #251b14; }
html.in-telegram .pocket-bottom-nav :is(a, button):active { background: #302319; }
html.in-telegram .pocket-bottom-nav :focus-visible { outline: 2px solid #f0d58d; outline-offset: -2px; }
html.in-telegram .pocket-bottom-nav svg { width: 22px; height: 22px; flex-shrink: 0; }
html.in-telegram .pocket-bottom-nav small { font-size: 10px; color: #a69789; }
html.in-telegram .pocket-nav-notice {
  position: fixed;
  z-index: 35;
  left: 50%;
  bottom: calc(var(--pocket-nav-height) + 12px);
  transform: translateX(-50%);
  box-sizing: border-box;
  width: min(calc(100% - 32px), 360px);
  padding: 16px;
  border: 1px solid #73603f;
  border-radius: 14px;
  background: #241a13;
  color: #fff4e6;
  font: 15px/1.45 system-ui, sans-serif;
}
html.in-telegram.keyboard-open .pocket-bottom-nav { display: none; }
html.in-telegram :is(textarea, input[type="text"], input[type="email"]) { font-size: 16px; }
