@import "tailwindcss";

@theme {
  --color-bg: var(--bg);
  --color-bg-panel: var(--bg-panel);
  --color-bg-hover: var(--bg-hover);
  --color-bg-selected: var(--bg-selected);
  --color-border: var(--border);
  --color-text: var(--text);
  --color-text-muted: var(--text-muted);
  --color-text-dim: var(--text-dim);
  --color-accent: var(--accent);
  --color-accent-hover: var(--accent-hover);
  --color-user-bg: var(--user-bg);
  --color-assistant-bg: var(--assistant-bg);
  --color-tool-bg: var(--tool-bg);
  --color-bg-subtle: var(--bg-subtle);
  --font-mono-font: var(--font-mono);
}

:root {
  --bg: #ffffff;
  --bg-panel: #f5f5f5;
  --bg-hover: #eeeeee;
  --bg-selected: #e8e8e8;
  --border: #e0e0e0;
  --text: #1a1a1a;
  --text-muted: #6b7280;
  --text-dim: #9ca3af;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --user-bg: #eff6ff;
  --assistant-bg: #ffffff;
  --tool-bg: #f9fafb;
  --bg-subtle: rgba(0,0,0,0.03);
}

html.dark {
  --bg: #1a1a1a;
  --bg-panel: #242424;
  --bg-hover: #2e2e2e;
  --bg-selected: #383838;
  --border: #3a3a3a;
  --text: #e8e8e8;
  --text-muted: #9ca3af;
  --text-dim: #6b7280;
  --accent: #60a5fa;
  --accent-hover: #93c5fd;
  --user-bg: #1e293b;
  --assistant-bg: #1a1a1a;
  --tool-bg: #1f2937;
  --bg-subtle: rgba(255,255,255,0.04);
}

.catppuccin-file-icon {
  display: block;
  flex-shrink: 0;
  background: center / contain no-repeat var(--catppuccin-icon-light);
}
html.dark .catppuccin-file-icon {
  background-image: var(--catppuccin-icon-dark);
}

/* Use the SVG alpha channel as a mask so file icons follow the app's
   restrained text palette instead of Catppuccin's language-specific colors. */
@supports (mask-image: url("mask.svg")) or (-webkit-mask-image: url("mask.svg")) {
  .catppuccin-file-icon {
    background: var(--text-dim);
    mask: center / contain no-repeat var(--catppuccin-icon-light);
    -webkit-mask: center / contain no-repeat var(--catppuccin-icon-light);
  }
  html.dark .catppuccin-file-icon {
    background: var(--text-dim);
    mask-image: var(--catppuccin-icon-dark);
    -webkit-mask-image: var(--catppuccin-icon-dark);
  }
}

/* Theme toggle: circular wipe via View Transitions API.
   Disable the UA cross-fade; the actual clip-path animation is driven by
   Element.animate() in hooks/useTheme.ts after transition.ready resolves. */
::view-transition-old(root),
::view-transition-new(root) {
  animation: none;
  mix-blend-mode: normal;
}
::view-transition-old(root) {
  z-index: 1;
}
::view-transition-new(root) {
  z-index: 2;
}

* {
  box-sizing: border-box;
}

html, body {
  width: 100%;
  height: 100vh;
  height: 100dvh;
  height: var(--app-viewport-height, 100dvh);
  margin: 0;
  padding: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  overscroll-behavior: none;
}

body {
  display: flex;
  flex-direction: column;
}

