/* Post Popup v2: isolated popup UI layer */

body.dydoss-post-popup-open {
  overflow: hidden;
}

#image-popup {
  position: fixed;
  inset: 0;
  z-index: 5000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding:
    max(10px, calc(var(--dydoss-safe-top, 0px) + 8px))
    max(10px, calc(var(--dydoss-safe-right, 0px) + 8px))
    max(10px, calc(var(--dydoss-safe-bottom, 0px) + 8px))
    max(10px, calc(var(--dydoss-safe-left, 0px) + 8px));
  box-sizing: border-box;
  opacity: 0;
  pointer-events: none;
  transition: opacity 220ms cubic-bezier(0.22, 0.78, 0.2, 1);
  -webkit-tap-highlight-color: transparent;
}

#image-popup[style*="display: none"] {
  opacity: 0;
  pointer-events: none;
}

#image-popup.is-opening {
  opacity: 0;
  pointer-events: none;
}

#image-popup.is-open {
  opacity: 1;
  pointer-events: auto;
}

#image-popup.is-closing {
  opacity: 0;
  pointer-events: none;
}

#popup-overlay {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 14% 12%, rgba(92, 136, 201, 0.34), rgba(92, 136, 201, 0) 40%),
    linear-gradient(180deg, rgba(8, 16, 30, 0.76), rgba(8, 16, 30, 0.86));
  opacity: 0;
  transition: opacity 220ms ease;
}

#image-popup.is-opening #popup-overlay,
#image-popup.is-open #popup-overlay {
  opacity: 1;
}

#image-popup.is-closing #popup-overlay {
  opacity: 0;
}

#popup-content {
  position: relative;
  z-index: 1;
  width: min(1240px, calc(100vw - (max(16px, calc(var(--dydoss-safe-left, 0px) + 10px)) + max(16px, calc(var(--dydoss-safe-right, 0px) + 10px)))));
  max-width: min(1240px, calc(100vw - (max(16px, calc(var(--dydoss-safe-left, 0px) + 10px)) + max(16px, calc(var(--dydoss-safe-right, 0px) + 10px)))));
  max-height: calc(
    var(--dydoss-viewport-height, 100dvh)
    - max(16px, calc(var(--dydoss-safe-top, 0px) + 10px))
    - max(16px, calc(var(--dydoss-safe-bottom, 0px) + 10px))
    - var(--dydoss-viewport-offset-top, 0px)
  );
  min-height: min(680px, calc(var(--dydoss-viewport-height, 100dvh) - 48px));
  display: flex;
  align-items: stretch;
  justify-content: flex-start;
  overflow: hidden;
  border-radius: 20px;
  border: 1px solid rgba(111, 145, 188, 0.88);
  background:
    radial-gradient(130% 150% at 0% 0%, rgba(165, 204, 255, 0.3) 0%, rgba(165, 204, 255, 0) 44%),
    linear-gradient(180deg, rgba(249, 252, 255, 0.98) 0%, rgba(230, 241, 255, 0.97) 54%, rgba(212, 228, 249, 0.97) 100%);
  box-shadow:
    0 30px 80px rgba(6, 15, 34, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.98),
    0 0 0 2px rgba(255, 255, 255, 0.88);
  opacity: 0;
  transform: translate3d(var(--popup-enter-shift-x, 0px), var(--popup-enter-shift-y, 18px), 0) scale(0.988);
  transform-origin: center center;
  transition:
    opacity 210ms cubic-bezier(0.2, 0.84, 0.24, 1),
    transform 250ms cubic-bezier(0.16, 1, 0.3, 1),
    box-shadow 220ms ease;
  will-change: opacity, transform;
}

#image-popup.is-opening #popup-content,
#image-popup.is-open #popup-content {
  opacity: 1;
  transform: translate3d(0, 0, 0) scale(1);
}

#image-popup.is-closing #popup-content {
  opacity: 0;
  transform: translate3d(calc(var(--popup-enter-shift-x, 0px) * 0.45), calc(var(--popup-enter-shift-y, 18px) * 0.72), 0) scale(0.99);
}

#popup-extra {
  display: flex;
  flex: 1 1 auto;
  width: 100%;
  min-height: 0;
  overflow: hidden;
}

