/* QL-Animation Maker Styles */
@import url('../../../shared/css/variables.css');

:root {
    --list-width: 360px;
    --md-sys-spacing-2: 16px;
    --md-sys-spacing-1-5: 12px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: inherit;
}

body {
    font-family: Roboto, 'Noto Sans JP', 'Noto Sans KR', 'Noto Sans SC', 'Noto Sans Symbols', 'Noto Color Emoji', sans-serif;
    height: 100vh;
    overflow: hidden;
    transition: background-color 0.3s, color 0.3s;
    background-color: var(--maker-bg);
    color: var(--md-sys-color-on-surface);
}

body.theme-dark {
    --maker-bg: var(--md-sys-color-surface-container-low);
    --pane-bg: #1e1e1e;
    --editor-border: #444;
    --preview-bg: #000;
}

body.theme-light {
    --maker-bg: var(--md-sys-color-surface-container-low);
    --pane-bg: #fff;
    --editor-border: #ccc;
    --preview-bg: #fff;
}

#maker-app {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* Footer */
.maker-footer {
    height: var(--editor-footer-height);
    display: flex;
    align-items: center;
    background-color: var(--md-sys-color-surface-container);
    border-top: 1px solid var(--md-sys-color-outline-variant);
    padding: 0 24px;
}

.maker-footer .footer-content-wrapper {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.maker-footer .footer-left,
.maker-footer .footer-right {
    display: flex;
    gap: 12px;
    align-items: center;
}

/* Header */
.maker-header {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0 24px;
    background-color: var(--md-sys-color-surface-container);
    border-bottom: 1px solid var(--md-sys-color-outline-variant);
    z-index: 100;
    height: var(--editor-header-height);
}

.header-content-wrapper {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.back-link {
    color: var(--md-sys-color-on-surface);
    text-decoration: none;
    display: flex;
    align-items: center;
    padding: 8px;
    border-radius: 50%;
    transition: background-color 0.2s;
}

.back-link:hover {
    background-color: var(--md-sys-color-surface-container-highest);
}

.header-left h1 {
    font-size: var(--md-sys-typescale-title-large-size);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
}

.film-icon {
    font-size: 1.5rem;
    color: var(--md-sys-color-primary);
}

.theme-switch-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: 16px;
}

.theme-switch-wrapper .material-symbols-outlined {
    font-size: 1.2rem;
    color: var(--md-sys-color-on-surface-variant);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

/* Main Layout */
.maker-main {
    display: flex;
    justify-content: center;
    flex: 1;
    overflow: hidden;
    background-color: var(--md-sys-color-surface);
}

.main-content-wrapper {
    display: flex;
    overflow: hidden;
}

.list-pane {
    width: var(--list-width);
    border-right: 1px solid var(--md-sys-color-outline-variant);
    display: flex;
    flex-direction: column;
    background-color: var(--md-sys-color-surface-container-low);
    overflow: hidden;
}

.edit-pane {
    flex: 1;
    overflow-y: auto;
    padding: var(--md-sys-spacing-2);
    display: flex;
    flex-direction: column;
    gap: var(--md-sys-spacing-2);
    background-color: var(--md-sys-color-surface);
}


.section-title {
    font-size: 1rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--md-sys-color-primary);
    margin-bottom: var(--md-sys-spacing-1-5);
}

.section-title .material-symbols-outlined {
    font-size: 1.2rem;
}

/* Custom Animation List Specifics */
.category-list-section {
    flex: 1;
    margin: var(--md-sys-spacing-2);
    margin-bottom: 8px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--md-sys-spacing-1-5);
}

.header-actions {
    display: flex;
    gap: 8px;
}

.category-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.category-item {
    display: flex;
    align-items: center;
    padding: 12px;
    background-color: var(--md-sys-color-surface-container-highest);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    gap: 12px;
    border: 2px solid transparent;
    position: relative;
}

.category-item:hover {
    background-color: var(--md-sys-color-surface-variant);
}

.delete-item-btn,
.more-item-btn {
    opacity: 0;
    position: absolute;
    right: 8px;
    transition: opacity 0.2s;
}