::-webkit-scrollbar {
  width: 4px;
  height: 4px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

.extension-status-shelf {
  display: flex;
  flex-shrink: 0;
  flex-wrap: wrap;
  align-items: stretch;
  min-width: 0;
  border-top: 1px solid var(--border);
  background: transparent;
}

.extension-widget-panels {
  display: flex;
  flex: 0 0 100%;
  flex-direction: column;
  max-height: min(144px, 18dvh);
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  border-bottom: 1px solid color-mix(in srgb, var(--border) 78%, transparent);
  background: var(--bg-panel);
}

.extension-widget-panel {
  flex-shrink: 0;
  min-width: 0;
  overflow: hidden;
  background: transparent;
}

.extension-widget-panel-heading {
  height: 26px;
  padding: 5px 12px 0;
  overflow: hidden;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.extension-widget-triggers {
  display: flex;
  flex: 1 1 100%;
  align-items: stretch;
  min-width: 0;
  height: 35px;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
}

.extension-widget-triggers::-webkit-scrollbar {
  display: none;
}

.extension-status-shelf.has-widgets.has-status .extension-widget-triggers {
  flex: 0 1 70%;
  max-width: 70%;
  border-right: 1px solid var(--border);
}

.extension-widget-trigger {
  position: relative;
  display: flex;
  flex: 0 0 108px;
  align-items: center;
  width: 108px;
  height: 35px;
  gap: 5px;
  padding: 0 7px;
  overflow: hidden;
  border: 0;
  border-right: 1px solid color-mix(in srgb, var(--border) 78%, transparent);
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 11px;
  text-align: left;
}

.extension-widget-update-pulse {
  position: absolute;
  z-index: 0;
  inset: 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease-out;
}

.extension-widget-update-pulse::before {
  position: absolute;
  inset: 0;
  background: var(--accent);
  content: "";
  opacity: 0.12;
}

.extension-widget-trigger.is-updating .extension-widget-update-pulse {
  opacity: 1;
}

.extension-widget-trigger.is-updating .extension-widget-update-pulse::before {
  animation: extension-widget-update-pulse 900ms ease-in-out infinite alternate;
}

@keyframes extension-widget-update-pulse {
  from { opacity: 0.18; }
  to { opacity: 0.06; }
}

button.extension-widget-trigger {
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}

button.extension-widget-trigger:hover,
.extension-widget-trigger.is-expanded {
  background: var(--bg-hover);
  color: var(--text);
}

button.extension-widget-trigger:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.extension-widget-placement {
  display: flex;
  position: relative;
  z-index: 1;
  width: 10px;
  flex: 0 0 10px;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
}

.extension-widget-placement-icon {
  display: block;
  width: 8px;
  height: 6px;
  flex: 0 0 8px;
  fill: currentColor;
}

.extension-widget-key {
  position: relative;
  z-index: 1;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (prefers-reduced-motion: reduce) {
  .extension-widget-update-pulse {
    transition: none;
  }

  .extension-widget-trigger.is-updating .extension-widget-update-pulse::before {
    animation: none;
    opacity: 0.12;
  }
}

.extension-widget-content {
  margin: 0;
  padding: 3px 12px 8px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 14px;
  line-height: 1.45;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.extension-status-line {
  display: flex;
  flex: 1 1 0;
  align-items: center;
  min-width: 0;
  height: 35px;
  padding: 0 12px;
}

.extension-status-text {
  min-width: 0;
  overflow: hidden;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-dim);
}

:root {
  --font-mono: var(--font-noto-mono), 'JetBrains Mono', 'Fira Code', 'Consolas', ui-monospace, 'PingFang SC', 'Microsoft YaHei', monospace;
}

pre, code {
  font-family: var(--font-mono);
}

/* react-markdown output styles */
.markdown-body {
  min-width: 0;
  max-width: 100%;
  overflow-x: hidden;
  font-size: 14px;
  line-height: 1.7;
  color: var(--text);
  word-break: break-word;
}
.markdown-body p { margin: 0 0 8px; }
.markdown-body p:last-child { margin-bottom: 0; }
.markdown-body h1, .markdown-body h2, .markdown-body h3,
.markdown-body h4, .markdown-body h5, .markdown-body h6 {
  font-weight: 600;
  margin: 10px 0 5px;
  color: var(--text);
  line-height: 1.35;
  letter-spacing: 0;
}
.markdown-body h1 { font-size: 1.16em; }
.markdown-body h2 { font-size: 1.08em; }
.markdown-body h3 { font-size: 0.98em; color: color-mix(in srgb, var(--text) 88%, var(--text-muted)); }
.markdown-body ul, .markdown-body ol {
  padding-left: 22px;
  margin: 5px 0 8px;
  list-style-position: outside;
}
.markdown-body li { margin: 3px 0; padding-left: 2px; }
.markdown-body ul > li { list-style-type: disc; }
.markdown-body ol > li { list-style-type: decimal; }
.markdown-body li > p { margin: 0; }
.markdown-body li::marker {
  color: color-mix(in srgb, var(--accent) 72%, var(--text-muted));
  font-weight: 600;
}
.markdown-body strong {
  color: color-mix(in srgb, var(--text) 88%, var(--accent));
  font-weight: 700;
}
.markdown-body em { color: var(--text-muted); }
.markdown-body a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  text-decoration-color: color-mix(in srgb, var(--accent) 45%, transparent);
}
.markdown-body a:hover { text-decoration-color: var(--accent); }
.markdown-body img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 8px 0;
  border-radius: 6px;
}
.markdown-body .markdown-inline-code {
  background: var(--bg-subtle);
  border-radius: 5px;
  padding: 1px 5px;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.92em;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--border) 70%, transparent);
}
.markdown-body .contains-task-list {
  padding-left: 0;
  list-style: none;
}
.markdown-body .task-list-item {
  display: block;
  position: relative;
  padding-left: 25px;
}
.markdown-body .task-list-item::marker { content: ""; }
.markdown-body .task-list-item > input[type="checkbox"],
.markdown-body .task-list-item > p:first-child > input[type="checkbox"]:first-child {
  appearance: none;
  position: absolute;
  left: 0;
  top: 0.35em;
  width: 14px;
  height: 14px;
  margin: 0;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg);
  display: inline-grid;
  place-content: center;
}
.markdown-body .task-list-item > input[type="checkbox"]:checked,
.markdown-body .task-list-item > p:first-child > input[type="checkbox"]:first-child:checked {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--border));
  background: color-mix(in srgb, var(--accent) 10%, var(--bg));
}
.markdown-body .task-list-item > input[type="checkbox"]:checked::before,
.markdown-body .task-list-item > p:first-child > input[type="checkbox"]:first-child:checked::before {
  content: "";
  width: 4px;
  height: 8px;
  border: solid var(--accent);
  border-width: 0 1.5px 1.5px 0;
  transform: rotate(45deg) translateY(-1px);
}
.markdown-body blockquote {
  border-left: 3px solid color-mix(in srgb, var(--border) 75%, var(--text-muted));
  border-radius: 0 6px 6px 0;
  margin: 6px 0;
  padding: 6px 11px;
  background: var(--bg-subtle);
  color: var(--text-muted);
}
.markdown-table-wrap {
  width: 100%;
  margin: 8px 0;
  overflow-x: auto;
  overflow-y: hidden;
  border: 1px solid var(--border);
  border-radius: 7px;
}
.markdown-body table {
  border-collapse: separate;
  border-spacing: 0;
  min-width: 100%;
  font-size: 13px;
}
.markdown-body th, .markdown-body td {
  border: 0;
  border-bottom: 1px solid var(--border);
  padding: 6px 10px;
  text-align: left;
  vertical-align: top;
}
.markdown-body tr:last-child td { border-bottom: 0; }
.markdown-body th {
  background: var(--bg-panel);
  color: color-mix(in srgb, var(--text) 88%, var(--text-muted));
  font-weight: 650;
}
.markdown-body tbody tr:nth-child(even) td { background: var(--bg-subtle); }
.markdown-body hr {
  border: none;
  height: 1px;
  margin: 12px 0;
  background: linear-gradient(90deg, transparent, var(--border), transparent);
}
.markdown-body .katex-display {
  margin: 0.6em 0;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 2px 0;
}
.markdown-body .katex {
  font-size: 1.05em;
}
.markdown-user-message p {
  white-space: pre-wrap;
}

.markdown-custom-message {
  line-height: 1.32;
}
.markdown-custom-message p { margin: 0; }
.markdown-custom-message h1,
.markdown-custom-message h2,
.markdown-custom-message h3,
.markdown-custom-message h4,
.markdown-custom-message h5,
.markdown-custom-message h6 {
  margin: 4px 0 2px;
  line-height: 1.18;
}
.markdown-custom-message ul,
.markdown-custom-message ol {
  margin: 2px 0 3px;
}
.markdown-custom-message li { margin: 0; }
.markdown-custom-message blockquote {
  margin: 3px 0;
  padding: 4px 8px;
}
.markdown-custom-message .markdown-table-wrap,
.markdown-custom-message .markdown-code-block {
  margin: 4px 0;
}

.markdown-compaction-message {
  line-height: 1.5;
}
.markdown-compaction-message p { margin: 0 0 7px; }
.markdown-compaction-message h1,
.markdown-compaction-message h2,
.markdown-compaction-message h3,
.markdown-compaction-message h4,
.markdown-compaction-message h5,
.markdown-compaction-message h6 {
  margin: 8px 0 3px;
  line-height: 1.25;
}
.markdown-compaction-message ul,
.markdown-compaction-message ol {
  margin: 4px 0 8px;
}
.markdown-compaction-message li { margin: 2px 0; }
.markdown-compaction-message .markdown-table-wrap,
.markdown-compaction-message .markdown-code-block {
  margin: 6px 0;
}

.compaction-file-details {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 12px;
}
.compaction-file-details summary {
  cursor: pointer;
  font-weight: 600;
  line-height: 1.4;
}
.compaction-file-section {
  margin-top: 8px;
}
.compaction-file-title {
  margin-bottom: 4px;
  color: var(--text);
  font-size: 11px;
  font-weight: 650;
}
.compaction-file-list {
  max-height: 180px;
  margin: 0;
  padding: 7px 8px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-panel);
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.45;
  list-style: none;
}
.compaction-file-list li {
  overflow-wrap: anywhere;
}
.compaction-file-list li + li {
  margin-top: 3px;
}

.markdown-code-block {
  position: relative;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  margin: 6px 0;
  border: 1px solid var(--border);
  border-radius: 7px;
  overflow: hidden;
  background: var(--bg);
  box-shadow: 0 1px 0 color-mix(in srgb, var(--border) 42%, transparent);
}
.markdown-code-header {
  padding: 5px 10px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 11px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.markdown-code-lang {
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-weight: 650;
}
.markdown-code-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}
.markdown-code-action {
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 2px 7px;
  background: var(--bg);
  color: var(--text-muted);
  cursor: pointer;
  font: inherit;
  font-size: 11px;
  line-height: 1.25;
}
.markdown-code-action:hover:not(:disabled) {
  color: var(--text);
  border-color: color-mix(in srgb, var(--border) 70%, var(--text-muted));
}
.markdown-code-action:disabled {
  color: var(--text-dim);
  cursor: not-allowed;
  opacity: 0.75;
}
.markdown-code-action.is-active {
  background: var(--bg-selected);
  color: var(--text);
}

