/* =================================================================
   Halo AI — "soft aurora" design system
   A calm, focused workspace. Indigo-violet primary, teal live accent,
   warm coral for rare emphasis, on a cool paper canvas.
   ================================================================= */

:root {
  /* Brand */
  --indigo:      #5B53E0;
  --indigo-600:  #4d45cf;
  --indigo-700:  #3f38b8;
  --teal:        #16BDCA;
  --teal-600:    #0fa9b6;
  --coral:       #FF7A5A;

  /* Canvas / surfaces (light) */
  --canvas:      #F7F8FB;
  --canvas-2:    #EEF0F6;
  --surface:     #FFFFFF;
  --surface-2:   #FBFCFE;
  --sidebar-bg:  #F0F1F7;

  /* Ink / text */
  --ink:         #171723;
  --ink-2:       #3b3b4d;
  --muted:       #6c6c81;
  --faint:       #9a9aae;

  /* Lines */
  --line:        #E4E6EF;
  --line-2:      #D6D9E6;

  /* States */
  --ok:          #16a34a;
  --ok-bg:       #e7f7ec;
  --err:         #d1453b;
  --err-bg:      #fcebe9;

  /* Aurora gradient */
  --aurora: linear-gradient(120deg, var(--indigo), var(--teal));

  /* Geometry */
  --r-sm: 8px;
  --r:    12px;
  --r-lg: 18px;
  --r-xl: 24px;
  --sidebar-w: 280px;

  /* Shadow */
  --sh-sm: 0 1px 2px rgba(23,23,35,.06), 0 1px 1px rgba(23,23,35,.04);
  --sh:    0 4px 14px rgba(23,23,35,.08);
  --sh-lg: 0 18px 50px rgba(23,23,35,.16);
  --glow:  0 0 0 4px rgba(91,83,224,.14);

  --font-ui:   'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-disp: 'Fraunces', Georgia, serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --canvas:     #14141c;
    --canvas-2:   #1b1b25;
    --surface:    #1e1e2a;
    --surface-2:  #23232f;
    --sidebar-bg: #17171f;
    --ink:        #ECECF3;
    --ink-2:      #c9c9d6;
    --muted:      #9595a8;
    --faint:      #6d6d80;
    --line:       #2c2c3a;
    --line-2:     #383848;
    --ok-bg:      #14301f;
    --err-bg:     #3a1c1a;
    --sh-sm: 0 1px 2px rgba(0,0,0,.3);
    --sh:    0 4px 14px rgba(0,0,0,.35);
    --sh-lg: 0 18px 50px rgba(0,0,0,.5);
    --glow:  0 0 0 4px rgba(91,83,224,.28);
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--canvas);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button { font-family: inherit; cursor: pointer; }
a { color: var(--indigo); text-decoration: none; }
a:hover { text-decoration: underline; }
::selection { background: rgba(91,83,224,.18); }

/* ============================ Auth ============================ */
.auth-body {
  display: grid;
  place-items: center;
  min-height: 100%;
  background:
    radial-gradient(1200px 600px at 15% -10%, rgba(91,83,224,.14), transparent 60%),
    radial-gradient(1000px 600px at 110% 110%, rgba(22,189,202,.12), transparent 55%),
    var(--canvas);
  padding: 24px;
}
.auth-shell { position: relative; width: 100%; max-width: 420px; }
.auth-aurora { position: absolute; inset: -80px -40px; z-index: 0; filter: blur(60px); opacity: .55; pointer-events: none; }
.blob { position: absolute; border-radius: 50%; }
.blob-a { width: 240px; height: 240px; background: var(--indigo); top: -40px; left: -30px; animation: float 14s ease-in-out infinite; }
.blob-b { width: 200px; height: 200px; background: var(--teal); bottom: -30px; right: -20px; animation: float 18s ease-in-out infinite reverse; }
.blob-c { width: 160px; height: 160px; background: var(--coral); top: 40%; left: 60%; opacity: .5; animation: float 22s ease-in-out infinite; }
@keyframes float { 0%,100% { transform: translate(0,0); } 50% { transform: translate(20px,-24px); } }

