/* ===================== 基础变量 ===================== */
:root {
  --primary: #6a5cff;
  --primary-2: #00c2ff;
  --accent: #ff5c8a;
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #f0f2f8;
  --text: #1f2330;
  --text-soft: #6b7180;
  --line: #e7eaf2;
  --ok: #19c37d;
  --warn: #ff9f43;
  --danger: #ff5b6e;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 10px 30px rgba(40, 50, 90, 0.12);
  --shadow-sm: 0 4px 14px rgba(40, 50, 90, 0.08);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  background: linear-gradient(160deg, #eef1fb 0%, #f7f0fb 100%);
  color: var(--text);
  display: flex;
  justify-content: center;
  align-items: stretch;
}
#app {
  width: 100%;
  max-width: 480px;
  min-height: 100vh;
  background: var(--bg);
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
}

/* ===================== 通用组件 ===================== */
button { font-family: inherit; cursor: pointer; border: none; }
.btn {
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 15px;
  font-weight: 600;
  transition: transform .08s ease, filter .15s ease, opacity .15s;
  width: 100%;
}
.btn:active { transform: scale(0.98); }
.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #fff;
  box-shadow: 0 8px 20px rgba(106, 92, 255, 0.35);
}
.btn-ghost { background: var(--surface-2); color: var(--text); }
.btn-accent { background: linear-gradient(135deg, var(--accent), #ff8fb0); color:#fff; }
.btn-danger { background: linear-gradient(135deg, #ff5b6e, #ff8a5b); color:#fff; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.input {
  width: 100%;
  border: 1.5px solid var(--line);
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 13px 14px;
  font-size: 15px;
  color: var(--text);
  outline: none;
  transition: border-color .15s;
}
.input:focus { border-color: var(--primary); }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: var(--text-soft); margin-bottom: 6px; }

/* 语言选择 */
.lang-select {
  border: 1.5px solid var(--line);
  background: var(--surface);
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 13px;
  color: var(--text);
  outline: none;
}

/* 顶部栏 */
.topbar {
  height: 56px;
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #fff;
  box-shadow: var(--shadow-sm);
  z-index: 5;
}
.topbar .tb-title { font-weight: 700; font-size: 17px; flex: 1; text-align: center; }
.topbar .tb-btn {
  background: rgba(255,255,255,0.18);
  color: #fff;
  border-radius: 10px;
  padding: 7px 10px;
  font-size: 13px;
  font-weight: 600;
}
.topbar .tb-icon {
  width: 38px; height: 38px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,0.18);
  border-radius: 12px;
  font-size: 18px;
}

/* ===================== 登录/注册 ===================== */
.auth-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 26px 22px 30px;
  overflow-y: auto;
}
.auth-head { text-align: center; margin-bottom: 18px; }
.auth-logo {
  width: 84px; height: 84px;
  margin: 6px auto 12px;
  border-radius: 26px;
  background: #fff;
  border: 3px solid #111;
  color: #111;
  display: flex; align-items: center; justify-content: center;
  font-size: 42px;
  box-shadow: 0 10px 26px rgba(0,0,0,.14);
}
.auth-head h1 { margin: 0; font-size: 26px; letter-spacing: 1px; }
.auth-head p { margin: 6px 0 0; color: var(--text-soft); font-size: 13px; }
.auth-lang { display: flex; justify-content: center; margin-bottom: 18px; }
.auth-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 22px 20px;
  box-shadow: var(--shadow-sm);
}
.auth-tabs { display: flex; background: var(--surface-2); border-radius: 12px; padding: 4px; margin-bottom: 18px; }
.auth-tabs button {
  flex: 1; border: none; background: transparent; padding: 10px; border-radius: 9px;
  font-weight: 700; font-size: 15px; color: var(--text-soft);
}
.auth-tabs button.active { background: var(--surface); color: var(--primary); box-shadow: var(--shadow-sm); }
.auth-switch { text-align: center; margin-top: 14px; font-size: 13px; color: var(--text-soft); }
.auth-switch a { color: var(--primary); font-weight: 700; cursor: pointer; }

