/* ════════════════════════════════════════════════════════
   JARVIS — Complete Design System
   Professional, minimal, accessible. No neons. No sci-fi.
   ════════════════════════════════════════════════════════ */

/* ── Design Tokens ────────────────────────────────────── */
:root {
  --font: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  --mono: 'JetBrains Mono', 'Cascadia Code', 'Fira Code', monospace;

  --r-xs: 4px;  --r-sm: 6px;  --r-md: 10px;
  --r-lg: 14px; --r-xl: 20px; --r-2xl: 28px; --r-full: 9999px;

  --shadow-xs: 0 1px 2px rgba(0,0,0,.06);
  --shadow-sm: 0 2px 6px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md: 0 4px 16px rgba(0,0,0,.10), 0 2px 6px rgba(0,0,0,.06);
  --shadow-lg: 0 12px 40px rgba(0,0,0,.16), 0 4px 12px rgba(0,0,0,.08);

  --ease: cubic-bezier(.4,0,.2,1);
  --spring: cubic-bezier(.34,1.56,.64,1);
  --t1: 100ms; --t2: 200ms; --t3: 320ms; --t4: 480ms;

  --sidebar-width: 248px;
  --topbar-h: 52px;
}

/* ── Dark Theme ──────────────────────────────────────── */
[data-theme="dark"] {
  --bg:           #0d1117;
  --bg-surf:      #161b24;
  --bg-elev:      #1e2635;
  --bg-hover:     #232d40;
  --bg-active:    #29364d;
  --bg-input:     #1a2233;

  --border:       rgba(255,255,255,.072);
  --border-sub:   rgba(255,255,255,.038);
  --border-focus: rgba(255,255,255,.2);
  --border-strong:rgba(255,255,255,.14);

  --text-1:  #e2e8f4;
  --text-2:  #8c96ab;
  --text-3:  #5a6275;
  --text-inv:#0d1117;

  --accent:       #4f7dff;
  --accent-h:     #6691ff;
  --accent-muted: rgba(79,125,255,.12);
  --accent-text:  #dde6ff;

  --green:        #3db87a;
  --green-muted:  rgba(61,184,122,.12);
  --amber:        #d9943a;
  --amber-muted:  rgba(217,148,58,.12);
  --red:          #d95454;
  --red-muted:    rgba(217,84,84,.12);

  --tok-fill:     #3db87a;

  --scrollbar: rgba(255,255,255,.07);
}

/* ── Light Theme ─────────────────────────────────────── */
[data-theme="light"] {
  --bg:           #f3f5f7;
  --bg-surf:      #ffffff;
  --bg-elev:      #edf0f4;
  --bg-hover:     #e4e8ee;
  --bg-active:    #d8dde7;
  --bg-input:     #f8fafc;

  --border:       rgba(0,0,0,.082);
  --border-sub:   rgba(0,0,0,.04);
  --border-focus: rgba(0,0,0,.22);
  --border-strong:rgba(0,0,0,.14);

  --text-1:  #141820;
  --text-2:  #4a5368;
  --text-3:  #8898aa;
  --text-inv:#ffffff;

  --accent:       #3a6af5;
  --accent-h:     #2558e8;
  --accent-muted: rgba(58,106,245,.10);
  --accent-text:  #1e40af;

  --green:        #2e9f63;
  --green-muted:  rgba(46,159,99,.10);
  --amber:        #c07d20;
  --amber-muted:  rgba(192,125,32,.10);
  --red:          #c03535;
  --red-muted:    rgba(192,53,53,.10);

  --tok-fill:     #2e9f63;

  --scrollbar: rgba(0,0,0,.08);
}

/* ── Reset ────────────────────────────────────────────── */
*,*::before,*::after{box-sizing:border-box;margin:0;padding:0}
html{font-size:15px;-webkit-font-smoothing:antialiased;text-rendering:optimizeLegibility}
body{font-family:var(--font);background:var(--bg);color:var(--text-1);height:100dvh;overflow:hidden;transition:background var(--t3) var(--ease),color var(--t3) var(--ease)}
button,input,select,textarea{font-family:var(--font);font-size:inherit}
a{color:var(--accent);text-decoration:none}
a:hover{text-decoration:underline}
img,video{display:block;max-width:100%}
::-webkit-scrollbar{width:4px;height:4px}
::-webkit-scrollbar-track{background:transparent}
::-webkit-scrollbar-thumb{background:var(--scrollbar);border-radius:var(--r-full)}
::selection{background:var(--accent-muted);color:var(--accent-text)}
.hidden{display:none!important}
.sr-only{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0,0,0,0)}

/* ── Screens ─────────────────────────────────────────── */
.screen{position:fixed;inset:0;z-index:10}
.screen.active{display:flex}
.screen.hidden{display:none}

/* ══════════════════════════════════════════════════════
   AUTH SCREEN
══════════════════════════════════════════════════════ */
.screen-auth{align-items:center;justify-content:center;background:var(--bg)}

.auth-bg{position:absolute;inset:0;overflow:hidden;pointer-events:none}
.auth-bg-grid{
  position:absolute;inset:-20px;
  background-image:
    linear-gradient(var(--border-sub) 1px,transparent 1px),
    linear-gradient(90deg,var(--border-sub) 1px,transparent 1px);
  background-size:40px 40px;
  mask-image:radial-gradient(ellipse 70% 70% at 50% 50%,black 30%,transparent 100%);
  opacity:.5;
}

.auth-container{
  position:relative;z-index:1;
  display:flex;flex-direction:column;align-items:center;
  gap:1.5rem;width:100%;max-width:400px;padding:1.5rem;
}

.auth-brand{text-align:center}
.brand-logo{
  width:56px;height:56px;border-radius:50%;
  border:1.5px solid var(--border);background:var(--bg-surf);
  display:flex;align-items:center;justify-content:center;
  margin:0 auto 1rem;color:var(--accent);
  box-shadow:var(--shadow-sm);
}
.brand-logo svg{width:30px;height:30px}
.brand-name{font-size:1.75rem;font-weight:700;letter-spacing:-.03em;color:var(--text-1)}
.brand-tagline{font-size:.8rem;color:var(--text-3);margin-top:.2rem}

/* Profile selector */
.profile-selector{width:100%;text-align:center}
.profile-selector-label{font-size:.72rem;font-weight:600;letter-spacing:.06em;text-transform:uppercase;color:var(--text-3);margin-bottom:.75rem}
.profile-list{display:flex;flex-direction:column;gap:.4rem;margin-bottom:.75rem}
.profile-list-item{
  display:flex;align-items:center;gap:.75rem;
  padding:.7rem .9rem;border-radius:var(--r-md);
  background:var(--bg-surf);border:1px solid var(--border);
  cursor:pointer;transition:all var(--t1) var(--ease);
  text-align:left;width:100%;
}
.profile-list-item:hover{background:var(--bg-hover);border-color:var(--border-strong)}
.profile-list-item .pli-avatar{
  width:34px;height:34px;border-radius:50%;
  background:var(--accent-muted);color:var(--accent);
  display:flex;align-items:center;justify-content:center;
  font-size:.85rem;font-weight:700;flex-shrink:0;
}
.profile-list-item .pli-info p{font-size:.85rem;font-weight:500;color:var(--text-1)}
.profile-list-item .pli-info span{font-size:.72rem;color:var(--text-3)}