#close-post-popup-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 20;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  border: 1px solid rgba(126, 159, 203, 0.96);
  background: linear-gradient(180deg, #ffffff 0%, #ebf2fb 100%);
  color: #2b4f7b;
  font-size: 1.9rem;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.98),
    0 5px 14px rgba(30, 60, 103, 0.16);
  transition: transform 0.14s ease, box-shadow 0.14s ease, filter 0.14s ease;
}

#close-post-popup-btn:hover,
#close-post-popup-btn:focus-visible {
  transform: translateY(-1px);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 1),
    0 8px 16px rgba(30, 60, 103, 0.2);
}

#close-post-popup-btn:active {
  transform: translateY(1px);
}

.post-popup-layout {
  flex: 1 1 auto;
  width: 100%;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(320px, 31vw, 392px);
  gap: 14px;
  padding: 14px;
}

.popup-left-side {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow: hidden;
}

.popup-post-main {
  border-radius: 18px;
  border: 1px solid rgba(167, 193, 227, 0.9);
  background:
    radial-gradient(120% 130% at 0% 0%, rgba(188, 219, 255, 0.42) 0%, rgba(188, 219, 255, 0) 52%),
    linear-gradient(180deg, #fbfdff 0%, #edf4fd 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.94),
    0 10px 18px rgba(20, 43, 79, 0.1);
  padding: 14px;
}

.popup-post-viewport {
  width: 100%;
  min-height: 0;
}

.popup-post-viewport-image {
  height: 100%;
  min-height: min(620px, calc(var(--dydoss-viewport-height, 100dvh) - 158px));
  display: flex;
  align-items: center;
  justify-content: center;
}

.popup-post-viewport-text {
  min-height: 260px;
  display: flex;
  align-items: stretch;
}

.popup-main-img {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 15px;
  border: 1px solid rgba(168, 195, 228, 0.85);
  background: #f8fbff;
}

.popup-text-card {
  width: 100%;
  min-height: 0;
  border-radius: 14px;
  border: 1px solid rgba(175, 201, 232, 0.9);
  background:
    radial-gradient(130% 85% at 100% 0%, rgba(102, 176, 255, 0.24) 0%, rgba(102, 176, 255, 0) 46%),
    linear-gradient(165deg, #fffdf8 0%, #eef6ff 100%);
  box-shadow: inset 0 1px 0 #ffffff, 0 6px 14px rgba(38, 83, 141, 0.1);
  padding: 18px 16px;
  overflow: auto;
}

.popup-text-card-body {
  margin: 0;
  color: #1e3b66;
  font-size: 1.02rem;
  line-height: 1.58;
  white-space: pre-wrap;
  word-break: break-word;
}

.popup-video-slot {
  width: 100%;
  height: 100%;
  min-height: min(620px, calc(var(--dydoss-viewport-height, 100dvh) - 158px));
  display: flex;
  align-items: center;
  justify-content: center;
}

.popup-video-slot .dydoss-media-player,
.popup-main-video-player,
.popup-main-video {
  width: min(100%, 900px);
  max-width: 100%;
  margin: 0 auto;
}

.popup-main-video {
  border-radius: 14px;
  border: 1px solid rgba(168, 195, 228, 0.85);
  background: #040b16;
}

.popup-video-slot .dydoss-media-player.is-mode-popup.is-portrait-video,
.popup-video-slot .dydoss-media-player.is-mode-media-popup.is-portrait-video {
  width: min(100%, 440px);
}

.popup-gallery-shell {
  width: 100%;
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 12px;
}

.popup-gallery-stage {
  position: relative;
  min-height: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.popup-gallery-main-wrap {
  position: relative;
  flex: 1 1 auto;
  height: 100%;
  min-height: 0;
  border-radius: 17px;
  border: 1px solid rgba(169, 195, 228, 0.75);
  background: linear-gradient(180deg, #f8fbff 0%, #e6eefb 100%);
  overflow: hidden;
}

.popup-gallery-stage-image {
  position: absolute;
  inset: 0;
  margin: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  opacity: 1;
  backface-visibility: hidden;
  will-change: opacity, transform;
}

.popup-gallery-stage-next {
  opacity: 0;
  pointer-events: none;
  transform: translate3d(14%, 0, 0);
  visibility: hidden;
  z-index: 2;
}

.popup-gallery-stage.is-backward .popup-gallery-stage-next {
  transform: translate3d(-14%, 0, 0);
}

.popup-gallery-stage.is-gallery-switching .popup-gallery-stage-current {
  opacity: 0.58;
  transform: translate3d(-11%, 0, 0);
}

.popup-gallery-stage.is-gallery-switching.is-backward .popup-gallery-stage-current {
  transform: translate3d(11%, 0, 0);
}

.popup-gallery-stage.is-gallery-switching .popup-gallery-stage-next {
  opacity: 1;
  transform: translate3d(0, 0, 0);
  visibility: visible;
}

.popup-gallery-stage-current,
.popup-gallery-stage-next {
  transition: opacity 0.34s ease, transform 0.34s cubic-bezier(0.16, 1, 0.3, 1), visibility 0s linear 0s;
}

.popup-gallery-nav {
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  border: 1px solid rgba(180, 205, 237, 0.92);
  background: rgba(20, 39, 68, 0.6);
  color: #f5f8ff;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.22),
    0 8px 16px rgba(7, 16, 32, 0.24);
  cursor: pointer;
  transition: transform 0.16s ease, background 0.16s ease, box-shadow 0.16s ease;
}

.popup-gallery-nav:hover,
.popup-gallery-nav:focus-visible {
  transform: translateY(-1px);
  background: rgba(26, 52, 92, 0.78);
}

.popup-gallery-nav:active {
  transform: translateY(1px) scale(0.985);
}

.popup-gallery-rail {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 2px 0;
  scrollbar-width: thin;
}

.popup-gallery-thumb {
  flex: 0 0 70px;
  width: 70px;
  height: 70px;
  border-radius: 12px;
  border: 1px solid rgba(162, 187, 220, 0.62);
  background: rgba(255, 255, 255, 0.78);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9);
  overflow: hidden;
  padding: 0;
  cursor: pointer;
  transition: transform 0.14s ease, box-shadow 0.14s ease, border-color 0.14s ease;
}

.popup-gallery-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.popup-gallery-thumb:hover,
.popup-gallery-thumb:focus-visible {
  transform: translateY(-1px);
}

.popup-gallery-thumb.active {
  border-color: #2d74cf;
  box-shadow:
    0 0 0 2px rgba(45, 116, 207, 0.24),
    inset 0 1px 0 rgba(255, 255, 255, 0.94);
}

.popup-comments-side {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.popup-social-rail-window {
  position: relative;
  min-width: 0;
  min-height: 0;
  height: 100%;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  border-radius: 18px;
  border: 1px solid rgba(167, 191, 224, 0.92);
  background:
    radial-gradient(140% 120% at 0% 0%, rgba(124, 171, 235, 0.3) 0%, rgba(124, 171, 235, 0) 34%),
    linear-gradient(180deg, #fbfdff 0%, #eef4fd 52%, #dde9f9 100%);
  color: #24446d;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.96),
    0 10px 20px rgba(28, 58, 103, 0.12);
  overflow: hidden;
}

.popup-rail-header,
.popup-rail-owner,
.popup-rail-owner-meta,
.popup-rail-tools,
.popup-rail-body,
.popup-comments-panel,
.popup-post-stats,
.popup-comments-heading,
.popup-gallery-stage,
.popup-gallery-main-wrap {
  min-width: 0;
}

.popup-rail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 14px 12px;
  border-bottom: 1px solid rgba(170, 193, 224, 0.72);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.86) 0%, rgba(228, 239, 253, 0.78) 100%);
}

.popup-rail-owner {
  display: flex;
  align-items: center;
  gap: 10px;
}

.popup-rail-avatar {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  object-fit: cover;
  border: 1px solid rgba(170, 196, 227, 0.82);
  box-shadow: 0 3px 8px rgba(35, 70, 116, 0.12);
  flex: 0 0 auto;
}

.popup-rail-owner-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.popup-rail-owner-name {
  font-size: 0.96rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: #24476f;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.popup-rail-owner-time {
  font-size: 0.77rem;
  color: #5d7ca6;
}

.popup-rail-tools {
  position: relative;
  flex: 0 0 auto;
}

.popup-post-menu-btn {
  width: 32px;
  height: 32px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 9px;
  border: 1px solid rgba(159, 184, 216, 0.88);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.96) 0%, rgba(230, 239, 251, 0.94) 100%);
  color: #28507d;
  cursor: pointer;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.96),
    0 4px 10px rgba(49, 87, 137, 0.12);
  transition: transform 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

