/* =====================================================================
 * Woo Banner Designer
 *
 * Everything is namespaced `udb-` and scoped to #udb-overlay. The sibling
 * t-shirt and sticker plugins use the same generic ids (.app-header, #c, …),
 * and this plugin's own older selectors (.bd-header, .color-swatch, .size-box)
 * were generic enough to trade styles with the theme in both directions —
 * which is why the old stylesheet needed !important to win its own buttons.
 *
 * Token values are deliberately identical to the t-shirt designer's --udt-*
 * set, so the two editors read as one product.
 * ===================================================================== */

/* ---------------------------------------------------------------------
 * Product page launcher — light, so it belongs to the shop.
 * ------------------------------------------------------------------- */
.udb-launcher {
	display: flex; align-items: center; gap: 14px;
	padding: 14px; margin: 0 0 20px;
	border: 2px dashed #c9ced6; border-radius: 12px; background: #fbfcfd;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
.udb-launcher.is-ready { border-style: solid; border-color: #4CAF50; background: #f4fbf6; }
.udb-launcher .udb-launcher-thumb {
	flex: 0 0 56px; width: 56px; height: 56px;
	display: flex; align-items: center; justify-content: center;
	border-radius: 10px; background: #eef1f5; color: #8a929e; overflow: hidden;
}
.udb-launcher.is-ready .udb-launcher-thumb { background: #e3f3e6; color: #3f8f43; }
.udb-launcher .udb-launcher-body { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.udb-launcher .udb-launcher-title { font-size: 1rem; font-weight: 700; color: #12151a; }
.udb-launcher .udb-launcher-meta {
	font-size: 0.82rem; color: #6b727d;
	overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.udb-launcher .udb-launcher-cta {
	flex: 0 0 auto; padding: 11px 18px; border: 0; border-radius: 8px;
	background: #16181d; color: #fff; font-size: 0.9rem; font-weight: 600;
	font-family: inherit; text-transform: none; letter-spacing: normal; cursor: pointer;
}
.udb-launcher .udb-launcher-cta:hover { background: #2a2e36; }
.udb-launcher.is-ready .udb-launcher-cta { background: #4CAF50; color: #0d1410; }
@media (max-width: 480px) {
	.udb-launcher { flex-wrap: wrap; }
	.udb-launcher .udb-launcher-cta { width: 100%; }
}

/* Explains why the length snapped back to the designed size. Lives on the
 * product page, so it is light like the launcher, not like the editor. */
.udb-lock {
	display: flex; align-items: flex-start; gap: 8px;
	margin: 0 0 18px; padding: 11px 14px;
	border: 1px solid #f0d9a8; border-left: 3px solid #e0a32e;
	border-radius: 9px; background: #fdf7ec;
	color: #5a4515; font-size: 0.85rem; line-height: 1.5;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
.udb-lock[hidden] { display: none; }
.udb-lock strong { color: #3d2f0d; }

/* ---------------------------------------------------------------------
 * Editor. Scoped so nothing leaks into the theme, and the resets stop the
 * theme leaking in here.
 * ------------------------------------------------------------------- */
#udb-overlay {
	--udb-bg: #16181d;
	--udb-panel: #1e2026;
	--udb-panel-2: #24262d;
	--udb-line: #2c2f36;
	--udb-line-2: #3a3e47;
	--udb-text: #e6e8ec;
	--udb-muted: #9aa0aa;
	--udb-accent: #4CAF50;
	--udb-accent-soft: rgba(76,175,80,0.18);
	--udb-guide: #ff8a5b;
	--udb-danger: #ff6b6b;
	--udb-warn: #ffb020;
	--udb-radius: 10px;
	--udb-sh-1: 0 1px 2px rgba(0,0,0,0.4);
	--udb-sh-2: 0 12px 32px rgba(0,0,0,0.45);

	display: none; position: fixed; inset: 0; z-index: 999999;
	background: var(--udb-bg); color: var(--udb-text);
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	font-size: 14px; line-height: 1.4; -webkit-font-smoothing: antialiased;
}
#udb-overlay *, #udb-overlay *::before, #udb-overlay *::after { box-sizing: border-box; }

/* Neutralise theme button/input styling. The old stylesheet fought this with
 * !important on .btn-align; resetting once here is what makes that needless. */
#udb-overlay button,
#udb-overlay input,
#udb-overlay select,
#udb-overlay textarea,
#udb-overlay label {
	font: inherit; color: inherit; margin: 0; width: auto; min-height: 0;
	text-transform: none; letter-spacing: normal; text-shadow: none; box-shadow: none;
	-webkit-appearance: none; appearance: none;
}
#udb-overlay :focus { outline: none; }
#udb-overlay :focus-visible { outline: 2px solid var(--udb-accent); outline-offset: 2px; }
#udb-overlay .udb-icon { flex: 0 0 auto; display: block; }

/* Visually hidden, still read aloud. */
#udb-overlay .udb-sr {
	position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
	overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

#udb-overlay .udb-modal {
	width: 100%; height: 100%; display: flex; flex-direction: column;
	overflow: hidden; position: relative; background: var(--udb-bg);
}

/* ----- Header ----- */
#udb-overlay .udb-header {
	flex-shrink: 0; height: 52px; display: flex; align-items: center;
	justify-content: space-between; gap: 10px; padding: 0 14px;
	background: var(--udb-panel); border-bottom: 1px solid var(--udb-line);
}
#udb-overlay .udb-header h3 {
	margin: 0; min-width: 0; font-size: 0.95rem; font-weight: 600; color: var(--udb-text);
	overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
#udb-overlay .udb-header-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
#udb-overlay .udb-header-actions button {
	display: flex; align-items: center; justify-content: center; gap: 7px;
	padding: 9px 16px; border: 1px solid transparent; border-radius: 8px;
	font-size: 0.85rem; font-weight: 600; cursor: pointer;
}
#udb-overlay .udb-btn-close { background: transparent; border-color: var(--udb-line); color: var(--udb-muted); }
#udb-overlay .udb-btn-close:hover { color: var(--udb-text); border-color: var(--udb-line-2); }
#udb-overlay .udb-btn-save { background: var(--udb-accent); color: #0d1410; min-width: 142px; }
#udb-overlay .udb-btn-save:hover:not(:disabled) { background: #5bbd5f; }
#udb-overlay .udb-btn-save:disabled { background: var(--udb-line-2); color: var(--udb-muted); cursor: not-allowed; }

#udb-overlay .udb-spinner {
	width: 14px; height: 14px; flex: 0 0 auto;
	border: 2px solid rgba(0,0,0,0.25); border-top-color: #0d1410;
	border-radius: 50%; animation: udb-spin 0.6s linear infinite;
}
@keyframes udb-spin { to { transform: rotate(360deg); } }

#udb-overlay .udb-workspace { flex: 1; display: flex; flex-direction: column; overflow: hidden; position: relative; min-height: 0; }
#udb-overlay .udb-main-row { flex: 1; display: flex; overflow: hidden; position: relative; min-height: 0; }

/* ----- Sidebar ----- */
#udb-overlay .udb-sidebar {
	flex-shrink: 0; width: 320px; display: flex; flex-direction: column; gap: 18px;
	padding: 16px; background: var(--udb-panel);
	border-right: 1px solid var(--udb-line); overflow-y: auto; z-index: 20;
}
#udb-overlay .udb-group { display: flex; flex-direction: column; gap: 8px; }
#udb-overlay .udb-group-label {
	font-size: 0.68rem; font-weight: 700; letter-spacing: 0.09em;
	text-transform: uppercase; color: var(--udb-muted);
}
#udb-overlay .udb-note { margin: 0; font-size: 0.72rem; line-height: 1.5; color: var(--udb-muted); }
#udb-overlay .udb-note[hidden] { display: none; }
#udb-overlay .udb-note strong { color: var(--udb-text); font-variant-numeric: tabular-nums; }

#udb-overlay .udb-hint {
	margin: auto 0 0; padding-top: 12px; border-top: 1px solid var(--udb-line);
	font-size: 0.72rem; line-height: 1.5; color: var(--udb-muted);
}

/* ----- Text ----- */
#udb-overlay .udb-textarea {
	width: 100%; height: 84px; padding: 10px 12px; resize: vertical;
	border: 1px solid var(--udb-line); border-radius: var(--udb-radius);
	background: var(--udb-bg); color: var(--udb-text);
	font-size: 0.92rem; line-height: 1.45;
}
#udb-overlay .udb-textarea:focus { border-color: var(--udb-accent); }
#udb-overlay .udb-textarea::placeholder { color: var(--udb-muted); }
#udb-overlay .udb-counter {
	align-self: flex-end; font-size: 0.68rem; color: var(--udb-muted);
	font-variant-numeric: tabular-nums;
}
#udb-overlay .udb-counter.is-near { color: var(--udb-warn); }