.auth-card {
  position: relative; z-index: 1;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  box-shadow: var(--sh-lg);
  padding: 36px 34px 30px;
}
.auth-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; }
.brand-mark { display: inline-flex; }
.brand-name { font-family: var(--font-disp); font-size: 22px; font-weight: 600; letter-spacing: -.01em; }
.auth-title { font-family: var(--font-disp); font-weight: 600; font-size: 26px; margin: 0 0 4px; letter-spacing: -.02em; }
.auth-sub { color: var(--muted); margin: 0 0 22px; font-size: 14.5px; }
.auth-form { display: flex; flex-direction: column; gap: 16px; }
.auth-alert { padding: 10px 14px; border-radius: var(--r); font-size: 13.5px; }
.auth-alert.ok { background: var(--ok-bg); color: var(--ok); }
.auth-alert.err { background: var(--err-bg); color: var(--err); }
.auth-switch { margin: 18px 0 0; text-align: center; color: var(--muted); font-size: 14px; }
.auth-foot { text-align: center; color: var(--faint); font-size: 12.5px; margin: 18px 0 0; position: relative; z-index: 1; }

/* Form primitives (shared by auth + admin + modals) */
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 13px; font-weight: 500; color: var(--ink-2); }
.field-help { font-size: 12.5px; color: var(--muted); }
.field input, .field select, .field textarea,
input[type=text], input[type=email], input[type=password], input[type=number], select, textarea {
  font-family: inherit; font-size: 14.5px; color: var(--ink);
  background: var(--surface-2);
  border: 1px solid var(--line-2);
  border-radius: var(--r);
  padding: 11px 13px;
  width: 100%;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
textarea { resize: vertical; line-height: 1.5; }
.field input:focus, .field select:focus, .field textarea:focus,
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--indigo);
  box-shadow: var(--glow); background: var(--surface);
}
.field input::placeholder, textarea::placeholder { color: var(--faint); }
.mono { font-family: var(--font-mono); font-size: 13px; }

.btn-primary {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--indigo); color: #fff;
  border: none; border-radius: var(--r);
  padding: 11px 18px; font-size: 14.5px; font-weight: 600;
  box-shadow: var(--sh-sm);
  transition: background .15s, transform .05s, box-shadow .15s;
}
.btn-primary:hover { background: var(--indigo-600); }
.btn-primary:active { transform: translateY(1px); }
.btn-primary.btn-block { width: 100%; padding: 13px; }
.btn-primary.btn-sm { padding: 8px 14px; font-size: 13.5px; }

/* ============================ App shell ============================ */
.app { display: flex; height: 100vh; height: 100dvh; overflow: hidden; }

/* ---------- Sidebar ---------- */
.sidebar {
  width: var(--sidebar-w); flex: 0 0 var(--sidebar-w);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  transition: margin-left .26s cubic-bezier(.4,0,.2,1);
}
.app.sidebar-hidden .sidebar { margin-left: calc(var(--sidebar-w) * -1); }
.sidebar-top { display: flex; align-items: center; justify-content: space-between; padding: 16px 14px 10px; }
.brand { display: flex; align-items: center; gap: 9px; }
.brand:hover { text-decoration: none; }
.brand .brand-name { font-size: 18px; color: var(--ink); }
.new-chat-btn {
  margin: 4px 14px 12px; display: flex; align-items: center; gap: 9px;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--line-2); border-radius: var(--r);
  padding: 11px 13px; font-size: 14px; font-weight: 550;
  box-shadow: var(--sh-sm); transition: border-color .15s, background .15s;
}
.new-chat-btn:hover { border-color: var(--indigo); color: var(--indigo); }
.new-chat-btn svg { color: var(--indigo); }

.sidebar-search { position: relative; margin: 0 14px 8px; }
.sidebar-search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--faint); }
.sidebar-search input { padding: 9px 12px 9px 32px; font-size: 13.5px; background: var(--canvas-2); border-color: transparent; }
.sidebar-search input:focus { box-shadow: none; border-color: var(--line-2); background: var(--surface); }

