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

:root {
    --control-height: 46px;
    --control-radius: 10px;
    --panel-gap: 16px;
}

html,
body {
    height: 100%;
}

body {
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    background: #000000;
    color: #c9d1d9;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    overflow: hidden;
}

.container {
    position: relative;
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 20px;
    gap: var(--panel-gap);
    min-height: 0;
}

.toolbar {
    background: #161b22;
    border: 1px solid #30363d;
    border-radius: 6px;
    padding: 16px;
    display: flex;
    flex-wrap: nowrap;
    gap: 10px;
    width: 100%;
    align-items: flex-end;
}

.toolbar-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
    min-width: 0;
}

.toolbar-group.file-picker-group {
    min-width: 110px;
    position: relative;
}

.file-picker-group input[type='file'] {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.toolbar-group.config-toggle-group {
    flex: 0 0 auto;
    align-items: flex-start;
}

.toolbar-group.playback-group {
    flex: 0 1 150px;
}

.toolbar-group.demo-group,
.toolbar-group.color-group {
    min-width: 60px;
}

.color-group input[type='color'] {
    width: 50px;
    min-width: 50px;
    padding: 0;
}

.toolbar-label,
.toolbar-group label {
    font-weight: 500;
    color: rgba(201, 209, 217, 0.45);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    white-space: nowrap;
}

.toolbar select,
.toolbar button,
.toolbar input[type='color'] {
    height: var(--control-height);
    border-radius: var(--control-radius);
    border: 1px solid #30363d;
    background: #000000;
    color: #c9d1d9;
    font-size: 14px;
    font-family: inherit;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.toolbar select {
    padding: 0 38px 0 12px;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8' width='12' height='8'%3E%3Cpath fill='%23c9d1d9' d='M1 1l5 6 5-6 1 1-6 7-6-7z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
}

.toolbar select:focus {
    outline: none;
    border-color: #58a6ff;
}

.toolbar select::-ms-expand {
    display: none;
}

.toolbar input[type='color'] {
    padding: 0;
}

.file-trigger-btn {
    width: 100%;
}

.file-trigger-btn.loaded {
    background: #05603a;
    border-color: #10b981;
    color: #d1fae5;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.playback-buttons {
    display: flex;
    gap: 12px;
}

.icon-button {
    padding: 0 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.icon-button svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
    transition: transform 0.2s ease;
}

.config-toggle-btn.collapsed svg {
    transform: rotate(180deg);
}

.demo-button {
    width: 100%;
}

.demo-button--disabled {
    opacity: 0.45;
    pointer-events: none;
}

.config-toggle-btn {
    width: var(--control-height);
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

button {
    border: 1px solid #30363d;
    border-radius: var(--control-radius);
    background: #21262d;
    color: #c9d1d9;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    font-family: inherit;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
}

button:hover {
    background: #30363d;
    border-color: #58a6ff;
}

button.primary {
    background: #f97316;
    border-color: #fdba74;
}

button.primary:hover {
    background: #ea580c;
    border-color: #fdba74;
}


.main-grid {
    flex: 1;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(280px, 420px);
    gap: var(--panel-gap);
    min-height: 0;
    height: 100%;
}

.main-grid.config-collapsed {
    grid-template-columns: minmax(0, 1fr);
}

.main-grid.config-collapsed #config-panel {
    display: none;
}

.viewer-container {
    background: #161b22;
    border: 1px solid #30363d;
    border-radius: 6px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.meta-panel {
    margin-bottom: 12px;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid #30363d;
    background: radial-gradient(circle at top left, #111827, #020617);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.meta-section {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.meta-section.two-column {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 8px;
}

.meta-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 8px;
    font-size: 12px;
}

.meta-label {
    color: #8b949e;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.meta-value {
    color: #c9d1d9;
    font-size: 12px;
    font-weight: 500;
    text-align: right;
}

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

.meta-list {
    list-style: none;
    margin: 0;
    padding: 6px 8px;
    border-radius: 8px;
    border: 1px solid #30363d;
    background: #000000;
    max-height: 100px;
    overflow-y: auto;
    font-size: 12px;
}

.meta-list li + li {
    margin-top: 2px;
}

.meta-list-empty {
    opacity: 0.6;
}

.meta-export-btn {
    align-self: flex-start;
    margin-top: 4px;
    padding: 6px 14px;
    font-size: 11px;
    border-radius: 999px;
    border: 1px solid #30363d;
    background: #111827;
    color: #e5e7eb;
    cursor: pointer;
    font-weight: 500;
}

.meta-export-btn:hover {
    background: #1f2937;
    border-color: #58a6ff;
}

@media (max-width: 900px) {
    .meta-section.two-column {
        grid-template-columns: 1fr;
    }
}

.canvas-drop-target,
#canvas-container {
    width: 100%;
    background-color: #000000;
    background-image: url("data:image/svg+xml,%3Csvg%20xmlns%3D%27http%3A//www.w3.org/2000/svg%27%20width%3D%27120%27%20height%3D%27120%27%3E%0A%3Ctext%20x%3D%2710%27%20y%3D%2760%27%20font-size%3D%2726%27%20font-family%3D%27system-ui%2C%20-apple-system%2C%20sans-serif%27%20fill%3D%27rgba%28148%2C163%2C184%2C0.12%29%27%3E.riv%3C/text%3E%0A%3C/svg%3E");
    background-repeat: repeat;
    border: 1px solid #30363d;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.canvas-drop-target .placeholder,
#canvas-container .placeholder {
    color: #484f58;
    text-align: center;
}

.canvas-drop-target.drag-over {
    border-color: #58a6ff;
    border-style: dashed;
    background: #111827;
}

.canvas-drop-target.drag-over .placeholder {
    color: #58a6ff;
}

#rive-canvas {
    width: 100%;
    height: 100%;
    display: block;
}

.info {
    padding: 10px;
    background: #000000;
    border: 1px solid #30363d;
    border-radius: 6px;
    font-size: 12px;
    color: #8b949e;
    text-align: center;
    font-family: inherit;
}

.error {
    position: fixed;
    top: 90px;
    right: 20px;
    width: 320px;
    background: rgba(45, 21, 25, 0.95);
    border: 1px solid #f85149;
    color: #f85149;
    padding: 12px 14px;
    border-radius: 6px;
    font-size: 13px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
    opacity: 0;
    transform: translateY(-10px);
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
    z-index: 3000;
}

.error.visible {
    opacity: 1;
    transform: translateY(0);
}

.code-editor-container {
    background: #161b22;
    border: 1px solid #30363d;
    border-radius: 6px;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 0;
}

.config-extra-row {
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
    gap: 12px;
    margin-bottom: 12px;
}

.config-extra-row .form-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.config-extra-row label {
    font-size: 12px;
    color: #8b949e;
}

.artboard-info {
    padding: 8px 10px;
    border-radius: 999px;
    border: 1px solid #30363d;
    background: #000000;
    font-size: 12px;
    color: #c9d1d9;
    min-height: 32px;
    display: flex;
    align-items: center;
}

@media (max-width: 900px) {
    .config-extra-row {
        grid-template-columns: 1fr;
    }
}


.code-editor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    padding-bottom: 10px;
    border-bottom: 1px solid #30363d;
}

