:root {
  --bg: #0a0810;
  --bg2: #12101a;
  --panel: #16121f;
  --panel2: #1c1728;
  --line: rgba(255, 214, 180, 0.08);
  --line2: rgba(240, 168, 208, 0.12);
  --text: #f8f2fa;
  --muted: #9a8fa8;
  --muted2: #6f647a;
  --rose: #f0a8d0;
  --rose2: #e08ab8;
  --gold: #e8c9a0;
  --gold2: #c9a87a;
  --ok: #8fd6a8;
  --warn: #e8c07a;
  --danger: #f0a0b0;
  --bubble-me: linear-gradient(145deg, #7a4d8a 0%, #5c356e 55%, #4a2c5c 100%);
  --bubble-her: #221c2c;
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.35);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-width: 480px;
  margin: 0 auto;
  background:
    radial-gradient(900px 420px at 50% -8%, rgba(224, 138, 184, 0.14), transparent 55%),
    radial-gradient(600px 300px at 100% 30%, rgba(232, 201, 160, 0.05), transparent 50%),
    var(--bg);
}

/* —— 顶栏信息卡 —— */
.top-card {
  padding: calc(10px + var(--safe-top)) 14px 12px;
  border-bottom: 1px solid var(--line);
  background: rgba(10, 8, 16, 0.78);
  backdrop-filter: blur(18px) saturate(1.2);
  -webkit-backdrop-filter: blur(18px) saturate(1.2);
  position: sticky;
  top: 0;
  z-index: 8;
}
.top-row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.avatar-wrap { position: relative; flex-shrink: 0; }
.avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(145deg, var(--rose), #7a4d8c 70%);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 16px;
  box-shadow:
    0 0 0 1px rgba(232, 201, 160, 0.25),
    0 8px 22px rgba(240, 168, 208, 0.28);
  transition: transform 0.25s ease;
}
.avatar.pulse { animation: softpulse 1.25s ease-in-out infinite; }
@keyframes softpulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.04); }
}
.dot {
  position: absolute;
  right: 1px;
  bottom: 1px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--muted2);
  border: 2px solid var(--bg);
  transition: background 0.25s ease, box-shadow 0.25s ease;
}
.dot.on {
  background: var(--ok);
  box-shadow: 0 0 0 3px rgba(143, 214, 168, 0.18);
}

.meta { flex: 1; min-width: 0; }
.name-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.name {
  font-weight: 700;
  font-size: 17px;
  letter-spacing: 0.03em;
  background: linear-gradient(90deg, #fff 0%, var(--rose) 120%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.chip {
  font-size: 10px;
  font-weight: 650;
  padding: 2px 7px;
  border-radius: 999px;
  letter-spacing: 0.02em;
}
.chip.hidden { display: none; }
.chip-gold {
  color: var(--gold);
  background: rgba(232, 201, 160, 0.12);
  border: 1px solid rgba(232, 201, 160, 0.2);
}
.chip-mute {
  color: var(--rose);
  background: rgba(240, 168, 208, 0.1);
  border: 1px solid rgba(240, 168, 208, 0.18);
}
.sub-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  min-width: 0;
  font-size: 12px;
}
.mood-line {
  color: var(--rose);
  opacity: 0.95;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 42%;
}
.sep { color: var(--muted2); }
.status {
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}
.status.on { color: var(--ok); }
.status.warn { color: var(--warn); }

.icon-btn {
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--gold);
  display: grid;
  place-items: center;
  flex-shrink: 0;
  transition: background 0.2s ease, border-color 0.2s ease;
}
.icon-btn:active {
  background: rgba(240, 168, 208, 0.1);
  border-color: var(--line2);
}

/* push banner */
.push-banner {
  display: flex;
  gap: 10px;
  align-items: center;
  margin: 10px 12px 0;
  padding: 11px 12px;
  border-radius: 16px;
  background: linear-gradient(120deg, rgba(240,168,208,0.12), rgba(232,201,160,0.08));
  border: 1px solid rgba(240, 168, 208, 0.22);
  animation: fadein 0.28s ease;
}
.push-banner.hidden { display: none; }
.push-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.push-text strong { font-size: 13px; color: var(--text); }
.push-text span { font-size: 11px; color: var(--muted); line-height: 1.35; }
.push-banner button {
  border: 0;
  border-radius: 999px;
  padding: 8px 14px;
  background: linear-gradient(145deg, var(--rose), var(--rose2));
  color: #2a1520;
  font-weight: 700;
  font-size: 13px;
  white-space: nowrap;
  box-shadow: 0 4px 14px rgba(240, 168, 208, 0.3);
}

/* thread */
.thread {
  flex: 1;
  overflow-y: auto;
  padding: 14px 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 11px;
  -webkit-overflow-scrolling: touch;
}
.day-sep {
  align-self: center;
  font-size: 11px;
  color: var(--muted2);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
  padding: 4px 12px;
  border-radius: 999px;
  margin: 2px 0;
  letter-spacing: 0.02em;
}
.row {
  display: flex;
  flex-direction: column;
  max-width: 86%;
  animation: fadein 0.22s ease;
}
@keyframes fadein {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}
.row.me { align-self: flex-end; align-items: flex-end; }
.row.her { align-self: flex-start; align-items: flex-start; }
.row.pending .bubble { opacity: 0.62; }

