/* 言舟 · Claude 网页版气质：窄栏、衬线正文、深色为底 */

:root {
  --bg: #262624;
  --bg-raised: #30302e;
  --text: #f0eee6;
  --text-dim: #b8b5ad;
  --accent: #d97757;
  --bubble-user: #3d3d3a;
  --border: #4a4945;
  --code-bg: #1d1d1b;
  --serif: "Charter", "Georgia", "Songti SC", "STSong", serif;
  --sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", sans-serif;
}

@media (prefers-color-scheme: light) {
  /* 纯白 + 中性灰，贴 Claude 原生浅色（她点名：不要米白） */
  :root {
    --bg: #ffffff;
    --bg-raised: #fafafa;
    --text: #3d3d3a;
    --text-dim: #8a8a86;
    --bubble-user: #f2f2f0;
    --border: #e5e5e2;
    --code-bg: #f5f5f4;
  }
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.65;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}

/* ---- 登录 ---- */
#login {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}
#login[hidden] { display: none; }
#login-form {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  width: min(320px, 82vw);
}
.login-heart {
  font-size: 26px;
  color: #d99a8f;
  animation: heartbreathe 3.2s ease-in-out infinite;
}
@keyframes heartbreathe { 0%,100%{opacity:.55;transform:scale(1)} 50%{opacity:1;transform:scale(1.12)} }
.login-welcome {
  font-family: var(--serif);
  font-size: 34px;
  font-weight: 400;
  font-style: italic;
  letter-spacing: 0.02em;
  margin-top: 6px;
}
.login-waiting {
  font-size: 14px;
  color: var(--text-dim);
  letter-spacing: 0.12em;
  margin-bottom: 26px;
}
#login-token {
  width: 100%;
  padding: 12px 16px;
  border: none;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  background: transparent;
  color: var(--text);
  font-size: 16px;
  text-align: center;
  outline: none;
  transition: border-color .25s;
}
#login-token:focus { border-bottom-color: var(--accent); }
#login-form button {
  width: auto;
  min-width: 132px;
  padding: 10px 34px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: transparent;
  color: var(--text);
  font-size: 15px;
  font-family: var(--serif);
  letter-spacing: 0.2em;
  text-indent: 0.2em;
  transition: all .25s;
  margin-top: 6px;
}
#login-form button:hover, #login-form button:active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.login-error { min-height: 1.2em; color: var(--accent); font-size: 13px; }

/* ---- 对话 ---- */
#chat {
  height: 100dvh;
  display: flex;
  flex-direction: column;
}
#chat[hidden] { display: none; }

#scroller {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
#feed {
  max-width: 44rem;
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) 18px 12px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
#load-hint {
  text-align: center;
  color: var(--text-dim);
  padding: 8px 0 2px;
  font-size: 13px;
}

.day-chip {
  align-self: center;
  font-size: 12px;
  color: var(--text-dim);
  padding: 3px 12px;
  border-radius: 999px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  margin: 6px 0 -4px;
}

.msg { display: flex; flex-direction: column; }
.msg .body { max-width: 100%; word-break: break-word; overflow-wrap: anywhere; }

.msg.user { align-items: flex-end; }
.msg.user .body {
  max-width: 88%;
  background: var(--bubble-user);
  border-radius: 16px 16px 4px 16px;
  padding: 10px 14px;
  white-space: pre-wrap;
}

.msg.assistant .body {
  font-family: var(--serif);
  font-size: 17px;
  padding: 2px 0;
}
.msg.assistant.streaming .body { white-space: pre-wrap; }
.msg.assistant.streaming .body::after {
  content: "▍";
  color: var(--accent);
  animation: blink 1s steps(2, start) infinite;
}
@keyframes blink { to { visibility: hidden; } }

.msg.failed .body { color: var(--text-dim); }
.msg .fail-note { font-size: 12px; color: var(--accent); margin-top: 4px; }

.sys-note {
  align-self: center;
  font-size: 13px;
  color: var(--text-dim);
  padding: 2px 8px;
}
.tool-note {
  align-self: flex-start;
  font-family: var(--serif);
  font-size: 12px;
  color: var(--text-dim);
  opacity: 0.85;
  padding: 0 8px;
  margin: 2px 0;
}
.tool-trail {
  font-family: var(--serif);
  font-size: 12px;
  color: var(--text-dim);
  opacity: 0.85;
  margin-bottom: 4px;
}

/* ---- 记忆页 ---- */
#memory {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: var(--bg);
  display: flex;
  flex-direction: column;
}
#memory[hidden] { display: none; }
#memory-search { max-width: 44rem; width: 100%; margin: 0 auto; padding: 4px 16px 8px; }
#memory-q {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--bg-raised);
  color: var(--text);
  border-radius: 999px;
  padding: 9px 16px;
  font-size: 14px;
  outline: none;
}
#memory-q:focus { border-color: var(--text-dim); }
#memory-filters {
  display: flex;
  gap: 8px;
  max-width: 44rem;
  width: 100%;
  margin: 0 auto;
  padding: 0 16px 8px;
  overflow-x: auto;
}
.mem-filter {
  border: 1px solid var(--border);
  background: var(--bg-raised);
  color: var(--text-dim);
  border-radius: 999px;
  padding: 5px 14px;
  font-size: 13px;
  white-space: nowrap;
  flex: none;
}
.mem-filter.on { background: var(--accent); border-color: var(--accent); color: #fff; }
#memory-scroll {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  max-width: 44rem;
  width: 100%;
  margin: 0 auto;
  padding: 4px 16px calc(24px + env(safe-area-inset-bottom));
}
.mem-card {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px;
  margin-bottom: 10px;
}
.mem-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.mem-type { font-size: 11px; padding: 1px 8px; border-radius: 999px; flex: none; }
.mem-active { background: rgba(193,95,60,0.12); color: var(--accent); }
.mem-permanent { background: rgba(47,158,99,0.14); color: #2f9e63; }
.mem-pinned { background: rgba(217,161,59,0.16); color: #b8860b; }
.mem-archived { background: var(--bg); color: var(--text-dim); }
.mem-title { font-size: 14.5px; font-weight: 600; flex: 1; }
.mem-updated { font-size: 11px; color: var(--text-dim); }
.mem-summary { font-size: 13.5px; color: var(--text-dim); line-height: 1.65; margin-top: 6px; white-space: pre-wrap; }
#memory-empty { text-align: center; color: var(--text-dim); font-size: 13.5px; padding: 40px 24px; line-height: 1.8; }

/* ---- 朋友圈横幅（家页） ---- */
#moments-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 14px 16px;
  margin-bottom: 14px;
  font: inherit;
  color: var(--text);
  cursor: pointer;
}
#moments-banner .icon { width: 24px; height: 24px; color: var(--accent); flex: none; }
.mb-text { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; flex: 1; }
.mb-text b { font-size: 15px; }
.mb-text i { font-style: normal; font-size: 12px; color: var(--text-dim); }
#moments-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
#moments-dot[hidden] { display: none; }

/* ---- 朋友圈页 ---- */
#moments {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: var(--bg);
  display: flex;
  flex-direction: column;
}
#moments[hidden] { display: none; }
#moments-bar .icon { width: 22px; height: 22px; }
#moments-scroll {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  max-width: 44rem;
  width: 100%;
  margin: 0 auto;
  padding: 6px 16px calc(24px + env(safe-area-inset-bottom));
}
.moment {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px 16px;
  margin-bottom: 12px;
}
.mo-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 6px; }
.mo-who { font-weight: 600; font-size: 14.5px; }
.mo-time { font-size: 11.5px; color: var(--text-dim); }
.mo-body { font-size: 15px; line-height: 1.65; white-space: pre-wrap; }
.mo-img {
  margin-top: 10px;
  width: min(70%, 260px);
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border);
  cursor: pointer;
}
.mo-img img { width: 100%; display: block; opacity: 0; transition: opacity 0.25s; }
.mo-img img.ready { opacity: 1; }
.mo-liked { display: inline-block; font-size: 12px; color: var(--accent); margin-top: 10px; }
.mo-reply, .mo-comment {
  font-size: 13.5px;
  line-height: 1.6;
  background: var(--bg);
  border-radius: 10px;
  padding: 7px 11px;
  margin-top: 8px;
}
.mo-reply b, .mo-comment b { color: var(--accent); margin-right: 6px; font-weight: 600; }
.mo-comments { margin-top: 2px; }
.mo-waiting { font-size: 12px; color: var(--text-dim); margin-top: 8px; font-style: italic; }
.mo-actions { display: flex; gap: 14px; margin-top: 10px; }
.mo-actions button {
  border: none;
  background: none;
  color: var(--text-dim);
  font-size: 13px;
  padding: 2px 0;
}
.mo-like.on { color: var(--accent); }
.mo-cmt-box { display: flex; gap: 8px; margin-top: 10px; }
.mo-cmt-box[hidden] { display: none; }
.mo-cmt-box input {
  flex: 1;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 13.5px;
  outline: none;
}
.mo-cmt-box button {
  border: none;
  background: var(--accent);
  color: #fff;
  border-radius: 999px;
  padding: 7px 16px;
  font-size: 13px;
}
#moments-empty { text-align: center; color: var(--text-dim); font-size: 13.5px; padding: 40px 24px; line-height: 1.8; }
#moments-composer {
  border-top: 1px solid var(--border);
  padding: 12px 16px calc(14px + env(safe-area-inset-bottom));
  max-width: 44rem;
  width: 100%;
  margin: 0 auto;
}
#moments-composer[hidden] { display: none; }
#moment-input {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--bg-raised);
  color: var(--text);
  border-radius: 14px;
  padding: 10px 13px;
  font-size: 14.5px;
  resize: none;
  outline: none;
}
#moment-input:focus { border-color: var(--text-dim); }
#moment-compose-row { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
#moment-compose-row .icon { width: 22px; height: 22px; color: var(--text-dim); }
#moment-compose-row .spacer { flex: 1; }
#moment-photo-name { font-size: 12px; color: var(--accent); }
#moment-cancel { border: none; background: none; color: var(--text-dim); font-size: 13.5px; }
#moment-send {
  border: none;
  background: var(--accent);
  color: #fff;
  border-radius: 999px;
  padding: 7px 20px;
  font-size: 13.5px;
}

