:root {
    color-scheme: light;
    --accent: #f97316;
    --accent-hover: #ea580c;
    --accent-soft: #fff1e8;
    --accent-ink: #9a3412;
    --app-bg: #f5f5f7;
    --surface: #ffffff;
    --surface-raised: #ffffff;
    --surface-muted: #f5f5f7;
    --surface-hover: #eeeeef;
    --text: #1d1d1f;
    --text-secondary: #6e6e73;
    --text-tertiary: #8e8e93;
    --border: rgba(29, 29, 31, 0.12);
    --border-strong: rgba(29, 29, 31, 0.2);
    --stage: #e8e8ed;
    --canvas-surround: #151516;
    --danger: #d70015;
    --success: #218739;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 8px 30px rgba(0, 0, 0, 0.1);
    --shadow-canvas: 0 22px 60px rgba(0, 0, 0, 0.28);
    --radius: 8px;
}

#canvasPanLockBtn .canvas-pan-locked-icon,
#canvasPanLockBtn.active .canvas-pan-unlocked-icon {
    display: none;
}

#canvasPanLockBtn.active .canvas-pan-locked-icon {
    display: block;
}

#canvasPanLockBtn.active {
    border-color: var(--accent);
    background: var(--accent-soft);
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 20%, transparent);
    color: var(--accent-ink);
}

:root[data-theme="dark"] {
    color-scheme: dark;
    --accent: #ff8a30;
    --accent-hover: #ff9f5a;
    --accent-soft: #3a2418;
    --accent-ink: #ffb17a;
    --app-bg: #0b0b0c;
    --surface: #161617;
    --surface-raised: #1d1d1f;
    --surface-muted: #242426;
    --surface-hover: #2c2c2e;
    --text: #f5f5f7;
    --text-secondary: #a1a1a6;
    --text-tertiary: #7d7d83;
    --border: rgba(255, 255, 255, 0.11);
    --border-strong: rgba(255, 255, 255, 0.19);
    --stage: #101011;
    --canvas-surround: #050506;
    --danger: #ff453a;
    --success: #32d74b;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 12px 40px rgba(0, 0, 0, 0.4);
    --shadow-canvas: 0 24px 70px rgba(0, 0, 0, 0.52);
}

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

html,
body {
    width: 100%;
    min-width: 320px;
    min-height: 100%;
}

body {
    overflow: hidden;
    background: var(--app-bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    font-size: 14px;
    letter-spacing: 0;
    -webkit-font-smoothing: antialiased;
}

button,
input,
select,
textarea {
    color: inherit;
    font: inherit;
    letter-spacing: 0;
}

button {
    border: 0;
}

button,
select,
input[type="file"],
input[type="color"],
input[type="range"] {
    cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 3px solid color-mix(in srgb, var(--accent) 35%, transparent);
    outline-offset: 1px;
}

svg {
    display: block;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.8;
}

[hidden] {
    display: none !important;
}

.app-shell {
    display: grid;
    --editor-width: 340px;
    --filmstrip-height: 182px;
    --slide-card-width: 190px;
    --slide-card-height: 124px;
    --slide-preview-width: 176px;
    --slide-preview-height: 99px;
    --filmstrip-gap: 12px;
    --filmstrip-padding: 14px 18px;
    --right-panel-width: 272px;
    --configuration-width: var(--right-panel-width);
    grid-template-rows: 64px minmax(0, 1fr) 6px var(--filmstrip-height);
    width: 100%;
    height: 100dvh;
    min-height: 640px;
    overflow: hidden;
    background: var(--app-bg);
}

.topbar {
    position: relative;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-width: 0;
    padding: 0 20px;
    border-bottom: 1px solid var(--border);
    background: color-mix(in srgb, var(--surface) 92%, transparent);
    box-shadow: var(--shadow-sm);
    backdrop-filter: blur(18px);
}

.brand,
.topbar-actions {
    display: flex;
    align-items: center;
}

.brand {
    gap: 0;
    text-decoration: none;
}

.brand h1 {
    color: var(--text);
    font-size: 15px;
    font-weight: 720;
    line-height: 1.1;
}

.brand p {
    margin-top: 3px;
    color: var(--text-secondary);
    font-size: 11px;
    line-height: 1.1;
}

.topbar-actions {
    gap: 10px;
}

.format-badge {
    padding: 5px 8px;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 650;
}

.autosave-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
    transition: color 200ms ease, border-color 200ms ease;
}

.autosave-status svg {
    width: 13px;
    height: 13px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.4;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.autosave-status[data-state="saved"] {
    color: #16a34a;
    border-color: rgba(22, 163, 74, 0.4);
}

.autosave-status[data-state="saving"] {
    color: var(--text-secondary);
    border-color: var(--border-strong);
}

.autosave-status[data-state="saving"] svg {
    animation: autosave-spin 0.7s linear infinite;
}

.autosave-status[data-state="offline"] {
    color: #d97706;
    border-color: rgba(217, 119, 6, 0.4);
}

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

@media (prefers-reduced-motion: reduce) {
    .autosave-status[data-state="saving"] svg {
        animation: none;
    }
}

.ui-language-control {
    display: grid;
    grid-template-columns: 15px minmax(0, 1fr) 12px;
    width: 118px;
    height: 34px;
    align-items: center;
    gap: 5px;
    padding: 0 8px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface-muted);
    color: var(--text-secondary);
}

.ui-language-control:hover,
.ui-language-control:focus-within {
    border-color: var(--border-strong);
    background: var(--surface-hover);
    color: var(--accent-ink);
}

.ui-language-control select {
    width: 100%;
    height: 100%;
    min-width: 0;
    appearance: none;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--text);
    font-size: 10px;
    font-weight: 680;
}

.ui-language-icon {
    width: 15px;
    height: 15px;
}

.ui-language-chevron {
    width: 12px;
    height: 12px;
    pointer-events: none;
}

.icon-button {
    display: grid;
    width: 34px;
    height: 34px;
    place-items: center;
    border: 1px solid var(--border);
    border-radius: 50%;
    background: var(--surface-muted);
    color: var(--text-secondary);
    transition: background-color 160ms ease, color 160ms ease, border-color 160ms ease;
}

.icon-button:hover {
    border-color: var(--border-strong);
    background: var(--surface-hover);
    color: var(--text);
}

.icon-button svg {
    width: 17px;
    height: 17px;
}

.sun-icon {
    display: none;
}

:root[data-theme="dark"] .sun-icon {
    display: block;
}

:root[data-theme="dark"] .moon-icon {
    display: none;
}

.workspace {
    display: grid;
    grid-template-columns: var(--editor-width) 6px minmax(320px, 1fr) var(--right-panel-width) var(--configuration-width);
    min-width: 0;
    min-height: 0;
}

.panel-resizer {
    position: relative;
    z-index: 7;
    background: var(--border);
    transition: background-color 140ms ease;
}

.panel-resizer::after {
    position: absolute;
    content: '';
}

.panel-resizer:hover,
.panel-resizer.is-resizing {
    background: var(--accent);
}

.editor-resizer {
    cursor: col-resize;
}

.editor-resizer::after {
    inset: 0 -4px;
}

.filmstrip-resizer {
    cursor: row-resize;
}

.filmstrip-resizer::after {
    inset: -4px 0;
}

body.resizing-columns,
body.resizing-columns * {
    cursor: col-resize !important;
    user-select: none !important;
}

body.resizing-rows,
body.resizing-rows * {
    cursor: row-resize !important;
    user-select: none !important;
}

.editor-panel,
.layers-sidebar,
.properties-panel,
.export-panel {
    background: var(--surface);
}

.editor-panel {
    min-width: 0;
    overflow-x: hidden;
    overflow-y: auto;
    border-right: 1px solid var(--border);
    overscroll-behavior: contain;
}

.properties-panel {
    min-width: 0;
    overflow-x: hidden;
    overflow-y: auto;
    border-left: 1px solid var(--border);
    overscroll-behavior: contain;
}

