@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&family=Fira+Code:wght@300;400;500&display=swap');

/* ────────────────────────────────────────────────────────────
   Tokens
──────────────────────────────────────────────────────────── */
:root {
  --bg:       #0b0b0f;
  --bg1:      #101015;
  --bg2:      #15151c;
  --bg3:      #1c1c25;
  --bg4:      #23232e;
  --bg5:      #2a2a36;

  --br:       #1e1e28;
  --br2:      #28283a;
  --br3:      #333348;

  --t1:       #eeeef4;
  --t2:       #9090a8;
  --t3:       #52526a;
  --t4:       #33333f;

  --blue:     #5b8ef0;
  --blue-bg:  rgba(91,142,240,.1);
  --blue-br:  rgba(91,142,240,.22);

  --green:    #3ecf8e;
  --green-bg: rgba(62,207,142,.1);

  --red:      #f06a6a;
  --red-bg:   rgba(240,106,106,.1);
  --red-br:   rgba(240,106,106,.22);

  --amber:    #e9a84a;
  --amber-bg: rgba(233,168,74,.1);

  --purple:   #9b8afb;
  --purple-bg:rgba(155,138,251,.1);

  --r1:  4px;
  --r2:  7px;
  --r3:  10px;
  --r4:  14px;
  --r5:  18px;

  --font: 'Outfit', sans-serif;
  --mono: 'Fira Code', monospace;

  --ease:   cubic-bezier(.4,0,.2,1);
  --spring: cubic-bezier(.34,1.56,.64,1);
  --t: .14s;

  /* spacing scale */
  --sp1: 4px;
  --sp2: 8px;
  --sp3: 12px;
  --sp4: 16px;
  --sp5: 24px;
  --sp6: 32px;
  --sp7: 48px;
}

/* ────────────────────────────────────────────────────────────
   Reset
──────────────────────────────────────────────────────────── */
#aio-root, #aio-root *, #aio-root *::before, #aio-root *::after {
  box-sizing: border-box; margin: 0;
}
#aio-root {
  font-family: var(--font); color: var(--t1); background: var(--bg);
  min-height: 100vh; font-size: 14px; line-height: 1.55;
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
}
#aio-root a { color: var(--blue); text-decoration: none; }
#aio-root a:hover { opacity: .8; }
#aio-root button, #aio-root input, #aio-root textarea, #aio-root select {
  font-family: var(--font);
}

/* ────────────────────────────────────────────────────────────
   Shell
──────────────────────────────────────────────────────────── */
.shell {
  display: grid;
  grid-template-columns: 228px 1fr;
  grid-template-rows: 56px 1fr;
  height: 100vh;
  overflow: hidden;
}
.shell > .topbar  { grid-column: 1 / -1; }
.shell > .sidebar { grid-row: 2; overflow-y: auto; }
.shell-main    { grid-row: 2; overflow-y: auto; }

/* ────────────────────────────────────────────────────────────
   Topbar
──────────────────────────────────────────────────────────── */
.topbar {
  display: flex; align-items: center;
  height: 56px;
  background: var(--bg1);
  border-bottom: 1px solid var(--br);
  position: relative; z-index: 60;
}
.topbar-brand {
  width: 228px; flex-shrink: 0;
  display: flex; align-items: center; gap: 10px;
  padding: 0 var(--sp5);
  border-right: 1px solid var(--br);
  height: 100%;
}
.brand-mark {
  width: 28px; height: 28px; border-radius: var(--r2);
  background: var(--blue); display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.brand-mark svg { width: 14px; height: 14px; }
.brand-name {
  font-size: 13px; font-weight: 600; color: var(--t1);
  white-space: nowrap;
}
.brand-name em { color: var(--t3); font-style: normal; font-weight: 400; }
.topbar-center {
  flex: 1; padding: 0 var(--sp5);
  display: flex; align-items: center; gap: var(--sp2);
  font-size: 13px; color: var(--t3);
}
.topbar-center b { color: var(--t1); font-weight: 500; }
.topbar-center .sep { color: var(--br3); }
.topbar-right {
  display: flex; align-items: center; gap: var(--sp2);
  padding: 0 var(--sp4) 0 0;
}

/* ────────────────────────────────────────────────────────────
   Sidebar
──────────────────────────────────────────────────────────── */
.sidebar {
  background: var(--bg1);
  border-right: 1px solid var(--br);
  padding: var(--sp3) var(--sp2) var(--sp4);
  display: flex; flex-direction: column;
}
.nav-section { margin-bottom: var(--sp3); }
.nav-label {
  font-size: 10px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .1em; color: var(--t4);
  padding: var(--sp4) var(--sp3) var(--sp2);
}
.nav-item {
  display: flex; align-items: center; gap: var(--sp2);
  padding: 9px var(--sp3); border-radius: var(--r2);
  font-size: 13px; font-weight: 500; color: var(--t2);
  cursor: pointer; user-select: none;
  transition: background var(--t) var(--ease), color var(--t) var(--ease);
  border: 1px solid transparent;
}
.nav-item:hover { background: var(--bg3); color: var(--t1); }
.nav-item.active {
  background: var(--blue-bg); color: var(--blue);
  border-color: var(--blue-br);
}
.nav-icon {
  width: 16px; height: 16px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; opacity: .65;
}
.nav-item.active .nav-icon { opacity: 1; }
.nav-icon svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 1.65; stroke-linecap: round; stroke-linejoin: round; }
.nav-badge {
  margin-left: auto; min-width: 19px; height: 19px; padding: 0 5px;
  background: var(--bg4); color: var(--t3);
  border-radius: 20px; font-size: 10px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--mono);
}
.nav-item.active .nav-badge { background: var(--blue-bg); color: var(--blue); }
.sidebar-footer {
  margin-top: auto; padding-top: var(--sp3);
  border-top: 1px solid var(--br);
}
.sidebar-footer .nav-item { color: var(--t3); font-size: 12px; }