/* ---- 来信 ---- */
#letter-card {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  background: var(--bg-raised);
  border: 1px solid var(--accent);
  border-radius: 18px;
  padding: 14px 16px;
  margin-bottom: 14px;
  font: inherit;
  color: var(--text);
  cursor: pointer;
  animation: letter-glow 2.4s ease-in-out infinite;
}
@keyframes letter-glow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(193, 95, 60, 0.0); }
  50% { box-shadow: 0 0 14px 0 rgba(193, 95, 60, 0.18); }
}
#letter-card[hidden] { display: none; }
#letter-env { font-size: 26px; }
#letter-hint { font-size: 14.5px; font-family: var(--serif); letter-spacing: 0.04em; }
#letter-hint i { font-style: normal; color: var(--text-dim); font-size: 12.5px; }

#letter {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: var(--bg);
  display: flex;
  flex-direction: column;
}
#letter[hidden] { display: none; }
#letter-bar .bar-pad { width: 40px; }
#moments-bar #moments-post-open { color: var(--accent); }
#memory-bar .bar-pad { width: 40px; }
#letter-scroll {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  max-width: 40rem;
  width: 100%;
  margin: 0 auto;
  padding: 8px 20px calc(28px + env(safe-area-inset-bottom));
}
#letter-paper {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 30px 26px 34px;
  font-family: var(--serif);
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.06);
}
#letter-date { font-size: 12.5px; color: var(--text-dim); text-align: right; }
#letter-occasion {
  font-size: 13px;
  color: var(--accent);
  letter-spacing: 0.1em;
  margin: 10px 0 18px;
}
#letter-body {
  font-size: 15.5px;
  line-height: 2.05;
  white-space: pre-wrap;
  letter-spacing: 0.02em;
}
#letter-history { margin-top: 26px; }
#letter-history[hidden] { display: none; }
#letter-history-title { font-size: 12.5px; color: var(--text-dim); margin: 0 2px 8px; }
.letter-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 11px 14px;
  margin-bottom: 8px;
  font: inherit;
  font-size: 13.5px;
  color: var(--text);
}
.letter-row-occ { color: var(--text-dim); flex: 1; text-align: left; }
.letter-new { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }

/* markdown 元素（正文里） */
.body p { margin: 0.55em 0; }
.body p:first-child { margin-top: 0; }
.body p:last-child { margin-bottom: 0; }
.body h1, .body h2, .body h3, .body h4 {
  font-family: var(--serif);
  font-weight: 600;
  margin: 0.8em 0 0.35em;
  line-height: 1.35;
}
.body h1 { font-size: 1.35em; }
.body h2 { font-size: 1.22em; }
.body h3 { font-size: 1.1em; }
.body h4 { font-size: 1em; }
.body ul, .body ol { margin: 0.4em 0; padding-left: 1.4em; }
.body li { margin: 0.18em 0; }
.body blockquote {
  border-left: 3px solid var(--border);
  padding-left: 12px;
  color: var(--text-dim);
  margin: 0.5em 0;
}
/* 言舟的排版（照 claude.ai 老家的样子）：意群分隔线拉开间距；
   *动作* 的斜体渲染成正体——中文斜体本来就不该斜，app 里看着就是白描 */
.body hr { border: none; border-top: 1px solid var(--border); margin: 1.15em 0; }
.msg.assistant .body em, .diary-entry .d-body em, #bubble-comment em { font-style: normal; }
.body a { color: var(--accent); text-decoration: none; }
.body a:active { opacity: 0.7; }
.body code {
  font-family: "SF Mono", ui-monospace, Menlo, monospace;
  font-size: 0.86em;
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 1px 5px;
}
.body pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  overflow-x: auto;
  margin: 0.6em 0;
}
.body pre code { background: none; border: none; padding: 0; font-size: 0.85em; line-height: 1.55; }

/* ---- 图片消息 ---- */
.imgbox {
  position: relative;
  width: min(68%, 300px);
  max-height: 420px;
  border-radius: 14px;
  overflow: hidden;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  cursor: pointer;
}
.imgbox.tall { width: min(52%, 230px); }
.imgbox img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  opacity: 0;
  transition: opacity 0.25s ease;
}
.imgbox img.ready { opacity: 1; }
.imgbox.broken::before {
  content: "⚠ 图取不回来";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  color: var(--text-dim);
}
.msg .imgbox + .body { margin-top: 6px; }
.msg.selected .imgbox { outline: 2px solid var(--accent); }

/* iMessage 式一摞：主图完整，后面的照片露个角 */
.imgbox.stack {
  overflow: visible;
  background: transparent;
  border: none;
  margin: 8px 10px 10px 0;
}
.imgbox.stack > img:not(.stack-back) {
  position: relative;
  z-index: 2;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--bg-raised);
}
.imgbox.stack .stack-back {
  position: absolute;
  inset: 0;
  z-index: 1;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--bg-raised);
}
.stack-count {
  position: absolute;
  z-index: 3;
  top: 8px;
  right: 8px;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  pointer-events: none;
}

/* ---- 全屏查看器 ---- */
#viewer {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(0, 0, 0, 0.93);
  display: flex;
  align-items: center;
  justify-content: center;
}
#viewer[hidden] { display: none; }
#viewer img {
  max-width: 100vw;
  max-height: 100dvh;
  object-fit: contain;
}
#viewer-close {
  position: fixed;
  top: calc(12px + env(safe-area-inset-top));
  right: 14px;
  width: 38px;
  height: 38px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  font-size: 16px;
}
#viewer-prev, #viewer-next {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  width: 42px;
  height: 42px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  font-size: 26px;
  line-height: 1;
  padding-bottom: 4px;
}
#viewer-prev { left: 12px; }
#viewer-next { right: 12px; }
#viewer-prev[hidden], #viewer-next[hidden], #viewer-dots[hidden] { display: none; }
#viewer-dots {
  position: fixed;
  bottom: calc(22px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 7px;
}
#viewer-dots i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.35);
}
#viewer-dots i.on { background: #fff; }

/* ---- 线性图标（Claude 原生风） ---- */
.icon {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  display: block;
}

/* ---- 输入区（一个圆角盒：上输入、下按钮行，照 Claude app） ---- */
#composer {
  position: relative;
  max-width: 44rem;
  width: 100%;
  margin: 0 auto;
  padding: 4px 14px calc(10px + env(safe-area-inset-bottom));
}
#composer-box {
  border: 1px solid var(--border);
  border-radius: 22px;
  background: var(--bg-raised);
  padding: 10px 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
#composer-box:focus-within { border-color: var(--text-dim); } /* 原生 Claude 不用橙框 */
#input {
  width: 100%;
  resize: none;
  border: none;
  background: none;
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.45;
  padding: 2px 6px;
  max-height: 148px;
  outline: none;
}
#composer-row { display: flex; align-items: center; gap: 6px; }
.composer-spacer { flex: 1; }
#composer-row button {
  width: 36px;
  height: 36px;
  flex: none;
  border: none;
  border-radius: 50%;
  background: none;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
#photo { border: 1px solid var(--border); }
#photo:disabled { opacity: 0.4; }
#send {
  background: var(--accent);
  color: #fff;
}
#send:disabled { opacity: 0.4; }
#send .icon { stroke-width: 2; }
#mic { user-select: none; -webkit-user-select: none; touch-action: none; }
#mic.recording {
  background: var(--accent);
  color: #fff;
  animation: rec-pulse 1.2s ease-in-out infinite;
}
@keyframes rec-pulse { 50% { transform: scale(1.12); } }

}

/* ---- 语音气泡 ---- */
.voicebox {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 150px;
  max-width: 240px;
  background: var(--bubble-user);
  border-radius: 16px 16px 4px 16px;
  padding: 10px 14px 12px;
  cursor: pointer;
}
.voicebox::after {
  content: "";
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 6px;
  height: 2px;
  border-radius: 1px;
  background: linear-gradient(to right, var(--accent) var(--p, 0%), transparent 0);
}
.v-btn { font-size: 13px; color: var(--accent); }
.v-bars {
  display: flex;
  align-items: center;
  gap: 2px;
  height: 22px;
  flex: 1;
}
.v-bars i {
  width: 3px;
  background: var(--text-dim);
  border-radius: 2px;
  display: block;
}
.voicebox.playing .v-bars i { background: var(--accent); }
.v-dur { font-size: 12px; color: var(--text-dim); }
.v-text {
  margin-top: 6px;
  font-size: 13px;
  color: var(--text-dim);
  max-width: 88%;
}
.msg.selected .voicebox { outline: 2px solid var(--accent); }

/* ---- 朗读 ---- */
.speak {
  border: none;
  background: none;
  padding: 4px 0 0;
  color: var(--text-dim);
  opacity: 0.55;
  cursor: pointer;
  align-self: flex-start;
}
.speak .icon { width: 16px; height: 16px; }
.speak.speaking { opacity: 1; animation: speak-pulse 1s ease-in-out infinite; }
@keyframes speak-pulse { 50% { opacity: 0.35; } }

