/* ─── reset ─── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
button { font: inherit; cursor: pointer; border: none; background: none; }
textarea { font: inherit; }

/* ─── tokens ─── */
:root {
  --bg:      #F8F8F6;
  --surface: #F0EFED;
  --border:  rgba(31,30,29,.10);
  --text:    #1F1E1D;
  --text2:   #6E6D66;
  --text3:   #A8A79F;
  --accent:  #DA7756;
  --user-bubble: #EEEEEC;
  --shadow-composer: 0 2px 16px rgba(0,0,0,.08), 0 0 0 1px var(--border);
  --hover:   rgba(0,0,0,.015);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bot: max(20px, env(safe-area-inset-bottom, 0px));
  --topbar-h: 56px;
  --serif: ui-serif, Georgia, 'PingFang SC', serif;
  --sans:  -apple-system, system-ui, 'PingFang SC', sans-serif;
  --mono:  ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  --avatar-sz: 32px;
  --avatar-gap: 8px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg:          #1C1C1A;
    --surface:     #242422;
    --border:      rgba(255,255,255,.09);
    --text:        #ECEAE4;
    --text2:       #9E9D96;
    --text3:       #6E6D66;
    --hover:       rgba(255,255,255,.02);
    --user-bubble: #2E2E2C;
    --shadow-composer: 0 2px 16px rgba(0,0,0,.3), 0 0 0 1px var(--border);
    --bubble-shadow: 0 1px 4px rgba(0,0,0,.2);
  }
  .msg-row.ai .bubble, .msg-row.user .bubble {
    box-shadow: var(--bubble-shadow);
  }
  .msg-row.ai::before, .msg-row.user::after {
    box-shadow: 0 0 0 1.5px rgba(255,255,255,.12), 0 2px 8px rgba(0,0,0,.2);
  }
}

html, body {
  height: 100%; width: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
@media (display-mode: standalone) {
  html, body { height: 100vh; }
}

/* ─── layout shell ─── */
#app {
  display: flex;
  flex-direction: column;
  height: 100vh; height: 100dvh;
  overflow: hidden;
}

/* ─── overlay (drawer backdrop) ─── */
#overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.25);
  z-index: 100;
  backdrop-filter: blur(1px);
}
#overlay.show { display: block; }

/* ─── DRAWER ─── */
#drawer {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: min(300px, 82vw);
  z-index: 101;
  background: var(--bg);
  display: flex; flex-direction: column;
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bot);
  transform: translateX(-100%);
  transition: transform .26s cubic-bezier(.4,0,.2,1);
  border-right: 1px solid var(--border);
}
#drawer.open { transform: translateX(0); }

.drawer-header {
  display: flex; align-items: center; gap: 12px;
  padding: 20px 16px 16px;
  border-bottom: 1px solid var(--border);
}
.drawer-avatar {
  width: 40px; height: 40px; border-radius: 50%;
  object-fit: cover;
  box-shadow: 0 0 0 1.5px rgba(218,119,86,.25), 0 2px 8px rgba(0,0,0,.08);
}
.drawer-brand-group { flex: 1; min-width: 0; }
.drawer-brand {
  display: block;
  font-size: 18px; font-weight: 700; letter-spacing: -.02em;
  font-family: var(--serif);
}
.drawer-brand-sub {
  display: block;
  font-size: 11px; color: var(--text3); margin-top: 1px;
}
.drawer-close {
  width: 32px; height: 32px;
  display: grid; place-items: center;
  border-radius: 10px; color: var(--text3);
  transition: background .15s;
}
.drawer-close:active { background: var(--border); }

.drawer-section {
  padding: 14px 16px 6px;
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .06em; color: var(--text3);
}

.drawer-list {
  flex: 1; overflow-y: auto; padding: 4px 10px;
}
.drawer-list::-webkit-scrollbar { display: none; }

.drawer-item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 12px;
  border-radius: 14px;
  color: var(--text); font-size: 15px;
  width: 100%; text-align: left;
  position: relative;
  transition: background .15s;
  -webkit-touch-callout: none;
  -webkit-user-select: none; user-select: none;
}
.drawer-item:active { background: var(--surface); }
.drawer-item.active { background: rgba(218,119,86,.1); }
.drawer-item.active .drawer-item-name { color: var(--accent); font-weight: 600; }
.drawer-item-icon {
  width: 36px; height: 36px; border-radius: 10px;
  background: var(--surface);
  display: grid; place-items: center; flex-shrink: 0;
  color: var(--text3);
}
.drawer-item.active .drawer-item-icon { background: rgba(218,119,86,.12); color: var(--accent); }
.drawer-item-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.drawer-item-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.drawer-item-name {
  flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  font-size: 14px; font-weight: 500;
}
.drawer-item-time {
  font-size: 10px; color: var(--text3); flex-shrink: 0; letter-spacing: .02em;
}
.drawer-item-preview {
  font-size: 12px; color: var(--text2); line-height: 1.4;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.drawer-item-del {
  display: none; width: 24px; height: 24px;
  place-items: center; border-radius: 8px;
  color: var(--text3); font-size: 14px;
  position: absolute; right: 8px; top: 8px;
}
.drawer-item:active .drawer-item-del { display: grid; }
.drawer-item-del:active { color: #c05b5b; background: rgba(192,91,91,.12); }

.drawer-item.sandbox { color: var(--text2); }
.drawer-item.sandbox.active { color: #c8a464; background: rgba(200,164,100,.08); }

.drawer-footer { padding: 10px 10px calc(6px + var(--safe-bot)); display: flex; flex-direction: column; gap: 6px; }
.drawer-new-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; padding: 12px 14px;
  border-radius: 14px;
  background: var(--text); color: var(--bg);
  font-size: 14px; font-weight: 600;
  transition: opacity .15s;
}
.drawer-new-btn:active { opacity: .85; }
@media (prefers-color-scheme: dark) {
  .drawer-avatar { box-shadow: 0 0 0 1.5px rgba(218,119,86,.3), 0 2px 8px rgba(0,0,0,.3); }
  .drawer-item-icon { background: rgba(255,255,255,.06); }
  .drawer-item.active .drawer-item-icon { background: rgba(218,119,86,.15); }
}

/* ─── CHATS PAGE ─── */
#chats-page {
  position: fixed; inset: 0; z-index: 300;
  background: var(--bg);
  display: flex; flex-direction: column;
}
.chats-topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; flex: none;
  padding-top: calc(12px + var(--safe-top));
}
.chats-topbar-btn {
  width: 36px; height: 36px; display: grid; place-items: center;
  border-radius: 10px; color: var(--text);
}
.chats-topbar-btn:active { background: var(--surface); }
.chats-topbar-title {
  font-size: 17px; font-weight: 700; color: var(--text);
}
.chats-search-wrap {
  position: relative; margin: 0 16px 12px; flex: none;
}
.chats-search-icon {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  color: var(--text3); pointer-events: none;
}
.chats-search-input {
  width: 100%; padding: 10px 12px 10px 36px;
  border-radius: 10px; border: none;
  background: var(--surface); color: var(--text);
  font-size: 15px; outline: none;
  box-sizing: border-box;
}
.chats-search-input::placeholder { color: var(--text3); }
.chats-list {
  flex: 1; overflow-y: auto; padding: 0 16px;
  -webkit-overflow-scrolling: touch;
}
.chats-list::-webkit-scrollbar { display: none; }
.chats-item {
  display: flex; align-items: center; gap: 12px;
  width: 100%; padding: 14px 4px;
  border-bottom: 1px solid var(--border);
  text-align: left; color: var(--text);
  -webkit-touch-callout: none;
  -webkit-user-select: none; user-select: none;
}
.chats-item:last-child { border-bottom: none; }
.chats-item:active { background: var(--surface); border-radius: 10px; }
.chats-item.active { color: var(--accent); }
.chats-item-main { flex: 1; min-width: 0; }
.chats-item-name {
  font-size: 15px; font-weight: 600; display: block;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chats-item-ago {
  font-size: 12px; color: var(--text3); margin-top: 2px; display: block;
}
.chats-item-arrow { flex-shrink: 0; color: var(--text3); }
.chats-item.hidden-conv .chats-item-name { color: var(--text2); font-weight: 500; }
.chats-new-btn {
  position: fixed; bottom: calc(24px + var(--safe-bot)); right: 20px;
  display: flex; align-items: center; gap: 8px;
  padding: 14px 22px; border-radius: 24px;
  background: var(--text); color: var(--bg);
  font-size: 14px; font-weight: 600;
  box-shadow: 0 4px 16px rgba(0,0,0,.15);
  z-index: 301;
}
.chats-new-btn:active { opacity: .85; }

/* ─── ACTION SHEET ─── */
.action-sheet-overlay {
  position: fixed; inset: 0; z-index: 9999;
  display: flex; flex-direction: column; justify-content: flex-end;
}
.action-sheet-backdrop {
  position: absolute; inset: 0; background: rgba(0,0,0,.4);
  animation: fadeIn .15s;
}
.action-sheet {
  position: relative; z-index: 1;
  background: var(--bg); border-radius: 16px 16px 0 0;
  padding: 8px 10px calc(10px + var(--safe-bot));
  animation: slideUp .2s ease-out;
}
.action-sheet-btn {
  display: flex; align-items: center; gap: 12px;
  width: 100%; padding: 14px 16px;
  border-radius: 12px;
  font-size: 15px; color: var(--text);
  text-align: left;
}
.action-sheet-btn:active { background: var(--surface); }
.action-sheet-danger { color: #d04040; }
.action-sheet-cancel {
  margin-top: 6px; justify-content: center;
  color: var(--text2); font-size: 14px;
  border-top: 1px solid var(--border);
  border-radius: 0;
  padding-top: 14px;
}
@keyframes slideUp { from { transform: translateY(100%); } }
@keyframes fadeIn { from { opacity: 0; } }

/* ─── CONFIRM / RENAME MODAL ─── */
.confirm-overlay {
  position: fixed; inset: 0; z-index: 10000;
  display: flex; align-items: center; justify-content: center;
}
.confirm-backdrop {
  position: absolute; inset: 0; background: rgba(0,0,0,.4);
  animation: fadeIn .15s;
}
.confirm-box {
  position: relative; z-index: 1;
  background: var(--bg); border-radius: 16px;
  padding: 24px 20px 16px; width: 280px;
  animation: fadeIn .15s;
}
.confirm-text {
  font-size: 15px; font-weight: 600; text-align: center;
  margin-bottom: 16px; color: var(--text);
}
.confirm-btns { display: flex; gap: 10px; }
.confirm-btn {
  flex: 1; padding: 10px; border-radius: 10px;
  font-size: 14px; font-weight: 500;
  background: var(--surface); color: var(--text);
}
.confirm-btn:active { opacity: .8; }
.confirm-btn-danger { background: #d04040; color: #fff; }
.confirm-btn-ok { background: var(--accent); color: #fff; }
.rename-input {
  width: 100%; padding: 10px 12px; border-radius: 10px;
  border: 1.5px solid var(--border); background: var(--surface);
  font-size: 15px; color: var(--text);
  margin-bottom: 16px; outline: none;
  box-sizing: border-box;
}
.rename-input:focus { border-color: var(--accent); }

/* ─── MAIN COLUMN ─── */
#main {
  flex: 1; display: flex; flex-direction: column;
  min-width: 0; overflow: hidden;
}

/* ─── TOPBAR ─── */
.topbar {
  flex: none;
  height: calc(var(--safe-top) + var(--topbar-h));
  padding-top: var(--safe-top);
  display: flex;
  align-items: center;
  padding-left: 4px; padding-right: 4px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  position: relative; z-index: 10;
}
.topbar-btn {
  width: 36px; height: 36px;
  display: grid; place-items: center;
  border-radius: 50%; color: var(--text); font-size: 19px;
  flex-shrink: 0;
}
.topbar-btn:hover { background: var(--border); }
#btn-sleep { margin-left: auto; }

.topbar-center {
  position: absolute; left: 0; right: 0; top: var(--safe-top); height: var(--topbar-h);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; line-height: 1.2;
  pointer-events: none;
}
.topbar-center * { pointer-events: auto; }
.topbar-title {
  font-size: 16px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 160px; text-align: center;
}
.topbar-sub {
  font-size: 11px; color: var(--text2);
  display: none;
}
.topbar-sub.show { display: block; }
.sys-notice {
  text-align: center;
  color: var(--text-secondary, #888);
  font-size: 0.72rem;
  padding: 6px 0 2px;
  opacity: 0.7;
  letter-spacing: 0.02em;
}
#ctx-bar {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 2px;
  background: var(--border);
  pointer-events: none;
  z-index: 1;
}
#ctx-bar::after {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: var(--ctx-pct, 0%);
  background: #4CAF50;
  transition: width 0.6s ease, background 0.4s ease;
}
#ctx-bar.warn::after { background: #e6a23c; }
#ctx-bar.danger::after { background: #f56c6c; }


.conn-dot {
  display: inline-block;
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--text3);
  margin-right: 4px; transition: background .3s;
}
.conn-dot.ok { background: #5bc07a; }
.conn-dot.busy { background: #c8a464; animation: blink 1s ease-in-out infinite; }
.conn-dot.err { background: #c05b5b; }
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:.3} }

.hb-playing-hint {
  display: none;
  align-items: center; gap: 6px;
  padding: 8px 14px;
  margin: 0 12px 6px;
  border-radius: 12px;
  background: var(--bg2);
  font-size: 13px; color: var(--text2);
  animation: hb-hint-in 0.3s ease;
  flex-wrap: wrap;
}
.hb-playing-hint.show { display: flex; }
.hb-playing-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: #c8a464;
  animation: blink 1.2s ease-in-out infinite;
  flex-shrink: 0;
}
@keyframes hb-hint-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

/* ─── VIEWS ─── */
#home-view, #chat-view, #memory-view {
  display: none; flex: 1; overflow: hidden;
}
#home-view.active { display: block; overflow-y: auto; -webkit-overflow-scrolling: touch; }
#chat-view.active { display: flex; flex-direction: column; }
#memory-view.active { display: flex; flex-direction: column; }
#memory-view .topbar { position: relative; }