/* ────────────────────────────────────────────────────────────
   Main content
──────────────────────────────────────────────────────────── */
.main { padding: var(--sp6) var(--sp7); }

.page-hd { margin-bottom: var(--sp6); }
.page-hd h1 { font-size: 22px; font-weight: 600; color: var(--t1); letter-spacing: -.01em; }
.page-hd p  { font-size: 13px; color: var(--t2); margin-top: 3px; }

/* ────────────────────────────────────────────────────────────
   Notification Bell
──────────────────────────────────────────────────────────── */
.bell-wrap { position: relative; }
.bell-btn {
  width: 36px; height: 36px; border-radius: var(--r2);
  background: transparent; border: 1px solid var(--br);
  display: flex; align-items: center; justify-content: center;
  color: var(--t2); cursor: pointer;
  transition: all var(--t) var(--ease);
}
.bell-btn:hover { background: var(--bg3); color: var(--t1); border-color: var(--br2); }
.bell-btn.lit { color: var(--blue); border-color: var(--blue-br); background: var(--blue-bg); }
.bell-btn svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.bell-dot {
  position: absolute; top: -3px; right: -3px;
  min-width: 17px; height: 17px; padding: 0 4px;
  background: var(--red); color: #fff; border-radius: 10px;
  font-size: 9px; font-weight: 700; font-family: var(--mono);
  display: flex; align-items: center; justify-content: center;
  border: 2px solid var(--bg1);
}
@keyframes bell-ring {
  0%,100%{transform:rotate(0)}15%{transform:rotate(13deg)}35%{transform:rotate(-11deg)}55%{transform:rotate(8deg)}75%{transform:rotate(-5deg)}
}
.bell-btn.lit svg { animation: bell-ring 2.8s ease-in-out infinite; }
.bell-panel {
  position: absolute; top: calc(100% + 9px); right: 0;
  width: 330px; background: var(--bg2);
  border: 1px solid var(--br2); border-radius: var(--r5);
  box-shadow: 0 24px 60px rgba(0,0,0,.65), 0 0 0 1px rgba(255,255,255,.03);
  overflow: hidden; z-index: 200;
}
.bell-panel-hd {
  padding: var(--sp4) var(--sp5) var(--sp3);
  border-bottom: 1px solid var(--br);
  display: flex; align-items: center; justify-content: space-between;
}
.bell-panel-hd h4 { font-size: 13px; font-weight: 600; }
.bell-read-all { font-size: 12px; color: var(--blue); font-weight: 500; cursor: pointer; }
.bell-read-all:hover { opacity: .7; }
.bell-list { max-height: 340px; overflow-y: auto; }
.bell-empty { padding: 32px var(--sp5); text-align: center; font-size: 13px; color: var(--t3); }
.bell-notif {
  padding: var(--sp3) var(--sp5); border-bottom: 1px solid var(--br);
  display: flex; gap: var(--sp3); align-items: flex-start;
  cursor: pointer; transition: background var(--t) var(--ease);
}
.bell-notif:hover { background: var(--bg3); }
.bell-notif:last-child { border-bottom: none; }
.bell-notif-dot {
  width: 7px; height: 7px; border-radius: 50%; margin-top: 5px; flex-shrink: 0;
}
.bell-notif-dot.u { background: var(--blue); }
.bell-notif-dot.r { background: var(--t4); }
.bell-notif-text .t1 { font-size: 13px; font-weight: 500; color: var(--t1); }
.bell-notif-text .t2 { font-size: 12px; color: var(--t2); margin-top: 2px; line-height: 1.45; }
.bell-notif-text .t3 { font-size: 11px; color: var(--t3); margin-top: 5px; font-family: var(--mono); }

/* ────────────────────────────────────────────────────────────
   Buttons
──────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px; padding: 8px 16px; border-radius: var(--r2);
  font-size: 13px; font-weight: 500; border: 1px solid transparent;
  transition: all var(--t) var(--ease); white-space: nowrap;
  cursor: pointer; line-height: 1;
}
.btn svg { width: 13px; height: 13px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.btn-primary  { background: var(--blue);  color: #fff;    border-color: var(--blue);  }
.btn-primary:hover  { filter: brightness(1.14); }
.btn-default  { background: var(--bg3);   color: var(--t1); border-color: var(--br2); }
.btn-default:hover  { background: var(--bg4); border-color: var(--br3); }
.btn-ghost    { background: transparent;  color: var(--t2); border-color: transparent; }
.btn-ghost:hover    { background: var(--bg3); color: var(--t1); }
.btn-danger   { background: var(--red-bg); color: var(--red); border-color: var(--red-br); }
.btn-danger:hover   { filter: brightness(1.1); }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-xs { padding: 4px 9px;  font-size: 11px; border-radius: var(--r1); }
.btn-icon {
  width: 32px; height: 32px; padding: 0;
  background: transparent; border-color: var(--br);
  color: var(--t2);
}
.btn-icon:hover { background: var(--bg3); color: var(--t1); border-color: var(--br2); }
.btn-icon svg { width: 14px; height: 14px; }
.btn:disabled { opacity: .4; cursor: not-allowed; filter: none; }

/* ────────────────────────────────────────────────────────────
   Stats
──────────────────────────────────────────────────────────── */
.stats-row {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: var(--sp4); margin-bottom: var(--sp6);
}
.stat-card {
  background: var(--bg2); border: 1px solid var(--br);
  border-radius: var(--r4); padding: var(--sp5) var(--sp5);
  transition: border-color var(--t) var(--ease);
}
.stat-card:hover { border-color: var(--br2); }
.stat-val {
  font-size: 32px; font-weight: 600; color: var(--t1);
  font-family: var(--mono); line-height: 1; margin-bottom: 6px;
  letter-spacing: -.02em;
}
.stat-lbl { font-size: 12px; color: var(--t2); }