.category-item:hover .delete-item-btn,
.category-item:hover .more-item-btn,
.category-item:focus-within .delete-item-btn,
.category-item:focus-within .more-item-btn {
    opacity: 1;
}

.category-item.active {
    border-color: var(--md-sys-color-primary);
    background-color: var(--md-sys-color-secondary-container);
}

.category-item.dragging {
    opacity: 0.4;
    background-color: var(--md-sys-color-surface-variant);
    border: 2px dashed var(--md-sys-color-outline);
}

.drop-indicator {
    height: 4px;
    background-color: var(--md-sys-color-primary);
    border-radius: 2px;
    margin: -2px 0;
    pointer-events: none;
    z-index: 10;
    transition: transform 0.1s ease;
}

.category-item .drag-handle {
    cursor: grab;
    color: var(--md-sys-color-on-surface-variant);
}

.list-footer-actions {
    margin: var(--md-sys-spacing-2);
    margin-top: 0;
    padding: 12px;
}

/* Inputs */
.input-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--md-sys-spacing-1-5);
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.input-group.full-width {
    grid-column: span 2;
}

.input-group label {
    font-size: 0.8rem;
    color: var(--md-sys-color-on-surface-variant);
}

.input-group input, .input-group select {
    padding: 10px;
    border-radius: var(--md-sys-shape-extra-small);
    border: 1px solid var(--md-sys-color-outline-variant);
    background-color: var(--md-sys-color-surface-container-lowest);
    color: var(--md-sys-color-on-surface);
    width: 100%;
}

.checkbox-container-maker {
    display: flex;
    align-items: center;
    justify-content: center;
}

.checkbox-inline-maker {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--md-sys-color-on-surface);
}

/* Drop Zone */
.drop-zone {
    border: 2px dashed var(--md-sys-color-outline-variant);
    border-radius: var(--md-sys-shape-medium);
    padding: 24px;
    text-align: center;
    cursor: pointer;
    background-color: var(--md-sys-color-surface-container-lowest);
    transition: all 0.2s ease-in-out;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.drop-zone:hover, .drop-zone.dragover {
    border-color: var(--md-sys-color-primary);
    background-color: var(--md-sys-color-primary-container);
    color: var(--md-sys-color-on-primary-container);
}

.drop-zone .cloud-icon {
    font-size: 40px;
    color: var(--md-sys-color-primary);
}

.gif-info-box {
    margin-top: 0;
    padding: 8px 16px;
    border-radius: var(--md-sys-shape-extra-small);
    background-color: var(--md-sys-color-surface-container-highest);
    font-size: 0.85rem;
    display: flex;
    gap: 16px;
    align-items: center;
    flex-wrap: wrap;
    box-shadow: none;
}

.gif-info-box.hidden {
    display: none !important;
}

.gif-info-box p {
    margin: 0;
}

/* Params Monitor */
.monitor-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.monitor-item {
    background-color: var(--md-sys-color-surface-container-highest);
    padding: 8px 12px;
    border-radius: var(--md-sys-shape-extra-small);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.monitor-label {
    font-size: 0.75rem;
    color: var(--md-sys-color-on-surface-variant);
    font-weight: 500;
}

.monitor-value {
    font-family: 'Fira Code', monospace;
    font-size: 0.9rem;
    font-weight: bold;
    color: var(--md-sys-color-primary);
}

/* Preview Section */
.boundary-controls {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
}

.boundary-controls label {
    font-size: 0.8rem;
    color: var(--md-sys-color-on-surface-variant);
}

.boundary-selector {
    display: flex;
    gap: 16px;
}

.radio-label {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-size: 0.85rem;
}

#preview-container-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    background-color: var(--md-sys-color-surface-container-lowest);
    border-radius: var(--md-sys-shape-medium);
    padding: 16px;
    border: 1px solid var(--md-sys-color-outline-variant);
}

.preview-container {
    position: relative;
    width: 100%;
    max-width: 600px;
    height: 150px;
    background-color: #000;
    overflow: hidden;
    user-select: none;
    border-radius: var(--md-sys-shape-medium);
    border: 1px solid var(--md-sys-color-outline-variant);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4), inset 0 0 1px rgba(255, 255, 255, 0.2);
    transition: background-color 0.3s, box-shadow 0.3s;
}

