:root {
  --fg: #eaeaea;
  --bg: #0f1115;
  --muted: #9aa0a6;
  --card: #151821;
  --brand: #4f8cff;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans TC", "Helvetica Neue", Arial, "Apple Color Emoji", "Segoe UI Emoji";
  background: var(--bg);
  color: var(--fg);
}

.container { width: min(1100px, 94%); margin: 0 auto; }

.site-header { border-bottom: 1px solid #3f3f3f; background: #0d0f14; }
.site-header .container { display: flex; align-items: center; justify-content: space-between; padding: 14px 0; }
.logo { color: var(--fg); text-decoration: none; font-weight: 100; letter-spacing: .5px; }
.nav a { color: var(--muted); text-decoration: none; margin-left: 14px; }
.nav a:hover { color: var(--fg); }

.upload-card {
  background: var(--card);
  padding: 18px;
  margin: 22px 0;
  text-align: center;
}
h2 { margin: 0 0 8px 0; font-size: 20px; }
.muted { color: var(--muted); font-size: 14px; margin: 6px 0 14px; }

/* =========================
   美化上傳拖曳區：drop-area
   ========================= */
.drop-area{
  position: relative;
  padding: 28px 20px;
  text-align: center;
  border: 1px dashed #2a2f44;
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(79,140,255,.08), transparent 60%),
    radial-gradient(1000px 500px at 110% 110%, rgba(122,255,214,.06), transparent 60%),
    var(--card);
  transition: transform .25s ease, box-shadow .25s ease, border-color .25s ease, background .25s ease;
  will-change: transform, box-shadow;
  overflow: hidden; /* 給 ::before/::after 用 */
}

/* 內文排版（維持你原本內容，不用改 HTML） */
.drop-area h2{
  font-size: 20px;
  margin: 0 0 10px 0;
}
.drop-area .muted { margin-top: 6px; }

