/* ============================================================
   Lightbox / 大图全屏查看器
   ============================================================ */

.lightbox {
  position: fixed;
  inset: 0;
  padding: 0;
  margin: 0;
  max-width: none;
  max-height: none;
  border: none;
  background:
    radial-gradient(circle at top left, rgba(247,249,253,0.96), rgba(239,243,249,0.9) 34%, rgba(236,241,248,0.84) 100%),
    linear-gradient(180deg, rgba(247,249,253,0.94), rgba(239,243,249,0.88));
  backdrop-filter: blur(18px) saturate(115%);
  -webkit-backdrop-filter: blur(18px) saturate(115%);
  z-index: 9999;
  overflow: hidden;
  overscroll-behavior: contain;
}

.lightbox:not([open]) {
  display: none !important;
}

.lightbox::backdrop {
  background: rgba(239, 243, 249, 0.78);
  backdrop-filter: blur(12px) saturate(112%);
  -webkit-backdrop-filter: blur(12px) saturate(112%);
}

.lightbox-content {
  position: relative;
  width: 100vw;
  height: 100vh;
  padding: 18px 26px;
  box-sizing: border-box;
  isolation: isolate;
}

.lightbox-main {
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(360px, 500px);
  gap: 18px;
  align-items: stretch;
}

.lightbox-image-panel,
.lightbox-side-panel {
  min-height: 0;
  border-radius: 30px;
  border: 1px solid rgba(219, 227, 240, 0.88);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.76),
    0 14px 34px rgba(15, 23, 42, 0.06);
  backdrop-filter: blur(18px) saturate(115%);
  -webkit-backdrop-filter: blur(18px) saturate(115%);
}

.lightbox-image-panel {
  position: relative;
  overflow: hidden;
  background: linear-gradient(180deg, rgba(247,249,253,0.78), rgba(242,246,252,0.7));
  padding: 20px;
  overscroll-behavior: contain;
}

.lightbox-image-nav-layer {
  position: absolute;
  inset: 20px;
  z-index: 20;
  pointer-events: none;
}

.lightbox-image-container {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-radius: 24px;
  background-color: rgba(236, 241, 248, 0.92);
  background: linear-gradient(180deg, rgba(246,248,252,0.88), rgba(236,241,248,0.82));
  padding: 0;
}

.lightbox-image-panel:hover .lightbox-nav,
.lightbox-image-panel:focus-within .lightbox-nav {
  opacity: 1;
}

.lightbox-image-container img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 18px;
  box-shadow: 0 14px 30px rgba(15, 23, 42, 0.1);
  transition: opacity 120ms ease;
  will-change: opacity;
  user-select: none;
  -webkit-user-select: none;
  -webkit-user-drag: none;
}

.lightbox-side-panel {
  position: relative;
  z-index: 3;
  background: linear-gradient(180deg, rgba(255,255,255,0.92), rgba(249,251,255,0.84));
  color: var(--text, #1f2937);
  padding: 26px 26px 24px;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  align-content: start;
  gap: 16px;
}

.lightbox-side-header {
  display: grid;
  gap: 8px;
  padding-right: 56px;
}

.lightbox-top-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 28px;
}

.lightbox-meta {
  margin: 0;
  font-size: 14px;
  line-height: 1.5;
  color: var(--muted, #6b7280);
}
.lightbox-counter {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 52px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(241, 245, 249, 0.92);
  border: 1px solid rgba(219, 227, 240, 0.95);
  color: #64748b;
  font-size: 12px;
  line-height: 1.2;
}

.lightbox-counter-group {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
}

.lightbox-series-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(241, 245, 249, 0.66);
  border: 1px solid rgba(219, 227, 240, 0.8);
  color: #7c8797;
  font-size: 11px;
  line-height: 1.2;
  white-space: nowrap;
}

#lightbox-title {
  margin: 0;
  font-size: 1.72rem;
  line-height: 1.38;
  color: var(--text, #1f2937);
  font-weight: 700;
}

.lightbox-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  align-content: start;
}

.lightbox-reference-block {
  display: grid;
  gap: 8px;
}

.lightbox-reference-card {
  display: grid;
  gap: 12px;
  padding: 14px;
  border-radius: 18px;
  border: 1px solid rgba(219, 227, 240, 0.84);
  background: linear-gradient(180deg, rgba(255,255,255,0.72), rgba(248,250,252,0.92));
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.78);
}

.lightbox-reference-thumb {
  width: min(100%, 180px);
  height: 128px;
  border-radius: 16px;
  border: 1px solid rgba(219, 227, 240, 0.88);
  background-color: rgba(255,255,255,0.92);
  background-repeat: no-repeat;
  background-position: center center;
  background-size: contain;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.85);
}

