/* ============================================================
   社畜小猫 · 桌宠 — 牛皮纸 + 手绘治愈系 设计系统
   视觉 DNA:粗黑蜡笔描边小猫 / 奶油便签纸 / 牛皮纸桌面 / 和纸胶带
   ============================================================ */

:root {
  color-scheme: light;

  /* 墨色(贴近小猫描边的粗黑蜡笔)*/
  --ink: #2a2018;
  --ink-soft: #6f6151;
  --ink-faint: rgba(42, 32, 24, 0.42);
  --line: rgba(42, 32, 24, 0.16);

  /* 牛皮纸桌面 */
  --kraft: #c7a574;
  --kraft-deep: #b08d57;
  --kraft-shadow: rgba(90, 64, 32, 0.34);

  /* 奶油便签纸 */
  --paper: #fcf4e1;
  --paper-2: #f6e9ca;
  --paper-edge: #ecd9ab;

  /* 治愈系点缀 */
  --coral: #e8746a; /* 亲密度 / 爱心 */
  --coral-deep: #c9544a;
  --sage: #93a86a; /* 能量 */
  --honey: #e0a637; /* 饱腹 */
  --blush: #efa6ac; /* 心情 */
  --sky: #7ea8bd; /* 信息 / 交流 */

  --tape: rgba(245, 224, 150, 0.55);
  --tape-2: rgba(231, 162, 150, 0.5);

  --r-card: 22px;
  --shadow-card: 0 14px 30px -14px rgba(74, 50, 22, 0.45);
  --shadow-soft: 0 6px 16px -8px rgba(74, 50, 22, 0.4);

  --font-hand: "ZCOOL KuaiLe", "PingFang SC", "Hiragino Sans GB", sans-serif;
  --font-body: "Noto Sans SC", "PingFang SC", "Hiragino Sans GB", sans-serif;
}

* {
  box-sizing: border-box;
}

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

body {
  font-family: var(--font-body);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

#root {
  height: 100%;
}

