.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--la-s-4);
  padding: var(--la-s-2) var(--la-s-3);
  background: var(--la-surface);
  border: 1px solid var(--la-border);
  border-radius: var(--la-radius-md);
}

.brand { display: flex; align-items: center; gap: var(--la-s-2); }
.brand-logo { height: 32px; }

.top-actions {
  display: flex;
  align-items: center;
  gap: var(--la-s-2);
  position: relative;
  flex-wrap: wrap;
  justify-content: flex-end;
  flex: 1 1 auto;
  min-width: 0;
}

.top-actions-secondary {
  display: flex;
  align-items: center;
  gap: var(--la-s-2);
}

.mobile-agent-bar {
  display: none;
  width: 100%;
  border: none;
  border-radius: var(--la-radius-pill);
  padding: 6px 10px;
  background: #dbeafe;
  color: #1d4ed8;
  font-size: var(--la-fs-1);
  line-height: var(--la-lh-2);
  cursor: pointer;
  margin-top: 2px;
}

.mobile-agent-row {
  display: none;
  width: 100%;
  gap: var(--la-s-2);
  align-items: center;
}

.mobile-context-btn {
  display: none;
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  border-radius: var(--la-radius-pill);
  border: 1px solid var(--la-border);
  background: var(--la-surface);
  color: var(--la-text-muted);
  cursor: pointer;
  align-items: center;
  justify-content: center;
}

.mobile-context-btn svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.mobile-context-btn:hover {
  color: var(--la-text);
  border-color: var(--la-border-strong);
  background: var(--la-surface-2);
}

.tenant-pill { margin-left: var(--la-s-1); }

.tenant-pill {
  background: var(--la-accent-100);
  color: var(--la-accent-700);
  border-radius: var(--la-radius-pill);
  padding: 6px 12px;
  font-size: var(--la-fs-2);
}

.agent-pill {
  border-radius: var(--la-radius-pill);
  padding: 6px 12px;
  border: 1px solid var(--la-border);
  background: var(--la-surface);
  font-size: var(--la-fs-2);
}

.upload-pill {
  display: inline-flex;
  align-items: center;
  gap: var(--la-s-2);
  border-radius: var(--la-radius-pill);
  padding: 6px 12px;
  border: 1px solid var(--la-border);
  background: var(--la-surface);
  font-size: var(--la-fs-2);
  cursor: pointer;
}

.upload-pill.upload-inline {
  padding: 6px;
  gap: 0;
}

.upload-pill.upload-inline span {
  display: none;
}

.tenant-pill,
.agent-pill,
.upload-pill,
.icon-btn {
  color: var(--la-text);
}

@media (max-width: 720px) {
  .topbar {
    align-items: flex-start;
    flex-wrap: nowrap;
    gap: var(--la-s-2);
    padding: var(--la-s-1) var(--la-s-2);
  }
  .top-actions {
    justify-content: flex-end;
    max-width: 100%;
    gap: var(--la-s-1);
    flex-wrap: nowrap;
  }

  .top-actions-secondary {
    flex-wrap: nowrap;
    gap: var(--la-s-1);
  }

  #tenantPill { order: 1; }
  #topActionsSecondary { order: 2; }
  #menuBtn { order: 3; margin-left: auto; }

  #activeAgentBtn {
    display: none;
  }

  #uploadBtnTop span {
    display: none;
  }

  #uploadBtnTop {
    padding: 6px 10px;
  }

  .mobile-agent-bar {
    display: inline-flex;
    align-items: center;
    justify-content: flex-start;
    gap: var(--la-s-2);
    margin-top: 0;
  }

  .mobile-agent-row {
    display: flex;
  }

  .mobile-context-btn {
    display: inline-flex;
  }
}

@media (prefers-color-scheme: dark) {
  .menu {
    background: var(--la-surface);
    border-color: var(--la-border-strong);
  }
  .menu-item,
  .menu-item .hint {
    color: var(--la-text);
  }
  .menu-item .hint {
    color: var(--la-text-muted);
  }
}

@media (prefers-color-scheme: dark) {
  .tenant-pill,
  .agent-pill,
  .upload-pill,
  .icon-btn {
    background: var(--la-surface);
    border-color: var(--la-border-strong);
    color: var(--la-text);
  }

  .mobile-agent-bar {
    background: rgba(37, 99, 235, 0.16);
    color: #bfdbfe;
    border: 1px solid rgba(37, 99, 235, 0.28);
  }

  .mobile-context-btn {
    background: rgba(15, 23, 42, 0.6);
    border-color: var(--la-border-strong);
    color: #bfdbfe;
  }

  .mobile-context-btn:hover {
    background: rgba(37, 99, 235, 0.2);
    border-color: rgba(96, 165, 250, 0.55);
    color: #dbeafe;
  }

  .tts-menu-panel,
  .tts-menu-btn {
    background: var(--la-surface);
    border-color: var(--la-border-strong);
    color: var(--la-text);
  }

  .activity-indicator-dot {
    background: #60a5fa;
  }
}

.upload-pill svg,
.icon-btn svg,
.send-btn svg,
.mic-btn svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--la-radius-pill);
  border: 1px solid var(--la-border);
  background: var(--la-surface);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.activity-indicator {
  min-height: 22px;
  padding: 2px 8px 2px 4px;
  border-radius: var(--la-radius-pill);
  border: 1px solid color-mix(in srgb, var(--la-accent) 30%, transparent);
  background: color-mix(in srgb, var(--la-accent) 10%, transparent);
  display: none;
  align-items: center;
  justify-content: center;
  gap: 6px;
  opacity: 0;
  transform: scale(0.9);
  transition: opacity 0.16s ease, transform 0.16s ease;
  pointer-events: none;
}

.activity-indicator.is-active {
  display: inline-flex;
  opacity: 0.9;
  transform: scale(1);
}

.activity-indicator-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--la-accent);
  box-shadow: 0 0 0 0 rgba(37, 99, 235, 0.35);
  animation: activityPulse 1.6s ease-out infinite;
}

.activity-indicator-label {
  font-size: var(--la-fs-1);
  line-height: 1;
  color: var(--la-text-muted);
  white-space: nowrap;
}

@keyframes activityPulse {
  0% { box-shadow: 0 0 0 0 rgba(37, 99, 235, 0.34); }
  70% { box-shadow: 0 0 0 8px rgba(37, 99, 235, 0); }
  100% { box-shadow: 0 0 0 0 rgba(37, 99, 235, 0); }
}

@media (prefers-reduced-motion: reduce) {
  .activity-indicator { transition: none; }
  .activity-indicator-dot {
    animation: none;
    box-shadow: none;
  }
  .context-group-header.drop-target.drag-over::before {
    animation: none;
  }
}

@media (max-width: 720px) {
  .activity-indicator {
    min-height: 18px;
    padding: 0;
    border: none;
    background: transparent;
    gap: 0;
  }

  .activity-indicator-label {
    display: none;
  }
}

.menu {
  position: absolute;
  top: calc(100% + var(--la-s-2));
  right: 0;
  min-width: 220px;
  background: var(--la-surface);
  border: 1px solid var(--la-border);
  border-radius: var(--la-radius-md);
  box-shadow: var(--la-shadow-md);
  padding: var(--la-s-2);
  display: none;
  z-index: 150;
}

.menu.open { display: block; }

.menu-item {
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  padding: var(--la-s-2) var(--la-s-3);
  border-radius: var(--la-radius-sm);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.menu-item:hover { background: var(--la-surface-2); }
.menu-sep { height: 1px; background: var(--la-border); margin: var(--la-s-2) 0; }
.menu-item .hint { font-size: var(--la-fs-1); color: var(--la-text-muted); }

.status-row {
  display: flex;
  align-items: center;
  gap: var(--la-s-3);
  flex-wrap: wrap;
  display: none;
}

#status {
  padding: var(--la-s-2) var(--la-s-3);
  border-radius: var(--la-radius-md);
  background: var(--la-accent-100);
  color: var(--la-accent-700);
  font-size: var(--la-fs-3);
}

#loading {
  display: none;
  font-size: var(--la-fs-3);
}

.spinner {
  width: 16px;
  height: 16px;
  display: inline-block;
  border-radius: 50%;
  border: 2px solid var(--la-accent-100);
  border-top-color: var(--la-accent);
  animation: spin 0.7s linear infinite;
  vertical-align: middle;
  margin-right: 6px;
}

@keyframes spin { to { transform: rotate(360deg); } }

.boot-splash {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(6px);
  z-index: 300;
}

.boot-splash.open { display: flex; }

.boot-card {
  display: inline-flex;
  align-items: center;
  gap: var(--la-s-3);
  padding: var(--la-s-4) var(--la-s-5);
  border-radius: var(--la-radius-lg);
  background: var(--la-surface);
  border: 1px solid var(--la-border);
  box-shadow: var(--la-shadow-md);
  color: var(--la-text);
  font-size: var(--la-fs-3);
}

.boot-spinner {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--la-accent-100);
  border-top-color: var(--la-accent);
  animation: spin 0.7s linear infinite;
}

.boot-text {
  font-size: var(--la-fs-3);
}

.context-drawer-btn {
  display: none;
  height: 36px;
  border-radius: var(--la-radius-pill);
  border: 1px solid var(--la-border);
  background: var(--la-surface);
  color: var(--la-text);
  font-size: var(--la-fs-3);
  padding: 0 var(--la-s-3);
  cursor: pointer;
}

@media (max-width: 980px) {
  .context-drawer-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
}

#contextBackdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.25);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 110;
}

body.drawer-open #contextBackdrop {
  opacity: 1;
  pointer-events: auto;
}

#chatWindow {
  background: var(--la-surface);
  border: 1px solid var(--la-border);
  border-radius: var(--la-radius-md);
  padding: var(--la-s-4);
  min-height: 0;
  max-height: none;
  overflow: auto;
  height: 100%;
}

#chatWindow.drag-over {
  border-color: var(--la-accent);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.28);
}

#textForm.drag-over {
  border-radius: var(--la-radius-md);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.22);
}

#contextPanel.drag-over {
  border-radius: var(--la-radius-md);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.24);
}

#chatWindow::-webkit-scrollbar,
.modal::-webkit-scrollbar,
.modal-body::-webkit-scrollbar,
.context-list::-webkit-scrollbar,
.table-preview::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

#chatWindow::-webkit-scrollbar-thumb,
.modal::-webkit-scrollbar-thumb,
.modal-body::-webkit-scrollbar-thumb,
.context-list::-webkit-scrollbar-thumb,
.table-preview::-webkit-scrollbar-thumb {
  background-color: rgba(15, 23, 42, 0.22);
  background-image:
    radial-gradient(circle at center, rgba(15, 23, 42, 0.55) 0 2px, transparent 3px);
  border-radius: var(--la-radius-pill);
}

#chatWindow::-webkit-scrollbar-track,
.modal::-webkit-scrollbar-track,
.modal-body::-webkit-scrollbar-track,
.context-list::-webkit-scrollbar-track,
.table-preview::-webkit-scrollbar-track {
  background: transparent;
}

@supports (scrollbar-color: auto) {
  #chatWindow,
  .modal,
  .modal-body,
  .context-list,
  .table-preview {
    scrollbar-color: rgba(15, 23, 42, 0.25) transparent;
    scrollbar-width: thin;
  }
}

#suggestionPanel { margin-top: 0; }

.chat-message { display: flex; margin-bottom: var(--la-s-3); }
.chat-message.chat-user { justify-content: flex-end; }
.chat-message.chat-agent { justify-content: flex-start; }
.chat-message.chat-suggestions { justify-content: flex-start; }

.chat-message .bubble {
  max-width: 100%;
  padding: 10px 36px 10px 14px;
  border-radius: var(--la-radius-lg);
  line-height: var(--la-lh-3);
  font-size: var(--la-fs-3);
  word-break: break-word;
  position: relative;
}

.chat-message.chat-user .bubble {
  background: var(--la-accent);
  color: #fff;
  padding: 6px 20px 6px 10px;
  line-height: var(--la-lh-2);
}

.chat-message.chat-agent .bubble {
  background: #f1f5f9;
  border: 1px solid var(--la-border);
}

.chat-message.chat-agent .bubble.has-tool {
  background: rgba(59, 130, 246, 0.08);
  box-shadow: 0 10px 24px rgba(37, 99, 235, 0.12), 0 2px 6px rgba(37, 99, 235, 0.08);
  width: min(100%, 1040px);
}

@media (prefers-color-scheme: dark) {
  .chat-message.chat-agent .bubble.has-tool {
    background: rgba(59, 130, 246, 0.18);
    box-shadow: 0 16px 34px rgba(2, 6, 23, 0.6), 0 6px 14px rgba(37, 99, 235, 0.28), 0 0 0 1px rgba(59, 130, 246, 0.22);
  }
}

.bubble-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--la-s-2);
  margin-bottom: 4px;
  min-height: 0;
}

.bubble-agent-name { font-weight: 500; color: var(--la-text-muted); font-size: var(--la-fs-2); }
.bubble-badge {
  border-radius: var(--la-radius-pill);
  padding: 2px 8px;
  font-size: var(--la-fs-1);
  background: var(--la-surface-2);
  color: var(--la-text-muted);
}