.sidebar-scroll { flex: 1; overflow-y: auto; padding: 6px 8px 12px; }
.sidebar-scroll::-webkit-scrollbar { width: 9px; }
.sidebar-scroll::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 6px; border: 2px solid var(--sidebar-bg); }
.side-section { margin-bottom: 10px; }
.side-section-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 8px; font-size: 11.5px; font-weight: 600; letter-spacing: .04em;
  text-transform: uppercase; color: var(--faint);
}
.icon-btn-xs { display: inline-flex; padding: 3px; border: none; background: none; color: var(--faint); border-radius: 6px; }
.icon-btn-xs:hover { background: var(--canvas-2); color: var(--indigo); }

.project-list, .conversation-list { list-style: none; margin: 0; padding: 0; }
.project-item, .conv-item {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 9px; border-radius: var(--r-sm);
  color: var(--ink-2); font-size: 14px; cursor: pointer;
  position: relative; user-select: none;
}
.project-item:hover, .conv-item:hover { background: var(--canvas-2); }
.conv-item.active, .project-item.active { background: rgba(91,83,224,.12); color: var(--indigo-700); font-weight: 550; }
.project-dot { width: 9px; height: 9px; border-radius: 3px; flex: 0 0 auto; }
.conv-item-title, .project-item-title { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-pin { color: var(--teal); display: inline-flex; }
.row-menu-btn {
  opacity: 0; border: none; background: none; color: var(--muted);
  padding: 2px; border-radius: 5px; display: inline-flex; transition: opacity .12s;
}
.conv-item:hover .row-menu-btn, .project-item:hover .row-menu-btn { opacity: 1; }
.row-menu-btn:hover { background: var(--line-2); color: var(--ink); }
.project-chats { list-style: none; margin: 2px 0 2px 14px; padding: 0 0 0 8px; border-left: 1.5px solid var(--line); }
.side-empty { color: var(--faint); font-size: 13px; padding: 8px 10px; }

.sidebar-foot { border-top: 1px solid var(--line); padding: 10px; position: relative; }
.user-chip {
  display: flex; align-items: center; gap: 10px; width: 100%;
  background: none; border: none; padding: 7px 8px; border-radius: var(--r);
  color: var(--ink); transition: background .15s;
}
.user-chip:hover { background: var(--canvas-2); }
.avatar {
  width: 32px; height: 32px; flex: 0 0 32px; border-radius: 9px;
  display: grid; place-items: center; color: #fff; font-weight: 600; font-size: 14px;
}
.user-meta { flex: 1; text-align: left; overflow: hidden; }
.user-name { display: block; font-size: 13.5px; font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-plan { display: block; font-size: 11.5px; color: var(--muted); }
.chev { color: var(--faint); }

.user-menu {
  position: absolute; bottom: calc(100% + 6px); left: 10px; right: 10px;
  background: var(--surface); border: 1px solid var(--line-2);
  border-radius: var(--r-lg); box-shadow: var(--sh-lg);
  padding: 6px; z-index: 40;
}
.user-menu button, .user-menu a {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 9px 11px; border: none; background: none; border-radius: var(--r-sm);
  color: var(--ink-2); font-size: 13.5px; text-align: left;
}
.user-menu button:hover, .user-menu a:hover { background: var(--canvas-2); text-decoration: none; color: var(--ink); }
.user-menu svg { color: var(--muted); }
.user-menu .menu-admin { color: var(--indigo); }
.user-menu .menu-admin svg { color: var(--indigo); }
.menu-logout { margin-top: 4px; border-top: 1px solid var(--line); padding-top: 4px; }
.menu-logout button { color: var(--err); }
.menu-logout button svg { color: var(--err); }

/* ---------- Main ---------- */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; background: var(--canvas); }
.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 18px; border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--canvas) 85%, transparent);
  backdrop-filter: blur(8px);
}
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border: none; background: none;
  color: var(--muted); border-radius: var(--r-sm); position: relative;
  transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--canvas-2); color: var(--ink); }
.sidebar-open { display: none; }
.topbar-title { flex: 1; min-width: 0; }
.conv-title {
  font-size: 16px; font-weight: 600; margin: 0; letter-spacing: -.01em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; outline: none;
  border-radius: 6px; padding: 2px 4px; max-width: 60ch;
}
.conv-title[contenteditable=true] { background: var(--surface); box-shadow: var(--glow); }
.conv-project-tag { font-size: 12px; color: var(--muted); padding: 2px 4px; }