/* Auth card */
.auth-card{
  width:100%;background:var(--bg-surf);
  border:1px solid var(--border);border-radius:var(--r-xl);
  padding:1.75rem 1.5rem;box-shadow:var(--shadow-lg);
  animation:slideUp var(--t3) var(--ease);
}
.auth-card-header{display:flex;align-items:center;gap:.75rem;margin-bottom:1.25rem}
.auth-card-avatar{
  width:40px;height:40px;border-radius:50%;flex-shrink:0;
  background:var(--accent-muted);color:var(--accent);
  display:flex;align-items:center;justify-content:center;
  font-size:1rem;font-weight:700;
}
.auth-card-name{font-size:.9rem;font-weight:600;color:var(--text-1)}
.auth-card-sub{font-size:.75rem;color:var(--text-3)}
.auth-card-title{font-size:1.1rem;font-weight:700;letter-spacing:-.02em;color:var(--text-1);margin-bottom:.3rem}
.auth-card-subtitle{font-size:.8rem;color:var(--text-3);margin-bottom:1.25rem}

.back-btn{margin-right:.25rem}

/* Auth tabs */
.auth-tabs{
  display:flex;background:var(--bg-elev);
  border-radius:var(--r-md);padding:3px;gap:3px;margin-bottom:1.25rem;
}
.auth-tab{
  flex:1;padding:.42rem .6rem;border:none;background:transparent;
  border-radius:7px;font-size:.78rem;font-weight:500;
  color:var(--text-3);cursor:pointer;transition:all var(--t2) var(--ease);
}
.auth-tab.active{background:var(--bg-surf);color:var(--text-1);box-shadow:var(--shadow-xs)}

.auth-panel{display:none}
.auth-panel.active{display:block}

/* Biometric zone */
.biometric-zone{
  border:1.5px dashed var(--border);border-radius:var(--r-lg);
  padding:2rem 1.25rem;text-align:center;cursor:pointer;
  transition:all var(--t2) var(--ease);position:relative;overflow:hidden;
}
.biometric-zone:hover,.biometric-zone:focus{border-color:var(--accent);outline:none}
.biometric-zone:hover{background:var(--accent-muted)}
.bio-pulse{
  position:absolute;inset:0;border-radius:inherit;
  background:var(--accent-muted);opacity:0;
  animation:bioPulse 2s ease-in-out infinite;
}
.bio-icon{color:var(--text-3);margin-bottom:.75rem;transition:color var(--t2)}
.bio-icon svg{width:36px;height:36px;margin:0 auto}
.biometric-zone:hover .bio-icon{color:var(--accent)}
.biometric-zone p{font-size:.85rem;font-weight:500;color:var(--text-2);margin-bottom:.3rem}
.bio-status{font-size:.72rem;color:var(--text-3)}

/* Password strength */
.password-strength{margin-top:.4rem}
.strength-bar{height:3px;border-radius:var(--r-full);background:var(--border);overflow:hidden;margin-bottom:.3rem}
.strength-fill{height:100%;border-radius:var(--r-full);width:0;transition:width var(--t2),background var(--t2)}
.strength-label{font-size:.7rem;color:var(--text-3)}

.auth-feedback{min-height:1.2em;font-size:.78rem;text-align:center;padding:.25rem 0}
.auth-feedback.error{color:var(--red)}
.auth-feedback.success{color:var(--green)}
.auth-feedback.info{color:var(--text-3)}

.auth-footer{
  display:flex;align-items:center;gap:.5rem;flex-wrap:wrap;justify-content:center;
  font-size:.7rem;color:var(--text-3);
}
.auth-footer-sep{opacity:.35}

/* ══════════════════════════════════════════════════════
   APP LAYOUT
══════════════════════════════════════════════════════ */
.screen-app{display:flex;overflow:hidden}

/* ── Sidebar ─────────────────────────────────────────── */
.sidebar{
  width:var(--sidebar-width);min-width:var(--sidebar-width);
  background:var(--bg-surf);border-right:1px solid var(--border);
  display:flex;flex-direction:column;height:100%;
  transition:width var(--t3) var(--ease),min-width var(--t3) var(--ease),transform var(--t3) var(--ease);
  overflow:hidden;position:relative;z-index:20;flex-shrink:0;
}
.sidebar.collapsed{width:56px;min-width:56px}
.sidebar.collapsed .sidebar-brand-name,
.sidebar.collapsed .nav-item span,
.sidebar.collapsed .new-chat-btn span,
.sidebar.collapsed .sidebar-section,
.sidebar.collapsed .mini-token-meter,
.sidebar.collapsed .sidebar-status,
.sidebar.collapsed .profile-info,
.sidebar.collapsed .profile-name,
.sidebar.collapsed .profile-sub{opacity:0;width:0;overflow:hidden;pointer-events:none}

.sidebar-head{
  display:flex;align-items:center;justify-content:space-between;
  padding:.85rem .7rem .7rem;flex-shrink:0;
  border-bottom:1px solid var(--border-sub);
}
.sidebar-brand{display:flex;align-items:center;gap:.55rem;overflow:hidden;min-width:0}
.brand-logo-sm{
  color:var(--accent);flex-shrink:0;
  width:26px;height:26px;display:flex;align-items:center;justify-content:center;
}
.brand-logo-sm svg{width:22px;height:22px}
.sidebar-brand-name{
  font-size:.9rem;font-weight:700;letter-spacing:-.02em;
  color:var(--text-1);white-space:nowrap;transition:opacity var(--t2),width var(--t3);
}

.new-chat-btn{
  display:flex;align-items:center;gap:.55rem;
  margin:.6rem .6rem .25rem;padding:.52rem .7rem;
  background:var(--accent);color:white;border:none;border-radius:var(--r-md);
  font-size:.8rem;font-weight:600;cursor:pointer;white-space:nowrap;overflow:hidden;
  transition:background var(--t1),transform var(--t1);
}
.new-chat-btn svg{width:14px;height:14px;flex-shrink:0}
.new-chat-btn:hover{background:var(--accent-h)}
.new-chat-btn:active{transform:scale(.97)}

/* Sidebar nav */
.sidebar-nav{display:flex;flex-direction:column;gap:1px;padding:.25rem .5rem}
.nav-item{
  display:flex;align-items:center;gap:.65rem;
  padding:.52rem .6rem;border-radius:var(--r-sm);
  font-size:.82rem;font-weight:500;color:var(--text-2);
  background:none;border:none;cursor:pointer;
  text-align:left;white-space:nowrap;overflow:hidden;
  transition:all var(--t1) var(--ease);
}
.nav-item svg{width:15px;height:15px;flex-shrink:0}
.nav-item:hover{background:var(--bg-hover);color:var(--text-1)}
.nav-item.active{background:var(--accent-muted);color:var(--accent)}

/* Chat history */
.sidebar-section{flex:1;overflow-y:auto;padding:.25rem .5rem;min-height:0}
.sidebar-section-label{
  font-size:.66rem;font-weight:600;letter-spacing:.07em;text-transform:uppercase;
  color:var(--text-3);padding:.5rem .4rem .3rem;transition:opacity var(--t2);
}
.chat-history-list{display:flex;flex-direction:column;gap:1px}
.chat-history-item{
  display:flex;align-items:center;gap:.55rem;
  padding:.45rem .55rem;border-radius:var(--r-sm);
  cursor:pointer;font-size:.8rem;color:var(--text-2);
  transition:all var(--t1);white-space:nowrap;overflow:hidden;
}
.chat-history-item:hover{background:var(--bg-hover);color:var(--text-1)}
.chat-history-item.active{background:var(--bg-active);color:var(--text-1)}
.chat-history-item svg{width:12px;height:12px;flex-shrink:0;opacity:.5}
.chi-text{flex:1;overflow:hidden;text-overflow:ellipsis}
.chi-del{
  opacity:0;background:none;border:none;cursor:pointer;
  color:var(--text-3);padding:.15rem;border-radius:3px;flex-shrink:0;
  transition:opacity var(--t1),color var(--t1);
}
.chat-history-item:hover .chi-del{opacity:1}
.chi-del:hover{color:var(--red)}
.chi-del svg{width:11px;height:11px}