/* ---------- 牛皮纸桌面 ---------- */
.deck {
  position: relative;
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: clamp(0px, 2vw, 26px);
  background:
    radial-gradient(
      120% 80% at 30% 0%,
      rgba(255, 248, 230, 0.5),
      transparent 55%
    ),
    radial-gradient(
      120% 90% at 80% 100%,
      rgba(120, 84, 38, 0.28),
      transparent 60%
    ),
    linear-gradient(160deg, #cdac7c 0%, #c19c66 48%, #b6904f 100%);
}
.deck::before {
  /* 纸纤维噪点 */
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.5;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix type='saturate' values='0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)' opacity='0.45'/></svg>");
}

/* ---------- 手机壳 ---------- */
.phone {
  position: relative;
  z-index: 1;
  width: min(100%, 452px);
  height: min(100%, 924px);
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: clamp(0px, 5vw, 34px);
  background: linear-gradient(180deg, #fbf2dc 0%, #f7ecd0 100%);
  box-shadow:
    0 30px 60px -24px rgba(60, 40, 16, 0.6),
    0 0 0 2.5px var(--ink);
}
@media (max-width: 470px) {
  .deck {
    padding: 0;
  }
  .phone {
    border-radius: 0;
    box-shadow: none;
    height: 100%;
  }
}

/* ============================================================
   顶栏
   ============================================================ */
.topbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 13px 15px 12px;
  background: linear-gradient(
    180deg,
    rgba(252, 244, 225, 0.96),
    rgba(247, 235, 207, 0.92)
  );
  border-bottom: 2.5px solid var(--ink);
  position: relative;
  z-index: 6;
}

.avatar {
  flex: 0 0 auto;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 2.5px solid var(--ink);
  background:
    radial-gradient(circle at 38% 34%, #fff 0 38%, transparent 39%) no-repeat,
    #fbf6ea;
  overflow: hidden;
  display: grid;
  place-items: center;
  box-shadow: inset 0 -5px 10px rgba(176, 150, 110, 0.35);
}
.avatar img {
  width: 132%;
  height: 132%;
  object-fit: contain;
  margin-top: 6px;
}

.id-block {
  flex: 1 1 auto;
  min-width: 0;
}
.id-line {
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.pet-name {
  font-family: var(--font-hand);
  font-size: 21px;
  line-height: 1;
  letter-spacing: 0.5px;
}
.lv-pill {
  flex: 0 0 auto;
  font-family: var(--font-hand);
  font-size: 12px;
  color: var(--coral-deep);
  background: #fff0ec;
  border: 2px solid var(--coral);
  border-radius: 9px 12px 8px 11px;
  padding: 1px 8px;
}
.title-row {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 4px;
}
.title-text {
  font-size: 12px;
  color: var(--ink-soft);
  font-weight: 600;
}
.time-pill {
  flex: 0 0 auto;
  font-size: 11px;
  line-height: 1;
  color: #4b6254;
  background: #edf3df;
  border: 1.6px solid #93a86a;
  border-radius: 999px;
  padding: 3px 7px;
  font-weight: 700;
  white-space: nowrap;
}
.heart-row {
  display: inline-flex;
  gap: 2px;
  align-items: center;
}
.heart-row .hb {
  width: 13px;
  height: 13px;
  display: inline-block;
}
.intimacy-bar {
  margin-top: 6px;
  height: 7px;
  border-radius: 6px;
  border: 1.5px solid var(--ink);
  background: rgba(42, 32, 24, 0.07);
  overflow: hidden;
}
.intimacy-fill {
  height: 100%;
  background: repeating-linear-gradient(
    -45deg,
    var(--coral) 0 7px,
    #ef8a80 7px 14px
  );
  border-radius: 6px;
  transition: width 0.6s cubic-bezier(0.34, 1.4, 0.5, 1);
}

.icon-btn {
  flex: 0 0 auto;
  position: relative;
  width: 42px;
  height: 42px;
  border: 2.5px solid var(--ink);
  border-radius: 13px 15px 12px 14px;
  background: var(--paper);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition:
    transform 0.12s ease,
    background 0.15s ease;
}
.icon-btn:hover {
  background: #fff;
}
.icon-btn:active {
  transform: translateY(2px) rotate(-2deg);
}
.icon-btn .badge {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 19px;
  height: 19px;
  padding: 0 4px;
  border-radius: 50%;
  border: 2px solid var(--ink);
  background: var(--coral);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: grid;
  place-items: center;
  animation: badge-pop 0.4s cubic-bezier(0.34, 1.6, 0.5, 1);
}
@keyframes badge-pop {
  from {
    transform: scale(0);
  }
  to {
    transform: scale(1);
  }
}

/* ============================================================
   舞台(场景 + 小猫)
   ============================================================ */
.stage {
  flex: 0 0 auto;
  position: relative;
  height: clamp(230px, 34vh, 330px);
  overflow: hidden;
  border-bottom: 2.5px solid var(--ink);
  transition: background 0.5s ease;
}
/* 公司场景 */
.stage[data-scene="office"] {
  background: linear-gradient(180deg, #dceaf0 0%, #eef2e6 62%, #efe2c8 100%);
}
/* 家场景 */
.stage[data-scene="home"] {
  background:
    radial-gradient(
      90% 70% at 50% 18%,
      rgba(255, 246, 232, 0.8),
      transparent 70%
    ),
    linear-gradient(180deg, #f7e4d4 0%, #f7ecd5 60%, #f0dcc0 100%);
}

/* 场景里的手绘道具(纯 CSS,粗描边)*/
.prop {
  position: absolute;
  border: 2.5px solid var(--ink);
  pointer-events: none;
}
.scene-set {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity 0.45s ease;
}
.stage[data-scene="office"] .scene-office,
.stage[data-scene="home"] .scene-home {
  opacity: 1;
}

/* 公司道具 */
.p-window {
  top: 26px;
  left: 26px;
  width: 92px;
  height: 70px;
  border-radius: 8px 8px 6px 6px;
  background: linear-gradient(180deg, #bcdcea, #e7f3d9);
}
.p-window::before,
.p-window::after {
  content: "";
  position: absolute;
  background: var(--ink);
}
.p-window::before {
  left: 50%;
  top: 0;
  bottom: 0;
  width: 2px;
  transform: translateX(-50%);
}
.p-window::after {
  top: 50%;
  left: 0;
  right: 0;
  height: 2px;
  transform: translateY(-50%);
}
.p-plant {
  bottom: 0;
  left: 122px;
  width: 30px;
  height: 34px;
  border-radius: 4px 4px 7px 7px;
  background: #cf8f63;
}
.p-plant::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 26px;
  width: 34px;
  height: 40px;
  transform: translateX(-50%);
  border: 2.5px solid var(--ink);
  border-radius: 60% 60% 40% 40%/ 70% 70% 40% 40%;
  background: radial-gradient(circle at 50% 40%, #9cbf72, #7ba055);
}
.p-board {
  top: 30px;
  right: 22px;
  width: 96px;
  height: 66px;
  border-radius: 7px;
  background: #f6efda;
  box-shadow:
    inset 0 0 0 6px #fff,
    inset 0 0 0 8px var(--ink);
}
.p-board i {
  position: absolute;
  left: 14px;
  height: 6px;
  border-radius: 4px;
  background: var(--sky);
}
.p-board i:nth-child(1) {
  top: 16px;
  width: 54px;
}
.p-board i:nth-child(2) {
  top: 30px;
  width: 38px;
  background: var(--sage);
}
.p-board i:nth-child(3) {
  top: 44px;
  width: 46px;
  background: var(--honey);
}

/* 家道具 */
.p-lamp {
  top: 18px;
  right: 36px;
  width: 50px;
  height: 30px;
  border-bottom: 0;
  border-radius: 26px 26px 4px 4px;
  background: linear-gradient(180deg, #f3cf6e, #e7b53f);
}
.p-lamp::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 28px;
  width: 3px;
  height: 60px;
  transform: translateX(-50%);
  background: var(--ink);
}
.p-frame {
  top: 30px;
  left: 30px;
  width: 46px;
  height: 40px;
  border-radius: 5px;
  background: #fff7ea;
  box-shadow:
    inset 0 0 0 5px #fff,
    inset 0 0 0 7px var(--ink);
}
.p-frame::before {
  content: "";
  position: absolute;
  inset: 12px 10px 8px;
  border-radius: 50% 50% 0 0;
  background: var(--blush);
}
.p-rug {
  left: 50%;
  bottom: 12px;
  width: 230px;
  height: 30px;
  transform: translateX(-50%);
  border-radius: 50%;
  border-width: 2.5px;
  background: rgba(126, 168, 189, 0.26);
}

/* 地面 + 小猫 */
.cat-area {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  width: 100%;
  height: 86%;
  display: grid;
  place-items: end center;
  cursor: grab;
  touch-action: manipulation;
}
.cat-area:active {
  cursor: grabbing;
}
.cat-shadow {
  position: absolute;
  bottom: 6px;
  left: 50%;
  width: 132px;
  height: 26px;
  transform: translateX(-50%);
  border-radius: 50%;
  background: radial-gradient(
    50% 60% at 50% 50%,
    rgba(90, 64, 32, 0.34),
    transparent 72%
  );
  animation: shadow-breathe 3.6s ease-in-out infinite;
}
.cat-breathe {
  position: relative;
  transform-origin: 50% 100%;
  animation: breathe 3.6s ease-in-out infinite;
  will-change: transform;
}
.cat-breathe.is-arrive {
  animation:
    breathe 3.6s ease-in-out infinite,
    arrive 0.42s cubic-bezier(0.3, 1.5, 0.5, 1);
}
.cat-breathe.is-pet {
  animation:
    breathe 3.6s ease-in-out infinite,
    wiggle 0.5s ease-in-out;
}
.cat-breathe.is-fidget {
  animation:
    breathe 3.6s ease-in-out infinite,
    hop 0.6s ease-in-out;
}
.cat-frame {
  display: block;
  height: clamp(180px, 27vh, 250px);
  width: auto;
  object-fit: contain;
  filter: drop-shadow(0 4px 5px rgba(74, 50, 22, 0.18));
  opacity: 0.92;
  transition: opacity 90ms ease-out;
  -webkit-user-drag: none;
  user-select: none;
  pointer-events: none;
}
.cat-frame.is-visible {
  opacity: 1;
}

@keyframes breathe {
  0%,
  100% {
    transform: translateY(0) scale(1, 1);
  }
  50% {
    transform: translateY(-2px) scale(1.012, 0.99);
  }
}
@keyframes shadow-breathe {
  0%,
  100% {
    transform: translateX(-50%) scale(1);
    opacity: 0.9;
  }
  50% {
    transform: translateX(-50%) scale(0.9);
    opacity: 0.7;
  }
}
@keyframes arrive {
  0% {
    transform: scale(0.84, 1.16) translateY(6px);
  }
  55% {
    transform: scale(1.07, 0.93) translateY(-3px);
  }
  100% {
    transform: scale(1, 1) translateY(0);
  }
}
@keyframes wiggle {
  0%,
  100% {
    transform: rotate(0deg);
  }
  22% {
    transform: rotate(-4deg) scale(1.03);
  }
  60% {
    transform: rotate(4deg) scale(1.03);
  }
}
@keyframes hop {
  0%,
  100% {
    transform: translateY(0);
  }
  40% {
    transform: translateY(-12px);
  }
  70% {
    transform: translateY(0) scaleY(0.94);
  }
}

/* 浮层:气泡 / 盖章 / 爱心 */
.bubble-layer,
.stamp-layer,
.heart-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.speech {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  max-width: 78%;
  padding: 9px 14px;
  font-family: var(--font-hand);
  font-size: 14.5px;
  line-height: 1.4;
  color: var(--ink);
  background: #fffdf6;
  border: 2.5px solid var(--ink);
  border-radius: 16px 18px 16px 6px;
  box-shadow: var(--shadow-soft);
  animation: speech-pop 0.34s cubic-bezier(0.34, 1.5, 0.5, 1);
  text-wrap: pretty;
}
.speech::after {
  content: "";
  position: absolute;
  left: 28px;
  bottom: -11px;
  width: 14px;
  height: 14px;
  background: #fffdf6;
  border-right: 2.5px solid var(--ink);
  border-bottom: 2.5px solid var(--ink);
  transform: rotate(40deg);
}
.speech.is-out {
  animation: speech-out 0.3s ease forwards;
}
@keyframes speech-pop {
  from {
    opacity: 0;
    transform: translate(-50%, 8px) scale(0.8);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0) scale(1);
  }
}
@keyframes speech-out {
  to {
    opacity: 0;
    transform: translate(-50%, -6px) scale(0.92);
  }
}

.stamp {
  position: absolute;
  top: 8px;
  right: 12px;
  width: 92px;
  height: 92px;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  filter: drop-shadow(0 3px 5px rgba(74, 50, 22, 0.28));
  animation: stamp-in 0.9s cubic-bezier(0.3, 1.5, 0.5, 1) forwards;
}
@keyframes stamp-in {
  0% {
    opacity: 0;
    transform: rotate(-22deg) scale(1.7);
  }
  18% {
    opacity: 1;
    transform: rotate(8deg) scale(0.92);
  }
  30% {
    transform: rotate(-4deg) scale(1.02);
  }
  40% {
    transform: rotate(0deg) scale(1);
  }
  82% {
    opacity: 1;
    transform: rotate(0deg) scale(1);
  }
  100% {
    opacity: 0;
    transform: rotate(0deg) scale(0.9) translateY(-8px);
  }
}

.heart {
  position: absolute;
  bottom: 40%;
  font-size: 20px;
  color: var(--coral);
  animation: heart-float 1.1s ease-out forwards;
}
@keyframes heart-float {
  0% {
    opacity: 0;
    transform: translateY(0) scale(0.4);
  }
  20% {
    opacity: 1;
    transform: translateY(-12px) scale(1);
  }
  100% {
    opacity: 0;
    transform: translateY(-78px) scale(0.7) rotate(12deg);
  }
}

/* 舞台浮动控件 */
.scene-toggle {
  position: absolute;
  top: 12px;
  left: 12px;
  display: flex;
  gap: 0;
  border: 2.5px solid var(--ink);
  border-radius: 12px;
  overflow: hidden;
  background: rgba(252, 244, 225, 0.84);
  backdrop-filter: blur(4px);
  z-index: 4;
}
.scene-toggle button {
  font-family: var(--font-hand);
  font-size: 13px;
  border: 0;
  background: transparent;
  color: var(--ink-soft);
  padding: 5px 12px;
  cursor: pointer;
}
.scene-toggle button.on {
  background: var(--ink);
  color: #fff4dd;
}

.meters {
  position: absolute;
  top: 12px;
  right: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-end;
  z-index: 4;
}
.meter {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 9px 4px 7px;
  background: rgba(252, 244, 225, 0.86);
  border: 2px solid var(--ink);
  border-radius: 13px;
  backdrop-filter: blur(4px);
}
.meter .m-ico {
  width: 15px;
  height: 15px;
  display: grid;
  place-items: center;
  font-size: 12px;
}
.meter .m-track {
  width: 56px;
  height: 8px;
  border-radius: 5px;
  background: rgba(42, 32, 24, 0.12);
  overflow: hidden;
  border: 1.5px solid var(--ink);
}

.feed-dock {
  position: absolute;
  right: 12px;
  bottom: 14px;
  z-index: 5;
}
.feed-menu {
  position: absolute;
  right: 0;
  bottom: 52px;
  display: grid;
  grid-template-columns: repeat(2, 42px);
  gap: 7px;
  animation: feed-menu-in 0.18s cubic-bezier(0.34, 1.35, 0.5, 1) both;
}
.feed-toggle,
.food-dot {
  display: grid;
  place-items: center;
  border: 2.5px solid var(--ink);
  border-radius: 50%;
  cursor: pointer;
  backdrop-filter: blur(4px);
  transition:
    transform 0.13s ease,
    background 0.15s ease,
    box-shadow 0.13s ease;
}
.feed-toggle {
  width: 46px;
  height: 46px;
  background: var(--ink);
  box-shadow: 0 4px 0 rgba(42, 32, 24, 0.18);
}
.feed-toggle .food-ico {
  width: 28px;
  height: 28px;
  filter: drop-shadow(0 1px 0 rgba(255, 255, 255, 0.5));
}
.food-dot {
  width: 42px;
  height: 42px;
  background: rgba(255, 253, 247, 0.9);
  box-shadow: 0 4px 0 rgba(42, 32, 24, 0.16);
}
.feed-toggle:hover,
.food-dot:hover {
  background: #fff;
  transform: translateY(-2px);
  box-shadow: 0 6px 0 rgba(42, 32, 24, 0.14);
}
.feed-toggle:hover {
  background: #2f251d;
}
.feed-toggle:active,
.food-dot:active {
  transform: translateY(2px) scale(0.96);
  box-shadow: 0 2px 0 rgba(42, 32, 24, 0.18);
}
.feed-toggle:disabled,
.food-dot.cooldown,
.food-dot:disabled {
  opacity: 0.45;
  cursor: wait;
}
.food-dot .food-ico {
  width: 26px;
  height: 26px;
}
@keyframes feed-menu-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.92);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}
.meter .m-fill {
  height: 100%;
  border-radius: 5px;
  transition: width 0.5s ease;
}
.meter.energy .m-fill {
  background: var(--sage);
}
.meter.fullness .m-fill {
  background: var(--honey);
}
.meter.mood .m-fill {
  background: var(--blush);
}
.meter.is-low {
  animation: meter-warn 1.1s ease-in-out infinite;
}
@keyframes meter-warn {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(232, 116, 106, 0);
  }
  50% {
    box-shadow: 0 0 0 3px rgba(232, 116, 106, 0.4);
  }
}

/* ============================================================
   聊天(核心大面积)
   ============================================================ */
.chat {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 11px;
  padding: 16px 15px 8px;
  scrollbar-width: thin;
  scrollbar-color: var(--kraft-deep) transparent;
  background:
    radial-gradient(
      120% 60% at 50% 0%,
      rgba(255, 250, 238, 0.7),
      transparent 60%
    ),
    #fbf3df;
}
.chat::-webkit-scrollbar {
  width: 7px;
}
.chat::-webkit-scrollbar-thumb {
  background: var(--kraft-deep);
  border-radius: 6px;
}

.day-sep {
  align-self: center;
  font-size: 11px;
  color: var(--ink-faint);
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 1px 0 3px;
}

.msg {
  max-width: 84%;
  padding: 10px 13px;
  font-size: 14.5px;
  line-height: 1.5;
  word-break: break-word;
  text-wrap: pretty;
  border: 2.5px solid var(--ink);
  animation: msg-in 0.26s cubic-bezier(0.34, 1.4, 0.5, 1) both;
}
@keyframes msg-in {
  from {
    opacity: 0;
    transform: translateY(7px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}
.msg.pet {
  align-self: flex-start;
  background: #fffdf6;
  border-radius: 18px 18px 18px 6px;
  box-shadow: var(--shadow-soft);
}
.msg.user {
  align-self: flex-end;
  background: var(--ink);
  color: #fdf5e3;
  border-radius: 18px 18px 6px 18px;
}
.msg.fallback {
  background: #fff2cf;
}
.msg.typing {
  display: inline-flex;
  gap: 5px;
  align-items: center;
}
.msg.typing i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ink-soft);
  animation: dot 1s infinite ease-in-out;
}
.msg.typing i:nth-child(2) {
  animation-delay: 0.15s;
}
.msg.typing i:nth-child(3) {
  animation-delay: 0.3s;
}
@keyframes dot {
  0%,
  60%,
  100% {
    transform: translateY(0);
    opacity: 0.5;
  }
  30% {
    transform: translateY(-5px);
    opacity: 1;
  }
}

.msg-photo {
  display: block;
  max-width: 180px;
  border-radius: 12px;
  border: 2px solid rgba(253, 245, 227, 0.4);
  margin-bottom: 5px;
}
.msg.user .msg-photo {
  border-color: rgba(253, 245, 227, 0.4);
}

.mem-chip {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--coral-deep);
  background: #fff0ec;
  border: 2px dashed var(--coral);
  border-radius: 11px;
  padding: 4px 10px;
  animation: msg-in 0.3s ease both;
}

/* 升级 / 成就 横幅 */
.toast-line {
  align-self: center;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: var(--font-hand);
  font-size: 13px;
  color: var(--coral-deep);
  background: linear-gradient(180deg, #fff4ec, #ffe8e0);
  border: 2.5px solid var(--coral);
  border-radius: 14px 16px 13px 15px;
  padding: 6px 14px;
  box-shadow: var(--shadow-soft);
  animation: msg-in 0.34s cubic-bezier(0.34, 1.5, 0.5, 1) both;
}

/* ============================================================
   底部:投喂 + 快捷 + 输入
   ============================================================ */
.composer {
  flex: 0 0 auto;
  border-top: 2.5px solid var(--ink);
  background: linear-gradient(
    180deg,
    rgba(247, 236, 208, 0.96),
    rgba(244, 231, 199, 0.98)
  );
  padding: 9px 13px calc(10px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.tray-label {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 11px;
  font-weight: 700;
  color: var(--ink-faint);
  letter-spacing: 0.05em;
}
.tray-label::before,
.tray-label::after {
  content: "";
  flex: 1;
  height: 0;
  border-top: 2px dashed var(--line);
}

.quick-row {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  scrollbar-width: none;
}
.quick-row::-webkit-scrollbar {
  display: none;
}
.category-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 7px;
}
.chip {
  font-family: var(--font-hand);
  font-size: 12.5px;
  color: var(--ink);
  background: #fff;
  border: 2px solid var(--ink);
  border-radius: 11px 13px 10px 12px;
  padding: 5px 10px;
  cursor: pointer;
  white-space: nowrap;
  transition:
    transform 0.12s ease,
    background 0.15s ease;
}
.chip:hover {
  background: #fff6e3;
}
.chip:active {
  transform: translateY(1px);
}
.chip.selected {
  background: var(--ink);
  color: #fdf5e3;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.18);
}
.chip.accent {
  background: #fff0ec;
  border-color: var(--coral);
  color: var(--coral-deep);
}
.chip.accent.selected {
  color: #fff7ec;
  background: var(--coral);
}
.chip.photo-chip {
  background: #eef4f7;
  border-color: var(--sky);
  color: #4d7689;
}
.category-hint {
  min-height: 16px;
  margin: -3px 2px 0;
  color: var(--ink-faint);
  font-size: 11.5px;
  line-height: 1.3;
}

.input-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.input-row input[type="text"] {
  flex: 1 1 auto;
  min-width: 0;
  height: 44px;
  padding: 0 14px;
  font: inherit;
  font-size: 15px;
  color: var(--ink);
  background: #fffdf7;
  border: 2.5px solid var(--ink);
  border-radius: 14px;
}
.input-row input::placeholder {
  color: var(--ink-faint);
}
.input-row input:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(126, 168, 189, 0.35);
}
.send-btn,
.photo-btn {
  flex: 0 0 auto;
  height: 44px;
  border: 2.5px solid var(--ink);
  border-radius: 14px;
  cursor: pointer;
  background: var(--ink);
  color: #fdf5e3;
  font-family: var(--font-hand);
  font-size: 15px;
  display: grid;
  place-items: center;
  transition: transform 0.12s ease;
}
.send-btn {
  padding: 0 17px;
}
.photo-btn {
  width: 44px;
  background: var(--paper);
  color: var(--ink);
}
.photo-btn:hover {
  background: #fff;
}
.send-btn:active,
.photo-btn:active {
  transform: translateY(2px);
}
.send-btn:disabled,
.input-row input:disabled {
  opacity: 0.55;
  cursor: wait;
}

.msg-tag {
  display: inline-flex;
  align-items: center;
  height: 20px;
  margin: 0 6px 4px 0;
  padding: 0 7px;
  border: 1.5px solid currentColor;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  opacity: 0.78;
  vertical-align: 1px;
}

/* ============================================================
   信箱 / 明信片(等待与惊喜)
   ============================================================ */
.scrim {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(56, 38, 16, 0.42);
  backdrop-filter: blur(2px);
  animation: fade 0.25s ease;
}
@keyframes fade {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.postcard {
  position: relative;
  width: min(100%, 350px);
  max-height: 90%;
  overflow-y: auto;
  background: linear-gradient(180deg, #fdf6e6, #f7ead0);
  border: 2.5px solid var(--ink);
  border-radius: 6px;
  box-shadow: var(--shadow-card);
  padding: 22px 20px 18px;
  animation: card-pop 0.4s cubic-bezier(0.34, 1.5, 0.5, 1);
  scrollbar-width: thin;
}
@keyframes card-pop {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.92) rotate(-1deg);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1) rotate(0);
  }
}
.postcard::before {
  /* 和纸胶带 */
  content: "";
  position: absolute;
  top: -11px;
  left: 50%;
  width: 116px;
  height: 26px;
  transform: translateX(-50%) rotate(-2.5deg);
  background: var(--tape);
  border: 1px dashed rgba(180, 150, 70, 0.5);
}
.postcard .pc-stamp {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 76px;
  height: 76px;
  background-size: contain;
  background-repeat: no-repeat;
  transform: rotate(7deg);
}
.pc-kicker {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--coral-deep);
  text-transform: uppercase;
}
.pc-title {
  font-family: var(--font-hand);
  font-size: 23px;
  margin: 4px 0 10px;
  max-width: 72%;
}
.pc-body {
  font-size: 14.5px;
  line-height: 1.7;
  color: var(--ink);
  text-wrap: pretty;
}
.pc-source {
  margin-top: 10px;
  padding: 8px 9px;
  border: 1.5px dashed rgba(42, 32, 24, 0.28);
  border-radius: 10px;
  background: rgba(255, 253, 246, 0.78);
  font-size: 11.5px;
  line-height: 1.45;
  color: var(--ink-faint);
}
.pc-source span {
  display: block;
  font-weight: 700;
  color: #4b6254;
}
.pc-source a,
.pc-source em,
.mi-source a,
.mi-source span {
  color: var(--ink-soft);
  font-style: normal;
  text-decoration: none;
}
.pc-effects {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin: 14px 0 16px;
}
.pc-eff {
  font-size: 12px;
  font-weight: 600;
  color: var(--sage);
  background: #f0f4e4;
  border: 2px solid var(--sage);
  border-radius: 10px;
  padding: 3px 9px;
}
.pc-eff.coral {
  color: var(--coral-deep);
  background: #fff0ec;
  border-color: var(--coral);
}
.pc-eff.honey {
  color: #b5811f;
  background: #fdf3da;
  border-color: var(--honey);
}
.pc-btn {
  width: 100%;
  height: 46px;
  border: 2.5px solid var(--ink);
  border-radius: 14px;
  background: var(--ink);
  color: #fdf5e3;
  font-family: var(--font-hand);
  font-size: 16px;
  cursor: pointer;
}
.pc-btn:active {
  transform: translateY(2px);
}