.bubble-copy {
  background: transparent;
  border: none;
  color: var(--la-text-muted);
  padding: 0;
  cursor: pointer;
  opacity: 0;
  position: absolute;
  top: 8px;
  right: 8px;
  transition: opacity 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.bubble-artifact {
  background: transparent;
  border: none;
  color: var(--la-text-muted);
  padding: 0;
  cursor: pointer;
  opacity: 0;
  position: absolute;
  top: 8px;
  right: 30px;
  transition: opacity 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.bubble:hover .bubble-copy { opacity: 0.6; }
.bubble:hover .bubble-copy:hover { opacity: 0.95; color: var(--la-text); transform: translateY(-1px); }
.bubble-copy svg { width: 16px; height: 16px; }
.bubble:hover .bubble-artifact { opacity: 0.6; }
.bubble:hover .bubble-artifact:hover { opacity: 0.95; color: var(--la-text); transform: translateY(-1px); }
.bubble-artifact svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.8; }
.bubble-copy-hint {
  position: absolute;
  top: 8px;
  right: 52px;
  border: 1px solid var(--la-border);
  background: var(--la-surface);
  color: var(--la-text-muted);
  border-radius: var(--la-radius-pill);
  padding: 2px 8px;
  font-size: var(--la-fs-1);
  line-height: 1.2;
  pointer-events: none;
  opacity: 0;
  transform: translateY(-2px);
  transition: opacity 0.14s ease, transform 0.14s ease;
}
.bubble-copy-hint.is-visible {
  opacity: 0.96;
  transform: translateY(0);
}

@media (prefers-color-scheme: dark) {
  .bubble-copy-hint {
    border-color: var(--la-border-strong);
    background: rgba(15, 23, 42, 0.9);
    color: #dbeafe;
  }
}

.chart-correction-card {
  margin-top: 10px;
  padding: 10px 12px;
  border: 1px solid var(--la-border);
  border-radius: 12px;
  background: var(--la-surface-muted, rgba(15, 23, 42, 0.04));
}

.chart-correction-title {
  font-weight: 700;
  margin-bottom: 4px;
}

.chart-correction-reason {
  color: var(--la-text-muted);
  font-size: var(--la-fs-2);
  margin-bottom: 8px;
}

.chart-correction-controls {
  display: grid;
  gap: 8px;
}

.chart-correction-label {
  display: grid;
  gap: 4px;
  font-size: var(--la-fs-2);
  font-weight: 600;
}

.chart-correction-select {
  min-height: 34px;
  border-radius: 8px;
  border: 1px solid var(--la-border);
  background: var(--la-surface);
  color: inherit;
  padding: 4px 8px;
}

.chart-correction-series {
  display: grid;
  gap: 6px;
}

.chart-correction-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-right: 10px;
  font-size: var(--la-fs-2);
}

.chart-correction-actions {
  margin-top: 10px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

@media (prefers-color-scheme: dark) {
  .chart-correction-card {
    background: rgba(15, 23, 42, 0.5);
    border-color: var(--la-border-strong);
  }
  .chart-correction-select {
    background: rgba(15, 23, 42, 0.75);
  }
}

.bubble-agent-name { font-size: var(--la-fs-2); }
.bubble-badge { font-size: var(--la-fs-1); }

.bubble-status {
  margin-top: var(--la-s-1);
  font-size: var(--la-fs-1);
  color: var(--la-text-muted);
}

.bubble-status.bubble-status-hover {
  opacity: 0;
  max-height: 0;
  overflow: hidden;
  margin-top: 0;
  transition: opacity 0.15s ease, max-height 0.15s ease, margin-top 0.15s ease;
}

.bubble.is-meta-open .bubble-status.bubble-status-hover {
  opacity: 1;
  max-height: 22px;
  margin-top: 4px;
}

.bubble-badge.meta-trigger {
  cursor: pointer;
}

.tool-brief-summary {
  margin-top: 4px;
  margin-bottom: 6px;
  display: grid;
  gap: 2px;
  color: var(--la-text-muted);
}

.tool-brief-line {
  font-size: var(--la-fs-2);
  line-height: 1.3;
}

.bubble-error {
  border-color: rgba(239, 68, 68, 0.45);
  background: rgba(239, 68, 68, 0.06);
}

.error-box {
  display: flex;
  gap: var(--la-s-2);
  align-items: flex-start;
  padding: var(--la-s-2);
  border-radius: var(--la-radius-md);
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.error-icon {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(239, 68, 68, 0.9);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  flex: 0 0 auto;
}

.error-title {
  font-weight: 600;
  font-size: var(--la-fs-3);
  color: var(--la-text);
}

.error-hint {
  font-size: var(--la-fs-2);
  color: var(--la-text-muted);
  margin-top: 2px;
}

.error-action {
  margin-top: var(--la-s-2);
}

.bubble-context {
  margin-top: var(--la-s-2);
  display: flex;
  flex-wrap: wrap;
  gap: var(--la-s-2);
  align-items: center;
}

.context-chip {
  border: 1px solid var(--la-border);
  border-radius: var(--la-radius-pill);
  background: var(--la-surface-2);
  padding: 3px 9px;
  font-size: 11px;
  color: var(--la-text-muted);
}

.context-chip-btn {
  border: 1px solid var(--la-border);
  border-radius: var(--la-radius-pill);
  background: var(--la-surface);
  padding: 2px 10px;
  font-size: var(--la-fs-1);
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease, border-color 0.12s ease, background 0.12s ease;
}

.context-chip-btn:hover {
  border-color: var(--la-border-strong);
  background: var(--la-surface-2);
  box-shadow: var(--la-shadow-sm);
  transform: translateY(-1px);
}

.context-chip-btn:focus {
  outline: none;
  box-shadow: var(--la-focus);
}

.chat-message.chat-user .context-chip {
  font-size: 10px;
  padding: 2px 8px;
  color: #bfdbfe;
  background: transparent;
  border-color: rgba(191, 219, 254, 0.45);
}

.chat-message.chat-user .context-chip-btn-open {
  opacity: 0;
  pointer-events: none;
  transform: translateY(2px);
  transition: opacity 0.14s ease, transform 0.14s ease, box-shadow 0.12s ease, border-color 0.12s ease, background 0.12s ease;
}

.chat-message.chat-user .bubble:hover .context-chip-btn-open,
.chat-message.chat-user .bubble:focus-within .context-chip-btn-open {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.agent-text {
  font-size: var(--la-fs-3);
}

.user-text {
  font-size: var(--la-fs-3);
}

.agent-text p {
  margin: 0 0 var(--la-s-2);
}

.agent-text p:last-child {
  margin-bottom: 0;
}

.agent-text ul,
.agent-text ol {
  margin: 0 0 var(--la-s-2);
  padding-left: var(--la-s-5);
}

.agent-text li {
  margin: 0 0 var(--la-s-1);
}

.agent-text li:last-child {
  margin-bottom: 0;
}

.agent-text strong,
.user-text strong {
  font-weight: 600;
}

.agent-text em,
.user-text em {
  font-style: italic;
}

.chat-table {
  margin: var(--la-s-2) 0;
  width: 100%;
  border-collapse: collapse;
  font-size: var(--la-fs-2);
}

.chat-message.chat-user .chat-table {
  background: rgba(255, 255, 255, 0.12);
}

.tool-result {
  margin-top: var(--la-s-1);
  border: none;
  border-radius: var(--la-radius-md);
  background: transparent;
  padding: 0;
  overflow: auto;
  max-height: min(60vh, 360px);
  color: var(--la-text);
  position: relative;
}
.artifact-html-preview .bubble-copy,
.artifact-html-preview .tool-open-modal,
.artifact-html-preview .chart-hover-actions {
  display: none !important;
}
.artifact-html-preview {
  border: 1px solid var(--la-border);
  border-radius: var(--la-radius-md);
  background: var(--la-surface);
  padding: 10px 12px;
}

.tool-result .tool-table,
.tool-result .chat-table {
  font-size: var(--la-fs-1);
  margin: 0;
}

.tool-result .tool-chart,
.tool-result .tool-chart-wrap {
  margin: 0;
}

.tool-chart-spacer {
  height: 10px;
}

.tool-open-modal {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 30px;
  height: 30px;
  border-radius: var(--la-radius-pill);
  border: 1px solid var(--la-border);
  background: var(--la-surface);
  color: var(--la-text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transform: translateY(-2px);
  transition: opacity 0.15s ease, transform 0.15s ease, border-color 0.15s ease, background 0.15s ease;
  z-index: 2;
}

.tool-open-modal svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.tool-result:hover .tool-open-modal,
.tool-result:focus-within .tool-open-modal {
  opacity: 1;
  transform: translateY(0);
}

.chat-md-table-wrap {
  position: relative;
  margin: 6px 0;
}

.chat-md-table-wrap:hover .tool-open-modal,
.chat-md-table-wrap:focus-within .tool-open-modal {
  opacity: 1;
  transform: translateY(0);
}

.tool-open-modal:hover {
  background: var(--la-surface-2);
  border-color: rgba(59, 130, 246, 0.45);
  color: var(--la-text);
}

.tool-summary-card {
  border-radius: var(--la-radius-md);
  padding: 10px 12px;
  background: rgba(59, 130, 246, 0.16);
  color: var(--la-text);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.tool-summary-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: var(--la-fs-3);
}

.tool-input-required {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 8px;
  padding: 12px 14px;
  border: 1px solid var(--la-border);
  border-radius: var(--la-radius-md);
  background: var(--la-surface);
}

.tool-input-title {
  font-weight: 600;
  color: var(--la-text);
}

.tool-input-help {
  font-size: var(--la-fs-2);
  color: var(--la-text-muted);
}

.tool-input-form {
  display: grid;
  gap: 10px;
}

.tool-input-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.tool-input-label {
  font-size: var(--la-fs-2);
  color: var(--la-text);
}

.tool-input-control {
  width: 100%;
  min-height: var(--la-btn-h-sm);
  border-radius: var(--la-radius-sm);
  border: 1px solid var(--la-border);
  background: var(--la-surface);
  color: var(--la-text);
  font-size: var(--la-fs-2);
  padding: 0 var(--la-s-2);
}

.tool-input-control[multiple] {
  height: auto;
  min-height: 112px;
  padding: 6px 8px;
}

.tool-input-checkbox {
  width: 18px;
  height: 18px;
  accent-color: var(--la-accent);
}

.tool-input-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.tool-input-open-btn {
  align-self: flex-start;
}

.tool-summary-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: rgba(22, 163, 74, 0.2);
  color: #16a34a;
  font-size: 12px;
}

.tool-summary-meta {
  font-size: var(--la-fs-1);
  color: var(--la-text-soft);
  display: grid;
  gap: 2px;
}

@media (prefers-color-scheme: dark) {
  .tool-summary-card {
    background: rgba(59, 130, 246, 0.28);
    border: 1px solid rgba(59, 130, 246, 0.35);
  }
  .tool-summary-icon {
    background: rgba(34, 197, 94, 0.2);
    color: #22c55e;
  }
}

.table-preview {
  position: relative;
  overflow: visible;
  margin-top: 18px;
}

.table-preview.is-selectable tr.is-selected td {
  background: rgba(37, 99, 235, 0.16);
}

@media (prefers-color-scheme: dark) {
  .table-preview.is-selectable tr.is-selected td {
    background: rgba(37, 99, 235, 0.28);
  }
}

.table-preview-tools {
  position: sticky;
  top: 0;
  left: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px;
  background: var(--la-surface);
  border-bottom: 1px solid var(--la-border);
  z-index: 2;
}

.table-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--la-s-2);
  margin-bottom: 6px;
  font-size: 11px;
  color: var(--la-text-muted);
}

.table-row-count {
  font-size: 11px;
  color: var(--la-text-muted);
}

.table-load-all {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 10px;
  font-size: 11px;
  height: 28px;
}

.table-load-all svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.table-load-all.is-hidden {
  display: none;
}

.table-select-toggle {
  width: 22px;
  height: 22px;
  border-radius: var(--la-radius-pill);
  border: 1px solid var(--la-border);
  background: var(--la-surface);
  color: var(--la-text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}

.table-select-toggle svg {
  width: 12px;
  height: 12px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
}

.table-select-toggle.is-active {
  color: var(--la-accent-700);
  border-color: var(--la-accent-100);
}

.table-select-count {
  min-width: 16px;
  height: 16px;
  padding: 0 6px;
  border-radius: var(--la-radius-pill);
  background: var(--la-surface-2);
  color: var(--la-text-muted);
  font-size: 11px;
  line-height: 16px;
  text-align: center;
  border: 1px solid var(--la-border);
}

.table-select-count.is-hidden {
  display: none;
}
.tool-result.compact {
  margin-top: var(--la-s-1);
  padding: 6px 8px;
  font-size: var(--la-fs-1);
  max-height: min(50vh, 260px);
}

.tool-chart {
  display: flex;
  flex-direction: column;
  gap: var(--la-s-2);
  padding: var(--la-s-2);
  border: 1px dashed var(--la-border);
  border-radius: var(--la-radius-md);
  background: var(--la-surface);
  color: var(--la-text);
  width: 100%;
  position: relative;
}

.has-card-actions {
  position: relative;
}

.card-action-layer {
  position: absolute;
  top: 10px;
  right: 12px;
  z-index: 7;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: calc(100% - 24px);
}

.card-action-anchor {
  width: 28px;
  height: 28px;
  border: 1px solid color-mix(in srgb, var(--la-border) 88%, transparent);
  border-radius: 999px;
  background: color-mix(in srgb, var(--la-surface) 92%, transparent);
  color: var(--la-text-muted);
  opacity: 0.16;
  transition: opacity 120ms ease, transform 120ms ease, color 120ms ease, border-color 120ms ease;
}

.has-card-actions:hover .card-action-anchor,
.has-card-actions:focus-within .card-action-anchor,
.card-action-anchor:focus-visible {
  opacity: 0.92;
  color: var(--la-text);
  border-color: var(--la-border);
}

.card-action-anchor:hover {
  transform: translateY(-1px);
}

.card-open-anchor {
  max-width: min(160px, calc(100vw - 120px));
  height: 28px;
  padding: 0 10px;
  border: 1px solid color-mix(in srgb, var(--la-border) 88%, transparent);
  border-radius: 999px;
  background: color-mix(in srgb, var(--la-surface) 94%, transparent);
  color: var(--la-text-muted);
  font-size: var(--la-fs-1);
  line-height: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0.18;
  transition: opacity 120ms ease, transform 120ms ease, color 120ms ease, border-color 120ms ease, background 120ms ease;
}

.has-card-actions:hover .card-open-anchor,
.has-card-actions:focus-within .card-open-anchor,
.card-open-anchor:focus-visible {
  opacity: 0.94;
  color: var(--la-text);
  border-color: var(--la-border);
}

.card-open-anchor:hover {
  transform: translateY(-1px);
  background: color-mix(in srgb, var(--la-surface-2) 92%, transparent);
}

.card-action-menu {
  position: absolute;
  top: 34px;
  right: 0;
  min-width: 164px;
  display: none;
  padding: 6px;
  border: 1px solid var(--la-border);
  border-radius: var(--la-radius-md);
  background: var(--la-surface);
  box-shadow: var(--la-shadow-lg);
}

.card-action-menu.is-open {
  display: grid;
  gap: 4px;
}

.card-action-item {
  text-align: left;
  padding: 8px 10px;
  border-radius: var(--la-radius-sm);
  color: var(--la-text);
}

.card-action-item:hover,
.card-action-item:focus-visible {
  background: var(--la-surface-2);
  outline: none;
}

.card-action-item:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.has-card-actions .chart-hover-actions,
.has-card-actions .preview-copy,
.has-card-actions .tool-open-modal {
  display: none !important;
}

.chart-hover-actions {
  position: absolute;
  top: 6px;
  right: 6px;
  display: inline-flex;
  gap: 6px;
  opacity: 0;
  transform: translateY(-2px);
  transition: opacity 0.15s ease, transform 0.15s ease;
  z-index: 2;
}

.tool-chart:hover .chart-hover-actions,
.tool-chart:focus-within .chart-hover-actions {
  opacity: 1;
  transform: translateY(0);
}

.chart-hover-btn {
  border: 1px solid var(--la-border);
  border-radius: var(--la-radius-pill);
  background: var(--la-surface);
  color: var(--la-text);
  font-size: 11px;
  line-height: 1;
  padding: 6px 9px;
  cursor: pointer;
}

.chart-hover-btn:hover {
  background: var(--la-surface-2);
  border-color: rgba(59, 130, 246, 0.45);
}

.bubble-draggable {
  cursor: grab;
}

.bubble-draggable:active {
  cursor: grabbing;
}

@media (prefers-color-scheme: dark) {
  .bubble-error {
    border-color: rgba(239, 68, 68, 0.5);
    background: rgba(239, 68, 68, 0.12);
  }
  .error-box {
    background: rgba(239, 68, 68, 0.16);
    border-color: rgba(239, 68, 68, 0.35);
  }
  .error-hint {
    color: var(--la-text-soft);
  }
}

.result-chart {
  display: flex;
  flex-direction: column;
  gap: var(--la-s-2);
}

.result-chart-large .tool-chart {
  min-height: 760px;
}

.result-chart-large .tool-chart-echarts-host {
  min-height: 680px;
}

.chart-type-toggle {
  display: inline-flex;
  gap: var(--la-s-2);
  flex-wrap: wrap;
}

.chart-type-btn {
  padding: 4px 10px;
  border-radius: var(--la-radius-pill);
  border: 1px solid var(--la-border);
  background: var(--la-surface);
  font-size: var(--la-fs-2);
  color: var(--la-text);
}

.chart-type-btn.is-active {
  background: var(--la-accent);
  color: #fff;
  border-color: transparent;
}

.tool-chart-wrap .tool-chart {
  border-style: solid;
  border-color: var(--la-border-strong);
}

.result-chart .tool-chart svg {
  height: 260px;
}

.tool-chart svg {
  font-family: var(--la-font);
}

.chart-axis-line,
.chart-axis-tick {
  stroke: var(--la-border-strong);
}

.chart-axis-text {
  font-size: 11px;
  fill: var(--la-text-muted);
  letter-spacing: 0.2px;
}

.chart-axis-text.is-compact {
  font-size: 10px;
  letter-spacing: 0.2px;
}

.chart-value {
  font-size: calc(var(--la-fs-1) - 1px);
  font-weight: 600;
  fill: var(--la-text);
}

.chart-value.is-bar {
  font-size: 10px;
  font-weight: 700;
}

.tool-chart-title {
  font-size: var(--la-fs-2);
  font-weight: 600;
  color: var(--la-text);
}

.tool-chart-caption {
  font-size: var(--la-fs-1);
  color: var(--la-text-soft);
  text-align: center;
}

.tool-chart-unit {
  font-size: var(--la-fs-1);
  color: var(--la-text-muted);
  text-align: right;
}

.tool-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--la-fs-2);
}