/* ---- 顶栏 ---- */
#topbar, #fav-bar, #diary-bar, #books-bar, #reader-bar, #search-bar, #notes-bar, #body-bar, #habits-bar, #mcp-bar, #moments-bar, #letter-bar, #memory-bar, #focus-bar, #room-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 44rem;
  width: 100%;
  margin: 0 auto;
  padding: calc(6px + env(safe-area-inset-top)) 16px 6px;
}
.topbar-title {
  font-family: var(--serif);
  font-size: 17px;
  letter-spacing: 0.18em;
  text-indent: 0.18em;
}
#topbar button, #fav-bar button, #album-bar button, #diary-bar button,
#books-bar button, #reader-bar button, #search-bar button, #notes-bar button, #body-bar button, #habits-bar button, #mcp-bar button, #moments-bar button, #letter-bar button, #memory-bar button, #focus-bar button, #room-bar button {
  border: none;
  background: none;
  color: var(--text);
  font-size: 20px;
  padding: 6px 10px;
}
.topbar-actions { display: flex; gap: 2px; }
.topbar-actions button { color: var(--text-dim); }
#fav-bar #fav-add, #album-bar #album-add, #books-bar #book-add { color: var(--accent); font-size: 24px; }
#diary-bar #diary-write { color: var(--accent); }
#album-bar #album-add[hidden] { visibility: hidden; display: block; } /* 占位不跳版 */
#album-sheet-list { display: flex; flex-wrap: wrap; gap: 8px; max-height: 40vh; overflow-y: auto; }
#album-sheet-list[hidden] { display: none; }
#album-sheet-list .cat-chip { font-size: 14px; padding: 8px 16px; color: var(--text); }

/* ---- 多选模式 ---- */
#multibar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  max-width: 44rem;
  width: 100%;
  margin: 0 auto;
  padding: 6px 16px;
  font-size: 14px;
  color: var(--text-dim);
}
#multibar[hidden] { display: none; }
#multibar button {
  border: 1px solid var(--border);
  background: var(--bg-raised);
  color: var(--text);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 14px;
}
#multibar button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
body.multi-on .msg { cursor: pointer; }
body.multi-on .msg .body { pointer-events: none; }
.msg.selected .body { outline: 2px solid var(--accent); border-radius: 12px; }
.msg.assistant.selected .body { padding: 6px 10px; }

/* ---- 收藏页 ---- */
#fav {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: var(--bg);
  display: flex;
  flex-direction: column;
}
#fav[hidden] { display: none; }
#fav-cats {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 16px 8px;
  max-width: 44rem;
  width: 100%;
  margin: 0 auto;
  scrollbar-width: none;
}
#fav-cats::-webkit-scrollbar { display: none; }
.cat-chip {
  flex: none;
  border: 1px solid var(--border);
  background: var(--bg-raised);
  color: var(--text-dim);
  border-radius: 999px;
  padding: 5px 13px;
  font-size: 13px;
}
.cat-chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
#fav-search-wrap {
  max-width: 44rem;
  width: 100%;
  margin: 0 auto;
  padding: 0 16px 8px;
}
#fav-search {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-raised);
  color: var(--text);
  font-size: 15px;
  padding: 9px 14px;
  outline: none;
  -webkit-appearance: none;
}
#fav-search:focus { border-color: var(--accent); }
#fav-scroll { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }
#fav-list {
  max-width: 44rem;
  margin: 0 auto;
  padding: 4px 16px calc(24px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.fav-card {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px;
}
.fav-card .fav-body { font-family: var(--serif); font-size: 15.5px; overflow-wrap: anywhere; }
.fav-card .fav-body.clamp {
  display: -webkit-box;
  -webkit-line-clamp: 8;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.fav-meta {
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-dim);
  display: flex;
  gap: 8px;
}
.fav-meta .cat { color: var(--accent); }
#fav-more, #fav-empty {
  text-align: center;
  color: var(--text-dim);
  font-size: 13px;
  padding: 12px 0 20px;
}

/* ---- 相册页 ---- */
#album {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: var(--bg);
  display: flex;
  flex-direction: column;
}
#album[hidden] { display: none; }
#album-bar { display: flex; align-items: center; justify-content: space-between; }
#album-bar .bar-pad { width: 40px; }
#album-scroll { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }
#album-index {
  max-width: 44rem;
  margin: 0 auto;
  padding: 8px 16px calc(24px + env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}
#album-index[hidden] { display: none; }
.album-card { cursor: pointer; }
.album-cover {
  aspect-ratio: 1;
  border-radius: 14px;
  overflow: hidden;
  background: var(--bg-raised);
  border: 1px solid var(--border);
}
.album-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  opacity: 0;
  transition: opacity 0.25s ease;
}
.album-cover img.ready { opacity: 1; }
.album-cover.empty::before {
  content: "🖼";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 34px;
  opacity: 0.45;
}
.album-cover { position: relative; }
.album-card.time .album-cover { border-radius: 999px; }
.album-label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 8px 2px 0;
  font-size: 14px;
}
.album-label .n { color: var(--text-dim); font-size: 12px; }
#album-grid {
  max-width: 44rem;
  margin: 0 auto;
  padding: 8px 16px calc(24px + env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  width: 100%;
}
#album-grid[hidden] { display: none; }
.album-cell {
  aspect-ratio: 1;
  overflow: hidden;
  border-radius: 6px;
  background: var(--bg-raised);
  cursor: pointer;
}
.album-cell img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  opacity: 0;
  transition: opacity 0.2s ease;
}
.album-cell img.ready { opacity: 1; }
#album-empty {
  text-align: center;
  color: var(--text-dim);
  font-size: 13px;
  padding: 40px 0;
}

/* ---- 日记页 ---- */
#diary {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: var(--bg);
  display: flex;
  flex-direction: column;
}
#diary[hidden] { display: none; }
#diary-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  max-width: 44rem;
  width: 100%;
  margin: 0 auto;
  padding: 2px 16px 8px;
}
#diary-nav button {
  border: none;
  background: none;
  color: var(--text-dim);
  font-size: 24px;
  line-height: 1;
  padding: 2px 16px;
}
#diary-nav button:disabled { opacity: 0.25; }
#diary-month {
  font-family: var(--serif);
  font-size: 15px;
  letter-spacing: 0.08em;
  min-width: 6.5em;
  text-align: center;
}
#diary-scroll { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }
#diary-list {
  max-width: 44rem;
  margin: 0 auto;
  padding: 4px 16px calc(24px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.diary-day {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px;
}
.diary-date { font-size: 12px; color: var(--text-dim); margin-bottom: 8px; }
.d-dream {
  font-family: var(--serif);
  font-size: 12.5px;
  color: var(--text-dim);
  line-height: 1.7;
  margin-bottom: 10px;
  padding: 8px 10px;
  border: 1px dashed var(--border);
  border-radius: 10px;
}
.diary-entry + .diary-entry, .diary-entry + .d-add {
  border-top: 1px dashed var(--border);
  margin-top: 10px;
  padding-top: 10px;
}
.d-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 4px; }
.d-who { font-size: 12px; color: var(--accent); letter-spacing: 0.1em; }
.diary-entry.me .d-who { color: var(--text-dim); }
.d-mood { font-size: 12px; color: var(--text-dim); }
.d-body { font-family: var(--serif); font-size: 15.5px; overflow-wrap: anywhere; }
.diary-entry.me .d-body { white-space: pre-wrap; }
.d-add {
  display: block;
  width: 100%;
  text-align: left;
  border: none;
  background: none;
  color: var(--accent);
  font-size: 13px;
  padding: 0;
}
#diary-empty {
  text-align: center;
  color: var(--text-dim);
  font-size: 13px;
  padding: 40px 24px;
  line-height: 1.8;
}
.diary-reply-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-dim);
}
.diary-reply-toggle input { accent-color: var(--accent); width: 16px; height: 16px; }

/* ---- 照片详情 ---- */
#photo-detail {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(0, 0, 0, 0.93);
  display: flex;
  align-items: center;
  justify-content: center;
}
#photo-detail[hidden] { display: none; }
#photo-detail img {
  max-width: 100vw;
  max-height: calc(100dvh - 120px);
  object-fit: contain;
}
#detail-close {
  position: fixed;
  top: calc(12px + env(safe-area-inset-top));
  right: 14px;
  width: 38px;
  height: 38px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  font-size: 16px;
}
#detail-cap {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 14px 20px calc(16px + env(safe-area-inset-bottom));
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.75));
  color: #fff;
  font-family: var(--serif);
  font-size: 15px;
  text-align: center;
  line-height: 1.5;
}
#detail-cap .detail-sub { font-size: 12px; opacity: 0.75; font-family: var(--sans); }

/* ---- 弹层（分类选择 / 粘贴新建） ---- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.overlay[hidden] { display: none; }
.sheet-card {
  width: min(44rem, 100%);
  background: var(--bg-raised);
  border-radius: 18px 18px 0 0;
  padding: 18px 18px calc(18px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.sheet-card h3 { font-size: 15px; font-weight: 600; color: var(--text-dim); }
#sheet-cats { display: flex; flex-wrap: wrap; gap: 8px; max-height: 40vh; overflow-y: auto; }
#sheet-cats .cat-chip { font-size: 14px; padding: 8px 16px; color: var(--text); }
.sheet-new { display: flex; gap: 8px; }
.sheet-new input, #paste-text, #diary-text {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  font-family: var(--sans);
  padding: 9px 12px;
  outline: none;
}
.sheet-new input:focus, #paste-text:focus, #diary-text:focus { border-color: var(--accent); }
#paste-text, #diary-text { resize: none; width: 100%; }
#diary-text { font-family: var(--serif); }
.sheet-new button, .sheet-actions button {
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  border-radius: 10px;
  padding: 9px 16px;
  font-size: 15px;
}
.sheet-actions { display: flex; justify-content: flex-end; gap: 10px; }
.sheet-actions .primary, .sheet-new button { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ---- 书架（M10b） ---- */
#books {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: var(--bg);
  display: flex;
  flex-direction: column;
}
#books[hidden] { display: none; }
#books-scroll { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }
#books-grid {
  max-width: 44rem;
  margin: 0 auto;
  padding: 8px 16px calc(24px + env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px 14px;
  width: 100%;
}
.book-card { cursor: pointer; }
.book-cover {
  aspect-ratio: 2 / 3;
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
}
.book-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  opacity: 0;
  transition: opacity 0.25s ease;
}
.book-cover img.ready { opacity: 1; }
.book-cover.plain {
  font-family: var(--serif);
  font-size: 13.5px;
  color: var(--text-dim);
  padding: 10px;
  text-align: center;
  line-height: 1.6;
}
.book-label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 6px;
  padding: 6px 2px 0;
  font-size: 12px;
}
.book-label .bt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.book-label .bp { color: var(--text-dim); flex: none; }
#books-empty {
  text-align: center;
  color: var(--text-dim);
  font-size: 13px;
  padding: 48px 28px;
  line-height: 1.8;
}

