:root {
  --paper: #FFF7EE;
  --paper-2: #FFFDFA;
  --ink: #24190F;
  --muted: #8B7462;
  --line: #F0DFCB;
  --accent: #FF6A2B;
  --accent-2: #FFB300;
  --gold: #F5A623;
  --good: #1F9D63;
  --bad: #D4553F;
  --radius: 20px;
  --shadow: 0 8px 24px rgba(126, 84, 32, 0.1);
  --tab-h: 56px;
}

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

html, body {
  margin: 0;
  padding: 0;
  overflow-x: hidden;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  overscroll-behavior-y: none;
}

body {
  min-height: 100vh;
  background-image:
    radial-gradient(120% 60% at 12% -8%, rgba(255, 179, 0, 0.16), transparent 60%),
    radial-gradient(90% 50% at 100% 0%, rgba(255, 106, 43, 0.12), transparent 55%);
  background-attachment: fixed;
}

img { max-width: 100%; display: block; }
img, video { image-orientation: from-image; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
input { font: inherit; }
.hidden { display: none !important; }

.wrap {
  max-width: 520px;
  margin: 0 auto;
  padding: 0 16px calc(var(--tab-h) + 26px + env(safe-area-inset-bottom));
}

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  margin: 0 0 14px;
  background: rgba(255, 247, 238, 0.92);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar .brand { font-weight: 800; letter-spacing: .5px; font-size: 17px; }
.topbar .date { color: var(--muted); font-size: 12px; }
.topbar .spacer { flex: 1; }
.dots { display: flex; gap: 5px; }
.dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: #E7D6C3;
}
.dot.on { background: linear-gradient(140deg, var(--accent), var(--accent-2)); }
.icon-btn {
  width: 34px; height: 34px; border-radius: 12px;
  display: grid; place-items: center;
  color: var(--muted);
  border: 1px solid var(--line);
  background: var(--paper-2);
}
.icon-btn:active { transform: scale(.94); }

/* ---------- 通用卡片 ---------- */
.card {
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 14px;
}
.card.pad0 { padding: 0; overflow: hidden; }
.title {
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: .6px;
  margin: 2px 0 12px;
}
.hint { color: var(--muted); font-size: 12.5px; }

/* ---------- 登录 ---------- */
#login {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 32px 22px calc(32px + env(safe-area-inset-bottom));
  max-width: 520px;
  margin: 0 auto;
}
.login-hero { margin-bottom: 26px; }
.login-hero .mark {
  width: 60px; height: 60px; border-radius: 22px;
  background: linear-gradient(140deg, var(--accent), var(--accent-2));
  display: grid; place-items: center;
  box-shadow: 0 12px 26px rgba(255, 106, 43, .28);
  margin-bottom: 16px;
}
.login-hero h1 { margin: 0 0 6px; font-size: 27px; letter-spacing: -.5px; }
.login-hero p { margin: 0; color: var(--muted); font-size: 14px; }
.nick-grid { display: flex; flex-wrap: wrap; gap: 9px; margin-bottom: 18px; }
.nick-chip {
  padding: 11px 15px;
  border-radius: 14px;
  border: 1.5px solid var(--line);
  background: var(--paper-2);
  font-weight: 600;
  transition: .16s;
}
.nick-chip.sel {
  border-color: transparent;
  background: linear-gradient(140deg, var(--accent), var(--accent-2));
  color: #fff;
  box-shadow: 0 8px 18px rgba(255, 106, 43, .26);
}
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 7px; font-weight: 600; }
.field input {
  width: 100%;
  padding: 14px 15px;
  border-radius: 14px;
  border: 1.5px solid var(--line);
  background: var(--paper-2);
  color: var(--ink);
  outline: none;
}
.field input:focus { border-color: var(--accent); }
.btn {
  width: 100%;
  padding: 15px;
  border-radius: 16px;
  background: linear-gradient(140deg, var(--accent), var(--accent-2));
  color: #fff;
  font-weight: 800;
  letter-spacing: .5px;
  box-shadow: 0 10px 22px rgba(255, 106, 43, .26);
}
.btn:active { transform: scale(.985); }
.btn[disabled] { opacity: .5; box-shadow: none; }
.btn.ghost {
  background: var(--paper-2);
  color: var(--ink);
  border: 1.5px solid var(--line);
  box-shadow: none;
  font-weight: 700;
}
.shake { animation: shake .36s; }
@keyframes shake { 0%,100%{transform:translateX(0)} 25%{transform:translateX(-7px)} 75%{transform:translateX(7px)} }

