/* ============================================================
 *  CSS Custom Properties — Light Mode (default)
 * ============================================================ */
:root {
	/* ── Layout ── */
	--ii-sidebar-width: 260px;
	--ii-assets-sidebar-width: 288px;
	--ii-rec-panel-width: 310px;
	--header-sidebar-height: 3rem;

	/* ── Backgrounds ── */
	--ii-bg-primary: #f3f4f6;
	--ii-surface-white: #ffffff;
	--ii-bg-secondary: #f9fafb;
	--ii-bg-tertiary: #f3f4f6;
	--ii-bg-hover: #e5e7eb;
	--ii-bg-active: #d1d5db;

	/* ── Text ── */
	--ii-text-primary: #111827;
	--ii-text-secondary: #4b5563;
	--ii-text-tertiary: #9ca3af;

	/* ── Accent / Brand ── */
	--ii-accent: #2563eb;
	--ii-accent-hover: #1d4ed8;
	--ii-accent-dim: rgba(37, 99, 235, 0.1);
	--ii-primary: #0d5fff;
	--ii-primary-tinted: #f0f4ff;
	--ii-primary-hover: #333333;

	/* ── Borders & Dividers ── */
	--ii-border: #e5e7eb;

	/* ── Gradients ── */
	--ii-gradient-start: #232526;
	--ii-gradient-mid: #414345;
	--ii-gradient-end: #1a1a1a;

	/* ── Inputs ── */
	--ii-input-bg: #ffffff;

	/* ── Shadows ── */
	--ii-shadow:
		0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
	--ii-shadow-elegant:
		0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);

	/* ── Radii ── */
	--ii-radius-sm: 8px;
	--ii-radius-md: 12px;
	--ii-radius-lg: 16px;
	--ii-radius-rounded: 20px;
	--ii-radius-lgx: 24px;
	--ii-radius-xl: 32px;

	/* ── Motion ── */
	--ii-transition: 0.35s cubic-bezier(0.2, 0.8, 0.2, 1);

	/* ── Typography ── */
	--ii-font-display: Inter, sans-serif;
	--ii-font-body: Inter, sans-serif;

	/* ── Toast system ── */
	--ai-toast-bg: #1c1c1e;
	--ai-toast-border: rgba(255, 255, 255, 0.08);
	--ai-toast-shadow:
		0 4px 24px rgba(0, 0, 0, 0.6), 0 1px 2px rgba(0, 0, 0, 0.4);
	--ai-toast-radius: 16px;
	--ai-toast-text-primary: #fafafa;
	--ai-toast-text-secondary: rgba(255, 255, 255, 0.5);
	--ai-toast-success: #4ade80;
	--ai-toast-error: #f87171;
	--ai-toast-warning: #fbbf24;
	--ai-toast-info: #60a5fa;

	/* ================================================================
     *  SEMANTIC TOKENS
     *  These replace every hardcoded color value across all CSS files.
     *  Redefine only what changes in [data-theme="dark"] below.
     * ================================================================ */

	/* ── Sticky section-title backdrop (sidebar) ── */
	--ii-sticky-title-bg: rgba(255, 255, 255, 0.8);

	/* ── Checkbox ── */
	--ii-checkbox-bg: #ffffff;
	--ii-checkbox-border: #d1d5db;

	/* ── Empty / "add assets" button ── */
	--ii-empty-btn-bg: #fafbfc;
	--ii-empty-btn-border: #cbd5e1;
	--ii-empty-btn-hover-bg: #f1f5f9;
	--ii-muted-icon: #64748b;

	/* ── Input row glass surface ── */
	--ii-input-row-bg: rgba(255, 255, 255, 0.7);

	/* ── Popper / dropdown menu ── */
	--ii-popper-bg: #ffffff;
	--ii-popper-border: rgba(0, 0, 0, 0.08);
	--ii-popper-separator: rgba(0, 0, 0, 0.08);
	--ii-popper-shadow:
		0 10px 38px -10px rgba(22, 23, 24, 0.35),
		0 10px 20px -15px rgba(22, 23, 24, 0.2);

	/* ── Danger / destructive actions ── */
	--ii-danger: #dc2626;
	--ii-danger-text: #dc2626;
	--ii-danger-solid: #ef4444;
	--ii-danger-solid-border: #dc2626;
	--ii-danger-solid-text: #ffffff;
	--ii-danger-bg: rgba(239, 68, 68, 0.07);
	--ii-danger-border: rgba(239, 68, 68, 0.28);
	--ii-danger-badge-bg: rgba(239, 68, 68, 0.1);
	--ii-danger-badge-border: rgba(239, 68, 68, 0.22);

	/* ── Error / warning message blocks ── */
	--ii-error-msg-bg: #fffcfc;
	--ii-error-msg-border: #fee2e2;
	--ii-error-text: #b91c1c;
	--ii-retry-bg: #ffffff;
	--ii-retry-border: #fecaca;
	--ii-retry-color: #dc2626;
	--ii-retry-hover-bg: #fef2f2;
	--ii-retry-hover-border: #fca5a5;

	/* ── Bulk action bar ── */
	--ii-bulk-bar-bg: #ffffff;
	--ii-bulk-bar-shadow:
		0 -4px 16px rgba(0, 0, 0, 0.06), 0 -1px 4px rgba(0, 0, 0, 0.04);

	/* ── Image download overlay button ── */
	--ii-img-dl-btn-bg: rgba(255, 255, 255, 0.92);

	/* ── Skeleton loading placeholders ── */
	--ii-skeleton-base: #eeeeee;
	--ii-skeleton-shimmer-1: #f3f4f6;
	--ii-skeleton-shimmer-2: #e5e7eb;
	--ii-skeleton-btn-bg: #f3f4f6;
	--ii-skeleton-send-bg: #f0f4ff;
}