#animation-canvas, #raw-canvas {
    width: 100%;
    height: 100%;
    display: block;
}

/* Boundary Helpers */
.boundary-line {
    position: absolute;
    left: 0;
    width: 100%;
    height: 3px;
    border-top: 3px dashed #39ff14; /* Highly visible fluorescent green */
    z-index: 5;
    pointer-events: none;
    transition: top 0.2s ease-out;
}

/* Standard height helper line defaults (100px) */
.boundary-top, .raw-boundary-top {
    top: 25px; /* (150 - 100) / 2 */
}

.boundary-bottom, .raw-boundary-bottom {
    top: 125px; /* 150 - 25 */
}

.drag-instruction-overlay {
    position: absolute;
    bottom: 8px;
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(0, 0, 0, 0.6);
    color: rgba(255, 255, 255, 0.8);
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    gap: 6px;
    pointer-events: none;
    z-index: 10;
    opacity: 1;
    transition: opacity 0.3s ease-out;
}

.drag-instruction-overlay.fade-out {
    opacity: 0;
}

.drag-instruction-overlay .material-symbols-outlined {
    font-size: 14px;
}

/* Scale & playback controls */
.scale-buttons-container {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
    margin-top: 12px;
}

.icon-btn-large {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--md-sys-color-surface-container-highest);
    color: var(--md-sys-color-on-surface);
}

.playback-controls {
    display: flex;
    justify-content: center;
    gap: 16px;
    margin-top: 16px;
}

.playback-btn {
    min-width: 100px;
    height: 40px;
}

/* Color Palette Selector */
.color-palette {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.color-option {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid transparent;
    transition: transform 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
}

.color-option .material-symbols-outlined {
    font-size: 16px;
    opacity: 0;
}

.color-option.selected .material-symbols-outlined {
    opacity: 1;
}

.color-option:hover {
    transform: scale(1.1);
}

.color-option.selected {
    border-color: var(--md-sys-color-on-surface);
}

/* Retro Display Mode Color Options in Palette (L, C, N indicators) */
.color-option[data-color="retro-lcd"] {
    background-color: #9bbc0f !important;
    border-color: #0f380f !important;
    position: relative;
}

.color-option[data-color="retro-lcd"]::after {
    content: "L";
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #0f380f;
    font-weight: bold;
    font-size: 14px;
}

.color-option[data-color="retro-crt"] {
    background-color: #3f3 !important;
    border-color: #030c04 !important;
    position: relative;
}

.color-option[data-color="retro-crt"]::after {
    content: "C";
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #030c04;
    font-weight: bold;
    font-size: 14px;
}

.color-option[data-color="retro-nixie"] {
    background-color: #f50 !important;
    border-color: #0c0603 !important;
    position: relative;
}

.color-option[data-color="retro-nixie"]::after {
    content: "N";
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #0c0603;
    font-weight: bold;
    font-size: 14px;
}

/* Hide the letter when selected so only checkmark displays */
.color-option.selected[data-color="retro-lcd"]::after,
.color-option.selected[data-color="retro-crt"]::after,
.color-option.selected[data-color="retro-nixie"]::after {
    display: none;
}

/* Modal and Toast styling matching Studio exactly */
.modal {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}

.modal.hidden {
    display: none;
}

.modal-content {
    background-color: var(--md-sys-color-surface-container);
    padding: 24px;
    border-radius: var(--md-sys-shape-large);
    max-width: 500px;
    width: 90%;
    position: relative;
    box-shadow: var(--md-sys-elevation-3);
    display: flex;
    flex-direction: column;
}

.modal h3 {
    font-size: 1.1rem;
    font-weight: 500;
}

/* Toast */
#toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    background-color: var(--md-sys-color-inverse-surface);
    color: var(--md-sys-color-inverse-on-surface);
    padding: 12px 24px;
    border-radius: var(--md-sys-shape-full);
    z-index: 2000;
    font-size: 0.9rem;
}

#toast.hidden {
    display: none;
}