/* ─── BOTTOM TAB BAR ─── */
#tab-bar {
  flex: none;
  display: flex;
  height: calc(50px + var(--safe-bot));
  padding-bottom: var(--safe-bot);
  background: var(--bg);
  border-top: 1px solid var(--border);
  z-index: 20;
}
.tab-item {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 3px; color: var(--text3);
  font-size: 10px; letter-spacing: .03em;
  transition: color .15s;
  -webkit-tap-highlight-color: transparent;
}
.tab-item.active { color: var(--accent); }
.tab-icon { line-height: 1; }

/* ─── HOME VIEW ─── */
#home-view::-webkit-scrollbar { display: none; }
.home-inner {
  max-width: 480px; margin: 0 auto;
  padding: calc(var(--safe-top) + 20px) 16px 32px;
  display: flex; flex-direction: column; gap: 14px;
}

/* name design widget */
.hw-names {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 20px; overflow: hidden;
}
.hw-names-header {
  padding: 16px 18px 0;
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .12em; color: var(--text3);
}
.hw-names-body {
  display: flex;
}
.hw-name-col {
  flex: 1; text-align: center; padding: 18px 14px 22px;
}
.hw-name-col:first-child { border-right: 1px solid var(--border); }
.hw-name-han {
  font-family: var(--serif); font-size: 38px; font-weight: 400;
  color: var(--text); line-height: 1; margin-bottom: 10px;
  letter-spacing: .06em;
}
.hw-name-origin {
  font-size: 12px; color: var(--text2); line-height: 1.8; margin-bottom: 8px;
}
.hw-name-note {
  font-size: 11px; color: var(--accent); font-style: italic; line-height: 1.4;
}

