:root {
  --bg0: #f8f9fb;
  --bg1: #f0f2f5;
  --panel: rgba(255, 255, 255, 0.78);
  --panel2: rgba(255, 255, 255, 0.92);
  --line: rgba(17, 24, 39, 0.10);
  --text: rgba(17, 24, 39, 0.92);
  --muted: rgba(17, 24, 39, 0.58);
  --muted2: rgba(17, 24, 39, 0.42);
  --danger: #ef4444;
  --ok: #10b981;
  --brand: #2563eb;
  --brand2: #1d4ed8;
  --shadow: 0 8px 32px rgba(17, 24, 39, 0.08);
  --radius: 12px;
  --radius-sm: 8px;
  --fg: var(--text);
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  color: var(--text);
  background: radial-gradient(1200px 700px at 18% 18%, rgba(14, 165, 233, 0.14), transparent 58%),
    radial-gradient(900px 600px at 82% 14%, rgba(124, 58, 237, 0.12), transparent 60%),
    radial-gradient(1000px 700px at 55% 92%, rgba(34, 211, 238, 0.12), transparent 55%),
    linear-gradient(180deg, var(--bg0), var(--bg1));
  font-family: "Noto Sans SC", ui-sans-serif, system-ui, -apple-system, "Segoe UI", "Microsoft YaHei", "PingFang SC",
    sans-serif;
  letter-spacing: 0.2px;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: repeating-linear-gradient(
    45deg,
    rgba(255, 255, 255, 0.04) 0px,
    rgba(255, 255, 255, 0.04) 1px,
    transparent 1px,
    transparent 10px
  );
  opacity: 0.15;
  mix-blend-mode: overlay;
}

* {
  box-sizing: border-box;
}

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

a:hover {
  text-decoration: underline;
}

.appShell {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 12px;
  height: 100vh;
  padding: 14px;
  transition: grid-template-columns 0.2s ease;
}
.appShellCollapsed {
  grid-template-columns: 56px 1fr;
}

.sidebar {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.82), rgba(255, 255, 255, 0.62));
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: width 0.2s ease;
}
.sidebarCollapsed .sidebarHeader { padding: 12px 8px 10px 8px; justify-content: center; }
.sidebarCollapsed .sidebarNav { padding: 6px 4px; }
.sidebarCollapsed .navItem { justify-content: center; padding: 8px 0; gap: 0; }
.sidebarCollapsed .configSection { padding: 0 4px; }
.sidebarCollapsed .configHeader { justify-content: center; padding: 8px 0; }

.sidebarHeader {
  padding: 12px 14px 10px 14px;
  border-bottom: 1px solid var(--line);
}

.brandLogo {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  object-fit: contain;
  flex-shrink: 0;
}

.brandTitle {
  font-family: "Noto Serif SC", ui-serif, Georgia, serif;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.brandSub {
  margin-top: 2px;
  font-size: 11px;
  color: var(--muted2);
  letter-spacing: 0.3px;
}

/* ─── Sidebar navigation ─── */

.sidebarNav {
  padding: 8px 8px 4px 8px;
}

.navItem {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 10px;
  cursor: pointer;
  user-select: none;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  border: 1px solid transparent;
  transition: background 0.15s, color 0.15s;
}

.navItem:hover {
  background: rgba(14, 165, 233, 0.06);
  color: var(--text);
}

.navItemActive {
  background: rgba(14, 165, 233, 0.1);
  color: var(--brand);
  border-color: rgba(14, 165, 233, 0.18);
}

/* ─── Config section (collapsible) ─── */

.configSection {
  border-top: 1px solid var(--line);
  margin-top: auto;
}

.configHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  cursor: pointer;
  user-select: none;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  transition: background 0.15s;
}

.configHeader:hover {
  background: rgba(14, 165, 233, 0.04);
}

.configProgress {
  font-size: 11px;
  color: var(--muted2);
  background: rgba(14, 165, 233, 0.08);
  padding: 1px 6px;
  border-radius: 8px;
}

