body {
    font-family: Arial, sans-serif;
    text-align: center;
    background: linear-gradient(135deg, #ff9800 0%, #ff6f00 100%);
    color: #333;
    margin: 0;
    padding: 0;
    min-height: 100vh;
}

.container {
    margin: 0;
    padding: 0;
    width: 100%;
    border-radius: 0;
    background-color: #ffffff;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    overflow: hidden;
}

/* App Header */
.app-header {
    background: linear-gradient(135deg, #ff9800 0%, #ff6f00 100%);
    color: white;
    padding: 30px 20px;
    margin: 0;
    text-align: center;
}

.app-header h1 {
    margin: 0 0 8px 0;
    font-size: 2.5em;
    font-weight: 300;
    letter-spacing: 2px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.app-subtitle {
    margin: 0;
    font-size: 1em;
    opacity: 0.9;
    font-weight: 300;
    letter-spacing: 1px;
}

/* Settings Section */
.settings-section {
    margin: 20px;
    border: 2px solid #ffcc80;
    border-radius: 12px;
    background-color: #f9f9f9;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12), 0 1px 4px rgba(255, 152, 0, 0.15);
    outline: 2px solid #ffcc80;
    outline-offset: -2px;
}

.settings-section summary {
    padding: 16px 20px;
    cursor: pointer;
    font-weight: bold;
    font-size: 18px;
    user-select: none;
    background: linear-gradient(to right, #fff3e0, #ffe0b2);
    border-bottom: 2px solid #ff9800;
    transition: background-color 0.3s ease;
    text-align: left;
}

.settings-section summary:hover {
    background: linear-gradient(to right, #ffe0b2, #ffcc80);
}

.settings-section[open] summary {
    border-bottom: 2px solid #ff9800;
}

.settings-content {
    padding: 16px;
    background-color: #fff3e0;
}

/* Progress button — fills like a progress bar */
button.progress-btn {
    position: relative;
    overflow: hidden;
    background: linear-gradient(90deg, #ff6f00 var(--progress, 0%), #ccc var(--progress, 0%));
    transition: none;
}

button.progress-btn.progress-rendering {
    background: linear-gradient(90deg, #ff6f00 var(--progress, 0%), #e0a040 var(--progress, 0%));
    animation: progressPulse 1.5s ease-in-out infinite;
}

@keyframes progressPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* Settings Grid — responsive 2-column layout */
.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
    margin-bottom: 12px;
}

.setting-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.setting-field label {
    font-size: 13px;
    font-weight: 600;
    color: #555;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.setting-field select {
    padding: 7px 10px;
    font-size: 14px;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: #fff;
    cursor: pointer;
}

.setting-field select:focus {
    outline: none;
    border-color: #ff9800;
    box-shadow: 0 0 0 2px rgba(255, 152, 0, 0.2);
}

.setting-field-range {
    justify-content: center;
}

.setting-field-range input[type="range"] {
    width: 100%;
    margin: 0;
    accent-color: #ff9800;
}

.range-value {
    display: inline-block;
    background: #ff9800;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    min-width: 20px;
    text-align: center;
    padding: 1px 6px;
    border-radius: 10px;
    margin-left: 4px;
    vertical-align: middle;
}

/* Checkbox toggles — inline row */
.settings-toggles {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    align-items: center;
    margin-bottom: 4px;
}

.toggle-label {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 14px;
    font-weight: 500;
    color: #444;
    cursor: pointer;
    user-select: none;
}

.toggle-label input[type="checkbox"] {
    accent-color: #ff9800;
    width: 16px;
    height: 16px;
    cursor: pointer;
}

/* Preset row — full width at top */
.preset-row {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 10px;
    padding-bottom: 12px;
    margin-bottom: 12px;
    border-bottom: 1px solid #ffcc80;
}

.preset-field {
    flex: 1;
    min-width: 160px;
}

.preset-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

/* Button Container */
.button-container {
    padding: 10px 20px;
    margin: 0 20px;
    background-color: #ffffff;
    border-radius: 12px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
}

.button-container button {
    min-width: 110px;
    box-sizing: border-box;
}

button {
    margin: 10px;
    padding: 12px 24px;
    font-size: 16px;
    cursor: pointer;
    border: none;
    border-radius: 6px;
    background: linear-gradient(135deg, #ff9800 0%, #ff6f00 100%);
    color: white;
    font-weight: 500;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    box-shadow: 0 2px 8px rgba(255, 152, 0, 0.3);
}

button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 152, 0, 0.5);
}

button:active {
    transform: translateY(0);
}

button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Instruments Section */
.instruments-section {
    margin: 20px;
    border: 2px solid #ffcc80;
    border-radius: 12px;
    background-color: #fff3e0;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12), 0 1px 4px rgba(255, 152, 0, 0.15);
    outline: 2px solid #ffcc80;
    outline-offset: -2px;
}

.instruments-section summary {
    padding: 16px 20px;
    cursor: pointer;
    font-weight: bold;
    font-size: 18px;
    user-select: none;
    background: linear-gradient(to right, #fff3e0, #ffe0b2);
    border-bottom: 2px solid #ff9800;
    transition: background-color 0.3s ease;
    text-align: left;
}

.instruments-section summary:hover {
    background: linear-gradient(to right, #ffe0b2, #ffcc80);
}

.instruments-section[open] summary {
    border-bottom: 2px solid #ff9800;
}

#soundControls {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 15px;
    overflow-x: auto;
    padding: 20px;
    padding-bottom: 15px;
    background-color: #fff3e0;
}

.instruments-buttons {
    display: flex;
    justify-content: center;
    padding: 10px 20px 15px;
    background-color: #fff3e0;
    border-top: 1px solid #ffcc80;
    border-radius: 0 0 10px 10px;
}

.control button {
    margin: 10px 5px;
}

.sound-control {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    background-color: #e0e0e0;
    color: #999;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 8px;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease, color 0.2s ease;
    cursor: pointer;
}

.sound-control:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.sound-control.pressed {
    background: linear-gradient(135deg, #ffe0b2 0%, #ffcc80 100%);
    color: #333;
    box-shadow: inset 0 3px 6px rgba(0, 0, 0, 0.2);
    transform: translateY(1px);
}

.sound-control.pressed:hover {
    box-shadow: inset 0 3px 6px rgba(0, 0, 0, 0.2), 0 2px 6px rgba(255, 152, 0, 0.3);
    transform: translateY(0);
}

.sound-control img.icon {
    width: 50px;
    height: 50px;
    margin-bottom: 10px;
    border-radius: 50%;
    border: 2px solid #ccc;
    cursor: pointer;
    opacity: 0.5;
}

.sound-control.pressed img.icon {
    border-color: rgba(255, 255, 255, 0.6);
    opacity: 1;
}

.sound-control img.icon:hover {
    transform: scale(1.1);
    animation: iconHoverPulse 1.5s ease-in-out infinite;
}

.sound-control img.icon:active {
    animation: iconClickEmanate 0.6s ease-out;
}

@keyframes iconHoverPulse {
    0% {
        box-shadow: 0 0 5px 2px rgba(255, 152, 0, 0.4);
    }
    50% {
        box-shadow: 0 0 15px 6px rgba(255, 152, 0, 0.7);
    }
    100% {
        box-shadow: 0 0 5px 2px rgba(255, 152, 0, 0.4);
    }
}

@keyframes iconClickEmanate {
    0% {
        box-shadow: 0 0 0 0 rgba(255, 152, 0, 0.8);
    }
    100% {
        box-shadow: 0 0 0 20px rgba(255, 152, 0, 0);
    }
}

.sound-control label {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.sound-control input[type="checkbox"] {
    margin-top: 5px;
}

.sound-control.glowing {
    box-shadow: 0 0 20px 10px rgba(255, 165, 0, 0.8);
    animation: shrink-glow var(--glow-duration) linear;
}

@keyframes shrink-glow {
    0% {
        box-shadow: 0 0 20px 10px rgba(255, 165, 0, 0.8);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(255, 165, 0, 0);
    }
}

.sound-control.glowing-blue {
    box-shadow: 0 0 5px #ff9800;
    animation: orangeGlowPulse ease-in-out;
    animation-duration: var(--blue-glow-duration, 1s);
}

@keyframes orangeGlowPulse {
    0% {
        box-shadow: 0 0 5px #ff9800;
    }
    50% {
        box-shadow: 0 0 15px #ff9800;
    }
    100% {
        box-shadow: 0 0 5px #ff9800;
    }
}


.control {
    margin: 10px 0;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
}

.instruments-buttons button {
    margin: 0 5px;
}

/* Timeline Wrapper - scrollable/zoomable viewport */
#timelineWrapper {
    position: relative;
    margin: 10px 20px;
    border: 1px solid #ccc;
    border-radius: 8px;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

#timelineControls {
    position: sticky;
    left: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 3px 8px;
    background: hsl(39, 40%, 18%);
    border-bottom: 1px solid hsl(39, 40%, 30%);
}

.zoom-btn {
    width: 26px;
    height: 26px;
    border: 1px solid hsl(39, 40%, 40%);
    background: hsl(39, 30%, 25%);
    color: #ddd;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.zoom-btn:hover {
    background: hsl(39, 40%, 35%);
}

.zoom-btn:active {
    background: hsl(39, 50%, 40%);
}

#zoomLevel {
    font-size: 12px;
    color: #bbb;
    min-width: 32px;
    text-align: center;
}

/* Timeline toolbar buttons (Record, Delete) */
.timeline-btn {
    height: 26px;
    border: 1px solid hsl(39, 40%, 40%);
    background: hsl(39, 30%, 25%);
    color: #ddd;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 8px;
    margin: 0 0 0 2px;
    box-shadow: none;
    transition: background 0.15s ease;
}

.timeline-btn:hover {
    background: hsl(39, 40%, 35%);
    transform: none;
    box-shadow: none;
}

.timeline-btn:active {
    background: hsl(39, 50%, 40%);
}

/* The timeline container spans the inner width and scales with zoom */
#timelineContainer {
    position: relative;
    height: 80px;
    background-color: #fff3e0;
    min-width: 100%;
}

/* The progress overlay shows the bright portion of the timeline */
#timelineProgress {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 0;
    background-color: hsl(39, 100%, 50%);
    transition: width 0.5s linear;
}

/* Style for the instrument icons on the timeline */
.timelineIcon {
    position: absolute;
    top: 10px;
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 50%;
    border: 1px solid #ddd;
    background: #fff;
    z-index: 1;
}

/* Static active state — no animation, used when re-rendering already-played icons */
.timelineIcon.active-icon {
    z-index: 10;
    border-color: #ff9800;
}

/* Animated activation — only added when an icon first becomes active during playback */
.timelineIcon.active-icon-animate {
    animation: flipIcon 0.5s forwards, pulseOrange 2s ease-out;
}

@keyframes flipIcon {
    from {
      transform: rotateY(0deg);
    }
    to {
      transform: rotateY(360deg);
    }
}

@keyframes pulseOrange {
    0% {
      box-shadow: 0 0 0 0 rgba(255, 152, 0, 0.7);
    }
    50% {
      box-shadow: 0 0 15px 10px rgba(255, 152, 0, 1);
    }
    100% {
      box-shadow: 0 0 0 0 rgba(255, 152, 0, 0.7);
    }
}

/* Preset Buttons */
.preset-btn {
    padding: 5px 12px;
    font-size: 13px;
    cursor: pointer;
    margin: 0;
    border-radius: 6px;
}

.preset-btn:disabled {
    background-color: #ccc;
    cursor: not-allowed;
    opacity: 0.5;
    box-shadow: none;
}

.preset-btn-delete:not(:disabled) {
    background: linear-gradient(135deg, #e53935, #c62828);
}

#updateScheduleButton {
    background-color: #ff9800;
}

#updateScheduleButton:hover:not(:disabled) {
    background-color: #e68900;
}

/* Instructions Section */
.instructions {
    margin: 20px;
    border: 2px solid #ffcc80;
    border-radius: 12px;
    background-color: #f9f9f9;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12), 0 1px 4px rgba(255, 152, 0, 0.15);
    outline: 2px solid #ffcc80;
    outline-offset: -2px;
}

.instructions summary {
    padding: 16px 20px;
    cursor: pointer;
    font-weight: bold;
    font-size: 18px;
    user-select: none;
    background: linear-gradient(to right, #fff3e0, #ffe0b2);
    border-bottom: 2px solid #ff9800;
    transition: background-color 0.3s ease;
    text-align: left;
}

.instructions summary:hover {
    background: linear-gradient(to right, #ffe0b2, #ffcc80);
}

.instructions[open] summary {
    border-bottom: 2px solid #ff9800;
}

.instructions-content {
    padding: 20px;
    line-height: 1.6;
    background-color: #fff3e0;
}

.instructions-content h3 {
    margin-top: 15px;
    margin-bottom: 8px;
    color: #e65100;
    font-size: 16px;
}

.instructions-content h3:first-child {
    margin-top: 0;
}

.instructions-content ul,
.instructions-content ol {
    margin: 8px 0;
    padding-left: 25px;
}

.instructions-content li {
    margin: 5px 0;
}

.instructions-content p {
    margin: 8px 0;
}

.setting-hint {
    font-size: 12px;
    color: #999;
    margin-left: 2px;
}

#backgroundControl input:disabled + .setting-hint {
    opacity: 0.5;
}

.background-warning {
    display: block;
    font-size: 13px;
    color: #d32f2f;
    font-weight: bold;
    margin-top: 4px;
}

/* Record Button — push to right side of toolbar */
#recordButton {
    margin-left: auto;
}

#recordButton .record-led {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #666;
    margin-right: 5px;
    flex-shrink: 0;
}

#recordButton.recording {
    border-color: hsl(0, 60%, 40%);
    background: hsl(0, 40%, 25%);
}

#recordButton.recording .record-led {
    background: #ff0000;
    box-shadow: 0 0 6px 2px rgba(255, 0, 0, 0.7);
    animation: redPulse 1s ease-in-out infinite;
}

