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

:root {
    --primary-color: #ffffff;
    --primary-hover: #e0e0e0;
    --secondary-color: #cccccc;
    --background: #000000;
    --surface: #1a1a1a;
    --surface-light: #2a2a2a;
    --text-primary: #ffffff;
    --text-secondary: #aaaaaa;
    --border-color: #555555;
    --success: #888888;
    --error: #666666;
    --shadow: rgba(0, 0, 0, 0.5);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--background);
    color: var(--text-primary);
    min-height: 100vh;
    padding: 20px;
    line-height: 1.6;
    -webkit-tap-highlight-color: transparent; /* Remove tap highlights on mobile */
    touch-action: manipulation; /* Improve touch responsiveness */
}

.container {
    max-width: 900px;
    margin: 0 auto;
}

header {
    text-align: center;
    margin-bottom: 40px;
    padding-top: 20px;
}

.banner-header {
    padding-top: 0;
    margin-bottom: 40px;
}

.banner-header .banner {
    display: block;
    width: 100%;
    max-width: 100%;
    height: auto;
    vertical-align: middle;
}

.back-to-studio {
    display: inline-block;
    margin-top: 12px;
    padding: 10px 20px;
    background: var(--surface);
    color: var(--text-primary);
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 500;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    transition: background 0.2s, border-color 0.2s;
}

.back-to-studio:hover {
    background: var(--surface-light);
    border-color: var(--secondary-color);
}

header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

/* Waveform Section (always visible: placeholder or waveform) */
.waveform-section {
    margin-bottom: 30px;
    min-height: 180px;
}

.waveform-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 180px;
    border: 2px dashed var(--border-color);
    border-radius: 12px;
    padding: 60px 20px;
    text-align: center;
    background: var(--surface);
    transition: all 0.3s ease;
    cursor: pointer;
}

.waveform-placeholder:hover {
    border-color: var(--text-primary);
    background: var(--surface-light);
}

.waveform-section.dragover .waveform-placeholder {
    border-color: var(--text-primary);
    background: var(--surface-light);
    transform: scale(1.02);
}

.waveform-section.dragover {
    outline: 2px dashed var(--text-primary);
    outline-offset: 2px;
    border-radius: 12px;
}

.waveform-placeholder-label {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.waveform-placeholder-label svg {
    color: var(--text-secondary);
}

.waveform-placeholder-text {
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-primary);
}

.file-info {
    margin-top: 16px;
    padding: 16px;
    background: var(--surface);
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

.file-name {
    font-weight: 500;
    color: var(--text-primary);
    word-break: break-all;
}

.file-duration {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Loading */
.loading {
    text-align: center;
    padding: 40px;
    color: var(--text-secondary);
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--surface-light);
    border-top-color: var(--text-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 16px;
}

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

/* Controls Section */
.controls-section {
    background: var(--surface);
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 4px 6px var(--shadow);
}

.waveform-container {
    margin-bottom: 24px;
    background: var(--background);
    border-radius: 8px;
    padding: 16px;
    position: relative;
    overflow: hidden;
    touch-action: pan-y; /* Allow vertical scrolling but handle horizontal touch */
    -webkit-tap-highlight-color: transparent;
    user-select: none; /* Prevent text selection while scrubbing */
    -webkit-user-select: none;
}

#waveform {
    width: 100%;
}

/* Playback Controls */
.playback-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 24px;
    margin-bottom: 32px;
}

.btn {
    background: var(--surface-light);
    color: var(--text-primary);
    border: 2px solid var(--border-color);
    border-radius: 50%;
    width: 56px;
    height: 56px;
    min-width: 56px;
    min-height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    touch-action: manipulation; /* Improve touch responsiveness */
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px var(--shadow);
    -webkit-tap-highlight-color: transparent; /* Remove tap highlight on mobile */
}

.btn:hover {
    background: var(--surface);
    border-color: var(--text-primary);
    transform: scale(1.05);
}

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

.btn-icon {
    padding: 0;
}

.time-display {
    font-size: 1.1rem;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
    min-width: 100px;
    text-align: center;
}

.separator {
    color: var(--text-secondary);
    margin: 0 4px;
}

/* Speed Control */
.speed-control {
    margin-bottom: 24px;
}

.quality-tip {
    margin-top: 8px;
    text-align: center;
    color: var(--text-secondary);
    font-style: italic;
}

.control-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    font-weight: 500;
    color: var(--text-primary);
}

.speed-value {
    color: var(--primary-color);
    font-weight: 600;
    font-size: 1.1rem;
}

.slider-container {
    position: relative;
}

.slider {
    width: 100%;
    height: 10px;
    border-radius: 4px;
    background: var(--surface-light);
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 24px;
    height: 24px;
    min-width: 24px;
    min-height: 24px;
    border-radius: 50%;
    background: var(--text-primary);
    border: 2px solid var(--border-color);
    cursor: pointer;
    touch-action: manipulation;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px var(--shadow);
}