.layers-sidebar {
    min-width: 0;
    overflow-x: hidden;
    overflow-y: auto;
    border-left: 1px solid var(--border);
    background: var(--surface);
    overscroll-behavior: contain;
}

.configuration-panel-header {
    position: sticky;
    z-index: 4;
    top: 0;
    display: flex;
    height: 68px;
    min-height: 68px;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 0 14px;
    border-bottom: 1px solid var(--border);
    background: color-mix(in srgb, var(--surface) 94%, transparent);
    backdrop-filter: blur(14px);
}

.configuration-panel-header strong {
    font-size: 14px;
    font-weight: 680;
}

.configuration-panel-header button {
    display: grid;
    width: 30px;
    height: 30px;
    flex: 0 0 auto;
    place-items: center;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface-muted);
    color: var(--text-secondary);
}

.configuration-panel-header svg {
    width: 15px;
    height: 15px;
    transition: transform 160ms ease;
}

.configuration-collapsed {
    --configuration-width: 46px;
}

.configuration-collapsed #configurationPanelSections,
.configuration-collapsed .configuration-panel-header > div {
    display: none;
}

.configuration-collapsed .configuration-panel-header {
    justify-content: center;
    padding-inline: 7px;
}

.configuration-collapsed .configuration-panel-header svg {
    transform: rotate(180deg);
}

.right-panel-section {
    padding: 0 14px 15px;
    border-bottom: 1px solid var(--border);
}

.properties-panel .editor-section {
    padding: 0 14px 15px;
}

.right-panel-section.is-collapsed {
    padding-bottom: 0;
}

.right-panel-section.is-collapsed > :not(.section-title-row):not(.right-panel-heading) {
    display: none !important;
}

.right-panel-section.is-collapsed > .section-title-row,
.right-panel-section.is-collapsed > .right-panel-heading {
    margin-bottom: 0;
}

.right-panel-section.is-collapsed .section-collapse-button svg {
    transform: rotate(-90deg);
}

.right-panel-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    min-height: 50px;
    margin: 0 -14px 14px;
    padding: 0 14px;
    border-bottom: 1px solid var(--border);
    background: color-mix(in srgb, var(--surface-muted) 54%, var(--surface));
}

.properties-panel .right-panel-section > .section-title-row {
    min-height: 50px;
    margin: 0 -14px 14px;
    padding: 0 14px;
    border-bottom: 1px solid var(--border);
    background: color-mix(in srgb, var(--surface-muted) 54%, var(--surface));
}

.right-panel-heading h2 {
    color: var(--text);
    font-size: 12px;
    font-weight: 700;
}

.layers-sidebar > .layers-panel > .right-panel-heading {
    min-height: 68px;
}

.layer-toolbar {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 3px;
    margin-bottom: 10px;
    padding: 3px;
    border: 1px solid var(--border);
    border-radius: 7px;
    background: var(--surface-muted);
}

.layer-toolbar button {
    display: grid;
    height: 29px;
    place-items: center;
    border-radius: 5px;
    color: var(--text-secondary);
}

.layer-toolbar button:hover:not(:disabled) {
    background: var(--surface-raised);
    color: var(--accent-ink);
}

.layer-toolbar button.danger:hover:not(:disabled) {
    color: var(--danger);
}

.layer-toolbar button:disabled {
    cursor: not-allowed;
    opacity: 0.32;
}

.layer-toolbar svg {
    width: 15px;
    height: 15px;
}

.touch-layer-order {
    display: none;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
    margin-bottom: 10px;
}

.touch-layer-order button {
    display: flex;
    height: 34px;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface-muted);
    color: var(--text-secondary);
    font-size: 10px;
    font-weight: 680;
}

.touch-layer-order button:disabled {
    cursor: not-allowed;
    opacity: 0.38;
}

.touch-layer-order svg {
    width: 14px;
    height: 14px;
}

.layer-rename-form {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 30px 30px;
    gap: 4px;
    margin-bottom: 9px;
}

.layer-rename-form input {
    min-width: 0;
    height: 32px;
    padding: 0 8px;
    border: 1px solid var(--accent);
    border-radius: 6px;
    background: var(--surface-raised);
    font-size: 10px;
}

.layer-rename-form button {
    display: grid;
    place-items: center;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface-muted);
    color: var(--text-secondary);
}

.layer-rename-form button:hover {
    border-color: var(--accent);
    color: var(--accent-ink);
}

.layer-rename-form svg {
    width: 14px;
    height: 14px;
}

.layers-panel-mount:empty::after,
.element-inspector-mount:empty::after {
    display: block;
    padding: 16px 8px;
    color: var(--text-tertiary);
    font-size: 10px;
    text-align: center;
    content: 'Sin elementos';
}

.element-inspector-mount:empty::after {
    content: 'Selecciona una capa para editarla';
}

.mode-tabs {
    position: sticky;
    top: 0;
    z-index: 4;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    height: 68px;
    min-height: 68px;
    align-items: center;
    gap: 4px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    background: color-mix(in srgb, var(--surface) 94%, transparent);
    backdrop-filter: blur(18px);
}

.mode-tab {
    display: flex;
    min-width: 0;
    height: 38px;
    align-items: center;
    justify-content: center;
    gap: 5px;
    border-radius: 7px;
    background: transparent;
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 620;
    transition: background-color 160ms ease, color 160ms ease, box-shadow 160ms ease;
}

.mode-tab svg {
    width: 16px;
    height: 16px;
}

.mode-tab:hover {
    background: var(--surface-muted);
    color: var(--text);
}

.mode-tab.active {
    background: var(--surface-raised);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
    color: var(--accent-ink);
}

.editor-section {
    padding: 18px 16px;
    border-bottom: 1px solid var(--border);
}

.editor-section.is-collapsed {
    padding-block: 13px;
}

.properties-panel .right-panel-section.is-collapsed {
    padding-block: 0;
}

.editor-section.is-collapsed > :not(.section-title-row) {
    display: none !important;
}

.editor-section.is-collapsed > .section-title-row {
    margin-bottom: 0;
}

.collapsible-section-header {
    margin-bottom: 14px;
}

.collapsible-section-header h2 {
    margin-bottom: 0;
}

.section-collapse-button {
    display: grid;
    width: 26px;
    height: 26px;
    flex: 0 0 auto;
    place-items: center;
    border-radius: 6px;
    background: var(--surface-muted);
    color: var(--text-tertiary);
}

.section-collapse-button:hover {
    background: var(--surface-hover);
    color: var(--accent-ink);
}

.section-collapse-button svg {
    width: 14px;
    height: 14px;
    transition: transform 160ms ease;
}

.editor-section.is-collapsed .section-collapse-button svg {
    transform: rotate(-90deg);
}

.legacy-content-editor {
    display: none;
}

.smart-content-section textarea {
    min-height: 116px;
    resize: vertical;
}

.smart-content-section textarea:disabled {
    cursor: default;
    opacity: 0.72;
}

.editor-section h2,
.export-panel h2,
.filmstrip-header h2 {
    color: var(--text);
    font-size: 12px;
    font-weight: 700;
    line-height: 1.2;
}

.editor-section > h2 {
    margin-bottom: 14px;
}

.section-title-row,
.range-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.section-title-row {
    margin-bottom: 14px;
}

.section-status,
.field-note,
.privacy-note {
    color: var(--text-tertiary);
    font-size: 11px;
}

.text-button {
    background: transparent;
    color: var(--accent);
    font-size: 11px;
    font-weight: 650;
}

.text-button:hover {
    color: var(--accent-hover);
}

.segmented-control {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 3px;
    padding: 3px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-muted);
}

.language-option {
    min-width: 0;
    height: 30px;
    overflow: hidden;
    border-radius: 6px;
    background: transparent;
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 620;
    text-overflow: ellipsis;
    white-space: nowrap;
    transition: background-color 160ms ease, color 160ms ease, box-shadow 160ms ease;
}