/* Button general overrides */
button {
    cursor: pointer;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.primary-btn, .secondary-btn, .danger-btn {
    padding: 12px 24px;
    border-radius: var(--md-sys-shape-full);
    font-weight: 500;
    font-size: 0.9rem;
}

.primary-btn {
    background-color: var(--md-sys-color-primary);
    color: var(--md-sys-color-on-primary);
}

.secondary-btn {
    background-color: var(--md-sys-color-secondary-container);
    color: var(--md-sys-color-on-secondary-container);
}

.primary-btn:hover, .secondary-btn:hover {
    filter: brightness(1.1);
    box-shadow: var(--md-sys-elevation-1);
    transform: translateY(-1px);
}

.primary-btn:active, .secondary-btn:active {
    transform: translateY(0);
}

/* Icon Buttons */
.icon-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: transparent;
    color: var(--md-sys-color-on-surface-variant);
}

.icon-btn:hover {
    background-color: var(--md-sys-color-surface-container-highest);
    color: var(--md-sys-color-on-surface);
}

.icon-btn:disabled {
    opacity: 0.3;
    pointer-events: none;
}

/* Classes to assist visibility */
.hidden {
    display: none !important;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
}

/* Responsive options */
@media (width <= 900px) {
    .maker-main {
        flex-direction: column;
        overflow-y: auto;
    }

    .list-pane {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--md-sys-color-outline-variant);
    }
}

/* ==========================================================================
   QL-Animation Maker Horizontal Button Controls & Retro Modes CSS
   ========================================================================== */

.control-and-info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    margin-top: 12px;
}

.control-buttons-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Overlay UI styles - Defined first to preserve correct specificity order */
.preview-overlay-base {
    position: absolute;
    inset: 0;
    z-index: 1;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 0 8px;
    pointer-events: none;
    transition: background-color 0.3s;
}

.preview-overlay-base.anim-active {
    background-color: transparent !important;
    backdrop-filter: none;
}

#preview-overlay-base {
    background-color: transparent !important;
    transition: background-color 0.3s, color 0.3s;
}

#preview-overlay-base.anim-active {
    background-color: rgba(255, 255, 255, 0.05) !important;
    color: var(--md-sys-color-on-surface) !important;
}

#preview-name-heading {
    font-size: var(--md-sys-typescale-title-medium-size);
    font-family: var(--font-family);
    font-weight: var(--font-weight-custom, var(--md-sys-typescale-title-large-weight));
    text-shadow: 0 0 4px var(--md-sys-color-surface-container-high);
    line-height: 1.2;
    margin-bottom: var(--md-sys-spacing-0-5, 4px);
    text-align: center;
    width: 100%;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--md-sys-color-on-surface);
}

.preview-timer-box {
    display: flex;
    align-items: center;
    gap: 8px;
}

.preview-elapsed {
    font-size: var(--md-sys-typescale-headline-medium-size, 1.75rem);
    font-family: var(--font-family), 'Roboto Mono', 'Courier New', monospace;
    font-weight: var(--font-weight-custom, var(--md-sys-typescale-headline-large-weight, 700));
    line-height: 1;
    text-shadow: 0 0 4px var(--md-sys-color-surface-container-high, #000);
    color: var(--md-sys-color-on-surface);
}

#preview-status-label {
    font-size: 1.5rem;
    line-height: 1;
    color: #22c55e;
}

/* Ultimate Realism Retro Display Modes CSS for Preview - Defined after general overlay styles to avoid descending-specificity violations */
#preview-container.retro-lcd {
    background-color: #9bbc0f !important;
    filter: contrast(0.92) saturate(1.1);
}

#preview-container.retro-lcd::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 10;

    /* Ultra-fine pixel grid bounds */
    background: linear-gradient(rgba(0,0,0,0.035) 1px, transparent 1px),
                linear-gradient(90deg, rgba(0,0,0,0.035) 1px, transparent 1px);
    background-size: 6px 6px; /* Sync with CELL_SIZE = 6 */
}

#preview-container.retro-lcd #preview-name,
#preview-container.retro-lcd #preview-elapsed,
#preview-container.retro-lcd #preview-status-label {
    color: #0f380f !important;
    text-shadow: 0 0 2px rgba(155, 188, 15, 0.5) !important;
}

