/* Shared media layout for Telegram prompt and home reference cards. */
.tg-media-stage { display: contents; }
.tg-media-rail { display: none; }
.tg-media-stage > video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
html.caleo-telegram-native .tg-media-page {
  background-color: #08080a;
  background-image: radial-gradient(circle at 50% 0%,rgba(0,216,255,.14),transparent 55%),radial-gradient(circle at 85% 42%,rgba(166,255,77,.08),transparent 45%),radial-gradient(circle at 15% 76%,rgba(0,216,255,.07),transparent 45%);
  background-attachment: fixed;
}
html.caleo-telegram-native .tg-media-page.reference {
  height: calc(100dvh - var(--caleo-tg-safe-top, 0px));
  min-height: 0;
  background: transparent;
}
html.caleo-telegram-native #detail-overlay.tg-media-page {
  display: block;
  padding: var(--caleo-tg-safe-top, 0px) 0 0;
}
html.caleo-telegram-native .tg-media-page .tg-viewer {
  position: relative;
  display: block;
  width: 100%;
  height: calc(100dvh - var(--caleo-tg-safe-top, 0px));
  min-height: 0;
  max-height: none;
  margin: 0 auto;
  overflow: hidden;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}
html.caleo-telegram-native .tg-viewer::after,
html.caleo-telegram-native .tg-viewer .gradient { display: none; }
html.caleo-telegram-native .tg-media-stage {
  position: absolute;
  inset: 0 0 calc(max(18px, var(--caleo-tg-safe-bottom, env(safe-area-inset-bottom, 0px))) + 58px);
  display: grid;
  min-height: 0;
  overflow: hidden;
  border-radius: 12px;
  place-items: center;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  padding: 0;
}
html.caleo-telegram-native .tg-media-stage::after {
  position: absolute;
  inset: auto 0 0;
  z-index: 1;
  height: 42%;
  content: "";
  background: linear-gradient(to top,rgba(4,10,13,.78),rgba(4,10,13,.24),transparent);
  pointer-events: none;
}
html.caleo-telegram-native .tg-media-stage > .detail-image,
html.caleo-telegram-native .tg-media-stage > .reference-image,
html.caleo-telegram-native .tg-media-stage > video {
  position: relative;
  z-index: 2;
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  border-radius: 12px;
  background: transparent;
  object-fit: contain;
  object-position: center;
}
html.caleo-telegram-native .tg-media-stage.is-vertical > .detail-image,
html.caleo-telegram-native .tg-media-stage.is-vertical > .reference-image,
html.caleo-telegram-native .tg-media-stage.is-vertical > video {
  position: absolute;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  object-fit: cover;
}
html.caleo-telegram-native .tg-viewer .detail-body,
html.caleo-telegram-native .tg-viewer .info {
  position: absolute;
  inset: 0;
  z-index: 3;
  width: 100%;
  max-height: none;
  display: block;
  overflow: visible;
  padding: 0;
  background: transparent;
  pointer-events: none;
}
html.caleo-telegram-native .tg-viewer .tg-media-meta {
  position: absolute;
  right: 86px;
  bottom: calc(max(18px, var(--caleo-tg-safe-bottom, env(safe-area-inset-bottom, 0px))) + 66px);
  left: 20px;
  z-index: 4;
  color: #fff;
  text-shadow: 0 1px 5px rgba(0,0,0,.72);
  pointer-events: auto;
}
html.caleo-telegram-native .tg-viewer .author img { display: none; }
html.caleo-telegram-native .tg-viewer .author,
html.caleo-telegram-native .tg-viewer .author-row { margin-bottom: 6px; }
html.caleo-telegram-native .tg-viewer .detail-prompt,
html.caleo-telegram-native .tg-viewer .prompt-toggle {
  min-height: 0;
  margin-bottom: 0;
  overflow-wrap: anywhere;
}
html.caleo-telegram-native .tg-viewer .repeat {
  position: absolute;
  right: 20px;
  bottom: max(18px, var(--caleo-tg-safe-bottom, env(safe-area-inset-bottom, 0px)));
  left: 20px;
  width: auto;
  margin: 0;
  pointer-events: auto;
}
html.caleo-telegram-native .tg-viewer .topbar {
  position: absolute;
  inset: 20px 16px auto;
  z-index: 4;
  padding: 0;
  justify-content: flex-end;
}
html.caleo-telegram-native .tg-viewer .detail-close,
html.caleo-telegram-native .tg-viewer .topbar .back,
html.caleo-telegram-native .tg-viewer .expand-prompt,
html.caleo-telegram-native .tg-viewer .copy { display: none; }
html.caleo-telegram-native .tg-viewer .detail-close,
html.caleo-telegram-native .tg-viewer .story-progress {
  top: 20px;
}
html.caleo-telegram-native .tg-viewer .detail-close { left: 20px; }
html.caleo-telegram-native .tg-viewer .story-progress { right: 20px; }
html.caleo-telegram-native .tg-viewer .story-side { top: 70px; bottom: calc(max(18px, var(--caleo-tg-safe-bottom, env(safe-area-inset-bottom, 0px))) + 58px); }
html.caleo-telegram-native .tg-media-rail {
  position: absolute;
  right: 24px;
  bottom: 18px;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
html.caleo-telegram-native .tg-media-rail img {
  width: 46px;
  height: 46px;
  border: 0;
  border-radius: 12px;
  object-fit: cover;
  box-shadow: 0 3px 14px rgba(0,0,0,.35);
}
html.caleo-telegram-native .tg-rail-button {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 50%;
  background: rgba(20,24,29,.72);
  color: #fff;
  box-shadow: 0 3px 14px rgba(0,0,0,.2);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
html.caleo-telegram-native .tg-rail-button svg {
  width: 23px;
  height: 23px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
html.caleo-telegram-native .tg-rail-button[aria-pressed="true"] { color: #00d8ff; }
html.caleo-telegram-native .tg-rail-button[aria-pressed="true"] svg { fill: currentColor; }
html.caleo-telegram-native .tg-viewer .detail-prompt.is-expanded,
html.caleo-telegram-native .tg-viewer .prompt-toggle.expanded {
  display: block;
  max-height: min(22dvh, 150px);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: none;
}
html.caleo-telegram-native .tg-viewer .detail-prompt.is-expanded::-webkit-scrollbar,
html.caleo-telegram-native .tg-viewer .prompt-toggle.expanded::-webkit-scrollbar { display: none; }
html.caleo-telegram-native .tg-viewer .prompt-toggle.expanded .prompt-text {
  display: block;
  max-height: none;
  overflow: visible;
}
html.caleo-telegram-native .tg-viewer .detail-body .author-name,
html.caleo-telegram-native .tg-viewer .info .author-name { font-size: 14px; line-height: 19px; }
html.caleo-telegram-native .tg-viewer .model-line,
html.caleo-telegram-native .tg-viewer .model { font-size: 12px; line-height: 17px; }
@media (max-height: 660px) {
  html.caleo-telegram-native .tg-media-rail { gap: 7px; }
}

@media (max-width: 767px) {
  html:not(.caleo-telegram-native) #detail-overlay.tg-media-page {
    display: block;
    padding: 0;
    background-color: #08080a;
    background-image: radial-gradient(circle at 50% 0%,rgba(0,216,255,.14),transparent 55%),radial-gradient(circle at 85% 42%,rgba(166,255,77,.08),transparent 45%),radial-gradient(circle at 15% 76%,rgba(0,216,255,.07),transparent 45%);
    backdrop-filter: none;
  }
  html:not(.caleo-telegram-native) .tg-media-page.reference {
    height: 100dvh;
    min-height: 0;
    background-color: #08080a;
    background-image: radial-gradient(circle at 50% 0%,rgba(0,216,255,.14),transparent 55%),radial-gradient(circle at 85% 42%,rgba(166,255,77,.08),transparent 45%),radial-gradient(circle at 15% 76%,rgba(0,216,255,.07),transparent 45%);
  }
  html:not(.caleo-telegram-native) .tg-media-page .tg-viewer {
    display: block;
    width: 100%;
    height: 100dvh;
    min-height: 0;
    max-height: none;
    margin: 0;
    overflow: hidden;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
  }
  html:not(.caleo-telegram-native) .tg-viewer::after,
  html:not(.caleo-telegram-native) .tg-viewer .gradient { display: none; }
  html:not(.caleo-telegram-native) .tg-media-stage {
    position: absolute;
    inset: 0 0 calc(max(18px,env(safe-area-inset-bottom,0px)) + 58px);
    display: grid;
    min-height: 0;
    overflow: hidden;
    border-radius: 12px;
    place-items: center;
    grid-template: minmax(0,1fr) / minmax(0,1fr);
    padding: 0;
  }
  html:not(.caleo-telegram-native) .tg-media-stage::after {
    position: absolute;
    inset: auto 0 0;
    z-index: 1;
    height: 42%;
    content: "";
    background: linear-gradient(to top,rgba(4,10,13,.78),rgba(4,10,13,.24),transparent);
    pointer-events: none;
  }
  html:not(.caleo-telegram-native) .tg-media-stage > .detail-image,
  html:not(.caleo-telegram-native) .tg-media-stage > .reference-image,
  html:not(.caleo-telegram-native) .tg-media-stage > video {
    position: relative;
    z-index: 2;
    display: block;
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 100%;
    border-radius: 12px;
    object-fit: contain;
    object-position: center;
  }
  html:not(.caleo-telegram-native) .tg-media-stage.is-vertical > .detail-image,
  html:not(.caleo-telegram-native) .tg-media-stage.is-vertical > .reference-image,
  html:not(.caleo-telegram-native) .tg-media-stage.is-vertical > video {
    position: absolute;
    inset: 0;
    z-index: 0;
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
    object-fit: cover;
  }
  html:not(.caleo-telegram-native) .tg-viewer .detail-body,
  html:not(.caleo-telegram-native) .tg-viewer .info {
    position: absolute;
    inset: 0;
    z-index: 3;
    display: block;
    width: 100%;
    padding: 0;
    pointer-events: none;
  }
  html:not(.caleo-telegram-native) .tg-viewer .tg-media-meta {
    position: absolute;
    right: 86px;
    bottom: calc(max(18px,env(safe-area-inset-bottom,0px)) + 66px);
    left: 20px;
    z-index: 4;
    color: #fff;
    text-shadow: 0 1px 5px rgba(0,0,0,.72);
    pointer-events: auto;
  }
  html:not(.caleo-telegram-native) .tg-viewer .author img { display: none; }
  html:not(.caleo-telegram-native) .tg-viewer .author,
  html:not(.caleo-telegram-native) .tg-viewer .author-row { margin-bottom: 6px; }
  html:not(.caleo-telegram-native) .tg-viewer .detail-prompt,
  html:not(.caleo-telegram-native) .tg-viewer .prompt-toggle { margin-bottom: 0; overflow-wrap: anywhere; }
  html:not(.caleo-telegram-native) .tg-viewer .copy,
  html:not(.caleo-telegram-native) .tg-viewer .expand-prompt { display: none; }
  html:not(.caleo-telegram-native) .tg-viewer .repeat {
    position: absolute;
    right: 20px;
    bottom: max(18px,env(safe-area-inset-bottom,0px));
    left: 20px;
    z-index: 5;
    width: auto;
    margin: 0;
    pointer-events: auto;
  }
  html:not(.caleo-telegram-native) .tg-viewer .topbar {
    position: absolute;
    inset: max(16px,env(safe-area-inset-top,0px)) 16px auto;
    z-index: 4;
    padding: 0;
  }
  html:not(.caleo-telegram-native) .tg-viewer .detail-close {
    top: max(16px,env(safe-area-inset-top,0px));
    left: 20px;
    right: auto;
  }
  html:not(.caleo-telegram-native) .tg-viewer .story-progress { top: max(16px,env(safe-area-inset-top,0px)); right: 20px; }
  html:not(.caleo-telegram-native) .tg-media-rail {
    position: absolute;
    right: 24px;
    bottom: 18px;
    z-index: 5;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
  }
  html:not(.caleo-telegram-native) .tg-media-rail img {
    width: 46px;
    height: 46px;
    border: 0;
    border-radius: 12px;
    object-fit: cover;
    box-shadow: 0 3px 14px rgba(0,0,0,.35);
  }
  html:not(.caleo-telegram-native) .tg-rail-button {
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    padding: 0;
    border: 1px solid rgba(255,255,255,.18);
    border-radius: 50%;
    background: rgba(20,24,29,.72);
    color: #fff;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
  }
  html:not(.caleo-telegram-native) .tg-rail-button svg { width: 23px; height: 23px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
  html:not(.caleo-telegram-native) .tg-rail-button[aria-pressed="true"] { color: #00d8ff; }
  html:not(.caleo-telegram-native) .tg-rail-button[aria-pressed="true"] svg { fill: currentColor; }
  html:not(.caleo-telegram-native) .tg-viewer .detail-prompt.is-expanded,
  html:not(.caleo-telegram-native) .tg-viewer .prompt-toggle.expanded {
    display: block;
    max-height: min(22dvh,150px);
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: none;
  }
  html:not(.caleo-telegram-native) .tg-viewer .detail-prompt.is-expanded::-webkit-scrollbar,
  html:not(.caleo-telegram-native) .tg-viewer .prompt-toggle.expanded::-webkit-scrollbar { display: none; }
  html:not(.caleo-telegram-native) .tg-viewer .prompt-toggle.expanded .prompt-text { display: block; max-height: none; overflow: visible; }
  html:not(.caleo-telegram-native) .tg-viewer .detail-body .author-name,
  html:not(.caleo-telegram-native) .tg-viewer .info .author-name { font-size: 14px; line-height: 19px; }
  html:not(.caleo-telegram-native) .tg-viewer .model-line,
  html:not(.caleo-telegram-native) .tg-viewer .model { font-size: 12px; line-height: 17px; }
}
