/* 小纸条 · 极简浪漫 */
:root {
  --bg: #FBF6EF;
  --surface: #FFFDF9;
  --surface-2: #F5EEE5;
  --ink: #3A2E2A;
  --ink-2: #6E5F58;
  --muted: #A3948B;
  --line: #EDE3D8;
  --rose: #E8707E;
  --rose-ink: #C9505F;
  --rose-soft: #FBE4E7;
  --ok: #4E9F84;
  --shadow: 0 1px 2px rgba(80, 50, 40, .06), 0 8px 24px rgba(80, 50, 40, .08);
  --shadow-lg: 0 2px 6px rgba(80, 50, 40, .08), 0 18px 48px rgba(80, 50, 40, .14);
  --serif: "Songti SC", "STSong", "Noto Serif SC", "Source Han Serif SC", "SimSun", serif;
  --sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "HarmonyOS Sans SC", "MiSans", "Noto Sans CJK SC", "Microsoft YaHei", sans-serif;
  --radius: 18px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1E1A19;
    --surface: #2A2423;
    --surface-2: #332C2A;
    --ink: #F4EAE3;
    --ink-2: #CDBFB6;
    --muted: #8F807A;
    --line: #3D3532;
    --rose: #EE8593;
    --rose-ink: #F29AA6;
    --rose-soft: #4A2D31;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .3);
    --shadow-lg: 0 2px 6px rgba(0, 0, 0, .35), 0 18px 48px rgba(0, 0, 0, .45);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
a { color: var(--rose-ink); }
[hidden] { display: none !important; }

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100%;
  padding: calc(var(--safe-top) + 12px) 16px calc(var(--safe-bottom) + 20px);
  display: flex;
  flex-direction: column;
}
.view { display: flex; flex-direction: column; flex: 1; animation: rise .35s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

/* ---------- 通用 ---------- */
.serif { font-family: var(--serif); }
.muted { color: var(--muted); }
.center { text-align: center; }
.spacer { flex: 1; }
.row { display: flex; align-items: center; gap: 10px; }
.stack { display: flex; flex-direction: column; gap: 12px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 52px; padding: 0 22px; border-radius: 999px;
  font-weight: 600; letter-spacing: .02em;
  transition: transform .12s ease, background .2s, opacity .2s;
  user-select: none;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; pointer-events: none; }
.btn-primary { background: var(--rose); color: #fff; box-shadow: 0 6px 18px rgba(232, 112, 126, .35); }
.btn-ghost { background: var(--surface); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line); }
.btn-block { width: 100%; }
.btn-sm { min-height: 38px; padding: 0 14px; font-size: 14px; }
.link { color: var(--muted); font-size: 14px; text-decoration: underline; text-underline-offset: 3px; padding: 8px; }
.danger { color: #D0473F; }

.icon-btn {
  width: 42px; height: 42px; border-radius: 50%;
  display: inline-grid; place-items: center; position: relative;
  color: var(--ink-2);
  transition: background .15s, color .15s;
}
.icon-btn:active { background: var(--surface-2); }
.icon-btn svg { width: 22px; height: 22px; }
.badge {
  position: absolute; top: 5px; right: 4px; min-width: 17px; height: 17px; padding: 0 5px;
  border-radius: 9px; background: var(--rose); color: #fff; font-size: 11px; line-height: 17px; font-weight: 700;
}

.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; color: var(--ink-2); padding-left: 4px; }
.input {
  width: 100%; min-height: 52px; padding: 0 18px; border-radius: 16px;
  border: 1px solid var(--line); background: var(--surface); outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.input:focus { border-color: var(--rose); box-shadow: 0 0 0 4px var(--rose-soft); }
textarea.input { padding: 14px 18px; min-height: 96px; resize: none; line-height: 1.6; }

.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.tip { background: var(--rose-soft); color: var(--rose-ink); border-radius: 14px; padding: 12px 14px; font-size: 14px; }

/* ---------- 顶栏 ---------- */
.topbar { display: flex; align-items: center; gap: 4px; min-height: 48px; margin-bottom: 8px; }
.topbar h1 { font: 600 20px/1.2 var(--serif); margin: 0; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar h1 small { display: block; font: 12px var(--sans); color: var(--muted); margin-top: 2px; }

/* ---------- 欢迎页 ---------- */
.hero { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 10px; padding: 24px 0; }
.hero-art { width: 168px; height: 168px; margin-bottom: 8px; animation: float 5s ease-in-out infinite; }
@keyframes float { 50% { transform: translateY(-6px) rotate(-1.5deg); } }
.hero h1 { font: 600 40px/1.15 var(--serif); margin: 0; letter-spacing: .08em; }
.hero p { margin: 0; color: var(--ink-2); font-family: var(--serif); font-size: 17px; }

/* ---------- 配对码 ---------- */
.code-boxes { display: flex; justify-content: center; gap: 8px; margin: 8px 0 4px; border-radius: 14px; }
.code-boxes:active { transform: scale(.98); }
.code-boxes span {
  width: 46px; height: 58px; display: grid; place-items: center;
  font: 600 28px var(--serif); background: var(--surface); border-radius: 12px; box-shadow: var(--shadow);
}
.code-input { text-align: center; font: 600 26px var(--serif); letter-spacing: .4em; text-transform: uppercase; padding-left: .4em; }
.waiting-dots span { display: inline-block; animation: blink 1.4s infinite both; }
.waiting-dots span:nth-child(2) { animation-delay: .2s; }
.waiting-dots span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .2; } 40% { opacity: 1; } }

/* ---------- 写纸条 ---------- */
.incoming {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; margin-bottom: 10px;
  background: var(--surface); border-radius: 16px; box-shadow: var(--shadow); text-align: left; width: 100%;
  animation: rise .4s ease both;
}
.incoming img { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; transform: rotate(-4deg); box-shadow: 0 2px 6px rgba(0,0,0,.12); }
.incoming b { font-weight: 600; }
.incoming .muted { font-size: 12px; }

.paper-wrap { position: relative; margin: 6px auto 12px; width: 100%; max-width: min(100%, calc(100dvh - 330px)); min-width: 240px; }
.paper-wrap::before {
  /* 一小截和纸胶带 */
  content: ""; position: absolute; z-index: 2; top: -11px; left: 50%; width: 96px; height: 24px;
  transform: translateX(-50%) rotate(-3deg);
  background: repeating-linear-gradient(45deg, rgba(232,112,126,.38) 0 8px, rgba(232,112,126,.26) 8px 16px);
  border-radius: 2px; pointer-events: none;
}
.paper {
  display: block; width: 100%; aspect-ratio: 1; border-radius: 6px;
  box-shadow: var(--shadow-lg); touch-action: none; background: #FFF8EC;
}
.paper-wrap.flying { animation: fly 1s cubic-bezier(.55, -.2, .7, .3) forwards; }
@keyframes fly {
  30% { transform: scale(.82) rotate(-4deg); }
  100% { transform: translate(60vw, -90vh) scale(.12) rotate(28deg); opacity: 0; }
}
.paper-wrap.landing { animation: land .45s ease both; }
@keyframes land { from { opacity: 0; transform: translateY(14px) scale(.98); } }

.tools {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--surface); border-radius: 18px; box-shadow: var(--shadow); padding: 6px;
}
.tool {
  flex: 1; min-width: 0; height: 46px; border-radius: 13px; display: grid; place-items: center; color: var(--ink-2);
  transition: background .15s, color .15s;
}
.tool svg { width: 22px; height: 22px; }
.tool.active { background: var(--rose-soft); color: var(--rose-ink); }
.tool:disabled { opacity: .3; }