/* ============================================================
 *  CSS Custom Properties — Dark Mode
 *
 *  Palette: deep neutral charcoal — barely any hue.
 *  The blue accent stands out cleanly against the near-greyscale.
 *
 *  Layer scale (darkest → lightest):
 *    --ii-dk-base        #0b0b0e   page canvas
 *    --ii-dk-surface-1   #111116   sidebar, modal header/footer
 *    --ii-dk-surface-2   #18181e   cards, popper, nav
 *    --ii-dk-surface-3   #1f1f26   hover targets, raised elements
 *    --ii-dk-hover       #262630   interactive hover
 *    --ii-dk-active      #2e2e3a   pressed / selected
 *    --ii-dk-border      #28282f   all borders
 * ============================================================ */
[data-theme='dark'] {
	color-scheme: dark;

	/* ── Dark palette foundation ── */
	--ii-dk-base: #0b0b0e;
	--ii-dk-surface-1: #111116;
	--ii-dk-surface-2: #18181e;
	--ii-dk-surface-3: #1f1f26;
	--ii-dk-hover: #262630;
	--ii-dk-active: #2e2e3a;
	--ii-dk-border: #28282f;
	--ii-dk-text-primary: #e5e5ea;
	--ii-dk-text-secondary: #b2b2be;
	/* bumped from #7c7c88 for readability */
	--ii-dk-text-faint: #8a8a96;
	/* bumped from #4a4a56 for readability */
	--ii-dk-text-body: #d0d0d8;
	/* bumped from #c2c2cc */
	--ii-dk-link: #5b96f7;
	--ii-dk-link-hover: #81b0fa;
	--ii-dk-error-bg: #1e1212;
	--ii-dk-error-border: rgba(239, 68, 68, 0.22);
	--ii-dk-tooltip-bg: rgba(11, 11, 14, 0.96);
	--ii-dk-shimmer-base: #18181e;
	--ii-dk-shimmer-peak: #1f1f26;

	/* ── Studio UI token overrides ── */
	--ii-bg-primary: #0b0b0e;
	--ii-surface-white: #111116;
	--ii-bg-secondary: #18181e;
	--ii-bg-tertiary: #1f1f26;
	--ii-bg-hover: #262630;
	--ii-bg-active: #2e2e3a;
	--ii-text-primary: #e5e5ea;
	--ii-text-secondary: #b2b2be;
	/* bumped from #7c7c88 — much more readable */
	--ii-text-tertiary: #8a8a96;
	/* bumped from #4a4a56 — visible but still subordinate */
	--ii-border: #28282f;
	--ii-accent: #3b82f6;
	--ii-accent-hover: #2563eb;
	--ii-accent-dim: rgba(59, 130, 246, 0.14);
	--ii-primary: #5b96f7;
	--ii-primary-tinted: rgba(59, 130, 246, 0.1);
	--ii-primary-hover: #e5e5ea;
	--ii-input-bg: #18181e;
	--ii-shadow: 0 1px 3px rgba(0, 0, 0, 0.55), 0 1px 2px rgba(0, 0, 0, 0.4);
	--ii-shadow-elegant:
		0 4px 6px -1px rgba(0, 0, 0, 0.55), 0 2px 4px -2px rgba(0, 0, 0, 0.4);

	/* ── Semantic token overrides ── */
	--ii-sticky-title-bg: rgba(17, 17, 22, 0.85);

	--ii-checkbox-bg: #18181e;
	--ii-checkbox-border: #28282f;

	--ii-empty-btn-bg: #18181e;
	--ii-empty-btn-border: #28282f;
	--ii-empty-btn-hover-bg: #262630;
	--ii-muted-icon: #b2b2be;
	/* bumped to match text-secondary */

	--ii-input-row-bg: rgba(17, 17, 22, 0.7);

	--ii-popper-bg: #18181e;
	--ii-popper-border: #28282f;
	--ii-popper-separator: #28282f;
	--ii-popper-shadow:
		0 10px 38px -10px rgba(0, 0, 0, 0.65),
		0 10px 20px -15px rgba(0, 0, 0, 0.45);

	/* Danger — slightly lighter red so it reads well on dark */
	--ii-danger: #f87171;
	--ii-danger-text: #f87171;
	--ii-danger-solid: #ef4444;
	--ii-danger-solid-border: #dc2626;
	--ii-danger-solid-text: #ffffff;
	--ii-danger-bg: rgba(239, 68, 68, 0.1);
	--ii-danger-border: rgba(239, 68, 68, 0.32);
	--ii-danger-badge-bg: rgba(239, 68, 68, 0.12);
	--ii-danger-badge-border: rgba(239, 68, 68, 0.28);

	--ii-error-msg-bg: #1e1212;
	--ii-error-msg-border: rgba(239, 68, 68, 0.22);
	--ii-error-text: #f87171;
	--ii-retry-bg: #18181e;
	--ii-retry-border: rgba(239, 68, 68, 0.3);
	--ii-retry-color: #f87171;
	--ii-retry-hover-bg: #262630;
	--ii-retry-hover-border: rgba(239, 68, 68, 0.5);

	--ii-bulk-bar-bg: #111116;
	--ii-bulk-bar-shadow: 0 -4px 16px rgba(0, 0, 0, 0.4);

	--ii-img-dl-btn-bg: rgba(11, 11, 14, 0.88);

	--ii-skeleton-base: #18181e;
	--ii-skeleton-shimmer-1: #18181e;
	--ii-skeleton-shimmer-2: #1f1f26;
	--ii-skeleton-btn-bg: #18181e;
	--ii-skeleton-send-bg: #1f1f26;
}

