/* 3D Text Studio (extension package). The modal chrome (backdrop,
   frame, header, close, selects, chips, tiles, buttons, scrollbars)
   comes from the editor's own modal design (dsm family) - the dialog
   mounts inside #wpie-root exactly for that. Only studio-specific
   layout lives here (prefix wpie3do- so the sibling 3D Mockup Studio
   never collides). */

.wpie3do-dialog {
	display: flex;
	flex-direction: column;
	width: min( 1500px, 97vw );
	height: min( 780px, 92vh );
}

.wpie3do-body {
	display: flex;
	flex: 1;
	min-height: 0;
}

.wpie3do-view {
	position: relative;
	display: grid;
	flex: 1;
	place-items: center;
	min-width: 0;

	/* Oversized scene canvases must scale down, never paint over the
	   dialog footer. */
	overflow: hidden;
	background:
		repeating-conic-gradient(
			rgba( 128, 128, 128, 0.07 ) 0 25%,
			transparent 0 50%
		)
		0 0 / 22px 22px;
}

/* "Show document": the flattened document sits contain-fitted behind the
   transparent scene canvas (inline background-image, set by main.js). */
.wpie3do-view.is-doc {
	background-color: #05060a;
	background-repeat: no-repeat;
	background-position: center;
	background-size: contain;
}