.popup-post-menu-btn:hover,
.popup-post-menu-btn:focus-visible {
  transform: translateY(-1px);
  background: linear-gradient(180deg, rgba(255, 255, 255, 1) 0%, rgba(236, 244, 255, 0.98) 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.98),
    0 6px 14px rgba(49, 87, 137, 0.16);
}

.popup-post-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 180px;
  padding: 6px;
  display: grid;
  gap: 4px;
  border-radius: 11px;
  border: 1px solid rgba(157, 183, 216, 0.92);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98) 0%, rgba(232, 241, 252, 0.98) 100%);
  box-shadow:
    0 14px 24px rgba(40, 75, 121, 0.18),
    inset 0 1px 0 rgba(255, 255, 255, 0.98);
  z-index: 8;
}

.popup-post-menu[hidden] {
  display: none !important;
}

.popup-post-menu.is-open {
  display: grid;
}

.popup-post-menu-item {
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  color: #24486f;
  text-align: left;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 0.83rem;
  cursor: pointer;
  transition: background 0.14s ease, transform 0.14s ease, border-color 0.14s ease;
}

.popup-post-menu-item:hover,
.popup-post-menu-item:focus-visible {
  background: linear-gradient(180deg, rgba(238, 245, 255, 0.98) 0%, rgba(217, 230, 247, 0.94) 100%);
  border-color: rgba(152, 180, 216, 0.72);
}

