/* v35: consolidated card/detail layer.
   This replaces the old v20-v34 override pile that repeatedly fought itself.
   Keep every gallery card on this one structure:
   media -> hoverbar -> left controls(heart/profile) + right text. */

/* ---- Detail modal: whole-image first, click to zoom. ---- */
.gallery-post-dialog {
  width: min(1240px, calc(100vw - 32px)) !important;
  height: auto !important;
  max-height: calc(100dvh - 32px) !important;
  overflow: hidden !important;
}
.gallery-post-image-pane {
  min-height: 0 !important;
  max-height: calc(100dvh - 32px) !important;
  overflow: hidden !important;
  background: color-mix(in srgb, var(--muted) 7%, transparent) !important;
}
.gallery-post-image-button {
  all: unset;
  box-sizing: border-box;
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  min-height: min(72vh, 760px);
  padding: 16px;
  cursor: zoom-in;
}
.gallery-post-image-button img {
  display: block !important;
  width: auto !important;
  height: auto !important;
  max-width: 100% !important;
  max-height: calc(100dvh - 72px) !important;
  object-fit: contain !important;
  object-position: center center !important;
  transform: none !important;
  border: 0 !important;
}
.gallery-post-close {
  display: inline-grid !important;
  place-items: center !important;
  line-height: 1 !important;
}
.gallery-post-close:hover,
.gallery-post-close:focus-visible,
.gallery-post-action:hover,
.gallery-post-action:focus-visible {
  border-color: rgba(255, 111, 171, .55) !important;
  background: rgba(255, 122, 184, .18) !important;
  color: #c93f80 !important;
}
html[data-theme="dark"] .gallery-post-close:hover,
html[data-theme="dark"] .gallery-post-close:focus-visible,
html[data-theme="dark"] .gallery-post-action:hover,
html[data-theme="dark"] .gallery-post-action:focus-visible,
[data-theme="dark"] .gallery-post-close:hover,
[data-theme="dark"] .gallery-post-close:focus-visible,
[data-theme="dark"] .gallery-post-action:hover,
[data-theme="dark"] .gallery-post-action:focus-visible {
  border-color: rgba(255, 139, 194, .62) !important;
  background: rgba(255, 112, 174, .22) !important;
  color: #ffd2e6 !important;
}
.gallery-post-zoom-hint {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translate(-50%, 6px);
  opacity: 0;
  pointer-events: none;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,.62);
  background: rgba(255,255,255,.86);
  color: #443847;
  box-shadow: 0 10px 28px rgba(33,22,38,.16);
  backdrop-filter: blur(10px);
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
  transition: opacity .16s ease, transform .16s ease;
}
.gallery-post-image-button:hover .gallery-post-zoom-hint,
.gallery-post-image-button:focus-visible .gallery-post-zoom-hint {
  opacity: 1;
  transform: translate(-50%, 0);
}
[data-theme="dark"] .gallery-post-zoom-hint {
  background: rgba(45,35,49,.88);
  color: var(--text);
  border-color: rgba(255,255,255,.14);
}

