:root {
  --page: #f7f5f0;
  --surface: #fff;
  --text: #2e2c28;
  --dim: #a09a90;
  --faint: #c8c3ba;
  --line: #ebe7e0;
  --line-light: #f2efea;
  --mine: #c26b5a;
  --mine-soft: rgba(194,107,90,.08);
  --partner: #5a8f6e;
  --partner-soft: rgba(90,143,110,.08);
  --r: 12px;
  --r-sm: 8px;
  --shadow: 0 1px 2px rgba(0,0,0,.04);
  --font: -apple-system,BlinkMacSystemFont,'Segoe UI','PingFang SC','Microsoft YaHei',sans-serif;
}
[data-theme="dark"] {
  --page: #131211;
  --surface: #1c1b19;
  --text: #e2ded6;
  --dim: #706b63;
  --faint: #4a4640;
  --line: #28261f;
  --line-light: #201e1a;
  --mine: #d48b7c;
  --mine-soft: rgba(212,139,124,.12);
  --partner: #7db88e;
  --partner-soft: rgba(125,184,142,.12);
  --shadow: 0 1px 3px rgba(0,0,0,.15);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0 }
html { scroll-behavior: smooth; overscroll-behavior-x: none; -webkit-tap-highlight-color: transparent }

body { font-family: var(--font); background: var(--page); color: var(--text); line-height: 1.5;
  min-height: 100svh; -webkit-font-smoothing: antialiased; transition: background .3s, color .3s }

a { color: inherit; text-decoration: none }
button { font: inherit; cursor: pointer }
::-webkit-scrollbar { width: 3px }
::-webkit-scrollbar-thumb { background: rgba(128,128,128,.12); border-radius: 2px }

/* ── 导航栏 ── */
.topbar { position: sticky; top: 0; z-index: 90;
  background: color-mix(in srgb, var(--page) 80%, transparent);
  backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid color-mix(in srgb, var(--line) 50%, transparent) }
.topbar-inner { max-width: 540px; margin: 0 auto; padding: 0 16px; height: 48px;
  display: flex; align-items: center; justify-content: space-between }

.topbar-title { font-size: 15px; font-weight: 700; letter-spacing: -.02em }
.topbar-right { display: flex; align-items: center; gap: 6px }
.topbar-couple { font-size: 12px; color: var(--faint) }
.topbar-amp { color: var(--mine) }

.icon-btn { background: none; border: none; color: var(--dim); width: 34px; height: 34px;
  border-radius: 50%; display: flex; align-items: center; justify-content: center; transition: all .2s }
.icon-btn:hover { background: var(--line-light); color: var(--text) }
.icon-btn:active { transform: scale(.9) }
.icon-btn .lucide { width: 17px; height: 17px }

/* ── 主容器 ── */
.main { max-width: 540px; margin: 0 auto; padding: 16px 16px calc(20px + env(safe-area-inset-bottom)) }

/* ── 编辑器 ── */
.compose { background: var(--surface); border-radius: var(--r); border: 1px solid var(--line);
  padding: 16px; margin-bottom: 16px; box-shadow: var(--shadow); transition: box-shadow .25s }
.compose:focus-within { box-shadow: var(--shadow), 0 0 0 2px var(--mine-soft) }
.compose-top { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 10px;
  flex-wrap: wrap; gap: 6px }
.compose-date { font-size: 11px; color: var(--faint); font-weight: 500; padding-top: 4px }
.compose-input { display: block; width: 100%; border: none; outline: none; resize: none;
  font: inherit; font-size: 15px; color: var(--text); line-height: 1.7; background: transparent;
  min-height: 44px; max-height: 200px; overflow-y: auto }
.compose-input::placeholder { color: var(--faint) }
.compose-input::-webkit-scrollbar { width: 0 }

.compose-top { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px }
.mood-head { display: flex; align-items: center; gap: 8px }
.mood-grid { display: flex; flex-wrap: wrap; gap: 2px }
.mood-radio { display: none }
.mood-label { width: 28px; height: 28px; border-radius: var(--r-sm); display: flex; align-items: center;
  justify-content: center; color: var(--faint); cursor: pointer; transition: all .15s }