.tool-table th {
  position: sticky;
  top: 0;
  background: var(--la-surface-2);
  text-align: left;
  padding: 4px 6px;
  border-bottom: 1px solid var(--la-border);
}

.tool-table th:hover {
  background: var(--la-surface);
}

.tool-table-sort {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: none;
  background: transparent;
  color: inherit;
  font: inherit;
  padding: 0;
  cursor: pointer;
}

.tool-table-sort .sort-icon {
  width: 12px;
  height: 12px;
  display: inline-block;
  opacity: 0.4;
}

.tool-table-sort.is-asc .sort-icon,
.tool-table-sort.is-desc .sort-icon {
  opacity: 0.9;
}

.tool-table-sort .sort-icon::before {
  content: "↕";
  font-size: 11px;
  line-height: 1;
}

.tool-table-sort.is-asc .sort-icon::before { content: "↑"; }
.tool-table-sort.is-desc .sort-icon::before { content: "↓"; }
.tool-table td {
  padding: 4px 6px;
  border-bottom: 1px solid var(--la-border);
}

.tool-table td.num,
.tool-table th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.tool-table tr:nth-child(even) td {
  background: rgba(15, 23, 42, 0.04);
}

.tool-note { font-size: 11px; color: var(--la-text-muted); margin-top: var(--la-s-1); }
.tool-analysis-bullets {
  margin: var(--la-s-2) 0;
  padding-left: 20px;
  font-size: var(--la-fs-2);
  line-height: 1.4;
}
.tool-analysis-bullets li {
  margin: 0 0 4px;
}
.tool-kv { display: grid; gap: var(--la-s-2); }
.tool-table + .tool-kv { margin-top: var(--la-s-3); }
.tool-kv-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--la-s-3); }
.tool-kv-key {
  font-weight: 600;
  font-size: var(--la-fs-2);
  line-height: 1.35;
}
.tool-kv-value {
  font-size: var(--la-fs-2);
  line-height: 1.35;
  font-variant-numeric: tabular-nums;
}
.tool-pre { white-space: pre-wrap; font-size: var(--la-fs-1); }

.btn-primary,
.btn-secondary,
.btn-ghost {
  height: var(--la-btn-h);
  padding: 0 var(--la-s-4);
  border-radius: var(--la-radius-pill);
  border: 1px solid transparent;
  font-size: var(--la-fs-3);
  cursor: pointer;
}

.btn-primary { background: var(--la-accent); color: #fff; }
.btn-secondary { background: var(--la-surface); border-color: var(--la-border); }
.btn-ghost { background: transparent; border-color: var(--la-border); }

.btn-primary:focus,
.btn-secondary:focus,
.btn-ghost:focus {
  outline: none;
  box-shadow: var(--la-focus);
}

@media (prefers-color-scheme: dark) {
  .btn-secondary,
  .btn-ghost {
    color: var(--la-text);
    border-color: var(--la-border-strong);
  }

  .btn-ghost:hover,
  .btn-secondary:hover {
    background: var(--la-surface-2);
  }
}

.context-panel {
  background: #fbfdff;
  border: 1px solid var(--la-border);
  border-radius: var(--la-radius-md);
  padding: 6px;
  box-shadow: var(--la-shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: var(--la-fs-2);
  height: 100%;
  max-height: 100%;
  overflow: hidden;
}

.context-header {
  display: flex;
  align-items: center;
  gap: var(--la-s-2);
  justify-content: space-between;
  padding: 2px 8px;
  margin: -6px -6px 0 -6px;
  border-radius: var(--la-radius-md) var(--la-radius-md) 0 0;
  background: var(--la-accent-100);
  border: 0;
  position: relative;
}

/* Keep the top "Käytössä olevat tiedot" header isolated from generic group-header resets */
.context-header.context-group-header,
.context-header.context-group-header.is-primary {
  margin: -6px -6px 0 -6px;
  padding: 2px 8px;
}

.context-title-row {
  width: auto;
  flex: 1 1 auto;
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: var(--la-s-2);
  padding-right: 28px;
}

.context-title {
  font-size: var(--la-fs-2);
  font-weight: 650;
  letter-spacing: 0.012em;
}

.context-count {
  font-size: var(--la-fs-2);
  font-weight: 650;
  color: inherit;
  letter-spacing: 0.012em;
}

.context-close {
  margin-left: auto;
}
.context-header .context-close.icon-only {
  width: 22px;
  height: 22px;
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  border: 1px solid color-mix(in srgb, var(--la-border) 70%, var(--la-accent) 30%);
  border-radius: var(--la-radius-pill);
  background: color-mix(in srgb, var(--la-surface) 88%, var(--la-accent-100) 12%);
  color: color-mix(in srgb, var(--la-text) 78%, var(--la-accent) 22%);
  opacity: 0;
  pointer-events: none;
  transition: border-color 0.14s ease, background-color 0.14s ease, color 0.14s ease, transform 0.12s ease, opacity 0.12s ease;
}
.context-header:hover .context-close.icon-only,
.context-header:focus-within .context-close.icon-only {
  opacity: 1;
  pointer-events: auto;
}
.context-header .context-close.icon-only:hover,
.context-header .context-close.icon-only:focus-visible {
  border-color: color-mix(in srgb, var(--la-accent) 58%, var(--la-border) 42%);
  background: color-mix(in srgb, var(--la-accent-100) 68%, var(--la-surface) 32%);
  color: var(--la-accent);
  transform: translateY(calc(-50% - 1px));
}
.context-header .context-close.icon-only svg {
  width: 12px;
  height: 12px;
}
.context-header .context-group-toggle {
  margin-right: 4px;
}

.context-header .context-group-actions {
  margin-left: auto;
}

@media (prefers-color-scheme: dark) {
  .context-header {
    background: rgba(37, 99, 235, 0.24);
    border-color: rgba(59, 130, 246, 0.35);
  }
  .context-header .context-close.icon-only {
    border-color: rgba(96, 165, 250, 0.36);
    background: rgba(15, 23, 42, 0.64);
    color: rgba(226, 232, 240, 0.86);
  }
  .context-header .context-close.icon-only:hover,
  .context-header .context-close.icon-only:focus-visible {
    border-color: rgba(96, 165, 250, 0.62);
    background: rgba(37, 99, 235, 0.26);
    color: #dbeafe;
  }
}

@media (max-width: 720px) {
  .context-header.context-group-header,
  .context-header.context-group-header.is-primary {
    padding: 3px 8px;
  }
  .context-header {
    min-height: 30px;
    padding: 3px 8px;
  }
  .context-title-row {
    align-items: center;
    line-height: 1.2;
    padding-right: 30px;
  }
  .context-header .context-group-toggle {
    margin-right: 6px;
    flex: 0 0 auto;
    align-self: center;
  }
  .context-header .context-close.icon-only {
    opacity: 1;
    pointer-events: auto;
  }
}

.context-selection {
  font-size: var(--la-fs-2);
  font-weight: 650;
  padding: 0;
  border-radius: 0;
  background: transparent;
  color: inherit;
  letter-spacing: 0.012em;
  white-space: nowrap;
}

.context-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  max-height: 100%;
  overflow: auto;
  overflow-x: hidden;
}

.context-list.is-hidden { display: none; }

.context-group-title {
  font-size: var(--la-fs-1);
  font-weight: 600;
  color: var(--la-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0;
}

.context-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.context-group.context-group-tools {
  margin-top: 4px;
  border: 0;
  border-radius: 0;
  background: transparent;
  overflow: visible;
}

.context-group-header {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0;
  margin: 0 -6px;
  position: relative;
}

.context-group-title {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: auto;
  margin: 0;
  padding: 2px 8px;
  border: 0;
  border-radius: 0;
  box-sizing: border-box;
  transition: background-color 0.14s ease, border-color 0.14s ease, color 0.14s ease;
  align-self: stretch;
}

.context-group-title.is-secondary {
  background: var(--la-surface-2);
  background: color-mix(in srgb, var(--la-accent-100) 52%, var(--la-surface) 48%);
  border: 0;
}

.context-group-title.is-primary {
  background: transparent;
  color: inherit;
  text-transform: none;
  font-size: var(--la-fs-2);
  font-weight: 650;
  letter-spacing: 0.012em;
  border-color: transparent;
  width: auto;
  margin: 0;
  padding: 0;
  border-width: 0;
}

.context-group-header.is-primary {
  margin: 4px -6px 0 -6px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: var(--la-accent-100);
  color: var(--la-text);
  gap: 0;
}

.context-group.context-group-tools .context-group-header.is-primary {
  margin: 0 -6px;
  border: 0;
  border-radius: 0;
  padding: 0;
  background: var(--la-accent-100);
}

.context-group.context-group-tools .context-group-title.is-primary {
  width: 100%;
  margin: 0;
  padding: 2px 8px;
  border: 0;
  border-radius: 0;
  box-sizing: border-box;
  align-self: stretch;
}

.context-group.context-group-tools .context-group-list {
  padding: 6px 0 0 0;
  overflow-x: hidden;
}

.context-group-header:hover .context-group-title.is-secondary {
  background: color-mix(in srgb, var(--la-accent-100) 62%, var(--la-surface) 38%);
}

.context-group-header:hover .context-group-title.is-primary {
  color: inherit;
}

.context-group-header.is-primary:hover {
  background: color-mix(in srgb, var(--la-accent-100) 84%, var(--la-accent) 16%);
}

.context-group-header.drop-target {
  cursor: copy;
  border-radius: 10px;
  transition: box-shadow 0.12s ease, background-color 0.12s ease;
}

.context-group-header.drop-target::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 10px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.12s ease, border-color 0.12s ease, background 0.12s ease;
}

.context-drop-hint {
  width: 100%;
  padding: 0 8px;
  font-size: 11px;
  line-height: 1.25;
  color: var(--la-text-muted);
  opacity: 0;
  max-height: 0;
  overflow: hidden;
  user-select: none;
  pointer-events: none;
  transition: opacity 0.12s ease, max-height 0.12s ease, padding 0.12s ease;
}

.context-group-header.drop-target.drag-over .context-drop-hint {
  color: var(--la-accent-700);
  opacity: 1;
  max-height: 40px;
  padding: 2px 8px 5px 8px;
}

.context-group-header.drop-target.drag-over {
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--la-accent) 72%, white 28%), 0 6px 18px rgba(37, 99, 235, 0.18);
}