#wpie-root .wpie3do-docbtn {
	position: absolute;
	top: 10px;
	right: 12px;
	z-index: 3;
	display: inline-flex;
	gap: 6px;
	align-items: center;
	padding: 4px 11px;
	font-size: 11px;
	color: var( --ed-text-muted, #9aa1ab );
	cursor: pointer;
	background: var( --ed-panel, #1d2126 );
	border: 1px solid var( --ed-border, #333a44 );
	border-radius: 999px;
	opacity: 0.92;
}

#wpie-root .wpie3do-docbtn:hover {
	color: var( --ed-text, #e6e9ee );
}

#wpie-root .wpie3do-docbtn[aria-pressed='true'] {
	color: #fff;
	background: var( --ed-accent, #3b66ff );
	border-color: var( --ed-accent, #3b66ff );
}

.wpie3do-docbtn svg {
	width: 13px;
	height: 13px;
}

.wpie3do-view canvas {
	max-width: 100%;
	max-height: 100%;
	cursor: grab;
	border-radius: 4px;
}

.wpie3do-view canvas:active {
	cursor: grabbing;
}

.wpie3do-hint {
	position: absolute;
	bottom: 10px;
	left: 12px;
	padding: 3px 9px;
	font-size: 11px;
	color: var( --ed-text-muted, #9aa1ab );
	pointer-events: none;
	background: var( --ed-panel, #1d2126 );
	border-radius: 999px;
	opacity: 0.9;
}

.wpie3do-side {
	display: flex;
	flex-direction: column;
	gap: 10px;
	width: 348px;
	padding: 14px;
	overflow-y: auto;
	border-left: 1px solid var( --ed-border, #333a44 );
}

.wpie3do-seg {
	display: flex;
}

.wpie3do-seg button {
	flex: 1;
}

.wpie3do-controls {
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.wpie3do-row {
	display: grid;
	grid-template-columns: 94px 1fr;
	gap: 8px;
	align-items: center;
}

.wpie3do-row.has-val {
	grid-template-columns: 94px 1fr 34px;
}

.wpie3do-row .dsm-label {
	overflow: hidden;
	font-size: 10.5px;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.wpie3do-val {
	font-size: 10.5px;
	font-variant-numeric: tabular-nums;
	color: var( --ed-text-muted, #8b93a1 );
	text-align: right;
	white-space: nowrap;
}

/* Settings cards. */
.wpie3do-card {
	overflow: hidden;
	background: var( --ed-panel-alt, rgba( 255, 255, 255, 0.03 ) );
	border: 1px solid var( --ed-border, #333a44 );
	border-radius: 10px;
}

.wpie3do-card-head {
	display: flex;
	gap: 9px;
	align-items: center;
	padding: 14px 16px 4px;
	font-size: 11px;
	font-weight: 600;
	letter-spacing: 0.04em;
	color: var( --ed-text-dim, #b9c0cc );
	text-transform: uppercase;
}

.wpie3do-card-head svg {
	flex: none;
	opacity: 0.85;
}

.wpie3do-card-body {
	display: flex;
	flex-direction: column;
	gap: 9px;
	padding: 9px 16px 15px;
}

/* Model picker tiles. */
.wpie3do-grid.wpie3do-models {
	grid-template-columns: repeat( 3, 1fr );
	max-height: 276px;
}

.wpie3do-models .dsm-tile {
	min-width: 0;
	padding: 5px 3px 4px;
}

.wpie3do-models .wpie3do-thumb {
	background: none;
}

.wpie3do-models .wpie3do-tile-label {
	font-size: 10px;
}

/* Body color presets. */
.wpie3do-swatches {
	display: flex;
	gap: 7px;
	padding: 2px 0 2px 68px;
}

.wpie3do-swatch {
	width: 18px;
	height: 18px;
	padding: 0;
	cursor: pointer;
	border: 1px solid rgba( 255, 255, 255, 0.35 );
	border-radius: 50%;
}

.wpie3do-dialog .wpie3do-colorhost input[type='color'] {
	width: 46px;
	height: 24px;
}

.wpie3do-swatch:hover {
	transform: scale( 1.15 );
}

.wpie3do-swatch.active {
	box-shadow: 0 0 0 2px var( --ed-bg, #14171c ),
		0 0 0 4px var( --accent, #3b66ff );
}

.wpie3do-colorhost {
	display: flex;
	align-items: center;
}

.wpie3do-grid {
	display: grid;
	grid-template-columns: repeat( auto-fill, minmax( 88px, 1fr ) );
	gap: 8px;
	max-height: 320px;
	padding: 2px;
	overflow-y: auto;
}

.wpie3do-tile {
	position: relative;
	gap: 4px;
	padding: 8px 6px 6px;
}

.wpie3do-thumb {
	width: 100%;
	aspect-ratio: 1 / 1;
	object-fit: contain;
	background:
		repeating-conic-gradient(
			rgba( 128, 128, 128, 0.08 ) 0 25%,
			transparent 0 50%
		)
		0 0 / 12px 12px;
	border-radius: 4px;
}

.wpie3do-tile-badge {
	position: absolute;
	top: 4px;
	right: 4px;
	min-width: 16px;
	height: 16px;
	padding: 0 4px;
	font-size: 10px;
	font-weight: 700;
	line-height: 16px;
	color: #fff;
	text-align: center;
	background: var( --accent, #3b66ff );
	border-radius: 999px;
}

.wpie3do-tile-label {
	max-width: 100%;
	overflow: hidden;
	font-size: 10.5px;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.wpie3do-sect {
	margin-top: 4px;
	padding-top: 10px;
	font-size: 11px;
	font-weight: 600;
	letter-spacing: 0.04em;
	color: var( --ed-text-dim, #b9c0cc );
	text-transform: uppercase;
	border-top: 1px solid var( --ed-border, #333a44 );
}

.wpie3do-note {
	min-height: 14px;
	font-size: 11px;
	color: var( --ed-text-muted, #8b93a1 );
}

.wpie3do-dialog input[type='color'] {
	width: 100%;
	height: 28px;
	padding: 2px;
	cursor: pointer;
	background: var( --ed-panel-alt, #262b33 );
	border: 1px solid var( --ed-border, #333a44 );
	border-radius: 6px;
}

/* The text input. */
.wpie3do-dialog textarea.wpie3do-text {
	min-height: 52px;
	font-size: 13px;
	line-height: 1.4;
	resize: vertical;
}

/* Transparent-background swatch. */
.wpie3do-swatch.wpie3do-checker {
	background:
		repeating-conic-gradient(
			rgba( 128, 128, 128, 0.45 ) 0 25%,
			rgba( 255, 255, 255, 0.14 ) 0 50%
		)
		0 0 / 8px 8px;
}

/* 360 spin export buttons. */
.wpie3do-spinrow {
	display: flex;
	gap: 8px;
}

.wpie3do-spinrow .ai-btn {
	flex: 1;
}

/* Text | Logo mode switch + logo controls. */
.wpie3do-mode {
	margin-bottom: 2px;
}

.wpie3do-checkbox {
	justify-self: start;
	width: 15px;
	height: 15px;
	accent-color: var( --accent, #3b66ff );
}

/* Checkbox rows: full-width label, control right-aligned. */
.wpie3do-row.wpie3do-wide {
	grid-template-columns: 1fr auto;
}

/* Per-letter color row. */
.wpie3do-letterrow {
	grid-template-columns: 94px auto 1fr;
}

.wpie3do-reset {
	justify-self: start;
	padding: 3px 9px;
	font-size: 11px;
	color: var( --ed-text-dim, #b9c0cc );
	cursor: pointer;
	background: var( --ed-panel-alt, #262b33 );
	border: 1px solid var( --ed-border, #333a44 );
	border-radius: 6px;
}

.wpie3do-letterpanel {
	padding: 8px 10px 10px;
	background: var( --ed-panel, rgba( 0, 0, 0, 0.18 ) );
	border: 1px solid var( --ed-border, #333a44 );
	border-radius: 8px;
}

.wpie3do-letterpanel .wpie3do-sect {
	margin-top: 0;
	padding-top: 0;
	border-top: 0;
}

/* Text field + variable-picker button side by side (API 2.6+). */
.wpie3do-textwrap {
	display: flex;
	gap: 6px;
	align-items: flex-start;
}

.wpie3do-textwrap .wpie3do-text {
	flex: 1;
	min-width: 0;
}

.wpie3do-varhost {
	flex: 0 0 auto;
	display: flex;
}

/* ------------------------- 3D Objects additions ------------------------- */

/* Category segments wrap into two rows without shrinking. */
#wpie-root .wpie3do-cats {
	flex-wrap: wrap;
}

#wpie-root .wpie3do-cats button {
	flex: 1 1 30%;
}

/* Library tiles show a rendered thumbnail above the caption. */
#wpie-root .wpie3do-tile {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 2px;
	padding: 6px 4px 5px;
}

#wpie-root .wpie3do-thumb {
	width: 100%;
	aspect-ratio: 1;
	object-fit: contain;
	display: block;
	pointer-events: none;
}

/* Material presets: compact text chips in a 3-up grid. */
#wpie-root .wpie3do-mats {
	grid-template-columns: repeat( 3, 1fr );
}

#wpie-root .wpie3do-mat {
	padding: 7px 4px;
	text-align: center;
}

/* GLB import row. */
#wpie-root .wpie3do-importrow {
	display: flex;
	align-items: center;
	gap: 8px;
	margin-top: 6px;
}

#wpie-root .wpie3do-importname {
	font-size: 12px;
	color: var( --ed-text-muted );
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	min-width: 0;
}

#wpie-root .wpie3do-importnote,
#wpie-root .wpie3do-importstate {
	margin-top: 4px;
}

/* Mood + camera chips wrap into a tidy 2x2 grid, no clipped labels. */
#wpie-root .wpie3do-moods,
#wpie-root .wpie3do-campresets {
	flex-wrap: wrap;
}

#wpie-root .wpie3do-moods button,
#wpie-root .wpie3do-campresets button {
	flex: 1 1 42%;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

/* v1.2/v1.3: model library rows + AI 3D section. */
#wpie-root .wpie3do-saverow {
	display: flex;
	align-items: center;
	gap: 7px;
	margin-top: 8px;
	font-size: 12px;
	color: var( --ed-text-muted );
	cursor: pointer;
}

#wpie-root .wpie3do-models-list {
	margin-top: 10px;
	display: flex;
	flex-direction: column;
	gap: 4px;
}

#wpie-root .wpie3do-modelshead {
	font-size: 11px;
	font-weight: 600;
	letter-spacing: 0.04em;
	text-transform: uppercase;
	color: var( --ed-text-muted );
	margin: 2px 0;
}

#wpie-root .wpie3do-modelrow {
	display: flex;
	align-items: center;
	gap: 6px;
	border: 1px solid var( --ed-border, #333a44 );
	border-radius: 8px;
	padding: 4px 6px;
}

#wpie-root .wpie3do-modelrow.active {
	border-color: var( --ed-accent, #3b66ff );
}

#wpie-root .wpie3do-modelload {
	flex: 1;
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	background: none;
	border: 0;
	color: inherit;
	text-align: left;
	cursor: pointer;
	padding: 3px 2px;
	font-size: 12px;
}

#wpie-root .wpie3do-modelsize {
	font-size: 11px;
	color: var( --ed-text-muted );
	flex: 0 0 auto;
}

#wpie-root .wpie3do-modeldel {
	background: none;
	border: 0;
	color: var( --ed-text-muted );
	cursor: pointer;
	padding: 2px;
	line-height: 0;
}

#wpie-root .wpie3do-modeldel:hover {
	color: var( --ed-danger, #e5484d );
}

#wpie-root .wpie3do-airow {
	margin-top: 8px;
	display: flex;
	justify-content: flex-end;
}

#wpie-root .wpie3do-aistatus {
	margin-top: 6px;
	min-height: 16px;
}

#wpie-root .wpie3do-aithumb {
	margin-top: 6px;
	width: 84px;
	height: 84px;
	object-fit: cover;
	border-radius: 8px;
	border: 1px solid var( --ed-border, #333a44 );
	display: block;
}

#wpie-root .wpie3do-aitext .dsm-input {
	width: 100%;
	margin-top: 8px;
	min-height: 96px;
	resize: vertical;
}

/* v1.5: two-panel layout, model thumbs, picker popover. */
#wpie-root .wpie3do-left {
	display: flex;
	flex-direction: column;
	gap: 10px;
	width: 330px;
	padding: 14px;
	overflow-y: auto;
	border-right: 1px solid var( --ed-border, #333a44 );
	flex: 0 0 auto;
}

#wpie-root .wpie3do-modelthumb {
	width: 34px;
	height: 34px;
	border-radius: 6px;
	object-fit: cover;
	background: var( --ed-surface-2, #262a31 );
	flex: 0 0 auto;
	display: block;
}

#wpie-root span.wpie3do-modelthumb {
	background:
		linear-gradient( 135deg, transparent 46%, var( --ed-border, #333a44 ) 46%, var( --ed-border, #333a44 ) 54%, transparent 54% ),
		var( --ed-surface-2, #262a31 );
}

#wpie-root .wpie3do-renameinput {
	flex: 1;
	min-width: 0;
	font-size: 12px;
	padding: 3px 6px;
}

#wpie-root .wpie3do-aimedia {
	display: flex;
	flex-direction: column;
	align-items: stretch;
	gap: 10px;
	margin-top: 8px;
}

#wpie-root .wpie3do-left .wpie3do-aimedia .ai-btn {
	width: 100%;
}

#wpie-root .wpie3do-aipickprev img {
	width: 44px;
	height: 44px;
	border-radius: 8px;
	object-fit: cover;
	display: block;
	border: 1px solid var( --ed-border, #333a44 );
}

#wpie-root .wpie3do-pickover {
	position: absolute;
	inset: 0;
	background: rgba( 10, 12, 16, 0.55 );
	display: flex;
	align-items: center;
	justify-content: center;
	z-index: 60;
	border-radius: inherit;
}

#wpie-root .wpie3do-pickover-card {
	width: min( 560px, 92% );
	background: var( --ed-surface, #1c1f24 );
	border: 1px solid var( --ed-border, #333a44 );
	border-radius: 12px;
	padding: 12px;
	box-shadow: 0 18px 50px rgba( 0, 0, 0, 0.45 );
}

#wpie-root .wpie3do-pickover-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	font-weight: 600;
	margin-bottom: 8px;
}

#wpie-root .wpie3do-pickover-body {
	max-height: 380px;
	overflow: hidden;
}

/* v1.5.1: full-width action buttons in the left panel; stacked rows. */
#wpie-root .wpie3do-left .wpie3do-importrow {
	flex-direction: column;
	align-items: stretch;
}

#wpie-root .wpie3do-left .wpie3do-importrow .ai-btn {
	width: 100%;
}

#wpie-root .wpie3do-left .wpie3do-airow {
	display: block;
}

#wpie-root .wpie3do-left .wpie3do-airow .ai-btn {
	width: 100%;
}

#wpie-root .wpie3do-left .wpie3do-aipickprev {
	align-self: center;
}

/* v1.5.2: full-width model name field. */
#wpie-root .wpie3do-ainame {
	width: 100%;
	margin-top: 8px;
}

/* The side column is a flex column with its own scroll area. Without
   this the cards keep the default flex-shrink and get SQUEEZED instead
   of overflowing, so overflow-y never triggers and the panel simply has
   no scrollbar - the content below the fold becomes unreachable.
   (Bug class from 2026-07-17, fixed in five studios then; swept across
   the family on 2026-08-01.) */
#wpie-root .wpie3do-side > * {
	flex-shrink: 0;
}
