:root {
  --blue: #2469f6;
  --blue-dark: #1a55d6;
  --blue-light: #e8effd;
  --bg: #f0f4fb;
  --card: #ffffff;
  --text: #26334d;
  --muted: #8a97ab;
  --line: #e4ebf6;
  --danger: #e5484d;
  --radius: 14px;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body { height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  padding-bottom: env(safe-area-inset-bottom);
}

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: linear-gradient(180deg, var(--blue), var(--blue-dark));
  color: #fff;
  padding: 14px 16px calc(12px + 2px);
  padding-bottom: 14px;
  padding-top: calc(14px + env(safe-area-inset-top));
  border-radius: 0 0 18px 18px;
  box-shadow: 0 4px 14px rgba(36, 105, 246, .25);
}

.topbar-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 12px;
}

.topbar h1 { font-size: 19px; font-weight: 600; letter-spacing: 1px; }
.subtitle { font-size: 12px; opacity: .8; }

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, .95);
  border-radius: 10px;
  padding: 9px 12px;
  color: var(--muted);
}

.search-box input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-size: 15px;
  color: var(--text);
}

.clear-btn {
  border: none;
  background: var(--line);
  color: var(--muted);
  width: 20px; height: 20px;
  border-radius: 50%;
  font-size: 11px;
  line-height: 1;
  cursor: pointer;
}

/* ---------- 列表 ---------- */
.list { padding: 14px 14px 90px; display: flex; flex-direction: column; gap: 12px; }

.pane {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: 0 2px 8px rgba(38, 51, 77, .06);
  overflow: hidden;
}

.pane-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

.pane-date { font-size: 16px; font-weight: 600; color: var(--blue); }
.pane-count { font-size: 12px; color: var(--muted); }

.grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding: 10px;
}

.grid img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: 8px;
  display: block;
  background: var(--blue-light);
  cursor: pointer;
  transition: transform .12s ease;
}

.grid img:active { transform: scale(.96); }

.empty {
  text-align: center;
  color: var(--muted);
  padding: 80px 20px;
  font-size: 14px;
}
.empty-icon { font-size: 44px; margin-bottom: 10px; }

/* ---------- 上传按钮 ---------- */
.fab {
  position: fixed;
  right: 18px;
  bottom: calc(24px + env(safe-area-inset-bottom));
  width: 56px; height: 56px;
  border-radius: 50%;
  border: none;
  background: var(--blue);
  color: #fff;
  font-size: 28px;
  line-height: 1;
  box-shadow: 0 6px 18px rgba(36, 105, 246, .4);
  cursor: pointer;
  z-index: 20;
}
.fab:active { transform: scale(.94); }

/* ---------- 上传面板 ---------- */
.mask, .viewer { position: fixed; inset: 0; z-index: 30; }
.mask { background: rgba(15, 27, 51, .45); }

.sheet {
  position: fixed;
  left: 0; right: 0;
  bottom: 0;
  z-index: 40;
  background: #fff;
  border-radius: 18px 18px 0 0;
  padding: 16px 18px calc(20px + env(safe-area-inset-bottom));
  animation: slideUp .22s ease;
}

@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  font-size: 17px;
}

.icon-btn {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 16px;
  cursor: pointer;
  padding: 4px 6px;
}

.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }

.field input[type="date"] {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 15px;
  color: var(--text);
  background: #fff;
  outline: none;
}
.field input[type="date"]:focus { border-color: var(--blue); }

.file-pick {
  display: block;
  text-align: center;
  padding: 16px;
  border: 1.5px dashed var(--blue);
  border-radius: 10px;
  color: var(--blue);
  background: var(--blue-light);
  font-size: 15px;
  cursor: pointer;
}
.file-pick:active { background: #dbe6fb; }

.pick-info { margin-top: 8px; font-size: 12px; color: var(--muted); }

.progress {
  height: 6px;
  background: var(--line);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 6px;
}
.progress > div {
  height: 100%;
  width: 0;
  background: var(--blue);
  border-radius: 3px;
  transition: width .15s ease;
}
.prog-text { font-size: 12px; color: var(--muted); margin-bottom: 10px; text-align: center; }

.btn {
  width: 100%;
  padding: 13px;
  border: none;
  border-radius: 12px;
  background: var(--blue);
  color: #fff;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
}
.btn:active { background: var(--blue-dark); }
.btn:disabled { opacity: .55; }

.tip { margin-top: 10px; text-align: center; font-size: 12px; color: var(--muted); }

/* ---------- 全屏查看 ---------- */
.viewer {
  background: rgba(8, 14, 28, .94);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.viewer-top {
  position: absolute;
  top: 0; left: 0; right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(12px + env(safe-area-inset-top)) 16px 12px;
  color: #fff;
  font-size: 14px;
}

.viewer-actions { display: flex; gap: 6px; }

.viewer-btn {
  border: none;
  background: rgba(255, 255, 255, .14);
  color: #fff;
  font-size: 14px;
  padding: 7px 14px;
  border-radius: 18px;
  cursor: pointer;
}
.viewer-btn:active { background: rgba(255, 255, 255, .28); }

#vImg {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
}

.viewer-hint {
  position: absolute;
  bottom: calc(18px + env(safe-area-inset-bottom));
  color: rgba(255, 255, 255, .55);
  font-size: 12px;
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(100px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 60;
  background: rgba(30, 41, 66, .92);
  color: #fff;
  font-size: 14px;
  padding: 10px 18px;
  border-radius: 20px;
  max-width: 80vw;
  text-align: center;
  animation: fadeIn .18s ease;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

[hidden] { display: none !important; }