/* ----- Segmented control (alignment) ----- */
#udb-overlay .udb-seg { display: flex; gap: 6px; }
#udb-overlay .udb-seg-btn {
	flex: 1; display: flex; align-items: center; justify-content: center;
	padding: 9px 0; border: 1px solid var(--udb-line); border-radius: 8px;
	background: var(--udb-panel-2); color: var(--udb-muted); cursor: pointer;
	transition: background 0.15s, border-color 0.15s, color 0.15s;
}
#udb-overlay .udb-seg-btn:hover { border-color: var(--udb-line-2); color: var(--udb-text); }
#udb-overlay .udb-seg-btn.is-active {
	background: var(--udb-accent); border-color: var(--udb-accent); color: #0d1410;
}

/* ----- Checkbox ----- */
#udb-overlay .udb-check {
	display: flex; align-items: center; gap: 9px; cursor: pointer;
	font-size: 0.83rem; color: var(--udb-text);
}
#udb-overlay .udb-check input { position: absolute; opacity: 0; width: 0; height: 0; }
#udb-overlay .udb-check-box {
	flex: 0 0 auto; display: flex; align-items: center; justify-content: center;
	width: 20px; height: 20px; border: 1px solid var(--udb-line-2); border-radius: 6px;
	background: var(--udb-bg); color: transparent;
	transition: background 0.15s, border-color 0.15s, color 0.15s;
}
#udb-overlay .udb-check-box .udb-icon { width: 14px; height: 14px; }
#udb-overlay .udb-check input:checked + .udb-check-box {
	background: var(--udb-accent); border-color: var(--udb-accent); color: #0d1410;
}
#udb-overlay .udb-check input:focus-visible + .udb-check-box {
	outline: 2px solid var(--udb-accent); outline-offset: 2px;
}

