/* ===== Tokens ===== */
:root {
	--color-bg: #f4f5f7;
	--color-surface: #ffffff;
	--color-ink: #1f2328;
	--color-muted: #6b7280;
	--color-faint: #9ca3af;
	--color-line: #e5e7eb;
	--color-line-strong: #cfd4dc;
	--color-hover: #f1f3f5;
	--color-accent: #4f7cff;
	--color-accent-soft: #e8eeff;
	--color-brand: #4ebe4e;
	--color-backdrop: rgba(17, 24, 39, 0.35);
	--radius-card: 12px;
	--radius-control: 9px;
	--shadow-card: 0 4px 16px rgba(0, 0, 0, 0.07);
	--shadow-popover: 0 10px 30px rgba(0, 0, 0, 0.12);
	--rail-left: 10px;
	--rail-width: 44px;
	--canvas-left: calc(var(--rail-left) + var(--rail-width) + 8px);
	--font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* ===== Base ===== */
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
	margin: 0;
	overflow: hidden;
	background: var(--color-bg);
	color: var(--color-ink);
	font: 14px/1.45 var(--font);
	-webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; color: inherit; }
input[type="text"], input[type="number"], select {
	padding: 6px 8px;
	border: 1px solid var(--color-line-strong);
	border-radius: 8px;
	background: var(--color-surface);
}
input:focus-visible, select:focus-visible, button:focus-visible, a:focus-visible {
	outline: 2px solid var(--color-accent);
	outline-offset: 2px;
}
.icon-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.no-select { user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.cursor-default { cursor: default; }
.link { color: var(--color-accent); text-decoration: none; }
.link:hover { text-decoration: underline; }
.hint { color: var(--color-muted); font-size: 12.5px; }
#enable-javascript { margin: 40px auto; max-width: 640px; padding: 16px; background: var(--color-surface); border-radius: var(--radius-card); }

/* ===== Building blocks ===== */
.card {
	background: var(--color-surface);
	border: 1px solid var(--color-line);
	border-radius: var(--radius-card);
	box-shadow: var(--shadow-card);
}
.icon-button {
	display: grid;
	place-items: center;
	width: 34px;
	height: 34px;
	padding: 0;
	border: 0;
	border-radius: var(--radius-control);
	background: none;
	color: #374151;
	cursor: pointer;
	position: relative;
}
.icon-button svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-button:hover:not(:disabled) { background: var(--color-hover); }
.shape-choices { display: flex; flex-wrap: wrap; gap: 4px; }
.shape-choice { position: relative; display: grid; place-items: center; width: 36px; height: 36px; border-radius: 8px; color: var(--color-ink); cursor: pointer; }
.shape-choice input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; } /* the icon is the visible part; the radio keeps keyboard and screen reader use */
.shape-choice svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; }
.shape-choice:hover { background: var(--color-hover); }
.shape-choice:has(input:checked) { background: var(--color-accent-soft); color: var(--color-accent); }
.shape-choice:has(input:focus-visible) { outline: 2px solid var(--color-accent); outline-offset: 1px; }
.shape-choice input:checked + svg { color: var(--color-accent); } /* the chosen shape also without :has (older browsers) */
@supports not selector(:has(*)) { .shape-choice input:focus-visible + svg { outline: 2px solid var(--color-accent); outline-offset: 6px; border-radius: 4px; } }
body.is-mobile .shape-choice { width: 44px; height: 44px; } /* a finger-sized target in the dock */
.icon-button.is-active { background: var(--color-accent-soft); color: var(--color-accent); }
.icon-button:disabled { opacity: 0.35; cursor: default; }
.icon-button.small { width: 28px; height: 28px; }
.icon-button.small svg { width: 16px; height: 16px; }
.primary-button {
	display: inline-block;
	padding: 7px 14px;
	border: 0;
	border-radius: 8px;
	background: var(--color-accent);
	color: #fff;
	font-size: 13px;
	font-weight: 600;
	text-decoration: none;
	cursor: pointer;
}
.primary-button:hover { filter: brightness(1.05); }
.text-button { padding: 0 8px; border: 0; background: none; color: var(--color-muted); font-size: 12px; cursor: pointer; }
.text-button:hover { color: var(--color-ink); }
.chip {
	padding: 5px 10px;
	background: var(--color-surface);
	border: 1px solid var(--color-line);
	border-radius: 10px;
	color: var(--color-muted);
	font-size: 12px;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

/* ===== Layout ===== */
#page { display: none; }
#canvas-viewport {
	position: fixed;
	top: 0;
	right: 0;
	bottom: 0;
	left: var(--canvas-left);
	overflow: auto;
}
#canvas-zoom-box { position: relative; min-width: 100%; min-height: 100%; }
#canvas-stage { position: absolute; top: 0; left: 0; transform-origin: 0 0; white-space: nowrap; }
.layer-canvas, #paste-canvas, .handle { touch-action: none; }
#canvas-viewport.is-panning, #canvas-viewport.is-panning * { cursor: grabbing !important; }
#canvas-viewport.can-pan, #canvas-viewport.can-pan .layer-canvas { cursor: grab; }
#canvas-viewport.can-zoom .layer-canvas { cursor: zoom-in; }
body.is-chrome-hidden .chrome { display: none !important; }
body.is-chrome-hidden #canvas-viewport { left: 0; }

