/* X-Gallery 统一样式：高颜值通透毛玻璃深浅色主题、瀑布流、弹性胶囊与无边框灯箱 */

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  min-height: 100vh;
  overflow-x: hidden;
  transition: color 0.25s ease, background-color 0.25s ease;
}

/* 氛围渐变底色 */
.app-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(circle at 15% 18%, rgba(99, 102, 241, 0.26), transparent 45%),
    radial-gradient(circle at 84% 22%, rgba(236, 72, 153, 0.18), transparent 42%),
    radial-gradient(circle at 52% 88%, rgba(14, 165, 233, 0.22), transparent 50%),
    linear-gradient(180deg, #e2e8f0 0%, #cbd5e1 100%);
  transition: background 0.35s ease;
}

html.dark .app-bg {
  background:
    radial-gradient(circle at 18% 15%, rgba(56, 189, 248, 0.22), transparent 46%),
    radial-gradient(circle at 82% 24%, rgba(139, 92, 246, 0.24), transparent 46%),
    radial-gradient(circle at 50% 88%, rgba(15, 118, 110, 0.22), transparent 52%),
    linear-gradient(180deg, #070d19 0%, #0f172a 55%, #090f1d 100%);
}

/* 统一毛玻璃材质 */
.glass-panel {
  background: rgba(255, 255, 255, 0.64);
  backdrop-filter: blur(18px) saturate(150%);
  -webkit-backdrop-filter: blur(18px) saturate(150%);
  border: 1px solid rgba(255, 255, 255, 0.72);
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.08);
}

html.dark .glass-panel {
  background: rgba(15, 23, 42, 0.64);
  border-color: rgba(255, 255, 255, 0.12);
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.38);
}

.glass-chip {
  background: rgba(255, 255, 255, 0.58);
  border: 1px solid rgba(148, 163, 184, 0.32);
}

html.dark .glass-chip {
  background: rgba(30, 41, 59, 0.65);
  border-color: rgba(255, 255, 255, 0.12);
}

/* 左侧浮动毛玻璃抽屉 */
.side-drawer {
  position: fixed;
  top: 16px;
  left: 16px;
  bottom: 16px;
  width: 240px;
  border-radius: 22px;
  z-index: 35;
  display: flex;
  flex-direction: column;
  transition: transform 0.32s cubic-bezier(0.22, 1, 0.36, 1);
}

.side-drawer.is-collapsed {
  transform: translateX(calc(-100% - 22px));
}

.side-handle {
  position: fixed;
  top: 50%;
  left: 260px;
  transform: translateY(-50%);
  z-index: 36;
  width: 24px;
  height: 54px;
  border-radius: 0 12px 12px 0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: left 0.32s cubic-bezier(0.22, 1, 0.36, 1), background 0.2s ease;
}

.side-handle.is-collapsed {
  left: 0;
}

.side-handle svg {
  transition: transform 0.3s ease;
}

.side-handle.is-collapsed svg {
  transform: rotate(180deg);
}

/* 主内容区随侧栏自适应 */
.main-shell {
  transition: padding-left 0.32s cubic-bezier(0.22, 1, 0.36, 1);
  padding-left: 276px;
}

.main-shell.sidebar-closed {
  padding-left: 20px;
}

@media (max-width: 1023px) {
  .main-shell,
  .main-shell.sidebar-closed {
    padding-left: 14px;
  }
  .side-drawer {
    top: 14px;
    bottom: 14px;
    left: 12px;
    z-index: 45;
  }
  .side-handle {
    z-index: 46;
  }
}

/* 右下角毛玻璃悬浮胶囊（默认收起 [ ‹ | ↑ ]，点 ‹ 向左弹性展开） */
.fab-dock {
  position: fixed;
  right: 18px;
  bottom: max(20px, env(safe-area-inset-bottom, 20px));
  z-index: 38;
  display: inline-flex;
  align-items: center;
  padding: 5px;
  border-radius: 9999px;
  background: rgba(255, 255, 255, 0.58);
  backdrop-filter: blur(18px) saturate(160%);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
  border: 1px solid rgba(255, 255, 255, 0.65);
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.18);
}

html.dark .fab-dock {
  background: rgba(15, 23, 42, 0.72);
  border-color: rgba(255, 255, 255, 0.16);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.48);
}

.fab-drawer-items {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  overflow: hidden;
  max-width: 0;
  opacity: 0;
  margin-right: 0;
  pointer-events: none;
  transition:
    max-width 0.36s cubic-bezier(0.34, 1.38, 0.64, 1),
    opacity 0.24s ease,
    margin-right 0.32s cubic-bezier(0.34, 1.38, 0.64, 1);
}

.fab-dock.is-open .fab-drawer-items {
  max-width: 240px;
  opacity: 1;
  margin-right: 6px;
  pointer-events: auto;
}

.fab-drawer-items .fab-btn {
  transform: translateX(12px) scale(0.75);
  opacity: 0;
  transition:
    transform 0.36s cubic-bezier(0.34, 1.52, 0.64, 1),
    opacity 0.22s ease,
    background 0.2s ease;
}

.fab-dock.is-open .fab-drawer-items .fab-btn {
  transform: translateX(0) scale(1);
  opacity: 1;
}

.fab-btn {
  width: 38px;
  height: 38px;
  border-radius: 9999px;
  border: 1px solid rgba(148, 163, 184, 0.28);
  background: rgba(255, 255, 255, 0.76);
  color: #0f172a;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  text-decoration: none;
}

.fab-btn:hover {
  background: rgba(255, 255, 255, 0.96);
}