.bubble {
  padding: 11px 14px;
  border-radius: 20px;
  line-height: 1.48;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 15.5px;
  letter-spacing: 0.01em;
}
.row.me .bubble {
  background: var(--bubble-me);
  border-bottom-right-radius: 6px;
  color: #fff;
  box-shadow: 0 6px 18px rgba(92, 53, 110, 0.35);
}
.row.her .bubble {
  background: var(--bubble-her);
  border-bottom-left-radius: 6px;
  border: 1px solid var(--line);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
}
.row.her.proactive .bubble {
  box-shadow: 0 0 0 1px rgba(240, 168, 208, 0.28), 0 4px 16px rgba(0,0,0,0.18);
}
.bubble code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  background: rgba(0,0,0,0.28);
  padding: 1px 4px;
  border-radius: 4px;
}
.bubble pre {
  margin: 8px 0 0;
  padding: 8px;
  background: rgba(0,0,0,0.3);
  border-radius: 12px;
  overflow-x: auto;
  font-size: 12px;
  white-space: pre;
}
.time {
  font-size: 10.5px;
  color: var(--muted2);
  margin-top: 4px;
  padding: 0 4px;
}

.typing {
  padding: 0 16px 8px;
  min-height: 28px;
}
.typing.hidden { display: none; }
.typing-bubble {
  display: inline-flex;
  gap: 5px;
  align-items: center;
  padding: 11px 14px;
  border-radius: 18px;
  background: var(--bubble-her);
  border: 1px solid var(--line);
}
.typing-bubble span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--rose);
  opacity: 0.45;
  animation: bounce 1.1s infinite ease-in-out;
}
.typing-bubble span:nth-child(2) { animation-delay: 0.15s; }
.typing-bubble span:nth-child(3) { animation-delay: 0.3s; }
@keyframes bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.35; }
  40% { transform: translateY(-3px); opacity: 1; }
}

/* wechat emoji tray */
.emoji-tray {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 6px;
  padding: 10px 12px;
  border-top: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(22,18,31,0.98), rgba(12,10,18,0.98));
  max-height: 200px;
  overflow-y: auto;
  animation: slideUp 0.22s ease;
}
.emoji-tray.hidden { display: none; }
.emoji-item {
  border: 0;
  background: rgba(255,255,255,0.03);
  border-radius: 10px;
  font-size: 22px;
  padding: 8px 0;
  line-height: 1;
}
.emoji-item:active { background: rgba(240,168,208,0.14); transform: scale(0.95); }