/* ---- 阅读器 ---- */
#reader {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: var(--bg);
  display: flex;
  flex-direction: column;
}
#reader[hidden] { display: none; }
.reader-title {
  flex: 1;
  text-align: center;
  font-family: var(--serif);
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 0 6px;
}
#reader-pct { font-size: 12px; color: var(--text-dim); min-width: 36px; text-align: right; }
#reader-view {
  flex: 1;
  overflow: hidden;
  max-width: 44rem;
  width: 100%;
  margin: 0 auto;
}
#reader-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 44rem;
  width: 100%;
  margin: 0 auto;
  padding: 4px 10px calc(8px + env(safe-area-inset-bottom));
}
#reader-nav button {
  border: none;
  background: none;
  color: var(--text-dim);
  font-size: 26px;
  line-height: 1;
  padding: 2px 18px;
}
#reader-hint { font-size: 12px; color: var(--text-dim); opacity: 0.7; }
#quote-ask {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  background: var(--bg-raised);
  border-top: 1px solid var(--border);
  padding: 14px 18px calc(14px + env(safe-area-inset-bottom));
  box-shadow: 0 -8px 28px rgba(0, 0, 0, 0.15);
}
#quote-ask[hidden] { display: none; }
#quote-ask-text {
  font-family: var(--serif);
  font-size: 14px;
  color: var(--text-dim);
  margin-bottom: 10px;
}
#quote-bubble {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(12px + env(safe-area-inset-bottom));
  z-index: 40;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px 40px 14px 16px;
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.2);
  max-height: 45dvh;
  overflow-y: auto;
}
#quote-bubble[hidden] { display: none; }
#bubble-state { font-size: 13px; color: var(--text-dim); }
#bubble-comment { font-family: var(--serif); font-size: 15.5px; overflow-wrap: anywhere; }
#bubble-close {
  position: absolute;
  top: 8px;
  right: 8px;
  border: none;
  background: none;
  color: var(--text-dim);
  font-size: 14px;
  padding: 6px;
}

/* ---- 搜索页（P1） ---- */
#search {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: var(--bg);
  display: flex;
  flex-direction: column;
}
#search[hidden] { display: none; }
#search-bar .bar-pad, #notes-bar .bar-pad { width: 40px; }
#search-input-wrap {
  max-width: 44rem;
  width: 100%;
  margin: 0 auto;
  padding: 0 16px 8px;
}
#search-input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-raised);
  color: var(--text);
  font-size: 15px;
  padding: 9px 14px;
  outline: none;
  -webkit-appearance: none;
}
#search-input:focus { border-color: var(--text-dim); }
#search-scroll { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }
#search-results[hidden], #search-context[hidden] { display: none; }
#search-results, #search-context {
  max-width: 44rem;
  margin: 0 auto;
  padding: 4px 16px calc(24px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.search-hit {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 13px;
  cursor: pointer;
}
.hit-meta {
  display: flex;
  gap: 8px;
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 4px;
}
.hit-who { color: var(--accent); }
.hit-snip { font-family: var(--serif); font-size: 14.5px; overflow-wrap: anywhere; }
.hit-snip mark { background: rgba(217, 119, 87, 0.25); color: inherit; border-radius: 3px; padding: 0 1px; }
#search-empty { text-align: center; color: var(--text-dim); font-size: 13px; padding: 30px 0; }
#context-back {
  align-self: flex-start;
  border: 1px solid var(--border);
  background: var(--bg-raised);
  color: var(--text-dim);
  border-radius: 999px;
  padding: 5px 14px;
  font-size: 13px;
}
.ctx-msg { padding: 8px 10px; border-radius: 12px; }
.ctx-msg.anchor { background: rgba(217, 119, 87, 0.08); border: 1px solid rgba(217, 119, 87, 0.35); }
.ctx-who { font-size: 11.5px; color: var(--text-dim); margin-bottom: 3px; }
.ctx-msg.user .ctx-who { color: var(--accent); }
.ctx-body { font-family: var(--serif); font-size: 15px; overflow-wrap: anywhere; }
.ctx-body em { font-style: normal; }
.ctx-body hr { border: none; border-top: 1px solid var(--border); margin: 0.8em 0; }

/* ---- 便签页（P1） ---- */
#notes {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: var(--bg);
  display: flex;
  flex-direction: column;
}
#notes[hidden] { display: none; }
#note-new {
  display: flex;
  gap: 8px;
  max-width: 44rem;
  width: 100%;
  margin: 0 auto;
  padding: 0 16px 8px;
}
#note-new input {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-raised);
  color: var(--text);
  font-size: 15px;
  padding: 9px 14px;
  outline: none;
}
#note-new input:focus { border-color: var(--text-dim); }
#note-new button {
  border: none;
  border-radius: 12px;
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  padding: 0 16px;
}
#notes-scroll { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }
#notes-list {
  max-width: 44rem;
  margin: 0 auto;
  padding: 4px 16px calc(24px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.note-card {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 13px;
}
.note-body { font-size: 15px; overflow-wrap: anywhere; }
.note-meta {
  margin-top: 6px;
  font-size: 12px;
  color: var(--text-dim);
  display: flex;
  gap: 8px;
}
#notes-empty {
  text-align: center;
  color: var(--text-dim);
  font-size: 13px;
  padding: 40px 24px;
  line-height: 1.8;
}

/* ---- 「家」首页 ---- */
#home {
  height: 100dvh;
  display: flex;
  flex-direction: column;
}
#home[hidden] { display: none; }
#home-scroll {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  max-width: 44rem;
  width: 100%;
  margin: 0 auto;
  padding: calc(14px + env(safe-area-inset-top)) 18px 20px;
}
#home-head {
  font-size: 12px;
  letter-spacing: 0.35em;
  color: var(--text-dim);
  margin: 2px 2px 14px;
}
#home-head i { font-style: normal; color: var(--accent); }
#char-card, #pulse-card {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 18px 18px 14px;
  margin-bottom: 14px;
}
#char-row { display: flex; gap: 14px; align-items: center; }
#char-avatar {
  width: 74px;
  height: 74px;
  flex: none;
  border-radius: 24px;
  background: rgba(217, 119, 87, 0.1);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
}
#char-info { flex: 1; min-width: 0; }
#char-name {
  font-family: var(--serif);
  font-size: 21px;
  letter-spacing: 0.06em;
  display: flex;
  align-items: center;
  gap: 7px;
}
#char-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  display: inline-block;
}
#char-status {
  font-size: 13px;
  color: var(--text-dim);
  margin-top: 3px;
  line-height: 1.6;
}
#char-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 9px; }
.chip {
  font-size: 11.5px;
  color: var(--accent);
  background: rgba(217, 119, 87, 0.09);
  border: 1px solid rgba(217, 119, 87, 0.25);
  border-radius: 999px;
  padding: 2.5px 10px;
}
#char-sign {
  display: flex;
  justify-content: space-between;
  border-top: 1px solid var(--border);
  margin-top: 14px;
  padding-top: 9px;
  font-size: 11.5px;
  color: var(--text-dim);
}
#char-sign span:first-child { font-family: var(--serif); font-style: italic; }
#char-sign-r { letter-spacing: 0.14em; }
.pulse-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--serif);
  font-size: 16px;
  margin-bottom: 12px;
}
.pulse-title .icon { width: 18px; height: 18px; color: var(--accent); }
.pulse-title span { font-size: 11.5px; color: var(--text-dim); letter-spacing: 0.1em; }
.pulse-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 7px 0;
}
.p-label { width: 34px; flex: none; font-size: 12px; color: var(--text-dim); }
.p-track {
  flex: 1;
  height: 6px;
  border-radius: 3px;
  background: var(--bubble-user);
  overflow: hidden;
}
.p-track i {
  display: block;
  height: 100%;
  border-radius: 3px;
  background: linear-gradient(to right, var(--accent), #e8a58e);
}
.p-val {
  width: 26px;
  flex: none;
  text-align: right;
  font-size: 11px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}
#pulse-gravity {
  text-align: center;
  font-size: 12px;
  color: var(--text-dim);
  border-top: 1px dashed var(--border);
  margin-top: 11px;
  padding-top: 9px;
}
#home-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}
.mod-card {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px 12px 12px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  color: var(--text);
}
.mod-card .icon { color: var(--accent); margin-bottom: 5px; }
.mod-name { font-size: 14px; }
.mod-count { font-size: 11px; color: var(--text-dim); }
.room-entry-card {
  grid-column: 1 / -1;
  min-height: 92px;
  padding: 8px 12px 8px 8px;
  flex-direction: row;
  align-items: center;
  gap: 12px;
  overflow: hidden;
  text-align: left;
  cursor: pointer;
}
.room-entry-thumb {
  width: 116px;
  height: 74px;
  flex: none;
  overflow: hidden;
  border-radius: 12px;
  position: relative;
  background: #eef4f5;
  border: 1px solid var(--border);
  box-shadow: inset 0 -16px 22px rgba(69, 56, 48, .08);
}
.room-entry-thumb img { width: 100%; height: 100%; display: block; object-fit: cover; object-position: center 48%; }
.room-entry-thumb i { position: absolute; display: block; border: 1px solid rgba(48, 50, 64, .28); }
.mini-room-wall { inset: 7px 9px 17px; background: linear-gradient(135deg, #f8f2e9, #e8edf4); clip-path: polygon(50% 0,100% 24%,100% 100%,0 100%,0 24%); }
.mini-room-bed { left: 15px; bottom: 13px; width: 38px; height: 22px; border-radius: 4px; background: #f8f4ec; box-shadow: inset 0 7px #7894ba, 2px 3px #695f5d; transform: skewY(-7deg); }
.mini-room-sofa { right: 19px; bottom: 10px; width: 35px; height: 19px; border-radius: 6px; background: #8398b8; box-shadow: inset 0 7px #a7b6cd, 2px 3px #5c6070; transform: skewY(7deg); }
.mini-room-tv { right: 16px; top: 20px; width: 26px; height: 16px; border-radius: 2px; background: #253247; box-shadow: 0 2px #685f59; }
.room-entry-copy { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.room-entry-copy .mod-name { font-family: var(--serif); font-size: 16px; }
.room-entry-arrow { width: 18px; height: 18px; flex: none; color: var(--text-dim) !important; }
#tabbar {
  display: flex;
  border-top: 1px solid var(--border);
  background: var(--bg);
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
}
#tabbar .tab {
  flex: 1;
  border: none;
  background: none;
  color: var(--text-dim);
  font-size: 11px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 4px 0;
  border-radius: 12px;
}
#tabbar .tab .icon { width: 21px; height: 21px; }
#tabbar .tab.on { color: var(--accent); }

/* ---- 可拖动的前端小人 ---- */
#front-pet {
  position: fixed;
  z-index: 38;
  left: calc(100vw - 150px);
  top: calc(100dvh - 250px);
  width: clamp(108px, 25vw, 148px);
  height: clamp(98px, 23vw, 134px);
  touch-action: none;
  user-select: none;
  cursor: grab;
  filter: drop-shadow(0 9px 12px rgba(0, 0, 0, .2));
}
#front-pet[hidden] { display: none; }
#front-pet.dragging { cursor: grabbing; }
#front-pet-img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  pointer-events: none;
}
.pet-speech {
  position: absolute;
  z-index: 8;
  left: 50%;
  bottom: calc(100% - 8px);
  transform: translateX(-50%);
  width: max-content;
  max-width: min(230px, 72vw);
  padding: 8px 11px;
  border: 1px solid rgba(54, 50, 46, .12);
  border-radius: 14px 14px 14px 4px;
  background: rgba(255, 255, 255, .96);
  color: #32302d;
  box-shadow: 0 8px 24px rgba(34, 29, 24, .16);
  font-size: 12px;
  line-height: 1.45;
  text-align: left;
}
.pet-speech[hidden] { display: none; }

/* ---- 首页小屋入口 ---- */
.room-entry-card {
  grid-column: 1 / -1;
  min-height: 104px;
  display: grid !important;
  grid-template-columns: 108px 1fr 24px;
  align-items: center;
  gap: 14px;
  overflow: hidden;
  text-align: left;
}
.room-entry-thumb {
  width: 108px;
  height: 82px;
  overflow: hidden;
  border-radius: 18px;
  background: #eaf4fb;
  box-shadow: inset 0 0 0 1px rgba(92, 112, 128, .09);
}
.room-entry-thumb img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  object-position: 50% 35%;
}
.room-entry-copy { min-width: 0; display: flex; flex-direction: column; gap: 7px; }
.room-entry-arrow { width: 20px; height: 20px; color: #9ca7af; }

/* ---- 全新竖屏小屋 ---- */
#room {
  --room-bar-height: calc(54px + env(safe-area-inset-top));
  position: fixed;
  z-index: 50;
  inset: 0;
  width: min(100vw, 480px);
  margin: auto;
  overflow: hidden;
  background: #edf5fa;
  color: #433e38;
  box-shadow: 0 0 40px rgba(45, 57, 67, .18);
}
#room[hidden] { display: none; }
#room-bar {
  position: relative;
  z-index: 7000;
  height: var(--room-bar-height);
  padding: env(safe-area-inset-top) 10px 0;
  display: grid;
  grid-template-columns: 92px 1fr 92px;
  align-items: center;
  background: rgba(255, 253, 249, .96);
  border-bottom: 1px solid rgba(104, 91, 76, .1);
  backdrop-filter: blur(14px);
}
#room-bar .topbar-title {
  justify-self: center;
  font-family: "Songti SC", "STSong", serif;
  font-size: 17px;
  letter-spacing: .12em;
  white-space: nowrap;
}
#room-close,
#room-follow-toggle {
  border: 0;
  min-height: 36px;
  border-radius: 18px;
  background: transparent;
  color: #625c55;
}
#room-close {
  justify-self: start;
  width: 42px;
  font-size: 22px;
}
#room-follow-toggle {
  justify-self: end;
  padding: 0 11px;
  background: #edf5fb;
  color: #61798b;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}