.background-option {
    min-width: 0;
    height: 30px;
    overflow: hidden;
    border-radius: 6px;
    background: transparent;
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 620;
    text-overflow: ellipsis;
    white-space: nowrap;
    transition: background-color 160ms ease, color 160ms ease, box-shadow 160ms ease;
}

.language-option.active,
.background-option.active {
    background: var(--surface-raised);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
    color: var(--accent-ink);
}

.template-gallery {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 9px;
    max-height: min(46vh, 430px);
    padding-right: 4px;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
}

.template-card {
    min-width: 0;
    overflow: hidden;
    border: 2px solid transparent;
    border-radius: 7px;
    background: var(--surface-muted);
    color: var(--text-secondary);
    text-align: left;
    transition: border-color 160ms ease, background-color 160ms ease, transform 160ms ease;
}

.template-card:hover {
    border-color: var(--border-strong);
    transform: translateY(-1px);
}

.template-card.active {
    border-color: var(--accent);
    background: var(--accent-soft);
    color: var(--accent-ink);
}

.template-preview {
    display: block;
    width: 100%;
    aspect-ratio: var(--template-preview-aspect, 16 / 9);
    object-fit: cover;
    background: #1c1c1e;
}

.template-card > span {
    display: block;
    padding: 7px 8px;
    overflow: hidden;
    font-size: 10px;
    font-weight: 680;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.text-box-presets {
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.text-box-presets h3 {
    margin-bottom: 8px;
    color: var(--text-secondary);
    font-size: 10px;
    font-weight: 680;
}

.text-box-preset-gallery {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.text-box-preset-card {
    min-width: 0;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 7px;
    background: var(--surface-muted);
    color: var(--text-secondary);
    text-align: left;
    transition: border-color 160ms ease, background-color 160ms ease, transform 160ms ease;
}

.text-box-preset-card:hover {
    border-color: var(--accent);
    background: var(--accent-soft);
    color: var(--accent-ink);
    transform: translateY(-1px);
}

.text-box-preset-preview {
    display: block;
    width: 100%;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    background: #171717;
}

.text-box-preset-card > span {
    display: block;
    padding: 6px 7px;
    overflow: hidden;
    font-size: 9px;
    font-weight: 680;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.template-save-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-top: 10px;
}

.custom-styles-section {
    margin-top: 16px;
    padding-top: 15px;
    border-top: 1px solid var(--border);
}

.custom-styles-section h3 {
    margin-bottom: 9px;
    color: var(--text-secondary);
    font-size: 11px;
}

.custom-style-card {
    position: relative;
    min-width: 0;
}

.custom-style-card .template-card {
    width: 100%;
}

.custom-style-delete {
    position: absolute;
    top: 6px;
    right: 6px;
    display: grid;
    width: 22px;
    height: 22px;
    place-items: center;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.72);
    color: #ffffff;
    font-size: 16px;
    opacity: 0;
    transition: opacity 160ms ease, background-color 160ms ease;
}

.custom-style-card:hover .custom-style-delete,
.custom-style-delete:focus-visible {
    opacity: 1;
}

.custom-style-delete:hover {
    background: var(--danger);
}

.control-group {
    min-width: 0;
    margin-bottom: 12px;
}

.control-group:last-child {
    margin-bottom: 0;
}

.control-group label,
.color-control span,
.range-label label {
    display: block;
    margin-bottom: 6px;
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 620;
}

.control-group input:not([type="color"]):not([type="range"]):not([type="file"]),
.control-group select,
.control-group textarea,
.control-row input[type="number"] {
    width: 100%;
    min-width: 0;
    border: 1px solid var(--border);
    border-radius: 7px;
    background: var(--surface-muted);
    color: var(--text);
    transition: border-color 160ms ease, background-color 160ms ease, box-shadow 160ms ease;
}

.control-group input:not([type="color"]):not([type="range"]):not([type="file"]),
.control-group select,
.control-row input[type="number"] {
    height: 38px;
    padding: 0 10px;
    font-size: 12px;
}

.control-group textarea {
    min-height: 104px;
    padding: 10px;
    resize: vertical;
    font-size: 12px;
    line-height: 1.45;
}

.control-group input:hover,
.control-group select:hover,
.control-group textarea:hover,
.control-row input[type="number"]:hover {
    border-color: var(--border-strong);
}

.control-group input:focus,
.control-group select:focus,
.control-group textarea:focus,
.control-row input[type="number"]:focus {
    border-color: var(--accent);
    background: var(--surface-raised);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 13%, transparent);
    outline: none;
}

.control-row.two-columns {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 10px;
}

.control-row.three-columns {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 7px;
}

.design-subsection + .design-subsection {
    margin-top: 19px;
    padding-top: 18px;
    border-top: 1px solid var(--border);
}

.design-subsection > h3,
.subsection-title-row h3 {
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 700;
}

.design-subsection > h3 {
    margin-bottom: 13px;
}

.subsection-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 11px;
}

.background-type-control {
    margin-bottom: 12px;
}

.background-panel {
    margin-bottom: 13px;
    padding: 11px;
    border: 1px solid var(--border);
    border-radius: 7px;
    background: color-mix(in srgb, var(--surface-muted) 72%, transparent);
}

.wide-color-control {
    display: flex;
    height: 38px;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 0 7px 0 10px;
    border: 1px solid var(--border);
    border-radius: 7px;
    background: var(--surface-raised);
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 620;
}

.wide-color-control input[type="color"] {
    width: 25px;
    height: 25px;
    padding: 2px;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 50%;
    background: transparent;
}

.gradient-presets {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 6px;
    margin-bottom: 11px;
}

.gradient-preset {
    aspect-ratio: 1;
    min-width: 0;
    border: 2px solid var(--surface-raised);
    border-radius: 50%;
    box-shadow: 0 0 0 1px var(--border);
    transition: transform 160ms ease, box-shadow 160ms ease;
}

.gradient-preset:hover {
    box-shadow: 0 0 0 2px var(--accent);
    transform: scale(1.06);
}

.background-finishing {
    align-items: end;
    margin-top: 2px;
}

.background-effects-group {
    margin-top: 15px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
}

.background-effects-group h3 {
    margin-bottom: 10px;
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 700;
}

.background-light-color {
    margin-bottom: 11px;
}

.background-effects-reset {
    width: 100%;
    justify-content: center;
    margin-top: 15px;
}

.compact-range .range-label {
    min-height: 15px;
}

.switch-control {
    display: flex;
    min-height: 34px;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 620;
}

.switch-control input[type="checkbox"] {
    width: 31px;
    height: 18px;
    accent-color: var(--accent);
}

.template-switch {
    margin-top: 4px;
    padding: 2px 0 10px;
}

.palette-row {
    display: flex;
    min-height: 30px;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-top: 7px;
}

.image-palette {
    display: flex;
    min-width: 0;
    flex: 1;
    gap: 6px;
}

.palette-swatch {
    width: 25px;
    height: 25px;
    flex: 0 0 auto;
    border: 2px solid var(--surface-raised);
    border-radius: 50%;
    box-shadow: 0 0 0 1px var(--border);
    transition: transform 160ms ease;
}

.palette-swatch:hover {
    transform: scale(1.1);
}

.small-action-button {
    display: inline-flex;
    height: 29px;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 0 9px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface-raised);
    color: var(--accent-ink);
    font-size: 10px;
    font-weight: 680;
}

.small-action-button svg {
    width: 13px;
    height: 13px;
    flex: 0 0 auto;
}

.small-action-button:hover {
    border-color: var(--accent);
    background: var(--accent-soft);
}

.element-add-button {
    display: grid;
    width: 29px;
    height: 29px;
    flex: 0 0 auto;
    place-items: center;
    border-radius: 6px;
    background: var(--accent);
    color: #ffffff;
}

.element-add-control {
    display: flex;
    align-items: center;
    gap: 5px;
}