.popup-post-menu-item:active {
  transform: translateY(1px);
}

.popup-post-menu-item.is-danger {
  color: #b33a3a;
}

.popup-rail-body {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-height: 0;
}

.popup-post-caption,
.popup-rail-caption {
  margin: 0 12px 10px;
  padding: 9px 11px;
  color: #27466f;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.92) 0%, rgba(233, 242, 252, 0.9) 100%);
  border: 1px solid rgba(176, 201, 233, 0.78);
  border-radius: 12px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.94),
    0 6px 12px rgba(47, 83, 133, 0.08);
  font-size: 0.86rem;
  line-height: 1.48;
}

.popup-rail-caption-copy {
  white-space: pre-wrap;
  word-break: break-word;
}

.popup-rail-caption--textonly {
  margin-bottom: 8px;
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.popup-rail-caption--compact {
  margin-bottom: 6px;
  font-size: 0.8rem;
  line-height: 1.35;
}

.popup-comments-window {
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
}

.popup-comments-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-height: 0;
  border-top: 1px solid rgba(173, 196, 226, 0.72);
}

.popup-comments-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 14px 10px;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #5273a0;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.52), rgba(230, 239, 249, 0.35));
}

.popup-replies-count {
  margin-left: auto;
  font-size: 0.78rem;
  background: rgba(255, 255, 255, 0.74);
  border: 1px solid rgba(175, 199, 230, 0.94);
  padding: 2px 8px;
  border-radius: 999px;
}

.popup-comments-scroll-shell {
  min-height: 0;
  overflow: hidden;
  background: linear-gradient(180deg, rgba(250, 252, 255, 0.46), rgba(227, 238, 251, 0.38));
}

.popup-comments {
  height: 100%;
  min-height: 0;
  max-height: none;
  overflow-y: auto;
  padding: 0 14px 14px;
}

.comment-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 11px 0;
  border-bottom: 1px solid rgba(174, 197, 227, 0.5);
  position: relative;
}

.reply-row {
  padding-left: 4px;
}

.reply-row::before {
  content: "";
  position: absolute;
  left: 22px;
  top: 8px;
  bottom: 8px;
  width: 2px;
  border-radius: 2px;
  background: linear-gradient(180deg, rgba(114, 156, 218, 0.45), rgba(114, 156, 218, 0.1));
}

