:root{--bg:#f8f7f2;--side:#efeee8;--card:#fff;--ink:#252622;--muted:#73756e;--line:#ddddd6;--green:#1f6f50;--soft:#dcecdf;--danger:#a94335}*{box-sizing:border-box}html,body{height:100%}body{margin:0;background:var(--bg);color:var(--ink);font:15px/1.55 Inter,system-ui,sans-serif}button,input,textarea{font:inherit;color:inherit}.hidden{display:none!important}.brand{display:flex;align-items:center;gap:9px;font-size:17px;font-weight:750}.brand b,.welcome>b{display:grid;place-items:center;background:var(--green);color:#fff;font:20px Georgia;width:32px;height:32px;border-radius:10px}.app{height:100dvh;display:grid;grid-template-columns:280px 1fr;overflow:hidden}aside{min-height:0;padding:17px 13px 12px;background:var(--side);border-right:1px solid var(--line);display:flex;flex-direction:column}aside header,aside footer,.topbar{display:flex;align-items:center}aside header{justify-content:space-between;padding:0 7px 15px}.new{border:1px solid var(--line);background:var(--card);border-radius:12px;padding:10px 12px;text-align:left;cursor:pointer}.history-label{display:flex;align-items:center;justify-content:space-between;padding:22px 7px 7px;text-transform:uppercase;letter-spacing:.08em;font-size:11px;font-weight:700;color:var(--muted)}.icon,.link{border:0;background:none;cursor:pointer}.icon{width:34px;height:34px;border-radius:9px;color:var(--muted)}.icon:hover{background:#dedfd8}nav{min-height:0;overflow:auto;display:flex;flex-direction:column;gap:3px}.history-item{border:0;background:none;border-radius:9px;padding:9px 10px;text-align:left;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;cursor:pointer;color:#4d4f49}.history-item:hover,.history-item.active{background:#dfdfd8}.empty{padding:14px 9px;color:var(--muted);font-size:13px}aside footer{gap:9px;margin-top:auto;padding:13px 7px 2px;border-top:1px solid var(--line)}aside footer i{width:34px;height:34px;border-radius:50%;display:grid;place-items:center;background:var(--soft);color:var(--green);font-style:normal;font-weight:750}aside footer span{min-width:0;display:flex;flex:1;flex-direction:column}aside footer strong,aside footer small{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}aside footer small{color:var(--muted)}.main{min-width:0;height:100dvh;display:flex;flex-direction:column}.topbar{height:57px;flex:none;padding:0 20px;border-bottom:1px solid var(--line);gap:10px}.topbar>strong{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.online{margin-left:auto;color:var(--muted);font-size:12px}.online::first-letter{color:#39a56e}.messages{flex:1;min-height:0;overflow:auto;padding:32px max(22px,calc((100% - 760px)/2)) 14px;scroll-behavior:smooth}.welcome{min-height:72%;display:grid;place-content:center;text-align:center}.welcome>b{width:54px;height:54px;border-radius:18px;margin:auto;font-size:29px}.welcome h1,.auth h1{font:500 clamp(34px,5vw,48px)/1.05 Georgia,serif;letter-spacing:-.035em;margin:18px 0 10px}.welcome p{max-width:520px;color:var(--muted)}.welcome div{display:flex;justify-content:center;flex-wrap:wrap;gap:8px;margin-top:20px}.welcome button{border:1px solid var(--line);background:var(--card);border-radius:999px;padding:9px 13px;cursor:pointer}.row{max-width:760px;margin:0 auto 27px}.row.user{display:flex;justify-content:flex-end}.bubble{max-width:84%;border-radius:18px;padding:11px 15px;background:#e8e7e1;overflow-wrap:anywhere}.assistant .bubble{max-width:100%;padding:0;background:transparent}.content>:first-child{margin-top:0}.content>:last-child{margin-bottom:0}.content p{margin:.55em 0}.content h1,.content h2,.content h3{line-height:1.25}.content a{color:var(--green)}.content pre{background:#20231f;color:#edf2ed;padding:16px;border-radius:12px;overflow:auto;font:13px/1.55 ui-monospace,monospace}.content code:not(pre code){background:#e9e9e3;padding:2px 5px;border-radius:5px}.tools{height:27px;display:flex;gap:3px;opacity:0}.row:hover .tools{opacity:1}.tool{border:0;background:none;color:var(--muted);font-size:12px;cursor:pointer}.typing{display:flex;gap:5px;padding:10px 0}.typing i{width:6px;height:6px;background:#78847a;border-radius:50%;animation:pulse 1s infinite}.typing i:nth-child(2){animation-delay:.15s}.typing i:nth-child(3){animation-delay:.3s}@keyframes pulse{50%{opacity:.25;transform:translateY(-3px)}}.message-error{border:1px solid #ead0ca;background:#fff4f1;color:var(--danger);padding:11px;border-radius:12px}.composer-wrap{padding:10px max(18px,calc((100% - 760px)/2)) max(9px,env(safe-area-inset-bottom));text-align:center}.composer-wrap form{display:flex;align-items:flex-end;gap:8px;padding:8px 8px 8px 17px;background:var(--card);border:1px solid #d4d5ce;border-radius:22px;box-shadow:0 6px 30px #313d3514}.composer-wrap textarea{flex:1;min-width:0;min-height:38px;max-height:180px;padding:8px 0;border:0;outline:0;resize:none;background:none}.send{width:40px;height:40px;border:0;border-radius:14px;background:var(--green);color:#fff;cursor:pointer}.composer-wrap>small{color:#8a8c85;font-size:10px}.auth{min-height:100dvh;display:grid;place-items:center;padding:24px;background:radial-gradient(circle at 12% 5%,#dceadf,transparent 30%),var(--bg)}.auth-card{width:min(430px,100%);padding:30px;text-align:center;background:#fffd;border:1px solid var(--line);border-radius:24px;box-shadow:0 14px 46px #28352d17}.auth-card .brand{justify-content:center}.eyebrow{margin-top:28px;color:var(--green);text-transform:uppercase;letter-spacing:.1em;font-size:12px;font-weight:700}.auth h1{font-size:34px;margin:6px 0}.auth-card>p{color:var(--muted)}.auth form{display:grid;gap:13px;text-align:left}.auth label{display:grid;gap:5px;font-size:12px;font-weight:650}.auth input{border:1px solid var(--line);border-radius:11px;padding:12px;background:#fbfbf8}.auth form>button{border:0;border-radius:12px;padding:12px;background:var(--green);color:#fff;font-weight:700}.error{min-height:20px;text-align:center;color:var(--danger);font-size:12px}.link{color:var(--green)}.auth small{color:#92938e}.toast{position:fixed;bottom:90px;left:50%;transform:translate(-50%,10px);padding:8px 12px;background:#282b27;color:#fff;border-radius:9px;opacity:0;transition:.2s}.toast.show{opacity:1;transform:translate(-50%,0)}.scrim,.mobile{display:none}
@media(max-width:760px){.app{display:block}aside{position:fixed;z-index:20;inset:0 auto 0 0;width:min(86vw,310px);transform:translateX(-103%);transition:.2s;box-shadow:18px 0 55px #0003}aside.open{transform:none}.scrim{display:block;position:fixed;z-index:19;inset:0;background:#18221d73;opacity:0;pointer-events:none}.scrim.show{opacity:1;pointer-events:auto}.mobile{display:inline-grid;place-items:center}.topbar{height:55px;padding:0 12px}.messages{padding:24px 14px 8px}.welcome{min-height:64%;padding:12px}.welcome div{flex-direction:column}.bubble{max-width:91%}.tools{opacity:1}.composer-wrap{padding:8px 9px max(7px,env(safe-area-inset-bottom))}.auth-card{padding:24px 19px}}
@media(prefers-color-scheme:dark){:root{--bg:#171916;--side:#111310;--card:#222520;--ink:#eff1ec;--muted:#a1a39c;--line:#343832;--green:#64b88e;--soft:#253d31}.history-item{color:#c7cac3}.history-item:hover,.history-item.active,.icon:hover{background:#282b26}.bubble{background:#2b2e29}.content code:not(pre code){background:#292c27}.auth{background:radial-gradient(circle at 12% 5%,#243a2d,transparent 30%),var(--bg)}.auth-card{background:#1f221edd}.auth input{background:#191b18}.message-error{background:#321f1c;border-color:#59342e}}
.message-error strong{color:var(--ink)}.message-error .retry{margin-top:9px;border:0;border-radius:8px;background:var(--green);color:#fff;padding:7px 12px;cursor:pointer}
.progress{display:flex;align-items:center;gap:10px;min-height:32px;color:var(--muted);font-size:13px}.progress .typing{padding:0}.progress-label{animation:soft-pulse 1.8s ease-in-out infinite}.stream-cursor{display:inline-block;width:7px;height:1.05em;margin-left:3px;vertical-align:-.15em;border-radius:2px;background:var(--green);animation:cursor-blink .8s steps(1) infinite}@keyframes soft-pulse{50%{opacity:.55}}@keyframes cursor-blink{50%{opacity:0}}
.thinking-arrows{display:inline-flex;gap:2px;color:var(--green);font-weight:750;font-size:17px}.thinking-arrows i{font-style:normal;opacity:.2;animation:arrow-flow 1.15s ease-in-out infinite}.thinking-arrows i:nth-child(2){animation-delay:.18s}.thinking-arrows i:nth-child(3){animation-delay:.36s}@keyframes arrow-flow{0%,70%,100%{opacity:.2;transform:translateX(0)}35%{opacity:1;transform:translateX(2px)}}
body{font-size:16px}.history-entry{display:flex;align-items:center;min-width:0}.history-entry .history-item{flex:1;min-width:0}.history-entry .icon{flex-shrink:0}.tools{height:auto;min-height:36px;flex-wrap:wrap}.tools:focus-within{opacity:1}.tool{min-height:36px;font-size:14px}.table-scroll{overflow-x:auto;max-width:100%}table{border-collapse:collapse;width:100%;margin:1rem 0}th,td{padding:8px 12px;border:1px solid var(--line);text-align:left}th{background:var(--side)}.sources{font-size:14px;color:var(--muted);margin-top:8px}.sources a{color:var(--green)}.chat-options{text-align:left;margin-bottom:8px;font-size:14px;max-height:180px;overflow:auto}.chat-options label{display:block;margin:8px 0}.chat-options input:not([type=checkbox]){display:block;width:100%;background:var(--card);border:1px solid var(--line);padding:8px;border-radius:8px}.chat-options small{display:block}.chat-options summary{cursor:pointer}dialog{width:min(580px,94vw);max-height:88dvh;overflow:auto;border:1px solid var(--line);border-radius:18px;background:var(--bg);color:var(--ink);padding:22px}dialog::backdrop{background:#0008}dialog header{display:flex;justify-content:space-between;align-items:center}dialog h2{margin:0}dialog button{min-height:44px;cursor:pointer;border:1px solid var(--line);background:var(--card);border-radius:8px;padding:6px 12px}dialog label{display:block}dialog textarea{display:block;width:100%;min-height:80px;margin:8px 0;background:var(--card);border:1px solid var(--line);color:var(--ink);padding:8px}.memory-row{display:flex;gap:12px;align-items:center;border-bottom:1px solid var(--line);padding:10px 0}.memory-row p{flex:1;overflow-wrap:anywhere}#privacy{margin:12px 0}.toast{z-index:50;max-width:90vw;pointer-events:none}.auth label{font-size:14px}.composer-wrap>small{font-size:12px}:focus-visible{outline:2px solid var(--green);outline-offset:3px}@media(max-width:760px){input,textarea{font-size:16px}.tool,.icon{min-width:44px;min-height:44px}.chat-options{max-height:150px}.messages{scroll-behavior:auto}}@media(prefers-reduced-motion:reduce){*,*::before,*::after{animation:none!important;transition:none!important;scroll-behavior:auto!important}}

/* Keep history scrollable without compressing its rows, including the legacy markup. */
#sidebar{height:100dvh;overflow:hidden}
#sidebar>header,#sidebar>.new,#sidebar>.history-label,#sidebar>footer{flex:0 0 auto}
#sidebar>#history{flex:1 1 0;min-height:0;overflow-y:auto;overflow-x:hidden;overscroll-behavior:contain}
#history>*{flex:0 0 auto}
#history .history-item{min-height:44px;line-height:1.55}
#history .history-entry{min-height:44px}
/* Account menu sits above the fixed sidebar footer on desktop and mobile. */
#sidebar>footer{position:relative;padding:8px 0 0}
#accountToggle{display:flex;align-items:center;gap:9px;width:100%;min-width:0;padding:9px 7px;border:0;border-radius:12px;background:transparent;text-align:left;cursor:pointer}
#accountToggle:hover{background:#dfdfd8}
#accountToggle i{flex-shrink:0}
#accountToggle .account-chevron{flex:0 0 auto;font-size:18px}
.account-menu{position:absolute;bottom:calc(100% + 8px);left:0;right:0;z-index:30;padding:6px;background:var(--card);border:1px solid var(--line);border-radius:14px;box-shadow:0 8px 28px #25362b24}
.account-menu button{display:block;width:100%;min-height:44px;border:0;background:none;border-radius:8px;padding:9px 12px;text-align:left;cursor:pointer}
.account-menu button:hover,.account-menu button:focus-visible{background:var(--soft)}
.account-menu #privacy{margin:0}
.account-menu #logout{color:var(--danger);border-top:1px solid var(--line);border-radius:0 0 8px 8px}
dialog form{display:grid;gap:12px;margin-top:18px}
dialog input{display:block;width:100%;margin:6px 0 12px;padding:10px 12px;border:1px solid var(--line);border-radius:9px;background:var(--card)}
#profileError,#renameError{color:var(--danger);margin:0}

.chat-more{font-size:24px;line-height:1;font-weight:600}
#chatTitle{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;border:0;background:none;padding:5px 0;font-weight:650;text-align:left;cursor:pointer}
#chatTitle:disabled{cursor:default;color:var(--ink)}
#headingChatMore{flex-shrink:0}
.chat-actions-menu{position:fixed;z-index:100;width:160px;padding:5px;border:1px solid var(--line);border-radius:12px;background:var(--card);box-shadow:0 8px 28px #25362b24}
.chat-actions-menu button{display:block;width:100%;min-height:44px;border:0;background:none;border-radius:7px;padding:9px 12px;text-align:left;cursor:pointer}
.chat-actions-menu button:hover,.chat-actions-menu button:focus-visible{background:var(--soft)}
#chatActionDelete{color:var(--danger)}
.chat-actions-menu button:disabled{opacity:.5;cursor:default}