.mood-label:hover { color: var(--dim); background: var(--line-light) }
.mood-radio:checked + .mood-label { color: var(--mine); background: var(--mine-soft) }
.mood-label .lucide { width: 15px; height: 15px }

.weather-grid { display: flex; flex-wrap: wrap; gap: 2px }

.select-hint { font-size: 10px; color: var(--mine); font-weight: 500;
  min-height: 14px; transition: opacity .15s; letter-spacing: .02em }
.select-hint:empty { opacity: 0 }

.comfort-float { position: fixed; top: 56px; left: 50%; transform: translateX(-50%) translateY(-8px);
  z-index: 500; max-width: 380px; width: calc(100% - 32px); padding: 12px 16px;
  background: var(--surface); border: 1px solid var(--mine-soft); border-radius: var(--r);
  box-shadow: 0 8px 24px rgba(0,0,0,.08); display: flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--mine); line-height: 1.5;
  opacity: 0; pointer-events: none; transition: opacity .3s, transform .3s }
.comfort-float.show { opacity: 1; pointer-events: auto; transform: translateX(-50%) translateY(0) }
.comfort-float .lucide { width: 16px; height: 16px; flex-shrink: 0; opacity: .5 }
.comfort-float span { flex: 1 }
[data-theme="dark"] .comfort-float { box-shadow: 0 8px 24px rgba(0,0,0,.25) }

.weather-row { display: none; flex-direction: column; gap: 6px; margin-bottom: 10px;
  padding: 10px 12px; background: var(--line-light); border-radius: var(--r-sm) }
.weather-row.show { display: flex }
.weather-head { display: flex; align-items: center; gap: 6px }
.weather-lbl { font-size: 11px; color: var(--faint); white-space: nowrap }
.weather-btn { width: 28px; height: 28px; border-radius: 6px; border: none; background: none;
  display: flex; align-items: center; justify-content: center; color: var(--faint); transition: all .15s }
.weather-btn .lucide { width: 15px; height: 15px }
.weather-btn:hover { color: var(--dim); background: var(--surface) }
.weather-btn.on { color: var(--mine); background: var(--mine-soft) }

.toolbar { display: flex; align-items: center; gap: 2px; margin-top: 10px; padding-top: 10px;
  border-top: 1px solid var(--line-light) }
.tool-btn { background: none; border: none; color: var(--faint); padding: 6px; border-radius: var(--r-sm);
  display: flex; align-items: center; transition: all .15s }
.tool-btn .lucide { width: 18px; height: 18px }
.tool-btn:hover { color: var(--mine); background: var(--mine-soft) }
.tool-btn.on { color: var(--mine) }
.char-count { font-size: 11px; color: var(--faint); margin-left: auto; margin-right: 8px; tabular-nums: true }
.char-count.warn { color: #d4a052 }
.char-count.over { color: #c25050 }

.submit-btn { border: none; background: var(--mine); color: #fff; font-size: 12px;
  font-weight: 600; padding: 7px 20px; border-radius: var(--r-sm); transition: all .15s }
.submit-btn:hover { opacity: .9 }
.submit-btn:active { transform: scale(.97) }
.submit-btn:disabled { opacity: .35; cursor: default; transform: none }

/* ── 温馨提示栏 ── */
.whisper-bar { margin-bottom: 16px; display: none; flex-direction: column; gap: 8px;
  padding: 14px 16px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); box-shadow: var(--shadow) }
.whisper-bar.show { display: flex }
.whisper-stats { display: flex; align-items: center; gap: 14px; flex-wrap: wrap }
.whisper-stat { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--dim) }
.whisper-stat .lucide { width: 13px; height: 13px; color: var(--mine); opacity: .6 }
.whisper-stat b { font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums }
.whisper-nudge { font-size: 12px; color: var(--mine); display: flex; align-items: center; gap: 5px;
  line-height: 1.5 }