/* Sidebar bottom */
.sidebar-bottom{
  border-top:1px solid var(--border-sub);
  padding:.65rem .6rem;display:flex;flex-direction:column;gap:.5rem;flex-shrink:0;
}

/* Mini token meter */
.mini-token-meter{
  background:var(--bg-elev);border:1px solid var(--border);
  border-radius:var(--r-sm);padding:.55rem .65rem;cursor:pointer;
  transition:background var(--t1);
}
.mini-token-meter:hover{background:var(--bg-hover)}
.mini-token-head{display:flex;justify-content:space-between;align-items:center;margin-bottom:.35rem}
.mini-token-head span{font-size:.7rem;color:var(--text-3)}
.mini-token-head span:last-child{font-family:var(--mono);font-size:.68rem;color:var(--text-2)}
.mini-token-track{height:3px;border-radius:var(--r-full);background:var(--border);overflow:hidden}
.mini-token-fill{height:100%;border-radius:var(--r-full);background:var(--tok-fill);transition:width var(--t4) var(--ease),background var(--t2)}

/* Sidebar status */
.sidebar-status{display:flex;gap:.75rem;padding:0 .1rem}
.status-badge{display:flex;align-items:center;gap:.35rem;font-size:.7rem;color:var(--text-3)}

/* Sidebar profile */
.sidebar-profile{
  display:flex;align-items:center;gap:.6rem;
  padding:.45rem .35rem;border-radius:var(--r-sm);cursor:pointer;
  transition:background var(--t1);min-width:0;
}
.sidebar-profile:hover{background:var(--bg-hover)}
.profile-avatar{
  width:30px;height:30px;border-radius:50%;flex-shrink:0;
  background:var(--accent-muted);color:var(--accent);
  display:flex;align-items:center;justify-content:center;
  font-size:.78rem;font-weight:700;
}
.profile-info{flex:1;min-width:0;overflow:hidden}
.profile-name{font-size:.8rem;font-weight:500;color:var(--text-1);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.profile-sub{font-size:.68rem;color:var(--text-3)}

/* ── Main Content ────────────────────────────────────── */
.main-content{
  flex:1;display:flex;flex-direction:column;
  height:100%;overflow:hidden;background:var(--bg);min-width:0;
}

/* ── Topbar ──────────────────────────────────────────── */
.topbar{
  display:flex;align-items:center;justify-content:space-between;
  padding:.65rem 1.25rem;height:var(--topbar-h);
  background:var(--bg-surf);border-bottom:1px solid var(--border);
  flex-shrink:0;gap:.75rem;
}
.topbar-left{display:flex;align-items:center;gap:.65rem;min-width:0}
.topbar-title{font-size:.9rem;font-weight:600;letter-spacing:-.01em;white-space:nowrap}
.topbar-sub{font-size:.75rem;color:var(--text-3);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.topbar-right{display:flex;align-items:center;gap:.3rem;flex-shrink:0}

#mobile-menu-btn{display:none}

.model-badge{
  display:flex;align-items:center;gap:.4rem;
  font-size:.72rem;color:var(--text-3);
  padding:.25rem .55rem;border-radius:var(--r-full);
  background:var(--bg-elev);border:1px solid var(--border);
}
.offline-badge{
  display:flex;align-items:center;gap:.35rem;
  font-size:.72rem;color:var(--amber);
  padding:.25rem .55rem;border-radius:var(--r-full);
  background:var(--amber-muted);border:1px solid rgba(217,148,58,.25);
}
.offline-badge svg{width:12px;height:12px}

/* ── Views ───────────────────────────────────────────── */
.view{display:none;flex:1;overflow:hidden;flex-direction:column}
.view.active{display:flex}

.view-layout{
  flex:1;overflow-y:auto;padding:1.5rem;
  display:flex;flex-direction:column;gap:1.25rem;
}
.view-header{margin-bottom:.5rem}
.view-header h3{font-size:1.1rem;font-weight:700;letter-spacing:-.02em;margin-bottom:.25rem}
.view-header p{font-size:.82rem;color:var(--text-3);line-height:1.55}

/* ══════════════════════════════════════════════════════
   CHAT VIEW
══════════════════════════════════════════════════════ */
.chat-layout{
  display:flex;flex-direction:column;
  height:100%;overflow:hidden;
}

.messages-area{
  flex:1;overflow-y:auto;overflow-x:hidden;
  padding:1.5rem 0;display:flex;flex-direction:column;
}

/* Welcome state */
.welcome-state{
  flex:1;display:flex;flex-direction:column;
  align-items:center;justify-content:center;
  text-align:center;padding:2rem 1.5rem;
  animation:fadeIn var(--t3) var(--ease);
}
.welcome-logo{
  width:56px;height:56px;margin-bottom:1.5rem;
  color:var(--accent);opacity:.55;
}
.welcome-logo svg{width:56px;height:56px}
.welcome-state h2{
  font-size:1.5rem;font-weight:700;letter-spacing:-.03em;
  color:var(--text-1);margin-bottom:.4rem;
}
.welcome-state p{font-size:.875rem;color:var(--text-2);margin-bottom:1.75rem}
.welcome-state p strong{color:var(--text-1)}

.quick-chips{display:flex;flex-wrap:wrap;gap:.45rem;justify-content:center;max-width:540px}
.chip{
  background:var(--bg-surf);border:1px solid var(--border);
  border-radius:var(--r-full);padding:.4rem .9rem;
  font-size:.78rem;color:var(--text-2);cursor:pointer;
  transition:all var(--t1) var(--ease);
}
.chip:hover{background:var(--bg-hover);color:var(--text-1);border-color:var(--border-strong)}

/* Ollama notice */
.setup-notice{
  display:flex;align-items:flex-start;gap:.75rem;
  background:var(--amber-muted);border:1px solid rgba(217,148,58,.3);
  border-radius:var(--r-md);padding:.85rem 1rem;
  text-align:left;max-width:480px;margin-top:1.5rem;
}
.setup-notice svg{width:16px;height:16px;color:var(--amber);flex-shrink:0;margin-top:.15rem}
.setup-notice div{flex:1}
.setup-notice strong{font-size:.82rem;color:var(--text-1)}
.setup-notice p{font-size:.78rem;color:var(--text-2);margin-top:.2rem;line-height:1.5}
.setup-notice code{font-family:var(--mono);font-size:.75rem;background:var(--bg-elev);padding:.1em .3em;border-radius:3px}

/* Messages list */
.messages-list{
  display:flex;flex-direction:column;
  max-width:760px;width:100%;margin:0 auto;padding:0 1.25rem;
}

/* Message bubble */
.message{
  display:flex;flex-direction:column;
  padding:.85rem 0;
  border-bottom:1px solid var(--border-sub);
  animation:fadeIn var(--t2) var(--ease);
}
.message:last-child{border-bottom:none}

.message-header{
  display:flex;align-items:center;gap:.5rem;margin-bottom:.6rem;
}
.msg-avatar{
  width:22px;height:22px;border-radius:50%;
  display:flex;align-items:center;justify-content:center;
  font-size:.62rem;font-weight:700;flex-shrink:0;
}
.message.user .msg-avatar{background:var(--accent-muted);color:var(--accent)}
.message.assistant .msg-avatar{background:var(--bg-elev);color:var(--text-2)}
.msg-role{font-size:.73rem;font-weight:600;color:var(--text-3)}
.msg-time{font-size:.66rem;color:var(--text-3);margin-left:auto}
.msg-mode-badge{
  font-size:.62rem;padding:.1rem .4rem;border-radius:var(--r-full);
  background:var(--bg-elev);color:var(--text-3);border:1px solid var(--border);
}

.message-body{
  font-size:.875rem;line-height:1.7;color:var(--text-1);
  padding-left:1.85rem;
}
.message-body p{margin-bottom:.6rem}
.message-body p:last-child{margin-bottom:0}
.message-body h1,.message-body h2,.message-body h3,.message-body h4{
  font-weight:600;letter-spacing:-.01em;margin:.8rem 0 .4rem;
}
.message-body h1{font-size:1.1rem}
.message-body h2{font-size:1rem}
.message-body h3{font-size:.95rem}
.message-body h4{font-size:.88rem}
.message-body ul,.message-body ol{padding-left:1.4rem;margin:.4rem 0}
.message-body li{margin-bottom:.3rem}
.message-body strong{font-weight:600}
.message-body em{font-style:italic}
.message-body code{
  font-family:var(--mono);font-size:.8em;
  background:var(--bg-elev);border-radius:3px;
  padding:.1em .4em;border:1px solid var(--border-sub);
}
.message-body pre{
  background:var(--bg-elev);border:1px solid var(--border);
  border-radius:var(--r-md);padding:1rem;margin:.75rem 0;overflow-x:auto;
  position:relative;
}
.message-body pre code{background:none;border:none;padding:0;font-size:.82rem;line-height:1.65}
.pre-copy{
  position:absolute;top:.5rem;right:.5rem;
  background:var(--bg-hover);border:1px solid var(--border);border-radius:var(--r-xs);
  padding:.2rem .5rem;font-size:.68rem;cursor:pointer;color:var(--text-3);
  transition:all var(--t1);
}
.pre-copy:hover{color:var(--text-1);background:var(--bg-active)}
.message-body blockquote{
  border-left:3px solid var(--accent);padding-left:.85rem;margin:.5rem 0;
  color:var(--text-2);font-style:italic;
}
.message-body table{width:100%;border-collapse:collapse;margin:.75rem 0;font-size:.82rem}
.message-body th,.message-body td{padding:.5rem .75rem;border:1px solid var(--border);text-align:left}
.message-body th{background:var(--bg-elev);font-weight:600}
.message-body a{color:var(--accent)}
.message-body hr{border:none;border-top:1px solid var(--border);margin:1rem 0}

/* Message image */
.msg-image{
  max-width:320px;border-radius:var(--r-md);
  border:1px solid var(--border);margin-bottom:.6rem;
  margin-left:1.85rem;
}

/* Message actions */
.message-actions{
  display:flex;gap:.2rem;margin-top:.4rem;padding-left:1.85rem;
  opacity:0;transition:opacity var(--t1);
}
.message:hover .message-actions,.message:focus-within .message-actions{opacity:1}
.msg-act-btn{
  display:flex;align-items:center;gap:.3rem;
  background:none;border:none;cursor:pointer;
  font-size:.7rem;color:var(--text-3);
  padding:.2rem .5rem;border-radius:var(--r-xs);
  transition:all var(--t1);
}
.msg-act-btn svg{width:11px;height:11px}
.msg-act-btn:hover{background:var(--bg-hover);color:var(--text-1)}
.msg-act-btn.danger:hover{color:var(--red)}

/* Thinking animation */
.thinking-indicator{
  display:flex;align-items:center;gap:.6rem;
  padding:.85rem 0;border-bottom:1px solid var(--border-sub);
}
.thinking-avatar{
  width:22px;height:22px;border-radius:50%;
  background:var(--bg-elev);display:flex;align-items:center;justify-content:center;
  font-size:.62rem;color:var(--text-2);font-weight:700;flex-shrink:0;margin-right:.25rem;
}
.thinking-dots{display:flex;gap:4px;align-items:center;padding-left:1.85rem}
.thinking-dots span{
  width:5px;height:5px;border-radius:50%;background:var(--text-3);
  animation:dotPop .9s ease-in-out infinite;
}
.thinking-dots span:nth-child(2){animation-delay:.15s}
.thinking-dots span:nth-child(3){animation-delay:.3s}

/* Web search result style */
.web-results-block{
  background:var(--bg-elev);border:1px solid var(--border);
  border-radius:var(--r-md);padding:.85rem;margin:.6rem 0;font-size:.8rem;
}
.web-results-block h5{font-size:.75rem;font-weight:600;color:var(--text-3);margin-bottom:.5rem;letter-spacing:.04em;text-transform:uppercase}
.web-result-item{padding:.4rem 0;border-bottom:1px solid var(--border-sub)}
.web-result-item:last-child{border-bottom:none}
.web-result-item a{font-size:.8rem;font-weight:500}
.web-result-item p{font-size:.75rem;color:var(--text-3);margin-top:.15rem;line-height:1.5}

/* ── Input Area ──────────────────────────────────────── */
.input-area{
  border-top:1px solid var(--border);
  padding:.75rem 1.25rem .9rem;
  background:var(--bg-surf);flex-shrink:0;
}
.attach-previews{display:flex;gap:.45rem;flex-wrap:wrap;margin-bottom:.5rem}
.attach-thumb-wrap{position:relative;width:54px;height:54px;border-radius:var(--r-sm);overflow:hidden;border:1px solid var(--border);background:var(--bg-elev)}
.attach-thumb-wrap img{width:100%;height:100%;object-fit:cover}
.attach-thumb-file{
  width:54px;height:54px;border-radius:var(--r-sm);border:1px solid var(--border);
  background:var(--bg-elev);display:flex;flex-direction:column;align-items:center;
  justify-content:center;gap:.1rem;font-size:.55rem;color:var(--text-3);
  text-align:center;padding:.25rem;overflow:hidden;
}
.attach-thumb-file .att-ext{font-size:.7rem;font-weight:700;color:var(--accent)}
.attach-remove{
  position:absolute;top:2px;right:2px;
  width:16px;height:16px;border-radius:50%;
  background:rgba(0,0,0,.7);color:white;border:none;cursor:pointer;
  font-size:.65rem;display:flex;align-items:center;justify-content:center;line-height:1;
}

.input-shell{display:flex;gap:.5rem;align-items:flex-end}
.input-box{
  flex:1;background:var(--bg-input);border:1px solid var(--border);
  border-radius:var(--r-xl);overflow:hidden;transition:border-color var(--t1);
}
.input-box:focus-within{border-color:var(--border-focus)}
.chat-textarea{
  display:block;width:100%;background:none;border:none;outline:none;resize:none;
  font-size:.875rem;color:var(--text-1);line-height:1.6;
  padding:.8rem 1.1rem .4rem;max-height:200px;overflow-y:auto;
}
.chat-textarea::placeholder{color:var(--text-3)}

.input-toolbar{
  display:flex;align-items:center;justify-content:space-between;
  padding:.3rem .55rem .55rem;
}
.input-toolbar-left,.input-toolbar-right{display:flex;align-items:center;gap:.15rem}
.input-action{width:28px;height:28px;color:var(--text-3)}
.input-action:hover{color:var(--text-2);background:var(--bg-hover)}
.input-action.active{color:var(--accent);background:var(--accent-muted)}
.char-counter{font-size:.67rem;color:var(--text-3);font-family:var(--mono)}

.mic-btn.recording{color:var(--red);animation:pulse 1.2s ease infinite}
.mic-btn.recording:hover{background:var(--red-muted)}

.send-btn{
  width:32px;height:32px;border-radius:var(--r-sm);
  background:var(--accent);border:none;cursor:pointer;
  display:flex;align-items:center;justify-content:center;
  color:white;flex-shrink:0;
  transition:background var(--t1),transform var(--t1),opacity var(--t1);
}
.send-btn svg{width:13px;height:13px}
.send-btn:hover:not(:disabled){background:var(--accent-h)}
.send-btn:active:not(:disabled){transform:scale(.9)}
.send-btn:disabled{opacity:.3;cursor:not-allowed}

.input-disclaimer{
  font-size:.67rem;color:var(--text-3);text-align:center;
  margin-top:.5rem;display:flex;align-items:center;justify-content:center;gap:.3rem;
}
.input-disclaimer svg{width:10px;height:10px}
.web-search-indicator{color:var(--amber)}

/* ══════════════════════════════════════════════════════
   CAMERA VIEW
══════════════════════════════════════════════════════ */
.camera-layout{display:grid;grid-template-columns:1fr 340px;gap:1rem;min-height:0}
.camera-feed-container{
  position:relative;background:var(--bg-elev);border-radius:var(--r-lg);
  overflow:hidden;aspect-ratio:16/10;
}
.camera-placeholder{
  display:flex;flex-direction:column;align-items:center;justify-content:center;
  height:100%;gap:1rem;color:var(--text-3);
}
.camera-placeholder svg{width:48px;height:48px;opacity:.4}
.camera-placeholder p{font-size:.85rem;color:var(--text-3)}
.camera-video{width:100%;height:100%;object-fit:cover}

/* Camera HUD */
.camera-hud{
  position:absolute;inset:0;display:flex;flex-direction:column;
  justify-content:space-between;pointer-events:none;
}
.camera-hud>*{pointer-events:all}
.hud-top{
  display:flex;align-items:flex-start;justify-content:space-between;
  padding:.75rem;
}
.cam-indicator{
  display:flex;align-items:center;gap:.4rem;
  background:rgba(0,0,0,.5);color:white;
  font-size:.68rem;font-weight:700;letter-spacing:.08em;
  padding:.3rem .6rem;border-radius:var(--r-full);
  backdrop-filter:blur(4px);
}
.cam-rec-dot{
  width:7px;height:7px;border-radius:50%;background:#f44;
  animation:pulse 1.2s ease infinite;
}
.cam-controls-top{display:flex;gap:.4rem}
.hud-btn{
  width:34px;height:34px;border-radius:50%;
  background:rgba(0,0,0,.45);backdrop-filter:blur(4px);
  border:1px solid rgba(255,255,255,.15);color:white;cursor:pointer;
  display:flex;align-items:center;justify-content:center;
  transition:all var(--t1);
}
.hud-btn:hover{background:rgba(0,0,0,.65)}
.hud-btn.danger:hover{background:rgba(192,53,53,.6)}
.hud-btn svg{width:15px;height:15px}
.hud-bottom{
  display:flex;flex-direction:column;align-items:center;
  padding:1rem;gap:.5rem;
}
.capture-btn{
  width:56px;height:56px;border-radius:50%;
  background:rgba(255,255,255,.9);border:3px solid rgba(255,255,255,.5);
  cursor:pointer;position:relative;transition:transform var(--t1);
  display:flex;align-items:center;justify-content:center;
}
.capture-btn:hover{transform:scale(1.08)}
.capture-btn:active{transform:scale(.95)}
.capture-ring{
  width:40px;height:40px;border-radius:50%;
  background:var(--text-inv);display:block;
}
.hud-hint{font-size:.72rem;color:rgba(255,255,255,.7);text-shadow:0 1px 3px rgba(0,0,0,.5)}

/* Analysis panel */
.camera-analysis-panel{
  background:var(--bg-surf);border:1px solid var(--border);
  border-radius:var(--r-lg);display:flex;flex-direction:column;
  overflow:hidden;
}
.analysis-header{
  display:flex;align-items:center;justify-content:space-between;
  padding:.75rem 1rem;border-bottom:1px solid var(--border);flex-shrink:0;
}
.analysis-header h4{font-size:.85rem;font-weight:600}
.analysis-results{flex:1;overflow-y:auto;padding:.75rem 1rem}
.analysis-empty{
  display:flex;flex-direction:column;align-items:center;justify-content:center;
  height:160px;gap:.75rem;color:var(--text-3);text-align:center;
}
.analysis-empty svg{width:28px;height:28px;opacity:.4}
.analysis-empty p{font-size:.8rem}
.vision-prompt-area{padding:.75rem 1rem;border-top:1px solid var(--border);flex-shrink:0}
.vision-input-row{display:flex;gap:.4rem;margin-top:.4rem}

/* Frame history */
.frame-history{margin-top:.25rem}
.frame-thumbs{display:flex;gap:.5rem;flex-wrap:wrap}
.frame-thumb{
  width:72px;height:54px;border-radius:var(--r-sm);overflow:hidden;
  border:1.5px solid var(--border);cursor:pointer;
  transition:border-color var(--t1);flex-shrink:0;
}
.frame-thumb:hover,.frame-thumb.selected{border-color:var(--accent)}
.frame-thumb img{width:100%;height:100%;object-fit:cover}

/* ══════════════════════════════════════════════════════
   MEMORY VIEW
══════════════════════════════════════════════════════ */
.memory-toolbar{display:flex;align-items:center;gap:.5rem;flex-wrap:wrap}
.search-wrap{
  position:relative;flex:1;min-width:180px;
  display:flex;align-items:center;
}
.search-wrap svg{
  position:absolute;left:.65rem;width:12px;height:12px;
  color:var(--text-3);pointer-events:none;
}
.search-wrap .field-input{padding-left:2rem}

.memory-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(260px,1fr));gap:1rem}
.memory-card{
  background:var(--bg-surf);border:1px solid var(--border);
  border-radius:var(--r-lg);overflow:hidden;
}
.memory-card-head{
  display:flex;align-items:center;gap:.55rem;
  padding:.75rem 1rem;border-bottom:1px solid var(--border-sub);
  background:var(--bg-elev);
}
.memory-card-head svg{width:14px;height:14px;color:var(--text-3);flex-shrink:0}
.memory-card-head h4{font-size:.82rem;font-weight:600;flex:1}
.mem-count{
  font-size:.68rem;background:var(--bg-hover);color:var(--text-3);
  padding:.1rem .45rem;border-radius:var(--r-full);font-family:var(--mono);
}
.memory-list{padding:.5rem .75rem}
.memory-item{
  display:flex;align-items:flex-start;gap:.5rem;
  padding:.45rem .25rem;border-bottom:1px solid var(--border-sub);
  font-size:.8rem;
}
.memory-item:last-child{border-bottom:none}
.mem-item-key{font-weight:500;color:var(--text-2);flex-shrink:0;min-width:80px}
.mem-item-val{color:var(--text-1);flex:1;word-break:break-word}
.mem-item-del{
  background:none;border:none;cursor:pointer;color:var(--text-3);
  opacity:0;padding:.1rem;border-radius:3px;flex-shrink:0;transition:opacity var(--t1),color var(--t1);
}
.memory-item:hover .mem-item-del{opacity:1}
.mem-item-del:hover{color:var(--red)}
.mem-item-del svg{width:10px;height:10px}
.memory-empty{font-size:.78rem;color:var(--text-3);padding:.5rem .25rem;text-align:center}