.element-add-control select {
    width: 92px;
    height: 29px;
    padding: 0 6px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface-muted);
    color: var(--text-secondary);
    font-size: 10px;
}

.element-add-button svg {
    width: 16px;
    height: 16px;
}

.element-library {
    margin-bottom: 14px;
}

.element-library-group + .element-library-group {
    margin-top: 13px;
}

.element-library h3,
.element-layers-heading h3 {
    color: var(--text-secondary);
    font-size: 10px;
    font-weight: 680;
}

.element-library-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 7px;
    margin-top: 8px;
}

.element-library-grid button {
    display: grid;
    min-width: 0;
    height: 68px;
    place-items: center;
    align-content: center;
    gap: 6px;
    border: 1px solid var(--border);
    border-radius: 7px;
    background: var(--surface-raised);
    color: var(--text-secondary);
    transition: border-color 160ms ease, background-color 160ms ease, color 160ms ease;
}

.element-library-grid button:hover {
    border-color: var(--accent);
    background: var(--accent-soft);
    color: var(--accent-ink);
}

.element-library-icon {
    display: grid;
    width: 30px;
    height: 30px;
    place-items: center;
    border: 1px solid color-mix(in srgb, var(--accent) 18%, var(--border));
    border-radius: 6px;
    background: var(--accent-soft);
    color: var(--accent-ink);
}

.element-library-icon svg {
    width: 19px;
    height: 19px;
}

.element-library-letter,
.element-library-quote {
    font-family: Georgia, serif;
    font-size: 18px;
    font-weight: 700;
}

.element-library-quote {
    padding-top: 5px;
    font-size: 25px;
}

.element-library-grid small {
    width: 100%;
    overflow: hidden;
    font-size: 9px;
    font-weight: 650;
    text-align: center;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.element-layers-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 7px;
}

.element-layers-heading span {
    color: var(--text-tertiary);
    font-size: 9px;
}

.template-elements-list {
    display: grid;
    gap: 5px;
}

.template-element-item {
    display: grid;
    position: relative;
    grid-template-columns: 20px minmax(0, 1fr) 34px;
    min-width: 0;
    align-items: center;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 7px;
    background: var(--surface-muted);
    color: var(--text-secondary);
}

.template-element-item.is-reorderable {
    cursor: grab;
}

.template-element-item.is-layer-dragging {
    opacity: 0.42;
}

.template-element-item.is-drop-before::before,
.template-element-item.is-drop-after::after {
    position: absolute;
    z-index: 2;
    right: 4px;
    left: 4px;
    height: 2px;
    border-radius: 2px;
    background: var(--accent);
    content: '';
}

.template-element-item.is-drop-before::before {
    top: -4px;
}

.template-element-item.is-drop-after::after {
    bottom: -4px;
}

.layer-drag-handle {
    display: grid;
    height: 100%;
    min-height: 43px;
    place-items: center;
    color: var(--text-tertiary);
}

.layer-drag-handle svg {
    width: 14px;
    height: 22px;
    fill: currentColor;
    stroke: none;
}

.template-element-item:not(.is-reorderable) .layer-drag-handle {
    opacity: 0.22;
}

.template-element-item:hover,
.template-element-item.active {
    border-color: var(--accent);
    background: var(--accent-soft);
    color: var(--accent-ink);
}

.template-element-item.is-hidden {
    opacity: 0.52;
}

.template-element-select {
    display: grid;
    grid-template-columns: 28px minmax(0, 1fr);
    min-width: 0;
    align-items: center;
    gap: 8px;
    padding: 7px 8px;
    color: inherit;
    text-align: left;
}

.template-element-select > span:nth-child(2) {
    min-width: 0;
}

.template-element-type {
    display: grid;
    width: 28px;
    height: 28px;
    place-items: center;
    border-radius: 5px;
    background: var(--surface-raised);
    color: var(--accent);
    font-family: Georgia, serif;
    font-size: 15px;
    font-weight: 700;
}

.template-element-type svg {
    width: 17px;
    height: 17px;
}

.template-element-item strong,
.template-element-item small {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.template-element-item strong {
    font-size: 10px;
}

.template-element-item small {
    margin-top: 2px;
    color: var(--text-tertiary);
    font-size: 9px;
}

.element-layer-visibility {
    display: grid;
    width: 34px;
    height: 100%;
    min-height: 43px;
    place-items: center;
    border-left: 1px solid var(--border);
    color: var(--text-tertiary);
}

.element-layer-visibility:hover,
.element-layer-visibility.is-hidden {
    background: var(--surface-raised);
    color: var(--accent-ink);
}

.element-layer-visibility svg {
    width: 15px;
    height: 15px;
}

.template-element-inspector {
    margin-top: 0;
    padding-top: 0;
    border-top: 0;
}

.template-element-inspector .range-control {
    min-width: 0;
}

.template-element-inspector input[data-mixed="true"],
.template-element-inspector select[data-mixed="true"] {
    border-color: var(--accent);
}

.template-element-inspector input[type="color"][data-mixed="true"]::-webkit-color-swatch {
    background: repeating-linear-gradient(135deg, var(--surface) 0 5px, var(--border-strong) 5px 10px);
}

.element-transform-section {
    margin: 0 0 12px;
    padding: 11px;
    border: 1px solid var(--border);
    border-radius: 7px;
    background: color-mix(in srgb, var(--surface-muted) 72%, transparent);
}

.element-transform-section > .element-control-label {
    margin-bottom: 9px;
    color: var(--text);
}

.element-transform-row {
    display: grid;
    grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr);
    align-items: end;
    gap: 8px;
    margin-top: 8px;
}

.element-flip-control > span {
    display: block;
    margin-bottom: 6px;
    color: var(--text-secondary);
    font-size: 10px;
    font-weight: 650;
}

.element-transform-toolbar {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    height: 38px;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 7px;
    background: var(--surface-raised);
}

.element-transform-toolbar button {
    display: grid;
    place-items: center;
    border-right: 1px solid var(--border);
    color: var(--text-secondary);
}

.element-transform-toolbar button:last-child {
    border-right: 0;
}

.element-transform-toolbar button:hover,
.element-transform-toolbar button.active {
    background: var(--accent-soft);
    color: var(--accent-ink);
}

.element-transform-toolbar svg {
    width: 15px;
    height: 15px;
}

.element-aspect-lock {
    display: grid;
    grid-template-columns: 16px 16px 1fr auto;
    min-height: 34px;
    align-items: center;
    gap: 7px;
    margin-bottom: 12px;
    padding: 0 9px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface-muted);
    color: var(--text-secondary);
    font-size: 10px;
    cursor: pointer;
}

.element-aspect-lock input {
    accent-color: var(--accent);
}

.element-aspect-lock svg {
    width: 15px;
    height: 15px;
}

.element-aspect-lock kbd {
    padding: 2px 5px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--surface);
    color: var(--text-tertiary);
    font: inherit;
}

.element-color-control {
    display: flex;
    height: 38px;
    align-items: center;
    justify-content: space-between;
    align-self: end;
    padding: 0 7px 0 10px;
    border: 1px solid var(--border);
    border-radius: 7px;
    background: var(--surface-muted);
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 620;
}

.element-color-control input {
    width: 25px;
    height: 25px;
    padding: 2px;
    border: 1px solid var(--border);
    border-radius: 50%;
    background: transparent;
}

.element-format-row,
.element-actions {
    display: flex;
    gap: 7px;
}

.element-format-row {
    margin-top: 8px;
    margin-bottom: 12px;
}

.element-control-label {
    display: block;
    margin-bottom: 6px;
    color: var(--text-secondary);
    font-size: 10px;
    font-weight: 650;
}

.element-alignment-toolbar {
    display: grid;
    gap: 4px;
    margin-bottom: 10px;
}