#canvas-editor {
	display: inline-block;
	position: relative;
	overflow: hidden;
	vertical-align: top;
	margin: 5px;
	border: 1px solid var(--color-line-strong);
	background-color: #fff;
	background-image:
		linear-gradient(45deg, #eef0f3 25%, transparent 25%),
		linear-gradient(-45deg, #eef0f3 25%, transparent 25%),
		linear-gradient(45deg, transparent 75%, #eef0f3 75%),
		linear-gradient(-45deg, transparent 75%, #eef0f3 75%);
	background-size: 16px 16px;
	background-position: 0 0, 0 8px, 8px -8px, -8px 0;
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 8px 24px rgba(0, 0, 0, 0.06);
}
.layer-canvas { position: absolute; left: 0; top: 0; z-index: 1; cursor: crosshair; } /* layers stack in DOM order */
#preview-canvas { position: absolute; left: 0; top: 0; z-index: 2; pointer-events: none; } /* live shape/pencil preview */
#paste-canvas {
	display: none;
	position: absolute;
	z-index: 3;
	cursor: move;
	border-width: 1px;
	border-color: var(--color-accent);
}
/* Handles: 7px squares on screen at any zoom, centered on the point they control */
.handle {
	position: absolute;
	z-index: 5;
	box-sizing: border-box;
	width: calc(7px / var(--zoom, 1));
	height: calc(7px / var(--zoom, 1));
	margin: calc(-3.5px / var(--zoom, 1)) 0 0 calc(-3.5px / var(--zoom, 1));
	background: #fff;
	border: calc(1px / var(--zoom, 1)) solid var(--color-ink);
	box-shadow: 0 0 0 calc(1px / var(--zoom, 1)) rgba(255, 255, 255, 0.8);
}
.handle::before { content: ""; position: absolute; inset: calc(-6px / var(--zoom, 1)); } /* bigger grab area */
body.is-mobile .handle::before { inset: calc(-14px / var(--zoom, 1)); }
.paste-handle { display: none; }
.handle[data-handle="e"], .handle[data-handle="w"] { cursor: ew-resize; }
.handle[data-handle="n"], .handle[data-handle="s"] { cursor: ns-resize; }
.handle[data-handle="nw"], .handle[data-handle="se"] { cursor: nwse-resize; }
.handle[data-handle="ne"], .handle[data-handle="sw"] { cursor: nesw-resize; }
#paste-canvas { outline: calc(1px / var(--zoom, 1)) dashed var(--color-accent); }
/* Text tool box: edited in place, rasterized on commit */
#text-box { display: none; position: absolute; z-index: 6; padding: calc(5px / var(--zoom, 1)); margin: calc(-5px / var(--zoom, 1)) 0 0 calc(-5px / var(--zoom, 1)); outline: calc(1px / var(--zoom, 1)) dashed var(--color-accent); cursor: move; touch-action: none; }
#text-editor { display: block; box-sizing: content-box; margin: 0; padding: 0; border: 0; outline: none; resize: none; overflow: hidden; white-space: pre-wrap; overflow-wrap: break-word; cursor: text; }
.text-resize { position: absolute; right: calc(-4px / var(--zoom, 1)); bottom: calc(-4px / var(--zoom, 1)); width: calc(7px / var(--zoom, 1)); height: calc(7px / var(--zoom, 1)); background: #fff; border: calc(1px / var(--zoom, 1)) solid var(--color-ink); cursor: ew-resize; box-sizing: border-box; }
.style-toggles { display: flex; gap: 4px; margin-bottom: 10px; }
.style-toggles .icon-button { width: 32px; height: 28px; font-family: Georgia, serif; font-size: 14px; border: 1px solid var(--color-line); }
#resize-overlay { display: none; position: absolute; pointer-events: none; border: calc(1px / var(--zoom, 1)) dashed var(--color-accent); box-sizing: border-box; }
body.is-dragging-handle .chrome { pointer-events: none; }

/* ===== Tool rail ===== */
#tool-rail {
	position: fixed;
	top: 10px;
	left: var(--rail-left);
	width: var(--rail-width);
	max-height: calc(100% - 20px);
	overflow-y: auto;
	overflow-x: hidden;
	padding: 4px;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 2px;
	z-index: 20;
	scrollbar-width: none;
}
.rail-separator { flex: none; width: 24px; height: 1px; margin: 4px 0; background: var(--color-line); }
#tool-groups { display: flex; flex-direction: column; align-items: center; gap: 2px; }
#tool-flyout { position: fixed; display: none; flex-direction: column; gap: 2px; padding: 4px; z-index: 40; }
#tool-flyout.is-open { display: flex; }

/* ===== App menu ===== */
.menu {
	position: fixed;
	top: 10px;
	left: var(--canvas-left);
	min-width: 230px;
	padding: 6px;
	display: none;
	z-index: 50;
	box-shadow: var(--shadow-popover);
}
.menu.is-open { display: block; }
.menu-brand { display: flex; align-items: center; gap: 9px; padding: 6px 10px 10px; margin-bottom: 4px; border-bottom: 1px solid var(--color-line); }
.menu-brand b { font-size: 14px; }
.menu-brand small { margin-left: auto; color: var(--color-faint); font-size: 11.5px; }
.menu-heading { padding: 8px 10px 3px; color: var(--color-faint); font-size: 10.5px; font-weight: 600; letter-spacing: 0.5px; text-transform: uppercase; }
.menu-item {
	display: flex;
	justify-content: space-between;
	align-items: center;
	gap: 16px;
	width: 100%;
	padding: 7px 10px;
	border: 0;
	border-radius: 7px;
	background: none;
	font-size: 13px;
	text-align: left;
	cursor: pointer;
}
.menu-item:hover { background: var(--color-hover); }
.menu-item small { color: var(--color-faint); font-size: 11.5px; }
.menu-separator { height: 1px; margin: 5px 4px; background: var(--color-line); }

/* ===== Properties panel ===== */
#props-panel {
	position: fixed;
	top: 10px;
	right: 10px;
	width: 196px;
	max-height: calc(100% - 80px);
	overflow-y: auto;
	padding: 12px;
	z-index: 20;
	color: var(--color-muted);
	font-size: 12px;
}
.props-header { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: -2px -4px 8px 0; }
#props-title { margin: 0; color: var(--color-ink); font-size: 13.5px; font-weight: 600; }
#props-panel.is-collapsed { width: auto; padding: 4px; }
#props-panel.is-collapsed .props-header { margin: 0; }
#props-panel.is-collapsed #props-title, #props-panel.is-collapsed #props-body { display: none; }
#props-panel.is-collapsed #props-collapse svg { transform: scaleX(-1); }

/* ===== Bottom clusters ===== */
#zoom-cluster {
	position: fixed;
	right: 10px;
	bottom: 10px;
	display: flex;
	align-items: center;
	gap: 2px;
	padding: 4px;
	z-index: 20;
	font-size: 12px;
}
#zoom-label { min-width: 44px; padding: 4px; border-radius: 6px; text-align: center; color: #374151; font-size: 13px; cursor: text; }
#zoom-label:hover { background: var(--color-hover); }
#zoom-input { width: 56px; padding: 3px 4px; border: 1px solid var(--color-accent); border-radius: 6px; text-align: center; font-size: 13px; }
#zoom-input[hidden], #zoom-label[hidden] { display: none; }
.cluster-separator { width: 1px; height: 22px; margin: 0 4px; background: var(--color-line); }
#cursor-coords { position: fixed; left: var(--canvas-left); bottom: 10px; z-index: 20; pointer-events: none; }
#cursor-coords:empty { display: none; }