.gallery-image-zoom.hidden { display: none !important; }
.gallery-image-zoom {
  position: fixed;
  inset: 0;
  z-index: 10020;
  display: grid;
  place-items: stretch;
}
.gallery-image-zoom-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(18,14,22,.78);
  backdrop-filter: blur(10px);
}
.gallery-image-zoom-panel {
  position: relative;
  z-index: 1;
  min-width: 0;
  min-height: 0;
}
.gallery-image-zoom-toolbar {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 3;
  display: flex;
  gap: 8px;
  align-items: center;
}
.gallery-image-zoom-mode,
.gallery-image-zoom-close {
  min-height: 40px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,.22);
  background: rgba(255,255,255,.88);
  color: #443847;
  box-shadow: 0 12px 30px rgba(0,0,0,.18);
  backdrop-filter: blur(12px);
  font-weight: 950;
  cursor: pointer;
}
.gallery-image-zoom-mode { padding: 0 15px; }
.gallery-image-zoom-close {
  width: 42px;
  padding: 0;
  font-size: 24px;
  line-height: 1;
  display: inline-grid;
  place-items: center;
}
.gallery-image-zoom-mode:hover,
.gallery-image-zoom-mode:focus-visible,
.gallery-image-zoom-close:hover,
.gallery-image-zoom-close:focus-visible {
  border-color: rgba(255, 111, 171, .55);
  background: rgba(255, 122, 184, .18);
  color: #c93f80;
}
html[data-theme="dark"] .gallery-image-zoom-mode,
html[data-theme="dark"] .gallery-image-zoom-close,
html[data-theme="dark"] .gallery-image-zoom-help,
[data-theme="dark"] .gallery-image-zoom-mode,
[data-theme="dark"] .gallery-image-zoom-close,
[data-theme="dark"] .gallery-image-zoom-help {
  background: rgba(45,35,49,.88);
  color: var(--text);
  border-color: rgba(255,255,255,.14);
}
html[data-theme="dark"] .gallery-image-zoom-mode:hover,
html[data-theme="dark"] .gallery-image-zoom-mode:focus-visible,
html[data-theme="dark"] .gallery-image-zoom-close:hover,
html[data-theme="dark"] .gallery-image-zoom-close:focus-visible,
[data-theme="dark"] .gallery-image-zoom-mode:hover,
[data-theme="dark"] .gallery-image-zoom-mode:focus-visible,
[data-theme="dark"] .gallery-image-zoom-close:hover,
[data-theme="dark"] .gallery-image-zoom-close:focus-visible {
  border-color: rgba(255, 139, 194, .62);
  background: rgba(255, 112, 174, .22);
  color: #ffd2e6;
}
.gallery-image-zoom-stage {
  position: fixed;
  inset: 0;
  overflow: hidden;
  display: grid;
  place-items: center;
  padding: 72px 28px 54px;
  box-sizing: border-box;
  touch-action: none;
  cursor: grab;
}
.gallery-image-zoom-stage:active { cursor: grabbing; }
.gallery-image-zoom-stage img {
  display: block;
  max-width: calc(100vw - 56px);
  max-height: calc(100dvh - 126px);
  width: auto;
  height: auto;
  object-fit: contain;
  cursor: zoom-in;
  user-select: none;
  touch-action: none;
  border-radius: 10px;
  box-shadow: 0 24px 80px rgba(0,0,0,.32);
  will-change: transform;
}
.gallery-image-zoom.is-actual-size .gallery-image-zoom-stage {
  place-items: center;
}
/* v47: keep the image laid out at screen-fit size and scale it with the
   original bitmap. Removing max-width/max-height here prevents double-upscaling
   in actual-size mode, which made original images look blurry. */
.gallery-image-zoom.is-actual-size .gallery-image-zoom-stage img,
.gallery-image-zoom.is-pannable .gallery-image-zoom-stage img {
  cursor: zoom-out;
  transform-origin: center center;
  image-rendering: auto;
}
.gallery-image-zoom-help {
  position: fixed;
  left: 50%;
  bottom: 18px;
  z-index: 3;
  transform: translateX(-50%);
  margin: 0;
  padding: 8px 13px;
  border-radius: 999px;
  background: rgba(255,255,255,.84);
  color: #443847;
  font-size: 12px;
  font-weight: 900;
  box-shadow: 0 12px 30px rgba(0,0,0,.16);
  backdrop-filter: blur(12px);
  white-space: nowrap;
}
body.image-zoom-open { overflow: hidden; }

/* ---- Mobile drawer: do not jump scroll; keep one menu icon. ---- */
@media (max-width: 820px) {
  body.sidebar-open-mobile {
    position: static !important;
    top: auto !important;
    left: auto !important;
    right: auto !important;
    width: auto !important;
    overflow: hidden !important;
    overscroll-behavior: contain !important;
    touch-action: auto !important;
  }
}
.mobile-menu,
body.sidebar-collapsed .mobile-menu,
body.sidebar-open-mobile .mobile-menu {
  font-family: inherit !important;
}


