:root{--app-font:"Inter";
  --bg:#f7f8fb;--panel:#ffffff;--panel-2:#f3f5f8;--panel-3:#eef1f5;--line:#e2e6ec;
  --text:#171a21;--muted:#697386;--soft:#4f596a;--accent:#1b1f27;--shadow:0 24px 80px rgba(20,30,50,.12);
  font-family:var(--app-font),ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;color:var(--text);background:var(--bg);
}
*{box-sizing:border-box}
html,body{margin:0;min-height:100%;background:var(--bg)}
body{overflow:hidden}
button,select,textarea,input{font:inherit}
button{color:inherit}
.hidden,.app-hidden{display:none!important}
#app{min-height:100vh;display:flex;background:radial-gradient(circle at 70% 18%,rgba(100,120,160,.08),transparent 30%),var(--bg)}

.brand{display:flex;align-items:center;gap:10px;font-size:19px;font-weight:750;letter-spacing:-.03em}
.brand-accent{opacity:.58}
.brand-mark{width:35px;height:35px;display:grid;place-items:center;border-radius:11px;background:#171a20;color:#fff;font-weight:850;box-shadow:0 5px 18px rgba(20,30,50,.12)}
.auth-brand{font-size:21px;margin-bottom:20px}
.auth-gate{position:relative;min-height:100vh;display:grid;place-items:center;padding:22px;background:radial-gradient(circle at 50% 20%,rgba(120,145,190,.12),transparent 34%),#f7f8fb}
.auth-card{position:relative;width:min(430px,100%);padding:34px;border:1px solid #e0e4ea;border-radius:24px;background:rgba(255,255,255,.96);box-shadow:var(--shadow);overflow:hidden;backdrop-filter:blur(18px)}
.auth-glow{position:absolute;width:180px;height:180px;right:-100px;top:-100px;border-radius:50%;background:rgba(100,125,170,.08);filter:blur(10px)}
.auth-kicker,.eyebrow{font-size:10px;font-weight:750;letter-spacing:.16em;color:#7b8494}
.auth-card h1{font-size:31px;line-height:1.08;letter-spacing:-.045em;margin:0 0 9px;color:#151922}
.auth-card>p{color:#697386;margin:0 0 25px;font-size:14px}
.auth-card form{display:grid;gap:14px}
.auth-card label{display:grid;gap:7px;color:#596375;font-size:12px;font-weight:600}
.auth-card input{width:100%;padding:13px 14px;border:1px solid #d9dee6;border-radius:12px;background:#fff;color:#171a21;outline:none;transition:.18s}
.auth-card input:focus{border-color:#7c8799;box-shadow:0 0 0 3px rgba(100,120,150,.1)}
.auth-link,.auth-switch{border:0;background:transparent;cursor:pointer}
.auth-link{color:#596579;text-align:right;font-size:12px;padding:4px 0}
.auth-link:hover,.auth-switch:hover{color:#171a21}
.google-divider{display:flex;align-items:center;gap:12px;color:#8a93a1;font-size:9px;font-weight:700;letter-spacing:.14em;margin:17px 0 13px}
.google-divider:before,.google-divider:after{content:"";height:1px;background:#e1e5eb;flex:1}
.google-button{display:flex;justify-content:center;min-height:40px}
.auth-submit{width:100%;display:flex;align-items:center;justify-content:space-between;border:0;border-radius:12px;padding:13px 15px;background:#171a20;color:#fff;font-weight:750;cursor:pointer;margin-top:2px;transition:transform .15s,box-shadow .15s}
.auth-submit:hover{transform:translateY(-1px);box-shadow:0 10px 25px rgba(20,30,50,.14)}
.auth-submit:disabled{opacity:.6;cursor:wait;transform:none}
.button-arrow{font-size:17px}
.auth-switch{width:100%;color:#596579;padding:13px 4px 6px;font-size:13px}
.auth-message{min-height:20px;margin:14px 0 0;color:#697386;font-size:12px;line-height:1.5}
.auth-message.error{color:#c43b3b}
.auth-foot{text-align:center;color:#8a93a1;font-size:10px;margin-top:20px}

.sidebar{width:270px;flex:none;padding:15px 13px;background:rgba(255,255,255,.96);border-right:1px solid #e1e5eb;display:flex;flex-direction:column;gap:16px}
.sidebar-head{display:flex;align-items:center;justify-content:space-between;padding:1px 5px}
.new-chat{width:100%;display:flex;align-items:center;gap:10px;border:1px solid #d9dee6;background:linear-gradient(180deg,#fff,#f5f7fa);padding:12px;border-radius:13px;text-align:left;cursor:pointer;transition:.18s;color:#20242c}
.new-chat:hover{border-color:#bfc7d3;background:#f2f4f7}
.new-chat-icon{font-size:20px;line-height:1;color:#303641}
.new-chat kbd{margin-left:auto;color:#8a93a1;font-size:10px;border:1px solid #d9dee6;padding:2px 5px;border-radius:5px}
.sidebar-section{flex:1;min-height:0;color:#697386;font-size:12px;overflow:auto}
.section-label{display:flex;align-items:center;justify-content:space-between;padding:3px 7px 8px;color:#8992a1;text-transform:uppercase;letter-spacing:.12em;font-size:9px;font-weight:750}
.history{display:grid;gap:4px}
.history-item{
  width:100%;padding:9px 10px;border:1px solid transparent;border-radius:9px;
  background:transparent;color:#596579;text-align:left;font:500 11px/1.35 var(--app-font,ui-sans-serif,system-ui,sans-serif);
  overflow:hidden;text-overflow:ellipsis;white-space:nowrap;cursor:pointer;
}
.history-item:hover{background:#eef1f5;color:#171a21}
.history-item.active{background:#e7ebf1;border-color:#d5dbe4;color:#171a21;font-weight:700}
.empty-history{padding:16px 9px;color:#98a0ad;font-size:11px;line-height:1.5}
.control-card{display:grid;gap:10px;padding:11px;border:1px solid #e1e5eb;border-radius:14px;background:linear-gradient(180deg,#fafbfc,#f3f5f8)}
.sidebar label{display:grid;gap:6px;color:#7b8493;font-size:9px;font-weight:750;text-transform:uppercase;letter-spacing:.09em}
.sidebar select{width:100%;background:#fff;border:1px solid #d9dee6;color:#303641;border-radius:9px;padding:9px 10px;outline:none;font-size:12px;text-transform:none;letter-spacing:normal}
.account{display:flex;align-items:center;gap:10px;border-top:1px solid #e1e5eb;padding:13px 4px 1px}
.account-avatar{width:33px;height:33px;display:grid;place-items:center;border-radius:10px;background:#171a20;color:#fff;font-size:12px;font-weight:800}
.account-info{min-width:0;display:grid;gap:2px;flex:1}
.account-info strong{font-size:11px;color:#303641}
.account-info span{font-size:10px;color:#8992a1;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.logout-button{width:31px;height:31px;border:1px solid #d9dee6;background:transparent;color:#697386;border-radius:9px;cursor:pointer;font-size:17px;line-height:1;display:grid;place-items:center;flex:none}
.logout-button:hover{color:#171a21;border-color:#b9c2cf}

.icon-button{border:0;background:transparent;color:#596579;cursor:pointer}
.mobile-only{display:none}

.main{position:relative;flex:1;min-width:0;height:100vh;display:flex;flex-direction:column;background:radial-gradient(circle at 50% 5%,rgba(100,120,160,.05),transparent 28%)}
.topbar{height:62px;flex:none;border-bottom:1px solid #e1e5eb;display:flex;align-items:center;padding:0 22px;gap:13px;background:rgba(255,255,255,.82);backdrop-filter:blur(14px);z-index:2}
.topbar-title{display:flex;align-items:center;gap:10px;font-size:14px}
.topbar-mark{width:24px;height:24px;display:grid;place-items:center;border-radius:7px;background:#171a20;color:#fff;font-size:10px;font-weight:850}
.model-chip{font-size:8px;letter-spacing:.13em;color:#8992a1;border:1px solid #e1e5eb;border-radius:20px;padding:4px 7px}
.topbar-controls{margin-left:auto;display:flex;align-items:center;gap:12px}
.model-pill{display:flex;align-items:center;gap:7px;border:1px solid #e1e5eb;background:#fff;border-radius:999px;padding:6px 10px;color:#697386;font-size:10px}
.model-pulse{width:6px;height:6px;border-radius:50%;background:#8792a4}
.status-wrap{display:flex;align-items:center;gap:7px;color:#697386;font-size:10px;padding:6px 9px;border:1px solid transparent;border-radius:999px}
.status-dot{width:6px;height:6px;border-radius:50%;background:#4e9b68;box-shadow:0 0 0 3px rgba(78,155,104,.1)}

.messages{flex:1;overflow:auto;padding:38px 22px 215px;scroll-behavior:smooth}
.welcome{width:min(860px,100%);margin:9vh auto 0;text-align:center}
.hero-orbit{position:relative;width:70px;height:70px;margin:0 auto 25px;display:grid;place-items:center}
.hero-mark{width:52px;height:52px;display:grid;place-items:center;border-radius:17px;background:#171a20;color:#fff;font-size:21px;font-weight:850;box-shadow:0 12px 32px rgba(20,30,50,.16)}
.orbit{position:absolute;border:1px solid #cfd5de;border-radius:50%;inset:0;opacity:.9}
.orbit-a{transform:rotate(38deg) scale(.82,1.14)}
.orbit-b{transform:rotate(-38deg) scale(.82,1.14)}
.welcome h1{font-size:clamp(34px,5vw,54px);line-height:1.02;letter-spacing:-.06em;margin:10px 0 14px;font-weight:760;color:#171a21}
.welcome h1 span{color:#7b8494}
.welcome>p{max-width:570px;margin:0 auto;color:#697386;font-size:14px;line-height:1.6}
.prompt-grid{display:grid;grid-template-columns:repeat(2,1fr);gap:9px;margin:30px auto 0;max-width:720px;text-align:left}
.prompt-card{min-height:72px;display:flex;align-items:center;gap:11px;padding:11px 12px;border:1px solid #e1e5eb;border-radius:14px;background:rgba(255,255,255,.82);cursor:pointer;transition:.18s;color:#303641}
.prompt-card:hover{transform:translateY(-2px);border-color:#c3cbd6;background:#fff;box-shadow:0 12px 30px rgba(20,30,50,.08)}
.prompt-icon{width:31px;height:31px;display:grid;place-items:center;border-radius:9px;background:#eef1f5;color:#4e5868;font-size:12px;flex:none}
.prompt-card span:nth-child(2){display:grid;gap:3px;min-width:0}
.prompt-card strong{font-size:11px;color:#303641}
.prompt-card small{font-size:10px;color:#8992a1;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.prompt-card b{margin-left:auto;color:#8992a1;font-size:13px}

.message{width:min(900px,100%);margin:0 auto 28px;display:flex;gap:12px;align-items:flex-start}
.role{width:31px;height:31px;flex:none;display:grid;place-items:center;border-radius:10px;background:#eef1f5;color:#4a5362;font-size:10px;font-weight:800;box-shadow:0 4px 15px rgba(20,30,50,.08)}
.bubble{max-width:calc(100% - 45px);padding:13px 16px;border:1px solid #e1e5eb;border-radius:6px 16px 16px 16px;background:#fff;line-height:1.65;white-space:pre-wrap;overflow-wrap:anywhere;color:#303641;font-size:var(--chat-font-size,13px)}
.user .bubble{margin-left:auto;border-color:#d5dbe4;background:#f0f3f7;border-radius:16px 6px 16px 16px;color:#242932}
.bubble h1,.bubble h2,.bubble h3{margin:0 0 9px;line-height:1.25;letter-spacing:-.02em}
.bubble h1{font-size:18px}.bubble h2{font-size:16px}.bubble h3{font-size:14px}
.bubble p{margin:0 0 10px}.bubble p:last-child{margin-bottom:0}
.bubble ul,.bubble ol{margin:7px 0 10px;padding-left:20px}
.bubble li{margin:4px 0}
.bubble strong{color:#171a21;font-weight:750}
.bubble code{font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:.9em;padding:2px 5px;border-radius:5px;background:#eef1f5;color:#3b4452}
.sources{display:grid;gap:6px;margin-top:14px;padding-top:11px;border-top:1px solid #e5e8ed}
.sources-title{font-size:9px;text-transform:uppercase;letter-spacing:.12em;color:#8992a1;font-weight:750}
.source-link{display:block;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:#596579;text-decoration:none;font-size:10px;padding:6px 8px;border:1px solid #dce1e8;border-radius:8px;background:#f7f8fa;transition:.15s}
.source-link:hover{color:#171a21;border-color:#bfc7d3;background:#fff}

.composer{position:fixed;z-index:3;bottom:25px;left:calc(270px + (100% - 270px)/2);transform:translateX(-50%);width:min(850px,calc(100% - 320px));margin:0;padding:0;background:transparent}
.composer-inner{border:1px solid #cfd6e0;border-radius:20px;background:rgba(255,255,255,.96);box-shadow:0 18px 55px rgba(20,30,50,.13);backdrop-filter:blur(18px);padding:12px 13px 10px}
.composer textarea{width:100%;resize:none;display:block;background:transparent;border:0;outline:0;color:#171a21;padding:4px 5px 10px;min-height:31px;max-height:160px;line-height:1.5;font-size:var(--chat-font-size,14px)}
.composer textarea::placeholder{color:#8a93a1}
.composer-footer{display:flex;align-items:center;justify-content:space-between;gap:10px}
.composer-tools{display:flex;align-items:center;gap:6px}
.tool-button{height:32px;display:flex;align-items:center;gap:5px;border:1px solid #d9dee6;border-radius:10px;background:#f5f7fa;color:#596579;padding:0 9px;cursor:pointer;font-size:11px}
.tool-button:hover{background:#eef1f5;color:#171a21}
.image-tool{font-size:10px}
.tool-hint{color:#8992a1;font-size:9px;margin-left:5px}
.send{width:36px;height:36px;display:grid;place-items:center;border:0;border-radius:11px;background:#171a20;color:#fff;font-size:17px;font-weight:700;cursor:pointer;transition:.15s}
.send:hover{transform:translateY(-1px)}
.send:disabled,.image-tool:disabled{opacity:.45;cursor:wait}
.attachment{font-size:10px;color:#697386;padding:7px 8px;margin:0 0 5px;border:1px solid #dce1e8;border-radius:9px;background:#f7f8fa;display:inline-block}
.hint{position:fixed;z-index:1;bottom:6px;left:270px;right:0;text-align:center;font-size:9px;color:#8992a1}

.sidebar-section::-webkit-scrollbar,.messages::-webkit-scrollbar{width:6px}
.sidebar-section::-webkit-scrollbar-thumb,.messages::-webkit-scrollbar-thumb{background:#d8dde5;border-radius:99px}
.sidebar-overlay{display:none}
.file-queue{display:flex;flex-wrap:wrap;gap:6px;padding:5px 4px 8px}
.file-chip{display:flex;align-items:center;gap:7px;max-width:100%;padding:6px 8px;border:1px solid #d9dee6;border-radius:9px;background:#f5f7fa;color:#596579;font-size:10px}
.file-chip-name{max-width:180px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.file-chip-size{color:#8992a1}
.file-chip-remove{width:18px;height:18px;border:0;border-radius:5px;background:#e7ebf0;color:#697386;cursor:pointer;display:grid;place-items:center;padding:0}
.file-chip-remove:hover{background:#dce1e8;color:#171a21}
.file-success{color:#438556}
::selection{background:#dfe5ee;color:#171a21}
button:focus-visible,select:focus-visible,textarea:focus-visible,input:focus-visible{outline:2px solid #7b8798;outline-offset:2px}
.control-card label select{font-family:var(--app-font),ui-sans-serif,system-ui,sans-serif}
.bubble,.composer textarea,.prompt-card,.auth-card input{font-family:var(--app-font),ui-sans-serif,system-ui,sans-serif}

@media(max-width:900px){
  .sidebar{width:252px}
  .composer{left:calc(252px + (100% - 252px)/2);width:min(780px,calc(100% - 292px))}
  .hint{left:252px}
}
@media(max-width:760px){
  body{overflow:hidden}
  .sidebar{position:fixed;z-index:10;inset:0 auto 0 0;width:min(310px,88vw);transform:translateX(-102%);transition:transform .22s ease;box-shadow:20px 0 60px rgba(20,30,50,.16);padding:16px 14px}
  .sidebar.open{transform:none}.mobile-only{display:block;font-size:26px;line-height:1}
  .sidebar-overlay{position:fixed;inset:0;z-index:9;background:rgba(30,40,55,.18);backdrop-filter:blur(3px);opacity:0;pointer-events:none;display:block;transition:.2s}
  .sidebar-overlay.open{opacity:1;pointer-events:auto}
  .topbar{height:58px;padding:0 13px}
  .topbar-controls{gap:7px}
  .model-pill{padding:6px 8px}
  .status-wrap{padding:5px 7px}
  .messages{padding:24px 12px 190px}
  .welcome{margin-top:5vh}
  .welcome h1{font-size:34px}
  .welcome>p{font-size:12px}
  .prompt-grid{grid-template-columns:1fr;margin-top:25px}
  .prompt-card{min-height:64px}
  .message{gap:9px;margin-bottom:21px}
  .role{width:29px;height:29px}
  .bubble{max-width:calc(100% - 38px);font-size:13px;padding:11px 13px}
  .composer{left:50%;bottom:18px;width:calc(100% - 16px)}
  .composer-inner{border-radius:17px;padding:9px 9px 8px}
  .composer textarea{font-size:14px}
  .tool-hint{display:none}
  .hint{left:0;bottom:2px}
  .image-tool span{display:inline}
  .auth-card{padding:27px 22px;border-radius:20px}.auth-card h1{font-size:28px}
}
@media(max-width:430px){
  .topbar-title strong{font-size:13px}
  .model-pill{display:none}
  .welcome h1{font-size:31px}
  .prompt-card small{max-width:170px}
  .auth-gate{padding:14px}.auth-card{padding:24px 19px}
  .file-chip-name{max-width:145px}
}

/* Theme + workspace background controls */
:root{--workspace-bg:radial-gradient(circle at 50% 5%,rgba(100,120,160,.07),transparent 30%),#f7f8fb}
html[data-background="solid"]{--workspace-bg:#f7f8fb}
html[data-background="soft"]{--workspace-bg:radial-gradient(circle at 50% 5%,rgba(100,120,160,.08),transparent 32%),linear-gradient(135deg,#f8f9fc,#eef2f7)}
html[data-background="blue"]{--workspace-bg:linear-gradient(135deg,#eef6ff 0%,#f4f1ff 48%,#edf7f5 100%)}
html[data-background="violet"]{--workspace-bg:linear-gradient(135deg,#f5efff 0%,#eef2ff 52%,#f9f4ff 100%)}
html[data-background="sunset"]{--workspace-bg:linear-gradient(135deg,#fff5ed 0%,#fff8e9 48%,#f5efff 100%)}
#app,.main{background:var(--workspace-bg)}
.sidebar-head-actions{display:flex;align-items:center;gap:4px}
.desktop-collapse{width:30px;height:30px;border:1px solid #d9dee6;border-radius:9px;background:#f5f7fa;color:#697386;font-size:20px;line-height:1}
.desktop-collapse:hover{background:#eef1f5;color:#171a21}
.sidebar{transition:width .24s ease,padding .24s ease,transform .22s ease}
body.sidebar-collapsed .sidebar{width:0;padding-left:0;padding-right:0;border-right:0;overflow:hidden}
body.sidebar-collapsed .sidebar>*{opacity:0;pointer-events:none}
body.sidebar-collapsed .composer{left:50%;width:min(850px,calc(100% - 40px))}
body.sidebar-collapsed .hint{left:0}
.message-files{display:flex;flex-wrap:wrap;gap:6px;margin-top:11px;padding-top:10px;border-top:1px solid #e5e8ed}
.message-file{display:inline-flex;align-items:center;max-width:260px;padding:6px 9px;border:1px solid #d9dee6;border-radius:9px;background:#f7f8fa;color:#596579;font-size:10px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
body.sidebar-collapsed .topbar{padding-left:16px}
@media(max-width:760px){
  body.sidebar-collapsed .sidebar{width:min(310px,88vw);padding:16px 14px}
  body.sidebar-collapsed .sidebar>*{opacity:1;pointer-events:auto}
  body.sidebar-collapsed .composer{left:50%;width:calc(100% - 16px)}
}
@media(prefers-color-scheme:dark){
  html[data-theme="system"]{
    --bg:#080b10;--panel:#0d121a;--panel-2:#121925;--panel-3:#171f2c;--line:#252f40;
    --text:#f5f7fb;--muted:#8995a9;--soft:#b9c4d5;--workspace-bg:radial-gradient(circle at 50% 5%,rgba(93,113,150,.055),transparent 28%),#080b10;
  }
}
html[data-theme="dark"]{
  --bg:#080b10;--panel:#0d121a;--panel-2:#121925;--panel-3:#171f2c;--line:#252f40;
  --text:#f5f7fb;--muted:#8995a9;--soft:#b9c4d5;
  --workspace-bg:radial-gradient(circle at 50% 5%,rgba(93,113,150,.055),transparent 28%),#080b10;
}
html[data-theme="dark"] body,html[data-theme="dark"]{background:#080b10;color:#f5f7fb}
html[data-theme="dark"] .sidebar{background:rgba(10,14,20,.98);border-right-color:#1e2634}
html[data-theme="dark"] .new-chat{border-color:#30394b;background:linear-gradient(180deg,#171e2b,#141a25);color:#dce3ee}
html[data-theme="dark"] .control-card{border-color:#20293a;background:linear-gradient(180deg,#101621,#0e141d)}
html[data-theme="dark"] .sidebar select{background:#171e2b;border-color:#293345;color:#dce3ee}
html[data-theme="dark"] .topbar{background:rgba(8,11,16,.78);border-bottom-color:#1d2533}
html[data-theme="dark"] .topbar-mark,html[data-theme="dark"] .brand-mark,html[data-theme="dark"] .hero-mark{background:#f3f5f8;color:#0b0e14}
html[data-theme="dark"] .model-pill{background:#101621;border-color:#263143;color:#aeb9ca}
html[data-theme="dark"] .model-chip{border-color:#242d3c;color:#657186}
html[data-theme="dark"] .welcome h1{color:#f5f7fb}
html[data-theme="dark"] .welcome h1 span{color:#8e9bb0}
html[data-theme="dark"] .welcome>p{color:#7f8a9e}
html[data-theme="dark"] .prompt-card{background:rgba(14,19,28,.72);border-color:#222c3b;color:#dbe2ed}
html[data-theme="dark"] .prompt-card:hover{background:#141b27;border-color:#3a465b}
html[data-theme="dark"] .prompt-icon{background:#1a2230;color:#c9d3e4}
html[data-theme="dark"] .prompt-card strong{color:#dbe2ed}
html[data-theme="dark"] .prompt-card small{color:#6f7b8e}
html[data-theme="dark"] .role{background:#1b2331;color:#d7dfec}
html[data-theme="dark"] .bubble{background:#101721;border-color:#202a3a;color:#dce3ee}
html[data-theme="dark"] .user .bubble{background:#192231;border-color:#293448;color:#eef2f8}
html[data-theme="dark"] .bubble strong{color:#fff}
html[data-theme="dark"] .bubble code{background:#1a2330;color:#d8e0ee}
html[data-theme="dark"] .message-files{border-top-color:#252f40}
html[data-theme="dark"] .message-file{background:#151c28;border-color:#293448;color:#b9c4d5}
html[data-theme="dark"] .composer-inner{background:rgba(14,19,28,.96);border-color:#354156}
html[data-theme="dark"] .composer textarea{color:#f2f5f9}
html[data-theme="dark"] .composer textarea::placeholder{color:#69758a}
html[data-theme="dark"] .tool-button{background:#151c28;border-color:#283245;color:#aeb9cb}
html[data-theme="dark"] .attachment,html[data-theme="dark"] .file-chip{background:#151c28;border-color:#293448;color:#b9c4d5}
html[data-theme="dark"] .file-chip-size{color:#68758a}
html[data-theme="dark"] .file-chip-remove{background:#202a3a;color:#9ca8ba}
html[data-theme="dark"] .source-link{background:#151c28;border-color:#273244;color:#aebbd0}
html[data-theme="dark"] .desktop-collapse{background:#151c28;border-color:#293448;color:#aeb9cb}
html[data-theme="dark"] .auth-gate{background:#080b10}
html[data-theme="dark"] .auth-card{background:rgba(14,18,26,.94);border-color:#283143}
html[data-theme="dark"] .auth-card h1{color:#f5f7fb}
html[data-theme="dark"] .auth-card>p,html[data-theme="dark"] .auth-message{color:#8995a9}
html[data-theme="dark"] .auth-card label{color:#aeb8c9}
html[data-theme="dark"] .auth-card input{background:#121824;border-color:#2b3446;color:#fff}
html[data-theme="dark"] .auth-switch,html[data-theme="dark"] .auth-link{color:#b9c4d7}
html[data-theme="dark"] .auth-foot{color:#596579}
html[data-theme="dark"] .auth-submit{background:#f4f6fa;color:#090c12}


/* Stronger theme contrast and visible transitions */
html,body,#app,.sidebar,.main,.topbar,.auth-gate,.auth-card,.control-card,.bubble,.composer-inner,.prompt-card,.sidebar select,.new-chat,.tool-button,.file-chip,.source-link{
  transition:background .25s ease,color .25s ease,border-color .25s ease,box-shadow .25s ease;
}

/* Make theme changes unmistakable */
html[data-theme="light"] .sidebar{background:#ffffff;border-right-color:#cfd6e0}
html[data-theme="light"] .topbar{background:rgba(255,255,255,.96);border-bottom-color:#cfd6e0}
html[data-theme="light"] .control-card{background:#f0f3f7;border-color:#cbd3de}
html[data-theme="light"] .sidebar select{background:#ffffff;border-color:#c4ccd8;color:#202630}
html[data-theme="light"] .composer-inner{background:rgba(255,255,255,.98);border-color:#bfc8d5}
html[data-theme="light"] .bubble{background:#ffffff;border-color:#cfd7e2}
html[data-theme="light"] .user .bubble{background:#e8edf4;border-color:#c4cedb}

/* Dark mode: stronger, clearly visible inversion */
html[data-theme="dark"]{
  --bg:#05070b;
  --text:#f8fafc;
  --muted:#a7b1c2;
  --soft:#c9d2df;
}
html[data-theme="dark"] #app,
html[data-theme="dark"] .main{
  background:var(--workspace-bg)!important;
}
html[data-theme="dark"] .sidebar{
  background:#0b1018!important;
  border-right-color:#303b4d!important;
}
html[data-theme="dark"] .topbar{
  background:#080d14!important;
  border-bottom-color:#303b4d!important;
}
html[data-theme="dark"] .control-card{
  background:#121a25!important;
  border-color:#354154!important;
}
html[data-theme="dark"] .sidebar select{
  background:#1a2432!important;
  border-color:#445166!important;
  color:#f3f6fa!important;
}
html[data-theme="dark"] .new-chat{
  background:#151e2a!important;
  border-color:#3d495c!important;
  color:#f3f6fa!important;
}
html[data-theme="dark"] .new-chat:hover,
html[data-theme="dark"] .prompt-card:hover,
html[data-theme="dark"] .tool-button:hover{
  background:#202b3a!important;
}
html[data-theme="dark"] .welcome h1,
html[data-theme="dark"] .topbar-title,
html[data-theme="dark"] .brand,
html[data-theme="dark"] .sidebar label,
html[data-theme="dark"] .section-label{
  color:#f8fafc!important;
}
html[data-theme="dark"] .welcome>p,
html[data-theme="dark"] .sidebar-section,
html[data-theme="dark"] .sidebar label span,
html[data-theme="dark"] .tool-hint{
  color:#aab5c6!important;
}
html[data-theme="dark"] .bubble{
  background:#111923!important;
  border-color:#354154!important;
  color:#e8edf4!important;
}
html[data-theme="dark"] .user .bubble{
  background:#202b3a!important;
  border-color:#4b5a70!important;
  color:#f8fafc!important;
}
html[data-theme="dark"] .composer-inner{
  background:#0e151f!important;
  border-color:#4b596e!important;
  box-shadow:0 18px 60px rgba(0,0,0,.45);
}
html[data-theme="dark"] .composer textarea{
  color:#f8fafc!important;
}
html[data-theme="dark"] .tool-button,
html[data-theme="dark"] .file-chip,
html[data-theme="dark"] .source-link{
  background:#17212d!important;
  border-color:#3d4a5f!important;
  color:#dbe3ee!important;
}
html[data-theme="dark"] .model-pill,
html[data-theme="dark"] .model-chip{
  background:#121a25!important;
  border-color:#3a475b!important;
  color:#b8c3d4!important;
}
html[data-theme="dark"] .status-wrap{
  color:#b8c3d4!important;
}
html[data-theme="dark"] .role{
  background:#202b3a!important;
  color:#eef3f9!important;
}
html[data-theme="dark"] .history-item{color:#b8c3d4}
html[data-theme="dark"] .history-item:hover{background:#202b3a;color:#f8fafc}
html[data-theme="dark"] .history-item.active{background:#263244;border-color:#3d4a5f;color:#f8fafc}
html[data-theme="dark"] .desktop-collapse{
  background:#17212d!important;
  border-color:#405067!important;
  color:#eef3f9!important;
}


/* Make workspace background presets much more visible */
html[data-background="soft"]{--workspace-bg:linear-gradient(135deg,#e7edf7 0%,#f8f9fc 45%,#e4ebf5 100%)}
html[data-background="solid"]{--workspace-bg:#e9edf3}
html[data-background="blue"]{--workspace-bg:linear-gradient(135deg,#cfe5ff 0%,#e4dcff 50%,#d3f1ea 100%)}
html[data-background="violet"]{--workspace-bg:linear-gradient(135deg,#ead8ff 0%,#d9ddff 50%,#f2d8f2 100%)}
html[data-background="sunset"]{--workspace-bg:linear-gradient(135deg,#ffd9c2 0%,#ffe9b8 48%,#e6d8ff 100%)}

/* Dark-mode background presets with stronger color */
html[data-theme="dark"][data-background="solid"]{--workspace-bg:#111722}
html[data-theme="dark"][data-background="soft"]{--workspace-bg:linear-gradient(135deg,#101827 0%,#182131 48%,#0e1724 100%)}
html[data-theme="dark"][data-background="blue"]{--workspace-bg:linear-gradient(135deg,#092441 0%,#202052 50%,#0b3030 100%)}
html[data-theme="dark"][data-background="violet"]{--workspace-bg:linear-gradient(135deg,#28133f 0%,#182454 50%,#35183b 100%)}
html[data-theme="dark"][data-background="sunset"]{--workspace-bg:linear-gradient(135deg,#472315 0%,#493719 48%,#321c45 100%)}

#app,.main{background:var(--workspace-bg)!important}

.background-picker{margin-top:2px;padding:12px;border:1px solid #cbd3de;border-radius:13px;background:#fff;box-shadow:0 12px 28px rgba(20,30,50,.12)}
.picker-title{display:flex;align-items:center;justify-content:space-between;font-size:10px;font-weight:750;color:#4f596a;margin-bottom:10px}
.picker-close{width:24px;height:24px;border:1px solid #d9dee6;border-radius:7px;background:#f5f7fa;color:#697386;cursor:pointer}
.picker-row{display:grid;grid-template-columns:42px 1fr;gap:8px;align-items:center}
.picker-row input[type=color]{width:42px;height:34px;padding:3px;border:1px solid #d9dee6;border-radius:8px;background:#fff;cursor:pointer}
.picker-row input[type=text]{width:100%;height:34px;padding:0 9px;border:1px solid #d9dee6;border-radius:8px;background:#fff;color:#303641;font-size:11px;outline:none}
.color-presets{display:grid;grid-template-columns:repeat(6,1fr);gap:7px;margin-top:11px}
.color-swatch{width:100%;aspect-ratio:1;border-radius:50%;border:2px solid #fff;box-shadow:0 0 0 1px #cbd3de;background:var(--swatch);cursor:pointer;padding:0}
.color-swatch:hover{transform:scale(1.08);box-shadow:0 0 0 2px #8d99aa}
.picker-subtitle{font-size:9px;color:#8992a1;text-transform:uppercase;letter-spacing:.08em;font-weight:750;margin:12px 0 7px}
.angle-control{display:grid;grid-template-columns:1fr auto;gap:7px;align-items:center;margin-top:9px;font-size:9px;color:#697386}
.angle-control input{grid-column:1/-1;width:100%;accent-color:#171a20}
.angle-control output{font-size:10px;color:#303641}
html[data-theme="dark"] .background-picker{background:#121a25;border-color:#354154}
html[data-theme="dark"] .picker-title,html[data-theme="dark"] .picker-subtitle,html[data-theme="dark"] .angle-control{color:#b8c3d4}
html[data-theme="dark"] .picker-close,html[data-theme="dark"] .picker-row input[type=text]{background:#1a2432;border-color:#445166;color:#eef3f9}
html[data-theme="dark"] .picker-row input[type=color]{background:#1a2432;border-color:#445166}
html[data-theme="dark"] .color-swatch{border-color:#121a25;box-shadow:0 0 0 1px #4b586d}


/* Sidebar is independently scrollable so every setting remains reachable */
.sidebar{overflow:hidden;min-height:100vh}
.sidebar-section{min-height:0;overflow-y:auto}
.sidebar-bottom{flex:0 0 auto;min-height:0;max-height:58vh;overflow-y:auto;padding-right:2px;scroll-behavior:smooth}
.sidebar-bottom::-webkit-scrollbar{width:7px}
.sidebar-bottom::-webkit-scrollbar-track{background:transparent}
.sidebar-bottom::-webkit-scrollbar-thumb{background:#c4ccd8;border-radius:99px}
.sidebar-bottom:hover::-webkit-scrollbar-thumb{background:#9ea9b8}
.control-card{margin-bottom:10px}
@media(max-height:800px){
  .sidebar-bottom{max-height:48vh}
}
@media(max-width:760px){
  .sidebar-bottom{max-height:55vh}
}


/* Chat actions + message editing */
.message{position:relative}
.message-actions{
  display:flex;
  align-items:center;
  gap:3px;
  margin-top:7px;
  margin-left:38px;
  opacity:.72;
}
.message-action{
  width:29px;
  height:29px;
  display:grid;
  place-items:center;
  border:0;
  border-radius:7px;
  background:transparent;
  color:#8992a1;
  cursor:pointer;
  font-size:14px;
  line-height:1;
  transition:background .15s ease,color .15s ease,transform .15s ease;
}
.message-action:hover{background:#eef1f5;color:#303641}
.message-action.selected{background:#e6ebf2;color:#171a21}
.message-actions.copied .message-action:first-child{color:#438556}
.user-message-actions{opacity:0;margin-top:4px}
.message.user:hover .user-message-actions{opacity:.72}
.message-menu{
  position:absolute;
  right:0;
  bottom:34px;
  z-index:8;
  min-width:150px;
  padding:5px;
  border:1px solid #d9dee6;
  border-radius:10px;
  background:#fff;
  box-shadow:0 12px 28px rgba(20,30,50,.16);
}
.message-menu button{
  width:100%;
  border:0;
  border-radius:7px;
  background:transparent;
  color:#303641;
  text-align:left;
  padding:8px 10px;
  font-size:11px;
  cursor:pointer;
}
.message-menu button:hover{background:#f1f4f7}
.composer-actions{display:flex;align-items:center;gap:7px}
.cancel-edit{
  height:36px;
  padding:0 15px;
  border:1px solid #cfd6e0;
  border-radius:11px;
  background:#fff;
  color:#4f596a;
  font-size:12px;
  cursor:pointer;
}
.cancel-edit:hover{background:#f5f7fa;color:#171a21}
.send{
  width:auto;
  min-width:82px;
  padding:0 13px;
  display:flex;
  align-items:center;
  justify-content:center;
  gap:7px;
}
.send-label{font-size:12px;font-weight:650}
.send-icon{font-size:16px;line-height:1}
.send.editing-send{min-width:82px}
html[data-theme="dark"] .message-action{color:#8995a9}
html[data-theme="dark"] .message-action:hover{background:#202b3a;color:#f3f6fa}
html[data-theme="dark"] .message-action.selected{background:#2a3648;color:#fff}
html[data-theme="dark"] .message-menu{background:#121a25;border-color:#354154;box-shadow:0 16px 38px rgba(0,0,0,.42)}
html[data-theme="dark"] .message-menu button{color:#e5ebf3}
html[data-theme="dark"] .message-menu button:hover{background:#202b3a}
html[data-theme="dark"] .cancel-edit{background:#151c28;border-color:#3d4a5f;color:#dbe3ee}
html[data-theme="dark"] .cancel-edit:hover{background:#202b3a}
@media(max-width:760px){
  .message-actions{margin-left:38px}
  .message-action{width:28px;height:28px}
  .send{min-width:72px}
  .send-label{font-size:11px}
  .cancel-edit{padding:0 12px}
}
