@font-face {
	font-family: "BDO Grotesk";
	src: url("fonts/BDOGrotesk-Regular.woff2") format("woff2");
	font-weight: 400;
	font-style: normal;
	font-display: swap;
}

:root {
	--black: #000000;
	--white: #ffffff;
	--gray: #b1b1b1;
	--gray-soft: #e5e5e5;
	--canvas-bg: #f2f2f2;
	--cursor: #ff0000;
	--eraser: #005ff8;
	--fg: var(--black);
	--fg-muted: var(--gray);
	--bg: var(--white);
	--bg-hover: var(--gray-soft);
	--bg-disabled: var(--gray-soft);
	--font-family: "BDO Grotesk", "Helvetica Neue", Helvetica, Arial, sans-serif;
	--body-lg: 16px;
	--body-m: 14px;
	--body-sm: 12px;
	--leading-tight: 1.1;
	--leading-body: 1.35;
	--border: 1px solid var(--black);
	--border-muted: 1px solid var(--gray);
	--radius-0: 0;
	--radius-sm: 4px;
	--space-1: 4px;
	--space-2: 8px;
	--space-3: 12px;
	--space-4: 16px;
	--space-6: 24px;
	--space-8: 32px;
	--control-h: 36px;

	/* Active tool/state color + contrast text (updated dynamically by JS) */
	--pd-active-color: #000000;
	--pd-active-text: #ffffff;

	/* Color picker palette — edit freely */
	--pd-color-1: #000000;
	--pd-color-2: #555555;
	--pd-color-3: #aaaaaa;
	--pd-color-4: #ffffff;
	--pd-color-5: #fc2821;
	--pd-color-6: #e87722;
	--pd-color-7: #e8c922;
	--pd-color-8: #88c922;
	--pd-color-9: #19cd0c;
	--pd-color-10: #22aaaa;
	--pd-color-11: #14d3f9;
	--pd-color-12: #7722cc;
	--pd-color-13: #cc22aa;
	--pd-color-14: #cc2266;
	--pd-color-15: #884422;
	--pd-color-16: #2525ff;
}

*,
*::before,
*::after {
	box-sizing: border-box;
}
[hidden] {
	display: none !important;
}

html,
body {
	margin: 0;
	padding: 0;
	width: 100%;
	height: 100%;
	overflow: hidden;
	font-family: var(--font-family);
	color: var(--fg);
	background: var(--canvas-bg);
	font-size: var(--body-sm);
	line-height: var(--leading-body);
	-webkit-font-smoothing: antialiased;
	text-rendering: optimizeLegibility;
}

button {
	font: inherit;
	color: inherit;
	background: none;
	border: 0;
	padding: 0;
	margin: 0;
	cursor: pointer;
}
button:focus-visible {
	outline: 2px solid var(--cursor);
	outline-offset: 1px;
}
.pd-tbtn:focus-visible,
.pd-hand-btn:focus-visible,
.pd-pattern-chip:focus-visible,
.pd-shortcuts-btn:focus-visible {
	outline: none;
}

.t-numeric {
	font-variant-numeric: tabular-nums;
	font-size: var(--body-sm);
}

/* App */
#app {
	position: relative;
	width: 100%;
	height: 100%;
}

/* Canvas layers */
#main-canvas,
#overlay-canvas {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
}
#main-canvas {
	z-index: 0;
}
#overlay-canvas {
	z-index: 1;
	cursor: none;
}

/* Ruler strips — thin L-shaped visual guides at top + left edges */
.pd-ruler {
	position: absolute;
	z-index: 2;
	pointer-events: none; /* overlay-canvas handles all pointer events */
	background: rgba(200, 200, 200, 0.55);
	backdrop-filter: blur(2px);
	-webkit-backdrop-filter: blur(2px);
}
.pd-ruler-corner {
	top: 0;
	left: 0;
	width: 16px;
	height: 16px;
}
.pd-ruler-h {
	top: 0;
	left: 16px;
	width: calc(100% - 16px);
	height: 16px;
}
.pd-ruler-v {
	top: 16px;
	left: 0;
	width: 16px;
	height: calc(100% - 16px);
}
/* Dark canvas mode → lighter ruler */
.pd-canvas-dark .pd-ruler {
	background: rgba(60, 60, 60, 0.55);
}