/* ---------- 主按钮（今日未打卡） ---------- */
.hero-empty { text-align: center; padding: 26px 18px 24px; }
.hero-empty .big { font-size: 21px; font-weight: 800; margin-bottom: 4px; }
.hero-empty .sub { color: var(--muted); font-size: 13px; margin-bottom: 20px; }
.shutter-wrap { position: relative; display: inline-block; }
.shutter {
  width: 132px; height: 132px; border-radius: 50%;
  background: linear-gradient(150deg, var(--accent), var(--accent-2));
  /* 用 flex 而不是 grid：grid 的两行会被拉伸，图标和文字会被拆到圆钮上下两半 */
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 5px;
  color: #fff;
  box-shadow: 0 16px 34px rgba(255, 106, 43, .34);
}
.shutter span { font-size: 15px; font-weight: 800; letter-spacing: .5px; }
.shutter-ring {
  position: absolute; inset: -9px;
  border-radius: 50%;
  border: 2px dashed rgba(255, 106, 43, .35);
  animation: spin 18s linear infinite;
  /* 装饰层不能挡住手指，否则点快门没反应 */
  pointer-events: none;
}
@keyframes spin { to { transform: rotate(360deg); } }
.alt-line { margin-top: 18px; font-size: 12.5px; color: var(--muted); }
.link { color: var(--accent); font-weight: 700; text-decoration: underline; }