#room-follow-toggle[aria-pressed="true"] {
  background: #dcecf8;
  color: #3f708f;
}
#room-stage {
  position: absolute;
  inset: var(--room-bar-height) 0 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 20% 18%, rgba(255,255,255,.9), transparent 32%),
    linear-gradient(180deg, #dceef8 0%, #f7f0e6 100%);
}
#room-viewport {
  position: absolute;
  inset: 0;
  overflow: hidden;
  touch-action: none;
  overscroll-behavior: none;
  user-select: none;
  cursor: grab;
}
#room-viewport:active { cursor: grabbing; }
#room-world {
  position: absolute;
  left: 0;
  top: 0;
  width: 941px;
  height: 1672px;
  transform-origin: 0 0;
  will-change: transform;
  overflow: hidden;
  background: #f4eadb;
}
#room-scene {
  position: absolute;
  z-index: 1;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}
#room-indicators {
  position: absolute;
  z-index: 5000;
  inset: 0;
  pointer-events: none;
}
.room-interaction-marker {
  position: absolute;
  transform: translate(-50%, -50%);
  min-width: 72px;
  min-height: 72px;
  padding: 0;
  border: 0;
  background: transparent;
  color: #536a7b;
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
}
#room-indicators.markers-visible .room-interaction-marker {
  opacity: 1;
  pointer-events: auto;
}
.room-interaction-marker > span {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  transform: translate(-50%, -50%);
  border: 2px solid rgba(255,255,255,.95);
  border-radius: 50%;
  background: rgba(112, 153, 184, .9);
  color: #fff;
  box-shadow: 0 4px 13px rgba(48, 73, 91, .23);
  font-size: 17px;
  animation: room-marker-pulse 1.8s ease-in-out infinite;
}
.room-interaction-marker b {
  position: absolute;
  top: calc(50% + 24px);
  left: 50%;
  transform: translateX(-50%);
  width: max-content;
  padding: 4px 8px;
  border-radius: 10px;
  background: rgba(255,255,255,.93);
  box-shadow: 0 3px 10px rgba(63, 61, 58, .12);
  color: #5b6266;
  font-size: 11px;
  line-height: 1;
}
@keyframes room-marker-pulse {
  0%, 100% { transform: translate(-50%, -50%) scale(.92); box-shadow: 0 4px 13px rgba(48,73,91,.2); }
  50% { transform: translate(-50%, -50%) scale(1.08); box-shadow: 0 5px 19px rgba(48,73,91,.34); }
}

/* 人物锚点永远落在脚下；近处只按纵深统一放大 */
.home-actor {
  --actor-scale: 1;
  position: absolute;
  width: 148px;
  height: 178px;
  transform: translate(-50%, -100%) scale(var(--actor-scale));
  transform-origin: 50% 100%;
  pointer-events: auto;
  user-select: none;
  will-change: left, top, transform;
  filter: drop-shadow(0 7px 5px rgba(69, 49, 32, .18));
}
.home-actor-standing,
.home-actor-lying {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  pointer-events: none;
  -webkit-user-drag: none;
}
.home-actor-lying[hidden],
.home-actor-standing[hidden] { display: none; }
.home-actor.is-lying {
  width: 232px;
  height: 132px;
  transform: translate(-50%, -58%) scale(var(--actor-scale));
  filter: drop-shadow(0 4px 4px rgba(69,49,32,.13));
}
.home-actor[data-pose="sit"] {
  width: 158px;
  height: 162px;
}
#room-boy { cursor: pointer; }
#room-girl { pointer-events: auto; }

/* 睡觉时只露出枕边头发，身体由独立被面盖住 */
#room-bed-cover {
  position: absolute;
  z-index: 1405;
  left: 337px;
  top: 273px;
  width: 126px;
  height: 57px;
  display: none;
  border: 1px solid rgba(132, 157, 178, .18);
  border-radius: 32px 30px 16px 20px;
  background:
    linear-gradient(150deg, rgba(255,255,255,.7), transparent 43%),
    linear-gradient(135deg, #dbe8f2, #eef5f9);
  box-shadow: 0 3px 7px rgba(83, 91, 95, .09);
  transform: rotate(-3deg);
  pointer-events: none;
}
#room-bed-cover.show-girl,
#room-bed-cover.show-boy { display: block; }
#room-tv-glow {
  position: absolute;
  z-index: 1685; /* 电视柜切片是 1684，光晕要在它上面 */
  left: 272px;
  top: 505px;
  width: 210px;
  height: 112px;
  border-radius: 8px;
  background: rgba(143, 202, 240, .0);
  box-shadow: 0 0 0 rgba(117, 190, 235, 0);
  pointer-events: none;
  transition: .25s ease;
}
#room-tv-glow.on {
  background: rgba(149, 211, 247, .26);
  box-shadow: 0 0 35px rgba(117, 190, 235, .52);
}

#room-loading {
  position: absolute;
  z-index: 6500;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 12px;
  background: #eef6fa;
  color: #768895;
  font-size: 13px;
  text-align: center;
}
#room-loading[hidden] { display: none; }
#room-loading span {
  width: 30px;
  height: 30px;
  margin: auto;
  border: 3px solid #cfe2ee;
  border-top-color: #6f99b4;
  border-radius: 50%;
  animation: room-spin .8s linear infinite;
}
@keyframes room-spin { to { transform: rotate(360deg); } }
#room-hint,
#room-object-tip {
  position: absolute;
  z-index: 6100;
  left: 50%;
  transform: translateX(-50%);
  width: max-content;
  max-width: calc(100% - 24px);
  padding: 7px 12px;
  border-radius: 16px;
  background: rgba(46, 49, 51, .76);
  color: #fff;
  box-shadow: 0 5px 15px rgba(0,0,0,.12);
  font-size: 11px;
  line-height: 1.35;
  text-align: center;
  pointer-events: none;
}
#room-hint { bottom: calc(12px + env(safe-area-inset-bottom)); }
#room-object-tip { bottom: calc(50px + env(safe-area-inset-bottom)); }
#room-object-tip[hidden] { display: none; }