/* View toolbar — top right */
.pd-view-toolbar {
	position: absolute;
	top: 24px;
	right: 28px;
	display: inline-flex;
	flex-direction: column;
	align-items: center;
	gap: 8px;
	z-index: 10;
}
.pd-zoom-label {
	font-size: 13px;
	width: 44px;
	text-align: center;
	background: transparent;
	border: 0;
	border-bottom: 1px solid transparent;
	color: var(--black);
	font-family: inherit;
	padding: 0;
	cursor: text;
}
.pd-zoom-label:hover {
	border-bottom-color: var(--gray);
}

/* Canvas background is dark → flip overlay controls to white */
.pd-canvas-dark .pd-zoom-label,
.pd-canvas-dark #btn-fit,
.pd-canvas-dark .pd-shortcuts-btn,
.pd-canvas-dark .pd-shortcuts-list {
	color: #ffffff;
}
.pd-canvas-dark .pd-zoom-label:hover {
	border-bottom-color: rgba(255, 255, 255, 0.4);
}
.pd-canvas-dark .pd-zoom-label:focus {
	border-bottom-color: #ffffff;
}
.pd-zoom-label:focus {
	outline: none;
	border-bottom-color: var(--black);
}
.pd-hand-btn {
	width: 28px;
	height: 28px;
	background: transparent;
	border: 0;
	color: var(--black);
	display: inline-flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	padding: 0;
}
.pd-hand-btn.is-active {
	color: var(--cursor);
}

/* Round zoom buttons */
.pd-rbtn {
	width: 28px;
	height: 28px;
	border-radius: 50%;
	background: var(--white);
	color: var(--black);
	border: 1px solid var(--black);
	display: inline-flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
}
.pd-rbtn:hover {
	background: var(--black);
	color: var(--white);
}

/* Shortcuts toggle */
.pd-shortcuts-wrap {
	position: absolute;
	bottom: 24px;
	left: 28px;
	z-index: 5;
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: 10px;
}
.pd-shortcuts-btn {
	color: var(--black);
	opacity: 0.6;
	transition: opacity 0.1s;
}
.pd-shortcuts-btn:hover,
.pd-shortcuts-btn.is-active {
	opacity: 1;
}
.pd-shortcuts-list {
	display: grid;
	grid-template-columns: max-content 1fr;
	column-gap: 10px;
	row-gap: 2px;
	font-size: 10px;
	line-height: 1.5;
	color: var(--black);
	margin: 0;
	padding: 0;
}
.pd-shortcuts-list dt {
	font-weight: 500;
	white-space: nowrap;
}
.pd-shortcuts-list dd {
	margin: 0;
	white-space: nowrap;
}
.pd-shortcuts-list .pd-sc-divider {
	grid-column: 1 / -1;
	height: 6px;
}

/* Bottom toolbar */
.pd-toolbar-wrap {
	position: absolute;
	left: 50%;
	bottom: 24px;
	transform: translateX(-50%);
	z-index: 5;
}
.pd-toolbar-row {
	display: flex;
	align-items: center;
	gap: 6px;
}
.pd-tg {
	display: inline-flex;
	align-items: center;
	gap: 0px;
	background: var(--white);
	border-radius: 4px;
	/* padding: 3px; */
	color: var(--black);
	border: 1px solid var(--black);
}

/* Buttons & pattern chip inside a cluster pill */
.pd-tg .pd-tbtn {
	background: transparent;
	border: none;
	color: var(--black);
	border-radius: 0px;
}
.pd-tg .pd-tbtn:hover {
	background: var(--gray-soft);
	color: var(--black);
}
.pd-tg .pd-tbtn[data-state="active"],
.pd-tg .pd-tbtn[aria-pressed="true"] {
	background: var(--pd-active-color);
	color: var(--pd-active-text);
}
.pd-tg .pd-tbtn[data-state="open"] {
	background: var(--gray-soft);
	color: var(--black);
}
.pd-view-toolbar .pd-tg {
	flex-direction: column;
}
.pd-view-toolbar .pd-tbtn,
.pd-toolbar-row .pd-tbtn {
	height: 26px;
	min-width: 26px;
	padding-inline: 6px;
}
.pd-view-toolbar .pd-tbtn--square,
.pd-toolbar-row .pd-tbtn--square {
	width: 26px;
}
.pd-toolbar-row .pd-tbtn--size {
	width: 40px;
}
.pd-view-toolbar .pd-rbtn {
	width: 24px;
	height: 24px;
}
.pd-view-toolbar .pd-hand-btn {
	width: 24px;
	height: 24px;
}
.pd-toolbar-row .pd-pattern-chip {
	width: 26px;
	height: 26px;
}
.pd-tg .pd-tbtn[disabled] {
	background: transparent;
	color: var(--gray);
	cursor: not-allowed;
}
.pd-tg .pd-tbtn.is-active {
	background: var(--pd-active-color);
	color: var(--pd-active-text);
}
.pd-tg .pd-pattern-chip {
	border: none;
	border-radius: 0px;
	outline-offset: 0;
}
.pd-tg .pd-pattern-chip[data-state="open"] {
	outline: 1px solid var(--cursor);
	outline-offset: 1px;
}

