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

:root {
  --bg:            #0e0e10;
  --bg-low:        #131315;
  --bg-mid:        #19191c;
  --bg-high:       #1f1f22;
  --bg-bright:     #2c2c2f;
  --bg-highest:    #262528;
  --border:        #1e293b;
  --outline:       #48474a;
  --outline-dim:   #767577;
  --text:          #f6f3f5;
  --text-muted:    #acaaad;
  --primary:       #ba9eff;
  --primary-dim:   #8455ef;
  --secondary:     #699cff;
  --tertiary:      #ff716a;
  --quaternary:    #ff985d;
  --quinternary:   #a2ff99;
  --black:         #000000;
  --font-ui:       'Space Grotesk', sans-serif;
  --font-mono:     'JetBrains Mono', monospace;
  --tr:            0.15s ease;
  --sb-width:      256px;
}

html, body { height: 100%; overflow: hidden; background: var(--bg); color: var(--text); font-family: var(--font-ui); font-size: 14px; line-height: 1.5; }

::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--bg-high); }
::-webkit-scrollbar-thumb:hover { background: var(--primary); }

/* ── ICON ───────────────────────────────────────────────────── */
.icon {
  font-family: 'Material Symbols Outlined';
  font-style: normal; font-weight: normal;
  font-size: 18px; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
  user-select: none;
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
  vertical-align: middle;
}

/* ── LAYOUT ─────────────────────────────────────────────────── */
#app { display: flex; height: 100vh; overflow: hidden; }

/* ── SIDEBAR ────────────────────────────────────────────────── */
#sidebar {
  width: var(--sb-width); 
  flex-shrink: 0;
  background: var(--bg-low);
  border-right: 1px solid var(--border);
  display: flex; 
  flex-direction: column;
  transition: width 0.22s cubic-bezier(.4,0,.2,1);
  position: relative;
  overflow: hidden;
}

#sidebar.hidden-sb {
  width: 0 !important;
  border-right: none;
}

/* Brand */
.sb-brand {
  padding: 13px 16px;
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--border);
  background: var(--black);
  position: relative;
  min-width: 256px; /* Keep content from squishing during collapse */
}
.sb-brand-name { font-size: 11px; font-weight: 900; letter-spacing: 0.18em; color: var(--primary); text-transform: uppercase; }
.sb-brand-btn  { font-size: 14px; color: var(--text-muted); cursor: pointer; transition: color var(--tr); }
.sb-brand-btn:hover { color: var(--primary); }

/* More menu */
.more-menu {
  position: absolute; right: 0; top: 100%;
  background: var(--bg-high); border: 1px solid var(--border);
  z-index: 200; min-width: 150px;
  box-shadow: 0 8px 32px rgba(0,0,0,.6);
  display: none;
}
.more-menu.open { display: block; }
.more-item { padding: 7px 14px; font-size: 11px; color: var(--text-muted); cursor: pointer; transition: background var(--tr), color var(--tr); }
.more-item:hover { background: var(--bg-bright); color: var(--primary); }
.more-sep { border-top: 1px solid var(--border); margin: 3px 0; }

/* Search */
.sb-search { padding: 10px 12px;  min-width: 64px; }
.sb-search-wrap { position: relative; }
.sb-search-wrap .icon { position: absolute; left: 8px; top: 50%; transform: translateY(-50%); color: var(--primary); font-size: 16px; }
.sb-search-wrap input {
  width: 100%; background: var(--black); border: 1px solid var(--outline);
  color: var(--text); font-family: var(--font-mono); font-size: 11px;
  padding: 5px 10px 5px 30px; outline: none; transition: border-color var(--tr);
}
.sb-search-wrap input:focus { border-color: var(--primary); }
.sb-search-wrap input::placeholder { color: var(--text-muted); }

/* Body */
.sb-body { flex: 1; overflow-y: auto; min-width: 128px; }

