:root {
	--primary: #4CAF50;
	--danger: #f44336;
	--gray: #9e9e9e;
	--dark-gray: #424242;
	--light-gray: #f5f5f5;
	--app-version: "v1.2.0";
	--pencil-cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='32' height='32' viewBox='0 0 32 32'%3E%3Cpath fill='%23222222' d='m5 27 2-7L22 5l5 5L12 25z'/%3E%3Cpath fill='%23f5c542' d='m9 20 13-13 2 2-13 13z'/%3E%3Cpath fill='%23fff' d='m22 5 2-2 5 5-2 2z'/%3E%3Cpath fill='%23000' d='m5 27 2-7 5 5z'/%3E%3C/svg%3E") 5 27, crosshair;
	--eraser-cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='32' height='32' viewBox='0 0 32 32'%3E%3Cpath fill='%23ef7f93' d='m5 20 12-12 10 10-8 8H9z'/%3E%3Cpath fill='%23f7b3c0' d='m17 8 3-3 10 10-3 3z'/%3E%3Cpath fill='%23fff' d='m5 20 4 6h10l4-4-8-8z'/%3E%3Cpath fill='none' stroke='%23666' stroke-width='1.5' d='m5 20 12-12 10 10-8 8H9z'/%3E%3C/svg%3E") 5 27, crosshair;
}

.show-version::after {
	font-size: 9px;
	content: var(--app-version);
}

* {
	box-sizing: border-box;
	font-family: system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
	user-select: none;
}

body, html {
	margin: 0;
	padding: 0;
	width: 100%;
	height: 100%;
	overflow: hidden;
	background-color: #e0e0e0;
}

#workspace {
	width: 100vw;
	height: 100vh;
	overflow: auto;
	position: relative;
	display: flex;
	align-items: center;
	justify-content: center;
	touch-action: none;
	user-select: none;
	-webkit-user-select: none;
	-webkit-touch-callout: none;
}

#zoomWrapper {
	position: relative;
	background-color: white;
	transform-origin: top left;
	transition: transform 0.1s ease-out;
	box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
	touch-action: none;
	user-select: none;
	-webkit-user-select: none;
	-webkit-touch-callout: none;
}

#watermark {
	position: fixed;
	bottom: 20px;
	left: 10px;
	text-align: left;
	color: black;
	opacity: 0.2;
	pointer-events: none;
	z-index: 5;
	display: flex;
	align-items: baseline;
	white-space: nowrap;
}

#storageReport {
	margin-left: 10px;
	color: black;
	opacity: 0.4;
	font-family: "Courier New", Courier, monospace;
	font-size: 10px;
	line-height: 1;
	white-space: nowrap;
	pointer-events: auto;
	cursor: help;
}

#watermark h1 {
	font-size: 15px;
	margin: 0;
	font-weight: 800;
	text-transform: uppercase;
	letter-spacing: 1px;
}

#bgImg {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	object-fit: contain;
	z-index: 1;
	pointer-events: none;
	-webkit-user-drag: none;
}

#drawingCanvas {
	position: relative;
	z-index: 2;
	cursor: var(--pencil-cursor);
	display: block;
	touch-action: none;
	user-select: none;
	-webkit-user-select: none;
	-webkit-touch-callout: none;
	-webkit-user-drag: none;
}

#drawingCanvas[data-tool="eraser"] {
	cursor: var(--eraser-cursor);
}

.ui-layer {
	position: fixed;
	z-index: 10;
	pointer-events: none;
	width: 100%;
	height: 100%;
	top: 0;
	left: 0;
}

.interactive {
	pointer-events: auto;
	cursor: pointer;
	transition: background 0.2s, transform 0.1s;
}

.interactive:active {
	transform: scale(0.9);
}

.btn-icon {
	width: 44px;
	height: 44px;
	border-radius: 8px;
	border: 1px solid var(--gray);
	background-color: rgba(255, 255, 255, 0.9);
	display: flex;
	align-items: center;
	justify-content: center;
	box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
	color: var(--dark-gray);
	fill: var(--dark-gray);
}

.btn-icon:hover {
	background-color: white;
	border-color: var(--dark-gray);
	fill: black;
	color: black;
}

.btn-icon svg {
	width: 22px;
	height: 22px;
}

.top-left {
	position: absolute;
	top: 10px;
	left: 10px;
	display: flex;
	align-items: center;
	gap: 8px;
}

.logo-btn {
	display: flex;
	align-items: center;
	margin-right: 4px;
}

.logo-btn img {
	width: 44px;
	height: 44px;
	object-fit: contain;
	transition: width 0.2s, height 0.2s;
}

.dropdown-container {
	position: relative;
	pointer-events: auto;
}

