/* 8-bit Color Cycle - Styles */

:root {
	--cycle-accent: #e8a832;
	--cycle-accent-hover: #d4962a;
	--cycle-accent-light: rgba(232, 168, 50, 0.1);
}

body {
	overflow: hidden;
	height: 100vh;
	background: linear-gradient(135deg, #0a0a0a 0%, #0f0a1a 100%);
}

/* Canvas Container */
.canvas-container {
	position: fixed;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	z-index: 1;
	display: flex;
	align-items: center;
	justify-content: center;
	background: #000;
}

#cycleCanvas {
	max-width: 85%;
	max-height: 75%;
	border-radius: var(--radius);
	box-shadow: var(--shadow-lg);
	image-rendering: pixelated;
	image-rendering: crisp-edges;
}

#cycleCanvas.smooth-scale {
	image-rendering: auto;
}

/* Mask Overlay Canvas — must overlay exactly on #cycleCanvas */
#maskOverlayCanvas {
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	max-width: 85%;
	max-height: 75%;
	image-rendering: pixelated;
	image-rendering: crisp-edges;
	pointer-events: none;
	z-index: 5;
	border-radius: var(--radius);
	opacity: 0.6;
	display: none;
}

#maskOverlayCanvas.painting {
	pointer-events: auto;
	cursor: none;
}

#maskOverlayCanvas.hidden-mask {
	opacity: 0;
}

/* Brush Cursor */
.brush-cursor {
	position: fixed;
	pointer-events: none;
	z-index: 200;
	border: 2px solid rgba(255, 255, 255, 0.9);
	border-radius: 50%;
	box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.5), inset 0 0 0 1px rgba(0, 0, 0, 0.3);
	transform: translate(-50%, -50%);
	display: none;
	transition: width 0.1s ease, height 0.1s ease;
}

.canvas-overlay {
	position: absolute;
	bottom: 80px;
	left: 50%;
	transform: translateX(-50%);
	pointer-events: none;
	z-index: 10;
}

.help-text {
	background: rgba(0, 0, 0, 0.6);
	backdrop-filter: blur(10px);
	padding: 10px 20px;
	border-radius: 20px;
	font-size: 13px;
	color: rgba(255, 255, 255, 0.8);
	border: 1px solid rgba(255, 255, 255, 0.1);
	white-space: nowrap;
}

/* Toolbar */
.toolbar {
	position: fixed;
	top: 80px;
	left: 50%;
	transform: translateX(-50%);
	background: rgba(18, 18, 18, 0.95);
	backdrop-filter: blur(20px);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	padding: 8px 16px;
	display: flex;
	align-items: center;
	gap: 8px;
	z-index: 100;
	box-shadow: var(--shadow-lg);
}

.toolbar-section {
	display: flex;
	align-items: center;
	gap: 6px;
}

.toolbar-label {
	font-size: 11px;
	color: var(--text-muted);
	text-transform: uppercase;
	letter-spacing: 0.5px;
	margin-right: 4px;
}

.toolbar-divider {
	width: 1px;
	height: 28px;
	background: var(--border);
	margin: 0 8px;
}

.tool-btn {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 38px;
	height: 38px;
	border: 1px solid transparent;
	border-radius: var(--radius-sm);
	background: transparent;
	color: var(--text-secondary);
	cursor: pointer;
	transition: var(--transition);
}

.tool-btn:hover {
	background: var(--bg-hover);
	color: var(--text-primary);
}

.tool-btn.active {
	background: var(--cycle-accent-light);
	border-color: var(--cycle-accent);
	color: var(--cycle-accent);
}

/* Panels */
.properties-panel {
	position: fixed;
	top: 140px;
	right: 20px;
	width: 280px;
	background: rgba(18, 18, 18, 0.95);
	backdrop-filter: blur(20px);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	z-index: 100;
	box-shadow: var(--shadow-lg);
	transition: var(--transition);
}

.properties-panel.collapsed {
	width: 48px;
}

.properties-panel.collapsed .panel-body {
	display: none;
}

.scene-panel {
	position: fixed;
	bottom: 20px;
	left: 20px;
	width: 340px;
	background: rgba(18, 18, 18, 0.95);
	backdrop-filter: blur(20px);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	z-index: 100;
	box-shadow: var(--shadow-lg);
	transition: var(--transition);
}

.scene-panel.collapsed .panel-body {
	display: none;
}

/* Panel Common */
.panel-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 14px 16px;
	border-bottom: 1px solid var(--border);
}

.panel-title {
	display: flex;
	align-items: center;
	gap: 8px;
	font-size: 13px;
	font-weight: 600;
	color: var(--text-primary);
}

.panel-title iconify-icon {
	color: var(--cycle-accent);
}

.panel-toggle {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 28px;
	height: 28px;
	border: none;
	border-radius: var(--radius-xs);
	background: transparent;
	color: var(--text-muted);
	cursor: pointer;
	transition: var(--transition);
}

.panel-toggle:hover {
	background: var(--bg-hover);
	color: var(--text-primary);
}

.panel-body {
	padding: 16px;
	max-height: 450px;
	overflow-y: auto;
}

.panel-body::-webkit-scrollbar {
	width: 6px;
}

.panel-body::-webkit-scrollbar-thumb {
	background: var(--bg-quaternary);
	border-radius: 3px;
}

.panel-body::-webkit-scrollbar-thumb:hover {
	background: var(--cycle-accent);
}

/* Control Groups */
.control-group {
	margin-bottom: 16px;
}

.control-group:last-child {
	margin-bottom: 0;
}

.control-group label {
	display: flex;
	align-items: center;
	justify-content: space-between;
	font-size: 12px;
	font-weight: 500;
	color: var(--text-muted);
	margin-bottom: 8px;
}

.control-group input[type="range"] {
	width: 100%;
	height: 6px;
	border-radius: 3px;
	background: var(--bg-quaternary);
	-webkit-appearance: none;
	cursor: pointer;
}

.control-group input[type="range"]::-webkit-slider-thumb {
	-webkit-appearance: none;
	width: 16px;
	height: 16px;
	border-radius: 50%;
	background: var(--cycle-accent);
	border: 2px solid white;
	cursor: pointer;
	box-shadow: 0 2px 8px rgba(232, 168, 50, 0.4);
}

.control-group input[type="checkbox"] {
	width: 16px;
	height: 16px;
	accent-color: var(--cycle-accent);
	margin-right: 8px;
}

.control-group select {
	width: 100%;
	padding: 10px 12px;
	background: var(--bg-tertiary);
	border: 1px solid var(--border);
	border-radius: var(--radius-xs);
	color: var(--text-primary);
	font-size: 13px;
	cursor: pointer;
	transition: var(--transition);
}

.control-group select:focus {
	outline: none;
	border-color: var(--cycle-accent);
}

.value-display {
	font-size: 11px;
	font-family: monospace;
	font-weight: 600;
	color: var(--cycle-accent);
	background: var(--cycle-accent-light);
	padding: 2px 8px;
	border-radius: var(--radius-xs);
}

/* Cycle Ranges */
.cycle-ranges-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	margin-bottom: 8px;
}

.cycle-ranges-header label {
	font-size: 12px;
	font-weight: 500;
	color: var(--text-muted);
	margin: 0;
}

.mini-btn {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 24px;
	height: 24px;
	border: 1px solid var(--border);
	border-radius: var(--radius-xs);
	background: var(--bg-tertiary);
	color: var(--text-muted);
	cursor: pointer;
	transition: var(--transition);
}

.mini-btn:hover {
	background: var(--cycle-accent-light);
	border-color: var(--cycle-accent);
	color: var(--cycle-accent);
}

.cycle-ranges {
	display: flex;
	flex-direction: column;
	gap: 6px;
	max-height: 200px;
	overflow-y: auto;
}

.cycle-range-item {
	display: flex;
	align-items: center;
	gap: 6px;
	padding: 6px 8px;
	background: var(--bg-tertiary);
	border: 1px solid var(--border);
	border-radius: var(--radius-xs);
	font-size: 11px;
	font-family: monospace;
	color: var(--text-secondary);
}

.cycle-range-item .range-preview {
	width: 60px;
	height: 12px;
	border-radius: 3px;
	flex-shrink: 0;
}

.cycle-range-item .range-info {
	flex: 1;
	min-width: 0;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.cycle-range-item .range-remove {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 18px;
	height: 18px;
	border: none;
	border-radius: 3px;
	background: transparent;
	color: var(--text-disabled);
	cursor: pointer;
	transition: var(--transition);
	flex-shrink: 0;
}

.cycle-range-item .range-remove:hover {
	background: rgba(239, 68, 68, 0.15);
	color: var(--danger);
}

.cycle-range-item .range-reverse {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 18px;
	height: 18px;
	border: none;
	border-radius: 3px;
	background: transparent;
	color: var(--text-disabled);
	cursor: pointer;
	transition: var(--transition);
	flex-shrink: 0;
}

.cycle-range-item .range-reverse:hover,
.cycle-range-item .range-reverse.active {
	color: var(--cycle-accent);
}

/* Action Button */
.action-btn {
	width: 100%;
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	padding: 12px 16px;
	background: var(--cycle-accent);
	border: none;
	border-radius: var(--radius-sm);
	color: #0a0a0a;
	font-size: 13px;
	font-weight: 600;
	cursor: pointer;
	transition: var(--transition);
	margin-top: 12px;
}

.action-btn:hover {
	background: var(--cycle-accent-hover);
	transform: translateY(-1px);
	box-shadow: 0 4px 12px rgba(232, 168, 50, 0.3);
}

/* Upload Zone */
.upload-zone {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 8px;
	padding: 28px 16px;
	border: 2px dashed var(--border);
	border-radius: var(--radius-sm);
	color: var(--text-muted);
	cursor: pointer;
	transition: var(--transition);
	text-align: center;
	margin-bottom: 16px;
}

.upload-zone:hover,
.upload-zone.dragover {
	border-color: var(--cycle-accent);
	background: var(--cycle-accent-light);
	color: var(--cycle-accent);
}

.upload-zone p {
	font-size: 13px;
	font-weight: 500;
	margin: 0;
}

.upload-hint {
	font-size: 11px;
	color: var(--text-disabled);
}

/* Zone Painter */
.zone-painter-info {
	display: flex;
	align-items: center;
	gap: 6px;
	font-size: 12px;
	color: var(--cycle-accent);
	padding: 8px 12px;
	background: var(--cycle-accent-light);
	border: 1px solid rgba(232, 168, 50, 0.2);
	border-radius: var(--radius-xs);
	margin-bottom: 14px;
}

.zone-chips {
	display: flex;
	gap: 6px;
	flex-wrap: wrap;
}

.zone-chip {
	width: 28px;
	height: 28px;
	border-radius: 50%;
	border: 2px solid var(--border);
	cursor: pointer;
	transition: var(--transition);
	position: relative;
}

.zone-chip:hover {
	transform: scale(1.15);
}

.zone-chip.active {
	border-color: white;
	box-shadow: 0 0 0 2px var(--cycle-accent), 0 0 8px rgba(232, 168, 50, 0.3);
}

.zone-chip.has-pixels::after {
	content: '';
	position: absolute;
	top: -3px;
	right: -3px;
	width: 8px;
	height: 8px;
	background: var(--cycle-accent);
	border-radius: 50%;
	border: 1px solid var(--bg-primary);
}

/* Zone List */
.zone-list {
	display: flex;
	flex-direction: column;
	gap: 6px;
	margin-top: 14px;
}

.zone-list-item {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 8px 10px;
	background: var(--bg-tertiary);
	border: 1px solid var(--border);
	border-radius: var(--radius-xs);
	font-size: 12px;
	color: var(--text-secondary);
}

.zone-color-dot {
	width: 14px;
	height: 14px;
	border-radius: 50%;
	flex-shrink: 0;
	border: 1px solid rgba(255, 255, 255, 0.2);
}

.zone-list-item .zone-info {
	flex: 1;
	min-width: 0;
}

.zone-list-item .zone-direction {
	font-size: 10px;
	color: var(--text-muted);
	font-family: monospace;
}

.zone-list-item .zone-toggle {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 22px;
	height: 22px;
	border: none;
	border-radius: 3px;
	background: transparent;
	color: var(--text-muted);
	cursor: pointer;
	transition: var(--transition);
	flex-shrink: 0;
}

.zone-list-item .zone-toggle:hover {
	color: var(--text-primary);
}

.zone-list-item .zone-toggle.hidden-zone {
	color: var(--text-disabled);
	opacity: 0.5;
}

/* Inline direction selector per zone */
.zone-dir-select {
	font-size: 11px;
	padding: 2px 4px;
	border: 1px solid var(--border);
	border-radius: var(--radius-xs);
	background: var(--bg-secondary);
	color: var(--text-primary);
	cursor: pointer;
	flex-shrink: 0;
	max-width: 80px;
}
.zone-dir-select:focus {
	border-color: var(--accent);
	outline: none;
}

/* Gallery */
.gallery-info {
	display: flex;
	align-items: center;
	gap: 6px;
	font-size: 11px;
	color: var(--success);
	padding: 8px 12px;
	background: rgba(16, 185, 129, 0.08);
	border: 1px solid rgba(16, 185, 129, 0.2);
	border-radius: var(--radius-xs);
	margin-bottom: 12px;
}

.gallery-filters {
	display: flex;
	gap: 4px;
	margin-bottom: 12px;
	flex-wrap: wrap;
}

.gallery-filter-btn {
	padding: 4px 10px;
	font-size: 11px;
	background: var(--bg-tertiary);
	border: 1px solid var(--border);
	border-radius: 12px;
	color: var(--text-muted);
	cursor: pointer;
	transition: var(--transition);
}

.gallery-filter-btn:hover {
	border-color: var(--cycle-accent);
	color: var(--text-primary);
}

.gallery-filter-btn.active {
	background: var(--cycle-accent-light);
	border-color: var(--cycle-accent);
	color: var(--cycle-accent);
}

.gallery-grid {
	display: grid;
	grid-template-columns: repeat(2, 1fr);
	gap: 8px;
}

.gallery-item {
	position: relative;
	border-radius: var(--radius-sm);
	overflow: hidden;
	border: 2px solid var(--border);
	cursor: pointer;
	transition: var(--transition);
	aspect-ratio: 4/3;
}

.gallery-item:hover {
	border-color: var(--cycle-accent);
	transform: translateY(-2px);
	box-shadow: 0 4px 16px rgba(232, 168, 50, 0.2);
}

.gallery-item.active {
	border-color: var(--cycle-accent);
	box-shadow: 0 0 0 2px var(--cycle-accent-light);
}

.gallery-item img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

.gallery-item .gallery-label {
	position: absolute;
	bottom: 0;
	left: 0;
	right: 0;
	padding: 4px 6px;
	background: rgba(0, 0, 0, 0.75);
	backdrop-filter: blur(4px);
	font-size: 10px;
	color: var(--text-secondary);
	text-align: center;
}

.gallery-item .loading-spinner {
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	width: 20px;
	height: 20px;
	border: 2px solid var(--border);
	border-top-color: var(--cycle-accent);
	border-radius: 50%;
	animation: spin 0.8s linear infinite;
}

@keyframes spin {
	to { transform: translate(-50%, -50%) rotate(360deg); }
}

/* Palette Bar */
.palette-bar {
	position: fixed;
	bottom: 70px;
	left: 50%;
	transform: translateX(-50%);
	z-index: 90;
	background: rgba(18, 18, 18, 0.9);
	backdrop-filter: blur(10px);
	border: 1px solid var(--border);
	border-radius: var(--radius-sm);
	padding: 4px;
	transition: var(--transition);
}

.palette-bar.hidden {
	opacity: 0;
	pointer-events: none;
}

#paletteCanvas {
	display: block;
	border-radius: 4px;
	width: 512px;
	height: 24px;
}

/* Share Panel */
.share-panel {
	position: fixed;
	bottom: 20px;
	left: 380px;
	z-index: 100;
}

.share-toggle {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 44px;
	height: 44px;
	background: rgba(18, 18, 18, 0.95);
	backdrop-filter: blur(20px);
	border: 1px solid var(--border);
	border-radius: var(--radius-sm);
	color: var(--text-secondary);
	cursor: pointer;
	transition: var(--transition);
}

.share-toggle:hover {
	background: var(--bg-hover);
	color: var(--text-primary);
}

.share-content {
	position: absolute;
	bottom: 54px;
	left: 0;
	width: 280px;
	background: rgba(18, 18, 18, 0.95);
	backdrop-filter: blur(20px);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	padding: 16px;
	display: none;
	box-shadow: var(--shadow-lg);
}

.share-content.show {
	display: block;
}

.share-header {
	font-size: 13px;
	font-weight: 600;
	color: var(--text-primary);
	margin-bottom: 12px;
}

.hash-input {
	width: 100%;
	padding: 10px 12px;
	background: var(--bg-tertiary);
	border: 1px solid var(--border);
	border-radius: var(--radius-xs);
	color: var(--text-primary);
	font-size: 11px;
	font-family: monospace;
	margin-bottom: 12px;
}

.hash-input:focus {
	outline: none;
	border-color: var(--cycle-accent);
}

.share-buttons {
	display: flex;
	gap: 8px;
}

.share-btn {
	flex: 1;
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 6px;
	padding: 8px 12px;
	background: var(--bg-tertiary);
	border: 1px solid var(--border);
	border-radius: var(--radius-xs);
	color: var(--text-secondary);
	font-size: 11px;
	cursor: pointer;
	transition: var(--transition);
}

.share-btn:hover {
	background: var(--bg-hover);
	border-color: var(--cycle-accent);
	color: var(--text-primary);
}

/* Status Indicator */
.status-indicator {
	position: fixed;
	bottom: 20px;
	right: 20px;
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 10px 16px;
	background: rgba(18, 18, 18, 0.95);
	backdrop-filter: blur(20px);
	border: 1px solid var(--border);
	border-radius: var(--radius-sm);
	font-size: 13px;
	color: var(--text-muted);
	z-index: 100;
}

.status-indicator iconify-icon {
	color: var(--cycle-accent);
}

/* Toast */
.toast {
	position: fixed;
	bottom: 80px;
	left: 50%;
	transform: translateX(-50%) translateY(20px);
	background: rgba(18, 18, 18, 0.95);
	backdrop-filter: blur(20px);
	border: 1px solid var(--cycle-accent);
	border-radius: var(--radius-sm);
	padding: 12px 24px;
	color: var(--text-primary);
	font-size: 13px;
	z-index: 1000;
	opacity: 0;
	transition: all 0.3s ease;
	pointer-events: none;
}

.toast.show {
	opacity: 1;
	transform: translateX(-50%) translateY(0);
}

/* Responsive */
@media (max-width: 1024px) {
	.properties-panel {
		width: 260px;
	}

	.scene-panel {
		width: 300px;
	}

	#paletteCanvas {
		width: 400px;
	}
}

@media (max-width: 768px) {
	.toolbar {
		top: auto;
		bottom: 20px;
		padding: 6px 12px;
		flex-wrap: wrap;
		max-width: calc(100% - 40px);
	}

	.toolbar-label {
		display: none;
	}

	.properties-panel {
		top: 80px;
		right: 10px;
		width: 240px;
	}

	.scene-panel {
		bottom: 80px;
		left: 10px;
		width: 240px;
	}

	#cycleCanvas,
	#maskOverlayCanvas {
		max-width: 95%;
		max-height: 55%;
	}

	#paletteCanvas {
		width: 280px;
	}

	.palette-bar {
		bottom: 80px;
	}
}

@media (max-width: 480px) {
	.properties-panel,
	.scene-panel {
		position: fixed;
		bottom: 0;
		left: 0;
		right: 0;
		top: auto;
		width: 100%;
		max-width: 100%;
		max-height: 60vh;
		border-radius: var(--radius) var(--radius) 0 0;
		overflow-y: auto;
		z-index: 100;
	}

	.toolbar {
		left: 10px;
		right: 10px;
		transform: none;
		justify-content: center;
	}

	.tool-btn {
		min-width: 44px;
		min-height: 44px;
	}

	#paletteCanvas {
		width: 200px;
	}

	.gallery-grid {
		grid-template-columns: 1fr;
	}

	.zone-chips {
		gap: 4px;
	}

	.zone-chip {
		width: 24px;
		height: 24px;
	}
}