@keyframes redPulse {
    0% {
        box-shadow: 0 0 3px 1px rgba(255, 0, 0, 0.5);
    }
    50% {
        box-shadow: 0 0 8px 4px rgba(255, 0, 0, 0.9);
    }
    100% {
        box-shadow: 0 0 3px 1px rgba(255, 0, 0, 0.5);
    }
}

/* Delete Button */
#deleteButton.delete-active {
    background: hsl(0, 40%, 25%);
    border-color: hsl(0, 60%, 40%);
    color: #f99;
}

/* Delete mode timeline styling */
#timelineWrapper.delete-mode .timelineIcon {
    cursor: crosshair;
    transition: filter 0.15s ease;
}

#timelineWrapper.delete-mode .timelineIcon:hover {
    filter: brightness(0.6) sepia(1) hue-rotate(-30deg) saturate(3);
    box-shadow: 0 0 8px 3px rgba(211, 47, 47, 0.7);
}

/* Custom Modal Dialog */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: modalFadeIn 0.2s ease;
}

@keyframes modalFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-dialog {
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(255, 152, 0, 0.2);
    width: 90%;
    max-width: 400px;
    overflow: hidden;
    animation: modalSlideIn 0.25s ease;
}

@keyframes modalSlideIn {
    from { transform: translateY(-20px) scale(0.95); opacity: 0; }
    to { transform: translateY(0) scale(1); opacity: 1; }
}