.memory-actions-row{display:flex;gap:.5rem;flex-wrap:wrap}

/* ══════════════════════════════════════════════════════
   LAUNCHER VIEW
══════════════════════════════════════════════════════ */
.os-info-bar{
  display:flex;align-items:center;gap:.65rem;
  background:var(--bg-surf);border:1px solid var(--border);
  border-radius:var(--r-md);padding:.65rem .9rem;font-size:.8rem;color:var(--text-2);
}
.os-info-bar svg{width:14px;height:14px;color:var(--text-3);flex-shrink:0}
.os-badge{
  margin-left:auto;font-size:.7rem;font-weight:600;
  background:var(--bg-elev);color:var(--text-3);
  padding:.2rem .6rem;border-radius:var(--r-full);border:1px solid var(--border);
}

.app-search-row{display:flex;gap:.5rem;align-items:center}

.app-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(160px,1fr));gap:.75rem}
.app-card{
  background:var(--bg-surf);border:1px solid var(--border);
  border-radius:var(--r-lg);padding:1rem;
  display:flex;flex-direction:column;align-items:center;gap:.6rem;
  cursor:pointer;transition:all var(--t2) var(--ease);text-align:center;
  position:relative;
}
.app-card:hover{background:var(--bg-hover);border-color:var(--border-strong);transform:translateY(-2px);box-shadow:var(--shadow-sm)}
.app-card-icon{
  width:44px;height:44px;border-radius:var(--r-md);
  background:var(--bg-elev);display:flex;align-items:center;justify-content:center;
  font-size:1.4rem;
}
.app-card-name{font-size:.8rem;font-weight:600;color:var(--text-1)}
.app-card-alias{font-size:.68rem;color:var(--text-3)}
.app-card-del{
  position:absolute;top:.4rem;right:.4rem;
  background:none;border:none;cursor:pointer;
  color:var(--text-3);opacity:0;padding:.2rem;border-radius:3px;
  transition:opacity var(--t1),color var(--t1);
}
.app-card:hover .app-card-del{opacity:1}
.app-card-del:hover{color:var(--red)}
.app-card-del svg{width:12px;height:12px}
.app-card.empty-card{
  border-style:dashed;cursor:default;
  background:transparent;pointer-events:none;opacity:.4;
}