/* ===== Dialog ===== */
.modal {
	position: fixed;
	inset: 0;
	display: none;
	align-items: center;
	justify-content: center;
	padding: max(16px, var(--cards-top, 0px)) 16px max(16px, var(--cards-bottom, 0px)); /* room for the page cards (set by ui.js) */
	background: var(--color-backdrop);
	z-index: 60;
}
.modal.is-open { display: flex; }
#dialog-content { width: min(640px, 100%); max-height: calc(100% - 32px); overflow: auto; box-shadow: var(--shadow-popover); }
#dialog-content[data-width="wide"] { width: min(780px, 100%); } /* lots of rows: use the room of large screens (data-width of the open section) */
#dialog-content[data-width="narrow"] { width: min(480px, 100%); } /* a few lines: stay compact; phones override both (body.is-mobile) */
#dialog-content:focus { outline: none; } /* focus rests on the card on open */
#dialog-content:focus-visible { outline: 2px solid var(--color-accent); outline-offset: -2px; } /* keyboard users see where focus is (WCAG 2.4.7) */
.dialog-header { display: flex; align-items: center; justify-content: space-between; padding: 14px 14px 8px 20px; }
#dialog-title { margin: 0; font-size: 16px; font-weight: 600; }
.dialog-body { padding: 0 20px 18px; }
.dialog-section { display: none; }
.dialog-section.is-active { display: block; }
.dialog-section h4 { margin: 16px 0 6px; font-size: 13px; color: var(--color-muted); text-transform: uppercase; letter-spacing: 0.4px; }
.dialog-section p { margin: 10px 0; }
label.check { display: flex; align-items: flex-start; gap: 8px; margin: 7px 0; cursor: pointer; }
label.check input { margin-top: 3px; }
#dialog label.check { width: -moz-fit-content; width: fit-content; max-width: 100%; } /* in dialogs a checkbox row is only as wide as its text: the empty part is not clickable */
#dialog .field { display: flex; align-items: center; gap: 8px; margin: 10px 0; } /* a row with its own <label for> around the text only */
#dialog .field > label { cursor: pointer; }
#dialog .field.is-disabled > label { color: var(--color-muted); cursor: default; } /* e.g. the stabilizer strength while the stabilizer is off */
#dialog .field > input, #dialog .field > select { flex: none; width: 230px; margin-left: auto; box-sizing: border-box; } /* one column of equal fields */
body.is-mobile #dialog .field { flex-wrap: wrap; row-gap: 6px; }
body.is-mobile #dialog .field > input, body.is-mobile #dialog .field > select { width: 100%; margin-left: 0; }

