.caldesigner-app {
	--cd-ink: #1c1917;
	--cd-muted: #57534e;
	--cd-line: #e7e5e4;
	--cd-panel: #ffffff;
	--cd-stage: #e7e2d8;
	--cd-accent: #1e3a5f;
	--cd-accent-soft: #e8eef6;
	--cd-danger: #9a3412;
	--cd-ok: #166534;
	--cd-radius: 14px;
	--cd-shadow: 0 18px 40px rgba(28, 25, 23, 0.12);
	color: var(--cd-ink);
	font-family: "Segoe UI", system-ui, sans-serif;
	font-size: 14px;
	line-height: 1.45;
	margin: 12px 0 20px;
}

.caldesigner-app *,
.caldesigner-app *::before,
.caldesigner-app *::after {
	box-sizing: border-box;
}

.caldesigner-app button,
.caldesigner-app input,
.caldesigner-app select,
.caldesigner-app textarea {
	font: inherit;
	color: inherit;
}

.cd-shell {
	display: grid;
	grid-template-columns: 220px minmax(0, 1fr) 280px;
	gap: 14px;
	align-items: stretch;
	min-height: 560px;
}

.caldesigner-app.is-readonly .cd-shell {
	grid-template-columns: minmax(0, 1fr);
}

.cd-rail,
.cd-inspector {
	background: var(--cd-panel);
	border: 1px solid var(--cd-line);
	border-radius: var(--cd-radius);
	padding: 14px;
	min-width: 0;
}

.cd-rail h2,
.cd-inspector h2 {
	margin: 0 0 10px;
	font-size: 12px;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	color: var(--cd-muted);
	font-weight: 650;
}

.cd-actions {
	display: grid;
	gap: 8px;
	margin-bottom: 14px;
}

.cd-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 6px;
	border: 1px solid var(--cd-line);
	background: #fff;
	border-radius: 10px;
	padding: 8px 10px;
	cursor: pointer;
	width: 100%;
}

.cd-btn:hover {
	border-color: #c8c5c0;
	background: #fafaf9;
}

.cd-btn.is-primary {
	background: var(--cd-accent);
	border-color: var(--cd-accent);
	color: #fff;
}

.cd-btn.is-quiet {
	width: auto;
	padding: 6px 8px;
}

.cd-btn.is-danger {
	color: var(--cd-danger);
	border-color: #fdba74;
	background: #fff7ed;
}

.cd-btn[disabled] {
	opacity: 0.45;
	cursor: not-allowed;
}

.cd-layers {
	list-style: none;
	margin: 0;
	padding: 0;
	display: grid;
	gap: 4px;
	max-height: 420px;
	overflow: auto;
}

.cd-layers button {
	width: 100%;
	text-align: left;
	border: 0;
	background: transparent;
	border-radius: 8px;
	padding: 7px 8px;
	cursor: pointer;
}

.cd-layers button.is-active,
.cd-layers button:hover {
	background: var(--cd-accent-soft);
}

.cd-layers small {
	display: block;
	color: var(--cd-muted);
	font-size: 11px;
}

.cd-stage {
	background: var(--cd-stage);
	border-radius: var(--cd-radius);
	min-width: 0;
	display: flex;
	flex-direction: column;
	overflow: hidden;
}

.cd-toolbar {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	align-items: center;
	padding: 10px 12px;
	background: rgba(255, 255, 255, 0.72);
	border-bottom: 1px solid rgba(28, 25, 23, 0.06);
}

.cd-seg {
	display: inline-flex;
	background: #fff;
	border-radius: 999px;
	padding: 3px;
	border: 1px solid var(--cd-line);
}

.cd-seg button {
	border: 0;
	background: transparent;
	border-radius: 999px;
	padding: 6px 12px;
	cursor: pointer;
}

.cd-seg button.is-active {
	background: var(--cd-accent);
	color: #fff;
}

.cd-zoom-label {
	min-width: 48px;
	text-align: center;
	color: var(--cd-muted);
	font-variant-numeric: tabular-nums;
}

.cd-scroll {
	flex: 1;
	overflow: auto;
	padding: 28px 20px 36px;
}

.cd-board {
	margin: 0 auto;
	position: relative;
}

.cd-sheet {
	position: relative;
	background: #fff;
	box-shadow: var(--cd-shadow);
	background-size: 100% 100%;
	background-repeat: no-repeat;
	outline: none;
}

.cd-bg-layer {
	position: absolute;
	inset: 0;
	overflow: hidden;
	pointer-events: none;
	z-index: 0;
}

.cd-bg-layer img {
	position: absolute;
	max-width: none;
}

.cd-sheet.is-bg-adjust {
	cursor: grab;
}

.cd-sheet.is-bg-panning {
	cursor: grabbing;
}

.cd-sheet.is-over {
	outline: 2px dashed var(--cd-accent);
	outline-offset: 4px;
}

.cd-guide {
	position: absolute;
	z-index: 1;
	pointer-events: none;
	box-sizing: border-box;
}