/* ===================== 主页 ===================== */
.home { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.home-body { flex: 1; overflow-y: auto; padding: 16px 16px 90px; }
.user-bar {
  display: flex; align-items: center; gap: 12px;
  padding: 14px; background: var(--surface); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); margin-bottom: 16px;
}
.user-bar .ub-info { flex: 1; min-width: 0; }
.user-bar .ub-name { font-weight: 700; font-size: 16px; display: flex; align-items: center; gap: 6px; }
.user-bar .ub-sub { font-size: 12px; color: var(--text-soft); }
.points-pill {
  display: inline-flex; align-items: center; gap: 4px;
  background: linear-gradient(135deg, #ffd66b, #ff9f43);
  color: #5a3b00; font-weight: 800; font-size: 13px;
  padding: 5px 10px; border-radius: 999px;
}
.section-title { font-size: 14px; font-weight: 700; color: var(--text-soft); margin: 6px 4px 10px; display:flex; align-items:center; justify-content:space-between;}

.room-card {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface); border-radius: 14px; padding: 14px;
  box-shadow: var(--shadow-sm); margin-bottom: 12px; cursor: pointer;
  transition: transform .08s;
}
.room-card:active { transform: scale(0.99); }
.room-icon {
  width: 46px; height: 46px; border-radius: 14px; flex: none;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  display: flex; align-items: center; justify-content: center; color: #fff; font-size: 22px;
}
.room-info { flex: 1; min-width: 0; }
.room-info .rn { font-weight: 700; font-size: 15px; }
.room-info .rm { font-size: 12px; color: var(--text-soft); margin-top: 3px; }
.online-dot { display:inline-block; width:7px; height:7px; border-radius:50%; background: var(--ok); margin-right:4px; }
.room-card .arrow { color: var(--text-soft); font-size: 18px; }

.action-row { display: flex; gap: 10px; margin-bottom: 18px; }
.action-row .btn { flex: 1; }

.empty-hint { text-align:center; color: var(--text-soft); font-size: 13px; padding: 30px 10px; }

.bottom-nav {
  position: absolute; left: 0; right: 0; bottom: 0;
  height: 64px; display: flex; background: var(--surface);
  border-top: 1px solid var(--line); z-index: 4;
}
.bottom-nav button {
  flex: 1; background: transparent; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 3px;
  color: var(--text-soft); font-size: 11px; font-weight: 600;
}
.bottom-nav button.active { color: var(--primary); }
.bottom-nav button .ic { font-size: 21px; }

