/* 现场照片收集 —— 蓝白 + 浅橙，移动端优先 */

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

:root {
  --primary: #2f7df6;
  --primary-dark: #1e63d0;
  --primary-weak: #e8f1ff;
  --accent: #ff9f43;
  --accent-weak: #fff3e3;
  --bg1: #eaf3ff;
  --bg2: #fdf3e7;
  --card: #ffffff;
  --text: #2b3445;
  --muted: #8590a3;
  --border: #e4ebf5;
  --danger: #e5484d;
  --ok: #18a058;
  --radius: 16px;
  --shadow: 0 6px 24px rgba(47, 125, 246, 0.08);
}

html { font-size: 16px; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background: linear-gradient(180deg, var(--bg1), var(--bg2) 60%, #ffffff);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: contain;
}

/* 禁止双击缩放（手势由 JS 控制） */
body { touch-action: manipulation; }

.page { max-width: 640px; margin: 0 auto; padding: 0 16px 40px; }

/* ---------- 顶栏 ---------- */
header.top {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  padding: calc(env(safe-area-inset-top, 0px) + 10px) 16px 10px;
}
header.top .row {
  max-width: 640px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
}
header.top .title { font-size: 1.02rem; font-weight: 700; color: var(--primary-dark); }
header.top .spacer { flex: 1; }
header.top .who { font-size: 0.78rem; color: var(--muted); max-width: 40vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icon-btn {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--primary-dark);
  border-radius: 999px;
  padding: 6px 13px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}
.icon-btn.danger { color: var(--danger); border-color: #f7c9ca; }

/* ---------- 卡片 ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 16px;
  margin-bottom: 14px;
}

.notice {
  border-radius: 12px;
  padding: 11px 13px;
  font-size: 0.86rem;
  line-height: 1.65;
  margin-bottom: 14px;
  word-break: break-word;
}
.notice.warn { background: var(--accent-weak); border: 1px solid #ffd9a8; color: #92550a; }
.notice.error { background: #fdeaea; border: 1px solid #f7c9ca; color: #a3242a; }
.notice.info { background: var(--primary-weak); border: 1px solid #c9dcfb; color: var(--primary-dark); }
.notice code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.82em;
  background: rgba(0, 0, 0, 0.05);
  padding: 1px 5px;
  border-radius: 5px;
  word-break: break-all;
}
.notice a { color: inherit; text-decoration: underline; font-weight: 600; }
.fix-btn {
  display: inline-block;
  margin-top: 9px;
  padding: 8px 15px;
  border: 0;
  border-radius: 999px;
  background: var(--primary);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}
.fix-btn:active { background: var(--primary-dark); }
.notice a.fix-btn { color: #fff; text-decoration: none; }
.fix-btn.ghost { background: #fff; color: var(--primary-dark); border: 1px solid #c9dcfb; margin-left: 8px; }
.fix-btn.ghost:active { background: #eef4ff; }

/* ---------- 表单 ---------- */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 0.84rem; color: var(--muted); margin-bottom: 6px; }
.field input {
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 12px 13px;
  font-size: 1rem;
  background: #fafcff;
  color: var(--text);
}
.field input:focus { outline: none; border-color: var(--primary); background: #fff; }
.field .with-btn { display: flex; gap: 8px; }
.field .with-btn input { flex: 1; }
.field .with-btn button { flex-shrink: 0; }

.btn {
  border: 0;
  border-radius: 999px;
  background: var(--primary);
  color: #fff;
  font-size: 0.95rem;
  font-weight: 600;
  padding: 12px 18px;
  cursor: pointer;
}
.btn:active { background: var(--primary-dark); }
.btn.block { width: 100%; }
.btn[disabled] { opacity: 0.55; cursor: not-allowed; }
.btn.accent { background: var(--accent); }
.btn.accent:active { background: #f08c2a; }
.btn.ghost { background: #fff; color: var(--primary-dark); border: 1.5px solid #c9dcfb; }
.btn.danger-ghost { background: #fff; color: var(--danger); border: 1.5px solid #f7c9ca; }
.btn.small { padding: 7px 13px; font-size: 0.82rem; }

.tabbar { display: flex; background: var(--primary-weak); border-radius: 999px; padding: 4px; margin-bottom: 16px; }
.tabbar .tab {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 600;
  padding: 9px 0;
  border-radius: 999px;
  cursor: pointer;
}
.tabbar .tab.active { background: #fff; color: var(--primary-dark); box-shadow: 0 2px 8px rgba(47, 125, 246, 0.12); }

.msg { font-size: 0.84rem; margin-top: 10px; display: none; }
.msg.ok { color: var(--ok); display: block; }
.msg.err { color: var(--danger); display: block; }
.msg code { word-break: break-all; }

.sub-links { display: flex; justify-content: space-between; margin-top: 14px; font-size: 0.84rem; }
.sub-links a { color: var(--primary-dark); text-decoration: none; font-weight: 600; }

/* ---------- 上传区 ---------- */
.upload-card { text-align: center; }
.upload-btn {
  width: 100%;
  border: 2px dashed #b9d2fb;
  background: var(--primary-weak);
  color: var(--primary-dark);
  border-radius: 16px;
  padding: 26px 16px;
  font-size: 1.06rem;
  font-weight: 700;
  cursor: pointer;
}
.upload-btn:active { background: #dbe9ff; }
.upload-btn .plus { display: block; font-size: 2rem; line-height: 1.1; margin-bottom: 4px; color: var(--primary); }
.hint { font-size: 0.78rem; color: var(--muted); margin-top: 10px; line-height: 1.6; }

/* ---------- 工具条 ---------- */
.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 9px 11px;
  margin-bottom: 12px;
  font-size: 0.84rem;
}
.toolbar .grow { flex: 1; }
.toolbar label { display: flex; align-items: center; gap: 5px; color: var(--text); }
.toolbar input[type="checkbox"] { width: 17px; height: 17px; accent-color: var(--primary); }
.sel-count { color: var(--primary-dark); font-weight: 700; }

/* ---------- 照片网格 ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.item {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  background: #eef2f8;
  border: 1px solid var(--border);
  aspect-ratio: 1 / 1;
}
.item img.thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  background: #f2f5fa;
}
.item .check {
  position: absolute;
  left: 6px;
  top: 6px;
  z-index: 3;
  width: 20px;
  height: 20px;
  accent-color: var(--primary);
  cursor: pointer;
}
.item .ops {
  position: absolute;
  right: 5px;
  bottom: 5px;
  z-index: 3;
  display: flex;
  gap: 5px;
}
.item .ops button {
  border: 0;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: rgba(20, 30, 50, 0.55);
  color: #fff;
  font-size: 0.82rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.item .ops button:active { background: rgba(20, 30, 50, 0.8); }
.item .ops button.del { background: rgba(229, 72, 77, 0.75); }
.item.selected { outline: 2.5px solid var(--primary); outline-offset: -2.5px; }

/* 上传中的占位 */
.item.pending .mask {
  position: absolute;
  inset: 0;
  z-index: 2;
  background: rgba(240, 245, 252, 0.88);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font-size: 0.72rem;
  color: var(--primary-dark);
  text-align: center;
  padding: 6px;
}
.item.failed .mask { background: rgba(253, 234, 234, 0.92); color: var(--danger); }
.item .mask .bar { width: 72%; height: 5px; border-radius: 999px; background: #d8e4f8; overflow: hidden; }
.item .mask .bar i { display: block; height: 100%; width: 0%; border-radius: 999px; background: var(--primary); transition: width 0.25s; }
.item .mask .retry-btn {
  border: 0;
  background: var(--danger);
  color: #fff;
  font-size: 0.74rem;
  font-weight: 600;
  border-radius: 999px;
  padding: 6px 14px;
  cursor: pointer;
}
.spinner {
  width: 20px;
  height: 20px;
  border: 2.5px solid #c9dcfb;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty {
  text-align: center;
  color: var(--muted);
  padding: 48px 16px;
  font-size: 0.9rem;
}
.empty .big { font-size: 2.4rem; margin-bottom: 8px; }

/* ---------- 全屏预览 ---------- */
.viewer {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(8, 12, 22, 0.96);
  display: none;
}
.viewer.open { display: block; }
.viewer .stage {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.viewer img {
  max-width: 100%;
  max-height: 100%;
  user-select: none;
  -webkit-user-drag: none;
  transition: transform 0.18s ease-out;
  transform-origin: center center;
}
.viewer .bar {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + 10px);
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  color: #fff;
  z-index: 5;
}
.viewer .bar .cnt { font-size: 0.86rem; opacity: 0.85; }
.viewer .bar button {
  border: 0;
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 0.84rem;
  cursor: pointer;
}
.viewer .nav {
  position: absolute;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 18px);
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  gap: 14px;
  z-index: 5;
}
.viewer .nav button {
  border: 0;
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  border-radius: 999px;
  width: 46px;
  height: 46px;
  font-size: 1.2rem;
  cursor: pointer;
}

/* ---------- Toast ---------- */
.h5-toast {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 76px);
  transform: translateX(-50%) translateY(16px);
  background: rgba(23, 32, 52, 0.92);
  color: #fff;
  font-size: 0.88rem;
  padding: 10px 18px;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s;
  z-index: 200;
  max-width: 86vw;
  text-align: center;
}
.h5-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.h5-toast.ok { background: rgba(24, 160, 88, 0.95); }
.h5-toast.error { background: rgba(229, 72, 77, 0.95); }

/* 拖拽排序时的视觉 */
.sortable-ghost { opacity: 0.4; }
.sortable-chosen { box-shadow: 0 0 0 2px var(--accent); }

.footer-note { text-align: center; color: var(--muted); font-size: 0.76rem; margin-top: 22px; line-height: 1.7; }