/* ===== Setting explanations (i) ===== */
.info-tip {
	flex: none;
	display: inline-grid;
	place-items: center;
	width: 17px;
	height: 17px;
	padding: 0;
	border: 1px solid var(--color-line);
	border-radius: 50%;
	background: var(--color-surface);
	color: var(--color-muted);
	font: italic 700 11px/1 Georgia, "Times New Roman", serif;
	cursor: help;
}
.info-tip:hover, .info-tip[aria-expanded="true"] { color: var(--color-accent); border-color: var(--color-accent); }
label.check .info-tip { margin-top: 1px; }
#dialog .field .info-tip { margin-left: -2px; } /* hugs the label text */
#info-popover { position: fixed; z-index: 200; padding: 10px 12px; font-size: 12.5px; line-height: 1.5; box-shadow: var(--shadow-popover); }
#info-popover[hidden] { display: none; }
#file-name-container { display: none; margin: 8px 0; }
#file-name { width: 100%; }
.size-fields { display: flex; gap: 16px; margin-top: 6px; }
.size-fields label { display: flex; flex-direction: column; gap: 4px; color: var(--color-muted); font-size: 12px; }
.size-fields input { width: 120px; }
.shortcuts-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.shortcuts-table th, .shortcuts-table td { padding: 6px 8px; border-bottom: 1px solid var(--color-line); text-align: left; }
.shortcuts-table th { color: var(--color-muted); font-weight: 600; }
.shortcuts-table td:first-child { white-space: nowrap; font-family: ui-monospace, Consolas, monospace; font-size: 12px; }
.dialog-section.about { text-align: center; }
.dialog-section.about h4 { color: var(--color-ink); font-size: 18px; text-transform: none; letter-spacing: 0; margin: 6px 0; }

