:root {
  --ink: #5b4a52;
  --ink-soft: #9a8890;
  --card: #fffdfb;
  --line: #f2e3e6;
  --pink: #ff8fab;
  --pink-deep: #f26d91;
  --pink-soft: #ffe3ea;
  --shadow: 0 10px 30px rgba(186, 120, 140, 0.18), 0 2px 6px rgba(186, 120, 140, 0.12);
  --r: 22px;
  font-family: "Fredoka", "ZCOOL KuaiLe", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  color: var(--ink);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body {
  background:
    radial-gradient(1200px 700px at 15% 10%, #fff0f5 0%, transparent 60%),
    radial-gradient(900px 600px at 90% 90%, #e6f4ff 0%, transparent 60%),
    linear-gradient(160deg, #ffeef3 0%, #f3ecff 50%, #e7f5ff 100%);
  -webkit-tap-highlight-color: transparent;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }

#world { position: fixed; inset: 0; }
#world canvas { display: block; touch-action: none; }
.labels { position: absolute; inset: 0; pointer-events: none; }

/* ---------- 3D 里的标签 ---------- */
.room-tag {
  pointer-events: auto; cursor: pointer;
  display: flex; align-items: center; gap: 6px;
  padding: 6px 14px; border-radius: 999px;
  background: var(--card); box-shadow: var(--shadow);
  font-family: "ZCOOL KuaiLe", "Fredoka", sans-serif; font-size: 16px; white-space: nowrap;
  transition: transform .2s;
}
.room-tag:hover { transform: translateY(-2px) scale(1.04); }
.room-tag.active { background: var(--pink); color: #fff; }
.room-badge { display: none; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px;
  background: var(--pink-deep); color: #fff; font: 600 12px/20px "Fredoka", sans-serif; text-align: center; }
.room-badge.on { display: inline-block; }
.room-tag.active .room-badge { background: #fff; color: var(--pink-deep); }
.av-name { padding: 2px 8px; border-radius: 999px; background: rgba(255,255,255,.88);
  font-size: 12px; font-weight: 600; white-space: nowrap; }
.av-name.me { background: var(--pink); color: #fff; }
.bubble { max-width: 180px; padding: 7px 11px; border-radius: 16px 16px 16px 4px;
  background: #fff; box-shadow: var(--shadow); font-size: 13px; line-height: 1.35;
  opacity: 0; transform: translateY(6px) scale(.9); transition: opacity .25s, transform .25s; word-break: break-word; }
.bubble.show { opacity: 1; transform: none; }

/* ---------- 顶栏 ---------- */
.top { position: fixed; top: 0; left: 0; right: 0; display: flex; align-items: center; gap: 10px;
  padding: max(14px, env(safe-area-inset-top)) 16px 14px; pointer-events: none; z-index: 5; }
.top > * { pointer-events: auto; }
.brand { font-family: "Fredoka", sans-serif; font-weight: 700; font-size: 22px; letter-spacing: .3px;
  color: var(--pink-deep); text-shadow: 0 2px 0 #fff; margin-right: auto; }
.chip { display: inline-flex; align-items: center; gap: 7px; padding: 7px 13px 7px 8px; border-radius: 999px;
  background: var(--card); box-shadow: var(--shadow); font-weight: 600; }
.dot { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: 13px; }
.btn { padding: 9px 16px; border-radius: 999px; font-weight: 600; transition: transform .12s, background .15s; }
.btn:active { transform: scale(.95); }
.btn.primary { background: var(--pink); color: #fff; box-shadow: 0 4px 0 var(--pink-deep); }
.btn.primary:hover { background: #ff9db6; }
.btn.soft { background: var(--pink-soft); color: var(--pink-deep); }
.btn.danger { background: #ffe1df; color: #e0574f; }
.btn.wide { width: 100%; }
.icon { width: 34px; height: 34px; border-radius: 50%; font-size: 16px; color: var(--ink-soft); }
.icon:hover { background: var(--pink-soft); color: var(--pink-deep); }

/* ---------- 空状态 ---------- */
.empty { position: fixed; inset: 0; display: grid; place-items: center; z-index: 3; pointer-events: none; }
.empty-card { pointer-events: auto; text-align: center; padding: 26px 34px; border-radius: 28px; background: var(--card); box-shadow: var(--shadow); }
.empty-emoji { font-size: 46px; animation: bob 2.4s ease-in-out infinite; }
.empty-title { font-family: "ZCOOL KuaiLe", sans-serif; font-size: 20px; margin: 6px 0 14px; }
@keyframes bob { 50% { transform: translateY(-6px); } }

/* ---------- 底部房间列 ---------- */
.dock { position: fixed; left: 50%; bottom: max(16px, env(safe-area-inset-bottom)); transform: translateX(-50%);
  display: flex; gap: 8px; padding: 8px; border-radius: 999px; background: rgba(255,253,251,.75);
  backdrop-filter: blur(10px); box-shadow: var(--shadow); max-width: calc(100vw - 32px); overflow-x: auto; z-index: 4; scrollbar-width: none; }
.dock:empty { display: none; }
.dock .chip { box-shadow: none; flex: none; position: relative; }
.dock .chip.active { background: var(--pink); color: #fff; }
.dock .n { font-size: 12px; opacity: .7; }
.dock .badge { position: absolute; top: -4px; right: -4px; min-width: 18px; height: 18px; border-radius: 9px; padding: 0 5px;
  background: var(--pink-deep); color: #fff; font-size: 11px; line-height: 18px; text-align: center; }

/* ---------- 房间面板 ---------- */
.panel { position: fixed; top: 76px; right: 16px; bottom: 16px; width: 360px; display: flex; flex-direction: column;
  border-radius: var(--r); background: var(--card); box-shadow: var(--shadow); z-index: 6; overflow: hidden;
  animation: slide .28s cubic-bezier(.2,.9,.3,1.2); }
@keyframes slide { from { transform: translateX(30px); opacity: 0; } }
.p-head { display: flex; align-items: center; gap: 8px; padding: 14px 10px 10px 16px; }
.p-dot { width: 14px; height: 14px; border-radius: 5px; transform: rotate(45deg); }
.p-head h2 { margin: 0 auto 0 0; font: 22px "ZCOOL KuaiLe", "Fredoka", sans-serif; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu { position: absolute; top: 54px; right: 14px; z-index: 2; display: flex; flex-direction: column; gap: 4px; padding: 8px;
  border-radius: 16px; background: #fff; box-shadow: var(--shadow); }
.menu button { text-align: left; padding: 8px 14px; border-radius: 10px; font-weight: 500; }
.menu button:hover { background: var(--pink-soft); }
.menu .warn { color: #e0574f; }
.people { display: flex; gap: 6px; flex-wrap: wrap; padding: 0 16px 10px; border-bottom: 2px dashed var(--line); }
.person { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px 3px 3px; border-radius: 999px;
  background: #faf4f5; font-size: 13px; font-weight: 500; }
.person.off { opacity: .45; }
.person .dot { width: 20px; height: 20px; font-size: 11px; }
.person .x { display: none; margin-left: 2px; color: var(--ink-soft); font-size: 11px; }
.person:hover .x { display: inline; }
.msgs { flex: 1; overflow-y: auto; padding: 14px 14px 6px; display: flex; flex-direction: column; gap: 10px; }
.msg { display: flex; gap: 8px; align-items: flex-end; max-width: 88%; animation: pop .25s ease-out; }
@keyframes pop { from { transform: scale(.9); opacity: 0; } }
.msg .dot { flex: none; }
.msg .b { padding: 8px 12px; border-radius: 16px 16px 16px 5px; background: #f6eff1; line-height: 1.4; word-break: break-word; white-space: pre-wrap; }
.msg .meta { font-size: 11px; color: var(--ink-soft); margin: 0 0 3px 4px; }
.msg.mine { align-self: flex-end; flex-direction: row-reverse; }
.msg.mine .b { background: var(--pink); color: #fff; border-radius: 16px 16px 5px 16px; }
.msg.mine .meta { text-align: right; margin: 0 4px 3px 0; }
.composer { display: flex; gap: 8px; padding: 10px 12px; }
.composer input { flex: 1; min-width: 0; padding: 10px 14px; border-radius: 999px; border: 2px solid var(--line); background: #fff; outline: none; }
.composer input:focus { border-color: var(--pink); }
.p-foot { display: flex; gap: 8px; padding: 0 12px 12px; }
.p-foot .btn { flex: 1; }

/* ---------- 对话框 ---------- */
.dlg { border: 0; padding: 0; border-radius: 26px; background: var(--card); box-shadow: var(--shadow); width: min(360px, calc(100vw - 32px)); color: var(--ink); }
.dlg::backdrop { background: rgba(255, 220, 230, .45); backdrop-filter: blur(4px); }
.dlg form { display: flex; flex-direction: column; gap: 14px; padding: 22px; }
.dlg h3 { margin: 0; font: 22px "ZCOOL KuaiLe", "Fredoka", sans-serif; text-align: center; }
.dlg input { padding: 11px 16px; border-radius: 14px; border: 2px solid var(--line); outline: none; text-align: center; font-size: 17px; }
.dlg input:focus { border-color: var(--pink); }
.dlg .row { display: flex; gap: 10px; }
.dlg .row .btn { flex: 1; }
.preview { display: grid; place-items: center; }
.pv-ava { width: 72px; height: 72px; border-radius: 50%; display: grid; place-items: center; font-size: 38px; box-shadow: inset 0 -6px 0 rgba(0,0,0,.06); transition: background .2s; }
.kinds, .swatches { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; }
.kinds button { width: 52px; height: 52px; border-radius: 16px; background: #faf4f5; font-size: 26px; transition: transform .12s; }
.kinds button.on { background: var(--pink-soft); box-shadow: inset 0 0 0 3px var(--pink); transform: scale(1.06); }
.swatches button { width: 32px; height: 32px; border-radius: 50%; box-shadow: inset 0 -3px 0 rgba(0,0,0,.08); transition: transform .12s; }
.swatches button.on { transform: scale(1.18); box-shadow: 0 0 0 3px #fff, 0 0 0 5px var(--pink); }
.themes button { border-radius: 10px; }

.toast { position: fixed; left: 50%; top: 80px; transform: translate(-50%, -10px); padding: 10px 18px; border-radius: 999px;
  background: var(--ink); color: #fff; font-weight: 500; opacity: 0; pointer-events: none; transition: .25s; z-index: 20; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 720px) {
  .panel { top: auto; left: 0; right: 0; bottom: 0; width: auto; height: 64vh; border-radius: 26px 26px 0 0;
    animation-name: rise; padding-bottom: env(safe-area-inset-bottom); }
  @keyframes rise { from { transform: translateY(40px); opacity: 0; } }
  body.panel-open .dock { display: none; }
  .brand { font-size: 19px; }
}