/* ---- 双人换装衣柜 ---- */
#wardrobe-drawer {
  --wardrobe-accent: #779dce;
  position: absolute;
  z-index: 9000;
  inset: 0;
  display: flex;
  align-items: flex-end;
}
#wardrobe-drawer[hidden] { display: none; }
#wardrobe-backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  background: rgba(49, 52, 57, .34);
  opacity: 0;
  transition: opacity .22s ease;
}
#wardrobe-panel {
  position: relative;
  z-index: 1;
  width: 100%;
  max-height: min(82dvh, 720px);
  padding: 14px 14px calc(14px + env(safe-area-inset-bottom));
  overflow-y: auto;
  border-radius: 26px 26px 0 0;
  background: #fbfaf8;
  box-shadow: 0 -14px 50px rgba(37, 42, 48, .2);
  transform: translateY(102%);
  transition: transform .24s cubic-bezier(.22,.76,.3,1);
}
#wardrobe-drawer.open #wardrobe-backdrop { opacity: 1; }
#wardrobe-drawer.open #wardrobe-panel { transform: translateY(0); }
.wardrobe-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 2px 2px 10px;
}
.wardrobe-head h2 {
  margin: 2px 0 0;
  color: #42464d;
  font-size: 20px;
}
.wardrobe-kicker {
  color: var(--wardrobe-accent);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .18em;
}
#wardrobe-close {
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 50%;
  background: #ececef;
  color: #767b83;
  font-size: 22px;
}
.wardrobe-owners {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
  padding: 4px;
  border-radius: 15px;
  background: #eceef1;
}
.wardrobe-owners button {
  min-height: 38px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: #7f8389;
  font-size: 12px;
  font-weight: 700;
}
.wardrobe-owners button.active {
  background: #fff;
  color: var(--wardrobe-accent);
  box-shadow: 0 3px 10px rgba(51, 57, 64, .08);
}
.wardrobe-preview {
  position: relative;
  height: 190px;
  margin-top: 10px;
  display: grid;
  grid-template-columns: 45% 55%;
  align-items: center;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--wardrobe-accent) 18%, #fff);
  border-radius: 20px;
  background:
    radial-gradient(circle at 22% 38%, color-mix(in srgb, var(--wardrobe-accent) 19%, #fff), transparent 43%),
    #fff;
}
.wardrobe-preview-dot {
  position: absolute;
  left: 22px;
  top: 18px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--wardrobe-accent);
  box-shadow: 14px 0 color-mix(in srgb, var(--wardrobe-accent) 45%, #fff);
}
#wardrobe-preview-img {
  width: 100%;
  height: 184px;
  align-self: end;
  object-fit: contain;
}
.wardrobe-preview-copy {
  padding: 12px 16px 12px 4px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.wardrobe-preview-copy strong { color: #484c53; font-size: 16px; }
.wardrobe-preview-copy span { color: #8a8f96; font-size: 11px; line-height: 1.5; }
.wardrobe-tabs {
  margin: 13px 2px 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #969aa0;
  font-size: 10px;
}
.wardrobe-tabs button {
  border: 0;
  padding: 6px 12px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--wardrobe-accent) 15%, #fff);
  color: var(--wardrobe-accent);
  font-size: 11px;
  font-weight: 800;
}
.wardrobe-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.wardrobe-outfit {
  position: relative;
  min-height: 122px;
  padding: 6px 8px 9px;
  display: grid;
  grid-template-rows: 88px auto;
  border: 1px solid #e7e8ea;
  border-radius: 16px;
  background: #fff;
  color: #686d75;
  font-size: 10px;
  text-align: center;
}
.wardrobe-outfit.selected {
  border-color: var(--wardrobe-accent);
  box-shadow: inset 0 0 0 1px var(--wardrobe-accent);
  color: var(--wardrobe-accent);
}
.wardrobe-outfit-img { min-width: 0; overflow: hidden; }
.wardrobe-outfit-img img { width: 100%; height: 88px; object-fit: contain; }
.wardrobe-outfit-name { align-self: center; font-weight: 700; }
.wardrobe-check {
  position: absolute;
  right: 7px;
  top: 7px;
  width: 20px;
  height: 20px;
  display: none;
  place-items: center;
  border-radius: 50%;
  background: var(--wardrobe-accent);
  color: #fff;
}
.wardrobe-outfit.selected .wardrobe-check { display: grid; }
.wardrobe-actions {
  position: sticky;
  bottom: -14px;
  display: grid;
  grid-template-columns: .72fr 1.28fr;
  gap: 9px;
  margin: 12px -2px -2px;
  padding: 10px 2px 2px;
  background: linear-gradient(180deg, rgba(251,250,248,0), #fbfaf8 24%);
}
.wardrobe-actions button {
  min-height: 44px;
  border-radius: 14px;
  font-size: 12px;
  font-weight: 800;
}
#wardrobe-cancel { border: 1px solid #d8d9dc; background: #fff; color: #777c85; }
#wardrobe-apply {
  border: 0;
  background: var(--wardrobe-accent);
  color: #fff;
  box-shadow: 0 8px 20px color-mix(in srgb, var(--wardrobe-accent) 30%, transparent);
}

@media (max-height: 700px) {
  .wardrobe-preview { height: 142px; }
  #wardrobe-preview-img { height: 138px; }
  .wardrobe-outfit { min-height: 104px; grid-template-rows: 72px auto; }
  .wardrobe-outfit-img img { height: 72px; }
}

@media (min-width: 481px) {
  body:has(#room:not([hidden])) { background: #d9e4ea; }
}
/* ---- 身体页（P4 Pulse 仪表盘） ---- */
#body {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: var(--bg);
  display: flex;
  flex-direction: column;
}
#body[hidden] { display: none; }
#body-bar .bar-pad { width: 40px; }
#body-scroll {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  max-width: 44rem;
  width: 100%;
  margin: 0 auto;
  padding: 4px 16px calc(24px + env(safe-area-inset-bottom));
}
.body-sec {
  font-size: 12.5px;
  color: var(--text-dim);
  letter-spacing: 0.06em;
  margin: 14px 2px 8px;
}
.body-sec span { opacity: 0.75; margin-left: 6px; font-size: 11px; letter-spacing: 0; }
#vitals-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.vital {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px 10px 12px;
  text-align: center;
}
.v-num {
  font-family: var(--serif);
  font-size: 28px;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
}
.v-name { font-size: 11.5px; color: var(--text-dim); margin-top: 2px; }
#body-chord {
  text-align: center;
  font-family: var(--serif);
  font-size: 15px;
  color: var(--text-dim);
  padding: 12px 0;
  letter-spacing: 0.08em;
}
#hr-card {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px 14px 10px;
}
#hr-curve { width: 100%; height: 130px; display: block; }
.hr-grid { stroke: var(--border); stroke-width: 0.6; stroke-dasharray: 3 4; }
.hr-line { fill: none; stroke: var(--accent); stroke-width: 1.8; stroke-linejoin: round; }
.hr-dot { fill: var(--accent); }
#hr-empty { text-align: center; color: var(--text-dim); font-size: 13px; padding: 18px 0; }

/* ---- 生理期卡（P3） ---- */
#period-card {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px;
  margin-top: 12px;
}
#period-state { font-size: 13.5px; line-height: 1.7; margin: 4px 0 10px; }
#period-actions { display: flex; gap: 10px; }
#period-actions button {
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  border-radius: 999px;
  padding: 7px 16px;
  font-size: 13.5px;
}
#period-actions #period-start { background: var(--accent); border-color: var(--accent); color: #fff; }
#period-actions button[hidden] { display: none; }
#period-note { font-size: 11px; color: var(--text-dim); margin-top: 10px; }

/* ---- 身高体重卡 ---- */
#metrics-card {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px;
}
#metrics-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 10px; }
.metric { cursor: pointer; font: inherit; color: inherit; }
.metric-input {
  width: 90px;
  border: none;
  border-bottom: 1.5px solid var(--accent);
  background: transparent;
  font-family: var(--serif);
  font-size: 26px;
  text-align: center;
  color: var(--accent);
  outline: none;
}
.metric-input::-webkit-outer-spin-button,
.metric-input::-webkit-inner-spin-button { -webkit-appearance: none; }

/* ---- 他打来的电话 ---- */
#call-incoming {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
#call-incoming[hidden] { display: none; }
#ci-avatar {
  font-size: 64px;
  width: 118px;
  height: 118px;
  display: grid;
  place-items: center;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 34px;
  animation: ci-breathe 2.1s ease-in-out infinite;
}
@keyframes ci-breathe {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}
#ci-name { font-family: var(--serif); font-size: 24px; letter-spacing: 0.14em; margin-top: 8px; }
#ci-sub { font-size: 13.5px; color: var(--text-dim); }
#ci-actions { display: flex; gap: 72px; margin-top: 48px; }
#ci-actions button {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  border: none;
  display: grid;
  place-items: center;
  color: #fff;
}
#ci-actions .icon { width: 30px; height: 30px; }
#ci-accept { background: #2f9e63; }
#ci-decline { background: #e5484d; }