.dropdown-btn {
	background: rgba(255, 255, 255, 0.9);
	border: 1px solid var(--gray);
	padding: 0 10px;
	height: 32px;
	font-size: 15px;
	font-weight: bold;
	border-radius: 6px;
	box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
	max-width: 150px;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	line-height: 30px;
}

.dropdown-menu {
	display: none;
	position: absolute;
	top: 110%;
	left: 0;
	background: white;
	border: 1px solid var(--gray);
	border-radius: 6px;
	box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
	width: 220px;
	flex-direction: column;
}

.dropdown-menu.show {
	display: flex;
}

.dropdown-search {
	padding: 8px;
	border-bottom: 1px solid #eee;
}

.dropdown-search input {
	width: 100%;
	padding: 6px;
	font-size: 15px;
	border: 1px solid var(--gray);
	border-radius: 4px;
}

.dropdown-list {
	max-height: 200px;
	overflow-y: auto;
	list-style: none;
	padding: 0;
	margin: 0;
}

.dropdown-list li {
	padding: 8px 12px;
	font-size: 15px;
	border-bottom: 1px solid #eee;
	cursor: pointer;
}

.dropdown-list li:hover {
	background-color: var(--light-gray);
}

.right-tools {
	--toolbar-width: 62px;
	position: absolute;
	top: 50%;
	right: auto;
	left: 10px;
	transform: translateY(-50%);
	display: flex;
	flex-direction: column;
	width: var(--toolbar-width);
	gap: 8px;
	pointer-events: auto;
	background: rgba(255, 255, 255, 0.9);
	padding: 8px;
	border-radius: 8px;
	border: 1px solid var(--gray);
	box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
	align-items: center;
	height: auto;
	overflow: visible;
}

.drag-handle {
	width: 100%;
	padding: 4px 0;
	cursor: grab;
	display: flex;
	justify-content: center;
	align-items: center;
	background: transparent;
	margin-bottom: -4px;
	touch-action: none;
}

.drag-handle:active {
	cursor: grabbing;
}

.right-tools.collapsed {
	height: auto;
	padding: 8px;
	padding-bottom: 12px;
	min-height: auto;
}

.right-tools.collapsed .drag-handle {
	width: 100%;
}

.right-tools.collapsed > :not(.drag-handle) {
	display: none !important;
}

.active-tool {
	background-color: #e3f2fd;
	border-color: #2196f3;
	fill: #2196f3;
}

#strokePreviewBtn.active-realtime {
	background-color: #fff3e0;
	border-color: #ff9800;
	fill: #ef6c00;
	color: #ef6c00;
}

.divider {
	width: 24px;
	height: 1px;
	background-color: #ccc;
	margin: 4px 0;
}

.size-label,
.zoom-label {
	font-size: 10px;
	font-weight: bold;
	text-align: center;
	color: var(--dark-gray);
}

.size-label {
	margin-top: 4px;
}

.zoom-label {
	width: 100%;
}

.brush-icon {
	width: 16px;
	height: 16px;
	fill: var(--dark-gray);
	margin: -4px 0;
}

.size-btn {
	color: var(--dark-gray);
	font-weight: bold;
}

.size-btn-plus {
	font-size: 18px;
	line-height: 1;
	margin-top: 2px;
}

.size-btn-minus {
	font-size: 24px;
	line-height: 0.5;
	margin-bottom: 6px;
}

input[type="range"] {
	writing-mode: vertical-lr;
	direction: rtl;
	width: 8px;
	height: 80px;
	margin: 5px 0;
	cursor: pointer;
}

.palette-modal {
	position: absolute;
	background: white;
	border: 1px solid var(--gray);
	padding: 8px;
	border-radius: 8px;
	box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
	display: none;
	grid-template-columns: repeat(4, 24px);
	gap: 6px;
	pointer-events: auto;
	z-index: 20;
}

.swatch {
	width: 24px;
	height: 24px;
	border-radius: 4px;
	border: 1px solid rgba(0, 0, 0, 0.2);
	cursor: pointer;
	transition: transform 0.1s;
}

.swatch:hover {
	transform: scale(1.15);
	border-color: black;
}

.brush-divider {
	grid-column: span 4;
	display: none;
	margin-top: 4px;
	padding-top: 8px;
	border-top: 1px solid #eee;
	font-size: 11px;
	font-weight: bold;
	color: #555;
}

.brush-selector {
	grid-column: span 4;
	display: none;
	grid-template-columns: repeat(4, 30px);
	gap: 6px;
}

.palette-modal.show-brush-selector .brush-divider,
.palette-modal.show-brush-selector .brush-selector {
	display: grid;
}

.palette-modal.show-brush-selector {
	grid-template-columns: repeat(4, 30px);
}