/* ----- Generic tool button / file upload ----- */
#udb-overlay .udb-tool {
	display: flex; align-items: center; justify-content: flex-start; gap: 9px;
	width: 100%; padding: 10px 12px;
	border: 1px solid var(--udb-line); border-radius: var(--udb-radius);
	background: var(--udb-panel-2); color: var(--udb-text);
	font-size: 0.85rem; font-weight: 500; cursor: pointer;
	transition: background 0.15s, border-color 0.15s;
}
#udb-overlay .udb-tool:hover { background: #2c2f37; border-color: var(--udb-line-2); }
#udb-overlay .udb-upload input { display: none; }

/* ----- Font picker ----- */
#udb-overlay .udb-fontpicker { display: flex; flex-direction: column; gap: 8px; }
#udb-overlay .udb-font-searchwrap {
	display: flex; align-items: center; gap: 8px; padding: 0 10px;
	border: 1px solid var(--udb-line); border-radius: 8px; background: var(--udb-bg);
	color: var(--udb-muted);
}
#udb-overlay .udb-font-searchwrap:focus-within { border-color: var(--udb-accent); }
#udb-overlay .udb-font-search {
	flex: 1; min-width: 0; height: 38px; padding: 0; border: 0;
	background: transparent; color: var(--udb-text); font-size: 0.86rem;
}
#udb-overlay .udb-font-search::placeholder { color: var(--udb-muted); }
#udb-overlay .udb-font-search::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; }

