:root {
    --bg-color: #0d0e12;
    --panel-bg: rgba(23, 25, 35, 0.7);
    --primary-color: #FBBC04;
    /* VRM themed color (Gold/Yellow) */
    --primary-hover: #d4a003;
    --text-color: #f8fafc;
    --text-muted: #94a3b8;
    --border-color: rgba(255, 255, 255, 0.1);
    --glass-bg: rgba(255, 255, 255, 0.03);
    --error-color: #ef4444;
}

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

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    overflow: hidden;
    /* App container will handle scroll */
    height: 100vh;
}

.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* Main Layout */
.main-layout {
    display: flex;
    flex: 1;
    overflow: hidden;
}

.viewer-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    position: relative;
}

#canvas-container {
    flex: 1;
    position: relative;
    background: radial-gradient(circle at center, #1e293b 0%, #0f172a 100%);
    overflow: hidden;
}

.watermark {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    /* Align credits to the right */
    gap: 0.2rem;
    color: rgba(255, 255, 255, 0.04);
    pointer-events: none;
    user-select: none;
    z-index: 0;
}

.watermark-main {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0.05em;
    font-size: clamp(3rem, 10vw, 12rem);
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    white-space: nowrap;
}

.watermark svg {
    height: 1.1em;
    width: auto;
    margin-right: 0.2em;
    opacity: 0.8;
}

.watermark-credits {
    font-size: clamp(0.8rem, 2vw, 2.5rem);
    font-weight: 600;
    opacity: 0.6;
    letter-spacing: 0.1em;
    margin-right: 0.5em;
}

.sidebar {
    width: 320px;
    background: var(--panel-bg);
    backdrop-filter: blur(16px);
    border-left: 1px solid var(--border-color);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    z-index: 10;
}

/* Dropzone */
.dropzone {
    position: absolute;
    inset: 1.5rem;
    border: 2px dashed var(--primary-color);
    opacity: 0.6;
    border-radius: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.02);
    transition: all 0.3s ease;
    cursor: pointer;
    z-index: 5;
}

.dropzone:hover,
.dropzone.active {
    border-color: var(--primary-color);
    background: rgba(251, 187, 4, 0.05);
    opacity: 1;
}

.dropzone-content {
    text-align: center;
}

.drop-icon {
    margin-bottom: 1.5rem;
    color: var(--primary-color);
    opacity: 0.5;
}

.dropzone h3 {
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
}

.dropzone p {
    color: var(--text-muted);
}

/* Sidebar Panels */
.panel-section {
    background: var(--glass-bg);
    border: 1px solid var(--border-color);
    border-radius: 1rem;
    padding: 1rem;
}

.panel-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.trash-btn {
    margin-left: auto;
    background: none;
    border: none;
    color: var(--primary-color);
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 0.375rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    opacity: 0.8;
}

.trash-btn:hover {
    background: rgba(239, 68, 68, 0.1);
    color: var(--error-color);
    opacity: 1;
}

.trash-btn:active {
    transform: scale(0.95);
}

.info-content {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.info-item {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
}

.info-item .label {
    color: var(--text-muted);
}

.info-item .value {
    font-weight: 500;
}

.select-wrapper {
    margin-top: 1.25rem;
}

.select-wrapper select {
    width: 100%;
    background: #1a1e2e;
    border: 1px solid var(--primary-color);
    color: var(--text-color);
    padding: 0.6rem 1rem;
    border-radius: 0.5rem;
    outline: none;
    cursor: pointer;
    opacity: 0.8;
    transition: all 0.2s ease;
}

.select-wrapper select:hover {
    opacity: 1;
    background: #252a3e;
}

/* Playback Controls */
.playback-controls {
    display: flex;
    justify-content: center;
    align-items: stretch;
    gap: 0;
    margin-top: 0.75rem;
    background: rgba(0, 0, 0, 0.2);
    /* Darker base for segments */
    border: 1px solid var(--border-color);
    border-radius: 2rem;
    padding: 0;
    overflow: hidden;
}

.playback-btn {
    flex: 1;
    background: transparent;
    border: none;
    border-right: 1px solid var(--border-color);
    color: var(--text-muted);
    width: 42px;
    /* Fixed width for segments */
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    border-radius: 0;
}

.playback-btn:last-child {
    border-right: none;
}

.playback-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-color);
}

.playback-btn svg {
    width: 16px;
    height: 16px;
    opacity: 0.8;
}

.playback-btn:active {
    background: rgba(255, 255, 255, 0.1);
}

.playback-btn.main-play-btn {
    width: 50px;
    /* Slightly wider center segment */
    background: transparent;
    color: var(--primary-color);
    box-shadow: none;
}

.playback-btn.main-play-btn:hover {
    box-shadow: 0 6px 16px rgba(251, 187, 4, 0.4);
}

.playback-btn.main-play-btn:active {
    transform: translateY(1px);
}

.panel-actions {
    margin-top: auto;
}

.secondary-btn {
    width: 100%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: var(--text-color);
    padding: 0.75rem;
    border-radius: 0.75rem;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
}

.secondary-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.sidebar-footer {
    margin-top: auto;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: center;
}

.github-link-simple {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--primary-color);
    text-decoration: none;
    font-size: 0.75rem;
    transition: all 0.2s;
    opacity: 0.7;
}

.github-link-simple:hover {
    color: var(--primary-color);
    opacity: 1;
}

/* Global Overlays */
#global-drag-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(13, 14, 18, 0.9);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(8px);
    pointer-events: none;
}