/* ===================== 聊天 ===================== */
.chat { flex: 1; display: flex; flex-direction: column; overflow: hidden; background: var(--surface-2); }
.chat-header { flex: none; }
.chat-meta { display:flex; align-items:center; gap:8px; font-size:12px; color:#fff; justify-content:center; flex-wrap:wrap; background: linear-gradient(135deg, var(--primary), var(--primary-2)); padding:6px 10px; }
.chat-meta .chip { background: rgba(255,255,255,.18); padding:3px 8px; border-radius:999px; }
.chat-body {
  flex: 1; overflow-y: auto; padding: 14px 12px;
  display: flex; flex-direction: column; gap: 12px;
}
.msg { display: flex; gap: 9px; max-width: 100%; }
.msg .avatar { width: 38px; height: 38px; flex: none; }
.msg .bubble-wrap { max-width: 74%; display: flex; flex-direction: column; }
.msg .sender-name { font-size: 11px; color: var(--text-soft); margin: 0 0 3px 4px; }
.msg .bubble {
  background: var(--surface); border-radius: 4px 14px 14px 14px;
  padding: 9px 12px; font-size: 15px; line-height: 1.45; word-break: break-word;
  box-shadow: var(--shadow-sm); position: relative;
}
.msg .read-tip { font-size: 11px; color: var(--text-soft); margin: 3px 4px 0; }
.msg.self { flex-direction: row-reverse; }
.msg.self .bubble-wrap { align-items: flex-end; }
.msg.self .bubble { border-radius: 14px 4px 14px 14px; background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: #fff; }

/* 系统消息 */
.sys-msg { align-self: center; font-size: 12px; color: var(--text-soft); background: rgba(0,0,0,.05); padding: 4px 12px; border-radius: 999px; }

/* 图片/文件消息 */
.msg .bubble img.msg-img { max-width: 200px; border-radius: 10px; display: block; }
.msg .file-chip { display: flex; align-items: center; gap: 8px; background: rgba(0,0,0,.06); border-radius: 10px; padding: 8px 10px; color: inherit; text-decoration: none; cursor: pointer; }
.msg.self .file-chip { background: rgba(255,255,255,.2); }
.file-chip:hover { filter: brightness(.97); }
.file-chip .dl-hint { margin-left: auto; padding-left: 10px; font-size: 11px; color: var(--primary); white-space: nowrap; }
.msg.self .file-chip .dl-hint { color: #fff; }

/* 红包消息 */
.redpacket {
  width: 200px; border-radius: 12px; overflow: hidden; box-shadow: var(--shadow-sm);
  background: linear-gradient(135deg, #ff7a59, #ff4d6d); color: #fff; cursor: pointer;
}
.redpacket .rp-top { padding: 12px; display:flex; gap:10px; align-items:center; }
.redpacket .rp-ic { width: 38px; height: 38px; border-radius: 50%; background: rgba(0,0,0,.14); color: #fff; display:flex; align-items:center; justify-content:center; font-size:20px; }
.redpacket .rp-title { font-weight: 700; font-size: 14px; }
.redpacket .rp-sub { font-size: 11px; opacity: .9; }
.redpacket .rp-bottom { background: rgba(255,255,255,.16); font-size: 11px; padding: 6px 12px; }

/* 头像 + 头像框 */
.avatar {
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 16px; position: relative;
  background: var(--primary);
}
.avatar.frame-gold { box-shadow: 0 0 0 3px #ffd700, 0 0 0 5px #fff3b0; }
.avatar.frame-star { box-shadow: 0 0 0 3px #7b5cff, 0 0 0 5px #d9ccff; }
.avatar.frame-sakura { box-shadow: 0 0 0 3px #ff8fb0, 0 0 0 5px #ffd9e6; }
.avatar.frame-diamond { box-shadow: 0 0 0 3px #4fd6ff, 0 0 0 5px #c8f3ff; }
.avatar.frame-rainbow { box-shadow: 0 0 0 3px #ff5c8a, 0 0 0 5px #ffe08a, 0 0 0 7px #8affc1; }

/* 气泡样式（自己发的） */
.msg.self .bubble.bubble-neon { background: linear-gradient(135deg,#00f5d4,#00bbf9); color:#012; }
.msg.self .bubble.bubble-candy { background: linear-gradient(135deg,#ff9a9e,#fad0c4); color:#5a2b2b; }
.msg.self .bubble.bubble-ocean { background: linear-gradient(135deg,#2af598,#009efd); color:#013; }
.msg.self .bubble.bubble-dark { background: linear-gradient(135deg,#232526,#414345); color:#fff; }
.msg.self .bubble.bubble-love { background: linear-gradient(135deg,#ff5c8a,#ff9a8b); color:#fff; }

/* 聊天背景主题 */
.chat-body.theme-galaxy { background: radial-gradient(circle at 30% 20%, #3a2a6b, #0d0b1f) ; }
.chat-body.theme-galaxy .msg .bubble { background:#2a2750; color:#eee; }
.chat-body.theme-fresh { background: linear-gradient(160deg,#d7f9e3,#e8f6ff); }
.chat-body.theme-cherry { background: linear-gradient(160deg,#ffe1ec,#fff0f5); }

/* 输入区 */
.chat-input-area { flex: none; background: var(--surface); border-top: 1px solid var(--line); padding: 8px 10px 10px; }
.chat-tools { display: flex; gap: 6px; margin-bottom: 8px; flex-wrap: wrap; }
.chat-tools .tool {
  width: 38px; height: 38px; border-radius: 10px; background: var(--surface-2);
  display: flex; align-items: center; justify-content: center; font-size: 18px; color: var(--text-soft);
}
.chat-tools .tool:active { background: var(--line); }
.chat-input-row { display: flex; gap: 8px; align-items: flex-end; }
.chat-input-row textarea {
  flex: 1; border: 1.5px solid var(--line); border-radius: 14px; padding: 10px 12px;
  font-size: 15px; resize: none; outline: none; max-height: 100px; min-height: 42px; font-family: inherit;
}
.chat-input-row textarea:focus { border-color: var(--primary); }
.send-btn { width: 46px; height: 46px; border-radius: 14px; background: linear-gradient(135deg,var(--primary),var(--primary-2)); color:#fff; font-size: 20px; flex:none; }

/* 表情 / 颜文字面板 */
.pop-panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: var(--shadow); padding: 10px; margin-bottom: 8px;
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; max-height: 200px; overflow-y: auto;
}
.pop-panel .em { font-size: 22px; text-align: center; padding: 6px 0; border-radius: 8px; cursor: pointer; }
.pop-panel .em:hover { background: var(--surface-2); }
.pop-panel.kao { grid-template-columns: 1fr 1fr; }
.pop-panel.kao .em { font-size: 15px; }

/* ===================== 商店 ===================== */
.store { flex: 1; display: flex; flex-direction: column; overflow: hidden; background: linear-gradient(180deg,#fff7e6,#fff); }
.store-banner {
  background: linear-gradient(135deg,#ff9f43,#ff5c8a);
  color:#fff; padding: 18px 16px; text-align:center;
}
.store-banner h2 { margin:0; font-size: 22px; }
.store-banner p { margin: 6px 0 0; font-size: 13px; opacity:.95; }
.store-banner .bal { display:inline-block; margin-top:10px; background: rgba(255,255,255,.25); padding:5px 14px; border-radius:999px; font-weight:800; }
.store-lang { margin-top: 10px; }
.store-lang .lang-select { background: rgba(255,255,255,.9); border: none; }
.store-body { flex:1; overflow-y:auto; padding: 14px; padding-bottom: 84px; }
.cat-title { font-size: 15px; font-weight: 800; margin: 14px 4px 10px; color:#7a4b00; display:flex; align-items:center; gap:6px; }
.cat-title:first-child { margin-top: 0; }
.goods-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.goods-card {
  background: var(--surface); border-radius: 14px; padding: 12px; box-shadow: var(--shadow-sm);
  display: flex; flex-direction: column; align-items: center; text-align: center;
  border: 1px solid #ffe6c2;
}
.goods-preview {
  width: 86px; height: 86px; border-radius: 18px; margin-bottom: 10px;
  display: flex; align-items: center; justify-content: center; position: relative;
  background: linear-gradient(135deg,#fef3e0,#ffe1ec);
}
.goods-preview .pv-avatar { width: 52px; height: 52px; font-size: 22px; }
.goods-preview .pv-bubble {
  background: linear-gradient(135deg,var(--primary),var(--primary-2)); color:#fff;
  padding: 8px 12px; border-radius: 12px; font-size: 13px; font-weight:700;
}
.goods-name { font-size: 13px; font-weight: 700; margin-bottom: 4px; }
.goods-price { font-size: 13px; font-weight: 800; color: #ff8c1a; margin-bottom: 8px; }
.goods-price::before { content: "★ "; }
.goods-card .btn { padding: 8px; font-size: 13px; }
.tag-equipped { font-size: 11px; color: var(--ok); font-weight: 700; margin-bottom: 6px; }

/* ===================== 弹窗 ===================== */
.modal-mask {
  position: fixed; inset: 0; background: rgba(20,22,40,.45);
  display: flex; align-items: center; justify-content: center; z-index: 50; padding: 20px;
}
.modal {
  width: 100%; max-width: 360px; background: var(--surface); border-radius: 18px;
  padding: 20px; box-shadow: var(--shadow); animation: pop .18s ease;
}
@keyframes pop { from { transform: scale(.92); opacity:.6;} to {transform: scale(1); opacity:1;} }
.modal h3 { margin: 0 0 14px; font-size: 18px; }
.modal .modal-actions { display: flex; gap: 10px; margin-top: 16px; }

/* 踢人列表 */
.member-list { max-height: 260px; overflow-y: auto; }
.member-item { display: flex; align-items: center; gap: 10px; padding: 10px 4px; border-bottom: 1px solid var(--line); }
.member-item .mi-name { flex: 1; font-weight: 600; }
.member-item .mi-tag { font-size: 11px; color: var(--warn); font-weight: 700; }

/* Toast */
#toast-root { position: fixed; bottom: 80px; left: 0; right: 0; display:flex; flex-direction:column; align-items:center; gap:8px; z-index: 99; pointer-events:none; }
.toast {
  background: rgba(20,22,40,.9); color:#fff; padding: 10px 18px; border-radius: 999px;
  font-size: 14px; box-shadow: var(--shadow); animation: fade .25s ease;
}
@keyframes fade { from {opacity:0; transform: translateY(8px);} to {opacity:1; transform:none;} }

/* 内联 SVG 图标：不依赖字体，避免显示成 □ */
.ic-svg { display: inline-block; vertical-align: -0.15em; flex: none; }

.hidden { display: none !important; }

/* ===================== 响应式（平板 / 桌面两栏全屏） ===================== */
.shell { display: flex; flex: 1; min-height: 0; width: 100%; }
.content { flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--bg); }
.sidebar { display: none; }
.home-welcome { display: none; }

/* 侧边栏内部 */
.sb-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; }
.sb-logo { width: 42px; height: 42px; border-radius: 13px; background: #fff; border: 2px solid #111; color: #111; display: flex; align-items: center; justify-content: center; box-shadow: 0 6px 16px rgba(0,0,0,.12); }
.sb-logo .ic-svg { width: 24px; height: 24px; }
.sb-name { font-weight: 800; font-size: 18px; flex: 1; min-width: 0; }
.sb-user { display: flex; align-items: center; gap: 10px; padding: 12px; background: var(--surface-2); border-radius: 14px; margin-bottom: 12px; }
.sb-user .ub-info { flex: 1; min-width: 0; }
.sb-user .ub-name { font-weight: 700; font-size: 15px; display: flex; align-items: center; gap: 6px; }
.sb-user .ub-sub { font-size: 12px; color: var(--text-soft); }
.sb-points { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.sb-points .points-pill { flex: 1; justify-content: center; }
.sb-nav { display: flex; gap: 8px; margin-bottom: 14px; }
.sb-nav button { flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px; background: var(--surface-2); border-radius: 12px; padding: 11px; font-weight: 700; font-size: 14px; color: var(--text-soft); }
.sb-nav button.active { background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: #fff; }
.sb-nav .ic-svg { width: 20px; height: 20px; }
  .sb-actions { display: flex; gap: 8px; margin-bottom: 16px; }
  .sb-actions .btn { flex: 1; }
  .sb-account { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
  .sb-account .btn { width: 100%; display: flex; align-items: center; justify-content: center; gap: 6px; }
.sb-rooms-title { font-size: 14px; font-weight: 700; color: var(--text-soft); margin: 4px 4px 10px; display: flex; align-items: center; gap: 6px; }
.sidebar .room-list { display: flex; flex-direction: column; gap: 10px; }

/* 桌面 / 平板：两栏全屏 */
@media (min-width: 860px) {
  #app {
    max-width: none; width: 100%; height: 100vh; flex-direction: row; box-shadow: none;
  }
  .sidebar {
    display: flex; flex-direction: column; width: 320px; flex: none;
    background: var(--surface); border-right: 1px solid var(--line);
    padding: 18px; overflow-y: auto;
  }
  .bottom-nav { display: none !important; }
  .home .topbar,
  .home .user-bar,
  .home .action-row,
  .home .section-title,
  .home .room-list { display: none; }
  .home-welcome { display: flex; flex: 1; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 10px; padding: 40px 20px; color: var(--text-soft); }
  .home-welcome .hw-icon .ic-svg { width: 64px; height: 64px; color: var(--primary); }
  .home-welcome .hw-title { font-size: 20px; font-weight: 800; color: var(--text); }
  .home-welcome .hw-sub { font-size: 14px; }
  .only-mobile { display: none !important; }
  .home-body, .store-body { padding-bottom: 16px; }
  .chat, .store, .home { max-width: 1040px; width: 100%; align-self: center; }
  .chat, .home { background: var(--surface); }
  .auth-wrap { align-items: center; justify-content: center; }
  .auth-card { max-width: 420px; width: 100%; }
}