.lightbox-tag {
  display: inline-flex;
  align-items: center;
  padding: 7px 12px;
  border-radius: 999px;
  background: #f6f8fc;
  color: #64748b;
  border: 1px solid rgba(219, 227, 240, 0.95);
  font-size: 13px;
  line-height: 1.3;
}
.lightbox-tag.clickable {
  cursor: pointer;
  transition: transform .06s ease, background .15s ease, border-color .15s ease, color .15s ease;
}
.lightbox-tag.clickable:hover {
  background: #e9f1ff;
  border-color: #bfd4fb;
  color: #335caa;
  transform: translateY(-1px);
}
.lightbox-tag.clickable:active {
  transform: translateY(0);
}

.lightbox-prompt-block {
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 10px;
}

.lightbox-summary-block {
  display: grid;
  gap: 10px;
}

.lightbox-section-title {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted, #6b7280);
}

.lightbox-section-title.subtle {
  font-size: 12px;
  letter-spacing: 0.08em;
  color: #94a3b8;
  margin: 0;
}

#lightbox-prompt {
  margin: 0;
  min-height: 0;
  overflow: auto;
  padding: 16px 16px;
  border-radius: 20px;
  background: rgba(255,255,255,0.82);
  border: 1px solid rgba(219, 227, 240, 0.9);
  color: #475569;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 16px;
  line-height: 1.9;
  white-space: pre-wrap;
  word-break: break-word;
  user-select: text;
  -webkit-user-select: text;
  cursor: text;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.84);
  scrollbar-width: thin;
}

.lightbox-summary-text {
  margin: 0;
  padding: 16px 16px;
  border-radius: 20px;
  background: rgba(255,255,255,0.82);
  border: 1px solid rgba(219, 227, 240, 0.9);
  color: #586579;
  font-size: 14px;
  line-height: 1.8;
  white-space: pre-wrap;
  word-break: break-word;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.84);
}

.lightbox-side-actions {
  display: flex;
  justify-content: flex-start;
}

#lightbox-copy-prompt {
  min-width: 208px;
  min-height: 46px;
  padding: 11px 18px;
  border-radius: 999px;
  font-weight: 650;
  border: 1px solid rgba(219, 227, 240, 0.95);
  background: linear-gradient(180deg, #ffffff, #f8fbff);
  color: var(--text, #1f2937);
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.05);
  flex: 0 0 auto;
  align-self: start;
}

.lightbox-close {
  position: absolute;
  top: 28px;
  right: 34px;
  width: 44px;
  height: 44px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.78);
  color: #6b7280;
  border: 1px solid rgba(219, 227, 240, 0.95);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.06);
}

/* iOS/Safari 会给 button 加默认 focus ring（蓝色圈），这里关掉 */
.lightbox-close:focus,
.lightbox-close:focus-visible {
  outline: none;
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.06);
}

/* 导航热区（桌面/平板）：仅作用于图片区，不覆盖右侧信息面板 */
.lightbox-nav {
  position: absolute;
  top: 0;
  bottom: 0;
  width: clamp(72px, 16%, 136px);
  margin-top: 0;
  padding: 0;
  border: 0;
  background: linear-gradient(90deg, rgba(15, 23, 42, 0.03), rgba(15, 23, 42, 0));
  color: rgba(71, 85, 105, 0.62);
  cursor: pointer;
  pointer-events: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
  opacity: 0;
  transition: background 0.16s ease, opacity 0.16s ease, color 0.16s ease;
}

.lightbox-nav span {
  width: 42px;
  height: 42px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  line-height: 1;
  color: inherit;
  opacity: 0.48;
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  transition: transform 0.14s ease, opacity 0.14s ease, background 0.14s ease, border-color 0.14s ease;
  user-select: none;
  pointer-events: none;
}

.lightbox-nav:hover {
  opacity: 1;
}

.lightbox-nav:hover span {
  opacity: 0.92;
  background: rgba(255, 255, 255, 0.3);
  border-color: rgba(255, 255, 255, 0.32);
}

.lightbox-nav:active span {
  transform: scale(0.98);
}

.lightbox-nav:focus,
.lightbox-nav:focus-visible {
  opacity: 1;
  outline: none;
}

.lightbox-prev {
  left: 0;
  border-top-left-radius: 20px;
  border-bottom-left-radius: 20px;
}

.lightbox-prev:hover {
  background: linear-gradient(90deg, rgba(15, 23, 42, 0.07), rgba(15, 23, 42, 0));
}

.lightbox-next {
  right: 0;
  border-top-right-radius: 20px;
  border-bottom-right-radius: 20px;
  background: linear-gradient(270deg, rgba(15, 23, 42, 0.025), rgba(15, 23, 42, 0));
}

.lightbox-next:hover {
  background: linear-gradient(270deg, rgba(15, 23, 42, 0.07), rgba(15, 23, 42, 0));
}