.modal-header {
    background: linear-gradient(135deg, #ff9800 0%, #ff6f00 100%);
    color: white;
    padding: 16px 20px;
    font-size: 18px;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.modal-body {
    padding: 20px;
    background-color: #fff3e0;
}

.modal-body p {
    margin: 0 0 12px 0;
    font-size: 15px;
    color: #333;
    line-height: 1.5;
}

.modal-input {
    width: 100%;
    padding: 10px 12px;
    font-size: 16px;
    border: 2px solid #ffcc80;
    border-radius: 8px;
    background: #fff;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    box-sizing: border-box;
}

.modal-input:focus {
    border-color: #ff9800;
    box-shadow: 0 0 0 3px rgba(255, 152, 0, 0.2);
}

.modal-buttons {
    display: flex;
    gap: 10px;
    padding: 16px 20px;
    background: #f9f9f9;
    border-top: 1px solid #eee;
    justify-content: flex-end;
}

.modal-btn {
    padding: 10px 24px;
    font-size: 15px;
    font-weight: 500;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    margin: 0;
}

.modal-btn:hover {
    transform: translateY(-1px);
}

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

.modal-btn-ok {
    background: linear-gradient(135deg, #ff9800 0%, #ff6f00 100%);
    color: white;
    box-shadow: 0 2px 8px rgba(255, 152, 0, 0.3);
}

.modal-btn-ok:hover {
    box-shadow: 0 4px 12px rgba(255, 152, 0, 0.5);
}

.modal-btn-cancel {
    background: #e0e0e0;
    color: #555;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
}

.modal-btn-cancel:hover {
    background: #d0d0d0;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}