/* v54: Pinterest-style in-place share menu. Shared URL still uses OG metadata page. */
.gallery-post-actions{overflow:visible!important;align-items:center!important}
.gallery-post-actions>*{flex:1 1 118px!important;min-width:118px!important}
.gallery-post-actions>button{width:100%!important}
.post-share-action{position:relative!important;display:inline-flex!important;flex:1 1 118px!important;min-width:118px!important}
.gallery-post-actions .post-share-action>.pin-share-button,.gallery-post-actions>.pin-share-button{
  display:inline-flex!important;align-items:center!important;justify-content:center!important;
  width:100%!important;min-width:118px!important;min-height:38px!important;padding:0 16px!important;border-radius:999px!important;
  border:1px solid rgba(255,255,255,.68)!important;background:rgba(255,255,255,.9)!important;color:#443847!important;
  box-shadow:0 10px 24px rgba(54,31,58,.18)!important;backdrop-filter:blur(10px)!important;
  font-weight:950!important;cursor:pointer!important;white-space:nowrap!important
}
.gallery-post-actions .post-share-action>.pin-share-button:hover,.gallery-post-actions .post-share-action>.pin-share-button:focus-visible,.gallery-post-actions>.pin-share-button:hover,.gallery-post-actions>.pin-share-button:focus-visible{
  border-color:rgba(255,111,171,.55)!important;background:rgba(255,122,184,.18)!important;color:#c93f80!important
}
.post-share-popover{
  position:fixed!important;z-index:10080!important;display:grid!important;gap:6px!important;width:260px!important;padding:10px!important;
  border-radius:20px!important;border:1px solid rgba(255,143,196,.32)!important;background:rgba(255,255,255,.97)!important;
  color:#443847!important;box-shadow:0 24px 70px rgba(62,35,66,.24)!important;backdrop-filter:blur(18px)!important;
  opacity:0!important;visibility:hidden!important;transform:translateY(-4px) scale(.98)!important;pointer-events:none!important;
  transition:opacity .14s ease,transform .14s ease,visibility .14s ease!important
}
.post-share-popover.open{opacity:1!important;visibility:visible!important;transform:translateY(0) scale(1)!important;pointer-events:auto!important}
.post-share-title{display:block!important;padding:8px 10px 4px!important;color:rgba(68,56,71,.72)!important;font-size:12px!important;font-weight:950!important;letter-spacing:.03em!important}
.post-share-item{
  display:flex!important;align-items:center!important;justify-content:flex-start!important;width:100%!important;min-height:42px!important;
  padding:0 12px!important;border:0!important;border-radius:14px!important;background:transparent!important;color:inherit!important;
  font:inherit!important;font-size:14px!important;font-weight:950!important;text-align:left!important;cursor:pointer!important
}
.post-share-item:hover,.post-share-item:focus-visible{background:rgba(255,122,184,.16)!important;color:#c93f80!important;outline:none!important}
html[data-theme="dark"] .gallery-post-actions .post-share-action>.pin-share-button,[data-theme="dark"] .gallery-post-actions .post-share-action>.pin-share-button,html[data-theme="dark"] .gallery-post-actions>.pin-share-button,[data-theme="dark"] .gallery-post-actions>.pin-share-button{
  background:rgba(45,35,49,.88)!important;color:var(--text)!important;border-color:rgba(255,255,255,.14)!important
}
html[data-theme="dark"] .post-share-popover,[data-theme="dark"] .post-share-popover{background:rgba(45,35,49,.97)!important;color:var(--text)!important;border-color:rgba(255,255,255,.14)!important;box-shadow:0 24px 70px rgba(0,0,0,.42)!important}
html[data-theme="dark"] .post-share-title,[data-theme="dark"] .post-share-title{color:rgba(250,238,255,.74)!important}
html[data-theme="dark"] .post-share-item:hover,html[data-theme="dark"] .post-share-item:focus-visible,[data-theme="dark"] .post-share-item:hover,[data-theme="dark"] .post-share-item:focus-visible{background:rgba(255,112,174,.2)!important;color:#ffd2e6!important}
@media (max-width:680px){.post-share-action,.post-share-action>.pin-share-button{width:100%!important}.post-share-popover{width:min(276px,calc(100vw - 24px))!important}}
