/* ========== 圆点日记 — Chrome 61 基线样式 ========== */
:root {
  --bg: #FAF7F2;
  --ink: #2B2622;
  --muted: #9A918A;
  --accent: #FF5A36;
  --accent-soft: #FFE9E3;
  --line: #EDE6DE;
  --card: #FFFFFF;
  --radius: 16px;
}

* { box-sizing: border-box; }
html { touch-action: manipulation; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
               "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
}
img { max-width: 100%; display: block; }

/* ---------- 布局骨架 ---------- */
.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: var(--app-height, 100vh);
  max-width: 560px;
  margin: 0 auto;
  background: var(--bg);
}

.app-header {
  padding: 16px 20px 10px;
  padding-top: calc(16px + var(--safe-area-inset-top, env(safe-area-inset-top, 0px)));
  flex: 0 0 auto;
}
.app-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 1px;
}
.app-title .dot { color: var(--accent); }
.app-sub {
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted);
}

.stats-bar {
  display: flex;
  align-items: center;
  padding: 10px 20px;
  flex: 0 0 auto;
}
.stats-num {
  font-size: 26px;
  font-weight: 700;
  color: var(--accent);
  margin-right: 6px;
}
.stats-label { font-size: 12px; color: var(--muted); }
.stats-progress {
  flex: 1;
  height: 6px;
  margin-left: 14px;
  background: var(--line);
  border-radius: 3px;
  overflow: hidden;
}
.stats-progress i {
  display: block;
  height: 100%;
  width: 0%;
  background: var(--accent);
  border-radius: 3px;
  transition: width 0.3s ease;
}

/* ---------- 分类筛选 ---------- */
.category-bar {
  display: flex;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding: 8px 20px 12px;
  flex: 0 0 auto;
}
.cat-chip {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 999px;
  padding: 7px 14px 7px 10px;
  font-size: 13px;
  color: var(--ink);
  margin-right: 8px;
  cursor: pointer;
}
.cat-chip .cat-badge {
  display: inline-block;
  min-width: 16px;
  text-align: center;
  font-size: 11px;
  color: var(--muted);
  margin-left: 4px;
}
.cat-chip.active {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}
.cat-chip.active .cat-badge { color: rgba(255,255,255,0.7); }

/* ---------- 图鉴网格 ---------- */
.gallery {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  padding: 4px 16px 16px;
  min-height: 0;
}
.grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-gap: 10px;
}
.cell {
  position: relative;
  border-radius: 14px;
  overflow: hidden;
  background: var(--card);
  border: 1px solid var(--line);
  /* aspect-ratio 基线回退：百分比 padding 比例盒 */
  height: 0;
  padding-top: 100%;
  cursor: pointer;
}
.cell:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.cell img {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  transform: scale(0.86);
}
.cell .cell-score {
  position: absolute;
  right: 4px;
  bottom: 4px;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(43,38,34,0.72);
  color: #fff;
}
.cell:active { opacity: 0.75; }

/* ---------- 空状态 ---------- */
.empty {
  text-align: center;
  padding: 48px 24px;
  color: var(--muted);
}
.empty .empty-ring {
  width: 72px;
  height: 72px;
  margin: 0 auto 14px;
  border: 3px dashed var(--line);
  border-radius: 50%;
}
.empty p { font-size: 13px; line-height: 1.8; }

/* ---------- 底部操作栏 ---------- */
.bottom-bar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  padding: 12px 20px 16px;
  padding-bottom: calc(16px + var(--safe-area-inset-bottom, env(safe-area-inset-bottom, 0px)));
  background: var(--bg);
  border-top: 1px solid var(--line);
}
.btn {
  border: none;
  border-radius: 999px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
.btn:active { opacity: 0.8; }
.btn-share {
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--ink);
  padding: 12px 18px;
  margin-right: 12px;
}
.btn-add {
  flex: 1;
  background: var(--accent);
  color: #fff;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.btn-add .plus {
  font-size: 20px;
  line-height: 1;
  margin-right: 6px;
}

/* ---------- 弹层 ---------- */
.sheet-mask {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(43,38,34,0.45);
  display: none;
  z-index: 20;
}
.sheet {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  max-width: 560px;
  margin: 0 auto;
  background: var(--card);
  border-radius: 20px 20px 0 0;
  padding: 20px 20px 24px;
  padding-bottom: calc(24px + var(--safe-area-inset-bottom, env(safe-area-inset-bottom, 0px)));
  transform: translateY(100%);
  transition: transform 0.25s ease;
  z-index: 21;
}
.sheet-mask.open { display: block; }
.sheet.open { transform: translateY(0); }

