:root {
  --bg: #212121;
  --sidebar: #171717;
  --panel: #2f2f2f;
  --bubble: #2f2f2f;
  --user-bubble: #303030;
  --assistant-surface: transparent;
  --border: #3a3a3a;
  --text: #ececec;
  --muted: #9b9b9b;
  --accent: #7c8cff;
  --ok: #4ade80;
  --bad: #f87171;
  --warn: #fbbf24;
  --mono: "JetBrains Mono", ui-monospace, Menlo, monospace;
  --sans: "DM Sans", system-ui, -apple-system, sans-serif;
  --content-w: 768px;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body.chat-app {
  display: flex;
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

/* Sidebar */
.sidebar {
  width: 260px;
  flex-shrink: 0;
  background: var(--sidebar);
  border-right: 1px solid #252525;
  display: flex;
  flex-direction: column;
  padding: 0.7rem 0.65rem;
  height: 100vh;
  overflow: hidden;
}
.sidebar-top { margin-bottom: 0.65rem; flex-shrink: 0; }
.brand {
  display: flex; gap: 0.55rem; align-items: center;
  margin-bottom: 0.6rem; padding: 0.15rem 0.2rem;
}
.logo {
  width: 30px; height: 30px; border-radius: 8px;
  display: grid; place-items: center;
  background: linear-gradient(145deg, #4f6ef7, #8b9cff);
  font-weight: 700; color: #fff; font-size: 0.85rem;
}
.brand-name { font-weight: 600; font-size: 0.9rem; }
.brand-sub { font-size: 0.68rem; color: var(--muted); }
.btn-new {
  width: 100%;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  border-radius: 8px;
  padding: 0.5rem 0.7rem;
  font: inherit;
  font-weight: 500;
  font-size: 0.88rem;
  cursor: pointer;
  text-align: left;
}
.btn-new:hover { background: #222; }

.sidebar-section {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  background: var(--sidebar);
  position: relative;
  z-index: 1;
}
/* Departments: capped height, scrolls inside — never bleeds into chats */
.sidebar-depts-section {
  flex: 0 1 42%;
  max-height: 42%;
  min-height: 0;
  margin-bottom: 0;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid #252525;
}
.sidebar-depts-section .sidebar-collapse-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
/* Recent chats: fills remaining space, scrolls inside */
.sidebar-runs-section {
  flex: 1 1 58%;
  min-height: 0;
  overflow: hidden;
  padding-top: 0.35rem;
}
.sidebar-runs-section > .sidebar-label {
  margin: 0.15rem 0.2rem 0.35rem;
  flex-shrink: 0;
}
.sidebar-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.35rem;
  margin: 0.1rem 0.2rem 0.35rem;
  flex-shrink: 0;
}
.sidebar-collapse-head {
  cursor: pointer;
  user-select: none;
  border-radius: 6px;
  padding: 0.2rem 0.15rem;
  margin-left: 0.05rem;
  margin-right: 0.05rem;
  flex-shrink: 0;
  z-index: 2;
  background: var(--sidebar);
}
.sidebar-collapse-head:hover {
  background: rgba(255, 255, 255, 0.04);
}
.sidebar-collapse-head:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: 1px;
}
.sidebar-label-with-chevron {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-width: 0;
}
.sidebar-chevron {
  display: inline-block;
  font-size: 0.7rem;
  color: var(--muted);
  line-height: 1;
  transition: transform 0.15s ease;
  width: 0.75rem;
  text-align: center;
}
.sidebar-section.is-collapsed .sidebar-chevron {
  transform: rotate(-90deg);
}
.sidebar-section.is-collapsed .sidebar-collapse-body {
  display: none !important;
}
.sidebar-section.is-collapsed.sidebar-depts-section {
  flex: 0 0 auto;
  max-height: none;
  padding-bottom: 0.2rem;
}
.sidebar-section.is-collapsed.sidebar-runs-section {
  flex: 0 0 auto;
}
.sidebar-label {
  font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--muted); margin: 0;
}
.btn-sidebar-icon {
  width: 24px; height: 24px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  border-radius: 6px;
  font: inherit;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
  padding: 0;
  flex-shrink: 0;
}
.btn-sidebar-icon:hover {
  color: var(--text);
  border-color: var(--accent);
  background: rgba(124, 140, 255, 0.08);
}

.sidebar-depts {
  display: flex;
  flex-direction: column;
  gap: 0.12rem;
  overflow-x: hidden;
  overflow-y: auto;
  min-height: 0;
  flex: 1 1 auto;
  padding-right: 0.15rem;
  overscroll-behavior: contain;
}
.side-dept {
  border: none;
  background: transparent;
  color: var(--text);
  text-align: left;
  padding: 0.4rem 0.45rem;
  border-radius: 8px;
  cursor: pointer;
  font: inherit;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.08rem;
  border: 1px solid transparent;
  box-sizing: border-box;
}
.side-dept:hover { background: #222; }
.side-dept.active {
  background: rgba(124, 140, 255, 0.12);
  border-color: rgba(124, 140, 255, 0.28);
}
.side-dept .t {
  font-size: 0.84rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.side-dept .m {
  font-size: 0.68rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.side-dept-row {
  display: flex;
  align-items: center;
  gap: 0.1rem;
  flex-shrink: 0;
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}
.side-dept-row .side-dept {
  flex: 1 1 auto;
  min-width: 0;
}
.side-dept-ctx,
.side-dept-del {
  flex: 0 0 24px;
  width: 24px;
  height: 28px;
  border: none;
  background: transparent;
  color: var(--muted);
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.7rem;
  padding: 0;
  display: grid;
  place-items: center;
  opacity: 0.7;
}
.side-dept-row:hover .side-dept-ctx,
.side-dept-row:hover .side-dept-del {
  opacity: 1;
}
.side-dept-ctx:hover {
  color: var(--accent);
  background: rgba(124, 140, 255, 0.1);
}
.side-dept-del:hover {
  color: var(--bad);
  background: rgba(248, 113, 113, 0.12);
}
.side-dept-empty {
  padding: 0.55rem 0.45rem;
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.35;
}
.context-tabs {
  display: flex;
  gap: 0.25rem;
  background: #1f1f1f;
  border-radius: 8px;
  padding: 0.15rem;
  border: 1px solid var(--border);
}
.context-tab {
  border: none;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 500;
  padding: 0.28rem 0.7rem;
  border-radius: 6px;
  cursor: pointer;
}
.context-tab:hover { color: var(--text); }
.context-tab.active {
  background: #2f2f2f;
  color: var(--text);
}
.sidebar-runs {
  display: flex;
  flex-direction: column;
  gap: 0.12rem;
  overflow-x: hidden;
  overflow-y: auto;
  min-height: 0;
  flex: 1 1 auto;
  padding-right: 0.15rem;
  overscroll-behavior: contain;
}
.side-run {
  border: none; background: transparent; color: var(--text);
  text-align: left; padding: 0.4rem 0.55rem; border-radius: 8px;
  cursor: pointer; font: inherit; width: 100%;
  flex-shrink: 0;
  box-sizing: border-box;
}
.side-run:hover, .side-run.active { background: #2a2a2a; }
.side-run .t {
  font-size: 0.82rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.side-run .m { font-size: 0.68rem; color: var(--muted); margin-top: 0.1rem; }

.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0);
  white-space: nowrap; border: 0;
}

.composer-dept-label {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--muted);
  max-width: 46%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.composer-dept-label.has-dept { color: var(--text); }

/* Main */
.main-col {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column;
  height: 100vh;
}
.chat-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0.7rem 1.25rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  flex-shrink: 0;
  background: rgba(33, 33, 33, 0.85);
  backdrop-filter: blur(10px);
}
.chat-header h1 { margin: 0; font-size: 0.98rem; font-weight: 600; letter-spacing: -0.01em; }
.muted { color: var(--muted); font-size: 0.8rem; margin: 0.15rem 0 0; }
.header-actions { display: flex; gap: 0.35rem; }
.btn-ghost {
  border: 1px solid var(--border); background: transparent; color: var(--muted);
  border-radius: 999px; padding: 0.3rem 0.7rem; font: inherit; font-size: 0.8rem;
  cursor: pointer;
}
.btn-ghost:hover { color: var(--text); border-color: #555; }

.view { display: none; flex: 1; min-height: 0; flex-direction: column; }
.view.active { display: flex; }

/* Messages — full-width scroll (scrollbar on far right of main pane) */
.messages {
  flex: 1;
  overflow-x: hidden;
  overflow-y: auto;
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 1.25rem 0 1.5rem;
  scroll-behavior: smooth;
  /* Thin scrollbar on the right edge of the main column */
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  scrollbar-color: #555 transparent;
}
.messages::-webkit-scrollbar {
  width: 10px;
}
.messages::-webkit-scrollbar-track {
  background: transparent;
}
.messages::-webkit-scrollbar-thumb {
  background: #4a4a4a;
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
.messages::-webkit-scrollbar-thumb:hover {
  background: #666;
  border: 2px solid transparent;
  background-clip: padding-box;
}
/* Keep chat content centered; only the scroll container is full width */
.messages > .msg,
.messages > .empty-state {
  max-width: var(--content-w);
  width: 100%;
  margin-left: auto;
  margin-right: auto;
  padding-left: 1.25rem;
  padding-right: 1.25rem;
  box-sizing: border-box;
}
.empty-state {
  text-align: center;
  padding: 3.5rem 1rem;
  color: var(--muted);
}
.empty-icon {
  width: 48px; height: 48px; margin: 0 auto 0.85rem; border-radius: 14px;
  display: grid; place-items: center;
  background: linear-gradient(145deg, #4f6ef7, #8b9cff);
  color: #fff; font-weight: 700; font-size: 1.1rem;
  box-shadow: 0 8px 24px rgba(79, 110, 247, 0.25);
}
.empty-state h2 { color: var(--text); margin: 0 0 0.4rem; font-size: 1.15rem; font-weight: 600; }
.empty-state p { max-width: 36ch; margin: 0 auto; line-height: 1.5; font-size: 0.9rem; }
.empty-context { margin-top: 0.65rem !important; max-width: 42ch !important; font-size: 0.8rem !important; }
.empty-context.ok { color: var(--ok) !important; }
.empty-context.bad { color: var(--bad) !important; }

.msg {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1.35rem;
  width: 100%;
  animation: in 0.22s cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

/* Assistant — left aligned, full column */
.msg.assistant {
  flex-direction: row;
  justify-content: flex-start;
  align-items: flex-start;
}
.msg.assistant .avatar {
  width: 28px; height: 28px; border-radius: 50%;
  flex-shrink: 0;
  display: grid; place-items: center;
  font-size: 0.7rem; font-weight: 700;
  margin-top: 0.15rem;
  background: linear-gradient(145deg, #4f6ef7, #8b9cff);
  color: #fff;
  box-shadow: 0 2px 8px rgba(79, 110, 247, 0.3);
}
.msg.assistant .body {
  flex: 1;
  min-width: 0;
  max-width: min(100%, 640px);
}
.msg.assistant .who {
  font-size: 0.72rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
  font-weight: 500;
  letter-spacing: 0.01em;
}
.msg.assistant .content {
  line-height: 1.55;
  font-size: 0.95rem;
  word-break: break-word;
  white-space: normal;
  color: var(--text);
}

/* User — right aligned bubble (ChatGPT style) */
.msg.user {
  flex-direction: row-reverse;
  justify-content: flex-start;
  align-items: flex-start;
}
.msg.user .avatar {
  display: none; /* cleaner premium look; bubble is enough */
}
.msg.user .body {
  flex: 0 1 auto;
  min-width: 0;
  max-width: min(85%, 520px);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}
.msg.user .who {
  display: none;
}
.msg.user .content {
  white-space: pre-wrap;
  background: var(--user-bubble);
  border: 1px solid rgba(255, 255, 255, 0.06);
  padding: 0.7rem 1rem;
  border-radius: 22px;
  display: inline-block;
  max-width: 100%;
  line-height: 1.5;
  font-size: 0.95rem;
  color: var(--text);
  text-align: left;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.15);
}

/* Result blocks — softer premium cards */
.result-root {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}
.result-meta {
  display: flex; gap: 0.4rem; align-items: center; flex-wrap: wrap;
}
.result-meta .muted { margin: 0; font-size: 0.75rem; }
.status-steps {
  display: flex; flex-wrap: wrap; gap: 0.25rem;
}
.step-chip {
  font-size: 0.68rem; color: var(--muted);
  border: 1px solid var(--border); border-radius: 999px;
  padding: 0.12rem 0.45rem;
}
.step-chip.done { color: var(--ok); border-color: rgba(74, 222, 128, 0.3); }
.step-chip.active { color: var(--warn); border-color: rgba(251, 191, 36, 0.35); }

.result-card {
  background: rgba(47, 47, 47, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 16px;
  padding: 0.9rem 1.05rem;
  backdrop-filter: blur(8px);
}
.result-card h3 {
  margin: 0 0 0.45rem;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 600;
}
.result-lead {
  margin: 0;
  line-height: 1.55;
  font-size: 0.95rem;
  color: var(--text);
}
.result-section-label {
  margin: 0.65rem 0 0.3rem;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.result-list {
  margin: 0;
  padding-left: 1.1rem;
  line-height: 1.5;
}
.result-list li { margin-bottom: 0.35rem; font-size: 0.92rem; }
.result-list li:last-child { margin-bottom: 0; }
.result-card p { margin: 0; line-height: 1.5; }
.result-card p.muted { font-size: 0.82rem; }
.result-card p.tight { margin-top: 0.4rem; font-size: 0.85rem; }
.progress-line {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
  font-style: italic;
}

.badge {
  display: inline-block;
  font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.04em;
  padding: 0.15rem 0.45rem; border-radius: 999px;
  border: 1px solid var(--border); font-weight: 600;
}
.badge.succeeded { color: var(--ok); border-color: rgba(74, 222, 128, 0.35); }
.badge.failed { color: var(--bad); border-color: rgba(248, 113, 113, 0.35); }
.badge.running, .badge.queued { color: var(--warn); border-color: rgba(251, 191, 36, 0.35); }
.badge.agentic {
  color: #a8b8ff;
  border-color: rgba(124, 140, 255, 0.35);
  background: rgba(30, 58, 95, 0.45);
}

.claim-list { display: flex; flex-direction: column; gap: 0; }
.claim-item {
  border-top: 1px solid #383838;
  padding: 0.45rem 0;
}
.claim-item:first-child { border-top: none; padding-top: 0; }
.claim-item:last-child { padding-bottom: 0; }
.claim-text {
  margin: 0 !important;
  font-size: 0.86rem;
  line-height: 1.4;
}
.claim-meta {
  font-size: 0.68rem; color: var(--muted); margin-top: 0.2rem;
  font-family: var(--mono);
}
.dim-item { margin-bottom: 0.4rem; }
.dim-item:last-child { margin-bottom: 0; }
.dim-item strong { display: block; margin-bottom: 0.1rem; font-size: 0.88rem; }
.dim-extra { margin-top: 0.15rem; font-size: 0.82rem; }

/* Composer */
.composer-wrap {
  padding: 0.5rem 1.25rem 1.15rem;
  max-width: var(--content-w);
  width: 100%;
  margin: 0 auto;
  flex-shrink: 0;
  background: linear-gradient(to top, var(--bg) 70%, transparent);
}
.composer {
  background: #2f2f2f;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 22px;
  padding: 0.55rem 0.75rem 0.55rem;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.28);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.composer:focus-within {
  border-color: rgba(124, 140, 255, 0.35);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.32), 0 0 0 1px rgba(124, 140, 255, 0.12);
}
.composer-top {
  display: flex; flex-wrap: nowrap; gap: 0.45rem; align-items: center;
  margin-bottom: 0.35rem; padding: 0 0.15rem;
  min-height: 1.65rem;
}
.dept-pill {
  display: inline-flex; align-items: center; gap: 0.4rem;
  background: #252525; border: 1px solid var(--border);
  border-radius: 999px; padding: 0.28rem 0.4rem 0.28rem 0.7rem;
  font-size: 0.78rem; color: var(--muted);
  flex-shrink: 0;
}
.dept-pill select {
  border: none; background: transparent; color: var(--text);
  font: inherit; font-size: 0.88rem; max-width: 220px; outline: none;
  cursor: pointer;
}
.dept-hint {
  font-size: 0.78rem; color: var(--muted); flex: 1; min-width: 0;
  overflow: hidden;
}
.dept-context-status {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  font-size: 0.78rem;
  font-weight: 500;
}
.dept-context-status.ok { color: var(--ok); }
.dept-context-status.ok::before {
  content: "";
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--ok); flex-shrink: 0;
}
.dept-context-status.bad { color: var(--bad); }
.dept-context-status.loading { color: var(--warn); }
.composer-row { display: flex; gap: 0.55rem; align-items: flex-end; }
.composer textarea {
  flex: 1; border: none; background: transparent; color: var(--text);
  font: inherit; font-size: 0.98rem; resize: none; outline: none;
  max-height: 180px; line-height: 1.5; padding: 0.45rem 0.4rem;
  min-height: 30px;
}
.composer textarea::placeholder { color: #7a7a7a; }
.btn-send {
  width: 34px; height: 34px; border-radius: 50%; border: none;
  background: #fff; color: #111; cursor: pointer;
  display: grid; place-items: center; flex-shrink: 0;
  font-weight: 700; font-size: 1.05rem;
  transition: transform 0.12s ease, opacity 0.12s ease, background 0.12s ease;
}
.btn-send:hover:not(:disabled) {
  background: #f0f0f0;
  transform: scale(1.04);
}
.btn-send:disabled { opacity: 0.35; cursor: not-allowed; }
.btn-add-dept {
  flex-shrink: 0;
  padding: 0.28rem 0.65rem !important;
  font-size: 0.78rem !important;
}
.modal-card-wide {
  width: min(640px, calc(100vw - 1.5rem));
}
.context-textarea {
  width: 100%;
  border: 1px solid var(--border);
  background: #1a1a1a;
  color: var(--text);
  border-radius: 8px;
  padding: 0.65rem 0.75rem;
  font-family: var(--mono);
  font-size: 0.78rem;
  line-height: 1.45;
  resize: vertical;
  outline: none;
  box-sizing: border-box;
}
.context-textarea:focus { border-color: var(--accent); }
.context-editor {
  min-height: 280px;
  max-height: min(55vh, 480px);
}
.context-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  margin: 0 0 0.5rem;
  font-size: 0.72rem;
}
.dept-form .context-textarea {
  font-size: 0.78rem !important;
  padding: 0.55rem 0.7rem !important;
  margin-top: 0.35rem;
}
.dept-context-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.dept-context-label {
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 500;
}
.dept-form .context-tabs {
  transform: scale(0.92);
  transform-origin: right center;
}
.dept-form .context-textarea:not(.hidden) {
  font-family: var(--sans);
}
#dept-form-context-json:not(.hidden) {
  font-family: var(--mono);
}
.btn-send .btn-spinner {
  width: 12px; height: 12px; border: 2px solid #999; border-top-color: #111;
  border-radius: 50%; animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.hidden { display: none !important; }
.mono { font-family: var(--mono); font-size: 0.72rem; }

/* Modal */
.modal.hidden { display: none !important; }
.modal {
  position: fixed; inset: 0; z-index: 100;
  display: grid; place-items: center;
}
.modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.55);
}
.modal-card {
  position: relative; z-index: 1;
  width: min(420px, calc(100vw - 1.5rem));
  max-height: calc(100vh - 1.5rem);
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 0.95rem 1rem 1rem;
  box-shadow: 0 16px 40px rgba(0,0,0,0.45);
}
.modal-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 0.25rem;
}
.modal-head h2 { margin: 0; font-size: 1rem; font-weight: 600; }
.modal-lead { margin: 0 0 0.75rem; font-size: 0.78rem; line-height: 1.4; }
.modal-lead code {
  font-family: var(--mono); font-size: 0.72rem;
  background: #252525; padding: 0.08rem 0.25rem; border-radius: 4px;
}
.dept-form { display: flex; flex-direction: column; gap: 0.6rem; }
.dept-form label {
  display: flex; flex-direction: column; gap: 0.3rem;
  font-size: 0.78rem; color: var(--muted); font-weight: 500;
}
.dept-form .opt { font-weight: 400; opacity: 0.75; }
.dept-form input, .dept-form select { font-size: 0.92rem !important; padding: 0.55rem 0.7rem !important; }
.dept-form input, .dept-form select {
  border: 1px solid var(--border);
  background: #252525;
  color: var(--text);
  border-radius: 8px;
  padding: 0.55rem 0.7rem;
  font: inherit;
  font-size: 0.92rem;
  outline: none;
}
.dept-form input:focus, .dept-form select:focus { border-color: var(--accent); }
.form-error { margin: 0; font-size: 0.78rem; color: var(--bad); }
.form-error.hidden { display: none; }
.modal-actions {
  display: flex; justify-content: flex-end; gap: 0.4rem;
  margin-top: 0.25rem;
}
.btn-primary {
  border: none;
  background: linear-gradient(145deg, #4f6ef7, #8b9cff);
  color: #fff;
  border-radius: 999px;
  padding: 0.42rem 0.9rem;
  font: inherit;
  font-weight: 600;
  font-size: 0.82rem;
  cursor: pointer;
}
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

/* Trace view */
.trace-toolbar {
  display: flex; gap: 0.65rem; align-items: center;
  padding: 0.55rem 1rem; border-bottom: 1px solid #2a2a2a;
}
.trace-grid {
  flex: 1; overflow: auto; padding: 0.75rem 1rem;
  display: grid; grid-template-columns: 1fr 1fr; gap: 0.65rem;
}
@media (max-width: 900px) {
  .sidebar { display: none; }
  .trace-grid { grid-template-columns: 1fr; }
}
.card {
  background: var(--bubble); border: 1px solid var(--border);
  border-radius: 12px; padding: 0.65rem 0.8rem;
}
.card h3 { margin: 0 0 0.45rem; font-size: 0.8rem; color: var(--muted); }
.code {
  margin: 0; font-family: var(--mono); font-size: 0.72rem; line-height: 1.4;
  white-space: pre-wrap; word-break: break-word; color: #cfcfcf;
  max-height: 280px; overflow: auto; background: #1a1a1a;
  border-radius: 8px; padding: 0.5rem; border: 1px solid #333;
}
.code.tall { max-height: 360px; }
.timeline { display: flex; flex-direction: column; gap: 0.25rem; max-height: 360px; overflow: auto; }
.ev {
  display: grid; grid-template-columns: 2.2rem 1fr auto; gap: 0.35rem;
  padding: 0.35rem 0.4rem; border-radius: 6px; cursor: pointer;
  border: 1px solid transparent; background: #1a1a1a;
}
.ev:hover, .ev.selected { border-color: #555; background: #222; }
.ev .seq { font-family: var(--mono); color: var(--muted); font-size: 0.7rem; }
.ev .type { font-size: 0.8rem; font-weight: 600; }
.ev .phase { font-size: 0.68rem; color: var(--muted); }
.ev .actor { font-size: 0.65rem; color: #888; }
.filters { display: flex; flex-wrap: wrap; gap: 0.65rem; align-items: end; margin: 0.75rem 1rem; }
.filters label { display: flex; flex-direction: column; gap: 0.2rem; font-size: 0.72rem; color: var(--muted); }
.filters input {
  background: #1a1a1a; border: 1px solid var(--border); color: var(--text);
  border-radius: 8px; padding: 0.4rem 0.55rem; font: inherit; min-width: 12rem;
}
#diff-out { margin: 0 1rem 1rem; }
.diff-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.65rem; }
.diff-kv { font-family: var(--mono); font-size: 0.78rem; margin: 0.2rem 0; }
