@font-face{font-family:Wenkai;src:url(lxgwwenkai-common.woff2)}
:root{--ink:#243b31;--muted:#6b7f72;--green:#185c49;--line:#dbe6dc;--bg:#e9f0e9}
*{box-sizing:border-box}html,body{height:100%}
body{margin:0;color:var(--ink);background:radial-gradient(circle at 12% 8%,#f3f8f1 0,transparent 36%),radial-gradient(circle at 88% 92%,#dfece2 0,transparent 40%),var(--bg);font:16px/1.65 system-ui,"Microsoft YaHei","PingFang SC",sans-serif}
main.chat{height:100dvh;max-width:880px;margin:auto;display:grid;grid-template-rows:auto minmax(0,1fr) auto;background:#f7faf6;box-shadow:0 0 70px #183b2b1c;overflow:hidden}
.chat-head{display:flex;align-items:center;gap:10px;padding:12px 18px;background:#fbfdf9e6;backdrop-filter:blur(12px);border-bottom:1px solid var(--line);position:relative;z-index:2}
.back{font:28px/1 Georgia,serif;color:#476457;text-decoration:none;padding:0 6px 4px;border-radius:8px}.back:hover{background:#edf4ed}
.head-avatar{width:42px;height:42px;border-radius:50%;object-fit:cover;box-shadow:0 0 0 2px #fff,0 0 0 3px #d6e6d9}
.who{flex:1;min-width:0}.who h1{margin:0;font:700 17px/1.3 Wenkai,"Microsoft YaHei",sans-serif;letter-spacing:.5px}.who p{margin:2px 0 0;display:flex;align-items:center;gap:5px;font-size:11px;color:var(--muted);line-height:1.4}
.dot{width:6px;height:6px;border-radius:50%;background:#62a87a;box-shadow:0 0 0 3px #e3f0e5}
#settings,#history{font-size:12px;color:#426454;background:#edf4ed;border:1px solid #dce8dd;border-radius:999px;padding:6px 10px;white-space:nowrap}
#settings:hover,#history:hover{background:#e3efe5}
#history{font-weight:650}
#thread{overflow-y:auto;padding:20px clamp(12px,3vw,28px) 12px;scroll-behavior:smooth}
#empty{min-height:100%;display:grid;place-content:center;justify-items:center;text-align:center;padding:30px}
#empty img{width:104px;height:104px;border-radius:50%;object-fit:cover;box-shadow:0 10px 28px #1b3d2c2b;animation:bob 3.2s ease-in-out infinite}
#empty h2{font:700 22px/1.3 Wenkai,"Microsoft YaHei",sans-serif;margin:17px 0 5px}#empty p{margin:0;color:var(--muted);font-size:13px}
.msg{display:flex;align-items:flex-start;gap:8px;margin:0 0 16px;animation:rise .2s ease-out}.msg.mine{flex-direction:row-reverse}
.msg-avatar{width:34px;height:34px;border-radius:50%;object-fit:cover;flex:none;box-shadow:0 0 0 1px #d9e5da}
.msg-avatar.me{display:grid;place-items:center;background:#dcebe1;color:#2f6a51;font-size:12px;font-weight:700}
.bubble-wrap{max-width:min(76%,560px);min-width:0}.msg.mine .bubble-wrap{display:flex;flex-direction:column;align-items:flex-end}
.bubble-wrap small{display:block;font-size:10px;color:#84968a;margin:0 4px 3px;line-height:1.4}
.bubble{position:relative;margin:0;padding:9px 13px;border-radius:4px 14px 14px;background:#fff;border:1px solid #dfe8e0;white-space:pre-wrap;overflow-wrap:anywhere;font-size:15px;line-height:1.62;box-shadow:0 1px 2px #1b3d2c08}
.mine .bubble{background:#dcefdc;border-color:#cfe4d0;border-radius:14px 4px 14px 14px}
.bubble:before{content:"";position:absolute;left:-5px;top:11px;width:8px;height:8px;background:inherit;border-left:1px solid #dfe8e0;border-bottom:1px solid #dfe8e0;transform:rotate(45deg);border-radius:0 0 0 1px}
.mine .bubble:before{left:auto;right:-5px;border:0;border-right:1px solid #cfe4d0;border-top:1px solid #cfe4d0;border-radius:0 1px 0 0}
.bubble.emoji-only,.bubble.sticker{background:transparent;border-color:transparent;box-shadow:none}
.bubble.emoji-only{font-size:40px;line-height:1.25;padding:0 2px 0 0}
.bubble.sticker{font-size:46px;line-height:1.25;padding:0;animation:sticker-pop .45s cubic-bezier(.2,1.6,.4,1),float 3s ease-in-out .45s infinite}
.bubble.extra-sticker{margin-top:5px}
.bubble.emoji-only:before,.bubble.sticker:before{display:none}
.day-divider{display:flex;align-items:center;gap:9px;margin:3px 0 16px;color:#87988c;font-size:10px;line-height:1.4;text-align:center}
.day-divider:before,.day-divider:after{content:"";height:1px;flex:1;background:linear-gradient(90deg,transparent,#dce7de)}
.day-divider:after{background:linear-gradient(90deg,#dce7de,transparent)}
.day-divider span{padding:2px 7px;border-radius:999px;background:#f1f6f1;white-space:nowrap}
.collect{margin:3px 3px 0;font-size:11px;color:#6d8376;background:none;border:0;padding:2px 0;text-decoration:underline;text-underline-offset:2px}.collect:hover{color:var(--green)}
.typing .bubble{display:flex;align-items:center;gap:4px;padding:13px 14px}
.typing .bubble i{width:6px;height:6px;border-radius:50%;background:#95a99b;animation:blink 1.2s infinite}
.typing .bubble i:nth-child(2){animation-delay:.15s}.typing .bubble i:nth-child(3){animation-delay:.3s}
.sources{display:flex;flex-wrap:wrap;align-items:center;gap:5px;margin:7px 2px 0}
.sources-label{font-size:10px;color:#84968a;line-height:1.4}
.source-link{display:inline-flex;align-items:center;gap:4px;max-width:100%;font-size:10px;line-height:1.3;color:#426454;background:#edf4ed;border:1px solid #dce8dd;border-radius:999px;padding:4px 7px;text-decoration:none;transition:background .15s ease,transform .15s ease}
.source-link:hover{background:#e3efe5;transform:translateY(-1px)}
.source-link b{font-size:9px;font-weight:700;color:#5e7b69}
.source-link span{max-width:190px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.think-badge{display:inline-block;margin-left:5px;padding:0 5px;border:1px solid #d4e2e9;border-radius:999px;background:#edf4f7;color:#547486;font-size:9px;font-weight:600;line-height:1.65;vertical-align:1px}
.composer-area{padding:8px clamp(12px,3vw,24px) max(12px,env(safe-area-inset-bottom));background:#fbfdf9ee;border-top:1px solid var(--line);backdrop-filter:blur(10px)}
.composer-meta{display:flex;align-items:center;justify-content:space-between;gap:8px;margin:0 2px 6px;min-height:22px}
#status{font-size:11px;color:#7d8f83;margin:0 2px;min-height:15px;line-height:1.4;flex:1;min-width:0}
.meta-actions{display:flex;align-items:center;gap:5px;flex:none}
.web-toggle{display:inline-flex;align-items:center;gap:5px;flex:none;font-size:10px;line-height:1.2;color:#718477;background:#eef3ee;border:1px solid #dce7de;border-radius:999px;padding:4px 8px;transition:background .15s ease,border-color .15s ease,color .15s ease}
.web-toggle:hover{background:#e6efe7}
.web-toggle[aria-pressed="true"]{color:#185c49;background:#e5f2e7;border-color:#c8dfcc;box-shadow:inset 0 0 0 1px #d4e8d7}
.web-dot{width:6px;height:6px;border-radius:50%;background:#9aac9f;box-shadow:0 0 0 2px #f4f8f4}
.web-toggle[aria-pressed="true"] .web-dot{background:#379166;box-shadow:0 0 0 2px #d9eddf}
.deep-toggle[aria-pressed="true"]{color:#315b7a;background:#e8f1f6;border-color:#cbdeea;box-shadow:inset 0 0 0 1px #d8e7ef}
.deep-toggle[aria-pressed="true"] .deep-dot{background:#3f7da5;box-shadow:0 0 0 2px #dcebf3}
#chat{display:flex;align-items:flex-end;gap:7px;background:#fff;border:1px solid #cddccf;border-radius:22px;padding:5px 6px 5px 4px;box-shadow:0 2px 10px #1b3d2c0d}
#emoji{width:38px;height:38px;border-radius:50%;font-size:22px;color:#5f7a68;background:transparent;flex:none;display:grid;place-items:center}
#emoji:hover,#emoji[aria-expanded=true]{background:#edf4ed}
#question{flex:1;border:0;background:transparent;resize:none;font:inherit;font-size:15px;line-height:1.5;padding:8px 2px;max-height:128px;min-height:38px;outline:none}
.accent{background:var(--green);color:#fff;border-radius:18px;padding:8px 16px;font-size:14px;font-weight:600;flex:none}.accent:disabled{opacity:.5;cursor:wait}
#tray{border-top:1px solid var(--line);padding:9px 4px 12px;max-height:236px;overflow:auto;animation:rise .15s ease-out}
.tray-label{font-size:11px;color:#8a9a8f;margin:4px 6px 7px}
#sticker-grid,#emoji-grid{display:grid;grid-template-columns:repeat(8,1fr);gap:4px;margin-bottom:8px}
.sticker-btn,.emoji-btn{font-size:26px;line-height:1.25;background:transparent;border:0;border-radius:10px;padding:6px 2px;cursor:pointer}
.sticker-btn{font-size:23px}.sticker-btn:hover,.emoji-btn:hover{background:#e9f2ea;transform:translateY(-1px)}
dialog{color:inherit;width:min(480px,94vw);max-height:90dvh;border:0;padding:22px;border-radius:16px;overflow:auto;background:#fdfefc}dialog::backdrop{background:#17322966}
.head{display:flex;align-items:center;justify-content:space-between;gap:12px;margin-bottom:18px}.head h2{font:700 19px/1.3 Wenkai,"Microsoft YaHei",sans-serif;margin:0}
.history-panel{width:min(780px,calc(100vw - 24px));max-height:min(88dvh,780px);overflow:hidden}
.history-panel>.hint{margin:-6px 0 12px;font-size:12px}
.history-layout{display:grid;grid-template-columns:190px minmax(0,1fr);gap:14px;height:min(61dvh,560px);min-height:260px}
.history-dates{display:flex;flex-direction:column;gap:6px;overflow-y:auto;padding:2px 3px 8px 2px;border-right:1px solid #e1e9e1}
.history-date{display:grid;gap:2px;width:100%;padding:9px 10px;border:1px solid transparent;border-radius:9px;background:transparent;color:#52675a;text-align:left;line-height:1.35}
.history-date span{font-size:12px;font-weight:650;white-space:nowrap}
.history-date small{font-size:10px;color:#8a9a8f}
.history-date:hover{background:#f0f6f0}
.history-date[aria-pressed=true]{border-color:#cde0d1;background:#e9f3ea;color:#245d45}
.history-date[aria-pressed=true] small{color:#5d7d69}
.history-turns{min-width:0;overflow-y:auto;padding:2px 5px 8px 2px;overscroll-behavior:contain}
.history-turn{padding:12px 13px;margin-bottom:9px;border:1px solid #e0e9e1;border-radius:12px;background:#f9fbf8}
.history-turn>header{display:flex;align-items:center;justify-content:space-between;gap:10px;margin-bottom:8px;color:#8a9a8f;font-size:10px;line-height:1.4}
.history-turn>header time{font-variant-numeric:tabular-nums;font-weight:650}
.history-message{display:grid;gap:2px;margin-top:7px}
.history-message b{font-size:10px;line-height:1.35;color:#7b8f81}
.history-message p{margin:0;padding:7px 9px;border:1px solid #e3eae3;border-radius:9px;background:#fff;white-space:pre-wrap;overflow-wrap:anywhere;font-size:13px;line-height:1.62}
.history-message.mine p{background:#edf6ea;border-color:#dcebd9}
.history-sticker{justify-self:start;margin-top:2px;font-size:31px;line-height:1.25;animation:sticker-pop .35s ease-out}
.history-state{min-height:18px;margin:10px 1px 0;color:#76897b;font-size:11px;line-height:1.45}
.reset-link{color:#315f48;text-decoration:underline;text-underline-offset:2px}.reset-link:hover{color:var(--green)}
label,h3{display:block;font-weight:650;margin:12px 0 6px}h3{font-size:15px;margin-top:0}hr{border:0;border-top:1px solid var(--line);margin:20px 0}
input,select,textarea{font:inherit;color:inherit;background:#fff;border:1px solid #bfcfc4;border-radius:8px;padding:8px;width:100%;max-width:100%}input,select{margin-bottom:12px}label+textarea{margin-bottom:10px}
select{background:#fff}.model-actions{display:flex;gap:8px}.model-actions .accent{background:var(--green);color:#fff}
#model-state,#feedback{min-height:1em;font-size:14px;color:var(--muted)}.hint{color:var(--muted);font-size:13px;line-height:1.6}
.switch-line{display:flex;align-items:center;gap:8px;margin:12px 0 10px;font-weight:650;cursor:pointer}
.switch-line input{width:auto;margin:0;accent-color:var(--green);flex:none}
.memory-actions{display:flex;align-items:center;gap:9px;margin:2px 0 8px}
.memory-actions button{border:1px solid #cbdcd0;border-radius:8px;background:#eef5ef;color:#315f48;padding:6px 10px;font-size:12px}
.memory-actions button:hover{background:#e4f0e7}.memory-actions button:disabled{opacity:.55;cursor:wait}
#memory-last{font-size:11px;color:#84968a}
.memory-list{display:grid;gap:6px;margin:8px 0 10px}
.memory-item{display:grid;grid-template-columns:auto minmax(0,1fr) auto;align-items:start;gap:7px;padding:8px 9px;border:1px solid #dbe7dd;border-radius:9px;background:#f8fbf7}
.memory-tag{flex:none;border-radius:999px;background:#e6f0e7;color:#426454;padding:1px 6px;font-size:10px;line-height:1.65;white-space:nowrap}
.memory-text{font-size:13px;line-height:1.55;overflow-wrap:anywhere;min-width:0}
.memory-text small{display:block;margin-top:2px;color:#8b9b90;font-size:9px}
.memory-buttons{display:flex;gap:3px}.memory-buttons button{font-size:11px;color:#60786a;padding:2px 3px;text-decoration:underline;text-underline-offset:2px}.memory-buttons button:hover{color:var(--green)}
.memory-empty{border:1px dashed #d7e3d8;border-radius:9px;padding:12px;text-align:center;color:#86978b;font-size:12px}
.memory-add{display:grid;grid-template-columns:88px minmax(0,1fr) auto;gap:6px;align-items:center;margin-top:8px}
.memory-add input,.memory-add select{margin:0;min-width:0;font-size:13px;padding:7px}
.memory-add button{border:1px solid #cbdcd0;border-radius:8px;background:#eef5ef;color:#315f48;padding:7px 10px;font-size:12px;white-space:nowrap}
.memory-add button:hover{background:#e4f0e7}
#memory-state{min-height:1em;font-size:12px;color:var(--muted);line-height:1.5}
button{font:inherit;color:inherit;cursor:pointer;border:0;background:none}button:focus-visible,a:focus-visible,textarea:focus-visible,input:focus-visible,select:focus-visible{outline:2px solid #317958;outline-offset:2px}
[hidden]{display:none!important}
@keyframes rise{from{opacity:0;transform:translateY(6px)}to{opacity:1;transform:none}}
@keyframes bob{0%,100%{transform:translateY(0)}50%{transform:translateY(-5px)}}
@keyframes blink{0%,60%,100%{opacity:.3;transform:translateY(0)}30%{opacity:1;transform:translateY(-2px)}}
@keyframes sticker-pop{0%{opacity:0;transform:scale(.5)}70%{transform:scale(1.08)}100%{opacity:1;transform:scale(1)}}
@keyframes float{0%,100%{transform:translateY(0)}50%{transform:translateY(-4px)}}
@media(min-width:700px){body{padding:18px}main.chat{height:calc(100dvh - 36px);border-radius:20px;border:1px solid #d7e3d8}}
@media(max-width:640px){body{background:#f7faf6}main.chat{height:100dvh;max-width:none;border:0;border-radius:0}.chat-head{padding:10px 12px;gap:8px}.head-avatar{width:38px;height:38px}.who h1{font-size:16px}#settings,#history{font-size:11px;padding:5px 8px}#history{padding-inline:9px}#thread{padding:14px 12px 8px}.bubble-wrap{max-width:80%}.bubble{font-size:15px}#sticker-grid,#emoji-grid{grid-template-columns:repeat(8,1fr)}.sticker-btn,.emoji-btn{font-size:24px}.composer-area{padding:6px 10px max(10px,env(safe-area-inset-bottom))}.composer-meta{margin-bottom:4px}.meta-actions{gap:4px}.web-toggle{font-size:10px;padding:5px 7px;min-height:28px}.source-link span{max-width:150px}.memory-add{grid-template-columns:78px minmax(0,1fr) auto}.memory-add input,.memory-add select{font-size:16px}.memory-add button{padding:8px}.memory-buttons button{padding:5px 4px}}
@media(max-width:640px),(pointer:coarse){
  .history-panel{width:calc(100vw - 12px);height:min(86dvh,760px);max-height:none;padding:17px 13px 13px;overflow:hidden}
  .history-panel>.head{margin-bottom:10px}
  .history-panel>.hint{font-size:11px;margin-bottom:9px}
  .history-layout{grid-template-columns:minmax(0,1fr);grid-template-rows:auto minmax(0,1fr);gap:9px;height:calc(100% - 82px);min-height:0}
  .history-dates{flex-direction:row;overflow-x:auto;overflow-y:hidden;padding:1px 0 7px;border-right:0;border-bottom:1px solid #e1e9e1;scrollbar-width:none}
  .history-dates::-webkit-scrollbar{display:none}
  .history-date{width:auto;min-width:max-content;padding:7px 10px;white-space:nowrap}
  .history-date small{display:none}
  .history-turns{padding:2px 1px 10px}
  .history-turn{padding:11px 11px 12px}
  .history-message p{font-size:14px}
  .history-state{font-size:10px;margin-top:7px}
}
@media(max-width:390px){.memory-item{grid-template-columns:1fr auto}.memory-tag{grid-column:1/-1;justify-self:start}.memory-add{grid-template-columns:1fr auto}.memory-add select{grid-column:1/-1}#memory-text{min-width:0}}
@media(prefers-reduced-motion:reduce){*{animation:none!important;scroll-behavior:auto!important}}

main.chat { grid-template-columns: minmax(0, 1fr); }
#question { min-width: 0; width: 0; }
#status, #presence { overflow-wrap: anywhere; }

@media (max-width: 640px), (pointer: coarse) {
  body.fish-page { padding: 0; }
  main.chat {
    width: 100%;
    max-width: none;
    height: var(--chat-visible-height, 100dvh);
    border: 0;
    border-radius: 0;
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
  }
  .chat-head { padding-top: max(10px, env(safe-area-inset-top)); }
  #question { font-size: 16px; max-height: min(128px, 24dvh); }
  #tray { max-height: min(236px, calc(var(--chat-visible-height, 100dvh) * .28)); }
  #sticker-grid, #emoji-grid { grid-template-columns: repeat(8, minmax(0, 1fr)); }
}

.send-target { display:inline-flex; flex:none; }
.send-target, #send { touch-action:none; }
#send { min-height:44px; }
#send:disabled { pointer-events:none; }
@media (max-width:640px), (pointer:coarse) {
  html:has(body.fish-page), body.fish-page { overflow:hidden; overscroll-behavior:none; }
  main.chat { position:fixed; top:var(--chat-visible-top,0px); inset-inline:0; }
  #thread { min-height:0; overscroll-behavior:contain; }
  #question { max-height:min(128px,calc(var(--chat-visible-height,100dvh) * .24)); }
  body.chat-keyboard .composer-meta { display:none; }
  body.chat-keyboard .composer-area { padding-bottom:max(6px,env(safe-area-inset-bottom)); }
  body.chat-keyboard #thread { padding-bottom:4px; }
}

#journal-search-form{display:flex;gap:8px}#journal-search{flex:1;min-width:0;padding:10px;font:inherit}#journal-results{display:grid;gap:8px;max-height:50vh;overflow:auto;margin-top:12px}.journal-result{display:grid;gap:5px;text-align:left;padding:12px;border:1px solid #dce8df;border-radius:10px;background:white;color:#274c3b;font:inherit}.journal-result span{white-space:pre-wrap;overflow-wrap:anywhere}