.slider::-webkit-slider-thumb:hover {
    background: var(--text-secondary);
    transform: scale(1.2);
}

.slider::-moz-range-thumb {
    width: 24px;
    height: 24px;
    min-width: 24px;
    min-height: 24px;
    border-radius: 50%;
    background: var(--text-primary);
    border: 2px solid var(--border-color);
    cursor: pointer;
    touch-action: manipulation;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px var(--shadow);
}

.slider::-moz-range-thumb:hover {
    background: var(--text-secondary);
    transform: scale(1.2);
}

.slider-labels {
    position: relative;
    margin-top: 8px;
    height: 16px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.slider-labels span {
    position: absolute;
    top: 0;
    transform: translateX(-50%);
    white-space: nowrap;
}

/* Loop Section */
.loop-section {
    margin-top: 24px;
    padding: 16px 20px;
    border-radius: 8px;
    background: var(--background);
    border: 1px solid var(--border-color);
}

.loop-section .loop-control {
    margin-top: 0;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    color: var(--text-primary);
    font-size: 1rem;
}

.checkbox-label input[type="checkbox"] {
    width: 24px;
    height: 24px;
    min-width: 24px;
    min-height: 24px;
    cursor: pointer;
    accent-color: var(--text-primary);
    touch-action: manipulation;
}

.loop-help {
    margin-top: 8px;
    padding-left: 32px;
    color: var(--text-secondary);
}

/* Keyboard Shortcuts Info */
.shortcuts-info {
    margin-top: 16px;
    padding: 12px;
    background: var(--background);
    border-radius: 6px;
    text-align: center;
    color: var(--text-secondary);
}

kbd {
    display: inline-block;
    padding: 2px 6px;
    background: var(--surface-light);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-family: monospace;
    font-size: 0.9em;
    color: var(--text-primary);
    box-shadow: 0 1px 2px var(--shadow);
}

/* Error Message */
.error-message {
    background: var(--surface-light);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 16px;
    border-radius: 8px;
    margin-top: 20px;
    text-align: center;
}

/* Responsive Design */
@media (max-width: 768px) {
    header h1 {
        font-size: 2rem;
    }

    .waveform-placeholder {
        padding: 40px 20px;
    }

    .controls-section {
        padding: 20px;
    }

    .playback-controls {
        gap: 16px;
    }

    .time-display {
        font-size: 1rem;
        min-width: 80px;
    }
    
    /* Larger touch targets for mobile */
    .btn {
        width: 64px;
        height: 64px;
        min-width: 64px;
        min-height: 64px;
    }
    
    .slider {
        height: 12px;
    }
    
    .slider::-webkit-slider-thumb {
        width: 28px;
        height: 28px;
        min-width: 28px;
        min-height: 28px;
    }
    
    .slider::-moz-range-thumb {
        width: 28px;
        height: 28px;
        min-width: 28px;
        min-height: 28px;
    }
    
    .waveform-container {
        padding: 12px;
        min-height: 120px; /* Ensure waveform is tall enough for touch */
    }
}

@media (max-width: 480px) {
    body {
        padding: 12px;
    }

    header h1 {
        font-size: 1.75rem;
    }

    .subtitle {
        font-size: 1rem;
    }

    .file-info {
        flex-direction: column;
        align-items: flex-start;
    }
    
    /* Even larger touch targets for small phones */
    .btn {
        width: 72px;
        height: 72px;
        min-width: 72px;
        min-height: 72px;
    }
    
    .slider::-webkit-slider-thumb {
        width: 32px;
        height: 32px;
        min-width: 32px;
        min-height: 32px;
    }
    
    .slider::-moz-range-thumb {
        width: 32px;
        height: 32px;
        min-width: 32px;
        min-height: 32px;
    }
    
    .waveform-container {
        min-height: 140px; /* Taller waveform for easier touch interaction */
    }
    
    .waveform-placeholder {
        padding: 30px 15px;
    }
}

/* Footer */
.site-footer {
    text-align: center;
    padding: 40px 20px 30px;
    margin-top: 48px;
    background: var(--background);
    border-top: 1px solid var(--border-color);
    color: #E6D7B7;
}

.site-footer p {
    margin: 0 0 12px;
    font-size: 0.95rem;
}

.site-footer a {
    color: #E6D7B7;
    text-decoration: none;
}

.site-footer a:hover {
    text-decoration: underline;
}

.footer-sep {
    margin: 0 0.5em;
    opacity: 0.8;
}

.footer-social {
    display: flex;
    justify-content: center;
    gap: 16px;
    margin-top: 20px;
}

.footer-social-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: 1.5px solid #E6D7B7;
    border-radius: 50%;
    color: #E6D7B7;
    transition: opacity 0.2s ease;
}

.footer-social-link:hover {
    opacity: 0.85;
    text-decoration: none;
}

.footer-icon {
    width: 22px;
    height: 22px;
}
