:root {
  --bg: #0b0f14;
  --panel: #111826;
  --panel-2: #0f1722;
  --text: #e9eef6;
  --muted: #9fb1c7;
  --primary: #4f8cff;
  --primary-2: #3a6fd3;
  --success: #10b981;
  --danger: #ef4444;
  --border: #1e293b;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, sans-serif; }
.app {
  display: grid;
  grid-template-columns: 320px 1fr;
  height: 100dvh;
}
.sidebar { background: var(--panel); border-right: 1px solid var(--border); display: flex; flex-direction: column; }
.sidebar header { padding: 16px; border-bottom: 1px solid var(--border); font-weight: 700; letter-spacing: .2px; }
.section { padding: 16px; border-bottom: 1px solid var(--border); }
.section h3 { margin: 0 0 8px; font-size: 14px; color: var(--muted); font-weight: 600; }
.row { display: flex; gap: 8px; margin-bottom: 8px; }
input, button, select, textarea { padding: 10px 12px; border-radius: 8px; border: 1px solid var(--border); background: var(--panel-2); color: var(--text); }
input::placeholder, textarea::placeholder { color: #7b8aa1; }
button { background: var(--primary); border: none; cursor: pointer; font-weight: 600; }
button:hover { background: var(--primary-2); }
button.ghost { background: transparent; border: 1px solid var(--border); }
.pill { font-size: 12px; padding: 6px 8px; border-radius: 999px; background: #0e1522; border: 1px solid var(--border); color: var(--muted); }
.stack { display: flex; flex-direction: column; gap: 8px; }
.stack-md { gap: 12px; }
.stack-lg { gap: 16px; }
.status { font-size: 12px; color: var(--muted); }
.token { display: inline-block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; vertical-align: bottom; }

.main { display: grid; grid-template-rows: auto 1fr auto; height: 100%; }
.main header { padding: 16px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.chat { padding: 16px; overflow: auto; }
.bubble { max-width: 70%; padding: 12px 14px; border-radius: 14px; margin: 8px 0; line-height: 1.45; }
.bubble.user { background: #1a2434; margin-left: auto; }
.bubble.assistant { background: #0e1624; border: 1px solid var(--border); }
.composer { padding: 12px 16px; border-top: 1px solid var(--border); display: grid; grid-template-columns: 1fr auto; gap: 8px; }

.list { display: flex; flex-direction: column; gap: 6px; max-height: 150px; overflow: auto; }
.list-item { display: flex; align-items: center; justify-content: space-between; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--panel-2); }
.list-item small { color: var(--muted); }

.toast { position: fixed; right: 16px; bottom: 16px; background: #0d1421; border: 1px solid var(--border); padding: 10px 12px; border-radius: 10px; color: var(--text); box-shadow: 0 10px 30px rgba(0,0,0,.35); }
.toast.error { border-color: #3b1114; color: #fecaca; }
.toast.success { border-color: #0b2b1f; color: #d1fae5; }

/* Backdrop for mobile */
.backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.45); backdrop-filter: blur(2px); display: none; z-index: 30; }
.backdrop.show { display: block; }

/* Mobile tweaks */
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  /* Off-canvas sidebar */
  .sidebar {
    position: fixed;
    top: 0; bottom: 0; left: 0;
    width: 88%; max-width: 360px;
    transform: translateX(-100%);
    transition: transform .25s ease;
    z-index: 40;
  }
  .sidebar.open { transform: translateX(0); }
  /* Show menu button in header */
  .menu-btn { display: inline-flex; align-items: center; gap: 6px; }
}

/* Desktop: hide backdrop and menu button */
@media (min-width: 901px) {
  .backdrop { display: none !important; }
  .menu-btn { display: none; }
}


