/* ============ Private Chat · 设计系统 ============ */
:root {
  color-scheme: light dark;
  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
  --accent: #5b5bd6;
  --accent-2: #8b5cf6;
  --accent-grad: linear-gradient(135deg, #5b5bd6, #8b5cf6);
  --accent-soft: rgba(91, 91, 214, .12);
  --bg: #eceef3;
  --surface: #ffffff;
  --surface-2: #f3f4f7;
  --surface-3: #e8eaf0;
  --text: #16181d;
  --text-2: #6d7278;
  --text-3: #a2a7ae;
  --border: #e3e5ea;
  --bubble-them: #e9ebf1;
  --bubble-them-text: #16181d;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .06);
  --shadow-md: 0 8px 24px rgba(16, 24, 40, .10);
  --shadow-lg: 0 20px 56px rgba(16, 24, 40, .18);
  --rail-bg: #f7f8fa;
  --danger: #e5484d;
  --radius: 16px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --accent-soft: rgba(139, 124, 246, .16);
    --bg: #0d0f13;
    --surface: #15181e;
    --surface-2: #1c2029;
    --surface-3: #262c38;
    --text: #eef1f4;
    --text-2: #9aa1ab;
    --text-3: #5f666f;
    --border: #232933;
    --bubble-them: #222836;
    --bubble-them-text: #eef1f4;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, .45);
    --shadow-lg: 0 20px 56px rgba(0, 0, 0, .55);
    --rail-bg: #101318;
  }
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}
.hidden { display: none !important; }
.view { min-height: 100dvh; display: flex; flex-direction: column; }
button { font-family: inherit; }
input, textarea { font-family: inherit; font-size: 15px; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--text-3); border-radius: 8px; opacity: .5; }
::-webkit-scrollbar-track { background: transparent; }

/* ============ 通用控件 ============ */
input, textarea {
  width: 100%;
  padding: 12px 14px;
  margin-bottom: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--text);
  transition: border-color .15s, box-shadow .15s, background .15s;
}
input::placeholder, textarea::placeholder { color: var(--text-3); }
input:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
button {
  padding: 12px 18px;
  border: none;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  background: var(--surface-3);
  color: var(--text);
  transition: transform .12s, box-shadow .15s, background .15s, opacity .15s;
}
button:active { transform: scale(.97); }
button.primary {
  background: var(--accent-grad);
  color: #fff;
  box-shadow: 0 4px 14px rgba(91, 91, 214, .35);
}
button.primary:hover { box-shadow: 0 6px 20px rgba(91, 91, 214, .45); }
button.ghost { background: transparent; color: var(--text-2); }
button.danger-ghost {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--border);
  width: 100%;
}
.btn-icon {
  width: 38px; height: 38px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 12px; background: transparent; color: var(--text-2);
  padding: 0; flex-shrink: 0;
}
.btn-icon:hover { background: var(--surface-3); color: var(--text); }
.btn-icon svg { width: 20px; height: 20px; }
.btn-text { background: none; color: var(--accent); padding: 8px 10px; font-size: 14px; flex-shrink: 0; }
.error { color: var(--danger); font-size: 13px; text-align: center; margin-top: 10px; min-height: 20px; }
.hint { font-size: 13px; color: var(--text-3); }
.badge {
  background: var(--accent-grad); color: #fff;
  font-size: 11px; font-weight: 700;
  padding: 3px 10px; border-radius: 20px; letter-spacing: .04em;
}

/* 头像：渐变底 + 首字母 */
.avatar {
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 26%;
  color: #fff; font-weight: 700; flex-shrink: 0;
  width: 48px; height: 48px; font-size: 20px;
  text-shadow: 0 1px 2px rgba(0,0,0,.2);
}
.avatar.sm { width: 40px; height: 40px; font-size: 17px; }
.avatar.xs { width: 34px; height: 34px; font-size: 15px; border-radius: 50%; }
.avatar.xl { width: 64px; height: 64px; font-size: 26px; border-radius: 24px; }
.avatar > img { width: 100%; height: 100%; object-fit: cover; border-radius: inherit; display: block; }

/* 头像更换 */
.avatar-wrap { position: relative; background: none; border: none; padding: 0; cursor: pointer; border-radius: 24px; }
.avatar-edit-badge {
  position: absolute; right: -3px; bottom: -3px;
  width: 27px; height: 27px; border-radius: 50%;
  background: var(--accent-grad); color: #fff;
  display: flex; align-items: center; justify-content: center;
  border: 3px solid var(--surface);
  box-shadow: var(--shadow-sm);
}
.avatar-edit-badge svg { width: 13px; height: 13px; }
.avatar-wrap:hover .avatar-edit-badge { transform: scale(1.1); }
.avatar-edit-badge { transition: transform .15s; }