.pc-dot-nav {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-top: 12px;
}
.pc-dot-nav i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 1.5px solid var(--ink);
  background: transparent;
}
.pc-dot-nav i.on {
  background: var(--ink);
}

/* 信箱列表 */
.mailbox {
  width: min(100%, 360px);
  max-height: 86%;
  overflow-y: auto;
  background: var(--paper);
  border: 2.5px solid var(--ink);
  border-radius: 18px;
  box-shadow: var(--shadow-card);
  animation: card-pop 0.35s cubic-bezier(0.34, 1.5, 0.5, 1);
}
.mailbox-head {
  position: sticky;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--paper-2);
  border-bottom: 2.5px solid var(--ink);
}
.mailbox-head h3 {
  margin: 0;
  font-family: var(--font-hand);
  font-size: 19px;
}
.mailbox-list {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.mail-item {
  display: flex;
  gap: 10px;
  padding: 11px;
  background: #fffdf6;
  border: 2px solid var(--ink);
  border-radius: 14px;
}
.mail-item .mi-stamp {
  flex: 0 0 auto;
  width: 46px;
  height: 46px;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
}
.mail-item .mi-title {
  font-family: var(--font-hand);
  font-size: 15px;
}
.mail-item .mi-kicker {
  margin-bottom: 2px;
  font-size: 10.5px;
  font-weight: 800;
  color: #4b6254;
}
.mail-item .mi-body {
  font-size: 12.5px;
  color: var(--ink-soft);
  line-height: 1.5;
  margin-top: 2px;
}
.mail-item .mi-source {
  margin-top: 6px;
  font-size: 11px;
  line-height: 1.35;
}
.mail-empty {
  text-align: center;
  color: var(--ink-faint);
  font-size: 13px;
  padding: 30px 10px;
}

/* 进场 */
.app-enter {
  animation: app-in 0.5s ease both;
}
@keyframes app-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
  }
  .cat-breathe,
  .cat-shadow {
    animation: none;
  }
}
