.tx-letters { --tx-border: rgba(12, 10, 9, .18); }
.tx-view { position: relative; width: 100%; aspect-ratio: 4 / 3; overflow: hidden; border-radius: .75rem; background: linear-gradient(180deg, #efece6, #e2ded6); }
.tx-stage { position: absolute; inset: 0; }
.tx-stage[hidden] { display: none; }
.tx-stage canvas { display: block; width: 100%; height: 100%; cursor: grab; }
.tx-stage canvas:active { cursor: grabbing; }
.tx-status { position: absolute; left: 50%; bottom: .75rem; translate: -50% 0; margin: 0; padding: .25rem .8rem; color: #292524; font-size: .85rem; background: rgba(255, 255, 255, .85); border-radius: 99px; white-space: nowrap; }
.tx-status[hidden] { display: none; }
.tx-enable3d { position: absolute; right: .6rem; bottom: .6rem; min-height: 2.75rem; padding: .3rem 1rem; font: inherit; font-size: .9rem; font-weight: 500; color: #fff; background: #292524; border: 0; border-radius: 99px; cursor: pointer; }
.tx-enable3d[hidden] { display: none; }
.tx-rotate-hint { margin: .5rem 0 0; color: var(--muted, #57534e); font-size: .85rem; }
.tx-letters[data-mode="flat"] .tx-rotate-hint { display: none; }

/* Without 3D: pre-rendered letters, tinted with CSS. */
.tx-flat { position: absolute; inset: 0; display: grid; place-items: center; padding: 6% 9%; }
.tx-flat[hidden] { display: none; }
.tx-flat__frame { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5%; width: 100%; height: 100%; padding: 6%; background: #f4efe6; border: 4px solid #fbf9f5; outline: clamp(8px, 2.6vw, 14px) solid #c9a57c; box-shadow: 0 10px 24px rgba(60, 40, 20, .25); }
.tx-flat__letters { display: flex; align-items: center; justify-content: center; width: 100%; height: 56%; gap: 1%; container-type: size; }
.tx-flat__letter { display: block; flex: 0 1 auto; height: min(100%, calc(100cqw / var(--tx-count) * 1.05)); cursor: pointer; background-color: var(--tx-letter-color); background-image: var(--tx-sprite); background-size: 100% 100%; background-blend-mode: multiply; -webkit-mask: var(--tx-sprite) center / 100% 100% no-repeat; mask: var(--tx-sprite) center / 100% 100% no-repeat; filter: drop-shadow(0 2px 2px rgba(50, 35, 20, .28)); }
.tx-flat__letter.is-selected { translate: 0 -3%; }
.tx-flat__space { flex: 0 0 4%; }
.tx-flat__date { padding: .1rem .7rem; color: #4a342a; font: 700 clamp(.55rem, 2.2vw, .85rem)/1.5 Georgia, serif; letter-spacing: .04em; white-space: nowrap; background: #f1d9c9; box-shadow: 0 1px 2px rgba(50, 35, 20, .25); }
.tx-flat__date[hidden] { display: none; }

/* Letter and colour choice: big enough for thumbs. */
.tx-label { display: block; font-weight: 700; margin-bottom: .4rem; }
.tx-chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.tx-chip { min-width: 2.75rem; height: 2.75rem; padding: 0 .4rem; font: 700 1rem/1 inherit; font-family: inherit; color: #1c1917; background: var(--tx-chip); border: 1px solid var(--tx-border); border-radius: .6rem; cursor: pointer; }
.tx-chip.is-selected { outline: 2px solid currentColor; outline-offset: 2px; }
.tx-letters .tx-chip.is-selected { outline-color: var(--ink, #0c0a09); }
.tx-hint { min-height: 1.5em; margin: .5rem 0 .3rem; color: var(--muted, #57534e); font-size: .9rem; }
.tx-palette { display: grid; grid-template-columns: repeat(auto-fill, minmax(2.75rem, 1fr)); gap: .45rem; }
.tx-paint { aspect-ratio: 1; min-height: 2.75rem; padding: 0; border: 1px solid var(--tx-border); border-radius: 50%; cursor: pointer; }
.tx-paint.is-selected { outline: 2px solid var(--ink, #0c0a09); outline-offset: 2px; }
/* Out of stock: visible but greyed, crossed and not clickable. */
.tx-paint.is-out, .tx-swatch-dot.is-out span:not(.screen-reader-text) { position: relative; filter: grayscale(.75); opacity: .4; background-image: linear-gradient(to top right, transparent calc(50% - 1px), #57534e calc(50% - 1px), #57534e calc(50% + 1px), transparent calc(50% + 1px)) !important; cursor: not-allowed; }
.tx-swatch-dot.is-out, .tx-swatch-dot.is-out input { cursor: not-allowed; }
.tx-color-tools { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem; margin-top: .7rem; }
.tx-all { min-height: 2.75rem; padding: .3rem .9rem; font: inherit; font-size: .9rem; color: var(--ink, #0c0a09); background: transparent; border: 1px solid var(--line, #e7e5e4); border-radius: 99px; cursor: pointer; }
.tx-auto { display: inline-flex; align-items: center; gap: .4rem; font-size: .85rem; font-weight: 400 !important; color: var(--muted, #57534e); }

/* Big letter with a name */
.tx-flat-canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.tx-flat-canvas[hidden] { display: none; }
.tx-warning { margin: .6rem 0 0; padding: .7rem .9rem; color: #7f1d1d; font-weight: 600; font-size: .95rem; background: #fef2f2; border: 1px solid #fca5a5; border-radius: .6rem; }
.tx-warning[hidden] { display: none; }
.tx-initial select { width: 100%; min-height: 3rem; padding: .5rem 1rem; font: inherit; color: inherit; background-color: transparent; border: 1px solid rgba(12, 10, 9, .35); border-radius: 99px; }
.tx-slider input[type="range"] { width: 100%; height: 2.5rem; margin: 0; accent-color: var(--ink, #0c0a09); touch-action: pan-y; }
.tx-slider label { display: flex; justify-content: space-between; gap: 1rem; }
.tx-slider output { font-weight: 400; color: var(--muted, #57534e); }
.tx-radio-swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(2.75rem, 1fr)); gap: .45rem; }
.tx-radio-swatches legend { padding: 0; margin-bottom: .5rem; font-weight: 700; }
.tx-swatch-dot { position: relative; display: block; aspect-ratio: 1; min-height: 2.75rem; cursor: pointer; }
.tx-swatch-dot input { position: absolute; inset: 0; margin: 0; opacity: 0; cursor: pointer; }
.tx-swatch-dot span:not(.screen-reader-text) { display: block; width: 100%; height: 100%; border: 1px solid var(--tx-border, rgba(12, 10, 9, .18)); border-radius: 50%; }
.tx-swatch-dot input:checked + span { outline: 2px solid var(--ink, #0c0a09); outline-offset: 2px; }
.tx-swatch-dot input:focus-visible + span { outline: 2px solid var(--ink, #0c0a09); outline-offset: 2px; }
.woocommerce div.product form.cart .button:disabled { opacity: .45; cursor: not-allowed; }
.tx-save { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; margin: .7rem 0 0; }
.tx-save-3mf, .tx-save-blender { min-height: 2.75rem; padding: .3rem 1.1rem; font: inherit; font-size: .9rem; font-weight: 500; color: var(--ink, #0c0a09); background: transparent; border: 1px solid var(--line, #d6d3d1); border-radius: 99px; cursor: pointer; }
.tx-save-3mf:disabled, .tx-save-blender:disabled { opacity: .5; cursor: progress; }
.tx-save-status { font-size: .88rem; color: var(--muted, #57534e); }

/* Edit mode: the preview locks and every touch moves the name. */
.tx-edit-layer { position: absolute; inset: 0; z-index: 3; cursor: move; touch-action: none; -webkit-user-select: none; user-select: none; }
.tx-edit-layer[hidden] { display: none; }
.tx-edit-tools { position: absolute; top: .4rem; right: .4rem; z-index: 4; display: flex; gap: .4rem; }
.tx-edit-toggle, .tx-edit-reset { position: relative; display: inline-flex; align-items: center; gap: .3rem; min-height: 2rem; padding: .2rem .7rem; font: inherit; font-size: .8rem; font-weight: 600; color: #fff; background: rgba(41, 37, 36, .88); border: 0; border-radius: 99px; cursor: pointer; box-shadow: 0 1px 4px rgba(0, 0, 0, .25); }
/* A small button with a thumb-sized touch area. */
.tx-edit-toggle::after, .tx-edit-reset::after { content: ""; position: absolute; inset: -.4rem -.15rem; }
.tx-edit-reset { color: #292524; background: rgba(255, 255, 255, .92); }
.tx-edit-reset[hidden], .tx-edit-toggle[hidden] { display: none; }
.tx-edit-status { position: absolute; left: .6rem; bottom: .6rem; z-index: 4; max-width: calc(100% - 1.2rem); margin: 0; padding: .2rem .7rem; color: #292524; font-size: .8rem; line-height: 1.35; background: rgba(255, 255, 255, .88); border-radius: 99px; pointer-events: none; }
.tx-edit-status[hidden] { display: none; }
.tx-edit-status.is-warning { color: #7f1d1d; font-weight: 600; background: #fef2f2; }
.tx-initial[data-editing="yes"] .tx-view { outline: 3px solid #292524; outline-offset: 2px; }
.tx-initial[data-editing="yes"] .tx-enable3d { display: none; }
/* The same message is inside the preview while editing. */
.tx-initial[data-editing="yes"] .tx-warning { display: none; }
/* More room to work: on phones the preview grows while editing. */
@media (max-width: 960px) {
	.tx-initial[data-editing="yes"] .tx-view { aspect-ratio: auto; height: min(72vh, 150vw); max-height: none; border-radius: .75rem; }
}

/* Pinned preview: it stays in sight while the controls scroll underneath. */
.tx-letters .tx-view, .tx-initial .tx-view { position: sticky; top: .5rem; z-index: 5; box-shadow: 0 6px 18px rgba(20, 15, 10, .16); }
.admin-bar .tx-letters .tx-view, .admin-bar .tx-initial .tx-view { top: calc(32px + .5rem); }
@media (max-width: 960px) {
	.tx-letters .tx-view, .tx-initial .tx-view { top: 0; max-height: 42vh; border-radius: 0 0 .75rem .75rem; }
	.admin-bar .tx-letters .tx-view, .admin-bar .tx-initial .tx-view { top: 46px; }
}
/* An admin bar scrolls away on small phones instead of staying fixed. */
@media (max-width: 600px) {
	.admin-bar .tx-letters .tx-view, .admin-bar .tx-initial .tx-view { top: 0; }
}
/* Not pinned in edit mode: it takes its full height, and nothing else is being scrolled. */
.tx-initial[data-editing="yes"] .tx-view { position: relative; top: auto; max-height: none; }
@media (max-width: 960px) {
	.tx-initial[data-editing="yes"] .tx-view { top: auto; height: min(72vh, 150vw); max-height: none; border-radius: .75rem; }
}
/* A focused field must not end up hidden behind the pinned preview. */
@media (max-width: 960px) {
	.tx-letters input, .tx-letters textarea, .tx-initial input, .tx-initial select, .tx-initial textarea { scroll-margin-top: 48vh; }
}
.tx-check label { display: flex; align-items: center; gap: .5rem; min-height: 2.75rem; font-weight: 400; cursor: pointer; }
.tx-check input { width: 1.25rem; height: 1.25rem; margin: 0; accent-color: var(--ink, #0c0a09); }