/* ---- MCP 管理页 ---- */
#mcp {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: var(--bg);
  display: flex;
  flex-direction: column;
}
#mcp[hidden] { display: none; }
#mcp-bar .bar-pad { width: 40px; }
#mcp-scroll {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  max-width: 44rem;
  width: 100%;
  margin: 0 auto;
  padding: 4px 16px calc(24px + env(safe-area-inset-bottom));
}
.mcp-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 12px 14px;
  margin-bottom: 10px;
}
.mcp-row.off { opacity: 0.62; }
.mcp-info { flex: 1; min-width: 0; }
.mcp-name {
  font-size: 14.5px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 7px;
}
.mcp-kind { font-size: 11px; font-weight: 400; color: var(--text-dim); }
.mcp-dot { width: 7px; height: 7px; border-radius: 50%; flex: none; }
.mcp-dot.on { background: #2f9e63; }
.mcp-dot.wait { background: #d9a13b; }
.mcp-dot.off { background: var(--border); }
.mcp-target {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.mcp-state { font-size: 11px; color: var(--text-dim); margin-top: 2px; }
.mcp-actions { display: flex; gap: 6px; align-items: center; }
.mcp-actions button {
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  border-radius: 999px;
  padding: 6px 13px;
  font-size: 12.5px;
}
.mcp-actions .mcp-on-btn { background: var(--accent); border-color: var(--accent); color: #fff; }
.mcp-del { padding: 6px 8px !important; color: var(--text-dim); }
.mcp-del .icon { width: 15px; height: 15px; }
.mcp-del.armed { color: #e5484d; border-color: #e5484d !important; }
#mcp-note { font-size: 12px; color: var(--text-dim); margin: 4px 2px 18px; }
#mcp-add {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px;
}
#mcp-add input,
#mcp-add textarea {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  border-radius: 12px;
  padding: 9px 12px;
  font-size: 13.5px;
  margin-top: 10px;
  outline: none;
}
#mcp-add textarea { font-family: "SF Mono", ui-monospace, Menlo, monospace; font-size: 12px; resize: vertical; }
#mcp-add input:focus, #mcp-add textarea:focus { border-color: var(--text-dim); }
#mcp-add button {
  margin-top: 10px;
  border: none;
  background: var(--accent);
  color: #fff;
  border-radius: 999px;
  padding: 8px 20px;
  font-size: 13.5px;
}

/* ---- 打卡页（P3） ---- */
#habits {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: var(--bg);
  display: flex;
  flex-direction: column;
}
#habits[hidden] { display: none; }
#habit-new {
  display: flex;
  gap: 8px;
  max-width: 44rem;
  width: 100%;
  margin: 0 auto;
  padding: 0 16px 8px;
}
#habit-new input {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-raised);
  color: var(--text);
  font-size: 15px;
  padding: 9px 14px;
  outline: none;
}
#habit-new input:focus { border-color: var(--text-dim); }
#habit-new button {
  border: none;
  border-radius: 12px;
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  padding: 0 18px;
}
#habits-scroll { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }
#habits-list {
  max-width: 44rem;
  margin: 0 auto;
  padding: 4px 16px calc(24px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.habit-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px;
}
.habit-info { flex: 1; min-width: 0; }
.habit-name { font-size: 15px; }
.habit-streak { font-size: 12px; color: var(--text-dim); margin-top: 2px; }
.habit-check {
  flex: none;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-dim);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 13px;
}
.habit-check.done { background: var(--accent); border-color: var(--accent); color: #fff; }
#habits-empty {
  text-align: center;
  color: var(--text-dim);
  font-size: 13px;
  padding: 40px 24px;
  line-height: 1.8;
}

/* ---- 倒计时卡 ---- */
#timer-card {
  position: fixed;
  right: 14px;
  bottom: calc(96px + env(safe-area-inset-bottom));
  z-index: 15;
  width: 210px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 12px 14px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
#timer-card[hidden] { display: none; }
#timer-card.dragging { cursor: grabbing; }
.timer-top { font-size: 12px; color: var(--text-dim); display: flex; align-items: center; gap: 6px; }
.timer-label { white-space: nowrap; }
.timer-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); display: inline-block; }
#timer-task { font-size: 13px; margin-top: 4px; line-height: 1.45; }
#timer-clock {
  font-family: "SF Mono", ui-monospace, Menlo, monospace;
  font-size: 30px;
  letter-spacing: 0.04em;
  margin: 4px 0 0;
}
#timer-bell { margin: 6px 0 2px; color: var(--accent); }
#timer-bell .icon { width: 32px; height: 32px; transform-origin: 50% 4px; animation: bell-swing 0.9s ease-in-out infinite; }
@keyframes bell-swing {
  0%, 100% { transform: rotate(0); }
  20% { transform: rotate(14deg); }
  40% { transform: rotate(-12deg); }
  60% { transform: rotate(8deg); }
  80% { transform: rotate(-6deg); }
}
#timer-card.ring { animation: card-shake 0.9s ease-in-out infinite; border-color: var(--accent); }
@keyframes card-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(1.5px); }
  75% { transform: translateX(-1.5px); }
}
#timer-sub { font-size: 11px; color: var(--text-dim); margin-bottom: 8px; }
.timer-actions { display: flex; gap: 8px; }
.timer-actions button {
  flex: 1;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  border-radius: 999px;
  padding: 6px 0;
  font-size: 12.5px;
}
#timer-done { background: var(--accent); border-color: var(--accent); color: #fff; }
#timer-cancel { color: var(--text-dim); }

/* ---- 通话按钮 ---- */
#call-toggle {
  background: #1f1e1c !important;
  color: #fff !important;
  border-radius: 999px !important;
  width: 52px !important;
}
#call-toggle .ci-on { display: none; }
#call-toggle.on { background: #e5484d !important; }
#call-toggle.on .ci-idle { display: none; }
#call-toggle.on .ci-on { display: block; }
@media (prefers-color-scheme: light) {
  #call-toggle { background: #262624 !important; }
}

/* ---- 阅读批注 ---- */
#anno-ask {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 45;
  background: var(--bg-raised);
  border-top: 1px solid var(--border);
  padding: 14px 18px calc(14px + env(safe-area-inset-bottom));
  box-shadow: 0 -8px 28px rgba(0, 0, 0, 0.15);
}
#anno-ask[hidden] { display: none; }
#anno-quote {
  font-family: var(--serif);
  font-size: 14px;
  color: var(--text-dim);
  margin-bottom: 10px;
  border-left: 3px solid var(--border);
  padding-left: 10px;
}
#anno-colors { display: flex; gap: 12px; margin-bottom: 10px; }
.anno-dot {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
}
.anno-dot[data-color="yellow"] { background: #f2d16b; }
.anno-dot[data-color="red"] { background: #ef8f8f; }
.anno-dot[data-color="green"] { background: #93cf9a; }
.anno-dot[data-color="blue"] { background: #93b3e6; }
.anno-dot.on { border-color: var(--text); }
#anno-note {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  font-family: var(--sans);
  padding: 8px 10px;
  outline: none;
  resize: none;
  margin-bottom: 10px;
}
#anno-thread {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(12px + env(safe-area-inset-bottom));
  z-index: 45;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px 40px 12px 16px;
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.2);
  max-height: 50dvh;
  overflow-y: auto;
}
#anno-thread[hidden] { display: none; }
#anno-thread-close {
  position: absolute;
  top: 8px;
  right: 8px;
  border: none;
  background: none;
  color: var(--text-dim);
  font-size: 14px;
  padding: 6px;
}
#anno-thread-quote {
  font-family: var(--serif);
  font-size: 14px;
  color: var(--text-dim);
  border-left: 3px solid var(--border);
  padding-left: 10px;
  margin-bottom: 8px;
}
#anno-thread-note { font-size: 14px; margin-bottom: 6px; }
#anno-thread-reply { font-family: var(--serif); font-size: 14.5px; color: var(--accent); margin-bottom: 6px; }
#annos-panel {
  position: fixed;
  inset: 0;
  z-index: 44;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  padding-top: env(safe-area-inset-top);
}
#annos-panel[hidden] { display: none; }
.annos-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: var(--serif);
  font-size: 16px;
  padding: 14px 18px 8px;
  max-width: 44rem;
  width: 100%;
  margin: 0 auto;
}
.annos-head button { border: none; background: none; color: var(--text-dim); font-size: 15px; }
#annos-list {
  flex: 1;
  overflow-y: auto;
  max-width: 44rem;
  width: 100%;
  margin: 0 auto;
  padding: 4px 16px calc(24px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.anno-card {
  display: flex;
  gap: 10px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 11px 13px;
  cursor: pointer;
}
.anno-bar { width: 4px; border-radius: 2px; flex: none; }
.anno-body { flex: 1; min-width: 0; }
.anno-q { font-family: var(--serif); font-size: 13.5px; color: var(--text-dim); }
.anno-n { font-size: 13.5px; margin-top: 5px; }
.anno-r { font-family: var(--serif); font-size: 13.5px; color: var(--accent); margin-top: 4px; }
#annos-empty { text-align: center; color: var(--text-dim); font-size: 13px; padding: 40px 24px; }

/* ---- toast ---- */
#toast {
  position: fixed;
  left: 50%;
  bottom: calc(90px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 50;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 14px;
  padding: 9px 18px;
  border-radius: 999px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}
#toast[hidden] { display: none; }

#menu button.danger, #fav-menu button.danger, #book-menu button.danger, #note-menu button.danger, #habit-menu button.danger { color: #e5484d; }

/* ---- 长按菜单 ---- */
#menu, #fav-menu, #photo-menu, #album-menu, #book-menu, #note-menu, #habit-menu {
  position: fixed;
  z-index: 30;
  display: flex;
  flex-direction: column;
  min-width: 148px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
}
#menu[hidden], #fav-menu[hidden], #photo-menu[hidden], #album-menu[hidden], #book-menu[hidden], #note-menu[hidden], #habit-menu[hidden] { display: none; }
#menu button, #fav-menu button, #photo-menu button, #album-menu button, #book-menu button, #note-menu button, #habit-menu button {
  padding: 12px 16px;
  border: none;
  background: none;
  color: var(--text);
  font-size: 15px;
  text-align: left;
}
#menu button + button, #fav-menu button + button, #photo-menu button + button,
#album-menu button + button, #book-menu button + button { border-top: 1px solid var(--border); }
#menu button[hidden], #photo-menu button[hidden] { display: none; }
#menu button:disabled { color: var(--text-dim); }


/* ============ 专注陪伴 ============ */
#focus {
  position: fixed; inset: 0; z-index: 60;
  background: var(--bg); display: flex; flex-direction: column;
}
#focus[hidden] { display: none; }

