:root {
  --font-ui: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --font-book: "Songti SC", "STSong", "SimSun", serif;
  --radius: 14px;
  --radius-sm: 9px;
}

html, html[data-theme="letter"], html[data-theme="paper"] {
  --bg: #f6f2e8; --bg-2: #eee8da; --bg-3: #e5dccb;
  --line: #d8cebb; --line-2: #bdaf98; --text: #292821;
  --text-2: #716b5e; --text-3: #9d9380; --accent: #628273;
  --accent-deep: #d2dfd4; --on-accent: #f9f6ed; --them: transparent;
  --them-text: #292821; --me: #dfe9df; --me-text: #47594b;
  --warn: #a47724; --cool: #587589; --danger: #a65347;
  --danger-bg: rgba(166, 83, 71, .08); --body-font: var(--font-book);
  --shadow: 0 20px 55px rgba(98, 82, 58, .11);
}

html[data-theme="night"] {
  --bg: #080d1b; --bg-2: #0e1628; --bg-3: #16223a;
  --line: #22304a; --line-2: #3d5274; --text: #edf3ff;
  --text-2: #aab8d0; --text-3: #687995; --accent: #d8b7ff;
  --accent-deep: #392c5a; --on-accent: #161022; --them: #f0e8dc;
  --them-text: #282436; --me: #293d63; --me-text: #e7efff;
  --warn: #eacb8a; --cool: #8ec7e5; --danger: #e6a29b;
  --danger-bg: rgba(230, 162, 155, .1); --body-font: var(--font-ui);
  --shadow: 0 20px 65px rgba(0, 0, 0, .35);
}

html[data-theme="vacation"] {
  --bg: #f8f2df; --bg-2: #fff9e9; --bg-3: #f5e2bd;
  --line: #ddcfaa; --line-2: #bea979; --text: #253d49;
  --text-2: #5f7272; --text-3: #899792; --accent: #e36f52;
  --accent-deep: #cce4df; --on-accent: #fffaf0; --them: #fff8e8;
  --them-text: #29434d; --me: #a9d4cf; --me-text: #214650;
  --warn: #e2a33e; --cool: #4a91a1; --danger: #c96c5c;
  --danger-bg: rgba(201, 108, 92, .1); --body-font: var(--font-ui);
  --shadow: 0 18px 50px rgba(143, 108, 60, .14);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; padding: 0; }
body {
  overflow: hidden; background: var(--bg); color: var(--text); font-family: var(--body-font);
  font-size: 15px; line-height: 1.6; -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%; transition: background .3s ease, color .3s ease;
}
#app { width: 100%; max-width: 680px; height: 100dvh; margin: 0 auto; display: flex; flex-direction: column; position: relative; isolation: isolate; }
#app::before { content: ""; position: fixed; inset: 0; pointer-events: none; opacity: .18; background: radial-gradient(circle at 50% -10%, var(--accent-deep), transparent 42%); z-index: -2; }
.ambient-layer { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.view { flex: 1; min-height: 0; display: flex; flex-direction: column; position: relative; z-index: 1; }
.hidden, .view.hidden, .badge.hidden, .mem-panel.hidden { display: none; }
button { color: inherit; background: none; border: 0; cursor: pointer; font: inherit; -webkit-tap-highlight-color: transparent; }
button:disabled { opacity: .45; cursor: default; }
.theme-toast { position: fixed; z-index: 10; top: 18px; left: 50%; max-width: calc(100vw - 36px); padding: 8px 14px; border: 1px solid var(--line-2); border-radius: 30px; color: var(--text-2); background: color-mix(in srgb, var(--bg-2) 92%, transparent); font-family: var(--font-book); font-size: 12px; letter-spacing: .04em; opacity: 0; pointer-events: none; transform: translate(-50%, -10px); transition: opacity .35s ease, transform .55s cubic-bezier(.22,1,.36,1); }
.theme-toast.visible { opacity: 1; transform: translate(-50%, 0); }

/* Persona setup */
.setup-inner { width: 100%; max-width: 560px; margin: auto; padding: 42px 26px 32px; overflow-y: auto; }
.setup-head { position: relative; margin-bottom: 34px; }
.setup-back { display: inline-flex; align-items: center; gap: 7px; margin: 0 0 22px; padding: 0; color: var(--text-3); font-size: 12px; letter-spacing: .04em; }
.setup-back:hover { color: var(--accent); }
.setup-back span { font-size: 17px; line-height: 1; }
.setup-back.hidden { display: none; }
.setup-head::after { content: ""; display: block; width: 54px; height: 1px; margin-top: 25px; background: var(--accent); opacity: .75; }
.age-tag { display: inline-flex; align-items: center; gap: 7px; margin-bottom: 20px; color: var(--accent); font-size: 11px; letter-spacing: .16em; }
.age-tag::before { content: ""; width: 6px; height: 6px; border: 1px solid currentColor; border-radius: 50%; }
.setup-head h1 { margin: 0 0 13px; font-family: var(--font-book); font-size: clamp(30px, 8vw, 42px); font-weight: 500; letter-spacing: .04em; line-height: 1.2; }
.note { margin: 0; color: var(--text-2); font-size: 14px; line-height: 1.9; letter-spacing: .03em; }
.note .faint { color: var(--text-3); font-size: 12px; }
.setup-form { display: block; }
.field { display: block; margin-bottom: 21px; }
.field-label { display: flex; align-items: center; gap: 9px; margin-bottom: 8px; color: var(--text-2); font-size: 12px; letter-spacing: .13em; }
.field-label::before { content: ""; width: 3px; height: 3px; border-radius: 50%; background: var(--accent); }
input[type="text"], textarea {
  display: block; width: 100%; padding: 13px 15px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  color: var(--text); background: rgba(255,255,255,.018); font: inherit; font-size: 15px; line-height: 1.65;
  resize: none; outline: 0; transition: border-color .2s, background .2s, box-shadow .2s; -webkit-appearance: none;
}
input[type="text"]::placeholder, textarea::placeholder { color: var(--text-3); }
input[type="text"]:hover, textarea:hover { border-color: var(--line-2); }
input[type="text"]:focus, textarea:focus { border-color: var(--accent); background: var(--bg-2); box-shadow: 0 0 0 3px rgba(157, 189, 167, .09); }
.row { display: flex; gap: 10px; }
.setup-actions { margin-top: 29px; }
.primary { flex: 1; padding: 14px 20px; border-radius: var(--radius-sm); background: var(--accent); color: var(--on-accent); font-size: 15px; font-weight: 600; letter-spacing: .08em; transition: filter .2s, transform .1s, box-shadow .2s; box-shadow: 0 8px 22px rgba(99, 135, 111, .14); }
.primary:hover { filter: brightness(1.08); box-shadow: 0 10px 28px rgba(99, 135, 111, .2); }
.primary:active, .send:active { transform: translateY(1px); }
.setup-sub { justify-content: space-between; margin-top: 13px; }
.ghost { min-height: 44px; padding: 7px 10px; border-radius: 7px; color: var(--text-2); font-size: 13px; transition: background .18s, color .18s; }
.ghost:hover { background: var(--bg-3); color: var(--text); }
.ghost.danger-text { color: var(--danger); opacity: .78; }
.ghost.danger-text:hover { background: var(--danger-bg); opacity: 1; }
.ghost.small { padding: 5px 8px; font-size: 12px; }

/* Chat header and memory */
.chat-header { flex: 0 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 17px 18px 14px; border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--bg) 92%, transparent); }
.chat-who { min-width: 0; display: flex; align-items: center; gap: 9px; }
.chat-who strong { overflow: hidden; color: var(--text); font-family: var(--font-book); font-size: 19px; font-weight: 600; letter-spacing: .05em; text-overflow: ellipsis; white-space: nowrap; }
.chat-who::before { content: ""; width: 8px; height: 8px; flex: 0 0 auto; border: 1px solid var(--accent); border-radius: 50%; box-shadow: 0 0 0 3px rgba(157,189,167,.12); }
.badge { padding: 2px 7px; border-radius: 20px; color: var(--warn); background: rgba(197,166,100,.12); font-size: 10px; letter-spacing: .07em; }
.chat-tools { display: flex; align-items: center; gap: 1px; flex: 0 0 auto; }
.count { display: inline-block; min-width: 16px; margin-left: 4px; padding: 0 4px; border-radius: 20px; color: var(--accent); background: var(--accent-deep); font-size: 10px; line-height: 16px; text-align: center; }
.theme-btn { width: 44px; height: 44px; min-width: 44px; min-height: 44px; padding: 0; border-radius: 50%; }
.theme-dot { display: block; width: 12px; height: 12px; margin: auto; border: 1px solid var(--bg); border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 2px var(--accent-deep); }
.mem-panel { flex: 0 0 auto; max-height: 48vh; overflow-y: auto; padding: 17px 18px 18px; border-bottom: 1px solid var(--line); background: var(--bg-2); animation: panel-in .24s ease; }
@keyframes panel-in { from { opacity: 0; transform: translateY(-7px); } to { opacity: 1; transform: none; } }
.mem-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 3px; color: var(--text); font-family: var(--font-book); font-size: 16px; }
.mem-note { margin: 0 0 14px; color: var(--text-3); font-size: 12px; }
.mem-list { display: flex; flex-direction: column; gap: 7px; }
.mem-item { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); color: var(--text-2); background: var(--bg-3); font-size: 13.5px; line-height: 1.65; word-break: break-word; }
.mem-discuss { display: inline-flex; align-items: center; justify-content: center; min-width: 44px; min-height: 44px; flex: 0 0 auto; padding: 3px 5px; color: var(--accent); font-size: 11px; white-space: nowrap; }
.mem-discuss:hover { text-decoration: underline; }
.mem-item.summary { display: block; padding: 0 0 13px; margin-bottom: 5px; border: 0; border-bottom: 1px dashed var(--line-2); border-radius: 0; color: var(--text-2); background: transparent; font-size: 13px; }
.mem-item.empty { justify-content: center; padding: 15px 0; border: 0; color: var(--text-3); background: transparent; font-size: 13px; }
.mem-del { width: 44px; height: 44px; min-width: 44px; min-height: 44px; flex: 0 0 auto; border-radius: 50%; color: var(--text-3); line-height: 44px; text-align: center; transition: background .16s, color .16s; }
.mem-del:hover { color: var(--danger); background: var(--danger-bg); }