.whisper-nudge .lucide { width: 14px; height: 14px; flex-shrink: 0; opacity: .7 }

/* ── 筛选栏 ── */
.filter-bar { display: flex; gap: 0; padding: 0; margin-bottom: 16px;
  background: var(--line-light); border-radius: var(--r-sm); overflow: hidden }
.filter-btn { flex: 1; background: none; border: none; font-size: 12px; color: var(--faint);
  padding: 8px 0; position: relative; transition: all .2s; text-align: center }
.filter-btn:hover { color: var(--dim) }
.filter-btn.active { color: var(--text); font-weight: 600; background: var(--surface);
  box-shadow: var(--shadow); border-radius: var(--r-sm) }

.memory-trigger { display: flex; align-items: center; justify-content: center; margin-bottom: 16px }
.memory-trigger button { background: none; border: 1px solid var(--line); font-size: 12px; color: var(--faint);
  display: flex; align-items: center; gap: 5px; padding: 5px 14px; border-radius: 16px; transition: all .2s }
.memory-trigger button .lucide { width: 13px; height: 13px }
.memory-trigger button:hover { color: var(--dim); border-color: var(--dim) }

/* ── 时间线 ── */
.tl-date { font-size: 11px; color: var(--faint); font-weight: 600; letter-spacing: .05em;
  padding: 20px 0 8px }
.tl-date:first-child { padding-top: 4px }

/* ── 卡片 ── */
.card { position: relative; background: var(--surface); border-radius: var(--r);
  border: 1px solid var(--line); margin-bottom: 10px; overflow: hidden;
  box-shadow: var(--shadow); transition: background .3s, box-shadow .3s }
.card-enter { opacity: 0; transform: translateY(16px) }
.card-visible { opacity: 1; transform: translateY(0);
  transition: opacity .45s cubic-bezier(.25,.1,.25,1), transform .45s cubic-bezier(.25,.1,.25,1) }
.card-inner { padding: 14px 16px 10px; position: relative; overflow: hidden; min-height: 68px }

.card-bg-icon { position: absolute; pointer-events: none; z-index: 0 }
.card-bg-mood { left: -12px; bottom: -12px; width: 80px; height: 80px }
.card-bg-weather { right: -8px; top: -8px; width: 64px; height: 64px }
.card-bg-icon .lucide { width: 100%; height: 100%; stroke-width: .8 }
.card-mine .card-bg-mood .lucide { color: var(--mine); opacity: .06 }
.card-partner .card-bg-mood .lucide { color: var(--partner); opacity: .06 }
.card-mine .card-bg-weather .lucide { color: var(--mine); opacity: .04 }
.card-partner .card-bg-weather .lucide { color: var(--partner); opacity: .04 }

.card-head { display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 5px; position: relative; z-index: 1 }
.card-name { font-size: 12px; font-weight: 600 }
.card-mine .card-name { color: var(--mine) }
.card-partner .card-name { color: var(--partner) }
.card-time { font-size: 11px; color: var(--faint) }

.card-body { font-size: 14px; line-height: 1.85; white-space: pre-wrap; word-break: break-word;
  position: relative; z-index: 1 }
.card-body:empty { display: none }
.inline-icon { display: inline; width: 1.1em; height: 1.1em; vertical-align: -.15em; stroke-width: 2; color: var(--mine) }

.card-foot { display: flex; align-items: center; gap: 5px; margin-top: 8px; position: relative; z-index: 1 }
.card-tag { display: inline-flex; align-items: center; gap: 3px; font-size: 10px; color: var(--dim);
  background: var(--line-light); padding: 3px 8px; border-radius: 10px; line-height: 1.3 }