/* Popovers */
.pd-popover {
	position: absolute;
	z-index: 6;
	border: var(--border);
	border-radius: var(--radius-sm);
	overflow: hidden;
}

/* Toolbar buttons */
.pd-tbtn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	height: 24px;
	min-width: var(--control-h);
	padding-inline: var(--space-1);
	padding-top: 0px;
	font-size: var(--body-sm);
	line-height: 1;
	letter-spacing: 0.02em;
	color: var(--black);
	background: var(--white);
	border: 1px solid var(--black);
	border-radius: var(--radius-sm);
	cursor: pointer;
	user-select: none;
}
.pd-tbtn:hover {
	background: var(--gray-soft);
	color: var(--black);
}
.pd-tbtn[data-state="active"],
.pd-tbtn[aria-pressed="true"] {
	background: var(--pd-active-color);
	color: var(--pd-active-text);
}
.pd-tbtn[data-state="open"] {
	background: var(--gray-soft);
	color: var(--black);
}
.pd-tbtn[data-state="inactive"],
.pd-tbtn[disabled] {
	background: var(--white);
	color: var(--gray);
	border-color: var(--gray);
	cursor: not-allowed;
}
.pd-tbtn--square {
	padding: 0;
	width: var(--control-h);
}
#btn-layers.is-active {
	background: var(--black);
	color: var(--white);
	border-color: var(--black);
}
.pd-tbtn--size {
	width: 52px;
}
.pd-tbtn--export {
	padding: 0 14px;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	font-size: var(--body-sm);
}
.ped-tbtn--arrow {
	gap: 5px;
	padding: 0 10px;
	min-width: auto;
}
.ped-tbtn--arrow span {
	font-size: 10px;
	letter-spacing: 0.06em;
	text-transform: uppercase;
}

/* Pattern chip */
.pd-pattern-chip {
	width: var(--control-h);
	height: var(--control-h);
	border: 1px solid var(--black);
	border-radius: var(--radius-sm);
	background-color: var(--white);
	background-repeat: repeat;
	image-rendering: pixelated;
	cursor: pointer;
	padding: 0;
}
.pd-pattern-chip[data-state="open"] {
	outline: 2px solid var(--black);
	outline-offset: -1px;
}

/* Color picker palette */
.pd-color-palette {
	display: grid;
	grid-template-columns: repeat(4, 22px);
	gap: 8px;
	padding: 12px;
	background: var(--white);
}
.pd-color-tile {
	width: 22px;
	height: 22px;
	border-radius: 50%;
	border: 1px solid rgba(0, 0, 0, 0.15);
	cursor: pointer;
	padding: 0;
	transition: transform 0.08s;
}
.pd-color-tile:hover {
	transform: scale(1.18);
	z-index: 1;
	position: relative;
}
.pd-color-tile[aria-selected="true"] {
	outline: 2px solid var(--black);
	outline-offset: 1px;
}

/* Hidden color input anchored to viewport center so the native picker opens centered */
.pd-color-input-anchor {
	position: fixed;
	left: 50%;
	top: 50%;
	width: 0;
	height: 0;
	opacity: 0;
	pointer-events: none;
	border: 0;
	padding: 0;
}

/* Color picker popover structure */
.pd-color-wrap {
	display: flex;
	flex-direction: column;
	gap: 0;
}

.pd-color-custom-section {
	display: flex;
	flex-direction: column;
	gap: 6px;
	padding: 10px 12px 0;
	background: var(--white);
}
.pd-color-custom-grid {
	border: none !important;
	background: none !important;
	border-radius: 0 !important;
	padding: 0; /* section provides the side spacing */
}

