/* ==================== */
/* CSS Reset & Base */
/* ==================== */

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

:root {
    --primary-color: #4f46e5;
    --primary-hover: #4338ca;
    --secondary-color: #8b5cf6;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --text-primary: #1f2937;
    --text-secondary: #4b5563;
    --bg-primary: #ffffff;
    --bg-secondary: #f3f4f6;
    --border-color: #e5e7eb;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 4px 6px rgba(0, 0, 0, 0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 1rem;
    color: var(--text-primary);
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    background: var(--bg-primary);
    border-radius: 1rem;
    padding: 1.5rem;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

/* ==================== */
/* Header */
/* ==================== */

header {
    text-align: center;
    margin-bottom: 2rem;
}

header h1 {
    font-size: 1.75rem;
    color: var(--primary-color);
}

/* ==================== */
/* Search Section */
/* ==================== */

.search-section {
    margin-bottom: 2rem;
}

.search-results {
    margin-top: 1rem;
    display: grid;
    gap: 0.75rem;
    max-height: 300px;
    overflow-y: auto;
}

.search-result-item {
    background: var(--bg-secondary);
    border-radius: 0.5rem;
    padding: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
    border: 2px solid transparent;
    display: flex;
    gap: 0.75rem;
    align-items: start;
}

.search-result-item:hover {
    border-color: var(--primary-color);
    background: #f9fafb;
}

.search-result-item img {
    width: 120px;
    height: 68px;
    object-fit: cover;
    border-radius: 0.25rem;
    flex-shrink: 0;
}

.search-result-info {
    flex: 1;
    min-width: 0;
}

.search-result-info h4 {
    font-size: 0.875rem;
    margin-bottom: 0.25rem;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.search-result-info p {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* ==================== */
/* Add Video Section */
/* ==================== */

.add-video-section {
    margin-bottom: 2rem;
}

.input-group {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.input-group input {
    flex: 1;
    min-width: 200px;
    padding: 0.875rem 1rem;
    font-size: 1rem;
    border: 2px solid var(--border-color);
    border-radius: 0.5rem;
    outline: none;
    transition: border-color 0.2s;
}

.input-group input:focus {
    border-color: var(--primary-color);
}

/* ==================== */
/* Buttons */
/* ==================== */

.btn {
    padding: 0.875rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.2s;
    outline: none;
    min-height: 48px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    touch-action: manipulation; /* Prevent double-tap zoom */
    user-select: none;
}

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

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-secondary {
    background: var(--secondary-color);
    color: white;
}

.btn-secondary:hover {
    background: #7c3aed;
}

.btn-danger {
    background: var(--danger-color);
    color: white;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    min-height: 36px;
}

.btn-danger:hover {
    background: #dc2626;
}

/* ==================== */
/* Video Library */
/* ==================== */

.video-library {
    margin-bottom: 2rem;
}

.video-library h2 {
    font-size: 1.25rem;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.video-list {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

.video-item {
    background: var(--bg-secondary);
    border-radius: 0.5rem;
    padding: 1rem;
    cursor: pointer;
    transition: all 0.2s;
    border: 2px solid transparent;
}

.video-item:hover {
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.video-item.active {
    border-color: var(--primary-color);
    background: #eef2ff;
}

.video-item-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.video-item h3 {
    font-size: 0.875rem;
    color: var(--text-primary);
    flex: 1;
    word-break: break-word;
}

.video-item .video-id {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-family: monospace;
}

/* ==================== */
/* Player Section */
/* ==================== */

.player-section {
    margin-top: 2rem;
}

.video-container {
    position: relative;
    padding-bottom: 56.25%; /* 16:9 aspect ratio */
    height: 0;
    overflow: hidden;
    border-radius: 0.5rem;
    background: #000;
    margin-bottom: 1rem;
}

.video-container iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.video-info {
    margin-bottom: 1.5rem;
}

.video-info h3 {
    font-size: 1.25rem;
    color: var(--text-primary);
}

/* ==================== */
/* Controls */
/* ==================== */

.controls {
    background: var(--bg-secondary);
    border-radius: 0.75rem;
    padding: 1.5rem;
}

.control-group {
    margin-bottom: 1.5rem;
}

.control-group:last-child {
    margin-bottom: 0;
}

.control-group h4 {
    margin-bottom: 0.75rem;
    color: var(--text-primary);
    font-size: 1rem;
}

/* Main Controls Row */
.main-controls-row {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
}

/* Main Play/Pause Button */
.btn-play-pause {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: var(--primary-color);
    color: white;
    font-size: 2rem;
    padding: 0;
    flex-shrink: 0;
}

.btn-play-pause:hover {
    background: var(--primary-hover);
}

.btn-play-pause .icon {
    display: block;
}

.btn-play-pause.playing .icon::before {
    content: '⏸';
}

/* Skip to Start Button */
.btn-skip {
    background: var(--secondary-color);
    color: white;
    font-size: 1rem;
    min-height: 60px;
    min-width: 70px;
    flex-direction: column;
    gap: 0.25rem;
}

.btn-skip:hover {
    background: #7c3aed;
}

.btn-skip .icon {
    font-size: 1.25rem;
}

.btn-skip .label {
    font-size: 0.75rem;
}

/* Speed Control */
.speed-control label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--text-primary);
}

#speedDisplay {
    color: var(--primary-color);
    font-size: 1.25rem;
}

#speedSlider {
    width: 100%;
    height: 48px;
    margin-bottom: 1rem;
    cursor: pointer;
}

/* Custom range slider styling */
input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    background: transparent;
}

input[type="range"]::-webkit-slider-track {
    height: 8px;
    background: #ddd;
    border-radius: 4px;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 24px;
    height: 24px;
    background: var(--primary-color);
    border-radius: 50%;
    cursor: pointer;
    margin-top: -8px;
}

input[type="range"]::-moz-range-track {
    height: 8px;
    background: #ddd;
    border-radius: 4px;
}

input[type="range"]::-moz-range-thumb {
    width: 24px;
    height: 24px;
    background: var(--primary-color);
    border-radius: 50%;
    cursor: pointer;
    border: none;
}

.speed-presets {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.btn-preset {
    flex: 1;
    min-width: 80px;
    background: white;
    color: var(--primary-color);
    border: 2px solid var(--primary-color);
}

.btn-preset:hover {
    background: var(--primary-color);
    color: white;
}

.btn-preset.active {
    background: var(--primary-color);
    color: white;
}

/* Seek Buttons (in main controls row) */
.btn-seek {
    background: var(--secondary-color);
    color: white;
    font-size: 1rem;
    min-height: 60px;
    min-width: 70px;
    flex-direction: column;
    gap: 0.25rem;
}

.btn-seek:hover {
    background: #7c3aed;
}

.btn-seek .icon {
    font-size: 1.25rem;
}

.btn-seek .label {
    font-size: 0.75rem;
}

/* Timeline */
.timeline {
    margin-top: 1rem;
}

.time-display {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.timeline-container {
    position: relative;
}

.timeline-bar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 8px;
    background: #ddd;
    border-radius: 4px;
    pointer-events: none;
    margin-top: 20px;
}

.progress-bar {
    height: 100%;
    background: var(--primary-color);
    border-radius: 4px;
    width: 0;
    transition: width 0.1s linear;
}

.loop-overlay {
    position: absolute;
    top: 0;
    height: 100%;
    background: rgba(16, 185, 129, 0.3);
    border-left: 2px solid var(--success-color);
    border-right: 2px solid var(--success-color);
}

#timelineSlider {
    width: 100%;
}

/* Loop Controls */
.loop-instructions {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
    padding: 0.75rem;
    background: #f9fafb;
    border-radius: 0.375rem;
    border-left: 3px solid var(--primary-color);
    line-height: 1.5;
}

.loop-buttons {
    display: grid;
    gap: 0.75rem;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}

.btn-loop,
.btn-loop-clear {
    background: white;
    color: var(--text-primary);
    border: 2px solid var(--border-color);
    flex-direction: column;
    min-height: 60px;
    padding: 0.75rem;
}

.btn-loop:hover,
.btn-loop-clear:hover {
    border-color: var(--primary-color);
    background: #f9fafb;
}

.btn-loop.active {
    background: var(--success-color);
    color: white;
    border-color: var(--success-color);
}

.btn-loop:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-loop-clear {
    border-color: var(--danger-color);
    color: var(--danger-color);
}

.btn-loop-clear:hover {
    background: var(--danger-color);
    color: white;
}

.loop-time {
    font-size: 0.875rem;
    font-weight: 400;
    opacity: 0.8;
}

/* ==================== */
/* Responsive Design */
/* ==================== */

/* Tablets and up */
@media (min-width: 768px) {
    .container {
        padding: 2rem;
    }

    header h1 {
        font-size: 2.5rem;
    }

    .video-list {
        grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    }

    .controls {
        padding: 2rem;
    }

    .btn-play-pause {
        width: 100px;
        height: 100px;
        font-size: 2.5rem;
    }

    .btn-seek,
    .btn-skip {
        min-width: 90px;
        min-height: 70px;
    }
}

/* Desktop and up */
@media (min-width: 1024px) {
    .seek-controls {
        max-width: 500px;
        margin: 0 auto;
    }

    .loop-buttons {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* Landscape mobile specific */
@media (max-height: 500px) and (orientation: landscape) {
    body {
        padding: 0.5rem;
    }

    .container {
        padding: 1rem;
    }

    header {
        margin-bottom: 1rem;
    }

    header h1 {
        font-size: 1.5rem;
    }

    .btn-play-pause {
        width: 70px;
        height: 70px;
        font-size: 1.75rem;
    }

    .btn-seek,
    .btn-skip {
        min-width: 60px;
        min-height: 50px;
    }

    .control-group {
        margin-bottom: 1rem;
    }

    .main-controls-row {
        gap: 0.5rem;
    }
}

/* Prevent zoom on double-tap for all interactive elements */
input,
button,
a {
    touch-action: manipulation;
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    .btn {
        min-height: 52px;
    }

    .btn-seek {
        min-height: 68px;
    }

    input[type="range"]::-webkit-slider-thumb {
        width: 28px;
        height: 28px;
    }

    input[type="range"]::-moz-range-thumb {
        width: 28px;
        height: 28px;
    }
}

/* ==================== */
/* Footer               */
/* ==================== */

.app-footer {
    text-align: center;
    padding: 2rem 0 1rem;
    margin-top: 2rem;
    border-top: 1px solid var(--border-color);
}

.app-footer .version {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin: 0;
}

.app-footer .instrument-links {
    margin-top: 0.75rem;
    display: flex;
    justify-content: center;
    gap: 1.25rem;
    flex-wrap: wrap;
}

.app-footer .instrument-links a {
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-decoration: none;
    transition: opacity 0.2s;
}

.app-footer .instrument-links a:hover {
    opacity: 1;
    text-decoration: underline;
}

/* ==================== */
/* Header Enhancements  */
/* ==================== */

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.account-badge {
    padding: 0.5rem 1rem;
    border-radius: 2rem;
    font-size: 0.875rem;
    font-weight: 600;
}

.account-badge.free {
    background: var(--bg-secondary);
    color: var(--text-secondary);
}

.account-badge.paid {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.buy-license-link {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 600;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    transition: opacity 0.2s;
}

.buy-license-link:hover {
    opacity: 0.9;
}

.license-link {
    color: var(--primary-color);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 600;
    transition: opacity 0.2s;
}

.license-link:hover {
    opacity: 0.8;
}

@media (max-width: 640px) {
    .header-content {
        flex-direction: column;
        text-align: center;
    }

    .header-content h1 {
        font-size: 1.5rem;
    }
}

/* ==================== */
/* Modal System         */
/* ==================== */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    padding: 1rem;
    animation: fadeIn 0.2s ease-out;
}

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

.modal-content {
    background: white;
    border-radius: 1rem;
    padding: 2rem;
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    animation: slideUp 0.3s ease-out;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.3);
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: none;
    border: none;
    font-size: 2rem;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s;
}

.modal-close:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.modal-content h2 {
    color: var(--primary-color);
    margin-bottom: 1rem;
    font-size: 1.75rem;
}

.modal-content p {
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 1rem;
}

.modal-actions {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
    flex-wrap: wrap;
}

.modal-actions .btn,
.modal-actions a.btn {
    flex: 1;
    min-width: 140px;
    text-decoration: none;
    text-align: center;
    display: inline-block;
}

/* Welcome Modal */
.welcome-modal .benefits {
    display: grid;
    gap: 1.5rem;
    margin: 2rem 0;
}

.welcome-modal .benefit {
    display: flex;
    gap: 1rem;
    align-items: start;
}

.welcome-modal .benefit-icon {
    font-size: 2rem;
    flex-shrink: 0;
}

.welcome-modal .benefit h3 {
    font-size: 1rem;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.welcome-modal .benefit p {
    font-size: 0.875rem;
    margin: 0;
}

.welcome-modal .account-info {
    background: var(--bg-secondary);
    padding: 1rem;
    border-radius: 0.5rem;
    margin-bottom: 1rem;
}

.welcome-modal .account-info p {
    margin: 0.5rem 0;
    font-size: 0.875rem;
}

/* License Modal */
.license-input {
    width: 100%;
    padding: 0.875rem 1rem;
    font-size: 1rem;
    border: 2px solid var(--border-color);
    border-radius: 0.5rem;
    margin: 1rem 0;
    font-family: monospace;
    text-transform: uppercase;
}

.license-input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.error-message {
    color: var(--danger-color);
    font-size: 0.875rem;
    margin-top: -0.5rem;
    margin-bottom: 1rem;
}

/* ==================== */
/* Referral System      */
/* ==================== */

/* Share & Earn Button in Header */
.btn-share-referral {
    background: linear-gradient(135deg, #14b8a6 0%, #0d9488 100%);
    color: white;
    border: none;
    font-size: 0.875rem;
    font-weight: 600;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-share-referral:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(20, 184, 166, 0.4);
}

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

/* Referral Account Badge */
.account-badge.referral {
    background: linear-gradient(135deg, #14b8a6 0%, #0d9488 100%);
    color: white;
}

/* Referral Modal */
.referral-modal h2 {
    color: #0d9488;
}

.referral-link-box {
    display: flex;
    gap: 0.5rem;
    margin: 1.5rem 0;
    background: var(--bg-secondary);
    padding: 0.5rem;
    border-radius: 0.5rem;
}

.referral-link-box input {
    flex: 1;
    padding: 0.75rem;
    border: 2px solid var(--border-color);
    border-radius: 0.375rem;
    font-size: 0.875rem;
    background: white;
}

.referral-link-box input:focus {
    outline: none;
    border-color: #14b8a6;
}

.referral-link-box .btn {
    min-width: 80px;
    background: #14b8a6;
}

.referral-link-box .btn:hover {
    background: #0d9488;
}

.referral-link-box .btn.copied {
    background: var(--success-color);
}

/* Share Buttons */
.share-buttons {
    display: flex;
    gap: 0.75rem;
    margin: 1.5rem 0;
    flex-wrap: wrap;
}

.btn-share {
    flex: 1;
    min-width: 100px;
    padding: 0.75rem 1rem;
    border: none;
    border-radius: 0.5rem;
    font-weight: 600;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    color: white;
}

.btn-whatsapp {
    background: #25D366;
}

.btn-whatsapp:hover {
    background: #20bd5a;
}

.btn-twitter {
    background: #1DA1F2;
}

.btn-twitter:hover {
    background: #1a8cd8;
}

.btn-email {
    background: #6366f1;
}

.btn-email:hover {
    background: #4f46e5;
}

/* Referral Info */
.referral-info {
    background: var(--bg-secondary);
    padding: 1rem;
    border-radius: 0.5rem;
    margin-top: 1rem;
}

.referral-info p {
    margin: 0.5rem 0;
    font-size: 0.875rem;
}

.referral-status {
    color: var(--text-secondary);
}

.referral-status.active {
    color: #0d9488;
    font-weight: 600;
}

/* Upgrade Modal Options */
.upgrade-features-list {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    margin: 1rem 0;
    padding: 1rem;
    background: var(--bg-secondary);
    border-radius: 0.5rem;
}

.upgrade-feature-item {
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.check-icon {
    color: var(--success-color);
    font-weight: bold;
}

.upgrade-options {
    display: grid;
    gap: 1rem;
    margin: 1rem 0;
}

.upgrade-option {
    text-align: center;
}

.upgrade-option-primary {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
}

.btn-upgrade-main {
    font-size: 1.1rem;
    padding: 0.875rem 2rem;
    width: 100%;
    max-width: 300px;
}

.upgrade-price-hint {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.upgrade-or {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.upgrade-option h3 {
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    font-size: 1rem;
}

.upgrade-option p {
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

.upgrade-option .btn,
.upgrade-option a.btn {
    text-decoration: none;
}

.btn-share-earn {
    background: linear-gradient(135deg, #14b8a6 0%, #0d9488 100%);
    color: white;
    border: none;
    font-size: 1rem;
    font-weight: 600;
    padding: 0.875rem 1.5rem;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.2s;
    width: 100%;
}

.btn-share-earn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(20, 184, 166, 0.4);
}

@media (min-width: 640px) {
    .upgrade-options {
        grid-template-columns: 1fr 1fr;
    }
}

/* Mobile adjustments for header */
@media (max-width: 640px) {
    .btn-share-referral {
        padding: 0.5rem 0.75rem;
        font-size: 0.75rem;
    }

    .share-buttons {
        flex-direction: column;
    }

    .btn-share {
        min-width: auto;
    }
}

/* ==================== */
/* Progressive Speed    */
/* ==================== */

.progressive-section {
    border-top: 1px solid var(--border-color);
    padding-top: 1rem;
}

.progressive-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.25rem;
}

.progressive-header h4 {
    margin: 0;
}

.progressive-hint {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    cursor: pointer;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    inset: 0;
    background: #d1d5db;
    border-radius: 24px;
    transition: background 0.2s;
}

.toggle-slider::before {
    content: '';
    position: absolute;
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background: white;
    border-radius: 50%;
    transition: transform 0.2s;
}

.toggle-switch input:checked + .toggle-slider {
    background: var(--primary-color);
}

.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(20px);
}

.progressive-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: end;
}

.progressive-setting {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    flex: 1;
    min-width: 100px;
}

.progressive-setting label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    white-space: nowrap;
}

.progressive-input {
    width: 100%;
    padding: 0.4rem 0.5rem;
    border: 2px solid var(--border-color);
    border-radius: 0.375rem;
    font-size: 0.85rem;
    text-align: center;
}

.progressive-input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.progressive-progress-bar {
    width: 100%;
    height: 6px;
    background: var(--bg-secondary);
    border-radius: 3px;
    overflow: hidden;
    margin-top: 0.5rem;
}

.progressive-progress-fill {
    height: 100%;
    background: var(--success-color);
    border-radius: 3px;
    transition: width 0.3s ease;
    width: 0%;
}

.progressive-status {
    width: 100%;
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-align: center;
    margin-top: 0.25rem;
    min-height: 1.2em;
}

/* Progressive notification toast */
.progressive-notification {
    position: fixed;
    top: 1rem;
    left: 50%;
    transform: translateX(-50%) translateY(-60px);
    background: var(--success-color);
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 0.5rem;
    font-weight: 600;
    font-size: 0.95rem;
    z-index: 10000;
    opacity: 0;
    transition: transform 0.3s ease, opacity 0.3s ease;
    pointer-events: none;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.progressive-notification.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.progressive-notification.progressive-complete {
    background: linear-gradient(135deg, #667eea, #764ba2);
}

/* ==================== */
/* Saved Loops          */
/* ==================== */

.save-loop-section h4 {
    margin-bottom: 0.75rem;
}

.save-loop-row {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.loop-name-input {
    flex: 1;
    min-width: 200px;
    padding: 0.75rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: 0.5rem;
    font-size: 0.9rem;
}

.loop-name-input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.btn-save-loop {
    background: var(--success-color);
    color: white;
    white-space: nowrap;
}

.btn-save-loop:hover {
    background: #059669;
}

.btn-save-loop:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.saved-loops-container {
    display: grid;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.saved-loop-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    padding: 0.75rem 1rem;
    gap: 1rem;
}

.saved-loop-info {
    flex: 1;
    min-width: 0;
}

.saved-loop-name {
    font-weight: 600;
    font-size: 0.9rem;
    display: block;
}

.saved-loop-times {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-family: monospace;
}

.saved-loop-actions {
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;
}

.btn-loop-load {
    background: var(--primary-color);
    color: white;
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
    min-height: 36px;
    border-radius: 0.375rem;
    border: none;
    cursor: pointer;
    font-weight: 600;
}

.btn-loop-load:hover {
    background: var(--primary-hover);
}

.btn-loop-delete {
    background: white;
    color: var(--danger-color);
    border: 1px solid var(--danger-color);
    padding: 0.4rem 0.6rem;
    font-size: 0.9rem;
    min-height: 36px;
    border-radius: 0.375rem;
    cursor: pointer;
}

.btn-loop-delete:hover {
    background: var(--danger-color);
    color: white;
}

.no-loops-hint {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-style: italic;
    text-align: center;
    padding: 0.5rem;
}

.keyboard-hints {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-align: center;
    margin-top: 0.75rem;
    padding: 0.5rem;
    background: #f9fafb;
    border-radius: 0.375rem;
}

/* ==================== */
/* Welcome Banner       */
/* ==================== */

.welcome-banner {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    border-radius: 0.75rem;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    animation: bannerSlideDown 0.4s ease-out;
}

@keyframes bannerSlideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.welcome-banner-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1.5rem;
}

.welcome-banner-text h2 {
    color: #ffffff;
    font-size: 1.25rem;
    margin-bottom: 0.375rem;
}

.welcome-banner-text p {
    color: #a0aec0;
    font-size: 0.9rem;
    margin: 0;
    line-height: 1.5;
}

.welcome-banner-text .welcome-subtitle {
    color: #667eea;
    font-weight: 500;
    margin-bottom: 0.75rem;
}

.welcome-shortcuts {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.shortcut-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.75rem;
    color: #a0aec0;
}

.shortcut-tag kbd,
.shortcuts-tooltip-list kbd {
    display: inline-block;
    background: rgba(102, 126, 234, 0.2);
    color: #667eea;
    border: 1px solid rgba(102, 126, 234, 0.3);
    border-radius: 0.25rem;
    padding: 0.125rem 0.375rem;
    font-family: inherit;
    font-size: 0.7rem;
    font-weight: 600;
    min-width: 1.5rem;
    text-align: center;
}

.btn-welcome-dismiss {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 0.5rem 1.25rem;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    flex-shrink: 0;
}

.btn-welcome-dismiss:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

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

@media (max-width: 640px) {
    .welcome-banner-content {
        flex-direction: column;
        align-items: flex-start;
    }

    .btn-welcome-dismiss {
        align-self: flex-start;
    }

    .welcome-shortcuts {
        gap: 0.375rem;
    }
}

/* ==================== */
/* Shortcuts Help Icon  */
/* ==================== */

.video-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.shortcuts-help {
    position: relative;
    flex-shrink: 0;
}

.btn-shortcuts-help {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 2px solid var(--border-color);
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    padding: 0;
}

.btn-shortcuts-help:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
    background: #eef2ff;
}

.shortcuts-tooltip {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: #1a1a2e;
    border-radius: 0.5rem;
    padding: 1rem;
    min-width: 220px;
    z-index: 100;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
    animation: tooltipFadeIn 0.15s ease-out;
}

@keyframes tooltipFadeIn {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

.shortcuts-tooltip.visible {
    display: block;
}

.shortcuts-tooltip-title {
    color: #667eea;
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.75rem;
}

.shortcuts-tooltip-list {
    display: grid;
    gap: 0.5rem;
}

.shortcut-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.shortcut-row span {
    color: #a0aec0;
    font-size: 0.8rem;
}

.shortcuts-tooltip-list kbd {
    background: rgba(102, 126, 234, 0.15);
    border-color: rgba(102, 126, 234, 0.25);
}

/* ==================== */
/* Share Section         */
/* ==================== */

.share-section {
    margin-top: 1.5rem;
    margin-bottom: 1rem;
}

.share-section-inner {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    border-radius: 0.75rem;
    padding: 1.25rem 1.5rem;
}

.share-section-inner h4 {
    color: #ffffff;
    font-size: 1rem;
    margin-bottom: 0.375rem;
}

.share-section-inner p {
    color: #a0aec0;
    font-size: 0.8rem;
    margin-bottom: 0.75rem;
    line-height: 1.4;
}

.share-url-row {
    display: flex;
    gap: 0.5rem;
}

.share-url-input {
    flex: 1;
    padding: 0.625rem 0.875rem;
    border: 2px solid rgba(102, 126, 234, 0.3);
    border-radius: 0.5rem;
    font-size: 0.8rem;
    background: rgba(255, 255, 255, 0.05);
    color: #e2e8f0;
    font-family: monospace;
    min-width: 0;
}

.share-url-input:focus {
    outline: none;
    border-color: #667eea;
}

.btn-copy-share {
    padding: 0.625rem 1.25rem;
    font-size: 0.85rem;
    white-space: nowrap;
    min-height: 40px;
}

.btn-copy-share.copied {
    background: var(--success-color);
}

@media (max-width: 480px) {
    .share-url-row {
        flex-direction: column;
    }

    .btn-copy-share {
        width: 100%;
    }
}

.share-social-buttons {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.75rem;
    flex-wrap: wrap;
}

.btn-social {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 0.5rem;
    font-size: 0.85rem;
    font-weight: 500;
    color: #ffffff;
    cursor: pointer;
    transition: all 0.2s ease;
    flex: 1;
    min-width: fit-content;
    justify-content: center;
}

.btn-social svg {
    flex-shrink: 0;
}

.btn-twitter {
    background: #1DA1F2;
}

.btn-twitter:hover {
    background: #1a8cd8;
    transform: translateY(-1px);
}

.btn-reddit {
    background: #FF4500;
}

.btn-reddit:hover {
    background: #e03d00;
    transform: translateY(-1px);
}

.btn-facebook {
    background: #1877F2;
}

.btn-facebook:hover {
    background: #1664d4;
    transform: translateY(-1px);
}

@media (max-width: 480px) {
    .share-social-buttons {
        flex-direction: column;
    }

    .btn-social {
        width: 100%;
    }
}

/* ==================== */
/* Demo / Try It Section */
/* ==================== */

.demo-section {
    margin-top: 2.5rem;
    margin-bottom: 1.5rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border-color);
}

.demo-section h2 {
    font-size: 1.25rem;
    color: var(--text-primary);
    margin-bottom: 0.375rem;
}

.demo-subtitle {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 1.25rem;
    line-height: 1.5;
}

.demo-links {
    display: grid;
    gap: 0.75rem;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

.demo-card {
    display: flex;
    gap: 1rem;
    align-items: center;
    padding: 1rem 1.25rem;
    background: var(--bg-secondary);
    border: 2px solid transparent;
    border-radius: 0.75rem;
    text-decoration: none;
    color: inherit;
    transition: all 0.2s;
    cursor: pointer;
}

.demo-card:hover {
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
    background: #eef2ff;
}

.demo-card:active {
    transform: translateY(0);
}

.demo-icon {
    font-size: 2rem;
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: white;
    border-radius: 0.5rem;
    box-shadow: var(--shadow);
}

.demo-info {
    flex: 1;
    min-width: 0;
}

.demo-info h3 {
    font-size: 0.9rem;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
    line-height: 1.3;
}

.demo-info p {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 0.375rem;
    line-height: 1.3;
}

.demo-tag {
    display: inline-block;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--primary-color);
    background: rgba(99, 102, 241, 0.1);
    padding: 0.125rem 0.5rem;
    border-radius: 1rem;
}

@media (max-width: 640px) {
    .demo-links {
        grid-template-columns: 1fr;
    }
}

/* ==================== */
/* Mobile Practice UX   */
/* ==================== */

/* 1. Large touch targets for loop controls on mobile */
@media (max-width: 767px) {
    .loop-buttons {
        grid-template-columns: 1fr 1fr;
        gap: 0.5rem;
    }

    .btn-loop,
    .btn-loop-clear {
        min-height: 56px;
        padding: 0.875rem;
        font-size: 1rem;
        font-weight: 600;
    }

    .btn-loop .loop-time {
        font-size: 0.9rem;
    }
}

/* 2. Mobile speed preset quick-access buttons */
.speed-presets-mobile {
    display: none;
}

@media (max-width: 767px) {
    .speed-presets-mobile {
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        gap: 0.5rem;
        margin-bottom: 0.75rem;
    }

    .speed-presets-mobile .btn-preset-mobile {
        padding: 0.75rem 0.5rem;
        font-size: 1rem;
        font-weight: 700;
        border: 2px solid var(--primary-color);
        border-radius: 0.5rem;
        background: white;
        color: var(--primary-color);
        cursor: pointer;
        min-height: 52px;
        display: flex;
        align-items: center;
        justify-content: center;
        touch-action: manipulation;
        user-select: none;
        transition: all 0.15s;
    }

    .speed-presets-mobile .btn-preset-mobile:active {
        transform: scale(0.96);
    }

    .speed-presets-mobile .btn-preset-mobile.active {
        background: var(--primary-color);
        color: white;
    }
}

/* 4. Landscape optimisation - maximise video player */
@media (max-height: 500px) and (orientation: landscape) {
    .container {
        padding: 0.5rem;
        border-radius: 0;
    }

    header {
        margin-bottom: 0.5rem;
    }

    header h1 {
        font-size: 1.25rem;
    }

    .header-actions {
        gap: 0.5rem;
    }

    .add-video-section {
        margin-bottom: 0.75rem;
    }

    .video-library {
        margin-bottom: 0.75rem;
    }

    .video-library h2 {
        font-size: 1rem;
        margin-bottom: 0.5rem;
    }

    .player-section {
        margin-top: 0.5rem;
    }

    .video-container {
        margin-bottom: 0.5rem;
    }

    .video-info {
        margin-bottom: 0.5rem;
    }

    .video-info h3 {
        font-size: 1rem;
    }

    .controls {
        padding: 0.75rem;
    }

    .control-group {
        margin-bottom: 0.5rem;
    }

    .loop-instructions {
        display: none;
    }

    .keyboard-hints {
        display: none;
    }

    .speed-presets-mobile {
        grid-template-columns: repeat(4, 1fr);
        gap: 0.375rem;
    }

    .speed-presets-mobile .btn-preset-mobile {
        min-height: 44px;
        padding: 0.5rem;
        font-size: 0.9rem;
    }

    .btn-play-pause {
        width: 60px;
        height: 60px;
        font-size: 1.5rem;
    }

    .btn-seek,
    .btn-skip {
        min-width: 56px;
        min-height: 44px;
        font-size: 0.875rem;
    }

    /* Hide non-essential sections in landscape */
    .welcome-banner,
    .demo-section,
    .share-section {
        display: none;
    }
}

/* 5. Sticky speed/loop controls on mobile */
@media (max-width: 767px) {
    .controls {
        position: sticky;
        top: 0;
        z-index: 50;
        border-radius: 0 0 0.75rem 0.75rem;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
        max-height: 80vh;
        overflow-y: auto;
    }
}

/* ==================== */
/* Practice Timer Chip  */
/* ==================== */

.practice-timer-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    color: #667eea;
    font-size: 0.8rem;
    font-weight: 700;
    font-family: monospace;
    padding: 0.25rem 0.65rem;
    border-radius: 1rem;
    margin-left: 0.5rem;
    vertical-align: middle;
    letter-spacing: 0.03em;
    border: 1px solid rgba(102, 126, 234, 0.25);
    transition: opacity 0.3s;
}

.practice-timer-chip.active {
    color: #10b981;
    border-color: rgba(16, 185, 129, 0.3);
}

/* ==================== */
/* Session Stats Section*/
/* ==================== */

.session-stats-section {
    margin-top: 1.5rem;
    margin-bottom: 1rem;
}

.session-stats-toggle {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    color: #a0aec0;
    border: none;
    border-radius: 0.75rem;
    padding: 0.75rem 1.25rem;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.session-stats-toggle:hover {
    color: #ffffff;
}

.session-stats-toggle.open {
    border-radius: 0.75rem 0.75rem 0 0;
}

.session-stats-toggle-arrow {
    font-size: 0.7rem;
    transition: transform 0.2s;
}

.session-stats-toggle.open .session-stats-toggle-arrow {
    transform: rotate(180deg);
}

.session-stats-body {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    border-radius: 0 0 0.75rem 0.75rem;
    padding: 0 1.25rem 1.25rem;
    display: none;
}

.session-stats-body.open {
    display: block;
}

.session-stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.75rem;
}

.stat-card {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(102, 126, 234, 0.15);
    border-radius: 0.5rem;
    padding: 0.75rem 0.5rem;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.stat-label {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #667eea;
}

.stat-value {
    font-size: 1.1rem;
    font-weight: 700;
    color: #e2e8f0;
    font-family: monospace;
}

.streak-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    margin-top: 0.75rem;
    padding: 0.5rem;
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.25);
    border-radius: 0.5rem;
}

.streak-flame {
    color: #10b981;
    font-size: 1rem;
}

.streak-text {
    color: #10b981;
    font-size: 0.8rem;
    font-weight: 600;
}

@media (max-width: 480px) {
    .session-stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-height: 500px) and (orientation: landscape) {
    .session-stats-section {
        display: none;
    }
}

/* Wake lock indicator */
.wake-lock-indicator {
    display: none;
    font-size: 0.7rem;
    color: var(--success-color);
    text-align: center;
    padding: 0.25rem;
    opacity: 0.7;
}

.wake-lock-indicator.active {
    display: block;
}

/* ==================== */
/* Metronome Section    */
/* ==================== */

.metronome-section {
    margin-top: 1.5rem;
    margin-bottom: 1rem;
}

.metronome-toggle {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    color: #a0aec0;
    border: none;
    border-radius: 0.75rem;
    padding: 0.75rem 1.25rem;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.metronome-toggle:hover {
    color: #ffffff;
}

.metronome-toggle.open {
    border-radius: 0.75rem 0.75rem 0 0;
}

.metronome-toggle-arrow {
    font-size: 0.7rem;
    transition: transform 0.2s;
}

.metronome-toggle.open .metronome-toggle-arrow {
    transform: rotate(180deg);
}

.metronome-body {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    border-radius: 0 0 0.75rem 0.75rem;
    padding: 0 1.25rem 1.25rem;
    display: none;
}

.metronome-body.open {
    display: block;
}

.metronome-controls {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.metronome-label {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #667eea;
    display: block;
    margin-bottom: 0.25rem;
}

.metronome-bpm-row {
    display: flex;
    align-items: flex-end;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.metronome-bpm-group {
    flex: 0 0 auto;
}

.metronome-bpm-input {
    width: 80px;
    padding: 0.5rem 0.625rem;
    border: 2px solid rgba(102, 126, 234, 0.3);
    border-radius: 0.5rem;
    font-size: 1.1rem;
    font-weight: 700;
    font-family: monospace;
    background: rgba(255, 255, 255, 0.05);
    color: #e2e8f0;
    text-align: center;
    outline: none;
    transition: border-color 0.2s;
    -moz-appearance: textfield;
}

.metronome-bpm-input::-webkit-inner-spin-button,
.metronome-bpm-input::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.metronome-bpm-input:focus {
    border-color: #667eea;
}

.metronome-time-sig-group {
    flex: 0 0 auto;
}

.metronome-time-sig-select {
    padding: 0.5rem 0.625rem;
    border: 2px solid rgba(102, 126, 234, 0.3);
    border-radius: 0.5rem;
    font-size: 0.9rem;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.05);
    color: #e2e8f0;
    outline: none;
    cursor: pointer;
    transition: border-color 0.2s;
    min-height: 40px;
}

.metronome-time-sig-select:focus {
    border-color: #667eea;
}

.metronome-time-sig-select option {
    background: #1a1a2e;
    color: #e2e8f0;
}

.metronome-tap-btn {
    background: rgba(102, 126, 234, 0.15);
    color: #667eea;
    border: 2px solid rgba(102, 126, 234, 0.3);
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    font-weight: 600;
    min-height: 40px;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}

.metronome-tap-btn:hover {
    background: rgba(102, 126, 234, 0.25);
    border-color: #667eea;
}

.metronome-tap-btn:active {
    transform: scale(0.95);
    background: rgba(102, 126, 234, 0.35);
}

.metronome-action-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.metronome-start-btn {
    background: var(--success-color);
    color: white;
    padding: 0.5rem 1.5rem;
    font-size: 0.9rem;
    font-weight: 700;
    min-height: 44px;
    min-width: 90px;
    border-radius: 0.5rem;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
}

.metronome-start-btn:hover {
    background: #059669;
}

.metronome-start-btn.running {
    background: var(--danger-color);
}

.metronome-start-btn.running:hover {
    background: #dc2626;
}

.metronome-beat-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    flex-shrink: 0;
}

.metronome-beat-dot {
    display: block;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: rgba(102, 126, 234, 0.2);
    border: 2px solid rgba(102, 126, 234, 0.3);
    transition: background 0.05s, border-color 0.05s, transform 0.05s;
}

.metronome-beat-dot.flash {
    background: #667eea;
    border-color: #667eea;
    transform: scale(1.3);
}

.metronome-beat-dot.flash-downbeat {
    background: #10b981;
    border-color: #10b981;
    transform: scale(1.4);
}

.metronome-volume-group {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 100px;
}

.metronome-volume-slider {
    width: 100%;
    height: 28px;
    cursor: pointer;
}

.metronome-volume-slider::-webkit-slider-track {
    height: 6px;
    background: rgba(102, 126, 234, 0.2);
    border-radius: 3px;
}

.metronome-volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    background: #667eea;
    border-radius: 50%;
    cursor: pointer;
    margin-top: -6px;
}

.metronome-volume-slider::-moz-range-track {
    height: 6px;
    background: rgba(102, 126, 234, 0.2);
    border-radius: 3px;
}

.metronome-volume-slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    background: #667eea;
    border-radius: 50%;
    cursor: pointer;
    border: none;
}

@media (max-width: 480px) {
    .metronome-bpm-row {
        gap: 0.5rem;
    }

    .metronome-action-row {
        gap: 0.75rem;
    }

    .metronome-tap-btn {
        flex: 1;
    }
}

@media (max-height: 500px) and (orientation: landscape) {
    .metronome-section {
        display: none !important;
    }
}

/* ==================== */
/* YouTube API Loading Placeholder */
/* ==================== */

.yt-loading-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    background: #1a1a2e;
    border-radius: 12px;
    color: #a0a0b8;
    font-size: 0.95rem;
    gap: 1rem;
}

.yt-loading-placeholder p {
    margin: 0;
}

.yt-loading-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid rgba(99, 102, 241, 0.2);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: yt-spin 0.8s linear infinite;
}

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