#preview-container.retro-crt {
    background-color: #030c04 !important;
    box-shadow: var(--md-sys-elevation-1);
    animation: crt-jitter-flicker-editor 0.15s infinite;
}

#preview-container.retro-crt::before {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 10;

    /* Horizontal scanlines & vertical aperture grille slits */
    background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.28) 50%),
                linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px);
    background-size: 100% 4px, 3px 100%;
    box-shadow: inset 0 0 24px rgba(0,0,0,0.92);
}

#preview-container.retro-crt #animation-canvas {
    filter: drop-shadow(0 0 4px rgba(51, 255, 51, 0.85)) !important;
}

#preview-container.retro-crt #preview-name,
#preview-container.retro-crt #preview-elapsed,
#preview-container.retro-crt #preview-status-label {
    color: #3f3 !important;
    text-shadow: 0 0 4px rgba(51, 255, 51, 0.75) !important;
}

@keyframes crt-jitter-flicker-editor {
    0%, 100% { opacity: 0.992; }
    50% { opacity: 1.0; }
}

#preview-container.retro-nixie {
    background-color: #0c0603 !important;
    position: relative;
    filter: url("#nixie-heat-shimmer");
    animation: nixie-flicker-editor 0.2s infinite;
}

#preview-container.retro-nixie::before {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 10;

    /* Honeycomb grid / anode mesh pattern */
    background-image: radial-gradient(rgba(255, 85, 0, 0.055) 1.2px, transparent 1.2px);
    background-size: 5px 5px;
}

#preview-container.retro-nixie::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 11;

    /* Glass bulb glare highlight */
    background: linear-gradient(135deg, rgba(255,255,255,0.06) 0%, rgba(255,255,255,0.01) 40%, transparent 100%);
    border-radius: inherit;
    box-shadow: inset 0 0 32px rgba(0,0,0,0.95);
}

#preview-container.retro-nixie #animation-canvas {
    filter: drop-shadow(0 0 2px #fff) drop-shadow(0 0 6px #f50) drop-shadow(0 0 12px #ff2a00) !important;
}

#preview-container.retro-nixie #preview-name,
#preview-container.retro-nixie #preview-elapsed,
#preview-container.retro-nixie #preview-status-label {
    color: #f50 !important;
    text-shadow: 0 0 2px #fff, 0 0 6px #f50, 0 0 12px #ff2a00 !important;
}

@keyframes nixie-flicker-editor {
    0%, 100% {
        opacity: 0.99;
        filter: url("#nixie-heat-shimmer") brightness(1);
    }

    50% {
        opacity: 1.0;
        filter: url("#nixie-heat-shimmer") brightness(1.05);
    }
}

#preview-container.anim-active #animation-canvas {
    background-color: transparent !important;
}

#preview-container.retro-lcd #animation-canvas,
#preview-container.retro-crt #animation-canvas,
#preview-container.retro-nixie #animation-canvas {
    background-color: transparent !important;
}

/* Meatballs / Category Menu Styles */
.category-menu {
    position: absolute;
    background-color: var(--md-sys-color-surface-container-high);
    box-shadow: var(--md-sys-elevation-2);
    border-radius: 8px;
    padding: 8px 0;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    min-width: 120px;
}

.category-menu button {
    background: none;
    border: none;
    width: 100%;
    padding: 10px 20px;
    text-align: left;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
    font-size: 0.9rem;
    color: var(--md-sys-color-on-surface);
    cursor: pointer;
}

.category-menu button:hover {
    background-color: var(--md-sys-color-surface-variant);
}

.category-menu button.delete {
    color: var(--md-sys-color-error);
}