/* Color dot inside toolbar button */
.pd-color-dot {
	width: 14px;
	height: 14px;
	border-radius: 50%;
	border: 1.5px solid rgba(0, 0, 0, 0.25);
	display: block;
	flex-shrink: 0;
	pointer-events: none;
}

/* Pattern palette */
.pd-palette {
	display: grid;
	grid-template-columns: repeat(7, 32px);
	gap: var(--radius-sm);
	padding: 16px;
	background: var(--white);
	width: max-content;
}
.pd-palette__tile {
	width: 32px;
	height: 32px;
	background-color: var(--white);
	background-repeat: repeat;
	image-rendering: pixelated;
	cursor: pointer;
	position: relative;
}
.pd-palette__tile:hover {
	outline: 1px solid var(--black);
	outline-offset: -1px;
	z-index: 1;
}
.pd-palette__tile[aria-selected="true"] {
	outline: 2px solid var(--cursor);
	outline-offset: -1px;
	z-index: 1;
}

/* Size select */
.pd-select {
	display: inline-flex;
	flex-direction: column;
	background: var(--white);
	min-width: 40px;
}
.pd-select__item {
	height: 26px;
	padding: 0 var(--space-1);
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: var(--body-sm);
	background: var(--white);
	color: var(--black);
	border-bottom: var(--border);
	cursor: pointer;
	user-select: none;
}
.pd-select__item:last-child {
	border-bottom: 0;
}
.pd-select__item:hover {
	background: var(--bg-hover);
}
.pd-select__item[aria-selected="true"] {
	background: var(--black);
	color: var(--white);
}

.pd-select__custom {
	height: 26px;
	width: 100%;
	padding: 0 var(--space-1);
	border: none;
	border-top: var(--border);
	font-size: var(--body-sm);
	font-family: inherit;
	text-align: center;
	background: var(--white);
	color: var(--black);
	box-sizing: border-box;
}
.pd-select__custom::-webkit-outer-spin-button,
.pd-select__custom::-webkit-inner-spin-button {
	-webkit-appearance: none;
	margin: 0;
}
.pd-select__custom:focus {
	outline: none;
	background: var(--bg-hover);
}

/* Export modal */
.pd-modal-shell {
	position: fixed;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	z-index: 10;
	pointer-events: none;
}
.pd-modal-shell:not([hidden]) {
	pointer-events: auto;
}
.pd-modal {
	background: var(--white);
	border: var(--border);
	border-radius: var(--radius-sm);
	padding: 24px;
	min-width: 280px;
	display: flex;
	flex-direction: column;
	gap: 18px;
	pointer-events: auto;
}
.pd-field {
	display: flex;
	flex-direction: row;
	gap: 6px;
}
.pd-field__label {
	font-size: 11px;
	color: var(--gray);
	letter-spacing: 0.04em;
}
.pd-field__sub {
	display: flex;
	flex-direction: row;
	gap: 6px;
}
.pd-field--actions {
	flex-direction: column;
	align-items: flex-start;
	justify-content: space-between;
	gap: 40px;
}
.pd-field__input {
	border: 0;
	border-bottom: 1px solid var(--gray);
	width: 100%;
	padding: 6px 0;
	font: inherit;
	color: var(--fg);
	background: transparent;
	outline: none;
}
.pd-field__input:focus {
	border-bottom-color: var(--black);
}
.pd-field__input::placeholder {
	color: var(--gray);
}
.pd-segment {
	display: inline-flex;
	gap: 6px;
}
.pd-modal__actions {
	display: inline-flex;
	gap: 6px;
	align-items: flex-end;
}

/* =========================================================
   Pattern palette — custom section
   ========================================================= */
.ped-palette-wrap {
	display: flex;
	flex-direction: column;
	gap: 0;
}

.ped-custom-section {
	display: flex;
	flex-direction: column;
	gap: 6px;
	padding: 10px 16px 0;
	background: var(--white);
}

.ped-custom-label {
	font-size: 10px;
	letter-spacing: 0.02em;
	text-transform: uppercase;
	color: var(--gray);
	padding-inline: var(--space-2);
}

.ped-custom-grid {
	border: none;
	padding: 0;
	border-radius: 0;
}

/* Custom tile with delete button */
.ped-tile-wrap {
	position: relative;
	display: inline-flex;
}

