/* ─── Mobile responsive ─── */
@media (max-width: 640px) {
  /* Fix content-w: ignore sidebar width, use full viewport */
  :root {
    --sidebar-w: 0px;
    --content-w: calc(100vw - 32px);
  }

  /* Sidebar becomes a full-height overlay, does not push main content */
  #sidebar {
    position: fixed;
    top: 0; left: 0;
    height: 100%;
    z-index: 300;
    transform: translateX(-100%);
    transition: transform 0.28s ease;
    background: #fff;
    box-shadow: 2px 0 20px rgba(0,0,0,0.12);
    width: 280px !important;
  }
  /* When sidebar is open on mobile, slide it in */
  body:not(.sidebar-collapsed) #sidebar {
    transform: translateX(0);
  }
  /* Backdrop shown when sidebar is open */
  #sidebar-backdrop {
    display: block;
  }
  body.sidebar-collapsed #sidebar-backdrop {
    display: none;
  }
  /* Main always takes full width on mobile */
  #main {
    width: 100vw;
  }
  /* Open button always visible on mobile */
  #sidebar-open-btn {
    display: flex !important;
  }
  body:not(.sidebar-collapsed) #sidebar-open-btn {
    display: none !important;
  }
  /* Input: prevent iOS auto-zoom (requires font-size >= 16px) */
  #user-input {
    font-size: 16px !important;
  }
  /* Slightly tighter input box and turns on small screens */
  .input-box {
    padding-left: 44px !important;
    padding-right: 12px !important;
  }
  #input-wrap {
    padding: 12px 8px 0 !important;
  }
  .turn, .tool-turn {
    padding-left: 12px !important;
    padding-right: 12px !important;
  }
  /* 窄屏不做竖排导航（正文占满，没有留白），避免遮挡 */
  #turn-nav { display: none !important; }
  /* Private seal pill: 窄屏按整宽居中（侧栏已收起） */
  #private-banner {
    left: 50% !important;
    max-width: calc(100vw - 24px);
  }
  /* Scroll-to-bottom btn: center on full width */
  #scroll-to-bottom {
    left: 50% !important;
  }
  /* Model bar hint text: truncate if too long */
  #model-bar {
    padding: 4px 8px 0 !important;
  }
}

/* 文件预览弹窗 */
#file-preview-modal {
  display: none; position: fixed; inset: 0; z-index: 10000;
  background: rgba(0,0,0,0.85); backdrop-filter: blur(4px);
  align-items: center; justify-content: center;
}
#file-preview-modal.show { display: flex; }
#file-preview-content {
  position: relative; max-width: 95vw; max-height: 95vh;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
}
#file-preview-content img {
  max-width: 100%; max-height: calc(95vh - 56px);
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.6);
}
#file-preview-download {
  display: flex; align-items: center; gap: 6px;
  padding: 9px 20px; border-radius: 999px;
  background: rgba(255,255,255,0.12); border: 1px solid rgba(255,255,255,0.3);
  color: #fff; font-size: 14px; text-decoration: none;
  backdrop-filter: blur(4px); transition: all 0.2s;
}
#file-preview-download:hover { background: rgba(255,255,255,0.22); border-color: #fff; }
#file-preview-close {
  position: fixed; top: 20px; right: 20px; z-index: 10001;
  width: 40px; height: 40px; border: 2px solid rgba(255,255,255,0.6);
  border-radius: 50%; background: rgba(0,0,0,0.6); color: #fff;
  font-size: 24px; line-height: 1; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.2s; backdrop-filter: blur(4px);
}
#file-preview-close:hover {
  background: rgba(255,255,255,0.15);
  border-color: #fff;
  transform: scale(1.15);
}

