@font-face {
    font-family: "BC Montserrat";
    src: url("/api/text-fonts/Montserrat-Bold.ttf") format("truetype");
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: "BC Bebas Neue";
    src: url("/api/text-fonts/BebasNeue-Regular.ttf") format("truetype");
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: "BC Oswald";
    src: url("/api/text-fonts/Oswald-Bold.ttf") format("truetype");
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: "BC Anton";
    src: url("/api/text-fonts/Anton-Regular.ttf") format("truetype");
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: "BC Archivo Black";
    src: url("/api/text-fonts/ArchivoBlack-Regular.ttf") format("truetype");
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: "BC Russo One";
    src: url("/api/text-fonts/RussoOne-Regular.ttf") format("truetype");
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: "BC Playfair Display";
    src: url("/api/text-fonts/PlayfairDisplay-Bold.ttf") format("truetype");
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: "BC Libre Baskerville";
    src: url("/api/text-fonts/LibreBaskerville-Bold.ttf") format("truetype");
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: "BC Cinzel";
    src: url("/api/text-fonts/Cinzel-Bold.ttf") format("truetype");
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}
.text-track {
    position: relative;
    height: 16px;
    margin: 0 0 2px;
    background: rgba(167,139,250,0.08);
    border: 1px dashed rgba(167,139,250,0.4);
    border-radius: 3px;
    box-sizing: border-box;
}
.text-block {
    position: absolute;
    top: 1px;
    height: 14px;
    background: rgba(76, 29, 149, 0.72);
    color: #ede9fe;
    border: 1px solid rgba(167, 139, 250, 0.85);
    border-radius: 3px;
    font-size: 10px;
    font-weight: 700;
    line-height: 14px;
    overflow: hidden;
    white-space: nowrap;
    cursor: grab;
    box-sizing: border-box;
    z-index: 2;
    user-select: none;
}
.text-block.selected { outline: 1px solid #fff; }
.text-block .text-block-label {
    display: block;
    padding: 0 8px;
    pointer-events: none;
    overflow: hidden;
    text-overflow: ellipsis;
}
.text-trim {
    position: absolute;
    top: 0;
    width: 7px;
    height: 100%;
    cursor: ew-resize;
    z-index: 3;
}
.text-trim.l { left: 0; }
.text-trim.r { right: 0; }
.text-editor-bar {
    display: none;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    background: #12121c;
    border-top: 1px solid rgba(167,139,250,0.35);
    flex-wrap: wrap;
}
.text-editor-bar.open { display: flex; }
.text-editor-bar input[type="text"] {
    flex: 1;
    min-width: 140px;
    background: #0d0d16;
    color: #fff;
    border: 1px solid rgba(255,255,255,0.16);
    border-radius: 4px;
    padding: 4px 8px;
    font-family: inherit;
    font-size: 13px;
}
.text-editor-bar select,
.text-editor-bar button {
    background: #0d0d16;
    color: #ddd;
    border: 1px solid rgba(255,255,255,0.16);
    border-radius: 4px;
    padding: 4px 6px;
    font-family: inherit;
    font-size: 12px;
}
.text-editor-bar label {
    color: #aaa;
    font-size: 11px;
    display: flex;
    align-items: center;
    gap: 4px;
}
.text-overlay-layer {
    position: absolute;
    overflow: hidden;
    pointer-events: none;
    z-index: 12;
}
.text-preview-item {
    position: absolute;
    transform: translate(-50%, -50%);
    display: flex;
    align-items: center;
    cursor: grab;
    user-select: none;
    pointer-events: auto;
}
.text-preview-label {
    display: block;
    outline: none;
    cursor: text;
    user-select: text;
    white-space: pre;
    paint-order: stroke fill;
    font-synthesis: weight style;
    min-width: 0.4em;
    min-height: 1.2em;
}
.text-preview-label:not(:focus) {
    cursor: move;
}
.text-preview-item.selected {
    outline: 1px solid #c4b5fd;
    outline-offset: 4px;
}
.text-preview-item.has-box {
    border-radius: 2px;
}
.text-preview-item img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    pointer-events: none;
}
.text-scale-handle,
.text-rot-handle {
    position: absolute;
    width: 8px;
    height: 8px;
    background: #fff;
    border: 1px solid #8b5cf6;
    display: none;
    z-index: 3;
    box-sizing: border-box;
}
.text-preview-item.selected .text-scale-handle { display: block; }
.text-scale-handle.tl { left: 0; top: 0; transform: translate(-50%, -50%); cursor: nwse-resize; }
.text-scale-handle.tr { right: 0; top: 0; transform: translate(50%, -50%); cursor: nesw-resize; }
.text-scale-handle.bl { left: 0; bottom: 0; transform: translate(-50%, 50%); cursor: nesw-resize; }
.text-scale-handle.br { right: 0; bottom: 0; transform: translate(50%, 50%); cursor: nwse-resize; }
.text-rot-handle {
    left: 50%;
    top: 0;
    transform: translate(-50%, -16px);
    border-radius: 50%;
    cursor: grab;
}
.text-overlay-layer.alt-rotate .text-preview-item.selected .text-rot-handle { display: block; }
.text-overlay-layer.alt-rotate .text-preview-item.selected .text-scale-handle { display: none; }
#textPicturePrompt {
    width: 100%;
    box-sizing: border-box;
    min-height: 64px;
    margin-bottom: 8px;
}
.title-place-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 0 0 8px;
    align-items: center;
}
.title-font-row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 0 0 10px;
}
.title-font-row .fx-var-select {
    flex: 1 1 auto;
    min-width: 0;
    width: auto;
}
.title-font-row .fx-list-mode-btn {
    padding: 4px 8px;
}
.title-file-name {
    text-align: left;
    margin: -4px 0 6px;
    overflow: hidden;
    text-overflow: ellipsis;
}
.title-ai-actions .fx-act-fill {
    flex: 1 1 auto;
}
#textEditorBold { font-weight: 700; }
#textEditorItalic { font-style: italic; }
.title-swatches {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 2px 0 6px;
}
.title-swatch {
    width: 18px;
    height: 18px;
    border-radius: 4px;
    border: 1px solid rgba(255,255,255,0.28);
    padding: 0;
    cursor: pointer;
}
.title-swatch.on {
    outline: 1px solid #fff;
    outline-offset: 1px;
}
#titleBody {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 12px;
    align-content: start;
    padding: 12px;
}
#textEditorTextSection,
#textEditorBackSection,
#titleAiCol,
#textEditorMoveSection {
    min-width: 0;
    padding: 10px 12px;
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 8px;
    background: rgba(255,255,255,0.03);
}
/* The sliders in the title columns need air between them. */
#titleBody .fx-param-label {
    margin: 14px 0 4px;
    font-size: 10px;
}
#titleBody .fx-param-label:first-child {
    margin-top: 0;
}
#titleBody .fx-param-row {
    min-height: 22px;
}
#titleBody .fx-param-range {
    height: 16px;
}
.title-col-idle {
    opacity: 0.4;
    pointer-events: none;
}
#titleAiCol textarea {
    width: 100%;
    box-sizing: border-box;
    min-height: 220px;
    margin-bottom: 8px;
}
.title-scale {
    margin: 0 0 8px;
}
.title-sv {
    position: relative;
    height: 99px;
    border-radius: 8px;
    cursor: crosshair;
    border: 1px solid rgba(255,255,255,0.18);
    background-image:
        linear-gradient(to top, #000, transparent),
        linear-gradient(to right, #fff, transparent);
    background-color: #f00;
    touch-action: none;
}
.title-sv-knob {
    position: absolute;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 2px solid #fff;
    box-shadow: 0 0 0 1px rgba(0,0,0,0.65);
    transform: translate(-50%, -50%);
    pointer-events: none;
}
.title-hue {
    -webkit-appearance: none;
    appearance: none;
    display: block;
    width: 100%;
    height: 18px;
    margin: 8px 0 0;
    border-radius: 9px;
    border: none;
    background: linear-gradient(to right, #f00 0%, #ff0 17%, #0f0 33%, #0ff 50%, #00f 67%, #f0f 83%, #f00 100%);
    cursor: pointer;
}
.title-hue::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    border: 2px solid #1e1b2e;
    box-shadow: 0 0 0 1px rgba(255,255,255,0.35);
}
.title-hue::-moz-range-track {
    height: 18px;
    border: none;
    border-radius: 9px;
    background: linear-gradient(to right, #f00 0%, #ff0 17%, #0f0 33%, #0ff 50%, #00f 67%, #f0f 83%, #f00 100%);
}
.title-hue::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border: 2px solid #1e1b2e;
    border-radius: 50%;
    background: #fff;
}

.title-layer-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    padding: 8px 12px 0;
}
.title-layer-label {
    margin: 0 4px 0 0;
}

.fx-list-mode-btn.title-busy,
.fx-list-mode-btn.title-busy:hover,
.fx-list-mode-btn.title-busy:disabled {
    background-color: #2a2445;
    color: #fff;
    border-color: rgba(167,139,250,0.7);
    opacity: 1;
    cursor: progress;
    background-image: linear-gradient(to right, #8b5cf6 0, #a78bfa var(--p, 0%), rgba(255,255,255,0.05) var(--p, 0%));
    transition: background-image 0.2s linear;
}

.text-pic-clip {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
    pointer-events: none;
}
.text-pic-clip img {
    display: block;
    max-width: none;
}
.text-crop-handle {
    position: absolute;
    left: 50%;
    width: 34px;
    height: 8px;
    margin-left: -17px;
    border-radius: 4px;
    background: #fff;
    border: 1px solid #8b5cf6;
    display: none;
    z-index: 3;
    cursor: ns-resize;
    box-sizing: border-box;
}
.text-crop-handle.top { top: -4px; }
.text-crop-handle.bottom { bottom: -4px; }
.text-overlay-layer.ctrl-crop .text-preview-item.selected .text-crop-handle { display: block; }
.text-overlay-layer.ctrl-crop .text-preview-item.selected .text-scale-handle { display: none; }
.title-pair {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}
#textEditorMoveSection > .title-pair { margin-top: 14px; gap: 10px; }
#textCropGroup { margin-top: 14px; }
#textCropGroup .title-pair { margin-top: 4px; }
#textCropGroup .title-pair .fx-param-label { margin-top: 6px; }
.title-hint {
    margin-left: 6px;
    color: #a78bfa;
    font-weight: 600;
    opacity: 0.85;
}
.title-phase {
    min-width: 0;
    padding: 8px 10px 10px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 8px;
}
.title-phase-head {
    display: flex;
    gap: 6px;
}
.title-phase select {
    width: 100%;
}
.title-phase-off > :not(.title-phase-head) {
    opacity: 0.4;
    pointer-events: none;
}
#textPictureEdit:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}