.palette-modal.show-brush-selector .brush-divider {
	display: block;
}

.brush-option {
	width: 30px;
	height: 30px;
	padding: 0;
	border: 1px solid rgba(0, 0, 0, 0.2);
	border-radius: 5px;
	background: #fff;
	color: var(--dark-gray);
	fill: currentColor;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
}

.brush-option:hover {
	border-color: var(--dark-gray);
}

.brush-option.selected-brush {
	background: #e3f2fd;
	border: 2px solid #2196f3;
	color: #2196f3;
}

.brush-option svg {
	width: 18px;
	height: 18px;
}

.modal-overlay {
	position: fixed;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	background: rgba(0, 0, 0, 0.5);
	z-index: 100;
	display: none;
	justify-content: center;
	align-items: center;
	pointer-events: auto;
}

.modal {
	background: white;
	border: 1px solid var(--gray);
	border-radius: 8px;
	padding: 20px;
	width: 90%;
	max-width: 350px;
	box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.modal h2 {
	margin: 0 0 15px 0;
	font-size: 15px;
	color: var(--dark-gray);
}

.modal p {
	font-size: 15px;
	color: var(--dark-gray);
	margin: 0 0 15px 0;
}

.modal input[type="text"] {
	width: 100%;
	padding: 8px;
	font-size: 16px;
	border: 1px solid var(--gray);
	border-radius: 4px;
	margin-bottom: 15px;
}

.modal .about-heading {
	display: flex;
	align-items: center;
	gap: 8px;
}

.modal .about-heading img {
	width: 32px;
	height: 32px;
	object-fit: contain;
}

.modal .about-credit {
	font-size: 11px;
}

.modal .about-copy {
	font-size: 10px;
	color: #808080;
}

.modal-buttons {
	display: flex;
	justify-content: flex-end;
	gap: 10px;
}

#insecureBackgroundUrlModal .modal-buttons {
	flex-wrap: wrap;
}

.btn {
	padding: 6px 12px;
	font-size: 15px;
	border-radius: 4px;
	border: none;
	cursor: pointer;
	color: white;
	font-weight: bold;
}

.btn-gray {
	background-color: var(--gray);
}

.btn-green {
	background-color: var(--primary);
}

.btn-red {
	background-color: var(--danger);
}

.bg-choice-row {
	display: flex;
	gap: 15px;
	margin-bottom: 15px;
}

.bg-choice-card {
	flex: 1;
	border: 1px solid var(--gray);
	border-radius: 8px;
	padding: 15px;
	text-align: center;
	background: var(--light-gray);
}

.bg-choice-card svg {
	width: 32px;
	height: 32px;
	fill: var(--primary);
	margin-bottom: 8px;
}

.bg-choice-title {
	font-weight: bold;
	font-size: 14px;
	color: var(--dark-gray);
}

.bg-choice-desc {
	font-size: 11px;
	color: #666;
	margin-top: 4px;
}

.click-tooltip {
	position: fixed;
	background: black;
	color: white;
	padding: 5px 10px;
	border-radius: 4px;
	font-size: 11px;
	font-weight: bold;
	pointer-events: none;
	opacity: 0;
	transition: opacity 0.2s ease-out;
	z-index: 1000;
	white-space: nowrap;
	transform: translateY(-50%);
}

.click-tooltip::after {
	content: '';
	position: absolute;
	top: 50%;
	margin-top: -4px;
	border-style: solid;
}

/* Toolbar nearer the right edge — label sits to the left of the control */
.click-tooltip--left::after {
	right: -4px;
	left: auto;
	border-width: 4px 0 4px 4px;
	border-color: transparent transparent transparent black;
}

/* Toolbar nearer the left edge — label sits to the right of the control */
.click-tooltip--right::after {
	left: -4px;
	right: auto;
	border-width: 4px 4px 4px 0;
	border-color: transparent black transparent transparent;
}

.tips-container,
#tipsContainer {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 44px;
	box-sizing: border-box;
	padding: 0 10px;
	display: none;
	align-items: center;
	justify-content: flex-end;
	font-size: 15px;
	text-align: right;
	white-space: nowrap;
	pointer-events: none;
}

@media (min-width: 1180px) {
	.tips-container:not([hidden]),
	#tipsContainer:not([hidden]) {
		display: flex;
	}
}

#splash-screen {
	position: fixed;
	top: 0;
	left: 0;
	width: 100vw;
	height: 100vh;
	background-color: #e0e0e0;
	z-index: 9999;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: opacity 0.5s ease-out, visibility 0.5s ease-out;
}

.splash-container {
	position: relative;
	width: 75vmin;
	height: 75vmin;
	display: flex;
	flex-direction: column;
	justify-content: center;
	padding: 0;
}