.topbar-actions { display: flex; align-items: center; gap: 6px; }
.model-picker { position: relative; }
.model-btn {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--line-2);
  border-radius: 10px; padding: 8px 11px; font-size: 13.5px; font-weight: 500; color: var(--ink-2);
  transition: border-color .15s;
}
.model-btn:hover { border-color: var(--indigo); }
.model-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--teal); box-shadow: 0 0 0 3px rgba(22,189,202,.18); }
.model-menu {
  position: absolute; top: calc(100% + 6px); right: 0; min-width: 260px;
  background: var(--surface); border: 1px solid var(--line-2);
  border-radius: var(--r-lg); box-shadow: var(--sh-lg); padding: 6px; z-index: 40;
  max-height: 60vh; overflow-y: auto;
}
.model-opt { display: flex; flex-direction: column; gap: 1px; padding: 9px 11px; border-radius: var(--r-sm); cursor: pointer; }
.model-opt:hover { background: var(--canvas-2); }
.model-opt.active { background: rgba(91,83,224,.1); }
.model-opt-name { font-size: 13.5px; font-weight: 550; color: var(--ink); }
.model-opt-provider { font-size: 12px; color: var(--muted); }
.model-group-label { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--faint); padding: 8px 11px 3px; }
.badge-count {
  position: absolute; top: 3px; right: 3px; min-width: 16px; height: 16px;
  background: var(--coral); color: #fff; font-size: 10px; font-weight: 700;
  border-radius: 9px; display: grid; place-items: center; padding: 0 4px;
}

