:root {
  --bg: #faf7f5;
  --ink: #2b2523;
  --muted: #948883;
  --line: #ece4df;
  --card: #ffffff;
  --accent: #e0725c;
  --accent-soft: #fbece7;
  --shadow: 0 6px 24px rgba(70, 45, 35, .08);
  --radius: 16px;
}

* {
  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, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  overscroll-behavior-y: none;
}

.hidden { display: none !important; }

/* ---------------- 配置页 ---------------- */
.setup {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(1200px 600px at 50% -10%, #fdece7 0%, transparent 60%),
    var(--bg);
}

.setup-card {
  width: 100%;
  max-width: 420px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 32px 26px 26px;
  box-shadow: var(--shadow);
}

.kicker {
  margin: 0 0 6px;
  font-size: 11px;
  letter-spacing: .26em;
  color: var(--accent);
  font-weight: 600;
}

.setup-card h1 {
  margin: 0 0 8px;
  font-size: 26px;
  letter-spacing: .02em;
}

.sub {
  margin: 0 0 24px;
  color: var(--muted);
  font-size: 13.5px;
}

.field {
  display: block;
  margin-bottom: 16px;
}

.field span {
  display: block;
  font-size: 12.5px;
  color: var(--muted);
  margin-bottom: 6px;
  letter-spacing: .04em;
}

.field input {
  width: 100%;
  padding: 12px 14px;
  font-size: 14px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  outline: none;
  transition: border-color .18s, box-shadow .18s;
  font-family: inherit;
}

.field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.primary {
  width: 100%;
  padding: 13px 18px;
  font-size: 15px;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: 12px;
  cursor: pointer;
  font-family: inherit;
  transition: transform .12s, filter .18s;
}

.primary:active { transform: scale(.98); }
.primary:hover { filter: brightness(1.04); }

.msg {
  margin: 12px 0 0;
  font-size: 13px;
  color: var(--accent);
  min-height: 18px;
}

/* ---------------- 主界面 ---------------- */
.app {
  padding: 0 14px 40px;
  min-height: 100vh;
}

.bar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 2px 12px;
  background: rgba(250, 247, 245, .88);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.brand h2 {
  margin: 0;
  font-size: 18px;
  letter-spacing: .04em;
  font-weight: 650;
}

.count {
  font-size: 12px;
  color: var(--muted);
}

.actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.fab {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(224, 114, 92, .32);
  transition: transform .12s;
}

.fab:active { transform: scale(.92); }

.fab.busy {
  opacity: .6;
  pointer-events: none;
}

.ghost {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 13px;
  padding: 8px 4px;
  cursor: pointer;
  font-family: inherit;
}

/* ---------------- 月份筛选 ---------------- */
.months {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 2px 12px;
  scrollbar-width: none;
}

.months::-webkit-scrollbar { display: none; }

.chip {
  flex: 0 0 auto;
  padding: 7px 14px;
  font-size: 12.5px;
  color: var(--muted);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  font-family: inherit;
  transition: all .16s;
}

.chip.on {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
}

/* ---------------- 图片网格 ---------------- */
.grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 9px;
}

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

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

.tile {
  position: relative;
  aspect-ratio: 4 / 5;
  border-radius: var(--radius);
  overflow: hidden;
  background: #efe8e4;
  cursor: pointer;
  border: none;
  padding: 0;
  display: block;
  width: 100%;
  animation: fadeIn .32s ease both;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform .35s ease;
}

.tile:active img { transform: scale(1.03); }

.tile .stamp {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 16px 9px 7px;
  font-size: 11px;
  color: #fff;
  background: linear-gradient(to top, rgba(0, 0, 0, .42), transparent);
  letter-spacing: .03em;
  text-align: left;
}

.tile .badge {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 3px 7px;
  font-size: 10px;
  color: #fff;
  background: rgba(43, 37, 35, .55);
  border-radius: 999px;
  backdrop-filter: blur(4px);
}

.tile .caption {
  position: absolute;
  left: 9px;
  right: 9px;
  bottom: 26px;
  font-size: 11px;
  color: rgba(255, 255, 255, .92);
  text-shadow: 0 1px 6px rgba(0, 0, 0, .5);
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

/* ---------------- 空状态 / 页脚 ---------------- */
.empty {
  text-align: center;
  padding: 70px 20px;
  color: var(--muted);
}

.empty p { margin: 4px 0; }
.dim { font-size: 13px; opacity: .8; }

.foot {
  margin-top: 34px;
  text-align: center;
  font-size: 11.5px;
  color: var(--muted);
  opacity: .75;
  letter-spacing: .02em;
}

/* ---------------- 查看器 ---------------- */
.viewer {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: #14100e;
  display: flex;
  flex-direction: column;
  animation: fadeIn .2s ease both;
}

.viewer-top {
  padding: calc(env(safe-area-inset-top) + 12px) 16px 8px;
  display: flex;
  justify-content: flex-end;
}

.v-btn {
  background: rgba(255, 255, 255, .12);
  color: #fff;
  border: none;
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
  backdrop-filter: blur(8px);
}

.viewer-stage {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 10px;
  min-height: 0;
}

.v-loading {
  color: rgba(255, 255, 255, .55);
  font-size: 13px;
}

#v-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 6px;
}

.v-quark {
  text-align: center;
  color: rgba(255, 255, 255, .8);
  font-size: 13.5px;
  max-width: 300px;
}

.v-quark .primary { margin-top: 16px; }

.viewer-bottom {
  padding: 14px 20px calc(env(safe-area-inset-bottom) + 22px);
  color: #fff;
}

.v-meta {
  font-size: 12px;
  color: rgba(255, 255, 255, .55);
  letter-spacing: .04em;
}

.v-caption {
  font-size: 14px;
  margin-top: 6px;
  color: rgba(255, 255, 255, .92);
  line-height: 1.5;
}

/* ---------------- Toast ---------------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom) + 26px);
  transform: translate(-50%, 20px);
  background: rgba(43, 37, 35, .92);
  color: #fff;
  font-size: 13px;
  padding: 10px 18px;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s, transform .22s;
  z-index: 80;
  max-width: 80vw;
  text-align: center;
}

.toast.on {
  opacity: 1;
  transform: translate(-50%, 0);
}

.toast.err { background: rgba(178, 62, 44, .95); }