.sheet h3 {
  font-size: 17px;
  margin: 0 0 14px;
  text-align: center;
}
.sheet .preview-wrap {
  display: flex;
  align-items: center;
  margin-bottom: 16px;
}
.sheet .preview-img {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--accent-soft);
  flex: 0 0 auto;
}
.sheet .score-box { margin-left: 16px; min-width: 0; }
.sheet .score-num {
  font-size: 30px;
  font-weight: 700;
  color: var(--accent);
}
.sheet .score-tip { font-size: 12px; color: var(--muted); margin-top: 2px; }

.field-label {
  font-size: 13px;
  color: var(--muted);
  margin: 12px 0 6px;
}
.cat-select { display: flex; flex-wrap: wrap; }
.cat-select .cat-chip { margin: 0 8px 8px 0; }
.cat-select .cat-chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.note-input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  resize: none;
  background: var(--bg);
}
.note-input:focus { outline: none; border-color: var(--accent); }

.sheet-actions { display: flex; margin-top: 18px; }
.sheet-actions .btn { flex: 1; padding: 13px; }
.btn-ghost {
  background: var(--bg);
  color: var(--ink);
  margin-right: 12px;
}
.btn-primary { background: var(--accent); color: #fff; }

/* ---------- 分享预览弹层 ---------- */
.share-preview {
  width: 240px;
  margin: 0 auto 16px;
  border-radius: 14px;
  box-shadow: 0 8px 30px rgba(43,38,34,0.15);
}

/* ---------- 图鉴详情 ---------- */
.detail-sheet {
  max-height: calc(100vh - 28px);
  overflow-y: auto;
  padding-top: 16px;
}
.detail-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 14px;
}
.detail-head h3 { text-align: left; margin: 2px 0 0; font-size: 21px; }
.detail-kicker {
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 2px;
}
.detail-close {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: var(--bg);
  color: var(--ink);
  font-size: 24px;
  line-height: 32px;
  cursor: pointer;
}
.detail-img {
  width: 100%;
  height: auto;
  max-height: 42vh;
  margin: 0 auto;
  border-radius: 16px;
  object-fit: contain;
  background: var(--bg);
  border: 1px solid var(--line);
  box-shadow: 0 12px 32px rgba(43,38,34,0.12);
}
.detail-photo-label {
  margin: 0 0 7px;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 1px;
}
.detail-score-row {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 18px 0;
}
.detail-score {
  color: var(--accent);
  font-size: 38px;
  font-weight: 750;
  line-height: 1;
  margin-right: 12px;
}
.detail-score small { font-size: 15px; font-weight: 500; }
.detail-score-label { font-size: 12px; color: var(--muted); }
.detail-verdict { margin-top: 3px; font-size: 14px; font-weight: 600; }
.detail-list { margin: 0; padding: 0; border-top: 1px solid var(--line); }
.detail-list > div {
  display: flex;
  align-items: flex-start;
  padding: 13px 2px;
  border-bottom: 1px solid var(--line);
}
.detail-list dt {
  flex: 0 0 76px;
  color: var(--muted);
  font-size: 13px;
}
.detail-list dd {
  flex: 1;
  margin: 0;
  font-size: 14px;
  line-height: 1.5;
  text-align: right;
  overflow-wrap: anywhere;
}
.detail-list .detail-empty-note { color: var(--muted); }
.detail-actions { display: flex; margin-top: 18px; }
.detail-actions .btn { flex: 1; padding: 13px; }
.detail-delete {
  color: #c33b2a;
  background: #fff2ef;
  margin-left: 12px;
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 96px;
  -webkit-transform: translateX(-50%);
  transform: translateX(-50%);
  background: rgba(43,38,34,0.88);
  color: #fff;
  font-size: 13px;
  padding: 9px 16px;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 40;
  max-width: 80%;
  text-align: center;
}
.toast.show { opacity: 1; }

/* ---------- 隐藏文件输入 ---------- */
.file-input { display: none; }

/* ---------- 圆形取景相机 ---------- */
.camera-view {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: #000;
  z-index: 50;
}
.camera-video {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform-origin: center center;
  -webkit-transform-origin: center center;
  transition: transform 0.08s linear;
}

/* 四周变暗的 SVG 遮罩，中间圆形镂空（位置尺寸由 JS 注入，纯像素无 calc） */
.camera-mask {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  pointer-events: none;
}
/* 白色圆环描边 */
.camera-ring {
  position: absolute;
  border-radius: 50%;
  border: 3px solid #fff;
  pointer-events: none;
}
/* 圆环上下刻度线 */
.camera-ring .camera-tick {
  position: absolute;
  left: 50%;
  width: 3px;
  height: 16px;
  margin-left: -1px;
  background: #fff;
}
.camera-ring .camera-tick.top { top: -10px; }
.camera-ring .camera-tick.bottom { bottom: -10px; }