#udb-overlay .udb-font-list {
	max-height: 264px; margin: 0; padding: 4px; list-style: none;
	border: 1px solid var(--udb-line); border-radius: var(--udb-radius);
	background: var(--udb-bg); overflow-y: auto; overscroll-behavior: contain;
}
#udb-overlay .udb-font-group {
	padding: 9px 8px 5px; font-size: 0.64rem; font-weight: 700;
	letter-spacing: 0.09em; text-transform: uppercase; color: var(--udb-muted);
}
#udb-overlay .udb-font-group[hidden],
#udb-overlay .udb-font-opt[hidden] { display: none; }
#udb-overlay .udb-font-opt {
	display: flex; align-items: center; justify-content: space-between; gap: 8px;
	padding: 9px 10px; border-radius: 7px; cursor: pointer;
	color: var(--udb-text); transition: background 0.12s;
}
#udb-overlay .udb-font-opt:hover { background: var(--udb-panel-2); }
#udb-overlay .udb-font-opt .udb-icon { opacity: 0; color: var(--udb-accent); }
#udb-overlay .udb-font-opt[aria-selected="true"] { background: var(--udb-accent-soft); }
#udb-overlay .udb-font-opt[aria-selected="true"] .udb-icon { opacity: 1; }
/* The preview face is assigned per row by the JS once the row scrolls into
 * view; 1.05rem keeps a script face legible without the row jumping height. */
#udb-overlay .udb-font-opt-name {
	min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
	font-size: 1.05rem; line-height: 1.5;
}
#udb-overlay .udb-font-empty { margin: 0; padding: 10px 2px; font-size: 0.78rem; color: var(--udb-muted); }
#udb-overlay .udb-font-empty[hidden] { display: none; }
#udb-overlay .udb-font-status { font-size: 0.72rem; color: var(--udb-muted); min-height: 1em; }
#udb-overlay .udb-font-status.is-error { color: var(--udb-danger); }

/* The picker is inline on desktop; these two only exist for the portrait
 * bottom sheet, where the 264px list cannot sit in a horizontal dock. */
#udb-overlay .udb-fontsheet-toggle,
#udb-overlay .udb-fontsheet-done { display: none; }

/* ----- Height presets ----- */
#udb-overlay .udb-presets { display: flex; flex-wrap: wrap; gap: 6px; }
#udb-overlay .udb-preset-btn {
	flex: 1 0 auto; min-width: 44px; padding: 8px 0;
	border: 1px solid var(--udb-line); border-radius: 8px;
	background: var(--udb-panel-2); color: var(--udb-muted);
	font-size: 0.76rem; font-weight: 700; font-variant-numeric: tabular-nums;
	text-align: center; cursor: pointer;
	transition: background 0.15s, border-color 0.15s, color 0.15s;
}
#udb-overlay .udb-preset-btn:hover { border-color: var(--udb-line-2); color: var(--udb-text); }
#udb-overlay .udb-preset-btn.is-active {
	background: var(--udb-accent); border-color: var(--udb-accent); color: #0d1410;
}

/* ----- Dimension inputs ----- */
#udb-overlay .udb-dims-row { display: flex; gap: 8px; }
#udb-overlay .udb-dims-group {
	flex: 1; min-width: 0; display: flex; align-items: center; gap: 6px;
	padding: 8px 10px; border: 1px solid var(--udb-line); border-radius: 8px;
	background: var(--udb-bg);
}
#udb-overlay .udb-dims-group:focus-within { border-color: var(--udb-accent); }
#udb-overlay .udb-dims-label { font-size: 0.7rem; font-weight: 700; color: var(--udb-muted); }
#udb-overlay .udb-dims-input {
	flex: 1; min-width: 0; padding: 0; border: 0; background: transparent;
	color: var(--udb-text); font-size: 0.95rem; font-weight: 600;
	font-variant-numeric: tabular-nums; text-align: right;
}
#udb-overlay .udb-dims-input:disabled { color: var(--udb-muted); cursor: not-allowed; }
#udb-overlay .udb-dims-input::-webkit-outer-spin-button,
#udb-overlay .udb-dims-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
#udb-overlay .udb-dims-input { -moz-appearance: textfield; }
#udb-overlay .udb-dims-unit { font-size: 0.72rem; color: var(--udb-muted); }

