*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #FFF5F5; --bg-bubble-self: #FF8BA7; --bg-bubble-other: #FFFFFF;
  --bubble-border: #FFD4DE; --text-primary: #332233; --text-on-pink: #FFFFFF;
  --text-secondary: #887777; --accent: #FF6B8A; --accent-light: #FFE0E8;
  --radius: 18px; --radius-sm: 12px; --shadow: 0 2px 12px rgba(255,107,138,0.10);
  --header-height: 52px; --input-height: 56px;
}
html, body { height: 100%; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif; background: var(--bg); color: var(--text-primary); -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; overscroll-behavior: none; }
.view { display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0; flex-direction: column; background: var(--bg); }
.view.active { display: flex; }
.chat-header { height: var(--header-height); display: flex; align-items: center; justify-content: space-between; padding: 0 14px; background: linear-gradient(135deg, #FF8BA7, #FFB3C6); color: white; flex-shrink: 0; box-shadow: 0 2px 8px rgba(255,107,138,0.15); z-index: 10; }
.header-left { display: flex; align-items: center; gap: 10px; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: rgba(255,255,255,0.25); display: flex; align-items: center; justify-content: center; font-size: 20px; }
.header-info { display: flex; flex-direction: column; }
.header-name { font-size: 17px; font-weight: 700; }
.header-status { font-size: 11px; opacity: 0.85; }
.header-right { display: flex; gap: 6px; }
.icon-btn { width: 36px; height: 36px; border: none; border-radius: 50%; background: rgba(255,255,255,0.2); color: white; font-size: 18px; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: background 0.15s; }
.icon-btn:active { background: rgba(255,255,255,0.4); }
.messages { flex: 1; overflow-y: auto; padding: 16px 12px 8px; display: flex; flex-direction: column; gap: 10px; -webkit-overflow-scrolling: touch; }
.welcome { text-align: center; padding: 40px 20px; color: var(--text-secondary); }
.welcome-icon { font-size: 48px; margin-bottom: 10px; }
.welcome p { font-size: 15px; }
.message-row { display: flex; animation: bubbleIn 0.3s ease-out; }
.message-row.user { justify-content: flex-end; }
.message-row.assistant { justify-content: flex-start; }
.message-bubble { max-width: 80%; padding: 10px 14px; border-radius: var(--radius); font-size: 15px; line-height: 1.55; word-break: break-word; box-shadow: var(--shadow); position: relative; }
.message-row.user .message-bubble { background: var(--bg-bubble-self); color: var(--text-on-pink); border-bottom-right-radius: 4px; }
.message-row.assistant .message-bubble { background: var(--bg-bubble-other); color: var(--text-primary); border: 1px solid var(--bubble-border); border-bottom-left-radius: 4px; }
.message-time { font-size: 10px; margin-top: 4px; opacity: 0.5; text-align: right; }
@keyframes bubbleIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.typing-indicator { padding: 0 12px; }
.typing-indicator.hidden { display: none; }
.typing-bubble { display: inline-flex; gap: 4px; padding: 10px 16px; background: var(--bg-bubble-other); border: 1px solid var(--bubble-border); border-radius: var(--radius); border-bottom-left-radius: 4px; }
.typing-dot { width: 7px; height: 7px; border-radius: 50%; background: #FFB3C6; animation: bounce 1.4s infinite both; }
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes bounce { 0%,80%,100% { transform: scale(0.4); } 40% { transform: scale(1); } }
.input-bar { height: var(--input-height); padding: 8px 10px; display: flex; align-items: center; gap: 6px; background: white; border-top: 1px solid var(--bubble-border); flex-shrink: 0; z-index: 10; }
#input { flex: 1; height: 38px; padding: 0 14px; border: 1px solid var(--bubble-border); border-radius: 19px; font-size: 15px; background: var(--accent-light); color: var(--text-primary); outline: none; transition: border-color 0.15s; }
#input:focus { border-color: var(--accent); }
#input::placeholder { color: #C8A0A8; }
.send-btn { width: 40px; height: 40px; border: none; border-radius: 50%; background: var(--accent); color: white; font-size: 18px; cursor: pointer; flex-shrink: 0; transition: transform 0.15s; }
.send-btn:active { transform: scale(1.15); }
.send-btn:disabled { opacity: 0.5; }
.clear-btn, .install-btn { width: 32px; height: 32px; border: none; border-radius: 50%; background: transparent; color: #999; font-size: 14px; cursor: pointer; flex-shrink: 0; }
.install-btn.hidden { display: none; }
.panel-header { height: var(--header-height); display: flex; align-items: center; justify-content: space-between; padding: 0 14px; background: linear-gradient(135deg, #FF8BA7, #FFB3C6); color: white; font-size: 17px; font-weight: 700; flex-shrink: 0; box-shadow: 0 2px 8px rgba(255,107,138,0.15); }
.back-btn { background: none; border: none; color: white; font-size: 16px; cursor: pointer; padding: 4px 8px; border-radius: 8px; }
.back-btn:active { background: rgba(255,255,255,0.2); }
.panel-content { flex: 1; overflow-y: auto; padding: 14px; -webkit-overflow-scrolling: touch; }
.add-memory { display: flex; gap: 6px; margin-bottom: 16px; }
.add-memory select { padding: 8px 10px; border: 1px solid var(--bubble-border); border-radius: var(--radius-sm); font-size: 13px; background: white; color: var(--text-primary); flex-shrink: 0; }
.add-memory input { flex: 1; padding: 8px 12px; border: 1px solid var(--bubble-border); border-radius: var(--radius-sm); font-size: 14px; background: var(--accent-light); outline: none; }
.add-memory button { padding: 8px 14px; border: none; border-radius: var(--radius-sm); background: var(--accent); color: white; font-size: 13px; cursor: pointer; flex-shrink: 0; }
.memory-list { display: flex; flex-direction: column; gap: 8px; }
.memory-card { background: white; border: 1px solid var(--bubble-border); border-radius: var(--radius-sm); padding: 12px; display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.memory-cat { font-size: 11px; padding: 2px 8px; border-radius: 10px; background: var(--accent-light); color: var(--accent); flex-shrink: 0; margin-right: 8px; }
.memory-text { flex: 1; font-size: 14px; line-height: 1.5; }
.memory-del { background: none; border: none; color: #ccc; font-size: 16px; cursor: pointer; flex-shrink: 0; padding: 2px; }
.memory-del:hover { color: #e88; }
.diary-list { display: flex; flex-direction: column; gap: 12px; }
.diary-card { background: white; border: 1px solid var(--bubble-border); border-radius: var(--radius); padding: 16px; cursor: pointer; transition: transform 0.15s, box-shadow 0.15s; box-shadow: var(--shadow); }
.diary-card:active { transform: scale(0.98); }
.diary-card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.diary-card-date { font-size: 14px; font-weight: 600; color: var(--text-primary); }
.diary-card-mood { font-size: 20px; }
.diary-card-preview { font-size: 13px; color: var(--text-secondary); line-height: 1.6; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.diary-card-empty { text-align: center; padding: 40px 20px; color: var(--text-secondary); font-size: 14px; }
.diary-detail { background: white; border: 1px solid var(--bubble-border); border-radius: var(--radius); padding: 20px 16px; margin-top: 8px; }
.diary-detail .diary-mood { font-size: 32px; margin-bottom: 12px; }
.diary-detail .diary-body { font-size: 15px; line-height: 1.8; color: var(--text-primary); white-space: pre-wrap; }
@media (min-width: 500px) { body { display: flex; justify-content: center; background: #F0E0E5; } .view { max-width: 480px; position: relative; box-shadow: 0 4px 24px rgba(0,0,0,0.1); } .view.active { display: flex; } }
.messages::-webkit-scrollbar, .panel-content::-webkit-scrollbar { width: 4px; }
.messages::-webkit-scrollbar-thumb, .panel-content::-webkit-scrollbar-thumb { background: var(--bubble-border); border-radius: 4px; }