.comment-avatar-side {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: 1px solid rgba(167, 191, 224, 0.74);
  object-fit: cover;
  flex: 0 0 auto;
}

.comment-main-content {
  flex: 1;
  min-width: 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.9) 0%, rgba(234, 242, 252, 0.96) 100%);
  border: 1px solid rgba(182, 205, 234, 0.76);
  border-radius: 10px;
  box-shadow: 0 4px 10px rgba(43, 82, 129, 0.06);
  padding: 7px 11px;
}

.comment-meta {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 2px;
}

.comment-user {
  color: #2461a4;
  font-weight: 700;
  text-decoration: none;
}

.comment-user:hover {
  text-decoration: underline;
}

.comment-time {
  color: #6a84a9;
  font-size: 0.76rem;
}

.comment-text {
  color: #2b486f;
  font-size: 0.95rem;
  line-height: 1.4;
  word-break: break-word;
}

.popup-comments-empty {
  color: rgba(67, 97, 138, 0.72);
  padding: 12px 0;
  margin: 0;
  font-size: 0.92rem;
}

.delete-comment-btn,
.delete-btn {
  background: #fff;
  border: 1.3px solid #edb6b6;
  color: #d63d3d;
  border-radius: 50%;
  width: 26px;
  height: 26px;
  font-size: 1.1rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.delete-comment-btn {
  position: absolute;
  top: 11px;
  right: 12px;
}

.popup-rail-footer {
  display: grid;
  gap: 10px;
  padding: 12px 14px 14px;
  border-top: 1px solid rgba(173, 196, 226, 0.72);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.68) 0%, rgba(224, 236, 250, 0.72) 100%);
}

.popup-post-stats {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 0.83rem;
  color: #54729a;
}

.popup-post-stats-sep {
  opacity: 0.42;
}