.ped-tile-delete {
	position: absolute;
	top: -4px;
	right: -4px;
	width: 14px;
	height: 14px;
	border-radius: 50%;
	background: var(--black);
	color: var(--white);
	border: 0;
	font-size: 10px;
	line-height: 1;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	padding: 0;
	opacity: 0;
	transition: opacity 0.1s;
	z-index: 2;
}
.ped-tile-wrap:hover .ped-tile-delete {
	opacity: 1;
}
.ped-tile-delete:hover {
	background: var(--cursor);
}

.ped-new-btn {
	display: flex;
	align-items: center;
	justify-content: center;
	height: 32px;
	padding: 0;
	font-size: 11px;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	color: var(--black);
	background: var(--white);
	border: none;
	border-top: var(--border);
	border-radius: 0;
	cursor: pointer;
	/* Negative margins bleed past the parent's horizontal padding; flex stretch
	   sets the width automatically so no calc(100%+…) needed. */
	margin: 4px -16px 0;
}
.pd-color-custom-section .ped-new-btn {
	margin: 4px -12px 0;
}
.ped-new-btn:hover {
	background: var(--black);
	color: var(--white);
}

/* =========================================================
   Pattern Editor modal
   ========================================================= */
.ped-modal {
	width: auto;
	max-width: 580px;
}

.ped-header {
	display: flex;
	align-items: baseline;
	gap: 20px;
}

.ped-name-input {
	flex: 1;
	max-width: 220px;
}

.ped-workspace {
	display: flex;
	gap: 24px;
	align-items: flex-start;
}

/* 8×8 grid — 40px cells = 320px */
.ped-grid {
	display: grid;
	grid-template-columns: repeat(8, 40px);
	grid-template-rows: repeat(8, 40px);
	border: var(--border);
	cursor: crosshair;
	user-select: none;
	flex-shrink: 0;
}

.ped-cell {
	width: 40px;
	height: 40px;
	background: var(--white);
	border-right: 1px solid var(--gray-soft);
	border-bottom: 1px solid var(--gray-soft);
	cursor: crosshair;
	box-sizing: border-box;
}
.ped-cell:nth-child(8n) {
	border-right: none;
}
.ped-cell:nth-child(n + 57) {
	border-bottom: none;
}

.ped-cell.is-set {
	background: var(--black);
}
.ped-cell:not(.is-set):hover {
	background: var(--gray-soft);
}

/* Live preview canvas */
.ped-preview {
	border: var(--border);
	image-rendering: pixelated;
	image-rendering: -moz-crisp-edges;
	flex-shrink: 0;
}

.ped-actions {
	display: flex;
	justify-content: space-between;
	align-items: center;
	gap: 12px;
}

.ped-actions-left,
.ped-actions-right {
	display: flex;
	gap: 6px;
}

/* ── Layer Panel ──────────────────────────────────────────────────────────── */

/* ── Layer panel ─────────────────────────────────────────────────────────────── */

.pd-layer-panel {
	position: fixed;
	width: 300px;
	background: var(--white);
	border: var(--border);
	border-radius: var(--radius-sm);
	display: flex;
	flex-direction: column;
	max-height: calc(100vh - 80px);
	z-index: 200;
	user-select: none;
	overflow: hidden;
}

.pd-layer-panel__header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 0 4px 0 10px;
	height: 32px;
	flex-shrink: 0;
	border-bottom: var(--border);
}

.pd-layer-panel__title {
	font-size: var(--body-sm);
	letter-spacing: 0.03em;
}

.pd-layer-panel__add {
	width: 28px;
	height: 28px;
	border: none;
	background: none;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	border-radius: var(--radius-sm);
	color: var(--black);
	padding: 0;
	flex-shrink: 0;
}

.pd-layer-panel__add:hover {
	background: var(--bg-hover);
}

.pd-layer-list {
	list-style: none;
	margin: 0;
	padding: 3px 0;
	overflow-y: auto;
	flex: 1;
}

/* ── Layer item ─────────────────────────────────────────────────────────── */

.pd-layer-item {
	display: flex;
	align-items: center;
	gap: 2px;
	padding: 0 4px;
	height: 32px;
	cursor: pointer;
	border-radius: calc(var(--radius-sm) - 1px);
	margin: 0 3px;
}

.pd-layer-item:hover {
	background: var(--bg-hover);
}

.pd-layer-item--active {
	background: var(--black);
	color: var(--white);
}

.pd-layer-item--active:hover {
	background: var(--black);
}

