*,*::before,*::after{box-sizing:border-box;margin:0;padding:0}

/* ===== THEME VARS ===== */
:root {
  --accent: #4da8da;
  --bg: #0c0c0e;
  --surface: #141416;
  --surface2: #1c1c1e;
  --surface3: #242426;
  --border: #2c2c2e;
  --text: #f0f0f2;
  --text-sub: #aeaeb2;
  --text-muted: #636366;
  --warn: #f87171;
  --sidebar-w: 260px;
  --max-w: 700px;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f0efe8;
    --surface: #f8f7f0;
    --surface2: #e8e7e0;
    --surface3: #dcdbd4;
    --border: #cac9c2;
    --text: #1c1c1e;
    --text-sub: #48484a;
    --text-muted: #9a9a9c;
    color-scheme: light;
  }
}
[data-theme="light"] {
  --bg: #f0efe8;
  --surface: #f8f7f0;
  --surface2: #e8e7e0;
  --surface3: #dcdbd4;
  --border: #cac9c2;
  --text: #1c1c1e;
  --text-sub: #48484a;
  --text-muted: #9a9a9c;
  color-scheme: light;
}
[data-theme="dark"] {
  --bg: #0c0c0e;
  --surface: #141416;
  --surface2: #1c1c1e;
  --surface3: #242426;
  --border: #2c2c2e;
  --text: #f0f0f2;
  --text-sub: #aeaeb2;
  --text-muted: #636366;
  color-scheme: dark;
}

body { font-family:'Outfit',sans-serif; background:var(--bg); color:var(--text); height:100dvh; display:flex; overflow:hidden; font-size:clamp(15px, 0.6vw + 13.5px, 17px); }

/* ===== SIDEBAR ===== */
#sidebar {
  width:var(--sidebar-w); background:var(--surface);
  display:flex; flex-direction:column;
  flex-shrink:0; overflow:hidden; z-index:30;
  border-right:1px solid var(--border);
  transition:width .22s ease, opacity .22s ease;
}
#sidebar.closed { width:0; opacity:0; pointer-events:none; }

.sb-top { padding:12px 10px 8px; flex-shrink:0; }
.sb-brand { display:flex; align-items:center; gap:9px; padding:6px 10px 10px; }
.sb-brand-logo img { width:28px; height:28px; border-radius:6px; display:block; }
.sb-brand-name { font-size:.93rem; font-weight:700; letter-spacing:-.01em; }