.stepList {
  padding: 4px 8px 8px 8px;
  overflow: auto;
  max-height: 320px;
}

.stepItem {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 6px 8px;
  border-radius: 10px;
  cursor: pointer;
  user-select: none;
  border: 1px solid transparent;
}

.stepItem:not(.stepItemDisabled):hover {
  background: rgba(14, 165, 233, 0.06);
  border-color: rgba(14, 165, 233, 0.16);
}

.stepItemActive {
  background: rgba(14, 165, 233, 0.08);
  border-color: rgba(14, 165, 233, 0.2);
}

.stepItemActive:hover {
  background: rgba(14, 165, 233, 0.1);
  border-color: rgba(14, 165, 233, 0.26);
}

.stepItemDisabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.stepItemDisabled:hover {
  background: transparent;
  border-color: transparent;
}

.stepDot {
  width: 22px;
  height: 22px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.96);
  background: linear-gradient(135deg, rgba(14, 165, 233, 1), rgba(124, 58, 237, 1));
  box-shadow: 0 4px 8px rgba(17, 24, 39, 0.1);
  flex: 0 0 auto;
}

.stepDotDone {
  background: linear-gradient(135deg, rgba(16, 185, 129, 1), rgba(14, 165, 233, 1));
}

.stepMeta {
  padding-top: 1px;
}

.stepTitle {
  font-size: 13px;
  font-weight: 650;
}

.stepDesc {
  margin-top: 2px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.35;
}

.main {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.84), rgba(255, 255, 255, 0.62));
  box-shadow: var(--shadow);
  overflow: hidden;
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-width: 0;
}

.topbar {
  padding: 8px 16px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 40px;
}

.topbarStatusRow {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 12px;
  color: var(--muted);
}

.topbarWs {
  font-weight: 700;
  color: var(--text);
  padding: 2px 8px;
  background: rgba(14, 165, 233, 0.06);
  border-radius: 6px;
}

.topbarIndicator {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.topbarEpCount {
  color: var(--muted2);
}

.topbarRefreshBtn {
  padding: 4px 8px !important;
  border-radius: 8px !important;
  background: transparent !important;
  border: 1px solid var(--line) !important;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.topbarRefreshBtn:hover {
  background: rgba(14, 165, 233, 0.06) !important;
}

.topbarConnectBtn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px !important;
  border-radius: 6px !important;
  border: 1px solid var(--brand) !important;
  background: transparent !important;
  color: var(--brand) !important;
  font-size: 11px !important;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
}
.topbarConnectBtn:hover {
  background: rgba(14,165,233,0.06) !important;
}
.topbarConnectBtn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Window control buttons (custom title bar) */
.winCtrl {
  width: 32px; height: 24px;
  border: none; background: transparent;
  cursor: pointer; font-size: 14px;
  color: var(--muted); display: inline-flex;
  align-items: center; justify-content: center;
  border-radius: 4px;
  transition: background 0.12s;
  -webkit-app-region: no-drag;
}
.winCtrl:hover { background: rgba(0,0,0,0.06); }
.winCtrlClose:hover { background: rgba(255,0,0,0.75); color: #fff; }

/* Secondary button */
.btnSecondary {
  padding: 8px 24px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--fg);
  cursor: pointer;
  font-weight: 700;
  font-size: 14px;
  transition: background 0.15s;
}
.btnSecondary:hover { background: rgba(14,165,233,0.06); }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.7);
  color: var(--muted);
  font-size: 12px;
}

.content {
  padding: 18px;
  overflow: auto;
  min-width: 0;
}

.card {
  border: 1px solid rgba(17, 24, 39, 0.12);
  background: rgba(255, 255, 255, 0.72);
  border-radius: var(--radius);
  padding: 16px;
  min-width: 0;
  overflow: hidden;
}

.card + .card {
  margin-top: 12px;
}