/* ===== 平板及以下（<=1100px）：布局从双栏切到上下结构 ===== */
@media (max-width: 1100px) {
  .lightbox-content {
    padding: 14px;
  }

  .lightbox-main {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(300px, 52vh) minmax(0, 1fr);
  }

  .lightbox-image-panel {
    padding: 24px;
  }

  .lightbox-image-nav-layer {
    inset: 24px;
  }

  .lightbox-image-container {
    padding: 24px;
  }

  .lightbox-side-panel {
    padding: 20px;
  }

  .lightbox-counter {
    min-width: 46px;
    padding: 4px 9px;
  }

  #lightbox-title {
    font-size: 1.5rem;
  }
}

/* ===== 手机端（<=720px）：安全区 + 玻璃层 + 触控优先 ===== */
@media (max-width: 720px) {
  /* 容器与背景玻璃层 */
  .lightbox {
    background:
      radial-gradient(circle at top left, rgba(255,255,255,0.965), rgba(245,247,251,0.94) 36%, rgba(245,247,251,0.92) 100%),
      linear-gradient(180deg, rgba(255,255,255,0.95), rgba(245,247,251,0.92));
    backdrop-filter: blur(22px) saturate(120%);
    -webkit-backdrop-filter: blur(22px) saturate(120%);
  }

  .lightbox::backdrop {
    background: rgba(245, 247, 251, 0.88);
    backdrop-filter: blur(16px) saturate(116%);
    -webkit-backdrop-filter: blur(16px) saturate(116%);
  }

  .lightbox-content::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: 0;
    background: rgba(245, 247, 251, 0.34);
    backdrop-filter: blur(10px) saturate(108%);
    -webkit-backdrop-filter: blur(10px) saturate(108%);
    pointer-events: none;
    z-index: 0;
  }

  /* 主内容层级（盖在玻璃遮罩之上） */
  .lightbox-main {
    position: relative;
    z-index: 1;
  }

  .lightbox-close {
    position: absolute;
    z-index: 30;
  }

  /* 安全区适配（刘海/底部手势条） */
  .lightbox-content {
    height: 100dvh;
    padding:
      calc(10px + env(safe-area-inset-top))
      calc(10px + env(safe-area-inset-right))
      calc(10px + env(safe-area-inset-bottom))
      calc(10px + env(safe-area-inset-left));
  }

  /* 手机端改为纯看图：只保留图片和必要控制 */
  .lightbox-main {
    display: block;
    width: 100%;
    height: calc(100dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 20px);
    min-height: 0;
  }

  .lightbox-image-panel {
    position: relative;
    height: 100%;
    min-height: 0;
    padding: 2px 6px 6px;
    touch-action: pan-y;
  }

  .lightbox-side-panel {
    display: none !important;
  }

  .lightbox-image-nav-layer {
    inset: 6px;
  }

  .lightbox-image-container {
    height: 100%;
    padding: 0;
    border-radius: 18px;
  }

  .lightbox-image-container img {
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
    border-radius: 16px;
    object-position: center top;
  }

  .lightbox-side-header {
    gap: 2px;
    padding-right: 0;
    min-width: 0;
  }

  .lightbox-top-meta-row {
    gap: 6px;
    min-height: 18px;
  }

  .lightbox-meta {
    font-size: 12px;
    line-height: 1.25;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .lightbox-counter {
    min-width: 42px;
    padding: 3px 8px;
    font-size: 11px;
  }

  #lightbox-title {
    font-size: 0.96rem;
    line-height: 1.2;
    display: block;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
  }

  .lightbox-tags {
    display: flex !important;
    flex-wrap: nowrap !important;
    align-items: center;
    align-content: center;
    gap: 6px;
    min-width: 0;
    width: 100%;
    height: 32px;
    max-height: 32px;
    overflow-x: auto;
    overflow-y: hidden !important;
    padding: 1px 1px 2px;
    margin: 0 -1px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    touch-action: pan-x;
    overscroll-behavior-x: contain;
  }

  .lightbox-tags::-webkit-scrollbar {
    display: none;
  }

  .lightbox-tag {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 26px;
    max-height: 26px;
    padding: 0 9px;
    font-size: 11px;
    line-height: 1;
    white-space: nowrap;
  }

  /* 关闭按钮：固定右上，更符合手机习惯 */
  .lightbox-close {
    top: calc(8px + env(safe-area-inset-top));
    right: calc(8px + env(safe-area-inset-right));
    left: auto;
    width: 44px;
    height: 44px;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.68);
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.28);
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.22);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
  }

  .lightbox-image-nav-layer,
  .lightbox-nav {
    display: none !important;
  }

  /* 手机端隐藏次要信息，优先看图与翻页 */
  #lightbox-copy-prompt {
    min-width: 180px;
    min-height: 44px;
    display: none !important;
  }

  .lightbox-reference-block,
  .lightbox-prompt-block,
  .lightbox-summary-block,
  .lightbox-side-actions {
    display: none !important;
  }
}


