/* ── Imports ───────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Inter:ital,wght@0,400;0,500;0,600;0,700;1,400&display=swap');

/* ── Design tokens ─────────────────────────────────── */
:root {
  /* Brand purple */
  --brand:       #6644c0;
  --brand-light: #7c56d4;
  --brand-hover: #8f6be0;
  --brand-dark:  #150438;
  --brand-mid:   #1e0850;
  --brand-fade:  rgba(102,68,192,0.12);

  /* Surface */
  --bg:    #f2f3f8;
  --card:  #ffffff;
  --border: #e3e6ef;
  --border-strong: #c8ccdb;

  /* Text */
  --ink:   #1c1f2e;
  --muted: #636a82;

  /* Status */
  --danger:    #c0392b;
  --danger-bg: #fdecea;
  --ok:        #1a7f4b;
  --ok-bg:     #eafaf2;

  /* Sidenav */
  --snav-w:  56px;
  --snav-wx: 200px;

  /* Radii */
  --r:   10px;
  --r-sm: 6px;
  --r-xs: 4px;

  /* Shadows */
  --shadow-sm: 0 1px 4px rgba(0,0,0,0.07);
  --shadow-md: 0 2px 10px rgba(0,0,0,0.10);
}

/* ── Reset ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.55;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ══════════════════════════════════════════════════════
   APP SHELL  (sidebar + content column)
   ══════════════════════════════════════════════════════ */
.app-shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

.sidenav-content {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

/* ══════════════════════════════════════════════════════
   SIDENAV
   ══════════════════════════════════════════════════════ */
.sidenav {
  display: flex;
  flex-direction: column;
  width: var(--snav-w);
  min-width: var(--snav-w);
  height: 100%;
  flex-shrink: 0;
  background: linear-gradient(175deg, #150438 0%, #1e0850 28%, #2d1070 55%, #1a0544 80%, #0d0228 100%);
  overflow: hidden;
  transition: width 220ms cubic-bezier(0.4,0,0.2,1),
              min-width 220ms cubic-bezier(0.4,0,0.2,1);
  position: relative;
  z-index: 200;
  isolation: isolate;
}

/* Right-edge shimmer */
.sidenav::after {
  content: '';
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: 1px;
  background: linear-gradient(to bottom,
    transparent 0%,
    rgba(166,146,230,0.35) 25%,
    rgba(102,68,192,0.5)   50%,
    rgba(166,146,230,0.25) 75%,
    transparent 100%
  );
  pointer-events: none;
}

.sidenav.expanded {
  width: var(--snav-wx);
  min-width: var(--snav-wx);
}

/* Logo row */
.sidenav-logo {
  display: flex;
  align-items: center;
  height: 56px;
  min-height: 56px;
  padding: 0 14px;
  gap: 10px;
  border-bottom: 1px solid rgba(166,146,230,0.12);
  flex-shrink: 0;
  overflow: hidden;
}

.sidenav-logo-icon {
  font-size: 20px;
  min-width: 28px;
  text-align: center;
  flex-shrink: 0;
  line-height: 1;
  color: #c8b4fc;
}

.sidenav-logo-text {
  color: #fff;
  font-weight: 700;
  font-size: 0.95rem;
  white-space: nowrap;
  opacity: 0;
  transform: translateX(-6px);
  transition: opacity 200ms 40ms, transform 200ms 20ms cubic-bezier(0.2,0.8,0.2,1);
}
.sidenav.expanded .sidenav-logo-text { opacity: 1; transform: translateX(0); }

/* Collapse / expand toggle */
.sidenav-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--snav-w);
  height: 36px;
  min-height: 36px;
  background: none;
  border: none;
  cursor: pointer;
  color: rgba(220,210,250,0.45);
  font-size: 16px;
  font-weight: 300;
  transition: color 150ms, background 150ms;
  flex-shrink: 0;
  padding: 0;
  margin: 4px 0;
}
.sidenav-toggle:hover {
  color: rgba(220,210,250,0.9);
  background: rgba(166,146,230,0.08);
}
.sidenav.expanded .sidenav-toggle {
  width: 100%;
  justify-content: flex-end;
  padding-right: 14px;
}
.snav-chevron {
  display: inline-block;
  line-height: 1;
  transition: transform 220ms cubic-bezier(0.4,0,0.2,1);
}
.sidenav.expanded .snav-chevron { transform: rotate(180deg); }

/* Nav item groups */
.sidenav-items {
  display: flex;
  flex-direction: column;
  flex: 1;
  padding: 6px 0;
  gap: 2px;
  overflow: hidden;
}

.sidenav-bottom {
  display: flex;
  flex-direction: column;
  padding: 6px 0 12px;
  gap: 2px;
  border-top: 1px solid rgba(166,146,230,0.10);
}

/* Nav item base */
.snav-item {
  display: flex;
  align-items: center;
  height: 42px;
  min-height: 42px;
  padding: 0;
  cursor: pointer;
  border: none;
  background: transparent;
  color: rgba(210,200,245,0.55);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.01em;
  white-space: nowrap;
  width: 100%;
  overflow: hidden;
  position: relative;
  flex-shrink: 0;
  user-select: none;
  text-decoration: none;
  transition: color 120ms, background 120ms;
}
.snav-item:hover {
  color: rgba(235,228,255,0.92);
  background: rgba(166,146,230,0.10);
  text-decoration: none;
}
.snav-item.active {
  color: #e8e0ff;
  background: linear-gradient(90deg, rgba(124,86,212,0.42) 0%, rgba(100,65,185,0.24) 55%, rgba(75,48,148,0.10) 100%);
}
.snav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 6px; bottom: 6px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: linear-gradient(to bottom, #c8b4fc, #7c56d4);
  box-shadow: 0 0 6px rgba(168,146,230,0.5);
}

/* Icon zone — always 56px wide so collapsed mode works */
.snav-icon {
  width: var(--snav-w);
  min-width: var(--snav-w);
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
  line-height: 1;
}

/* Label — slides in on expand */
.snav-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0;
  transform: translateX(-6px);
  transition: opacity 160ms 0ms, transform 180ms cubic-bezier(0.4,0,0.2,1);
}
.sidenav.expanded .snav-label {
  opacity: 1;
  transform: translateX(0);
  transition: opacity 200ms 40ms, transform 200ms 20ms cubic-bezier(0.2,0.8,0.2,1);
}