/* Section */
.sec-divider { border-top: 1px solid rgba(30,41,59,.5);}
.sec-hdr {
  display: flex; align-items: center; gap: 4px;
  padding: 6px 8px; color: var(--text-muted);
  cursor: pointer; transition: background var(--tr); user-select: none;
}
.sec-hdr:hover { background: var(--bg-high); }
.sec-hdr .arrow { font-size: 14px; transition: transform .2s ease; }
.sec-hdr.open .arrow { transform: rotate(90deg); }
.sec-title { font-size: 10px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }
.sec-badge { margin-left: auto; font-size: 9px; background: rgba(186,158,255,.15); color: var(--primary); border: 1px solid rgba(186,158,255,.3); padding: 1px 6px; font-family: var(--font-mono); }

.sec-body { overflow: scroll; max-height: 0; opacity: 0; transition: max-height .22s cubic-bezier(.4,0,.2,1), opacity .18s ease; }
.sec-body.open { max-height: 500px; opacity: 1; }

/* Chat item */
.chat-item {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 10px 4px 24px; cursor: pointer;
  color: var(--text-muted); transition: background var(--tr);
}
.chat-item:hover { background: var(--bg-high); }
.chat-item.active { background: var(--bg-high); color: var(--primary); border-left: 2px solid var(--primary); padding-left: 22px; }
.chat-item .icon  { font-size: 13px; flex-shrink: 0; }
.chat-name         { font-size: 11px; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Model item */
.model-item { display: flex; align-items: center; gap: 8px; padding: 5px 10px 5px 24px; cursor: pointer; transition: background var(--tr); }
.model-item:hover { background: var(--bg-high); }
.model-dot  { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; transition: opacity var(--tr); background: var(--primary) }
.model-lbl  { font-size: 11px; color: var(--text-muted); transition: color var(--tr), opacity var(--tr), text-decoration var(--tr); }
.model-item.disabled .model-dot { opacity: .9; background: var(--secondary) }
.model-item.disabled .model-lbl { opacity: .9; }

/* Space / Tool items */
.space-item, .tool-item {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 10px 5px 24px; font-size: 11px;
  color: var(--text-muted); cursor: pointer; transition: background var(--tr), color var(--tr);
}
.space-item:hover { background: var(--bg-high); color: var(--primary); }
.space-item .icon, .tool-item .icon { font-size: 13px; }
.tool-item { justify-content: space-between; }
.tool-left  { display: flex; align-items: center; gap: 8px; }
.tool-item:hover .tool-left { color: var(--primary); }

/* Toggle */
.toggle { width: 26px; height: 13px; border-radius: 999px; background: rgba(186,158,255,.18); position: relative; cursor: pointer; transition: background .2s; flex-shrink: 0; }
.toggle.on { background: rgba(105,156,255,.28); }
.toggle-knob { width: 11px; height: 11px; border-radius: 50%; background: var(--primary); position: absolute; top: 1px; left: 1px; transition: left .2s ease, background .2s; }
.toggle.on .toggle-knob { left: 14px; background: var(--secondary); }

/* Sidebar footer */
.sb-footer { border-top: 1px solid var(--border); color: var(--text-muted); flex-shrink: 0; }
 
/* ── Logged-in footer ── */
.footer-user {
  padding: 10px 14px;
  display: flex; justify-content: space-between; align-items: center;
}
.footer-user .icon { font-size: 20px; cursor: pointer; transition: color var(--tr); }
.footer-user .icon:hover { color: var(--primary); }
.footer-user-info { display: flex; align-items: center; gap: 9px; flex: 1; min-width: 0; }
.footer-avatar {
  width: 26px; height: 26px; border-radius: 50%;
  object-fit: cover; flex-shrink: 0;
  border: 1px solid var(--outline);
}
.footer-avatar-placeholder {
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--primary-dim); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; color: #fff;
  border: 1px solid var(--outline);
}
.footer-username {
  font-size: 11px; font-weight: 600; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
 
/* ── Logged-out footer ── */
.footer-auth {
  padding: 12px 14px;
  display: flex; flex-direction: column; gap: 8px;
}
.footer-auth-label {
  font-size: 10px; color: var(--text-muted);
  letter-spacing: .04em; line-height: 1.4;
}
.btn-google {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 7px 10px;
  background: var(--bg-high); border: 1px solid var(--outline);
  color: var(--text); font-family: var(--font-ui);
  font-size: 11px; font-weight: 600;
  cursor: pointer; transition: background var(--tr), border-color var(--tr);
  width: 100%;
}
.btn-google:hover { background: var(--bg-bright); border-color: var(--primary); color: var(--primary); }
.btn-google svg { flex-shrink: 0; }
 
.notif-wrap { position: relative; display: inline-flex; }
.notif-badge { position: absolute; top: -4px; right: -5px; background: var(--tertiary); color: #fff; font-size: 8px; font-weight: 700; min-width: 14px; height: 14px; border-radius: 50%; display: flex; align-items: center; justify-content: center; }
 
.notif-wrap { position: relative; display: inline-flex; }
.notif-badge { position: absolute; top: -4px; right: -5px; background: var(--tertiary); color: #fff; font-size: 8px; font-weight: 700; min-width: 14px; height: 14px; border-radius: 50%; display: flex; align-items: center; justify-content: center; }

/* ── RESIZE HANDLE ──────────────────────────────────────────── */
#resize-handle {
  width: 4px; flex-shrink: 0;
  background: transparent;
  cursor: col-resize;
  position: relative;
  transition: background var(--tr);
  z-index: 10;
}
#resize-handle:hover,
#resize-handle.dragging { background: var(--primary-dim); }
#resize-handle::after {
  content: '';
  position: absolute; inset: 0 -3px;
}
#sidebar.hidden-sb + #resize-handle {
  display: none;
}

