* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; font-family: var(--font-family, -apple-system, "PingFang SC", sans-serif); overflow: hidden; transition: background 0.3s ease; }

:root { --bg-color: #0d1117; --nav-bg: rgba(22, 27, 34, 0.9); --text-color: #c9d1d9; --bubble-ai-bg: #161b22; --bubble-ai-text: #58a6ff; --bubble-user-bg: #238636; --bubble-user-text: #ffffff; --input-bg: #161b22; --input-text: #c9d1d9; --btn-bg: #1f6feb; --btn-text: #ffffff; --nav-border: #30363d; --font-family: -apple-system, "PingFang SC", sans-serif; --border-radius: 8px; }

.theme-jichang { --bg-color: #0f172a; --nav-bg: rgba(15, 23, 42, 0.95); --text-color: #818cf8; --bubble-ai-bg: #1e293b; --bubble-ai-text: #e2e8f0; --bubble-user-bg: #4f46e5; --bubble-user-text: #fff; --input-bg: #1e293b; --input-text: #818cf8; --btn-bg: #6366f1; --btn-text: #fff; --nav-border: #334155; --border-radius: 12px; }
.theme-clone { --bg-color: #100b1a; --nav-bg: rgba(16, 11, 26, 0.95); --text-color: #d8b4fe; --bubble-ai-bg: #2e1065; --bubble-ai-text: #f3e8ff; --bubble-user-bg: #9333ea; --bubble-user-text: #fff; --input-bg: #1c112b; --input-text: #d8b4fe; --btn-bg: #a855f7; --btn-text: #fff; --nav-border: #4c1d95; --border-radius: 16px; }
.theme-lickdog { --bg-color: #f4f5f7; --nav-bg: #ffffff; --text-color: #333333; --bubble-ai-bg: #e9eaec; --bubble-ai-text: #333333; --bubble-user-bg: #d8d8d8; --bubble-user-text: #333; --input-bg: #fff; --input-text: #333; --btn-bg: #a0a0a0; --btn-text: #fff; --nav-border: #ddd; --border-radius: 12px; }
.theme-couple { --bg-color: #fff0f5; --nav-bg: rgba(255, 240, 245, 0.95); --text-color: #ff1493; --bubble-ai-bg: #ffe4e1; --bubble-ai-text: #ff1493; --bubble-user-bg: #ff69b4; --bubble-user-text: #fff; --input-bg: #ffffff; --input-text: #ff1493; --btn-bg: #ff69b4; --btn-text: #fff; --nav-border: #ffb6c1; --border-radius: 20px; }
.theme-cold { --bg-color: #ffffff; --nav-bg: #fafafa; --text-color: #999999; --bubble-ai-bg: #f5f5f5; --bubble-ai-text: #666; --bubble-user-bg: #eeeeee; --bubble-user-text: #999; --input-bg: #fafafa; --input-text: #999; --btn-bg: #e0e0e0; --btn-text: #999; --nav-border: #eeeeee; --border-radius: 2px; }
.theme-breakup { --bg-color: #2c3e50; --nav-bg: rgba(44, 62, 80, 0.95); --text-color: #95a5a6; --bubble-ai-bg: #34495e; --bubble-ai-text: #bdc3c7; --bubble-user-bg: #546e7a; --bubble-user-text: #cfd8dc; --input-bg: #1a252f; --input-text: #bdc3c7; --btn-bg: #7f8c8d; --btn-text: #fff; --nav-border: #34495e; --border-radius: 4px; }
.theme-tsundere { --bg-color: #fff8e1; --nav-bg: rgba(255, 248, 225, 0.95); --text-color: #f57c00; --bubble-ai-bg: #ffe082; --bubble-ai-text: #e65100; --bubble-user-bg: #ff9800; --bubble-user-text: #fff; --input-bg: #ffffff; --input-text: #f57c00; --btn-bg: #ff9800; --btn-text: #fff; --nav-border: #ffcc80; --border-radius: 16px; }
.theme-scumbag { --bg-color: #1e0a3c; --nav-bg: rgba(30, 10, 60, 0.95); --text-color: #e0b0ff; --bubble-ai-bg: #3b146b; --bubble-ai-text: #ffd700; --bubble-user-bg: #8a2be2; --bubble-user-text: #fff; --input-bg: #130526; --input-text: #ffd700; --btn-bg: #ffd700; --btn-text: #1e0a3c; --nav-border: #6a0dad; --border-radius: 10px; }
.theme-yandere { --bg-color: #0f0505; --nav-bg: rgba(20, 5, 5, 0.95); --text-color: #d8b4b4; --bubble-ai-bg: #2a0d0d; --bubble-ai-text: #e63946; --bubble-user-bg: #5a1515; --bubble-user-text: #ffcccc; --input-bg: #150808; --input-text: #e63946; --btn-bg: #b31b1b; --btn-text: #fff; --nav-border: #4a1010; --border-radius: 8px; }
.theme-mock { --bg-color: #fffbeb; --nav-bg: rgba(255, 251, 235, 0.95); --text-color: #78350f; --bubble-ai-bg: #fef08a; --bubble-ai-text: #854d0e; --bubble-user-bg: #f59e0b; --bubble-user-text: #fff; --input-bg: #fff; --input-text: #78350f; --btn-bg: #eab308; --btn-text: #fff; --nav-border: #fcd34d; --border-radius: 6px; }
.theme-loved { --bg-color: #f4f9f4; --nav-bg: rgba(244, 249, 244, 0.95); --text-color: #5c7a4b; --bubble-ai-bg: #ffffff; --bubble-ai-text: #6b8e5a; --bubble-user-bg: #a3c99c; --bubble-user-text: #ffffff; --input-bg: #ffffff; --input-text: #6b8e5a; --btn-bg: #8fc182; --btn-text: #ffffff; --nav-border: #d4e5c1; --border-radius: 18px; }
.theme-sad { --bg-color: #0f172a; --nav-bg: rgba(15, 23, 42, 0.95); --text-color: #94a3b8; --bubble-ai-bg: #1e293b; --bubble-ai-text: #cbd5e1; --bubble-user-bg: #334155; --bubble-user-text: #94a3b8; --input-bg: #1e293b; --input-text: #94a3b8; --btn-bg: #475569; --btn-text: #fff; --nav-border: #334155; --border-radius: 8px; }

.app { width: 100%; height: 100%; display: flex; flex-direction: column; position: relative; background: var(--bg-color); color: var(--text-color); transition: all 0.3s ease; }
.bg-layer { position: absolute; inset: 0; background-size: cover; background-position: center; z-index: 0; pointer-events: none; opacity: 0.3; }

#fxCanvas { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 99999; }

#welcome-screen { position: fixed; inset: 0; background: #0a0a0a; z-index: 9999; display: flex; flex-direction: column; align-items: center; justify-content: center; animation: hideScreen 0.4s ease 1.5s forwards; }
@keyframes hideScreen { to { opacity: 0; visibility: hidden; pointer-events: none; } }
.ai-core { position: relative; width: 120px; height: 120px; display: flex; align-items: center; justify-content: center; margin-bottom: 30px; }
.ring { position: absolute; border-radius: 50%; border: 2px solid transparent; }
.ring1 { width: 100%; height: 100%; border-top-color: var(--btn-bg); border-bottom-color: var(--btn-bg); animation: spin 2s linear infinite; }
.ring2 { width: 75%; height: 75%; border-left-color: #3b82f6; border-right-color: #3b82f6; animation: spin 3s linear infinite reverse; }
.ring3 { width: 50%; height: 50%; border-top-color: #a855f7; border-bottom-color: #a855f7; animation: spin 1.5s linear infinite; }
.center-dot { width: 15px; height: 15px; background: #fff; border-radius: 50%; box-shadow: 0 0 20px var(--btn-bg); animation: pulse 1.5s infinite alternate; }
@keyframes spin { 100% { transform: rotate(360deg); } }
@keyframes pulse { 0% { transform: scale(0.8); opacity: 0.6; } 100% { transform: scale(1.2); opacity: 1; } }
.boot-text { color: var(--btn-bg); font-size: 14px; letter-spacing: 2px; font-family: monospace; }

.navbar { z-index: 10; height: 52px; display: flex; align-items: center; justify-content: space-between; padding: 0 12px; background: var(--nav-bg); border-bottom: 1px solid var(--nav-border); position: relative; backdrop-filter: blur(10px); transition: all 0.3s; }
.nav-title { flex: 1; text-align: center; font-size: 18px; font-weight: 800; color: var(--text-color); letter-spacing: 1px; text-shadow: 0 1px 2px rgba(0,0,0,0.05); transition: color 0.3s; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 0 10px; }
.nav-title small { color: var(--btn-bg); font-size: 11px; margin-left: 6px; font-weight: 600; opacity: 0.8; letter-spacing: 0; padding: 2px 6px; background: rgba(255,255,255,0.1); border-radius: 10px; vertical-align: middle;}

.nav-left-stats { display: flex; gap: 6px; align-items: center; z-index: 2; }
.stat-pill { background: rgba(255, 255, 255, 0.1); border: 1px solid rgba(255,255,255,0.05); border-radius: 20px; padding: 3px 10px; font-size: 13px; font-weight: bold; color: #fff; display: flex; align-items: center; gap: 4px; backdrop-filter: blur(5px); transition: transform 0.2s; }
.stat-pill:active { transform: scale(0.95); }
.stat-icon { font-size: 14px; filter: drop-shadow(0 0 2px rgba(255,255,255,0.3)); }

.nav-right { display: flex; gap: 5px; z-index: 2; }
.icon-btn { background: transparent; border: none; font-size: 22px; padding: 5px; cursor: pointer; color: var(--text-color); transition: transform 0.2s; }
.icon-btn:active { transform: rotate(90deg); }

.chat { flex: 1 1 auto; overflow-y: auto; padding: 20px 0 10px; z-index: 1; position: relative; -webkit-overflow-scrolling: touch; }
.msg { display: flex; align-items: flex-start; padding: 0 12px; margin-bottom: 16px; animation: pop .2s ease-out; }
@keyframes pop { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.msg.me { flex-direction: row-reverse; }
.avatar { width: 40px; height: 40px; flex: 0 0 40px; border-radius: var(--border-radius); display: flex; align-items: center; justify-content: center; font-size: 20px; background: var(--input-bg); border: 1px solid var(--nav-border); overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.bubble { max-width: 75%; margin: 0 10px; padding: 10px 14px; background: var(--bubble-ai-bg); border-radius: var(--border-radius); font-size: 15px; line-height: 1.5; color: var(--bubble-ai-text); word-break: break-word; box-shadow: 0 2px 5px rgba(0,0,0,0.05); border: 1px solid var(--nav-border); }
.msg.me .bubble { background: var(--bubble-user-bg); color: var(--bubble-user-text); border-color: transparent; }

.inputbar { z-index: 10; display: flex; align-items: center; gap: 8px; padding: 10px 12px; background: var(--nav-bg); border-top: 1px solid var(--nav-border); padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px)); transition: all 0.3s; }
.inputbar input { flex: 1; border: 1px solid var(--nav-border); outline: none; background: var(--input-bg); color: var(--input-text); border-radius: var(--border-radius); padding: 10px 12px; font-size: 16px; font-family: inherit; }
.send-btn { border: none; border-radius: var(--border-radius); background: var(--btn-bg); color: var(--btn-text); font-size: 14px; padding: 9px 16px; cursor: pointer; font-weight: bold; transition: 0.2s; }
.send-btn:active { opacity: 0.8; }

.mask { position: absolute; inset: 0; background: rgba(0,0,0,0.6); display: none; align-items: flex-end; justify-content: center; z-index: 100; backdrop-filter: blur(4px); opacity: 0; transition: opacity 0.3s ease; }
.mask.show { display: flex; opacity: 1; }
.modal { width: 100%; max-width: 500px; background: #ffffff; border-radius: 24px 24px 0 0; padding: 24px 20px; max-height: 90vh; overflow-y: auto; color: #333; transform: translateY(100%); transition: transform 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.1); box-shadow: 0 -4px 20px rgba(0,0,0,0.1); }
.mask.show .modal { transform: translateY(0); }

.slide-up { opacity: 0; transform: translateY(15px); animation: slideUpFade 0.4s forwards; }
@keyframes slideUpFade { to { opacity: 1; transform: translateY(0); } }

.modal-header { text-align: center; margin-bottom: 20px; }
.modal-header h3 { margin: 0; font-size: 20px; font-weight: 800; color: #333; }
.modal-subtitle { margin: 4px 0 0; font-size: 12px; color: #999; letter-spacing: 1px; }

.config-section { margin-bottom: 16px; }
.config-section label { display: block; margin-bottom: 8px; font-size: 13px; font-weight: 600; color: #555; }
.config-section input[type="text"] { width: 100%; padding: 12px; border: 2px solid #f0f0f0; border-radius: 12px; background: #fafafa; outline: none; font-size: 14px; transition: all 0.2s; }
.config-section input[type="text"]:focus { border-color: #6366f1; background: #fff; box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1); }

.persona-group { background: #f8f9fa; border-radius: 16px; padding: 16px; margin-bottom: 16px; border: 1px solid #eef0f2; }
.group-title { display: block; margin-bottom: 12px; font-size: 13px; font-weight: bold; color: #333; }
.persona-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.persona-btn { background: #fff; border: 2px solid transparent; border-radius: 12px; padding: 10px 8px; font-size: 13px; text-align: center; cursor: pointer; transition: all 0.2s; line-height: 1.4; box-shadow: 0 2px 5px rgba(0,0,0,0.02); color: #555; }
.persona-btn small { color: #999; font-size: 11px; }
.persona-btn:active { transform: scale(0.95); }
.persona-btn.active { background: #eef2ff; border-color: #6366f1; color: #4f46e5; font-weight: bold; box-shadow: 0 4px 10px rgba(99, 102, 241, 0.15); }
.persona-btn.active small { color: #818cf8; }

.memory-section { background: #fff; border-radius: 12px; padding: 16px; border: 2px dashed #e2e8f0; margin-bottom: 16px; transition: border-color 0.3s; }
.memory-section:focus-within { border-color: #6366f1; }
.memory-section label { font-size: 13px; font-weight: bold; }
.memory-section textarea { width: 100%; height: 70px; border: none; background: #f8fafc; border-radius: 8px; padding: 12px; font-size: 13px; resize: none; margin-top: 8px; outline: none; line-height: 1.5; color: #333; }
.memory-section textarea:focus { background: #f1f5f9; }

.upload-row { display: flex; gap: 10px; }
.upload-btn { flex: 1; text-align: center; background: #fff; color: #6366f1; padding: 10px; border-radius: 10px; font-size: 13px; font-weight: 600; cursor: pointer; border: 2px dashed #c7d2fe; transition: all 0.2s; }
.upload-btn:active { background: #eef2ff; transform: scale(0.98); }

.bg-setting { background: #f0f9ff; padding: 16px; border-radius: 12px; border: 1px solid #e0f2fe; }
.radio-group { display: flex; justify-content: space-between; margin-bottom: 8px; }
.radio-group label { font-size: 13px; color: #444; display: flex; align-items: center; gap: 4px; font-weight: normal; margin: 0; }

.modal-btns { display: flex; gap: 10px; margin-top: 24px; }
.modal-btns button { padding: 14px; border-radius: 12px; border: none; font-weight: bold; font-size: 15px; cursor: pointer; transition: transform 0.1s; }
.modal-btns button:active { transform: scale(0.96); }
.btn-cancel { background: #f1f5f9; color: #64748b; }
.btn-clear { background: #fef08a; color: #854d0e; }
.btn-danger { background: #fee2e2; color: #ef4444; }
.btn-save { background: linear-gradient(135deg, #6366f1, #4f46e5); color: #fff; box-shadow: 0 4px 12px rgba(99,102,241,0.3); }

.confirm-mask { position: fixed; inset: 0; background: rgba(0,0,0,0.5); backdrop-filter: blur(5px); display: none; align-items: center; justify-content: center; z-index: 200; opacity: 0; transition: opacity 0.2s ease; }
.confirm-mask.show { display: flex; opacity: 1; }
.confirm-box { width: 80%; max-width: 320px; background: #fff; border-radius: 18px; padding: 24px; text-align: center; transform: scale(0.9); transition: transform 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275); box-shadow: 0 10px 40px rgba(0,0,0,0.2); }
.confirm-mask.show .confirm-box { transform: scale(1); }
.confirm-box h4 { margin: 0 0 10px; font-size: 18px; color: #333; }
.confirm-box p { margin: 0 0 20px; font-size: 14px; color: #666; line-height: 1.5; text-align: left; white-space: pre-wrap; }
.confirm-actions { display: flex; gap: 12px; }
.confirm-actions button { flex: 1; padding: 12px; border-radius: 10px; border: none; font-size: 15px; font-weight: bold; cursor: pointer; transition: 0.2s; }
.c-cancel { background: #f1f5f9; color: #64748b; }
.c-ok { background: #ef4444; color: #fff; box-shadow: 0 4px 10px rgba(239,68,68,0.3); }
.c-ok:active, .c-cancel:active { transform: scale(0.95); }

.custom-toast { position: fixed; bottom: 120px; left: 50%; transform: translateX(-50%) translateY(20px); background: rgba(30, 30, 30, 0.85); backdrop-filter: blur(8px); color: #fff; padding: 12px 24px; border-radius: 25px; font-size: 14px; opacity: 0; pointer-events: none; transition: all 0.3s; z-index: 9999; }
.custom-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }