/* =====================================================
   SCENE CREATOR — preset preview controls
   Border radius / box shadow / text shadow swatches for
   chat-scene-creator.html. Loaded after wildcat-theme.css so the
   Post-Industrial Modernism tokens (--background-color, --primary-color,
   --border-color, --shadow-sm/md/lg, sharp corners) are already set.

   Kept as real classes (not per-element inline styles) so the presets are
   restylable in one place; only the data-driven preview value itself
   (the actual border-radius / box-shadow / text-shadow being previewed)
   is still set inline by chat-scene-creator.js, since that value comes
   straight from UIHelpers.getBoxShadowValue()/getTextShadowValue() and
   must never drift from what gets applied to the real overlay.
   ===================================================== */

.preset-group {
    display: flex;
    gap: var(--spacing-sm, 8px);
    flex-wrap: wrap;
}

.preset-btn {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-xs, 4px);
    padding: var(--spacing-xs, 4px);
    background: var(--panel-color, #0a0a0a);
    color: var(--text-color, #ffffff);
    border: 2px solid var(--border-color, #333333);
    border-radius: 0;
    cursor: pointer;
    font-family: inherit;
    font-size: 11px;
    line-height: 1.2;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.preset-btn:hover {
    border-color: var(--primary-color, #fffdd9);
}

.preset-btn:focus-visible {
    outline: 2px solid var(--primary-color, #fffdd9);
    outline-offset: 2px;
}

.preset-btn.active {
    border-color: var(--primary-color, #fffdd9);
    box-shadow: var(--shadow-sm, 3px 3px 0 rgba(255, 255, 255, 0.15));
}

.preset-label {
    display: block;
    font-size: 10px;
    opacity: 0.8;
    white-space: nowrap;
}

/* --- Border radius: the swatch IS the radius, no icon asset needed --- */
.preset-btn.radius-btn {
    width: 64px;
    height: 64px;
    padding: var(--spacing-sm, 8px);
}

.radius-swatch {
    display: block;
    width: 100%;
    height: 100%;
    border: 3px solid var(--text-color, #ffffff);
    box-sizing: border-box;
}

/* --- Box shadow: a light tile on a mid-tone stage, so a dark shadow is
   actually visible. A dark shadow blurring straight off a light tile onto
   this page's near-black button background reads as almost nothing — the
   shadow and the backdrop are nearly the same color. Giving the tile a
   mid-grey "stage" to sit on (like a product photo backdrop) gives every
   preset's shadow, even the faint low-opacity ones, a surface it visibly
   contrasts against. --- */
.preset-btn.shadow-btn {
    width: 88px;
    padding: 16px var(--spacing-sm, 8px) 10px;
    /* The "sharp" preset offsets 8px with no blur, and "intense3d" blurs out
       ~20px — keep room for both to render fully instead of clipping. */
    overflow: visible;
}

.shadow-stage {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 34px;
    margin: 0 auto;
    background: #c9c9c9;
}

.shadow-tile {
    display: block;
    width: 26px;
    height: 16px;
    background: #fafafa;
}

/* --- Text shadow: light text over a mid-tone chip, real shadow applied.
   Sized well above the overlay's own chat text so a 1-2px preset shadow is
   still a legible fraction of the glyph instead of disappearing at 12px. --- */
.preset-btn.text-shadow-btn {
    width: 88px;
    padding: 10px var(--spacing-sm, 8px);
    /* The "glow" preset blurs up to 24px past the glyph edges. */
    overflow: visible;
}

.text-shadow-sample {
    display: block;
    min-width: 48px;
    padding: 6px 10px;
    background: #9a9a9a;
    color: #ffffff;
    font-weight: 800;
    font-size: 24px;
    line-height: 1;
}

/* --- Color Picker Swatch & Hex Control --- */
.color-control-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
}

input[type="color"],
.color-picker-swatch {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    width: 38px !important;
    height: 30px !important;
    padding: 2px !important;
    border: 1px solid var(--border-color, #444) !important;
    border-radius: 4px !important;
    background-color: transparent !important;
    cursor: pointer;
    flex-shrink: 0;
    box-sizing: border-box;
}

input[type="color"]::-webkit-color-swatch-wrapper,
.color-picker-swatch::-webkit-color-swatch-wrapper {
    padding: 0 !important;
    background-color: transparent !important;
    border-radius: 2px;
}

input[type="color"]::-webkit-color-swatch,
.color-picker-swatch::-webkit-color-swatch {
    border: 1px solid rgba(255, 255, 255, 0.25) !important;
    border-radius: 2px !important;
}

input[type="color"]::-moz-color-swatch,
.color-picker-swatch::-moz-color-swatch {
    border: 1px solid rgba(255, 255, 255, 0.25) !important;
    border-radius: 2px !important;
}

input[type="color"]:disabled,
.color-picker-swatch:disabled {
    opacity: 1 !important;
    filter: none !important;
    cursor: not-allowed;
}

input[type="color"]:disabled::-webkit-color-swatch-wrapper,
.color-picker-swatch:disabled::-webkit-color-swatch-wrapper,
input[type="color"]:disabled::-webkit-color-swatch,
.color-picker-swatch:disabled::-webkit-color-swatch {
    opacity: 1 !important;
    filter: none !important;
}

.color-hex-input {
    width: 85px !important;
    font-family: monospace !important;
    font-size: 13px !important;
    text-transform: uppercase;
    text-align: center;
}

/* --text-muted had no definition anywhere in src/, so the #a1a1aa literal was
   always what rendered. Defined here (this stylesheet is loaded only by the
   scene creator, so the name can't collide with the overlay's own tokens) and
   given a real light-scheme value: #a1a1aa on the near-white light panel is
   2.5:1, nowhere near the 4.5:1 that 12.8px text needs. */
:root {
    --text-muted: #a1a1aa;   /* 7.5:1 on the dark section background */
}

@media (prefers-color-scheme: light) {
    :root {
        --text-muted: #6b6b74;   /* 5.1:1 on the light section background */
    }
}

/* Help text is a sibling of the row it describes, so it lines itself up with
   the control column by reading --control-offset, which the label column also
   drives (see .settings-section in styles.css), instead of hard-coding 196px.
   When the row stacks, --control-offset goes to 0 and this follows.
   --help-indent is set inline by creator-form-renderer for indented subfields.

   No `opacity` here. Compositing at 0.75 dropped this to 1.9:1 in light mode,
   and container opacity silently drags down every descendant with it — the
   inline-coloured help link was landing at 2.3:1 the same way. Muting is the
   colour token's job so each piece can be checked on its own. */
.help-text {
    font-size: 0.8em;
    color: var(--text-muted);
    margin-top: -4px;
    margin-bottom: 8px;
    /* 0px fallback, not 196px: outside a .settings-section there is no label
       column, and a phantom indent would be the silent failure mode. */
    margin-left: calc(var(--control-offset, 0px) + var(--help-indent, 0px));
}

/* Once the settings rows stack, the theme carousel's name/description block has
   the full row width available — give it its own line above the arrows rather
   than letting flex-wrap strand the two arrows on separate rows. Keyed to the
   workspace container declared in styles.css; on chat.html, which loads this
   carousel without that stylesheet, no such container exists and the query
   simply never matches. */
@container workspace (max-width: 28rem) {
    #theme-info-and-nav {
        justify-content: center;
    }

    /* Two IDs deliberately: theme-carousel.css loads after this file and its
       `flex: 1 1 7rem` shorthand would otherwise reset the basis set here. */
    #theme-info-and-nav > #theme-details {
        order: -1;
        flex-basis: 100%;
        margin: 0 0 6px;
    }
}

/* --- Live Preview Background Picker --- */
.live-preview-box {
    max-width: 100%;
}

.preview-header {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    margin-bottom: 8px;
}

.preview-header h3 {
    margin: 0;
    font-size: 1.1em;
}

.preview-bg-picker {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    width: 100%;
    box-sizing: border-box;
}

.preview-bg-label {
    color: var(--text-color, #ffffff);
    opacity: 0.8;
    font-weight: 500;
    font-size: 12px;
    white-space: nowrap;
}

.preview-bg-options {
    display: inline-flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 3px;
    background: var(--secondary-color, rgba(0, 0, 0, 0.4));
    padding: 3px;
    border: 1px solid var(--border-color, #333);
    border-radius: 4px;
    box-sizing: border-box;
}

@media (prefers-color-scheme: light) {
    .preview-bg-options {
        background: var(--secondary-color, #f0f0f0);
    }
}

.preview-bg-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 3px 7px;
    /* 11px text on 3px padding rendered these 21px tall — under the 24px
       minimum pointer target. The floor doesn't change the visual weight
       because the swatch and label are centred inside it. */
    min-height: 24px;
    background: transparent;
    color: var(--text-color, #ffffff);
    border: 1px solid transparent;
    border-radius: 3px;
    cursor: pointer;
    font-family: inherit;
    font-size: 11px;
    font-weight: 500;
    line-height: 1.2;
    white-space: nowrap;
    transition: all 0.15s ease;
    overflow: hidden;
}

.preview-bg-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
}

@media (prefers-color-scheme: light) {
    .preview-bg-btn:hover {
        background: rgba(0, 0, 0, 0.08);
        border-color: rgba(0, 0, 0, 0.15);
    }
}

.preview-bg-btn.active {
    background: var(--panel-color, #1a1a1a);
    border-color: var(--primary-color, #fffdd9);
    color: var(--primary-color, #fffdd9);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

@media (prefers-color-scheme: light) {
    .preview-bg-btn.active {
        background: var(--panel-color, #ffffff);
        border-color: var(--primary-color, #1a1a1a);
        color: var(--text-color, #050505);
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
    }
}

.preview-color-input {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
    border: none;
    padding: 0;
    margin: 0;
}

.bg-swatch {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 2px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    flex-shrink: 0;
    pointer-events: none;
}

.bg-swatch.dark-swatch {
    background: #000000;
}

.bg-swatch.light-swatch {
    background: #ffffff;
    border-color: #999999;
}

.bg-swatch.checkerboard-swatch {
    background-image: repeating-conic-gradient(#888888 0% 25%, #444444 0% 50%);
    background-size: 6px 6px;
}

.bg-swatch.custom-swatch {
    background: #121212;
}

.preview-iframe-container.bg-checkerboard {
    background-color: #1a1a1a !important;
    background-image: repeating-conic-gradient(#2b2b2b 0% 25%, #141414 0% 50%) !important;
    background-size: 20px 20px !important;
}

/* OBS Tip Banner */
.obs-tip-banner {
    margin-top: 12px;
    margin-bottom: 16px;
    padding: 10px 12px;
    background: rgba(145, 71, 255, 0.08);
    border: 1px solid rgba(145, 71, 255, 0.22);
    border-radius: 6px;
    font-size: 13px;
    color: var(--text-color, #e4e4e7);
    line-height: 1.4;
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.obs-tip-icon {
    color: #eab308;
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    margin-top: 1px;
}
/* =====================================================
   FONT PICKER — search dropdown for createFontPicker()
   Mirrors the font search dropdown from config-panel.css
   so the standalone font picker used in the creator form
   gets the same treatment: searchable input, Google Fonts
   remote results, loading spinner, section labels, etc.
   ===================================================== */

.font-picker-wrapper {
    position: relative;
}

.font-picker-input {
    width: 100%;
    box-sizing: border-box;
}

/* The base state is hidden; FontManager toggles the .visible class */
.font-search-results {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    max-height: 240px;
    overflow-y: auto;
    background-color: var(--panel-color, #0a0a0a);
    border: 1px solid var(--primary-color, #fffdd9);
    border-top: none;
    border-radius: 0 0 4px 4px;
    z-index: 1100;
    scrollbar-width: thin;
    scrollbar-color: #555 var(--panel-color, #0a0a0a);
}

.font-search-results.visible {
    display: block;
}

.font-search-result {
    padding: 6px 10px;
    cursor: pointer;
    font-size: 13px;
    color: var(--text-muted, #a1a1aa);
    border-bottom: 1px solid var(--border-color, #333);
    transition: background-color 0.15s ease;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.font-search-result:last-child {
    border-bottom: none;
}

.font-search-result:hover,
.font-search-result.highlighted {
    background-color: rgba(255, 253, 217, 0.12);
    color: var(--text-color, #ffffff);
}

@media (prefers-color-scheme: light) {
    .font-search-result:hover,
    .font-search-result.highlighted {
        background-color: rgba(0, 0, 0, 0.08);
        color: var(--text-color, #050505);
    }
}

.font-search-result .font-category {
    font-size: 10px;
    color: var(--text-muted, #71717a);
    margin-left: 6px;
    font-family: var(--font-sans);
}

.font-search-section-label {
    padding: 5px 10px;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted, #71717a);
    background-color: var(--background-color, #000000);
    border-bottom: 1px solid var(--border-color, #333);
    font-family: var(--font-sans);
    user-select: none;
}

.font-search-loading {
    padding: 8px 10px;
    font-size: 12px;
    color: var(--text-muted, #71717a);
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: var(--font-sans);
}

.font-search-loading .mini-spinner {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid var(--border-color, #333);
    border-top-color: var(--primary-color, #fffdd9);
    animation: spin 0.8s infinite linear;
    flex-shrink: 0;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

@media (prefers-color-scheme: light) {
    input[type="color"]::-webkit-color-swatch,
    .color-picker-swatch::-webkit-color-swatch {
        border: 1px solid rgba(0, 0, 0, 0.2) !important;
    }

    input[type="color"]::-moz-color-swatch,
    .color-picker-swatch::-moz-color-swatch {
        border: 1px solid rgba(0, 0, 0, 0.2) !important;
    }
}

.range-val-display {
    min-width: 38px;
    text-align: right;
    margin-right: 12px;
    font-size: 13px;
    font-variant-numeric: tabular-nums;
    opacity: 0.9;
}

/* "Save Current Settings as Preset", directly beneath the theme carousel */
.theme-preset-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin: 4px 0 12px 0;
}

.theme-preset-actions #creatorPresetStatus {
    font-size: 12px;
    opacity: 0.7;
}

.creator-subcard,
.creator-bg-image-box {
    margin-top: 12px;
    margin-bottom: 16px;
    padding: 12px;
    background: var(--bg-secondary, #1a1a1a);
    border: 1px solid var(--border-color, #333333);
    border-radius: var(--border-radius-md, 6px);
    color: var(--text-color, #ffffff);
}

@media (prefers-color-scheme: light) {
    .creator-subcard,
    .creator-bg-image-box {
        background: var(--bg-secondary, #f4f4f5);
        border-color: var(--border-color, #e4e4e7);
        color: var(--text-color, #050505);
    }
}

/* =====================================================
   TOAST NOTIFICATIONS (Save & Sync Feedback)
   ===================================================== */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 400px;
    width: calc(100vw - 48px);
    pointer-events: none;
}

.toast-notification {
    pointer-events: auto;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
    background: var(--panel-color, #0a0a0a);
    color: var(--text-color, #ffffff);
    border: 2px solid var(--border-color, #333333);
    border-left-width: 5px;
    box-shadow: var(--shadow-md, 5px 5px 0 rgba(255, 255, 255, 0.18));
    animation: toastSlideIn 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    position: relative;
    box-sizing: border-box;
}

.toast-notification.toast-hiding {
    animation: toastFadeOut 0.2s cubic-bezier(0.7, 0, 0.84, 0) forwards;
}

.toast-notification.toast-success {
    border-left-color: var(--success-color, #4caf50);
}
.toast-notification.toast-success .toast-icon-wrapper {
    color: var(--success-color, #4caf50);
}

.toast-notification.toast-warning {
    border-left-color: var(--warning-color, #ffb300);
}
.toast-notification.toast-warning .toast-icon-wrapper {
    color: var(--warning-color, #ffb300);
}

.toast-notification.toast-error {
    border-left-color: var(--danger-color, #ef5350);
}
.toast-notification.toast-error .toast-icon-wrapper {
    color: var(--danger-color, #ef5350);
}

.toast-notification.toast-info {
    border-left-color: var(--primary-color, #fffdd9);
}
.toast-notification.toast-info .toast-icon-wrapper {
    color: var(--primary-color, #fffdd9);
}

.toast-icon-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-top: 1px;
}

.toast-content {
    flex: 1;
    min-width: 0;
}

.toast-title {
    font-weight: 700;
    font-size: 14px;
    line-height: 1.3;
    margin-bottom: 2px;
}

.toast-message {
    font-size: 13px;
    line-height: 1.4;
    opacity: 0.85;
    word-break: break-word;
}

.toast-close {
    background: transparent;
    border: none;
    color: var(--text-color, #ffffff);
    opacity: 0.6;
    font-size: 20px;
    line-height: 1;
    padding: 0 4px;
    cursor: pointer;
    margin-left: 4px;
    transition: opacity 0.15s ease;
    flex-shrink: 0;
    /* A bare 20px glyph on zero vertical padding is a ~20x13 hit area; give the
       dismiss control the 24px minimum without enlarging the glyph itself. */
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 24px;
    min-height: 24px;
}

.toast-close:hover {
    opacity: 1;
}

.spin {
    animation: spin 0.8s linear infinite;
    display: inline-block;
}

@keyframes toastSlideIn {
    from {
        opacity: 0;
        transform: translateY(16px) scale(0.96);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes toastFadeOut {
    from {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    to {
        opacity: 0;
        transform: translateY(-8px) scale(0.95);
    }
}

/* =====================================================
   DIRTY STATE (Unsaved Changes) STYLING
   ===================================================== */
.btn-primary.btn-dirty {
    background: #e6c845 !important;
    color: #050505 !important;
    border-color: #f5e06b !important;
    box-shadow: 0 0 10px rgba(255, 253, 217, 0.4), var(--shadow-md, 5px 5px 0 rgba(255, 255, 255, 0.18)) !important;
    animation: dirtyPulse 2s infinite ease-in-out;
}

.unsaved-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: rgba(0, 0, 0, 0.25);
    color: #050505;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 12px;
    margin-left: 8px;
    letter-spacing: 0.3px;
    text-transform: uppercase;
}

@media (prefers-color-scheme: light) {
    .btn-primary.btn-dirty {
        background: #27272a !important;
        color: #fffdd9 !important;
    }
    .unsaved-badge {
        background: rgba(255, 255, 255, 0.2);
        color: #fffdd9;
    }
}

.unsaved-title-badge {
    font-size: 12px;
    font-weight: 700;
    color: var(--warning-color, #ffb300);
    background: rgba(255, 179, 0, 0.12);
    border: 1px solid var(--warning-color, #ffb300);
    padding: 2px 8px;
    border-radius: 12px;
    margin-left: 10px;
    vertical-align: middle;
    letter-spacing: 0.3px;
    text-transform: uppercase;
    /* Keep the dot and its label together on one line */
    white-space: nowrap;
}

.unsaved-dot {
    color: var(--warning-color, #ffb300);
    font-size: 11px;
    margin-left: 4px;
    vertical-align: middle;
    display: inline-block;
    animation: dirtyDotFade 1.5s infinite ease-in-out;
}

@keyframes dirtyPulse {
    0%, 100% {
        box-shadow: 0 0 4px rgba(255, 253, 217, 0.2), var(--shadow-sm, 3px 3px 0 rgba(255, 255, 255, 0.15));
    }
    50% {
        box-shadow: 0 0 14px rgba(255, 253, 217, 0.5), var(--shadow-md, 5px 5px 0 rgba(255, 255, 255, 0.18));
    }
}

@keyframes dirtyDotFade {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.4; transform: scale(0.85); }
}