.cardTitle {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.2px;
  margin: 0 0 8px 0;
}

.cardHint {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
}

.grid2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* Welcome step guide */
.welcomeInfoTag {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 6px;
  background: rgba(14,165,233,0.06);
  font-size: 12px;
  color: var(--muted);
  font-family: "SF Mono", ui-monospace, monospace;
}
.welcomeSteps {
  display: flex;
  flex-direction: column;
  gap: 0;
}
.welcomeStepRow {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.welcomeStepRow:last-child { border-bottom: none; }
.welcomeStepNum {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
}

.grid3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
}

.field {
  display: grid;
  gap: 6px;
}

.labelRow {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.label {
  font-size: 12px;
  color: var(--text);
  font-weight: 650;
}

.help {
  font-size: 11px;
  color: var(--muted2);
  line-height: 1.35;
}

input,
select,
textarea {
  width: 100%;
  border-radius: 12px;
  border: 1px solid rgba(17, 24, 39, 0.14);
  background: rgba(255, 255, 255, 0.9);
  color: var(--text);
  padding: 10px 10px;
  outline: none;
}

textarea {
  min-height: 90px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(14, 165, 233, 0.38);
  box-shadow: 0 0 0 4px rgba(14, 165, 233, 0.12);
}

.row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.btnRow {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

/* (legacy btnSmall override removed; see status section) */

button {
  border: 0;
  cursor: pointer;
  border-radius: 14px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.82);
  color: rgba(17, 24, 39, 0.92);
  font-weight: 700;
  letter-spacing: 0.2px;
  border: 1px solid rgba(17, 24, 39, 0.12);
}

button:not(.btnPrimary):not(.btnDanger):hover {
  background: rgba(255, 255, 255, 0.92);
  border-color: rgba(17, 24, 39, 0.16);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btnPrimary {
  background: var(--brand);
  color: #fff;
  border: 1px solid transparent;
}

.btnPrimary:hover {
  background: var(--brand2);
}

.btnDanger {
  background: rgba(255, 77, 109, 0.16);
  border-color: rgba(255, 77, 109, 0.28);
}

.btnDanger:hover {
  background: rgba(255, 77, 109, 0.18);
  border-color: rgba(255, 77, 109, 0.32);
}
.footer {
  border-top: 1px solid var(--line);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.statusLine {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.35;
}

.errorBox {
  margin-top: 10px;
  border: 1px solid rgba(255, 77, 109, 0.28);
  background: rgba(255, 77, 109, 0.1);
  color: rgba(17, 24, 39, 0.9);
  border-radius: 14px;
  padding: 12px;
  white-space: pre-wrap;
}

.okBox {
  margin-top: 10px;
  border: 1px solid rgba(98, 246, 213, 0.25);
  background: rgba(98, 246, 213, 0.08);
  border-radius: 14px;
  padding: 12px;
  color: rgba(17, 24, 39, 0.9);
}

.divider {
  height: 1px;
  background: var(--line);
  margin: 12px 0;
}

/* Chat view: full-height content without padding */
.contentChat {
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* Chat markdown content styling */
.chatMdContent {
  font-size: 14px;
  line-height: 1.7;
}

.chatMdContent p {
  margin: 0.4em 0;
}

.chatMdContent pre {
  background: rgba(17, 24, 39, 0.04);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  overflow-x: auto;
  font-size: 12px;
  margin: 8px 0;
}

.chatMdContent code {
  background: rgba(14, 165, 233, 0.08);
  padding: 2px 5px;
  border-radius: 4px;
  font-size: 0.9em;
}

.chatMdContent pre code {
  background: none;
  padding: 0;
  border-radius: 0;
}

.chatMdContent ul,
.chatMdContent ol {
  padding-left: 20px;
  margin: 0.4em 0;
}

.chatMdContent blockquote {
  border-left: 3px solid var(--brand);
  margin: 0.4em 0;
  padding: 4px 12px;
  color: var(--muted);
}

.chatMdContent table {
  border-collapse: collapse;
  width: 100%;
  margin: 8px 0;
  font-size: 13px;
}

.chatMdContent th,
.chatMdContent td {
  border: 1px solid var(--line);
  padding: 6px 10px;
  text-align: left;
}

.chatMdContent th {
  background: rgba(14, 165, 233, 0.04);
  font-weight: 700;
}

/* Bouncing dots animation */
.dotBounce {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 3px;
  background: var(--muted);
  animation: dotBounce 1.2s infinite ease-in-out;
}

@keyframes dotBounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

/* Health status dot */
.healthDot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 4px;
  margin-right: 6px;
  flex-shrink: 0;
}

.healthDot.healthy { background: rgba(16, 185, 129, 1); }
.healthDot.degraded { background: rgba(245, 158, 11, 1); }
.healthDot.unhealthy { background: rgba(255, 77, 109, 1); }
.healthDot.unknown { background: rgba(17, 24, 39, 0.25); }
.healthDot.disabled { background: rgba(17, 24, 39, 0.15); }

/* Spinning animation for health check */
@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* Pulse animation for voice recording */
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.spinIcon {
  display: inline-block;
  animation: spin 1s linear infinite;
}

/* ─── Status page compact layout ─── */
.statusGrid3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
}
.statusGrid2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.statusCard {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255,255,255,0.72);
  padding: 12px 14px;
}
.statusCardHead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}
.statusCardLabel {
  font-weight: 700;
  font-size: 13px;
  color: var(--fg);
}
.statusCardValue {
  font-size: 15px;
  font-weight: 800;
  margin-bottom: 2px;
}
.statusCardSub {
  font-size: 11px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.statusCardActions {
  margin-top: 6px;
  display: flex;
  gap: 6px;
}
/* ─── Small buttons ─── */
.btnSmall {
  padding: 5px 12px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: #fff;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  transition: all 0.15s ease;
  line-height: 1.4;
  white-space: nowrap;
}
.btnSmall:hover {
  background: var(--bg1);
  border-color: rgba(0,0,0,0.15);
}
.btnSmall:disabled { opacity: 0.35; cursor: not-allowed; }
.btnSmallPrimary {
  border-color: var(--brand);
  color: var(--brand);
  background: rgba(37,99,235,0.04);
}
.btnSmallPrimary:hover {
  background: rgba(37,99,235,0.10);
}
.btnSmallDanger {
  border-color: rgba(239,68,68,0.3);
  color: #dc2626;
}
.btnSmallDanger:hover {
  background: rgba(239,68,68,0.06);
}

/* ─── Endpoint table ─── */
.epTable {
  font-size: 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}
.epTableHeader {
  display: grid;
  grid-template-columns: 1.4fr 1.6fr 44px 64px 90px;
  gap: 12px;
  padding: 10px 16px;
  background: var(--bg1);
  border-bottom: 1px solid var(--line);
  font-weight: 700;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.epTableRow {
  display: grid;
  grid-template-columns: 1.4fr 1.6fr 44px 64px 90px;
  gap: 12px;
  padding: 10px 16px;
  align-items: center;
  border-bottom: 1px solid rgba(0,0,0,0.04);
  transition: background 0.1s;
}
.epTableRow:last-child { border-bottom: none; }
.epTableRow:hover { background: rgba(37,99,235,0.02); }
.epTableName {
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
}
.epTableModel {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: 12px;
}
.epTableStatus {
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* IM status row */
.imStatusRow {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid rgba(0,0,0,0.04);
}
.imStatusRow:last-child { border-bottom: none; }
.imStatusLabel { font-size: 11px; color: var(--muted); }

/* Status metrics */
.statusMetric {
  display: flex;
  justify-content: space-between;
  padding: 3px 0;
  font-size: 13px;
}

/* Log display */
.logPre {
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 11px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(0,0,0,0.02);
  max-height: 200px;
  overflow: auto;
  margin: 0;
}

/* ─── Modal & Dialog ─── */
.modalOverlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.32);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: fadeIn 0.15s ease-out;
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.modalContent {
  background: #fff;
  border-radius: 16px;
  padding: 0;
  width: 480px;
  max-width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 24px 64px rgba(0,0,0,0.18), 0 0 0 1px rgba(0,0,0,0.05);
  animation: slideUp 0.2s ease-out;
}
.modalContent > * {
  padding-left: 24px;
  padding-right: 24px;
}
.modalContent > *:first-child {
  padding-top: 20px;
}
.modalContent > *:last-child {
  padding-bottom: 20px;
}

/* Dialog header */
.dialogHeader {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px 12px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 4px;
}
.dialogHeader .cardTitle {
  margin: 0;
  font-size: 16px;
}
.dialogCloseBtn {
  width: 28px;
  height: 28px;
  border-radius: 8px !important;
  border: none !important;
  background: transparent !important;
  color: var(--muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 !important;
  font-size: 16px;
  transition: all 0.12s;
}
.dialogCloseBtn:hover {
  background: var(--bg1) !important;
  color: var(--text);
}

/* Dialog sections */
.dialogSection {
  margin-bottom: 16px;
  padding-left: 24px;
  padding-right: 24px;
}
.dialogLabel {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 6px;
  letter-spacing: 0.3px;
}
.dialogSection input,
.dialogSection select {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 13px;
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.dialogSection input:focus,
.dialogSection select:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.08);
}

/* Dialog footer */
.dialogFooter {
  padding: 12px 24px 20px;
  border-top: 1px solid var(--line);
  margin-top: 8px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* Capability chips */
.capChip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: #fff;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.12s;
  color: var(--muted);
}
.capChip:hover {
  border-color: rgba(0,0,0,0.15);
  background: var(--bg1);
}
.capChipActive {
  border-color: var(--brand);
  color: var(--brand);
  background: rgba(37,99,235,0.06);
}
.capChipActive:hover {
  background: rgba(37,99,235,0.10);
}

/* Advanced details */
.dialogDetails {
  margin: 8px 24px 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}
.dialogDetails summary {
  cursor: pointer;
  padding: 10px 14px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  background: var(--bg1);
  user-select: none;
  list-style: none;
}
.dialogDetails summary::before {
  content: "\25B8  ";
}
.dialogDetails[open] summary::before {
  content: "\25BE  ";
}
.dialogDetails summary:hover {
  background: rgba(0,0,0,0.04);
}
.dialogDetails > div {
  padding: 12px 14px;
}

/* ─── Config page details (no side margin) ─── */
.configDetails {
  margin: 6px 0 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}
.configDetails summary {
  cursor: pointer;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  background: var(--bg1);
  user-select: none;
  list-style: none;
}
.configDetails summary::before {
  content: "\25B8  ";
  color: var(--muted);
}
.configDetails[open] summary::before {
  content: "\25BE  ";
}
.configDetails summary:hover {
  background: rgba(0,0,0,0.04);
}
.configDetailsBody {
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ─── Password eye button ─── */
.btnEye {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  padding: 4px;
  border-radius: 6px;
  display: flex;
  align-items: center;
}
.btnEye:hover {
  color: var(--text);
  background: var(--bg1);
}

/* ─── Field tooltip (info icon) ─── */
.fieldTip {
  display: inline-flex;
  align-items: center;
  margin-left: 4px;
  color: var(--muted);
  cursor: help;
  vertical-align: middle;
}
.fieldTip:hover {
  color: var(--brand);
}

/* ─── Chat top bar ─── */

.chatTopBar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}

.chatTopBarBtn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px !important;
  border-radius: 8px !important;
  border: 1px solid var(--line) !important;
  background: transparent !important;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

.chatTopBarBtn:hover {
  background: rgba(14, 165, 233, 0.06) !important;
  color: var(--text);
}

/* ─── Cursor-style unified input box ─── */

.chatInputArea {
  padding: 12px 16px;
  flex-shrink: 0;
  position: relative;
}

.chatInputBox {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel2);
  overflow: hidden;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.chatInputBox:focus-within {
  border-color: rgba(14, 165, 233, 0.35);
  box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.08);
}

.chatInputBoxPlan {
  border-color: rgba(124, 58, 237, 0.3);
  background: rgba(124, 58, 237, 0.02);
}

.chatInputBoxPlan:focus-within {
  border-color: rgba(124, 58, 237, 0.4);
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.08);
}