/* 昵称编辑 */
.me-name-row { display: flex; align-items: center; gap: 6px; }
.btn-icon.xs { width: 30px; height: 30px; border-radius: 10px; }
.btn-icon.xs svg { width: 15px; height: 15px; }
#name-edit { margin-top: 8px; }
#name-edit input { margin-bottom: 8px; }
.name-edit-actions { display: flex; gap: 8px; }
.name-edit-actions button { padding: 9px 20px; font-size: 13.5px; border-radius: 10px; }

/* ============ 登录 / 注册 ============ */
#view-auth { position: relative; justify-content: center; align-items: center; padding: 24px; overflow: hidden; }
.auth-bg { position: absolute; inset: 0; background: var(--bg); }
.blob { position: absolute; border-radius: 50%; filter: blur(90px); opacity: .45; animation: drift 14s ease-in-out infinite alternate; }
.blob.b1 { width: 480px; height: 480px; background: #5b5bd6; top: -160px; left: -120px; }
.blob.b2 { width: 420px; height: 420px; background: #22d3ee; bottom: -140px; right: -100px; animation-delay: -5s; }
.blob.b3 { width: 300px; height: 300px; background: #f472b6; top: 40%; left: 60%; animation-delay: -9s; opacity: .3; }
@media (prefers-color-scheme: dark) { .blob { opacity: .22; } .blob.b3 { opacity: .14; } }
@keyframes drift {
  from { transform: translate(0, 0) scale(1); }
  to { transform: translate(40px, 30px) scale(1.08); }
}
.auth-card {
  position: relative; z-index: 1;
  width: 100%; max-width: 380px;
  background: color-mix(in srgb, var(--surface) 84%, transparent);
  backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 36px 30px 28px;
  box-shadow: var(--shadow-lg);
  animation: rise .45s cubic-bezier(.2, .9, .3, 1.2);
}
@keyframes rise { from { opacity: 0; transform: translateY(18px) scale(.98); } }
.auth-logo { display: flex; justify-content: center; margin-bottom: 14px; }
.auth-card h1 { text-align: center; font-size: 26px; font-weight: 800; letter-spacing: -.01em; }
.auth-card .subtitle { text-align: center; color: var(--text-2); font-size: 13px; margin: 8px 0 22px; letter-spacing: .06em; }
.seg {
  display: flex; background: var(--surface-2);
  border-radius: 14px; padding: 4px; margin-bottom: 18px;
}
.seg .tab {
  flex: 1; background: none; border: none; padding: 10px;
  font-size: 15px; font-weight: 600; color: var(--text-2);
  border-radius: 11px; cursor: pointer;
}
.seg .tab.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.auth-card button.primary { width: 100%; margin-top: 4px; }
.auth-foot { position: relative; z-index: 1; margin-top: 22px; font-size: 12px; color: var(--text-2); letter-spacing: .08em; }

/* ============ 应用骨架 ============ */
#view-app { flex-direction: row; height: 100dvh; overflow: hidden; }

/* 左侧导航轨 */
#rail {
  width: 78px; flex-shrink: 0;
  background: var(--rail-bg);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column; align-items: center;
  padding: 14px 0; gap: 6px; z-index: 5;
}
.rail-logo { margin-bottom: 10px; }
.rail-btn {
  width: 58px; padding: 9px 0 7px;
  background: none; border: none; border-radius: 16px;
  color: var(--text-2);
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  font-size: 11px; font-weight: 600;
}
.rail-btn svg { width: 22px; height: 22px; }
.rail-btn:hover { background: var(--surface-3); color: var(--text); }
.rail-btn.active { background: var(--accent-soft); color: var(--accent); }
.rail-space { flex: 1; }
.rail-me { padding: 6px 0; }

/* 中间列表面板 */
#panel {
  width: 340px; flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column; min-height: 0;
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 18px 12px;
}
.panel-head h2 { font-size: 22px; font-weight: 800; letter-spacing: -.01em; }
#panel-action .btn-icon { color: var(--accent); }
#panel-action .btn-icon:hover { background: var(--accent-soft); }
#panel-action .btn-icon svg { width: 22px; height: 22px; }
.panel-page { flex: 1; overflow-y: auto; min-height: 0; }
#view-app[data-tab="feed"] #panel,
#view-app[data-tab="me"] #panel { display: none; }

/* 右侧内容区 */
#content { flex: 1; min-width: 0; display: flex; background: var(--bg); }
.content-page { flex: 1; min-width: 0; display: flex; flex-direction: column; }

/* 列表项 */
.list-label {
  padding: 16px 18px 6px; font-size: 12px; font-weight: 700;
  color: var(--text-3); letter-spacing: .08em;
}
.list:empty::after {
  content: "空空如也"; display: block; text-align: center;
  color: var(--text-3); padding: 36px 20px; font-size: 14px;
}
#search-results:empty::after { content: none; }
.item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 18px; cursor: pointer;
  border-left: 3px solid transparent;
  transition: background .12s;
}
.item:hover { background: var(--surface-2); }
.item.active { background: var(--accent-soft); border-left-color: var(--accent); }
.item .info { flex: 1; min-width: 0; }
.item .name { font-size: 15.5px; font-weight: 600; display: flex; align-items: center; gap: 7px; }
.item .preview {
  font-size: 13px; color: var(--text-2); margin-top: 3px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.item .time { font-size: 12px; color: var(--text-3); flex-shrink: 0; }
.item .mini { flex-shrink: 0; font-size: 12.5px; padding: 7px 13px; border-radius: 10px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: #22c55e; display: inline-block; box-shadow: 0 0 0 3px rgba(34,197,94,.18); }
.dot.off { background: var(--text-3); box-shadow: none; }

/* 搜索行 */
.search-row {
  display: flex; align-items: center; gap: 4px;
  margin: 0 14px 6px; padding: 4px 6px 4px 12px;
  background: var(--surface-2); border-radius: 14px;
  border: 1px solid transparent; transition: border-color .15s, box-shadow .15s;
}
.search-row:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); background: var(--surface); }
.search-row svg { width: 17px; height: 17px; color: var(--text-3); flex-shrink: 0; }
.search-row input { margin: 0; border: none; background: none; padding: 9px 4px; box-shadow: none !important; }

