/* 共享云端相册 · 暖色浅色主题（DESIGN.md Q24）
   配色：#b08968 棕金 + #faf7f2 米白
   零 CDN，纯原生 CSS */

:root {
  --accent: #b08968;
  --accent-dark: #8a6a4f;
  --accent-soft: #d9c3ad;
  --bg: #faf7f2;
  --surface: #ffffff;
  --surface-2: #f4ede4;
  --ink: #3d3630;
  --ink-2: #6b6157;
  --ink-3: #a1958a;
  --line: #e3d9cd;
  --line-2: #d3c5b4;
  --danger: #b4513f;
  --ok: #5f7d52;
  --warn: #b8892f;
  --radius: 12px;
  --radius-lg: 16px;
  --shadow: 0 1px 3px rgba(61, 54, 48, .06), 0 6px 20px rgba(61, 54, 48, .05);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
               "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent-dark); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }

/* ---------------- 布局 ---------------- */

.wrap { max-width: 1180px; margin: 0 auto; padding: 0 16px; }

.topbar {
  position: sticky; top: 0; z-index: 30;
  background: rgba(250, 247, 242, .92);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar-in {
  max-width: 1180px; margin: 0 auto; padding: 10px 16px;
  display: flex; align-items: center; gap: 12px; min-height: 56px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 500; font-size: 16px; color: var(--ink); }
.brand-dot {
  width: 26px; height: 26px; border-radius: 8px; flex: none;
  background: var(--accent); position: relative;
}
.brand-dot::after {
  content: ''; position: absolute; inset: 7px;
  border: 2px solid #faf7f2; border-radius: 2px;
}
.grow { flex: 1 1 auto; min-width: 0; }

.page { padding: 20px 0 calc(80px + var(--safe-b)); }

/* ---------------- 通用组件 ---------------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px; border-radius: 10px; border: 1px solid var(--line-2);
  background: var(--surface); color: var(--ink); cursor: pointer;
  font-size: 14px; font-weight: 500; transition: .15s; white-space: nowrap;
  text-decoration: none;
}
.btn:hover { border-color: var(--accent-soft); background: #fdfbf8; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { color: var(--danger); border-color: #e6cdc7; background: #fdf7f5; }
.btn-danger:hover { background: #fbeeea; border-color: #dcb3aa; }
.btn-sm { padding: 6px 11px; font-size: 13px; border-radius: 8px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn-icon { padding: 8px; width: 38px; height: 38px; }

.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-lg); padding: 18px; box-shadow: var(--shadow);
}
.card + .card { margin-top: 16px; }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: var(--ink-2); margin-bottom: 6px; font-weight: 500; }
.input, .select, .textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line-2);
  border-radius: 10px; background: var(--surface); outline: none; transition: .15s;
}
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px rgba(176, 137, 104, .12);
}

/* 密码框右侧工具区：清空（×）+ 可见性（眼睛） */
.input-wrap { position: relative; }
.input-wrap .input { padding-right: 76px; }
.input-tools {
  position: absolute; top: 50%; right: 8px; transform: translateY(-50%);
  display: flex; align-items: center; gap: 2px;
}
.pw-btn {
  border: 0; background: transparent; color: var(--ink-3);
  padding: 7px; border-radius: 8px; cursor: pointer; line-height: 0;
  display: flex; align-items: center; justify-content: center;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
.pw-btn:hover { background: var(--surface-2); color: var(--accent-dark); }
.pw-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.pw-btn.on { color: var(--accent-dark); }
/* 眼睛 / 睁眼闭眼两态切换 */
.pw-btn .ic-eye-off { display: none; }
.pw-btn.on .ic-eye { display: none; }
.pw-btn.on .ic-eye-off { display: block; }
/* × 只在有内容时出现，避免出现一个永远点不动的空按钮 */
.pw-btn#pwClear { visibility: hidden; width: 0; padding-left: 0; padding-right: 0; transition: .12s; }
.pw-btn#pwClear.show { visibility: visible; width: auto; padding-left: 7px; padding-right: 7px; }
.pw-sep { width: 1px; height: 16px; background: var(--line); visibility: hidden; }
.pw-btn#pwClear.show + .pw-sep { visibility: visible; }


.muted { color: var(--ink-2); font-size: 13px; }
.tiny { color: var(--ink-3); font-size: 12px; }
.center { text-align: center; }
.row { display: flex; align-items: center; gap: 10px; }
.row-wrap { flex-wrap: wrap; }
.spacer { height: 16px; }
.hide { display: none !important; }

.alert {
  padding: 11px 14px; border-radius: 10px; font-size: 13px;
  border: 1px solid var(--line-2); background: var(--surface-2); color: var(--ink-2);
}
.alert-danger { background: #fdf5f3; border-color: #e8cdc6; color: #8f3f30; }
.alert-warn { background: #fdf9ef; border-color: #e8dcc0; color: #8a6a1f; }
.alert-ok { background: #f5f8f3; border-color: #cfe0c8; color: #4c6741; }

.badge {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 500; background: var(--surface-2);
  color: var(--ink-2); border: 1px solid var(--line);
}
.badge-accent { background: #f7f0e8; color: var(--accent-dark); border-color: var(--accent-soft); }
.badge-ok { background: #f2f7ef; color: var(--ok); border-color: #cfe0c8; }
.badge-warn { background: #fdf9ef; color: var(--warn); border-color: #e8dcc0; }

.empty { padding: 56px 20px; text-align: center; color: var(--ink-3); }
.empty-title { font-size: 16px; color: var(--ink-2); margin-bottom: 6px; font-weight: 500; }

/* ---------------- 相册列表 ---------------- */

.album-grid {
  display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}
.album-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg);
  overflow: hidden; box-shadow: var(--shadow); transition: .18s; cursor: pointer; display: block;
  color: inherit;
}
.album-card:hover { border-color: var(--accent-soft); transform: translateY(-2px); }
.album-cover {
  aspect-ratio: 4 / 3; background: var(--surface-2); position: relative; overflow: hidden;
}
.album-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.album-cover-ph {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: var(--accent-soft);
}
.album-body { padding: 13px 15px 15px; }
.album-title { font-weight: 500; font-size: 15px; margin-bottom: 4px; word-break: break-word; }

/* ---------------- 照片网格 ---------------- */

.bar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 12px 0 14px;
}
.seg {
  display: inline-flex; background: var(--surface-2); border-radius: 10px;
  padding: 3px; border: 1px solid var(--line); gap: 2px;
}
.seg button {
  border: 0; background: transparent; padding: 6px 12px; border-radius: 8px;
  cursor: pointer; font-size: 13px; color: var(--ink-2); font-weight: 500;
}
.seg button.on { background: var(--surface); color: var(--accent-dark); box-shadow: var(--shadow); }

.day-group { margin-bottom: 26px; }
.day-head {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 8px 0 12px; position: sticky; top: 56px; z-index: 10;
  background: linear-gradient(var(--bg) 72%, rgba(250, 247, 242, 0));
}
.day-title { font-weight: 500; font-size: 15px; color: var(--ink); }
.day-title .dow { color: var(--ink-3); font-weight: 400; font-size: 13px; margin-left: 6px; }

.grid {
  display: grid; gap: 6px;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
}
@media (min-width: 700px) { .grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 8px; } }

.cell {
  position: relative; aspect-ratio: 1; background: var(--surface-2);
  border-radius: 10px; overflow: hidden; cursor: pointer; border: 1px solid transparent;
}
.cell img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cell.selected { border-color: var(--accent); }
.cell.selected::after {
  content: ''; position: absolute; inset: 0; background: rgba(176, 137, 104, .22);
}
/* ★ 勾选框常驻左上角（2026-09-23 回退）：点勾选框 = 选中/取消，点图片本体 = 打开详情。
   （长按进入多选的方案在真机上始终有「勾选框闪退」问题，已整体移除。） */
.cell-check {
  position: absolute; top: 5px; left: 5px; width: 30px; height: 30px; border-radius: 50%;
  border: 2px solid #fff; background: rgba(61, 54, 48, .35); z-index: 3;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
/* 不让长按图片弹出「存储图像 / 拷贝」系统菜单干扰勾选操作。 */
.cell img, .cell video {
  -webkit-touch-callout: none; -webkit-user-select: none; user-select: none;
}
.cell.selected .cell-check { background: var(--accent); border-color: #fff; }
.cell-check::after { content: ''; width: 10px; height: 6px; border: 2px solid #fff;
  border-top: 0; border-right: 0; transform: rotate(-45deg) translateY(-1px); opacity: 0; }
.cell.selected .cell-check::after { opacity: 1; }
.cell-tag {
  position: absolute; bottom: 6px; left: 6px; right: 6px; z-index: 2;
  display: flex; gap: 5px; align-items: center; justify-content: space-between;
  font-size: 11px; color: #fff; text-shadow: 0 1px 3px rgba(0, 0, 0, .6);
}
.cell-video::before {
  content: ''; position: absolute; inset: 0; z-index: 1;
  background: linear-gradient(to top, rgba(0, 0, 0, .32), transparent 42%);
}
.cell-play {
  position: absolute; inset: 0; margin: auto; width: 40px; height: 40px; z-index: 2;
  border-radius: 50%; background: rgba(255, 255, 255, .88);
  display: flex; align-items: center; justify-content: center;
}
.cell-play::after {
  content: ''; border-left: 12px solid var(--accent-dark);
  border-top: 8px solid transparent; border-bottom: 8px solid transparent; margin-left: 3px;
}

/* 骨架 */
.skel { background: linear-gradient(90deg, var(--surface-2) 25%, #efe6da 50%, var(--surface-2) 75%);
  background-size: 200% 100%; animation: sk 1.3s infinite; }
@keyframes sk { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ---------------- 底部操作条 ---------------- */

.actionbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  background: rgba(255, 255, 255, .96); backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
  padding: 10px 16px calc(10px + var(--safe-b));
}
.actionbar-in { max-width: 1180px; margin: 0 auto; display: flex; align-items: center; gap: 10px; }

.fab {
  position: fixed; right: 18px; bottom: calc(84px + var(--safe-b)); z-index: 41;
  width: 56px; height: 56px; border-radius: 18px; border: 0; cursor: pointer;
  background: var(--accent); color: #fff; box-shadow: 0 6px 22px rgba(176, 137, 104, .42);
  display: flex; align-items: center; justify-content: center;
}
.fab:active { transform: scale(.96); }

/* 左下角「我的历史」悬浮球。
   ★ 外观与「＋」**完全一致**（同尺寸、同配色、同圆角、同阴影）—— 用户明确要求。
   所以这里**只覆盖水平定位**，其余全部继承 .fab；垂直方向也不写，
   继承同一个 bottom，圆心自然对齐（曾因为单独设 bottom+高度而错位过）。
   ⚠️ 不要在这里重设 width/height/background/border/box-shadow ——
   那样两个球会再次出现视觉漂移，`test:ui` 的 [6e] 段有断言盯着这两点。 */
.fab-sub { right: auto; left: 18px; }

/* 「我下载过」角标：勾选中样式保持一致（不引入第二套视觉语言）。
   明确的查看方式是工具栏的「未下载」筛选，这里只做轻提示。 */
.cell-dl {
  position: absolute; top: 6px; right: 6px; z-index: 3;
  width: 20px; height: 20px; border-radius: 50%;
  background: rgba(61, 54, 48, .52);
  display: flex; align-items: center; justify-content: center;
  pointer-events: none;
}
.cell-dl::after {
  content: ''; width: 9px; height: 5px;
  border: 2px solid #fff; border-top: 0; border-right: 0;
  transform: rotate(-45deg) translate(-1px, -1px);
}

/* ---------------- 大图浏览 ---------------- */

.viewer {
  position: fixed; inset: 0; z-index: 100; background: #1f1b17;
  display: flex; flex-direction: column;
}
.viewer-top {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px;
  color: #f2ece5; padding-top: calc(10px + env(safe-area-inset-top, 0px));
}
.viewer-top .btn-ghost { color: #f2ece5; }
.viewer-top .btn-ghost:hover { background: rgba(255, 255, 255, .12); }
.viewer-stage {
  flex: 1 1 auto; display: flex; align-items: center; justify-content: center;
  overflow: hidden; position: relative; min-height: 0;
}
.viewer-stage img, .viewer-stage video {
  max-width: 100%; max-height: 100%; object-fit: contain; display: block;
}
.viewer-meta {
  padding: 12px 16px calc(14px + var(--safe-b)); color: #cfc4b8; font-size: 13px;
  border-top: 1px solid rgba(255, 255, 255, .1);
}
.viewer-nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 42px; height: 62px; border: 0; border-radius: 10px; cursor: pointer;
  background: rgba(250, 247, 242, .16); color: #fff; display: flex; align-items: center; justify-content: center;
}
.viewer-nav:hover { background: rgba(250, 247, 242, .28); }
.viewer-nav.prev { left: 12px; }
.viewer-nav.next { right: 12px; }
@media (max-width: 560px) { .viewer-nav { display: none; } }
.chev { width: 10px; height: 10px; border: 2px solid currentColor; border-bottom: 0; border-right: 0; }
.chev.l { transform: rotate(-45deg); }
.chev.r { transform: rotate(135deg); }

/* ---------------- 上传面板 ---------------- */

.upload-panel {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
  background: var(--surface); border-top: 1px solid var(--line);
  border-radius: 18px 18px 0 0; box-shadow: 0 -10px 40px rgba(61, 54, 48, .16);
  max-height: 68vh; display: flex; flex-direction: column;
}
.upload-head {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px; border-bottom: 1px solid var(--line);
}
/* 「＋ 添加」固定在头栏右侧，与「收起」同一行（不要 flex-wrap —— 折行会把
   添加按钮甩到第二行左侧，用户已反馈过） */
.upload-head > .btn:last-child { flex: none; margin-left: auto; }
.upload-list { overflow: auto; padding: 10px 16px 4px; min-height: 0; }
.upload-foot {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 16px 4px; border-top: 1px solid var(--line);
}
/* 收起状态：只留标题栏（带进度摘要），把屏幕还给相册 */
.upload-panel.folded { max-height: none; }
.upload-panel.folded .upload-list,
.upload-panel.folded .upload-foot,
.upload-panel.folded .up-hint { display: none; }
.upload-panel.folded .upload-head { border-bottom: 0; padding-bottom: 14px; }

/* ---------------- 轻量查看浮层（不导航，任务进行中用） ----------------
   详情页是独立页面，点缩略图整页跳转会把当前页卸载 —— 正在跑的分片
   上传/下载会被浏览器直接掐断。上传/下载进行中时改用这个浮层看图。
   深色底是为了看图（不跟随主题），但文字统一用浅色保证可读。 */
.viewer {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(18, 15, 13, .95);
  display: flex; flex-direction: column;
}
.viewer-bar {
  display: flex; align-items: center; gap: 8px; flex-wrap: nowrap;
  padding: calc(10px + env(safe-area-inset-top, 0px)) 12px 10px;
  color: #f2ecE4;
}
.viewer-name {
  font-size: 13px; color: #f2ece4; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.viewer-bar .btn { flex: none; }
.viewer-stage {
  flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center;
  padding: 4px 10px; gap: 10px;
}
.viewer-stage img,
.viewer-stage video { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 8px; }
.viewer-note {
  padding: 10px 16px calc(14px + env(safe-area-inset-bottom, 0px));
  font-size: 12px; line-height: 1.55; text-align: center; color: #e6d9c9;
}
/* 队列里的行内小按钮（重试/移除）不要撑高行 */
.up-item .btn-sm { padding: 5px 10px; font-size: 12px; flex: none; }
.up-item { display: flex; align-items: center; gap: 10px; padding: 8px 0; }
.up-name { flex: 1 1 auto; min-width: 0; }
.up-name div:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.up-bar { height: 4px; background: var(--surface-2); border-radius: 3px; overflow: hidden; margin-top: 5px; }
.up-bar i { display: block; height: 100%; background: var(--accent); width: 0; transition: width .25s; }
.up-state { font-size: 11px; color: var(--ink-3); flex: none; width: 62px; text-align: right; }

/* ---------------- 相册管理 ---------------- */

.member-row {
  display: flex; align-items: center; gap: 10px; padding: 9px 0;
  border-bottom: 1px solid var(--line);
}
.member-row:last-child { border-bottom: 0; }
.code-box {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 17px; letter-spacing: 2px; font-weight: 500;
  background: var(--surface-2); border: 1px dashed var(--line-2);
  border-radius: 10px; padding: 10px 14px; text-align: center; user-select: all;
}
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.stat {
  background: var(--surface-2); border-radius: 12px; padding: 12px 14px;
}
.stat .k { font-size: 12px; color: var(--ink-3); margin-bottom: 3px; }
.stat .v { font-size: 16px; font-weight: 500; color: var(--ink); }

.progress-line { height: 8px; background: var(--surface-2); border-radius: 5px; overflow: hidden; }
.progress-line i { display: block; height: 100%; background: var(--accent); }

@media (max-width: 560px) {
  .wrap { padding: 0 12px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 5px; }
  .card { padding: 15px; border-radius: 14px; }
  .day-head { top: 56px; }
}