[data-element-kind="text"] > .element-alignment-toolbar {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.element-object-alignment .element-alignment-toolbar {
    grid-template-columns: repeat(6, minmax(0, 1fr));
}

.element-text-align-button,
.element-object-align-button {
    display: grid;
    width: 100%;
    height: 32px;
    place-items: center;
    border: 1px solid var(--border);
    border-radius: 5px;
    background: var(--surface-muted);
    color: var(--text-secondary);
}

.element-text-align-button:hover,
.element-text-align-button.active,
.element-object-align-button:hover {
    border-color: var(--accent);
    background: var(--accent-soft);
    color: var(--accent-ink);
}

.element-text-align-button svg,
.element-object-align-button svg {
    width: 15px;
    height: 15px;
}

.shape-style-fields {
    margin-top: 2px;
}

.element-inspector-subsection {
    margin: 12px 0;
    padding: 12px 0 2px;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}

.shape-style-fields input:disabled,
.shape-style-fields select:disabled {
    cursor: not-allowed;
    opacity: 0.45;
}

.element-object-alignment {
    margin-top: 11px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
}

.element-format-toggle {
    display: grid;
    grid-template-columns: 18px 18px auto;
    height: 34px;
    align-items: center;
    gap: 5px;
    padding: 0 8px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface-muted);
    color: var(--text-secondary);
    font-size: 10px;
}

.element-format-toggle input {
    accent-color: var(--accent);
}

.element-actions {
    flex-wrap: wrap;
}

.element-actions .small-action-button {
    display: flex;
    align-items: center;
    gap: 5px;
}

.element-actions svg {
    width: 13px;
    height: 13px;
}

.element-remove-button {
    color: var(--danger);
}

.element-hidden-icon,
.shows-hidden-state .element-visible-icon {
    display: none;
}

.shows-hidden-state .element-hidden-icon {
    display: block;
}

.search-control {
    position: relative;
}

.search-control input {
    padding-right: 42px !important;
}

.search-button {
    position: absolute;
    top: 4px;
    right: 4px;
    display: grid;
    width: 30px;
    height: 30px;
    place-items: center;
    border-radius: 6px;
    background: var(--accent);
    color: #ffffff;
    transition: background-color 160ms ease, transform 160ms ease;
}

.search-button:hover {
    background: var(--accent-hover);
}

.search-button:active {
    transform: scale(0.96);
}

.search-button svg {
    width: 15px;
    height: 15px;
    stroke-width: 2;
}

.field-note {
    margin-top: 6px;
    line-height: 1.35;
}

.language-fields + .language-fields {
    margin-top: 18px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.field-language-label {
    display: inline-flex;
    margin-bottom: 10px;
    padding: 4px 7px;
    border-radius: 5px;
    background: var(--accent-soft);
    color: var(--accent-ink);
    font-size: 10px;
    font-weight: 720;
}

.font-selector {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 72px;
    gap: 10px;
}

.tool-row {
    display: grid;
    grid-template-columns: repeat(4, 34px) 1px repeat(3, 34px);
    gap: 5px;
    align-items: center;
    margin-bottom: 14px;
}

.image-position-controls {
    margin-top: 2px;
}

.image-reset-button {
    width: 100%;
    margin: 0 0 12px;
}

.tool-button {
    display: grid;
    width: 34px;
    height: 34px;
    place-items: center;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface-muted);
    color: var(--text-secondary);
    font-size: 13px;
    transition: border-color 160ms ease, background-color 160ms ease, color 160ms ease;
}

.tool-button svg {
    width: 16px;
    height: 16px;
}

.tool-button:hover {
    border-color: var(--border-strong);
    background: var(--surface-hover);
    color: var(--text);
}

.tool-button.active {
    border-color: var(--accent);
    background: var(--accent-soft);
    color: var(--accent-ink);
}

.tool-divider {
    width: 1px;
    height: 22px;
    margin: 0 2px;
    background: var(--border);
}

.color-controls {
    margin-bottom: 12px;
}

.color-control {
    display: flex;
    height: 38px;
    align-items: center;
    justify-content: space-between;
    padding: 0 7px 0 10px;
    border: 1px solid var(--border);
    border-radius: 7px;
    background: var(--surface-muted);
}

.color-control span {
    margin: 0;
}

.color-control input[type="color"] {
    width: 25px;
    height: 25px;
    padding: 2px;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 50%;
    background: transparent;
}

input[type="file"] {
    width: 100%;
    color: var(--text-tertiary);
    font-size: 11px;
}

input[type="file"]::file-selector-button {
    height: 32px;
    margin-right: 8px;
    padding: 0 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface-muted);
    color: var(--text-secondary);
    font: inherit;
    font-weight: 620;
    cursor: pointer;
}

.range-label label {
    margin-bottom: 0;
}

.range-label output {
    color: var(--accent-ink);
    font-size: 10px;
    font-weight: 650;
}

input[type="range"] {
    width: 100%;
    height: 18px;
    margin-top: 6px;
    accent-color: var(--accent);
}

.stage-panel {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: 68px minmax(0, 1fr);
    min-width: 0;
    min-height: 0;
    background: var(--stage);
}

.stage-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 0 22px;
    border-bottom: 1px solid var(--border);
    background: color-mix(in srgb, var(--surface) 78%, var(--stage));
}

.eyebrow {
    display: block;
    margin-bottom: 4px;
    color: var(--accent);
    font-size: 9px;
    font-weight: 750;
    text-transform: uppercase;
}

.stage-header h2 {
    font-size: 14px;
    font-weight: 680;
}

.save-status {
    color: var(--text-tertiary);
    font-size: 10px;
    white-space: nowrap;
}

.stage-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.stage-icon-button {
    display: grid;
    width: 30px;
    height: 30px;
    place-items: center;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface-muted);
    color: var(--text-secondary);
}

.stage-icon-button:hover:not(:disabled) {
    border-color: var(--accent);
    color: var(--accent-ink);
}

.stage-icon-button:disabled {
    color: var(--text-tertiary);
    cursor: not-allowed;
    opacity: 0.62;
}

.stage-icon-button svg {
    width: 15px;
    height: 15px;
}

.canvas-zoom-control,
.canvas-history-control {
    display: grid;
    height: 30px;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface-muted);
}

.canvas-zoom-control {
    grid-template-columns: 30px 52px 30px;
}

.canvas-history-control {
    grid-template-columns: repeat(2, 34px);
    height: 32px;
    border-color: var(--border-strong);
    background: var(--surface-raised);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.09);
}

.canvas-zoom-control button,
.canvas-history-control button {
    display: grid;
    min-width: 0;
    place-items: center;
    border-right: 1px solid var(--border);
    color: var(--text-secondary);
    font-size: 10px;
    font-weight: 680;
}

.canvas-zoom-control button:last-child,
.canvas-history-control button:last-child {
    border-right: 0;
}

.canvas-zoom-control button:hover:not(:disabled),
.canvas-history-control button:hover:not(:disabled) {
    background: var(--surface-hover);
    color: var(--accent-ink);
}

.canvas-zoom-control button:disabled,
.canvas-history-control button:disabled {
    background: var(--surface-muted);
    color: var(--text-tertiary);
    opacity: 0.62;
}

.canvas-zoom-control svg,
.canvas-history-control svg {
    width: 14px;
    height: 14px;
}

.canvas-history-control svg {
    width: 16px;
    height: 16px;
    stroke-width: 2.2;
}

.safe-zone-control {
    display: grid;
    grid-template-columns: repeat(2, 30px);
    height: 30px;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface-muted);
}

.safe-zone-control button {
    display: grid;
    min-width: 0;
    place-items: center;
    border-right: 1px solid var(--border);
    color: var(--text-secondary);
}

.safe-zone-control button:last-child {
    border-right: 0;
}

.safe-zone-control button:hover,
.safe-zone-control button.active {
    background: var(--accent-soft);
    color: var(--accent-ink);
}

.safe-zone-control svg {
    width: 15px;
    height: 15px;
}

.safe-zone-locked-icon,
.safe-zone-is-locked .safe-zone-unlocked-icon {
    display: none;
}