/* ----- Range (line spacing) ----- */
#udb-overlay .udb-linespace[data-active="false"] { opacity: 0.4; }
#udb-overlay .udb-range { display: flex; align-items: center; gap: 10px; }
#udb-overlay .udb-range input[type="range"] {
	flex: 1; min-width: 0; height: 20px; background: transparent; cursor: pointer;
}
#udb-overlay .udb-range input[type="range"]::-webkit-slider-runnable-track {
	height: 4px; border-radius: 99px; background: var(--udb-line-2);
}
#udb-overlay .udb-range input[type="range"]::-webkit-slider-thumb {
	-webkit-appearance: none; appearance: none; margin-top: -6px;
	width: 16px; height: 16px; border-radius: 50%;
	background: var(--udb-accent); border: 0;
}
#udb-overlay .udb-range input[type="range"]::-moz-range-track {
	height: 4px; border-radius: 99px; background: var(--udb-line-2);
}
#udb-overlay .udb-range input[type="range"]::-moz-range-thumb {
	width: 16px; height: 16px; border: 0; border-radius: 50%; background: var(--udb-accent);
}
#udb-overlay .udb-range-out {
	flex: 0 0 auto; min-width: 38px; text-align: right;
	font-size: 0.8rem; font-weight: 600; color: var(--udb-text);
	font-variant-numeric: tabular-nums;
}

/* ----- Colour swatches -----
 * The ring is a box-shadow, not a border, so selecting one does not reflow
 * the grid. */
#udb-overlay .udb-swatches {
	display: grid; grid-template-columns: repeat(auto-fill, minmax(58px, 1fr)); gap: 8px;
}
#udb-overlay .udb-swatch {
	display: flex; flex-direction: column; align-items: center; gap: 5px;
	padding: 0; border: 0; background: none; cursor: pointer;
}
#udb-overlay .udb-swatch-dot {
	width: 34px; height: 34px; border-radius: 50%;
	display: flex; align-items: center; justify-content: center;
	color: var(--udb-muted);
	box-shadow: inset 0 0 0 1px rgba(0,0,0,0.35), 0 0 0 2px var(--udb-line);
	transition: transform 0.12s, box-shadow 0.15s;
}
#udb-overlay .udb-swatch:hover .udb-swatch-dot { transform: translateY(-2px); }
#udb-overlay .udb-swatch[aria-pressed="true"] .udb-swatch-dot {
	box-shadow: inset 0 0 0 1px rgba(0,0,0,0.35), 0 0 0 2px var(--udb-accent), 0 0 0 5px var(--udb-accent-soft);
}
#udb-overlay .udb-swatch-none { background: var(--udb-panel-2); box-shadow: inset 0 0 0 1px var(--udb-line-2), 0 0 0 2px var(--udb-line); }
#udb-overlay .udb-swatch-name {
	font-size: 0.64rem; line-height: 1.2; text-align: center;
	color: var(--udb-muted); word-break: break-word;
}
#udb-overlay .udb-swatch[aria-pressed="true"] .udb-swatch-name { color: var(--udb-text); }
#udb-overlay .udb-swatch:disabled { opacity: 0.3; cursor: not-allowed; }
#udb-overlay .udb-swatch:disabled:hover .udb-swatch-dot { transform: none; }

/* ----- Outline panel: inert until a colour is picked ----- */
#udb-overlay .udb-outline { transition: opacity 0.15s; }
#udb-overlay .udb-outline[data-active="false"] .udb-dims-row,
#udb-overlay .udb-outline[data-active="false"] .udb-note { opacity: 0.4; }