/* 空状态 */
#content-empty { align-items: center; justify-content: center; text-align: center; padding: 32px; }
.empty-art { margin-bottom: 20px; animation: float 5s ease-in-out infinite; }
@keyframes float { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }
#content-empty h3 { font-size: 19px; font-weight: 700; margin-bottom: 8px; }
#content-empty p { color: var(--text-2); font-size: 14px; }

/* ============ 聊天窗口 ============ */
#content-chat { background: var(--bg); }
.chat-head {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 18px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  z-index: 2;
}
.chat-peer { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; }
.chat-peer-text { min-width: 0; }
.chat-title { font-size: 16.5px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-sub { font-size: 12.5px; color: var(--text-2); margin-top: 1px; }
.only-mobile { display: none; }

#msg-list {
  flex: 1; overflow-y: auto;
  padding: 22px clamp(16px, 6%, 72px);
  display: flex; flex-direction: column; gap: 4px;
}
.msg {
  max-width: min(68%, 520px);
  padding: 10px 15px;
  border-radius: 20px;
  font-size: 15px; line-height: 1.55;
  word-break: break-word;
  box-shadow: var(--shadow-sm);
  animation: msg-in .22s cubic-bezier(.2, .9, .3, 1.15);
  margin-top: 2px;
}
@keyframes msg-in { from { opacity: 0; transform: translateY(8px) scale(.98); } }
.msg.mine {
  align-self: flex-end;
  background: var(--accent-grad); color: #fff;
  border-bottom-right-radius: 7px;
}
.msg.theirs {
  align-self: flex-start;
  background: var(--bubble-them); color: var(--bubble-them-text);
  border-bottom-left-radius: 7px;
}
.msg .sender { font-size: 12px; font-weight: 700; color: var(--accent); margin-bottom: 3px; }
.msg.mine .sender { display: none; }
.msg .mtime {
  font-size: 10.5px; margin-top: 4px; text-align: right;
  opacity: .55; font-variant-numeric: tabular-nums;
}
.msg-row { display: flex; align-items: flex-end; gap: 8px; }
.msg-row.mine { justify-content: flex-end; }

.inputbar {
  display: flex; align-items: center; gap: 10px;
  padding: 14px clamp(16px, 6%, 72px) calc(14px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--border);
}
.inputbar input {
  margin: 0; border-radius: 24px; padding: 12px 18px;
  background: var(--surface-2);
}
.send-btn {
  width: 46px; height: 46px; border-radius: 50%;
  background: var(--accent-grad); color: #fff; padding: 0;
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
  box-shadow: 0 4px 14px rgba(91, 91, 214, .4);
}
.send-btn svg { width: 19px; height: 19px; margin-left: 2px; }