/* ===== Loading / unsupported ===== */
#loading-screen {
	position: fixed;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	background: var(--color-bg);
	z-index: 90;
}
.loading-screen-inner { display: flex; flex-direction: column; align-items: center; gap: 18px; pointer-events: none; }
.loader {
	width: 28px;
	height: 28px;
	border: 3px solid var(--color-line);
	border-top-color: var(--color-accent);
	border-radius: 50%;
	animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
#unsupported-browser { display: none; position: fixed; inset: 0; z-index: 100; background: var(--color-bg); }
.unsupported-browser-inner { display: flex; align-items: center; justify-content: center; height: 100%; padding: 16px; }
.unsupported-browser-inner p { max-width: 640px; padding: 16px 20px; margin: 0; background: var(--color-surface); border-radius: var(--radius-card); box-shadow: var(--shadow-card); }

/* ===== Cookie notice ===== */
#cookie-notice {
	position: fixed;
	left: 50%;
	bottom: 16px;
	transform: translateX(-50%);
	display: flex;
	align-items: center;
	gap: 12px;
	max-width: calc(100% - 32px);
	padding: 10px 12px 10px 16px;
	z-index: 80;
	font-size: 13px;
	box-shadow: var(--shadow-popover);
}
#cookie-notice .link { white-space: nowrap; }

/* ===== Restore autosaved drawing ===== */
#restore-card, #update-card {
	position: fixed;
	left: 50%;
	bottom: 16px;
	transform: translateX(-50%);
	display: flex;
	align-items: center;
	gap: 8px;
	max-width: calc(100% - 32px);
	padding: 10px 12px 10px 16px;
	z-index: 81;
	font-size: 13px;
	box-shadow: var(--shadow-popover);
}
#restore-text, #update-text { margin-right: 4px; }
#update-card { top: 16px; bottom: auto; }
body.is-mobile #restore-card, body.is-mobile #update-card { top: 56px; bottom: auto; flex-wrap: wrap; }