/* ────────────────────────────────────────────────────────────
   Toolbar
──────────────────────────────────────────────────────────── */
.toolbar {
  display: flex; align-items: center; gap: var(--sp2);
  margin-bottom: var(--sp4); flex-wrap: wrap;
}
.search {
  flex: 1; min-width: 180px; height: 36px; padding: 0 var(--sp3);
  background: var(--bg2); border: 1px solid var(--br);
  border-radius: var(--r2); color: var(--t1); font-size: 13px;
  outline: none; transition: border-color var(--t) var(--ease);
}
.search::placeholder { color: var(--t3); }
.search:focus { border-color: var(--blue-br); }
.filter-group { display: flex; gap: 6px; }
.fc {
  padding: 5px 13px; border-radius: 20px; font-size: 12px; font-weight: 500;
  border: 1px solid var(--br); color: var(--t2); cursor: pointer;
  background: transparent; transition: all var(--t) var(--ease);
}
.fc:hover { border-color: var(--br2); color: var(--t1); }
.fc.on  { background: var(--blue-bg); border-color: var(--blue-br); color: var(--blue); }

/* ────────────────────────────────────────────────────────────
   Card (table replacement with real breathing room)
──────────────────────────────────────────────────────────── */
.card {
  background: var(--bg2); border: 1px solid var(--br);
  border-radius: var(--r4); overflow: hidden;
}
.card-hd {
  padding: var(--sp4) var(--sp5); border-bottom: 1px solid var(--br);
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--sp3);
}
.card-hd h3 { font-size: 13px; font-weight: 600; color: var(--t1); }

/* ────────────────────────────────────────────────────────────
   Data list rows (agents, prompts, docs)
──────────────────────────────────────────────────────────── */
.row {
  display: grid; padding: var(--sp4) var(--sp5);
  border-bottom: 1px solid var(--br);
  align-items: center; gap: var(--sp4);
  transition: background var(--t) var(--ease);
}
.row:last-child { border-bottom: none; }
.row:hover { background: var(--bg3); }
.row-hd {
  padding: var(--sp2) var(--sp5);
  border-bottom: 1px solid var(--br);
  background: var(--bg1);
  display: grid; align-items: center;
  gap: var(--sp4);
}
.col-label {
  font-size: 10px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .09em; color: var(--t3);
}
/* agent list: name|model|tags|status|actions */
.agents-row    { grid-template-columns: 1fr 160px 1fr auto 88px; }
/* prompts list: title|category|agent|uses|actions */
.prompts-row   { grid-template-columns: 1fr 140px 160px 60px 100px; }
/* docs list: title|filename|agent|date|actions */
.docs-row      { grid-template-columns: 1fr 180px 160px 110px 72px; }