.code-editor-header h3 {
    color: #8b949e;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.code-editor-body {
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex: 1;
    min-height: 0;
}

#code-editor {
    width: 100%;
    min-height: 320px;
    background: #000000;
    border: 1px solid #30363d;
    border-radius: 6px;
    color: #c9d1d9;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 13px;
    padding: 15px;
    resize: vertical;
    line-height: 1.6;
    tab-size: 2;
}

#code-editor:focus {
    outline: none;
    border-color: #58a6ff;
}

.apply-code-btn {
    margin-top: 16px;
    width: 100%;
    height: 56px;
    font-size: 15px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    border-radius: 999px;
    box-shadow: 0 14px 28px rgba(0, 0, 0, 0.45);
}

.version-info {
    margin-top: auto;
    background: #000000;
    border: 1px solid #30363d;
    border-radius: 6px;
    padding: 10px 12px;
    font-size: 11px;
    color: #8b949e;
    font-family: inherit;
    line-height: 1.4;
}

.version-footer {
    margin-top: 6px;
    font-size: 10px;
    color: #6e7681;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

@media (max-width: 799px) {
    :root {
        --control-height: 34px;
    }

    body {
        overflow: auto;
    }

    .toolbar {
        display: grid;
        grid-template-columns: repeat(4, minmax(0, 1fr));
        grid-auto-rows: auto;
        gap: 10px;
    }

    .toolbar-group {
        min-width: 0;
    }

    .toolbar-group.playback-group {
    order: 99;
    min-width: 150px;
    }

    .main-grid {
        grid-template-columns: 1fr;
    }

    .icon-button{
        padding: 0 4px;
        min-width: 30px
    }
    .viewer-container,
    .code-editor-container {
        min-height: auto;
    }
}


.dev-note-btn {
    height: 56px;
    font-size: 15px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    border-radius: 999px;
    box-shadow: 0 14px 28px rgba(0, 0, 0, 0.45);
}


@keyframes playGlow {
    0% {
        box-shadow: 0 0 0 0 rgba(249, 115, 22, 0.6);
    }
    70% {
        box-shadow: 0 0 0 12px rgba(249, 115, 22, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(249, 115, 22, 0);
    }
}

.apply-code-btn.glow {
    animation: playGlow 1.4s ease-out infinite;
}


.bg-presets {
    display: flex;
    gap: 6px;
    margin-top: 6px;
    flex-wrap: wrap;
}

.bg-presets button {
    padding: 4px 10px;
    font-size: 11px;
    border-radius: 999px;
}

.bg-presets button[data-bg="transparent"] {
    font-style: italic;
}


.version-footer a {
    color: #fed7aa;
    text-decoration: none;
}
.version-footer a:hover {
    color: #fb923c;
}


.bg-presets button[data-bg="#000000"] {
    background: #000000;
    color: #f9fafb;
    border-color: #27272a;
}
.bg-presets button[data-bg="#ffffff"] {
    background: #ffffff;
    color: #111827;
    border-color: #e5e7eb;
}
.bg-presets button[data-bg="#111827"] {
    background: #111827;
    color: #f9fafb;
    border-color: #27272a;
}
.bg-presets button[data-bg="transparent"] {
    background: transparent;
    color: #f9fafb;
    border-style: dashed;
}


.viewer-container {
    position: relative;
}

.canvas-fullscreen-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(15, 23, 42, 0.45);
    border-radius: 999px;
    border: 1px solid #4b5563;
    color: #e5e7eb;
    padding: 4px 10px;
    font-size: 13px;
    cursor: pointer;
    backdrop-filter: blur(6px);
}
.canvas-fullscreen-btn:hover {
    background: rgba(15, 23, 42, 0.8);
}


.app-header {
    margin-bottom: 10px;
}
.app-header h1 {
    font-size: 16px;
    font-weight: 500;
    color: #e5e7eb;
}