.launcher-hint{
  display:flex;align-items:flex-start;gap:.65rem;
  background:var(--bg-surf);border:1px solid var(--border);
  border-radius:var(--r-md);padding:.85rem 1rem;font-size:.8rem;color:var(--text-2);
}
.launcher-hint svg{width:14px;height:14px;color:var(--text-3);flex-shrink:0;margin-top:.15rem}
.security-banner{
  display:flex;align-items:flex-start;gap:.75rem;
  background:var(--green-muted);border:1px solid rgba(61,184,122,.25);
  border-radius:var(--r-md);padding:.85rem 1rem;
}
.security-banner svg{width:16px;height:16px;color:var(--green);flex-shrink:0;margin-top:.15rem}
.security-banner strong{font-size:.82rem;color:var(--text-1)}
.security-banner p{font-size:.78rem;color:var(--text-2);margin-top:.2rem;line-height:1.5}

/* ══════════════════════════════════════════════════════
   TOKEN VIEW
══════════════════════════════════════════════════════ */
.usage-overview{display:grid;grid-template-columns:repeat(auto-fit,minmax(160px,1fr));gap:.75rem}
.usage-card{
  background:var(--bg-surf);border:1px solid var(--border);
  border-radius:var(--r-lg);padding:1rem 1.1rem;
}
.usage-card.primary{border-color:var(--accent);background:var(--accent-muted)}
.usage-card-label{font-size:.72rem;font-weight:600;letter-spacing:.04em;text-transform:uppercase;color:var(--text-3);margin-bottom:.35rem}
.usage-card-value{font-size:1.6rem;font-weight:700;letter-spacing:-.03em;color:var(--text-1);font-family:var(--mono);margin-bottom:.2rem}
.usage-card.primary .usage-card-value{color:var(--accent)}
.usage-card-sub{font-size:.72rem;color:var(--text-3)}

