.settings-view-shell,
.style-view,
.tags-view-shell,
.scripts-view-shell,
.templates-view-shell,
.chat-panel {
  height: 100%;
  background: var(--vscode-editor-background);
}

.chat-panel {
  color: var(--vscode-editor-foreground);
}

.chat-panel-header {
  border-bottom: 1px solid var(--vscode-panel-border);
  background: var(--vscode-sideBar-background);
}

.chat-panel-title {
  flex: 1;
  min-width: 0;
  gap: 10px;
  overflow: visible;
  font-size: 14px;
  font-weight: 600;
}

.chat-panel-title-main {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-panel-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.chat-model-selector-wrap {
  position: relative;
  display: inline-flex;
  min-width: 0;
}

.chat-model-selector-button,
.chat-model-selector-option {
  border: 1px solid var(--vscode-input-border);
  background: var(--vscode-input-background);
  color: var(--vscode-input-foreground);
}

.chat-model-selector-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: auto;
  border: 1px solid var(--vscode-dropdown-border, var(--vscode-panel-border));
  background: var(--vscode-dropdown-background, var(--vscode-sideBar-background));
  color: var(--vscode-dropdown-foreground, var(--vscode-foreground));
  z-index: 20;
}

.chat-panel .chat-model-selector-button.chat-model-selector-inline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.chat-panel .chat-model-selector-caret {
  position: static;
  font-size: 10px;
}

.chat-messages,
.chat-surface-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.chat-messages {
}

.chat-message {
  display: flex;
  max-width: 100%;
  margin-bottom: 16px;
}

.chat-message.user {
  flex-direction: row-reverse;
}

.chat-message-content {
  max-width: min(760px, 100%);
  border: 1px solid var(--vscode-panel-border);
  border-radius: 6px;
  padding: 12px 14px;
  background: var(--vscode-sideBar-background);
  color: var(--vscode-editor-foreground);
}

.chat-panel .chat-message.user .chat-message-content {
  background: var(--vscode-button-background, var(--accent-color, #007acc));
  color: var(--vscode-button-foreground, var(--vscode-list-activeSelectionForeground, #ffffff));
  border: 1px solid var(--vscode-button-background, var(--accent-color, #007acc));
  border-radius: 6px;
  padding: 12px 14px;
  line-height: 1.35;
}

.chat-tool-surface-table {
  width: 100%;
  border-collapse: collapse;
}

.chat-tool-surface-table th,
.chat-tool-surface-table td {
  border-bottom: 1px solid var(--vscode-panel-border);
  padding: 6px 8px;
  text-align: left;
}

.chat-tool-surface-json {
  overflow: auto;
  padding: 10px 12px;
  border: 1px solid var(--vscode-panel-border);
  border-radius: 4px;
  background: var(--vscode-textCodeBlock-background);
}

/* ── Inline surfaces (<details> wrappers) ──────────────────────────── */

.chat-inline-surface {
  margin: 10px 0;
  border: 1px solid var(--vscode-panel-border);
  border-radius: 6px;
  background: var(--vscode-sideBar-background);
  overflow: hidden;
}

.chat-inline-surface-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  cursor: pointer;
  user-select: none;
  list-style: none;
  font-size: 12px;
  color: var(--vscode-descriptionForeground);
}

.chat-inline-surface-header::-webkit-details-marker {
  display: none;
}

.chat-inline-surface-header::marker {
  content: "";
}

.chat-inline-surface-icon {
  flex: 0 0 auto;
  font-size: 14px;
  line-height: 1;
  opacity: 0.7;
}

.chat-inline-surface-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
  color: var(--vscode-editor-foreground);
}

.chat-inline-surface-dismiss {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  padding: 0;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--vscode-descriptionForeground);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s;
}

.chat-inline-surface:hover .chat-inline-surface-dismiss {
  opacity: 1;
}

.chat-inline-surface-dismiss:hover {
  background: var(--vscode-toolbar-hoverBackground);
  color: var(--vscode-editor-foreground);
}

.chat-inline-surface-body {
  padding: 0 12px 12px;
}

.chat-inline-surface-body h3 {
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--vscode-editor-foreground);
}

/* ── Chart surface ─────────────────────────────────────────────────── */

.chat-surface-chart-type {
  margin: 0 0 8px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--vscode-descriptionForeground);
  display: none;
}

.chat-surface-chart-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.chat-surface-chart-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.chat-surface-chart-meta {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 12px;
}

.chat-surface-chart-meta span:first-child {
  color: var(--vscode-editor-foreground);
}

.chat-surface-chart-meta span:last-child {
  color: var(--vscode-descriptionForeground);
  font-variant-numeric: tabular-nums;
}

.chat-surface-chart-bar {
  height: 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.06);
  overflow: hidden;
}