.cd-guide-trim {
	border: 1px dashed #2f5bd1;
}

.cd-guide-safe {
	border: 1px solid rgba(22, 101, 52, 0.7);
}

.cd-snap-line,
.cd-snap-gap {
	position: absolute;
	pointer-events: none;
	z-index: 80;
	box-sizing: border-box;
}

.cd-snap-line.cd-snap-x {
	width: 0;
	border-left: 1px solid var(--cd-accent);
}

.cd-snap-line.cd-snap-y {
	height: 0;
	border-top: 1px solid var(--cd-accent);
}

.cd-snap-line.is-center.cd-snap-x {
	border-left-style: dashed;
}

.cd-snap-line.is-center.cd-snap-y {
	border-top-style: dashed;
}

.cd-snap-gap {
	width: 12px;
	margin-left: -6px;
	border-left: 1px solid var(--cd-accent);
	border-right: 1px solid var(--cd-accent);
}

.cd-snap-gap::before,
.cd-snap-gap::after {
	content: "";
	position: absolute;
	left: 0;
	right: 0;
	height: 0;
	border-top: 1px solid var(--cd-accent);
}

.cd-snap-gap::before {
	top: 0;
}

.cd-snap-gap::after {
	bottom: 0;
}

.cd-item {
	position: absolute;
	z-index: 1;
	box-sizing: border-box;
	cursor: grab;
	user-select: none;
	touch-action: none;
	container-type: size;
}

.cd-item.is-adjusting,
.cd-item.is-adjusting.is-locked {
	cursor: grab;
}

.cd-item.is-adjusting.is-panning {
	cursor: grabbing;
}

.cd-item.is-locked {
	cursor: default;
}

.cd-item.is-selected {
	z-index: 30;
}

.cd-item-body {
	position: relative;
	width: 100%;
	height: 100%;
	overflow: hidden;
	display: flex;
	pointer-events: none;
}

.cd-item-body.is-open {
	overflow: visible;
}

.cd-img-clip {
	position: absolute;
	inset: 0;
	overflow: hidden;
}

.cd-item.is-selected .cd-item-body {
	outline: 1.5px solid var(--cd-accent);
	outline-offset: 0;
}

.cd-item.is-unsafe.is-selected .cd-item-body {
	outline-color: var(--cd-danger);
}

.cd-item img {
	position: absolute;
	max-width: none;
	pointer-events: none;
}

.cd-img-ghost {
	opacity: 0.35;
}

.cd-mask-outline {
	position: absolute;
	box-sizing: border-box;
	pointer-events: none;
	z-index: 3;
}

div.cd-mask-outline {
	border: 1.5px dashed var(--cd-accent);
}

.cd-mask-oval {
	inset: 0;
	border-radius: 50%;
}

.cd-mask-circle {
	left: 50%;
	top: 50%;
	width: min(100cqw, 100cqh);
	height: min(100cqw, 100cqh);
	transform: translate(-50%, -50%);
	border-radius: 50%;
}

svg.cd-mask-outline {
	inset: 0;
	width: 100%;
	height: 100%;
	overflow: visible;
}

svg.cd-mask-outline polygon {
	stroke: var(--cd-accent);
	stroke-width: 1.5px;
	stroke-dasharray: 4 3;
	vector-effect: non-scaling-stroke;
}

.cd-zoom-row {
	display: flex;
	align-items: center;
	gap: 8px;
}

.cd-zoom-row input[type="range"] {
	flex: 1;
	width: auto;
	padding: 0;
}

.cd-zoom-readout {
	min-width: 2.4em;
	font-size: 12px;
	color: var(--cd-muted);
}

.cd-item.is-shape .cd-item-body {
	border-radius: 0;
}

.cd-item.is-placeholder .cd-item-body {
	border: 1px dashed #a8a29e;
	color: var(--cd-muted);
	align-items: center;
	justify-content: center;
	font-size: 12px;
	background: rgba(255, 255, 255, 0.55);
}

.cd-handle {
	position: absolute;
	width: 9px;
	height: 9px;
	background: #fff;
	border: 1.5px solid var(--cd-accent);
	border-radius: 2px;
	z-index: 2;
	pointer-events: auto;
}

.cd-handle-n { top: -5px; left: 50%; margin-left: -5px; cursor: ns-resize; }
.cd-handle-s { bottom: -5px; left: 50%; margin-left: -5px; cursor: ns-resize; }
.cd-handle-e { right: -5px; top: 50%; margin-top: -5px; cursor: ew-resize; }
.cd-handle-w { left: -5px; top: 50%; margin-top: -5px; cursor: ew-resize; }
.cd-handle-ne { top: -5px; right: -5px; cursor: nesw-resize; }
.cd-handle-nw { top: -5px; left: -5px; cursor: nwse-resize; }
.cd-handle-se { bottom: -5px; right: -5px; cursor: nwse-resize; }
.cd-handle-sw { bottom: -5px; left: -5px; cursor: nesw-resize; }