/* ── 光暈邊框（不動內容，用偽元素畫） ── */
.drop-area::before{
  content:"";
  position:absolute; inset:-1px;
  border-radius:16px;
  padding:1px;

  /* 發光邊框底圖 */
  background:
    conic-gradient(from 180deg at 50% 50%,
      rgba(79,140,255,.00),
      rgba(79,140,255,.25),
      rgba(122,255,214,.25),
      rgba(79,140,255,.25),
      rgba(79,140,255,.00)
    );

  /* 標準遮罩（先宣告） */
  mask:
    linear-gradient(#000 0 0) content-box,
    linear-gradient(#000 0 0);
  mask-composite: exclude;           /* 兩層相減，挖空中間 */

  /* WebKit 前綴（再宣告一次同樣的兩層）*/
  -webkit-mask:
    linear-gradient(#000 0 0) content-box,
    linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;       /* WebKit 的相減語法 */

  opacity:0;
  filter:blur(8px);
  transition:opacity .25s ease, filter .25s ease;
  pointer-events:none;
}


/* ── 玻璃感覆蓋層（拖曳時輕微提亮） ── */
.drop-area::after{
  position: absolute; inset: 8px;
  border-radius: 12px;
  background: rgba(17, 24, 39, 0.25);
  backdrop-filter: blur(3px) saturate(110%);
  -webkit-backdrop-filter: blur(3px) saturate(110%);
  display: grid;
  place-items: center;
  color: #e5e7eb;
  font-size: 15px;
  letter-spacing: .2px;
  opacity: 0;
  transform: scale(.98);
  transition: opacity .25s ease, transform .25s ease;
  pointer-events: none;
}

/* ── 拖曳中狀態 ── */
.drop-area.dragover{
  transform: translateY(-1px) scale(1.01);
  border-color: rgba(79,140,255,.75);
  box-shadow:
    0 8px 30px rgba(0,0,0,.35),
    0 0 0 1px rgba(79,140,255,.25) inset;
  background:
    radial-gradient(1000px 500px at 50% 0%, rgba(79,140,255,.10), transparent 60%),
    radial-gradient(800px 400px at 50% 100%, rgba(122,255,214,.08), transparent 60%),
    var(--card);
}
.drop-area.dragover::before{ opacity: 1; filter: blur(6px); }
.drop-area.dragover::after{
  opacity: 1;
  transform: scale(1);
  /* 帶一個小圖示（用 Emoji，免圖片資產；想用你自己的 SVG 也行） */
  content: "⬆"; /* 上傳 */
}

/* ── 支援降低動效的使用者偏好 ── */
@media (prefers-reduced-motion: reduce){
  .drop-area, .drop-area::before, .drop-area::after{
    transition: none !important;
  }
}

/* 你原有的 hover/focus（可選） */
.file-input{
  display:inline-block; border:1px dashed #2a2f44; padding:10px 14px; border-radius:8px; cursor:pointer; margin-right:10px;
  transition: border-color .2s ease, background .2s ease;
}
.file-input:hover{ border-color:#3a4a7a; background: rgba(58, 74, 122, .12); }


.file-input { display: inline-block; border: 1px dashed #2a2f44; padding: 10px 14px; border-radius: 4px; cursor: pointer; margin-right: 10px; }
.file-input input { display: none; }

.btn-primary { border: 1px solid #34487f;
  display: inline-block;
    padding: 10px 14px;
    font-size: 13px;
    background: #171b26;
    color: #d5d9e6;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
    border-radius: 25px 0px 25px 0px; }
    .btn-primary:hover:not(:disabled) {
      opacity: 0.92;
      transform: translateY(-0.5px);
    }
    .btn-primary:disabled {
      opacity: 0.6;
      cursor: not-allowed;
    }


.preview-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; margin-top: 14px; }
.preview-grid img { width: 100%; height: 140px; object-fit: cover; border-radius: 10px; border: 1px solid #262b40; }

.latest-section .section-head { display: flex; align-items: baseline; justify-content: space-between; margin: 26px 0 10px; }
.see-all { color: var(--muted); text-decoration: none; font-size: 14px; }
.see-all:hover { color: var(--fg); }

/* ====== 本次上傳的九宮格（保持不變） ====== */
.image-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; }
.image-card { display: block; border-radius: 4px; overflow: hidden; border: 1px solid #23283a; background: #0c0e13; }
.image-card img { width: 100%; height: 180px; object-fit: cover; display: block; transition: transform .2s ease; }
.image-card:hover img { transform: scale(1.03); }

/* 保證「最新上傳」不受上面固定高度影響（即使誤用 image-card） */
.latest-section .image-card img { height: auto !important; }

.thumb-wrap { position: relative; }
.gif-badge {
  position: absolute; bottom: 8px; right: 8px;
  background: rgba(0,0,0,.65); color: #fff; font-size: 12px;
  padding: 2px 6px; border-radius: 6px; letter-spacing: .5px;
}

.image-wrapper { display: flex; justify-content: center; align-items: flex-start; gap: 24px; margin-top: 32px; flex-wrap: wrap; }
.image-content { max-width: 800px; width: 100%; padding: 0 10px; flex: 1 1 100%; text-align: center; }
.main-image { width: 80%; height: auto; border-radius: 8px; box-shadow: 0 2px 10px rgba(0,0,0,0.2); margin-bottom: 10px; }

.ad-space {
  width: 160px; min-height: 600px; background-color: #f8f8f8; border: 1px dashed #ccc;
  display: flex; justify-content: center; align-items: center; color: #aaa; font-size: 14px; flex-shrink: 0;
}

.share-codes { margin-top: 24px; padding-top: 12px; border-top: 1px solid #595959; }
.share-codes h4 { font-size: 16px; margin-bottom: 10px; }
.code-block { margin-bottom: 10px; }
.code-block label { display: block; font-size: 14px; margin-bottom: 4px; color: #ffffff; }
.code-block input[type="text"]:hover { background: #969696; cursor: pointer; }

.copy-box {
  background-color: #111218; border: 1px solid #2d2f3a; border-radius: 3px; padding: 10px 12px;
  font-family: monospace; font-size: 14px; color: #e2e2e2; margin-top: 6px; cursor: pointer;
  user-select: none; transition: background 0.2s ease, border-color 0.2s ease; word-break: break-all;
}
.copy-box:hover { background-color: #1c1f29; border-color: #bb88ff; color: #ffffff; }
.copy-box:active { background-color: #2a2f42; border-color: #5888f0; }
.copy-box:focus { outline: none; border-color: #3a6ee8; }

.share-codes { margin-top: 24px; }
.share-codes label { font-size: 13px; color: #999; display: block; margin-bottom: 4px; margin-top: 16px; }

.site-footer { border-top: 1px solid #1d2130; margin-top: 40px; background: var(--footer-bg, transparent); }
.site-footer .container { padding: 2px 0; font-size: 14px; color: var(--muted, #aaa); line-height: 1.8; }
.footer-link { color: var(--accent, #58a6ff); text-decoration: none; transition: opacity 0.2s, text-decoration 0.2s; }
.footer-link:hover { opacity: 0.8; text-decoration: underline; }

/* ====== 最新上傳：Collage/Quilt 拼圖（核心） ====== */
.latest-section .collage-grid{
  display: grid;
  grid-auto-flow: dense;              /* 允許回填空位 */
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
  --tile-max: 300px;         
}

.latest-section .collage-grid .tile{
  position: relative;
  overflow: hidden;
  border-radius: 2px;
  background: var(--card-bg,#0c0e13);
  border: 1px solid #23283a;
  box-shadow: 0 1px 2px rgba(0,0,0,.15);
  transition: transform .12s ease, box-shadow .12s ease;
  outline: none;
  max-height: var(--tile-max);
}
.latest-section .collage-grid .tile:hover{
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(0,0,0,.28);
}

/* 欄寬（JS 會套 w1/w2；沒套時預設 1 欄寬） */
.latest-section .collage-grid .tile { grid-column: span 1; }
.latest-section .collage-grid .w1   { grid-column: span 1; }
.latest-section .collage-grid .w2   { grid-column: span 2; }

/* 用 ::before 佔位，避免 CLS；高度由比例控制（JS 寫入 --ar） */
.latest-section .collage-grid .tile::before{
  content: "";
  display: block;
  width: 100%;
  aspect-ratio: var(--ar, 1 / 1);
  /* 兼容極舊瀏覽器 */
  min-height: 120px;
  max-height: var(--tile-max);
}

/* 圖片覆蓋整塊卡片 */
.latest-section .collage-grid .tile > img{
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
  transition: transform .22s ease;
  object-position: center;
}
.latest-section .collage-grid .tile:hover > img{ transform: scale(1.03); }

/* ================================================= */
/* 按鈕風格 開關 (Toggle Switch) CSS              */
/* ================================================= */

/* 1. 基礎容器 - 定義尺寸 */
.switch {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 27px;
  vertical-align: middle;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

/* 2. 滑軌 (Slider Track) - 仿按鈕風格 */
.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  
  /* 仿按鈕樣式 - 關閉狀態 */
  background-color: #171b26; /* 按鈕深色背景 */
  border: 1px solid #34487f; /* 按鈕邊框藍色 */
  transition: 0.3s;
  border-radius: 26px;
}

/* 3. 滑塊 (Slider Knob) - 仿按鈕文字顏色 */
.slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 4px;
  bottom: 4px;
  
  /* 仿按鈕樣式 - 使用按鈕文字顏色 */
  background-color: #d5d9e6; 
  transition: 0.3s;
  border-radius: 50%;
}

/* 4. 開啟狀態 (Checked State) */
input:checked + .slider {
  /* 開啟時背景使用邊框色，邊框變亮 */
  background-color: #34487f; 
  border-color: #d5d9e6; 
}

input:checked + .slider:before {
  transform: translateX(20px); /* 準確的移動距離 */
}

/* 5. 禁用狀態 (Disabled State) */
input:disabled + .slider {
  opacity: 0.6; /* 與按鈕禁用樣式一致 */
  cursor: not-allowed;
}

input:disabled + .slider:before {
  opacity: 0.6; /* 讓滑塊也變暗 */
}

.public-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 10px 0;
  justify-content: center;
}

.label-text {
  color: #ccc;
  font-size: 14px;
}
.cc-revoke {
  display: none !important;
}

/* 🔥 新增：修復手機版 Email 自動變連結的問題 */
.welcome {
  pointer-events: none; /* 禁止點擊 */
  color: inherit;       /* 繼承原本顏色 */
  text-decoration: none;
}

/* 響應式欄數縮減 */
@media (max-width: 1200px){
  .latest-section .collage-grid{ grid-template-columns: repeat(4,1fr); }
}
@media (max-width: 992px){
  .latest-section .collage-grid{ grid-template-columns: repeat(3,1fr); }
}
@media (max-width: 768px){
  .latest-section .collage-grid{ grid-template-columns: repeat(2,1fr); }
  /* 手機避免寬兩欄造成空洞：全部視作單欄 */
  .latest-section .collage-grid .w2{ grid-column: span 1; }
}
@media (max-width: 480px){
  .latest-section .collage-grid{ grid-template-columns: 1fr; }
}

/* 手機佈局微調 */
@media (max-width: 768px) {
  .ad-space { display: none; }
  .image-wrapper { flex-direction: column; align-items: center; padding: 0 10px; }
  .image-content { padding: 0; }
  .site-footer .container { font-size: 13px; padding: 20px 10px; }
}

/* =========================================
   📱 手機版導航優化：橫向滑動
   ========================================= */
@media (max-width: 768px) {
  
  /* 1. 確保 Logo 不會被擠壓 */
  .logo {
    flex-shrink: 0;
    margin-right: 10px;
    z-index: 2; /* 確保 Logo 在最上層 */
  }

  /* 2. 導航選單容器設定 */
  .nav {
    display: flex;
    align-items: center;
    
    /* 核心：開啟橫向捲動 */
    overflow-x: auto;
    overflow-y: hidden;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch; /* 讓 iOS 滑動更順暢 */
    
    /* 讓容器佔據剩餘空間 */
    flex-grow: 1;
    justify-content: flex-end; /* 內容靠右對齊 */
    
    /* 隱藏捲軸 (美觀) */
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE/Edge */
    
    /* 增加一點右側內距，避免最後一個選項貼邊 */
    padding-right: 5px;
    
    /* 加上遮罩效果 (左側淡出)，提示還有內容 (選用) */
    mask-image: linear-gradient(to right, transparent, black 10px);
    -webkit-mask-image: linear-gradient(to right, transparent, black 10px);
  }

  /* 隱藏 Chrome/Safari 的捲軸 */
  .nav::-webkit-scrollbar {
    display: none;
  }

  /* 3. 確保連結不會換行，且好點擊 */
  .nav a {
    flex-shrink: 0; /* 禁止壓縮文字 */
    padding: 8px 4px; /* 增加點擊範圍 */
    margin-left: 12px;
  }

  /* 4. 🔥 優化：手機版隱藏「歡迎 xxx@gmail...」
     原因：Email 太長了，會佔據手機 70% 寬度，導致主要功能按鈕被擠到看不見。
     隱藏後，使用者能直接看到「首頁、最新、上傳」。 */
  .nav .welcome {
    display: none;
  }
}