.popup-photo-meta.popup-post-actions,
.popup-post-actions {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.popup-action-btn {
  min-height: 34px;
  border-radius: 10px;
}

.xp-btn.mini.like-btn.popup-like-btn {
  min-width: 52px;
  min-height: 34px;
  padding: 5px 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.xp-btn.mini.like-btn .like-heart,
.xp-btn.mini.like-btn .like-heart-icon {
  margin-right: 2px;
  transition: transform 0.2s ease, filter 0.2s ease, color 0.2s ease;
}

.xp-btn.mini.like-btn.liked .like-heart,
.xp-btn.mini.like-btn.liked .like-heart-icon {
  transform: scale(1.15);
  filter: drop-shadow(0 0 2px rgba(231, 76, 60, 0.45));
}

.xp-btn.mini.like-btn .like-count-badge {
  min-width: 20px;
  text-align: right;
  font-weight: 700;
  color: #19447e;
  transition: transform 0.2s ease, color 0.2s ease;
}

.xp-btn.mini.like-btn.liked .like-count-badge {
  color: #c73e3e;
}

.xp-btn.mini.like-btn.like-press {
  transform: translateY(1px) scale(0.98);
}

.xp-btn.mini.like-btn.like-pop {
  animation: xpLikePop 0.34s cubic-bezier(0.22, 0.8, 0.25, 1);
}

.xp-btn.mini.like-btn.like-unpop {
  animation: xpLikeUnpop 0.28s ease;
}

.xp-btn.mini.like-btn .like-count-badge.count-bump {
  animation: xpLikeCountBump 0.38s ease;
}

.popup-share-btn {
  min-width: 40px;
  width: 40px;
  padding: 0;
}

.popup-share-btn .xp-ui-icon {
  width: auto;
  max-width: 21px;
  height: 19px;
}

.popup-comment-form {
  width: 100%;
  margin: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.popup-comment-form input[type="text"] {
  min-width: 0;
  min-height: 34px;
  border-radius: 9px;
  border: 1px solid rgba(164, 190, 224, 0.9);
  background: linear-gradient(180deg, #ffffff 0%, #f1f6fd 100%);
  color: #224569;
  padding: 8px 10px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.94);
}

.popup-comment-form .xp-btn {
  min-height: 34px;
  padding-inline: 12px;
}

.popup-comment-locked {
  color: #58749a;
  font-size: 0.9rem;
  background: #f3f8ff;
  border: 1px dashed #bfd6f3;
  border-radius: 8px;
  padding: 8px 10px;
}

.dydoss-zoom-viewport.is-post-popup-image-zoom {
  width: 100%;
  height: 100%;
  margin: 0;
  border-radius: 15px;
  background: #f8fbff;
  border: 1px solid rgba(168, 195, 228, 0.85);
  overflow: hidden;
}

.dydoss-zoom-viewport.is-post-popup-image-zoom .popup-main-img,
.dydoss-zoom-viewport.is-post-popup-image-zoom .dydoss-media-load-shell {
  margin: 0;
  width: 100%;
  height: 100%;
  border: 0;
  border-radius: 15px;
}

@keyframes xpLikePop {
  0% { transform: scale(0.95); filter: brightness(0.98); }
  38% { transform: scale(1.06); filter: brightness(1.08); }
  100% { transform: scale(1); filter: brightness(1); }
}

@keyframes xpLikeUnpop {
  0% { transform: scale(0.98); }
  55% { transform: scale(1.02); }
  100% { transform: scale(1); }
}

@keyframes xpLikeCountBump {
  0% { transform: scale(1); }
  45% { transform: scale(1.18); }
  100% { transform: scale(1); }
}

@media (max-width: 900px) {
  #image-popup {
    align-items: flex-start;
    padding:
      max(6px, calc(var(--dydoss-safe-top, 0px) + 4px))
      max(6px, calc(var(--dydoss-safe-right, 0px) + 4px))
      max(6px, calc(var(--dydoss-safe-bottom, 0px) + 4px))
      max(6px, calc(var(--dydoss-safe-left, 0px) + 4px));
  }

  #popup-content {
    width: min(100vw - 8px, 980px);
    max-width: min(100vw - 8px, 980px);
    min-height: 0;
    max-height: calc(var(--dydoss-viewport-height, 100dvh) - 12px - var(--dydoss-viewport-offset-top, 0px));
    border-radius: 14px;
    box-shadow:
      0 14px 36px rgba(18, 40, 78, 0.3),
      0 0 0 2px rgba(255, 255, 255, 0.92);
  }

  #close-post-popup-btn {
    top: 8px;
    right: 8px;
    width: 38px;
    height: 38px;
    border-radius: 10px;
    font-size: 1.6rem;
  }

  .post-popup-layout {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
    gap: 10px;
    padding: 10px 8px calc(10px + env(safe-area-inset-bottom, 0px));
    align-content: start;
  }

  .popup-left-side {
    overflow: visible;
    gap: 8px;
    padding-right: 0;
  }

  .popup-post-main {
    padding: 10px;
    border-radius: 12px;
  }

  .popup-post-viewport,
  .popup-gallery-block,
  .popup-video-slot,
  .popup-main-video-player {
    max-width: 100%;
  }

  .popup-post-viewport-image {
    min-height: clamp(230px, calc(var(--dydoss-viewport-height, 100dvh) * 0.29), 330px);
    max-height: calc(var(--dydoss-viewport-height, 100dvh) * 0.45);
    overflow: hidden;
  }

  .popup-main-img {
    max-height: min(340px, calc(var(--dydoss-viewport-height, 100dvh) * 0.4));
  }

  .popup-text-card {
    min-height: clamp(130px, 22vh, 182px);
    padding: 14px 12px;
  }

  .popup-video-slot {
    min-height: clamp(236px, calc(var(--dydoss-viewport-height, 100dvh) * 0.32), 330px);
    max-height: calc(var(--dydoss-viewport-height, 100dvh) * 0.46);
  }

  .popup-video-slot .dydoss-media-player,
  .popup-main-video-player {
    width: min(100%, 280px);
  }

  .popup-video-slot .dydoss-media-player.is-mode-popup.is-portrait-video,
  .popup-video-slot .dydoss-media-player.is-mode-media-popup.is-portrait-video {
    width: min(100%, 260px);
  }

  .popup-social-rail-window {
    display: flex;
    flex-direction: column;
    min-height: 0;
    border-radius: 12px;
  }

  .popup-rail-header {
    padding: 9px 10px 8px;
  }

  .popup-rail-avatar {
    width: 34px;
    height: 34px;
    border-radius: 9px;
  }

  .popup-rail-owner-name {
    font-size: 0.92rem;
  }

  .popup-rail-owner-time {
    font-size: 0.73rem;
  }

  .popup-post-caption,
  .popup-rail-caption {
    margin: 0 10px 6px;
    padding: 7px 9px;
    font-size: 0.79rem;
    line-height: 1.35;
  }

  .popup-rail-caption--compact {
    margin-bottom: 4px;
    padding: 0;
    background: transparent;
    border: 0;
    box-shadow: none;
    font-size: 0.76rem;
    line-height: 1.28;
  }

  .popup-rail-footer {
    order: 2;
    gap: 8px;
    padding: 8px 10px 9px;
  }

  .popup-post-stats {
    font-size: 0.74rem;
  }

  .popup-post-actions {
    display: grid;
    grid-template-columns: auto auto;
    justify-content: start;
    gap: 10px;
    margin-bottom: 0;
  }

  .popup-action-btn,
  .popup-comment-form .xp-btn {
    min-height: 36px;
  }

  .popup-share-btn {
    min-width: 44px;
    width: 44px;
  }

  .popup-comment-form {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
  }

  .popup-comment-form input[type="text"] {
    min-height: 36px;
    font-size: 16px;
  }

  .popup-rail-body {
    order: 3;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 0;
  }

  .popup-comments-window {
    min-height: 0;
    max-height: clamp(116px, calc(var(--dydoss-viewport-height, 100dvh) * 0.24), 214px);
  }

  .popup-comments-panel {
    min-height: 0;
    border-top: 0;
  }

  .popup-comments-heading {
    display: none;
  }

  .popup-comments-scroll-shell {
    min-height: 0;
    overflow: hidden;
  }

  .popup-comments {
    padding: 0 10px calc(8px + env(safe-area-inset-bottom, 0px));
  }

  .comment-row {
    padding: 8px 0;
  }

  .comment-avatar-side {
    width: 34px;
    height: 34px;
    border-radius: 9px;
  }

  .popup-gallery-rail {
    gap: 6px;
    padding-top: 0;
  }

  .popup-gallery-thumb {
    flex: 0 0 52px;
    width: 52px;
    height: 52px;
    border-radius: 10px;
  }

  .popup-gallery-nav {
    width: 34px;
    height: 34px;
  }
}