.row-main      { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.row-name      { font-size: 14px; font-weight: 500; color: var(--t1); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-sub       { font-size: 12px; color: var(--t2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.4; }
.row-sub.code  { font-family: var(--mono); font-size: 11px; }
.row-actions   { display: flex; gap: 5px; justify-content: flex-end; }
.prompt-snippet {
  font-family: var(--mono); font-size: 11.5px; color: var(--t2);
  background: var(--bg3); border: 1px solid var(--br);
  border-radius: var(--r1); padding: 6px 10px; margin-top: 5px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; line-height: 1.55;
}

/* ────────────────────────────────────────────────────────────
   Pill / Tag / Badge
──────────────────────────────────────────────────────────── */
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 20px;
  font-size: 11px; font-weight: 500; white-space: nowrap;
}
.pill-green  { background: var(--green-bg); color: var(--green); }
.pill-red    { background: var(--red-bg);   color: var(--red);   }
.pill-blue   { background: var(--blue-bg);  color: var(--blue);  }
.pill-amber  { background: var(--amber-bg); color: var(--amber); }
.pill-purple { background: var(--purple-bg);color: var(--purple);}
.pill-muted  { background: var(--bg4);      color: var(--t3);    }
.dot {
  width: 6px; height: 6px; border-radius: 50%;
  display: inline-block; flex-shrink: 0;
}
.dot-green { background: var(--green); box-shadow: 0 0 5px rgba(62,207,142,.5); }
.dot-muted { background: var(--t4); }
.tag {
  display: inline-flex; padding: 2px 8px; border-radius: var(--r1);
  font-size: 11px; font-weight: 500;
  background: var(--bg4); color: var(--t3); border: 1px solid var(--br);
}
.tags { display: flex; gap: 5px; flex-wrap: wrap; }
.model-lozenge {
  font-family: var(--mono); font-size: 11px; padding: 3px 8px;
  border-radius: var(--r1); border: 1px solid var(--br);
  background: var(--bg3); color: var(--t2); white-space: nowrap;
}
.model-lozenge.openai    { color: #74aa9c; background: rgba(116,170,156,.09); border-color: rgba(116,170,156,.2); }
.model-lozenge.anthropic { color: #d97757; background: rgba(217,119,87,.09);  border-color: rgba(217,119,87,.2);  }
.model-lozenge.google    { color: #5b8ef0; background: var(--blue-bg);         border-color: var(--blue-br);        }
.model-lozenge.mistral   { color: #9b8afb; background: var(--purple-bg);       border-color: rgba(155,138,251,.2);  }

/* ────────────────────────────────────────────────────────────
   Form
──────────────────────────────────────────────────────────── */
.fg  { margin-bottom: var(--sp4); }
.fg:last-child { margin-bottom: 0; }
.fl  { display: block; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .07em; color: var(--t2); margin-bottom: 7px; }
.fi, .fs, .ft {
  width: 100%; padding: 9px 13px;
  background: var(--bg3); border: 1px solid var(--br);
  border-radius: var(--r2); color: var(--t1); font-size: 13px; outline: none;
  transition: border-color var(--t) var(--ease);
}
.fi::placeholder, .ft::placeholder { color: var(--t3); }
.fi:focus, .fs:focus, .ft:focus { border-color: var(--blue-br); }
.fs { appearance: none; cursor: pointer; }
.ft { resize: vertical; min-height: 96px; font-family: var(--mono); font-size: 12px; line-height: 1.65; }
.ft.tall   { min-height: 160px; }
.ft.xlarge { min-height: 220px; }
.f2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp4); }
.fhint { font-size: 11px; color: var(--t3); margin-top: 5px; }
.pw { position: relative; }
.pw .fi   { padding-right: 40px; }
.pw-eye   { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); background: none; border: none; color: var(--t2); cursor: pointer; display: flex; align-items: center; }
.pw-eye svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.color-row { display: flex; align-items: center; gap: 9px; }
input[type=color].color-pick { width: 36px; height: 36px; border-radius: var(--r1); border: 1px solid var(--br); background: var(--bg3); cursor: pointer; padding: 3px; }

/* ────────────────────────────────────────────────────────────
   Modal
──────────────────────────────────────────────────────────── */
.overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(11,11,15,.8); backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center; padding: var(--sp5);
}
.modal {
  background: var(--bg2); border: 1px solid var(--br2);
  border-radius: var(--r5); width: 100%; max-width: 520px;
  max-height: 92vh; overflow-y: auto;
  box-shadow: 0 40px 100px rgba(0,0,0,.7), 0 0 0 1px rgba(255,255,255,.03);
}
.modal.wide  { max-width: 680px; }
.modal.narrow{ max-width: 420px; }
.modal-hd {
  padding: var(--sp5) var(--sp6) var(--sp4);
  border-bottom: 1px solid var(--br);
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; background: var(--bg2); z-index: 1;
}
.modal-hd h2 { font-size: 16px; font-weight: 600; letter-spacing: -.01em; }
.modal-x {
  width: 30px; height: 30px; border-radius: var(--r1);
  background: transparent; border: none; color: var(--t3); font-size: 20px; line-height: 1;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
  transition: all var(--t) var(--ease);
}
.modal-x:hover { background: var(--bg4); color: var(--t1); }
.modal-body { padding: var(--sp5) var(--sp6); }
.modal-ft   { padding: var(--sp4) var(--sp6) var(--sp5); display: flex; justify-content: flex-end; gap: var(--sp2); border-top: 1px solid var(--br); }

/* ────────────────────────────────────────────────────────────
   Empty state
──────────────────────────────────────────────────────────── */
.empty {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; padding: var(--sp7) var(--sp5); text-align: center;
}
.empty-icon { color: var(--t4); margin-bottom: var(--sp4); }
.empty-icon svg { width: 40px; height: 40px; stroke: currentColor; fill: none; stroke-width: 1.2; stroke-linecap: round; stroke-linejoin: round; }
.empty h3 { font-size: 15px; font-weight: 600; color: var(--t2); margin-bottom: 5px; }
.empty p  { font-size: 13px; color: var(--t3); margin-bottom: var(--sp5); max-width: 280px; }

/* ────────────────────────────────────────────────────────────
   Toast
──────────────────────────────────────────────────────────── */
.toasts {
  position: fixed; bottom: var(--sp5); right: var(--sp5); z-index: 9999;
  display: flex; flex-direction: column; gap: var(--sp2);
}
.toast {
  background: var(--bg2); border: 1px solid var(--br2);
  border-radius: var(--r3); padding: 11px 16px;
  font-size: 13px; display: flex; align-items: center; gap: 10px;
  box-shadow: 0 14px 40px rgba(0,0,0,.6); min-width: 248px;
  animation: tin .22s var(--spring);
}
.toast.success { border-color: rgba(62,207,142,.28); }
.toast.error   { border-color: var(--red-br); }
.toast-d { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.success .toast-d { background: var(--green); }
.error   .toast-d { background: var(--red);   }
.info    .toast-d { background: var(--blue);  }
@keyframes tin { from{opacity:0;transform:translateX(18px)} to{opacity:1;transform:none} }

/* ────────────────────────────────────────────────────────────
   Dropzone
──────────────────────────────────────────────────────────── */
.dropzone {
  border: 1.5px dashed var(--br2); border-radius: var(--r4);
  padding: var(--sp6) var(--sp5); text-align: center; cursor: pointer;
  transition: all var(--t) var(--ease);
}
.dropzone:hover, .dropzone.drag { border-color: var(--blue-br); background: var(--blue-bg); }
.dropzone svg  { width: 28px; height: 28px; stroke: var(--t3); fill: none; stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }
.dropzone p    { font-size: 13px; color: var(--t2); margin-top: 9px; }
.dropzone span { color: var(--blue); font-weight: 500; }
.dropzone small{ font-size: 11px; color: var(--t3); display: block; margin-top: 4px; }

/* ────────────────────────────────────────────────────────────
   Markdown preview
──────────────────────────────────────────────────────────── */
.md {
  background: var(--bg3); border: 1px solid var(--br);
  border-radius: var(--r2); padding: var(--sp4);
  font-family: var(--mono); font-size: 12px; color: var(--t1);
  line-height: 1.75; max-height: 320px; overflow-y: auto;
}
.md h1,.md h2,.md h3 { font-family: var(--font); color: var(--blue); margin: 14px 0 6px; }
.md code  { background: var(--bg4); padding: 1px 5px; border-radius: 3px; color: var(--purple); }
.md pre   { background: var(--bg4); padding: 12px; border-radius: var(--r1); overflow-x: auto; margin: 8px 0; }
.md blockquote { border-left: 2px solid var(--blue-br); padding-left: 12px; color: var(--t2); margin: 8px 0; }
.md p     { margin-bottom: 8px; }
.md a     { color: var(--blue); }
.md ul, .md ol { padding-left: 18px; margin-bottom: 8px; }
.md hr    { border: none; border-top: 1px solid var(--br); margin: 12px 0; }

/* ────────────────────────────────────────────────────────────
   CHAT  –  full-height split layout
──────────────────────────────────────────────────────────── */
.chat-shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  height: calc(100vh - 56px);
  overflow: hidden;
}

/* sessions pane */
.chat-sessions {
  background: var(--bg1);
  border-right: 1px solid var(--br);
  display: flex; flex-direction: column;
  overflow: hidden;
}
.chat-sessions-hd {
  padding: var(--sp4) var(--sp4) var(--sp3);
  border-bottom: 1px solid var(--br);
  flex-shrink: 0;
}
.chat-sessions-hd h3 { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .09em; color: var(--t3); margin-bottom: var(--sp3); }
.chat-sessions-list { flex: 1; overflow-y: auto; padding: var(--sp2); }
.session-item {
  padding: 10px 12px; border-radius: var(--r2); cursor: pointer;
  transition: background var(--t) var(--ease); margin-bottom: 2px;
  display: flex; align-items: flex-start; gap: 9px;
  border: 1px solid transparent;
}
.session-item:hover { background: var(--bg3); }
.session-item.active { background: var(--blue-bg); border-color: var(--blue-br); }
.session-item-body { flex: 1; min-width: 0; }
.session-title {
  font-size: 12px; font-weight: 500; color: var(--t1);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  margin-bottom: 2px;
}
.session-item.active .session-title { color: var(--blue); }
.session-meta { font-size: 11px; color: var(--t3); font-family: var(--mono); }
.session-del {
  width: 22px; height: 22px; border-radius: var(--r1); border: none;
  background: transparent; color: var(--t4); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: all var(--t) var(--ease); flex-shrink: 0;
}
.session-item:hover .session-del { opacity: 1; }
.session-del:hover { background: var(--red-bg); color: var(--red); }
.session-del svg { width: 12px; height: 12px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.session-empty { padding: var(--sp5) var(--sp4); font-size: 12px; color: var(--t3); text-align: center; line-height: 1.55; }

/* chat panel */
.chat-panel {
  display: flex; flex-direction: column; overflow: hidden; height: 100%;
}
.chat-toolbar {
  padding: var(--sp3) var(--sp4);
  border-bottom: 1px solid var(--br);
  background: var(--bg1);
  display: flex; align-items: center; gap: var(--sp3); flex-shrink: 0;
}
.chat-toolbar .sep { width: 1px; height: 22px; background: var(--br2); }
.chat-toolbar label { font-size: 11px; color: var(--t3); margin-right: 3px; }
.chat-select {
  height: 30px; padding: 0 var(--sp3);
  background: var(--bg3); border: 1px solid var(--br);
  border-radius: var(--r1); color: var(--t1); font-size: 12px; outline: none;
  cursor: pointer; transition: border-color var(--t) var(--ease);
  font-family: var(--mono);
}
.chat-select:focus { border-color: var(--blue-br); }
.chat-messages { flex: 1; overflow-y: auto; padding: var(--sp6) var(--sp6); display: flex; flex-direction: column; gap: var(--sp5); }
.chat-welcome {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: var(--sp3);
  color: var(--t3);
}
.chat-welcome svg { width: 36px; height: 36px; stroke: currentColor; fill: none; stroke-width: 1.2; opacity: .4; }
.chat-welcome p { font-size: 13px; }

.msg { display: flex; gap: var(--sp3); max-width: 78%; }
.msg.user { align-self: flex-end; flex-direction: row-reverse; }
.msg.assistant { align-self: flex-start; }
.msg-avatar {
  width: 30px; height: 30px; border-radius: var(--r2); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; margin-top: 1px;
}
.msg.user      .msg-avatar { background: var(--blue);   color: #fff; }
.msg.assistant .msg-avatar { background: var(--bg4); color: var(--t2); border: 1px solid var(--br2); font-size: 10px; }
.msg-content { display: flex; flex-direction: column; gap: 4px; }
.msg-bubble {
  padding: var(--sp3) var(--sp4); border-radius: var(--r4);
  font-size: 13px; line-height: 1.65; word-break: break-word;
}
.msg.user      .msg-bubble { background: var(--blue); color: #fff; border-bottom-right-radius: var(--r1); }
.msg.assistant .msg-bubble { background: var(--bg2); border: 1px solid var(--br2); color: var(--t1); border-bottom-left-radius: var(--r1); }
.msg-bubble.err { background: var(--red-bg); border-color: var(--red-br); color: var(--red); }
.msg-actions { display: flex; gap: 5px; align-self: flex-end; }
.msg-btn {
  height: 22px; padding: 0 7px; border-radius: var(--r1);
  border: 1px solid var(--br); background: transparent; color: var(--t3);
  font-size: 11px; cursor: pointer; transition: all var(--t) var(--ease);
  display: flex; align-items: center; gap: 4px;
}
.msg-btn svg { width: 11px; height: 11px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.msg-btn:hover { background: var(--bg3); color: var(--t1); border-color: var(--br2); }
.typing-indicator {
  display: flex; align-items: center; gap: 4px;
  padding: var(--sp3) var(--sp4); background: var(--bg2);
  border: 1px solid var(--br2); border-radius: var(--r4); border-bottom-left-radius: var(--r1);
  width: fit-content;
}
.typing-dot {
  width: 5px; height: 5px; border-radius: 50%; background: var(--t2);
  animation: tdot 1.1s ease-in-out infinite;
}
.typing-dot:nth-child(2) { animation-delay: .15s; }
.typing-dot:nth-child(3) { animation-delay: .30s; }
@keyframes tdot { 0%,100%{opacity:.25;transform:scale(.8)} 50%{opacity:1;transform:scale(1)} }

/* system prompt banner */
.sys-banner {
  display: flex; align-items: center; gap: var(--sp2); padding: 7px var(--sp3);
  background: rgba(91,142,240,.07); border: 1px solid var(--blue-br);
  border-radius: var(--r2); font-size: 11px; color: var(--t3); font-family: var(--mono);
  margin-bottom: var(--sp3);
}
.sys-banner svg { width: 12px; height: 12px; stroke: var(--blue); fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }

/* input bar */
.chat-bar {
  padding: var(--sp4) var(--sp5);
  background: var(--bg1); border-top: 1px solid var(--br);
  flex-shrink: 0;
}
.chat-bar-inner { display: flex; gap: var(--sp2); align-items: flex-end; }
.chat-input {
  flex: 1; background: var(--bg3); border: 1px solid var(--br);
  border-radius: var(--r3); padding: var(--sp3) var(--sp4);
  color: var(--t1); font-size: 13px; font-family: var(--font);
  resize: none; outline: none; max-height: 130px; min-height: 44px;
  transition: border-color var(--t) var(--ease); line-height: 1.55;
}
.chat-input:focus { border-color: var(--blue-br); }
.chat-input::placeholder { color: var(--t3); }
.chat-send-btn {
  width: 40px; height: 40px; border-radius: var(--r2); border: none;
  background: var(--blue); color: #fff; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: filter var(--t); flex-shrink: 0;
}
.chat-send-btn:hover:not(:disabled) { filter: brightness(1.12); }
.chat-send-btn:disabled { opacity: .38; cursor: not-allowed; }
.chat-send-btn svg { width: 16px; height: 16px; stroke: #fff; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.chat-bar-meta {
  display: flex; align-items: center; gap: var(--sp3);
  margin-top: var(--sp2); padding: 0 2px;
}
.chat-hint { font-size: 11px; color: var(--t4); }
.chat-hint b { color: var(--t3); }

/* prompt picker */
.prompt-picker-btn {
  display: flex; align-items: center; gap: 5px;
  padding: 4px 10px; border-radius: var(--r1);
  background: transparent; border: 1px solid var(--br);
  color: var(--t3); font-size: 11px; cursor: pointer;
  transition: all var(--t) var(--ease);
}
.prompt-picker-btn:hover { background: var(--bg3); color: var(--t1); border-color: var(--br2); }
.prompt-picker-btn svg { width: 11px; height: 11px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.prompt-list {
  display: flex; flex-direction: column; gap: 2px; max-height: 320px; overflow-y: auto;
}
.prompt-opt {
  padding: var(--sp3) var(--sp4); border-radius: var(--r2); cursor: pointer;
  border: 1px solid transparent; transition: all var(--t) var(--ease);
}
.prompt-opt:hover { background: var(--bg3); border-color: var(--br); }
.prompt-opt-title { font-size: 13px; font-weight: 500; color: var(--t1); margin-bottom: 3px; }
.prompt-opt-pre   { font-family: var(--mono); font-size: 11px; color: var(--t2); line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.prompt-opt-cat   { font-size: 10px; color: var(--amber); background: var(--amber-bg); padding: 1px 6px; border-radius: 3px; display: inline-block; margin-top: 4px; }
.no-key-bar {
  display: flex; align-items: center; gap: var(--sp3);
  background: var(--red-bg); border: 1px solid var(--red-br);
  border-radius: var(--r2); padding: var(--sp2) var(--sp3);
  font-size: 12px; color: var(--red); margin-bottom: var(--sp3);
}
.no-key-bar svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }

/* ────────────────────────────────────────────────────────────
   Settings
──────────────────────────────────────────────────────────── */
.settings-max { max-width: 560px; }
.provider-block {
  padding: var(--sp5) var(--sp5);
  border-bottom: 1px solid var(--br);
  display: grid; grid-template-columns: 1fr auto; gap: var(--sp4); align-items: center;
}
.provider-block:last-child { border-bottom: none; }
.prov-name  { font-size: 14px; font-weight: 500; color: var(--t1); }
.prov-link  { font-size: 11px; color: var(--t3); margin-top: 3px; display: block; }
.prov-link:hover { color: var(--blue); }
.key-saved  { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--green); }
.key-saved svg { width: 13px; height: 13px; stroke: currentColor; fill: none; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }

/* ────────────────────────────────────────────────────────────
   Dashboard panels
──────────────────────────────────────────────────────────── */
.dash-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp4); margin-bottom: var(--sp4); }
.dash-list-item {
  display: flex; align-items: center; gap: var(--sp3);
  padding: var(--sp3) var(--sp4); border-bottom: 1px solid var(--br);
  font-size: 13px; transition: background var(--t) var(--ease);
}
.dash-list-item:last-child { border-bottom: none; }
.dash-list-item:hover { background: var(--bg3); }
.dash-item-name { flex: 1; font-weight: 500; color: var(--t1); }
.dash-item-meta { font-size: 12px; color: var(--t2); }

/* ────────────────────────────────────────────────────────────
   Vue transitions
──────────────────────────────────────────────────────────── */
.vp-enter-active { animation: vpIn .2s ease; }
.vp-leave-active { animation: vpIn .14s ease reverse; }
@keyframes vpIn { from{opacity:0;transform:translateY(7px)} to{opacity:1;transform:none} }
.vf-enter-active,.vf-leave-active { transition: opacity .14s ease; }
.vf-enter-from,.vf-leave-to       { opacity: 0; }
.vs-enter-active { animation: vsIn .26s var(--spring); }
.vs-leave-active { animation: vsIn .16s ease reverse; }
@keyframes vsIn { from{opacity:0;transform:scale(.94) translateY(-5px)} to{opacity:1;transform:none} }

/* ────────────────────────────────────────────────────────────
   Scrollbars
──────────────────────────────────────────────────────────── */
#aio-root ::-webkit-scrollbar       { width: 4px; height: 4px; }
#aio-root ::-webkit-scrollbar-track { background: transparent; }
#aio-root ::-webkit-scrollbar-thumb { background: var(--bg5); border-radius: 4px; }
#aio-root ::-webkit-scrollbar-thumb:hover { background: var(--br3); }

/* ────────────────────────────────────────────────────────────
   Misc
──────────────────────────────────────────────────────────── */
.divider { border: none; border-top: 1px solid var(--br); margin: var(--sp5) 0; }
.section-lbl { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .09em; color: var(--t3); margin-bottom: var(--sp3); }
.swatch { display: inline-block; width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }

/* ────────────────────────────────────────────────────────────
   Responsive
──────────────────────────────────────────────────────────── */
@media(max-width:900px) {
  .shell { grid-template-columns: 1fr; height: auto; overflow: visible; }
  .topbar-brand { width: auto; border-right: none; }
  .shell > .sidebar { grid-row: auto; }
  .sidebar { flex-direction: row; overflow-x: auto; padding: 6px; border-right: none; border-bottom: 1px solid var(--br); }
  .nav-label,.sidebar-footer { display: none; }
  .nav-item { flex-shrink: 0; }
  .shell-main { grid-row: auto; overflow: visible; }
  .main { padding: var(--sp4); }
  .stats-row { grid-template-columns: 1fr 1fr; }
  .chat-shell { grid-template-columns: 1fr; height: auto; }
  .chat-sessions { display: none; }
  .f2 { grid-template-columns: 1fr; }
  .agents-row,.prompts-row,.docs-row { grid-template-columns: 1fr auto; }
  .dash-grid { grid-template-columns: 1fr; }
}

/* ────────────────────────────────────────────────────────────
   Code blocks (syntax highlighted)
──────────────────────────────────────────────────────────── */
.msg-bubble pre {
  margin: 10px -2px 2px; border-radius: var(--r2); overflow: hidden;
  border: 1px solid var(--br2);
}
.msg-bubble pre .hljs { padding: 14px 16px; font-size: 12px; line-height: 1.65; background: #0d1117; }
.code-block-wrap { position: relative; margin: 8px 0; }
.code-block-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 7px 12px; background: #161b22; border: 1px solid var(--br2);
  border-bottom: none; border-radius: var(--r2) var(--r2) 0 0;
  font-size: 11px; font-family: var(--mono); color: var(--t3);
}
.code-block-header .lang { color: var(--t2); }
.code-copy-btn {
  display: flex; align-items: center; gap: 4px; padding: 3px 8px;
  border-radius: var(--r1); border: 1px solid var(--br3);
  background: transparent; color: var(--t3); font-size: 10px;
  cursor: pointer; transition: all var(--t) var(--ease); font-family: var(--font);
}
.code-copy-btn:hover { background: var(--bg4); color: var(--t1); border-color: var(--br3); }
.code-copy-btn svg  { width: 11px; height: 11px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.code-copy-btn.copied { color: var(--green); border-color: rgba(62,207,142,.3); }

/* Code Library panel */
.code-lib-panel {
  width: 340px; border-left: 1px solid var(--br);
  background: var(--bg1); display: flex; flex-direction: column;
  overflow: hidden; flex-shrink: 0;
}
.code-lib-hd {
  padding: var(--sp3) var(--sp4); border-bottom: 1px solid var(--br);
  display: flex; align-items: center; justify-content: space-between; flex-shrink: 0;
}
.code-lib-hd h3 { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .09em; color: var(--t3); }
.code-lib-list { flex: 1; overflow-y: auto; padding: var(--sp2); }
.code-lib-item {
  background: var(--bg2); border: 1px solid var(--br); border-radius: var(--r2);
  margin-bottom: 8px; overflow: hidden;
}
.code-lib-item-hd {
  padding: 8px 12px; background: var(--bg3); border-bottom: 1px solid var(--br);
  display: flex; align-items: center; justify-content: space-between;
  font-size: 11px; color: var(--t2); font-family: var(--mono);
}
.code-lib-item-body { padding: 10px 12px; font-family: var(--mono); font-size: 11px; color: var(--t1); line-height: 1.55; white-space: pre; overflow-x: auto; max-height: 120px; overflow-y: hidden; }
.code-lib-empty { padding: 28px 16px; text-align: center; font-size: 12px; color: var(--t3); }

/* File attachment */
.attach-bar {
  display: flex; gap: 6px; align-items: center; flex-wrap: wrap;
  padding: 8px var(--sp5) 0; border-top: 1px solid var(--br);
  margin-top: var(--sp2);
}
.attach-thumb {
  position: relative; width: 52px; height: 52px; border-radius: var(--r2);
  overflow: hidden; border: 1px solid var(--br2); flex-shrink: 0;
}
.attach-thumb img { width: 100%; height: 100%; object-fit: cover; }
.attach-thumb-x {
  position: absolute; top: 2px; right: 2px; width: 16px; height: 16px;
  border-radius: 50%; background: rgba(0,0,0,.7); color: #fff; border: none;
  font-size: 11px; line-height: 1; cursor: pointer; display: flex;
  align-items: center; justify-content: center;
}
.attach-file {
  display: flex; align-items: center; gap: 6px; padding: 5px 10px;
  background: var(--bg3); border: 1px solid var(--br); border-radius: var(--r2);
  font-size: 11px; color: var(--t2); font-family: var(--mono); max-width: 200px;
}
.attach-file span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attach-file-x { background: none; border: none; color: var(--t3); cursor: pointer; font-size: 14px; line-height: 1; flex-shrink: 0; }
.attach-file-x:hover { color: var(--red); }

/* Token counter */
.token-counter {
  font-family: var(--mono); font-size: 11px; color: var(--t4);
  transition: color var(--t) var(--ease);
}
.token-counter.warn { color: var(--amber); }
.token-counter.over { color: var(--red); }
.token-bar {
  height: 2px; background: var(--bg4); border-radius: 2px; margin-top: 4px; overflow: hidden;
}
.token-bar-fill {
  height: 100%; background: var(--blue); border-radius: 2px;
  transition: width .2s var(--ease), background .2s;
}
.token-bar-fill.warn { background: var(--amber); }
.token-bar-fill.over { background: var(--red); }

/* Usage display in messages */
.msg-usage {
  font-family: var(--mono); font-size: 10px; color: var(--t4);
  padding: 3px 8px; background: var(--bg3); border-radius: var(--r1);
  display: inline-flex; align-items: center; gap: 5px; margin-top: 4px;
}

/* Dev Mode */
.dev-mode-panel {
  background: var(--bg1); border-top: 1px solid var(--br);
  padding: var(--sp4) var(--sp5); flex-shrink: 0;
  animation: vpIn .2s ease;
}
.dev-mode-panel h4 { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .09em; color: var(--t3); margin-bottom: var(--sp3); display: flex; align-items: center; gap: 6px; }
.dev-mode-panel h4 svg { width: 13px; height: 13px; stroke: var(--blue); fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.dev-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; margin-bottom: 10px; }
.dev-field label { display: block; font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .07em; color: var(--t3); margin-bottom: 5px; }
.dev-textarea { width: 100%; padding: 8px 10px; background: var(--bg3); border: 1px solid var(--br); border-radius: var(--r2); color: var(--t1); font-size: 12px; font-family: var(--mono); resize: none; outline: none; transition: border-color var(--t) var(--ease); line-height: 1.55; min-height: 60px; }
.dev-textarea:focus { border-color: var(--blue-br); }
.dev-textarea::placeholder { color: var(--t3); }
.chat-shell.with-lib { grid-template-columns: 240px 1fr 340px; }

/* Attach button */
.attach-btn {
  display: flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: var(--r2);
  background: transparent; border: 1px solid var(--br);
  color: var(--t3); cursor: pointer; transition: all var(--t) var(--ease);
  flex-shrink: 0;
}
.attach-btn:hover { background: var(--bg3); color: var(--t1); border-color: var(--br2); }
.attach-btn svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 1.65; stroke-linecap: round; stroke-linejoin: round; }
.attach-btn.active { color: var(--blue); border-color: var(--blue-br); background: var(--blue-bg); }