.safe-zone-is-locked .safe-zone-locked-icon {
    display: block;
}

.canvas-container {
    display: grid;
    min-width: 0;
    min-height: 0;
    place-items: center;
    overflow: hidden;
    padding: clamp(18px, 3vw, 44px);
    background-color: var(--stage);
    background-image: linear-gradient(var(--border) 1px, transparent 1px), linear-gradient(90deg, var(--border) 1px, transparent 1px);
    background-size: 24px 24px;
    cursor: grab;
    touch-action: none;
    user-select: none;
}

.canvas-container:active {
    cursor: grabbing;
}

.canvas-container.is-pan-locked,
.canvas-container.is-pan-locked:active {
    cursor: default;
}

.canvas-frame {
    position: relative;
    width: min(100%, 1080px);
    max-height: 100%;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    background: var(--canvas-surround);
    box-shadow: var(--shadow-canvas);
    transform-origin: center;
    transition: transform 190ms cubic-bezier(0.2, 0.8, 0.2, 1);
    will-change: transform;
}

.canvas-frame.is-dragging {
    transition: none;
}

#slideCanvas {
    position: relative;
    z-index: 1;
    display: block;
    width: 100%;
    height: 100%;
}

.template-elements-overlay {
    position: absolute;
    z-index: 2;
    inset: 0;
    pointer-events: none;
}

.canvas-selection-marquee {
    position: absolute;
    border: 1px solid var(--accent);
    background: color-mix(in srgb, var(--accent) 16%, transparent);
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.72);
    pointer-events: none;
}

.canvas-inline-text-editor {
    position: absolute;
    z-index: 5;
    min-width: 80px;
    min-height: 44px;
    padding: 6px 8px;
    overflow: auto;
    border: 2px solid var(--accent);
    border-radius: 4px;
    outline: 0;
    background: color-mix(in srgb, var(--canvas-surround) 88%, transparent);
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.75), 0 8px 22px rgba(0, 0, 0, 0.28);
    caret-color: var(--accent);
    pointer-events: auto;
    resize: none;
}

.canvas-safe-zone {
    position: absolute;
    z-index: 3;
    inset: 7.5%;
    border: 1px dashed rgba(255, 255, 255, 0.86);
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.4), inset 0 0 0 1px rgba(0, 0, 0, 0.24);
    opacity: 0;
    pointer-events: none;
    transition: border-color 160ms ease, opacity 160ms ease;
}

.safe-zone-visible .canvas-safe-zone {
    opacity: 1;
}

.safe-zone-locked .canvas-safe-zone {
    border-style: solid;
    border-color: var(--accent);
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.82), 0 0 0 3px rgba(0, 0, 0, 0.25);
}

.canvas-element-hitbox {
    position: absolute;
    min-width: 12px;
    min-height: 12px;
    border: 1px dashed transparent;
    background: transparent;
    color: var(--accent);
    cursor: move;
    pointer-events: auto;
}

.canvas-element-hitbox:hover {
    border-color: color-mix(in srgb, var(--accent) 72%, transparent);
    background: color-mix(in srgb, var(--accent) 5%, transparent);
}

.canvas-element-hitbox.active,
.canvas-element-hitbox.is-dragging {
    border: 2px solid var(--accent);
    background: color-mix(in srgb, var(--accent) 8%, transparent);
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.72), 0 0 0 3px rgba(0, 0, 0, 0.24);
}

.canvas-element-resize-handle {
    position: absolute;
    right: -7px;
    bottom: -7px;
    width: 14px;
    height: 14px;
    border: 1px solid #ffffff;
    border-radius: 2px;
    background: var(--accent);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.32);
    cursor: nwse-resize;
    touch-action: none;
}

.canvas-element-rotation-handle {
    position: absolute;
    z-index: 1;
    top: -34px;
    left: 50%;
    width: 16px;
    height: 16px;
    border: 2px solid #ffffff;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.32);
    cursor: grab;
    touch-action: none;
    transform: translateX(-50%);
}

.canvas-element-rotation-handle::after {
    position: absolute;
    top: 14px;
    left: 50%;
    width: 2px;
    height: 18px;
    background: var(--accent);
    content: '';
    transform: translateX(-50%);
}

.canvas-element-hitbox.is-resizing {
    cursor: nwse-resize;
}

.canvas-element-hitbox.is-rotating,
.canvas-element-hitbox.is-rotating .canvas-element-rotation-handle {
    cursor: grabbing;
}

.export-menu {
    position: relative;
}

.export-menu > summary {
    list-style: none;
}

.export-menu > summary::-webkit-details-marker {
    display: none;
}

.export-menu[open] > summary {
    border-color: var(--accent);
    background: var(--accent-soft);
    color: var(--accent-ink);
}

.export-panel {
    position: absolute;
    z-index: 30;
    top: calc(100% + 11px);
    right: 0;
    display: grid;
    width: 330px;
    gap: 12px;
    padding: 15px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-raised);
    box-shadow: var(--shadow-md);
}

.export-panel .right-panel-heading {
    margin-bottom: 0;
}

.export-actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
}

.export-settings {
    display: grid;
    grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr);
    gap: 9px;
}

.export-setting label {
    display: block;
    margin-bottom: 4px;
    color: var(--text-tertiary);
    font-size: 9px;
    font-weight: 650;
}

.export-setting select {
    width: 100%;
    height: 32px;
    padding: 0 5px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface-muted);
    color: var(--text-secondary);
    font-size: 9px;
}

.export-resolution-hint {
    display: block;
    margin-top: 4px;
    color: var(--accent-ink);
    font-size: 9px;
    font-weight: 650;
}

.custom-resolution-fields {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    align-items: center;
    gap: 4px;
    margin-top: 6px;
}

.custom-resolution-fields input {
    width: 100%;
    min-width: 0;
    height: 30px;
    padding: 0 4px;
    border: 1px solid var(--border);
    border-radius: 5px;
    background: var(--surface-raised);
    font-size: 9px;
}

.export-button {
    display: flex;
    min-width: 0;
    height: 42px;
    align-items: center;
    justify-content: center;
    gap: 7px;
    border: 1px solid var(--border);
    border-radius: 7px;
    background: var(--surface-muted);
    color: var(--text-secondary);
    transition: border-color 160ms ease, background-color 160ms ease, color 160ms ease, transform 160ms ease;
}

.export-button:hover {
    border-color: var(--accent);
    background: var(--accent-soft);
    color: var(--accent-ink);
}

.export-button:active {
    transform: scale(0.97);
}

.export-button svg {
    width: 17px;
    height: 17px;
}

.export-button span {
    font-size: 10px;
    font-weight: 720;
}

.filmstrip-panel {
    display: grid;
    grid-template-columns: 248px minmax(0, 1fr);
    min-width: 0;
    min-height: 0;
    border-top: 1px solid var(--border);
    background: var(--surface);
}

.filmstrip-header {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 16px;
    border-right: 1px solid var(--border);
}

.filmstrip-title-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
}

.filmstrip-title-actions,
.filmstrip-size-control {
    display: flex;
    align-items: center;
}

.filmstrip-title-actions {
    gap: 6px;
}

.filmstrip-size-control {
    height: 28px;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface-muted);
}

.filmstrip-size-option {
    display: grid;
    width: 25px;
    height: 26px;
    place-items: center;
    border-right: 1px solid var(--border);
    background: transparent;
    color: var(--text-tertiary);
}

.filmstrip-size-option:last-child {
    border-right: 0;
}

.filmstrip-size-option:hover,
.filmstrip-size-option.active {
    background: var(--surface-raised);
    color: var(--accent-ink);
}

.filmstrip-size-option svg {
    width: 16px;
    height: 16px;
}

.filmstrip-size-small {
    --slide-card-width: 106px;
    --slide-card-height: 68px;
    --slide-preview-width: 96px;
    --slide-preview-height: 54px;
    --filmstrip-gap: 8px;
    --filmstrip-padding: 8px 12px;
}