/* Conversation */
.messages { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 25px 18px 13px; display: flex; flex-direction: column; gap: 10px; }
.empty { max-width: 280px; margin: auto; padding: 0 20px; color: var(--text-3); font-family: var(--font-book); font-size: 15px; line-height: 2; text-align: center; letter-spacing: .04em; }
.empty::before { content: "·"; display: block; margin-bottom: 7px; color: var(--accent); font-family: var(--font-ui); font-size: 28px; line-height: 1; }
.msg { max-width: 78%; padding: 11px 15px; border-radius: var(--radius); font-size: 15px; line-height: 1.75; letter-spacing: .01em; word-break: break-word; white-space: pre-wrap; animation: bubble-in .28s cubic-bezier(.22,1,.36,1); transition: background .25s, color .25s; }
@keyframes bubble-in { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }
.msg.assistant { align-self: flex-start; margin-right: auto; color: var(--them-text); background: var(--them); border-bottom-left-radius: 4px; box-shadow: var(--shadow); }
.msg.user { align-self: flex-end; margin-left: auto; color: var(--me-text); background: var(--me); border-bottom-right-radius: 4px; }
.msg.pending, .msg.retrying, .msg.fallback { align-self: flex-start; max-width: 92%; margin-right: auto; padding: 6px 3px; color: var(--text-3); background: transparent; border-radius: 0; font-size: 13px; letter-spacing: .04em; }
.msg.pending { animation: breathe 2.6s ease-in-out infinite; }
@keyframes breathe { 0%,100% { opacity: .38; } 50% { opacity: .95; } }
.msg.retrying { color: var(--warn); opacity: .86; }
.msg.fallback { color: var(--cool); opacity: .88; }
.msg.error { align-self: center; max-width: 92%; margin: 5px auto; padding: 7px 13px; color: var(--danger); background: var(--danger-bg); border-radius: var(--radius-sm); font-size: 13px; text-align: center; animation: none; }
html[data-theme="letter"] .msg.assistant, html[data-theme="letter"] .msg.user, html[data-theme="paper"] .msg.assistant, html[data-theme="paper"] .msg.user { max-width: 100%; padding: 12px 0 13px; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; box-shadow: none; background: transparent; }
html[data-theme="letter"] .msg.assistant, html[data-theme="paper"] .msg.assistant { padding-right: 22%; color: var(--them-text); }
html[data-theme="letter"] .msg.user, html[data-theme="paper"] .msg.user { padding-left: 22%; color: var(--me-text); text-align: right; }
html[data-theme="letter"] .msg.assistant::before, html[data-theme="letter"] .msg.user::before { content: ""; display: block; width: 28px; height: 1px; margin-bottom: 6px; background: var(--accent); opacity: .65; }
html[data-theme="letter"] .msg.user::before { margin-left: auto; opacity: .35; }
html[data-theme="letter"] .chat-form input[type="text"] { border: 0; border-bottom: 1px solid var(--line-2); border-radius: 0; background: transparent; }
html[data-theme="letter"] .chat-form input[type="text"]:focus { border-bottom-color: var(--accent); box-shadow: 0 4px 0 -3px var(--accent); }

/* Composer */
.chat-form { flex: 0 0 auto; display: flex; align-items: center; gap: 9px; padding: 12px 18px calc(12px + env(safe-area-inset-bottom, 0px)); border-top: 1px solid var(--line); background: var(--bg); }
.chat-form input[type="text"] { flex: 1; min-width: 0; padding: 11px 16px; border-radius: 22px; background: var(--bg-2); }
.send { flex: 0 0 auto; padding: 11px 18px; border-radius: 22px; background: var(--accent); color: var(--on-accent); font-size: 14px; font-weight: 600; letter-spacing: .06em; transition: filter .18s, transform .1s; }
.send:hover { filter: brightness(1.08); }

@media (max-width: 380px) {
  .setup-inner { padding: 32px 18px 28px; }
  .chat-header { padding-left: 13px; padding-right: 11px; }
  .chat-tools .ghost { padding: 7px 6px; font-size: 12px; }
  .messages { padding-left: 13px; padding-right: 13px; }
  .msg { max-width: 84%; }
  .chat-form { padding-left: 12px; padding-right: 12px; }
  .send { padding-left: 15px; padding-right: 15px; }
}
@media (min-width: 681px) { #app { border-left: 1px solid var(--line); border-right: 1px solid var(--line); box-shadow: var(--shadow); } }
.messages::-webkit-scrollbar, .mem-panel::-webkit-scrollbar, .setup-inner::-webkit-scrollbar { width: 5px; }
.messages::-webkit-scrollbar-thumb, .mem-panel::-webkit-scrollbar-thumb, .setup-inner::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 3px; }
.messages::-webkit-scrollbar-track, .mem-panel::-webkit-scrollbar-track, .setup-inner::-webkit-scrollbar-track { background: transparent; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; } }