/* anniversary widget – vintage */
.hw-ann {
  background: #F5EDE0; border: 1px solid rgba(163,120,80,.22);
  border-radius: 20px; overflow: hidden; cursor: pointer;
  position: relative;
  box-shadow: 0 1px 10px rgba(139,90,60,.08);
  transition: transform .12s, box-shadow .12s;
  -webkit-tap-highlight-color: transparent;
}
.hw-ann:active { transform: scale(.98); box-shadow: none; }
@media (prefers-color-scheme: dark) {
  .hw-ann { background: #2A1D13; border-color: rgba(180,130,80,.2); }
}
.hw-ann-main { text-align: center; padding: 36px 24px 30px; position: relative; }
.hw-ann-leaf {
  position: absolute; font-size: 32px; opacity: .32; pointer-events: none;
}
.hw-ann-leaf.l { left: 14px; bottom: 18px; transform: rotate(-20deg); }
.hw-ann-leaf.r { right: 14px; top: 14px; transform: rotate(15deg); }
.hw-ann-num {
  font-family: var(--serif); font-size: 88px; font-weight: 400;
  color: #5C3D28; line-height: 1; margin-bottom: 14px; letter-spacing: -.02em;
}
@media (prefers-color-scheme: dark) { .hw-ann-num { color: #D4A87A; } }
.hw-ann-div {
  display: flex; align-items: center; justify-content: center;
  gap: 8px; margin-bottom: 10px;
}
.hw-ann-line {
  height: 1px; width: 38px;
  background: linear-gradient(to right, transparent, #B88A60 50%, transparent);
}
@media (prefers-color-scheme: dark) {
  .hw-ann-line { background: linear-gradient(to right, transparent, #7A5035 50%, transparent); }
}
.hw-ann-heart { font-size: 11px; color: #C47A5A; }
.hw-ann-since {
  font-size: 11px; font-weight: 700; color: #7A5035;
  letter-spacing: .18em; text-transform: uppercase;
}
@media (prefers-color-scheme: dark) { .hw-ann-since { color: #A07050; } }
.hw-ann-hint {
  margin-top: 12px; font-size: 10px; letter-spacing: .04em;
  color: rgba(160,112,80,.6);
}

/* anniversary detail sheet */
#ann-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.3); z-index: 400;
  backdrop-filter: blur(2px);
}
#ann-overlay.show { display: block; }
#ann-sheet {
  position: fixed; left: 0; right: 0; bottom: 0;
  background: var(--bg); border-radius: 20px 20px 0 0;
  z-index: 401; max-height: 72vh;
  display: flex; flex-direction: column;
  transform: translateY(100%);
  transition: transform .28s cubic-bezier(.4,0,.2,1);
  padding-bottom: var(--safe-bot);
}
#ann-sheet.open { transform: translateY(0); }
.ann-sh-handle {
  width: 36px; height: 4px; border-radius: 2px;
  background: var(--border); margin: 10px auto 0; flex: none;
}
.ann-sh-title {
  font-family: var(--serif); font-size: 19px;
  padding: 14px 20px 10px; flex: none; color: var(--text);
}
.ann-sh-body { flex: 1; overflow-y: auto; padding: 0 20px 24px; }
.ann-sh-body::-webkit-scrollbar { display: none; }
.ann-sh-row {
  display: flex; gap: 14px; padding: 13px 0;
  border-bottom: 1px solid var(--border);
}
.ann-sh-row:last-child { border-bottom: none; }
.ann-sh-date {
  font-family: var(--mono); font-size: 11px; font-weight: 600;
  color: var(--text3); width: 40px; flex-shrink: 0; padding-top: 3px;
}
.ann-sh-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent); flex-shrink: 0; margin-top: 5px;
}
.ann-sh-name { font-size: 15px; font-weight: 500; color: var(--text); margin-bottom: 3px; }
.ann-sh-sub { font-size: 13px; color: var(--text2); line-height: 1.55; }

/* icon grid */
.hw-heartbeat {
  margin: 0 2px 14px;
  padding: 10px 14px;
  background: var(--surface);
  border-radius: 12px;
  border: 1px solid var(--border);
}
.hw-heartbeat-label {
  font-size: 11px;
  color: var(--text3);
  margin-bottom: 8px;
  font-family: var(--mono);
}
.hw-heartbeat-list { display: flex; flex-direction: column; gap: 6px; }
.hb-item {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; line-height: 1.4;
}
.hb-time { color: var(--text3); font-family: var(--mono); font-size: 11px; flex-shrink: 0; width: 38px; }
.hb-dot {
  width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0;
}
.hb-dot.completed { background: #8B9F7A; }
.hb-dot.skipped { background: var(--text3); opacity: .4; }
.hb-dot.failed { background: #DA7756; }
.hb-type { color: var(--text2); flex-shrink: 0; }
.hb-detail { color: var(--text3); font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.hb-empty { font-size: 12px; color: var(--text3); text-align: center; padding: 8px 0; }
.hb-more-btn {
  display: block; width: 100%; text-align: center; padding: 6px 0; margin-top: 4px;
  font-size: 11px; color: var(--text3); background: none; border: none; cursor: pointer;
}
.hb-more-btn:hover { color: var(--accent); }
#hb-sheet-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.3); z-index: 400; backdrop-filter: blur(2px);
}
#hb-sheet-overlay.show { display: block; }
#hb-sheet {
  position: fixed; left: 0; right: 0; bottom: 0;
  background: var(--bg); border-radius: 20px 20px 0 0;
  z-index: 401; max-height: 72vh;
  display: flex; flex-direction: column;
  transform: translateY(100%);
  transition: transform .28s cubic-bezier(.4,0,.2,1);
  padding-bottom: var(--safe-bot);
}
#hb-sheet.open { transform: translateY(0); }
.hb-sh-handle {
  width: 36px; height: 4px; border-radius: 2px;
  background: var(--border); margin: 10px auto 0; flex: none;
}
.hb-sh-title {
  font-family: var(--serif); font-size: 19px;
  padding: 14px 20px 10px; flex: none; color: var(--text);
}
.hb-sh-body { flex: 1; overflow-y: auto; padding: 0 20px 24px; }
.hb-sh-body::-webkit-scrollbar { display: none; }
.hb-sh-body .hb-item { padding: 10px 0; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.hb-sh-body .hb-detail { white-space: normal; width: 100%; padding-left: 28px; margin-top: 4px; }

.hw-projection {
  margin: 0 2px 14px;
  padding: 10px 14px;
  background: var(--surface);
  border-radius: 12px;
  border: 1px solid var(--border);
  display: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.hw-projection-label {
  font-size: 11px;
  color: var(--text3);
  margin-bottom: 4px;
  font-family: var(--mono);
}
.hw-projection-text {
  font-size: 13px;
  color: var(--text2);
  line-height: 1.6;
  max-height: 3.2em; overflow: hidden;
  transition: max-height .3s;
  position: relative;
}
.hw-projection-text.expanded { max-height: 2000px; }
.hw-projection-text:not(.expanded)::after {
  content: ''; position: absolute; bottom: 0; left: 0; right: 0;
  height: 1.6em; background: linear-gradient(transparent, var(--surface));
}

.hw-grid {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 14px; padding: 4px 0;
}
.hw-slot {
  aspect-ratio: 1; border-radius: 18px;
  background: var(--surface); border: 1px solid var(--border);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 6px; color: var(--text3); font-size: 11px;
  transition: background .15s, border-color .15s;
  -webkit-tap-highlight-color: transparent;
}
.hw-slot:active { background: var(--border); }
.hw-slot-icon { font-size: 26px; line-height: 1; }
.hw-slot-label { font-size: 10px; color: var(--text3); }

/* ─── SANDBOX BANNER ─── */
#sandbox-banner {
  display: none;
  flex: none;
  padding: 6px 16px;
  background: rgba(200,164,100,.08);
  border-bottom: 1px solid rgba(200,164,100,.18);
  font-size: 12px; color: #c8a464;
  text-align: center; letter-spacing: .02em;
}
#sandbox-banner.show { display: block; }

/* ─── MESSAGES ─── */
#msgs {
  flex: 1; overflow-y: auto;
  padding: 24px 0 12px;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 28px, #000 calc(100% - 36px), transparent 100%);
  mask-image: linear-gradient(to bottom, transparent 0, #000 28px, #000 calc(100% - 36px), transparent 100%);
}
#msgs::-webkit-scrollbar { display: none; }

#msgs-inner {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 14px;
  display: flex; flex-direction: column; gap: 14px;
}

/* welcome */
#welcome {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  min-height: 50vh; gap: 6px;
  color: var(--text2); font-size: 14px;
  pointer-events: none;
}
#welcome .w-name {
  font-family: var(--serif);
  font-size: 28px; font-weight: 400;
  color: var(--text); letter-spacing: -.01em;
  margin-bottom: 2px;
}

/* typing */
#typing {
  display: none;
  align-items: center; gap: 4px;
  padding: 10px 0;
  margin-left: calc(var(--avatar-sz) + var(--avatar-gap));
}
#typing.show { display: flex; }
#typing span {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--text3);
  animation: tdot 1.2s ease-in-out infinite;
}
#typing span:nth-child(2) { animation-delay: .2s; }
#typing span:nth-child(3) { animation-delay: .4s; }
@keyframes tdot { 0%,80%,100%{transform:scale(.65);opacity:.4} 40%{transform:scale(1);opacity:1} }

/* message row */
.msg-row { display: flex; flex-direction: column; position: relative; }
.msg-row.user { align-items: flex-end; padding-right: calc(var(--avatar-sz) + var(--avatar-gap)); }
.msg-row.ai   { align-items: flex-start; padding-left: calc(var(--avatar-sz) + var(--avatar-gap)); }

/* avatars */
.msg-row.ai::before {
  content: '';
  position: absolute; left: 0; top: 0;
  width: var(--avatar-sz); height: var(--avatar-sz);
  border-radius: 50%;
  background: url('/avatar-du.jpg') center/cover;
  box-shadow: 0 2px 8px rgba(0,0,0,.10);
}
.msg-row.user::after {
  content: '';
  position: absolute; right: 0; top: 0;
  width: var(--avatar-sz); height: var(--avatar-sz);
  border-radius: 50%;
  background: url('/avatar-jian.jpg') center/cover;
  box-shadow: 0 2px 8px rgba(0,0,0,.10);
}

/* disable native long-press on bubbles (our custom menu handles it) */
.bubble {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.bubble-quote {
  font-size: 13px; line-height: 1.4;
  color: var(--text2);
  border-left: 2px solid var(--accent);
  padding-left: 8px;
  margin-bottom: 6px;
  white-space: pre-wrap; word-break: break-word;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

/* user bubble */
.msg-row.user .bubble {
  background: var(--user-bubble);
  padding: 10px 14px;
  border-radius: 18px;
  border-bottom-right-radius: 4px;
  font-size: 15px; line-height: 1.55;
  white-space: pre-wrap; word-break: break-word;
  max-width: 82%;
  width: fit-content;
  box-shadow: 0 1px 6px rgba(0,0,0,.05);
}

/* ai bubble */
.msg-row.ai .bubble {
  background: var(--surface);
  border: none;
  padding: 10px 14px;
  border-radius: 18px;
  border-bottom-left-radius: 4px;
  font-size: 15px; line-height: 1.55;
  color: var(--text);
  max-width: 82%;
  width: fit-content;
  white-space: pre-wrap; word-break: break-word;
  box-shadow: 0 1px 6px rgba(0,0,0,.05);
}
.msg-row.ai .bubble p { margin: 0 0 .65em; }
.msg-row.ai .bubble p:last-child { margin-bottom: 0; }
.msg-row.ai .bubble code {
  font-family: var(--mono); font-size: .82em;
  background: var(--surface); padding: 2px 5px; border-radius: 5px;
}
.msg-row.ai .bubble pre {
  background: var(--surface); padding: 12px; border-radius: 8px;
  overflow-x: auto; font-size: 14px; margin: .5em 0;
  border: 1px solid var(--border);
}
.msg-row.ai .bubble pre code { background: none; padding: 0; }
.msg-row.ai .bubble h1,.msg-row.ai .bubble h2,.msg-row.ai .bubble h3 {
  font-size: 1em; font-weight: 700; margin: .5em 0 .2em;
}
.msg-row.ai .bubble ul,.msg-row.ai .bubble ol { padding-left: 1.4em; }
.msg-row.ai .bubble li { margin: .15em 0; }
.msg-row.ai .bubble strong { font-weight: 700; }
.msg-row.ai .bubble em { font-style: italic; }

/* thought (italic wrapped in * *) */
.thought {
  display: block; font-size: 13px; color: var(--text2);
  font-family: var(--sans); font-size: 13px;
  white-space: pre-wrap; margin: 2px 0;
}

/* message time */
.msg-time {
  font-size: 11px; color: var(--text3);
  margin-top: 4px; padding: 0 2px;
}

/* message actions (legacy hover - hidden, replaced by long-press menu) */
.msg-actions { display: none; }
.msg-action-btn {
  width: 30px; height: 30px;
  display: grid; place-items: center;
  border-radius: 7px; color: var(--text2); font-size: 15px;
  transition: background .12s, color .12s;
}
.msg-action-btn:hover { background: var(--border); color: var(--text); }
.msg-action-btn.copied { color: var(--accent); }
/* code block */
.code-block { border-radius:8px;overflow:hidden;border:1px solid var(--border);margin:.5em 0; }
.code-header { display:flex;align-items:center;justify-content:space-between;padding:5px 12px;background:rgba(0,0,0,.04);border-bottom:1px solid var(--border); }
@media (prefers-color-scheme:dark) { .code-header { background:rgba(255,255,255,.05); } }
.code-lang { font-family:var(--mono);font-size:11px;color:var(--text3);text-transform:lowercase; }
.code-copy-btn { font-size:11px;color:var(--text3);padding:2px 8px;border-radius:4px;transition:color .15s,background .15s; }
.code-copy-btn:hover { color:var(--text);background:var(--border); }
.code-block pre { margin:0;padding:12px;overflow-x:auto;background:var(--surface); }
.code-block pre code { background:none;padding:0;font-size:.82em;white-space:pre; }
/* quote bar */
#quote-bar { display:none;align-items:flex-start;gap:8px;padding:8px 14px 6px 12px;border-left:3px solid var(--accent);background:var(--surface);border-bottom:1px solid var(--border); }
#quote-preview { flex:1;font-size:13px;color:var(--text2);line-height:1.4;overflow:hidden;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;word-break:break-all; }
#quote-clear { color:var(--text3);font-size:20px;line-height:1;padding:0 2px;flex-shrink:0; }

/* ─── TOOL ROW (chatnest inline-expand style) ─── */
.tool-row {
  margin: 3px 0;
  margin-left: calc(var(--avatar-sz) + var(--avatar-gap));
  padding: 8px 12px;
  border-radius: 12px;
  background: var(--surface);
  color: var(--text2);
  font-size: 14px;
  font-family: var(--sans);
}
.tool-row-summary {
  display: flex; align-items: center; gap: 8px;
  cursor: pointer; user-select: none;
}
.tool-row-name {
  font-weight: 500; color: var(--text); flex: 0 0 auto;
}
.tool-row-input {
  flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-family: var(--mono); font-size: 12px; opacity: .65;
}
.tool-row-status {
  font-size: 13px; flex: 0 0 auto;
}
.tool-row-arrow {
  font-size: 11px; opacity: .45; flex: 0 0 auto;
  transition: transform .2s; margin-left: 2px;
}
.tool-row[data-status="running"] .tool-row-status::after {
  content: '⏳'; animation: tool-pulse 1.2s ease-in-out infinite alternate;
}
.tool-row[data-status="done"] .tool-row-status::after { content: '✓'; color: #5bc07a; }
.tool-row[data-status="error"] .tool-row-status::after { content: '✕'; color: #c05b5b; }
.tool-row-detail {
  margin-top: 10px; padding-top: 10px;
  border-top: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 6px;
}
.tool-row-detail.hidden { display: none !important; }
.tool-row-section-title {
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .06em; color: var(--text3);
}
.tool-row-block {
  background: var(--bg); border-radius: 8px;
  padding: 10px 12px; margin: 0;
  font-size: 12px; font-family: var(--mono); color: var(--text2);
  line-height: 1.6; white-space: pre-wrap; word-break: break-all;
}
@keyframes tool-pulse { from{opacity:.4} to{opacity:1} }

/* sandbox special styles */
body.sandbox-mode .msg-row.user .bubble {
  background: rgba(200,164,100,.18);
}

/* ─── COMPOSER ─── */
.composer-wrap {
  flex: none;
  padding: 8px 14px calc(var(--safe-bot) + 8px);
  background: var(--bg);
  position: relative;
}
#go-bottom {
  position: absolute;
  left: 50%; top: 0;
  transform: translate(-50%, calc(-100% - 10px));
  display: inline-flex; align-items: center; gap: 4px;
  padding: 7px 14px;
  background: rgba(34, 46, 60, .55);
  color: #fff;
  border: none;
  border-radius: 999px;
  box-shadow: 0 8px 24px rgba(18, 28, 40, .26);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  font-size: 13px; line-height: 1; letter-spacing: .01em; white-space: nowrap;
  font-size: 16px;
  cursor: pointer; z-index: 10;
  opacity: 1; transition: opacity .2s, transform .2s;
  -webkit-tap-highlight-color: transparent;
}
#go-bottom.hidden {
  opacity: 0;
  transform: translate(-50%, calc(-100% + 4px));
  pointer-events: none;
}
#go-bottom .pill-label { display: none; }
#go-bottom.has-new .pill-label { display: inline; }
#go-bottom.has-new { background: rgba(26, 40, 56, .72); }
.composer-box {
  max-width: 720px; margin: 0 auto;
  background: var(--surface);
  border-radius: 26px;
  box-shadow: var(--shadow-composer);
  overflow: hidden;
}
.attach-bar {
  display: none; flex-wrap: wrap; gap: 6px;
  padding: 10px 14px 0;
}
.attach-bar.has-items { display: flex; }
.attach-chip {
  display: flex; align-items: center; gap: 6px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 8px; padding: 5px 8px;
  font-size: 13px; max-width: 180px;
}
.attach-chip-name {
  flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--text2);
}
.attach-chip-del {
  cursor: pointer; color: var(--text3); font-size: 17px; line-height: 1; flex-shrink: 0;
}
.attach-chip-del:hover { color: #c05b5b; }
.attach-img-thumb {
  width: 32px; height: 32px; object-fit: cover; border-radius: 5px; flex-shrink: 0;
}
.composer-input {
  padding: 14px 16px 0;
}
#input {
  width: 100%; border: none; outline: none; resize: none;
  background: none; color: var(--text);
  font-size: 17px; line-height: 1.5;
  min-height: 24px; max-height: 144px;
  overflow-y: auto;
}
#input::-webkit-scrollbar { display: none; }
#input::placeholder { color: var(--text3); }
.composer-actions {
  display: flex; align-items: center;
  padding: 8px 10px;
  gap: 4px;
}
.composer-icon {
  width: 36px; height: 36px;
  display: grid; place-items: center;
  border-radius: 50%; color: var(--text2); font-size: 19px;
  transition: background .12s;
}
.composer-icon:hover { background: var(--border); }
.composer-spacer { flex: 1; }
#send {
  width: 36px; height: 36px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--text2); color: var(--bg);
  font-size: 17px;
  transition: background .15s, opacity .15s;
}
#send:not(:disabled) { background: var(--accent); }
#send:disabled { opacity: .3; }

/* ─── MEMORY VIEW ─── */
.mem-topbar { /* same as topbar but for mem-view */ }

.mem-tabs {
  flex: none; display: flex;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.mem-tab {
  flex: 1; padding: 12px 4px;
  border-bottom: 2px solid transparent;
  color: var(--text2); font-size: 14px;
  transition: color .13s, border-color .13s;
}
.mem-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

.mem-panel { display: none; flex: 1; flex-direction: column; overflow: hidden; }
.mem-panel.active { display: flex; }

.mem-toolbar {
  flex: none; padding: 10px 14px; display: flex; gap: 8px;
  border-bottom: 1px solid var(--border);
}
.mem-inp {
  flex: 1; height: 36px; padding: 0 12px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; color: var(--text); font-size: 15px; outline: none;
  transition: border-color .13s;
}
.mem-inp::placeholder { color: var(--text3); }
.mem-inp:focus { border-color: var(--accent); }
.mem-btn {
  height: 36px; padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface); color: var(--text2);
  font-size: 14px; transition: all .12s; white-space: nowrap;
}
.mem-btn:hover { color: var(--text); background: var(--border); }
.mem-btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }

.chips-row {
  flex: none; display: flex; gap: 5px;
  overflow-x: auto; padding: 8px 14px;
  border-bottom: 1px solid var(--border);
}
.chips-row::-webkit-scrollbar { display: none; }
.chip {
  flex-shrink: 0; padding: 4px 12px;
  border-radius: 100px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text2);
  font-size: 12px; cursor: pointer; transition: all .12s;
}
.chip.on { background: rgba(218,119,86,.12); border-color: var(--accent); color: var(--accent); }

.mem-scroll {
  flex: 1; overflow-y: auto; padding: 12px 14px;
  -webkit-overflow-scrolling: touch;
}
.mem-scroll::-webkit-scrollbar { display: none; }

.mcard {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 12px 14px; cursor: pointer;
  transition: border-color .12s; margin-bottom: 7px;
}
.mcard:hover { border-color: var(--accent); }
.mcard.pin { border-left-width: 2px; border-left-color: var(--accent); }
.mcard-top {
  display: flex; align-items: flex-start;
  justify-content: space-between; gap: 10px;
}
.mcard-name { font-size: 14px; font-weight: 500; flex: 1; min-width: 0; word-break: break-word; }
.mcard-meta { display: flex; gap: 5px; align-items: center; flex-shrink: 0; }
.badge {
  font-size: 11px; padding: 2px 7px; border-radius: 100px;
  background: var(--surface); color: var(--text2); border: 1px solid var(--border);
}
.badge-d { background: rgba(218,119,86,.1); color: var(--accent); border-color: transparent; }