.cd-handle-rotate {
	top: -26px;
	left: 50%;
	margin-left: -6px;
	width: 12px;
	height: 12px;
	border-radius: 50%;
	cursor: grab;
}

.cd-handle-rotate::before {
	content: "";
	position: absolute;
	left: 5px;
	top: 10px;
	width: 1px;
	height: 10px;
	background: var(--cd-accent);
}

.cd-field {
	display: grid;
	gap: 4px;
	margin: 0 0 10px;
}

.cd-field span {
	font-size: 12px;
	color: var(--cd-muted);
}

.cd-field input[type="text"],
.cd-field input[type="number"],
.cd-field select,
.cd-field textarea {
	width: 100%;
	border: 1px solid var(--cd-line);
	border-radius: 8px;
	padding: 7px 8px;
	background: #fff;
}

.cd-field textarea {
	min-height: 72px;
	resize: vertical;
}

.cd-inline {
	display: flex;
	gap: 6px;
	align-items: center;
}

.cd-inline .cd-btn {
	width: auto;
	min-width: 34px;
}

.cd-inline .cd-btn.is-on {
	background: var(--cd-accent);
	color: #fff;
	border-color: var(--cd-accent);
}

.cd-color {
	display: flex;
	align-items: center;
	gap: 8px;
}

.cd-color input[type="color"] {
	width: 42px;
	height: 32px;
	padding: 0;
	border: 1px solid var(--cd-line);
	background: #fff;
	border-radius: 8px;
}

.cd-note {
	font-size: 12px;
	color: var(--cd-danger);
	margin: 0 0 10px;
}

.cd-hint {
	margin: 8px 12px 0;
	color: var(--cd-muted);
	font-size: 12px;
}

.cd-check {
	display: flex;
	gap: 8px;
	align-items: center;
	margin: 0 0 8px;
	font-size: 13px;
}

.cd-sides-stack {
	display: grid;
	gap: 28px;
	justify-items: center;
}

.cd-caption {
	margin-top: 8px;
	font-weight: 650;
}

@media (max-width: 1100px) {
	.cd-shell {
		grid-template-columns: 1fr;
	}

	.cd-layers {
		max-height: 180px;
	}
}

.cd-import {
	background: #fff;
	border: 1px solid #e7e5e4;
	border-radius: 14px;
	padding: 14px 16px 8px;
	margin: 0 0 14px;
	color: #1c1917;
}

.cd-import summary {
	cursor: pointer;
	font-size: 14px;
	font-weight: 650;
}

.cd-import .cd-setting {
	margin-top: 10px;
}

.cd-import textarea {
	width: 100%;
	min-height: 140px;
	border: 1px solid #e7e5e4;
	border-radius: 8px;
	padding: 8px;
	font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
	font-size: 12px;
}

.cd-settings {
	background: #fff;
	border: 1px solid #e7e5e4;
	border-radius: 14px;
	padding: 14px 16px 12px;
	margin: 0 0 14px;
	color: #1c1917;
}

.cd-settings-row {
	display: flex;
	flex-wrap: wrap;
	gap: 12px;
	align-items: flex-end;
	margin-bottom: 10px;
}

.cd-setting {
	display: grid;
	gap: 4px;
	min-width: 0;
}

.cd-setting span {
	font-size: 12px;
	color: #57534e;
}

.cd-setting input,
.cd-setting select {
	width: 100%;
	border: 1px solid #e7e5e4;
	border-radius: 8px;
	padding: 7px 8px;
	background: #fff;
	color: #1c1917;
	font-size: 14px;
}

.cd-setting input[type="number"] {
	width: 110px;
}

.cd-setting-grow {
	flex: 1 1 220px;
}

.cd-setting-check {
	display: flex;
	align-items: center;
	gap: 8px;
	padding-bottom: 8px;
	font-size: 14px;
}

.cd-settings .cd-btn {
	width: auto;
	margin-bottom: 1px;
	padding: 8px 14px;
}

.cd-settings-note {
	margin: 0;
	font-size: 12px;
	color: #57534e;
}

.cd-settings-permalink {
	margin-top: 10px;
}

.cd-settings-permalink summary {
	cursor: pointer;
	font-size: 13px;
	color: #1e3a5f;
}

.cd-settings-permalink .cd-setting {
	margin-top: 8px;
	max-width: 360px;
}

#caldesigner-export-status {
	margin-top: 8px;
	color: #9a3412;
}

.caldesigner-dpi-warn {
	color: #9a3412;
	margin: 8px 0 0;
}

.caldesigner-status {
	color: #57534e;
	min-height: 1.2em;
}

.caldesigner-print {
	margin: 12px 0 0;
}

.caldesigner-print .cd-btn {
	width: auto;
	min-width: 10rem;
	padding: 10px 16px;
}

.caldesigner-print .cd-btn.is-primary {
	background: #1e3a5f;
	border-color: #1e3a5f;
	color: #fff;
}
