/* Editor theme mapping */
@theme {
	--color-cline: #9663f1;
	--color-background: var(--vscode-sideBar-background);
	--color-border: var(--vscode-focusBorder);
	--color-border-panel: var(--vscode-panel-border);
	--color-foreground: var(--vscode-foreground);
	--color-shadow: var(--vscode-widget-shadow);
	--color-code: var(--vscode-editor-background);
	--color-code-foreground: var(--vscode-editor-foreground);
	--color-code-border: var(--vscode-editor-border);
	--color-code-block-background: var(
		--vscode-textCodeBlock-background,
		--vscode-editor-background,
		--vscode-sideBar-background,
		rgb(30 30 30)
	);
	--color-quote: var(--vscode-textBlockQuote-background);
	--color-quote-foreground: var(--vscode-textBlockQuote-foreground);
	--color-text-block-background: var(--vscode-textCodeBlock-background);
	--color-editor-group-border: var(--vscode-editorGroup-border);
	--color-editor-widget-border: var(--vscode-editorWidget-border, #cccccc);
	--color-editor-warning-foreground: var(--vscode-editorWarning-foreground);
	--color-sidebar-background: var(--vscode-sideBar-background);
	--color-sidebar-foreground: var(--vscode-sideBar-foreground);
	--color-input-foreground: var(--vscode-input-foreground);
	--color-input-background: var(--vscode-input-background);
	--color-input-border: var(--vscode-input-border);
	--color-input-placeholder: var(--vscode-input-placeholderForeground);
	--color-input-error-background: var(--vscode-inputValidation-errorBackground, #a82424);
	--color-input-error-foreground: var(--vscode-inputValidation-errorForeground, #8f1f1f);
	--color-selection: var(--vscode-list-activeSelectionBackground);
	--color-selection-foreground: var(--vscode-list-activeSelectionForeground);
	--color-selection-inactive: var(--vscode-editor-inactiveSelectionBackground);
	--color-button-background: var(--vscode-button-background);
	--color-button-hover: var(--vscode-button-hoverBackground);
	--color-button-foreground: var(--vscode-button-foreground);
	--color-button-separator: var(--vscode-button-separator);
	--color-text-separator: var(--vscode-textSeparator-foreground, #424242);
	--color-button-secondary-background: var(--vscode-button-secondaryBackground);
	--color-button-secondary-background-hover: var(--vscode-button-secondaryHoverBackground);
	--color-button-secondary-foreground: var(--vscode-button-secondaryForeground);
	--color-muted: color-mix(in srgb, var(--vscode-toolbar-hoverBackground) 65%, transparent);
	--color-muted-foreground: var(--vscode-editor-foldPlaceholderForeground);
	--color-menu: var(--vscode-menu-background);
	--color-menu-foreground: var(--vscode-menu-foreground);
	--color-menu-border: var(--vscode-menu-border);
	--color-menu-shadow: var(--vscode-menu-shadow);
	--color-preformat: var(--vscode-textPreformat-foreground, #f78383);
	--color-link: var(--vscode-textLink-foreground);
	--color-link-hover: var(--vscode-textLink-activeForeground);
	--color-list-hover: var(--vscode-list-hoverBackground);
	--color-badge-foreground: var(--vscode-badge-foreground);
	--color-badge-background: var(--vscode-badge-background);
	--color-banner-background: var(--vscode-banner-background);
	--color-banner-foreground: var(--vscode-banner-foreground);
	--color-banner-icon: var(--vscode-banner-iconForeground);
	--color-editor-match-highlight: var(--vscode-editor-findMatchHighlightBackground);
	--color-icon-foreground: var(--vscode-icon-foreground);
	--color-notification-foreground: var(--vscode-notificationsInfoIcon-foreground);
	--color-toolbar-default: var(--vscode-toolbar-background);
	--color-toolbar-hover: var(--vscode-toolbar-hoverBackground);
	--color-diff-added: var(--vscode-diffEditor-insertedTextBackground);
	--color-diff-removed: var(--vscode-diffEditor-removedTextBackground);
	--color-error: var(--vscode-errorForeground);
	--color-error-icon: var(--vscode-problemsErrorIcon-foreground);
	--color-failed-icon: var(--vscode-testing-iconFailed);
	--color-error: var(--vscode-errorForeground, #c42b2b);
	--color-error-icon: var(--vscode-problemsErrorIcon-foreground, #c42b2b);
	--color-description: var(--vscode-descriptionForeground);
	--color-success: var(--vscode-charts-green);
	--color-brand-accent: #d76947;
	/* Adsum brand palette — Direction A (dual-brand). Centered on logo cyan. */
	--color-brand-primary: #00a9ce;
	--color-brand-primary-light: #6fd2e6;
	--color-brand-primary-hover: #19b6d8;
	--color-brand-primary-active: #0089a8;
	--color-brand-secondary: #d76947;
	--color-brand-secondary-hover: #e07d5f;
	--color-brand-secondary-active: #c0542f;
	--color-warning: var(--vscode-charts-yellow);
	--font-base:
		var(--vscode-font-family), system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell,
		"Open Sans", "Helvetica Neue", sans-serif;
	--font-mono:
		var(--vscode-editor-font-family), ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New",
		monospace;
	--font-azeret-mono: Azeret Mono, monospace;
	--font-editor: var(--vscode-editor-font-family);
	--text-editor-size: var(--vscode-editor-font-size);
	--text-2xl: calc(2.25 * var(--vscode-font-size));
	--text-xl: calc(2 * var(--vscode-font-size));
	--text-lg: calc(1.5 * var(--vscode-font-size));
	--text-md: calc(1.25 * var(--vscode-font-size));
	--text-base: var(--vscode-font-size, 14px);
	--text-sm: calc(0.95 * var(--vscode-font-size));
	--text-xs: calc(0.85 * var(--vscode-font-size));
	--text-xxs: calc(0.5 * var(--vscode-font-size));
	--breakpoint-xs: 400px;
	--radius-half: 50%;
	--radius-xs: 2px;
	--breakpoint-xxs: 180px;

	--animate-fade-in: fadeIn 0.4s ease-out forwards;
	@keyframes fadeIn {
		from {
			opacity: 0;
			transform: scale(0.98);
		}
		to {
			opacity: 1;
			transform: scale(1);
		}
	}

	--animate-cursor-blink: cursorBlink 1s ease-in-out infinite;
	@keyframes cursorBlink {
		0%,
		100% {
			opacity: 1;
		}
		50% {
			opacity: 0;
		}
	}

	--animate-icon-pulse: iconPulse 1s ease-in-out infinite;
	@keyframes iconPulse {
		0%,
		100% {
			opacity: 0.5;
		}
		50% {
			opacity: 1;
		}
	}

	--animate-shimmer: shimmer 5s infinite linear;
	@keyframes shimmer {
		0% {
			background-position: 200% 0;
		}
		100% {
			background-position: -200% 0;
		}
	}

	--animate-fade-slide-in: fadeSlideIn 0.6s cubic-bezier(0.16, 1, 0.3, 1);
	@keyframes fadeSlideIn {
		from {
			opacity: 0;
			transform: translateY(-12px);
		}
		to {
			opacity: 1;
			transform: translateY(0);
		}
	}

	--animate-thinking-dots: thinkingDots 1.2s steps(1, end) infinite;
	@keyframes thinkingDots {
		0%,
		33% {
			content: ".";
		}
		34%,
		66% {
			content: "..";
		}
		67%,
		100% {
			content: "...";
		}
	}
}

@theme inline {
	--radius-sm: calc(var(--radius) - 4px);
	--radius-md: calc(var(--radius) - 2px);
	--radius-lg: var(--radius);
	--radius-xl: calc(var(--radius) + 4px);
	--color-card: var(--card);
	--color-card-foreground: var(--card-foreground);
	--color-popover: var(--popover);
	--color-popover-foreground: var(--popover-foreground);
	--color-primary: var(--primary);
	--color-primary-foreground: var(--primary-foreground);
	--color-secondary: var(--secondary);
	--color-secondary-foreground: var(--secondary-foreground);
	--color-muted: color-mix(in srgb, var(--vscode-toolbar-hoverBackground) 65%, transparent);
	--color-muted-foreground: var(--muted-foreground);
	--color-accent: var(--accent);
	--color-accent-foreground: var(--accent-foreground);
	--color-destructive: var(--destructive);
	--color-border: var(--border);
	--color-input: var(--input);
	--color-ring: var(--ring);
	--color-chart-1: var(--chart-1);
	--color-chart-2: var(--chart-2);
	--color-chart-3: var(--chart-3);
	--color-chart-4: var(--chart-4);
	--color-chart-5: var(--chart-5);
	--color-sidebar: var(--sidebar);
	--color-sidebar-foreground: var(--sidebar-foreground);
	--color-sidebar-primary: var(--sidebar-primary);
	--color-sidebar-primary-foreground: var(--sidebar-primary-foreground);
	--color-sidebar-accent: var(--sidebar-accent);
	--color-sidebar-accent-foreground: var(--sidebar-accent-foreground);
	--color-sidebar-border: var(--sidebar-border);
	--color-sidebar-ring: var(--sidebar-ring);
	--size-1: calc(0.85 * var(--vscode-font-size));
	--size-2: calc(1 * var(--vscode-font-size));
	--size-3: calc(1.25 * var(--vscode-font-size));
	--size-4: calc(1.5 * var(--vscode-font-size));
	--size-5: calc(2 * var(--vscode-font-size));
}

:root {
	--radius: 0.625rem;
	--background: oklch(1 0 0);
	--foreground: oklch(0.145 0 0);
	--card: oklch(1 0 0);
	--card-foreground: oklch(0.145 0 0);
	--popover: oklch(1 0 0);
	--popover-foreground: oklch(0.145 0 0);
	--primary: oklch(0.205 0 0);
	--primary-foreground: oklch(0.985 0 0);
	--secondary: oklch(0.97 0 0);
	--secondary-foreground: oklch(0.205 0 0);
	--muted: oklch(0.97 0 0);
	--muted-foreground: oklch(0.556 0 0);
	--accent: oklch(0.97 0 0);
	--accent-foreground: oklch(0.205 0 0);
	--destructive: oklch(0.577 0.245 27.325);
	--border: oklch(0.922 0 0);
	--input: oklch(0.922 0 0);
	--ring: oklch(0.708 0 0);
	--chart-1: oklch(0.646 0.222 41.116);
	--chart-2: oklch(0.6 0.118 184.704);
	--chart-3: oklch(0.398 0.07 227.392);
	--chart-4: oklch(0.828 0.189 84.429);
	--chart-5: oklch(0.769 0.188 70.08);
	--sidebar: oklch(0.985 0 0);
	--sidebar-foreground: oklch(0.145 0 0);
	--sidebar-primary: oklch(0.205 0 0);
	--sidebar-primary-foreground: oklch(0.985 0 0);
	--sidebar-accent: oklch(0.97 0 0);
	--sidebar-accent-foreground: oklch(0.205 0 0);
	--sidebar-border: oklch(0.922 0 0);
	--sidebar-ring: oklch(0.708 0 0);
}

.dark {
	--background: oklch(0.145 0 0);
	--foreground: oklch(0.985 0 0);
	--card: oklch(0.205 0 0);
	--card-foreground: oklch(0.985 0 0);
	--popover: oklch(0.205 0 0);
	--popover-foreground: oklch(0.985 0 0);
	--primary: oklch(0.922 0 0);
	--primary-foreground: oklch(0.205 0 0);
	--secondary: oklch(0.269 0 0);
	--secondary-foreground: oklch(0.985 0 0);
	--muted: oklch(0.269 0 0);
	--muted-foreground: oklch(0.708 0 0);
	--accent: oklch(0.269 0 0);
	--accent-foreground: oklch(0.985 0 0);
	--destructive: oklch(0.704 0.191 22.216);
	--border: oklch(1 0 0 / 10%);
	--input: oklch(1 0 0 / 15%);
	--ring: oklch(0.556 0 0);
	--chart-1: oklch(0.488 0.243 264.376);
	--chart-2: oklch(0.696 0.17 162.48);
	--chart-3: oklch(0.769 0.188 70.08);
	--chart-4: oklch(0.627 0.265 303.9);
	--chart-5: oklch(0.645 0.246 16.439);
	--sidebar: oklch(0.205 0 0);
	--sidebar-foreground: oklch(0.985 0 0);
	--sidebar-primary: oklch(0.488 0.243 264.376);
	--sidebar-primary-foreground: oklch(0.985 0 0);
	--sidebar-accent: oklch(0.269 0 0);
	--sidebar-accent-foreground: oklch(0.985 0 0);
	--sidebar-border: oklch(1 0 0 / 10%);
	--sidebar-ring: oklch(0.556 0 0);
}

@layer utilities {
	/**
	 * Variant that becomes visible when focused
	 * Useful for skip links and other keyboard navigation aids
	 */
	.sr-only-focusable:focus {
		position: static;
		width: auto;
		height: auto;
		padding: inherit;
		margin: inherit;
		overflow: visible;
		clip: auto;
		white-space: normal;
	}

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

	.animate-flash {
		animation: flash 1.5s ease-in-out infinite;
	}

	.inline-markdown-block {
		@apply text-base text-foreground font-base;

		pre {
			@apply bg-code rounded-xs overflow-x-auto overflow-y-hidden;
			margin: 13px 0;
			padding: 10px 10px;
			max-width: calc(100vw - 20px);
			padding-right: 70px;
		}

		pre > code .hljs-deletion {
			@apply inline-block w-full bg-diff-removed;
			color: var(--vscode-editor-foreground);
		}

		pre > code .hljs-addition {
			@apply inline-block w-full bg-diff-added;
			color: var(--vscode-editor-foreground);
		}

		code span.line:empty {
			@apply hidden;
		}
		code {
			@apply break-words rounded-xs;
		}

		/* Wide tables in the narrow side panel must SCROLL, not collapse to one-char-per-line.
		   display:block + max-content + max-width:100% makes the table a horizontal-scroll container when its
		   natural width exceeds the panel, and shrink-to-fit when it doesn't; the cell min-width is the hard
		   floor that stops the per-character collapse. (CRA posture tables are authored as stacked blocks now —
		   this is the renderer-level backstop for any other wide markdown table.) */
		table {
			@apply border-collapse my-4 text-sm;
			display: block;
			width: max-content;
			max-width: 100%;
			overflow-x: auto;
			border: 1px solid var(--vscode-editorGroup-border, rgba(255, 255, 255, 0.1));
		}
		th,
		td {
			border: 1px solid var(--vscode-editorGroup-border, rgba(255, 255, 255, 0.1));
			padding: 6px 12px;
			text-align: left;
			min-width: 7rem;
			vertical-align: top;
		}
		th {
			background: var(--vscode-editor-background, rgba(0, 0, 0, 0.2));
			font-weight: 600;
		}
		tr:nth-child(even) {
			background: rgba(255, 255, 255, 0.03);
		}

		p,
		li,
		ol,
		ul {
			@apply leading-tight;
		}
		hr,
		ul,
		ol {
			@apply my-3 ml-5;
		}
		li > ul,
		li > ol {
			@apply my-1 ml-2;
		}

		code:not(pre > code) {
			@apply font-mono text-preformat bg-code-block-background border border-text-separator rounded-xs py-0.5 whitespace-pre-line break-words text-editor-size;
		}

		/* Inline cursor container - adds blinking cursor after last child */
		.inline-cursor-container > :last-child::after {
			content: "";
			@apply inline-block w-0.5 h-[1em] ml-0.5 bg-foreground align-text-bottom animate-cursor-blink;
		}
	}
}

.thinking-dots::after {
	content: ".";
	display: inline-block;
	min-width: 1.5em;
	text-align: left;
	animation: var(--animate-thinking-dots);
}

@media (prefers-reduced-motion: reduce) {
	.thinking-dots::after {
		animation: none;
		content: "...";
	}
}