body.dydoss-keyboard-open #image-popup {
  align-items: flex-start;
  padding-top: max(6px, calc(var(--dydoss-safe-top, 0px) + 4px));
  padding-bottom: max(6px, calc(var(--dydoss-safe-bottom, 0px) + 4px));
}

body.dydoss-keyboard-open #popup-content {
  max-height: calc(var(--dydoss-viewport-height, 100dvh) - 10px - var(--dydoss-viewport-offset-top, 0px));
}

body.dydoss-keyboard-open #popup-extra,
body.dydoss-keyboard-open .post-popup-layout,
body.dydoss-keyboard-open .popup-social-rail-window,
body.dydoss-keyboard-open .popup-rail-body,
body.dydoss-keyboard-open .popup-comments-window {
  min-height: 0;
}

@media (hover: none), (pointer: coarse) {
  #image-popup .popup-post-actions .xp-btn,
  #image-popup .popup-comment-form .xp-btn,
  #image-popup .popup-gallery-thumb,
  #image-popup .shared-post-open-btn,
  #close-post-popup-btn {
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
  }

  #image-popup .popup-post-actions .xp-btn:hover,
  #image-popup .popup-post-actions .xp-btn:focus-visible,
  #image-popup .popup-comment-form .xp-btn:hover,
  #image-popup .popup-comment-form .xp-btn:focus-visible,
  #image-popup .shared-post-open-btn:hover,
  #image-popup .shared-post-open-btn:focus-visible {
    filter: brightness(0.99);
  }
}

@media (prefers-reduced-motion: reduce) {
  #image-popup,
  #popup-overlay,
  #popup-content,
  .popup-gallery-stage-current,
  .popup-gallery-stage-next,
  .popup-gallery-nav,
  .popup-gallery-thumb,
  #close-post-popup-btn {
    transition: none !important;
    animation: none !important;
  }

  #popup-content {
    transform: none !important;
  }
}