html.dark .fab-btn {
  background: rgba(30, 41, 59, 0.82);
  border-color: rgba(255, 255, 255, 0.14);
  color: #f8fafc;
}

html.dark .fab-btn:hover {
  background: rgba(51, 65, 85, 0.96);
}

.fab-btn-upload {
  background: linear-gradient(135deg, #6366f1, #8b5cf6) !important;
  border-color: rgba(255, 255, 255, 0.3) !important;
  color: #ffffff !important;
}

.fab-btn-active {
  background: linear-gradient(135deg, #0ea5e9, #6366f1) !important;
  border-color: rgba(255, 255, 255, 0.32) !important;
  color: #ffffff !important;
}

.fab-toggle-btn {
  width: 28px;
  height: 38px;
  border-radius: 9999px;
  border: none;
  background: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}

.fab-chevron {
  transition: transform 0.32s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.fab-dock.is-open .fab-chevron {
  transform: rotate(180deg);
}

.fab-divider {
  width: 1px;
  height: 18px;
  background: rgba(148, 163, 184, 0.35);
  margin: 0 3px;
  flex-shrink: 0;
}

/* 顶部浮动搜索条 */
.floating-search {
  position: fixed;
  top: 18px;
  left: 50%;
  transform: translate(-50%, -24px);
  opacity: 0;
  pointer-events: none;
  z-index: 42;
  transition: opacity 0.22s ease, transform 0.28s cubic-bezier(0.34, 1.4, 0.64, 1);
}

.floating-search.is-open {
  opacity: 1;
  transform: translate(-50%, 0);
  pointer-events: auto;
}

/* 最短列真瀑布流布局（按时间顺序从左至右排布，分页加载零跳动） */
.masonry-columns {
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

.masonry-col {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

@media (max-width: 767px) {
  .masonry-columns,
  .masonry-col {
    gap: 10px;
  }
}

.masonry-item {
  border-radius: 18px;
  overflow: hidden;
  position: relative;
  cursor: zoom-in;
  transition: transform 0.24s ease, box-shadow 0.24s ease;
  background: rgba(148, 163, 184, 0.14);
}

html.dark .masonry-item {
  background: rgba(30, 41, 59, 0.55);
}

.masonry-item:hover {
  transform: translateY(-3px);
  box-shadow: 0 16px 32px rgba(0, 0, 0, 0.26);
}

.masonry-thumb-box {
  position: relative;
  width: 100%;
  overflow: hidden;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.12), rgba(14, 165, 233, 0.1));
}

.masonry-thumb-box img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: opacity 0.28s ease, transform 0.35s ease;
}

.masonry-item:hover .masonry-thumb-box img {
  transform: scale(1.02);
}

.masonry-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 52%, rgba(2, 6, 23, 0.8) 100%);
  opacity: 0;
  transition: opacity 0.22s ease;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 12px;
  pointer-events: none;
}

.masonry-item:hover .masonry-overlay {
  opacity: 1;
}

/* 全屏无边框全透明灯箱画布 */
.lightbox-stage {
  position: relative;
  overflow: hidden;
  cursor: grab;
  user-select: none;
  touch-action: none;
  background: transparent;
}

.lightbox-stage.is-video {
  cursor: default;
  touch-action: auto;
}

.lightbox-stage.is-dragging {
  cursor: grabbing;
}

.lightbox-media-wrap {
  transform-origin: center center;
  transition: transform 0.08s linear;
  will-change: transform;
  max-width: 100%;
  max-height: 100%;
}

.lightbox-media-img {
  max-width: min(88vw, 100%);
  max-height: 82vh;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 12px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
  pointer-events: none;
  user-select: none;
}

.lightbox-media-video {
  max-width: min(88vw, 100%);
  max-height: 82vh;
  border-radius: 14px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
  background: #000000;
}

@media (max-width: 1023px) {
  .lightbox-media-img,
  .lightbox-media-video {
    max-width: 94vw;
    max-height: 46vh;
  }
}

.lb-float-chip {
  background: rgba(255, 255, 255, 0.09);
  border: 1px solid rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.lb-float-chip:hover {
  background: rgba(255, 255, 255, 0.16);
}

.lb-text-shadow {
  text-shadow: 0 1px 10px rgba(0, 0, 0, 0.48);
}

/* 拖拽上传区激活态 */
.dropzone-active {
  border-color: #6366f1 !important;
  background: rgba(99, 102, 241, 0.16) !important;
  transform: scale(1.005);
}

/* 极细滚动条 */
.thin-scroll::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}

.thin-scroll::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.35);
  border-radius: 999px;
}

/* 全局轻提示 Toast */
.toast-bar {
  position: fixed;
  top: 18px;
  left: 50%;
  transform: translate(-50%, -18px);
  opacity: 0;
  pointer-events: none;
  z-index: 95;
  transition: opacity 0.22s ease, transform 0.24s cubic-bezier(0.34, 1.4, 0.64, 1);
}

.toast-bar.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* 设置开关 Toggle */
.xg-switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  width: 46px;
  height: 26px;
  border-radius: 9999px;
  background: rgba(148, 163, 184, 0.42);
  transition: background 0.22s ease;
  cursor: pointer;
  flex-shrink: 0;
}

.xg-switch input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.xg-switch-thumb {
  width: 20px;
  height: 20px;
  border-radius: 9999px;
  background: #ffffff;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.25);
  transform: translateX(3px);
  transition: transform 0.22s cubic-bezier(0.34, 1.4, 0.64, 1);
}

.xg-switch input:checked ~ .xg-switch-thumb {
  transform: translateX(23px);
}

.xg-switch:has(input:checked) {
  background: #6366f1;
}