/* ----- Select ----- */
#udb-overlay .udb-select {
	width: 100%; height: 38px; padding: 0 32px 0 12px;
	border: 1px solid var(--udb-line); border-radius: 8px;
	background: var(--udb-bg); color: var(--udb-text);
	font-size: 0.86rem; cursor: pointer;
	background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none' stroke='%239aa0aa' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
	background-repeat: no-repeat; background-position: right 12px center;
}
#udb-overlay .udb-select:focus { border-color: var(--udb-accent); }

/* ----- Canvas -----
 * A dot grid on a dark ground by default; the surface picker swaps it so the
 * customer can preview the vinyl against the material it will be applied to. */
#udb-overlay .udb-canvas-area {
	flex: 1; min-width: 0; display: flex; align-items: center; justify-content: center;
	overflow: hidden; position: relative; touch-action: none;
	background-color: var(--udb-bg);
	background-image: radial-gradient(circle at 1px 1px, rgba(255,255,255,0.05) 1px, transparent 0);
	background-size: 22px 22px;
}
#udb-overlay .udb-canvas-area[data-surface="light"] {
	background-image:
		linear-gradient(rgba(0,0,0,0.07) 1px, transparent 1px),
		linear-gradient(90deg, rgba(0,0,0,0.07) 1px, transparent 1px);
	background-size: 40px 40px; background-position: center;
}
#udb-overlay .udb-canvas-area[data-surface="checker"] {
	background-color: #fff;
	background-image:
		linear-gradient(45deg, #ccc 25%, transparent 25%),
		linear-gradient(-45deg, #ccc 25%, transparent 25%),
		linear-gradient(45deg, transparent 75%, #ccc 75%),
		linear-gradient(-45deg, transparent 75%, #ccc 75%);
	background-size: 20px 20px;
	background-position: 0 0, 0 10px, 10px -10px, -10px 0;
}

/* ----- Measurement chips -----
 * HTML, not canvas text: the old fabric.Text labels were sized in canvas units
 * and so ballooned with zoom. These stay crisp and keep tabular figures. */
#udb-overlay .udb-measure {
	position: absolute; top: 0; left: 0; z-index: 40; pointer-events: none;
	padding: 3px 8px; border: 1px solid var(--udb-line); border-radius: 6px;
	background: rgba(30,32,38,0.92); box-shadow: var(--udb-sh-1);
	color: var(--udb-text); font-size: 11px; font-weight: 600;
	font-variant-numeric: tabular-nums; white-space: nowrap;
}
#udb-overlay .udb-measure[hidden] { display: none; }
#udb-overlay .udb-measure-w { transform: translate(-50%, -100%); }
#udb-overlay .udb-measure-h { transform: translate(0, -50%); }

/* ----- Intro card ----- */
#udb-overlay .udb-intro {
	position: absolute; left: 16px; top: 16px; z-index: 45;
	display: flex; gap: 10px; max-width: 290px; padding: 14px;
	border: 1px solid var(--udb-line); border-radius: 12px;
	background: var(--udb-panel); box-shadow: var(--udb-sh-2);
}
#udb-overlay .udb-intro[hidden] { display: none; }
#udb-overlay .udb-intro > svg { margin-top: 1px; color: var(--udb-accent); }
#udb-overlay .udb-intro-body strong { display: block; margin-bottom: 6px; font-size: 0.85rem; }
#udb-overlay .udb-intro-body ul {
	margin: 0 0 10px; padding-left: 16px; list-style: disc;
	font-size: 0.78rem; line-height: 1.6; color: var(--udb-muted);
}
#udb-overlay .udb-intro-body li { margin: 0; }
#udb-overlay .udb-intro-dismiss {
	padding: 7px 14px; border: 1px solid var(--udb-line); border-radius: 7px;
	background: var(--udb-panel-2); color: var(--udb-text);
	font-size: 0.78rem; font-weight: 600; cursor: pointer;
}
#udb-overlay .udb-intro-dismiss:hover { border-color: var(--udb-line-2); }