/* ── SIDEBAR TOGGLE BUTTON ──────────────────────────────────── */
#sb-toggle {
  position: absolute;
  left: 0; top: 50%;
  transform: translateY(-50%);
  z-index: 100;
  width: 18px; height: 42px;
  background: var(--bg-high);
  border: 1px solid var(--border);
  border-left: none;
  border-radius: 0 4px 4px 0;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: background var(--tr), transform 0.22s cubic-bezier(.4,0,.2,1);
  color: var(--text-muted);
}
#sb-toggle:hover { background: var(--bg-bright); color: var(--primary); }
#sb-toggle .icon { font-size: 14px; transition: transform 0.22s ease; }
#sb-toggle.collapsed .icon { transform: rotate(180deg); }

/* ── MAIN ───────────────────────────────────────────────────── */
#main { 
  flex: 1; 
  display: flex; 
  flex-direction: column; 
  overflow: hidden; 
  position: relative; 
}

/* Workspace */
#workspace { flex: 1; overflow-y: auto; background: var(--black); padding: 24px; }
#msg-container { max-width: 800px; margin: 0 auto; display: flex; flex-direction: column; gap: 24px; }

@keyframes slideUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.msg-in { animation: slideUp .28s ease forwards; }

/* User message */
.user-label { display: flex; align-items: center; gap: 6px; font-family: var(--font-mono); font-size: 10px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .12em; margin-bottom: 6px; }
.user-label .icon { font-size: 12px; }
.user-label .mini-switch { margin-left: auto; }
.user-bubble { background: var(--bg-mid); border-left: 2px solid var(--primary-dim); padding: 14px 16px; }
.user-bubble p { font-family: var(--font-mono); font-size: 13px; color: var(--text); line-height: 1.65; }

/* Responses */
.responses-wrap { display: flex; flex-direction: column; gap: 10px; }

/* Panel */
.model-panel { border: 1px solid var(--border); background: var(--bg-low); transition: border-color var(--tr), opacity var(--tr); }
.model-panel.collapsed { opacity: .65; }
.model-panel.collapsed:hover { opacity: 1; }
.model-panel:hover { border-color: var(--outline); }