.chat-surface-chart-bar span {
  display: block;
  height: 100%;
  border-radius: 3px;
  background: var(--accent-color);
  min-width: 0;
  transition: width 0.3s ease;
}

/* Stacked bars: segments sit side by side inside the track. */
.chat-surface-chart-bar-stacked {
  display: flex;
}

.chat-surface-chart-bar-segment {
  display: block;
  height: 100%;
  min-width: 0;
  transition: width 0.3s ease;
}

/* Shared legend (pie/donut/stacked-bar). */
.chat-surface-chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 8px;
  font-size: 11px;
}

.chat-surface-chart-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--vscode-descriptionForeground);
}

.chat-surface-chart-legend-swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
}

/* Pie / donut. */
.chat-surface-chart-pie {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.chat-surface-chart-pie-svg {
  width: 140px;
  height: 140px;
}

.chat-surface-chart-pie-slice {
  stroke: var(--vscode-editor-background, #1e1e1e);
  stroke-width: 1;
}

.chat-surface-chart-donut-hole {
  fill: var(--vscode-editor-background, #1e1e1e);
}

.chat-surface-chart-donut-total {
  fill: var(--vscode-editor-foreground);
  font-size: 16px;
  font-weight: 600;
}

/* Line / area. */
.chat-surface-chart-line-svg {
  width: 100%;
  height: auto;
}

.chat-surface-chart-line-grid {
  stroke: rgba(255, 255, 255, 0.08);
  stroke-width: 1;
}

.chat-surface-chart-line-y-label,
.chat-surface-chart-line-x-label {
  fill: var(--vscode-descriptionForeground);
  font-size: 9px;
}

.chat-surface-chart-line-path {
  stroke: var(--accent-color);
  stroke-width: 2;
}

.chat-surface-chart-area-fill {
  fill: var(--accent-color);
  opacity: 0.18;
}

.chat-surface-chart-line-dot {
  fill: var(--accent-color);
}

/* Heatmap. */
.chat-surface-chart-heatmap {
  display: grid;
  gap: 2px;
  font-size: 11px;
}

.chat-surface-chart-heatmap-corner {
  /* empty top-left cell */
}

.chat-surface-chart-heatmap-col-label {
  text-align: center;
  opacity: 0.7;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-surface-chart-heatmap-row-label {
  text-align: right;
  padding-right: 4px;
  opacity: 0.7;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 80px;
}

.chat-surface-chart-heatmap-cell {
  aspect-ratio: 1;
  min-width: 14px;
  min-height: 14px;
  border-radius: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

/* ── Card surface ──────────────────────────────────────────────────── */

.chat-surface-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.chat-surface-subtitle {
  margin: 0;
  font-size: 12px;
  color: var(--vscode-descriptionForeground);
}

.chat-surface-body {
  margin: 0;
  font-size: 13px;
  line-height: 1.45;
}

.chat-surface-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.chat-surface-action-button {
  padding: 4px 12px;
  border: 1px solid var(--vscode-input-border);
  border-radius: 4px;
  background: var(--vscode-input-background);
  color: var(--vscode-editor-foreground);
  font-size: 12px;
  cursor: pointer;
}

.chat-surface-action-button:hover {
  background: var(--vscode-list-hoverBackground);
}

/* ── Metric surface ────────────────────────────────────────────────── */

.chat-surface-metric {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.chat-surface-metric-label {
  font-size: 12px;
  color: var(--vscode-descriptionForeground);
}

.chat-surface-metric-value {
  font-size: 22px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--vscode-editor-foreground);
}

/* ── List surface ──────────────────────────────────────────────────── */

.chat-surface-list {
  margin: 0;
  padding: 0 0 0 18px;
  font-size: 13px;
  line-height: 1.5;
}

/* ── Mindmap surface ───────────────────────────────────────────────── */

.chat-surface-mindmap {
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 13px;
}

.chat-surface-mindmap li {
  padding: 4px 0;
  border-bottom: 1px solid var(--vscode-panel-border);
}

.chat-surface-mindmap li:last-child {
  border-bottom: none;
}

.chat-surface-mindmap strong {
  display: block;
  color: var(--vscode-editor-foreground);
}

.chat-surface-mindmap-children {
  display: block;
  font-size: 12px;
  color: var(--vscode-descriptionForeground);
  padding-left: 12px;
}

/* ── Tabs surface ──────────────────────────────────────────────────── */

.chat-surface-tabs {
  display: flex;
  flex-direction: column;
}

.chat-surface-tab-list {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--vscode-panel-border);
}

.chat-surface-tab-button {
  padding: 6px 12px;
  border: none;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--vscode-descriptionForeground);
  font-size: 12px;
  cursor: pointer;
}

.chat-surface-tab-button.active {
  color: var(--vscode-editor-foreground);
  border-bottom-color: var(--accent-color);
}

.chat-surface-tab-button:hover:not(.active) {
  color: var(--vscode-editor-foreground);
}

.chat-surface-tab-panel {
  padding: 10px 0 0;
}

/* ── Form surface ──────────────────────────────────────────────────── */

.chat-surface-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chat-surface-form-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--vscode-descriptionForeground);
}

.chat-surface-form-field input,
.chat-surface-form-field textarea,
.chat-surface-form-field select {
  padding: 5px 8px;
  border: 1px solid var(--vscode-input-border);
  border-radius: 4px;
  background: var(--vscode-input-background);
  color: var(--vscode-input-foreground);
  font: inherit;
}

.chat-surface-form-field textarea {
  min-height: 60px;
  resize: vertical;
}

.chat-surface-form-checkbox {
  display: flex;
  align-items: center;
}

/* ── Text surface ──────────────────────────────────────────────────── */

.chat-surface-text {
  font-size: 13px;
  line-height: 1.45;
  white-space: pre-wrap;
}

/* ── Table surface wrapper ─────────────────────────────────────────── */

.chat-tool-surface-table-wrap {
  overflow-x: auto;
}

.chat-panel .chat-input-container {
  --chat-input-line-height: 22px;
  --chat-input-min-height: 24px;
  border-top: 1px solid var(--vscode-panel-border);
  padding: 12px 16px;
  background: var(--vscode-sideBar-background);
}

.chat-panel .chat-input-wrapper {
  min-height: 40px;
  border: 1px solid var(--vscode-input-border);
  border-radius: 8px;
  padding: 6px 8px;
  background: var(--vscode-input-background);
}

.chat-panel .chat-input-wrapper:focus-within {
  border-color: var(--vscode-focusBorder);
}

.chat-panel .chat-input {
  flex: 1;
  box-sizing: border-box;
  height: var(--chat-input-min-height);
  min-height: var(--chat-input-min-height);
  margin: 0;
  padding: 6px 8px;
  line-height: var(--chat-input-line-height);
  max-height: 160px;
  resize: vertical;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--vscode-input-foreground);
  overflow-y: hidden;
}