/* ===== Tool rail extras ===== */
.tool-button.has-variants::after {
	content: "";
	position: absolute;
	right: 3px;
	bottom: 3px;
	border-left: 4px solid transparent;
	border-bottom: 4px solid currentColor;
	opacity: 0.55;
}
.flyout-item {
	display: flex;
	align-items: center;
	gap: 9px;
	padding: 6px 12px 6px 8px;
	border: 0;
	border-radius: 8px;
	background: none;
	color: #374151;
	font-size: 13px;
	white-space: nowrap;
	cursor: pointer;
}
.flyout-item:hover { background: var(--color-hover); }
.flyout-item.is-active { background: var(--color-accent-soft); color: var(--color-accent); }
.flyout-item svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ===== Properties ===== */
.prop { margin-bottom: 12px; }
.prop:last-child { margin-bottom: 0; }
.prop-label { margin: 0 0 6px; color: var(--color-ink); font-weight: 500; }
.swatches { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.swatch {
	position: relative;
	width: 20px;
	height: 20px;
	padding: 0;
	border: 1px solid rgba(0, 0, 0, 0.14);
	border-radius: 50%;
	cursor: pointer;
}
.swatch.is-selected { outline: 2px solid var(--color-accent); outline-offset: 1px; }
.swatch.custom { background: conic-gradient(#e5534b, #ffd33d, #4ebe4e, #36c5f0, #4f7cff, #a371f7, #e5534b); overflow: hidden; }
.swatch.custom input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
#props-panel input[type="range"] { width: 100%; margin: 0 0 4px; accent-color: var(--color-accent); }
#props-panel .hint { margin: 0; line-height: 1.5; }
#props-panel label.check { margin: 4px 0; color: var(--color-ink); }

/* ===== Phone layout ===== */
.mobile-only, #zoom-toast { display: none; }
.icon-button.accent { color: var(--color-accent); }
body.is-mobile .chrome { display: none !important; }
body.is-mobile .mobile-only { display: flex; }
body.is-mobile #canvas-viewport { top: 48px; left: 0; bottom: 72px; touch-action: none; }
body.is-mobile.dock-open #canvas-viewport { bottom: 72px; }
body.is-mobile #app-menu.is-open { display: block !important; top: 52px; left: 8px; max-height: calc(100% - 60px); overflow-y: auto; }
#mobile-topbar {
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	height: 48px;
	align-items: center;
	gap: 2px;
	padding: 0 6px;
	background: var(--color-surface);
	border-bottom: 1px solid var(--color-line);
	z-index: 30;
}
#mobile-status { /* canvas size when idle, coordinates while touching, size while dragging a handle */
	flex: 1;
	min-width: 0;
	padding: 6px 8px;
	border: 0;
	background: none;
	color: var(--color-muted);
	font-size: 12.5px;
	font-variant-numeric: tabular-nums;
	text-align: center;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	cursor: pointer;
}
#mobile-dock {
	position: fixed;
	left: 0;
	right: 0;
	bottom: 0;
	flex-direction: column;
	max-height: 72px;
	overflow: hidden;
	background: var(--color-surface);
	border-radius: 18px 18px 0 0;
	box-shadow: 0 -6px 22px rgba(0, 0, 0, 0.1);
	transition: max-height 0.25s ease;
	z-index: 30;
}
#dock-handle, #dock-row { touch-action: none; }
#dock-panel { touch-action: pan-y; }
#mobile-dock.is-open { height: min(78%, 520px); max-height: min(78%, 520px); overflow-y: auto; } /* same height on every tab: the tabs never jump */
#mobile-dock.is-open #dock-tabs { position: sticky; top: 0; z-index: 1; padding: 6px 0; margin: -6px 0 4px; background: var(--color-surface); }
#dock-handle { flex: none; padding: 7px 0 5px; cursor: pointer; }
#dock-handle span { display: block; width: 36px; height: 4px; margin: 0 auto; border-radius: 2px; background: #d1d5db; }
#dock-row { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 4px; padding: 0 10px 10px; }
#dock-recent { display: flex; flex: 1; justify-content: center; gap: 4px; min-width: 0; }
#dock-recent .icon-button { width: 40px; height: 40px; }
#dock-color { flex: none; display: grid; place-items: center; width: 40px; height: 40px; padding: 0; border: 1px solid var(--color-line); border-radius: 50%; background: var(--color-surface); cursor: pointer; }
#dock-color span { width: 24px; height: 24px; border: 2px solid #fff; border-radius: 50%; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.15); }
#dock-panel { padding: 0 14px 16px; color: var(--color-muted); font-size: 12px; }
#dock-tools { display: grid; grid-template-columns: repeat(auto-fill, minmax(62px, 1fr)); gap: 4px; margin-bottom: 14px; }
#dock-tools .dock-tool { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 8px 2px; border: 0; border-radius: 10px; background: none; color: #374151; font-size: 10.5px; cursor: pointer; }
#dock-tools .dock-tool.is-active { background: var(--color-accent-soft); color: var(--color-accent); }
#dock-tools .dock-tool svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
#dock-props input[type="range"] { width: 100%; accent-color: var(--color-accent); }
#zoom-toast { position: fixed; top: 58px; left: 50%; transform: translateX(-50%); z-index: 40; pointer-events: none; }
#zoom-toast.is-visible { display: block; }
#gesture-hint { display: none; position: fixed; top: 58px; left: 50%; transform: translateX(-50%); z-index: 40; pointer-events: none; white-space: nowrap; }
#gesture-hint.is-visible { display: block; }
body.is-mobile .modal { align-items: flex-end; padding: var(--cards-top, 0px) 0 var(--cards-bottom, 0px); } /* the sheet starts below the cookie bar */
body.is-mobile #dialog-content { width: 100%; max-height: 85%; border-radius: 16px 16px 0 0; border-bottom: 0; }
body.is-mobile #cookie-notice { flex-wrap: wrap; }

