:root {
  --bg: #000000;
  --panel: #0a0a0a;
  --card: #121212;
  --card2: #1a1a1a;
  --line: #202020;
  --text: #f7f7f7;
  --muted: #8b8b8b;
  --dim: #5a5a5a;
  --green: #0ecb81;
  --red: #f6465d;
  --radius: 14px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Segoe UI", sans-serif;
  overscroll-behavior: none;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }
button { font-family: inherit; color: inherit; cursor: pointer; }
input, textarea { font-family: inherit; }

/* ---------------- 登录 ---------------- */
.login {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  padding: 24px; background: var(--bg);
}
.login-inner { width: 100%; max-width: 340px; text-align: center; }
.login-ava {
  width: 76px; height: 76px; border-radius: 22px; object-fit: cover;
  border: 1px solid var(--line); margin-bottom: 18px;
}
.login h1 { font-size: 20px; margin: 0 0 6px; font-weight: 600; letter-spacing: .5px; }
.login p { color: var(--muted); font-size: 13px; margin: 0 0 26px; }
.login input {
  width: 100%; height: 50px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--card); color: var(--text); padding: 0 16px; font-size: 17px;
  letter-spacing: 3px; text-align: center; outline: none;
}
.login input:focus { border-color: #3a3a3a; }
.btn-primary {
  width: 100%; height: 50px; margin-top: 12px; border: 0; border-radius: 12px;
  background: #fff; color: #000; font-size: 16px; font-weight: 600;
}
.btn-primary:active { opacity: .85; }
.err { color: var(--red); font-size: 13px; min-height: 18px; margin-top: 12px; }

/* ---------------- 主界面 ---------------- */
.main { position: fixed; inset: 0; display: flex; flex-direction: column; background: var(--bg); }

.topbar {
  display: flex; align-items: center; gap: 10px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  border-bottom: 1px solid var(--line);
  background: rgba(0, 0, 0, .82);
  backdrop-filter: blur(16px);
  z-index: 6;
}
.ident { flex: 1; display: flex; align-items: center; gap: 11px; min-width: 0; }
.ava-top { width: 36px; height: 36px; border-radius: 11px; object-fit: cover; border: 1px solid var(--line); }
.ident-txt { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ident-txt b { font-size: 16px; font-weight: 600; letter-spacing: .2px; }
.status { display: flex; align-items: center; gap: 5px; font-size: 11px; color: var(--muted); }
.dot { width: 6px; height: 6px; border-radius: 50%; background: var(--dim); display: inline-block; }
.dot.on { background: var(--green); box-shadow: 0 0 6px rgba(14, 203, 129, .7); }
.dot.off { background: var(--dim); }
.icon-btn {
  width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--card); font-size: 18px; line-height: 1; color: var(--text);
  display: grid; place-items: center;
}
.icon-btn:active { background: var(--card2); }

/* ---------------- 聊天 ---------------- */
.chat {
  flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 16px 14px 6px;
  display: flex; flex-direction: column; gap: 14px;
}

.divider { align-self: center; font-size: 11px; color: var(--dim); padding: 4px 0; }

.msg { display: flex; gap: 8px; align-items: flex-start; }
.msg .ava { width: 30px; height: 30px; border-radius: 9px; object-fit: cover; flex: 0 0 auto; margin-top: 2px; }
.msg .body { display: flex; flex-direction: column; gap: 5px; max-width: 78%; min-width: 0; }
.msg.me { justify-content: flex-end; }
.msg.me .body { align-items: flex-end; }

.bubble {
  padding: 9px 13px; border-radius: 15px; font-size: 15.5px; line-height: 1.45;
  white-space: pre-wrap; word-break: break-word;
  background: var(--card2); color: var(--text);
  animation: pop .16s ease-out;
}
.msg.me .bubble { background: #fff; color: #000; border-bottom-right-radius: 6px; }
.msg.her .bubble { border-bottom-left-radius: 6px; }
@keyframes pop { from { transform: translateY(5px); opacity: 0 } to { transform: none; opacity: 1 } }

.meta { font-size: 10px; color: var(--dim); padding: 0 4px; letter-spacing: .3px; }

.sticker { width: 124px; height: 124px; object-fit: contain; border-radius: 12px; display: block; }

/* 连续消息：不重复头像，气泡对齐 */
.msg.cont { margin-top: -8px; }
.msg.her.cont .ava { visibility: hidden; }
.typing { display: flex; gap: 4px; align-items: center; padding: 13px 14px; }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: blink 1.3s infinite; }
.typing i:nth-child(2) { animation-delay: .18s }
.typing i:nth-child(3) { animation-delay: .36s }
@keyframes blink { 0%,60%,100% { opacity: .22 } 30% { opacity: .9 } }
.typing .tlabel { font-style: normal; font-size: 11px; color: var(--muted); margin-left: 6px; }

.sysnote { align-self: center; font-size: 11px; color: var(--dim); text-align: center; max-width: 80%; }

.voice-chip {
  border: 1px solid var(--line); background: transparent; color: var(--muted);
  font-size: 11px; padding: 5px 10px; border-radius: 999px;
}
.voice-chip:active { background: var(--card); }
.voice-chip:disabled { opacity: .5; }
.audio-row audio { height: 30px; max-width: 74vw; filter: invert(1) hue-rotate(180deg) opacity(.85); }

.jump {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(80px + env(safe-area-inset-bottom));
  padding: 6px 14px; border-radius: 999px; background: #fff; color: #000;
  font-size: 12px; font-weight: 600;
}

/* ---------------- 输入 ---------------- */
.composer {
  display: flex; align-items: flex-end; gap: 9px;
  /* 只留安全区的三成左右，剩下的压掉，避免底部一大段空白 */
  padding: 7px 12px max(5px, calc(env(safe-area-inset-bottom, 0px) - 32px));
  background: var(--panel); border-top: 1px solid var(--line);
}
.composer textarea {
  flex: 1; resize: none; min-height: 40px; max-height: 120px;
  padding: 10px 15px; border-radius: 20px; border: 1px solid var(--line);
  background: var(--card); color: var(--text); font-size: 16px; line-height: 1.3;
  outline: none;
}
.composer textarea:focus { border-color: #333; }
.send {
  width: 40px; height: 40px; flex: 0 0 auto; border: 0; border-radius: 50%;
  background: #fff; color: #000; font-size: 18px; font-weight: 700;
}
.send:disabled { opacity: .35; }

/* ---------------- 页面（抽屉式） ---------------- */
.page {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  height: 100%;
  background: var(--bg); z-index: 30;
  display: flex; flex-direction: column;
  transform: translateX(100%);
  transition: transform .26s cubic-bezier(.32, .72, 0, 1);
  overflow: hidden;
}
.page.open { transform: none; }

.page-head {
  display: flex; align-items: center; gap: 8px;
  padding: calc(12px + env(safe-area-inset-top)) 12px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}
.page-head h1 { flex: 1; font-size: 17px; font-weight: 600; margin: 0; text-align: center; }
.back {
  width: 36px; height: 36px; border: 0; background: transparent;
  font-size: 26px; line-height: 1; color: var(--text); padding: 0 0 4px;
}
.text-btn { border: 0; background: transparent; color: #fff; font-size: 14px; font-weight: 500; padding: 8px 6px; }

.page-body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding-bottom: max(16px, env(safe-area-inset-bottom, 0px));
}

.group-title { font-size: 12px; color: var(--dim); padding: 20px 20px 8px; letter-spacing: .5px; }
.group { background: var(--card); border-radius: var(--radius); margin: 0 14px; overflow: hidden; }
.row-item {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 15px 16px; background: transparent; border: 0;
  border-bottom: 1px solid var(--line); text-align: left;
}
.row-item:last-child { border-bottom: 0; }
.row-item:active { background: var(--card2); }
.row-item .ico { width: 22px; text-align: center; color: var(--muted); font-size: 15px; }
.row-item .t { flex: 1; font-size: 15px; }
.row-item .sub { font-size: 12px; color: var(--dim); }
.row-item .chev { color: #333; font-size: 17px; }
.row-item.danger .t { color: var(--red); }
.foot-note { text-align: center; color: #2e2e2e; font-size: 11px; padding: 26px 0 10px; }
.stack { display: flex; flex-direction: column; gap: 8px; padding: 0 14px; }

/* ---------------- 表单 ---------------- */
.field-label { font-size: 13px; color: var(--muted); padding: 18px 20px 8px; }
.field-label .hint { color: var(--dim); font-size: 11px; margin-left: 6px; }
.ta {
  display: block; width: calc(100% - 28px); margin: 0 14px;
  background: var(--card); color: var(--text); border: 1px solid var(--line);
  border-radius: 12px; padding: 13px 14px; font-size: 14px; line-height: 1.65;
  outline: none; resize: vertical;
}
.ta:focus { border-color: #333; }
.tip { color: var(--dim); font-size: 11.5px; line-height: 1.6; padding: 14px 20px; }

.inp {
  flex: 1; height: 42px; border-radius: 11px; border: 1px solid var(--line);
  background: var(--card); color: var(--text); padding: 0 14px; font-size: 15px; outline: none;
}
.inp:focus { border-color: #333; }
.add-row { display: flex; gap: 8px; padding: 14px; }
.btn-sm { height: 42px; padding: 0 16px; border: 0; border-radius: 11px; background: #fff; color: #000; font-size: 14px; font-weight: 600; }

/* ---------------- 卡片 / 数据 ---------------- */
.card {
  background: var(--card); border-radius: var(--radius); margin: 14px;
  padding: 18px;
}
.card-label { font-size: 12px; color: var(--muted); margin-bottom: 10px; display: flex; align-items: center; gap: 6px; }
.big-num { font-size: 34px; font-weight: 600; letter-spacing: -.5px; font-variant-numeric: tabular-nums; }
.big-num small { font-size: 14px; color: var(--muted); font-weight: 400; margin-left: 6px; }
.card-sub { font-size: 12px; color: var(--dim); margin-top: 8px; line-height: 1.6; }
.badge { font-size: 10px; padding: 2px 7px; border-radius: 6px; background: rgba(14,203,129,.12); color: var(--green); }
.badge.gray { background: #1e1e1e; color: var(--muted); }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 14px; }
.cell { background: var(--card); border-radius: 12px; padding: 14px; }
.cell .k { font-size: 11px; color: var(--muted); margin-bottom: 6px; }
.cell .v { font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; }

.list-row { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.list-row:last-child { border-bottom: 0; }
.list-row .k { flex: 1; font-size: 14px; }
.list-row .v { font-size: 12px; color: var(--dim); text-align: right; max-width: 55%; }

/* 开关 */
.switch { position: relative; width: 46px; height: 27px; flex: 0 0 auto; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span {
  position: absolute; inset: 0; border-radius: 999px; background: #2a2a2a;
  transition: background .2s;
}
.switch span::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 21px; height: 21px;
  border-radius: 50%; background: #7a7a7a; transition: transform .2s, background .2s;
}
.switch input:checked + span { background: rgba(14,203,129,.25); }
.switch input:checked + span::after { transform: translateX(19px); background: var(--green); }

/* 步进器 */
.stepper { display: flex; align-items: center; gap: 2px; background: var(--card2); border-radius: 9px; padding: 3px; }
.stepper button {
  width: 30px; height: 28px; border: 0; border-radius: 7px; background: transparent;
  color: var(--text); font-size: 16px; line-height: 1;
}
.stepper button:active { background: #2c2c2c; }
.stepper .val {
  min-width: 58px; text-align: center; font-size: 14px; font-variant-numeric: tabular-nums;
}

/* 记忆 / 日记 */
.mem-item { display: flex; align-items: center; gap: 10px; background: var(--card); border-radius: 12px; padding: 13px 14px; }
.mem-item span { flex: 1; font-size: 14px; line-height: 1.5; }
.mem-item .tag { font-size: 10px; color: var(--dim); border: 1px solid var(--line); border-radius: 5px; padding: 1px 5px; }
.mem-item button { border: 0; background: transparent; color: var(--dim); font-size: 17px; padding: 0 2px; }

.diary-card { background: var(--card); border-radius: 12px; padding: 15px; margin: 0 14px 10px; }
.diary-date { font-size: 11px; color: var(--dim); margin-bottom: 8px; letter-spacing: .5px; }
.diary-text {
  font-size: 14px; line-height: 1.7; white-space: pre-wrap;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.diary-card.open .diary-text { display: block; -webkit-line-clamp: unset; }

/* ---------- 记忆图谱 ---------- */
.graph-body { position: relative; display: flex; flex-direction: column; overflow: hidden; }
.graph-stat { padding: 12px 18px 4px; font-size: 12px; color: var(--muted); }
.graph-hint { padding: 0 18px 10px; font-size: 11px; color: #4a4a4a; }
#graphCanvas { flex: 1; width: 100%; display: block; touch-action: none; }
.graph-legend {
  display: flex; gap: 16px; padding: 10px 18px calc(14px + env(safe-area-inset-bottom));
  font-size: 11px; color: var(--dim); border-top: 1px solid var(--line);
}
.graph-legend i { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 5px; }
.graph-info {
  position: absolute; left: 14px; right: 14px; bottom: 62px;
  background: #161616; border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 14px; font-size: 13px; line-height: 1.6; color: var(--text);
  box-shadow: 0 8px 30px rgba(0,0,0,.6);
}
.graph-info .g-k { font-size: 11px; color: var(--dim); margin-bottom: 6px; }

/* ---------- 发图片 ---------- */
.img-btn {
  width: 36px; height: 36px; flex: 0 0 auto; border-radius: 50%;
  border: 1px solid var(--line); background: var(--card); color: var(--muted);
  font-size: 20px; line-height: 1; display: grid; place-items: center; margin-bottom: 2px;
}
.img-btn:active { background: var(--card2); }
.img-preview {
  position: fixed; left: 12px; right: 12px;
  bottom: calc(58px + env(safe-area-inset-bottom, 0px));
  display: flex; align-items: flex-start; gap: 8px; z-index: 9;
  pointer-events: none;
}
.img-preview img {
  width: 76px; height: 76px; object-fit: cover; border-radius: 12px;
  border: 1px solid var(--line); box-shadow: 0 6px 24px rgba(0,0,0,.6);
  pointer-events: auto;
}
.img-clear {
  pointer-events: auto;
  width: 22px; height: 22px; border-radius: 50%; border: 0;
  background: rgba(255,255,255,.9); color: #000; font-size: 14px; line-height: 1;
}
.msg .photo {
  max-width: 62vw; border-radius: 14px; display: block; border: 1px solid var(--line);
}

/* ---------- 空间动态提示条 ---------- */
.feed-row {
  align-self: center; display: flex; align-items: center; gap: 8px;
  padding: 9px 14px; border-radius: 999px;
  background: #141414; border: 1px solid var(--line);
  font-size: 12.5px; color: var(--text); max-width: 88%;
}
.feed-row .ico { color: #4d6bfe; }

/* ---------- 她的空间 ---------- */
.ident { cursor: pointer; }
.space-enter {
  margin-left: auto; font-size: 11px; color: var(--dim);
  border: 1px solid var(--line); border-radius: 999px; padding: 3px 9px;
}
.space-profile {
  display: flex; align-items: center; gap: 14px; padding: 20px 18px 14px;
}
.space-ava {
  width: 62px; height: 62px; border-radius: 18px; object-fit: cover;
  border: 1px solid var(--line);
}
.space-profile b { font-size: 17px; display: block; margin-bottom: 6px; }
.space-sign { font-size: 12.5px; color: var(--muted); line-height: 1.5; }
.moment-card {
  background: var(--card); border-radius: 14px; margin: 0 14px 10px; padding: 14px;
}
.moment-text { font-size: 14.5px; line-height: 1.7; white-space: pre-wrap; }
.moment-time { font-size: 11px; color: var(--dim); margin-top: 8px; }
.comments { margin-top: 10px; border-top: 1px solid var(--line); padding-top: 8px; display: flex; flex-direction: column; gap: 6px; }
.comment { font-size: 13px; line-height: 1.55; color: #c9ccd4; }
.comment b { color: #4d6bfe; font-weight: 500; margin-right: 4px; }
.comment.me b { color: #8b8b8b; }
.comment-box { display: flex; gap: 6px; margin-top: 8px; }
.comment-box input {
  flex: 1; height: 34px; border-radius: 9px; border: 1px solid var(--line);
  background: var(--bg); color: var(--text); padding: 0 11px; font-size: 13px; outline: none;
}
.comment-box button {
  height: 34px; padding: 0 13px; border: 0; border-radius: 9px;
  background: #fff; color: #000; font-size: 13px; font-weight: 600;
}