.mermaid-block {
  padding: 12px;
  overflow-x: auto;
  background: color-mix(in srgb, var(--bg) 92%, var(--bg-panel));
}
.mermaid-block svg {
  display: block;
  max-width: none;
}
.mermaid-block-loading {
  min-height: 120px;
}
.mermaid-block-error {
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 12px;
}

.mermaid-preview-button {
  width: 100%;
  border: 0;
  color: inherit;
  cursor: zoom-in;
  text-align: left;
}
.mermaid-preview-button:hover {
  opacity: 0.85;
}
.mermaid-preview-button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.image-preview-dialog {
  position: fixed;
  inset: 0;
  width: 100vw;
  max-width: none;
  height: 100dvh;
  max-height: none;
  margin: 0;
  padding-top: max(16px, env(safe-area-inset-top));
  padding-right: max(16px, env(safe-area-inset-right));
  padding-bottom: max(16px, env(safe-area-inset-bottom));
  padding-left: max(16px, env(safe-area-inset-left));
  overflow: hidden;
  border: 0;
  background: transparent;
  color: var(--text);
}

.image-preview-dialog[open] {
  display: flex;
  align-items: center;
  justify-content: center;
}

.image-preview-dialog::backdrop {
  background: rgba(0, 0, 0, 0.72);
}

.image-preview-image {
  display: block;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
}

.image-preview-close {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  right: max(12px, env(safe-area-inset-right));
  z-index: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-panel);
  color: var(--text-muted);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.28);
  cursor: pointer;
  touch-action: manipulation;
  transition: background-color 0.12s, color 0.12s;
}

.image-preview-close:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.image-preview-close:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

@media (pointer: coarse) {
  .image-preview-close {
    width: 44px;
    height: 44px;
  }
}

.mermaid-zoom-dialog {
  width: 100vw;
  max-width: none;
  height: 100dvh;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: var(--bg);
  color: var(--text);
}
.mermaid-zoom-dialog::backdrop {
  background: rgba(0, 0, 0, 0.35);
}
.mermaid-zoom-layout {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  height: 100%;
}
.mermaid-zoom-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  padding: 7px 10px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
}
.mermaid-zoom-title {
  min-width: 0;
  overflow: hidden;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.mermaid-zoom-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}
.mermaid-zoom-stepper {
  display: flex;
  align-items: center;
  height: 24px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--bg);
}
.mermaid-zoom-stepper button,
.mermaid-zoom-icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  touch-action: manipulation;
}
.mermaid-zoom-stepper button {
  height: 22px;
}
.mermaid-zoom-stepper button + .mermaid-zoom-value,
.mermaid-zoom-value + button {
  border-left: 1px solid var(--border);
}
.mermaid-zoom-icon-button {
  flex: 0 0 24px;
  border: 1px solid var(--border);
  border-radius: 5px;
}
.mermaid-zoom-stepper button:hover:not(:disabled),
.mermaid-zoom-icon-button:hover {
  background: var(--bg-hover);
  color: var(--text);
}
.mermaid-zoom-stepper button:disabled {
  opacity: 0.35;
  cursor: default;
}
.mermaid-zoom-stepper button:focus-visible,
.mermaid-zoom-icon-button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
.mermaid-zoom-value {
  min-width: 48px;
  height: 22px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 22px;
  text-align: center;
  user-select: none;
}
.mermaid-zoom-viewport {
  min-width: 0;
  min-height: 0;
  overflow: auto;
  padding: 24px;
  background: var(--bg);
  -webkit-overflow-scrolling: touch;
}
.mermaid-zoom-canvas {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--bg-panel);
  margin: 0 auto;
  transition: width 0.15s ease;
}
.mermaid-zoom-canvas svg {
  display: block;
  width: 100% !important;
  height: auto;
  max-width: none !important;
}

@media (max-width: 480px) {
  .mermaid-zoom-toolbar {
    padding-inline: 8px;
  }

  .mermaid-zoom-title {
    font-size: 10px;
  }

  .mermaid-zoom-viewport {
    padding: 12px;
  }
}

/* File viewer toolbar */
.file-viewer-toolbar {
  min-width: 0;
  min-height: 35px;
}

.file-viewer-path {
  flex: 1 1 auto;
  min-width: 48px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-viewer-meta {
  flex: 0 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-viewer-live-indicator {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex: 0 0 7px;
}

.file-viewer-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.file-viewer-actions {
  display: flex;
  align-items: center;
  height: 24px;
  gap: 4px;
  flex-shrink: 0;
  order: -1;
}

.file-viewer-mode-switch {
  display: flex;
  height: 24px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 5px;
}

.file-viewer-mode-button {
  height: 22px;
  padding: 0 8px;
  border: 0;
  border-left: 1px solid var(--border);
  font: inherit;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0;
  cursor: pointer;
  white-space: nowrap;
}

.file-viewer-mode-button:first-child {
  border-left: 0;
}

.file-viewer-mode-button:hover {
  filter: brightness(1.08);
}

.file-viewer-icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  box-sizing: border-box;
  flex: 0 0 24px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  text-decoration: none;
}

.file-viewer-icon-button:hover {
  background: var(--bg-hover) !important;
  color: var(--text);
}

.file-viewer-icon-button:disabled {
  color: var(--text-dim);
  cursor: not-allowed;
  opacity: 0.55;
}

.file-viewer-icon-button:disabled:hover {
  background: transparent !important;
  color: var(--text-dim);
}

.file-viewer-mode-button:focus-visible,
.file-viewer-icon-button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.directory-picker-path:focus-visible {
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}

@media (max-width: 640px) {
  .file-viewer-meta {
    display: none;
  }
}

@media (max-width: 380px) {
  .file-viewer-toolbar {
    gap: 6px !important;
    padding-inline: 8px !important;
  }

  .file-viewer-mode-button {
    padding-inline: 6px;
  }
}

/* File viewer markdown preview — larger headings */
.markdown-file-preview h1 { font-size: 1.8em; }
.markdown-file-preview h2 { font-size: 1.4em; }
.markdown-file-preview h3 { font-size: 1.15em; }
.markdown-file-preview p { margin: 0 0 12px; }
.markdown-file-preview pre {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px 16px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 13px;
  margin: 12px 0;
}
.markdown-file-preview code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: var(--bg-panel);
  padding: 1px 5px;
  border-radius: 3px;
}
.markdown-file-preview pre code {
  background: none;
  padding: 0;
}

/* YAML frontmatter metadata card (file preview) */
.markdown-frontmatter {
  margin-bottom: 20px;
  padding: 14px 16px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-panel);
}
.markdown-frontmatter-title {
  font-size: 1.3em;
  font-weight: 600;
  line-height: 1.35;
  color: var(--text);
}
.markdown-frontmatter-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.markdown-frontmatter-tag {
  font-size: 12px;
  line-height: 1.6;
  color: var(--text-muted);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0 10px;
}
.markdown-frontmatter-rows {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 5px 14px;
  margin: 10px 0 0;
  font-size: 13px;
  line-height: 1.55;
}
.markdown-frontmatter-row {
  display: contents;
}
.markdown-frontmatter-row dt {
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.92em;
  white-space: nowrap;
}
.markdown-frontmatter-row dd {
  margin: 0;
  color: var(--text);
  min-width: 0;
  word-break: break-word;
}
.markdown-frontmatter-row dd a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* syntax highlighter line numbers */
.markdown-body span.linenumber,
span.linenumber {
  color: var(--text-dim) !important;
  font-style: normal !important;
}

@keyframes drop-zone-in {
  from { opacity: 0; transform: scale(0.97); }
  to   { opacity: 1; transform: scale(1); }
}