/* ----- Zoom pill ----- */
#udb-overlay .udb-zoom {
	position: absolute; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 50;
	display: flex; align-items: center; gap: 2px; padding: 4px;
	border: 1px solid var(--udb-line); border-radius: 99px;
	background: rgba(30,32,38,0.92); box-shadow: var(--udb-sh-2);
}
#udb-overlay .udb-zoom-btn {
	display: flex; align-items: center; justify-content: center;
	width: 34px; height: 34px; border: 0; border-radius: 99px;
	background: transparent; color: var(--udb-text); cursor: pointer;
}
#udb-overlay .udb-zoom-btn:hover { background: rgba(255,255,255,0.08); }
#udb-overlay .udb-zoom-reset {
	width: auto; padding: 0 12px; color: var(--udb-muted);
	font-size: 0.78rem; font-weight: 600; font-variant-numeric: tabular-nums;
}

#udb-overlay .udb-fullscreen {
	position: absolute; bottom: 18px; left: 18px; z-index: 60;
	display: flex; align-items: center; justify-content: center;
	width: 38px; height: 38px; border: 1px solid var(--udb-line); border-radius: 10px;
	background: rgba(30,32,38,0.92); box-shadow: var(--udb-sh-1);
	color: var(--udb-text); cursor: pointer;
}
#udb-overlay .udb-fullscreen:hover { border-color: var(--udb-line-2); }

/* ----- Toast ----- */
#udb-overlay .udb-toast {
	position: absolute; right: 16px; bottom: 16px; z-index: 200;
	max-width: 340px; padding: 11px 15px;
	border: 1px solid var(--udb-line); border-left: 3px solid var(--udb-accent);
	border-radius: 9px; background: var(--udb-panel); box-shadow: var(--udb-sh-2);
	font-size: 0.83rem; line-height: 1.45; color: var(--udb-text);
}
#udb-overlay .udb-toast[hidden] { display: none; }
#udb-overlay .udb-toast.is-error { border-left-color: var(--udb-danger); }
#udb-overlay .udb-toast.is-warn { border-left-color: var(--udb-warn); }
#udb-overlay .udb-toast-actions { display: flex; gap: 8px; margin-top: 10px; }
#udb-overlay .udb-toast-actions button {
	padding: 6px 12px; border: 1px solid var(--udb-line); border-radius: 7px;
	background: var(--udb-panel-2); color: var(--udb-text);
	font-size: 0.78rem; font-weight: 600; cursor: pointer;
}
#udb-overlay .udb-toast-actions button.is-primary {
	background: var(--udb-accent); border-color: var(--udb-accent); color: #0d1410;
}

/* Flash the field a failed save points at. */
#udb-overlay .udb-dims-group.is-flagged { border-color: var(--udb-warn); }

/* ----- Distraction-free ----- */
#udb-overlay.distraction-free .udb-sidebar,
#udb-overlay.distraction-free .udb-header { display: none !important; }
#udb-overlay.distraction-free .udb-canvas-area { width: 100%; height: 100%; }

@media (prefers-reduced-motion: reduce) {
	#udb-overlay * { transition: none !important; animation: none !important; }
}