/* ---------- 今日成果卡 ---------- */
.result { padding: 0; overflow: hidden; }
.result .photo-box { position: relative; aspect-ratio: 1 / 1; background: #EFE6DC; }
.result .photo-box img { width: 100%; height: 100%; object-fit: cover; }
.result .stamp {
  position: absolute; right: 12px; top: 12px;
  background: rgba(36, 25, 15, .62);
  color: #fff; font-size: 11.5px; padding: 5px 9px; border-radius: 10px;
  backdrop-filter: blur(4px);
}
.result .body { padding: 16px; display: flex; gap: 14px; align-items: center; }
.ring { position: relative; width: 88px; height: 88px; flex: none; }
.ring svg { transform: rotate(-90deg); }
.ring .num {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  font-size: 26px; font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.ring .num span { line-height: 1; }
.ring .num small { font-size: 10px; font-weight: 600; color: var(--muted); margin-left: 1px; }
.result .meta { min-width: 0; flex: 1; }
.result .lvl {
  display: inline-block;
  font-size: 12px; font-weight: 800;
  color: #fff;
  background: linear-gradient(140deg, var(--accent), var(--accent-2));
  padding: 3px 9px; border-radius: 9px;
  margin-bottom: 7px;
}
.result .cmt { font-size: 14.5px; line-height: 1.45; margin-bottom: 7px; }
.result .tags { display: flex; gap: 6px; flex-wrap: wrap; }
.tag {
  font-size: 11.5px; color: var(--muted);
  border: 1px solid var(--line); border-radius: 8px; padding: 2px 7px;
}
.foot-line {
  display: flex; align-items: center; gap: 7px;
  padding: 11px 16px;
  border-top: 1px solid var(--line);
  font-size: 12.5px; color: var(--muted);
  flex-wrap: wrap;
}
.foot-line a { color: var(--accent); text-decoration: none; font-weight: 700; }
.pending-art {
  aspect-ratio: 1/1; position: relative; overflow: hidden; background: #EFE6DC;
}
.pending-art img { width: 100%; height: 100%; object-fit: cover; filter: saturate(.7); }
.pending-art::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(100deg, transparent 20%, rgba(255,255,255,.55) 45%, transparent 70%);
  transform: translateX(-100%);
  animation: sweep 1.6s infinite;
}
@keyframes sweep { to { transform: translateX(100%); } }
.pending-text { padding: 16px; text-align: center; }

/* ---------- 打卡墙 ---------- */
.wall { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; }
.wall-item {
  border-radius: 14px; overflow: hidden; background: var(--paper-2);
  border: 1px solid var(--line); position: relative; aspect-ratio: 3/4;
}
.wall-item .crop { position: absolute; inset: 0; }
.wall-item .who {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 14px 6px 5px;
  background: linear-gradient(transparent, rgba(20, 12, 6, .78));
  color: #fff; font-size: 11px; font-weight: 700;
  display: grid; grid-template-columns: 1fr auto; align-items: end; gap: 0 6px;
}
.wall-item .who b { font-size: 13px; }
/* AI 评语跟着一起共享 */
.wall-item .who .cmt {
  grid-column: 1 / -1; margin: 3px 0 0;
  font-size: 10.5px; font-weight: 500; line-height: 1.3;
  color: rgba(255, 255, 255, .88);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.wall-item.empty {
  display: grid; place-items: center;
  background: repeating-linear-gradient(135deg, #FBF2E6, #FBF2E6 8px, #F6EADA 8px, #F6EADA 16px);
  color: var(--muted); font-size: 11.5px; text-align: center; padding: 6px;
}

/* ---------- 排行 ---------- */
.seg {
  display: flex; padding: 4px; gap: 4px;
  background: #F6E9D9; border-radius: 14px; margin-bottom: 12px;
}
.seg button {
  flex: 1; padding: 9px 0; border-radius: 11px;
  font-weight: 700; font-size: 14px; color: var(--muted);
}
.seg button.on { background: var(--paper-2); color: var(--ink); box-shadow: 0 2px 8px rgba(126,84,32,.12); }
.rank-row {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 0; border-bottom: 1px dashed var(--line);
}
.rank-row:last-child { border-bottom: 0; }
.rank-no {
  width: 26px; text-align: center; font-weight: 800; font-size: 15px; color: var(--muted);
  font-variant-numeric: tabular-nums; flex: none;
}
.rank-row.top1 .rank-no, .rank-row.top2 .rank-no, .rank-row.top3 .rank-no {
  width: 26px; height: 26px; border-radius: 9px; color: #fff; font-size: 13px;
  display: grid; place-items: center;
}
.rank-row.top1 .rank-no { background: linear-gradient(140deg, #FFB300, #FF8A00); }
.rank-row.top2 .rank-no { background: linear-gradient(140deg, #BFC6CE, #8E99A6); }
.rank-row.top3 .rank-no { background: linear-gradient(140deg, #D89A6C, #A8683C); }
.avatar { width: 44px; height: 44px; border-radius: 50%; flex: none; background: #EFE6DC; }
.avatar.none { display: grid; place-items: center; color: var(--muted); font-size: 11px; }
.rank-info { flex: 1; min-width: 0; }
.rank-info .nick { font-weight: 700; font-size: 15px; margin-bottom: 3px; }
.bar { height: 5px; border-radius: 4px; background: #F3E7D8; overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 4px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); }
.rank-sub { font-size: 11.5px; color: var(--muted); margin-top: 3px; }
.rank-score { text-align: right; flex: none; }
.rank-score b { font-size: 21px; font-weight: 800; font-variant-numeric: tabular-nums; display: block; line-height: 1.1; }
.rank-score i { font-style: normal; font-size: 11px; color: var(--muted); }
.me-flag {
  font-size: 10.5px; color: var(--accent); border: 1px solid rgba(255,106,43,.35);
  border-radius: 6px; padding: 0 5px; margin-left: 5px; vertical-align: 1px;
}

/* ---------- 历史流 ---------- */
.feed { display: flex; flex-direction: column; gap: 10px; }
.feed-item {
  display: flex; gap: 11px; align-items: center;
  padding: 9px; border-radius: 15px; background: var(--paper-2); border: 1px solid var(--line);
}
.feed-item .mini { width: 54px; height: 54px; border-radius: 13px; flex: none; }
.feed-item .txt { flex: 1; min-width: 0; }
.feed-item .l1 { font-size: 13.5px; font-weight: 700; margin-bottom: 2px; }
.feed-item .l2 { font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feed-item .sc { font-size: 19px; font-weight: 800; flex: none; font-variant-numeric: tabular-nums; }

/* ---------- 1:1 取景格：AI 框出的头部正方形 ---------- */
.crop { position: relative; display: block; overflow: hidden; background: #F1E7DA; }
.crop img { position: absolute; left: 0; top: 0; height: auto; max-width: none; }
.crop.none { display: grid; place-items: center; color: var(--muted); font-size: 11px; background: #EFE6DC; }

/* ---------- 我的 / 笑历 ---------- */
.cal-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.cal-nav { display: flex; gap: 6px; }
.cal-nav button {
  width: 30px; height: 30px; border-radius: 10px; background: #FBF3EA;
  font-size: 18px; font-weight: 700; line-height: 1; color: var(--ink);
}
.cal-nav button.off { color: #D8CABB; }
/* 翻谁的笑历：五个名字一排 */
.cal-who { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 11px; }
.who-chip {
  padding: 6px 12px; border-radius: 11px; background: #FBF3EA; border: 1px solid var(--line);
  font-size: 13px; font-weight: 700; color: var(--muted);
}
.who-chip.on { background: linear-gradient(140deg, var(--accent), var(--accent-2)); color: #fff; border-color: transparent; }
.who-chip i { font-style: normal; font-size: 9.5px; margin-left: 4px; opacity: .72; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.cal-cell {
  position: relative; aspect-ratio: 1/1; border-radius: 10px; overflow: hidden;
  background: #FAF2E8; border: 1px dashed #EADCCB;
}
.cal-cell.blank { background: transparent; border: 0; }
.cal-cell .crop { position: absolute; inset: 0; border-radius: 0; background: #F1E7DA; }
.cal-cell em {
  position: absolute; left: 4px; top: 1px; z-index: 2;
  font-style: normal; font-size: 9.5px; font-weight: 700; color: var(--muted);
}
.cal-cell b {
  position: absolute; right: 3px; bottom: 1px; z-index: 2;
  font-size: 11px; font-weight: 800; color: #fff; font-variant-numeric: tabular-nums;
}
.cal-cell.has { border: 0; }
.cal-cell.has em { color: #fff; text-shadow: 0 1px 3px rgba(0, 0, 0, .6); }
.cal-cell.has b { text-shadow: 0 1px 3px rgba(0, 0, 0, .65); }
.cal-cell b.wait { color: var(--muted); text-shadow: 0 1px 2px rgba(255, 255, 255, .8); }
.cal-cell.today { outline: 2px solid var(--accent); outline-offset: 1px; }
.cal-head { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; margin-bottom: 6px; }
.cal-head span { text-align: center; font-size: 10.5px; color: var(--muted); }

/* ---------- 拍照面板 ---------- */
.sheet {
  position: fixed; top: 0; left: 0; right: 0; z-index: 60;
  height: 100vh;
  background: #16100B;
  display: flex; flex-direction: column;
  color: #fff;
}
.sheet .sheet-top {
  display: flex; align-items: center; gap: 10px;
  padding: calc(12px + env(safe-area-inset-top)) 16px 8px;
}
.sheet .sheet-top .t { font-weight: 700; font-size: 15px; flex: 1; }
.sheet .sheet-top button { color: rgba(255,255,255,.75); font-size: 14px; }
.cam-stage { flex: 1; position: relative; display: grid; place-items: center; overflow: hidden; }
.cam-stage video, .cam-stage img.preview {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
}
.cam-stage video { transform: scaleX(var(--mirror, -1)); }
.guide {
  position: relative; width: min(62vw, 250px); aspect-ratio: 3/4;
  border-radius: 46% / 34%;
  border: 2.5px dashed rgba(255,255,255,.75);
  display: grid; place-items: center;
  text-align: center; padding: 10px;
  font-size: 12.5px; color: rgba(255,255,255,.85);
  text-shadow: 0 1px 6px rgba(0,0,0,.5);
  pointer-events: none;
}
.cam-note {
  padding: 10px 16px; font-size: 12px; color: rgba(255,255,255,.66);
  display: flex; align-items: center; gap: 8px; min-height: 40px;
}
.cam-foot {
  display: flex; align-items: center; justify-content: space-around; gap: 12px;
  padding: 8px 20px calc(24px + env(safe-area-inset-bottom));
}
.big-shutter {
  width: 72px; height: 72px; border-radius: 50%;
  background: #fff; border: 4px solid rgba(255,255,255,.35);
  box-shadow: 0 0 0 3px rgba(255,255,255,.2);
}
.big-shutter:active { transform: scale(.93); }
.foot-act { font-size: 13px; color: rgba(255,255,255,.82); padding: 10px 6px; min-width: 62px; text-align: center; }
.foot-act.primary { color: #FFC24B; font-weight: 800; }
.cam-alt {
  margin: 0 16px calc(8px + env(safe-area-inset-bottom));
  padding: 11px 13px; border-radius: 14px;
  background: rgba(255,255,255,.1);
  font-size: 12.5px; color: rgba(255,255,255,.8);
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.spinner {
  width: 15px; height: 15px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,.28); border-top-color: #fff;
  animation: spin .7s linear infinite; flex: none;
}

/* ---------- 底栏 ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  display: flex;
  height: calc(var(--tab-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: rgba(255, 252, 247, .94);
  backdrop-filter: blur(12px);
  will-change: transform;
  border-top: 1px solid var(--line);
}
.tabbar button {
  flex: 1; display: grid; place-content: center; gap: 2px;
  color: #B0A091; font-size: 11px; font-weight: 700;
}
.tabbar button.on { color: var(--accent); }
.tabbar .badge {
  position: absolute; transform: translate(14px, -6px);
  min-width: 15px; height: 15px; border-radius: 8px;
  background: var(--accent); color: #fff; font-size: 9.5px; line-height: 15px; padding: 0 4px;
}

/* ---------- Toast ---------- */
#toast {
  position: fixed; left: 50%; bottom: calc(var(--tab-h) + 26px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(14px);
  z-index: 80;
  max-width: 84vw;
  padding: 11px 16px; border-radius: 14px;
  background: rgba(36, 25, 15, .93); color: #fff; font-size: 13.5px;
  opacity: 0; pointer-events: none; transition: .22s;
  text-align: center;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.err { background: rgba(180, 62, 40, .95); }

/* ---------- 弹层：查看大图 ---------- */
#lightbox {
  position: fixed; inset: 0; z-index: 70;
  background: rgba(16, 10, 6, .92);
  display: grid; place-items: center; padding: 24px;
}
#lightbox img { max-height: 76vh; border-radius: 16px; }
#lightbox .cap { color: rgba(255,255,255,.82); font-size: 13px; text-align: center; margin-top: 12px; }

/* dvh 会跟着浏览器工具条收放，iOS/Android 上都能保住快门 */
@supports (height: 100dvh) {
  .sheet { height: 100dvh; }
}

@media (min-width: 560px) {
  .wall { grid-template-columns: repeat(5, 1fr); }
}
