/* ==========================================================
   给你的小房间 — 样式
   ========================================================== */
:root {
  --ink: #3a2b2f;
  --ink-2: #8b7378;
  --ink-3: #bda7ab;
  --pink: #ff6f8f;
  --pink-deep: #e94f75;
  --line: rgba(233, 79, 117, .13);
  --card: #fffdfc;
  --shadow-soft: 0 8px 24px rgba(214, 96, 122, .09);
  --shadow-bubble: 0 4px 14px rgba(214, 96, 122, .08);
  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
          "Microsoft YaHei", "Segoe UI", sans-serif;
  --serif: "Songti SC", "Noto Serif SC", "Source Han Serif SC", "SimSun", serif;
}

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

html, body { height: 100%; margin: 0; }

body {
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(760px 420px at 12% -8%, #ffe2d4 0%, rgba(255, 226, 212, 0) 62%),
    radial-gradient(680px 400px at 104% 2%, #ffdde9 0%, rgba(255, 221, 233, 0) 58%),
    linear-gradient(180deg, #fff8f4 0%, #fff3f0 42%, #fdeff2 100%);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

.app {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 480px;
  height: 100vh;
  height: 100dvh;
  margin: 0 auto;
  overflow: hidden;
}

@media (min-width: 620px) and (min-height: 700px) {
  body { display: flex; align-items: center; justify-content: center; padding: 24px; }
  .app {
    height: min(880px, 94vh);
    border-radius: 30px;
    box-shadow: 0 30px 70px rgba(180, 96, 116, .18), 0 2px 0 rgba(255, 255, 255, .9) inset;
    border: 1px solid rgba(255, 255, 255, .8);
    background: rgba(255, 250, 248, .55);
    backdrop-filter: blur(2px);
  }
}

/* ---------------- 顶部 ---------------- */
.hd {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 13px 16px 11px;
  padding-top: calc(13px + env(safe-area-inset-top));
  background: rgba(255, 250, 247, .72);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid var(--line);
  z-index: 5;
}

.hd-avatar {
  position: relative;
  width: 40px; height: 40px;
  flex: 0 0 40px;
  border-radius: 50%;
  display: grid; place-items: center;
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  background: linear-gradient(150deg, #ffa3b6, #ff6f8f 55%, #ef5c80);
  box-shadow: 0 6px 16px rgba(233, 79, 117, .32);
}
.hd-avatar .dot {
  position: absolute; right: -1px; bottom: -1px;
  width: 11px; height: 11px; border-radius: 50%;
  background: #4ede9e;
  border: 2px solid #fff8f5;
  box-shadow: 0 0 0 2px rgba(78, 222, 158, .22);
}

.hd-meta { flex: 1 1 auto; min-width: 0; }
.hd-name {
  font-size: 15.5px; font-weight: 650; letter-spacing: .2px;
  display: flex; align-items: center; gap: 6px;
}
.hd-name .badge {
  font-size: 10px; font-weight: 500; letter-spacing: .4px;
  color: var(--pink-deep);
  background: rgba(255, 111, 143, .12);
  padding: 2px 6px; border-radius: 6px;
}
.hd-sub {
  margin-top: 2px;
  font-size: 11.5px; color: var(--ink-2);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.hd-btn {
  flex: 0 0 34px;
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, .8);
  color: var(--pink-deep);
  cursor: pointer;
  transition: transform .18s ease, background .18s ease;
}
.hd-btn:active { transform: scale(.92); background: #fff; }

/* ---------------- 每日一句 ---------------- */
.daily {
  flex: 0 0 auto;
  padding: 9px 20px 3px;
  text-align: center;
}
.daily span {
  display: inline-block;
  font-family: var(--serif);
  font-size: 12px;
  line-height: 1.6;
  letter-spacing: .5px;
  color: #a8828a;
}

/* ---------------- 空状态水印 ---------------- */
.wm {
  position: absolute;
  left: 0; right: 0;
  top: 24%;
  z-index: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  color: rgba(255, 111, 143, .16);
  pointer-events: none;
  transition: opacity .7s ease;
}
.wm span {
  font-family: var(--serif);
  font-size: 8.5px;
  letter-spacing: 3.2px;
  text-transform: uppercase;
  color: rgba(160, 110, 120, .26);
}
body.started .wm { opacity: 0; }

/* ---------------- 聊天区 ---------------- */
.chat {
  position: relative;
  z-index: 1;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 10px 14px 6px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.chat::-webkit-scrollbar { display: none; }

/* 消息少的时候，让内容贴着底部，像真的微信 */
.chat > *:first-child { margin-top: auto; }

.row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  margin-bottom: 13px;
  animation: rise .32s cubic-bezier(.2, .8, .3, 1) both;
}
@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}
.row.me { flex-direction: row-reverse; }

.av {
  flex: 0 0 27px;
  width: 27px; height: 27px;
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 12px; font-weight: 600; color: #fff;
  background: linear-gradient(150deg, #ffb3c2, #ff7d99);
  box-shadow: 0 3px 9px rgba(233, 79, 117, .2);
  user-select: none;
}
.row.me .av { background: linear-gradient(150deg, #cbb8ff, #9d86f5); }

.bubble {
  position: relative;
  max-width: 76%;
  padding: 10px 14px;
  font-size: 15.2px;
  line-height: 1.62;
  word-break: break-word;
  white-space: pre-wrap;
  border-radius: 17px;
  background: var(--card);
  border: 1px solid var(--line);
  border-bottom-left-radius: 5px;
  box-shadow: var(--shadow-bubble);
  color: var(--ink);
}
.row.me .bubble {
  background: linear-gradient(145deg, #ff8fa5, #ff6f8f 60%, #f2607f);
  border: none;
  color: #fff;
  border-radius: 17px;
  border-bottom-right-radius: 5px;
  box-shadow: 0 6px 16px rgba(233, 79, 117, .26);
}

.bubble .caret {
  display: inline-block;
  width: 2px; height: 1em;
  margin-left: 1px;
  vertical-align: -2px;
  background: var(--pink);
  animation: blink .9s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

/* 打字中 */
.typing { display: flex; gap: 4px; padding: 4px 2px; }
.typing i {
  width: 6px; height: 6px; border-radius: 50%;
  background: #f0a9b8;
  animation: bob 1.15s infinite ease-in-out;
}
.typing i:nth-child(2) { animation-delay: .16s; }
.typing i:nth-child(3) { animation-delay: .32s; }
@keyframes bob {
  0%, 60%, 100% { transform: translateY(0); opacity: .55; }
  30% { transform: translateY(-5px); opacity: 1; }
}

/* 时间分割 */
.time-sep {
  text-align: center;
  font-size: 10.5px;
  color: var(--ink-3);
  letter-spacing: .6px;
  margin: 16px 0 12px;
}

/* ---------------- 快捷话 ---------------- */
.chips {
  flex: 0 0 auto;
  display: flex;
  gap: 8px;
  padding: 2px 14px 9px;
  overflow-x: auto;
  scrollbar-width: none;
  transition: opacity .25s ease, height .25s ease;
}
.chips::-webkit-scrollbar { display: none; }
.chips[hidden] { display: none; }

.chip {
  flex: 0 0 auto;
  padding: 8px 13px;
  font-size: 12.5px;
  color: #9c6b76;
  background: rgba(255, 255, 255, .85);
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
  transition: transform .16s ease, background .16s ease;
}
.chip:active { transform: scale(.94); background: #fff; }

/* ---------------- 输入栏 ---------------- */
.composer {
  position: relative;
  z-index: 5;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 12px;
  padding-bottom: calc(9px + env(safe-area-inset-bottom));
  background: rgba(255, 252, 250, .82);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
}

.input {
  flex: 1 1 auto;
  min-width: 0;
  height: 42px;
  padding: 0 16px;
  font-size: 15.2px;
  font-family: var(--font);
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 21px;
  outline: none;
  transition: border-color .2s ease, box-shadow .2s ease;
}
.input::placeholder { color: #cbb6ba; }
.input:focus {
  border-color: rgba(255, 111, 143, .45);
  box-shadow: 0 0 0 4px rgba(255, 111, 143, .08);
}

.send {
  flex: 0 0 42px;
  width: 42px; height: 42px;
  display: grid; place-items: center;
  border: none;
  border-radius: 50%;
  color: #fff;
  background: linear-gradient(150deg, #ff92a8, #ff6f8f 55%, #ea5279);
  box-shadow: 0 6px 16px rgba(233, 79, 117, .3);
  cursor: pointer;
  transition: transform .16s ease, opacity .2s ease, filter .2s ease;
}
.send:active { transform: scale(.9); }
.send:disabled { opacity: .45; filter: saturate(.6); box-shadow: none; }

/* ---------------- 门禁 ---------------- */
.gate {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 26px;
  background:
    radial-gradient(700px 420px at 18% 0%, #ffe0d2 0%, rgba(255, 224, 210, 0) 60%),
    radial-gradient(600px 380px at 96% 8%, #ffdce9 0%, rgba(255, 220, 233, 0) 58%),
    linear-gradient(175deg, #fff9f5, #fdeef1);
  animation: fadeIn .45s ease both;
}
.gate[hidden] { display: none; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.gate-card {
  position: relative;
  width: 100%;
  max-width: 340px;
  padding: 34px 26px 26px;
  text-align: center;
  border-radius: 26px;
  background: rgba(255, 255, 255, .78);
  border: 1px solid rgba(255, 255, 255, .9);
  box-shadow: 0 24px 60px rgba(190, 110, 130, .16);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
}
.gate-glow {
  position: absolute; inset: -1px;
  border-radius: inherit;
  pointer-events: none;
  background: linear-gradient(160deg, rgba(255, 255, 255, .9), rgba(255, 190, 205, .35) 45%, rgba(255, 255, 255, 0) 70%);
  -webkit-mask: linear-gradient(#000, #000) content-box, linear-gradient(#000, #000);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  padding: 1px;
}

.gate-eyebrow {
  margin: 0 0 14px;
  font-size: 10px;
  letter-spacing: 2.6px;
  color: #c99aa4;
}
.gate-title {
  margin: 0 0 10px;
  font-family: var(--serif);
  font-size: 26px;
  font-weight: 600;
  letter-spacing: 2px;
  color: #4a3438;
}
.gate-sub {
  margin: 0 0 20px;
  font-size: 12.5px;
  line-height: 1.8;
  color: var(--ink-2);
}
.gate-sub span { color: var(--ink-3); font-size: 11.5px; }

.gate-input {
  width: 100%;
  height: 56px;
  text-align: center;
  font-size: 26px;
  font-weight: 600;
  letter-spacing: 12px;
  text-indent: 12px;
  color: var(--pink-deep);
  background: #fff;
  border: 1.5px solid var(--line);
  border-radius: 16px;
  outline: none;
  transition: border-color .2s ease, box-shadow .2s ease;
}
.gate-input::placeholder { color: #f0d6da; letter-spacing: 8px; }
.gate-input:focus {
  border-color: rgba(255, 111, 143, .5);
  box-shadow: 0 0 0 5px rgba(255, 111, 143, .09);
}

.gate-btn {
  width: 100%;
  height: 48px;
  margin-top: 14px;
  font-size: 15px;
  font-family: var(--font);
  letter-spacing: 2px;
  color: #fff;
  border: none;
  border-radius: 15px;
  background: linear-gradient(120deg, #ff8ba2, #ff6f8f 50%, #ea5279);
  box-shadow: 0 12px 26px rgba(233, 79, 117, .26);
  cursor: pointer;
  transition: transform .16s ease, filter .2s ease;
}
.gate-btn:active { transform: scale(.97); filter: brightness(.97); }

.gate-err {
  min-height: 17px;
  margin: 10px 0 0;
  font-size: 12px;
  color: #e2647f;
  letter-spacing: .3px;
}
.shake { animation: shake .42s cubic-bezier(.36, .07, .19, .97) both; }
@keyframes shake {
  10%, 90% { transform: translateX(-2px); }
  20%, 80% { transform: translateX(4px); }
  30%, 50%, 70% { transform: translateX(-6px); }
  40%, 60% { transform: translateX(6px); }
}

/* ---------------- 记忆抽屉 ---------------- */
.sheet-mask {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(58, 43, 47, .3);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
  animation: fadeIn .3s ease both;
}

.sheet {
  position: fixed;
  left: 50%;
  bottom: 0;
  z-index: 41;
  width: 100%;
  max-width: 480px;
  max-height: 82vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 10px 22px calc(26px + env(safe-area-inset-bottom));
  border-radius: 24px 24px 0 0;
  background: linear-gradient(180deg, #fffdfc, #fff7f4);
  box-shadow: 0 -18px 50px rgba(160, 90, 108, .16);
  transform: translate(-50%, 102%);
  transition: transform .36s cubic-bezier(.2, .85, .3, 1);
}
.sheet.open { transform: translate(-50%, 0); }
.sheet[hidden] { display: none; }

.sheet-grip {
  width: 38px; height: 4px;
  margin: 2px auto 16px;
  border-radius: 99px;
  background: #ecdadd;
}
.sheet-title {
  margin: 0 0 4px;
  font-family: var(--serif);
  font-size: 20px;
  letter-spacing: 1.5px;
  color: #4a3438;
}
.sheet-lead {
  margin: 0 0 16px;
  font-size: 12.5px;
  color: var(--ink-2);
  line-height: 1.7;
}
.sheet-h3 {
  margin: 20px 0 9px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1.6px;
  color: #c0959e;
  text-transform: uppercase;
}

.mem-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.mem-cell {
  padding: 13px 14px;
  border-radius: 15px;
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: var(--shadow-soft);
}
.mem-cell .k {
  font-size: 10.5px;
  letter-spacing: .6px;
  color: var(--ink-3);
}
.mem-cell .v {
  margin-top: 5px;
  font-size: 14px;
  font-weight: 600;
  color: #4a3438;
  line-height: 1.4;
}
.mem-cell .v em {
  display: block;
  margin: 3px 0 0;
  font-style: normal;
  font-size: 11px;
  font-weight: 400;
  color: var(--pink-deep);
}

.mem-cell.wide { grid-column: 1 / -1; }

.tags { display: flex; flex-wrap: wrap; gap: 7px; }
.tag {
  padding: 6px 11px;
  font-size: 12px;
  color: #96606d;
  background: rgba(255, 111, 143, .08);
  border: 1px solid rgba(255, 111, 143, .14);
  border-radius: 9px;
}

.moments { margin: 0; padding: 0; list-style: none; }
.moments li {
  position: relative;
  padding: 0 0 0 18px;
  margin-bottom: 11px;
  font-size: 13px;
  line-height: 1.72;
  color: #6a5258;
}
.moments li::before {
  content: "";
  position: absolute;
  left: 3px; top: .68em;
  width: 5px; height: 5px;
  border-radius: 50%;
  background: #ffb3c1;
}
.moments li.empty {
  padding-left: 0;
  color: #a98c92;
  font-family: var(--serif);
  letter-spacing: .3px;
}
.moments li.empty::before { display: none; }

.sheet-foot {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px dashed #f0dfe2;
  text-align: center;
}
.ghost-btn {
  padding: 8px 16px;
  font-size: 12px;
  font-family: var(--font);
  color: #b08c93;
  background: transparent;
  border: 1px solid #eddbde;
  border-radius: 999px;
  cursor: pointer;
}
.ghost-btn:active { background: #fff; }
.sign {
  margin: 14px 0 0;
  font-family: var(--serif);
  font-size: 12px;
  letter-spacing: 1px;
  color: #bfa2a8;
}

/* ---------------- 爱心特效 ---------------- */
.hearts {
  position: fixed;
  inset: 0;
  z-index: 60;
  pointer-events: none;
  overflow: hidden;
}
.heart {
  position: absolute;
  bottom: -30px;
  font-size: 18px;
  will-change: transform, opacity;
  animation: floatUp 2.8s ease-out forwards;
}
@keyframes floatUp {
  0%   { transform: translateY(0) scale(.6) rotate(0deg); opacity: 0; }
  12%  { opacity: 1; }
  100% { transform: translateY(-90vh) scale(1.15) rotate(var(--rot, 12deg)); opacity: 0; }
}

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