.splash-container .splash-bg-logo {
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	width: 100%;
	height: 100%;
	z-index: 1;
	opacity: 0.5;
	object-fit: contain;
	pointer-events: none;
}

.splash-text {
	position: relative;
	z-index: 2;
	color: var(--dark-gray);
	text-shadow: 2px 2px 0px rgba(255, 255, 255, 0.9), -2px -2px 0px rgba(255, 255, 255, 0.9), 2px -2px 0px rgba(255, 255, 255, 0.9), -2px 2px 0px rgba(255, 255, 255, 0.9);
}

.splash-text h1 {
	text-align: left;
	font-size: 10vmin;
	margin: 0;
	font-weight: 900;
	letter-spacing: -0.2vmin;
}

.splash-text h1 .show-version::after {
	font-size: 3.5vmin;
	vertical-align: top;
	margin-left: 1vmin;
}

.splash-text .tagline {
	text-align: left;
	font-size: 4vmin;
	margin: 0;
	font-weight: 600;
	margin-left: 55px;
}

.loader-container {
	position: absolute;
	top: 60%;
	left: 35%;
	transform: translateX(-50%);
	display: flex;
	flex-direction: column;
	align-items: center;
	width: fit-content;
	min-width: 15vmin;
}

.spinner {
	opacity: 0.30;
	width: 15vmin;
	height: 15vmin;
	border-radius: 50%;
	border: 2vmin solid rgba(0, 0, 0, 0.05);
	border-top: 2vmin solid #FF5722;
	border-right: 2vmin solid #E91E63;
	border-bottom: 2vmin solid #2196F3;
	animation: spin 0.5s linear infinite;
}

.loader-container p {
	font-size: 11px;
	margin: 6px 0 0 0;
	color: var(--dark-gray);
	text-shadow: none;
	text-transform: lowercase;
	font-weight: bold;
}

.loader-container p {
	background: linear-gradient(110deg, #757575 35%, #fff 50%, #757575 65%);
	background-size: 250% 100%;
	-webkit-background-clip: text;
	background-clip: text;
	color: transparent;
	animation: loading-text-shimmer 1.2s linear infinite;
}

.splash-text .copyright {
	text-align: right;
	width: 100%;
	font-size: 2.5vmin;
	margin-top: 10vmin;
	color: #666;
	font-weight: bold;
	text-shadow: none;
}

@keyframes spin {
	0% { transform: rotate(0deg); }
	100% { transform: rotate(360deg); }
}

@keyframes loading-text-shimmer {
	from { background-position: 100% 0; }
	to { background-position: -100% 0; }
}

@media (prefers-reduced-motion: reduce) {
	.loader-container p {
		animation: none;
		color: var(--dark-gray);
		background: none;
	}
}

@media (max-width: 768px) {
	.right-tools {
		--toolbar-width: 50px;
		position: fixed;
		top: 50%;
		right: auto;
		bottom: auto;
		left: 8px;
		transform: translateY(-50%);
		width: var(--toolbar-width);
		max-height: calc(100vh - 72px);
		flex-direction: column;
		flex-wrap: nowrap;
		justify-content: center;
		align-content: center;
		gap: 6px;
		overflow-y: auto;
	}
	.drag-handle {
		width: 28px;
		padding: 0;
		margin: 0;
	}
	.divider {
		display: none;
	}
	.size-label,
	.zoom-label,
	.brush-icon,
	.size-btn {
		display: none;
	}
	.btn-icon {
		width: 32px;
		height: 32px;
		border-radius: 6px;
	}

	.btn-icon svg {
		width: 16px;
		height: 16px;
	}
	.logo-btn img {
		width: 32px;
		height: 32px;
	}
}

@media (max-width: 600px) {
	.top-left {
		gap: 4px;
		left: 5px;
		top: 5px;
	}
	.top-left .btn-icon {
		width: 28px;
		height: 28px;
	}
	.top-left .btn-icon svg {
		width: 14px;
		height: 14px;
	}
	.dropdown-btn {
		max-width: 90px;
		padding: 0 6px;
		font-size: 13px;
		height: 28px;
		line-height: 26px;
	}
	.logo-btn img {
		width: 28px;
		height: 28px;
	}
	#watermark h1 {
		font-size: 12px;
	}
}

@media (max-height: 500px) {
	.right-tools {
		--toolbar-width: 32px;
		gap: 2px;
		padding: 2px 4px;
	}
	.btn-icon {
		width: 22px;
		height: 22px;
		border-radius: 4px;
	}
	.btn-icon svg {
		width: 12px;
		height: 12px;
	}
	input[type="range"] {
		height: 35px;
		margin: 0;
	}
	.divider {
		margin: 1px 0;
	}
	#sizeText,
	#zoomText {
		display: none;
	}
}