.chatInputTop {
  padding: 8px 12px 0 12px;
}

.chatModelSelect {
  font-size: 12px !important;
  padding: 3px 8px !important;
  border-radius: 8px !important;
  border: 1px solid var(--line) !important;
  background: rgba(255, 255, 255, 0.7) !important;
  color: var(--muted) !important;
  width: auto !important;
  cursor: pointer;
}

/* Compact model picker button */
.chatModelPickerBtn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.6);
  color: var(--fg);
  font-size: 12px;
  cursor: pointer;
  max-width: 220px;
  transition: background 0.15s;
}
.chatModelPickerBtn:hover { background: rgba(14,165,233,0.06); }
.chatModelPickerLabel {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Floating model menu (opens upward) */
.chatModelMenu {
  position: absolute;
  bottom: calc(100% + 4px);
  left: 0;
  min-width: 240px;
  max-height: 320px;
  overflow-y: auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  z-index: 100;
  padding: 4px 0;
}
.chatModelMenuItem {
  padding: 7px 14px;
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  transition: background 0.1s;
}
.chatModelMenuItem:hover { background: rgba(14,165,233,0.06); }
.chatModelMenuItemActive {
  background: rgba(14,165,233,0.1);
  font-weight: 600;
}

.chatInputTextarea {
  width: 100% !important;
  border: none !important;
  background: transparent !important;
  padding: 8px 12px !important;
  font-size: 14px;
  line-height: 1.5;
  font-family: inherit;
  resize: none !important;
  max-height: 120px;
  overflow: auto;
  outline: none !important;
  box-shadow: none !important;
  min-height: 36px !important;
}

.chatInputToolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 8px 8px 8px;
}