/* ----- Phone, portrait: canvas first, tools in a scrolling dock ----- */
@media (max-width: 768px) and (orientation: portrait) {
	#udb-overlay .udb-header { height: 46px; padding: 0 10px; gap: 8px; }
	#udb-overlay .udb-header h3 { font-size: 0.85rem; }
	#udb-overlay .udb-header-actions button { padding: 8px 12px; font-size: 0.8rem; }
	#udb-overlay .udb-btn-save { min-width: 0; }

	#udb-overlay .udb-main-row { flex-direction: column; }
	#udb-overlay .udb-canvas-area { order: 1; flex: 1 1 auto; width: 100%; min-height: 0; }

	#udb-overlay .udb-sidebar {
		order: 2; flex: 0 0 auto; width: 100%; flex-direction: row; align-items: center;
		gap: 8px; padding: 8px 10px; border-right: 0; border-top: 1px solid var(--udb-line);
		overflow-x: auto; overflow-y: visible;
	}
	#udb-overlay .udb-sidebar { scrollbar-width: none; }
	#udb-overlay .udb-sidebar::-webkit-scrollbar { display: none; }

	#udb-overlay .udb-group { flex: 0 0 auto; flex-direction: row; align-items: center; gap: 6px; }
	#udb-overlay .udb-group + .udb-group { padding-left: 8px; border-left: 1px solid var(--udb-line); }
	#udb-overlay .udb-group-label { display: none; }
	#udb-overlay .udb-note,
	#udb-overlay .udb-hint,
	#udb-overlay .udb-counter { display: none; }

	#udb-overlay .udb-textarea { width: 190px; height: 44px; resize: none; }
	#udb-overlay .udb-seg-btn { min-width: 44px; height: 44px; padding: 0; }
	#udb-overlay .udb-check { white-space: nowrap; }
	#udb-overlay .udb-presets { flex-wrap: nowrap; }
	#udb-overlay .udb-preset-btn { min-width: 44px; height: 44px; }
	#udb-overlay .udb-dims-group { width: 104px; height: 44px; }
	#udb-overlay .udb-select { width: 132px; height: 44px; }
	#udb-overlay .udb-range { width: 130px; }
	#udb-overlay .udb-swatches { display: flex; flex-wrap: nowrap; gap: 8px; }
	#udb-overlay .udb-swatch-name { display: none; }
	#udb-overlay .udb-swatch-dot { width: 38px; height: 38px; }

	/* A 264px list cannot live in a horizontal strip, so the picker becomes a
	 * sheet over the canvas, opened from a single button in the dock. */
	#udb-overlay .udb-fontpicker {
		position: fixed; inset: auto 0 0 0; z-index: 120;
		max-height: 62vh; padding: 12px; gap: 10px;
		border-top: 1px solid var(--udb-line); border-radius: 14px 14px 0 0;
		background: var(--udb-panel); box-shadow: var(--udb-sh-2);
	}
	#udb-overlay .udb-fontpicker[data-open="false"] { display: none; }
	#udb-overlay .udb-font-list { max-height: 38vh; }
	#udb-overlay .udb-font-search { height: 44px; }
	#udb-overlay .udb-fontsheet-toggle {
		display: flex; align-items: center; gap: 8px; height: 44px; padding: 0 13px;
		border: 1px solid var(--udb-line); border-radius: var(--udb-radius);
		background: var(--udb-panel-2); color: var(--udb-text);
		font-size: 0.85rem; font-weight: 500; white-space: nowrap; cursor: pointer;
	}
	#udb-overlay .udb-fontsheet-done {
		display: block; width: 100%; height: 44px; border: 0; border-radius: 8px;
		background: var(--udb-accent); color: #0d1410; font-weight: 600; cursor: pointer;
	}

	#udb-overlay .udb-zoom { bottom: 12px; }
	#udb-overlay .udb-fullscreen { bottom: 12px; left: 12px; }
	#udb-overlay .udb-intro { left: 10px; right: 10px; top: 10px; max-width: none; }
	#udb-overlay .udb-toast { left: 10px; right: 10px; max-width: none; bottom: 12px; }
}

/* ----- Phone, landscape: narrow rail ----- */
@media (max-width: 900px) and (orientation: landscape) {
	#udb-overlay .udb-header { height: 44px; }
	#udb-overlay .udb-main-row { flex-direction: row; }
	#udb-overlay .udb-sidebar { width: 210px; height: 100%; gap: 10px; padding: 10px; }
	#udb-overlay .udb-sidebar { scrollbar-width: none; }
	#udb-overlay .udb-sidebar::-webkit-scrollbar { display: none; }
	#udb-overlay .udb-hint { display: none; }
	#udb-overlay .udb-textarea { height: 58px; }
	#udb-overlay .udb-font-list { max-height: 150px; }
	#udb-overlay .udb-swatches { grid-template-columns: repeat(auto-fill, minmax(42px, 1fr)); }
	#udb-overlay .udb-swatch-name { display: none; }
	#udb-overlay .udb-swatch-dot { width: 30px; height: 30px; }
	#udb-overlay .udb-canvas-area { flex: 1; height: 100%; }
	#udb-overlay .udb-intro { max-width: 240px; padding: 10px; }
}