[data-theme='light'] .ii-bubble-back {
	border-color: rgba(0, 0, 0, 0.08);
	background: rgba(255, 255, 255, 0.72);
}

[data-theme='light'] .ii-bubble-front {
	box-shadow:
		0 4px 18px rgba(0, 0, 0, 0.12),
		0 1px 4px rgba(0, 0, 0, 0.08);
	border-color: rgba(0, 0, 0, 0.08);
}

[data-theme='light'] .ii-bubble-stack:hover .ii-bubble-front,
[data-theme='light'] .ii-bubble-stack:focus-visible .ii-bubble-front {
	box-shadow:
		0 8px 28px rgba(0, 0, 0, 0.16),
		0 2px 8px rgba(0, 0, 0, 0.1);
}

[data-theme='light'] .ii-bubble-back--1 {
	opacity: 0.72;
}

[data-theme='light'] .ii-bubble-back--2 {
	opacity: 0.5;
}

[data-theme='light'] .ii-bubble-back--3 {
	opacity: 0.3;
}

[data-theme='light'] .ii-bubble-stack:hover .ii-bubble-back--1,
[data-theme='light'] .ii-bubble-stack:focus-visible .ii-bubble-back--1 {
	opacity: 0.8;
}

[data-theme='light'] .ii-bubble-stack:hover .ii-bubble-back--2,
[data-theme='light'] .ii-bubble-stack:focus-visible .ii-bubble-back--2 {
	opacity: 0.56;
}

[data-theme='light'] .ii-bubble-stack:hover .ii-bubble-back--3,
[data-theme='light'] .ii-bubble-stack:focus-visible .ii-bubble-back--3 {
	opacity: 0.34;
}

[data-theme='light'] .ii-bubble-count {
	background: rgba(0, 0, 0, 0.42);
}

[data-theme='light'] .ii-creations-show-more-btn {
	color: var(--ii-text-secondary);
}

[data-theme='light'] .ii-creation-skeleton-card,
[data-theme='light'] .ii-creations-skeleton-group-title {
	background: rgba(0, 0, 0, 0.06);
}

@media (max-width: 1024px) {
	:root {
		--ii-sidebar-width: 260px;
	}
}