.chat-panel .chat-input:focus {
  outline: none;
}

.chat-panel .chat-input::placeholder {
  color: var(--vscode-input-placeholderForeground);
}

.chat-panel .chat-send-button {
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  max-width: 22px;
  max-height: 22px;
  padding: 0;
  background: var(--vscode-button-background);
  color: var(--vscode-button-foreground);
}

.chat-panel .chat-send-button:hover:not(:disabled) {
  background: var(--vscode-button-hoverBackground);
}

.chat-panel .chat-send-button:disabled {
  opacity: 0.5;
}

@media (max-width: 720px) {
  .chat-panel-header {
    align-items: stretch;
    flex-direction: column;
    padding: 10px 12px;
  }

  .chat-panel-title {
    width: 100%;
    flex-wrap: wrap;
  }

  .chat-model-selector-wrap {
    width: 100%;
  }

  .chat-panel .chat-model-selector-button.chat-model-selector-inline {
    justify-content: space-between;
    width: 100%;
  }

  .chat-messages {
    padding: 12px;
  }

  .chat-message-content {
    max-width: 100%;
  }

  .chat-panel .chat-input-container {
    padding: 8px 12px;
  }
}

/* Colour picker popover */
.colour-picker-wrap {
  position: relative;
  display: inline-flex;
}

.colour-picker-trigger {
  width: 28px;
  height: 28px;
  border-radius: 4px;
  border: 1px solid var(--vscode-input-border);
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
}

.colour-picker-trigger:hover {
  opacity: 0.85;
}

.colour-picker-popover {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 30;
  padding: 8px;
  border: 1px solid var(--vscode-dropdown-border, var(--vscode-panel-border));
  border-radius: 6px;
  background: var(--vscode-dropdown-background, var(--vscode-sideBar-background));
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
  width: 196px;
}

.colour-picker-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 4px;
}

.colour-picker-swatch {
  width: 24px;
  height: 24px;
  border-radius: 4px;
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
  transition: border-color 0.1s;
}

.colour-picker-swatch:hover {
  border-color: var(--vscode-focusBorder);
}

.colour-picker-swatch.selected {
  border-color: var(--vscode-focusBorder);
  box-shadow: 0 0 0 1px var(--vscode-focusBorder);
}

.colour-picker-custom {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--vscode-panel-border);
}

.colour-picker-custom label {
  font-size: 11px;
  color: var(--vscode-descriptionForeground);
  white-space: nowrap;
}

.colour-picker-custom input {
  flex: 1;
  min-width: 0;
  font-size: 12px;
  padding: 2px 6px;
  border: 1px solid var(--vscode-input-border);
  border-radius: 3px;
  background: var(--vscode-input-background);
  color: var(--vscode-input-foreground);
  font-family: monospace;
}
