/* ============================================================
   主题变量
   浅色为默认；<html data-theme="dark"> 时整套换掉。
   想改配色只动这两块，不用满文件翻颜色。
   属性由 index.html <head> 里的内联脚本尽早设置，避免刷新闪白。
   ============================================================ */
:root {
  color-scheme: light;

  --bg-from: #ffffff;
  --bg-to: #d9d9d9;

  --fg: #111;
  --fg-strong: #000;
  --fg-body: #333;
  --fg-muted: #888;
  --fg-subtle: #999;

  --accent: #1a73e8;
  --accent-strong: #1666d0;
  --accent-glow: rgba(26, 115, 232, 0.35);
  --accent-glow-hover: rgba(26, 115, 232, 0.45);
  --accent-ring: rgba(26, 115, 232, 0.30);

  --divider: #ccc;

  --card-bg: rgba(255, 255, 255, 0.85);
  --card-border: transparent;
  --card-shadow: rgba(0, 0, 0, 0.08);
  --card-shadow-hover: rgba(0, 0, 0, 0.12);

  --cover-shadow: rgba(0, 0, 0, 0.15);
  --cover-shadow-hover: rgba(0, 0, 0, 0.22);

  --sheet-bg: #ffffff;
  --sheet-handle: #d5d5d5;
  --sheet-shadow: rgba(0, 0, 0, 0.28);

  --soft-bg: #f1f1f1;
  --soft-bg-active: #e2e2e2;
  --soft-fg: #555;

  --toggle-bg: rgba(255, 255, 255, 0.90);
  --toggle-border: rgba(0, 0, 0, 0.09);
  --toggle-fg: #444;
  --toggle-shadow: rgba(0, 0, 0, 0.14);

  --backdrop: rgba(0, 0, 0, 0.45);
}

html[data-theme="dark"] {
  color-scheme: dark;

  --bg-from: #14161d;
  --bg-to: #07080c;

  --fg: #e7eaf2;
  --fg-strong: #ffffff;
  --fg-body: #c9cedb;
  --fg-muted: #99a0b0;
  --fg-subtle: #7f8697;

  --accent: #5aa2ff;
  --accent-strong: #7cb6ff;
  --accent-glow: rgba(90, 162, 255, 0.35);
  --accent-glow-hover: rgba(90, 162, 255, 0.50);
  --accent-ring: rgba(90, 162, 255, 0.38);

  --divider: #2b2f3a;

  --card-bg: rgba(255, 255, 255, 0.055);
  --card-border: rgba(255, 255, 255, 0.07);
  --card-shadow: rgba(0, 0, 0, 0.45);
  --card-shadow-hover: rgba(0, 0, 0, 0.60);

  --cover-shadow: rgba(0, 0, 0, 0.50);
  --cover-shadow-hover: rgba(0, 0, 0, 0.65);

  --sheet-bg: #1b1e26;
  --sheet-handle: #3a3f4c;
  --sheet-shadow: rgba(0, 0, 0, 0.60);

  --soft-bg: #2a2f3a;
  --soft-bg-active: #363c49;
  --soft-fg: #c9cedb;

  --toggle-bg: rgba(255, 255, 255, 0.07);
  --toggle-border: rgba(255, 255, 255, 0.13);
  --toggle-fg: #e7eaf2;
  --toggle-shadow: rgba(0, 0, 0, 0.40);

  --backdrop: rgba(0, 0, 0, 0.62);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: linear-gradient(180deg, var(--bg-from) 0%, var(--bg-to) 100%);
  background-attachment: fixed;
  color: var(--fg);
}

/* ---------- 左上角个人信息 ---------- */
.profile {
  position: absolute;
  top:  12px;
  left: 24px;
  display: flex;
  align-items: stretch;
  gap: 12px;
  z-index: 10;
}

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.avatar-link {
  display: block;
  flex-shrink: 0;
  line-height: 0;        /* 去掉 a 标签底部可能的空隙 */
}

.avatar-link:hover .avatar {
  opacity: 0.85;
  transition: opacity 0.2s;
}

.profile-text {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;   /* 昵称与简介靠近 */
  gap: 6px;
}

.nickname {
  font-size: 22px;
  font-weight: 700;
  color: var(--fg-strong);
  line-height: 1;
}

.bio {
  font-size: 11px;
  color: var(--fg-muted);
  line-height: 1;
}