/* stickers tray */
.sticker-tray {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  padding: 12px;
  border-top: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(22,18,31,0.98), rgba(12,10,18,0.98));
  max-height: 230px;
  overflow-y: auto;
  animation: slideUp 0.22s ease;
}
.sticker-tray.hidden { display: none; }
@keyframes slideUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}
.sticker-item {
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.03);
  border-radius: 16px;
  padding: 8px 6px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  transition: transform 0.15s ease, background 0.15s ease;
}
.sticker-item:active {
  transform: scale(0.96);
  background: rgba(240, 168, 208, 0.12);
}
.sticker-item img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: contain;
  filter: drop-shadow(0 4px 10px rgba(0,0,0,0.28));
}
.sticker-item span { font-size: 11px; color: var(--muted); }
.tray-empty {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

/* composer */
.composer-bar {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  padding: 10px 12px calc(12px + var(--safe-bottom));
  border-top: 1px solid var(--line);
  background: rgba(14, 11, 20, 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}
.tools {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}
.tool-btn {
  width: 40px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255,255,255,0.03);
  color: var(--rose);
  display: grid;
  place-items: center;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.tool-btn:active {
  background: rgba(240, 168, 208, 0.12);
  border-color: var(--line2);
}
.composer-bar textarea {
  flex: 1;
  resize: none;
  max-height: 110px;
  min-height: 42px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: var(--bg2);
  color: var(--text);
  padding: 11px 14px;
  font-size: 16px;
  outline: none;
  line-height: 1.35;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.composer-bar textarea:focus {
  border-color: rgba(240, 168, 208, 0.35);
  box-shadow: 0 0 0 3px rgba(240, 168, 208, 0.08);
}
.send-btn {
  width: 46px;
  height: 46px;
  border: 0;
  border-radius: 50%;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  color: #2a1520;
  background: linear-gradient(145deg, var(--rose) 0%, var(--rose2) 55%, #c97aab 100%);
  box-shadow:
    0 0 0 1px rgba(232, 201, 160, 0.22),
    0 8px 20px rgba(224, 138, 184, 0.35);
  transition: transform 0.15s ease, opacity 0.15s ease;
}
.send-btn:active { transform: scale(0.94); }
.send-btn:disabled { opacity: 0.45; }

/* gate */
.gate {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(700px 420px at 50% 18%, rgba(224,138,184,0.16), transparent 55%),
    rgba(6, 4, 10, 0.96);
  display: grid;
  place-items: center;
  z-index: 30;
  padding: 20px;
}
.gate.hidden { display: none; }
.gate-card {
  position: relative;
  width: min(100%, 360px);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 30px 20px 22px;
  text-align: center;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.gate-glow {
  position: absolute;
  inset: -40% -20% auto;
  height: 160px;
  background: radial-gradient(circle, rgba(240,168,208,0.18), transparent 70%);
  pointer-events: none;
}
.gate-avatar {
  width: 72px;
  height: 72px;
  margin: 0 auto 14px;
  border-radius: 50%;
  background: linear-gradient(145deg, var(--rose), #7a4d8c);
  display: grid;
  place-items: center;
  font-size: 24px;
  font-weight: 700;
  box-shadow: 0 10px 30px rgba(240,168,208,0.35);
  position: relative;
}
.gate-card h1 {
  margin: 0 0 8px;
  font-size: 28px;
  background: linear-gradient(90deg, #fff, var(--rose));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.gate-card p {
  color: var(--muted);
  margin: 0 0 18px;
  font-size: 13px;
  line-height: 1.55;
}
.gate-card input {
  width: 100%;
  padding: 13px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  margin-bottom: 12px;
  text-align: center;
}
.gate-card button {
  width: 100%;
  border: 0;
  border-radius: 14px;
  padding: 13px;
  background: linear-gradient(145deg, var(--rose), var(--rose2));
  color: #2a1520;
  font-weight: 700;
  font-size: 16px;
  box-shadow: 0 8px 22px rgba(224, 138, 184, 0.3);
}

/* sheet drawer */
.sheet {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.52);
  z-index: 20;
  display: grid;
  align-items: end;
  animation: fadein 0.18s ease;
}
.sheet.hidden { display: none; }
.sheet-card {
  background: linear-gradient(180deg, var(--panel2), var(--panel));
  border-radius: 22px 22px 0 0;
  padding: 8px 14px calc(14px + var(--safe-bottom));
  border-top: 1px solid var(--line);
  box-shadow: 0 -12px 40px rgba(0,0,0,0.4);
  max-height: min(86vh, 720px);
  overflow-y: auto;
  animation: slideUp 0.26s ease;
}
.sheet-handle {
  width: 40px;
  height: 4px;
  border-radius: 99px;
  background: rgba(255,255,255,0.14);
  margin: 6px auto 10px;
}
.sheet-head { text-align: center; margin-bottom: 10px; }
.sheet-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.04em;
}
.sheet-sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}
.sheet-group { margin-bottom: 12px; }
.group-label {
  font-size: 11px;
  color: var(--gold);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.85;
  padding: 4px 4px 8px;
}
.sheet-item {
  width: 100%;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.03);
  color: var(--text);
  border-radius: 14px;
  padding: 12px 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
  text-align: left;
  transition: background 0.15s ease;
}
.sheet-item:active { background: rgba(240, 168, 208, 0.08); }
.sheet-item.danger { color: var(--danger); }
.item-ico {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: rgba(240, 168, 208, 0.1);
  border: 1px solid var(--line2);
  display: grid;
  place-items: center;
  font-size: 14px;
  color: var(--rose);
  flex-shrink: 0;
}
.item-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.item-body strong { font-size: 14.5px; font-weight: 650; }
.item-body small { font-size: 11.5px; color: var(--muted); }
.item-chev { color: var(--muted2); font-size: 18px; }
.sheet-close {
  width: 100%;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.03);
  color: var(--muted);
  border-radius: 14px;
  padding: 13px;
  font-size: 14px;
  margin-top: 4px;
}

/* media */
.sticker {
  display: block;
  width: 148px;
  height: 148px;
  object-fit: contain;
  border-radius: 16px;
  filter: drop-shadow(0 6px 14px rgba(0,0,0,0.28));
}
.chat-img-wrap { display: block; max-width: 220px; }
.chat-img {
  display: block;
  width: 100%;
  max-height: 280px;
  object-fit: cover;
  border-radius: 16px;
  box-shadow: 0 6px 18px rgba(0,0,0,0.25);
}
.caption { margin-top: 6px; white-space: pre-wrap; }
.row.her .bubble:has(.sticker),
.row.me .bubble:has(.sticker),
.row.me .bubble:has(.chat-img),
.row.her .bubble:has(.chat-img) {
  background: transparent;
  border: 0;
  padding: 2px;
  box-shadow: none;
}
.row.me .bubble:has(.caption),
.row.her .bubble:has(.caption) {
  background: var(--bubble-her);
  padding: 8px;
  border: 1px solid var(--line);
}
.row.me .bubble:has(.caption) {
  background: var(--bubble-me);
  border: 0;
}