#global-drag-overlay.hidden {
    display: none;
}

.overlay-content {
    text-align: center;
    color: var(--primary-color);
    animation: pulse 1.5s infinite;
}

.overlay-content p {
    margin-top: 1rem;
    font-size: 1.25rem;
    font-weight: 600;
}

@keyframes pulse {
    0% {
        transform: scale(1);
        opacity: 0.8;
    }

    50% {
        transform: scale(1.05);
        opacity: 1;
    }

    100% {
        transform: scale(1);
        opacity: 0.8;
    }
}

#loader-overlay {
    position: absolute;
    inset: 0;
    background: rgba(13, 14, 18, 0.8);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 20;
}

.loader-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(251, 187, 4, 0.2);
    border-top: 3px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

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

/* Controls Guide */
.controls-guide {
    position: absolute;
    top: 1rem;
    left: 1rem;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(8px);
    border: 2px solid rgba(251, 187, 4, 0.4);
    border-radius: 0.75rem;
    padding: 0.5rem 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    z-index: 8;
    cursor: default;
    opacity: 0.6;
    transition: all 0.2s ease;
    pointer-events: auto;
    /* Enable hover */
}

/* Viewer Toggles (Common Base) */
.viewer-toggle {
    position: absolute;
    right: 1rem;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 0.5rem;
    padding: 0.5rem 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    z-index: 8;
    cursor: pointer;
    color: var(--text-color);
    font-size: 0.85rem;
    transition: all 0.2s ease;
    user-select: none;
}

.viewer-toggle:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.3);
}

.viewer-toggle:active {
    transform: translateY(1px);
}

.viewer-toggle.active {
    background: rgba(251, 187, 4, 0.2);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.key-badge {
    background: rgba(255, 255, 255, 0.1);
    padding: 0.1rem 0.4rem;
    border-radius: 0.25rem;
    color: var(--primary-color);
    font-weight: 700;
    font-family: monospace;
    font-size: 0.8rem;
}

/* Toggle Positioning */
.projection-toggle {
    top: 1rem;
}

.lookat-toggle {
    top: 4rem;
}

.skeleton-toggle {
    top: 7rem;
}

.pose-toggle {
    top: 10rem;
}


.controls-guide:hover {
    opacity: 1;
    padding: 0.75rem 1rem;
}

.guide-title {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--primary-color);
}

.controls-guide:hover .guide-title {
    display: none;
    /* Hide title on hover to show details */
}

.guide-content {
    display: none;
    /* Hidden by default */
    flex-direction: column;
    gap: 0.5rem;
}

.controls-guide:hover .guide-content {
    display: flex;
    /* Show details on hover */
}

.guide-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 0.75rem;
}

.guide-item .key {
    background: rgba(255, 255, 255, 0.1);
    padding: 0.1rem 0.4rem;
    border-radius: 0.25rem;
    color: var(--primary-color);
    font-weight: 700;
    min-width: 3.5rem;
    text-align: center;
}

.guide-item .desc {
    color: var(--text-muted);
}

.guide-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.1);
    margin: 0.25rem 0;
}

/* Footer */
.app-footer {
    padding: 0.75rem;
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-muted);
    border-top: 1px solid var(--border-color);
    background: rgba(0, 0, 0, 0.2);
}

/* Sidebar Dropzone */
.sidebar-dropzone {
    margin-top: 1rem;
    padding: 1.5rem 1rem;
    border: 2px dashed var(--primary-color);
    opacity: 0.6;
    border-radius: 0.75rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    background: rgba(255, 255, 255, 0.02);
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
}

.sidebar-dropzone:hover,
.sidebar-dropzone.drag-over {
    border-color: var(--primary-color);
    background: rgba(251, 187, 4, 0.05);
    color: var(--primary-color);
    opacity: 1;
}

.sidebar-dropzone p {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-muted);
}

.sidebar-dropzone svg {
    opacity: 0.5;
    transition: transform 0.2s ease;
}

.sidebar-dropzone:hover svg {
    opacity: 1;
    transform: translateY(2px);
}

/* Common utilities */
.hidden {
    display: none !important;
}

/* Drag Active States */
.panel-section.drop-active {
    outline: 2px dashed var(--primary-color);
    outline-offset: 4px;
    background: rgba(251, 187, 4, 0.1);
}

.panel-section-divider {
    height: 1px;
    background: var(--border-color);
    margin: 0.75rem 0;
}

.control-item {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.control-label {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    font-weight: 400;
}

.header-value-label {
    margin-left: auto;
    font-size: 0.75rem;
    color: var(--text-muted);
    font-family: monospace;
}

.control-label span:last-child {
    font-family: monospace;
}

input[type="range"] {
    width: 100%;
    appearance: none;
    background: rgba(255, 255, 255, 0.1);
    height: 4px;
    border-radius: 2px;
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    width: 16px;
    height: 16px;
    background: var(--primary-color);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
    transition: transform 0.1s;
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

/* --- Expressions Scrollbar --- */
.expression-list-container {
    scrollbar-width: thin;
    scrollbar-color: rgba(251, 187, 4, 0.4) transparent;
}

.expression-list-container::-webkit-scrollbar {
    width: 6px;
}

.expression-list-container::-webkit-scrollbar-track {
    background: transparent;
}

.expression-list-container::-webkit-scrollbar-thumb {
    background: rgba(251, 187, 4, 0.2);
    border-radius: 10px;
}

.expression-list-container::-webkit-scrollbar-thumb:hover {
    background: rgba(251, 187, 4, 0.5);
}