.context-group-header.drop-target.drag-over::before {
  opacity: 1;
  border: 2px dashed color-mix(in srgb, var(--la-accent) 74%, white 26%);
  background: color-mix(in srgb, var(--la-accent-100) 78%, transparent 22%);
  animation: contextDropPulse 1.4s ease-in-out infinite;
}

.context-group-header.drop-target.drag-over .context-group-title.is-secondary {
  background: color-mix(in srgb, var(--la-accent-100) 78%, var(--la-accent) 22%);
}

.context-group-header.drop-target.drag-reject .context-group-title.is-secondary {
  background: color-mix(in srgb, #fca5a5 45%, var(--la-surface) 55%);
}

.context-group-header.drop-target.drag-reject .context-drop-hint {
  color: #b91c1c;
  opacity: 1;
  max-height: 40px;
  padding: 2px 8px 5px 8px;
}

.context-group-header.drop-target.drag-reject {
  box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.42);
}

.context-group-header.drop-target.drag-reject::before {
  opacity: 1;
  border: 2px dashed rgba(220, 38, 38, 0.62);
  background: rgba(248, 113, 113, 0.14);
}

@keyframes contextDropPulse {
  0% {
    background: color-mix(in srgb, var(--la-accent-100) 72%, transparent 28%);
  }
  50% {
    background: color-mix(in srgb, var(--la-accent-100) 86%, transparent 14%);
  }
  100% {
    background: color-mix(in srgb, var(--la-accent-100) 72%, transparent 28%);
  }
}

.context-group-count {
  font-size: var(--la-fs-1);
  color: var(--la-text-soft);
}

.context-group-actions {
  display: inline-flex;
  align-items: center;
  gap: var(--la-s-1);
  flex-wrap: wrap;
  width: 100%;
  justify-content: center;
}

.context-group-toggle {
  width: 22px;
  height: 22px;
  border-radius: var(--la-radius-pill);
  border: 1px solid var(--la-border);
  background: var(--la-surface);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--la-text-muted);
}

.context-toggle.icon-only,
.context-group-toggle.icon-only {
  width: 22px;
  height: 22px;
  border-radius: var(--la-radius-pill);
  border: 1px solid var(--la-border);
  background: var(--la-surface);
  color: var(--la-text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.14s ease, background-color 0.14s ease, color 0.14s ease, transform 0.12s ease;
}

.context-toggle.icon-only:hover,
.context-group-toggle.icon-only:hover {
  border-color: color-mix(in srgb, var(--la-border) 60%, var(--la-accent) 40%);
  background: var(--la-surface-2);
  color: var(--la-accent);
  transform: translateY(-1px);
}

.context-group-toggle svg {
  width: 12px;
  height: 12px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

@media (prefers-color-scheme: dark) {
  .context-header {
    border: 0;
  }

  .context-group-title.is-secondary {
    background: color-mix(in srgb, rgba(37, 99, 235, 0.22) 58%, rgba(15, 23, 42, 0.78) 42%);
    border: 0;
  }

  .context-group-title.is-primary {
    color: var(--la-text);
  }

  .context-group-header:hover .context-group-title.is-secondary {
    background: color-mix(in srgb, rgba(59, 130, 246, 0.30) 62%, rgba(15, 23, 42, 0.70) 38%);
  }

  .context-group-header.is-primary {
    background: rgba(37, 99, 235, 0.24);
    border-color: rgba(59, 130, 246, 0.35);
    color: var(--la-text);
  }

  .context-group.context-group-tools {
    border-color: transparent;
    background: transparent;
  }

  .context-group.context-group-tools .context-group-header.is-primary {
    background: rgba(37, 99, 235, 0.24);
    border: 0;
  }

  .context-group-header.is-primary:hover {
    background: rgba(37, 99, 235, 0.30);
  }

  .context-group-toggle {
    border-color: rgba(148, 163, 184, 0.35);
    background: rgba(15, 23, 42, 0.6);
    color: rgba(226, 232, 240, 0.75);
  }
  .context-group-toggle:hover {
    border-color: rgba(99, 102, 241, 0.6);
    color: rgba(255, 255, 255, 0.9);
  }

  .context-toggle.icon-only,
  .context-group-toggle.icon-only {
    border-color: rgba(148, 163, 184, 0.35);
    background: rgba(15, 23, 42, 0.6);
    color: rgba(226, 232, 240, 0.78);
  }

  .context-toggle.icon-only:hover,
  .context-group-toggle.icon-only:hover {
    border-color: rgba(99, 102, 241, 0.6);
    background: rgba(30, 41, 59, 0.72);
    color: rgba(255, 255, 255, 0.92);
  }
}

.context-group-list.is-collapsed {
  display: none;
}

.context-card {
  border: 1px solid var(--la-border);
  border-radius: var(--la-radius-md);
  padding: 6px 8px;
  display: flex;
  gap: 6px;
  background: #f8fafc;
  position: relative;
  transition: border-color 0.14s ease, background 0.14s ease, box-shadow 0.14s ease, transform 0.14s ease;
}

.context-body {
  min-width: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding-right: 28px;
}

.context-icon {
  width: 28px;
  height: 28px;
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(37, 99, 235, 0.12);
  color: var(--la-accent);
  margin-left: 0;
  margin-top: 0;
  flex: 0 0 auto;
  transition: background 0.14s ease, color 0.14s ease, box-shadow 0.14s ease;
}

.context-icon svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.context-icon[data-icon="chart"] {
  background: rgba(16, 185, 129, 0.14);
  color: #0f766e;
}
.context-icon[data-icon="calculation"] {
  background: rgba(99, 102, 241, 0.14);
  color: #4338ca;
}
.context-icon[data-icon="api"] {
  background: rgba(14, 165, 233, 0.14);
  color: #0369a1;
}
.context-icon[data-icon="merge"] {
  background: rgba(234, 88, 12, 0.14);
  color: #c2410c;
}
.context-icon[data-icon="transform"] {
  background: rgba(168, 85, 247, 0.14);
  color: #7e22ce;
}
.context-icon[data-icon="text"] {
  background: rgba(148, 163, 184, 0.2);
  color: #475569;
}

@media (prefers-color-scheme: dark) {
  .context-icon {
    background: rgba(59, 130, 246, 0.2);
    color: #93c5fd;
  }
  .context-icon[data-icon="chart"] {
    background: rgba(16, 185, 129, 0.2);
    color: #5eead4;
  }
  .context-icon[data-icon="calculation"] {
    background: rgba(99, 102, 241, 0.2);
    color: #c7d2fe;
  }
  .context-icon[data-icon="api"] {
    background: rgba(14, 165, 233, 0.2);
    color: #bae6fd;
  }
  .context-icon[data-icon="merge"] {
    background: rgba(249, 115, 22, 0.2);
    color: #fdba74;
  }
  .context-icon[data-icon="transform"] {
    background: rgba(168, 85, 247, 0.2);
    color: #e9d5ff;
  }
  .context-icon[data-icon="text"] {
    background: rgba(148, 163, 184, 0.2);
    color: #e2e8f0;
  }

  .context-card.is-active .context-icon {
    background: rgba(59, 130, 246, 0.3);
    color: #93c5fd;
    box-shadow: inset 0 0 0 1px rgba(96, 165, 250, 0.35);
  }
}

.context-card.is-active {
  border-color: var(--la-accent);
  background: color-mix(in srgb, var(--la-accent-100) 64%, var(--la-surface) 36%);
  box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.22), 0 3px 12px rgba(37, 99, 235, 0.12);
}

.context-card.is-active::before {
  content: none;
}

.context-card:hover {
  border-color: rgba(37, 99, 235, 0.55);
  background: rgba(37, 99, 235, 0.08);
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.12);
  transform: translateY(-1px);
}

.context-card.is-active .context-icon {
  background: rgba(37, 99, 235, 0.2);
  color: #1d4ed8;
  box-shadow: inset 0 0 0 1px rgba(37, 99, 235, 0.24);
}

.context-panel.selection-locked .context-card.is-inactive {
  opacity: 0.6;
}

  .context-actions { display: flex; flex-wrap: wrap; gap: var(--la-s-1); }
  .context-label-row {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: var(--la-s-2);
  }
  .context-meta-row {
    display: flex;
    align-items: baseline;
    gap: 6px;
    min-width: 0;
  }
  .context-label {
    font-weight: 650;
    font-size: 0.9rem;
    line-height: 1.15;
    letter-spacing: 0.002em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .context-label-input {
    min-width: 0;
    width: min(100%, 240px);
    height: 30px;
    padding: 4px 10px;
    font-size: 0.88rem;
  }
  .context-open-icon {
    width: 24px;
    height: 24px;
    border-radius: 6px;
    border: 1px solid var(--la-border);
    background: var(--la-surface);
    color: var(--la-text);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
  }
  .context-open-icon { display: none; }
  .context-open-icon svg {
    width: 14px;
    height: 14px;
    fill: currentColor;
  }
  .context-open-icon:hover {
    background: var(--la-surface-2);
  }
  .context-meta {
    font-size: 10px;
    color: var(--la-text-muted);
    line-height: 1.15;
    font-variant-numeric: tabular-nums;
  }
  .context-status {
    font-size: 10px;
    color: var(--la-text-soft);
    line-height: 1.15;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
  }
  .context-meta-row .context-status::before {
    content: "•";
    margin-right: 6px;
    color: var(--la-text-muted);
  }
  .context-status.active {
    color: var(--la-accent-700);
    font-weight: 600;
  }
  .context-status-icon {
    width: 16px;
    height: 16px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--la-border);
    color: var(--la-text-muted);
    background: var(--la-surface);
    flex: 0 0 auto;
  }
  .context-status-icon svg {
    width: 11px;
    height: 11px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2.2;
    stroke-linecap: round;
    stroke-linejoin: round;
  }
  .context-status-icon.active {
    border-color: rgba(16, 185, 129, 0.45);
    color: #047857;
    background: rgba(16, 185, 129, 0.12);
  }
  .context-card-tools {
    padding: 5px 7px;
    gap: 5px;
  }
  .context-card-tools.is-clickable {
    cursor: pointer;
  }
  .context-card-tools .context-body {
    min-width: 0;
    width: 100%;
  }
  .context-card-tools .context-label {
    font-size: 11px;
    font-weight: 600;
    line-height: 1.2;
  }
  .context-card-tools .context-meta {
    font-size: 10px;
    line-height: 1.2;
    margin-top: 1px;
  }
  .context-card-tools .context-label-row {
    gap: 4px;
    align-items: center;
  }
  .context-card-tools .context-status-icon {
    width: 14px;
    height: 14px;
  }
  .context-tool-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 4px;
  }
  .context-tool-actions .btn-ghost {
    height: 22px;
    padding: 0 8px;
    font-size: 11px;
  }
  .tool-context-form {
    display: grid;
    gap: 8px;
  }
  .tool-context-intro {
    font-size: 12px;
    line-height: 1.35;
    color: var(--la-text-soft);
    margin-bottom: 2px;
  }
  .tool-context-field {
    font-size: 12px;
    color: var(--la-text);
    font-weight: 600;
  }
  .tool-context-help {
    font-size: 11px;
    line-height: 1.3;
    color: var(--la-text-muted);
    margin-top: -4px;
  }
  .tool-context-input {
    width: 100%;
    min-height: 30px;
    border: 1px solid var(--la-border);
    border-radius: 8px;
    padding: 6px 8px;
    background: var(--la-surface);
    color: var(--la-text);
  }
  .context-time {
    font-size: 12px;
    color: var(--la-text-soft);
  }
.context-btn { border: 1px solid var(--la-border); border-radius: var(--la-radius-pill); background: var(--la-surface); padding: 3px 8px; font-size: var(--la-fs-1); cursor: pointer; }
.context-btn.primary { background: var(--la-accent); color: #fff; border-color: transparent; }
.context-btn.icon-only {
  width: 30px;
  height: 28px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.context-btn.icon-only svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.context-btn.icon-only:hover {
  background: var(--la-surface-2);
  color: var(--la-accent);
}
.context-btn:disabled,
.context-btn.icon-only:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  color: var(--la-text-muted);
}
@media (prefers-color-scheme: dark) {
  .context-btn.icon-only:hover {
    background: rgba(148, 163, 184, 0.2);
    color: #dbeafe;
  }
  .context-btn:disabled,
  .context-btn.icon-only:disabled {
    color: rgba(148, 163, 184, 0.7);
    background: rgba(15, 23, 42, 0.55);
  }
}

.context-remove {
  border: 1px solid var(--la-border);
  border-radius: var(--la-radius-pill);
  background: var(--la-surface);
  width: 24px;
  height: 24px;
  padding: 0;
  cursor: pointer;
  color: var(--la-text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.15s ease, background-color 0.14s ease, color 0.14s ease, border-color 0.14s ease;
  position: absolute;
  top: 50%;
  right: 34px;
  transform: translateY(-50%) scale(0.96);
  z-index: 4;
  pointer-events: none;
}

.context-remove svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.context-card:hover .context-remove {
  opacity: 1;
  transform: translateY(-50%) scale(1);
  pointer-events: auto;
}

.context-remove:hover {
  color: #dc2626;
  border-color: rgba(220, 38, 38, 0.4);
  background: rgba(220, 38, 38, 0.08);
}

.context-pin {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 22px;
  height: 22px;
  border: 0;
  background: transparent;
  padding: 0;
  font-size: 20px;
  cursor: pointer;
  color: var(--la-text-soft);
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  z-index: 3;
  opacity: 0.9;
}

.context-pin.active {
  color: #fbbf24;
  opacity: 1;
  text-shadow: 0 0 8px rgba(251, 191, 36, 0.35);
}

@media (prefers-color-scheme: dark) {
  .context-pin.active {
    color: #fbbf24;
  }
}

  .context-select {
    position: absolute;
    top: 8px;
    left: 8px;
    width: 28px;
    height: 28px;
  border-radius: 9px;
  border: none;
  background: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: transparent;
  z-index: 2;
}
.context-select svg {
  display: none;
}
.context-select.is-active {
  background: transparent;
  box-shadow: none;
}

@media (prefers-color-scheme: dark) {
  .context-select {
    color: transparent;
    border-color: transparent;
    background: transparent;
  }
  .context-select.is-active {
    background: transparent;
    box-shadow: none;
  }
}

.context-only {
  position: absolute;
  top: calc(50% + 16px);
  right: 34px;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  border: 1px solid var(--la-border);
  background: var(--la-surface);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--la-text-soft);
  opacity: 0;
  transform: translateY(-50%) scale(0.92);
  transition: opacity 0.15s ease, transform 0.14s ease, background-color 0.14s ease, border-color 0.14s ease, color 0.14s ease;
  z-index: 2;
  pointer-events: none;
}
.context-only svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
}
.context-card:hover .context-only {
  opacity: 1;
  transform: translateY(-50%) scale(1);
  pointer-events: auto;
}
.context-only:hover,
.context-only:focus-visible {
  border-color: rgba(37, 99, 235, 0.55);
  background: rgba(37, 99, 235, 0.12);
  color: var(--la-accent);
  outline: none;
}
.context-only::after {
  content: attr(title);
  position: absolute;
  right: 28px;
  top: 50%;
  transform: translateY(-50%);
  white-space: nowrap;
  font-size: 11px;
  line-height: 1.15;
  color: var(--la-text);
  background: var(--la-surface);
  border: 1px solid var(--la-border);
  border-radius: 999px;
  padding: 3px 8px;
  box-shadow: var(--la-shadow-sm);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s ease;
}
.context-only:hover::after,
.context-only:focus-visible::after {
  opacity: 1;
}