.panel-hdr { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; cursor: pointer; transition: background var(--tr); }
.model-panel:not(.collapsed) .panel-hdr { background: var(--bg-high); }
.panel-hdr-left { display: flex; align-items: center; gap: 10px; }
.panel-arrow { font-size: 16px; transition: transform .2s ease; }
.panel-name  { font-size: 10px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; }
.panel-hdr-right { display: flex; align-items: center; gap: 8px; }

.status-badge { font-family: var(--font-mono); font-size: 9px; padding: 2px 8px; border: 1px solid; }

.panel-copy { font-size: 14px; color: var(--text-muted); cursor: pointer; transition: color var(--tr); }

/* Panel body */
.panel-body { overflow: hidden; max-height: 0; opacity: 0; transition: max-height .25s cubic-bezier(.4,0,.2,1), opacity .2s ease; }
.panel-body.open { max-height: 100%; opacity: 1; }
.panel-body-inner { padding: 16px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 14px; }
.panel-text { padding-left: 1%;font-size: 13px; color: var(--text-muted); line-height: 1.7; }
.panel-text code { background: var(--bg-highest); padding: 1px 5px; font-family: var(--font-mono); font-size: 12px; }

/* Code block */
.code-block { background: var(--black); border: 1px solid var(--outline); padding: 14px 16px; overflow-x: auto; position: relative; }
.code-block:hover .code-copy-btn { opacity: 1; }
.code-block pre { font-family: var(--font-mono); font-size: 12px; line-height: 1.7; color: #d1d5db; }
.code-copy-btn {
  position: absolute; top: 8px; right: 8px;
  background: var(--bg-high); border: 1px solid rgba(186,158,255,.3);
  color: var(--primary); font-family: var(--font-mono); font-size: 10px;
  padding: 3px 8px; cursor: pointer; opacity: 0; transition: opacity var(--tr), background var(--tr);
}
.code-copy-btn:hover { background: var(--bg-bright); }

/* Syntax */
.syn-kw  { color: var(--secondary); }
.syn-fn  { color: var(--primary); }
.syn-cmt { color: var(--tertiary); }

/* ── MINI SWITCH ────────────────────────────────────────────── */
.mini-switch {
  display: inline-flex; align-items: center;
  width: 28px; height: 15px;
  border-radius: 999px;
  background: var(--bg-highest);
  border: 1px solid var(--outline);
  position: relative; cursor: pointer;
  flex-shrink: 0;
  transition: background .2s, border-color .2s;
}
.mini-switch.on {
  background: rgba(186,158,255,.12);
  border-color: var(--sw-on, var(--primary));
}
.mini-switch-knob {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--outline-dim);
  position: absolute; left: 2px;
  transition: left .18s ease, background .18s;
}
.mini-switch.on .mini-switch-knob {
  left: 15px;
  background: var(--sw-on, var(--primary));
}

/* ── PROMPT BAR ─────────────────────────────────────────────── */
#prompt-bar { background: var(--bg-low); border-top: 1px solid var(--border); padding: 13px 16px; display: flex; flex-direction: column; gap: 10px; }

.prompt-meta { display: flex; align-items: center; gap: 8px; font-family: var(--font-mono); font-size: 10px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .08em; flex-wrap: wrap; }
.prompt-meta .sep { color: var(--outline-dim); }
.prompt-meta .kw  { font-weight: 700; }
.prompt-meta select { background: transparent; border: none; color: var(--text-muted); font-family: var(--font-mono); font-size: 10px; text-transform: uppercase; cursor: pointer; outline: none; }
.prompt-meta select:hover { color: var(--primary); }
.prompt-meta select option { background: var(--bg-high); }

.prompt-wrap { display: flex; align-items: flex-end; gap: 10px; background: var(--black); border: 1px solid var(--border); padding: 10px 12px; transition: border-color var(--tr); }
.prompt-wrap:focus-within { border-color: var(--primary); }

