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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    overflow: hidden;
    background-color: #1a1a1a;
    color: #ffffff;
}

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

/* Left-side panel container */
#left-panels {
    position: absolute;
    top: 140px;
    left: 20px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    z-index: 100;
    transition: opacity 0.25s ease;
}

#scads-logo-link {
    position: fixed;
    top: 16px;
    left: 16px;
    z-index: 300;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 0;
    padding: 0;
    text-decoration: none;
    line-height: 0;
}

#scads-logo-link:hover {
    opacity: 0.9;
}

#scads-logo {
    display: block;
    width: 300px;
    height: auto;
    max-width: 100%;
}

.left-panel {
    background: rgba(0, 0, 0, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    padding: 10px;
    width: 350px;
}

#ui-panel {
    padding: 12px;
}

.panel-top-right-control {
    width: 100%;
}

.panel-top-right-control .info-label {
    margin-bottom: 4px;
}

.panel-top-right-control select {
    width: 100%;
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(74, 158, 255, 0.4);
    border-radius: 4px;
    color: #ffffff;
    padding: 6px 8px;
    font-size: 12px;
}

.panel-top-right-control select:focus {
    outline: none;
    border-color: #4a9eff;
}

.color-intensity-controls {
    margin-top: 8px;
}

.color-intensity-controls.hidden {
    display: none;
}

.color-gradient-track {
    position: relative;
    width: 100%;
    height: 7px;
    border-radius: 999px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.25);
    background: linear-gradient(90deg, rgb(49, 130, 189) 0%, rgb(255, 255, 255) 50%, rgb(230, 97, 1) 100%);
}

.color-gradient-mask {
    position: absolute;
    top: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.45);
    pointer-events: none;
}

#color-gradient-mask-left {
    left: 0;
    width: 0;
}

#color-gradient-mask-right {
    right: 0;
    width: 0;
}

.intensity-values {
    margin-top: 4px;
    display: flex;
    justify-content: space-between;
    color: #9db4cc;
    font-family: 'Courier New', monospace;
    font-size: 10px;
}

.color-intensity-controls input[type="range"] {
    width: 100%;
    margin-top: 4px;
}

.left-panel h2,
.left-panel h3 {
    margin-bottom: 8px;
    font-size: 18px;
}

.info-group {
    margin-bottom: 8px;
    font-size: 13px;
    line-height: 1.6;
}

.info-label {
    color: #aaa;
    text-transform: uppercase;
    font-size: 11px;
    font-weight: bold;
    letter-spacing: 0.5px;
    margin-bottom: 2px;
}

.info-value {
    color: #4a9eff;
    font-family: 'Courier New', monospace;
}

#controls {
    font-size: 12px;
    line-height: 1.5;
}

#controls h3 {
    margin-bottom: 6px;
    font-size: 14px;
}

.control-section {
    margin-bottom: 6px;
}

.control-key {
    color: #ffd700;
    font-weight: bold;
    font-family: 'Courier New', monospace;
}

#loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.9);
    padding: 30px;
    border-radius: 8px;
    text-align: center;
    z-index: 150;
}

.spinner {
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top: 4px solid #4a9eff;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto 15px;
}

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

/* Right-side mini views */
#side-views {
    position: absolute;
    top: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 110;
    transition: opacity 0.25s ease;
}

.side-view {
    background: rgba(0, 0, 0, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    padding: 8px;
    width: 240px;
}

.side-title {
    font-size: 12px;
    color: #aaa;
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.side-view canvas {
    display: block;
    width: 224px; /* 240 - padding*2 */
    height: 140px;
    background: #0f0f0f;
    border-radius: 4px;
}

/* Keyframes Panel Styles */
#keyframes-panel {
    max-height: 400px;
}

#keyframes-panel h3 {
    margin-bottom: 10px;
    font-size: 14px;
}

#keyframes-list {
    margin-bottom: 10px;
    min-height: 40px;
    max-height: 200px;
    overflow-y: auto;
    background: #0f0f0f;
    border-radius: 4px;
    padding: 5px;
}

.keyframe-item {
    background: rgba(74, 158, 255, 0.1);
    border: 1px solid rgba(74, 158, 255, 0.3);
    border-radius: 4px;
    padding: 6px 8px;
    margin-bottom: 4px;
    font-size: 11px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 6px;
    transition: background 0.2s;
}

.keyframe-item:hover {
    background: rgba(74, 158, 255, 0.2);
}

.keyframe-item-info {
    flex: 1;
    font-family: 'Courier New', monospace;
    color: #4a9eff;
}

.keyframe-item-buttons {
    display: flex;
    gap: 4px;
}

.keyframe-item-goto {
    background: rgba(74, 158, 255, 0.3);
    border: 1px solid rgba(74, 158, 255, 0.5);
    color: #4a9eff;
    padding: 2px 6px;
    border-radius: 3px;
    cursor: pointer;
    font-size: 10px;
    transition: background 0.2s;
}

.keyframe-item-goto:hover {
    background: rgba(74, 158, 255, 0.5);
}

.keyframe-item-delete {
    background: rgba(255, 80, 80, 0.3);
    border: 1px solid rgba(255, 80, 80, 0.5);
    color: #ff5050;
    padding: 2px 6px;
    border-radius: 3px;
    cursor: pointer;
    font-size: 10px;
    transition: background 0.2s;
}

.keyframe-item-delete:hover {
    background: rgba(255, 80, 80, 0.5);
}

.keyframe-controls {
    display: flex;
    gap: 5px;
    margin-bottom: 10px;
}