/* ===== Disabled states and small additions ===== */
.menu-item[hidden] { display: none; }
.menu-item:disabled { opacity: 0.4; cursor: default; }
.menu-item:disabled:hover { background: none; }
.primary-button:disabled { opacity: 0.4; cursor: default; filter: none; }
.width-row { display: flex; align-items: center; gap: 8px; }
.width-row input[type="range"] { flex: 1; margin: 0 !important; }
.width-row input[type="number"] { width: 64px; padding: 3px 6px; }
body.is-mobile #cookie-notice { top: 56px; bottom: auto; }
body.is-mobile #cookie-notice, body.is-mobile #restore-card, body.is-mobile #update-card { left: 16px; right: 16px; transform: none; } /* the full width: centred with left 50% it got only half the screen and grew tall */
body.is-mobile.dock-open #cookie-notice { display: none; } /* no room next to the open dock; it comes back when the dock closes */
/* ===== Language submenu ===== */
.submenu { margin: 2px 0 4px 12px; padding-left: 6px; border-left: 2px solid var(--color-line); }
.submenu[hidden] { display: none; }
.submenu .menu-item[aria-checked="true"] { color: var(--color-accent); font-weight: 600; }
.submenu .menu-item[aria-checked="true"]::after { content: "\2713"; }

/* ===== Layers panel ===== */
#layers-section { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--color-line); }
#props-panel.is-collapsed #layers-section { display: none; }
.layers-header { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.layers-header h3 { margin: 0; color: var(--color-ink); font-size: 13px; font-weight: 600; }
.layers-header small { color: var(--color-faint); font-size: 11px; }
.layers-header #layers-memory { margin-left: auto; } /* the counter stays on the right, next to its (i) button */
#layers-list { list-style: none; margin: 0 0 8px; padding: 0; max-height: 240px; overflow-y: auto; }
.layer-row { display: flex; align-items: center; gap: 6px; padding: 3px 4px; border-radius: 8px; cursor: pointer; }
.layer-row:hover { background: var(--color-hover); }
.layer-row.is-active { background: var(--color-accent-soft); }
.layer-row.is-hidden .layer-thumb, .layer-row.is-hidden .layer-name { opacity: 0.45; }
.layer-thumb { flex: none; border: 1px solid var(--color-line); border-radius: 4px; background-image: linear-gradient(45deg, #eef0f3 25%, transparent 25%), linear-gradient(-45deg, #eef0f3 25%, transparent 25%); background-size: 8px 8px; }
.layer-name { flex: 1; min-width: 0; color: var(--color-ink); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.layer-rename { flex: 1; min-width: 0; padding: 2px 4px; font-size: 12px; }
.layer-opacity-row { display: block; margin-bottom: 8px; color: var(--color-ink); }
.layer-opacity-label { display: block; margin-bottom: 2px; }
#layers-section input[type="range"] { display: block; width: 100%; margin: 0 0 4px; accent-color: var(--color-accent); } /* own line: the value text never moves it */
#layer-opacity-value, .prop-value { font-variant-numeric: tabular-nums; }
select { cursor: pointer; }
input[type="range"] { cursor: grab; }
input[type="range"]:active { cursor: grabbing; }
#canvas-editor.can-move-text .layer-canvas { cursor: move; }
.layer-buttons { display: flex; justify-content: space-between; gap: 2px; }
#dock-tabs { display: flex; gap: 4px; margin: 0 0 10px; }
.dock-tab { flex: 1; padding: 6px 8px; border: 1px solid var(--color-line); border-radius: 8px; background: var(--color-surface); color: var(--color-muted); font-size: 12px; cursor: pointer; }
.dock-tab.is-active { background: var(--color-accent-soft); border-color: transparent; color: var(--color-accent); font-weight: 600; }
.dock-tab[hidden] { display: none; }
#dock-layers #layers-section { margin-top: 0; padding-top: 0; border-top: 0; }