.context-rail {
  margin-top: var(--la-s-2);
  display: flex;
  justify-content: flex-end;
}

.context-rail-btn {
  border: 1px solid var(--la-border);
  border-radius: var(--la-radius-pill);
  background: var(--la-surface);
  padding: 4px 8px;
  font-size: var(--la-fs-1);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.context-rail-btn.icon-only {
  width: 28px;
  height: 28px;
  padding: 0;
}

.context-rail-btn svg {
  width: 14px;
  height: 14px;
}

.context-panel.collapsed .context-list-data {
  display: none;
}

.context-panel.is-hidden {
  display: none;
}

.artifact-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--la-s-2);
  margin-bottom: var(--la-s-1);
}
.artifact-header.drag-over {
  background: color-mix(in srgb, var(--la-accent) 10%, transparent);
  border-radius: 10px;
  outline: 1px dashed color-mix(in srgb, var(--la-accent) 55%, #7aa2ff);
}

.artifact-title { font-size: var(--la-fs-2); font-weight: 600; }
.artifact-title .results-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  margin-right: 6px;
  border-radius: 6px;
  border: 1px solid var(--la-border);
  background: var(--la-surface-2);
  font-size: 12px;
  color: var(--la-text-muted);
}
.results-panel-card.is-collapsed .artifact-title .results-icon {
  width: 16px;
  height: 16px;
  font-size: 11px;
}
.artifact-title .results-title-text { vertical-align: middle; }

.artifact-toggle {
  border: 1px solid var(--la-border);
  border-radius: var(--la-radius-pill);
  background: var(--la-surface);
  padding: 3px 8px;
  font-size: var(--la-fs-1);
  cursor: pointer;
}

.artifact-toggle.icon-only {
  padding: 2px 6px;
  min-width: 28px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

#suggestionPanel.results-panel {
  position: relative;
  z-index: 5;
  margin-bottom: 0;
}

.results-panel-card {
  background: rgba(248, 250, 252, 0.95);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--la-border-strong);
  border-radius: var(--la-radius-lg);
  box-shadow: var(--la-shadow-sm);
  padding: 10px;
}

.results-panel-card.is-collapsed {
  padding: 0 6px;
  min-height: 26px;
  max-height: 28px;
  overflow: hidden;
  border-radius: var(--la-radius-pill);
  box-shadow: var(--la-shadow-sm);
}

.results-panel-card.is-collapsed .artifact-header {
  margin-bottom: 0;
  align-items: center;
  height: 26px;
}

.results-panel-card.is-collapsed .artifact-title {
  font-size: var(--la-fs-1);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  line-height: 1;
  white-space: nowrap;
}

#suggestionPanel.results-panel .results-panel-card.is-collapsed {
  margin-bottom: 0;
}

.artifact-list { display: flex; flex-direction: column; gap: var(--la-s-1); }
.artifact-list.is-hidden { display: none; }

.artifact-card {
  border: 1px solid var(--la-border);
  border-radius: var(--la-radius-md);
  padding: 8px 10px;
  background: var(--la-surface);
  box-shadow: var(--la-shadow-sm);
  display: flex;
  flex-direction: column;
  gap: var(--la-s-1);
}

.artifact-card .tool-result {
  max-height: min(72vh, 560px);
}

.artifact-card .table-preview {
  max-height: min(72vh, 760px);
}

.artifact-card .text-preview.is-compact {
  max-height: min(56vh, 460px);
}

.artifact-card.artifact-draggable {
  cursor: grab;
}

.artifact-card.artifact-draggable:active {
  cursor: grabbing;
}

.artifact-name { font-weight: 600; font-size: var(--la-fs-2); }
.artifact-meta { font-size: var(--la-fs-1); color: var(--la-text-muted); }

.artifact-actions { display: flex; flex-wrap: wrap; gap: var(--la-s-1); }
.artifact-btn {
  border: 1px solid var(--la-border);
  border-radius: var(--la-radius-pill);
  background: var(--la-surface);
  padding: 4px 10px;
  font-size: var(--la-fs-1);
  cursor: pointer;
}
.artifact-btn.primary { background: var(--la-accent); color: #fff; border-color: transparent; }

.artifact-quick-actions { display: flex; flex-wrap: wrap; gap: var(--la-s-1); }
.artifact-quick-btn {
  border: 1px solid var(--la-border);
  border-radius: var(--la-radius-pill);
  background: var(--la-surface-2);
  padding: 3px 8px;
  font-size: var(--la-fs-1);
  cursor: pointer;
}

.artifact-quick-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.table-preview {
  max-height: min(60vh, 640px);
  overflow: auto;
  border: 1px solid var(--la-border);
  border-radius: var(--la-radius-md);
  position: relative;
}

.table-preview-footer {
  display: flex;
  justify-content: flex-end;
  padding: 4px 8px;
  border-top: 1px solid var(--la-border);
  background: var(--la-surface);
}

.table-preview-footer .btn-ghost {
  padding: 2px 8px;
  font-size: var(--la-fs-1);
}

.table-preview table { width: 100%; border-collapse: collapse; min-width: 520px; font-size: var(--la-fs-2); }

.table-preview tbody tr:nth-child(even) {
  background: rgba(15, 23, 42, 0.04);
}

.preview-copy {
  position: absolute;
  top: 6px;
  right: 6px;
  border: 1px solid var(--la-border);
  border-radius: var(--la-radius-pill);
  background: var(--la-surface);
  width: 26px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: var(--la-text-muted);
  opacity: 0;
  cursor: pointer;
  transition: opacity 0.15s ease;
}

.table-preview:hover .preview-copy {
  opacity: 1;
}
.table-preview th {
  position: sticky;
  top: 0;
  background: var(--la-surface-2);
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--la-border);
}

.table-preview th:hover {
  background: var(--la-surface);
}

.table-preview .row-actions-header {
  width: 28px;
  min-width: 28px;
  padding: 0;
}

.table-preview .row-actions-cell {
  width: 28px;
  min-width: 28px;
  padding: 0;
  text-align: center;
  position: relative;
}

.table-col-delete,
.table-row-delete {
  border: 1px solid var(--la-border);
  border-radius: var(--la-radius-pill);
  background: var(--la-surface);
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--la-text-muted);
  opacity: 0;
  transition: opacity 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.table-col-delete svg,
.table-row-delete svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
}

.table-preview th:hover .table-col-delete,
.table-preview tr:hover .table-row-delete {
  opacity: 1;
}

.table-save-btn {
  border: 1px solid var(--la-border);
  border-radius: var(--la-radius-pill);
  background: var(--la-surface);
  padding: 2px 8px;
  font-size: 11px;
  line-height: 1.4;
  color: var(--la-text-muted);
  opacity: 0.85;
  transition: opacity 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.table-save-btn svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
}

.table-save-btn.is-hidden {
  display: none;
}

.table-save-btn:hover {
  color: var(--la-text);
  background: var(--la-surface-2);
  opacity: 1;
}

.table-col-delete:hover,
.table-row-delete:hover {
  color: var(--la-danger);
  background: var(--la-surface-2);
}

.table-preview td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--la-border);
}

.table-preview tr:nth-child(even) td { background: var(--la-surface-2); }
.table-preview.is-modal { max-height: 70vh; }

.result-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: var(--la-s-2);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--la-s-2);
}

.chart-placeholder {
  border: 1px dashed var(--la-border);
  border-radius: var(--la-radius-md);
  padding: var(--la-s-4);
  min-height: 180px;
  text-align: center;
  color: var(--la-accent);
  font-size: var(--la-fs-2);
  background: var(--la-surface-2);
}

.chart-caption {
  margin-top: var(--la-s-2);
  font-size: var(--la-fs-1);
  color: var(--la-text-soft);
  text-align: center;
}

.suggestion-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--la-s-2);
  margin-bottom: var(--la-s-3);
}

.suggestion-chip {
  border: 1px solid var(--la-border);
  border-radius: var(--la-radius-pill);
  background: var(--la-surface);
  padding: 6px 12px;
  font-size: var(--la-fs-2);
  cursor: pointer;
}

#copyToast {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  z-index: 300;
  pointer-events: none;
  opacity: 0;
}

#copyToast.open { opacity: 1; }

.toast {
  background: var(--la-surface);
  border: 1px solid var(--la-border);
  border-radius: var(--la-radius-pill);
  box-shadow: var(--la-shadow-md);
  padding: 8px 14px;
  font-size: var(--la-fs-2);
  color: var(--la-text);
}

.toast[data-level="error"] { border-color: var(--la-danger); color: var(--la-danger); }
.toast[data-level="warning"] { border-color: var(--la-warning); color: var(--la-warning); }
.toast[data-level="success"] { border-color: var(--la-success); color: var(--la-success); }

.context-close {
  background: transparent;
  border: none;
  color: var(--la-text);
  border-radius: var(--la-radius-pill);
  padding: 2px 10px;
  font-size: var(--la-fs-2);
  cursor: pointer;
}
.context-toggle.icon-only,
.context-close.icon-only {
  width: 22px;
  height: 22px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.context-toggle.icon-only svg,
.context-close.icon-only svg {
  width: 12px;
  height: 12px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.25);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

.backdrop.open { display: flex; }

.backdrop.result-backdrop {
  background: rgba(0, 0, 0, 0.2);
}

.modal {
  background: var(--la-surface);
  border-radius: var(--la-radius-md);
  width: min(92vw, 1200px);
  max-height: 80vh;
  overflow: auto;
  border: 1px solid var(--la-border);
  box-shadow: var(--la-shadow-md);
  padding: var(--la-s-4);
}

.modal-wide { width: min(92vw, 1200px); }
.modal-small { width: min(92vw, 420px); }

.save-edits-modal .modal-body {
  padding-top: var(--la-s-2);
}

.save-edits-text {
  font-size: var(--la-fs-3);
  color: var(--la-text);
  margin: 0;
}

.save-edits-actions {
  margin-top: var(--la-s-3);
}

.combine-body {
  display: flex;
  flex-direction: column;
  gap: var(--la-s-3);
}

.combine-mode {
  display: flex;
  flex-wrap: wrap;
  gap: var(--la-s-2);
}

.combine-option {
  display: inline-flex;
  align-items: center;
  gap: var(--la-s-2);
  padding: var(--la-s-2) var(--la-s-3);
  border: 1px solid var(--la-border);
  border-radius: var(--la-radius-md);
  background: var(--la-surface-2);
  font-size: var(--la-fs-2);
}

.combine-join-options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--la-s-3);
}

.combine-join-options.is-hidden { display: none; }

.combine-field label {
  display: block;
  font-size: var(--la-fs-2);
  color: var(--la-text-muted);
  margin-bottom: var(--la-s-1);
}

.combine-select {
  width: 100%;
  height: var(--la-btn-h-sm);
  border-radius: var(--la-radius-sm);
  border: 1px solid var(--la-border);
  background: var(--la-surface);
  color: var(--la-text);
  font-size: var(--la-fs-2);
  padding: 0 var(--la-s-2);
}

.series-body {
  display: flex;
  flex-direction: column;
  gap: var(--la-s-3);
}

.series-fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--la-s-3);
}

.series-field {
  display: flex;
  flex-direction: column;
  gap: var(--la-s-1);
}

.series-label {
  font-size: var(--la-fs-2);
  color: var(--la-text-muted);
}

.series-select,
.series-input {
  width: 100%;
  height: var(--la-btn-h-sm);
  border-radius: var(--la-radius-sm);
  border: 1px solid var(--la-border);
  background: var(--la-surface);
  color: var(--la-text);
  font-size: var(--la-fs-2);
  padding: 0 var(--la-s-2);
}

.series-select[multiple] {
  height: auto;
  min-height: 120px;
  padding: 6px 8px;
}

.series-note {
  font-size: var(--la-fs-2);
  color: var(--la-text-muted);
}

.series-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--la-s-2);
  justify-content: flex-end;
}

.cumulative-series-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--la-s-2);
}

.cumulative-series-list {
  display: flex;
  flex-direction: column;
  gap: var(--la-s-3);
}

.cumulative-series-card {
  border: 1px solid var(--la-border);
  border-radius: var(--la-radius-md);
  background: color-mix(in srgb, var(--la-surface) 88%, var(--la-bg) 12%);
  padding: var(--la-s-3);
  display: flex;
  flex-direction: column;
  gap: var(--la-s-2);
}