.pd-layer-item--hidden .pd-layer-name {
	opacity: 0.4;
}

.pd-layer-item--dragging {
	opacity: 0.35;
}

.pd-layer-item--dragover {
	box-shadow: inset 0 2px 0 0 var(--black);
}

.pd-layer-item--active.pd-layer-item--dragover {
	box-shadow: inset 0 2px 0 0 var(--white);
}

/* ── Layer item buttons ──────────────────────────────────────────────────── */

.pd-layer-btn {
	width: 26px;
	height: 26px;
	border: none;
	background: none;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	border-radius: calc(var(--radius-sm) - 1px);
	color: currentColor;
	padding: 0;
	flex-shrink: 0;
}

.pd-layer-btn:hover {
	background: rgba(0, 0, 0, 0.08);
}

.pd-layer-item--active .pd-layer-btn:hover {
	background: rgba(255, 255, 255, 0.18);
}

.pd-layer-btn:disabled {
	opacity: 0.25;
	cursor: default;
	pointer-events: none;
}

/* ── Layer name ──────────────────────────────────────────────────────────── */

.pd-layer-name {
	flex: 1;
	font-size: var(--body-sm);
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	min-width: 0;
	padding: 0 2px;
}

.pd-layer-name-input {
	flex: 1;
	min-width: 0;
	border: none;
	outline: 1px solid currentColor;
	background: transparent;
	font-size: var(--body-sm);
	font-family: var(--font-family);
	color: currentColor;
	border-radius: 2px;
	padding: 1px 4px;
	height: 22px;
}

/* ── Action buttons (duplicate, delete) — only show on hover / active ─────── */

.pd-layer-action {
	opacity: 0;
	transition: opacity 0.1s;
}

.pd-layer-item:hover .pd-layer-action,
.pd-layer-item--active .pd-layer-action {
	opacity: 1;
}

/* Guide-layer toggle button — always visible when guide is active */
.pd-layer-guide-btn.is-active {
	opacity: 1;
	color: #005ff8;
}

/* Link toggle button — always visible when layer is linked */
.pd-layer-link-btn.is-active {
	opacity: 1;
	color: #005ff8;
}

/* Guide-layer row — dashed left border + name dimmed */
.pd-layer-item--guide {
	border-left: 2px dashed rgba(0, 95, 248, 0.45);
	padding-left: 6px;
}
.pd-layer-item--guide .pd-layer-name {
	opacity: 0.55;
	font-style: italic;
}

/* ── Drop zone ───────────────────────────────────────────────────────────────── */

#app.pd-drop-active::after {
	content: "Bild als Vorlage ablegen";
	position: fixed;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 18px;
	font-family: var(--font-family);
	color: #005ff8;
	background: rgba(0, 95, 248, 0.07);
	border: 2px dashed rgba(0, 95, 248, 0.5);
	pointer-events: none;
	z-index: 999;
}

/* ── Text tool panel ─────────────────────────────────────────────────────────── */

.pd-text-panel {
	position: fixed;
	z-index: 200;
	display: flex;
	flex-direction: column;
	gap: 6px;
	padding: 10px 12px;
	background: var(--white);
	border: var(--border);
	border-radius: var(--radius-sm);
	box-shadow: 0 2px 12px rgba(0, 0, 0, 0.14);
}

.pd-text-field {
	width: 236px;
	height: 30px;
	padding: 0 8px;
	font-size: var(--body-m);
	font-family: inherit;
	border: var(--border);
	border-radius: var(--radius-sm);
	background: var(--bg);
	color: var(--fg);
	outline: none;
}
.pd-text-field:focus {
	border-color: var(--fg);
}

.pd-text-controls {
	display: flex;
	align-items: center;
	gap: 6px;
}

.pd-text-size {
	width: 64px;
	height: 28px;
	padding: 0 6px;
	font-size: var(--body-sm);
	font-family: inherit;
	border: var(--border);
	border-radius: var(--radius-sm);
	background: var(--bg);
	color: var(--fg);
	outline: none;
	text-align: right;
}
.pd-text-size:focus {
	border-color: var(--fg);
}

.pd-text-btn {
	width: 28px;
	height: 28px;
	padding: 0;
	font-size: 14px;
	display: flex;
	align-items: center;
	justify-content: center;
}

/* ── Restore banner ──────────────────────────────────────────────────────────── */