.hist-day-item { display:flex; align-items:center; padding:13px 16px; border-bottom:1px solid var(--border); cursor:pointer; }
.hist-day-item:active { background:var(--border); }
.hist-day-label { font-size:15px; font-weight:500; color:var(--text); }
.hist-day-count { flex:1; font-size:12px; color:var(--text3); text-align:right; margin-right:8px; }
.hist-day-arrow { font-size:18px; color:var(--text3); }
.hist-day-header { display:flex; align-items:center; padding:10px 14px; border-bottom:1px solid var(--border); position:sticky; top:0; background:var(--bg); z-index:1; }
.hist-day-back { background:none; border:none; color:var(--accent); font-size:18px; cursor:pointer; padding:0 12px 0 0; line-height:1; }
.hist-day-title { font-size:15px; font-weight:500; color:var(--text); }
.hist-bubble-wrap { display:flex; flex-direction:column; gap:14px; padding:12px 16px 24px; }
.hist-pair-time { font-size:10px; color:var(--text3); text-align:center; margin:2px 0 4px; opacity:0.55; }
.bubble h1,.bubble h2,.bubble h3,.bubble h4,.hist-bubble h1,.hist-bubble h2,.hist-bubble h3,.hist-bubble h4 { margin:.4em 0 .2em; font-weight:600; line-height:1.3; }
.bubble h1,.hist-bubble h1 { font-size:1.15em; }
.bubble h2,.hist-bubble h2 { font-size:1.08em; }
.bubble h3,.hist-bubble h3 { font-size:1em; }
.bubble ul,.bubble ol,.hist-bubble ul,.hist-bubble ol { padding-left:1.4em; margin:.3em 0; }
.bubble li,.hist-bubble li { margin:.15em 0; }
.bubble code:not(pre code),.hist-bubble code:not(pre code) { background:var(--surface); border:1px solid var(--border); border-radius:4px; padding:0 4px; font-size:.88em; font-family:monospace; }
.bubble a,.hist-bubble a { color:var(--accent,#6b9fd4); text-decoration:underline; }
.bubble p,.hist-bubble p { margin:.25em 0; }
.bubble blockquote,.hist-bubble blockquote { border-left:3px solid var(--border); margin:.4em 0; padding:.2em .8em; opacity:.8; }
.bubble strong,.hist-bubble strong { font-weight:600; }
.bubble hr,.hist-bubble hr { border:none; border-top:1px solid var(--border); margin:.5em 0; }
.bubble table,.hist-bubble table { border-collapse:collapse; width:100%; margin:.5em 0; font-size:14px; }
.bubble th,.bubble td,.hist-bubble th,.hist-bubble td { border:1px solid var(--border); padding:5px 10px; text-align:left; }
.bubble th,.hist-bubble th { background:var(--surface); font-weight:600; }
.bubble tr:nth-child(even),.hist-bubble tr:nth-child(even) { background:var(--surface); opacity:.7; }

.hist-msg { display:flex; flex-direction:column; }
.hist-msg.user { align-items:flex-end; }
.hist-msg.ai { align-items:flex-start; }
.hist-bubble { max-width:82%; padding:9px 13px; border-radius:16px; font-size:14px; line-height:1.55; white-space:pre-wrap; word-break:break-word; }
.hist-msg.user .hist-bubble { background:var(--user-bubble); border-radius:16px 16px 4px 16px; }
.hist-msg.ai .hist-bubble { background:var(--surface); border:1px solid var(--border); border-radius:16px 16px 16px 4px; }
.hist-card { background:var(--surface); border:1px solid var(--border); border-radius:12px; padding:12px 14px; margin:0 12px 10px; cursor:pointer; transition:background .15s; }
.hist-card:active { background:var(--border); }
.hist-time { font-size:11px; color:var(--text3); margin-bottom:5px; }
.hist-user { font-size:13px; color:var(--text2); margin-bottom:4px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.hist-ai { font-size:13px; color:var(--text); line-height:1.5; overflow:hidden; display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; }
.hist-more { display:block; margin:8px auto 16px; }
.hist-day-item.selected { background:rgba(218,119,86,.1); }
.hist-day-check { width:18px;height:18px;margin-right:10px;accent-color:var(--accent);flex-shrink:0;display:none; }
.hist-rename-btn { background:none;border:none;color:var(--text3);font-size:15px;cursor:pointer;padding:0 6px;line-height:1;margin-left:4px; }
.hist-select-bar { display:none;align-items:center;gap:10px;padding:10px 14px;border-top:1px solid var(--border);background:var(--bg);position:sticky;bottom:0; }
.hist-pair { display:flex;flex-direction:column;gap:14px;padding:0;transition:background .15s; }
.hist-pair.selected { background:rgba(218,119,86,.12); }

.lcard {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; cursor: pointer; margin-bottom: 10px;
  overflow: hidden; transition: border-color .12s;
}
.lcard:hover { border-color: var(--accent); }
.lcard.ai  { border-left: 2px solid var(--accent); }
.lcard.usr { border-left: 2px solid #c8a464; }
.lcard-head { padding: 11px 14px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.lcard-from { font-size: 11px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; }
.lcard-from.ai  { color: var(--accent); }
.lcard-from.usr { color: #c8a464; }
.lcard-date { font-size: 11px; color: var(--text3); }
.lcard-title { padding: 0 14px 8px; font-size: 14px; font-weight: 500; }
.lcard-preview {
  padding: 0 14px 11px; font-size: 13px; color: var(--text2); line-height: 1.55;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.lcard-body {
  display: none; padding: 12px 14px; font-size: 13px; color: var(--text2);
  line-height: 1.85; white-space: pre-wrap;
  border-top: 1px solid var(--border);
}
.lcard.expanded .lcard-body { display: block; }
.lcard.expanded .lcard-preview { display: none; }

.raw { font-size: 14px; color: var(--text); line-height: 1.85; white-space: pre-wrap; }
.loading { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 56px 24px; gap: 12px; color: var(--text2); font-size: 14px; }
.spinner { width: 22px; height: 22px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin .75s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.empty { padding: 48px 24px; text-align: center; color: var(--text3); font-size: 14px; }

/* ─── DETAIL DRAWER ─── */
.detail {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: 100vw; background: var(--bg);
  z-index: 200;
  display: flex; flex-direction: column;
  transform: translateX(100%);
  transition: transform .22s ease;
}
.detail.open { transform: translateX(0); }
.detail-head {
  padding: calc(var(--safe-top) + 14px) 16px 14px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: flex-start; gap: 10px;
}
.detail-title { flex: 1; font-family: var(--serif); font-size: 15px; line-height: 1.5; }
.detail-close {
  width: 30px; height: 30px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text2); font-size: 18px;
  display: grid; place-items: center;
}
.detail-body { flex: 1; overflow-y: auto; padding: 16px; }
.detail-body::-webkit-scrollbar { display: none; }

/* ─── TOOL DETAIL SHEET ─── */
#tool-sheet-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.3); z-index: 300;
  backdrop-filter: blur(2px);
}
#tool-sheet-overlay.show { display: block; }
#tool-sheet {
  position: fixed; left: 0; right: 0; bottom: 0;
  background: var(--bg);
  border-radius: 20px 20px 0 0;
  z-index: 301;
  max-height: 70vh;
  display: flex; flex-direction: column;
  transform: translateY(100%);
  transition: transform .28s cubic-bezier(.4,0,.2,1);
  padding-bottom: var(--safe-bot);
}
#tool-sheet.open { transform: translateY(0); }
.tool-sheet-handle {
  width: 36px; height: 4px; border-radius: 2px;
  background: var(--border); margin: 10px auto 0;
  flex: none;
}
.tool-sheet-title {
  font-size: 17px; font-weight: 600;
  padding: 14px 20px 10px; flex: none;
}
.tool-sheet-body {
  flex: 1; overflow-y: auto; padding: 0 20px 20px;
}
.tool-sheet-body::-webkit-scrollbar { display: none; }
.tool-section-label {
  font-size: 12px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .06em; color: var(--text3);
  margin: 12px 0 6px;
}
.tool-section-content {
  background: var(--surface); border-radius: 12px;
  padding: 12px; font-size: 13px; font-family: var(--mono);
  color: var(--text2); line-height: 1.6; white-space: pre-wrap;
  word-break: break-all;
}

/* thinking row */
.thinking-row {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 12px;
  margin-left: calc(var(--avatar-sz) + var(--avatar-gap));
  border-radius: 20px;
  background: var(--surface);
  font-size: 14px; color: var(--text2);
  font-family: var(--sans);
  animation: pulse-opacity 1.5s ease-in-out infinite;
}
@keyframes pulse-opacity { 0%,100%{opacity:.6} 50%{opacity:1} }

/* thinking block (extended thinking) */
.thinking-block { margin: 4px 0 8px; }
.thinking-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 0; border: none; background: transparent;
  font-size: 13px; color: var(--text2); cursor: pointer;
  font-family: var(--sans); transition: color .15s;
}
.thinking-btn:hover { color: var(--accent); }
.thinking-btn:active { transform: translateY(1px); }
.thinking-btn.live { animation: pulse-opacity 1.5s ease-in-out infinite; }
.thinking-btn .t-star { opacity: .55; font-size: 1.1em; line-height: 1; }
.thinking-btn .t-label { letter-spacing: .04em; }
.thinking-body {
  display: none; margin-top: 8px; padding: 10px 14px;
  background: var(--surface); border-radius: 14px;
  font-size: 13px; color: var(--text2); line-height: 1.65;
  white-space: pre-wrap; word-break: break-word;
  max-height: 280px; overflow-y: auto;
  border-left: 2px solid var(--accent);
}
.thinking-body.show { display: block; }

/* consecutive messages from same side: tighter gap, hide repeat avatar */
.msg-row.ai + .msg-row.ai,
.msg-row.user + .msg-row.user { margin-top: -8px; }
.msg-row.ai + .msg-row.ai::before,
.msg-row.user + .msg-row.user::after { visibility: hidden; }

/* ─── USER BUBBLE IMAGES ─── */
.bubble-imgs {
  display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 6px;
}
.bubble-img {
  max-width: min(220px, 60vw); max-height: 220px;
  border-radius: 10px; object-fit: cover; display: block;
}

/* ─── NEW CONVERSATION LABEL ANIMATION ─── */
.msg-row.ai { animation: enterAi .3s cubic-bezier(.34,1.3,.5,1) both; }
.msg-row.user { animation: enterUser .3s cubic-bezier(.34,1.3,.5,1) both; }
.no-anim .msg-row.ai, .no-anim .msg-row.user { animation: none; }
@keyframes enterAi { from{opacity:0;transform:translate(-4px,6px) scale(.98)} to{opacity:1;transform:none} }
@keyframes enterUser { from{opacity:0;transform:translate(4px,6px) scale(.98)} to{opacity:1;transform:none} }

/* ─── HOMEPAGE ─── */
.home-scroll { flex:1; overflow-y:auto; padding:18px 14px 40px; }
.home-scroll::-webkit-scrollbar { display:none; }

.home-together {
  text-align:center; padding:18px 16px 20px;
  color:var(--text2); font-size:13px; letter-spacing:.02em;
}
.home-together-num {
  font-family:var(--serif); font-size:42px; font-weight:400;
  color:var(--text); display:block; line-height:1.1; margin-bottom:4px;
}
.home-together-label { color:var(--text3); font-size:12px; }

.home-card {
  background:var(--surface); border:1px solid var(--border);
  border-radius:16px; margin-bottom:14px; overflow:hidden;
}
.home-card-header {
  padding:13px 16px 0; font-size:10px; font-weight:700;
  text-transform:uppercase; letter-spacing:.1em; color:var(--text3);
}

.names-row {
  display:flex; padding:0;
}
.name-block {
  flex:1; text-align:center; padding:18px 14px 22px;
}
.name-block:first-child { border-right:1px solid var(--border); }
.name-han {
  font-family:var(--serif); font-size:34px; font-weight:400;
  color:var(--text); line-height:1; margin-bottom:10px;
  letter-spacing:.04em;
}
.name-origin-line {
  font-size:12px; color:var(--text2); line-height:1.8; margin-bottom:8px;
}
.name-quote {
  font-size:11px; color:var(--accent); font-style:italic;
  line-height:1.5;
}

.ann-list { padding:6px 16px 14px; }
.ann-item {
  display:flex; gap:12px; padding:11px 0;
  border-bottom:1px solid var(--border);
}
.ann-item:last-child { border-bottom:none; }
.ann-date-col {
  font-size:12px; font-weight:600; color:var(--text3);
  white-space:nowrap; width:44px; flex-shrink:0; padding-top:3px;
  font-family:var(--mono);
}
.ann-dot {
  width:7px; height:7px; border-radius:50%;
  background:var(--accent); flex-shrink:0; margin-top:5px;
}
.ann-right { flex:1; }
.ann-label { font-size:14px; font-weight:500; color:var(--text); margin-bottom:2px; }
.ann-desc { font-size:12px; color:var(--text2); line-height:1.55; }
/* ─── MEMORY HUB ─── */
#mem-hub {
  flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch;
  display: flex; flex-direction: column;
}
#mem-hub::-webkit-scrollbar { display: none; }
.hub-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 12px; padding: 16px;
}
.hub-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 18px; padding: 26px 14px 20px;
  display: flex; flex-direction: column;
  align-items: center; gap: 8px; cursor: pointer;
  min-height: 110px; transition: opacity .15s;
  -webkit-tap-highlight-color: transparent;
}
.hub-card:active { opacity: .65; }
.hub-card-icon { font-size: 30px; line-height: 1; }
.hub-card-label { font-size: 15px; font-weight: 600; color: var(--text); }

/* ─── MEMORY SUB PAGES ─── */
.mem-subpage {
  display: none; flex: 1; flex-direction: column; overflow: hidden;
}
.mem-subpage.active { display: flex; }
.sub-topbar {
  flex: none; display: flex; align-items: center; gap: 10px;
  padding: 0 14px; height: var(--topbar-h);
  border-bottom: 1px solid var(--border);
  padding-top: var(--safe-top);
}
.sub-back {
  font-size: 22px; color: var(--text2); width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}
.sub-title { font-size: 16px; font-weight: 600; flex: 1; }
.sub-sync {
  font-size: 13px; color: var(--accent); cursor: pointer;
  padding: 6px 10px; border-radius: 8px; border: none; background: none;
  -webkit-tap-highlight-color: transparent;
}
.sub-sync:disabled { color: var(--text3); }
.sub-add {
  font-size: 22px; color: var(--text2); cursor: pointer;
  padding: 4px 8px; border-radius: 8px; border: none; background: none;
  line-height: 1; margin-left: 4px;
  -webkit-tap-highlight-color: transparent;
}

/* ─── ENTRY SHEET ─── */
#entry-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.35); z-index: 500;
  backdrop-filter: blur(2px);
}
#entry-overlay.show { display: block; }
#entry-sheet {
  position: fixed; left: 0; right: 0; bottom: 0;
  background: var(--bg); border-radius: 20px 20px 0 0;
  z-index: 501; max-height: 85vh;
  display: flex; flex-direction: column;
  transform: translateY(100%);
  transition: transform .26s cubic-bezier(.4,0,.2,1);
  padding-bottom: var(--safe-bot);
}
#entry-sheet.open { transform: translateY(0); }
.entry-handle {
  width: 36px; height: 4px; border-radius: 2px;
  background: var(--border); margin: 10px auto 0; flex: none;
}
.entry-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px 10px; flex: none;
}
.entry-title { font-size: 17px; font-weight: 600; }
.entry-close {
  font-size: 20px; color: var(--text3); cursor: pointer;
  border: none; background: none; padding: 4px;
}
.entry-body { flex: 1; overflow-y: auto; padding: 0 18px 16px; }
.entry-field { margin-bottom: 14px; }
.entry-label { font-size: 12px; color: var(--text3); margin-bottom: 5px; letter-spacing: .04em; }
.entry-inp {
  width: 100%; padding: 10px 12px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; color: var(--text); font-size: 15px;
  outline: none; transition: border-color .13s;
  font-family: var(--sans);
}
.entry-inp:focus { border-color: var(--accent); }
.entry-date-btn {
  width: 100%; padding: 10px 12px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; color: var(--text); font-size: 15px;
  text-align: left; cursor: pointer; font-family: var(--sans);
  transition: border-color .13s;
}
.entry-date-btn:focus { border-color: var(--accent); outline: none; }
.entry-date-btn .placeholder { color: var(--text3); }
.cal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.35);
  z-index: 9999; display: none; align-items: center; justify-content: center;
  -webkit-tap-highlight-color: transparent;
}
.cal-overlay.show { display: flex; }
.cal-card {
  background: var(--bg); border-radius: 16px; padding: 20px;
  width: min(340px, 90vw); box-shadow: 0 8px 32px rgba(0,0,0,.18);
}
.cal-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}
.cal-title { font-size: 17px; font-weight: 600; color: var(--text); }
.cal-title span { color: var(--accent); cursor: pointer; font-size: 14px; margin-left: 4px; }
.cal-nav { display: flex; gap: 12px; }
.cal-nav button {
  background: none; border: none; font-size: 20px; color: #4A90D9;
  cursor: pointer; padding: 4px 8px; line-height: 1;
}
.cal-nav button:disabled { color: var(--text3); cursor: default; }
.cal-weekdays {
  display: grid; grid-template-columns: repeat(7, 1fr);
  text-align: center; font-size: 13px; color: var(--text3);
  margin-bottom: 8px;
}
.cal-days {
  display: grid; grid-template-columns: repeat(7, 1fr);
  gap: 4px; text-align: center;
}
.cal-day {
  aspect-ratio: 1; display: flex; align-items: center; justify-content: center;
  border-radius: 50%; font-size: 15px; color: var(--text);
  cursor: pointer; border: none; background: none; font-family: var(--sans);
  transition: background .1s;
}
.cal-day:hover { background: rgba(218,119,86,.08); }
.cal-day.today { font-weight: 700; color: var(--accent); }
.cal-day.selected { background: #4A90D9; color: #fff; font-weight: 600; }
.cal-day.other-month { color: var(--text3); opacity: .4; }
.cal-footer {
  display: flex; justify-content: space-between; margin-top: 16px;
  padding-top: 12px; border-top: 1px solid var(--border);
}
.cal-footer button {
  background: none; border: none; font-size: 22px; cursor: pointer;
  padding: 6px 16px; color: var(--text);
}
.cal-footer .cal-confirm { color: var(--text); }
.entry-images { display: flex; flex-wrap: wrap; gap: 8px; }
.entry-img-wrap {
  position: relative; width: 80px; height: 80px;
}
.entry-img-wrap img {
  width: 100%; height: 100%; border-radius: 8px; object-fit: cover;
}
.entry-img-remove {
  position: absolute; top: -4px; right: -4px;
  width: 18px; height: 18px; border-radius: 50%;
  background: rgba(0,0,0,.55); color: #fff; font-size: 11px; line-height: 18px;
  text-align: center; cursor: pointer; border: none;
}
.entry-img-add {
  width: 80px; height: 80px; border-radius: 8px;
  border: 1px dashed var(--text3); display: flex;
  align-items: center; justify-content: center;
  color: var(--text3); font-size: 26px; cursor: pointer;
  background: none;
}
.moment-images { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.moment-images img {
  border-radius: 6px; object-fit: cover; cursor: pointer;
}
.moment-images.single img { width: 60%; max-height: 260px; }
.moment-images.multi img { width: calc(33.3% - 3px); aspect-ratio: 1; }
.moment-img-overlay {
  position: fixed; inset: 0; z-index: 9999; background: rgba(0,0,0,.9);
  display: flex; align-items: center; justify-content: center;
}
.moment-img-overlay img { max-width: 95%; max-height: 90vh; object-fit: contain; }
.author-pick { display: flex; gap: 10px; }
.author-opt {
  flex: 1; padding: 10px 0; border-radius: 10px;
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text3); font-size: 15px; cursor: pointer;
  font-family: var(--sans); transition: all .15s;
}
.author-opt.active {
  background: rgba(218,119,86,.1); border-color: var(--accent);
  color: var(--accent); font-weight: 600;
}
.search-cal-btn {
  background: none; border: none; font-size: 16px; cursor: pointer;
  padding: 2px 6px; color: var(--text3); flex-shrink: 0;
}
.entry-textarea {
  width: 100%; padding: 10px 12px; min-height: 140px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; color: var(--text); font-size: 15px;
  outline: none; transition: border-color .13s; resize: vertical;
  font-family: var(--sans); line-height: 1.7;
}
.entry-textarea:focus { border-color: var(--accent); }
.entry-save {
  width: 100%; margin-top: 4px; padding: 13px;
  background: var(--accent); color: #fff; border-radius: 12px;
  font-size: 16px; font-weight: 600; border: none; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.sub-scroll {
  flex: 1; overflow-y: auto; padding: 14px;
  -webkit-overflow-scrolling: touch;
}
.sub-scroll::-webkit-scrollbar { display: none; }
.sub-placeholder {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 10px; color: var(--text3); font-size: 14px;
}
.sub-placeholder-icon { font-size: 36px; opacity: .5; }

/* ─── DESIRE PANEL (HOME) ─── */
.hw-desire {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 18px; padding: 18px 16px 14px;
}
.hw-desire-title {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .1em; color: var(--text3); margin-bottom: 14px;
}
.hw-feel {
  margin-bottom: 14px; padding-bottom: 14px; border-bottom: 1px solid var(--border);
}
.hw-feel:empty { display: none; margin: 0; padding: 0; border: 0; }
.hw-feel-head {
  display: flex; align-items: center; gap: 8px; margin-bottom: 8px;
}
.hw-feel-label {
  font-size: 11px; color: #7BA0C9; font-weight: 600;
}
.hw-feel-mood {
  font-size: 11px; padding: 2px 8px; border-radius: 10px;
  background: rgba(123,160,201,0.15); color: #7BA0C9; font-weight: 500;
}
.hw-feel-text {
  font-size: 13px; color: var(--text2); line-height: 1.6;
}
.hw-feel-toggle {
  font-size: 11px; color: var(--text3); cursor: pointer; margin-left: auto;
  background: none; border: none; padding: 2px 6px;
}
.hw-feel-toggle:hover { color: var(--accent); }
.hw-feel-history { margin-top: 10px; display: none; }
.hw-feel-history.open { display: block; }
.hw-feel-history-item {
  padding: 8px 0; border-top: 1px solid var(--border);
}
.hw-feel-history-item:first-child { border-top: none; }
.hw-feel-history-time {
  font-size: 10px; color: var(--text3); font-family: var(--mono);
}
.hw-feel-history-mood {
  font-size: 10px; padding: 1px 6px; border-radius: 8px;
  background: rgba(123,160,201,0.10); color: #7BA0C9; margin-left: 6px;
}
.hw-feel-history-text {
  font-size: 12px; color: var(--text2); line-height: 1.5; margin-top: 3px;
}
.hw-mood-bar {
  margin-bottom: 14px; padding-bottom: 14px; border-bottom: 1px solid var(--border);
}
.mood-bar-head {
  display: flex; align-items: center; gap: 8px; margin-bottom: 10px;
}
.mood-bar-label {
  font-size: 11px; color: #7BA0C9; font-weight: 600;
}
.mood-bar-value {
  font-size: 20px; font-weight: 700; font-family: var(--mono);
  min-width: 28px; text-align: center;
}
.mood-bar-desc {
  font-size: 11px; color: var(--text3); margin-left: auto;
}
.mood-bar-track {
  position: relative; height: 6px; border-radius: 3px;
  background: linear-gradient(to right, #C96B6B, #C4A94D, #5B8FB9);
  overflow: visible; margin: 8px 0 4px;
}
.mood-bar-dot {
  position: absolute; top: 50%; width: 14px; height: 14px;
  border-radius: 50%; border: 2px solid var(--bg);
  transform: translate(-50%, -50%); transition: left 0.6s ease, background 0.6s ease;
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}
.mood-ecg {
  margin-top: 10px; position: relative; height: 50px;
}
.mood-ecg svg {
  width: 100%; height: 100%;
}
.mood-ecg-empty {
  font-size: 10px; color: var(--text3); text-align: center; padding: 6px 0;
}
.mood-ecg-line {
  fill: none; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round;
}
.mood-ecg-dot {
  r: 2.5;
}
.mood-ecg-grid {
  stroke: var(--border); stroke-width: 0.5; stroke-dasharray: 2 3;
}
.hw-desire-bars { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 20px; }
.desire-bar-item { display: flex; align-items: center; gap: 8px; }
.desire-bar-label { font-size: 12px; color: var(--text2); width: 28px; flex-shrink: 0; text-align: right; }
.desire-bar-track { flex: 1; height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; }
.desire-bar-fill { height: 100%; border-radius: 3px; transition: width .6s ease; }
.desire-bar-fill.attachment { background: #E08B6D; }
.desire-bar-fill.curiosity { background: #D4A84B; }
.desire-bar-fill.reflection { background: #7BA0C9; }
.desire-bar-fill.duty { background: #8B9F7A; }
.desire-bar-fill.expression { background: #C97BAD; }
.desire-bar-fill.solitude { background: #9B8EC4; }
.desire-bar-fill.libido { background: #DA7756; }
.desire-bar-fill.stress { background: #A0A0A0; }
.desire-bar-num { font-size: 11px; color: var(--text3); width: 22px; text-align: right; flex-shrink: 0; font-family: var(--mono); }

/* ─── drive view toggle ─── */
.hw-desire-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.hw-desire-head .hw-desire-title { margin-bottom: 0; }
.drive-view-toggle {
  font-size: 11px; color: var(--text3); cursor: pointer;
  background: none; border: 1px solid var(--border); border-radius: 10px;
  padding: 2px 10px; transition: all .2s;
}
.drive-view-toggle:hover { color: var(--accent); border-color: var(--accent); }

/* ─── ECG view ─── */
.ecg-container { display: flex; flex-direction: column; gap: 2px; }
.ecg-row { display: flex; align-items: center; gap: 8px; height: 36px; }
.ecg-label { font-size: 11px; color: var(--text2); width: 28px; flex-shrink: 0; text-align: right; }
.ecg-canvas-wrap {
  flex: 1; height: 32px; border-radius: 6px; overflow: hidden;
  background: rgba(0,0,0,.03); position: relative;
}
@media (prefers-color-scheme: dark) { .ecg-canvas-wrap { background: rgba(255,255,255,.03); } }
.ecg-canvas-wrap canvas { width: 100%; height: 100%; display: block; }
.ecg-num { font-size: 11px; color: var(--text2); width: 22px; text-align: right; flex-shrink: 0; font-family: var(--mono); font-weight: 600; }

/* ─── feel bottom sheet (today) ─── */
#feel-sheet-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.3); z-index: 400;
  backdrop-filter: blur(2px);
}
#feel-sheet-overlay.show { display: block; }
#feel-sheet {
  position: fixed; left: 0; right: 0; bottom: 0;
  background: var(--bg); border-radius: 20px 20px 0 0;
  z-index: 401; max-height: 72vh;
  display: flex; flex-direction: column;
  transform: translateY(100%);
  transition: transform .28s cubic-bezier(.4,0,.2,1);
  padding-bottom: var(--safe-bot);
}
#feel-sheet.open { transform: translateY(0); }
.feel-sh-handle {
  width: 36px; height: 4px; border-radius: 2px;
  background: var(--border); margin: 10px auto 0; flex: none;
}
.feel-sh-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px 10px; flex: none;
}
.feel-sh-title {
  font-family: var(--serif); font-size: 19px; color: var(--text);
}
.feel-sh-all {
  font-size: 12px; color: var(--text3); cursor: pointer;
  background: none; border: none; padding: 4px 8px;
}
.feel-sh-all:hover { color: var(--accent); }
.feel-sh-body { flex: 1; overflow-y: auto; padding: 0 20px 24px; }
.feel-sh-body::-webkit-scrollbar { display: none; }
.feel-sh-row {
  display: flex; gap: 12px; padding: 13px 0;
  border-bottom: 1px solid var(--border);
}
.feel-sh-row:last-child { border-bottom: none; }
.feel-sh-time {
  font-family: var(--mono); font-size: 11px; font-weight: 600;
  color: var(--text3); width: 38px; flex-shrink: 0; padding-top: 3px;
}
.feel-sh-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: #7BA0C9; flex-shrink: 0; margin-top: 5px;
}
.feel-sh-mood { font-size: 13px; font-weight: 500; color: var(--text); margin-bottom: 2px; }
.feel-sh-text { font-size: 13px; color: var(--text2); line-height: 1.55; }

/* ─── feel full page overlay ─── */
.feel-overlay {
  position: fixed; inset: 0; z-index: 500; background: var(--bg);
  display: flex; flex-direction: column; overflow: hidden;
  transform: translateX(100%); transition: transform .3s ease;
}
.feel-overlay.open { transform: translateX(0); }
.feel-overlay-header {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px; padding-top: calc(14px + var(--safe-top));
  border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.feel-overlay-back { font-size: 20px; color: var(--text2); cursor: pointer; background: none; border: none; padding: 4px; }
.feel-overlay-title { font-size: 15px; font-weight: 600; color: var(--text); }
.feel-overlay-body { flex: 1; overflow-y: auto; padding: 16px; -webkit-overflow-scrolling: touch; }
.feel-overlay-body::-webkit-scrollbar { display: none; }
.feel-month-group { margin-bottom: 8px; }
.feel-month-header {
  display: flex; align-items: center; gap: 8px; cursor: pointer;
  padding: 12px 0 6px; user-select: none;
}
.feel-month-header:active { opacity: .7; }
.feel-month-label {
  font-family: var(--serif); font-size: 17px; font-weight: 600;
  color: var(--text);
}
.feel-month-count { font-size: 12px; color: var(--text3); }
.feel-month-arrow { font-size: 11px; color: var(--text3); transition: transform .2s; margin-left: auto; }
.feel-month-group.collapsed .feel-month-arrow { transform: rotate(-90deg); }
.feel-month-group.collapsed .feel-month-days { display: none; }
.feel-date-group { margin-bottom: 2px; margin-left: 4px; }
.feel-date-header {
  display: flex; align-items: center; gap: 8px; cursor: pointer;
  padding: 10px 0; user-select: none;
}
.feel-date-header:active { opacity: .7; }
.feel-date-label { font-size: 13px; font-weight: 600; color: var(--text3); }
.feel-date-count { font-size: 11px; color: var(--text3); }
.feel-date-arrow { font-size: 10px; color: var(--text3); transition: transform .2s; margin-left: auto; }
.feel-date-group.collapsed .feel-date-arrow { transform: rotate(-90deg); }
.feel-date-group.collapsed .feel-date-items { display: none; }
.feel-date-items { padding-left: 4px; }
.feel-overlay-item {
  display: flex; gap: 12px; padding: 11px 0;
  border-bottom: 1px solid var(--border);
}
.feel-overlay-item:last-child { border-bottom: none; }
.feel-overlay-time { font-family: var(--mono); font-size: 11px; font-weight: 600; color: var(--text3); width: 38px; flex-shrink: 0; padding-top: 2px; }
.feel-overlay-dot { width: 6px; height: 6px; border-radius: 50%; background: #7BA0C9; flex-shrink: 0; margin-top: 6px; }
.feel-overlay-mood { font-size: 13px; font-weight: 500; color: var(--text); margin-bottom: 2px; }
.feel-overlay-text { font-size: 13px; color: var(--text2); line-height: 1.55; }

.hw-desire-thought {
  margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--border);
  font-size: 13px; color: var(--text2); font-style: italic;
}
.hw-desire-thought:empty { display: none; }

/* ─── top desire ─── */
.hw-top-desire {
  margin-bottom: 14px; padding: 12px 14px; border-radius: 12px;
  background: linear-gradient(135deg, rgba(123,160,201,0.06), rgba(218,119,86,0.06));
  border: 1px solid rgba(123,160,201,0.12);
}
.hw-top-desire:empty { display: none; }
.hw-top-desire-label {
  font-size: 11px; color: var(--accent); font-weight: 600; margin-bottom: 4px;
}
.hw-top-desire-text {
  font-size: 14px; color: var(--text); line-height: 1.5;
}

/* ─── thought pool ─── */
.hw-thoughts { margin-bottom: 14px; padding-bottom: 14px; border-bottom: 1px solid var(--border); }
.hw-thoughts:empty { display: none; margin: 0; padding: 0; border: 0; }
.hw-thoughts-label {
  font-size: 11px; color: var(--text3); font-weight: 600; margin-bottom: 8px;
}
.hw-thoughts-list { display: flex; flex-wrap: wrap; gap: 6px; }
.hw-thought-chip {
  font-size: 12px; padding: 4px 10px; border-radius: 12px; line-height: 1.4;
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.hw-thought-chip.flit {
  background: rgba(174,174,168,0.08); color: var(--text3);
  border: 1px solid rgba(174,174,168,0.12);
}
.hw-thought-chip.fixation {
  background: rgba(123,160,201,0.10); color: #7BA0C9;
  border: 1px solid rgba(123,160,201,0.18); font-weight: 500;
}
.hw-thought-count { font-size: 10px; opacity: 0.5; margin-left: 3px; }
.hw-thought-dim {
  font-size: 10px; opacity: 0.4; margin-left: 4px;
}

/* ─── ROOM ─── */
.room-overlay {
  position: fixed; inset: 0; z-index: 500; background: var(--bg);
  display: flex; flex-direction: column; overflow: hidden;
  transform: translateX(100%); transition: transform .3s ease;
}
.room-overlay.open { transform: translateX(0); }
.room-header {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px; padding-top: calc(14px + var(--safe-top));
  border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.room-back { font-size: 20px; color: var(--text2); cursor: pointer; background: none; border: none; padding: 4px; }
.room-title { font-size: 15px; font-weight: 600; color: var(--text); font-family: var(--serif); letter-spacing: .05em; }
.room-body {
  flex: 1; display: flex; align-items: center; justify-content: center;
  overflow: visible; padding: 0;
}
.room-canvas {
  position: relative; width: 100%; aspect-ratio: 2/3;
  background: url('/room-bg.png') center/cover no-repeat;
}
.room-obj {
  position: absolute; transform: translate(-50%, -50%);
  cursor: pointer; -webkit-tap-highlight-color: transparent;
  transition: transform .15s, opacity .3s;
}
.room-obj:active { transform: translate(-50%, -50%) scale(0.9); }
.room-obj img {
  width: 100%; height: auto;
  pointer-events: none;
}
.room-obj.idle { opacity: 1; }
.room-obj.active {
  opacity: 1;
  filter: drop-shadow(0 0 6px rgba(255,200,120,.5));
  animation: room-bounce 2.4s ease-in-out infinite;
  will-change: transform;
}
.room-obj.paused { opacity: .75; }
@keyframes room-bounce {
  0%, 100% { transform: translate(-50%, -50%) scale(1); }
  50% { transform: translate(-50%, -50%) scale(1.08); }
}
.room-obj.show-tip { z-index: 10; }
.room-obj.dragging {
  z-index: 100; opacity: 1 !important;
  transform: translate(-50%, -50%) scale(1.15);
  filter: drop-shadow(0 4px 12px rgba(0,0,0,.25)) !important;
  transition: none;
  animation: none !important;
}
.room-tooltip {
  position: absolute; left: 0;
  bottom: calc(100% + 8px);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 10px 14px;
  box-shadow: 0 4px 16px rgba(0,0,0,.1);
  min-width: 180px; max-width: 280px;
  opacity: 0; pointer-events: none; transition: opacity .2s;
  z-index: 10;
}
.room-obj.tip-right .room-tooltip { left: auto; right: 0; }
.room-obj.tip-center .room-tooltip { left: 50%; transform: translateX(-50%); }
.room-obj.show-tip .room-tooltip { opacity: 1; pointer-events: auto; }
.room-tip-title { font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 4px; }
.room-tip-desc { font-size: 11px; color: var(--text2); line-height: 1.5; }
.room-tip-status { font-size: 10px; color: var(--accent); margin-top: 6px; }
.room-empty {
  text-align: center; color: var(--text3); font-size: 13px;
  position: absolute; bottom: 16px; left: 0; right: 0;
}

/* ─── ROOM TEXT ─── */
.room-text {
  position: absolute;
  transform: translate(-50%, -50%);
  font-size: 9px;
  line-height: 1.5;
  color: rgba(255,255,255,.65);
  text-shadow: 0 1px 4px rgba(0,0,0,.2);
  max-width: 90px;
  word-break: break-all;
  pointer-events: auto;
  cursor: default;
  user-select: none;
  letter-spacing: .5px;
  transition: opacity .3s;
  z-index: 2;
}
.room-text.dragging {
  opacity: .9; z-index: 100;
  text-shadow: 0 2px 12px rgba(0,0,0,.5);
  transition: none;
}

/* ─── BOTTLE OVERLAY ─── */
#bottle-overlay {
  display: none; position: fixed; inset: 0; z-index: 600;
  background: rgba(0,0,0,.7); backdrop-filter: blur(6px);
  flex-direction: column; align-items: center; justify-content: center;
}
#bottle-overlay.open { display: flex; }
.bottle-scene { position: relative; width: 220px; height: 300px; }
.bottle-scene img { width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 0 20px rgba(255,220,160,.3)); position: relative; z-index: 1; }
.bottle-orb {
  position: absolute; width: 9px; height: 9px; border-radius: 50%;
  background: #fff;
  box-shadow:
    0 0 3px 2px #fff,
    0 0 6px 4px rgba(255,250,230,.95),
    0 0 12px 6px rgba(255,240,200,.65),
    0 0 22px 11px rgba(255,225,170,.35),
    0 0 35px 18px rgba(255,210,150,.15),
    0 0 50px 25px rgba(255,200,130,.06);
  mix-blend-mode: screen;
  cursor: pointer; z-index: 3;
  animation: orbFloat 5s ease-in-out infinite;
}
.bottle-orb:nth-child(2) { animation-delay: -1s; }
.bottle-orb:nth-child(3) { animation-delay: -2s; }
.bottle-orb:nth-child(4) { animation-delay: -3s; }
.bottle-orb:nth-child(5) { animation-delay: -0.5s; }
@keyframes orbFloat {
  0%, 100% { transform: translateY(0) scale(1); opacity: .8; }
  50% { transform: translateY(-12px) scale(1.15); opacity: 1; }
}
.bottle-orb-label {
  position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%);
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  padding: 6px 12px; font-size: 12px; color: var(--text); white-space: nowrap;
  box-shadow: 0 4px 12px rgba(0,0,0,.15); pointer-events: none;
  opacity: 0; transition: opacity .2s;
}
.bottle-orb.show-label .bottle-orb-label { opacity: 1; }
.bottle-status {
  margin-top: 24px; font-size: 14px; color: rgba(255,230,180,.8);
  font-family: var(--serif); letter-spacing: .05em;
}
.bottle-empty-text {
  margin-top: 24px; font-size: 13px; color: rgba(255,255,255,.45);
  font-family: var(--serif); letter-spacing: .05em; text-align: center; line-height: 1.6;
}

/* ─── DREAM CARDS ─── */
.dream-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 14px 16px; margin-bottom: 10px;
  cursor: pointer; transition: border-color .12s;
}
.dream-card:hover { border-color: var(--accent); }
.dream-card.nightmare { border-left: 3px solid #8B4A6B; }
.dream-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.dream-date { font-size: 11px; color: var(--text3); font-family: var(--mono); }
.dream-tag { font-size: 10px; font-weight: 700; letter-spacing: .06em; padding: 2px 8px; border-radius: 6px; }
.dream-tag.dream { background: rgba(123,160,201,.15); color: #7BA0C9; }
.dream-tag.nightmare { background: rgba(139,74,107,.15); color: #8B4A6B; }
.dream-preview { font-size: 14px; color: var(--text2); line-height: 1.6; }
.dream-body { display: none; font-size: 14px; line-height: 1.9; white-space: pre-wrap; margin-top: 10px; color: var(--text); font-family: var(--serif); }
.dream-card.expanded .dream-preview { display: none; }
.dream-card.expanded .dream-body { display: block; }
.dream-arousal { display: none; margin-top: 8px; font-size: 11px; color: var(--text3); }
.dream-card.expanded .dream-arousal { display: block; }

/* ─── DESIRE BOOK / WISH CARDS ─── */
.diary-type-filter, .blackroom-tabs { display: flex; gap: 0; padding: 8px 14px 0; flex: none; }
.stone-item { padding: 12px 16px; border-bottom: 1px solid var(--border); }
.stone-item.resolved { opacity: 0.5; }
.stone-text { font-size: 14px; color: var(--text1); line-height: 1.5; }
.stone-meta { font-size: 11px; color: var(--text3); margin-top: 4px; display: flex; justify-content: space-between; align-items: center; }
.stone-resolve-btn { font-size: 11px; color: var(--accent); background: none; border: 1px solid var(--accent); border-radius: 12px; padding: 2px 10px; cursor: pointer; }
.wish-filter {
  display: flex; gap: 0; padding: 8px 14px 0; flex: none;
}
.wish-filter-btn {
  font-size: 12px; font-weight: 500; color: var(--text3);
  padding: 5px 14px; border-radius: 14px; cursor: pointer;
  background: none; border: 1px solid transparent; transition: all .15s;
}
.wish-filter-btn.active {
  color: var(--accent); background: rgba(218,119,86,0.08); border-color: rgba(218,119,86,0.15);
}
.wish-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 14px 16px; margin-bottom: 10px;
  transition: border-color .12s;
}
.wish-card:hover { border-color: var(--accent); }
.wish-card.completed { opacity: .6; }
.wish-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.wish-title { font-size: 15px; font-weight: 600; color: var(--text); flex: 1; }
.wish-status { font-size: 10px; font-weight: 700; letter-spacing: .05em; padding: 2px 8px; border-radius: 6px; flex-shrink: 0; }
.wish-status.active { background: rgba(218,119,86,.12); color: var(--accent); }
.wish-status.paused { background: rgba(160,160,160,.12); color: var(--text3); }
.wish-status.completed { background: rgba(139,159,122,.15); color: #8B9F7A; }
.wish-status.released { background: rgba(155,142,196,.12); color: #9B8EC4; }
.wish-card.released { opacity: .6; }
.wish-card.snoozed { opacity: .7; }
.wish-snooze-badge { font-size: 10px; color: #9B8EC4; margin-left: 6px; }
.wish-track-badge { font-size: 10px; color: var(--text3); background: var(--border); padding: 1px 6px; border-radius: 4px; margin-left: 4px; }
.wish-reflect-sep { width: 100%; border: none; border-top: 1px dashed var(--border); margin: 6px 0 4px; }
.wish-reflect-menu { display: flex; gap: 6px; flex-wrap: wrap; }
.wish-reflect-btn { font-size: 11px; color: #9B8EC4; padding: 3px 8px; border-radius: 5px; border: 1px solid rgba(155,142,196,.3); cursor: pointer; background: none; }
.wish-reflect-btn:hover { color: #7B6EB0; border-color: #9B8EC4; }
#wish-dialog-extra { margin-top: 8px; }
#wish-dialog-extra select { width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); font-size: 13px; margin-top: 4px; }
#wish-dialog-extra label { font-size: 12px; color: var(--text3); }
.wish-desc { font-size: 13px; color: var(--text2); line-height: 1.6; margin-top: 6px; }
.wish-artifact { font-size: 12px; color: var(--accent); margin-top: 6px; font-style: italic; }
.wish-actions { margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--border); }
.wish-action-item { display: flex; gap: 10px; padding: 6px 0; font-size: 13px; }
.wish-action-date { font-family: var(--mono); font-size: 11px; color: var(--text3); width: 60px; flex-shrink: 0; padding-top: 2px; }
.wish-action-note { color: var(--text2); line-height: 1.5; }
.wish-touch-btn {
  margin-top: 8px; width: 100%; padding: 8px; border-radius: 8px;
  border: 1px dashed var(--border); font-size: 13px; color: var(--text3);
  cursor: pointer; background: none;
}
.wish-touch-btn:hover { border-color: var(--accent); color: var(--accent); }
.wish-menu { display: flex; gap: 6px; margin-top: 8px; }
.wish-menu-btn { font-size: 12px; color: var(--text3); padding: 4px 10px; border-radius: 6px; border: 1px solid var(--border); cursor: pointer; background: none; }
.wish-menu-btn:hover { color: var(--accent); border-color: var(--accent); }
.wish-trail-summary {
  display: flex; align-items: center; gap: 8px;
  margin-top: 8px; font-size: 12px; color: var(--text3);
  cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.wish-trail-steps { font-family: var(--mono); }
.wish-trail-state {
  color: var(--accent); background: rgba(218,119,86,.08);
  padding: 1px 6px; border-radius: 4px; font-size: 11px;
}
.wish-trail-arrow {
  margin-left: auto; color: var(--text3);
  font-size: 11px; transition: transform .2s;
}
.wish-card.trail-open .wish-trail-arrow { transform: rotate(90deg); }
.wish-card.trail-open .wish-trail-full { display: block; }
.wish-trail-full {
  display: none; margin-top: 8px; padding-top: 8px;
  border-top: 1px solid var(--border);
  max-height: 300px; overflow-y: auto;
}
.wish-trail-entry {
  position: relative; padding: 6px 0 6px 18px; font-size: 13px;
}
.wish-trail-entry::before {
  content: ''; position: absolute; left: 3px; top: 13px;
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent); opacity: .5;
}
.wish-trail-entry::after {
  content: ''; position: absolute; left: 5px; top: 19px; bottom: -6px;
  width: 2px; background: var(--border);
}
.wish-trail-entry:last-child::after { display: none; }
.wish-trail-entry-date { font-family: var(--mono); font-size: 11px; color: var(--text3); }
.wish-trail-entry-note { color: var(--text2); line-height: 1.5; margin-top: 2px; }

/* ─── WISH TABS ─── */
.wish-tabs {
  display: flex; gap: 0; flex: none;
  border-bottom: 1px solid var(--border);
  padding: 0 14px;
}
.wish-tab {
  flex: 1; padding: 10px 0; font-size: 14px; font-weight: 500;
  color: var(--text3); text-align: center; cursor: pointer;
  border-bottom: 2px solid transparent; transition: color .15s, border-color .15s;
}
.wish-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.wish-panel { display: none; flex: 1; flex-direction: column; overflow: hidden; }
.wish-panel.active { display: flex; }

/* ─── EVIDENCE CARDS (MIRROR) ─── */
.mirror-entry { margin-bottom: 18px; }
.mirror-date {
  font-family: var(--mono); font-size: 11px; color: var(--text3);
  margin-bottom: 8px; padding: 0 2px;
}
.mirror-reflection {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 14px 16px; margin-bottom: 10px;
  font-size: 14px; line-height: 1.8; color: var(--text);
  font-family: var(--serif); font-style: italic;
}
.evidence-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 10px 14px; margin-bottom: 6px;
  display: flex; align-items: flex-start; gap: 10px;
}
.evidence-type {
  font-size: 10px; font-weight: 700; letter-spacing: .05em;
  padding: 2px 8px; border-radius: 6px; flex-shrink: 0; margin-top: 2px;
}
.evidence-type.印证 { background: rgba(139,159,122,.15); color: #8B9F7A; }
.evidence-type.对不上 { background: rgba(218,119,86,.12); color: var(--accent); }
.evidence-type.萌芽 { background: rgba(212,168,75,.12); color: #D4A84B; }
.evidence-type.沉睡 { background: rgba(155,142,196,.12); color: #9B8EC4; }
.evidence-type.毕业 { background: rgba(123,160,201,.15); color: #7BA0C9; }
.evidence-body { flex: 1; min-width: 0; }
.evidence-desire { font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 2px; }
.evidence-text { font-size: 12px; color: var(--text2); line-height: 1.5; }

/* ─── rings (年轮) ─── */
.ring-card {
  display: flex; gap: 14px; padding: 16px 0;
  border-bottom: 1px solid var(--border); align-items: flex-start;
}
.ring-card:last-child { border-bottom: none; }
.ring-icon {
  width: 40px; height: 40px; flex-shrink: 0; position: relative;
}
.ring-icon svg { width: 100%; height: 100%; }
.ring-body { flex: 1; min-width: 0; }
.ring-title { font-size: 14px; font-weight: 600; color: var(--text); margin-bottom: 4px; }
.ring-stats { font-size: 11px; color: var(--text3); display: flex; gap: 12px; }
.ring-date { font-size: 11px; color: var(--text3); font-family: var(--mono); margin-top: 4px; }

/* ─── desire tree (欲望树) ─── */
#desire-tree-wrap { overflow-x: auto; padding: 8px 0 0; -webkit-overflow-scrolling: touch; }
#desire-tree-wrap svg { display: block; margin: 0 auto; width: 100%; height: auto; }

/* ─── TOUCH/ADD DIALOG ─── */
#wish-dialog-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.35); z-index: 500;
  backdrop-filter: blur(2px);
  justify-content: center; align-items: center;
}
#wish-dialog-overlay.show { display: flex; }
#wish-dialog {
  background: var(--bg); border-radius: 16px;
  width: 88%; max-width: 340px; padding: 22px 20px 18px;
  box-shadow: 0 8px 32px rgba(0,0,0,.2);
}
#wish-dialog-title { font-size: 16px; font-weight: 600; margin-bottom: 14px; }
#wish-dialog-input {
  width: 100%; border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 12px; font-size: 14px; background: var(--surface);
  color: var(--text); resize: none; min-height: 60px;
}
#wish-dialog-input:focus { outline: none; border-color: var(--accent); }
.wish-dialog-btns { display: flex; justify-content: flex-end; gap: 10px; margin-top: 14px; }
.wish-dialog-btn { padding: 8px 18px; border-radius: 10px; font-size: 14px; font-weight: 500; }
.wish-dialog-btn.cancel { color: var(--text2); }
.wish-dialog-btn.confirm { background: var(--accent); color: #fff; }

/* ─── DIARY CARDS ─── */
.diary-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 14px 16px; margin-bottom: 10px;
  cursor: pointer; transition: border-color .12s;
}
.diary-card:hover { border-color: var(--accent); }
.diary-date { display:flex; align-items:center; justify-content:space-between; font-size: 11px; color: var(--text3); margin-bottom: 6px; font-family: var(--mono); }
.diary-preview { font-size: 14px; color: var(--text2); line-height: 1.6; }
.diary-body { display: none; font-size: 14px; line-height: 1.9; white-space: pre-wrap; margin-top: 10px; color: var(--text); }
.diary-card.expanded .diary-preview { display: none; }
.diary-card.expanded .diary-body { display: block; }

/* ─── LETTER SAVED CARDS ─── */
.lscard {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 14px 16px; margin-bottom: 10px;
  cursor: pointer; transition: border-color .12s;
}
.lscard:hover { border-color: var(--accent); }
.lscard-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.lscard-head-right { display: flex; align-items: center; gap: 6px; }
.lscard-from { font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; }
.lscard-from.ai { color: var(--accent); }
.lscard-from.usr { color: var(--text2); }
.lscard-date { font-size: 11px; color: var(--text3); font-family: var(--mono); margin-left: auto; }
.lscard-title { font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.lscard-preview { font-size: 13px; color: var(--text2); line-height: 1.6; }
.lscard-body { display: none; font-size: 14px; line-height: 1.9; white-space: pre-wrap; margin-top: 10px; color: var(--text); }
.lscard.expanded .lscard-preview { display: none; }
.lscard.expanded .lscard-body { display: block; }

/* ─── 月份折叠 ─── */
.month-group { margin-bottom: 2px; }
.month-group-header {
  display: flex; align-items: center; gap: 6px;
  padding: 10px 14px; cursor: pointer;
  font-size: 13px; font-weight: 600; color: var(--text2);
  border-radius: 10px;
  transition: background .15s;
}
.month-group-header:hover { background: var(--hover); }
.month-group-header::before { content: '▶'; font-size: 9px; transition: transform .2s; color: var(--text3); }
.month-group.expanded .month-group-header::before { transform: rotate(90deg); }
.month-group-count { font-size: 12px; color: var(--text3); font-weight: 400; margin-left: 2px; }
.month-group-body { display: none; }
.month-group.expanded .month-group-body { display: block; }

/* ─── 子页面工具栏 ─── */
.sub-toolbar {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 14px 6px; flex: none;
  border-bottom: 1px solid var(--border);
}
.sort-btn {
  font: inherit; font-size: 12px; color: var(--text2);
  padding: 4px 10px; border-radius: 16px;
  border: 1px solid var(--border); background: var(--surface);
  cursor: pointer; white-space: nowrap; flex: none;
}
.search-wrap { flex: 1; position: relative; display: flex; align-items: center; }
.search-inp {
  flex: 1; font: inherit; font-size: 13px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; padding: 4px 28px 4px 12px; color: var(--text);
}
.search-clr {
  position: absolute; right: 8px;
  font-size: 15px; color: var(--text3); cursor: pointer;
  background: none; border: none; line-height: 1;
}
.sub-count {
  flex: none; font-size: 12px; color: var(--text3); white-space: nowrap;
}

/* ─── 瞬间 ─── */
/* ─── 朋友圈瞬间 ─── */
.moments-banner {
  width: 100%;
}
.moments-banner > img {
  width: 100%; height: 220px; object-fit: cover; object-position: center 35%; display: block;
}
.moments-sig {
  text-align: right; padding: 8px 14px 10px;
}
.moments-sig-names {
  font-size: 15px; font-weight: 600;
}
.moments-sig-line {
  font-size: 12px; color: var(--text3); margin-top: 2px; font-style: italic;
}
.moment-card {
  display: flex; gap: 10px; padding: 14px;
  border-bottom: 1px solid var(--border); overflow: hidden;
}
.moment-avatar {
  width: 40px; height: 40px; border-radius: 6px; flex-shrink: 0;
  background: url('/avatar-xiaodu.jpg') center/cover no-repeat;
}
.moment-avatar.usr {
  background: url('/avatar-zhijian.jpg') center/cover no-repeat;
}
.moment-body { flex: 1; min-width: 0; overflow: hidden; }
.moment-head {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px;
}
.moment-author { font-size: 15px; font-weight: 600; }
.moment-author.ai { color: #5B9BD5; }
.moment-author.usr { color: #E5D0A4; }
.moment-text {
  font-size: 14px; line-height: 1.8; white-space: pre-wrap;
  word-break: break-word; color: var(--text);
}
.moment-text.clamped {
  display: -webkit-box; -webkit-line-clamp: 6;
  -webkit-box-orient: vertical; overflow: hidden;
}
.moment-expand {
  color: var(--text3); font-size: 13px; cursor: pointer; margin-top: 2px; text-align: right;
}
.moment-meaning {
  padding: 4px 0 4px 10px;
  margin: 8px 0; font-size: 13px; color: var(--text2); line-height: 1.6;
  font-style: italic;
}
.moment-meaning.ai { border-left: 3px solid #5B9BD5; }
.moment-meaning.usr { border-left: 3px solid #E5D0A4; }
.moment-meta {
  display: flex; align-items: center; justify-content: space-between; margin-top: 8px;
}
.moment-time { font-size: 12px; color: var(--text3); }
.moment-acts { display: flex; align-items: center; gap: 6px; }
.moment-acts button, .moment-acts .like-static {
  background: none; border: none; font-size: 14px;
  color: var(--text3); cursor: pointer; padding: 2px 4px;
}
.moment-acts button:hover { color: var(--accent); }
.moment-acts .liked { color: #e05a5a; }
.moment-acts .like-static { cursor: default; color: #5B9BD5; }
.moment-interact {
  background: var(--hover); border-radius: 4px; margin-top: 8px;
  font-size: 13px; overflow: hidden;
}
.moment-interact .moment-likes {
  padding: 5px 10px; display: flex; align-items: center; gap: 4px;
  font-size: 12px; color: var(--text2);
}
.moment-likes .like-name-ai { color: #5B9BD5; }
.moment-likes .like-name-usr { color: #E5D0A4; }
}
.moment-interact .moment-likes + .moment-comments-list { border-top: 1px solid var(--border); }
.moment-comments-list .comment-item {
  padding: 4px 10px; line-height: 1.6;
}
.moment-comments-list .comment-author {
  font-weight: 600; display: inline; font-size: 13px;
}
.moment-comments-list .comment-author.ai { color: #5B9BD5; }
.moment-comments-list .comment-author.usr { color: #E5D0A4; }
}
.moment-comments-list .comment-text {
  display: inline; font-size: 13px; color: var(--text);
}
.moment-interact .comment-input-row {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 10px; border-top: 1px solid var(--border);
}
.moment-interact .comment-text-inp {
  flex: 1; min-width: 0; font: inherit; font-size: 16px; background: var(--bg);
  border: 1px solid var(--border); border-radius: 4px;
  padding: 5px 8px; color: var(--text); outline: none; box-sizing: border-box;
}
.moment-interact .comment-send-btn {
  font: inherit; font-size: 13px; background: var(--accent);
  color: #fff; border: none; border-radius: 4px; padding: 5px 12px; cursor: pointer;
}

/* ─── LONG-PRESS MESSAGE MENU ─── */
#msg-menu {
  position: fixed; inset: 0; z-index: 250;
  opacity: 0; pointer-events: none;
  transition: opacity .22s ease;
}
#msg-menu.open { opacity: 1; pointer-events: auto; }

#msg-menu-scrim {
  position: absolute; inset: 0;
  background: rgba(0,0,0,.25);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}

#msg-menu .menu-clone {
  position: fixed !important; margin: 0 !important; animation: none !important;
  pointer-events: none; box-sizing: border-box;
  z-index: 2;
  transform: scale(1); transition: transform .22s ease;
}
#msg-menu.open .menu-clone { transform: scale(1.03); }

#msg-menu-actions {
  position: fixed; z-index: 3;
  display: flex; flex-direction: column;
  min-width: 140px; padding: 5px;
  border-radius: 14px;
  background: var(--bg); border: 1px solid var(--border);
  box-shadow: 0 8px 32px rgba(0,0,0,.18);
  opacity: 0; transform: translateY(6px);
  transition: opacity .18s ease .04s, transform .22s ease .04s;
}
#msg-menu.open #msg-menu-actions { opacity: 1; transform: none; }

.msg-menu-act {
  appearance: none; border: 0; background: transparent;
  color: var(--text); font: inherit; font-size: 15px;
  display: flex; align-items: center; gap: 10px;
  padding: 11px 14px; border-radius: 10px;
  transition: background .12s;
  -webkit-tap-highlight-color: transparent;
}
.msg-menu-act:active { background: var(--hover); transform: scale(.98); }
.msg-menu-act svg { width: 18px; height: 18px; opacity: .7; flex: 0 0 auto; }

.bubble.menu-highlight { opacity: .35; }

/* ── 引用跳转高亮 ── */
.bubble-quote { cursor: pointer; }
.bubble-quote:active { opacity: .6; }
.msg-row.highlight-jump .bubble {
  animation: jump-flash 1.5s ease;
}
.hist-pair.highlight-jump {
  animation: jump-flash 1.5s ease;
}
@keyframes jump-flash {
  0%,100% { box-shadow: none; }
  20% { box-shadow: 0 0 0 2px var(--accent); }
  60% { box-shadow: 0 0 0 1px var(--accent); }
}

/* ── 搜索高亮 ── */
mark {
  background: rgba(255,200,60,.35);
  color: inherit;
  border-radius: 2px;
  padding: 0 1px;
}
@media (prefers-color-scheme: dark) {
  mark { background: rgba(255,180,40,.25); }
}

/* ── 小纸条 ── */
.note-bar {
  display: flex; align-items: center; gap: 6px;
  margin-top: 6px; width: 100%; flex-basis: 100%;
}
.note-bar input {
  flex: 1; border: 1px solid var(--border); border-radius: 8px;
  padding: 6px 10px; font-size: 13px;
  background: var(--bg); color: var(--text);
  outline: none;
}
.note-bar input:focus { border-color: var(--accent); }
.note-bar button {
  appearance: none; border: none; background: transparent;
  color: var(--accent); font-size: 16px; cursor: pointer;
  padding: 4px 8px; border-radius: 6px;
}
.note-bar button:active { opacity: .6; }

/* ── 记忆抽屉 ── */
.mem-drawer-overlay {
  position: fixed; inset: 0; z-index: 400;
  background: rgba(0,0,0,.35);
  opacity: 0; pointer-events: none;
  transition: opacity .25s ease;
}
.mem-drawer-overlay.show { opacity: 1; pointer-events: auto; }
.mem-drawer {
  position: fixed; top: 0; right: -80vw; bottom: 0;
  width: 80vw; max-width: 340px;
  z-index: 401;
  background: var(--bg);
  display: flex; flex-direction: column;
  transition: right .28s cubic-bezier(.4,0,.2,1);
  box-shadow: -4px 0 20px rgba(0,0,0,.1);
}
.mem-drawer.open { right: 0; }
.mem-drawer-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border-bottom: 1px solid var(--border);
  font-size: 15px; font-weight: 600;
}
.mem-drawer-header button {
  appearance: none; border: none; background: transparent;
  color: var(--text2); font-size: 20px; cursor: pointer;
  padding: 2px 6px; border-radius: 6px;
}
.mem-drawer-tabs {
  display: flex; gap: 0; border-bottom: 1px solid var(--border);
  padding: 0 12px;
}
.mem-drawer-tab {
  appearance: none; border: none; background: transparent;
  color: var(--text3); font-size: 13px;
  padding: 10px 14px; cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color .15s, border-color .15s;
}
.mem-drawer-tab.active { color: var(--text); border-bottom-color: var(--accent); }
.mem-drawer-body {
  flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 8px 0;
}
.mem-drawer-item {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
}
.mem-drawer-author {
  font-size: 13px; font-weight: 600; color: var(--text);
  margin-bottom: 3px;
}
.mem-drawer-content {
  font-size: 13px; color: var(--text2); line-height: 1.5;
  word-break: break-word;
}
.mem-drawer-meaning {
  font-size: 12px; color: var(--text3); margin-top: 4px;
  font-style: italic;
}
.mem-drawer-date {
  font-size: 11px; color: var(--text3); margin-top: 4px;
}

/* ── ECG 时间轴 ── */
.ecg-time-axis {
  position: relative; height: 16px;
  margin-left: 36px; margin-right: 30px;
}
.ecg-time-axis span {
  position: absolute; transform: translateX(-50%);
  font-size: 9px; color: var(--text3);
  font-family: var(--mono);
  white-space: nowrap;
}

/* emoji reactions */
#msg-menu-react {
  display: flex; justify-content: center; gap: 2px;
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
}
.react-emoji-btn {
  border: none; background: none; font-size: 22px;
  padding: 4px 6px; cursor: pointer; border-radius: 8px;
  transition: transform .1s, background .1s;
  line-height: 1;
}
.react-emoji-btn:active { transform: scale(1.3); background: var(--border); }
.react-tag {
  display: inline-block; margin-top: 4px;
  font-size: 18px; line-height: 1;
  cursor: pointer; user-select: none;
}