.chatInputToolbarLeft {
  display: flex;
  align-items: center;
  gap: 2px;
}

.chatInputToolbarRight {
  display: flex;
  align-items: center;
  gap: 4px;
}

.chatInputIconBtn {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 5px 8px !important;
  border-radius: 8px !important;
  border: none !important;
  background: transparent !important;
  color: var(--muted2) !important;
  cursor: pointer;
  font-size: 12px;
  transition: color 0.15s, background 0.15s;
}

.chatInputIconBtn:hover {
  background: rgba(14, 165, 233, 0.08) !important;
  color: var(--text) !important;
}

.chatInputIconBtnActive {
  color: rgba(124, 58, 237, 0.9) !important;
  background: rgba(124, 58, 237, 0.08) !important;
}

.chatInputIconBtnDanger {
  color: var(--danger) !important;
  background: rgba(255, 77, 109, 0.08) !important;
  animation: pulse 1.5s infinite;
}

.chatInputSendBtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50% !important;
  border: none !important;
  background: var(--brand) !important;
  color: #fff !important;
  cursor: pointer;
  transition: opacity 0.15s;
  padding: 0;
  line-height: 1;
}
.chatInputSendBtn svg {
  width: 14px;
  height: 14px;
  display: block;
}

.chatInputSendBtn:hover {
  opacity: 0.9;
}