/* ============ 动态 ============ */
#content-feed { overflow-y: auto; }
.feed-wrap { width: 100%; max-width: 640px; margin: 0 auto; padding: 24px 20px 40px; }
.composer {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; margin-bottom: 18px;
  box-shadow: var(--shadow-sm);
}
.composer textarea { border: none; background: none; resize: none; padding: 4px; margin-bottom: 10px; box-shadow: none !important; }
.composer-foot { display: flex; align-items: center; justify-content: space-between; }
.composer-foot .primary { width: auto; padding: 9px 26px; font-size: 14px; }
.post {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px; margin-bottom: 14px;
  box-shadow: var(--shadow-sm);
  animation: msg-in .25s ease;
}
.post-head { display: flex; align-items: center; gap: 11px; margin-bottom: 10px; }
.post-head .who { font-weight: 700; font-size: 15px; }
.post-head .when { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.post .body { font-size: 15px; line-height: 1.65; white-space: pre-wrap; word-break: break-word; }
.post .actions { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--border); }
.post .actions button {
  background: none; border: 1px solid var(--border); color: var(--text-2);
  font-size: 13.5px; padding: 7px 15px; border-radius: 20px; font-weight: 600;
}
.post .actions button.liked { color: #f43f5e; border-color: rgba(244,63,94,.4); background: rgba(244,63,94,.08); }

/* ============ 我 ============ */
#content-me { overflow-y: auto; }
.me-wrap { width: 100%; max-width: 640px; margin: 0 auto; padding: 28px 20px 40px; display: flex; flex-direction: column; gap: 18px; }
.me-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 20px; padding: 24px;
  display: flex; align-items: center; gap: 18px;
  box-shadow: var(--shadow-sm);
}
.me-name { font-size: 21px; font-weight: 800; }
.me-sub { color: var(--text-2); font-size: 14px; margin-top: 5px; }
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 20px; padding: 20px;
  box-shadow: var(--shadow-sm);
}
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.card-head h3 { font-size: 16px; font-weight: 700; }
.card .row { display: flex; gap: 10px; margin-bottom: 6px; }
.card .row input { margin: 0; }
.card .row input[type="number"] { width: 76px; flex-shrink: 0; }
.card .row button.primary { width: auto; padding: 12px 22px; flex-shrink: 0; }
#invite-list .item { padding: 11px 4px; border-bottom: 1px solid var(--border); cursor: default; }
#invite-list .item:last-child { border-bottom: none; }
.invite-code {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  background: var(--surface-2); border: 1px dashed var(--text-3);
  padding: 5px 12px; border-radius: 9px; font-size: 13.5px; letter-spacing: .02em;
}
.danger-ghost { width: 100%; }

/* ============ 弹窗 ============ */
.modal {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(10, 12, 16, .45);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 22px; padding: 26px;
  width: 100%; max-width: 400px;
  box-shadow: var(--shadow-lg);
  animation: pop .28s cubic-bezier(.2, .9, .3, 1.2);
  max-height: 84dvh; overflow-y: auto;
}
@keyframes pop { from { opacity: 0; transform: scale(.94) translateY(10px); } }
.modal-card h3 { font-size: 18px; font-weight: 800; margin-bottom: 16px; }
.modal-card .hint { margin: 4px 0 10px; }
.modal-actions { display: flex; gap: 10px; margin-top: 16px; }
.modal-actions button { flex: 1; }
.checklist { display: flex; flex-direction: column; gap: 2px; max-height: 260px; overflow-y: auto; }
.checklist label {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px; border-radius: 12px; cursor: pointer; font-size: 15px;
}
.checklist label:hover { background: var(--surface-2); }
.checklist input[type="checkbox"] { width: 19px; height: 19px; margin: 0; accent-color: var(--accent); }

/* ============ 移动端 (< 960px) ============ */
@media (max-width: 960px) {
  #rail {
    position: fixed; bottom: 0; left: 0; right: 0; top: auto;
    width: auto; height: calc(62px + env(safe-area-inset-bottom, 0px));
    flex-direction: row; justify-content: space-around;
    border-right: none; border-top: 1px solid var(--border);
    padding: 6px 8px env(safe-area-inset-bottom, 0px);
  }
  .rail-logo, .rail-space { display: none; }
  .rail-btn { width: auto; flex: 1; padding: 6px 0; }
  .rail-btn span { font-size: 10.5px; }
  #view-app { padding-bottom: calc(62px + env(safe-area-inset-bottom, 0px)); }
  #panel { width: 100%; border-right: none; }
  .panel-head { padding: 16px 16px 10px; }
  .item { padding: 11px 16px; }
  #content { display: none; }
  #view-app[data-tab="feed"] #panel,
  #view-app[data-tab="me"] #panel { display: none; }
  #view-app[data-tab="feed"] #content,
  #view-app[data-tab="me"] #content { display: flex; flex: 1; }
  #view-app.chat-open #content {
    display: flex;
    position: fixed; inset: 0;
    bottom: calc(62px + env(safe-area-inset-bottom, 0px));
    z-index: 20;
  }
  .only-mobile { display: inline-flex; }
  #msg-list { padding: 16px 14px; }
  .msg { max-width: 78%; }
  .inputbar { padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px)); }
  .feed-wrap, .me-wrap { padding: 16px 14px 32px; }
  #content-empty { display: none; }
}