.subtools { display: flex; align-items: center; gap: 6px; min-height: 48px; padding: 4px 6px; overflow-x: auto; scrollbar-width: none; }
.subtools::-webkit-scrollbar { display: none; }
.subtools > :first-child { margin-left: auto; }
.subtools > :last-child { margin-right: auto; }
.swatch {
  flex: none; width: 25px; height: 25px; border-radius: 50%;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.12); transition: transform .15s;
}
.swatch.active { transform: scale(1.12); box-shadow: inset 0 0 0 1px rgba(0,0,0,.12), 0 0 0 3px var(--bg), 0 0 0 5px var(--rose); }
.divider { flex: none; width: 1px; height: 24px; background: var(--line); }
.size-dot { flex: none; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; }
.size-dot i { display: block; border-radius: 50%; background: var(--ink-2); }
.size-dot.active { background: var(--rose-soft); }
.size-dot.active i { background: var(--rose-ink); }
.hint { font-size: 13px; color: var(--muted); }

.send-row { display: flex; gap: 10px; margin-top: 4px; }
.send-row .btn-primary { flex: 1; }

/* ---------- 底部弹层 ---------- */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(30, 20, 18, .32); z-index: 40; animation: fade .2s ease both; }
@keyframes fade { from { opacity: 0; } }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 41; margin: 0 auto; max-width: 480px;
  background: var(--surface); border-radius: 24px 24px 0 0; box-shadow: var(--shadow-lg);
  padding: 10px 18px calc(var(--safe-bottom) + 18px); max-height: 78dvh; overflow-y: auto;
  animation: up .28s cubic-bezier(.2, .9, .3, 1) both;
}
@keyframes up { from { transform: translateY(100%); } }
.sheet .grabber { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 12px; }
.sheet h2 { font: 600 18px var(--serif); margin: 4px 0 14px; }
.sheet h3 { font-size: 13px; color: var(--muted); font-weight: 500; margin: 16px 0 8px; }
.emoji-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.emoji-grid button { font-size: 30px; height: 52px; border-radius: 12px; }
.emoji-grid button:active { background: var(--surface-2); }
.stamp-grid { display: flex; flex-wrap: wrap; gap: 10px; }
.stamp {
  padding: 6px 14px; border: 2.5px solid currentColor; border-radius: 10px; color: #D7263D;
  font: 700 18px var(--serif); transform: rotate(-4deg); outline: 1px solid currentColor; outline-offset: -6px;
}
.paper-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; }
.paper-chip { aspect-ratio: 1; border-radius: 12px; box-shadow: inset 0 0 0 1px rgba(0,0,0,.1); }
.paper-chip.active { box-shadow: inset 0 0 0 1px rgba(0,0,0,.1), 0 0 0 3px var(--surface), 0 0 0 5px var(--rose); }
.seg { display: flex; background: var(--surface-2); border-radius: 12px; padding: 4px; }
.seg button { flex: 1; height: 38px; border-radius: 9px; font-size: 14px; color: var(--ink-2); }
.seg button.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }

/* ---------- 纸条盒 ---------- */
.masonry { columns: 2; column-gap: 14px; padding-top: 6px; }
.note-card {
  break-inside: avoid; margin: 0 0 16px; display: block; width: 100%; text-align: left;
  background: var(--surface); border-radius: 10px; padding: 8px 8px 10px; box-shadow: var(--shadow);
  transform: rotate(var(--tilt, 0deg)); transition: transform .2s;
}
.note-card:active { transform: scale(.97); }
.note-card img { display: block; width: 100%; aspect-ratio: 1; border-radius: 4px; object-fit: cover; background: var(--surface-2); }
.note-meta { margin-top: 8px; font-size: 12px; color: var(--muted); line-height: 1.4; }
.note-meta b { color: var(--ink-2); font-weight: 600; }
.status-ok { color: var(--ok); }
.empty { text-align: center; color: var(--muted); padding: 60px 20px; font-family: var(--serif); }
.empty .big { font-size: 44px; display: block; margin-bottom: 10px; }

.viewer { position: fixed; inset: 0; z-index: 50; background: rgba(24, 18, 16, .86); display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 20px; animation: fade .2s both; }
.viewer img { width: min(92vw, 520px); aspect-ratio: 1; border-radius: 8px; box-shadow: 0 20px 60px rgba(0,0,0,.5); animation: land .3s both; }
.viewer .vmeta { color: #F4EAE3; margin: 16px 0 8px; font-size: 14px; text-align: center; }
.viewer .row { justify-content: center; flex-wrap: wrap; }
.viewer .btn-ghost { background: rgba(255,255,255,.12); color: #fff; box-shadow: none; }

/* ---------- 指南 / 设置 ---------- */
.steps { counter-reset: s; list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 14px; }
.steps li { counter-increment: s; position: relative; padding-left: 40px; color: var(--ink-2); }
.steps li::before {
  content: counter(s); position: absolute; left: 0; top: 0; width: 28px; height: 28px; border-radius: 50%;
  background: var(--rose-soft); color: var(--rose-ink); font-weight: 700; display: grid; place-items: center; font-size: 14px;
}
.steps b { color: var(--ink); }
.code-block {
  font: 12px/1.5 ui-monospace, Menlo, Consolas, monospace; background: var(--surface-2); border-radius: 12px;
  padding: 12px; max-height: 140px; overflow: auto; white-space: pre; color: var(--ink-2);
}
.list { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 15px 18px; width: 100%; text-align: left; border-bottom: 1px solid var(--line); min-height: 56px; }
.list-item:last-child { border-bottom: 0; }
.list-item .k { flex: 1; }
.list-item .v { color: var(--muted); font-size: 15px; }
.section-title { font-size: 13px; color: var(--muted); margin: 22px 6px 8px; }

/* ---------- 弹窗 / 提示 ---------- */
#toast {
  position: fixed; left: 50%; bottom: calc(var(--safe-bottom) + 96px); transform: translateX(-50%); z-index: 100;
  background: rgba(46, 36, 33, .92); color: #fff; padding: 11px 18px; border-radius: 999px; font-size: 14px;
  width: max-content; max-width: calc(100vw - 48px); text-align: center; box-shadow: var(--shadow-lg); animation: rise .25s both;
}
.dialog-backdrop { position: fixed; inset: 0; background: rgba(30, 20, 18, .4); z-index: 60; display: grid; place-items: center; padding: 24px; animation: fade .2s both; }
.dialog { background: var(--surface); border-radius: 22px; padding: 22px; width: 100%; max-width: 340px; box-shadow: var(--shadow-lg); animation: land .25s both; }
.dialog h2 { font: 600 18px var(--serif); margin: 0 0 8px; }
.dialog p { margin: 0 0 18px; color: var(--ink-2); font-size: 15px; }
.dialog .row { justify-content: flex-end; }

.hearts { position: fixed; inset: 0; pointer-events: none; z-index: 90; overflow: hidden; }
.hearts i { position: absolute; bottom: -40px; font-style: normal; animation: heart 2.4s ease-out forwards; }
@keyframes heart { to { transform: translateY(-110vh) rotate(var(--r)); opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}

/* 搬家提示条（仅旧临时地址） */
.moving-bar {
  position: sticky; top: 0; z-index: 50; display: block; width: 100%;
  padding: calc(10px + var(--safe-top)) 16px 10px; border: 0;
  background: var(--rose); color: #fff; font: 600 15px/1.4 var(--sans); text-align: center; cursor: pointer;
}
.moving-step { display: flex; gap: 12px; align-items: flex-start; }
.moving-step > b {
  flex: none; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center;
  background: var(--rose-soft); color: var(--rose-ink); font-size: 14px;
}
.moving-step > div { flex: 1; min-width: 0; }
.moving-step p { margin: 2px 0 8px; font-size: 14px; color: var(--ink-2); word-break: break-all; }