.chatInputSendBtn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.chatInputStopBtn {
  background: rgba(255, 77, 109, 0.9) !important;
}

/* ─── IM View ─── */

.imView {
  display: grid;
  grid-template-columns: 240px 1fr;
  height: 100%;
  overflow: hidden;
}

.imLeft {
  border-right: 1px solid var(--line);
  overflow: auto;
  display: flex;
  flex-direction: column;
}

.imRight {
  overflow: auto;
  display: flex;
  flex-direction: column;
}

.imSectionTitle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px 6px 12px;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted2);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.imRefreshBtn {
  padding: 2px 4px !important;
  border-radius: 6px !important;
  border: none !important;
  background: transparent !important;
  cursor: pointer;
  color: var(--muted2);
}

.imRefreshBtn:hover {
  background: rgba(14, 165, 233, 0.08) !important;
  color: var(--text);
}

.imChannelList, .imSessionList {
  padding: 0 6px;
}

.imChannelItem, .imSessionItem {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  user-select: none;
  font-size: 13px;
  transition: background 0.15s;
}

.imChannelItem:hover, .imSessionItem:hover {
  background: rgba(14, 165, 233, 0.06);
}

.imChannelItemActive, .imSessionItemActive {
  background: rgba(14, 165, 233, 0.1);
}