/* ---------- 右上角：夜间模式切换 ---------- */
.theme-toggle {
  position: absolute;
  top: 12px;
  right: 24px;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid var(--toggle-border);
  border-radius: 50%;
  background: var(--toggle-bg);
  color: var(--toggle-fg);
  cursor: pointer;
  box-shadow: 0 1px 6px var(--toggle-shadow);
  transition: transform 0.18s, box-shadow 0.18s,
              background 0.18s, color 0.18s, border-color 0.18s;
}

.theme-toggle:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px var(--toggle-shadow);
}

.theme-toggle:active { transform: translateY(0); }

.theme-icon {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* 浅色显示太阳，深色显示月亮 */
.icon-moon { display: none; }
html[data-theme="dark"] .icon-sun  { display: none; }
html[data-theme="dark"] .icon-moon { display: block; }

/* ---------- 横跨屏幕的细线 ---------- */
.divider {
  position: absolute;
  top: 68px;            /* 头像顶部 24px + 头像高 72px */
  left: 0;
  width: 100%;
  height: 1px;
  background: var(--divider);
}

/* ---------- 主布局 ---------- */
.layout {
  display: flex;
  height: 100vh;
  padding-top: 120px;
}

.left-panel {
  width: 75%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 24px;
}

.right-panel {
  width: 25%;
  height: 100%;
  overflow-y: auto;
  padding: 8px 16px 40px;
  scrollbar-width: none;
}
.right-panel::-webkit-scrollbar { display: none; }

/* ---------- WELCOME ---------- */
.welcome {
  font-size: 96px;
  font-weight: 800;
  letter-spacing: 4px;
  color: var(--fg);
  text-align: center;
  width: 70%;

  animation: welcomeIn 0.9s ease-out both;
}

/* ---------- 详情面板：左右两栏 ---------- */
/* 外层只负责居中；真正的两栏布局在 .detail-sheet 上 */
.detail {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.detail-sheet {
  width: 90%;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 48px;
}

/* 这两个只在手机端出现，桌面端隐藏 */
.sheet-backdrop,
.sheet-close { display: none; }

.detail-info {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.detail-head {
  font-size: 18px;
  color: var(--fg);
  line-height: 1.5;
}

.detail-head span {
  color: var(--fg-body);
  font-weight: 500;
}

/* 标头：蓝色 + 与自定义文字间隔 */
.detail-head .head-label {
  color: var(--accent);
  font-weight: 600;
  margin-right: 14px;
}

/* ---------- 下载按钮 ---------- */
.download-btn {
  margin-top: 20px;
  align-self: flex-start;
  display: inline-block;
  padding: 12px 32px;
  background: var(--accent);
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  text-decoration: none;
  text-align: center;
  border-radius: 999px;
  box-shadow: 0 2px 8px var(--accent-glow);
  transition: transform 0.15s, box-shadow 0.15s, background 0.15s;
}

.download-btn:hover {
  background: var(--accent-strong);
  transform: translateY(-2px);
  box-shadow: 0 4px 14px var(--accent-glow-hover);
}

.download-btn:active {
  transform: translateY(0);
}

/* ---------- 右栏高清图 ---------- */
.detail-cover-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;      /* 图片在上，文字在下 */
  justify-content: center;
  align-items: center;         /* 水平居中 */
  gap: 10px;                   /* 图片与文字的间距 */
}

.cover-hint {
  font-size: 12px;
  color: var(--fg-muted);
  letter-spacing: 1px;
  user-select: none;           /* 防止被选中 */
}

.detail-cover:hover + .cover-hint {
  color: var(--accent);
}

.detail-cover {
  width: 100%;
  max-width: 480px;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 12px;
  box-shadow: 0 6px 24px var(--cover-shadow);
  cursor: zoom-in;
  transition: transform 0.2s, box-shadow 0.2s;
}

.detail-cover:hover {
  transform: scale(1.02);
  box-shadow: 0 8px 30px var(--cover-shadow-hover);
}

/* 高清图就绪后淡入，避免"啪"地一下跳变 */
.detail-cover.hd-in {
  animation: coverIn 0.3s ease;
}

/* ---------- 文件卡片 ---------- */
.file-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.detail-fade {
  animation: detailIn 0.5s ease-out both;
}

.card {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 96px;
  padding: 10px 14px;
  background: var(--card-bg);
  border-radius: 16px;
  border: 2px solid var(--card-border);
  cursor: pointer;
  box-shadow: 0 1px 6px var(--card-shadow);
  transition: border-color 0.2s, transform 0.2s, box-shadow 0.2s,
              background 0.2s;

  opacity: 0;
  transform: translateY(14px);
}

.card.visible {
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.5s ease, transform 0.5s ease,
              border-color 0.2s, box-shadow 0.2s, background 0.2s;
}

.card:hover {
  box-shadow: 0 4px 14px var(--card-shadow-hover);
}

.card.active {
  border-color: var(--accent);
  box-shadow: 0 4px 16px var(--accent-ring);
}

.card-cover {
  width: 128px;
  height: 72px;
  object-fit: cover;
  border-radius: 8px;
  flex-shrink: 0;
}

.card-text {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 4px;
  height: 72px;
  margin-left: 12px;
  overflow: hidden;
  flex: 1;
}

.card-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--fg);
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.card-author {
  font-size: 12px;
  font-weight: 400;
  color: var(--fg-subtle);
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  padding-right: 160px;   /* 避开右下角的大小标注 */
}

.card-size {
  position: absolute;
  right: 14px;
  bottom: 10px;
  font-size: 11px;
  font-weight: 400;
  color: var(--fg);
  letter-spacing: 0.5px;
}

/* ---------- 灯箱 ---------- */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
  cursor: zoom-out;
  animation: fadeIn 0.25s ease;
}