.filmstrip-size-medium {
    --slide-card-width: 148px;
    --slide-card-height: 94px;
    --slide-preview-width: 134px;
    --slide-preview-height: 75px;
    --filmstrip-gap: 10px;
    --filmstrip-padding: 10px 14px;
}

.filmstrip-size-small .filmstrip-header {
    padding: 8px 10px;
}

.filmstrip-size-small .filmstrip-toolbar {
    grid-template-columns: repeat(5, 28px);
    gap: 4px;
}

.filmstrip-size-small .filmstrip-tool {
    width: 28px;
    height: 28px;
}

.filmstrip-size-small .select-all-slides {
    display: none;
}

.filmstrip-size-medium .filmstrip-header {
    padding: 10px 12px;
}

.filmstrip-collapse-button {
    display: grid;
    width: 28px;
    height: 28px;
    flex: 0 0 auto;
    place-items: center;
    border-radius: 6px;
    background: var(--surface-muted);
    color: var(--text-secondary);
}

.filmstrip-collapse-button svg {
    width: 15px;
    height: 15px;
    transition: transform 160ms ease;
}

.filmstrip-collapsed {
    grid-template-rows: 64px minmax(0, 1fr) 0 48px;
}

.filmstrip-collapsed .filmstrip-resizer {
    visibility: hidden;
}

.filmstrip-collapsed .filmstrip-panel {
    grid-template-columns: 1fr;
}

.filmstrip-collapsed .filmstrip-header {
    flex-direction: row;
    align-items: center;
    padding: 8px 16px;
    border-right: 0;
}

.filmstrip-collapsed .filmstrip-title-row {
    align-items: center;
}

.filmstrip-collapsed .filmstrip-collapse-button svg {
    transform: rotate(180deg);
}

.filmstrip-collapsed .filmstrip-toolbar,
.filmstrip-collapsed .select-all-slides,
.filmstrip-collapsed .slides-list {
    display: none;
}

.filmstrip-toolbar {
    display: grid;
    grid-template-columns: repeat(5, 36px);
    gap: 6px;
}

.filmstrip-tool {
    display: grid;
    width: 36px;
    height: 34px;
    place-items: center;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface-muted);
    color: var(--text-secondary);
    transition: border-color 160ms ease, background-color 160ms ease, color 160ms ease;
}

.filmstrip-tool:hover:not(:disabled) {
    border-color: var(--accent);
    background: var(--accent-soft);
    color: var(--accent-ink);
}

.filmstrip-tool.primary {
    border-color: var(--accent);
    background: var(--accent);
    color: #ffffff;
}

.filmstrip-tool.danger:hover:not(:disabled) {
    border-color: var(--danger);
    background: color-mix(in srgb, var(--danger) 12%, var(--surface));
    color: var(--danger);
}

.filmstrip-tool:disabled {
    cursor: not-allowed;
    opacity: 0.38;
}

.filmstrip-tool svg {
    width: 16px;
    height: 16px;
}

.select-all-slides {
    display: flex;
    align-items: center;
    gap: 7px;
    color: var(--text-tertiary);
    font-size: 10px;
    cursor: pointer;
}

.select-all-slides input,
.slide-selection {
    accent-color: var(--accent);
}

.filmstrip-header h2 {
    margin-bottom: 4px;
}

.filmstrip-header span {
    color: var(--text-tertiary);
    font-size: 10px;
}

.add-slide-button {
    display: flex;
    min-height: 38px;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 0 10px;
    border-radius: 7px;
    background: var(--accent);
    color: #ffffff;
    font-size: 11px;
    font-weight: 680;
    line-height: 1.2;
    transition: background-color 160ms ease, transform 160ms ease;
}

.add-slide-button:hover {
    background: var(--accent-hover);
}

.add-slide-button:active {
    transform: scale(0.98);
}

.add-slide-button svg {
    width: 15px;
    height: 15px;
    flex: 0 0 auto;
    stroke-width: 2;
}

.slides-list {
    display: flex;
    min-width: 0;
    min-height: 0;
    align-items: center;
    gap: var(--filmstrip-gap);
    overflow-x: auto;
    overflow-y: hidden;
    padding: var(--filmstrip-padding);
    scroll-snap-type: x proximity;
}

.slide-item {
    position: relative;
    width: var(--slide-card-width);
    min-width: var(--slide-card-width);
    height: var(--slide-card-height);
    padding: 6px;
    overflow: hidden;
    border: 2px solid transparent;
    border-radius: 8px;
    background: var(--surface-muted);
    color: var(--text);
    scroll-snap-align: start;
    cursor: pointer;
    transition: border-color 160ms ease, background-color 160ms ease, transform 160ms ease;
}

.slide-item:hover {
    border-color: var(--border-strong);
    transform: translateY(-2px);
}

.slide-item.active {
    border-color: var(--accent);
    background: var(--accent-soft);
}

.slide-item.selected {
    border-color: color-mix(in srgb, var(--accent) 68%, var(--border));
    box-shadow: inset 0 0 0 1px var(--accent);
}

.slide-item.dragging {
    opacity: 0.42;
    transform: scale(0.97);
}

.slide-item.drop-target {
    border-color: var(--accent);
    transform: translateY(-4px);
}

.slide-thumbnail {
    display: block;
    width: var(--slide-preview-width);
    height: var(--slide-preview-height);
    object-fit: contain;
    border-radius: 4px;
    background: #1c1c1e;
}

.slide-number {
    position: absolute;
    left: 10px;
    bottom: 8px;
    padding: 2px 5px;
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.72);
    color: #ffffff;
    font-size: 9px;
    font-weight: 700;
}

.slide-selection {
    position: absolute;
    top: 10px;
    left: 10px;
    width: 18px;
    height: 18px;
    margin: 0;
    border-radius: 4px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.28);
}

.slide-item-delete {
    position: absolute;
    top: 9px;
    right: 9px;
    display: grid;
    width: 24px;
    height: 24px;
    place-items: center;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.72);
    color: #ffffff;
    font-size: 17px;
    line-height: 1;
    opacity: 0;
    transition: opacity 160ms ease, background-color 160ms ease;
}

.slide-item:hover .slide-item-delete,
.slide-item:focus-within .slide-item-delete {
    opacity: 1;
}

.slide-item-delete:hover {
    background: var(--danger);
}

.filmstrip-size-small .slide-number {
    left: 7px;
    bottom: 6px;
    font-size: 8px;
}

.filmstrip-size-small .slide-selection {
    top: 7px;
    left: 7px;
    width: 14px;
    height: 14px;
}

.filmstrip-size-small .slide-item-delete {
    top: 6px;
    right: 6px;
    width: 20px;
    height: 20px;
    font-size: 14px;
}

.empty-state {
    display: grid;
    min-width: 220px;
    height: 100%;
    place-items: center;
    color: var(--text-tertiary);
    font-size: 11px;
    text-align: center;
}

.modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(0, 0, 0, 0.48);
    backdrop-filter: blur(8px);
}

.modal.show {
    display: flex;
}

.modal-content {
    width: min(100%, 470px);
    max-height: min(680px, 90vh);
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-raised);
    box-shadow: var(--shadow-md);
}

.modal-header,
.modal-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 18px;
}

.protected-change-actions {
    flex-wrap: wrap;
}

.protected-change-actions .btn-primary {
    flex: 1 1 180px;
}

.text-box-preset-modal-content {
    width: min(100%, 720px);
    max-height: min(760px, 92vh);
}

.text-box-preset-preview-stage {
    position: relative;
    display: grid;
    width: 100%;
    min-height: 250px;
    max-height: 430px;
    place-items: center;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 7px;
    background-color: var(--stage);
    background-image: linear-gradient(var(--border) 1px, transparent 1px), linear-gradient(90deg, var(--border) 1px, transparent 1px);
    background-size: 20px 20px;
}

