/* drawer.css - Reusable Bottom / Side Drawer.
   Modes: .ii-drawer--bottom (full-width, slides up) or .ii-drawer--side (sidebar-width, anchored right).
   Height via --ii-drawer-height (default 65vh). z-index: backdrop 5999, drawer 6000. */

/* CSS Custom Property defaults */
:root {
	--ii-drawer-height: 65vh;
	--ii-drawer-min-height: 80vh;
	--ii-drawer-min-height: 80svh;
	--ii-drawer-radius: 20px 20px 0 0;
	--ii-drawer-side-width: var(--ii-sidebar-width, 288px);
	--ii-drawer-transition: transform 0.38s cubic-bezier(0.32, 0.72, 0, 1);
	--ii-drawer-header-h: 56px;
	--ii-drawer-footer-h: 64px;
}

/* Backdrop */
.ii-drawer-backdrop {
	position: fixed;
	inset: 0;
	z-index: 5999;
	background: rgba(0, 0, 0, 0);
	pointer-events: none;
	transition: background 0.3s ease;
}

.ii-drawer-backdrop.is-visible {
	pointer-events: auto;
	background: rgba(0, 0, 0, 0.38);
	backdrop-filter: blur(2px);
	-webkit-backdrop-filter: blur(2px);
}

/* Drawer Shell - shared */
.ii-drawer {
	position: fixed;
	z-index: 6000;
	display: flex;
	flex-direction: column;
	background: var(--ii-surface-white, #fff);
	backface-visibility: hidden;
	transition:
		var(--ii-drawer-transition),
		visibility 0s linear 0.38s;
	visibility: hidden;
}

.ii-drawer.is-open {
	visibility: visible;
	transition:
		var(--ii-drawer-transition),
		visibility 0s linear 0s;
}

/* Bottom placement */
.ii-drawer--bottom {
	left: 0;
	right: 0;
	bottom: 0;

	height: var(--ii-drawer-height);
	min-height: var(--ii-drawer-min-height);
	max-height: 90vh;

	border-radius: var(--ii-drawer-radius);
	border-top: 1px solid var(--ii-border, #e5e7eb);
	box-shadow:
		0 -8px 40px -4px rgba(0, 0, 0, 0.13),
		0 -2px 8px rgba(0, 0, 0, 0.06);

	transform: translateY(100%);
}

.ii-drawer--bottom.is-open {
	transform: translateY(0);
}

/* Side placement (anchored to right edge of the sidebar) */
.ii-drawer--side {
	top: var(--header-sidebar-height, 3rem);
	left: var(--ii-drawer-side-width);
	bottom: 0;
	width: 320px;
	min-width: 280px;
	max-width: 380px;

	border-left: 1px solid var(--ii-border, #e5e7eb);
	border-top: none;
	border-radius: 0;
	box-shadow: 4px 0 32px rgba(0, 0, 0, 0.08);

	transform: translateX(-120%);
}

.ii-drawer--side.is-open {
	transform: translateX(0);
}

/* Drag handle (bottom only) */
.ii-drawer-handle {
	flex-shrink: 0;
	cursor: grab;
	padding: 12px 24px;
	box-sizing: content-box;
	background-clip: content-box;
	touch-action: none;
}

.ii-drawer-handle__line {
	display: block;
	width: 40px;
	height: 4px;
	background-color: var(--ii-bg-active, #d1d5db);
	margin: 0 auto;
	border-radius: 2px;
}

.ii-drawer-handle:hover .ii-drawer-handle__line {
	background-clip: content-box;
}

.ii-drawer-handle:active {
	cursor: grabbing;
}

/* Header */
.ii-drawer-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	flex-shrink: 0;
	height: var(--ii-drawer-header-h);
	padding: 0 18px;
	border-bottom: 1px solid var(--ii-border, #e5e7eb);
}

.ii-drawer-title-group {
	display: flex;
	flex-direction: column;
	gap: 1px;
	min-width: 0;
	flex: 1;
}

.ii-drawer-title {
	font-size: 14px;
	font-weight: 600;
	color: var(--ii-text-primary, #111827);
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	line-height: 1.3;
	letter-spacing: -0.01em;
}

.ii-drawer-title--icon {
	display: flex;
	align-items: center;
	gap: 8px;
}

.ii-drawer-subtitle {
	color: var(--ii-text-tertiary, #9ca3af);
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

/* Header slot for extra controls (breadcrumb, search, chip bar, etc.) */
.ii-drawer-header-extra {
	display: flex;
	align-items: center;
	gap: 8px;
	flex: 1;
	min-width: 0;
}

/* Close button */
.ii-drawer-close-btn {
	flex-shrink: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 30px;
	height: 30px;
	border-radius: var(--ii-radius-sm);
	border: none;
	background: transparent;
	color: var(--ii-text-tertiary, #9ca3af);
	cursor: pointer;
	transition:
		background 0.15s ease,
		color 0.15s ease;
	outline: none;
	margin-left: auto;
}

.ii-drawer-close-btn:hover {
	background: var(--ii-bg-hover, #f3f4f6);
	color: var(--ii-text-primary, #111827);
}

.ii-drawer-close-btn:focus-visible {
	box-shadow: 0 0 0 2px var(--ii-accent-dim, rgba(37, 99, 235, 0.2));
}

/* Body */
.ii-drawer-body {
	flex: 1;
	overflow-y: auto;
	overflow-x: hidden;
	min-height: 0;
	overscroll-behavior: contain;
	-webkit-overflow-scrolling: touch;
}

@supports (-moz-appearance: none) {
	.ii-drawer-body {
		scrollbar-width: thin;
		scrollbar-color: var(--ii-bg-active, #d1d5db) transparent;
	}
}

.ii-drawer-body::-webkit-scrollbar {
	width: 4px;
}

.ii-drawer-body::-webkit-scrollbar-thumb {
	background: var(--ii-bg-active, #d1d5db);
	border-radius: 2px;
}

/* Footer (action bar) */
.ii-drawer-footer {
	flex-shrink: 0;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
	padding: 12px 18px;
	padding-bottom: max(12px, env(safe-area-inset-bottom));
	border-top: 1px solid var(--ii-border, #e5e7eb);
	background: var(--ii-surface-white, #fff);
	min-height: var(--ii-drawer-footer-h);
}

.ii-drawer-footer:empty {
	display: none;
}

/* Footer left / right regions */
.ii-drawer-footer-left {
	display: flex;
	align-items: center;
	gap: 8px;
	flex: 1;
	min-width: 0;
}

.ii-drawer-footer-right {
	display: flex;
	align-items: center;
	gap: 8px;
	flex-shrink: 0;
}

/* Footer Buttons */
.ii-drawer-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 6px;
	height: 38px;
	padding: 0 18px;
	border-radius: var(--ii-radius-sm, 8px);
	font-size: 13px;
	font-weight: 600;
	font-family: var(--ii-font-body, Inter, sans-serif);
	cursor: pointer;
	outline: none;
	border: none;
	white-space: nowrap;
	transition:
		background 0.16s ease,
		color 0.16s ease,
		transform 0.12s ease,
		box-shadow 0.16s ease;
}

.ii-drawer-btn:active {
	transform: scale(0.96);
}

.ii-drawer-btn:focus-visible {
	box-shadow: 0 0 0 2px var(--ii-accent-dim);
}

.ii-drawer-btn--primary {
	background: var(--ii-accent, #2563eb);
	color: #fff;
}

.ii-drawer-btn--primary:hover {
	background: var(--ii-accent-hover, #1d4ed8);
}

.ii-drawer-btn--primary:disabled {
	opacity: 0.42;
}

.ii-drawer-btn--secondary {
	background: var(--ii-bg-secondary, #f3f4f6);
	color: var(--ii-text-secondary, #4b5563);
	border: 1px solid var(--ii-border, #e5e7eb);
}

.ii-drawer-btn--secondary:hover {
	background: var(--ii-bg-hover, #e5e7eb);
	color: var(--ii-text-primary);
}

.ii-drawer-btn--danger {
	background: var(--ii-danger-bg, rgba(239, 68, 68, 0.07));
	color: var(--ii-danger-text, #dc2626);
	border: 1px solid var(--ii-danger-border, rgba(239, 68, 68, 0.28));
}

.ii-drawer-btn--danger:hover {
	background: var(--ii-danger-solid, #ef4444);
	color: #fff;
	border-color: var(--ii-danger-solid-border, #dc2626);
	box-shadow: 0 2px 10px rgba(239, 68, 68, 0.3);
}

.ii-drawer-btn--danger:disabled {
	opacity: 0.38;
}

/* Selection count badge (footer) */
.ii-drawer-count-badge {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 22px;
	height: 22px;
	padding: 0 6px;
	border-radius: 11px;
	font-size: 11px;
	font-weight: 700;
	line-height: 1;
	background: var(--ii-accent-dim, rgba(37, 99, 235, 0.08));
	color: var(--ii-accent, #2563eb);
	border: 1px solid rgba(37, 99, 235, 0.18);
	transition:
		background 0.15s,
		color 0.15s;
}

.ii-drawer-count-badge.has-selection {
	background: var(--ii-accent, #2563eb);
	color: #fff;
	border-color: transparent;
}

/* Selected chips strip (horizontal scrollable row in footer) */
.ii-drawer-chips-row {
	display: flex;
	align-items: center;
	gap: 6px;
	overflow-x: auto;
	scrollbar-width: none;
	flex: 1;
	min-width: 0;
	padding: 2px 0;
}

.ii-drawer-chips-row::-webkit-scrollbar {
	display: none;
}

.ii-drawer-chip {
	display: inline-flex;
	align-items: center;
	gap: 5px;
	padding: 3px 5px 3px 4px;
	background: var(--ii-bg-secondary, #f3f4f6);
	border: 1px solid var(--ii-border, #e5e7eb);
	border-radius: 8px;
	font-size: 11px;
	font-weight: 500;
	color: var(--ii-text-secondary, #4b5563);
	white-space: nowrap;
	flex-shrink: 0;
	cursor: pointer;
	transition:
		border-color 0.14s ease,
		background 0.14s ease;
	max-width: 120px;
}

.ii-drawer-chip:hover {
	border-color: var(--ii-danger-border);
	background: var(--ii-danger-bg);
}

.ii-drawer-chip-thumb {
	width: 22px;
	height: 22px;
	border-radius: 4px;
	object-fit: cover;
	flex-shrink: 0;
	transition:
		opacity 0.2s ease,
		filter 0.25s ease;
}

.ii-drawer-chip-label {
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.ii-drawer-chip-remove {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 14px;
	height: 14px;
	border-radius: 3px;
	color: var(--ii-text-tertiary);
	flex-shrink: 0;
}

.ii-drawer-chip:hover .ii-drawer-chip-remove {
	color: var(--ii-danger-text, #dc2626);
}

/* Empty chips placeholder */
.ii-drawer-chips-empty {
	font-size: 11px;
	color: var(--ii-text-tertiary, #9ca3af);
	white-space: nowrap;
	font-style: italic;
}

/* Loading state */
.ii-drawer-loading {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 12px;
	padding: 48px 24px;
	min-height: 180px;
}

.ii-drawer-loading-dots {
	display: flex;
	gap: 6px;
}

.ii-drawer-loading-msg {
	font-size: 13px;
	color: var(--ii-text-tertiary);
}

/* Error state */
.ii-drawer-error {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 12px;
	padding: 40px 24px;
	text-align: center;
}

.ii-drawer-error p {
	font-size: 13.5px;
	color: var(--ii-error-text, #b91c1c);
	margin: 0;
}

.ii-drawer-retry-btn {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 8px 18px;
	border-radius: 8px;
	border: 1px solid var(--ii-retry-border);
	background: var(--ii-retry-bg);
	color: var(--ii-retry-color);
	font-size: 13px;
	font-weight: 600;
	cursor: pointer;
	font-family: var(--ii-font-body, Inter, sans-serif);
	transition: all 0.2s ease;
}

.ii-drawer-retry-btn:hover {
	background: var(--ii-retry-hover-bg);
	border-color: var(--ii-retry-hover-border);
}

/* Asset Grid (inside drawer body - shared by both drawer types) */
.ii-drawer-asset-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
	gap: 12px;
	padding: 16px 18px;
}

/* Asset card */
.ii-drawer-asset-card {
	position: relative;
	border-radius: 10px;
	border: 2px solid var(--ii-border, #e5e7eb);
	background: var(--ii-bg-secondary, #f9fafb);
	cursor: pointer;
	overflow: hidden;
	transition:
		border-color 0.16s ease,
		transform 0.14s ease,
		box-shadow 0.16s ease;
	-webkit-tap-highlight-color: transparent;
	touch-action: manipulation;
}

.ii-drawer-asset-card:hover {
	border-color: rgba(37, 99, 235, 0.3);
	transform: translateY(-1px);
	box-shadow: 0 3px 12px rgba(0, 0, 0, 0.07);
}

/* On touch devices, remove all hover-triggered visual changes so iOS fires
   the click on the first tap instead of treating it as a hover activation. */
@media (hover: none) and (pointer: coarse) {
	.ii-drawer-asset-card:hover {
		transform: none;
		box-shadow: none;
		border-color: var(--ii-border, #e5e7eb);
	}

	.ii-drawer-asset-card:hover .ii-drawer-asset-thumb img {
		transform: none;
	}

	/* Always show the options button - no hover needed on touch */
	.ii-drawer-asset-options {
		opacity: 1;
	}
}

.ii-drawer-asset-card.is-selected {
	background: var(--ii-primary-tinted, #f0f4ff);
	box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}

.ii-drawer-asset-card.is-selected .ii-drawer-asset-thumb img {
	opacity: 0.88;
}

/* Thumb */
.ii-drawer-asset-thumb {
	width: 100%;
	aspect-ratio: 1;
	overflow: hidden;
	background: var(--ii-bg-tertiary, #f3f4f6);
}

.ii-drawer-asset-thumb img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
	transition:
		transform 0.25s ease,
		opacity 0.15s ease,
		filter 0.25s ease;
}

.ii-drawer-asset-card:hover .ii-drawer-asset-thumb img {
	transform: scale(1.05);
}

/* Info */
.ii-drawer-asset-info {
	padding: 7px 8px 8px;
	display: flex;
	flex-direction: column;
	gap: 2px;
}

.ii-drawer-asset-name {
	font-size: 11px;
	font-weight: 600;
	color: var(--ii-text-primary, #111827);
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	line-height: 1.3;
}

.ii-drawer-asset-cat {
	font-size: 10px;
	color: var(--ii-text-tertiary, #9ca3af);
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

/* Brand/Artist link on drawer cards */
.ii-drawer-asset-brand {
	display: flex;
	align-items: center;
	gap: 3px;
	margin-top: 3px;
	font-size: 10px;
	line-height: 1.1;
	font-weight: 500;
	color: var(--ii-accent, #2563eb);
	text-decoration: none;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	cursor: pointer;
	opacity: 0.85;
	transition:
		opacity 0.15s ease,
		color 0.15s ease;
}

.ii-drawer-asset-brand:hover {
	opacity: 1;
	color: var(--ii-accent-hover, #1d4ed8);
	text-decoration: underline;
}

/* Selected checkmark overlay */
.ii-drawer-asset-check {
	position: absolute;
	top: 6px;
	left: 6px;
	width: 20px;
	height: 20px;
	border-radius: 50%;
	background: var(--ii-accent, #2563eb);
	color: #fff;
	display: flex;
	align-items: center;
	justify-content: center;
	opacity: 0;
	transform: scale(0.5);
	pointer-events: none;
	transition:
		opacity 0.15s ease,
		transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.ii-drawer-asset-card.is-selected .ii-drawer-asset-check {
	opacity: 1;
	transform: scale(1);
}

/* Action group wrapper: positions both view + options buttons */
.ii-drawer-asset-action-group {
	position: absolute;
	top: 6px;
	right: 6px;
	z-index: 4;
	display: flex;
	align-items: center;
	gap: 4px;
}

/* Options button on hover */
.ii-drawer-asset-options {
	width: 28px;
	height: 28px;
	display: flex;
	align-items: center;
	justify-content: center;
	border-radius: 2rem;
	background: rgba(26, 29, 39, 0.75);
	border: 1px solid;
	border-color: rgba(255, 255, 255, 0.1);
	backdrop-filter: blur(4px);
	-webkit-backdrop-filter: blur(4px);
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
	color: #f0f1f5;
	opacity: 0;
	cursor: pointer;
	transition: all var(--ii-transition, 0.2s);
}

.ii-drawer-asset-options.is-popper-open,
.ii-drawer-asset-card:hover .ii-drawer-asset-options {
	opacity: 1;
}

.ii-drawer-asset-options:hover {
	background: rgba(0, 0, 0, 0.78);
	transform: translateY(-2px);
}

.ii-drawer-asset-options:active {
	transform: translateY(0px);
}

.ii-drawer-asset-card .ii-asset-view-btn {
	width: 28px;
	height: 28px;
	display: flex;
	align-items: center;
	justify-content: center;
	border-radius: 2rem;
	background: rgba(26, 29, 39, 0.75);
	border: 1px solid rgba(255, 255, 255, 0.1);
	backdrop-filter: blur(4px);
	-webkit-backdrop-filter: blur(4px);
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
	color: #f0f1f5;
	opacity: 0;
	cursor: pointer;
	transition: all var(--ii-transition, 0.2s);
	padding: 0;
}

.ii-drawer-asset-card:hover .ii-asset-view-btn,
.ii-drawer-asset-action-group:has(.ii-drawer-asset-options.is-popper-open)
	.ii-asset-view-btn {
	opacity: 1;
}

.ii-drawer-asset-card .ii-asset-view-btn:hover {
	background: rgba(0, 0, 0, 0.78);
	transform: translateY(-2px);
}

.ii-drawer-asset-card .ii-asset-view-btn:active {
	transform: translateY(0px);
}

.ii-drawer-asset-card .ii-asset-view-btn svg {
	width: 16px;
	height: 16px;
}

/* Asset Browser - Category Grid (inside Browse drawer) */
.ii-drawer-cat-grid {
	display: grid;
	grid-template-columns: repeat(6, 1fr);
	gap: 10px;
	padding: 16px 18px;
}

/* Asset Browser - Group Grid (4 top-level group cards) */
.ii-drawer-group-grid {
	display: grid;
	grid-template-columns: repeat(4, 1fr);
	gap: 12px;
	padding: 16px 18px;
}

.ii-drawer-group-card {
	display: block;
	border-radius: 12px;
	border: 1px solid var(--ii-border, #e5e7eb);
	cursor: pointer;
	overflow: hidden;
	transition:
		border-color 0.18s ease,
		transform 0.16s ease,
		box-shadow 0.18s ease;
	-webkit-tap-highlight-color: transparent;
}

.ii-drawer-group-card:hover {
	border-color: var(--ii-accent, #2563eb);
	transform: translateY(-2px);
	box-shadow: 0 8px 20px rgba(0, 0, 0, 0.14);
}

.ii-drawer-group-card .ii-drawer-cat-img-wrap {
	aspect-ratio: 4 / 3;
}

.ii-drawer-group-card:hover .ii-drawer-cat-img-wrap img {
	transform: scale(1.07);
}

.ii-drawer-group-card .ii-drawer-cat-name {
	font-size: clamp(16px, 2vw, 22px);
	padding: 14px 12px 12px;
}

.ii-drawer-group-card:hover .ii-drawer-cat-arrow {
	transform: translateX(3px);
	color: #fff;
}

.ii-drawer-cat-card {
	display: block;
	border-radius: 12px;
	border: 1px solid var(--ii-border, #e5e7eb);
	cursor: pointer;
	overflow: hidden;
	transition:
		border-color 0.18s ease,
		transform 0.16s ease,
		box-shadow 0.18s ease;
	-webkit-tap-highlight-color: transparent;
}

.ii-drawer-cat-card:hover {
	transform: translateY(-2px);
	box-shadow: 0 8px 20px rgba(0, 0, 0, 0.14);
}

.ii-drawer-cat-img-wrap {
	position: relative;
	width: 100%;
	aspect-ratio: 1 / 1;
	overflow: hidden;
	background: var(--ii-bg-secondary, #f3f4f6);
}

.ii-drawer-cat-img-wrap img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
	transition:
		transform 0.32s ease,
		opacity 0.2s ease,
		filter 0.25s ease;
}

.ii-drawer-cat-card:hover .ii-drawer-cat-img-wrap img {
	transform: scale(1.07);
}

.ii-drawer-cat-img-wrap::after {
	content: '';
	position: absolute;
	inset: 0;
	background: linear-gradient(
		to bottom,
		transparent 30%,
		rgba(0, 0, 0, 0.72) 100%
	);
	pointer-events: none;
	z-index: 1;
}

.ii-drawer-cat-name {
	position: absolute;
	bottom: 0;
	left: 0;
	right: 0;
	z-index: 2;
	display: flex;
	align-items: flex-end;
	justify-content: space-between;
	gap: 4px;
	padding: 10px 10px 9px;
	font-size: 12px;
	font-weight: 700;
	color: #fff;
	line-height: 1.25;
	word-break: break-word;
	text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
	pointer-events: none;
}

.ii-drawer-cat-arrow {
	width: 14px;
	height: 14px;
	flex-shrink: 0;
	color: rgba(255, 255, 255, 0.7);
	transform: translateX(0);
	transition:
		transform 0.2s ease,
		color 0.2s ease;
	margin-bottom: 1px;
}

.ii-drawer-cat-card:hover .ii-drawer-cat-arrow {
	transform: translateX(3px);
	color: #fff;
}

/* Asset Browser - Toolbar (search + filters row inside header) */
.ii-drawer-toolbar {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 10px 18px;
	flex-shrink: 0;
	background: var(--ii-surface-white, #fff);
}

.ii-drawer-search-wrap {
	position: relative;
	flex: 1;
	min-width: 0;
}

.ii-drawer-search-icon {
	position: absolute;
	left: 10px;
	top: 50%;
	transform: translateY(-50%);
	color: var(--ii-text-tertiary, #9ca3af);
	pointer-events: none;
	transition: color 0.15s ease;
}

.ii-drawer-search-icon.ii-search-spinning {
	animation: iiSearchIconSpin 0.65s linear infinite;
	color: var(--ii-accent, #2563eb);
	transform-origin: center;
	transform-box: fill-box;
}

@keyframes iiSearchIconSpin {
	from {
		transform: translateY(-50%) rotate(0deg);
	}

	to {
		transform: translateY(-50%) rotate(360deg);
	}
}

.ii-drawer-search-input {
	width: 100%;
	height: 36px;
	padding: 0 12px 0 34px;
	border: 1px solid var(--ii-border, #e5e7eb);
	border-radius: 8px;
	font-size: 13px;
	font-family: var(--ii-font-body, Inter, sans-serif);
	color: var(--ii-text-primary, #111827);
	background: var(--ii-bg-secondary, #f9fafb);
	outline: none;
	transition:
		border-color 0.18s ease,
		box-shadow 0.18s ease;
	box-sizing: border-box;
}

.ii-drawer-search-input::placeholder {
	color: var(--ii-text-tertiary, #9ca3af);
}

.ii-drawer-search-input:focus {
	border-color: var(--ii-accent, #2563eb);
	box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
	background: var(--ii-surface-white, #fff);
}

/* Filter chips row (future filters slot) */
.ii-drawer-filters-row {
	display: flex;
	align-items: center;
	gap: 6px;
	overflow-x: auto;
	scrollbar-width: none;
	padding: 0 18px 8px 18px;
	border-bottom: 1px solid var(--ii-border, #e5e7eb);
	flex-shrink: 0;
}

.ii-drawer-filters-row::-webkit-scrollbar {
	display: none;
}

.ii-drawer-filters-row:empty {
	display: none;
}

.ii-drawer-filter-chip {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 7px 10px 7px 14px;
	border-radius: 8px;
	background: var(--ii-bg-secondary, #f9fafb);
	border: 1px solid var(--ii-border, #e5e7eb);
	font-size: 13px;
	font-weight: 500;
	color: var(--ii-text-secondary, #4b5563);
	cursor: pointer;
	white-space: nowrap;
	flex-shrink: 0;
	font-family: var(--ii-font-body, Inter, sans-serif);
	outline: none;
	-webkit-tap-highlight-color: transparent;
	transition:
		background 0.13s ease,
		border-color 0.13s ease,
		color 0.13s ease;
}

.ii-drawer-filter-chip:hover {
	background: var(--ii-bg-hover, #f3f4f6);
	color: var(--ii-text-primary, #111827);
	border-color: var(--ii-border-dark, #d1d5db);
}

.ii-drawer-filter-chip.is-active {
	background: var(--ii-accent-dim, rgba(37, 99, 235, 0.08));
	border-color: rgba(37, 99, 235, 0.28);
	color: var(--ii-accent, #2563eb);
}

.ii-filter-btn-label {
	line-height: 1;
}

.ii-filter-chevron {
	flex-shrink: 0;
	opacity: 0.5;
	transition:
		transform 0.15s ease,
		opacity 0.15s ease;
}

.ii-drawer-filter-chip:hover .ii-filter-chevron {
	opacity: 0.8;
}

.ii-drawer-filter-chip.is-active .ii-filter-chevron {
	opacity: 0.9;
}

/* Breadcrumb / back navigation (asset browser) */
.ii-drawer-breadcrumb {
	display: flex;
	align-items: center;
	gap: 6px;
	font-size: 14px;
	font-weight: 600;
	color: var(--ii-text-primary, #111827);
	font-family: var(--ii-font-body, Inter, sans-serif);
	min-width: 0;
	flex: 1;
}

.ii-drawer-breadcrumb-back {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 30px;
	height: 30px;
	border-radius: 8px;
	border: none;
	background: transparent;
	color: var(--ii-text-secondary, #6b7280);
	cursor: pointer;
	flex-shrink: 0;
	transition:
		background 0.14s ease,
		color 0.14s ease;
	outline: none;
}

.ii-drawer-breadcrumb-back:hover {
	background: var(--ii-bg-hover, #f3f4f6);
	color: var(--ii-text-primary, #111827);
}

.ii-drawer-breadcrumb-sep {
	color: var(--ii-text-tertiary, #9ca3af);
	font-weight: 400;
}

.ii-drawer-breadcrumb-cat {
	color: var(--ii-text-secondary, #6b7280);
	line-height: 1.125;
	font-weight: 500;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	min-width: 0;
}

/* Infinite scroll sentinel + spinners */
.ii-drawer-sentinel {
	height: 1px;
	width: 100%;
}

.ii-drawer-end-msg {
	text-align: center;
	padding: 14px;
	font-size: 12.5px;
	color: var(--ii-text-tertiary, #9ca3af);
	font-weight: 500;
}

.ii-drawer-empty {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 14px;
	padding: 40px 24px;
	text-align: center;
}

.ii-drawer-empty p {
	font-size: 13.5px;
	color: var(--ii-text-secondary, #6b7280);
	margin: 0;
}

/* Select-All button (inside Added Assets drawer footer) */
.ii-drawer-select-all-btn {
	display: inline-flex;
	align-items: center;
	height: 30px;
	padding: 0 12px;
	border-radius: 6px;
	font-size: 11.5px;
	font-weight: 600;
	white-space: nowrap;
	cursor: pointer;
	outline: none;
	background: transparent;
	border: 1px solid var(--ii-border, rgba(0, 0, 0, 0.1));
	color: var(--ii-text-secondary, #6b7280);
	font-family: var(--ii-font-body, Inter, sans-serif);
	transition:
		color 0.15s ease,
		background 0.15s ease,
		border-color 0.15s ease;
	flex-shrink: 0;
}

.ii-drawer-select-all-btn:hover {
	background: var(--ii-bg-hover, #f3f4f6);
	border-color: rgba(0, 0, 0, 0.15);
	color: var(--ii-text-primary, #111827);
}

/* Sidebar "Show All" gradient overlay - hides overflow cards, shows gradient + "Show All (N)" CTA */
.ii-sidebar-assets-overflow {
	position: relative;
	overflow: hidden;
	/* Show only ~4 rows of assets; the exact height depends on card size */
}

.ii-sidebar-show-all-overlay {
	position: absolute;
	bottom: 0;
	left: 0;
	right: 0;
	height: 90px;
	display: flex;
	align-items: flex-end;
	justify-content: center;
	padding-bottom: 10px;
	background: linear-gradient(
		to bottom,
		transparent 0%,
		var(--ii-surface-white, #fff) 70%
	);
	z-index: 3;
	cursor: pointer;
	transition: opacity 0.2s ease;
}

.ii-sidebar-show-all-overlay:hover {
	opacity: 0.95;
}

.ii-sidebar-show-all-overlay-btn {
	display: inline-flex;
	align-items: center;
	gap: 5px;
	padding: 6px 14px;
	border-radius: var(--ii-radius-rounded);
	font-size: 11.5px;
	font-weight: 600;
	color: var(--ii-accent, #2563eb);
	background: var(--ii-surface-white, #fff);
	border: 1px solid var(--ii-accent, #2563eb);
	cursor: pointer;
	font-family: var(--ii-font-body, Inter, sans-serif);
	outline: none;
	pointer-events: none;
	/* overlay handles the click */
	transition:
		background 0.15s ease,
		color 0.15s ease,
		transform 0.15s ease;
	box-shadow: 0 2px 8px rgba(37, 99, 235, 0.12);
}

.ii-sidebar-show-all-overlay:hover .ii-sidebar-show-all-overlay-btn {
	background: var(--ii-accent, #2563eb);
	color: #fff;
	transform: translateY(-1px);
	box-shadow: 0 4px 14px rgba(37, 99, 235, 0.25);
}

.ii-sidebar-show-all-overlay-btn svg {
	flex-shrink: 0;
	transition: transform 0.2s ease;
}

.ii-sidebar-show-all-overlay:hover .ii-sidebar-show-all-overlay-btn svg {
	transform: translateX(2px);
}

/* Unified Drawer Tab Bar (Added Assets + My Library inside drawer) */
.ii-drawer-tabs {
	display: flex;
	align-items: center;
	gap: 0;
	padding: 0 18px;
	border-bottom: 1px solid var(--ii-border, #e5e7eb);
	flex-shrink: 0;
	background: var(--ii-surface-white, #fff);
}

.ii-drawer-tab {
	position: relative;
	display: inline-flex;
	align-items: center;
	gap: 5px;
	padding: 10px 14px;
	font-size: 14px;
	font-weight: 600;
	color: var(--ii-text-tertiary, #9ca3af);
	background: none;
	border: none;
	cursor: pointer;
	font-family: var(--ii-font-body, Inter, sans-serif);
	outline: none;
	white-space: nowrap;
	transition: color 0.18s ease;
	-webkit-tap-highlight-color: transparent;
}

.ii-drawer-tab:hover {
	color: var(--ii-text-secondary, #6b7280);
}

.ii-drawer-tab.is-active {
	color: var(--ii-accent, #2563eb);
}

.ii-drawer-tab.is-active::after {
	content: '';
	position: absolute;
	bottom: -1px;
	left: 14px;
	right: 14px;
	height: 2px;
	border-radius: 2px 2px 0 0;
	background: var(--ii-accent, #2563eb);
}

.ii-drawer-tab-count {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 18px;
	height: 18px;
	padding: 0 5px;
	border-radius: 9px;
	font-size: 10px;
	font-weight: 700;
	line-height: 1;
	background: var(--ii-bg-secondary, #f3f4f6);
	color: var(--ii-text-tertiary, #9ca3af);
	transition:
		background 0.15s ease,
		color 0.15s ease;
}

.ii-drawer-tab.is-active .ii-drawer-tab-count {
	background: var(--ii-accent-dim, rgba(37, 99, 235, 0.08));
	color: var(--ii-accent, #2563eb);
}

/* Dark mode */
[data-theme='dark'] .ii-drawer {
	background: var(--ii-dk-surface-1, #111116);
	border-top-color: var(--ii-dk-border, #28282f);
	box-shadow:
		0 -8px 40px rgba(0, 0, 0, 0.5),
		0 -2px 8px rgba(0, 0, 0, 0.3);
}

[data-theme='dark'] .ii-drawer--side {
	border-left-color: var(--ii-dk-border, #28282f);
	box-shadow: 4px 0 32px rgba(0, 0, 0, 0.4);
}

[data-theme='dark'] .ii-drawer-header {
	border-bottom-color: var(--ii-dk-border, #28282f);
}

[data-theme='dark'] .ii-drawer-footer {
	border-top-color: var(--ii-dk-border, #28282f);
	background: var(--ii-dk-surface-1, #111116);
}

[data-theme='dark'] .ii-drawer-toolbar {
	background: var(--ii-dk-surface-1, #111116);
}

[data-theme='dark'] .ii-drawer-filters-row {
	border-bottom-color: var(--ii-dk-border, #28282f);
}

[data-theme='dark'] .ii-drawer-cat-card {
	border-color: var(--ii-dk-border, #28282f);
}

[data-theme='dark'] .ii-drawer-cat-img-wrap {
	background: var(--ii-dk-surface-1, #111116);
}

[data-theme='dark'] .ii-drawer-group-card {
	border-color: var(--ii-dk-border, #28282f);
}

[data-theme='dark'] .ii-drawer-group-card .ii-drawer-cat-img-wrap {
	background: var(--ii-dk-surface-1, #111116);
}

[data-theme='dark'] .ii-drawer-asset-card {
	background: var(--ii-dk-surface-2, #18181e);
	border-color: var(--ii-dk-border, #28282f);
}

[data-theme='dark'] .ii-drawer-asset-card:hover {
	background: var(--ii-dk-surface-1, #111116);
}

[data-theme='dark'] .ii-drawer-asset-card.is-selected {
	background: rgba(59, 130, 246, 0.1);
}

[data-theme='dark'] .ii-drawer-search-input {
	background: var(--ii-dk-surface-2, #18181e);
	border-color: var(--ii-dk-border, #28282f);
	color: var(--ii-dk-text-primary, #e5e5ea);
}

[data-theme='dark'] .ii-drawer-search-input:focus {
	background: var(--ii-dk-surface-1, #111116);
}

[data-theme='dark'] .ii-drawer-filter-chip {
	background: var(--ii-dk-surface-2, #1f1f26);
	border-color: var(--ii-dk-border, #28282f);
	color: var(--ii-dk-text-secondary, #b2b2be);
}

[data-theme='dark'] .ii-drawer-filter-chip.is-active {
	background: rgba(59, 130, 246, 0.12);
	border-color: rgba(59, 130, 246, 0.3);
	color: #60a5fa;
}

[data-theme='dark'] .ii-drawer-select-all-btn {
	border-color: var(--ii-dk-border, #28282f);
	color: var(--ii-dk-text-secondary, #b2b2be);
}

[data-theme='dark'] .ii-drawer-select-all-btn:hover {
	background: var(--ii-dk-hover, #262630);
	color: var(--ii-dk-text-primary, #e5e5ea);
}

[data-theme='dark'] .ii-drawer-chip {
	background: var(--ii-dk-surface-2, #18181e);
	border-color: var(--ii-dk-border, #28282f);
	color: var(--ii-dk-text-secondary, #b2b2be);
}

[data-theme='dark'] .ii-sidebar-show-all-overlay {
	background: linear-gradient(
		to bottom,
		transparent 0%,
		var(--ii-dk-surface-1, #111116) 70%
	);
}

[data-theme='dark'] .ii-sidebar-show-all-overlay-btn {
	background: var(--ii-dk-surface-2, #18181e);
	border-color: rgba(96, 165, 250, 0.4);
	color: #60a5fa;
}

[data-theme='dark']
	.ii-sidebar-show-all-overlay:hover
	.ii-sidebar-show-all-overlay-btn {
	background: rgba(59, 130, 246, 0.2);
	color: #93bbfd;
}

[data-theme='dark'] .ii-drawer-tabs {
	background: var(--ii-dk-surface-1, #111116);
	border-bottom-color: var(--ii-dk-border, #28282f);
}

[data-theme='dark'] .ii-drawer-tab.is-active {
	color: #60a5fa;
}

[data-theme='dark'] .ii-drawer-tab.is-active::after {
	background: #60a5fa;
}

/* Filter: reset button */

.ii-drawer-filter-reset {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 7px 14px;
	border-radius: 8px;
	border: 1px solid rgba(234, 88, 12, 0.35);
	background: rgba(234, 88, 12, 0.06);
	font-size: 13px;
	font-weight: 500;
	color: #c2410c;
	cursor: pointer;
	white-space: nowrap;
	flex-shrink: 0;
	margin-left: auto;
	font-family: var(--ii-font-body, Inter, sans-serif);
	outline: none;
	-webkit-tap-highlight-color: transparent;
	transition:
		background 0.13s ease,
		border-color 0.13s ease,
		color 0.13s ease;
}

.ii-drawer-filter-reset:hover {
	background: rgba(234, 88, 12, 0.12);
	border-color: rgba(234, 88, 12, 0.55);
	color: #9a3412;
}

/* Active filter tags row */

.ii-drawer-active-filters-row {
	display: flex;
	flex-wrap: wrap;
	gap: 5px;
	padding: 0 18px;
	flex-shrink: 0;
	overflow: hidden;
	max-height: 0;
	transition:
		max-height 0.22s ease,
		padding-top 0.22s ease,
		padding-bottom 0.22s ease;
}

.ii-drawer-active-filters-row.has-filters {
	max-height: 300px;
	padding-top: 10px;
	padding-bottom: 10px;
}

.ii-active-filter-tag {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	padding: 3px 4px 3px 8px;
	border-radius: var(--ii-radius-rounded);
	background: var(--ii-accent-dim, rgba(37, 99, 235, 0.08));
	border: 1px solid rgba(37, 99, 235, 0.28);
	color: var(--ii-accent, #2563eb);
	font-size: 11px;
	font-weight: 600;
	font-family: var(--ii-font-body, Inter, sans-serif);
	white-space: nowrap;
	max-width: 160px;
}

.ii-active-filter-tag-remove {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	width: 16px;
	height: 16px;
	border-radius: 50%;
	background: transparent;
	border: none;
	cursor: pointer;
	color: var(--ii-accent, #2563eb);
	opacity: 0.65;
	padding: 0;
	transition:
		opacity 0.1s,
		background 0.1s;
	-webkit-tap-highlight-color: transparent;
}

.ii-active-filter-tag-remove:hover {
	opacity: 1;
	background: rgba(37, 99, 235, 0.12);
}

/* Color swatch (used in both popper items and active tags) */

.ii-filter-color-swatch {
	display: inline-block;
	width: 14px;
	height: 14px;
	border-radius: 50%;
	border: 1.5px solid rgba(0, 0, 0, 0.14);
	flex-shrink: 0;
	vertical-align: middle;
	margin-right: 6px;
}

.ii-filter-color-swatch--tag {
	width: 10px;
	height: 10px;
	margin-right: 4px;
}

/* Dark mode */

[data-theme='dark'] .ii-active-filter-tag {
	background: rgba(59, 130, 246, 0.12);
	border-color: rgba(59, 130, 246, 0.28);
	color: #60a5fa;
}

[data-theme='dark'] .ii-active-filter-tag-remove {
	color: #60a5fa;
}

[data-theme='dark'] .ii-active-filter-tag-remove:hover {
	background: rgba(59, 130, 246, 0.18);
}

[data-theme='dark'] .ii-drawer-filter-reset {
	border-color: rgba(251, 146, 60, 0.3);
	background: rgba(251, 146, 60, 0.08);
	color: #fb923c;
}

[data-theme='dark'] .ii-drawer-filter-reset:hover {
	background: rgba(251, 146, 60, 0.15);
	border-color: rgba(251, 146, 60, 0.55);
	color: #fdba74;
}

[data-theme='dark'] .ii-filter-color-swatch {
	border-color: rgba(255, 255, 255, 0.14);
}

[data-theme='dark'] .ii-drawer-tab-count {
	background: var(--ii-dk-surface-2, #1f1f26);
	color: var(--ii-dk-text-secondary, #b2b2be);
}

[data-theme='dark'] .ii-drawer-tab.is-active .ii-drawer-tab-count {
	background: rgba(59, 130, 246, 0.15);
	color: #60a5fa;
}

/* Reduced-motion */
@media (prefers-reduced-motion: reduce) {
	.ii-drawer,
	.ii-drawer-backdrop {
		transition: none;
	}

	.ii-drawer-asset-card {
		transition: none;
	}

	.ii-drawer-asset-card:hover {
		transform: none;
	}

	.ii-drawer-asset-thumb img {
		transition: none;
	}
}

/* Responsive */
@media (max-width: 768px) {
	.ii-drawer--bottom {
		height: min(var(--ii-drawer-height), 80vh);
		max-height: 85vh;
		border-radius: 16px 16px 0 0;
	}

	.ii-drawer-asset-grid {
		grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
		gap: 8px;
		padding: 12px 14px;
	}

	.ii-drawer-cat-grid {
		grid-template-columns: repeat(3, 1fr);
		gap: 8px;
		padding: 12px 14px;
	}

	.ii-drawer-group-grid {
		grid-template-columns: 1fr;
		gap: 10px;
		padding: 12px 14px;
	}

	.ii-drawer-header {
		padding: 0 14px;
	}

	.ii-drawer-toolbar,
	.ii-drawer-filters-row {
		padding-left: 14px;
		padding-right: 14px;
	}

	.ii-drawer-footer {
		padding: 10px 14px;
		padding-bottom: max(10px, env(safe-area-inset-bottom));
	}
}

@media (max-width: 480px) {
	.ii-drawer-asset-grid {
		grid-template-columns: repeat(3, 1fr);
	}

	.ii-drawer-cat-grid {
		grid-template-columns: repeat(2, 1fr);
		gap: 8px;
	}

	.ii-drawer-group-grid {
		grid-template-columns: 1fr;
	}
}