@keyframes drop-icon-float {
  0%, 100% { transform: translateY(0px); }
  50%       { transform: translateY(-6px); }
}

@keyframes drop-ring-pulse {
  0%, 100% { opacity: 0.5; transform: scale(1); }
  50%       { opacity: 1;   transform: scale(1.06); }
}

@keyframes drop-ripple {
  0%   { transform: scale(0); opacity: 0.6; }
  100% { transform: scale(1); opacity: 0; }
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

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

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

@keyframes notice-shelf-in {
  from {
    opacity: 0;
    height: 0;
    max-height: 0;
    min-height: 0;
    margin-bottom: 0;
    transform: translateY(-6px) scale(0.995);
  }
  to {
    opacity: 1;
    height: 60px;
    max-height: 60px;
    min-height: 60px;
    transform: translateY(0) scale(1);
  }
}

@keyframes notice-shelf-out {
  from {
    opacity: 1;
    height: 60px;
    max-height: 60px;
    min-height: 60px;
    transform: translateY(0) scale(1);
  }
  to {
    opacity: 0;
    height: 0;
    max-height: 0;
    min-height: 0;
    margin-bottom: 0;
    transform: translateY(-5px) scale(0.995);
  }
}

@media (prefers-reduced-motion: reduce) {
  .notice-shelf-item {
    animation-duration: 0.001ms !important;
  }
}

@keyframes saved-pop {
  0%   { transform: scale(1); box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.55); }
  40%  { transform: scale(1.08); box-shadow: 0 0 0 6px rgba(74, 222, 128, 0.25); }
  100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(74, 222, 128, 0); }
}

@keyframes saved-check-draw {
  from { stroke-dashoffset: 18; opacity: 0; }
  to   { stroke-dashoffset: 0;  opacity: 1; }
}

/* Keep the panel border as the idle separator; this element only expands the hit target. */
.panel-resize-handle {
  position: relative;
  z-index: 220;
  width: 12px;
  margin: 0 -6px;
  flex: 0 0 12px;
  cursor: col-resize;
  touch-action: none;
  outline: none;
}
.panel-resize-handle::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 5px;
  width: 2px;
  pointer-events: none;
  background: transparent;
  transition: background 0.12s ease;
}
.panel-resize-handle:hover::after,
.panel-resize-handle:focus-visible::after,
.panel-resize-handle.is-resizing::after {
  background: color-mix(in srgb, var(--text-muted) 70%, var(--border));
}
.right-panel-overlay-backdrop {
  display: none;
}

/* Desktop sidebar: animate width */
@media (min-width: 641px) {
  .sidebar-overlay-backdrop {
    display: none !important;
  }
  .sidebar-container {
    position: relative;
    overflow: hidden;
    transition: width 0.2s ease, min-width 0.2s ease;
  }
  .sidebar-container.sidebar-open {
    width: var(--sidebar-width, 260px);
    min-width: var(--sidebar-width, 260px);
  }
  .sidebar-container.sidebar-closed {
    width: 0;
    min-width: 0;
    border-right: none !important;
  }
  /* keep inner content at fixed width so it doesn't reflow during animation */
  .sidebar-container > * {
    width: var(--sidebar-width, 260px);
    min-width: var(--sidebar-width, 260px);
  }
  .sidebar-container.sidebar-resizing,
  .sidebar-container.sidebar-resizing > * {
    transition: none !important;
  }
}

/* Wide desktop file panel: participate in the split layout. */
@media (min-width: 960px) {
  .right-panel-container {
    overflow: hidden;
    transition: width 0.2s ease, min-width 0.2s ease;
    flex-shrink: 0;
  }
  .right-panel-container.right-panel-open {
    width: var(--right-panel-width, clamp(360px, 42vw, 640px));
    min-width: 300px;
  }
  .right-panel-container.right-panel-closed {
    width: 0;
    min-width: 0;
    border-left: none !important;
  }
  /* keep inner content at fixed width so it doesn't reflow during animation */
  .right-panel-container > * {
    width: var(--right-panel-width, clamp(360px, 42vw, 640px));
    min-width: 300px;
  }
  .right-panel-container.right-panel-resizing,
  .right-panel-container.right-panel-resizing > * {
    transition: none !important;
  }
}

/* Compact desktop file panel: overlay the chat instead of collapsing it. */
@media (min-width: 641px) and (max-width: 959px) {
  .right-panel-resize-handle {
    display: none;
  }
  .right-panel-overlay-backdrop {
    position: fixed;
    inset: 0;
    z-index: 240;
    display: block;
    background: rgba(0, 0, 0, 0.24);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
  }
  .right-panel-overlay-backdrop.is-open {
    opacity: 1;
    pointer-events: auto;
  }
  .right-panel-container {
    position: fixed;
    top: 0;
    right: env(safe-area-inset-right);
    bottom: 0;
    z-index: 250;
    width: min(560px, calc(100vw - 48px));
    min-width: 300px;
    overflow: hidden;
    box-shadow: -12px 0 32px rgba(0, 0, 0, 0.18);
    transition: transform 0.2s ease;
  }
  .right-panel-container.right-panel-open {
    transform: translateX(0);
  }
  .right-panel-container.right-panel-closed {
    transform: translateX(100%);
    pointer-events: none;
  }
  .right-panel-container > * {
    width: 100%;
    min-width: 0;
  }
}

/* Mobile sidebar: slide in/out as overlay */
@media (max-width: 640px) {
  .chat-stats-center {
    display: none !important;
  }
  .sidebar-container {
    position: fixed !important;
    top: 0;
    left: env(safe-area-inset-left);
    bottom: 0;
    width: 280px;
    max-width: 85vw;
    height: var(--app-viewport-height, 100dvh);
    transition: transform 0.25s ease, box-shadow 0.25s ease;
  }
  .sidebar-container.sidebar-open {
    transform: translateX(0);
    box-shadow: 4px 0 20px rgba(0,0,0,0.15);
  }
  .sidebar-container.sidebar-closed {
    transform: translateX(calc(-100% - env(safe-area-inset-left)));
    box-shadow: none;
  }

  .right-panel-container {
    position: fixed;
    inset: 0 env(safe-area-inset-right) 0 env(safe-area-inset-left);
    height: var(--app-viewport-height, 100dvh);
    z-index: 250;
    overflow: hidden;
    transition: transform 0.2s ease;
  }
  .right-panel-container.right-panel-open {
    width: auto;
    min-width: 0;
  }
  .right-panel-container.right-panel-closed {
    width: 0 !important;
    min-width: 0 !important;
    border-left: none !important;
    display: none !important;
  }
  .right-panel-container > * {
    width: 100%;
    min-width: 0;
  }
  .panel-resize-handle,
  .right-panel-overlay-backdrop {
    display: none;
  }
  .directory-picker-back,
  .directory-picker-entry,
  .directory-picker-action {
    min-height: 44px !important;
  }
  .directory-picker-back {
    min-width: 44px !important;
  }
  .directory-picker-footer {
    flex-wrap: wrap;
    padding-bottom: max(10px, env(safe-area-inset-bottom)) !important;
  }
  textarea,
  input,
  select {
    font-size: 16px !important;
  }
}