/* Bottom pill items (settings) */
.sidenav-bottom .snav-item {
  margin: 2px 6px;
  border-radius: 8px;
  width: calc(100% - 12px);
  border: 1px solid transparent;
  transition: color 120ms, background 120ms, border-color 120ms;
}
.sidenav-bottom .snav-item:hover {
  background: rgba(166,146,230,0.14);
  border-color: rgba(166,146,230,0.22);
}
.sidenav-bottom .snav-item.active {
  background: linear-gradient(135deg, rgba(124,86,212,0.50) 0%, rgba(80,44,160,0.34) 100%);
  border-color: rgba(168,146,230,0.50);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.08), 0 2px 8px rgba(102,68,192,0.25);
  color: #ede8ff;
}
.sidenav-bottom .snav-item.active::before { display: none; }
.sidenav:not(.expanded) .sidenav-bottom .snav-item {
  margin: 2px 0; width: 100%; border-radius: 0; border-color: transparent;
}

/* ══════════════════════════════════════════════════════
   TOPBAR
   ══════════════════════════════════════════════════════ */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 52px;
  min-height: 52px;
  padding: 0 20px;
  flex-shrink: 0;
  background: linear-gradient(90deg, #1a0848 0%, #200d54 40%, #1e0c50 70%, #160638 100%);
  border-bottom: 1px solid rgba(166,146,230,0.18);
  box-shadow: 0 1px 12px rgba(0,0,0,0.28);
  z-index: 100;
}

.topbar-left, .topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar-app-name {
  color: rgba(210,200,245,0.65);
  font-size: 13px;
  font-weight: 500;
}

/* User button */
.topbar-user-btn {
  height: 32px;
  padding: 0 14px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 600;
  color: #ede8ff;
  background: linear-gradient(135deg, #7c56d4 0%, #5535a8 100%);
  border: 1px solid rgba(168,146,230,0.40);
  box-shadow: 0 1px 4px rgba(0,0,0,0.25), inset 0 1px 0 rgba(255,255,255,0.08);
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background 150ms, border-color 150ms, box-shadow 150ms;
  text-decoration: none;
}
.topbar-user-btn::before { content: '👤'; font-size: 12px; opacity: 0.85; }
.topbar-user-btn:hover {
  background: linear-gradient(135deg, #8f6be0 0%, #6644c0 100%);
  border-color: rgba(168,146,230,0.60);
  box-shadow: 0 2px 8px rgba(102,68,192,0.40);
  color: #fff;
  text-decoration: none;
}

/* Sign-out button */
.topbar-signout-btn {
  height: 32px;
  padding: 0 14px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 600;
  color: #ffd5d0;
  background: linear-gradient(135deg, rgba(180,48,32,0.55) 0%, rgba(140,28,18,0.65) 100%);
  border: 1px solid rgba(240,100,80,0.35);
  box-shadow: 0 1px 4px rgba(0,0,0,0.25);
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background 150ms, border-color 150ms, box-shadow 150ms;
  text-decoration: none;
}
.topbar-signout-btn::before { content: '↪'; font-size: 13px; opacity: 0.85; }
.topbar-signout-btn:hover {
  background: linear-gradient(135deg, rgba(210,58,40,0.70) 0%, rgba(165,35,22,0.80) 100%);
  border-color: rgba(240,100,80,0.55);
  box-shadow: 0 2px 8px rgba(200,50,30,0.35);
  color: #fff0ee;
  text-decoration: none;
}

/* ══════════════════════════════════════════════════════
   MAIN CONTENT CONTAINER
   ══════════════════════════════════════════════════════ */
.container {
  flex: 1;
  overflow-y: auto;
  padding: 28px 28px 60px;
  scrollbar-width: thin;
  scrollbar-color: rgba(102,68,192,0.18) transparent;
}
.container::-webkit-scrollbar { width: 6px; }
.container::-webkit-scrollbar-thumb { background: rgba(102,68,192,0.18); border-radius: 3px; }
.container::-webkit-scrollbar-thumb:hover { background: rgba(102,68,192,0.35); }

/* Unauthenticated variant */
.container-auth { max-width: 960px; margin: 0 auto; }

.container-inner { }

/* ── Typography ─────────────────────────────────────── */
h1 { margin: 0 0 6px; font-size: 1.5rem; font-weight: 700; letter-spacing: -0.02em; }
h2 { margin: 0 0 14px; font-size: 1.1rem; font-weight: 600; }
h3 { margin: 0 0 8px; font-size: 0.95rem; font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }

/* ══════════════════════════════════════════════════════
   CARDS
   ══════════════════════════════════════════════════════ */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 22px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}
.card.narrow { max-width: 560px; }

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 760px) { .grid-2 { grid-template-columns: 1fr; } }

/* ── Auth card (no sidebar) ─────────────────────────── */
.auth-card {
  max-width: 420px;
  margin: 60px auto;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 32px;
  box-shadow: var(--shadow-md);
}
.divider { text-align: center; margin: 18px 0; position: relative; color: var(--muted); }
.divider::before { content: ""; position: absolute; top: 50%; left: 0; right: 0; height: 1px; background: var(--border); }
.divider span { background: var(--card); padding: 0 12px; position: relative; }

/* ══════════════════════════════════════════════════════
   FORMS
   ══════════════════════════════════════════════════════ */
.stack { display: flex; flex-direction: column; gap: 6px; }
.stack > label { font-weight: 600; font-size: 0.875rem; margin-top: 10px; color: var(--ink); }
.stack label.checkbox { font-weight: 400; display: flex; align-items: center; gap: 8px; margin-top: 6px; }