.pd-restore-banner {
	position: fixed;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	z-index: 200;
	display: flex;
	align-items: center;
	gap: var(--space-3);
	padding: 8px 12px 8px 16px;
	background: var(--white);
	border: var(--border);
	border-radius: var(--radius-sm);
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
	white-space: nowrap;
	font-size: var(--body-sm);
}

.pd-restore-text {
	color: var(--fg);
}

.pd-restore-actions {
	display: flex;
	gap: var(--space-1);
}

.pd-tbtn--restore {
	height: 28px;
	padding: 0 10px;
	font-size: var(--body-sm);
	border: var(--border);
	background: var(--black);
	color: var(--white);
	border-radius: var(--radius-sm);
	cursor: pointer;
}

.pd-tbtn--restore:hover {
	opacity: 0.75;
}

.pd-tbtn--restore-dismiss {
	background: var(--white);
	color: var(--black);
}

/* ── Record button ───────────────────────────────────────────────────────────── */

.pd-rec-wrap {
	position: relative;
	display: flex;
	align-items: center;
}

/* Show only the idle icon by default */
#btn-record .pd-rec-icon--active {
	display: none;
}
#btn-record .pd-rec-icon--idle {
	display: block;
}

/* While recording: swap icons, turn button red */
#btn-record.is-recording .pd-rec-icon--idle {
	display: none;
}
#btn-record.is-recording .pd-rec-icon--active {
	display: block;
}

#btn-record.is-recording {
	color: #cc2222;
	border-color: #cc2222;
	animation: pd-rec-pulse 1.2s ease-in-out infinite;
}

@keyframes pd-rec-pulse {
	0%,
	100% {
		opacity: 1;
	}
	50% {
		opacity: 0.55;
	}
}

.pd-rec-timer {
	position: absolute;
	right: calc(100% + 6px);
	top: 50%;
	transform: translateY(-50%);
	font-size: var(--body-sm);
	color: #cc2222;
	white-space: nowrap;
	letter-spacing: 0.03em;
	pointer-events: none;
}

.pd-rec-timer--hidden {
	visibility: hidden;
}

/* ── Preferences modal ───────────────────────────────────────────────────────── */
.pd-prefs {
	min-width: 260px;
	max-width: 320px;
	gap: 0;
}
.pd-modal__header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	margin-bottom: 20px;
}
.pd-modal__title {
	font-size: var(--body-m);
	font-weight: 500;
}
.pd-prefs__close {
	opacity: 0.5;
	transition: opacity 0.1s;
	border-radius: 0;
	border: none;
	background: none;
	min-width: unset;
	padding: 0;
}
.pd-prefs__close:hover {
	opacity: 1;
}
.pd-pref-section {
	display: flex;
	flex-direction: column;
	gap: 8px;
	padding-block: 16px;
	border-top: var(--border-muted);
}
.pd-pref-section:first-of-type {
	border-top: none;
	padding-top: 0;
}
.pd-pref-label {
	font-size: var(--body-sm);
	color: var(--fg-muted);
	letter-spacing: 0.04em;
}
.pd-pref-row {
	display: flex;
	align-items: center;
	gap: 10px;
}
.pd-pref-row--toggle {
	justify-content: space-between;
	cursor: pointer;
	font-size: var(--body-sm);
}
.pd-pref-row--disabled {
	opacity: 0.35;
	pointer-events: none;
}
/* Color swatch input */
.pd-color-swatch {
	width: 32px;
	height: 32px;
	padding: 2px;
	border: var(--border-muted);
	border-radius: var(--radius-sm);
	background: var(--bg);
	cursor: pointer;
}
.pd-color-swatch::-webkit-color-swatch-wrapper {
	padding: 0;
	border-radius: 2px;
}
.pd-color-swatch::-webkit-color-swatch {
	border: none;
	border-radius: 2px;
}
/* Toggle checkbox */
.pd-toggle {
	appearance: none;
	width: 32px;
	height: 18px;
	border-radius: 9px;
	background: var(--gray);
	cursor: pointer;
	position: relative;
	transition: background 0.15s;
	flex-shrink: 0;
}
.pd-toggle::after {
	content: "";
	position: absolute;
	top: 2px;
	left: 2px;
	width: 14px;
	height: 14px;
	border-radius: 50%;
	background: var(--white);
	transition: transform 0.15s;
}
.pd-toggle:checked {
	background: var(--black);
}
.pd-toggle:checked::after {
	transform: translateX(14px);
}