/* Home */
.home-header { display: flex; align-items: flex-start; justify-content: space-between; padding: 32px 22px 12px; }
.home-header-actions { display: flex; align-items: center; gap: 8px; }
.eyebrow { color: var(--text-3); font-size: 10px; letter-spacing: .14em; }
.home-header h1 { margin: 10px 0 0; font-family: var(--font-book); font-size: 25px; font-weight: 500; letter-spacing: .04em; }
.profile-mark { width: 35px; height: 35px; border: 1px solid var(--line-2); border-radius: 50%; color: var(--accent); font-family: var(--font-book); font-size: 15px; }
.home-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 14px 22px 28px; }
.welcome-line { margin: 12px 0 24px; }
.welcome-line p { margin: 0 0 3px; color: var(--text); font-family: var(--font-book); font-size: 21px; }
.welcome-line span { color: var(--text-3); font-size: 12px; }
.active-person { position: relative; padding: 21px 20px 19px; border: 1px solid var(--line-2); border-radius: var(--radius); background: linear-gradient(135deg, var(--bg-2), rgba(157,189,167,.06)); box-shadow: var(--shadow); overflow: hidden; }
.active-person::after { content: ""; position: absolute; width: 150px; height: 150px; right: -65px; top: -80px; border: 1px solid var(--accent-deep); border-radius: 50%; opacity: .65; }
.active-topline { position: relative; z-index: 1; display: flex; align-items: center; gap: 7px; color: var(--accent); font-size: 11px; letter-spacing: .08em; }
.live-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px rgba(157,189,167,.1); }
.last-seen { margin-left: auto; color: var(--text-3); font-size: 10px; letter-spacing: 0; }
.active-person h2 { position: relative; z-index: 1; margin: 24px 0 7px; font-family: var(--font-book); font-size: 32px; font-weight: 500; letter-spacing: .04em; }
.active-person p { position: relative; z-index: 1; min-height: 48px; max-width: 85%; margin: 0; color: var(--text-2); font-family: var(--font-book); font-size: 15px; line-height: 1.8; }
.active-footer { position: relative; z-index: 1; display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 19px; padding-top: 14px; border-top: 1px solid var(--line); }
.active-footer > span { color: var(--text-3); font-size: 11px; }
.home-primary { min-height: 44px; padding: 8px 0 8px 12px; color: var(--accent); font-size: 13px; letter-spacing: .04em; white-space: nowrap; }
.home-primary span { margin-left: 4px; font-size: 17px; }
.section-heading { display: flex; align-items: center; justify-content: space-between; margin: 27px 1px 12px; color: var(--text-2); font-size: 12px; letter-spacing: .1em; }
.section-count { color: var(--text-3); font-size: 10px; letter-spacing: 0; }
.active-person-state { display: none; }
.persona-cards-container { position: relative; margin: 24px 0 28px; }
.persona-cards { display: flex; gap: 14px; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; padding: 0 22px; margin: 0 -22px; }
.persona-cards::-webkit-scrollbar { display: none; }
.persona-card { position: relative; display: flex; flex: 0 0 min(78vw, 420px); aspect-ratio: 3 / 4; flex-direction: column; padding: 32px 24px; border: 1px solid var(--line-2); border-radius: 2px; color: var(--text); background: linear-gradient(135deg, var(--bg-2), rgba(157,189,167,.03)); scroll-snap-align: center; scroll-snap-stop: always; cursor: pointer; opacity: .72; box-shadow: 0 12px 32px rgba(98,82,58,.08); transition: opacity .3s ease, transform .3s ease, border-color .3s ease, box-shadow .3s ease; }
.persona-card::before { content: ""; position: absolute; inset: 0; border: 1px solid rgba(255,255,255,.08); border-radius: 2px; pointer-events: none; }
.persona-card::after { content: ""; position: absolute; inset: 1px; border-radius: 2px; box-shadow: inset 0 1px 2px rgba(255,255,255,.12), inset 0 -1px 2px rgba(0,0,0,.04); pointer-events: none; }
.persona-card.selected { opacity: 1; transform: translateY(-2px); border-color: var(--accent); box-shadow: 0 16px 48px rgba(98,82,58,.18); }
.persona-card:hover:not(.selected) { opacity: .88; }
.card-top-label { margin-bottom: 28px; color: var(--text-3); font-size: 11px; letter-spacing: .3em; }
.card-name { margin-bottom: 20px; color: var(--text); font-family: var(--font-book); font-size: clamp(28px,5.5vw,34px); font-weight: 500; line-height: 1.1; }
.card-quote { flex: 1; margin-bottom: 24px; overflow: hidden; color: var(--text-2); font-family: var(--font-book); font-size: 15px; line-height: 1.8; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.card-bottom-info { display: flex; flex-direction: column; gap: 6px; padding-top: 12px; border-top: 1px solid var(--line); color: var(--text-3); font-size: 11px; }
.card-time { font-size: 10px; }
.card-delete { position: absolute; top: 9px; right: 9px; z-index: 2; display: flex; align-items: center; justify-content: center; width: 44px; height: 44px; min-width: 44px; min-height: 44px; border-radius: 50%; color: var(--text-3); font-size: 20px; opacity: .55; }
.card-delete:hover { color: var(--danger); background: var(--danger-bg); opacity: 1; }
.add-card { align-items: center; justify-content: center; border-style: dashed; color: var(--text-2); background: transparent; opacity: .76; }
.add-card-mark { margin-bottom: 16px; color: var(--accent); font-size: 44px; font-weight: 300; line-height: 1; }
.add-card-text { color: var(--text-2); font-family: var(--font-book); font-size: 18px; }
.add-card small { margin-top: 7px; color: var(--text-3); font-size: 11px; }
.persona-detail-modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; opacity: 0; pointer-events: none; transition: opacity .3s ease; }
.persona-detail-modal.visible { opacity: 1; pointer-events: auto; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(8, 13, 27, .58); backdrop-filter: blur(3px); }
.modal-content { position: relative; z-index: 1; width: min(calc(100vw - 32px), 480px); max-height: 78vh; overflow-y: auto; padding: 32px 28px 28px; border: 1px solid var(--line-2); border-radius: 8px; background: var(--bg); box-shadow: 0 24px 70px rgba(0,0,0,.24); transform: translateY(12px) scale(.98); transition: transform .35s cubic-bezier(.22,1,.36,1); }
.persona-detail-modal.visible .modal-content { transform: none; }
.modal-close { position: absolute; top: 12px; right: 12px; display: flex; align-items: center; justify-content: center; width: 44px; height: 44px; border-radius: 50%; color: var(--text-3); font-size: 24px; }
.modal-close:hover { color: var(--text); background: var(--bg-2); }
.modal-name { margin-bottom: 24px; color: var(--text); font-family: var(--font-book); font-size: 30px; }
.modal-relation { display: flex; gap: 12px; margin-bottom: 20px; padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.modal-relation .label, .modal-section .label { color: var(--text-3); font-size: 11px; letter-spacing: .1em; }
.modal-relation span:last-child { color: var(--accent); font-family: var(--font-book); }
.modal-section { margin-bottom: 18px; padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.modal-section .label { display: block; margin-bottom: 7px; }
.modal-section span:last-child { display: block; color: var(--text-2); font-size: 14px; line-height: 1.75; }
.modal-actions { display: flex; gap: 10px; margin-top: 24px; }
.modal-primary, .modal-secondary, .modal-danger { min-height: 44px; flex: 1; padding: 10px 12px; border-radius: 6px; font-size: 14px; letter-spacing: .05em; }
.modal-primary { color: var(--on-accent); background: var(--accent); }
.modal-secondary { border: 1px solid var(--line); color: var(--text-2); background: var(--bg-2); }
.modal-danger { color: var(--danger); background: var(--danger-bg); }
.memory-heading { margin-top: 29px; }
.memory-heading button { padding: 0; color: var(--accent); font-size: 11px; }
.home-memory { display: flex; align-items: flex-start; gap: 11px; padding: 14px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.memory-open { display: flex; align-items: flex-start; flex: 1; min-width: 0; gap: 11px; padding: 0; color: inherit; text-align: left; }
.memory-open:hover .memory-copy strong { color: var(--accent); }
.memory-pin { display: flex; align-items: center; justify-content: center; width: 25px; height: 25px; flex: 0 0 auto; border: 1px solid var(--line-2); border-radius: 50%; color: var(--accent); font-size: 11px; }
.memory-copy { display: flex; min-width: 0; flex-direction: column; gap: 3px; }
.memory-copy strong { color: var(--text-2); font-family: var(--font-book); font-size: 14px; font-weight: 500; line-height: 1.65; transition: color .18s; }
.memory-copy small { color: var(--text-3); font-size: 10px; }
.memory-open.memory-empty .memory-copy strong { color: var(--text-3); }
.memory-date { color: var(--text-3); font-size: 10px; white-space: nowrap; }
.memory-delete { width: 44px; height: 44px; min-width: 44px; min-height: 44px; flex: 0 0 auto; border-radius: 50%; color: var(--text-3); font-size: 16px; opacity: .45; transition: color .18s, background .18s, opacity .18s; }
.home-memory:hover .memory-delete { opacity: 1; }
.memory-delete:hover { color: var(--danger); background: var(--danger-bg); }
.bottom-nav { flex: 0 0 auto; display: flex; justify-content: space-around; padding: 10px 18px calc(10px + env(safe-area-inset-bottom, 0px)); border-top: 1px solid var(--line); background: var(--bg); }
.nav-item { display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 62px; padding: 3px 9px; color: var(--text-3); font-size: 11px; }
.nav-item span { height: 18px; color: currentColor; font-size: 17px; line-height: 18px; }
.nav-icon { display: inline-flex; align-items: center; justify-content: center; }
.nav-icon svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.35; }
.nav-item.active { color: var(--accent); }
html[data-theme="letter"] #app::before, html[data-theme="paper"] #app::before { opacity: .3; background: repeating-linear-gradient(0deg, transparent 0, transparent 31px, rgba(120, 105, 78, .07) 32px), radial-gradient(circle at 50% -10%, var(--accent-deep), transparent 44%); }
html[data-theme="letter"] .active-person, html[data-theme="paper"] .active-person { background: var(--bg-2); box-shadow: 0 18px 45px rgba(91, 79, 60, .1); }
html[data-theme="letter"] .active-person::before { content: "✉  private letter"; position: absolute; right: 20px; bottom: 17px; color: var(--text-3); font-family: var(--font-book); font-size: 10px; letter-spacing: .08em; opacity: .65; }
html[data-theme="letter"] .persona-card, html[data-theme="paper"] .persona-card { background: var(--bg-2); box-shadow: 0 10px 28px rgba(91,79,60,.1); }
html[data-theme="letter"] .persona-card.selected, html[data-theme="paper"] .persona-card.selected { box-shadow: 0 14px 40px rgba(91,79,60,.18); }
html[data-theme="letter"] .home-memory { border-style: dashed; }
html[data-theme="night"] #app::before { opacity: .4; background: radial-gradient(circle at 78% 12%, rgba(238, 220, 255, .9) 0 1px, transparent 2px), radial-gradient(circle at 23% 22%, rgba(211, 229, 255, .8) 0 1px, transparent 2px), radial-gradient(circle at 68% 39%, rgba(255, 255, 255, .7) 0 1px, transparent 2px), radial-gradient(circle at 12% 67%, rgba(216, 183, 255, .8) 0 1px, transparent 2px), radial-gradient(circle at 90% 72%, rgba(255, 255, 255, .75) 0 1px, transparent 2px), radial-gradient(ellipse at 50% -20%, #2b3965, transparent 55%); }
html[data-theme="night"] .active-person { background: linear-gradient(135deg, var(--bg-2), rgba(216,183,255,.1)); }
html[data-theme="night"] .active-person::after { border-color: rgba(216,183,255,.25); }
html[data-theme="vacation"] #app::before { opacity: .6; background: radial-gradient(circle at 83% 12%, rgba(255, 204, 91, .7) 0 18px, transparent 19px), radial-gradient(circle at 12% 82%, rgba(87, 181, 191, .34), transparent 30%), repeating-linear-gradient(170deg, transparent 0 25px, rgba(82, 160, 175, .09) 26px 27px), linear-gradient(145deg, rgba(174, 222, 226, .38), transparent 55%); }
html[data-theme="vacation"] .active-person { background: linear-gradient(160deg, #e9f7f2, #bfe2e3 58%, #a6d0d8); border-color: #8dbfc5; }
html[data-theme="vacation"] .active-person::after { border-color: rgba(227,111,82,.22); }
html[data-theme="vacation"] .active-person::before { content: "☼  sea day"; position: absolute; right: 20px; bottom: 17px; color: #4d8d98; font-size: 10px; letter-spacing: .08em; opacity: .8; }
html[data-theme="vacation"] .memory-pin { border-color: #78b7bf; color: #318391; }
html[data-theme="night"] .persona-card { background: linear-gradient(135deg, var(--bg-2), rgba(216,183,255,.08)); box-shadow: 0 12px 32px rgba(0,0,0,.25); }
html[data-theme="night"] .persona-card.selected { box-shadow: 0 16px 48px rgba(216,183,255,.2); }
html[data-theme="vacation"] .persona-card { background: linear-gradient(160deg, #e9f7f2, #bfe2e3 58%, #a6d0d8); border-color: #8dbfc5; box-shadow: 0 12px 32px rgba(143,108,60,.08); }
html[data-theme="vacation"] .persona-card.selected { border-color: #5babb6; box-shadow: 0 16px 48px rgba(143,108,60,.15); }
.theme-feedback .active-person { animation: theme-arrival .52s ease; }
.theme-feedback .theme-dot { animation: theme-pulse .52s ease; }
.memory-discussion-feedback .chat-form { animation: discussion-arrival .52s ease; }
html[data-theme="letter"].theme-feedback .active-person { animation-name: letter-arrival; }
html[data-theme="night"].theme-feedback .active-person { animation-name: night-arrival; }
html[data-theme="vacation"].theme-feedback .active-person { animation-name: ocean-arrival; }
@keyframes theme-arrival { 0% { transform: scale(.99); } 45% { transform: scale(1.015); } 100% { transform: none; } }
@keyframes letter-arrival { 0% { transform: perspective(500px) rotateX(-1deg); opacity: .7; } 45% { transform: perspective(500px) rotateX(0); opacity: 1; } 100% { transform: none; } }
@keyframes night-arrival { 0% { box-shadow: 0 0 0 rgba(216,183,255,0); } 45% { box-shadow: 0 0 28px rgba(216,183,255,.35); } 100% { box-shadow: var(--shadow); } }
@keyframes ocean-arrival { 0% { transform: translateY(2px); background-position: 0 0; } 45% { transform: translateY(-2px); background-position: 12px 5px; } 100% { transform: none; } }
@keyframes theme-pulse { 0%,100% { box-shadow: 0 0 0 2px var(--accent-deep); } 45% { box-shadow: 0 0 0 7px var(--accent-deep), 0 0 22px var(--accent); } }
@keyframes discussion-arrival { 0% { border-color: var(--accent); box-shadow: 0 0 0 0 var(--accent-deep); } 50% { border-color: var(--accent); box-shadow: 0 0 0 5px var(--accent-deep); } 100% { box-shadow: none; } }

/* Ambient theme layers stay behind content so they can never cover readable text. */
.star-field, .ocean-field { position: absolute; inset: 0; opacity: 0; transition: opacity 1.4s ease; }
.star { position: absolute; display: block; width: 3px; height: 3px; border-radius: 50%; background: #fff3d1; box-shadow: 0 0 9px 2px rgba(255, 243, 209, .42); animation: star-blink 4.8s ease-in-out infinite; }
.star-1 { top: 14%; left: 18%; animation-delay: -1.2s; }.star-2 { top: 24%; left: 76%; width: 2px; height: 2px; animation-delay: -3.5s; }.star-3 { top: 39%; left: 88%; animation-delay: -2.1s; }.star-4 { top: 62%; left: 13%; width: 2px; height: 2px; animation-delay: -4s; }.star-5 { top: 72%; left: 67%; animation-delay: -1.8s; }.star-6 { top: 9%; left: 52%; width: 2px; height: 2px; animation-delay: -.4s; }
.meteor { position: absolute; top: 20%; left: 72%; width: 90px; height: 1px; opacity: 0; background: linear-gradient(90deg, transparent, rgba(255,241,199,.9)); transform: rotate(135deg); transform-origin: right center; animation: meteor-fall 18s linear infinite; animation-delay: 4s; }
.moon { position: absolute; top: 30px; right: max(22px, calc(50% - 306px)); width: 46px; height: 46px; border-radius: 50%; opacity: 0; background: #fff1c7; box-shadow: 0 0 18px rgba(255,241,199,.35), 0 0 42px rgba(216,183,255,.16); animation: moon-breathe 16s ease-in-out infinite; }
.moon-phase { position: absolute; inset: 0; border-radius: 50%; background: var(--bg); transform: translateX(0); animation: moon-phase 52s ease-in-out infinite; }
.wave { position: absolute; left: -10%; width: 120%; height: 80px; border-top: 1px solid rgba(255,255,255,.28); border-radius: 50%; transform: rotate(-3deg); animation: wave-drift 12s ease-in-out infinite; }
.wave-1 { bottom: 13%; }.wave-2 { bottom: 18%; opacity: .5; animation-delay: -5s; }
.wave-3 { bottom: 24%; opacity: .32; animation-delay: -8s; }
.bubble { position: absolute; bottom: 11%; width: 8px; height: 8px; border: 1px solid rgba(255,255,255,.5); border-radius: 50%; animation: bubble-rise 10s ease-in infinite; }.bubble-1 { left: 17%; animation-delay: -2s; }.bubble-2 { left: 79%; width: 5px; height: 5px; animation-delay: -7s; }.bubble-3 { left: 58%; width: 4px; height: 4px; animation-delay: -5s; }
.seagull { position: absolute; top: 16%; left: -8%; width: 24px; height: 9px; opacity: 0; animation: seagull-fly 13s linear infinite; }
.seagull::before, .seagull::after { content: ""; position: absolute; top: 0; width: 50%; height: 100%; border-top: 1.4px solid rgba(255,255,255,.85); border-radius: 50%; }
.seagull::before { left: 0; transform-origin: right center; animation: gull-flap-l .7s ease-in-out infinite; }
.seagull::after { right: 0; transform-origin: left center; animation: gull-flap-r .7s ease-in-out infinite; }
.seagull-1 { top: 15%; animation-duration: 12s; animation-delay: -3s; }
.seagull-1::before, .seagull-1::after { animation-delay: -.2s; }
.seagull-2 { top: 26%; width: 17px; height: 7px; animation-duration: 16s; animation-delay: -8s; }
.seagull-2::before, .seagull-2::after { animation-duration: .6s; animation-delay: -.5s; }
.seagull-3 { top: 10%; width: 20px; height: 8px; animation-duration: 10s; animation-delay: -6s; }
.seagull-3::before, .seagull-3::after { animation-duration: .8s; }
html[data-theme="night"] .star-field, html[data-theme="night"] .moon { opacity: 1; }
html[data-theme="vacation"] .ocean-field { opacity: .62; }
html[data-theme="vacation"] .wave { border-top-color: rgba(74, 145, 161, .55); }
html[data-theme="vacation"] .bubble { border-color: rgba(74, 145, 161, .55); }
html[data-theme="vacation"] .seagull::before, html[data-theme="vacation"] .seagull::after { border-top-color: rgba(37, 61, 73, .7); }
@keyframes star-blink { 0%,100% { opacity: .24; transform: scale(.75); } 48% { opacity: .92; transform: scale(1); } 55% { opacity: .42; } }
@keyframes meteor-fall { 0%, 78% { opacity: 0; transform: translate(0,0) rotate(135deg); } 80% { opacity: .9; } 88% { opacity: 0; transform: translate(-170px,170px) rotate(135deg); } 100% { opacity: 0; } }
@keyframes moon-breathe { 0%,100% { transform: translateY(0); } 50% { transform: translateY(3px); } }
@keyframes moon-phase { 0%,100% { transform: translateX(18px); } 45% { transform: translateX(-4px); } 70% { transform: translateX(10px); } }
@keyframes wave-drift { 0%,100% { transform: translateX(-2%) rotate(-3deg); } 50% { transform: translateX(4%) rotate(-1deg); } }
@keyframes bubble-rise { 0% { opacity: 0; transform: translateY(20px) scale(.6); } 30% { opacity: .65; } 100% { opacity: 0; transform: translateY(-180px) scale(1.1); } }
@keyframes seagull-fly { 0% { left: -8%; opacity: 0; transform: translateY(0); } 8% { opacity: .9; } 30% { transform: translateY(-6px); } 60% { transform: translateY(3px); } 92% { opacity: .9; } 100% { left: 108%; opacity: 0; transform: translateY(-2px); } }
@keyframes gull-flap-l { 0%,100% { transform: rotate(18deg); } 50% { transform: rotate(52deg); } }
@keyframes gull-flap-r { 0%,100% { transform: rotate(-18deg) scaleX(-1); } 50% { transform: rotate(-52deg) scaleX(-1); } }
html[data-theme="vacation"] .primary, html[data-theme="vacation"] .send { box-shadow: 0 8px 20px rgba(227,111,82,.18); }
@media (max-width: 380px) {
  .home-header { padding-left: 17px; padding-right: 17px; }
  .home-scroll { padding-left: 17px; padding-right: 17px; }
  .active-person h2 { font-size: 29px; }
  .active-person p { max-width: 100%; }
  .active-footer { align-items: flex-end; }
  .active-footer > span { max-width: 112px; line-height: 1.4; }
  .tile-delete { opacity: .7; }
  .persona-cards { padding: 0 17px; margin: 0 -17px; }
  .persona-card { flex-basis: min(82vw, 310px); padding: 28px 20px; }
  .card-name { font-size: 27px; }
  .card-quote { font-size: 14px; }
  .modal-content { width: calc(100vw - 24px); padding: 28px 20px 24px; }
}

/* ============================================================
   陪伴首页 · 人物卡堆（pl-* 前缀，与既有样式隔离）
   ============================================================ */

.home-head-text { min-width: 0; flex: 1; }

.home-head-text .eyebrow b {
  color: var(--accent);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.pl-stage {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 0 2px;
}

.pl-deck {
  --pl-w: min(70vw, 286px);
  position: relative;
  width: var(--pl-w);
  aspect-ratio: 3 / 4;
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
  -webkit-user-drag: none;
}

.pl-card {
  position: absolute;
  inset: 0;
  transition: transform .34s cubic-bezier(.22, 1, .36, 1), filter .34s ease, opacity .34s ease;
  will-change: transform, filter;
}

/* 深度：每往下一张下沉 8px、缩 5.5%、糊 4px */
.pl-card[data-level="0"] { transform: none; filter: none; opacity: 1; }
.pl-card[data-level="1"] { transform: translateY(9px) scale(.945); filter: blur(4px); opacity: .6; pointer-events: none; }
.pl-card[data-level="2"] { transform: translateY(17px) scale(.895); filter: blur(9px); opacity: .38; pointer-events: none; }
.pl-card[data-level="99"] { transform: translateY(24px) scale(.86); filter: blur(12px); opacity: .16; pointer-events: none; }

.pl-face {
  position: relative;
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: 24px 22px 18px;
  border: 1px solid var(--line-2);
  border-radius: 16px;
  background: linear-gradient(158deg, var(--bg-2) 0%, var(--bg-3) 100%);
  box-shadow: 0 22px 44px -22px rgba(0, 0, 0, .5), inset 0 1px 0 rgba(255, 255, 255, .05);
  overflow: hidden;
  cursor: grab;
}

.pl-face:active { cursor: grabbing; }

/* 右上角一道极淡的弧线，全卡唯一的装饰 */
.pl-face::after {
  content: "";
  position: absolute;
  width: 200px;
  height: 200px;
  right: -78px;
  top: -92px;
  border: 1px solid var(--line-2);
  border-radius: 50%;
  opacity: .55;
  pointer-events: none;
}

.pl-rel {
  position: relative;
  margin: 0 0 15px;
  font-size: 10.5px;
  letter-spacing: .3em;
  color: var(--text-3);
}

.pl-name {
  position: relative;
  margin: 0 0 13px;
  font-family: var(--font-book);
  font-size: 29px;
  font-weight: 500;
  letter-spacing: .05em;
  line-height: 1.2;
  color: var(--text);
  word-break: break-word;
}

.pl-quote {
  position: relative;
  flex: 1;
  margin: 0;
  font-family: var(--font-book);
  font-size: 14px;
  line-height: 1.9;
  color: var(--text-2);
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}

.pl-meta {
  position: relative;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  font-size: 11px;
  letter-spacing: .05em;
  color: var(--text-3);
}

.pl-empty {
  text-align: center;
  color: var(--text-3);
}
.pl-empty p {
  margin: 0;
  font-family: var(--font-book);
  font-size: 19px;
  color: var(--text-2);
}
.pl-empty span {
  display: block;
  margin-top: 8px;
  font-size: 12.5px;
}
.pl-empty.hidden { display: none; }

.pl-actions {
  flex: 0 0 auto;
  display: flex;
  gap: 10px;
  padding: 8px 22px 4px;
}

.pl-btn {
  padding: 13px 15px;
  border-radius: 13px;
  font-size: 14px;
  letter-spacing: .05em;
  transition: filter .18s, background .18s, transform .1s;
}
.pl-btn:active { transform: scale(.985); }

.pl-btn.primary {
  flex: 2;
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 500;
}
.pl-btn.primary:hover { filter: brightness(1.07); }

.pl-btn.ghost {
  flex: 1;
  background: var(--bg-2);
  color: var(--text-2);
  border: 1px solid var(--line);
  white-space: nowrap;
}
.pl-btn.ghost:hover { background: var(--bg-3); color: var(--text); }

/* 记忆条目的文案（沿用既有 .home-memory / .memory-open 结构） */
.memory-open p {
  flex: 1;
  min-width: 0;
  margin: 0;
  font-family: var(--font-book);
  font-size: 13.5px;
  line-height: 1.65;
  color: var(--text-2);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.pl-anchors { display: none; }

@media (max-width: 380px) {
  .pl-actions { padding: 8px 16px 4px; }
  .home-header { padding: 18px 16px 8px; }
  .pl-deck { --pl-w: min(74vw, 268px); }
  .pl-name { font-size: 26px; }
}

/* ---- 人物详情浮层 ---- */

.pd-modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.pd-modal.hidden { display: none; }

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, .55);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}

.pd-sheet {
  position: relative;
  width: 100%;
  max-width: 660px;
  max-height: 82vh;
  overflow-y: auto;
  padding: 28px 24px calc(22px + env(safe-area-inset-bottom, 0px));
  border-radius: 22px 22px 0 0;
  background: var(--bg-2);
  border-top: 1px solid var(--line-2);
  box-shadow: 0 -20px 50px -30px rgba(0, 0, 0, .6);
  animation: sheet-up .34s cubic-bezier(.22, 1, .36, 1);
}

@keyframes sheet-up {
  from { transform: translateY(32px); opacity: 0; }
  to { transform: none; opacity: 1; }
}

.pd-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  color: var(--text-3);
  font-size: 20px;
  line-height: 1;
  transition: background .18s, color .18s;
}
.pd-close:hover { background: var(--bg-3); color: var(--text); }

.pd-name {
  margin: 0 0 18px;
  font-family: var(--font-book);
  font-size: 26px;
  font-weight: 500;
  letter-spacing: .05em;
  color: var(--text);
}

.pd-label {
  margin: 16px 0 5px;
  font-size: 10.5px;
  letter-spacing: .24em;
  color: var(--text-3);
}

.pd-text {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.8;
  color: var(--text-2);
  word-break: break-word;
}

.pd-memories { margin-top: 8px; }

.pd-actions {
  display: flex;
  gap: 10px;
  margin-top: 26px;
}

/* ============================================================
   材质变量（配色已与原型 v2 对齐，这里补质感层）
   ============================================================ */

html, html[data-theme="letter"], html[data-theme="paper"] {
  --orb-a: rgba(98, 130, 115, .26);
  --orb-b: rgba(212, 178, 116, .24);
  --grain: rgba(122, 101, 68, .022);
  --face-a: #fcf8ee;
  --face-b: #f1e9d8;
  --face-sheen: rgba(255, 255, 255, .78);
  --face-edge: rgba(255, 255, 255, .85);
  --face-shadow: 0 20px 44px -26px rgba(84, 68, 44, .42), 0 3px 8px -4px rgba(84, 68, 44, .16);
  --primary-shadow: 0 12px 26px -16px rgba(64, 84, 72, .7);
}

html[data-theme="night"] {
  --orb-a: rgba(216, 183, 255, .22);
  --orb-b: rgba(142, 199, 229, .14);
  --grain: rgba(255, 255, 255, .012);
  --face-a: #16213a;
  --face-b: #0a1424;
  --face-sheen: rgba(228, 206, 255, .1);
  --face-edge: rgba(255, 255, 255, .07);
  --face-shadow: 0 22px 50px -26px rgba(0, 0, 0, .85), 0 0 0 1px rgba(255, 255, 255, .02);
  --primary-shadow: 0 12px 30px -16px rgba(216, 183, 255, .45);
}

html[data-theme="vacation"] {
  --orb-a: rgba(74, 145, 161, .24);
  --orb-b: rgba(255, 204, 91, .34);
  --grain: rgba(160, 130, 80, .022);
  --face-a: #fffbf1;
  --face-b: #f7e9cf;
  --face-sheen: rgba(255, 255, 255, .82);
  --face-edge: rgba(255, 255, 255, .9);
  --face-shadow: 0 20px 44px -26px rgba(143, 108, 60, .34), 0 3px 8px -4px rgba(143, 108, 60, .16);
  --primary-shadow: 0 12px 26px -16px rgba(227, 111, 82, .55);
}

/* 卡面：一层柔光 + 一层渐变 + 一道细边 */
.pl-face {
  background:
    radial-gradient(115% 70% at 18% -8%, var(--face-sheen) 0%, transparent 58%),
    linear-gradient(158deg, var(--face-a) 0%, var(--face-b) 100%);
  box-shadow: var(--face-shadow);
  border: 1px solid var(--line-2);
}

.pl-btn.primary { box-shadow: var(--primary-shadow); }

/* 首页头部右侧的按钮组（主题 + 我的） */
.home-head-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

/* 对话示例字段 */
.field-label .opt {
  margin-left: 6px;
  font-size: 10.5px;
  letter-spacing: .04em;
  color: var(--accent);
  opacity: .8;
}

.field-tip {
  display: block;
  margin-top: 6px;
  font-size: 11.5px;
  line-height: 1.6;
  color: var(--text-3);
}

.field-example textarea {
  font-family: var(--font-book);
  line-height: 1.8;
}

/* ============================================================
   2026-12-01 预览定稿合入（只调色/调质感，不删原有装饰和动效）
   选择器按正式项目：html[data-theme]、#app、#chat-view。
   编号对应预览 tune.css / DESIGN-NOTES（T1–T27）。
   ============================================================ */

/* [T1] 信纸：正文副色/弱字压深；墨绿按钮压深；投影收薄 */
html, html[data-theme="letter"], html[data-theme="paper"] {
  --text-2: #4f4a40;
  --text-3: #6f6656;
  --accent: #4c6b5c;
  --shadow: 0 14px 38px rgba(98, 82, 58, .08);
  --face-shadow: 0 16px 36px -26px rgba(84, 68, 44, .30), 0 2px 6px -4px rgba(84, 68, 44, .12);
  --primary-shadow: 0 10px 22px -16px rgba(64, 84, 72, .45);
}

/* [T2] 夜晚：禁紫，按钮/强调改灯金，光晕改月银；弱字提高对比 */
html[data-theme="night"] {
  --text-3: #8492ab;
  --accent: #d8b878;
  --accent-deep: #2a3550;
  --on-accent: #17130b;
  --them: #ece6da;
  --shadow: 0 16px 48px rgba(0, 0, 0, .28);
  --orb-a: rgba(200, 210, 224, .16);
  --face-sheen: rgba(214, 222, 236, .07);
  --face-shadow: 0 18px 42px -26px rgba(0, 0, 0, .7), 0 0 0 1px rgba(255, 255, 255, .02);
  --primary-shadow: 0 10px 24px -16px rgba(216, 184, 120, .32);
}

/* [T3] 度假：珊瑚保留但降饱和压深；正文副色压深；投影收薄 */
html[data-theme="vacation"] {
  --text-2: #3a4e50;
  --text-3: #5c6d6a;
  --accent: #b2543d;
  --me: #b8d6d1;
  --shadow: 0 14px 38px rgba(143, 108, 60, .10);
  --face-shadow: 0 16px 36px -26px rgba(143, 108, 60, .26), 0 2px 6px -4px rgba(143, 108, 60, .12);
  --primary-shadow: 0 10px 22px -16px rgba(178, 84, 61, .38);
}

/* [T4] 夜晚背景星点：第 4 颗紫 → 月银；蓝晕略收。整体 .4 不变 */
html[data-theme="night"] #app::before {
  background:
    radial-gradient(circle at 78% 12%, rgba(232, 236, 244, .85) 0 1px, transparent 2px),
    radial-gradient(circle at 23% 22%, rgba(211, 229, 255, .8) 0 1px, transparent 2px),
    radial-gradient(circle at 68% 39%, rgba(255, 255, 255, .7) 0 1px, transparent 2px),
    radial-gradient(circle at 12% 67%, rgba(214, 222, 236, .75) 0 1px, transparent 2px),
    radial-gradient(circle at 90% 72%, rgba(255, 255, 255, .75) 0 1px, transparent 2px),
    radial-gradient(ellipse at 50% -20%, #26345a, transparent 55%);
}

/* [T5][T6][T7] 星星光晕收小；流星拖尾降亮；月亮去紫、收光。动画时长/延迟不变 */
.star { box-shadow: 0 0 6px 1px rgba(255, 243, 209, .26); }
.meteor { background: linear-gradient(90deg, transparent, rgba(255, 241, 199, .7)); }
.moon {
  background: #f3ead2;
  box-shadow: 0 0 14px rgba(255, 241, 199, .24), 0 0 34px rgba(200, 210, 224, .10);
}

/* 旧首页卡 / 旧横滑卡上残留的紫，一并改月银（元素若已不用也不留紫） */
html[data-theme="night"] .active-person { background: linear-gradient(135deg, var(--bg-2), rgba(200, 210, 224, .1)); }
html[data-theme="night"] .active-person::after { border-color: rgba(200, 210, 224, .25); }
html[data-theme="night"] .persona-card { background: linear-gradient(135deg, var(--bg-2), rgba(200, 210, 224, .08)); }
html[data-theme="night"] .persona-card.selected { box-shadow: 0 16px 48px rgba(200, 210, 224, .18); }

/* [T8] 主题到达：夜晚光晕改月银，.52s 不变；目标改到现用的顶卡（原 .active-person 已不在首页） */
@keyframes night-arrival {
  0% { box-shadow: 0 0 0 rgba(200, 210, 224, 0); }
  45% { box-shadow: 0 0 28px rgba(200, 210, 224, .28); }
  100% { box-shadow: var(--face-shadow); }
}
html.theme-feedback .pl-card[data-level="0"] .pl-face { animation: theme-arrival .52s ease; }
html[data-theme="letter"].theme-feedback .pl-card[data-level="0"] .pl-face { animation-name: letter-arrival; }
html[data-theme="night"].theme-feedback .pl-card[data-level="0"] .pl-face { animation-name: night-arrival; }
html[data-theme="vacation"].theme-feedback .pl-card[data-level="0"] .pl-face { animation-name: ocean-arrival; }

/* [T9] 主题点脉冲外发光 22px → 14px（.52s 不变） */
@keyframes theme-pulse {
  0%, 100% { box-shadow: 0 0 0 2px var(--accent-deep); }
  45% { box-shadow: 0 0 0 7px var(--accent-deep), 0 0 14px var(--accent); }
}

/* [T16–T20] 度假海元素：按预览最后一版加强可见度，不回到糖果色。
   数量和节奏保持原版（3 层浪含 wave-3、3 个泡泡、3 只海鸥）。 */
html[data-theme="vacation"] .ocean-field { opacity: .92; }
html[data-theme="vacation"] .wave { border-top: 2px solid rgba(46, 108, 122, .82); }
html[data-theme="vacation"] .wave-1 { opacity: 1; }
html[data-theme="vacation"] .wave-2 { opacity: .7; border-top: 2px solid rgba(46, 108, 122, .7); }
html[data-theme="vacation"] .wave-3 { opacity: .52; border-top: 2px solid rgba(46, 108, 122, .55); }
html[data-theme="vacation"] .bubble {
  border-width: 1.4px;
  border-color: rgba(46, 108, 122, .82);
}
html[data-theme="vacation"] .seagull::before,
html[data-theme="vacation"] .seagull::after {
  border-top-width: 1.85px;
  border-top-color: rgba(31, 52, 62, .85);
}
html[data-theme="vacation"] #app::before {
  opacity: .72;
  background:
    radial-gradient(circle at 83% 12%, rgba(240, 198, 120, .55) 0 18px, transparent 19px),
    radial-gradient(ellipse 90% 55% at 50% 100%, rgba(154, 196, 200, .48) 0 36%, rgba(185, 214, 216, .22) 62%, transparent 78%),
    radial-gradient(circle at 12% 82%, rgba(74, 145, 161, .40), transparent 34%),
    repeating-linear-gradient(170deg, transparent 0 25px, rgba(70, 130, 142, .08) 26px 27px),
    linear-gradient(180deg, transparent 52%, rgba(201, 226, 224, .22) 70%, rgba(166, 200, 204, .36) 100%);
}
html[data-theme="vacation"] .ocean-field::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 25%;
  height: 1px;
  background: linear-gradient(90deg, transparent 4%, rgba(46, 108, 122, .38) 18%, rgba(46, 108, 122, .5) 50%, rgba(46, 108, 122, .38) 82%, transparent 96%);
  pointer-events: none;
}

/* [T12] 度假珊瑚按钮阴影收轻 */
html[data-theme="vacation"] .primary,
html[data-theme="vacation"] .send { box-shadow: 0 6px 16px rgba(178, 84, 61, .14); }

/* [T13] 英文小标签：原挂在已不存在的 .active-person 上，现挂到顶卡右下。原文案不变 */
html[data-theme="letter"] .pl-face::before {
  content: "✉  private letter";
  position: absolute;
  right: 22px;
  bottom: 50px;
  color: var(--text-3);
  font-family: var(--font-book);
  font-size: 10px;
  letter-spacing: .12em;
  opacity: .75;
  pointer-events: none;
}
html[data-theme="vacation"] .pl-face::before {
  content: "☼  sea day";
  position: absolute;
  right: 22px;
  bottom: 50px;
  color: #3f7680;
  font-size: 10px;
  letter-spacing: .12em;
  opacity: .85;
  pointer-events: none;
}
.pl-card:not([data-level="0"]) .pl-face::before { opacity: 0; }

/* [T14][T15] 主按钮发光和弹层投影：保留，调软调薄 */
.primary { box-shadow: 0 6px 16px rgba(76, 107, 92, .10); }
.primary:hover { box-shadow: 0 8px 20px rgba(76, 107, 92, .14); }
html[data-theme="night"] .primary { box-shadow: 0 6px 16px rgba(216, 184, 120, .12); }
.pd-sheet { box-shadow: 0 -20px 50px -30px rgba(0, 0, 0, .4); }

/* [R1] 卡堆层级：原 CSS 未写 z-index，后排卡按 DOM 顺序会盖住顶卡 */
.pl-card[data-level="0"] { z-index: 3; }
.pl-card[data-level="1"] { z-index: 2; }
.pl-card[data-level="2"] { z-index: 1; }
.pl-card[data-level="99"] { z-index: 0; }

/* [R2] 信纸「记」条：dashed 左右边会画出竖虚线，左右宽度收为 0 */
html[data-theme="letter"] .home-memory { border-left-width: 0; border-right-width: 0; }

/* [T21] 信纸底：32px 横格加强，并加很淡的大间距纸纹（避免密点阵） */
html[data-theme="letter"] #app::before,
html[data-theme="paper"] #app::before {
  opacity: .45;
  background:
    radial-gradient(ellipse 80% 50% at 18% 12%, rgba(255, 252, 244, .55), transparent 62%),
    radial-gradient(ellipse 60% 40% at 82% 78%, rgba(120, 101, 68, .04), transparent 70%),
    radial-gradient(circle at 1px 1px, rgba(98, 82, 58, .05) 0.55px, transparent 0.85px),
    radial-gradient(circle at 1px 1px, rgba(98, 82, 58, .035) 0.45px, transparent 0.75px),
    repeating-linear-gradient(0deg, transparent 0, transparent 31px, rgba(120, 105, 78, .13) 32px),
    radial-gradient(circle at 50% -10%, var(--accent-deep), transparent 44%);
  background-size: auto, auto, 17px 21px, 29px 25px, auto, auto;
  background-position: 0 0, 0 0, 0 0, 8px 11px, 0 0, 0 0;
}

/* [T22] 左侧淡朱红装订线；内容左内边距收到 28px 以躲开这条线 */
html[data-theme="letter"] #app::after {
  content: "";
  position: absolute;
  inset: 0 auto 0 18px;
  width: 1px;
  background: rgba(140, 62, 50, .32);
  box-shadow: -3px 0 0 rgba(140, 62, 50, .12);
  pointer-events: none;
  z-index: 2;
}
html[data-theme="letter"] .home-header,
html[data-theme="letter"] .pl-actions,
html[data-theme="letter"] .bottom-nav,
html[data-theme="letter"] .chat-header,
html[data-theme="letter"] .messages,
html[data-theme="letter"] .chat-form,
html[data-theme="letter"] .mem-panel,
html[data-theme="letter"] .setup-inner { padding-left: 28px; }
html[data-theme="letter"] .home-memory { padding-left: 28px; padding-right: 14px; }

/* [T23] 克制邮戳：线稿、单色朱红、低对比。顶卡随 data-level=0 翻动；聊天页在输入框上方右侧 */
html[data-theme="letter"] .pl-card[data-level="0"]::after {
  content: "";
  position: absolute;
  top: 14px;
  right: 14px;
  width: 34px;
  height: 42px;
  border: 1px dashed rgba(140, 62, 50, .34);
  border-radius: 1px;
  box-shadow: inset 0 0 0 3px rgba(140, 62, 50, .14);
  pointer-events: none;
  z-index: 2;
}
html[data-theme="letter"] .pl-card[data-level="0"]::before {
  content: "";
  position: absolute;
  top: 28px;
  right: 6px;
  width: 38px;
  height: 38px;
  border: 1px solid rgba(140, 62, 50, .32);
  border-radius: 50%;
  box-shadow: inset 0 0 0 3px rgba(140, 62, 50, .18);
  background:
    linear-gradient(18deg, transparent 46%, rgba(140, 62, 50, .3) 46% 48.5%, transparent 48.5%) 0 12px / 100% 8px no-repeat,
    linear-gradient(18deg, transparent 46%, rgba(140, 62, 50, .3) 46% 48.5%, transparent 48.5%) 0 16px / 100% 8px no-repeat,
    linear-gradient(18deg, transparent 46%, rgba(140, 62, 50, .3) 46% 48.5%, transparent 48.5%) 0 20px / 100% 8px no-repeat;
  transform: rotate(14deg);
  pointer-events: none;
  z-index: 3;
}
html[data-theme="letter"] #chat-view::after {
  content: "";
  position: absolute;
  right: 20px;
  bottom: 86px;
  width: 52px;
  height: 52px;
  border: 1px solid rgba(140, 62, 50, .22);
  border-radius: 50%;
  box-shadow: inset 0 0 0 4px rgba(140, 62, 50, .12);
  background:
    linear-gradient(16deg, transparent 46%, rgba(140, 62, 50, .22) 46% 48.5%, transparent 48.5%) 0 18px / 100% 9px no-repeat,
    linear-gradient(16deg, transparent 46%, rgba(140, 62, 50, .22) 46% 48.5%, transparent 48.5%) 0 22px / 100% 9px no-repeat,
    linear-gradient(16deg, transparent 46%, rgba(140, 62, 50, .22) 46% 48.5%, transparent 48.5%) 0 26px / 100% 9px no-repeat;
  transform: rotate(12deg);
  pointer-events: none;
  z-index: 0;
  opacity: .85;
}

/* [T24][T27] 聊天页：只留一套淡横格；拿掉短墨线、消息分隔线、折痕。
   行高 32px 让字坐在格上。输入框底线保持原版。装订线和邮戳见上。 */
html[data-theme="letter"] .messages {
  background-color: var(--bg);
  background-image: repeating-linear-gradient(0deg, transparent 0, transparent 31px, rgba(120, 105, 78, .09) 32px);
  background-attachment: local;
  padding-top: 32px;
  gap: 0;
}
html[data-theme="letter"] .msg.assistant,
html[data-theme="letter"] .msg.user {
  font-family: var(--font-book);
  letter-spacing: .04em;
  line-height: 32px;
  padding-top: 0;
  padding-bottom: 32px;
  border: 0;
  border-bottom: 0;
  box-shadow: none;
}
html[data-theme="letter"] .msg.assistant::before,
html[data-theme="letter"] .msg.user::before {
  content: none;
  display: none;
  margin: 0;
}
html[data-theme="letter"] .msg.pending,
html[data-theme="letter"] .msg.retrying,
html[data-theme="letter"] .msg.fallback {
  line-height: 32px;
  padding-top: 0;
  padding-bottom: 0;
}

/* [T25] 首页标题和卡上的话更像手写信；卡内引言极淡横格。墨绿行动色保持 #4c6b5c */
html[data-theme="letter"] .home-header h1 {
  letter-spacing: .08em;
  line-height: 1.35;
}
html[data-theme="letter"] .pl-name { letter-spacing: .08em; }
html[data-theme="letter"] .pl-quote {
  letter-spacing: .04em;
  line-height: 28px;
  background-image: repeating-linear-gradient(transparent 0 27px, rgba(120, 105, 78, .12) 28px);
}