.cumulative-series-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--la-s-2);
}

.cumulative-series-card-title {
  font-size: var(--la-fs-3);
  font-weight: 600;
  color: var(--la-text);
}

.cumulative-series-card-actions {
  display: inline-flex;
  align-items: center;
  gap: var(--la-s-2);
}

.cumulative-series-fields {
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}

.cumulative-series-preview {
  border-top: 1px dashed var(--la-border);
  padding-top: var(--la-s-2);
}

.cumulative-preview-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--la-fs-2);
}

.cumulative-preview-table th,
.cumulative-preview-table td {
  text-align: left;
  padding: 6px 8px;
  border-bottom: 1px solid var(--la-border);
  vertical-align: top;
}

.cumulative-preview-table th {
  color: var(--la-text-muted);
  font-weight: 600;
}

.cumulative-modal {
  width: min(95vw, 1180px);
}

.cumulative-modal .modal-body {
  gap: var(--la-s-2);
}

.cumulative-modal .series-fields {
  gap: var(--la-s-2);
}

.cumulative-modal .cumulative-series-fields {
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}

.cumulative-modal .cumulative-series-card {
  padding: 0;
  gap: 8px;
  overflow: hidden;
}

.cumulative-modal .cumulative-series-card-head {
  gap: 10px;
  padding: 8px 10px;
  background: linear-gradient(180deg, rgba(96, 165, 250, 0.20), rgba(96, 165, 250, 0.10));
  border-bottom: 1px solid rgba(96, 165, 250, 0.22);
}

.cumulative-modal .cumulative-series-card-title {
  font-size: var(--la-fs-2);
  line-height: 1.2;
}

.cumulative-modal .series-label,
.cumulative-modal .series-note {
  font-size: var(--la-fs-1);
}

.cumulative-modal .series-select,
.cumulative-modal .series-input {
  height: 28px;
  font-size: var(--la-fs-1);
  padding: 0 8px;
}

.cumulative-modal .visualize-filters {
  gap: 6px;
  padding: 8px 10px;
}

.cumulative-modal .visualize-filter-row {
  grid-template-columns: minmax(120px, 1.1fr) minmax(110px, 0.9fr) minmax(120px, 1.1fr) 30px;
  gap: 8px;
}

.cumulative-modal .btn-secondary,
.cumulative-modal .btn-ghost {
  min-height: 27px;
  padding: 4px 8px;
  font-size: var(--la-fs-1);
}

.cumulative-modal .btn-primary {
  min-height: 30px;
  padding: 5px 12px;
  font-size: var(--la-fs-1);
}

.cumulative-modal .cumulative-series-card > .series-fields,
.cumulative-modal .cumulative-series-card > .series-note,
.cumulative-modal .cumulative-series-card > .visualize-filters,
.cumulative-modal .cumulative-series-card > .cumulative-series-preview {
  margin-left: 10px;
  margin-right: 10px;
}

.cumulative-modal .cumulative-series-card > .cumulative-series-preview {
  margin-bottom: 10px;
}

.visualize-modal {
  width: min(94vw, 1040px);
}

.visualize-body {
  gap: var(--la-s-3);
}

.visualize-title {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.visualize-mode-row {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.visualize-fields {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.visualize-presets {
  margin-bottom: 0;
}

.visualize-presets .suggestion-chip.active {
  border-color: color-mix(in srgb, var(--la-accent) 55%, var(--la-border));
  background: color-mix(in srgb, var(--la-accent) 14%, var(--la-surface));
  color: var(--la-accent);
  box-shadow: var(--la-shadow-sm);
}

.visualize-hint {
  padding: 10px 12px;
  border: 1px solid var(--la-border);
  border-radius: var(--la-radius-md);
  background: var(--la-surface-2);
}

.visualize-modal .series-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.field-help-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--la-accent) 30%, var(--la-border));
  background: color-mix(in srgb, var(--la-accent) 10%, var(--la-surface));
  color: var(--la-accent);
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  cursor: help;
  user-select: none;
  transition: transform 120ms ease, background 120ms ease, border-color 120ms ease;
}

.field-help-badge:hover,
.field-help-badge:focus-visible {
  transform: translateY(-1px);
  background: color-mix(in srgb, var(--la-accent) 16%, var(--la-surface));
  border-color: color-mix(in srgb, var(--la-accent) 55%, var(--la-border));
  outline: none;
}

.visualize-title-help {
  width: 20px;
  height: 20px;
  font-size: 12px;
}

.visualize-checkbox {
  width: 18px;
  height: 18px;
  accent-color: var(--la-accent);
}

.visualize-checkbox-label {
  justify-content: space-between;
}


.visualize-filters {
  display: grid;
  gap: var(--la-s-2);
  padding: 10px 12px;
  border: 1px solid var(--la-border);
  border-radius: var(--la-radius-md);
  background: var(--la-surface);
}

.visualize-filters.is-hidden {
  display: none;
}

.visualize-filter-title {
  color: var(--la-text);
  font-weight: 600;
}

.visualize-filter-rows {
  display: grid;
  gap: var(--la-s-2);
}

.visualize-filter-row {
  display: grid;
  grid-template-columns: minmax(140px, 1.2fr) minmax(120px, 1fr) minmax(140px, 1.2fr) 32px;
  gap: var(--la-s-2);
  align-items: center;
}

.visualize-filter-actions {
  display: flex;
  justify-content: flex-start;
}

.visualize-preview {
  display: grid;
  gap: var(--la-s-2);
  padding: 10px 12px;
  border: 1px solid var(--la-border);
  border-radius: var(--la-radius-md);
  background: var(--la-surface);
}

.visualize-preview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--la-s-2);
  flex-wrap: wrap;
}

.visualize-preview-toggle {
  font-weight: 600;
}

.visualize-preview-meta {
  font-size: var(--la-fs-2);
  color: var(--la-text-muted);
}

.visualize-preview-body {
  display: grid;
  gap: var(--la-s-2);
}

.visualize-preview-body.is-hidden {
  display: none;
}

.visualize-preview-table {
  max-height: 260px;
  overflow: auto;
}

.visualize-preview-more.is-hidden {
  display: none;
}

.series-input.is-hidden {
  display: none;
}

.series-field.is-hidden,
.visualize-fields .is-hidden {
  display: none;
}

.context-modal .context-panel {
  border: none;
  box-shadow: none;
  padding: 0;
  background: transparent;
  height: auto;
  max-height: none;
  min-height: 0;
  overflow: visible;
}

.context-modal .context-list {
  max-height: none;
  min-height: 0;
  overflow: visible;
}

.context-modal {
  width: min(92vw, 420px);
  height: calc(100vh - (var(--la-s-3) * 2));
  max-height: calc(100vh - (var(--la-s-3) * 2));
  padding: var(--la-s-2);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.context-modal .modal-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: 0;
}

.context-modal .context-group.context-group-tools .context-group-header.is-primary {
  position: sticky;
  top: 0;
  z-index: 3;
}

.result-modal {
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
  padding: var(--la-s-2);
  box-shadow: 0 28px 80px rgba(15, 23, 42, 0.25), 0 12px 32px rgba(15, 23, 42, 0.18);
  max-height: 94vh;
  width: min(97vw, 1520px);
}

.result-modal .modal-title {
  font-size: var(--la-fs-3);
}

.result-modal .modal-body {
  font-size: var(--la-fs-1);
  gap: var(--la-s-2);
  max-height: calc(94vh - 88px);
  overflow: auto;
}

.result-modal .tool-result {
  margin-top: var(--la-s-1);
  max-height: none;
}

.result-modal .modal-table .table-preview {
  max-height: 52vh;
}

.result-modal .modal-text {
  width: 100%;
}

.text-preview {
  border: 1px solid var(--la-border);
  border-radius: 14px;
  padding: 16px 18px;
  background: #fff;
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.04);
  max-height: 52vh;
  overflow: auto;
}

.text-preview.is-compact {
  max-height: 220px;
}

.text-preview-paragraph {
  margin: 0 0 10px 0;
  line-height: 1.58;
  color: var(--la-text);
}

.text-preview-heading {
  margin: 12px 0 8px 0;
  padding-bottom: 4px;
  font-size: var(--la-fs-2);
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--la-text);
  border-bottom: 1px solid var(--la-border);
}

.text-preview-heading.h1 { font-size: var(--la-fs-4); }
.text-preview-heading.h2 { font-size: var(--la-fs-3); }
.text-preview-heading.h3 { font-size: var(--la-fs-2); }
.text-preview-heading.h4,
.text-preview-heading.h5,
.text-preview-heading.h6 { font-size: var(--la-fs-1); }

.text-preview-divider {
  border: 0;
  border-top: 1px solid var(--la-border);
  margin: 10px 0 12px 0;
}

.text-preview-line {
  margin: 0 0 8px 0;
  padding-left: 14px;
  line-height: 1.45;
  color: var(--la-text);
  position: relative;
}

.text-preview-line::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.68em;
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--la-accent) 45%, #64748b);
}

.text-preview-more {
  font-size: var(--la-fs-1);
  color: var(--la-text-muted);
  text-align: right;
}

.text-preview-table {
  width: 100%;
  border-collapse: collapse;
  margin: 8px 0 12px 0;
  font-size: var(--la-fs-2);
  color: var(--la-text);
}

.text-preview-table th,
.text-preview-table td {
  border: 1px solid var(--la-border);
  padding: 6px 8px;
  text-align: left;
  vertical-align: top;
}

.text-preview-table th {
  background: var(--la-surface-2);
  font-weight: 600;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--la-s-3);
  position: sticky;
  top: 0;
  background: var(--la-surface);
  padding-bottom: var(--la-s-1);
  z-index: 1;
}

.modal-title { font-size: var(--la-fs-5); font-weight: 600; }

.modal-header .icon-btn:hover {
  background: var(--la-surface-2);
}

.modal-table { margin-top: var(--la-s-3); }
.modal-empty { color: var(--la-text-muted); margin-top: var(--la-s-3); font-size: var(--la-fs-2); }
.modal-note { color: var(--la-text-muted); margin-top: var(--la-s-2); font-size: var(--la-fs-2); }

.lang-list {
  display: flex;
  flex-direction: column;
  gap: var(--la-s-2);
}

.lang-option {
  border: 1px solid var(--la-border);
  border-radius: var(--la-radius-md);
  padding: var(--la-s-3);
  background: var(--la-surface);
  text-align: left;
  font-size: var(--la-fs-3);
  cursor: pointer;
}

.lang-option.active {
  border-color: var(--la-accent);
  background: var(--la-accent-100);
  color: var(--la-accent-700);
}

.lang-option:hover { background: var(--la-surface-2); }

.lang-hint {
  margin-top: var(--la-s-3);
  font-size: var(--la-fs-2);
  color: var(--la-text-muted);
}

@media (prefers-color-scheme: dark) {
  .lang-option {
    background: var(--la-surface);
    border-color: var(--la-border-strong);
    color: var(--la-text);
  }

  .lang-option.active {
    background: rgba(37, 99, 235, 0.2);
    color: var(--la-text);
    border-color: rgba(37, 99, 235, 0.45);
  }

  .lang-option:hover {
    background: var(--la-surface-2);
  }

  .lang-hint {
    color: var(--la-text-muted);
  }
}

.text-input-area { margin-top: 0; }

.composer {
  display: flex;
  gap: var(--la-s-2);
  align-items: center;
  padding: var(--la-s-2) var(--la-s-3);
  border-radius: var(--la-radius-lg);
  background: var(--la-surface);
  border: 1px solid var(--la-border);
  position: relative;
}

#textInput {
  flex: 1 1 auto;
  resize: none;
  border: none;
  background: transparent;
  font-family: var(--la-font);
  font-size: var(--la-fs-3);
  line-height: var(--la-lh-2);
  color: var(--la-text);
  min-height: 40px;
  scrollbar-width: none;
}

#textInput:focus { outline: none; }

#textInput::-webkit-scrollbar {
  width: 0;
  height: 0;
}

