*{margin:0;padding:0;box-sizing:border-box}
html{height:100%;background:#000}
body{color:#fff;font-family:-apple-system,'PingFang SC',sans-serif;display:flex;flex-direction:column;width:100%;max-width:430px;margin:0 auto;position:fixed;top:0;left:0;right:0;bottom:0;overflow:hidden}
@media (min-width:430px){body{left:50%;right:auto;transform:translateX(-50%)}}
@media all and (display-mode:standalone){textarea,input{-webkit-user-select:text!important;user-select:text!important;pointer-events:auto!important}}
.overlay{position:fixed;inset:0;background:rgba(0,0,0,.5);z-index:50;opacity:0;pointer-events:none;transition:opacity .28s ease}
.overlay.open{opacity:1;pointer-events:auto}
.sidebar{position:fixed;top:0;left:0;height:100%;width:78%;max-width:290px;background:#111;z-index:60;transform:translateX(-100%);transition:transform .28s cubic-bezier(.4,0,.2,1);display:flex;flex-direction:column;overflow-y:auto;box-shadow:2px 0 20px rgba(0,0,0,.6)}
.sidebar.open{transform:translateX(0)}
.sidebar::-webkit-scrollbar{display:none}
.sb-profile{display:flex;align-items:center;gap:14px;padding:calc(env(safe-area-inset-top,0px) + 30px) 20px 20px}
.sb-avatar{width:62px;height:62px;border-radius:50%;object-fit:cover;background:#333;cursor:pointer;display:block}
.sb-avatar-placeholder{width:62px;height:62px;border-radius:50%;background:#222;display:flex;align-items:center;justify-content:center;font-size:26px;cursor:pointer}
.sb-name{font-size:20px;font-weight:600;color:#fff}
.sb-divider{height:.5px;background:#2a2a2a;margin:0 0 6px}
.sb-section-label{font-size:10.5px;color:#555;letter-spacing:2.5px;padding:12px 20px 4px;font-weight:500}
.sb-item{display:flex;align-items:center;gap:13px;padding:11px 20px;font-size:14.5px;color:#ccc;cursor:pointer;transition:background .15s}
.sb-item:active{background:#1a1a1a}
.sb-item svg{flex-shrink:0;width:17px;height:17px;opacity:.45}
.sb-item svg path,.sb-item svg circle,.sb-item svg rect{stroke:#ccc}
.sb-item span{flex:1}
.header-chat{padding:calc(env(safe-area-inset-top,0px) + 14px) 16px 10px;display:flex;align-items:center;justify-content:space-between;background:#000;flex-shrink:0}
.header-chat-left{display:flex;align-items:center;gap:10px;cursor:pointer;-webkit-tap-highlight-color:transparent}
.header-chat-name{font-size:16px;font-weight:600;color:#fff}
.header-chat-dots{cursor:pointer;padding:4px;-webkit-tap-highlight-color:transparent}
.header-sub{padding:calc(env(safe-area-inset-top,0px) + 12px) 16px 10px;display:flex;align-items:center;background:#000;border-bottom:.5px solid #222;flex-shrink:0}
.header-sub-menu{cursor:pointer;-webkit-tap-highlight-color:transparent;padding:2px}
.page{display:none;flex-direction:column;overflow:hidden;position:relative;flex:1;min-height:0}
.page.active{display:flex}
.messages{flex:1;overflow-y:auto;padding:8px 12px 12px;display:flex;flex-direction:column;gap:2px;background:#000;min-height:0}
.messages::-webkit-scrollbar{display:none}
.time-label{text-align:center;font-size:11px;color:#666;margin:10px 0 4px;user-select:none}
.msg-row{display:flex;flex-direction:column;margin-bottom:6px}
.msg-row.me{align-items:flex-end}
.msg-row.them{align-items:flex-start}
.msg-row.no-tail{margin-bottom:2px}
.msg-row.no-tail .bubble::after{display:none}
.msg-row.no-tail.me .bubble{border-bottom-right-radius:20px}
.msg-row.no-tail.them .bubble{border-bottom-left-radius:20px}
.bubble{max-width:72%;padding:8px 14px;border-radius:20px;font-size:15px;line-height:1.5;word-break:break-word;position:relative}
.msg-row.me .bubble{background:#1d6fe5;color:#fff;border-bottom-right-radius:4px}
.msg-row.them .bubble{background:#1c1c1e;color:#fff;border-bottom-left-radius:4px}
.msg-row.me .bubble::after{content:'';position:absolute;bottom:0;right:-6px;width:12px;height:14px;background:#1d6fe5;clip-path:polygon(0 0,100% 100%,0 100%);border-radius:0 0 3px 0}
.msg-row.them .bubble::after{content:'';position:absolute;bottom:0;left:-6px;width:12px;height:14px;background:#1c1c1e;clip-path:polygon(100% 0,0 100%,100% 100%);border-radius:0 0 0 3px}
.read-label{font-size:10px;color:#555;margin-top:3px;padding-right:2px;align-self:flex-end}
.msg-time{font-size:10px;color:#555;margin-top:3px;padding-left:2px;align-self:flex-start}
.action-text{font-size:11.5px;color:#555;font-style:italic;margin-top:4px;padding-left:4px;letter-spacing:.2px}
.thinking-wrap{max-width:72%;margin-bottom:4px}
.thinking-toggle{font-size:11px;color:#555;cursor:pointer;display:flex;align-items:center;gap:4px;padding:2px 0;user-select:none}
.thinking-toggle svg{transition:transform .2s}
.thinking-toggle.open svg{transform:rotate(90deg)}
.thinking-body{font-size:12px;color:#666;background:#111;border-left:2px solid #333;padding:6px 10px;border-radius:0 6px 6px 0;margin-top:4px;line-height:1.5;display:none;white-space:pre-wrap}
.thinking-body.open{display:block}
.quote-preview{background:#1a1a1a;border-left:3px solid #444;padding:5px 10px;border-radius:4px;font-size:12px;color:#888;display:none;justify-content:space-between;align-items:center;margin-bottom:4px}
.quote-preview-close{font-size:18px;color:#555;cursor:pointer;line-height:1}
.bubble-quote{border-left:3px solid rgba(255,255,255,.35);padding:4px 8px;margin-bottom:6px;border-radius:0 4px 4px 0;max-width:100%;overflow:hidden}
.msg-row.me .bubble-quote{border-left-color:rgba(255,255,255,.5)}
.msg-row.them .bubble-quote{border-left-color:#5a9fe8}
.bubble-quote-name{font-size:11px;font-weight:600;color:rgba(255,255,255,.55);margin-bottom:2px}
.msg-row.them .bubble-quote-name{color:#5a9fe8}
.bubble-quote-text{font-size:12px;color:rgba(255,255,255,.45);line-height:1.4;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.input-bar{padding:8px 12px max(8px,env(safe-area-inset-bottom,0px)) 12px;display:flex;align-items:flex-end;gap:8px;background:#000;border-top:.5px solid #222;flex-shrink:0}
.input-img-btn{display:none}
.input-emoji-btn{display:none}
.input-plus-btn{width:32px;height:32px;border-radius:50%;border:1.5px solid #444;display:flex;align-items:center;justify-content:center;flex-shrink:0;cursor:pointer;-webkit-tap-highlight-color:transparent;margin-bottom:1px}
.plus-popup-dark{position:fixed;bottom:70px;left:12px;background:#1c1c1e;border-radius:14px;box-shadow:0 4px 20px rgba(0,0,0,.6);padding:4px 0;min-width:130px;z-index:70;opacity:0;pointer-events:none;transform:translateY(6px);transition:opacity .18s,transform .18s}
.plus-popup-dark.open{opacity:1;pointer-events:auto;transform:translateY(0)}
.plus-item-dark{display:flex;align-items:center;gap:10px;padding:12px 16px;font-size:14px;color:#ccc;cursor:pointer}
.plus-item-dark:active{background:#2a2a2a}
.plus-popup{display:none}
.plus-item{display:none}
.input-wrap{flex:1;display:flex;flex-direction:column;cursor:text;-webkit-tap-highlight-color:transparent}
.input-field{width:100%;background:#1c1c1e;border:none;border-radius:18px;padding:7px 13px;font-size:16px;color:#fff;outline:none;font-family:inherit;resize:none;overflow:hidden;line-height:1.45;-webkit-user-select:text;user-select:text;touch-action:manipulation;-webkit-appearance:none}
.input-field::placeholder{color:#555}
.input-btn{width:30px;height:30px;border-radius:50%;background:#1d6fe5;border:none;display:flex;align-items:center;justify-content:center;flex-shrink:0;cursor:pointer;margin-bottom:1px}
.msg-menu-overlay{position:fixed;inset:0;z-index:80;opacity:0;pointer-events:none}
.msg-menu-overlay.open{opacity:1;pointer-events:auto}
.msg-menu{position:absolute;background:#1c1c1e;border-radius:14px;box-shadow:0 4px 24px rgba(0,0,0,.6);overflow:hidden;min-width:140px}
.msg-menu-item{padding:12px 18px;font-size:14px;color:#fff;cursor:pointer;border-bottom:.5px solid #2a2a2a}
.msg-menu-item:last-child{border-bottom:none}
.msg-menu-item:active{background:#2a2a2a}
.msg-menu-item.danger{color:#ff453a}
.search-overlay{position:fixed;inset:0;background:#000;z-index:90;display:none;flex-direction:column}
.search-overlay.open{display:flex}
.search-header{padding:calc(env(safe-area-inset-top,0px) + 12px) 16px 10px;display:flex;align-items:center;gap:10px;border-bottom:.5px solid #222;flex-shrink:0}
.search-back{font-size:15px;color:#fff;cursor:pointer;padding:4px 8px 4px 0}
.search-input{flex:1;background:#1c1c1e;border:none;border-radius:10px;padding:7px 12px;font-size:14px;color:#fff;outline:none;font-family:inherit}
.search-results{flex:1;overflow-y:auto;padding:8px 0}
.search-results::-webkit-scrollbar{display:none}
.search-item{padding:12px 16px;border-bottom:.5px solid #1a1a1a;cursor:pointer}
.search-item:active{background:#1a1a1a}
.search-item-meta{font-size:11px;color:#555;margin-bottom:3px}
.search-item-text{font-size:14px;color:#fff;line-height:1.4}
.search-item-text mark{background:#3a3200;border-radius:2px;padding:0 1px;color:#ffe066}
.search-empty{text-align:center;color:#444;font-size:14px;padding:40px 0}
.popup-overlay{position:fixed;inset:0;z-index:70;opacity:0;pointer-events:none;transition:opacity .2s}
.popup-overlay.open{opacity:1;pointer-events:auto}
.popup-menu{position:absolute;top:52px;right:14px;background:#1c1c1e;border-radius:14px;box-shadow:0 4px 24px rgba(0,0,0,.5);min-width:160px;overflow:hidden}
.popup-item{padding:13px 18px;font-size:14px;color:#fff;cursor:pointer;border-bottom:.5px solid #2a2a2a}
.popup-item:last-child{border-bottom:none}
.popup-item:active{background:#2a2a2a}
.sub-page{flex:1;overflow-y:auto;padding:0 0 40px;display:flex;flex-direction:column;background:#000}
.sub-page::-webkit-scrollbar{display:none}
.sub-title{font-size:22px;font-weight:600;color:#fff;padding:24px 20px 4px}
.sub-desc{font-size:13px;color:#555;padding:0 20px 8px}
.card{background:#1c1c1e;border-radius:14px;padding:16px 18px;font-size:14px;color:#888;line-height:1.7;margin:0 16px}
.card-label{font-size:11px;color:#555;letter-spacing:1px;margin-bottom:8px;font-weight:500}
.setting-group{margin:20px 16px 0}
.setting-group-label{font-size:12px;color:#555;letter-spacing:.3px;margin-bottom:6px;padding-left:4px}
.setting-card{background:#1c1c1e;border-radius:14px;overflow:hidden}
.setting-row{display:flex;align-items:center;padding:13px 16px;border-bottom:.5px solid #2a2a2a;gap:10px;min-height:48px}
.setting-row:last-child{border-bottom:none}
.setting-label{font-size:15px;color:#fff;flex-shrink:0}
.setting-input{flex:1;border:none;outline:none;font-size:14px;color:#aaa;background:transparent;text-align:right;font-family:inherit}
.setting-input::placeholder{color:#444}
.setting-input.secret{letter-spacing:2px}
.toggle{width:44px;height:26px;border-radius:13px;background:#333;position:relative;cursor:pointer;transition:background .2s;flex-shrink:0}
.toggle.on{background:#1d6fe5}
.toggle-knob{position:absolute;top:3px;left:3px;width:20px;height:20px;border-radius:50%;background:#fff;transition:transform .2s;box-shadow:0 1px 3px rgba(0,0,0,.3)}
.toggle.on .toggle-knob{transform:translateX(18px)}
.model-select{flex:1;border:none;outline:none;font-size:14px;color:#aaa;background:transparent;text-align:right;font-family:inherit;cursor:pointer;max-width:200px}
.slider-wrap{flex:1;display:flex;align-items:center;gap:8px;justify-content:flex-end}
.slider{-webkit-appearance:none;width:90px;height:3px;border-radius:2px;background:#333;outline:none}
.slider::-webkit-slider-thumb{-webkit-appearance:none;width:16px;height:16px;border-radius:50%;background:#fff;cursor:pointer}
.slider-val{font-size:13px;color:#555;min-width:28px;text-align:right}
.setting-btn{width:calc(100% - 32px);margin:12px 16px 0;padding:14px;background:#1d6fe5;color:#fff;border:none;border-radius:14px;font-size:15px;font-family:inherit;cursor:pointer}
.setting-btn.ghost{background:#1c1c1e;color:#fff;border:.5px solid #333;margin-top:8px}
.setting-fetch-btn{padding:6px 12px;background:#2a2a2a;border:.5px solid #333;border-radius:8px;font-size:13px;color:#aaa;cursor:pointer;white-space:nowrap;font-family:inherit}
.mem-tabs{display:flex;gap:0;padding:0 16px;border-bottom:.5px solid #222;flex-shrink:0;background:#000}
.mem-tab{padding:10px 16px;font-size:14px;color:#555;cursor:pointer;border-bottom:2px solid transparent;transition:color .15s}
.mem-tab.active{color:#fff;border-bottom-color:#1d6fe5}
.mem-body{flex:1;overflow-y:auto;padding:16px}
.mem-body::-webkit-scrollbar{display:none}
.mem-connect-row{display:flex;flex-direction:column;gap:6px;margin-bottom:16px}
.mem-url-input{background:#1c1c1e;border:none;border-radius:10px;padding:9px 13px;font-size:14px;color:#fff;outline:none;font-family:inherit}
.mem-url-input::placeholder{color:#555}
.mem-fetch-btn{background:#1d6fe5;color:#fff;border:none;border-radius:10px;padding:10px;font-size:14px;cursor:pointer;font-family:inherit;margin-top:2px}
.mem-list{display:flex;flex-direction:column;gap:10px}
.mem-card{background:#1c1c1e;border-radius:12px;padding:14px 16px}
.mem-card-name{font-size:12px;color:#1d6fe5;margin-bottom:6px;letter-spacing:.3px}
.mem-card-content{font-size:14px;color:#ccc;line-height:1.6;white-space:pre-wrap}
.mem-card-meta{font-size:11px;color:#555;margin-top:6px}
.streaming-cursor{display:inline-block;width:2px;height:13px;background:#666;margin-left:1px;vertical-align:middle;animation:blink .8s infinite}
@keyframes blink{0%,100%{opacity:1}50%{opacity:0}}