/* Apply button container & button */
.apply-btn {
    width: auto;
    padding: 10px 24px;
    border-radius: var(--md-sys-shape-medium, 12px);
    background: linear-gradient(135deg, #0d47a1 0%, #4a148c 100%);
    color: #fff !important;
    font-size: 0.95rem;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    transition: transform 0.2s, filter 0.2s, box-shadow 0.2s;
}

.apply-btn:hover {
    filter: brightness(1.15);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
    transform: translateY(-2px);
}

.apply-btn:active {
    transform: translateY(0);
}

/* ==========================================================================
   QL-Animation Maker Compact & Grid Restructuring Styles
   ========================================================================== */

/* Metadata layout grid */
.metadata-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.metadata-left-column {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.metadata-right-column {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.metadata-right-column .input-group {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.metadata-right-column textarea {
    flex: 1;
    resize: none;
    padding: 10px;
    border-radius: var(--md-sys-shape-extra-small);
    border: 1px solid var(--md-sys-color-outline-variant);
    background-color: var(--md-sys-color-surface-container-lowest);
    color: var(--md-sys-color-on-surface);
    font-family: inherit;
    font-size: 0.9rem;
    min-height: 100px;
}

/* Preview Layout side-by-side */
.preview-layout-container {
    display: flex;
    gap: 24px;
    align-items: stretch;
}

.animation-side-wrapper {
    flex: 1;
    min-width: 0;
}

.preview-right-side-controls {
    width: 280px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    flex-shrink: 0;
}

.boundary-selector.vertical-stack {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.color-palette.compact-multi-line {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    max-width: 280px;
}

.color-palette.compact-multi-line .color-option {
    width: 28px;
    height: 28px;
}

/* Settings Layout side-by-side */
.config-layout-container {
    display: flex;
    gap: 24px;
    align-items: stretch;
}

.config-left-side {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.config-right-side-controls {
    width: 280px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    flex-shrink: 0;
}

#raw-preview-container-wrapper {
    margin-bottom: 0 !important;
    padding: 16px;
    background-color: var(--md-sys-color-surface-container-lowest);
    border-radius: var(--md-sys-shape-medium);
    border: 1px solid var(--md-sys-color-outline-variant);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.specs-vertical-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px 16px;
    background-color: var(--md-sys-color-surface-container-lowest);
    border: 1px solid var(--md-sys-color-outline-variant);
    border-radius: var(--md-sys-shape-medium);
}

.spec-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
}

.spec-label {
    color: var(--md-sys-color-on-surface-variant);
    font-weight: 500;
}

.spec-value {
    font-family: 'Fira Code', monospace;
    font-weight: bold;
    color: var(--md-sys-color-primary);
}

.playback-scale-control-group {
    background-color: var(--md-sys-color-surface-container-lowest);
    border: 1px solid var(--md-sys-color-outline-variant);
    border-radius: var(--md-sys-shape-medium);
    padding: 12px;
}

.playback-scale-control-group label {
    font-size: 0.8rem;
    color: var(--md-sys-color-on-surface-variant);
    margin-bottom: 8px;
    display: block;
}

.playback-scale-rows {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.playback-scale-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.playback-scale-row.upper-row {
    justify-content: center;
}

.playback-scale-row.upper-row #btn-play-pause {
    width: 100px;
    border-radius: var(--md-sys-shape-full);
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.playback-scale-row.lower-row {
    justify-content: center;
}

.playback-scale-row.lower-row #mon-scale {
    font-size: 0.95rem;
    font-weight: bold;
    color: var(--md-sys-color-on-surface-variant);
    min-width: 60px;
    text-align: center;
    display: inline-block;
}

.operation-vertical-stack {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.switch-group-vertical {
    display: flex;
    flex-direction: column;
    gap: 10px;
    background-color: var(--md-sys-color-surface-container-lowest);
    border: 1px solid var(--md-sys-color-outline-variant);
    border-radius: var(--md-sys-shape-medium);
    padding: 12px;
}

.switch-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

body.theme-light .preview-container {
    background-color: #f0f0f0;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15), inset 0 0 1px rgba(0, 0, 0, 0.1);
}

body.theme-light #preview-container.anim-active:not(.retro-lcd, .retro-crt, .retro-nixie) {
    background-color: #fff !important;
}

/* Responsiveness overrides for narrower viewports */
@media (width <= 1200px) {
    .preview-layout-container,
    .config-layout-container {
        flex-direction: column;
        gap: 16px;
    }

    .preview-right-side-controls,
    .config-right-side-controls {
        width: 100%;
        max-width: 100%;
    }
}