.imChannelName {
  font-weight: 600;
}

.imChannelCount {
  font-size: 11px;
  color: var(--muted2);
  background: rgba(14, 165, 233, 0.08);
  padding: 1px 6px;
  border-radius: 8px;
}

.imSessionId {
  font-size: 12px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.imSessionMeta {
  font-size: 11px;
  color: var(--muted2);
  margin-top: 2px;
}

.imViewEmpty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--muted2);
}

.imEmptyHint {
  padding: 16px;
  text-align: center;
  color: var(--muted2);
  font-size: 12px;
}

.imMessages {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.imMessagesHeader {
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}

.imMessagesList {
  flex: 1;
  overflow: auto;
  padding: 12px 16px;
}

.imMsg {
  margin-bottom: 12px;
}

.imMsgRole {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted2);
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.imMsgTime {
  font-weight: 400;
  color: var(--muted2);
  font-size: 10px;
}

.imMsgUser .imMsgRole {
  color: var(--brand);
}

.imMsgContent {
  font-size: 13px;
  line-height: 1.6;
  padding: 8px 12px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.6);
  border: 1px solid var(--line);
}

.imMsgUser .imMsgContent {
  background: rgba(14, 165, 233, 0.04);
  border-color: rgba(14, 165, 233, 0.12);
}

.imMediaCard {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 6px;
  background: rgba(14, 165, 233, 0.06);
  border: 1px solid rgba(14, 165, 233, 0.12);
  font-size: 12px;
  color: var(--brand);
  margin: 2px;
}

/* ── Toast Notifications ── */
.toastContainer {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 420px;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.4;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  animation: toastSlideIn 0.3s ease;
  cursor: pointer;
  word-break: break-word;
}
.toastInfo {
  background: #f0f4ff;
  border: 1px solid rgba(37,99,235,0.2);
  color: #1e40af;
}
.toastOk {
  background: #f0fdf4;
  border: 1px solid rgba(34,197,94,0.2);
  color: #166534;
}
.toastError {
  background: #fef2f2;
  border: 1px solid rgba(239,68,68,0.2);
  color: #991b1b;
}
@keyframes toastSlideIn {
  from { opacity: 0; transform: translateX(40px); }
  to { opacity: 1; transform: translateX(0); }
}

/* ── Icon Buttons (for table rows) ── */
.btnIcon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: white;
  cursor: pointer;
  color: var(--muted);
  transition: all 0.15s;
  padding: 0;
}
.btnIcon:hover {
  background: var(--bg1);
  color: var(--text);
  border-color: var(--text-secondary);
}
.btnIconDanger:hover {
  background: rgba(239,68,68,0.08);
  color: var(--danger);
  border-color: rgba(239,68,68,0.3);
}
.btnIcon:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

@media (max-width: 980px) {
  .appShell {
    grid-template-columns: 1fr;
    height: auto;
  }
  .imView {
    grid-template-columns: 1fr;
  }
}