.prompt-ta { flex: 1; background: transparent; border: none; outline: none; color: var(--text); font-family: var(--font-mono); font-size: 13px; resize: none; line-height: 1.6; }
.prompt-ta::placeholder { color: var(--text-muted); }

.prompt-actions { display: flex; flex-direction: column; gap: 6px; }

.btn { display: flex; align-items: center; gap: 6px; border: none; cursor: pointer; font-family: var(--font-ui); font-weight: 700; text-transform: uppercase; letter-spacing: .1em; transition: background var(--tr), opacity var(--tr); position: relative; overflow: hidden; }
.btn:active { opacity: .8; }
.btn .icon { font-size: 14px; }

.btn-ask { background: var(--primary); color: #39008c; font-size: 11px; padding: 8px 14px; }
.btn-ask:hover { background: var(--primary-dim); color: var(--text); }

.btn-sync { background: var(--bg-high); color: var(--secondary); font-size: 10px; padding: 6px 14px; }
.btn-sync:hover { background: var(--bg-bright); }

.new-chat-btn {  display: flex; align-items: center; gap: 8px;  padding: 5px 10px 5px 24px;  font-size: 11px; font-weight: 600;  color: var(--primary);  cursor: pointer;  border-bottom: 1px solid var(--border);  margin-top: 2px;  transition: background var(--tr);  letter-spacing: .04em;}
.new-chat-btn:hover { background: var(--bg-high); }

/* Ripple */
@keyframes ripple { from { transform: scale(0); opacity: .4; } to { transform: scale(5); opacity: 0; } }
.ripple-dot { position: absolute; width: 18px; height: 18px; border-radius: 50%; background: rgba(255,255,255,.3); pointer-events: none; animation: ripple .4s ease forwards; }

/* ── STATUS BAR ─────────────────────────────────────────────── */
#status-bar { height: 24px; background: var(--primary-dim); color: #000; display: flex; align-items: center; justify-content: space-between; padding: 0 12px; font-size: 10px; font-weight: 600; letter-spacing: .05em; }
#status-bar .icon { font-size: 11px; }
.st-left, .st-right { display: flex; align-items: center; gap: 14px; }
.st-item { display: flex; align-items: center; gap: 4px; }

@keyframes syncPulse { 0%,100%{ background: var(--primary-dim); } 50%{ background: var(--primary); } }
.syncing { animation: syncPulse .7s ease 4; }

/* ── NOTIF PANEL ────────────────────────────────────────────── */
#notif-panel { position: fixed; right: 16px; bottom: 34px; width: 280px; background: var(--bg-high); border: 1px solid var(--border); box-shadow: 0 10px 40px rgba(0,0,0,.7); z-index: 300; display: none; }
#notif-panel.open { display: block; }
.notif-hdr { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.notif-hdr-title { font-size: 10px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--primary); }
.notif-hdr .icon { font-size: 14px; color: var(--text-muted); cursor: pointer; }
.notif-hdr .icon:hover { color: var(--tertiary); }
.notif-list { max-height: 240px; overflow-y: auto; padding: 8px; display: flex; flex-direction: column; gap: 4px; }
.notif-item { padding: 8px 10px; background: var(--bg-mid); border-left: 2px solid var(--primary); font-size: 11px; animation: slideUp .2s ease; }
.notif-item-title { font-weight: 700; margin-bottom: 2px; }
.notif-item-msg { color: var(--text-muted); }

/* ── TOAST ──────────────────────────────────────────────────── */
#toast { position: fixed; bottom: 36px; left: 50%; transform: translateX(-50%) translateY(6px); background: var(--bg-high); border: 1px solid rgba(186,158,255,.4); color: var(--primary); font-family: var(--font-mono); font-size: 11px; padding: 7px 16px; z-index: 400; opacity: 0; pointer-events: none; transition: opacity .2s ease, transform .2s ease; box-shadow: 0 4px 20px rgba(0,0,0,.5); }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