.sb-new-btn {
  width:100%; display:flex; align-items:center; gap:10px;
  padding:9px 12px; border-radius:8px; border:1px solid var(--border);
  background:transparent; color:var(--text);
  font-family:'Outfit',sans-serif; font-size:.84rem; font-weight:500;
  cursor:pointer; transition:background .15s; text-align:left;
}
.sb-new-btn:hover { background:var(--surface2); }
.sb-section-label { padding:14px 12px 5px; font-size:.68rem; font-weight:700; letter-spacing:.08em; text-transform:uppercase; color:var(--text-muted); }
.sessions-limit-notice {
  margin:6px 8px 4px; padding:7px 10px; border-radius:7px;
  font-size:.72rem; line-height:1.5; font-family:'IBM Plex Mono',monospace;
  border:1px solid color-mix(in srgb, var(--warn) 35%, transparent);
  background:color-mix(in srgb, var(--warn) 8%, transparent);
  color:var(--warn);
}
.sessions-limit-notice.near {
  border-color:color-mix(in srgb, #fb923c 35%, transparent);
  background:color-mix(in srgb, #fb923c 8%, transparent);
  color:#fb923c;
}
.sessions-list { flex:1; overflow-y:auto; padding:0 8px; }
.sessions-list::-webkit-scrollbar { width:3px; }
.sessions-list::-webkit-scrollbar-thumb { background:var(--border); border-radius:3px; }
.session-item { display:flex; align-items:center; justify-content:space-between; padding:8px 10px; border-radius:8px; cursor:pointer; margin-bottom:1px; transition:background .12s; gap:6px; }
.session-item:hover { background:var(--surface2); }
.session-item.active { background:var(--surface3); }
.session-name { font-size:.82rem; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; flex:1; color:var(--text-sub); }
.session-item.active .session-name { color:var(--text); }
.session-del { width:22px; height:22px; border:none; background:transparent; color:var(--text-muted); cursor:pointer; border-radius:5px; font-size:.7rem; display:flex; align-items:center; justify-content:center; opacity:0; transition:opacity .12s, color .12s; flex-shrink:0; }
.session-item:hover .session-del { opacity:1; }
.session-del:hover { color:var(--warn); }

.sb-bottom { padding:10px; border-top:1px solid var(--border); flex-shrink:0; }
.sb-action-btn { width:100%; padding:9px 12px; border:1px solid var(--border); border-radius:8px; background:transparent; color:var(--text-sub); font-family:'Outfit',sans-serif; font-size:.82rem; font-weight:500; cursor:pointer; text-align:left; transition:background .12s, color .12s; display:flex; align-items:center; gap:8px; }
.sb-action-btn:hover { background:var(--surface2); color:var(--text); }

/* ===== OVERLAY ===== */
#overlay { display:none; position:fixed; inset:0; background:rgba(0,0,0,.5); z-index:25; }

/* ===== MAIN ===== */
#main { flex:1; display:flex; flex-direction:column; min-width:0; overflow:hidden; position:relative; }

/* ===== TOPBAR ===== */
#topbar { display:flex; align-items:center; gap:8px; padding:9px 14px; border-bottom:1px solid var(--border); flex-shrink:0; }
.icon-btn { width:34px; height:34px; border-radius:8px; border:1px solid transparent; background:transparent; color:var(--text-sub); cursor:pointer; display:flex; align-items:center; justify-content:center; font-size:.9rem; transition:background .12s, color .12s; flex-shrink:0; }
.icon-btn:hover { background:var(--surface2); color:var(--text); }

.topbar-model-info {
  display:flex; align-items:center; gap:7px;
  padding:5px 10px; border-radius:8px; border:1px solid var(--border);
  cursor:pointer; transition:background .12s;
  max-width:260px; overflow:hidden;
}
.topbar-model-info:hover { background:var(--surface2); }
.topbar-prov-logo { height:18px; width:auto; object-fit:contain; flex-shrink:0; }
.topbar-model-name { font-size:.78rem; font-weight:500; color:var(--text-sub); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; max-width:160px; }
.topbar-chevron { font-size:.62rem; color:var(--text-muted); flex-shrink:0; }
.topbar-spacer { flex:1; }

.export-wrap { position:relative; }
.export-dropdown {
  position:absolute; right:0; top:calc(100% + 6px); z-index:100;
  background:var(--surface); border:1px solid var(--border);
  border-radius:10px; box-shadow:0 8px 24px rgba(0,0,0,.25);
  overflow:hidden; min-width:170px;
  display:none;
}
.export-dropdown.open { display:block; }
.export-dropdown button {
  width:100%; padding:9px 14px; background:transparent; border:none;
  color:var(--text-sub); font-family:'Outfit',sans-serif; font-size:.82rem; font-weight:500;
  cursor:pointer; text-align:left; transition:background .1s, color .1s;
}
.export-dropdown button:hover { background:var(--surface2); color:var(--text); }

/* ===== CHAT ===== */
#chat { flex:1; overflow-y:auto; display:flex; flex-direction:column; align-items:center; padding:0 16px 148px; }
#chat::-webkit-scrollbar { width:4px; }
#chat::-webkit-scrollbar-thumb { background:var(--border); border-radius:4px; }
.chat-inner { width:100%; max-width:var(--max-w); display:flex; flex-direction:column; }

/* flat logo — no shadow */
.welcome { flex:1; display:flex; flex-direction:column; align-items:center; justify-content:center; padding:60px 20px 20px; text-align:center; gap:12px; width:100%; max-width:var(--max-w); align-self:center; }
.welcome-svg { width:56px; height:56px; border-radius:14px; overflow:hidden; margin-bottom:4px; }
.welcome-svg img { width:56px; height:56px; border-radius:14px; display:block; }
.welcome h2 { font-size:1.4rem; font-weight:700; }
.welcome p { font-size:.85rem; color:var(--text-muted); line-height:1.65; max-width:300px; }

.msg { padding:18px 0; display:flex; gap:14px; animation:fadeUp .18s ease; }
@keyframes fadeUp { from { opacity:0; transform:translateY(4px); } to { opacity:1; transform:translateY(0); } }
.msg-avatar { width:28px; height:28px; border-radius:50%; flex-shrink:0; display:flex; align-items:center; justify-content:center; font-size:.58rem; font-weight:700; font-family:'IBM Plex Mono',monospace; margin-top:2px; }
.msg.user .msg-avatar { background:color-mix(in srgb, var(--accent) 20%, transparent); color:var(--accent); }
.msg.assistant .msg-avatar { background:var(--surface2); color:var(--text-sub); border:1px solid var(--border); }
.msg-body { flex:1; min-width:0; }
.msg-name { font-size:.76rem; font-weight:700; margin-bottom:5px; color:var(--text-sub); }
.msg.user .msg-name { color:var(--accent); }
.msg-content { font-size:.88rem; line-height:1.78; color:var(--text); word-break:break-word; }
.msg.assistant .msg-content { font-family:'IBM Plex Mono',monospace; font-size:.82rem; }
.msg-image { max-width:240px; max-height:200px; border-radius:10px; display:block; margin-bottom:8px; object-fit:cover; border:1px solid var(--border); }
.msg-img-missing { font-size:.75rem; color:var(--text-muted); font-style:italic; margin-bottom:6px; }

/* Headings in messages */
.msg-content h1 { font-family:'Outfit',sans-serif; font-size:1.2em; font-weight:700; margin:18px 0 8px; padding-bottom:6px; border-bottom:1px solid var(--border); line-height:1.3; }
.msg-content h2 { font-family:'Outfit',sans-serif; font-size:1.05em; font-weight:700; margin:15px 0 7px; line-height:1.3; }
.msg-content h3 { font-family:'Outfit',sans-serif; font-size:.95em; font-weight:700; margin:12px 0 6px; color:var(--text-sub); line-height:1.3; }
.msg-content h1:first-child, .msg-content h2:first-child, .msg-content h3:first-child { margin-top:4px; }

/* Lists */
.msg-content ul, .msg-content ol { padding-left:20px; margin:8px 0; }
.msg-content li { margin-bottom:3px; }
.msg-content ul { list-style:disc; }
.msg-content ol { list-style:decimal; }

/* Table */
.msg-content table { border-collapse:collapse; width:100%; margin:10px 0; font-size:.8rem; overflow-x:auto; display:block; }
.msg-content th, .msg-content td { border:1px solid var(--border); padding:7px 12px; text-align:left; }
.msg-content th { background:var(--surface2); font-weight:600; }
.msg-content tr:nth-child(even) td { background:color-mix(in srgb, var(--surface2) 40%, transparent); }

/* Blockquote */
.msg-content blockquote { border-left:3px solid var(--accent); padding-left:12px; color:var(--text-sub); margin:8px 0; }

/* HR */
.msg-content hr { border:none; border-top:1px solid var(--border); margin:12px 0; }

/* Links */
.msg-content a { color:var(--accent); text-decoration:none; }
.msg-content a:hover { text-decoration:underline; }

/* del */
.msg-content del { opacity:.6; }

/* Inline code */
.msg-content :not(pre) > code { background:var(--surface2); padding:2px 6px; border-radius:4px; font-size:.85em; font-family:'IBM Plex Mono',monospace; border:1px solid var(--border); }

/* Code block (Prism overrides) */
.code-block-wrap { margin:12px 0; border-radius:10px; border:1px solid var(--border); overflow:hidden; }
.code-header { display:flex; align-items:center; justify-content:space-between; padding:6px 12px; background:#161620; border-bottom:1px solid rgba(255,255,255,.06); }
.code-lang { font-size:.68rem; font-family:'IBM Plex Mono',monospace; color:#7d8496; letter-spacing:.03em; }
.copy-btn { font-size:.7rem; font-family:'Outfit',sans-serif; font-weight:500; background:transparent; border:1px solid rgba(255,255,255,.1); color:#7d8496; padding:2px 9px; border-radius:4px; cursor:pointer; transition:color .12s, border-color .12s; }
.copy-btn:hover { color:#cdd; border-color:rgba(255,255,255,.25); }
.code-block-wrap pre[class*="language-"],
.code-block-wrap pre { margin:0 !important; border-radius:0 !important; background:#1a1b26 !important; border:none !important; }
code[class*="language-"], pre[class*="language-"] { font-family:'IBM Plex Mono',monospace !important; font-size:.78rem !important; line-height:1.65 !important; }

/* Math */
.msg-content .katex-display { overflow-x:auto; overflow-y:hidden; padding:4px 0; }
.msg-content .katex { font-size:1em; }

/* Think block */
.think-block { margin-bottom:10px; border:1px solid var(--border); border-radius:8px; overflow:hidden; font-family:'IBM Plex Mono',monospace; font-size:.76rem; }
.think-toggle { display:flex; align-items:center; gap:6px; padding:7px 12px; cursor:pointer; background:var(--surface2); color:var(--text-muted); user-select:none; border:none; width:100%; text-align:left; font-family:'IBM Plex Mono',monospace; font-size:.76rem; transition:color .12s; }
.think-toggle:hover { color:var(--text-sub); }
.think-arrow { transition:transform .2s; font-size:.65rem; }
.think-arrow.open { transform:rotate(90deg); }
.think-body { display:none; padding:10px 12px; color:var(--text-muted); line-height:1.6; background:color-mix(in srgb, var(--surface2) 40%, transparent); white-space:pre-wrap; }
.think-body.open { display:block; }
.streaming-cursor::after { content:''; display:inline-block; width:2px; height:.9em; background:var(--accent); margin-left:2px; vertical-align:middle; animation:blink .6s step-end infinite; }
@keyframes blink { 50% { opacity:0; } }

/* ===== INPUT AREA ===== */
.input-area { position:absolute; bottom:0; left:0; right:0; padding:10px 16px 18px; background:linear-gradient(to top, var(--bg) 65%, transparent); display:flex; justify-content:center; }
.input-box { width:100%; max-width:var(--max-w); background:var(--surface); border:1px solid var(--border); border-radius:14px; padding:10px 12px 8px 14px; display:flex; flex-direction:column; gap:7px; box-shadow:0 2px 20px rgba(0,0,0,.18); transition:border-color .15s; }
.input-box:focus-within { border-color:color-mix(in srgb, var(--accent) 45%, transparent); }

.image-preview-strip { display:flex; gap:8px; flex-wrap:wrap; padding-bottom:4px; }
.img-preview-item { position:relative; }
.img-preview-item img { width:64px; height:64px; object-fit:cover; border-radius:8px; border:1px solid var(--border); display:block; }
.img-preview-remove { position:absolute; top:-5px; right:-5px; width:18px; height:18px; border-radius:50%; background:var(--surface3); border:1px solid var(--border); color:var(--text-muted); font-size:.55rem; cursor:pointer; display:flex; align-items:center; justify-content:center; transition:color .12s; }
.img-preview-remove:hover { color:var(--warn); }

#userInput { width:100%; font-family:'Outfit',sans-serif; font-size:.9rem; background:transparent; border:none; outline:none; color:var(--text); resize:none; min-height:26px; max-height:180px; line-height:1.55; }
#userInput::placeholder { color:var(--text-muted); }

.input-actions { display:flex; align-items:center; justify-content:space-between; gap:8px; }
.input-left { display:flex; align-items:center; gap:6px; }
.input-right { display:flex; align-items:center; gap:8px; }
.attach-btn { width:28px; height:28px; border:none; background:transparent; color:var(--text-muted); cursor:pointer; border-radius:6px; font-size:.85rem; display:flex; align-items:center; justify-content:center; transition:background .12s, color .12s; }
.attach-btn:hover { background:var(--surface2); color:var(--text-sub); }
.input-counter { font-size:.68rem; font-family:'IBM Plex Mono',monospace; color:var(--text-muted); white-space:nowrap; transition:color .15s; }
.input-counter.warn { color:#fb923c; }
.input-counter.over { color:var(--warn); }
.input-meta-text { font-size:.68rem; color:var(--text-muted); font-family:'IBM Plex Mono',monospace; }
.status-ok { color:var(--accent); }
.status-err { color:var(--warn); }
#sendBtn { width:32px; height:32px; border-radius:8px; border:none; background:var(--accent); color:#fff; cursor:pointer; font-size:.85rem; display:flex; align-items:center; justify-content:center; transition:opacity .12s, transform .1s; font-weight:700; }
#sendBtn:hover { opacity:.85; }
#sendBtn:active { transform:scale(.92); }
#sendBtn:disabled { background:var(--surface3); color:var(--text-muted); cursor:not-allowed; }

/* ===== SETTINGS MODAL ===== */
.modal-bg { display:none; position:fixed; inset:0; background:rgba(0,0,0,.6); backdrop-filter:blur(6px); z-index:200; align-items:center; justify-content:center; padding:16px; }
.modal-bg.open { display:flex; }

.settings-modal {
  background:var(--bg); border:1px solid var(--border);
  border-radius:18px; width:min(680px, 100%);
  height:min(540px, 90dvh); display:flex; flex-direction:column;
  box-shadow:0 24px 64px rgba(0,0,0,.5); overflow:hidden;
}

/* Header */
.settings-hdr {
  padding:16px 22px; border-bottom:1px solid var(--border);
  display:flex; align-items:center; justify-content:space-between; flex-shrink:0;
  background:var(--bg);
}
.settings-hdr h2 { font-size:.98rem; font-weight:700; }

/* Split body */
.settings-split { display:flex; flex:1; overflow:hidden; }

/* Left nav */
.settings-nav {
  width:160px; flex-shrink:0; padding:10px 8px;
  border-right:1px solid var(--border); overflow-y:auto;
  background:var(--bg);
}
.settings-nav::-webkit-scrollbar { width:0; }
.snav-item {
  display:flex; align-items:center; gap:9px;
  padding:9px 12px; border-radius:9px; cursor:pointer;
  font-size:.88rem; font-weight:500; color:var(--text-sub);
  transition:background .12s, color .12s; user-select:none; border:none;
  width:100%; background:transparent; font-family:'Outfit',sans-serif;
  text-align:left;
}
.snav-item:hover { background:var(--surface2); color:var(--text); }
.snav-item.active { background:var(--surface2); color:var(--text); }
.snav-icon { width:15px; height:15px; flex-shrink:0; }

/* Right content */
.settings-content {
  flex:1; overflow-y:auto; padding:20px 24px;
  background:var(--surface);
}
.settings-content::-webkit-scrollbar { width:3px; }
.settings-content::-webkit-scrollbar-thumb { background:var(--border); border-radius:3px; }

.stab { display:none; }
.stab.active { display:block; }

.stab-title { font-size:.75rem; font-weight:700; letter-spacing:.09em; text-transform:uppercase; color:var(--text-muted); margin-bottom:18px; }

.settings-row { display:flex; align-items:flex-start; justify-content:space-between; gap:14px; margin-bottom:18px; }
.settings-row:last-child { margin-bottom:0; }
.settings-row-left { flex:1; }
.settings-label { font-size:.9rem; font-weight:500; color:var(--text); display:block; margin-bottom:3px; }
.settings-hint { font-size:.78rem; color:var(--text-muted); line-height:1.5; }
.settings-hint a { color:var(--accent); text-decoration:none; }
.settings-hint a:hover { text-decoration:underline; }

/* Theme cards */
.theme-cards { display:flex; gap:10px; flex-wrap:wrap; }
.theme-card {
  display:flex; flex-direction:column; align-items:center; gap:6px;
  padding:12px 18px; border-radius:12px; border:1.5px solid var(--border);
  background:var(--surface2); cursor:pointer; min-width:72px;
  transition:border-color .15s, background .15s; font-family:'Outfit',sans-serif;
}
.theme-card:hover { border-color:color-mix(in srgb, var(--accent) 40%, transparent); }
.theme-card.on {
  border-color:var(--accent);
  background:color-mix(in srgb, var(--accent) 10%, transparent);
}
.theme-card-icon { width:20px; height:20px; }
.theme-card-label { font-size:.76rem; font-weight:500; color:var(--text-sub); }
.theme-card.on .theme-card-label { color:var(--accent); }

/* Accent */
.accent-row { display:flex; align-items:center; gap:6px; flex-wrap:wrap; }
.ac-dot { width:22px; height:22px; border-radius:50%; border:2px solid transparent; cursor:pointer; transition:transform .12s, border-color .12s; flex-shrink:0; }
.ac-dot:hover { transform:scale(1.2); }
.ac-dot.on { border-color:var(--text); }
.ac-custom { position:relative; width:22px; height:22px; border-radius:50%; border:1.5px dashed var(--border); overflow:hidden; cursor:pointer; flex-shrink:0; }
.ac-custom input { position:absolute; width:200%; height:200%; top:-50%; left:-50%; opacity:0; cursor:pointer; }

/* Provider buttons */
.provider-btns { display:flex; gap:8px; flex-wrap:wrap; }
.prov-btn {
  display:flex; align-items:center; gap:7px;
  padding:7px 14px; border-radius:9px; border:1.5px solid var(--border);
  background:var(--surface2); color:var(--text-sub);
  font-family:'Outfit',sans-serif; font-size:.82rem; font-weight:500;
  cursor:pointer; transition:all .12s;
}
.prov-btn.on {
  background:color-mix(in srgb, var(--accent) 12%, transparent);
  border-color:var(--accent); color:var(--accent);
}
.prov-logo { height:18px; width:auto; object-fit:contain; }

/* Model select */
.model-select-full { width:100%; font-family:'Outfit',sans-serif; font-size:.82rem; padding:8px 11px; border-radius:8px; border:1px solid var(--border); background:var(--surface2); color:var(--text); cursor:pointer; outline:none; transition:border-color .15s; }
.model-select-full:focus { border-color:var(--accent); }
#customModelInput, #ollamaModelInput { width:100%; font-family:'IBM Plex Mono',monospace; font-size:.78rem; margin-top:7px; padding:8px 11px; border-radius:8px; border:1px solid var(--border); background:var(--surface2); color:var(--text); outline:none; transition:border-color .15s; }
#customModelInput:focus, #ollamaModelInput:focus { border-color:var(--accent); }

/* Ollama URL row */
.ollama-url-row { display:flex; gap:6px; margin-top:7px; }
#ollamaUrlInput { flex:1; font-family:'IBM Plex Mono',monospace; font-size:.78rem; padding:8px 11px; border-radius:8px; border:1px solid var(--border); background:var(--surface2); color:var(--text); outline:none; transition:border-color .15s; }
#ollamaUrlInput:focus { border-color:var(--accent); }
#ollamaFetchBtn { font-family:'Outfit',sans-serif; font-size:.78rem; font-weight:500; padding:7px 12px; border-radius:8px; border:1px solid var(--border); background:var(--surface3); color:var(--text-sub); cursor:pointer; white-space:nowrap; transition:background .12s, color .12s; }
#ollamaFetchBtn:hover { background:var(--surface2); color:var(--text); }

/* Ollama note */
.ollama-note { font-size:.75rem; color:var(--text-muted); line-height:1.55; font-family:'IBM Plex Mono',monospace; padding:8px 11px; border:1px solid var(--border); border-radius:8px; background:color-mix(in srgb, var(--surface2) 50%, transparent); margin-top:8px; }

/* Key input */
.key-group { margin-bottom:18px; padding-bottom:18px; border-bottom:1px solid var(--border); }
.key-group:last-child { margin-bottom:0; padding-bottom:0; border-bottom:none; }
.key-group-label { font-size:.82rem; font-weight:600; color:var(--text); margin-bottom:8px; display:flex; align-items:center; gap:8px; }
.key-input-row { display:flex; gap:8px; margin-bottom:6px; }
.key-input-row input[type="password"] {
  flex:1; font-family:'IBM Plex Mono',monospace; font-size:.8rem;
  padding:8px 12px; border-radius:8px; border:1px solid var(--border);
  background:var(--surface2); color:var(--text); outline:none; transition:border-color .15s;
}
.key-input-row input:focus { border-color:var(--accent); }
.key-status { font-size:.72rem; font-family:'IBM Plex Mono',monospace; min-height:16px; }
.key-status.set { color:var(--accent); }
.key-status.missing { color:var(--warn); }

/* System prompt */
#sysPromptInput {
  width:100%; font-family:'IBM Plex Mono',monospace; font-size:.8rem;
  padding:10px 12px; border-radius:9px; border:1px solid var(--border);
  background:var(--surface2); color:var(--text); outline:none;
  resize:vertical; min-height:100px; line-height:1.6; transition:border-color .15s;
}
#sysPromptInput:focus { border-color:var(--accent); }

/* Common button */
.mbtn {
  font-family:'Outfit',sans-serif; font-size:.82rem; font-weight:600;
  padding:7px 16px; border-radius:8px; border:1px solid var(--border);
  background:var(--surface2); color:var(--text-sub); cursor:pointer;
  transition:background .12s, color .12s;
}
.mbtn:hover { background:var(--surface3); color:var(--text); }
.mbtn-primary { background:var(--accent); color:#fff; border-color:var(--accent); }
.mbtn-primary:hover { opacity:.85; color:#fff; }
.mbtn-sm { padding:5px 12px; font-size:.78rem; }
.mbtn-danger { border-color:color-mix(in srgb,var(--warn) 40%,transparent); color:var(--warn); }
.mbtn-danger:hover { background:color-mix(in srgb,var(--warn) 12%,transparent); color:var(--warn); }

/* Remember checkbox */
.remember-check { display:flex; align-items:center; gap:8px; cursor:pointer; width:fit-content; }
.remember-check input[type="checkbox"] {
  appearance:none; -webkit-appearance:none;
  width:14px; height:14px; border-radius:4px;
  background:var(--surface3); border:1px solid var(--border);
  cursor:pointer; flex-shrink:0; position:relative;
}
.remember-check input[type="checkbox"]:checked { background:var(--accent); border-color:var(--accent); }
.remember-check input[type="checkbox"]:checked::after {
  content:''; position:absolute; top:1px; left:4px;
  width:4px; height:8px; border:solid #fff; border-width:0 2px 2px 0; transform:rotate(45deg);
}
.remember-check-label { font-size:.78rem; font-weight:500; color:var(--text-sub); user-select:none; }

/* Inline rename */
.session-rename-input {
  flex:1; background:var(--surface3); border:1px solid var(--accent);
  border-radius:5px; color:var(--text); font-family:'Outfit',sans-serif;
  font-size:.82rem; padding:2px 7px; outline:none; min-width:0;
}
.session-menu-wrap { position:relative; flex-shrink:0; }
.session-menu-btn { width:22px; height:22px; border:none; background:transparent; color:var(--text-muted); cursor:pointer; border-radius:5px; font-size:.75rem; display:flex; align-items:center; justify-content:center; opacity:0; transition:opacity .12s, color .12s; letter-spacing:.05em; }
.session-item:hover .session-menu-btn { opacity:1; }
.session-item.active .session-menu-btn { opacity:.6; }
.session-item.active:hover .session-menu-btn { opacity:1; }
.session-menu-btn:hover { color:var(--text); }
.session-ctx {
  position:absolute; right:0; top:calc(100% + 4px); z-index:100;
  background:var(--surface2); border:1px solid var(--border);
  border-radius:9px; box-shadow:0 6px 20px rgba(0,0,0,.25);
  overflow:hidden; min-width:155px; display:none;
}
.session-ctx.open { display:block; }
.session-ctx button {
  width:100%; padding:8px 13px; background:transparent; border:none;
  color:var(--text-sub); font-family:'Outfit',sans-serif; font-size:.8rem; font-weight:500;
  cursor:pointer; text-align:left; transition:background .1s, color .1s; display:flex; align-items:center; gap:8px;
}
.session-ctx button:hover { background:var(--surface3); color:var(--text); }
.session-ctx button.danger:hover { color:var(--warn); }

/* Code block light theme */
[data-theme="light"] .code-block-wrap pre[class*="language-"],
[data-theme="light"] .code-block-wrap pre { background:#f0efe6 !important; color:#24292e !important; }
[data-theme="light"] .code-header { background:#e4e3da; border-bottom-color:#cac9c0; }
[data-theme="light"] .code-lang { color:#57606a; }
[data-theme="light"] .copy-btn { color:#57606a; border-color:#cac9c0; }
[data-theme="light"] .copy-btn:hover { color:#24292e; border-color:#8c959f; }
[data-theme="light"] .token.comment { color:#6a737d; font-style:italic; }
[data-theme="light"] .token.punctuation { color:#24292e; }
[data-theme="light"] .token.property,[data-theme="light"] .token.number,[data-theme="light"] .token.boolean,[data-theme="light"] .token.constant { color:#005cc5; }
[data-theme="light"] .token.string,[data-theme="light"] .token.char,[data-theme="light"] .token.selector { color:#032f62; }
[data-theme="light"] .token.keyword,[data-theme="light"] .token.operator,[data-theme="light"] .token.variable { color:#d73a49; }
[data-theme="light"] .token.function,[data-theme="light"] .token.class-name { color:#6f42c1; }
[data-theme="light"] .token.regex,[data-theme="light"] .token.important { color:#e36209; }
@media (prefers-color-scheme:light) {
  html:not([data-theme="dark"]) .code-block-wrap pre[class*="language-"],
  html:not([data-theme="dark"]) .code-block-wrap pre { background:#f0efe6 !important; color:#24292e !important; }
  html:not([data-theme="dark"]) .code-header { background:#e4e3da; border-bottom-color:#cac9c0; }
  html:not([data-theme="dark"]) .code-lang { color:#57606a; }
  html:not([data-theme="dark"]) .copy-btn { color:#57606a; border-color:#cac9c0; }
  html:not([data-theme="dark"]) .token.comment { color:#6a737d; font-style:italic; }
  html:not([data-theme="dark"]) .token.property,html:not([data-theme="dark"]) .token.number,html:not([data-theme="dark"]) .token.boolean { color:#005cc5; }
  html:not([data-theme="dark"]) .token.string,html:not([data-theme="dark"]) .token.char { color:#032f62; }
  html:not([data-theme="dark"]) .token.keyword,html:not([data-theme="dark"]) .token.operator { color:#d73a49; }
  html:not([data-theme="dark"]) .token.function,html:not([data-theme="dark"]) .token.class-name { color:#6f42c1; }
}

/* ===== MOBILE ===== */
@media (max-width:640px) {
  #sidebar { position:fixed; top:0; left:0; bottom:0; width:var(--sidebar-w) !important; transform:translateX(-100%); transition:transform .22s ease; opacity:1 !important; pointer-events:all !important; }
  #sidebar.mobile-open { transform:translateX(0); }
  #overlay { display:block; opacity:0; pointer-events:none; transition:opacity .22s; }
  #overlay.show { opacity:1; pointer-events:all; }
  .input-area { padding:8px 10px 14px; }
  #topbar { padding:7px 10px; }
  .topbar-model-name { max-width:110px; }

  /* Settings modal: bottom sheet on mobile */
  .modal-bg { padding:0 !important; align-items:flex-end; }
  .settings-modal {
    width:100% !important;
    height:92dvh !important;
    max-height:92dvh !important;
    border-radius:20px 20px 0 0 !important;
    margin:0 !important;
    border-bottom:none !important;
  }

  /* Drag handle */
  .settings-hdr::before {
    content:''; display:block; width:36px; height:4px;
    border-radius:2px; background:var(--border);
    margin:0 auto 12px; position:absolute; top:8px; left:50%; transform:translateX(-50%);
  }
  .settings-hdr { position:relative; padding-top:22px !important; }

  /* Switch to top pill-tabs layout */
  .settings-split { flex-direction:column; }

  .settings-nav {
    width:100% !important;
    border-right:none !important;
    border-bottom:1px solid var(--border);
    padding:8px 12px !important;
    display:flex; flex-direction:row;
    overflow-x:auto; gap:6px;
    -webkit-overflow-scrolling:touch;
    scrollbar-width:none;
  }
  .settings-nav::-webkit-scrollbar { display:none; }

  .snav-item {
    flex-shrink:0; width:auto !important;
    padding:7px 14px !important; border-radius:20px !important;
    font-size:.84rem !important; gap:6px !important;
    border:1px solid transparent !important;
    white-space:nowrap;
  }
  .snav-item.active {
    background:color-mix(in srgb, var(--accent) 14%, transparent) !important;
    border-color:color-mix(in srgb, var(--accent) 35%, transparent) !important;
    color:var(--accent) !important;
  }
  .snav-icon { width:14px; height:14px; }
  .settings-content { padding:16px !important; }

  /* Bigger touch targets in settings content */
  .mbtn { padding:10px 18px; font-size:.9rem; }
  .key-input-row input[type="password"] { padding:11px 12px; font-size:.88rem; }
  .model-select-full { padding:11px; font-size:.88rem; }
  #sysPromptInput { font-size:.88rem; }
}