.lightbox img {
  max-width: 92vw;
  max-height: 92vh;
  border-radius: 8px;
  box-shadow: 0 10px 50px rgba(0, 0, 0, 0.6);
  animation: zoomIn 0.25s ease;
}

@keyframes welcomeIn {
  from {
    opacity: 0;
    transform: translateY(24px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes detailIn {
  from {
    opacity: 0;
    transform: translateY(18px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes zoomIn {
  from { transform: scale(0.92); opacity: 0; }
  to   { transform: scale(1);    opacity: 1; }
}

@keyframes coverIn {
  from { opacity: 0.30; }
  to   { opacity: 1; }
}

/* 通用隐藏 —— 必须放最后，且用 !important */
.hidden { display: none !important; }

/* 减少动态效果 */
@media (prefers-reduced-motion: reduce) {
  .card { opacity: 1; transform: none; transition: none; }
  .download-btn { transition: none; }
  .detail-cover.hd-in { animation: none; }
}

/* ============================================================
   平板适配（769px ~ 1024px）
   保持左右分栏，只是把右侧列表加宽一点，别太挤
   ============================================================ */
@media (max-width: 1024px) and (min-width: 769px) {
  .left-panel  { width: 60%; padding: 0 20px; }
  .right-panel { width: 40%; }
  .welcome     { font-size: 68px; letter-spacing: 3px; }

  .detail-sheet { width: 96%; gap: 26px; }
  .detail-head  { font-size: 16px; }
  .detail-head .head-label { margin-right: 8px; }
  .detail-cover { max-width: 340px; }
}


/* ============================================================
   手机适配（<= 768px）
   竖向堆叠：顶部信息 → WELCOME 头图 → 文件列表
   详情改为「底部抽屉」，点卡片从底部滑出
   ============================================================ */
@media (max-width: 768px) {

  html, body {
    height: auto;
    min-height: 100%;
    overflow-x: hidden;
    -webkit-text-size-adjust: 100%;
  }

  /* 触屏上取消点击高亮方块 */
  * { -webkit-tap-highlight-color: transparent; }

  /* ---------- 顶部信息：从绝对定位改为正常文档流 ---------- */
  .profile {
    position: relative;
    top: auto;
    left: auto;
    /* 右侧留出夜间模式按钮的位置 */
    padding: calc(14px + env(safe-area-inset-top)) 60px 12px 16px;
    gap: 10px;
  }

  .avatar { width: 38px; height: 38px; }

  .profile-text { gap: 5px; }
  .nickname { font-size: 18px; }
  .bio      { font-size: 10px; }

  /* 夜间模式按钮：跟随文档滚动，不悬浮遮挡内容 */
  .theme-toggle {
    top: calc(12px + env(safe-area-inset-top));
    right: 14px;
    width: 36px;
    height: 36px;
  }

  .theme-icon { width: 18px; height: 18px; }

  .divider {
    position: static;
    width: 100%;
  }

  /* ---------- 主布局：竖向堆叠，整页正常滚动 ---------- */
  .layout {
    flex-direction: column;
    height: auto;
    min-height: 0;
    padding-top: 8px;
  }

  /* 左栏（手机端只承载 WELCOME 头图） */
  .left-panel {
    width: 100%;
    min-height: 22vh;
    padding: 22px 16px 26px;
  }

  .welcome {
    width: 100%;
    font-size: clamp(38px, 13vw, 64px);
    letter-spacing: 2px;
  }

  /* 右栏列表：占满宽度，交给整页滚动 */
  .right-panel {
    width: 100%;
    height: auto;
    overflow: visible;
    padding: 4px 14px calc(40px + env(safe-area-inset-bottom));
  }

  .file-list { gap: 12px; }

  .card {
    min-height: 78px;
    padding: 10px;
    border-radius: 14px;
  }

  .card-cover { width: 104px; height: 58px; }

  .card-text {
    height: 58px;
    margin-left: 10px;
    gap: 3px;
  }

  .card-name   { font-size: 14px; }
  .card-author { font-size: 11px; padding-right: 66px; }
  .card-size   { font-size: 10px; right: 10px; bottom: 8px; }

  /* 触屏没有 hover，避免"卡住"的悬停态 */
  .card:hover { box-shadow: 0 1px 6px var(--card-shadow); }
  .detail-cover:hover { transform: none; box-shadow: 0 6px 24px var(--cover-shadow); }


  /* ---------- 详情：底部抽屉 ---------- */

  /* 外层铺满全屏，作为定位参照 */
  .detail {
    position: fixed;
    inset: 0;
    z-index: 200;
    align-items: flex-end;
    justify-content: center;
  }

  /* 抽屉滑入动画自己管，关掉桌面那套淡入 */
  .detail.detail-fade { animation: none; }

  .sheet-backdrop {
    display: block;
    position: absolute;
    inset: 0;
    background: var(--backdrop);
    animation: fadeIn 0.25s ease both;
  }

  .detail-sheet {
    position: relative;
    width: 100%;
    max-height: 84vh;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    gap: 18px;
    padding: 24px 20px calc(26px + env(safe-area-inset-bottom));
    background: var(--sheet-bg);
    border-radius: 22px 22px 0 0;
    box-shadow: 0 -10px 40px var(--sheet-shadow);
    overflow-y: auto;
    overscroll-behavior: contain;   /* 抽屉滚到底不再带动整页 */
    animation: sheetUp 0.32s cubic-bezier(0.22, 0.8, 0.24, 1) both;
  }

  /* 顶部小把手，暗示这是可关闭的抽屉 */
  .detail-sheet::before {
    content: "";
    position: absolute;
    top: 8px;
    left: 50%;
    width: 42px;
    height: 4px;
    border-radius: 999px;
    background: var(--sheet-handle);
    transform: translateX(-50%);
  }

  .sheet-close {
    display: flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    top: 10px;
    right: 10px;
    width: 32px;
    height: 32px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: var(--soft-bg);
    color: var(--soft-fg);
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    z-index: 2;
  }

  .sheet-close:active { background: var(--soft-bg-active); }

  /* 抽屉内部：文字在上，图片在下（纵向排列，各自按内容撑高，不要被压扁） */
  .detail-info {
    flex: 0 0 auto;
    gap: 8px;
    padding-top: 22px;   /* 让开顶部把手和关闭按钮 */
  }

  .detail-head { font-size: 15px; line-height: 1.6; }
  .detail-head .head-label { margin-right: 8px; }

  .download-btn {
    margin-top: 16px;
    align-self: stretch;   /* 按钮铺满，更好点 */
    padding: 13px 24px;
    font-size: 15px;
  }

  .detail-cover-wrap {
    flex: 0 0 auto;   /* 图片区按内容撑高，别被 flex 压扁 */
    gap: 8px;
  }

  .detail-cover {
    max-width: 100%;
    border-radius: 10px;
  }

  .cover-hint { font-size: 11px; }
}

/* 抽屉滑入动画 */
@keyframes sheetUp {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

/* ============================================================
   小屏微调（<= 380px）
   ============================================================ */
@media (max-width: 380px) {
  .nickname { font-size: 16px; }

  .card { min-height: 72px; }
  .card-cover { width: 88px; height: 50px; }
  .card-text  { height: 50px; }

  .welcome { font-size: clamp(32px, 12vw, 48px); }
}