.token-progress-wrap{
  background:var(--bg-surf);border:1px solid var(--border);
  border-radius:var(--r-lg);padding:1rem 1.1rem;
}
.token-progress-head{display:flex;justify-content:space-between;margin-bottom:.65rem;font-size:.8rem;color:var(--text-2)}
.token-progress-track{
  height:8px;border-radius:var(--r-full);background:var(--border);
  position:relative;overflow:visible;margin-bottom:.35rem;
}
.token-progress-fill{
  height:100%;border-radius:var(--r-full);
  background:var(--tok-fill);transition:width var(--t4) var(--ease),background var(--t2);
}
.token-progress-mark{
  position:absolute;top:-3px;height:14px;width:1.5px;
  background:var(--border-strong);border-radius:1px;
}
.token-progress-mark.danger{background:var(--red);opacity:.7}
.token-progress-legend{
  display:flex;justify-content:space-between;
  font-size:.65rem;color:var(--text-3);font-family:var(--mono);
}

.tok-breakdown{background:var(--bg-surf);border:1px solid var(--border);border-radius:var(--r-lg);padding:1rem 1.1rem}
.tok-breakdown h4{font-size:.82rem;font-weight:600;margin-bottom:.75rem}
.breakdown-list{display:flex;flex-direction:column;gap:.4rem}
.breakdown-item{
  display:flex;align-items:center;gap:.65rem;font-size:.8rem;
}
.breakdown-item-label{flex:1;color:var(--text-2)}
.breakdown-item-bar{flex:2;height:5px;border-radius:var(--r-full);background:var(--border);overflow:hidden}
.breakdown-item-bar-fill{height:100%;border-radius:var(--r-full);background:var(--accent)}
.breakdown-item-val{font-family:var(--mono);font-size:.72rem;color:var(--text-3);min-width:50px;text-align:right}

/* ══════════════════════════════════════════════════════
   PRIVACY VIEW
══════════════════════════════════════════════════════ */
.perm-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(260px,1fr));gap:.75rem}
.perm-card{
  display:flex;align-items:center;gap:.85rem;
  background:var(--bg-surf);border:1px solid var(--border);
  border-radius:var(--r-lg);padding:.9rem 1rem;
}
.perm-icon{
  width:38px;height:38px;border-radius:var(--r-sm);flex-shrink:0;
  background:var(--bg-elev);display:flex;align-items:center;justify-content:center;
  color:var(--text-3);
}
.perm-icon svg{width:20px;height:20px}
.perm-info{flex:1;min-width:0}
.perm-info h4{font-size:.82rem;font-weight:600;margin-bottom:.15rem}
.perm-info p{font-size:.73rem;color:var(--text-3)}
.perm-actions{display:flex;gap:.4rem;flex-shrink:0}
.perm-card.granted .perm-icon{background:var(--green-muted);color:var(--green)}
.perm-card.denied .perm-icon{background:var(--red-muted);color:var(--red)}

.mode-selector{display:flex;gap:.75rem;flex-wrap:wrap}
.mode-option{
  flex:1;min-width:150px;cursor:pointer;
}
.mode-option input{display:none}
.mode-content{
  display:flex;align-items:flex-start;gap:.65rem;
  padding:.85rem 1rem;border-radius:var(--r-md);
  border:1.5px solid var(--border);background:var(--bg-surf);
  transition:all var(--t1);
}
.mode-option input:checked ~ .mode-content{border-color:var(--accent);background:var(--accent-muted)}
.mode-content svg{width:16px;height:16px;color:var(--text-3);flex-shrink:0;margin-top:.1rem}
.mode-option input:checked ~ .mode-content svg{color:var(--accent)}
.mode-content strong{font-size:.82rem;display:block;margin-bottom:.15rem;color:var(--text-1)}
.mode-content p{font-size:.72rem;color:var(--text-3)}

.audit-log{
  background:var(--bg-elev);border-radius:var(--r-sm);
  padding:.65rem .8rem;font-family:var(--mono);font-size:.72rem;
  max-height:160px;overflow-y:auto;line-height:1.7;color:var(--text-3);
  margin-bottom:.5rem;
}
.audit-entry{display:flex;gap:.75rem}
.audit-time{color:var(--text-3);flex-shrink:0}
.audit-msg{color:var(--text-2)}
.audit-msg.warn{color:var(--amber)}
.audit-msg.error{color:var(--red)}
.audit-msg.ok{color:var(--green)}

.danger-zone h4{color:var(--red);margin-bottom:.75rem}
.danger-actions{display:flex;gap:.65rem;flex-wrap:wrap}