/* ---------- Thread ---------- */
.thread-wrap { flex: 1; overflow-y: auto; scroll-behavior: smooth; }
.thread { max-width: 760px; margin: 0 auto; padding: 28px 24px 12px; display: flex; flex-direction: column; gap: 26px; }
.msg { display: flex; gap: 14px; animation: rise .3s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.msg-avatar { width: 30px; height: 30px; flex: 0 0 30px; border-radius: 9px; display: grid; place-items: center; font-size: 13px; font-weight: 600; color: #fff; margin-top: 2px; }
.msg-ai .msg-avatar { background: var(--aurora); }
.msg-body { min-width: 0; flex: 1; }
.msg-role { font-size: 12.5px; font-weight: 600; color: var(--muted); margin-bottom: 3px; }
.msg-user { justify-content: flex-end; }
.msg-user .msg-body { max-width: 76%; flex: 0 1 auto; }
.msg-user .msg-content {
  background: var(--indigo); color: #fff;
  padding: 11px 15px; border-radius: 16px 16px 4px 16px;
  box-shadow: var(--sh-sm);
}
.msg-user .msg-content p { margin: 0; }
.msg-ai .msg-content { color: var(--ink); }

/* Markdown content */
.msg-content { font-size: 15px; line-height: 1.65; word-wrap: break-word; overflow-wrap: anywhere; }
.msg-content p { margin: 0 0 12px; }
.msg-content > :last-child { margin-bottom: 0; }
.msg-content h1, .msg-content h2, .msg-content h3 { font-weight: 650; line-height: 1.3; margin: 20px 0 10px; letter-spacing: -.01em; }
.msg-content h1 { font-size: 1.4em; } .msg-content h2 { font-size: 1.25em; } .msg-content h3 { font-size: 1.1em; }
.msg-content ul, .msg-content ol { margin: 0 0 12px; padding-left: 24px; }
.msg-content li { margin: 4px 0; }
.msg-content a { text-decoration: underline; text-underline-offset: 2px; }
.msg-content blockquote { border-left: 3px solid var(--line-2); margin: 0 0 12px; padding: 2px 0 2px 14px; color: var(--muted); }
.msg-content code:not(pre code) { font-family: var(--font-mono); font-size: .86em; background: var(--canvas-2); padding: 2px 6px; border-radius: 6px; color: var(--indigo-700); }
.msg-content pre {
  background: #0f1117; color: #e6e6ef; border-radius: var(--r);
  padding: 14px 16px; overflow-x: auto; margin: 0 0 12px; position: relative;
  font-size: 13px; line-height: 1.55; border: 1px solid rgba(255,255,255,.06);
}
.msg-content pre code { font-family: var(--font-mono); background: none; padding: 0; color: inherit; }
.msg-content table { border-collapse: collapse; width: 100%; margin: 0 0 12px; font-size: 14px; }
.msg-content th, .msg-content td { border: 1px solid var(--line-2); padding: 7px 10px; text-align: left; }
.msg-content th { background: var(--canvas-2); font-weight: 600; }
.code-copy {
  position: absolute; top: 8px; right: 8px; font-size: 11px; font-weight: 600;
  background: rgba(255,255,255,.1); color: #cfcfe0; border: none; border-radius: 6px; padding: 4px 8px;
  opacity: 0; transition: opacity .15s;
}
.msg-content pre:hover .code-copy { opacity: 1; }
.code-copy:hover { background: rgba(255,255,255,.2); color: #fff; }

/* Inline artifact card */
.artifact-chip {
  display: flex; align-items: center; gap: 11px; margin: 4px 0 12px;
  background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--r);
  padding: 11px 13px; cursor: pointer; transition: border-color .15s, box-shadow .15s;
}
.artifact-chip:hover { border-color: var(--indigo); box-shadow: var(--sh-sm); }
.artifact-chip-icon { width: 34px; height: 34px; border-radius: 9px; background: var(--aurora); display: grid; place-items: center; color: #fff; flex: 0 0 34px; }
.artifact-chip-meta { flex: 1; min-width: 0; }
.artifact-chip-title { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.artifact-chip-sub { font-size: 12px; color: var(--muted); }

/* Streaming cursor */
.cursor-blink::after { content: '▍'; color: var(--teal); animation: blink 1s steps(2) infinite; margin-left: 1px; }
@keyframes blink { 50% { opacity: 0; } }
.typing-dots { display: inline-flex; gap: 4px; padding: 4px 0; }
.typing-dots span { width: 7px; height: 7px; border-radius: 50%; background: var(--teal); animation: bob 1.2s ease-in-out infinite; }
.typing-dots span:nth-child(2) { animation-delay: .2s; } .typing-dots span:nth-child(3) { animation-delay: .4s; }
@keyframes bob { 0%,60%,100% { transform: translateY(0); opacity: .5; } 30% { transform: translateY(-5px); opacity: 1; } }

.msg-actions { display: flex; gap: 4px; margin-top: 8px; opacity: 0; transition: opacity .15s; }
.msg:hover .msg-actions { opacity: 1; }
.msg-action { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--muted); background: none; border: none; padding: 4px 7px; border-radius: 6px; }
.msg-action:hover { background: var(--canvas-2); color: var(--ink); }

/* ---------- Welcome ---------- */
.welcome { max-width: 720px; margin: 0 auto; padding: 8vh 24px 24px; text-align: center; }
.welcome-mark { display: inline-flex; margin-bottom: 18px; }
.welcome-title { font-family: var(--font-disp); font-weight: 600; font-size: 30px; letter-spacing: -.02em; margin: 0 0 6px; }
.welcome-sub { color: var(--muted); margin: 0 0 28px; font-size: 15px; }
.suggestions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; text-align: left; }
.suggestion {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  padding: 14px 16px; display: flex; flex-direction: column; gap: 3px;
  transition: border-color .15s, box-shadow .15s, transform .08s;
}
.suggestion:hover { border-color: var(--indigo); box-shadow: var(--sh-sm); transform: translateY(-1px); }
.suggestion strong { font-size: 14px; font-weight: 600; color: var(--ink); }
.suggestion span { font-size: 13px; color: var(--muted); }

/* ---------- Composer (signature) ---------- */
.composer-wrap { padding: 8px 24px 18px; }
.composer {
  max-width: 760px; margin: 0 auto;
  background: var(--surface); border: 1.5px solid var(--line-2);
  border-radius: var(--r-xl); box-shadow: var(--sh);
  transition: border-color .18s, box-shadow .18s; overflow: hidden;
}
.composer:focus-within { border-color: var(--indigo); box-shadow: var(--sh), 0 0 0 5px rgba(91,83,224,.12); }
.composer-skills { display: flex; flex-wrap: wrap; gap: 6px; padding: 12px 14px 0; }
.composer-row { display: flex; align-items: flex-end; gap: 8px; padding: 10px 12px; }
.composer-tool {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; flex: 0 0 38px; border: none; background: none;
  color: var(--muted); border-radius: 10px; transition: background .15s, color .15s;
}
.composer-tool:hover, .composer-tool.active { background: rgba(91,83,224,.1); color: var(--indigo); }
.composer-input {
  flex: 1; border: none; background: none; resize: none;
  font-size: 15.5px; line-height: 1.5; color: var(--ink);
  max-height: 220px; padding: 8px 4px; outline: none; box-shadow: none;
}
.composer-input:focus { box-shadow: none; background: none; }
.send-btn {
  width: 38px; height: 38px; flex: 0 0 38px; border: none; border-radius: 11px;
  background: var(--aurora); color: #fff; display: grid; place-items: center;
  transition: transform .08s, filter .15s, opacity .15s;
}
.send-btn:hover:not(:disabled) { filter: brightness(1.07); }
.send-btn:active:not(:disabled) { transform: scale(.94); }
.send-btn:disabled { opacity: .4; cursor: default; background: var(--faint); }
.send-btn.stop { background: var(--coral); }
.composer-foot { max-width: 760px; margin: 8px auto 0; text-align: center; font-size: 12px; color: var(--faint); }

.skill-pill {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px;
  background: var(--canvas-2); color: var(--ink-2); border: 1px solid transparent;
  border-radius: 20px; padding: 4px 11px; cursor: pointer; user-select: none;
}
.skill-pill:hover { border-color: var(--line-2); }
.skill-pill.on { background: rgba(91,83,224,.12); color: var(--indigo-700); border-color: rgba(91,83,224,.3); }
.skill-pill svg { width: 14px; height: 14px; }

/* ---------- Artifacts drawer ---------- */
.artifacts-drawer {
  width: min(48vw, 640px); flex: 0 0 min(48vw, 640px);
  background: var(--surface); border-left: 1px solid var(--line);
  display: flex; flex-direction: column;
  animation: slideIn .26s cubic-bezier(.4,0,.2,1);
}
@keyframes slideIn { from { transform: translateX(40px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 13px 16px; border-bottom: 1px solid var(--line); }
.drawer-title { display: flex; align-items: center; gap: 9px; font-weight: 600; font-size: 15px; }
.drawer-title svg { color: var(--indigo); }
.drawer-head-actions { display: flex; gap: 2px; }
.icon-btn-sm { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border: none; background: none; color: var(--muted); border-radius: 8px; }
.icon-btn-sm:hover { background: var(--canvas-2); color: var(--ink); }
.artifact-tabs { display: flex; gap: 4px; padding: 8px 12px; overflow-x: auto; border-bottom: 1px solid var(--line); }
.artifact-tab { white-space: nowrap; font-size: 13px; color: var(--muted); background: none; border: none; padding: 6px 11px; border-radius: 8px; }
.artifact-tab:hover { background: var(--canvas-2); }
.artifact-tab.active { background: rgba(91,83,224,.12); color: var(--indigo-700); font-weight: 550; }
.artifact-viewport { flex: 1; overflow: auto; position: relative; background: var(--canvas); }
.artifact-frame { width: 100%; height: 100%; border: none; background: #fff; }
.artifact-code { margin: 0; height: 100%; overflow: auto; }
.artifact-code pre { margin: 0; height: 100%; border-radius: 0; background: #0f1117; }
.artifact-switcher { display: flex; gap: 2px; padding: 8px 12px 0; }
.artifact-view-btn { font-size: 12px; color: var(--muted); background: none; border: 1px solid var(--line-2); padding: 5px 12px; border-radius: 7px; }
.artifact-view-btn.active { background: var(--ink); color: #fff; border-color: var(--ink); }
.artifact-empty { display: grid; place-items: center; height: 100%; color: var(--faint); text-align: center; padding: 40px; }

/* ---------- Scrim / responsive ---------- */
.scrim { position: fixed; inset: 0; background: rgba(15,16,23,.4); z-index: 30; backdrop-filter: blur(2px); }

@media (max-width: 980px) { .artifacts-drawer { position: fixed; right: 0; top: 0; bottom: 0; width: min(92vw, 560px); z-index: 35; box-shadow: var(--sh-lg); } }
@media (max-width: 760px) {
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; z-index: 36; box-shadow: var(--sh-lg); }
  .app:not(.sidebar-hidden) .scrim.for-sidebar { display: block; }
  .app.sidebar-hidden .sidebar { margin-left: calc(var(--sidebar-w) * -1); }
  .sidebar-open { display: inline-flex; }
  .sidebar-collapse { display: none; }
  .suggestions { grid-template-columns: 1fr; }
  .thread { padding: 20px 16px 12px; }
  .composer-wrap { padding: 8px 14px 14px; }
  .msg-user .msg-body { max-width: 88%; }
}

/* ---------- Modal ---------- */
.modal-host { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 24px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(15,16,23,.5); backdrop-filter: blur(3px); animation: fade .2s; }
@keyframes fade { from { opacity: 0; } }
.modal {
  position: relative; width: 100%; max-width: 560px; max-height: 84vh;
  background: var(--surface); border-radius: var(--r-xl); box-shadow: var(--sh-lg);
  display: flex; flex-direction: column; animation: pop .22s cubic-bezier(.34,1.4,.5,1);
  overflow: hidden;
}
.modal.wide { max-width: 720px; }
@keyframes pop { from { opacity: 0; transform: scale(.96) translateY(8px); } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.modal-head h2 { font-size: 18px; font-weight: 600; margin: 0; letter-spacing: -.01em; }
.modal-body { padding: 20px 22px; overflow-y: auto; }
.modal-body .field { margin-bottom: 16px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.btn-ghost { background: none; border: 1px solid var(--line-2); color: var(--ink-2); border-radius: var(--r); padding: 11px 18px; font-size: 14.5px; font-weight: 550; }
.btn-ghost:hover { border-color: var(--ink-2); }
.btn-danger { background: var(--err); color: #fff; border: none; border-radius: var(--r); padding: 11px 18px; font-size: 14.5px; font-weight: 600; }
.btn-danger:hover { filter: brightness(.94); }
.btn-danger.btn-sm { padding: 8px 14px; font-size: 13.5px; }

/* List inside management modals */
.mlist { display: flex; flex-direction: column; gap: 10px; }
.mlist-item { display: flex; align-items: flex-start; gap: 12px; padding: 13px; border: 1px solid var(--line); border-radius: var(--r); }
.mlist-item.pinned { border-color: rgba(22,189,202,.4); background: rgba(22,189,202,.05); }
.mlist-icon { width: 34px; height: 34px; flex: 0 0 34px; border-radius: 9px; background: var(--canvas-2); display: grid; place-items: center; color: var(--indigo); }
.mlist-main { flex: 1; min-width: 0; }
.mlist-title { font-size: 14px; font-weight: 600; }
.mlist-sub { font-size: 13px; color: var(--muted); margin-top: 2px; word-wrap: break-word; }
.mlist-actions { display: flex; gap: 4px; flex: 0 0 auto; }
.mlist-tag { font-size: 11px; font-weight: 600; color: var(--indigo); background: rgba(91,83,224,.1); padding: 2px 8px; border-radius: 20px; }
.mlist-tag.system { color: var(--muted); background: var(--canvas-2); }
.empty-note { text-align: center; color: var(--faint); padding: 30px 10px; font-size: 14px; }
.modal-section-head { display: flex; align-items: center; justify-content: space-between; margin: 4px 0 12px; }
.modal-section-head h3 { font-size: 14px; font-weight: 600; margin: 0; }
.usage-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 18px; }
.usage-card { background: var(--canvas-2); border-radius: var(--r); padding: 14px; }
.usage-card .label { font-size: 12px; color: var(--muted); }
.usage-card .value { font-size: 22px; font-weight: 700; letter-spacing: -.02em; margin-top: 2px; }

/* ---------- Toasts ---------- */
.toast-host { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 80; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  background: var(--ink); color: #fff; padding: 11px 18px; border-radius: 30px;
  font-size: 13.5px; font-weight: 500; box-shadow: var(--sh-lg);
  animation: toastIn .25s cubic-bezier(.34,1.4,.5,1); max-width: 90vw;
}
.toast.err { background: var(--err); }
.toast.ok { background: var(--ok); }
@keyframes toastIn { from { opacity: 0; transform: translateY(12px); } }

/* Accessibility */
:focus-visible { outline: 2px solid var(--indigo); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}
[hidden] { display: none !important; }