input[type="text"],
input[type="email"],
input[type="number"],
select,
textarea {
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  font-size: 0.93rem;
  font-family: inherit;
  width: 100%;
  background: var(--bg);
  color: var(--ink);
  transition: border-color 150ms, box-shadow 150ms, background 150ms;
  -webkit-appearance: none;
  appearance: none;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(102,68,192,0.12);
  background: #fff;
}
input:disabled, select:disabled { background: #eef0f5; color: var(--muted); cursor: not-allowed; }

fieldset.tools-fieldset {
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 12px 16px;
  margin-top: 10px;
  background: #fafafa;
}
fieldset.tools-fieldset legend { font-weight: 600; font-size: 0.875rem; padding: 0 6px; color: var(--ink); }
label.check { display: flex; align-items: center; gap: 8px; font-size: 0.9rem; margin: 4px 0; cursor: pointer; }

/* ══════════════════════════════════════════════════════
   BUTTONS
   ══════════════════════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--ink);
  border-radius: var(--r-sm);
  font-size: 0.9rem;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: background 150ms, border-color 150ms, box-shadow 150ms, color 150ms;
  text-decoration: none;
  white-space: nowrap;
  line-height: 1.4;
}
.btn:hover { background: #f5f5fb; border-color: var(--border-strong); text-decoration: none; }

/* Primary — purple gradient */
.btn-primary {
  background: linear-gradient(135deg, #7c56d4 0%, #5535a8 100%);
  border-color: rgba(168,146,230,0.35);
  color: #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.15), inset 0 1px 0 rgba(255,255,255,0.10);
  margin-top: 6px;
}
.btn-primary:hover {
  background: linear-gradient(135deg, #8f6be0 0%, #6644c0 100%);
  border-color: rgba(168,146,230,0.55);
  box-shadow: 0 2px 8px rgba(102,68,192,0.35);
  color: #fff;
  text-decoration: none;
}
.btn-primary:active {
  background: linear-gradient(135deg, #6644c0 0%, #4a2d96 100%);
  box-shadow: none;
}

.btn-small { padding: 5px 10px; font-size: 0.82rem; }

.btn-danger { color: var(--danger); border-color: #f0c5c5; }
.btn-danger:hover { background: var(--danger-bg); border-color: #e8a0a0; }

/* ══════════════════════════════════════════════════════
   FLASH MESSAGES
   ══════════════════════════════════════════════════════ */
.flashes { margin-bottom: 20px; display: flex; flex-direction: column; gap: 8px; }
.flash {
  padding: 10px 14px;
  border-radius: var(--r-sm);
  font-size: 0.9rem;
  border: 1px solid;
  word-break: break-word;
}
.flash-success { background: var(--ok-bg);    border-color: #bfe7cf; color: var(--ok); }
.flash-error   { background: var(--danger-bg); border-color: #f3c4c4; color: var(--danger); }
.flash-info    { background: #eeecff;           border-color: #cdc9f5; color: #4535a8; }

/* ══════════════════════════════════════════════════════
   TABLES
   ══════════════════════════════════════════════════════ */
.table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.table th, .table td {
  text-align: left;
  padding: 10px 8px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.table th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom-color: var(--border-strong);
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover td { background: #f8f7ff; }
.row-actions { white-space: nowrap; display: flex; gap: 6px; }

/* ── Badges ─────────────────────────────────────────── */
.role { font-size: 0.74rem; padding: 2px 9px; border-radius: 999px; text-transform: capitalize; font-weight: 600; }
.role-admin  { background: #ede7ff; color: #5b3bc4; }
.role-member { background: #eef1f6; color: #4a5263; }

/* ── KV list ─────────────────────────────────────────── */
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 18px; margin: 0; }
.kv dt { color: var(--muted); font-size: 0.875rem; }
.kv dd { margin: 0; }

/* ── Tool list ───────────────────────────────────────── */
.tool-list { list-style: none; padding: 0; margin: 0; }
.tool-list li { padding: 10px 0; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 2px; }
.tool-list li:last-child { border-bottom: none; }

.empty {
  background: var(--card);
  border: 2px dashed var(--border);
  border-radius: var(--r);
  padding: 36px;
  text-align: center;
  color: var(--muted);
}

/* ══════════════════════════════════════════════════════
   DASHBOARD TOOL GRID
   ══════════════════════════════════════════════════════ */
.tool-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.tool-launch {
  display: block;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 22px;
  color: var(--ink);
  transition: border-color 180ms, box-shadow 180ms, transform 180ms;
  text-decoration: none;
  box-shadow: var(--shadow-sm);
}
.tool-launch:hover {
  text-decoration: none;
  border-color: var(--brand);
  box-shadow: 0 4px 16px rgba(102,68,192,0.14);
  transform: translateY(-1px);
}
.tool-launch h2 { margin: 0 0 6px; font-size: 1.02rem; color: var(--brand); }
.tool-launch .open-link { color: var(--brand); font-size: 0.88rem; font-weight: 600; display: inline-block; margin-top: 10px; }

/* ══════════════════════════════════════════════════════
   JOB ACCORDION  (within project.html)
   ══════════════════════════════════════════════════════ */
.job-accordion { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }

.job-item {
  border: 1px solid var(--border);
  border-radius: var(--r);
  background: var(--card);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 180ms;
}
.job-item:hover { box-shadow: 0 3px 12px rgba(102,68,192,0.09); }
.job-item.open  { border-color: rgba(102,68,192,0.30); box-shadow: 0 3px 16px rgba(102,68,192,0.12); }

.job-item-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  cursor: pointer;
  user-select: none;
  transition: background 150ms;
}
.job-item-header:hover { background: #f8f7ff; }
.job-item.open .job-item-header { background: #f5f2ff; }

.job-item-title {
  font-weight: 600;
  font-size: 0.95rem;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.job-item-meta { font-size: 0.82rem; color: var(--muted); white-space: nowrap; }

.job-item-open-btn {
  font-size: 0.82rem;
  color: var(--brand);
  font-weight: 500;
  white-space: nowrap;
  text-decoration: none;
  padding: 4px 10px;
  border: 1px solid rgba(102,68,192,0.25);
  border-radius: var(--r-xs);
  background: rgba(102,68,192,0.06);
  transition: background 150ms, border-color 150ms;
}
.job-item-open-btn:hover {
  background: rgba(102,68,192,0.12);
  border-color: rgba(102,68,192,0.4);
  text-decoration: none;
}

.job-item-chevron {
  color: var(--muted);
  font-size: 11px;
  transition: transform 220ms cubic-bezier(0.4,0,0.2,1);
  flex-shrink: 0;
}
.job-item.open .job-item-chevron { transform: rotate(90deg); }

.job-item-body {
  display: none;
  padding: 4px 18px 16px;
  border-top: 1px solid var(--border);
  background: #faf9ff;
}
.job-item.open .job-item-body { display: block; }

.job-artifact-list { margin-top: 10px; }
.job-artifact-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.88rem;
}
.job-artifact-row:last-child { border-bottom: none; }
.job-artifact-type { color: var(--muted); font-size: 0.78rem; flex-shrink: 0; }
.job-artifact-date { color: var(--muted); font-size: 0.78rem; white-space: nowrap; }
.job-artifact-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ══════════════════════════════════════════════════════
   DOCUMENT CHIP SELECTOR
   ══════════════════════════════════════════════════════ */
.chip-select-wrap {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chip-actions { display: flex; gap: 8px; }
.chip-actions .btn { padding: 5px 12px; font-size: 0.82rem; margin-top: 0; }

.chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-height: 260px;
  overflow-y: auto;
  padding: 6px 2px;
  scrollbar-width: thin;
  scrollbar-color: rgba(102,68,192,0.25) transparent;
}
.chip-group::-webkit-scrollbar { width: 5px; }
.chip-group::-webkit-scrollbar-thumb { background: rgba(102,68,192,0.25); border-radius: 3px; }

.doc-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 10px;
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  background: #fff;
  color: var(--muted);
  font-size: 0.83rem;
  font-family: inherit;
  cursor: pointer;
  transition: border-color 150ms, background 150ms, color 150ms, box-shadow 150ms;
  user-select: none;
  white-space: nowrap;
  flex-shrink: 0;
  text-align: left;
}
.doc-chip:hover {
  border-color: var(--brand);
  color: var(--brand);
  background: #f5f3ff;
}
.doc-chip.selected {
  border-color: var(--brand);
  background: linear-gradient(135deg, rgba(124,86,212,0.12), rgba(85,53,168,0.07));
  color: var(--brand);
  font-weight: 500;
  box-shadow: 0 0 0 1px rgba(102,68,192,0.22);
}
.doc-chip.selected .chip-check { display: inline; }
.chip-check { display: none; font-size: 0.78em; flex-shrink: 0; margin-top: 1px; }
.doc-chip.unprocessed { opacity: 0.65; }
.doc-chip.unprocessed::after { content: ' ⚠'; font-size: 0.8em; opacity: 0.8; }

/* ── Chip search bar ── */
.chip-search-wrap {
  position: relative;
  margin-bottom: 8px;
}
.chip-search-wrap::before {
  content: '⌕';
  position: absolute;
  left: 8px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 13px;
  color: var(--muted);
  pointer-events: none;
  line-height: 1;
}
.chip-search {
  width: 100%;
  padding: 6px 10px 6px 26px;
  font-size: 0.82rem;
  border: 1px solid var(--border);
  border-radius: var(--r-xs);
  background: var(--bg);
  color: var(--ink);
  font-family: inherit;
  transition: border-color 150ms, box-shadow 150ms, background 150ms;
}
.chip-search:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 2px rgba(102,68,192,0.12);
  background: #fff;
}

/* ══════════════════════════════════════════════════════
   SCROLLABLE CONTEXT SECTION
   ══════════════════════════════════════════════════════ */
.context-scroll {
  max-height: 260px;
  overflow-y: auto;
  padding-right: 4px;
  scrollbar-width: thin;
  scrollbar-color: rgba(102,68,192,0.2) transparent;
}
.context-scroll::-webkit-scrollbar { width: 5px; }
.context-scroll::-webkit-scrollbar-thumb { background: rgba(102,68,192,0.2); border-radius: 3px; }

/* ══════════════════════════════════════════════════════
   FULL-HEIGHT CHAT LAYOUT
   Uses CSS :has() to push the flex chain down from the
   container whenever a .chat-layout wrapper is present.
   ══════════════════════════════════════════════════════ */
.container:has(.chat-layout) {
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding-bottom: 20px;        /* breathing room below the input */
}
.container:has(.chat-layout) .container-inner {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.chat-layout {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.chat-layout .page-head  { flex-shrink: 0; }
.chat-layout .tool-card  {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  margin-bottom: 0;
}
.chat-layout .chat       { flex: 1; min-height: 0; height: auto; }
.chat-layout .chat-form  { flex-shrink: 0; }

/* ══════════════════════════════════════════════════════
   CHAT
   ══════════════════════════════════════════════════════ */
.tool-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--r); padding: 22px; margin-bottom: 20px; box-shadow: var(--shadow-sm); }

.chat {
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  height: 520px;               /* fallback when not in full-height layout */
  overflow-y: auto;
  padding: 16px;
  margin-bottom: 10px;
  background: #f8f8fc;
  display: flex;
  flex-direction: column;
  gap: 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(102,68,192,0.2) transparent;
}
.chat::-webkit-scrollbar { width: 5px; }
.chat::-webkit-scrollbar-thumb { background: rgba(102,68,192,0.2); border-radius: 3px; }

/* ── User message — right-aligned bubble ── */
.from-user {
  flex-shrink: 0;
  align-self: flex-end;
  background: linear-gradient(135deg, #7c56d4 0%, #5535a8 100%);
  color: #fff;
  padding: 9px 14px;
  border-radius: 14px;
  border-bottom-right-radius: 3px;
  max-width: 72%;
  font-size: 0.9rem;
  line-height: 1.55;
  box-shadow: 0 1px 4px rgba(0,0,0,0.15);
  margin-bottom: 14px;
  word-break: break-word;
}
.from-user > strong.small {
  font-size: 0.8rem;
  font-weight: 600;
  color: rgba(255,255,255,0.75);
  margin-right: 3px;
}

/* ── Bot message — flat, full-width, markdown prose ── */
.from-bot {
  flex-shrink: 0;
  align-self: stretch;
  max-width: 100%;
  font-size: 0.9rem;
  line-height: 1.55;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
  color: var(--ink);
  overflow-x: auto;           /* horizontal scroll for wide tables */
}
.from-bot:last-child          { border-bottom: none; padding-bottom: 0; }
.from-bot > strong.small {
  display: block;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}

.chat-form { display: flex; gap: 8px; margin-top: 4px; }
.chat-form input { flex: 1; }

/* ══════════════════════════════════════════════════════
   MARKDOWN CONTENT
   ══════════════════════════════════════════════════════ */
.md-content { line-height: 1.72; overflow-x: auto; min-width: 0; }
.md-content p { margin: 0.65em 0; }
.md-content p:first-child { margin-top: 0; }
.md-content p:last-child  { margin-bottom: 0; }
.md-content h1, .md-content h2, .md-content h3, .md-content h4 {
  font-weight: 600;
  margin: 1.1em 0 0.4em;
  letter-spacing: -0.01em;
}
.md-content h1 { font-size: 1.2rem; }
.md-content h2 { font-size: 1.05rem; }
.md-content h3 { font-size: 0.95rem; }
.md-content h4 { font-size: 0.9rem; }
.md-content ul, .md-content ol { padding-left: 1.5em; margin: 0.55em 0; }
.md-content li { margin: 0.3em 0; }
.md-content code {
  background: rgba(102,68,192,0.09);
  color: #4a2d96;
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 0.875em;
  font-family: 'SFMono-Regular', Consolas, 'Cascadia Code', monospace;
}
.md-content pre {
  background: #f5f3ff;
  border: 1px solid #e0d8ff;
  border-radius: var(--r-sm);
  padding: 14px 16px;
  overflow-x: auto;
  margin: 0.9em 0;
}
.md-content pre code { background: none; color: #3a1f8a; padding: 0; font-size: 0.88em; }
.md-content blockquote {
  border-left: 3px solid rgba(102,68,192,0.4);
  padding-left: 14px;
  color: var(--muted);
  margin: 0.8em 0;
  font-style: italic;
}
.md-content strong { font-weight: 600; }
.md-content em { font-style: italic; }
.md-content a { color: var(--brand); }
.md-content hr { border: none; border-top: 1px solid var(--border); margin: 1.2em 0; }
.md-content table { display: block; overflow-x: auto; width: max-content; max-width: 100%; border-collapse: collapse; margin: 0.9em 0; font-size: 0.9rem; }
.md-content table th, .md-content table td { text-align: left; padding: 8px 10px; border: 1px solid var(--border); }
.md-content table th { background: #f5f3ff; font-weight: 600; color: var(--ink); }
.md-content table tr:nth-child(even) td { background: #faf9ff; }

/* ══════════════════════════════════════════════════════
   CODE BLOCK (artifact.html)
   ══════════════════════════════════════════════════════ */
.code-block {
  background: #f5f3ff;
  border: 1px solid #e0d8ff;
  border-radius: var(--r-sm);
  padding: 18px;
  font-size: 0.86rem;
  overflow-x: auto;
  line-height: 1.65;
  font-family: 'SFMono-Regular', Consolas, monospace;
  color: #3a1f8a;
}

/* ══════════════════════════════════════════════════════
   RAG CONTEXT CARDS  (rag.html + inline in chat.html)
   ══════════════════════════════════════════════════════ */
.rag-context-cards {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}
.rag-ctx-card {
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  overflow: hidden;
}
.rag-ctx-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 12px;
  background: #f5f3ff;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.rag-ctx-file {
  font-weight: 600;
  font-size: 0.83rem;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--ink);
}
.rag-ctx-chunk {
  font-size: 0.75rem;
  color: var(--muted);
  white-space: nowrap;
}
.rag-ctx-score {
  font-size: 0.78rem;
  color: var(--brand);
  font-weight: 600;
  white-space: nowrap;
}
.rag-ctx-text {
  padding: 10px 14px;
  font-size: 0.82rem;
  line-height: 1.72;
  color: var(--muted);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 180px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(102,68,192,0.2) transparent;
}
.rag-ctx-text::-webkit-scrollbar { width: 4px; }
.rag-ctx-text::-webkit-scrollbar-thumb { background: rgba(102,68,192,0.2); border-radius: 2px; }

/* Inline context disclosure used in chat turns */
.rag-ctx-inline {
  flex-shrink: 0;
  margin: -4px 0 12px;
}
.rag-ctx-toggle {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--r-xs);
  padding: 4px 10px;
  font-family: inherit;
  font-size: 0.79rem;
  color: var(--muted);
  cursor: pointer;
  transition: color 150ms, border-color 150ms, background 150ms;
}
.rag-ctx-toggle:hover {
  color: var(--brand);
  border-color: rgba(102,68,192,0.35);
  background: rgba(102,68,192,0.05);
}
.rag-ctx-toggle-arrow {
  display: inline-block;
  font-size: 0.7em;
  transition: transform 200ms;
}
.rag-ctx-inline.open .rag-ctx-toggle-arrow { transform: rotate(90deg); }
.rag-ctx-panel {
  display: none;
  margin-top: 8px;
}
.rag-ctx-inline.open .rag-ctx-panel { display: block; }
.score-bar {
  background: linear-gradient(90deg, var(--brand-light), var(--brand));
  border-radius: 2px;
  vertical-align: middle;
  margin-right: 6px;
}

/* ══════════════════════════════════════════════════════
   MISC
   ══════════════════════════════════════════════════════ */
code.small { font-size: 0.82rem; background: rgba(102,68,192,0.08); color: #4a2d96; padding: 1px 5px; border-radius: 3px; font-family: monospace; }

details.card { cursor: default; }
details.card summary { cursor: pointer; font-weight: 600; padding: 2px 0; }
details.card summary::-webkit-details-marker { color: var(--muted); }

/* Google sign-in button width */
.btn-google { width: 100%; }

/* ══════════════════════════════════════════════════════
   TOAST NOTIFICATIONS
   ══════════════════════════════════════════════════════ */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  min-width: 280px;
  max-width: 380px;
  padding: 14px 16px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--r);
  box-shadow: 0 6px 24px rgba(0,0,0,0.12), 0 1px 4px rgba(0,0,0,0.06);
  pointer-events: all;
  cursor: pointer;
  /* Slide up in */
  animation: toast-in 280ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
  position: relative;
  overflow: hidden;
}
.toast.toast-out {
  animation: toast-out 250ms cubic-bezier(0.4, 0, 1, 1) forwards;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(16px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0)    scale(1); }
}
@keyframes toast-out {
  from { opacity: 1; transform: translateY(0) scale(1); max-height: 120px; }
  to   { opacity: 0; transform: translateY(8px) scale(0.95); max-height: 0; padding: 0; margin: 0; }
}

/* Left accent bar */
.toast::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  border-radius: var(--r) 0 0 var(--r);
}
.toast-success::before { background: var(--ok); }
.toast-error::before   { background: var(--danger); }
.toast-info::before    { background: var(--brand); }

.toast-icon {
  font-size: 16px;
  flex-shrink: 0;
  margin-top: 1px;
  line-height: 1;
}
.toast-success .toast-icon { color: var(--ok); }
.toast-error   .toast-icon { color: var(--danger); }
.toast-info    .toast-icon { color: var(--brand); }

.toast-body { flex: 1; min-width: 0; }
.toast-msg  { font-size: 0.88rem; line-height: 1.45; color: var(--ink); word-break: break-word; }

.toast-progress {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 3px;
  transform-origin: left;
  animation: toast-progress linear forwards;
}
.toast-success .toast-progress { background: var(--ok); }
.toast-error   .toast-progress { background: var(--danger); }
.toast-info    .toast-progress { background: var(--brand); }

@keyframes toast-progress {
  from { transform: scaleX(1); }
  to   { transform: scaleX(0); }
}

/* ══════════════════════════════════════════════════════
   EMPTY STATE ILLUSTRATIONS
   ══════════════════════════════════════════════════════ */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
  text-align: center;
  gap: 12px;
}
.empty-state-svg {
  width: 96px;
  height: 80px;
  opacity: 0.9;
  margin-bottom: 4px;
}
.empty-state-title {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--ink);
}
.empty-state-body {
  font-size: 0.875rem;
  color: var(--muted);
  max-width: 300px;
  line-height: 1.55;
}
.empty-state .btn { margin-top: 4px; }

/* ══════════════════════════════════════════════════════
   TOPBAR BREADCRUMB
   ══════════════════════════════════════════════════════ */
.topbar-breadcrumb {
  display: flex;
  align-items: center;
  gap: 0;
  font-size: 13px;
  color: rgba(210,200,245,0.65);
  white-space: nowrap;
  overflow: hidden;
}
.topbar-breadcrumb a {
  color: rgba(210,200,245,0.72);
  text-decoration: none;
  transition: color 150ms;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.topbar-breadcrumb a:hover { color: #ede8ff; text-decoration: none; }
.topbar-breadcrumb .crumb-sep {
  margin: 0 7px;
  opacity: 0.35;
  flex-shrink: 0;
  font-size: 11px;
}
.topbar-breadcrumb .crumb-current {
  color: rgba(235,228,255,0.90);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ══════════════════════════════════════════════════════
   SETTINGS TABS
   ══════════════════════════════════════════════════════ */
.settings-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
}
.settings-tab-btn {
  padding: 10px 18px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  transition: color 150ms, border-color 150ms;
  white-space: nowrap;
  margin-bottom: -1px;
}
.settings-tab-btn:hover { color: var(--brand); }
.settings-tab-btn.active {
  color: var(--brand);
  border-bottom-color: var(--brand);
  font-weight: 600;
}

.settings-panel { display: none; }
.settings-panel.active { display: block; }

/* ══════════════════════════════════════════════════════
   SIDENAV PNG LOGO  (replaces text-based rules)
   ══════════════════════════════════════════════════════ */
.sidenav-logo {
  display: flex;
  align-items: center;
  height: 56px;
  min-height: 56px;
  padding: 0 14px;
  gap: 10px;
  border-bottom: 1px solid rgba(166,146,230,0.12);
  flex-shrink: 0;
  overflow: hidden;
}
/* Collapsed: square icon only */
.sidenav-logo .logo-mark {
  display: block;
  height: 28px;
  width: 28px;
  object-fit: contain;
  object-position: center;
  flex-shrink: 0;
}
/* Expanded: wide logo, hidden by default */
.sidenav-logo .logo-full {
  display: none;
  height: 22px;
  width: auto;
  max-width: 152px;
  object-fit: contain;
  object-position: left center;
}
.sidenav.expanded .sidenav-logo .logo-mark { display: none; }
.sidenav.expanded .sidenav-logo .logo-full  { display: block; }

/* PNGs designed for dark backgrounds — show as-is, no filter needed */
.sidenav-logo img { opacity: 0.92; }

/* ══════════════════════════════════════════════════════
   FRESHNESS DOT
   ══════════════════════════════════════════════════════ */
.freshness-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--border-strong);      /* default = unknown/stale */
  box-shadow: 0 0 0 2px rgba(255,255,255,0.8);
  transition: background 300ms;
}
.freshness-dot.fresh  { background: var(--ok);      box-shadow: 0 0 0 2px rgba(27,127,75,0.15); }
.freshness-dot.recent { background: #e0a020;         box-shadow: 0 0 0 2px rgba(224,160,32,0.15); }
.freshness-dot.stale  { background: var(--border-strong); }

/* ══════════════════════════════════════════════════════
   PROJECT CARD GRID  (index.html)
   ══════════════════════════════════════════════════════ */
.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 18px;
}
.project-grid.masonry {
  display: block;
  columns: 3 300px;
  column-gap: 18px;
}
.project-grid.masonry > *:not(script) {
  break-inside: avoid;
  display: inline-block; /* prevents column splits in all browsers */
  width: 100%;
  margin-bottom: 18px;
  vertical-align: top;
}

.project-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  text-decoration: none;
  color: var(--ink);
  transition: border-color 180ms, box-shadow 180ms, transform 180ms;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
}
.project-card::before {
  /* subtle top-edge colour bar */
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--brand-light), var(--brand));
  opacity: 0.55;
  border-radius: var(--r) var(--r) 0 0;
  transition: opacity 180ms;
}
.project-card:hover {
  border-color: rgba(102,68,192,0.35);
  box-shadow: 0 4px 18px rgba(102,68,192,0.13);
  transform: translateY(-2px);
  text-decoration: none;
  color: var(--ink);
}
.project-card:hover::before { opacity: 1; }

.project-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}
.project-card-name {
  font-weight: 700;
  font-size: 1.02rem;
  line-height: 1.3;
  flex: 1;
  min-width: 0;
}
.project-card-meta {
  display: flex;
  gap: 12px;
  font-size: 0.8rem;
  color: var(--muted);
}
.project-card-meta span { display: flex; align-items: center; gap: 4px; }

.project-card-jobs {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.project-job-chip {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 0.82rem;
  color: var(--muted);
  padding: 4px 0;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.project-job-chip:last-child { border-bottom: none; }
.project-job-chip .tool-icon { font-size: 11px; flex-shrink: 0; }

.project-card-footer {
  margin-top: auto;
  font-size: 0.82rem;
  color: var(--brand);
  font-weight: 600;
}

/* Decorative faint radial glow in card bottom-right */
.project-card::after {
  content: '';
  position: absolute;
  bottom: -30px; right: -30px;
  width: 100px; height: 100px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(102,68,192,0.07) 0%, transparent 70%);
  pointer-events: none;
}

/* ══════════════════════════════════════════════════════
   JOB GRID  (project.html — mirrors project-grid)
   ══════════════════════════════════════════════════════ */
.job-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 18px;
}
.job-grid.masonry {
  display: block;
  columns: 3 260px;
  column-gap: 18px;
}
.job-grid.masonry > *:not(script) {
  break-inside: avoid;
  display: inline-block;
  width: 100%;
  margin-bottom: 18px;
  vertical-align: top;
}

/* Keep old scroll classes for any legacy markup */
.job-scroll {
  display: flex;
  gap: 16px;
  overflow-x: auto;
  padding: 4px 2px 18px;
  scrollbar-width: thin;
  scrollbar-color: rgba(102,68,192,0.20) transparent;
  -webkit-overflow-scrolling: touch;
}
.job-scroll::-webkit-scrollbar { height: 5px; }
.job-scroll::-webkit-scrollbar-thumb { background: rgba(102,68,192,0.20); border-radius: 3px; }

.job-scroll-card {
  min-width: 250px;
  max-width: 290px;
  flex-shrink: 0;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: relative;
  box-shadow: var(--shadow-sm);
  transition: border-color 180ms, box-shadow 180ms, transform 180ms;
  text-decoration: none;
  color: var(--ink);
}
.job-scroll-card:hover {
  border-color: rgba(102,68,192,0.35);
  box-shadow: 0 4px 16px rgba(102,68,192,0.12);
  transform: translateY(-2px);
  text-decoration: none;
}
.job-scroll-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}
.job-scroll-card-name {
  font-weight: 600;
  font-size: 0.92rem;
  line-height: 1.3;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.job-scroll-card-stats {
  display: flex;
  gap: 8px;
  font-size: 0.78rem;
  color: var(--muted);
}
.job-scroll-card-artifacts {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  min-height: 24px;
}
.artifact-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  background: #f0eeff;
  border: 1px solid rgba(102,68,192,0.18);
  border-radius: 999px;
  font-size: 0.74rem;
  color: var(--brand);
  font-weight: 500;
  white-space: nowrap;
}
.artifact-badge .tool-icon { font-size: 10px; }

.job-scroll-card-footer {
  margin-top: auto;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  font-size: 0.8rem;
  color: var(--brand);
  font-weight: 600;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.job-scroll-date { font-size: 0.74rem; color: var(--muted); font-weight: 400; }

/* ── New job card (last in scroll) ── */
.job-scroll-new {
  min-width: 180px;
  max-width: 200px;
  flex-shrink: 0;
  border: 2px dashed rgba(102,68,192,0.25);
  border-radius: var(--r);
  background: transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 24px 16px;
  cursor: pointer;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 500;
  transition: border-color 150ms, color 150ms, background 150ms;
  text-decoration: none;
}
.job-scroll-new:hover {
  border-color: rgba(102,68,192,0.55);
  color: var(--brand);
  background: rgba(102,68,192,0.04);
  text-decoration: none;
}
.job-scroll-new-icon { font-size: 22px; opacity: 0.6; }

/* ══════════════════════════════════════════════════════
   RIGHT DRAWER  (context & members panel)
   ══════════════════════════════════════════════════════ */
.right-drawer {
  position: fixed;
  top: 52px;   /* below topbar */
  right: 0;
  bottom: 0;
  width: 0;
  z-index: 500;
  display: flex;
  align-items: stretch;
  pointer-events: none;
  transition: width 280ms cubic-bezier(0.4,0,0.2,1);
}

.right-drawer-tab {
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateX(-100%) translateY(-50%);
  background: linear-gradient(180deg, #7c56d4 0%, #5535a8 100%);
  border: none;
  border-radius: 8px 0 0 8px;
  color: #fff;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  writing-mode: vertical-rl;
  text-orientation: mixed;
  direction: rtl;
  padding: 14px 9px;
  cursor: pointer;
  pointer-events: all;
  box-shadow: -3px 0 12px rgba(0,0,0,0.15);
  transition: background 150ms, box-shadow 150ms;
  white-space: nowrap;
  letter-spacing: 0.03em;
}
.right-drawer-tab:hover {
  background: linear-gradient(180deg, #8f6be0 0%, #6644c0 100%);
  box-shadow: -4px 0 16px rgba(102,68,192,0.35);
}

.right-drawer-panel {
  width: 320px;
  background: var(--card);
  border-left: 1px solid var(--border);
  box-shadow: -6px 0 24px rgba(0,0,0,0.12);
  overflow-y: auto;
  pointer-events: all;
  transform: translateX(100%);
  transition: transform 280ms cubic-bezier(0.4,0,0.2,1);
  display: flex;
  flex-direction: column;
  scrollbar-width: thin;
  scrollbar-color: rgba(102,68,192,0.15) transparent;
}
.right-drawer-panel::-webkit-scrollbar { width: 4px; }
.right-drawer-panel::-webkit-scrollbar-thumb { background: rgba(102,68,192,0.15); border-radius: 2px; }

.right-drawer.open { width: 320px; pointer-events: all; }
.right-drawer.open .right-drawer-panel { transform: translateX(0); }
.right-drawer.open .right-drawer-tab { border-radius: 8px 0 0 8px; }

.right-drawer-header {
  padding: 16px 18px 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  background: var(--card);
  z-index: 1;
}
.right-drawer-header h3 { margin: 0; font-size: 0.92rem; }
.right-drawer-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
  padding: 2px 6px;
  border-radius: 4px;
  transition: color 150ms, background 150ms;
}
.right-drawer-close:hover { color: var(--ink); background: var(--bg); }

.right-drawer-section {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.right-drawer-section:last-child { border-bottom: none; }
.right-drawer-section h4 {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 0 0 10px;
}

/* ══════════════════════════════════════════════════════
   TOOL LAUNCHER  (job.html)
   ══════════════════════════════════════════════════════ */
.tool-launcher {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.tool-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tool-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 16px;
  border: 1.5px solid var(--border);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 160ms;
  user-select: none;
}
.tool-pill:hover {
  border-color: var(--brand);
  color: var(--brand);
  background: #f5f3ff;
}
.tool-pill.active {
  border-color: var(--brand);
  background: linear-gradient(135deg, rgba(124,86,212,0.13), rgba(85,53,168,0.07));
  color: var(--brand);
  font-weight: 600;
  box-shadow: 0 0 0 1px rgba(102,68,192,0.22);
}
.tool-pill-icon { font-size: 15px; line-height: 1; }

.launcher-input-wrap {
  display: flex;
  gap: 10px;
  align-items: center;
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px 10px 16px;
  transition: border-color 180ms, box-shadow 180ms;
  box-shadow: var(--shadow-sm);
}
.launcher-input-wrap:focus-within {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(102,68,192,0.12), var(--shadow-sm);
}
.launcher-input-wrap.tool-active {
  border-color: rgba(102,68,192,0.45);
  box-shadow: 0 0 0 3px rgba(102,68,192,0.09);
}
.launcher-input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-family: inherit;
  font-size: 0.95rem;
  color: var(--ink);
  min-width: 0;
  padding: 0;
  width: 100%;
}
.launcher-input::placeholder { color: var(--muted); }
.launcher-send {
  flex-shrink: 0;
  height: 36px;
  padding: 0 16px;
  border-radius: 8px;
  background: linear-gradient(135deg, #7c56d4 0%, #5535a8 100%);
  border: none;
  color: #fff;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 150ms, box-shadow 150ms, opacity 150ms;
  box-shadow: 0 1px 4px rgba(0,0,0,0.15);
}
.launcher-send:hover { background: linear-gradient(135deg, #8f6be0 0%, #6644c0 100%); box-shadow: 0 2px 8px rgba(102,68,192,0.35); }
.launcher-send:disabled { opacity: 0.45; cursor: not-allowed; box-shadow: none; }

.launcher-hint {
  font-size: 0.8rem;
  color: var(--muted);
  text-align: center;
}

/* ══════════════════════════════════════════════════════
   TOPBAR ORG BUTTON
   ══════════════════════════════════════════════════════ */
.topbar-org-btn {
  height: 32px;
  padding: 0 14px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 600;
  color: #ede8ff;
  background: rgba(166,146,230,0.15);
  border: 1px solid rgba(168,146,230,0.28);
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background 150ms, border-color 150ms;
  text-decoration: none;
}
.topbar-org-btn:hover {
  background: rgba(166,146,230,0.26);
  border-color: rgba(168,146,230,0.50);
  color: #fff;
  text-decoration: none;
}

/* ══════════════════════════════════════════════════════
   VIEW TOGGLE  (grid ↔ masonry switcher)
   ══════════════════════════════════════════════════════ */
.view-toggle {
  display: inline-flex;
  gap: 2px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 3px;
  flex-shrink: 0;
}
.view-toggle-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 28px;
  border: none;
  background: transparent;
  border-radius: 4px;
  cursor: pointer;
  color: var(--muted);
  transition: background 150ms, color 150ms, box-shadow 150ms;
  padding: 0;
}
.view-toggle-btn svg {
  width: 15px;
  height: 15px;
  display: block;
  flex-shrink: 0;
}
.view-toggle-btn:hover {
  background: var(--card);
  color: var(--ink);
}
.view-toggle-btn.active {
  background: var(--card);
  color: var(--brand);
  box-shadow: var(--shadow-sm);
}

/* ══════════════════════════════════════════════════════
   PURPLE SETTINGS OVERRIDES
   ══════════════════════════════════════════════════════ */
.settings-card-purple {
  background: linear-gradient(160deg, #faf8ff 0%, #f4f0ff 100%);
  border-color: rgba(102,68,192,0.18);
}

/* Tab bar — darker purple treatment */
.settings-tabs {
  background: linear-gradient(135deg, #f0ecff 0%, #ebe5ff 100%);
  border-radius: var(--r-sm) var(--r-sm) 0 0;
  border-bottom: 2px solid rgba(102,68,192,0.20);
  padding: 0 4px;
  margin: -22px -22px 24px -22px;  /* bleed to card edges */
}
.settings-tab-btn {
  color: rgba(102,68,192,0.55);
  border-bottom-width: 2px;
  margin-bottom: -2px;
  padding: 12px 20px;
}
.settings-tab-btn:hover { color: var(--brand); background: rgba(102,68,192,0.06); border-radius: var(--r-sm) var(--r-sm) 0 0; }
.settings-tab-btn.active {
  color: var(--brand);
  background: rgba(102,68,192,0.10);
  border-bottom-color: var(--brand);
  border-radius: var(--r-sm) var(--r-sm) 0 0;
}

/* Purple-tinted selects */
.settings-panel select {
  background: linear-gradient(135deg, #f8f5ff 0%, #f2eeff 100%);
  border-color: rgba(102,68,192,0.25);
  color: var(--ink);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236644c0' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
  -webkit-appearance: none;
  appearance: none;
}
.settings-panel select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(102,68,192,0.15);
  background-color: #fff;
}

.settings-panel input[type="number"] {
  background: #f8f5ff;
  border-color: rgba(102,68,192,0.22);
}
.settings-panel input[type="number"]:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(102,68,192,0.15);
  background: #fff;
}

fieldset.tools-fieldset {
  background: linear-gradient(135deg, #faf8ff 0%, #f5f1ff 100%);
  border-color: rgba(102,68,192,0.18);
}
fieldset.tools-fieldset legend { color: var(--brand); }

/* ══════════════════════════════════════════════════════
   INLINE CREATE CARDS (new project / new job in scroll)
   ══════════════════════════════════════════════════════ */

/* New project — first card in the project grid */
.project-card-new {
  background: linear-gradient(160deg, #f8f6ff 0%, #ede8ff 100%);
  border: 1.5px dashed rgba(102,68,192,0.30);
  border-radius: var(--r);
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: none;
  transition: border-color 150ms, box-shadow 150ms;
}
.project-card-new:hover {
  border-color: rgba(102,68,192,0.55);
  box-shadow: 0 2px 12px rgba(102,68,192,0.10);
}
.project-card-new h3 { margin: 0; font-size: 0.9rem; color: var(--brand); }
.project-card-new input[type="text"] {
  background: rgba(255,255,255,0.75);
  border-color: rgba(102,68,192,0.22);
  font-size: 0.9rem;
  padding: 8px 10px;
}
.project-card-new .btn-primary { margin-top: 4px; }

/* New job — first card in the horizontal job scroll */
.job-scroll-card-create {
  min-width: 240px;
  max-width: 260px;
  flex-shrink: 0;
  background: linear-gradient(160deg, #f8f6ff 0%, #ede8ff 100%);
  border: 1.5px dashed rgba(102,68,192,0.30);
  border-radius: var(--r);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color 150ms, box-shadow 150ms;
}
.job-scroll-card-create:hover {
  border-color: rgba(102,68,192,0.55);
  box-shadow: 0 2px 12px rgba(102,68,192,0.10);
}
.job-scroll-card-create h4 { margin: 0; font-size: 0.85rem; color: var(--brand); font-weight: 600; }
.job-scroll-card-create input[type="text"] {
  background: rgba(255,255,255,0.80);
  border-color: rgba(102,68,192,0.22);
  font-size: 0.85rem;
  padding: 7px 10px;
}
.job-scroll-card-create .btn-primary { margin-top: 2px; font-size: 0.85rem; padding: 7px 12px; }

/* ── Grid-based job cards (new approach) ── */
.job-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: border-color 180ms, box-shadow 180ms, transform 180ms;
  text-decoration: none;
  color: var(--ink);
  cursor: pointer;
}
.job-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--brand-light), var(--brand));
  opacity: 0.45;
  border-radius: var(--r) var(--r) 0 0;
  transition: opacity 180ms;
}
.job-card:hover {
  border-color: rgba(102,68,192,0.35);
  box-shadow: 0 4px 18px rgba(102,68,192,0.13);
  transform: translateY(-2px);
  text-decoration: none;
  color: var(--ink);
}
.job-card:hover::before { opacity: 1; }

.job-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}
.job-card-name {
  font-weight: 700;
  font-size: 0.98rem;
  line-height: 1.3;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.job-card-meta {
  display: flex;
  gap: 10px;
  font-size: 0.79rem;
  color: var(--muted);
}
.job-card-meta span { display: flex; align-items: center; gap: 4px; }
.job-card-artifacts {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  min-height: 22px;
}
.job-card-footer {
  margin-top: auto;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  font-size: 0.8rem;
  color: var(--brand);
  font-weight: 600;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.job-card-date { font-size: 0.74rem; color: var(--muted); font-weight: 400; }

/* Decorative glow */
.job-card::after {
  content: '';
  position: absolute;
  bottom: -30px; right: -30px;
  width: 90px; height: 90px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(102,68,192,0.06) 0%, transparent 70%);
  pointer-events: none;
}

/* New job card — first in grid */
.job-card-new {
  background: linear-gradient(160deg, #f8f6ff 0%, #ede8ff 100%);
  border: 1.5px dashed rgba(102,68,192,0.30);
  border-radius: var(--r);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: none;
  transition: border-color 150ms, box-shadow 150ms;
}
.job-card-new:hover {
  border-color: rgba(102,68,192,0.55);
  box-shadow: 0 2px 12px rgba(102,68,192,0.10);
}
.job-card-new h3 { margin: 0; font-size: 0.9rem; color: var(--brand); }
.job-card-new input[type="text"] {
  background: rgba(255,255,255,0.75);
  border-color: rgba(102,68,192,0.22);
  font-size: 0.9rem;
  padding: 8px 10px;
}
.job-card-new .btn-primary { margin-top: 4px; }

/* Context chips inside new-job card */
.job-card-new .chip-group {
  max-height: 180px;
  background: rgba(255,255,255,0.55);
  border-radius: var(--r-sm);
  border: 1px solid rgba(102,68,192,0.14);
  padding: 8px;
}
.job-card-new .chip-actions { margin-bottom: 6px; }
.job-card-new .chip-actions .btn {
  background: rgba(255,255,255,0.8);
  border-color: rgba(102,68,192,0.22);
  color: var(--brand);
  font-size: 0.78rem;
  padding: 4px 10px;
  margin-top: 0;
}
.job-card-new-context-label {
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: rgba(102,68,192,0.6);
  margin: 4px 0 2px;
}