:root{color-scheme:light;--bg:#f8f9f7;--fg:#242825;--muted:#92978f;--glass:#ffffffb3;--bubble:#eeefeb;--line:#e4e7df;--accent:#768568;--shadow:0 12px 35px #28331d0c}*{box-sizing:border-box}body{margin:0;background:var(--bg);color:var(--fg);font:16px/1.65 -apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif}html[data-theme=dark]{color-scheme:dark;--bg:#000000;--fg:#f2f2f2;--muted:#929292;--glass:#151515;--bubble:#1a1a1a;--line:#2b2b2b;--accent:#b6c7a5;--shadow:0 12px 35px #0002}button,input,textarea,select{font:inherit}button{cursor:pointer;color:inherit}button:focus-visible,textarea:focus-visible,input:focus-visible,select:focus-visible{outline:2px solid var(--accent);outline-offset:4px}.app{max-width:820px;margin:auto;height:100dvh;display:flex;flex-direction:column;padding-top:env(safe-area-inset-top)}header{display:flex;justify-content:space-between;align-items:center;padding:24px 25px}.circle,.identity{border:1px solid var(--line);background:var(--glass);box-shadow:var(--shadow);backdrop-filter:blur(18px);border-radius:40px}.circle{width:48px;height:48px;font-size:24px;display:grid;place-items:center}.identity{display:flex;gap:12px;align-items:center;padding:9px 22px;font-weight:600;font-size:18px}.avatar{color:var(--accent);font-size:30px;line-height:1}.dot{display:inline-block;width:6px;height:6px;background:#81a978;border-radius:50%;margin:0 0 2px 9px}main{flex:1;overflow-y:auto;padding:24px 25px;scroll-behavior:smooth}.welcome{max-width:480px;margin:clamp(24px,12vh,130px) auto 30px}.eyebrow{font-size:11px;letter-spacing:3px;color:var(--muted)}h1{font-size:34px;line-height:1.4;font-weight:500;letter-spacing:-1px;margin:16px 0}p{margin:10px 0}.welcome p{color:var(--muted);font-size:15px}.suggestions{display:grid;gap:10px;margin-top:30px}.suggestions button{border:1px solid var(--line);border-radius:18px;background:var(--glass);text-align:left;padding:15px 18px;font-size:14px;display:flex;justify-content:space-between}.suggestions span{color:var(--muted)}.message{white-space:pre-wrap;overflow-wrap:anywhere;max-width:89%;padding:15px 19px;margin:0 0 18px;border-radius:23px;background:var(--bubble);width:fit-content}.message.user{margin-left:auto;background:var(--fg);color:var(--bg);border-bottom-right-radius:7px}.message.assistant{border-bottom-left-radius:7px}.label{text-align:center;color:var(--muted);font-size:12px;margin:5px 0 26px}footer{padding:8px 25px max(15px,env(safe-area-inset-bottom));background:var(--bg)}#status{font-size:12px;color:var(--muted);padding-left:4px;min-height:20px}form{display:flex;align-items:flex-end;gap:12px}.input-wrap{display:flex;align-items:flex-end;flex:1;gap:10px;background:var(--glass);border:1px solid var(--line);border-radius:30px;box-shadow:var(--shadow);padding:7px 8px 7px 20px}textarea{resize:none;flex:1;min-width:0;border:0;outline:0;background:transparent;color:var(--fg);padding:7px 0;max-height:130px}textarea::placeholder{color:var(--muted)}#send{border:0;background:var(--fg);color:var(--bg);border-radius:50%;width:38px;height:38px;font-size:24px;flex-shrink:0}small{display:block;text-align:center;color:var(--muted);font-size:10px;margin-top:12px}dialog{color:var(--fg);background:var(--bg);border:1px solid var(--line);border-radius:26px;width:min(440px,calc(100% - 30px));padding:23px;max-height:85dvh}dialog::backdrop{background:#0005;backdrop-filter:blur(5px)}.panel-head{display:flex;align-items:center;justify-content:space-between;margin-bottom:22px}h2{font-size:20px;margin:0}label{display:block;font-size:14px;margin:18px 0 7px}select,input{width:100%;padding:12px;border-radius:12px;border:1px solid var(--line);background:var(--glass);color:var(--fg)}.save,.session{width:100%;border:1px solid var(--line);border-radius:12px;padding:12px;margin-top:12px;background:var(--bubble);text-align:left}.save{text-align:center;background:var(--fg);color:var(--bg)}.hint{font-size:12px;color:var(--muted)}@media(max-width:480px){header{padding:18px 19px}main{padding:15px 19px}footer{padding-left:17px;padding-right:17px}h1{font-size:30px}}
header{display:grid;grid-template-columns:1fr auto 1fr}.header-actions{display:flex;justify-self:end;gap:10px}header>.identity{grid-column:2}#theme-toggle svg{width:23px;height:23px;fill:none;stroke:currentColor;stroke-width:1.7;stroke-linecap:round;stroke-linejoin:round}@media(max-width:380px){.header-actions{gap:6px}header .circle{width:40px;height:40px}header .identity{padding:9px 13px;gap:8px}}

.message.has-usage{margin-bottom:5px}.token-usage{color:var(--muted);font-size:11px;line-height:1.6;margin:0 0 22px 4px;max-width:89%;overflow-wrap:anywhere}

/* Compact top navigation */
header .circle{width:42px;height:42px;font-size:21px}header .identity{padding:7px 18px;font-size:16px;gap:10px}header .avatar{display:flex;align-items:center}header .avatar svg{width:28px;height:28px}#theme-toggle svg{width:21px;height:21px}@media(max-width:380px){header .circle{width:38px;height:38px}header .identity{padding:7px 12px;gap:7px}}

[hidden]{display:none!important}
#history-page{height:100dvh;background:var(--bg);color:var(--fg);padding-top:env(safe-area-inset-top)}
.history-shell{max-width:820px;height:100%;margin:auto;display:flex;flex-direction:column}
.history-header{display:flex;align-items:center;justify-content:space-between;padding:20px 25px;flex-shrink:0}
.history-header h2{font-size:18px;font-weight:500}
.history-header .circle{width:42px;height:42px;box-shadow:none}
#history-list{flex:1;min-height:0;overflow-y:auto;padding:10px 25px max(24px,env(safe-area-inset-bottom))}
.history-item{display:block;width:100%;padding:20px 4px;border:0;border-bottom:1px solid var(--line);background:transparent;text-align:left}
.history-item>span{display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.history-preview{font-size:13px;color:var(--muted);margin-top:6px}
.history-clear{display:block;margin:30px auto 0;background:transparent;border:0;color:var(--muted);font-size:13px;padding:12px}
#history-page.is-empty{background:#fff;color:#242825;position:relative}
.is-empty .history-header{position:relative;z-index:1}
.is-empty .circle{background:#fff;color:#242825;border-color:#e4e7df}
.is-empty #history-list{display:flex;align-items:center;justify-content:center;position:absolute;inset:0;padding:80px 24px;pointer-events:none}
.history-empty{text-align:center;font-size:15px;color:#929292}

/* Keep the app shell fixed while allowing vertical content scrolling. */
html,body{width:100%;height:100%;overflow:hidden;overscroll-behavior:none}
body{touch-action:pan-y}
.app,#history-page{width:100%;overflow:hidden}
main,#history-list,dialog{overscroll-behavior-y:contain;touch-action:pan-y;-webkit-overflow-scrolling:touch}
button{touch-action:manipulation}
input,textarea,select{font-size:16px}
header,footer{flex-shrink:0}
main{min-height:0}
#input:focus,#input:focus-visible{outline:none;border:0;box-shadow:none}

.app{position:relative;isolation:isolate}
#chat-background{position:absolute;inset:-65px;z-index:-3;background-position:center;background-size:cover;pointer-events:none}
.app::before{content:'';position:absolute;inset:0;z-index:-2;pointer-events:none}
.app.custom-background::before{background:rgba(255,255,255,.32)}
html[data-theme=dark] .app.custom-background::before{background:rgba(0,0,0,.4)}
.app::after{content:'';position:absolute;inset:0;z-index:-1;pointer-events:none;opacity:.22}
.app[data-texture=paper]::after{background-image:radial-gradient(var(--fg) .6px,transparent .8px);background-size:5px 5px}
.app[data-texture=grid]::after{background-image:linear-gradient(var(--muted) 1px,transparent 1px),linear-gradient(90deg,var(--muted) 1px,transparent 1px);background-size:24px 24px;opacity:.14}
.app[data-texture=linen]::after{background-image:repeating-linear-gradient(0deg,var(--muted) 0 1px,transparent 1px 4px),repeating-linear-gradient(90deg,var(--muted) 0 1px,transparent 1px 7px);opacity:.12}
.custom-background footer{background:var(--glass);backdrop-filter:blur(12px)}
.custom-background .welcome{padding:22px;border-radius:24px;background:var(--glass);backdrop-filter:blur(10px)}
.background-settings{border-top:1px solid var(--line);margin-top:24px;padding-top:12px}.background-settings h3{font-size:16px;font-weight:500}
.background-choices{display:flex;gap:10px}.background-choices button{flex:1;padding:11px;border:1px solid var(--line);border-radius:12px;background:var(--bubble)}
#background-blur{padding:0;border:0;box-shadow:none;accent-color:var(--accent);height:32px;touch-action:auto}#blur-value{float:right;color:var(--muted)}

/* Full-viewport wallpaper with lightweight translucent controls. */
body:has(.custom-background){background:transparent}
.app.custom-background{isolation:auto;overflow:visible}
.custom-background #chat-background{position:fixed;inset:-40px;z-index:-3}
.app.custom-background::before,.app.custom-background::after{position:fixed}
.app.custom-background::before{background:rgba(255,255,255,.08)}
html[data-theme=dark] .app.custom-background::before{background:rgba(0,0,0,.16)}
.custom-background footer{background:transparent;backdrop-filter:none}
.custom-background .circle,.custom-background .identity,.custom-background .input-wrap,.custom-background .suggestions button{background:rgba(255,255,255,.3);border-color:rgba(255,255,255,.35);backdrop-filter:blur(12px);-webkit-backdrop-filter:blur(12px);box-shadow:none}
.custom-background .message.assistant{background:rgba(255,255,255,.58);backdrop-filter:blur(10px);-webkit-backdrop-filter:blur(10px)}
.custom-background .message.user{background:rgba(25,29,25,.7);color:#fff;backdrop-filter:blur(10px);-webkit-backdrop-filter:blur(10px)}
.custom-background .welcome{background:transparent;backdrop-filter:none;padding:0}
.custom-background #status,.custom-background footer small,.custom-background .label,.custom-background .token-usage{color:var(--fg);text-shadow:0 1px 3px var(--bg)}
html[data-theme=dark] .custom-background .circle,html[data-theme=dark] .custom-background .identity,html[data-theme=dark] .custom-background .input-wrap,html[data-theme=dark] .custom-background .suggestions button{background:rgba(0,0,0,.28);border-color:rgba(255,255,255,.16)}
html[data-theme=dark] .custom-background .message.assistant{background:rgba(0,0,0,.48)}
#auth-page{position:fixed;inset:0;background:#fff;color:#242825;z-index:10;display:grid;place-items:center;overflow-y:auto;padding:40px 24px;color-scheme:light}
.auth-card{width:min(100%,340px);text-align:center;margin:auto}#auth-logo svg{width:72px;height:72px;color:#768568}.auth-card h1{font-size:28px;margin:12px 0 0}.auth-subtitle{color:#92978f;font-size:14px;margin-bottom:32px}
#auth-actions{display:flex;gap:14px}#auth-page button{border:1px solid #e0e4dd;border-radius:24px;padding:12px 20px;background:#fff;color:#242825;flex:1}#auth-page #open-login,#auth-page #auth-submit{background:#242825;color:#fff}#auth-form{display:block;text-align:left}#auth-form input{background:#f7f8f5;color:#242825;border-color:#e0e4dd}#auth-form label{color:#555}#auth-submit,#auth-back{width:100%;margin-top:18px}#auth-status{font-size:13px;color:#7c5e50;min-height:24px}#auth-form .hint{color:#92978f}#auth-page button:disabled{opacity:.5}