.card-tag .lucide { width: 11px; height: 11px; flex-shrink: 0; stroke-width: 2; opacity: .6 }
.card-foot-acts { margin-left: auto; display: flex; gap: 2px; opacity: 0; transition: opacity .15s }
@media (hover:hover) { .card:hover .card-foot-acts { opacity: 1 } }
@media (hover:none) { .card-foot-acts { opacity: .5 } }
.card-foot-act { background: none; border: none; color: var(--faint); padding: 3px 8px;
  border-radius: 6px; font-size: 11px; display: flex; align-items: center; gap: 3px;
  transition: all .15s; cursor: pointer }
.card-foot-act .lucide { width: 12px; height: 12px }
.card-foot-act:hover { color: var(--dim); background: var(--line-light) }
.card-foot-act.del:hover { color: #c25050; background: rgba(194,80,80,.06) }
.card.editing .card-foot-acts { display: none }

/* ── 媒体网格 ── */
.card-inner:has(+ .card-media) { padding-bottom: 12px }
.card-media { display: grid; gap: 2px; border-radius: 0 0 var(--r) var(--r); overflow: hidden }
.card-media[data-n="1"] { grid-template-columns: 1fr }
.card-media[data-n="2"] { grid-template-columns: 1fr 1fr }
.card-media[data-n="3"] { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr }
.card-media[data-n="3"] > .mi:first-child { grid-row: 1/3 }
.card-media:not([data-n="1"]):not([data-n="2"]):not([data-n="3"]) { grid-template-columns: 1fr 1fr }
.mi { position: relative; aspect-ratio: 1; overflow: hidden; background: var(--line-light); cursor: pointer }
.card-media[data-n="1"] .mi { aspect-ratio: 16/10; max-height: 300px }
.mi img, .mi video, .mi .vi-player { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .3s }
.mi:hover img { transform: scale(1.03) }
.mi img.no-poster { visibility: hidden }
.mi-video { cursor: pointer; position: relative }
.mi-video::before { content: ''; position: absolute; inset: 0; background: rgba(0,0,0,.08);
  z-index: 1; pointer-events: none; transition: opacity .2s }
.mi-video:hover::before { opacity: 0 }
.mi .vbadge { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  background: rgba(0,0,0,.45); color: #fff; width: 36px; height: 36px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; z-index: 2; backdrop-filter: blur(4px) }
.mi .vbadge .lucide { width: 16px; height: 16px; margin-left: 2px }

/* ── 编辑模式 ── */
.card-edit { margin-top: 10px; position: relative; z-index: 1 }
.card-edit textarea { display: block; width: 100%; border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 10px 12px; font: inherit; font-size: 14px; color: var(--text); line-height: 1.7;
  min-height: 56px; resize: none; outline: none; background: var(--page); transition: border-color .15s }
.card-edit textarea:focus { border-color: var(--mine); box-shadow: 0 0 0 2px var(--mine-soft) }
.card-edit-actions { display: flex; justify-content: flex-end; gap: 6px; margin-top: 8px }
.btn-cancel { background: none; border: none; color: var(--faint); font-size: 13px; padding: 6px 12px;
  border-radius: 6px; transition: all .15s }
.btn-cancel:hover { color: var(--dim); background: var(--line-light) }
.btn-save { border: none; background: var(--mine); color: #fff; font-size: 12px;
  font-weight: 600; padding: 6px 16px; border-radius: 6px; transition: opacity .15s }
.btn-save:hover { opacity: .9 }
.btn-save:disabled { opacity: .35 }

/* ── 上传预览 ── */
.thumbs { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px }
.thumbs:empty { display: none }
.thumb { width: 56px; height: 56px; border-radius: var(--r-sm); overflow: hidden; background: var(--line-light) }
.thumb img, .thumb video { width: 100%; height: 100%; object-fit: cover; display: block }

.progress-wrap { display: none; align-items: center; gap: 8px; margin-top: 10px }
.progress-wrap.show { display: flex }
.progress-track { flex: 1; height: 3px; background: var(--line); border-radius: 2px; overflow: hidden }
.progress-fill { height: 100%; width: 0; background: var(--mine); border-radius: 2px; transition: width .2s }
.progress-text { font-size: 11px; color: var(--faint); white-space: nowrap }

/* ── 表情面板 ── */
.emoji-wrap { position: relative }
.emoji-box { display: none; position: fixed; bottom: 0; left: 0; right: 0;
  z-index: 200; border-radius: var(--r) var(--r) 0 0;
  box-shadow: 0 -4px 24px rgba(0,0,0,.1) }
.emoji-box.show { display: block }
.emoji-box emoji-picker { --num-columns: 8; --emoji-size: 1.35rem; --border-color: var(--line);
  --background: var(--surface); --category-font-size: .75rem; --indicator-color: var(--mine);
  --input-border-color: var(--line); --input-font-color: var(--text);
  --input-placeholder-color: var(--faint); --outline-color: var(--mine);
  width: 100%; height: 50vh; max-height: 360px; border: none;
  border-top: 1px solid var(--line); border-radius: var(--r) var(--r) 0 0 }
.emoji-scrim { display: none; position: fixed; inset: 0; z-index: 199; background: rgba(0,0,0,.15) }
.emoji-scrim.show { display: block }

@media (min-width: 640px) {
  .emoji-box { position: absolute; bottom: calc(100% + 8px); left: -8px; right: auto;
    top: auto; width: 340px; border-radius: var(--r);
    box-shadow: 0 8px 28px rgba(0,0,0,.1) }
  .emoji-box emoji-picker { height: 340px; max-height: 340px; border: 1px solid var(--line);
    border-radius: var(--r); border-top: 1px solid var(--line) }
  .emoji-scrim.show { display: none }
}

/* ── Toast ── */
.toast-bar { position: fixed; bottom: calc(24px + env(safe-area-inset-bottom)); left: 50%;
  transform: translateX(-50%) translateY(6px); background: var(--text); color: var(--page);
  padding: 10px 24px; border-radius: 20px; font-size: 12px; font-weight: 500;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 600;
  white-space: nowrap; box-shadow: 0 4px 16px rgba(0,0,0,.12) }
.toast-bar.on { opacity: 1; transform: translateX(-50%) translateY(0) }

/* ── 回到顶部 ── */
.scroll-top { position: fixed; bottom: calc(28px + env(safe-area-inset-bottom)); right: 16px;
  width: 38px; height: 38px; border-radius: 50%; background: var(--surface); border: 1px solid var(--line);
  color: var(--dim); display: flex; align-items: center; justify-content: center; z-index: 80;
  box-shadow: 0 2px 12px rgba(0,0,0,.06); opacity: 0; transform: translateY(10px);
  pointer-events: none; transition: all .25s }
.scroll-top .lucide { width: 16px; height: 16px }
.scroll-top.show { opacity: 1; transform: translateY(0); pointer-events: auto }
.scroll-top:hover { color: var(--mine); border-color: var(--mine) }

/* ── 弹层 ── */
.overlay { position: fixed; inset: 0; z-index: 300; background: rgba(0,0,0,.35);
  backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center;
  padding: 20px; opacity: 0; pointer-events: none; transition: opacity .2s }
.overlay.on { opacity: 1; pointer-events: auto }
.overlay-box { width: 100%; background: var(--surface); border-radius: var(--r); overflow: hidden;
  box-shadow: 0 16px 48px rgba(0,0,0,.15); transform: scale(.96); transition: transform .25s }
.overlay.on .overlay-box { transform: scale(1) }

.modal-box { max-width: 280px; padding: 28px 24px 20px; text-align: center }
.modal-title { font-size: 16px; font-weight: 600; margin-bottom: 4px }
.modal-msg { font-size: 13px; color: var(--dim); margin-bottom: 20px; line-height: 1.6 }
.modal-actions { display: flex; gap: 10px }
.modal-actions button { flex: 1; padding: 10px; border: none; border-radius: var(--r-sm);
  font: inherit; font-size: 13px; font-weight: 600; min-height: 44px; transition: all .15s }
.modal-actions .m-cancel { background: var(--line-light); color: var(--dim) }
.modal-actions .m-cancel:hover { background: var(--line) }
.modal-actions .m-confirm { background: var(--mine); color: #fff }
.modal-actions .m-confirm:hover { opacity: .9 }

.memory-box { max-width: 440px; max-height: 85svh; overflow-y: auto }
.memory-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 16px 0 }
.memory-date { font-size: 13px; font-weight: 600; color: var(--mine) }
.memory-body .card { margin: 12px; box-shadow: none; border: 1px solid var(--line) }
.memory-foot { display: flex; justify-content: center; padding: 0 16px 16px }
.memory-foot button { background: none; border: none; color: var(--faint); font-size: 12px;
  display: flex; align-items: center; gap: 5px; transition: color .2s }
.memory-foot button .lucide { width: 14px; height: 14px }
.memory-foot button:hover { color: var(--dim) }

/* ── 加载更多 / 空状态 ── */
.feed-end { text-align: center; padding: 12px 0 20px }
.load-more { background: none; border: 1px solid var(--line); color: var(--dim); padding: 8px 24px;
  border-radius: 20px; font-size: 12px; transition: all .2s }
.load-more:hover { border-color: var(--dim); color: var(--text) }
.feed-empty { text-align: center; padding: 64px 16px; color: var(--faint); font-size: 13px; line-height: 2 }
.feed-empty .lucide { width: 40px; height: 40px; stroke-width: 1; margin: 0 auto 10px; display: block; opacity: .4 }
.card.hidden, .tl-date.hidden { display: none }

/* ── 登录 ── */
.login-wrap { min-height: 100svh; display: flex; align-items: center; justify-content: center; padding: 24px;
  background: linear-gradient(160deg, var(--page) 0%, color-mix(in srgb, var(--mine-soft) 30%, var(--page)) 100%) }
.login-card { width: 100%; max-width: 320px; background: var(--surface); border-radius: var(--r);
  padding: 36px 28px; box-shadow: 0 8px 32px rgba(0,0,0,.06); border: 1px solid var(--line) }
.login-brand { text-align: center; margin-bottom: 28px }
.login-brand .lucide { width: 32px; height: 32px; color: var(--mine); margin: 0 auto 12px; display: block }
.login-brand h1 { font-size: 20px; font-weight: 700; letter-spacing: -.02em }
.login-brand p { font-size: 12px; color: var(--faint); margin-top: 4px }
.login-form { display: flex; flex-direction: column; gap: 10px }
.login-input { display: block; width: 100%; padding: 12px 14px; border: 1px solid var(--line);
  border-radius: var(--r-sm); font: inherit; font-size: 15px; color: var(--text); background: var(--page);
  outline: none; transition: border-color .2s, box-shadow .2s }
.login-input:focus { border-color: var(--mine); box-shadow: 0 0 0 2px var(--mine-soft) }
.login-input::placeholder { color: var(--faint) }
.login-btn { width: 100%; padding: 12px; border: none; border-radius: var(--r-sm); background: var(--mine);
  color: #fff; font: inherit; font-size: 14px; font-weight: 600; cursor: pointer;
  margin-top: 6px; transition: opacity .15s }
.login-btn:hover { opacity: .9 }
.login-error { background: #fef2f2; color: #b44040; border: 1px solid #fecaca; padding: 10px 14px;
  border-radius: var(--r-sm); font-size: 13px; margin-bottom: 6px }
[data-theme="dark"] .login-error { background: rgba(180,64,64,.1); border-color: rgba(180,64,64,.2); color: #d48b7c }

@keyframes fade-up { from { opacity: 0; transform: translateY(12px) } to { opacity: 1; transform: translateY(0) } }
.fade-up { animation: fade-up .35s ease both }

@media (min-width: 640px) {
  .main { padding: 20px 0 calc(24px + env(safe-area-inset-bottom)) }
  .compose { padding: 20px }
  .card-inner { padding: 16px 20px 12px }
  .card-media[data-n="1"] .mi { max-height: 380px }
}