/* ══════════════════════════════════════════════════════
   SETTINGS VIEW
══════════════════════════════════════════════════════ */
.card-section{
  background:var(--bg-surf);border:1px solid var(--border);
  border-radius:var(--r-lg);padding:1.1rem;
}
.card-section h4{
  font-size:.82rem;font-weight:700;letter-spacing:.02em;color:var(--text-2);
  margin-bottom:.85rem;padding-bottom:.55rem;border-bottom:1px solid var(--border-sub);
}

.setting-row{
  display:flex;align-items:center;justify-content:space-between;
  gap:1rem;padding:.5rem 0;border-bottom:1px solid var(--border-sub);
}
.setting-row:last-of-type,.setting-row:last-child{border-bottom:none}
.setting-row-right{display:flex;align-items:center;gap:.5rem}

.slider-row{display:flex;align-items:center;gap:.65rem}
.slider-row input[type=range]{flex:1;accent-color:var(--accent)}
.slider-row span{font-size:.75rem;color:var(--text-3);min-width:32px;text-align:right;font-family:var(--mono)}

.toggle-label{display:flex;align-items:center;gap:.4rem;cursor:pointer;font-size:.78rem;color:var(--text-2)}
.toggle-switch{
  position:relative;display:inline-block;
  width:32px;height:18px;border-radius:var(--r-full);
  background:var(--border);transition:background var(--t1);flex-shrink:0;
}
.toggle-label input{display:none}
.toggle-switch::after{
  content:'';position:absolute;top:2px;left:2px;
  width:14px;height:14px;border-radius:50%;background:white;
  transition:transform var(--t2) var(--spring),background var(--t1);
  box-shadow:0 1px 3px rgba(0,0,0,.2);
}
.toggle-label input:checked ~ .toggle-switch{background:var(--accent)}
.toggle-label input:checked ~ .toggle-switch::after{transform:translateX(14px)}

.segmented-ctrl{
  display:flex;background:var(--bg-elev);
  border-radius:var(--r-sm);padding:2px;gap:2px;
}
.seg-btn{
  padding:.3rem .65rem;border:none;border-radius:5px;
  background:transparent;font-size:.75rem;
  color:var(--text-3);cursor:pointer;transition:all var(--t1);
}
.seg-btn.active,.seg-btn:hover{background:var(--bg-surf);color:var(--text-1);box-shadow:var(--shadow-xs)}

.ollama-status-block{
  display:flex;align-items:center;gap:.45rem;
  margin-top:.75rem;font-size:.75rem;color:var(--text-3);
}

.settings-footer{
  display:flex;align-items:center;gap:.75rem;
  margin-top:.5rem;
}
.save-indicator{font-size:.75rem;color:var(--green)}

/* ══════════════════════════════════════════════════════
   GLOBAL UI COMPONENTS
══════════════════════════════════════════════════════ */

/* Status dots */
.status-dot{
  width:7px;height:7px;border-radius:50%;flex-shrink:0;
  background:var(--text-3);
}
.status-dot.green,.status-dot.online{
  background:var(--green);
  box-shadow:0 0 0 2px var(--green-muted);
}
.status-dot.amber,.status-dot.warning{background:var(--amber)}
.status-dot.red,.status-dot.error{background:var(--red)}
.status-dot.pulse{animation:pulse 2s ease infinite}
.conn-badge{display:flex;align-items:center;gap:.35rem;font-size:.7rem}

/* Badges */
.badge{
  font-size:.68rem;font-weight:600;padding:.15rem .5rem;
  border-radius:var(--r-full);border:1px solid transparent;
}
.badge.green{background:var(--green-muted);color:var(--green);border-color:rgba(61,184,122,.25)}
.badge.amber{background:var(--amber-muted);color:var(--amber)}
.badge.red{background:var(--red-muted);color:var(--red)}

/* Buttons */
.btn-primary{
  display:inline-flex;align-items:center;justify-content:center;gap:.45rem;
  background:var(--accent);color:white;border:none;border-radius:var(--r-md);
  padding:.6rem 1.2rem;font-size:.85rem;font-weight:600;cursor:pointer;
  transition:background var(--t1),transform var(--t1),opacity var(--t1);
  white-space:nowrap;
}
.btn-primary:hover{background:var(--accent-h)}
.btn-primary:active{transform:scale(.97)}
.btn-primary:disabled{opacity:.4;cursor:not-allowed;transform:none}
.btn-primary.full{width:100%;justify-content:center}
.btn-primary.sm{font-size:.78rem;padding:.45rem .9rem}

.btn-secondary{
  display:inline-flex;align-items:center;justify-content:center;gap:.45rem;
  background:var(--bg-elev);color:var(--text-2);
  border:1px solid var(--border);border-radius:var(--r-md);
  padding:.55rem 1rem;font-size:.82rem;font-weight:500;cursor:pointer;
  transition:all var(--t1);white-space:nowrap;
}
.btn-secondary:hover{background:var(--bg-hover);color:var(--text-1)}
.btn-secondary svg{width:13px;height:13px}
.btn-secondary.sm{font-size:.75rem;padding:.38rem .75rem}

.btn-ghost{
  display:inline-flex;align-items:center;justify-content:center;gap:.4rem;
  background:none;color:var(--text-2);border:1px solid var(--border);
  border-radius:var(--r-sm);padding:.4rem .8rem;
  font-size:.8rem;font-weight:500;cursor:pointer;
  transition:all var(--t1);white-space:nowrap;
}
.btn-ghost:hover{background:var(--bg-hover);color:var(--text-1)}
.btn-ghost.sm{font-size:.73rem;padding:.3rem .65rem}
.btn-ghost.center{text-align:center;justify-content:center}
.btn-ghost svg{width:12px;height:12px}
.btn-ghost.danger{color:var(--red);border-color:rgba(192,53,53,.3)}
.btn-ghost.danger:hover{background:var(--red-muted)}

.btn-danger{
  display:inline-flex;align-items:center;justify-content:center;gap:.4rem;
  background:var(--red);color:white;border:none;border-radius:var(--r-md);
  padding:.55rem 1rem;font-size:.82rem;font-weight:600;cursor:pointer;
  transition:all var(--t1);
}
.btn-danger:hover{opacity:.88}
.btn-danger svg{width:13px;height:13px}

.btn-danger-outline{
  display:inline-flex;align-items:center;justify-content:center;gap:.4rem;
  background:none;color:var(--red);border:1px solid var(--red);
  border-radius:var(--r-md);padding:.5rem 1rem;font-size:.82rem;font-weight:500;cursor:pointer;
  transition:all var(--t1);
}
.btn-danger-outline:hover{background:var(--red-muted)}
.btn-danger-outline svg{width:13px;height:13px}

.btn-icon{
  display:flex;align-items:center;justify-content:center;
  width:32px;height:32px;border-radius:var(--r-sm);
  background:none;border:none;cursor:pointer;color:var(--text-3);
  transition:color var(--t1),background var(--t1);flex-shrink:0;
}
.btn-icon svg{width:16px;height:16px}
.btn-icon:hover{color:var(--text-1);background:var(--bg-hover)}
.btn-icon.active{color:var(--accent);background:var(--accent-muted)}

/* Form fields */
.field-group{margin-bottom:1rem}
.field-label{display:block;font-size:.75rem;font-weight:500;color:var(--text-2);margin-bottom:.35rem}
.field-hint{font-weight:400;color:var(--text-3)}
.field-hint-text{font-size:.7rem;color:var(--text-3);margin-top:.3rem;line-height:1.5}
.field-hint-text code{font-family:var(--mono);font-size:.75em;background:var(--bg-elev);padding:.1em .3em;border-radius:3px}