/* Equaxis memory atlas */
.memory-dashboard-backdrop { position: fixed; inset: 0; z-index: 700; display: flex; align-items: stretch; justify-content: center; background: color-mix(in srgb, var(--bg) 78%, #000); }
.memory-dashboard { width: min(1180px, 100%); height: 100%; overflow: hidden; display: flex; flex-direction: column; background: var(--bg); color: var(--text); }
.memory-dashboard-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; padding: 30px 34px 24px; border-bottom: 1px solid var(--border); background: var(--bg-panel); }
.memory-kicker { color: var(--accent); font-size: 10px; font-weight: 700; letter-spacing: .14em; }
.memory-dashboard h1 { margin: 7px 0 5px; font-size: 24px; line-height: 1.1; font-weight: 650; }
.memory-dashboard-header p { margin: 0; color: var(--text-muted); font-size: 11px; overflow-wrap: anywhere; }
.memory-header-actions { display: flex; gap: 6px; }
.memory-icon-button { width: 34px; height: 34px; border: 1px solid var(--border); background: var(--bg); color: var(--text-muted); cursor: pointer; font-size: 18px; line-height: 1; }
.memory-icon-button:hover { color: var(--text); background: var(--bg-hover); }
.memory-dashboard-body { flex: 1; overflow: auto; padding: 22px 34px 40px; }
.memory-metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1px; margin-bottom: 24px; border: 1px solid var(--border); background: var(--border); }
.memory-metrics > div { min-height: 104px; display: flex; flex-direction: column; gap: 7px; padding: 16px 18px; background: var(--bg-panel); }
.memory-metrics span, .memory-metrics small { color: var(--text-muted); font-size: 11px; }
.memory-metrics strong { font-size: 28px; line-height: 1; font-weight: 600; font-variant-numeric: tabular-nums; }
.memory-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.memory-tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); }
.memory-tabs button { padding: 9px 12px; border: none; border-bottom: 2px solid transparent; background: none; color: var(--text-muted); cursor: pointer; font: inherit; font-size: 12px; }
.memory-tabs button.active { color: var(--text); border-bottom-color: var(--accent); }
.memory-toolbar input { width: min(300px, 42vw); height: 34px; padding: 0 11px; border: 1px solid var(--border); background: var(--bg-panel); color: var(--text); outline: none; font: inherit; font-size: 12px; }
.memory-toolbar input:focus { border-color: var(--accent); }
.memory-content-grid { display: grid; grid-template-columns: 210px minmax(0, 1fr); gap: 20px; align-items: start; }
.memory-rail { display: flex; flex-direction: column; gap: 2px; }
.memory-rail button { display: flex; justify-content: space-between; gap: 12px; padding: 10px 11px; border: none; background: none; color: var(--text-muted); cursor: pointer; text-align: left; font: inherit; font-size: 12px; }
.memory-rail button:hover, .memory-rail button.selected { background: var(--bg-selected); color: var(--text); }
.memory-rail b { color: var(--text-dim); font-weight: 500; }
.memory-list { display: grid; gap: 8px; }
.memory-entry { padding: 15px 17px; border: 1px solid var(--border); background: var(--bg-panel); }
.memory-entry-meta { display: flex; justify-content: space-between; gap: 12px; color: var(--accent); font-size: 10px; font-weight: 600; }
.memory-entry-meta em { color: var(--text-dim); font-style: normal; font-weight: 500; }
.memory-entry p { margin: 10px 0; color: var(--text); font: 13px/1.65 var(--font-mono); white-space: pre-wrap; overflow-wrap: anywhere; }
.memory-entry small { color: var(--text-dim); font-size: 10px; }
.memory-graph { min-height: 340px; border: 1px solid var(--border); background: var(--bg-panel); padding: 20px; }
.memory-graph-summary { display: flex; align-items: baseline; gap: 8px; padding-bottom: 18px; border-bottom: 1px solid var(--border); color: var(--text-muted); font-size: 12px; }
.memory-graph-summary strong { color: var(--text); font-size: 32px; font-weight: 600; }
.memory-fact-list { display: grid; gap: 8px; padding-top: 18px; }
.memory-fact { display: grid; grid-template-columns: minmax(80px, 1fr) minmax(80px, .7fr) minmax(80px, 1fr); align-items: center; gap: 10px; padding: 11px 13px; border: 1px solid var(--border); font: 12px var(--font-mono); overflow-wrap: anywhere; }
.memory-fact span { color: var(--accent); text-align: center; }
.memory-error, .memory-empty { padding: 34px; color: var(--text-muted); text-align: center; font-size: 12px; }
.memory-error button { margin-left: 12px; padding: 6px 10px; border: 1px solid var(--border); background: var(--bg-panel); color: var(--text); cursor: pointer; }
@media (max-width: 700px) { .memory-dashboard-header, .memory-dashboard-body { padding-left: 18px; padding-right: 18px; } .memory-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); } .memory-content-grid { grid-template-columns: 1fr; gap: 12px; } .memory-rail { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); } .memory-toolbar { align-items: stretch; flex-direction: column-reverse; gap: 10px; } .memory-toolbar input { width: 100%; } .memory-edit-fields { grid-template-columns: 1fr; } .memory-toolbar-right { flex-wrap: wrap; } }
/* Equaxis memory atlas — edit controls */
.memory-toolbar-right { display: flex; align-items: center; gap: 8px; }
.memory-add-toggle { height: 34px; padding: 0 12px; border: 1px dashed var(--border); background: none; color: var(--text-muted); cursor: pointer; font: inherit; font-size: 12px; }
.memory-add-toggle:hover, .memory-add-toggle.active { border-color: var(--accent); color: var(--accent); }
.memory-search-btn { height: 34px; padding: 0 12px; border: 1px solid var(--border); background: var(--bg-panel); color: var(--text-muted); cursor: pointer; font: inherit; font-size: 12px; }
.memory-search-btn:hover:not(:disabled) { color: var(--text); border-color: var(--accent); }
.memory-search-btn:disabled { opacity: 0.45; cursor: default; }
.memory-notice { color: #16a34a; font-size: 11px; align-self: center; }
.memory-semantic-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 0 10px; padding: 8px 12px; border: 1px solid var(--accent); background: color-mix(in srgb, var(--accent) 8%, var(--bg-panel)); color: var(--text-muted); font-size: 11px; }
.memory-semantic-header button { border: none; background: none; color: var(--text-muted); cursor: pointer; font: inherit; font-size: 12px; }
.memory-semantic-header button:hover { color: var(--text); }
.memory-actions { display: flex; justify-content: flex-end; gap: 6px; margin-top: 10px; }
.memory-action-btn { padding: 4px 10px; border: 1px solid var(--border); background: none; color: var(--text-muted); cursor: pointer; font: inherit; font-size: 11px; }
.memory-action-btn:hover:not(:disabled) { color: var(--text); }
.memory-action-btn.primary { border-color: var(--accent); background: var(--accent); color: #fff; }
.memory-action-btn.danger:hover:not(:disabled) { color: #dc2626; border-color: #dc2626; }
.memory-action-btn.danger.active { background: #dc2626; border-color: #dc2626; color: #fff; }
.memory-action-btn:disabled { opacity: 0.45; cursor: default; }
.memory-edit-area { margin-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.memory-edit-fields { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.memory-edit-fields label { display: flex; flex-direction: column; gap: 4px; color: var(--text-muted); font-size: 10px; font-weight: 600; }
.memory-edit-fields input, .memory-edit-fields select { height: 30px; padding: 0 9px; border: 1px solid var(--border); background: var(--bg); color: var(--text); outline: none; font: inherit; font-size: 12px; }
.memory-edit-fields input:focus, .memory-edit-fields select:focus { border-color: var(--accent); }
.memory-edit-area textarea, .memory-add-form textarea { min-height: 96px; padding: 9px 11px; border: 1px solid var(--border); background: var(--bg); color: var(--text); outline: none; resize: vertical; font: 12px/1.6 var(--font-mono); }
.memory-edit-area textarea:focus, .memory-add-form textarea:focus { border-color: var(--accent); }
.memory-add-form { margin-bottom: 16px; padding: 14px 16px; border: 1px solid var(--border); background: var(--bg-panel); display: flex; flex-direction: column; gap: 10px; }
/* Equaxis memory atlas — force-directed knowledge graph */
.memory-graph { min-height: 340px; border: 1px solid var(--border); background: var(--bg-panel); padding: 0; display: flex; flex-direction: column; overflow: hidden; }
.memory-graph-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 12px; border-bottom: 1px solid var(--border); }
.memory-graph-hint { color: var(--text-dim); font-size: 11px; }
.memory-graph-canvas { position: relative; flex: 1; min-height: 420px; }
.memory-graph-detail { position: absolute; top: 12px; right: 12px; width: min(300px, 60%); max-height: calc(100% - 24px); overflow-y: auto; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; box-shadow: 0 6px 20px rgba(0,0,0,0.15); }
.memory-graph-detail-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.memory-graph-detail-title strong { font-size: 13px; color: var(--text); overflow-wrap: anywhere; }
.memory-graph-detail-title button { border: none; background: none; color: var(--text-muted); cursor: pointer; font-size: 15px; line-height: 1; }
/* Equaxis harness dashboard — visual refresh */
.harness-backdrop { position: fixed; inset: 0; z-index: 700; display: flex; align-items: stretch; justify-content: center; background: color-mix(in srgb, var(--bg) 74%, #000); backdrop-filter: blur(6px); }
.harness-panel { position: relative; width: min(1180px, 100%); height: 100%; overflow: hidden; display: flex; flex-direction: column; background: var(--bg); color: var(--text); box-shadow: 0 24px 80px rgba(0,0,0,.45); }
.harness-panel::before { content: ""; position: absolute; top: 0; left: 0; right: 0; height: 3px; z-index: 5; background: linear-gradient(90deg, var(--accent), color-mix(in srgb, var(--accent) 35%, transparent)); }
.harness-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; padding: 30px 34px 22px; border-bottom: 1px solid var(--border); background: var(--bg-panel); }
.harness-kicker { color: var(--accent); font-size: 10px; font-weight: 700; letter-spacing: .18em; }
.harness-panel h1 { margin: 7px 0 5px; font-size: 24px; line-height: 1.1; font-weight: 650; }
.harness-header p { margin: 0; color: var(--text-muted); font-size: 11px; overflow-wrap: anywhere; }
.harness-header-actions { display: flex; gap: 6px; }
.harness-icon-button { width: 34px; height: 34px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); color: var(--text-muted); cursor: pointer; font-size: 18px; line-height: 1; transition: color .12s ease, background .12s ease, border-color .12s ease, transform .12s ease; }
.harness-icon-button:hover { color: var(--text); background: var(--bg-hover); border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); transform: translateY(-1px); }
.harness-icon-button:focus-visible { outline: 2px solid color-mix(in srgb, var(--accent) 60%, transparent); outline-offset: 1px; }
.harness-body { flex: 1; overflow: auto; padding: 22px 34px 40px; display: flex; flex-direction: column; gap: 22px; }
.harness-body > section { animation: harness-fade .18s ease; }
.harness-section-title { display: flex; align-items: center; gap: 10px; font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--text-muted); margin-bottom: 10px; }
.harness-ok-tag { padding: 2px 9px; border-radius: 999px; background: rgba(22,163,74,.14); color: #4ade80; font-size: 10px; font-weight: 600; }
.harness-bad-tag { padding: 2px 9px; border-radius: 999px; background: rgba(220,38,38,.14); color: #f87171; font-size: 10px; font-weight: 600; }
.harness-metrics { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 8px; }
.harness-metrics > div { display: flex; flex-direction: column; gap: 7px; padding: 13px 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg-panel); transition: transform .12s ease, border-color .12s ease; }
.harness-metrics > div:hover { transform: translateY(-1px); border-color: color-mix(in srgb, var(--accent) 35%, var(--border)); }
.harness-metrics span { color: var(--text-muted); font-size: 10px; }
.harness-metrics strong { font-size: 20px; line-height: 1; font-weight: 600; font-variant-numeric: tabular-nums; text-transform: capitalize; }
.harness-enforce { color: var(--accent); }
.harness-blocked { color: #f59e0b; }
.harness-failed { color: #f87171; }
.harness-metric-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 7px; vertical-align: 2px; }
.harness-metric-dot.on { background: #16a34a; box-shadow: 0 0 0 3px rgba(22,163,74,.16); }
.harness-metric-dot.off { background: #f87171; box-shadow: 0 0 0 3px rgba(220,38,38,.16); }
.harness-risk-pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 10px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; line-height: 1.3; }
.harness-risk-pill.low { background: rgba(22,163,74,.14); color: #4ade80; }
.harness-risk-pill.medium { background: rgba(245,158,11,.15); color: #fbbf24; }
.harness-risk-pill.high { background: rgba(220,38,38,.15); color: #f87171; }
.harness-risk-pill.blocked { background: rgba(220,38,38,.22); color: #fca5a5; }
.harness-progress { height: 4px; border-radius: 2px; background: var(--border); overflow: hidden; margin: 0 0 12px; }
.harness-progress > span { display: block; height: 100%; border-radius: 2px; background: linear-gradient(90deg, #16a34a, #4ade80); transition: width .3s ease; }
.harness-checks { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px 14px; }
.harness-check { display: flex; align-items: center; gap: 9px; padding: 6px 10px; border-radius: 8px; font-size: 12px; transition: background .12s ease; }
.harness-check:hover { background: color-mix(in srgb, var(--bg-hover) 70%, transparent); }
.harness-check-mark { flex-shrink: 0; display: inline-flex; width: 17px; height: 17px; border-radius: 50%; align-items: center; justify-content: center; font-size: 10px; }
.harness-check.ok .harness-check-mark { color: #16a34a; background: rgba(22,163,74,.14); }
.harness-check.bad .harness-check-mark { color: #f87171; background: rgba(220,38,38,.14); }
.harness-check-name { color: var(--text); white-space: nowrap; }
.harness-check.bad .harness-check-name { color: #f87171; }
.harness-check-detail { color: var(--text-dim); font: 10px var(--font-mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.harness-all-clear { margin-top: 8px; color: #16a34a; font-size: 12px; }
.harness-config-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; }
.harness-config-card { display: flex; flex-direction: column; gap: 5px; padding: 13px 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg-panel); font-size: 12px; transition: border-color .12s ease, transform .12s ease; }
.harness-config-card:hover { border-color: color-mix(in srgb, var(--accent) 30%, var(--border)); transform: translateY(-1px); }
.harness-config-card b { color: var(--text); font-size: 12px; margin-bottom: 2px; }
.harness-config-card span { color: var(--text-muted); overflow-wrap: anywhere; word-break: break-word; min-width: 0; }
.harness-config-card code { color: var(--text-dim); font: 10px var(--font-mono); overflow-wrap: anywhere; word-break: break-word; min-width: 0; }
.harness-eval-sortable { cursor: pointer; user-select: none; }
.harness-eval-sortable:hover { color: var(--text); }
.harness-eval-sort-ind { color: var(--accent); }
.harness-stream-grid { display: grid; grid-template-columns: 210px minmax(0, 1fr); gap: 18px; align-items: start; }
.harness-event-stats { display: flex; flex-direction: column; gap: 2px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg-panel); padding: 8px 10px; }
.harness-event-stat { display: flex; justify-content: space-between; gap: 10px; padding: 3px 0; font-size: 11px; color: var(--text-muted); }
.harness-event-stat b { color: var(--text-dim); font-weight: 500; font-variant-numeric: tabular-nums; }
.harness-recent { display: flex; flex-direction: column; gap: 2px; max-height: 360px; overflow-y: auto; }
.harness-event-row { display: flex; align-items: baseline; gap: 10px; padding: 4px 0; border-bottom: 1px solid var(--border); font-size: 11px; min-width: 0; }
.harness-event-time { color: var(--text-dim); font: 10px var(--font-mono); flex-shrink: 0; }
.harness-event-name { color: var(--text); flex-shrink: 0; font-weight: 500; }
.harness-event-name.bad { color: #f87171; }
.harness-event-row em { color: var(--text-dim); font-style: normal; font-size: 10px; flex-shrink: 0; }
.harness-event-tool { color: var(--accent); font: 10px var(--font-mono); flex-shrink: 0; }
.harness-event-risk { color: var(--text-muted); font-size: 10px; flex-shrink: 0; }
.harness-event-error { color: #f87171; font-size: 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.harness-error, .harness-empty { padding: 34px; color: var(--text-muted); text-align: center; font-size: 12px; }
.harness-empty { border: 1px dashed var(--border); border-radius: 12px; }
.harness-error button { margin-left: 12px; padding: 6px 10px; border: 1px solid var(--border); border-radius: 7px; background: var(--bg-panel); color: var(--text); cursor: pointer; }
/* harness tabs + trace browser + file browser */
.harness-tabs { display: flex; gap: 2px; padding: 0 34px; border-bottom: 1px solid var(--border); background: var(--bg-panel); flex-shrink: 0; }
.harness-tabs button { position: relative; padding: 11px 14px; border: none; border-bottom: 2px solid transparent; background: none; color: var(--text-muted); cursor: pointer; font: inherit; font-size: 12px; transition: color .14s ease; }
.harness-tabs button:hover { color: var(--text); }
.harness-tabs button.active { color: var(--text); border-bottom-color: var(--accent); }
.harness-tabs .harness-failures-tab { color: #f87171; }
.harness-tabs .harness-failures-tab.active { border-bottom-color: #f87171; }
.harness-tab-count { display: inline-block; margin-left: 5px; padding: 1px 7px; border-radius: 999px; background: var(--bg); color: var(--text-dim); font-size: 9px; font-weight: 600; line-height: 1.5; }
.harness-tabs button.active .harness-tab-count { background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent); }
.harness-tabs .harness-failures-tab .harness-tab-count { background: rgba(220,38,38,.12); color: #f87171; }
.harness-failure-link { border: none; background: none; color: #f87171; cursor: pointer; font: inherit; font-size: 11px; padding: 0; }
.harness-failure-link:hover { text-decoration: underline; }
.harness-events-toolbar { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.harness-events-toolbar select, .harness-events-toolbar input { height: 30px; padding: 0 9px; border: 1px solid var(--border); border-radius: 7px; background: var(--bg-panel); color: var(--text); outline: none; font: inherit; font-size: 12px; transition: border-color .12s ease; }
.harness-events-toolbar select:focus, .harness-events-toolbar input:focus { border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 18%, transparent); }
.harness-events-toolbar input { width: 180px; }
.harness-action-btn { padding: 5px 11px; border: 1px solid var(--border); border-radius: 7px; background: var(--bg-panel); color: var(--text-muted); cursor: pointer; font: inherit; font-size: 11px; transition: color .12s ease, border-color .12s ease; }
.harness-action-btn:hover:not(:disabled) { color: var(--text); border-color: var(--accent); }
.harness-action-btn:disabled { opacity: 0.4; cursor: default; }
.harness-failure-toggle { padding: 5px 11px; border: 1px solid var(--border); border-radius: 7px; background: var(--bg-panel); color: var(--text-muted); cursor: pointer; font: inherit; font-size: 11px; }
.harness-failure-toggle.active { border-color: #f87171; color: #f87171; background: rgba(220,38,38,.08); }
.harness-pagination { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 10px 0; font-size: 11px; color: var(--text-muted); }
.harness-event-list { display: flex; flex-direction: column; gap: 2px; }
.harness-event-row { display: flex; align-items: baseline; gap: 10px; padding: 6px 9px; border-bottom: 1px solid var(--border); border-left: 3px solid transparent; font-size: 11px; min-width: 0; flex-wrap: wrap; border-radius: 0 7px 7px 0; transition: background .12s ease; }
.harness-event-row[data-risk="high"] { border-left-color: rgba(220,38,38,.55); }
.harness-event-row[data-risk="medium"] { border-left-color: rgba(245,158,11,.55); }
.harness-event-row.clickable { cursor: pointer; }
.harness-event-row.clickable:hover { background: var(--bg-hover); }
.harness-event-row.failed { border-left: 3px solid #f87171; background: rgba(220,38,38,.05); }
.harness-event-session { color: var(--text-dim); font: 10px var(--font-mono); flex-shrink: 0; }
.harness-event-raw { flex-basis: 100%; margin: 6px 0 2px; padding: 10px; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; font: 10.5px/1.5 var(--font-mono); color: var(--text-muted); overflow-x: auto; white-space: pre-wrap; word-break: break-word; }
.harness-file-header { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; flex-wrap: wrap; }
.harness-file-path { font: 12px var(--font-mono); color: var(--text); }
.harness-file-meta { color: var(--text-dim); font-size: 11px; }
.harness-file-list { display: flex; flex-direction: column; gap: 2px; margin-bottom: 18px; }
.harness-file-item { display: flex; align-items: baseline; gap: 12px; padding: 6px 10px; border: none; border-bottom: 1px solid var(--border); background: none; color: var(--text-muted); cursor: pointer; text-align: left; font: inherit; font-size: 11px; min-width: 0; transition: background .12s ease; }
.harness-file-item:hover { background: var(--bg-hover); color: var(--text); }
.harness-file-kind { flex-shrink: 0; padding: 1px 8px; border-radius: 8px; background: var(--bg); color: var(--text-dim); font-size: 9px; text-transform: uppercase; }
.harness-file-kind.missing { color: #f87171; background: rgba(220,38,38,.1); }
.harness-file-item code { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 11px var(--font-mono); }
.harness-file-size { margin-left: auto; color: var(--text-dim); flex-shrink: 0; }
.harness-file-date { color: var(--text-dim); font-size: 10px; flex-shrink: 0; }
.harness-file-lines { display: flex; flex-direction: column; font: 11px/1.6 var(--font-mono); border: 1px solid var(--border); border-radius: 10px; background: var(--bg-panel); overflow: hidden; }
.harness-file-line { display: flex; gap: 12px; padding: 0 10px; }
.harness-file-line:hover { background: var(--bg-hover); }
.harness-line-n { flex-shrink: 0; width: 48px; text-align: right; color: var(--text-dim); user-select: none; }
.harness-line-text { margin: 0; flex: 1; white-space: pre-wrap; word-break: break-word; color: var(--text); }
/* harness eval + harbor panels */
.harness-metrics-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.harness-metrics-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.harness-eval-table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 10px; }
.harness-eval-table { width: 100%; border-collapse: collapse; font-size: 11px; white-space: nowrap; }
.harness-eval-table thead th { position: sticky; top: 0; z-index: 1; }
.harness-eval-table th { text-align: left; padding: 8px 10px; background: var(--bg-panel); color: var(--text-muted); font-weight: 600; border-bottom: 1px solid var(--border); }
.harness-eval-table td { padding: 7px 10px; border-bottom: 1px solid var(--border); color: var(--text); }
.harness-eval-table tbody tr:nth-child(even) td { background: color-mix(in srgb, var(--bg) 60%, var(--bg-panel)); }
.harness-eval-table tr:hover td { background: var(--bg-hover); }
.harness-eval-table code { font: 10.5px var(--font-mono); color: var(--accent); }
.harness-eval-caps { color: var(--text-muted); }
.harness-eval-errors { color: #f87171; }
.harness-rate { display: inline-block; padding: 1px 8px; border-radius: 999px; font-weight: 600; font-variant-numeric: tabular-nums; }
.harness-rate.ok { background: rgba(22,163,74,.14); color: #4ade80; }
.harness-rate.warn { background: rgba(245,158,11,.15); color: #fbbf24; }
.harness-rate.bad { background: rgba(220,38,38,.14); color: #f87171; }
.harness-rate.na { color: var(--text-dim); }
/* harness approvals */
.harness-approval-list { display: flex; flex-direction: column; gap: 10px; }
.harness-approval { border: 1px solid var(--border); border-radius: 10px; background: var(--bg-panel); padding: 13px 15px; }
.harness-approval.pending { border-color: rgba(245,158,11,.5); box-shadow: 0 0 0 3px rgba(245,158,11,.07); }
.harness-approval-meta { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.harness-pending-dot { width: 8px; height: 8px; border-radius: 50%; background: #f59e0b; box-shadow: 0 0 0 0 rgba(245,158,11,.5); animation: harness-pulse 1.6s infinite; flex-shrink: 0; }
.harness-approval-tool { color: var(--accent); font-weight: 600; font-size: 12px; }
.harness-approval-meta code { color: var(--text-dim); font: 10px var(--font-mono); }
.harness-approval-time { margin-left: auto; color: var(--text-dim); font-size: 10px; }
.harness-approval-reason { color: var(--text-muted); font-size: 11px; margin-bottom: 6px; }
.harness-approval-summary { margin: 0 0 10px; padding: 8px 10px; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; font: 11px/1.5 var(--font-mono); color: var(--text); white-space: pre-wrap; word-break: break-word; max-height: 160px; overflow-y: auto; }
.harness-actions-row { display: flex; gap: 8px; }
.harness-approve-btn { padding: 6px 15px; border: none; border-radius: 7px; background: #16a34a; color: #fff; cursor: pointer; font-size: 12px; font-weight: 600; transition: filter .12s ease, transform .12s ease; box-shadow: 0 1px 0 rgba(0,0,0,.18) inset; }
.harness-approve-btn:hover:not(:disabled) { background: #15803d; filter: brightness(1.05); transform: translateY(-1px); }
.harness-deny-btn { padding: 6px 15px; border: none; border-radius: 7px; background: #dc2626; color: #fff; cursor: pointer; font-size: 12px; font-weight: 600; transition: filter .12s ease, transform .12s ease; box-shadow: 0 1px 0 rgba(0,0,0,.18) inset; }
.harness-deny-btn:hover:not(:disabled) { background: #b91c1c; filter: brightness(1.05); transform: translateY(-1px); }
.harness-approve-btn:disabled, .harness-deny-btn:disabled { opacity: 0.5; cursor: default; transform: none; }
.harness-history-row { display: flex; align-items: baseline; gap: 10px; padding: 6px 10px; border-bottom: 1px solid var(--border); font-size: 11px; }
.harness-history-row code { color: var(--text-dim); font: 10px var(--font-mono); }
.harness-approved { color: #16a34a; text-transform: uppercase; font-size: 10px; font-weight: 600; }
.harness-denied { color: #f87171; text-transform: uppercase; font-size: 10px; font-weight: 600; }
/* harness settings panel */
.harness-settings-grid { display: grid; grid-template-columns: 210px minmax(0, 1fr); gap: 18px; align-items: start; }
.harness-settings-nav { display: flex; flex-direction: column; gap: 2px; border: 1px solid var(--border); background: var(--bg-panel); padding: 6px; }
.harness-settings-nav button { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; padding: 7px 10px; border: none; background: none; color: var(--text-muted); cursor: pointer; text-align: left; font: inherit; font-size: 12px; }
.harness-settings-nav button:hover { background: var(--bg-hover); color: var(--text); }
.harness-settings-nav button.selected { background: var(--bg-selected); color: var(--text); }
.harness-settings-nav em { font-style: normal; font-size: 9px; color: var(--text-dim); }
.harness-settings-desc { color: var(--text-dim); font-size: 11px; font-weight: 400; text-transform: none; letter-spacing: 0; }
.harness-config-row { border: 1px solid var(--border); background: var(--bg-panel); padding: 10px 12px; margin-bottom: 8px; }
.harness-config-row-head { display: flex; align-items: baseline; gap: 10px; }
.harness-config-key { font-size: 12px; font-weight: 600; color: var(--text); }
.harness-config-path { margin-left: auto; color: var(--text-dim); font: 10px var(--font-mono); }
.harness-layer-badge { flex-shrink: 0; padding: 0 7px; border-radius: 8px; font-size: 9px; text-transform: uppercase; }
.harness-layer-badge.default { background: var(--bg); color: var(--text-dim); }
.harness-layer-badge.global { background: rgba(59,130,246,.14); color: #60a5fa; }
.harness-layer-badge.project { background: rgba(22,163,74,.14); color: #16a34a; }
.harness-config-desc { color: var(--text-muted); font-size: 11px; margin: 4px 0 8px; }
.harness-config-value { display: flex; align-items: center; gap: 10px; }
.harness-config-value code { font: 11px var(--font-mono); color: var(--text); overflow-wrap: anywhere; word-break: break-word; flex: 1; }
.harness-config-readonly { color: var(--text-dim); font-size: 10px; }
.harness-config-edit { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.harness-config-edit input, .harness-config-edit select { height: 30px; padding: 0 9px; border: 1px solid var(--border); background: var(--bg); color: var(--text); outline: none; font: 12px var(--font-mono); min-width: 220px; }
.harness-config-edit input:focus, .harness-config-edit select:focus { border-color: var(--accent); }
@media (max-width: 900px) { .harness-settings-grid { grid-template-columns: 1fr; } }
.harness-spinner { display: inline-block; width: 13px; height: 13px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: harness-spin .7s linear infinite; vertical-align: -2px; margin-right: 7px; }
@keyframes harness-spin { to { transform: rotate(360deg); } }
@keyframes harness-pulse { 0% { box-shadow: 0 0 0 0 rgba(245,158,11,.45); } 70% { box-shadow: 0 0 0 7px rgba(245,158,11,0); } 100% { box-shadow: 0 0 0 0 rgba(245,158,11,0); } }
@keyframes harness-fade { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }
@media (max-width: 900px) { .harness-metrics { grid-template-columns: repeat(4, minmax(0, 1fr)); } .harness-checks { grid-template-columns: 1fr; } .harness-stream-grid { grid-template-columns: 1fr; } }
@media (max-width: 700px) { .harness-header, .harness-body, .harness-tabs { padding-left: 18px; padding-right: 18px; } .harness-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
