/* ============================================================
   Messages — conversation list + chat
   ============================================================ */
:root {
  --msg-ink: #2f2748;
  --msg-soft: #6e6384;
  --msg-muted: #9b8da9;
  --msg-pink: #ff8fc7;
  --msg-gutter: 14px;
  --msg-font: "Segoe UI Variable Display", "Manrope", "HarmonyOS Sans SC", "PingFang SC", "Microsoft YaHei UI", "Microsoft YaHei", system-ui, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { background: #fff8fc !important; }
body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  padding-bottom: calc(78px + env(safe-area-inset-bottom));
  color: var(--msg-ink);
  background:
    radial-gradient(circle at 8% -6%, rgba(255, 177, 211, .5), transparent 24rem),
    radial-gradient(circle at 96% 1%, rgba(184, 218, 255, .62), transparent 26rem),
    radial-gradient(circle at 50% 109%, rgba(226, 211, 255, .5), transparent 30rem),
    linear-gradient(180deg, #fff9fd 0%, #fbfbff 52%, #fff8f2 100%);
  font-family: var(--msg-font);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button, textarea { font: inherit; }
img { max-width: 100%; }
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  min-height: 58px; padding: 0 max(var(--msg-gutter), env(safe-area-inset-left)) 0 max(var(--msg-gutter), env(safe-area-inset-right));
  background: rgba(255, 250, 253, .86);
  border-bottom: 1px solid rgba(104, 80, 132, .12);
  -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px);
}
.brand { display: flex; align-items: center; gap: 8px; min-width: 0; }
.brand img { width: 32px; height: 32px; flex: none; object-fit: contain; }
.brand span { display: flex; flex-direction: column; min-width: 0; color: #3b2a50; font-size: 10.5px; font-weight: 800; line-height: 1.25; letter-spacing: -.02em; }
.brand small { margin-top: 1px; color: #9a83a9; font-size: 6px; font-weight: 600; letter-spacing: .14em; }
.page-tag { flex: none; padding: 4px 8px; color: #8e4e82; background: #fff2f9; border: 1px solid #f0d3e4; border-radius: 999px; font-size: 6.5px; font-weight: 700; }
.personal-bar {
  display: flex; align-items: center; justify-content: center; gap: 4px;
  padding: 7px 12px; color: #7a688c; background: rgba(255,255,255,.5);
  border-bottom: 1px solid rgba(126,101,166,.1); font-size: 7px; line-height: 1.5; text-align: center;
}
.personal-bar strong { color: #a84e88; font-weight: 600; }
.messages-shell { width: min(100%, 720px); margin: 0 auto; padding: 14px var(--msg-gutter) 20px; }
.messages-hero { position: relative; overflow: hidden; margin-bottom: 12px; padding: 17px 16px; background: linear-gradient(135deg,#ffe1ee,#e9e4ff 54%,#dcf1ff); border: 1px solid #fff; border-radius: 20px; box-shadow: 0 14px 34px rgba(107,78,137,.1); }
.messages-hero::after { content: "✦"; position: absolute; right: 18px; top: 12px; color: #fff; font-size: 20px; }
.messages-kicker { margin: 0; color: #a35b8b; font-size: 6px; font-weight: 800; letter-spacing: .18em; }
.messages-hero h1 { margin: 4px 0 0; color: #3b2a50; font-size: 27px; font-weight: 900; letter-spacing: -.05em; line-height: 1.1; }
.messages-hero p { margin: 5px 0 0; color: #796787; font-size: 8px; line-height: 1.7; }
.messages-hero strong { color: #c04688; }
.messages-tools { display: flex; justify-content: flex-end; margin: -2px 0 8px; }
.msg-refresh { min-height: 30px; padding: 4px 10px; color: #8b5a89; background: rgba(255,255,255,.72); border: 1px solid #efd8e7; border-radius: 999px; font-size: 7px; font-weight: 600; cursor: pointer; }
.conversation-list { display: grid; gap: 7px; }
.conversation-row {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 11px; color: #4c3b5f; background: rgba(255,255,255,.83);
  border: 1px solid #fff; border-radius: 14px; box-shadow: 0 8px 22px rgba(100,73,132,.07);
  text-align: left; cursor: pointer; transition: transform .18s ease, box-shadow .18s ease;
}
.conversation-row:active { transform: scale(.99); }
.conv-avatar { position: relative; width: 43px; height: 43px; flex: none; }
.conv-avatar img { width: 100%; height: 100%; display: block; object-fit: cover; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 4px 12px rgba(94,64,122,.13); }
.conv-copy { min-width: 0; flex: 1; }
.conv-copy strong { display: block; color: #3b2a50; font-size: 10px; font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-copy p { margin: 2px 0 0; color: #8b7a98; font-size: 7.5px; line-height: 1.5; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-meta { flex: none; align-self: flex-start; padding-top: 2px; color: #a28fa8; font-size: 6px; text-align: right; }
.conv-unread { display: block; width: 7px; height: 7px; margin: 5px 0 0 auto; border-radius: 50%; background: #ff5e9d; box-shadow: 0 0 0 3px rgba(255,94,157,.12); }
.conv-empty { padding: 34px 16px; color: #95829f; background: rgba(255,255,255,.55); border: 1px dashed #ead6e5; border-radius: 16px; text-align: center; font-size: 8.5px; line-height: 1.9; }
.conv-empty strong { display: block; margin-bottom: 3px; color: #4d395f; font-size: 14px; font-weight: 800; }

/* chat */
.chat-view { display: flex; flex-direction: column; min-height: calc(100vh - 190px); }
.chat-head { position: sticky; top: 58px; z-index: 20; display: flex; align-items: center; gap: 9px; margin: -4px 0 8px; padding: 9px 10px; background: rgba(255,250,253,.9); border: 1px solid #fff; border-radius: 14px; box-shadow: 0 8px 20px rgba(100,73,132,.08); -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px); }
.chat-back { width: 29px; height: 29px; flex: none; color: #9c5b8a; background: #fff2f9; border: 1px solid #f0d6e6; border-radius: 50%; font-size: 16px; line-height: 1; cursor: pointer; }
.chat-head-avatar { width: 35px; height: 35px; flex: none; overflow: hidden; border-radius: 50%; border: 2px solid #fff; background: #ffe4ef; }
.chat-head-avatar img { width: 100%; height: 100%; display: block; object-fit: cover; }
.chat-head-copy { min-width: 0; flex: 1; }
.chat-head-copy strong { display: block; color: #3b2a50; font-size: 10px; font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-head-copy small { display: block; color: #a08ca7; font-size: 6.5px; }
.chat-messages { display: flex; flex: 1; flex-direction: column; gap: 7px; min-height: 280px; padding: 5px 2px 11px; overflow-y: auto; }
.chat-day { align-self: center; margin: 3px 0; padding: 2px 7px; color: #a18da8; background: rgba(255,255,255,.55); border-radius: 999px; font-size: 5.5px; }
.chat-bubble { max-width: 78%; display: flex; flex-direction: column; gap: 2px; padding: 8px 10px; border-radius: 13px; font-size: 9px; line-height: 1.65; overflow-wrap: anywhere; }
.chat-bubble span { white-space: pre-wrap; }
.chat-bubble small { color: rgba(82,59,94,.48); font-size: 5.5px; }
.chat-bubble.mine { align-self: flex-end; color: #fff; background: linear-gradient(135deg,#ff87bf,#a57fff); border-bottom-right-radius: 4px; }
.chat-bubble.mine small { color: rgba(255,255,255,.7); }
.chat-bubble.theirs { align-self: flex-start; color: #4d3b60; background: #fff; border: 1px solid #f4e0ec; border-bottom-left-radius: 4px; box-shadow: 0 4px 12px rgba(100,73,132,.05); }
.chat-empty { align-self: center; margin-top: 24px; color: #9b87a3; text-align: center; font-size: 8px; line-height: 1.8; }
.chat-composer { position: sticky; bottom: calc(72px + env(safe-area-inset-bottom)); z-index: 18; display: flex; gap: 6px; margin-top: 4px; padding: 7px; background: rgba(255,250,253,.94); border: 1px solid #fff; border-radius: 15px; box-shadow: 0 10px 28px rgba(92,64,119,.13); -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px); }
.chat-composer textarea { flex: 1; min-width: 0; min-height: 38px; max-height: 100px; resize: none; padding: 7px 9px; color: #3b2a50; background: #fff; border: 1px solid #efd7e7; border-radius: 9px; outline: none; font-size: 9px; }
.chat-send { flex: none; min-width: 56px; color: #fff; background: linear-gradient(135deg,#ff87bf,#a57fff); border: 0; border-radius: 9px; font-size: 8px; font-weight: 700; cursor: pointer; }
.chat-send:disabled { opacity: .55; }
.msg-toast { position: fixed; left: 50%; bottom: calc(88px + env(safe-area-inset-bottom)); z-index: 80; transform: translate(-50%,10px); max-width: calc(100% - 28px); padding: 8px 13px; color: #fff; background: rgba(58,37,73,.92); border-radius: 999px; font-size: 8px; opacity: 0; pointer-events: none; transition: .2s ease; }
.msg-toast.is-visible { opacity: 1; transform: translate(-50%,0); }

/* dock */
.app-dock { position: fixed; left: 50%; bottom: max(10px, env(safe-area-inset-bottom)); z-index: 80; transform: translateX(-50%); display: grid; grid-template-columns: repeat(6, 1fr); width: min(calc(100% - 18px), 480px); padding: 5px; background: rgba(255,251,253,.9); border: 1px solid rgba(255,255,255,.96); border-radius: 18px; box-shadow: 0 12px 32px rgba(103,76,136,.18); -webkit-backdrop-filter: blur(18px); backdrop-filter: blur(18px); }
.app-dock-link { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; min-height: 40px; padding: 4px 2px 3px; color: #927f9f; border-radius: 12px; font-size: 7.5px; line-height: 1.15; }
.app-dock-link .icon { width: 14px; height: 14px; }
.app-dock-link.is-active { color: #4d2f62; background: linear-gradient(135deg,#ffe0ef,#eae1ff); font-weight: 700; }
.app-dock-link.is-active::after { content: ""; position: absolute; top: 3px; left: 50%; width: 3px; height: 3px; transform: translateX(-50%); border-radius: 50%; background: #b84f8a; }
.dock-badge { position: absolute; top: 3px; right: calc(50% - 15px); min-width: 12px; height: 12px; padding: 0 3px; color: #fff; background: #ff5e9d; border-radius: 999px; font-size: 5.5px; font-style: normal; line-height: 12px; text-align: center; }
@media (max-width: 380px) {
  .messages-shell { padding: 11px 10px 18px; }
  .messages-hero h1 { font-size: 24px; }
  .conversation-row { padding: 9px; }
  .app-dock { width: calc(100% - 12px); }
  .app-dock-link { font-size: 7px; }
  .chat-head { top: 54px; }
}