.send-btn,
.mic-btn,
.tts-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--la-radius-pill);
  border: 1px solid var(--la-border);
  background: var(--la-surface);
  color: var(--la-text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.send-btn {
  background: var(--la-accent);
  color: #fff;
  border-color: transparent;
}

.tts-btn {
  width: 34px;
  height: 34px;
  font-size: var(--la-fs-1);
  font-weight: 600;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  opacity: 0.65;
}

.tts-btn.active {
  opacity: 1;
  color: #fff;
  background: var(--la-accent);
  border-color: transparent;
}

.tts-btn,
#ttsToggle,
#sendBtn,
#startRec,
.tts-menu,
.tts-menu-panel,
.tts-menu-btn,
.tts-menu-button,
.send-btn,
.mic-btn {
  display: none !important;
}

.tts-menu {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.tts-menu-panel {
  position: absolute;
  right: 0;
  bottom: calc(100% + var(--la-s-2));
  display: none;
  gap: var(--la-s-2);
  padding: var(--la-s-2);
  background: var(--la-surface);
  border: 1px solid var(--la-border);
  border-radius: var(--la-radius-md);
  box-shadow: var(--la-shadow-md);
  z-index: 40;
}

.tts-menu.open .tts-menu-panel { display: flex; }

.tts-menu-btn {
  width: 32px;
  height: 32px;
  border-radius: var(--la-radius-pill);
  border: 1px solid var(--la-border);
  background: var(--la-surface);
  color: var(--la-text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.tts-menu-btn svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

@media (max-width: 720px) {
  #sendBtn,
  #startRec {
    display: none;
  }
}

@media (max-width: 980px) {
  .chat-message .bubble { max-width: 100%; }
}

@media (max-width: 720px) {
  .tenant-pill {
    font-size: var(--la-fs-1);
    padding: 4px 8px;
    max-width: calc(100% - 44px);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  #chatWindow {
    padding: var(--la-s-2);
  }
  .chat-message {
    margin-bottom: var(--la-s-2);
  }
  .chat-message .bubble {
    max-width: 100%;
    font-size: var(--la-fs-2);
    padding: 6px 18px 6px 10px;
  }
  .agent-text {
    font-size: var(--la-fs-2);
    line-height: 1.35;
  }
  .chat-message.chat-user .bubble {
    padding: 3px 12px 3px 7px;
  }
  .bubble-header {
    margin-bottom: 2px;
  }
  .bubble-status {
    margin-top: 2px;
  }
  .tool-result,
  .tool-table,
  .chat-table {
    font-size: var(--la-fs-2);
  }
  .bubble-agent-name {
    font-size: 11px;
  }
  .bubble-status {
    font-size: 11px;
  }
  .context-chip {
    font-size: 11px;
    padding: 2px 8px;
  }
  .context-chip-btn {
    font-size: 11px;
    padding: 1px 8px;
  }
}

@media (prefers-color-scheme: dark) {
  .topbar,
  #chatWindow,
  .context-panel,
  .artifact-card,
  .modal {
    border-color: var(--la-border-strong);
  }

  .context-panel {
    background: var(--la-surface);
  }

  .context-selection {
    color: var(--la-text);
    background: transparent;
  }

  .chat-message.chat-user .chat-table {
    background: rgba(15, 23, 42, 0.35);
  }

  .chat-message.chat-agent .bubble {
    background: rgba(37, 99, 235, 0.14);
    border-color: rgba(37, 99, 235, 0.28);
    box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.12), 0 8px 18px rgba(37, 99, 235, 0.12);
  }

  .chat-message.chat-agent .bubble.has-tool {
    background: linear-gradient(90deg, rgba(59, 130, 246, 0.26), rgba(59, 130, 246, 0.08) 60%, rgba(15, 23, 42, 0.2));
  }


  .context-chip {
    background: rgba(148, 163, 184, 0.14);
    color: var(--la-text);
    border-color: var(--la-border-strong);
  }

  .context-chip-btn {
    background: var(--la-surface);
    border-color: var(--la-border-strong);
    color: var(--la-text);
  }

  .context-chip-btn:hover {
    background: var(--la-surface-2);
    border-color: rgba(226, 232, 240, 0.35);
  }

  .modal-title,
  .artifact-title,
  .artifact-name,
  .context-title {
    color: var(--la-text);
  }
  .bubble-agent-name {
    color: var(--la-text-soft);
  }

  .bubble-badge,
  .artifact-meta,
  .tool-note,
  .context-meta {
    color: var(--la-text-soft);
  }

  .modal-header {
    background: var(--la-surface);
  }

  .modal-header .icon-btn {
    color: var(--la-text);
    border-color: var(--la-border-strong);
    background: var(--la-surface);
  }

  .tool-result {
    background: transparent;
    border-color: transparent;
  }

  .tool-open-modal {
    background: var(--la-surface);
    border-color: var(--la-border-strong);
    color: var(--la-text);
  }

  .tool-open-modal:hover {
    background: var(--la-surface-2);
    border-color: rgba(59, 130, 246, 0.45);
  }

  .result-modal {
    background: rgba(15, 23, 42, 0.9);
    box-shadow: 0 28px 80px rgba(0, 0, 0, 0.55), 0 12px 32px rgba(0, 0, 0, 0.35);
  }

  .result-modal .text-preview {
    background: var(--la-surface-2);
    border-color: var(--la-border-strong);
    box-shadow: 0 2px 10px rgba(2, 6, 23, 0.35);
  }

  .text-preview,
  .artifact-card .text-preview,
  #suggestionPanel.results-panel .text-preview {
    background: var(--la-surface-2);
    border-color: var(--la-border-strong);
    box-shadow: 0 2px 10px rgba(2, 6, 23, 0.35);
  }

  .result-modal .text-preview-paragraph,
  .result-modal .text-preview-heading,
  .result-modal .text-preview-line,
  .result-modal .text-preview-table {
    color: var(--la-text);
  }

  .result-modal .text-preview-heading {
    border-bottom-color: var(--la-border-strong);
  }

  .result-modal .text-preview-divider {
    border-top-color: var(--la-border-strong);
  }

  .result-modal .text-preview-more {
    color: var(--la-text-muted);
  }

  .result-modal .text-preview-table th,
  .result-modal .text-preview-table td {
    border-color: var(--la-border-strong);
  }

  .result-modal .text-preview-table th {
    background: var(--la-surface-2);
  }

  .artifact-html-preview {
    background: var(--la-surface-2);
    border-color: var(--la-border-strong);
  }

  .chat-message .artifact-html-preview,
  .result-modal .artifact-html-preview,
  .artifact-card .artifact-html-preview {
    box-shadow: inset 0 0 0 1px rgba(148, 163, 184, 0.12);
  }

  /* Imported/exported HTML often includes hardcoded white backgrounds. Soften them in dark mode. */
  .chat-message .artifact-html-preview [style*="background:#fff"],
  .chat-message .artifact-html-preview [style*="background: #fff"],
  .chat-message .artifact-html-preview [style*="background:#ffffff"],
  .chat-message .artifact-html-preview [style*="background: #ffffff"],
  .chat-message .artifact-html-preview [style*="background-color:#fff"],
  .chat-message .artifact-html-preview [style*="background-color: #fff"],
  .chat-message .artifact-html-preview [style*="background-color:#ffffff"],
  .chat-message .artifact-html-preview [style*="background-color: #ffffff"],
  .chat-message .artifact-html-preview [style*="background:rgb(255"],
  .chat-message .artifact-html-preview [style*="background: rgb(255"],
  .chat-message .artifact-html-preview [style*="background-color:rgb(255"],
  .chat-message .artifact-html-preview [style*="background-color: rgb(255"],
  .result-modal .artifact-html-preview [style*="background:#fff"],
  .result-modal .artifact-html-preview [style*="background: #fff"],
  .result-modal .artifact-html-preview [style*="background:#ffffff"],
  .result-modal .artifact-html-preview [style*="background: #ffffff"],
  .result-modal .artifact-html-preview [style*="background-color:#fff"],
  .result-modal .artifact-html-preview [style*="background-color: #fff"],
  .result-modal .artifact-html-preview [style*="background-color:#ffffff"],
  .result-modal .artifact-html-preview [style*="background-color: #ffffff"],
  .result-modal .artifact-html-preview [style*="background:rgb(255"],
  .result-modal .artifact-html-preview [style*="background: rgb(255"],
  .result-modal .artifact-html-preview [style*="background-color:rgb(255"],
  .result-modal .artifact-html-preview [style*="background-color: rgb(255"],
  .artifact-card .artifact-html-preview [style*="background:#fff"],
  .artifact-card .artifact-html-preview [style*="background: #fff"],
  .artifact-card .artifact-html-preview [style*="background:#ffffff"],
  .artifact-card .artifact-html-preview [style*="background: #ffffff"],
  .artifact-card .artifact-html-preview [style*="background-color:#fff"],
  .artifact-card .artifact-html-preview [style*="background-color: #fff"],
  .artifact-card .artifact-html-preview [style*="background-color:#ffffff"],
  .artifact-card .artifact-html-preview [style*="background-color: #ffffff"],
  .artifact-card .artifact-html-preview [style*="background:rgb(255"],
  .artifact-card .artifact-html-preview [style*="background: rgb(255"],
  .artifact-card .artifact-html-preview [style*="background-color:rgb(255"],
  .artifact-card .artifact-html-preview [style*="background-color: rgb(255"] {
    background: transparent !important;
    color: var(--la-text) !important;
  }

  .chat-message .artifact-html-preview table,
  .result-modal .artifact-html-preview table,
  .artifact-card .artifact-html-preview table {
    background: transparent !important;
    color: var(--la-text) !important;
    border-color: var(--la-border-strong) !important;
  }

  .chat-message .artifact-html-preview th,
  .chat-message .artifact-html-preview td,
  .result-modal .artifact-html-preview th,
  .result-modal .artifact-html-preview td,
  .artifact-card .artifact-html-preview th,
  .artifact-card .artifact-html-preview td {
    border-color: var(--la-border-strong) !important;
    color: var(--la-text) !important;
  }

  .chat-message .artifact-html-preview :is(h1,h2,h3,h4,h5,h6,p,div,span,li,strong,em,small),
  .result-modal .artifact-html-preview :is(h1,h2,h3,h4,h5,h6,p,div,span,li,strong,em,small),
  .artifact-card .artifact-html-preview :is(h1,h2,h3,h4,h5,h6,p,div,span,li,strong,em,small) {
    color: var(--la-text) !important;
  }

  #suggestionPanel.results-panel .results-panel-card {
    background: rgba(15, 23, 42, 0.78);
    border-color: var(--la-border-strong);
  }
  .artifact-title .results-icon {
    border-color: var(--la-border-strong);
    background: rgba(15, 23, 42, 0.55);
    color: var(--la-text-soft);
  }

  .artifact-toggle,
  .artifact-btn,
  .artifact-quick-btn {
    background: rgba(15, 23, 42, 0.65);
    border-color: var(--la-border-strong);
    color: var(--la-text);
  }

  .artifact-btn.primary {
    background: var(--la-accent);
    color: #fff;
    border-color: transparent;
  }

  .chart-placeholder {
    background: rgba(15, 23, 42, 0.6);
    border-color: var(--la-border-strong);
    color: #93c5fd;
  }

  .tool-chart {
    background: rgba(15, 23, 42, 0.6);
    border-color: var(--la-border-strong);
    color: #93c5fd;
  }

  .tool-chart-title {
    color: var(--la-text);
  }

  .tool-chart-caption,
  .tool-chart-unit {
    color: var(--la-text-soft);
  }

  .preview-copy {
    background: rgba(15, 23, 42, 0.65);
    border-color: var(--la-border-strong);
    color: var(--la-text);
  }

  .chart-axis-line,
  .chart-axis-tick {
    stroke: var(--la-border-strong);
  }

  .chart-axis-text {
    fill: var(--la-text-muted);
  }

  .chart-value {
    fill: var(--la-text);
  }

  .context-panel,
  .context-card,
  .context-btn,
  .context-rail-btn,
  .context-pin {
    border-color: var(--la-border-strong);
    color: var(--la-text);
  }

  .context-card {
    background: rgba(15, 23, 42, 0.55);
    border-color: rgba(148, 163, 184, 0.28);
    box-shadow: 0 8px 18px rgba(2, 6, 23, 0.35);
  }

  .context-card:hover {
    background: rgba(37, 99, 235, 0.24);
    border-color: rgba(96, 165, 250, 0.7);
    box-shadow: 0 8px 20px rgba(2, 6, 23, 0.42), 0 0 0 1px rgba(59, 130, 246, 0.35);
  }

  .context-card.is-active {
    border-color: rgba(96, 165, 250, 0.72);
    background: rgba(37, 99, 235, 0.26);
    box-shadow: 0 0 0 1px rgba(96, 165, 250, 0.38), 0 10px 22px rgba(2, 6, 23, 0.45);
  }

  .context-card.is-active .context-icon {
    background: rgba(59, 130, 246, 0.3);
    color: #93c5fd;
    box-shadow: inset 0 0 0 1px rgba(96, 165, 250, 0.35);
  }

  .tool-table tr:nth-child(even) td,
  .table-preview tbody tr:nth-child(even) {
    background: rgba(226, 232, 240, 0.06);
  }

  .context-pin.active {
    background: transparent;
    color: #fbbf24;
  }

  .context-group-header.drop-target.drag-over .context-group-title.is-secondary {
    background: color-mix(in srgb, rgba(37, 99, 235, 0.55) 64%, var(--la-surface) 36%);
  }

  .context-group-header.drop-target.drag-over .context-drop-hint {
    color: #93c5fd;
  }

  .context-group-header.drop-target.drag-over {
    box-shadow: 0 0 0 2px rgba(96, 165, 250, 0.75), 0 8px 22px rgba(2, 6, 23, 0.52);
  }

  .context-group-header.drop-target.drag-over::before {
    border: 2px dashed rgba(147, 197, 253, 0.9);
    background: rgba(59, 130, 246, 0.2);
  }

  .context-group-header.drop-target.drag-reject .context-group-title.is-secondary {
    background: color-mix(in srgb, rgba(239, 68, 68, 0.55) 50%, var(--la-surface) 50%);
  }

  .context-group-header.drop-target.drag-reject .context-drop-hint {
    color: #fca5a5;
  }

  .context-group-header.drop-target.drag-reject {
    box-shadow: 0 0 0 2px rgba(252, 165, 165, 0.65), 0 8px 18px rgba(2, 6, 23, 0.45);
  }

  .context-group-header.drop-target.drag-reject::before {
    border: 2px dashed rgba(252, 165, 165, 0.85);
    background: rgba(239, 68, 68, 0.2);
  }

  .context-status.active {
    color: #fde68a;
  }

  .context-only:hover,
  .context-only:focus-visible {
    border-color: rgba(96, 165, 250, 0.58);
    background: rgba(59, 130, 246, 0.2);
    color: #dbeafe;
  }

  .context-only::after {
    background: rgba(15, 23, 42, 0.92);
    border-color: rgba(148, 163, 184, 0.38);
    color: #e2e8f0;
  }

  #chatWindow::-webkit-scrollbar-thumb,
  .modal::-webkit-scrollbar-thumb,
  .modal-body::-webkit-scrollbar-thumb,
  .context-list::-webkit-scrollbar-thumb,
  .table-preview::-webkit-scrollbar-thumb {
    background-color: rgba(226, 232, 240, 0.22);
    background-image:
      radial-gradient(circle at center, rgba(226, 232, 240, 0.65) 0 2px, transparent 3px);
  }

  @supports (scrollbar-color: auto) {
    #chatWindow,
    .modal,
    .modal-body,
    .context-list,
    .table-preview {
      scrollbar-color: rgba(226, 232, 240, 0.3) transparent;
    }
  }
}