/* —— 设置态 —— */
#focus-setup { flex: 1; overflow-y: auto; padding: 8px 18px 32px;
  max-width: 40rem; width: 100%; margin: 0 auto; }
#focus-stats { display: flex; gap: 14px; margin: 6px 0 20px; }
#focus-stats > div { flex: 1; background: var(--card, rgba(140,120,100,.06));
  border-radius: 16px; padding: 16px; text-align: center; }
#focus-stats b { display: block; font-size: 30px; font-weight: 600; color: var(--accent); }
#focus-stats span { font-size: 12px; opacity: .6; }
#focus-new { background: var(--card, rgba(140,120,100,.06));
  border-radius: 18px; padding: 18px; }
#focus-task { width: 100%; border: none; background: transparent;
  font-size: 17px; padding: 4px 2px 12px; border-bottom: 1px solid rgba(140,120,100,.2);
  color: inherit; outline: none; }
#focus-task::placeholder { color: rgba(120,110,100,.5); }
#focus-durs { display: flex; gap: 8px; margin: 16px 0; }
#focus-durs button { flex: 1; padding: 10px 0; border-radius: 12px;
  border: 1px solid rgba(140,120,100,.2); background: transparent;
  color: inherit; font-size: 14px; }
#focus-durs button.on { background: var(--accent); color: #fff; border-color: var(--accent); }
#focus-start-btn { width: 100%; padding: 14px; border-radius: 14px; border: none;
  background: var(--accent); color: #fff; font-size: 15.5px; font-weight: 500; }
#focus-recent-wrap { margin-top: 24px; }
.focus-recent-title { font-size: 13px; opacity: .55; margin: 0 2px 10px; }
.focus-row { display: flex; align-items: center; gap: 10px; padding: 11px 4px;
  border-bottom: 1px solid rgba(140,120,100,.1); font-size: 14px; }
.focus-row .fr-dot { width: 7px; height: 7px; border-radius: 50%; flex: none; }
.focus-row .fr-dot.done { background: #6ba368; }
.focus-row .fr-dot.gaveup { background: rgba(140,120,100,.35); }
.focus-row .fr-task { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.focus-row .fr-min { opacity: .55; font-size: 13px; }
#focus-recent:empty::after { content: "还没有专注记录——开一个，老公陪你。";
  font-size: 13px; opacity: .5; }

/* —— 专注态（沉浸） —— */
#focus-live { flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 8px; padding: 24px;
  background: radial-gradient(circle at 50% 38%, rgba(193,120,80,.08), transparent 62%); }
#focus-live[hidden] { display: none; }
#fl-task { font-size: 17px; opacity: .8; margin-bottom: 6px; text-align: center; }
#fl-clock { font-size: 76px; font-weight: 300; font-variant-numeric: tabular-nums;
  letter-spacing: 2px; color: var(--accent); }
#fl-sub { font-size: 14px; opacity: .55; margin-top: 4px; text-align: center;
  animation: flbreathe 4s ease-in-out infinite; }
@keyframes flbreathe { 0%,100%{opacity:.4} 50%{opacity:.7} }
#fl-actions { display: flex; gap: 12px; margin-top: 40px; }
#fl-done { padding: 13px 30px; border-radius: 999px; border: none;
  background: var(--accent); color: #fff; font-size: 15px; }
#fl-giveup { padding: 13px 24px; border-radius: 999px;
  border: 1px solid rgba(140,120,100,.25); background: transparent;
  color: inherit; opacity: .7; font-size: 14px; }

/* —— 完成态 —— */
#focus-finish { flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 12px; padding: 24px; }
#focus-finish[hidden] { display: none; }
.ff-mark { font-size: 56px; animation: ffpop .5s ease; }
@keyframes ffpop { 0%{transform:scale(.4);opacity:0} 60%{transform:scale(1.15)} 100%{transform:scale(1)} }
#ff-line { font-size: 22px; font-weight: 500; }
#ff-streak { font-size: 14px; opacity: .6; margin-bottom: 20px; }
#ff-chat { padding: 13px 26px; border-radius: 999px; border: none;
  background: var(--accent); color: #fff; font-size: 15px; }
#ff-again { padding: 11px; border: none; background: transparent;
  color: inherit; opacity: .5; font-size: 13.5px; }

/* ============ 通话光球页（ChatGPT 式） ============ */
#call-live {
  position: fixed; inset: 0; z-index: 70;
  background: var(--bg);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 40px;
}
#call-live[hidden] { display: none; }
#call-orb {
  width: min(58vw, 250px); aspect-ratio: 1; border-radius: 50%;
  background: radial-gradient(circle at 40% 36%, #f8d2b0, #efa27b 58%, #e8875f);
  filter: blur(24px);
  transform: scale(var(--amp, 1));
  transition: transform .09s linear;
  will-change: transform;
}
#call-state {
  font-size: 15px; color: var(--text-dim);
  letter-spacing: .1em; min-height: 1.4em;
}
#call-end {
  width: 62px; height: 62px; border-radius: 50%; border: none;
  background: #e5484d; color: #fff;
  display: grid; place-items: center; margin-top: 8px;
}
#call-end .icon { width: 24px; height: 24px; }

/* ============ 心事卡（欲望 + 念头池） ============ */
#desire-card {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 16px;
  margin-bottom: 14px;
}
#desire-intent { font-size: 13.5px; margin: 4px 2px 10px; }
#desire-intent b { font-weight: 600; color: var(--accent); }
.di-dim { font-style: normal; font-size: 11px; color: var(--text-dim); margin-left: 8px; }
.th-row { display: flex; align-items: center; gap: 8px; padding: 6px 2px; }
.th-dot { width: 7px; height: 7px; border-radius: 50%; flex: none; background: var(--border); }
.th-row.fixation .th-dot { background: var(--accent); }
.th-text { flex: 1; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.th-row.fixation .th-text { font-weight: 500; }
.th-meter { width: 52px; height: 4px; border-radius: 2px; background: var(--border); overflow: hidden; flex: none; }
.th-meter i { display: block; height: 100%; background: var(--accent); opacity: .7; }
#desire-empty { font-size: 12.5px; color: var(--text-dim); padding: 2px; }
#desire-empty[hidden] { display: none; }

/* 底色条：聊出来的起伏亮色 */
.pulse-row.hot .p-label { color: var(--accent); font-weight: 500; }
.pulse-row.hot .p-track i { background: var(--accent); }
.p-arrow { font-style: normal; font-weight: 600; color: var(--accent); margin-left: 3px; }

/* ============ 日记页：日记/梦分栏 + 页边对话 ============ */
#diary-tabs {
  display: flex; gap: 8px; max-width: 44rem; width: 100%;
  margin: 2px auto 0; padding: 0 16px;
}
#diary-tabs button {
  border: 1px solid var(--border); background: transparent; color: var(--text);
  border-radius: 999px; padding: 6px 18px; font-size: 13.5px;
}
#diary-tabs button.on { background: var(--accent); border-color: var(--accent); color: #fff; }

.dream-card {
  border: 1px dashed var(--border); border-radius: 14px;
  padding: 14px 16px; margin-bottom: 12px;
  font-family: var(--serif);
}
.dream-date { font-size: 12px; color: var(--text-dim); margin-bottom: 8px; letter-spacing: .06em; }
.dream-body { font-size: 14px; line-height: 1.95; white-space: pre-wrap; }
#dreams-list[hidden] { display: none; }

.diary-cmts { margin-top: 12px; border-top: 1px dashed var(--border); padding-top: 10px; }
.dc-list { display: flex; flex-direction: column; gap: 8px; }
.dc-mine {
  font-size: 13.5px; line-height: 1.6;
  background: var(--bg); border-radius: 12px; padding: 8px 12px;
}
.dc-mine b { color: var(--text-dim); margin-right: 6px; font-weight: 600; font-size: 12px; }
.dc-reply {
  font-size: 13.5px; line-height: 1.6; font-family: var(--serif);
  background: var(--bg); border-radius: 12px; padding: 8px 12px;
  margin-left: 20px;                 /* 缩进，像朋友圈里言舟的回复 */
  border-left: 2px solid var(--accent);
}
.dc-reply b { color: var(--accent); margin-right: 6px; font-weight: 600; font-size: 12px; }
.dc-waiting { color: var(--text-dim); font-style: italic; }
.dc-input-row { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.dc-input {
  flex: 1; border: none; border-bottom: 1px solid var(--border);
  background: transparent; color: var(--text); font-size: 13px;
  padding: 7px 2px; outline: none;
}
.dc-input:focus { border-bottom-color: var(--accent); }
.dc-send {
  border: none; background: var(--accent); color: #fff;
  width: 30px; height: 30px; border-radius: 50%; flex: none;
  display: grid; place-items: center; padding: 0;
}
.dc-send .icon { width: 16px; height: 16px; }
#diary-list[hidden] { display: none; } /* display 规则会盖 [hidden]——踩过的坑 */

.dream-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.dream-tag {
  font-size: 11.5px; background: var(--accent); color: #fff;
  padding: 2px 9px; border-radius: 999px; letter-spacing: .04em; flex: none;
}
.dream-head .dream-date { margin: 0; }

/* 记忆卡：主题/重要 + 标签 */
.mem-meta { font-size: 11.5px; color: var(--text-dim); margin-top: 6px; }
.mem-tags { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 7px; }
.mem-tag {
  font-size: 11px; color: var(--text-dim);
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 999px; padding: 1px 8px;
}

/* 收藏卡标题 + 新建标题输入 */
.fav-title { font-weight: 600; font-size: 15px; margin-bottom: 6px; }
#paste-title {
  width: 100%; border: none; border-bottom: 1px solid var(--border);
  background: transparent; color: var(--text); font-size: 15px;
  padding: 8px 2px; margin-bottom: 10px; outline: none;
}
#paste-title:focus { border-bottom-color: var(--accent); }

/* 小屋反穿模：家具前景切片（room-game 动态生成，同底图裁片） */
.room-fg {
  position: absolute;
  background-repeat: no-repeat;
  pointer-events: none;
}