.text-box-preset-preview-stage img {
    display: block;
    width: 100%;
    max-height: 430px;
    object-fit: contain;
    box-shadow: var(--shadow-canvas);
}

.text-box-preset-preview-stage span {
    position: absolute;
    color: var(--text-tertiary);
    font-size: 11px;
}

.text-box-preset-modal-content .modal-body > p {
    margin-top: 13px;
}

.text-box-preset-actions {
    flex-wrap: wrap;
}

.text-box-preset-actions .btn-primary {
    min-width: 150px;
}

.modal-header {
    border-bottom: 1px solid var(--border);
}

.modal-header h3 {
    font-size: 16px;
}

.close-modal {
    display: grid;
    width: 30px;
    height: 30px;
    place-items: center;
    border-radius: 50%;
    background: var(--surface-muted);
    color: var(--text-secondary);
    font-size: 21px;
}

.modal-body {
    overflow-y: auto;
    padding: 18px;
    color: var(--text-secondary);
    font-size: 12px;
    line-height: 1.5;
}

.modal-body a {
    color: var(--accent);
}

.api-steps {
    margin: 14px 0 16px;
    padding-left: 20px;
}

.api-steps li + li {
    margin-top: 5px;
}

.privacy-note {
    margin-top: 8px;
}

.modal-footer {
    justify-content: flex-end;
    border-top: 1px solid var(--border);
}

.btn {
    min-height: 36px;
    padding: 0 14px;
    border-radius: 7px;
    font-size: 12px;
    font-weight: 650;
}

.btn-primary {
    background: var(--accent);
    color: #ffffff;
}

.btn-primary:hover {
    background: var(--accent-hover);
}

.btn-secondary {
    border: 1px solid var(--border);
    background: var(--surface-muted);
    color: var(--text-secondary);
}

.btn-danger {
    background: var(--danger);
    color: #ffffff;
}

#toastContainer {
    bottom: 198px !important;
    right: 16px !important;
}

.toast {
    display: flex;
    max-width: min(370px, calc(100vw - 32px));
    align-items: center;
    gap: 10px;
    margin-top: 8px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-raised);
    box-shadow: var(--shadow-md);
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 200ms ease, transform 200ms ease;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

.toast.success {
    border-left: 3px solid var(--success);
}

.toast.error {
    border-left: 3px solid var(--danger);
}

.toast.info,
.toast.warning {
    border-left: 3px solid var(--accent);
}

.toast-icon {
    display: grid;
    width: 20px;
    height: 20px;
    flex: 0 0 auto;
    place-items: center;
    border-radius: 50%;
    background: var(--accent-soft);
    color: var(--accent-ink);
    font-size: 11px;
    font-weight: 750;
}

.toast-message {
    color: var(--text);
    font-size: 12px;
    line-height: 1.35;
}

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    border: 2px solid transparent;
    border-radius: 8px;
    background: color-mix(in srgb, var(--text-tertiary) 48%, transparent);
    background-clip: padding-box;
}

@media (max-width: 1050px) {
    .app-shell {
        grid-template-rows: 64px minmax(0, 1fr) 6px var(--filmstrip-height);
    }

    .workspace {
        position: relative;
        grid-template-columns: min(var(--editor-width), 290px) 6px minmax(280px, 1fr) 224px 46px;
    }

    #toastContainer {
        bottom: 186px !important;
    }
}

@media (min-width: 841px) and (max-width: 1050px) {
    .properties-panel {
        position: absolute;
        z-index: 12;
        top: 0;
        right: 0;
        bottom: 0;
        width: var(--right-panel-width);
        box-shadow: -18px 0 38px rgba(0, 0, 0, 0.16);
    }

    .configuration-collapsed .properties-panel {
        position: static;
        width: auto;
        box-shadow: none;
    }

    .stage-header {
        gap: 10px;
        padding-inline: 14px;
    }

    .stage-header .save-status {
        display: none;
    }
}

@media (max-width: 840px) {
    body {
        overflow: auto;
    }

    .app-shell {
        display: block;
        height: auto;
        min-height: 100dvh;
        overflow: visible;
    }

    .topbar {
        position: sticky;
        top: 0;
        height: 60px;
    }

    .workspace {
        display: grid;
        grid-template-columns: 1fr;
    }

    .editor-resizer,
    .filmstrip-resizer,
    .filmstrip-collapse-button {
        display: none;
    }

    .editor-panel {
        max-height: none;
        overflow: visible;
        border-right: 0;
    }

    .mode-tabs {
        top: 60px;
    }

    .stage-panel {
        min-height: 420px;
        border-top: 1px solid var(--border);
    }

    .canvas-container {
        min-height: 330px;
        padding: 18px;
    }

    .properties-panel {
        position: static;
        width: auto;
        max-height: none;
        overflow: visible;
        box-shadow: none;
        border-top: 1px solid var(--border);
        border-left: 0;
    }

    .layers-sidebar {
        max-height: none;
        overflow: visible;
        border-top: 1px solid var(--border);
        border-left: 0;
    }

    .configuration-panel-header {
        position: static;
    }

    .configuration-collapsed #configurationPanelSections,
    .configuration-collapsed .configuration-panel-header > div,
    .app-shell:not(.configuration-collapsed) #configurationPanelSections,
    .app-shell:not(.configuration-collapsed) .configuration-panel-header > div {
        display: block;
    }

    .layer-toolbar {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .layer-toolbar .layer-order-button {
        display: none;
    }

    .touch-layer-order {
        display: grid;
    }

    .template-element-item {
        grid-template-columns: minmax(0, 1fr) 40px;
    }

    .layer-drag-handle {
        display: none;
    }

    .filmstrip-panel {
        grid-template-columns: 1fr;
        min-height: 190px;
    }

    .filmstrip-header {
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
        padding: 12px 16px;
        border-right: 0;
        border-bottom: 1px solid var(--border);
    }

    .filmstrip-toolbar {
        order: 3;
        width: 100%;
    }

    .add-slide-button {
        min-height: 36px;
    }

    .slides-list {
        min-height: 145px;
    }

    .filmstrip-size-small .filmstrip-panel,
    .filmstrip-size-medium .filmstrip-panel {
        min-height: 0;
    }

    .filmstrip-size-small .slides-list {
        min-height: 84px;
    }

    .filmstrip-size-medium .slides-list {
        min-height: 114px;
    }

    #toastContainer {
        bottom: 16px !important;
    }
}

@media (hover: none) and (pointer: coarse) {
    .layer-toolbar {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .layer-toolbar .layer-order-button,
    .layer-drag-handle {
        display: none;
    }

    .touch-layer-order {
        display: grid;
    }

    .template-element-item {
        grid-template-columns: minmax(0, 1fr) 40px;
    }
}

@media (max-width: 440px) {
    .brand p,
    .format-badge,
    .save-status,
    .autosave-status .autosave-text {
        display: none;
    }

    .editor-section {
        padding-inline: 14px;
    }

    .stage-header {
        padding-inline: 10px;
    }

    .stage-actions {
        gap: 0;
    }

    .ui-language-control {
        width: 106px;
    }

    .export-panel {
        position: fixed;
        top: 58px;
        right: 12px;
        width: min(330px, calc(100vw - 24px));
    }

    .text-box-preset-modal-content .modal-footer {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .text-box-preset-actions .btn-primary {
        grid-column: 1 / -1;
        grid-row: 1;
    }

    .text-box-preset-preview-stage {
        min-height: 180px;
    }

    .canvas-container {
        min-height: 260px;
        padding: 12px;
    }

    .add-slide-button {
        max-width: 148px;
    }
}

@media (max-width: 360px) {
    .stage-panel {
        grid-template-rows: 106px minmax(0, 1fr);
    }

    .stage-header {
        flex-direction: column;
        align-items: flex-start;
        justify-content: center;
        gap: 8px;
        padding-inline: 7px;
        padding-block: 10px;
    }

    .stage-actions {
        width: 100%;
    }
}