.camera-tip {
  position: absolute;
  left: 0; right: 0;
  top: 76%;
  text-align: center;
  color: #fff;
  font-size: 14px;
  text-shadow: 0 1px 4px rgba(0,0,0,0.6);
}
.camera-zoom {
  position: absolute;
  left: 50%;
  top: 69%;
  z-index: 2;
  display: flex;
  align-items: center;
  width: 76vw;
  max-width: 330px;
  padding: 6px 9px;
  border-radius: 999px;
  background: rgba(0,0,0,0.42);
  color: #fff;
  transform: translateX(-50%);
}
.camera-zoom button {
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 50%;
  background: rgba(255,255,255,0.18);
  color: #fff;
  font-size: 20px;
  line-height: 20px;
}
.camera-zoom input { flex: 1; min-width: 0; margin: 0 9px; accent-color: var(--accent); }
.camera-zoom span { width: 42px; font-size: 12px; text-align: right; }

.camera-err {
  position: absolute;
  left: 24px; right: 24px;
  top: 45%;
  text-align: center;
  color: #fff;
  font-size: 14px;
  line-height: 1.8;
  text-shadow: 0 1px 4px rgba(0,0,0,0.6);
}

/* 底部操作条 */
.camera-bar {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px 24px;
  padding-bottom: calc(24px + var(--safe-area-inset-bottom, env(safe-area-inset-bottom, 0px)));
}
.camera-shutter {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  border: 4px solid #fff;
  background: rgba(255,255,255,0.25);
  cursor: pointer;
  padding: 0;
}
.camera-shutter i {
  display: block;
  width: 52px;
  height: 52px;
  margin: 6px auto;
  border-radius: 50%;
  background: #fff;
}
.camera-shutter:active i { background: #FFE9E3; }
.camera-album,
.camera-close {
  background: rgba(255,255,255,0.16);
  border: none;
  color: #fff;
  font-size: 13px;
  padding: 10px 14px;
  border-radius: 999px;
  cursor: pointer;
  min-width: 64px;
}
.camera-album:active,
.camera-close:active { background: rgba(255,255,255,0.28); }

/* ---------- 兜底圆形裁剪页（系统相机/相册路径） ---------- */
.cropper-view {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: #000;
  z-index: 55;
  display: flex;
  flex-direction: column;
}
.cropper-stage {
  position: relative;
  flex: 1;
  overflow: hidden;
}
.cropper-img-wrap {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
}
.cropper-img-wrap img {
  position: absolute;
  max-width: none;
  max-height: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
/* 圆形蒙版（四边 dark crop + SVG 挖洞在裁剪页过重，直接用环 + 上下遮罩即可） */
.cropper-ring {
  position: absolute;
  left: 50%;
  top: 46%;
  width: 78vw;
  height: 78vw;
  -webkit-transform: translate(-50%, -50%);
  transform: translate(-50%, -50%);
  border-radius: 50%;
  border: 3px solid #fff;
  box-shadow: 0 0 0 2000px rgba(0,0,0,0.55);
  pointer-events: none;
}
.cropper-tip {
  position: absolute;
  left: 0; right: 0;
  top: 78%;
  text-align: center;
  color: #fff;
  font-size: 14px;
  text-shadow: 0 1px 4px rgba(0,0,0,0.6);
  pointer-events: none;
}
.cropper-bar {
  display: flex;
  align-items: center;
  padding: 14px 20px 20px;
  padding-bottom: calc(20px + var(--safe-area-inset-bottom, env(safe-area-inset-bottom, 0px)));
  background: #000;
}
.cropper-btn {
  flex: 1;
  padding: 13px;
  border-radius: 999px;
  border: none;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  background: rgba(255,255,255,0.16);
  color: #fff;
}
.cropper-btn:active { opacity: 0.8; }
.cropper-btn.primary {
  background: var(--accent);
  color: #fff;
  margin-left: 12px;
}

/* ---------- 悬停增强（仅指针设备） ---------- */
@media (hover: hover) {
  .cat-chip:hover, .btn:hover { opacity: 0.88; }
}

.cropper-stage { touch-action: none; min-height: 0; }
.cropper-canvas { position: absolute; inset: 0; top: 0; left: 0; width: 100%; height: 100%; }
.cropper-btn:disabled { opacity: .45; }