.field-input{
  width:100%;background:var(--bg-input);border:1px solid var(--border);
  border-radius:var(--r-sm);padding:.55rem .8rem;
  font-size:.85rem;color:var(--text-1);outline:none;
  transition:border-color var(--t1);
}
.field-input:focus{border-color:var(--border-focus)}
.field-input::placeholder{color:var(--text-3)}
.field-input.sm{width:auto;min-width:120px;font-size:.8rem;padding:.42rem .7rem}
.field-input-wrap{position:relative}
.field-input-wrap .field-input{padding-right:2.6rem}
.field-icon-btn{
  position:absolute;right:.6rem;top:50%;transform:translateY(-50%);
  background:none;border:none;cursor:pointer;color:var(--text-3);
  display:flex;align-items:center;justify-content:center;padding:.25rem;
}
.field-icon-btn svg{width:14px;height:14px}
.field-icon-btn:hover{color:var(--text-2)}

.field-select{
  background:var(--bg-input);border:1px solid var(--border);
  border-radius:var(--r-sm);padding:.5rem .75rem;
  font-size:.85rem;color:var(--text-1);outline:none;
  cursor:pointer;transition:border-color var(--t1);
  appearance:none;
  background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' fill='none' stroke='%238c96ab' stroke-width='1.5'%3E%3Cpath d='M1 1l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat:no-repeat;background-position:right .65rem center;
  padding-right:2rem;
}
.field-select:focus{border-color:var(--border-focus)}
.field-select.sm{font-size:.8rem;padding:.38rem .65rem}

textarea.field-input{resize:vertical;min-height:70px;line-height:1.55}

/* Modals */
.modal-overlay{
  position:fixed;inset:0;z-index:500;
  background:rgba(0,0,0,.45);backdrop-filter:blur(4px);
  display:flex;align-items:center;justify-content:center;padding:1.5rem;
  animation:fadeIn var(--t2) var(--ease);
}
.modal{
  background:var(--bg-surf);border:1px solid var(--border);
  border-radius:var(--r-xl);width:100%;max-width:440px;
  box-shadow:var(--shadow-lg);animation:slideUp var(--t2) var(--ease);
  overflow:hidden;display:flex;flex-direction:column;max-height:90dvh;
}
.modal-header{
  display:flex;align-items:center;gap:.75rem;
  padding:1.1rem 1.25rem .9rem;border-bottom:1px solid var(--border);flex-shrink:0;
}
.modal-icon{
  width:34px;height:34px;border-radius:var(--r-sm);
  background:var(--accent-muted);color:var(--accent);
  display:flex;align-items:center;justify-content:center;flex-shrink:0;
}
.modal-icon.warn{background:var(--amber-muted);color:var(--amber)}
.modal-icon.danger{background:var(--red-muted);color:var(--red)}
.modal-icon svg{width:18px;height:18px}
.modal-title{font-size:.95rem;font-weight:700;flex:1;letter-spacing:-.01em}
.modal-body{font-size:.84rem;color:var(--text-2);line-height:1.6;padding:1rem 1.25rem}
.modal-body-form{padding:.75rem 1.25rem;overflow-y:auto;flex:1}
.modal-actions{
  display:flex;justify-content:flex-end;gap:.5rem;
  padding:.9rem 1.25rem;border-top:1px solid var(--border);flex-shrink:0;
}

/* Toast */
.toast-container{
  position:fixed;bottom:1.25rem;right:1.25rem;z-index:1000;
  display:flex;flex-direction:column;gap:.4rem;align-items:flex-end;
}
.toast{
  display:flex;align-items:flex-start;gap:.6rem;
  background:var(--bg-elev);border:1px solid var(--border);
  border-radius:var(--r-md);padding:.7rem .9rem;
  box-shadow:var(--shadow-md);font-size:.8rem;max-width:340px;
  animation:slideUp var(--t2) var(--ease);
}
.toast.info{border-color:var(--accent);background:var(--accent-muted)}
.toast.success{border-color:rgba(61,184,122,.3);background:var(--green-muted)}
.toast.error{border-color:rgba(192,53,53,.3);background:var(--red-muted)}
.toast.warning{border-color:rgba(217,148,58,.3);background:var(--amber-muted)}
.toast-icon{flex-shrink:0;margin-top:.05rem}
.toast-icon svg{width:14px;height:14px}
.toast-msg{flex:1;color:var(--text-1);line-height:1.5}
.toast-close{background:none;border:none;cursor:pointer;color:var(--text-3);padding:.1rem;flex-shrink:0}
.toast-close svg{width:12px;height:12px}
.toast-exit{animation:toastExit var(--t2) var(--ease) forwards}

/* Voice indicator */
.voice-indicator{
  position:fixed;bottom:5.5rem;left:50%;transform:translateX(-50%);
  display:flex;flex-direction:column;align-items:center;gap:.65rem;
  background:var(--bg-surf);border:1px solid var(--border);
  border-radius:var(--r-xl);padding:1rem 1.5rem;
  box-shadow:var(--shadow-lg);z-index:400;
  animation:slideUp var(--t2) var(--ease);
}
.voice-waves{display:flex;align-items:center;gap:3px;height:28px}
.voice-waves span{
  width:3px;border-radius:var(--r-full);background:var(--accent);
  animation:waveBar 0.7s ease-in-out infinite alternate;transform-origin:bottom;
}
.voice-waves span:nth-child(1){height:8px;animation-delay:0s}
.voice-waves span:nth-child(2){height:18px;animation-delay:.1s}
.voice-waves span:nth-child(3){height:24px;animation-delay:.2s}
.voice-waves span:nth-child(4){height:16px;animation-delay:.15s}
.voice-waves span:nth-child(5){height:10px;animation-delay:.05s}
#voice-transcript{font-size:.82rem;color:var(--text-2);max-width:260px;text-align:center}

/* ══════════════════════════════════════════════════════
   ANIMATIONS
══════════════════════════════════════════════════════ */
@keyframes fadeIn{from{opacity:0}to{opacity:1}}
@keyframes slideUp{from{opacity:0;transform:translateY(14px)}to{opacity:1;transform:translateY(0)}}
@keyframes dotPop{0%,80%,100%{transform:scale(.55);opacity:.4}40%{transform:scale(1);opacity:1}}
@keyframes pulse{0%,100%{opacity:1}50%{opacity:.4}}
@keyframes bioPulse{0%{opacity:0;transform:scale(1)}50%{opacity:.5}100%{opacity:0;transform:scale(1.05)}}
@keyframes waveBar{from{transform:scaleY(.4)}to{transform:scaleY(1)}}
@keyframes toastExit{to{opacity:0;transform:translateX(20px)}}

/* ══════════════════════════════════════════════════════
   RESPONSIVE
══════════════════════════════════════════════════════ */
@media(max-width:740px){
  .sidebar{
    position:fixed;left:0;top:0;bottom:0;
    z-index:200;transform:translateX(-100%);
    box-shadow:none;
  }
  .sidebar.mobile-open{transform:translateX(0);box-shadow:var(--shadow-lg)}
  .sidebar.collapsed{width:var(--sidebar-width);min-width:var(--sidebar-width);transform:translateX(-100%)}
  .sidebar.collapsed.mobile-open{transform:translateX(0)}
  #mobile-menu-btn{display:flex}
  .camera-layout{grid-template-columns:1fr}
  .topbar-sub{display:none}
  .model-badge{display:none}
}
@media(max-width:480px){
  .usage-overview{grid-template-columns:repeat(2,1fr)}
  .perm-grid{grid-template-columns:1fr}
  .mode-selector{flex-direction:column}
  .messages-list{padding:0 .85rem}
  .input-area{padding:.6rem .85rem .75rem}
  .view-layout{padding:1rem}
}

/* ══════════════════════════════════════════════════════
   FONT SIZE VARIANTS
══════════════════════════════════════════════════════ */
[data-fontsize="sm"]{font-size:13px}
[data-fontsize="md"]{font-size:15px}
[data-fontsize="lg"]{font-size:17px}