@media (max-width: 720px) {
  .text-input-area {
    position: sticky;
    bottom: 0;
    z-index: 40;
    background: var(--la-bg);
    padding-bottom: calc(env(safe-area-inset-bottom) + var(--la-keyboard-offset, 0px));
  }
  .composer {
    padding: 6px 10px;
  }
  #textInput {
    font-size: 17px;
    line-height: 1.4;
  }
  #chatWindow {
    padding-bottom: calc(var(--la-s-6) + env(safe-area-inset-bottom) + var(--la-keyboard-offset, 0px));
    scroll-padding-bottom: calc(var(--la-s-6) + env(safe-area-inset-bottom) + var(--la-keyboard-offset, 0px));
  }
  .bubble-status {
    display: none;
  }
  .bubble-badge {
    display: none;
  }
  .context-chip {
    display: none;
  }
  .context-chip-btn {
    min-height: 32px;
  }
}

@media (max-width: 720px) {
  .chat-message .bubble {
    font-size: var(--la-fs-3);
  }
  .agent-text {
    font-size: var(--la-fs-3);
    line-height: 1.45;
  }
  .tool-result,
  .tool-table,
  .chat-table {
    font-size: var(--la-fs-3);
  }
  .bubble-agent-name {
    font-size: 12px;
  }
}

.upload-modal-body {
  display: flex;
  flex-direction: column;
  gap: var(--la-s-4);
}

.upload-out {
  font-size: var(--la-fs-2);
  color: var(--la-text-muted);
}

.upload-row {
  display: flex;
  gap: var(--la-s-3);
  align-items: center;
  flex-wrap: wrap;
}

.upload-file-input {
  flex: 1 1 auto;
  min-width: 220px;
  border: 1px solid var(--la-border);
  border-radius: var(--la-radius-pill);
  padding: 8px 12px;
  background: var(--la-surface);
  color: var(--la-text);
}

.upload-file-input::file-selector-button {
  margin-right: 12px;
  border: 1px solid var(--la-border);
  background: var(--la-surface-2);
  color: var(--la-text);
  border-radius: var(--la-radius-pill);
  padding: 6px 12px;
  cursor: pointer;
}

.upload-file-input::-ms-browse {
  border: 1px solid var(--la-border);
  background: var(--la-surface-2);
  color: var(--la-text);
  border-radius: var(--la-radius-pill);
  padding: 6px 12px;
}

.upload-select {
  width: 100%;
  min-height: 42px;
  border-radius: var(--la-radius-pill);
  border: 1px solid var(--la-border);
  padding: 0 14px;
  background: var(--la-surface);
  color: var(--la-text);
}

.upload-columns-actions {
  display: flex;
  gap: var(--la-s-2);
  margin-bottom: var(--la-s-2);
  flex-wrap: wrap;
}

.icon-btn.compact {
  width: 30px;
  height: 30px;
  border-radius: var(--la-radius-pill);
  border: 1px solid var(--la-border);
  background: var(--la-surface);
  color: var(--la-text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.icon-btn.compact svg {
  width: 16px;
  height: 16px;
}

.upload-active-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--la-s-2);
  margin-bottom: var(--la-s-2);
}

.upload-active-title {
  font-weight: 600;
}

.upload-active-loading {
  font-size: var(--la-fs-2);
  color: var(--la-text-muted);
}

.upload-active-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--la-s-3);
  padding: var(--la-s-2);
  border: 1px solid var(--la-border);
  border-radius: var(--la-radius-md);
  background: var(--la-surface);
  margin-bottom: var(--la-s-2);
}

.upload-active-label {
  flex: 1 1 auto;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: var(--la-fs-2);
  color: var(--la-text);
}

.upload-active-actions {
  display: flex;
  gap: var(--la-s-2);
  flex-wrap: wrap;
}

.upload-step {
  border: 1px solid var(--la-border);
  border-radius: var(--la-radius-md);
  background: var(--la-surface-2);
  padding: var(--la-s-3);
  display: flex;
  flex-direction: column;
  gap: var(--la-s-3);
}

.upload-step-head {
  display: flex;
  align-items: center;
  gap: var(--la-s-3);
}

.upload-step-number {
  width: 28px;
  height: 28px;
  border-radius: var(--la-radius-pill);
  background: var(--la-accent);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: var(--la-fs-2);
  font-weight: 600;
}

.upload-step-title { font-weight: 600; font-size: var(--la-fs-4); }
.upload-step-sub { color: var(--la-text-muted); font-size: var(--la-fs-2); }

.upload-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--la-s-2);
  align-items: center;
}

.upload-row input[type="file"] {
  padding: 6px;
  border: 1px dashed var(--la-border);
  border-radius: var(--la-radius-md);
  background: var(--la-surface);
}

.upload-canonical {
  border: 1px solid var(--la-border);
  border-radius: var(--la-radius-md);
  background: var(--la-surface);
  padding: var(--la-s-3);
}

.upload-status { color: var(--la-text-muted); font-size: var(--la-fs-2); }
.upload-columns { margin-top: var(--la-s-2); }
.upload-preview {
  margin-top: var(--la-s-2);
  border: 1px solid var(--la-border);
  border-radius: var(--la-radius-md);
  background: var(--la-surface-2);
  padding: var(--la-s-3);
  font-size: var(--la-fs-2);
  color: var(--la-text);
  position: relative;
}

.upload-preview table {
  width: 100%;
  border-collapse: collapse;
  min-width: 520px;
  font-size: var(--la-fs-2);
}

.upload-preview thead th {
  position: sticky;
  top: 0;
  background: var(--la-surface);
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--la-border);
}

.upload-preview thead th:hover {
  background: var(--la-surface-2);
}

.upload-preview tbody td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--la-border);
}

.upload-preview tbody tr:nth-child(even) td {
  background: var(--la-surface);
}

.preview-open-icon {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: 1px solid var(--la-border);
  background: var(--la-surface);
  color: var(--la-text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--la-shadow-sm);
  cursor: pointer;
}

.preview-open-icon svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

.preview-open-icon:hover {
  background: var(--la-surface-2);
}

.upload-result {
  margin-top: var(--la-s-2);
  font-size: var(--la-fs-2);
  color: var(--la-text-muted);
}

.upload-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--la-s-2);
  justify-content: space-between;
  align-items: center;
}

.upload-actions .btn-ghost {
  margin-right: auto;
}

.upload-actions button {
  align-self: center;
}

.upload-active {
  border: 1px solid var(--la-border);
  border-radius: var(--la-radius-md);
  background: var(--la-surface);
  padding: var(--la-s-3);
  min-height: 60px;
}

.preview-body {
  display: flex;
  flex-direction: column;
  gap: var(--la-s-3);
}

.preview-meta {
  font-size: var(--la-fs-2);
  color: var(--la-text-muted);
}

#canonicalPreviewTable {
  border: 1px solid var(--la-border);
  border-radius: var(--la-radius-md);
  background: var(--la-surface-2);
  padding: var(--la-s-3);
  max-height: 70vh;
  overflow: auto;
  font-size: var(--la-fs-2);
}

#canonicalPreviewTable .preview-table {
  width: 100%;
  border-collapse: collapse;
}

#canonicalPreviewTable .preview-table thead th {
  position: sticky;
  top: 0;
  background: var(--la-surface);
  font-size: var(--la-fs-2);
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--la-border);
}

#canonicalPreviewTable .preview-table thead th:hover {
  background: var(--la-surface-2);
}

#canonicalPreviewTable .preview-table tbody td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--la-border);
}

.agent-switch-shell {
  border: 1px solid var(--la-border);
  border-radius: var(--la-radius-md);
  background: var(--la-surface-2);
  padding: var(--la-s-3);
}

.agent-switch-viewport {
  overflow: hidden;
}

.agent-switch-track {
  display: flex;
  transition: transform 0.2s ease;
}

.agent-switch-page {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: var(--la-s-2);
  min-width: 100%;
}

.agent-switch-item {
  border: 1px solid var(--la-border);
  border-radius: var(--la-radius-md);
  background: var(--la-surface);
  padding: var(--la-s-3);
  text-align: left;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease, border-color 0.12s ease;
  display: flex;
  align-items: center;
  gap: var(--la-s-2);
}

.agent-switch-item:hover {
  border-color: var(--la-border-strong);
  box-shadow: var(--la-shadow-sm);
  transform: translateY(-1px);
}

.agent-switch-item.primary {
  border-color: var(--la-accent);
  background: var(--la-accent-100);
  color: var(--la-accent-700);
}

.agent-switch-name {
  font-size: var(--la-fs-3);
  font-weight: 600;
}

.agent-switch-badge {
  width: 22px;
  height: 22px;
  object-fit: contain;
  opacity: 0.9;
}

.agent-switch-empty {
  font-size: var(--la-fs-2);
  color: var(--la-text-muted);
  padding: var(--la-s-3);
}

.runs-meta {
  margin-top: var(--la-s-1);
  font-size: var(--la-fs-1);
  color: var(--la-text-muted);
}

.summary-meta {
  margin-top: var(--la-s-1);
  font-size: var(--la-fs-1);
  color: var(--la-text-muted);
}

.summary-box-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
  left: -9999px;
  top: auto;
}

.summary-content {
  margin-top: var(--la-s-2);
  border: 1px solid var(--la-border);
  border-radius: var(--la-radius-md);
  background: var(--la-surface-2);
  padding: var(--la-s-3);
  max-height: 62vh;
  overflow: auto;
}

.summary-content[draggable="true"] {
  cursor: grab;
}

.summary-content[draggable="true"]:active {
  cursor: grabbing;
}

.summary-doc {
  color: var(--la-text);
  font-size: var(--la-fs-3);
  line-height: 1.5;
}

.summary-title {
  margin: 0 0 var(--la-s-2);
  font-size: 1.05rem;
  font-weight: 700;
}

.summary-heading {
  margin: var(--la-s-3) 0 var(--la-s-2);
  font-size: 0.98rem;
  font-weight: 600;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--la-border);
}

.summary-paragraph {
  margin: 0 0 var(--la-s-2);
  white-space: pre-wrap;
}

.summary-list {
  margin: 0 0 var(--la-s-3);
  padding-left: 20px;
}

.summary-list li {
  margin: 0 0 4px;
}

.summary-empty {
  color: var(--la-text-muted);
  font-size: var(--la-fs-2);
}

.summary-table {
  width: 100%;
  border-collapse: collapse;
  margin: var(--la-s-2) 0 var(--la-s-3);
  font-size: var(--la-fs-2);
}

.summary-table th,
.summary-table td {
  border: 1px solid var(--la-border);
  padding: 8px 10px;
  text-align: left;
  vertical-align: top;
}

.summary-table th {
  position: sticky;
  top: 0;
  background: var(--la-surface);
  font-weight: 600;
}

.summary-table tr:nth-child(even) td {
  background: rgba(15, 23, 42, 0.03);
}

.summary-action-bar {
  margin-top: var(--la-s-3);
  display: flex;
  gap: var(--la-s-2);
  justify-content: flex-end;
  flex-wrap: wrap;
}

.summary-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  white-space: nowrap;
}

.summary-action-btn svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.runs-table-wrap {
  margin-top: var(--la-s-2);
  border: 1px solid var(--la-border);
  border-radius: var(--la-radius-md);
  overflow: auto;
  max-height: 50vh;
  background: var(--la-surface);
}

.runs-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--la-fs-1);
}

.runs-table th,
.runs-table td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--la-border);
  text-align: left;
  vertical-align: top;
}

.runs-table th {
  position: sticky;
  top: 0;
  background: var(--la-surface-2);
  font-weight: 600;
}

.runs-table tr:nth-child(even) td {
  background: rgba(15, 23, 42, 0.04);
}

@media (prefers-color-scheme: dark) {
  .upload-preview,
  #canonicalPreviewTable {
    background: var(--la-surface-2);
    border-color: var(--la-border-strong);
  }

  .agent-switch-shell {
    background: var(--la-surface-2);
    border-color: var(--la-border-strong);
  }

  .agent-switch-item {
    background: var(--la-surface);
    border-color: var(--la-border-strong);
    color: var(--la-text);
  }

  .agent-switch-item.primary {
    background: rgba(37, 99, 235, 0.2);
    color: var(--la-text);
    border-color: rgba(37, 99, 235, 0.45);
  }

  .runs-meta {
    color: var(--la-text-muted);
  }

  .summary-meta {
    color: var(--la-text-muted);
  }

  .summary-content {
    border-color: var(--la-border-strong);
    background: var(--la-surface-2);
  }

  .summary-heading,
  .summary-table th,
  .summary-table td {
    border-color: var(--la-border-strong);
  }

  .summary-table tr:nth-child(even) td {
    background: rgba(255, 255, 255, 0.03);
  }

  .summary-action-btn {
    border-color: var(--la-border-strong);
    color: var(--la-text);
  }

  .runs-table-wrap {
    border-color: var(--la-border-strong);
    background: var(--la-surface);
  }

  .runs-table th,
  .runs-table td {
    border-color: var(--la-border-strong);
    color: var(--la-text);
  }

  .runs-table th {
    background: var(--la-surface-2);
  }

  .runs-table tr:nth-child(even) td {
    background: rgba(255, 255, 255, 0.03);
  }

  #canonicalPreviewTable .preview-table thead th {
    background: var(--la-surface-2);
    color: var(--la-text);
  }

  #canonicalPreviewTable .preview-table tbody td,
  .tool-table td,
  .tool-table th,
  .table-preview td,
  .table-preview th,
  .upload-preview table td,
  .upload-preview table th {
    color: var(--la-text);
    border-color: var(--la-border-strong);
  }

  .tool-table th,
  .table-preview th,
  .upload-preview thead th,
  #canonicalPreviewTable .preview-table thead th {
    background: var(--la-surface-2);
  }

  .tool-table th:hover,
  .table-preview th:hover,
  .upload-preview thead th:hover,
  #canonicalPreviewTable .preview-table thead th:hover {
    background: var(--la-surface);
  }

  .tool-table tr:nth-child(even) td,
  .table-preview tr:nth-child(even) td,
  .upload-preview tbody tr:nth-child(even) td {
    background: rgba(255, 255, 255, 0.03);
  }
}

/* Hide sort glyphs only inside chat bubbles */
.chat-message .tool-table-sort .sort-icon,
.chat-message .tool-table-sort .sort-icon::before {
  display: none !important;
  content: "" !important;
}
/* generic visibility helper */
.is-hidden { display: none !important; }