.keyframe-btn {
    flex: 1;
    background: rgba(74, 158, 255, 0.2);
    border: 1px solid rgba(74, 158, 255, 0.5);
    color: #4a9eff;
    padding: 8px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    font-weight: bold;
    transition: all 0.2s;
}

#save-keyframes-btn,
#load-keyframes-btn,
#play-keyframes-btn {
    flex: 0 0 auto;
    min-width: 45px;
    padding: 8px 10px;
}

.keyframe-btn:hover {
    background: rgba(74, 158, 255, 0.3);
    border-color: #4a9eff;
}

.keyframe-btn:active {
    background: rgba(74, 158, 255, 0.4);
}

.keyframe-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.keyframe-speed-control {
    margin-top: 10px;
}

.keyframe-speed-control label {
    font-size: 11px;
    color: #aaa;
    display: block;
    margin-bottom: 4px;
}

#keyframe-speed-slider {
    width: 100%;
    margin-top: 2px;
}

/* Panel Scale Slider */
#panel-scale-slider {
    position: absolute;
    bottom: 20px;
    right: 20px;
    z-index: 120;
    width: 260px;
}

.panel-scale-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

#panel-scale-slider input[type="range"] {
    width: 100%;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
    outline: none;
    cursor: pointer;
}

#panel-scale-slider input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    background: #4a9eff;
    border-radius: 50%;
    cursor: pointer;
    transition: background 0.2s;
}

#panel-scale-slider input[type="range"]::-webkit-slider-thumb:hover {
    background: #6bb3ff;
}

#panel-scale-slider input[type="range"]::-moz-range-thumb {
    width: 16px;
    height: 16px;
    background: #4a9eff;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    transition: background 0.2s;
}

#panel-scale-slider input[type="range"]::-moz-range-thumb:hover {
    background: #6bb3ff;
}

.auto-hide-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: #c7d8eb;
    white-space: nowrap;
    user-select: none;
}

.auto-hide-toggle input[type="checkbox"] {
    accent-color: #4a9eff;
    cursor: pointer;
}

/* Modal Dialog Styles */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.modal-overlay.active {
    display: flex;
}

.modal-content {
    background: rgba(20, 20, 20, 0.95);
    border: 2px solid rgba(74, 158, 255, 0.5);
    border-radius: 12px;
    padding: 25px;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
}

.modal-header {
    font-size: 18px;
    font-weight: bold;
    color: #4a9eff;
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-close {
    cursor: pointer;
    font-size: 24px;
    color: #aaa;
    transition: color 0.2s;
}

.modal-close:hover {
    color: #fff;
}

.modal-input-group {
    margin-bottom: 20px;
}

.modal-input-group label {
    display: block;
    font-size: 12px;
    color: #aaa;
    margin-bottom: 8px;
}

.modal-input-group input {
    width: 100%;
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(74, 158, 255, 0.3);
    border-radius: 4px;
    padding: 10px;
    color: #fff;
    font-size: 14px;
}

.modal-input-group input:focus {
    outline: none;
    border-color: #4a9eff;
}

.file-list {
    max-height: 300px;
    overflow-y: auto;
    margin-bottom: 20px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 4px;
    padding: 5px;
}

.file-item {
    padding: 10px;
    margin-bottom: 4px;
    background: rgba(74, 158, 255, 0.1);
    border: 1px solid rgba(74, 158, 255, 0.3);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 13px;
    color: #fff;
}

.file-item:hover {
    background: rgba(74, 158, 255, 0.2);
    border-color: #4a9eff;
}

.file-item.selected {
    background: rgba(74, 158, 255, 0.3);
    border-color: #4a9eff;
}

.file-list:empty::before {
    content: "No saved keyframes found";
    display: block;
    text-align: center;
    color: #555;
    font-size: 12px;
    padding: 20px;
}

.modal-buttons {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.modal-btn {
    background: rgba(74, 158, 255, 0.2);
    border: 1px solid rgba(74, 158, 255, 0.5);
    color: #4a9eff;
    padding: 10px 20px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    font-weight: bold;
    transition: all 0.2s;
}

.modal-btn:hover {
    background: rgba(74, 158, 255, 0.3);
    border-color: #4a9eff;
}

.modal-btn.primary {
    background: rgba(74, 158, 255, 0.5);
}

.modal-btn.primary:hover {
    background: rgba(74, 158, 255, 0.6);
}

#keyframes-list:empty::before {
    content: "No keyframes yet";
    display: block;
    text-align: center;
    color: #555;
    font-size: 11px;
    padding: 15px 0;
}

/* Arrow Button Controls */
.arrow-buttons {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-top: 10px;
}

.arrow-btn {
    background: rgba(74, 158, 255, 0.2);
    border: 2px solid rgba(74, 158, 255, 0.5);
    color: #4a9eff;
    padding: 15px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 20px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
    font-weight: bold;
}

.arrow-btn:hover {
    background: rgba(74, 158, 255, 0.3);
    border-color: #4a9eff;
}

.arrow-btn:active {
    background: rgba(74, 158, 255, 0.5);
    transform: scale(0.95);
}

.arrow-btn:nth-child(1) {
    grid-column: 2;
}

.arrow-btn:nth-child(2) {
    grid-column: 1;
    grid-row: 2;
}

.arrow-btn:nth-child(3) {
    grid-column: 2;
    grid-row: 3;
}

.arrow-btn:nth-child(4) {
    grid-column: 3;
    grid-row: 2;
}

.arrow-btn:nth-child(5) {
    grid-column: 1;
    grid-row: 1;
}

.arrow-btn:nth-child(6) {
    grid-column: 3;
    grid-row: 3;
}

.arrow-btn:nth-child(7) {
    grid-column: 2;
    grid-row: 2;
}
