        :root {
            --bg-dark: #0f172a;
            --panel-bg: rgba(30, 41, 59, 0.75);
            --panel-border: rgba(255, 255, 255, 0.1);
            --accent-primary: #38bdf8;
            /* Sky Blue */
            --accent-success: #4ade80;
            /* Green */
            --accent-danger: #f472b6;
            /* Pink/Red */
            --text-main: #f1f5f9;
            --text-muted: #94a3b8;
            --court-green: #059669;

        }

        /* Utility class to hide elements regardless of media query !important rules */
        /* Must use high specificity (ID + class) to override media query rules like #btnAddStep.desktop-only */
        .hidden-readonly {
            display: none !important;
        }

        /* High-specificity overrides for edit control buttons (override @media 900px rules) */
        #btnAddStep.hidden-readonly,
        #btnDelStep.hidden-readonly,
        #btnEditNote.hidden-readonly,
        #editDivider1.hidden-readonly,
        #editDivider2.hidden-readonly,
        #birdieHitLabel.hidden-readonly,
        #birdieHitImage.hidden-readonly,
        #btnAddStepMobile.hidden-readonly,
        #btnDelStepMobile.hidden-readonly,
        #btnEditNoteMobile.hidden-readonly,
        /* Mobile group containers */
        .mobile-group.hidden-readonly,
        #mobile-tools-panel .hidden-readonly {
            display: none !important;
        }



        body {
            margin: 0;
            overflow: hidden;
            font-family: 'Inter', sans-serif;
            background: var(--bg-dark);
            color: var(--text-main);
            user-select: none;
        }

        /* --- Loading Overlay --- */
        #loading-overlay {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: #0f172a;
            display: flex;
            justify-content: center;
            align-items: center;
            z-index: 1000;
            transition: opacity 0.5s;
        }

        .loading-content {
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 20px;
            width: 280px;
        }

        .loading-title {
            display: flex;
            align-items: center;
            gap: 12px;
            font-size: 1.4rem;
            font-weight: 700;
            color: var(--text-main);
            letter-spacing: 0.5px;
        }

        .loading-progress-track {
            width: 100%;
            height: 6px;
            background: rgba(255, 255, 255, 0.08);
            border-radius: 3px;
            overflow: hidden;
        }

        .loading-progress-fill {
            height: 100%;
            width: 0%;
            background: linear-gradient(90deg, #38bdf8, #818cf8, #38bdf8);
            background-size: 200% 100%;
            border-radius: 3px;
            transition: width 0.4s ease;
            animation: progressShimmer 2s ease-in-out infinite;
            box-shadow: 0 0 8px rgba(56, 189, 248, 0.4);
        }

        @keyframes progressShimmer {
            0% {
                background-position: 200% 0;
            }

            100% {
                background-position: -200% 0;
            }
        }

        .loading-info {
            display: flex;
            justify-content: space-between;
            width: 100%;
            font-size: 0.8rem;
        }

        .loading-status {
            color: var(--text-muted);
        }

        .loading-percent {
            color: var(--accent-primary);
            font-weight: 600;
            font-variant-numeric: tabular-nums;
        }

        /* --- Modal Dialog --- */
        .modal-overlay {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(0, 0, 0, 0.7);
            z-index: 2000;
            display: none;
            justify-content: center;
            align-items: center;
            backdrop-filter: blur(4px);
        }

        .modal-box {
            background: var(--bg-dark);
            border: 1px solid var(--panel-border);
            border-radius: 12px;
            padding: 20px;
            width: 90%;
            max-width: 400px;
            box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
            display: flex;
            flex-direction: column;
            gap: 15px;
        }

        .modal-header {
            font-size: 1.1rem;
            font-weight: 700;
            color: var(--text-main);
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        .modal-textarea {
            width: 100%;
            height: 100px;
            background: rgba(0, 0, 0, 0.3);
            border: 1px solid var(--panel-border);
            color: var(--text-main);
            border-radius: 8px;
            padding: 10px;
            font-family: inherit;
            resize: vertical;
            box-sizing: border-box;
        }

        .modal-textarea:focus {
            outline: none;
            border-color: var(--accent-primary);
        }

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

        /* Mobile: Position Step Notes modal at top to avoid keyboard overlap */
        @media (max-width: 600px) {
            #noteModal {
                align-items: flex-start;
                padding-top: 20px;
            }

            #noteModal .modal-box {
                margin-top: env(safe-area-inset-top, 0);
            }
        }

        /* --- Login Modal --- */
        .login-modal .modal-box {
            max-width: 380px;
            text-align: center;
            position: relative;
        }

        .login-modal .modal-header {
            justify-content: center;
            border-bottom: none;
            padding-bottom: 0;
        }

        .login-modal .modal-header span {
            font-size: 1.3rem;
        }

        .login-modal .modal-header .btn-icon-only {
            position: absolute;
            top: 15px;
            right: 15px;
        }

        .login-tabs {
            display: flex;
            margin-bottom: 15px;
            border-bottom: 1px solid var(--panel-border);
        }

        .login-tab {
            flex: 1;
            padding: 10px;
            background: transparent;
            border: none;
            color: var(--text-muted);
            cursor: pointer;
            font-size: 0.9rem;
            font-weight: 600;
            transition: all 0.2s;
        }

        .login-tab.active {
            color: var(--accent-primary);
            border-bottom: 2px solid var(--accent-primary);
        }

        .login-tab:hover:not(.active) {
            color: var(--text-main);
        }

        .auth-form {
            display: flex;
            flex-direction: column;
            gap: 12px;
            margin-bottom: 15px;
        }

        .auth-input {
            width: 100%;
            padding: 12px 15px;
            background: rgba(0, 0, 0, 0.3);
            border: 1px solid var(--panel-border);
            color: var(--text-main);
            border-radius: 8px;
            font-family: inherit;
            font-size: 0.95rem;
            box-sizing: border-box;
        }

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

        .auth-input::placeholder {
            color: var(--text-muted);
        }

        .auth-btn {
            width: 100%;
            padding: 12px 20px;
            border: none;
            border-radius: 8px;
            cursor: pointer;
            font-size: 0.95rem;
            font-weight: 600;
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 10px;
            transition: all 0.2s;
        }

        .auth-btn.primary {
            background: var(--accent-primary);
            color: #0f172a;
        }

        .auth-btn.primary:hover {
            background: #7dd3fc;
            transform: translateY(-1px);
        }

        .auth-btn.google {
            background: #fff;
            color: #333;
            border: 1px solid #ddd;
        }

        .auth-btn.google:hover {
            background: #f5f5f5;
            transform: translateY(-1px);
        }

        .auth-btn:disabled {
            opacity: 0.6;
            cursor: not-allowed;
            transform: none;
        }

        .auth-divider {
            display: flex;
            align-items: center;
            gap: 15px;
            margin: 15px 0;
            color: var(--text-muted);
            font-size: 0.85rem;
        }

        .auth-divider::before,
        .auth-divider::after {
            content: '';
            flex: 1;
            border-top: 1px solid var(--panel-border);
        }

        .auth-error {
            background: rgba(239, 68, 68, 0.15);
            border: 1px solid rgba(239, 68, 68, 0.3);
            color: #fca5a5;
            padding: 10px;
            border-radius: 6px;
            font-size: 0.85rem;
            margin-bottom: 10px;
            display: none;
        }

        .auth-error.visible {
            display: block;
        }

        /* User Badge in Top Bar */
        .user-badge {
            width: 40px;
            height: 40px;
            padding: 0;
            background: rgba(30, 41, 59, 0.8);
            border: 1px solid var(--panel-border);
            border-radius: 50%;
            cursor: pointer;
            transition: all 0.2s;
            display: flex;
            align-items: center;
            justify-content: center;
            backdrop-filter: blur(4px);
            overflow: hidden;
        }

        .user-badge:hover {
            background: var(--accent-primary);
            border-color: var(--accent-primary);
        }

        .user-avatar {
            width: 100%;
            height: 100%;
            border-radius: 50%;
            background: var(--accent-primary);
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 1rem;
            font-weight: 700;
            color: #0f172a;
        }

        /* Email Verification Banner */
        .verify-email-banner {
            position: fixed;
            top: 60px;
            left: 50%;
            transform: translateX(-50%);
            display: flex;
            align-items: center;
            gap: 10px;
            padding: 10px 16px;
            background: rgba(251, 191, 36, 0.95);
            color: #1f2937;
            border-radius: 8px;
            font-size: 0.85rem;
            font-weight: 500;
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
            z-index: 1000;
        }

        .verify-email-banner i {
            font-size: 1rem;
        }

        .verify-resend-btn {
            background: rgba(0, 0, 0, 0.2);
            border: none;
            padding: 4px 10px;
            border-radius: 4px;
            color: #1f2937;
            font-size: 0.75rem;
            font-weight: 600;
            cursor: pointer;
            transition: background 0.2s;
        }

        .verify-resend-btn:hover {
            background: rgba(0, 0, 0, 0.3);
        }

        .user-name {
            font-size: 0.85rem;
            font-weight: 600;
            max-width: 120px;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }

        .login-btn {
            width: 40px;
            height: 40px;
            padding: 0;
            background: rgba(30, 41, 59, 0.8);
            color: var(--text-main);
            border: 1px solid var(--panel-border);
            border-radius: 50%;
            font-size: 1rem;
            cursor: pointer;
            transition: all 0.2s;
            display: flex;
            align-items: center;
            justify-content: center;
            backdrop-filter: blur(4px);
        }

        .login-btn:hover {
            background: var(--accent-primary);
            color: #0f172a;
            transform: translateY(-1px);
        }

        /* Auth container positioning - near sidebar */
        #authContainer {
            position: absolute;
            top: 20px;
            right: 330px;
            /* Left of 300px sidebar + 20px gap + 10px spacing */
            z-index: 30;
        }

        @media (max-width: 1200px) {
            #authContainer {
                right: 60px;
                /* Left of hamburger button */
                top: 15px;
            }
        }

        .user-dropdown {
            position: absolute;
            top: 100%;
            right: 0;
            margin-top: 8px;
            background: var(--panel-bg);
            backdrop-filter: blur(20px);
            border: 1px solid var(--panel-border);
            border-radius: 8px;
            padding: 8px 0;
            min-width: 150px;
            box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
            display: none;
            z-index: 1001;
        }

        .user-dropdown.visible {
            display: block;
        }

        .user-dropdown-header {
            padding: 12px 16px;
            font-size: 0.85rem;
            font-weight: 600;
            color: var(--text-muted);
            border-bottom: 1px solid var(--panel-border);
            margin-bottom: 4px;
        }

        .user-dropdown-item {
            padding: 10px 16px;
            cursor: pointer;
            font-size: 0.9rem;
            transition: background 0.2s;
        }

        .user-dropdown-item:hover {
            background: rgba(255, 255, 255, 0.1);
        }

        canvas {
            display: block;
            outline: none;
        }


        /* Features Modal Specifics */
        .features-modal-box {
            max-width: 500px;
            padding: 30px;
            background: linear-gradient(135deg, var(--bg-dark), #1e293b);
            border: 1px solid var(--accent-primary);
            box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5), 0 0 20px rgba(56, 189, 248, 0.2);
        }

        .features-header {
            text-align: center;
            margin-bottom: 25px;
        }

        .features-header h2 {
            margin: 0 0 5px 0;
            color: var(--text-main);
            font-size: 1.5rem;
        }

        .features-header p {
            margin: 0;
            color: var(--text-muted);
            font-size: 0.95rem;
        }

        .features-list {
            display: flex;
            flex-direction: column;
            gap: 20px;
            margin-bottom: 25px;
        }

        .feature-item {
            display: flex;
            align-items: flex-start;
            gap: 15px;
            padding: 10px;
            border-radius: 8px;
            transition: background 0.3s;
        }

        .feature-item:hover {
            background: rgba(255, 255, 255, 0.05);
        }

        .feature-icon {
            width: 40px;
            height: 40px;
            flex-shrink: 0;
            background: rgba(56, 189, 248, 0.1);
            color: var(--accent-primary);
            border-radius: 8px;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 1.2rem;
        }

        .feature-content h3 {
            margin: 0 0 4px 0;
            font-size: 1rem;
            color: var(--text-main);
        }

        .feature-content p {
            margin: 0;
            font-size: 0.85rem;
            color: var(--text-muted);
            line-height: 1.4;
        }

        /* --- Common UI Panels --- */
        .glass-panel {
            background: var(--panel-bg);
            backdrop-filter: blur(12px);
            -webkit-backdrop-filter: blur(12px);
            border: 1px solid var(--panel-border);
            border-radius: 16px;
            box-shadow: 0 4px 30px rgba(0, 0, 0, 0.5);
            color: var(--text-main);
        }

        /* --- Header / Top Bar --- */
        #top-bar {
            position: absolute;
            top: 20px;
            left: 20px;
            /* Position top-left */
            z-index: 20;
            display: flex;
            flex-direction: column;
            gap: 5px;
        }

        .brand-title {
            font-weight: 500;
            font-size: 1.1rem;
            color: var(--text-muted);
            text-transform: uppercase;
            letter-spacing: 0.5px;
            opacity: 0.7;
            display: flex;
            align-items: center;
            gap: 8px;
        }

        .brand-text {
            display: flex;
            flex-direction: column;
            line-height: 1.1;
        }

        .drill-indicator {
            font-size: 0.9rem;
            color: var(--accent-primary);
            font-weight: 600;
            background: rgba(0, 0, 0, 0.3);
            padding: 4px 12px;
            border-radius: 20px;
            display: inline-block;
        }

        /* --- Sidebar (Drills) --- */
        #sidebar {
            position: absolute;
            top: 20px;
            right: 20px;
            width: 300px;
            max-height: calc(100vh - 40px);
            display: flex;
            flex-direction: column;
            z-index: 20;
            overflow: auto;
        }

        .sidebar-header {
            padding: 15px;
            font-size: 0.75rem;
            text-transform: uppercase;
            letter-spacing: 1.5px;
            font-weight: 700;
            color: var(--text-muted);
            border-bottom: 1px solid var(--panel-border);
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        .sidebar-content {
            padding: 10px;
            overflow-y: auto;
            transition: max-height 0.3s ease-out, padding 0.3s ease;
        }

        .sidebar-content.collapsed {
            max-height: 0 !important;
            padding-top: 0;
            padding-bottom: 0;
            border-bottom: none !important;
        }



        .rotate-icon {
            transform: rotate(-90deg);
            transition: transform 0.3s ease;
        }

        /* Custom Scrollbar */
        .sidebar-content::-webkit-scrollbar {
            width: 4px;
        }

        .sidebar-content::-webkit-scrollbar-thumb {
            background: rgba(255, 255, 255, 0.2);
            border-radius: 4px;
        }

        .sidebar-footer {
            padding: 12px;
            border-top: 1px solid var(--panel-border);
            margin-top: auto;
        }

        /* Feedback button section - above playbook */
        .sidebar-feedback {
            padding: 12px;
            border-bottom: 1px solid var(--panel-border);
            display: flex;
            align-items: center;
            gap: 8px;
        }

        .feedback-btn {
            flex: 1;
            justify-content: center;
            background: transparent !important;
            border: none !important;
            color: var(--text-muted);
            padding: 10px 16px;
            font-size: 0.85rem;
        }

        .feedback-btn:hover {
            background: transparent !important;
            color: var(--accent-primary);
        }

        .feedback-btn i {
            margin-right: 6px;
        }



        /* Sidebar note section */
        .sidebar-note {
            display: none;
            padding: 8px 12px;
            background: rgba(56, 189, 248, 0.05);
            border-bottom: 1px solid var(--panel-border);
            color: var(--text-muted);
            font-size: 0.75rem;
            font-style: italic;
        }

        /* Feedback form styles */
        .feedback-select {
            width: 100%;
            padding: 12px 15px;
            background: rgba(0, 0, 0, 0.3);
            border: 1px solid var(--panel-border);
            color: var(--text-main);
            border-radius: 8px;
            font-family: inherit;
            font-size: 0.95rem;
            cursor: pointer;
        }

        .feedback-select:focus {
            outline: none;
            border-color: var(--accent-primary);
        }

        .char-counter {
            text-align: right;
            font-size: 0.75rem;
            color: var(--text-muted);
            margin-top: 4px;
        }

        .char-counter.warning {
            color: #f59e0b;
        }

        .char-counter.error {
            color: #ef4444;
        }

        .feedback-success {
            text-align: center;
            padding: 20px;
        }

        .feedback-success i {
            font-size: 3rem;
            color: var(--accent-success);
            margin-bottom: 12px;
        }

        .feedback-success h3 {
            margin: 0 0 8px 0;
            color: var(--text-main);
        }

        .feedback-success p {
            margin: 0;
            color: var(--text-muted);
            font-size: 0.9rem;
        }

        /* --- Help Guide Modal --- */
        .help-body {
            padding: 0 20px 8px;
            max-height: 65vh;
            overflow-y: auto;
        }

        .help-body::-webkit-scrollbar {
            width: 4px;
        }

        .help-body::-webkit-scrollbar-thumb {
            background: rgba(255, 255, 255, 0.2);
            border-radius: 4px;
        }

        .help-section-title {
            font-size: 0.7rem;
            font-weight: 700;
            text-transform: uppercase;
            letter-spacing: 1.5px;
            color: var(--text-muted);
            padding: 12px 0 8px;
        }

        .help-item {
            display: flex;
            align-items: center;
            gap: 12px;
            padding: 8px 4px;
            border-radius: 8px;
            transition: background 0.2s;
        }

        .help-item:hover {
            background: rgba(255, 255, 255, 0.04);
        }

        .help-icon-tile {
            width: 34px;
            height: 34px;
            flex-shrink: 0;
            border-radius: 8px;
            background: rgba(56, 189, 248, 0.1);
            color: var(--accent-primary);
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 0.85rem;
        }

        .help-icon-tile.danger {
            background: rgba(244, 114, 182, 0.1);
            color: var(--accent-danger);
        }

        .help-icon-tile.birdie {
            background: rgba(255, 255, 255, 0.08);
        }

        .help-item-text {
            display: flex;
            flex-direction: column;
            gap: 1px;
        }

        .help-item-name {
            font-size: 0.88rem;
            font-weight: 600;
            color: var(--text-main);
        }

        .help-item-desc {
            font-size: 0.78rem;
            color: var(--text-muted);
            line-height: 1.3;
        }

        .help-divider {
            height: 1px;
            background: var(--panel-border);
            margin: 8px 0 4px;
        }

        /* Drills List */
        .drill-item {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 10px 12px;
            border-radius: 8px;
            cursor: pointer;
            font-size: 0.9rem;
            margin-bottom: 4px;
            transition: all 0.2s;
            border: 1px solid transparent;
        }

        .drill-item:hover {
            background: rgba(255, 255, 255, 0.05);
        }

        .drill-item.active {
            background: rgba(56, 189, 248, 0.15);
            /* Sky Blue tint */
            border-color: rgba(56, 189, 248, 0.3);
            color: var(--accent-primary);
        }

        .drill-tag {
            font-size: 0.65rem;
            padding: 2px 6px;
            border-radius: 4px;
            font-weight: 700;
            margin-right: 10px;
            text-transform: uppercase;
        }

        /* Category-specific tag colors */
        .tag-md {
            background: #3b82f6;
            color: #fff;
        }

        /* Blue - Men's Doubles */
        .tag-wd {
            background: #ec4899;
            color: #fff;
        }

        /* Pink - Women's Doubles */
        .tag-xd {
            background: #8b5cf6;
            color: #fff;
        }

        /* Purple - Mixed Doubles */
        .tag-ms {
            background: #0ea5e9;
            color: #fff;
        }

        /* Sky Blue - Men's Singles */
        .tag-ws {
            background: #f472b6;
            color: #fff;
        }

        /* Light Pink - Women's Singles */
        .tag-kd {
            background: #22c55e;
            color: #fff;
        }

        /* Green - Kids' Doubles */

        .drill-lock {
            font-size: 0.7rem;
            color: var(--text-muted);
            margin-left: auto;
            margin-right: 8px;
            opacity: 0.6;
        }

        /* Category section headers in drill list */
        .category-header {
            padding: 10px 12px 6px;
            font-size: 0.7rem;
            text-transform: uppercase;
            letter-spacing: 1.2px;
            font-weight: 700;
            color: var(--text-muted);
            border-bottom: 1px solid var(--panel-border);
            margin-top: 8px;
            margin-bottom: 4px;
        }

        .category-header:first-child {
            margin-top: 0;
        }

        .btn-icon-only {
            background: none;
            border: none;
            color: var(--text-muted);
            cursor: pointer;
            padding: 5px;
            transition: color 0.2s;
        }

        .btn-icon-only:hover {
            color: var(--accent-danger);
        }



        /* Height Floating Label */
        #heightLabel {
            position: absolute;
            background: rgba(15, 23, 42, 0.8);
            backdrop-filter: blur(4px);
            padding: 4px 8px;
            border-radius: 4px;
            border: 1px solid rgba(255, 255, 255, 0.2);
            font-size: 12px;
            color: #fff;
            pointer-events: none;
            transform: translate(-50%, -150%);
            display: none;
            z-index: 1000;
        }

        /* --- Drill Info Overlay (Top Bar) --- */
        #drill-info-overlay {
            position: absolute;
            top: 30px;
            left: 50%;
            transform: translateX(-50%);
            background: transparent;
            border: none;
            border-radius: 10px;
            padding: 8px 20px;
            z-index: 25;
            display: flex;
            align-items: center;
            gap: 16px;
            max-width: 90vw;
            transition: opacity 0.3s ease;
        }

        #drill-info-overlay.hidden {
            display: none;
        }

        #drill-info-overlay .drill-name {
            font-size: 0.9rem;
            font-weight: 700;
            color: var(--accent-primary);
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            max-width: 150px;
        }

        #drill-info-overlay .divider {
            width: 1px;
            height: 20px;
            background: rgba(255, 255, 255, 0.2);
        }

        #drill-info-overlay .step-note {
            font-size: 0.85rem;
            color: var(--text-main);
            flex: 1;
            overflow: hidden;
            text-overflow: ellipsis;
            display: -webkit-box;
            -webkit-line-clamp: 2;
            line-clamp: 2;
            -webkit-box-orient: vertical;
            line-height: 1.3;
        }

        /* Mobile responsive - hide entire drill info overlay on phones (replaced by mobile step note panel) */
        @media (max-width: 600px) {
            #drill-info-overlay {
                display: none !important;
            }
        }

        /* --- Mobile Step Note Panel (phone only) --- */
        #mobile-step-note-panel {
            display: none;
        }

        @media (max-width: 600px) {
            #mobile-step-note-panel {
                position: fixed;
                top: 0;
                left: 0;
                right: 0;
                z-index: 2510;
                padding: 15px 50px 15px 15px;
                background: rgba(15, 23, 42, 0.95);
                backdrop-filter: blur(12px);
                -webkit-backdrop-filter: blur(12px);
                border-bottom: 1px solid var(--panel-border);
                box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
                animation: slideDown 0.2s ease-out;
            }

            #mobile-step-note-panel.visible {
                display: block;
            }

            #mobile-step-note-panel .note-text {
                color: var(--text-main);
                font-size: 0.9rem;
                line-height: 1.4;
                display: block;
            }

            #mobile-step-note-panel .close-btn {
                position: absolute;
                top: 50%;
                right: 10px;
                transform: translateY(-50%);
                width: 36px;
                height: 36px;
                border-radius: 8px;
                background: rgba(255, 255, 255, 0.1);
                border: 1px solid var(--panel-border);
                color: var(--text-muted);
                font-size: 1.4rem;
                cursor: pointer;
                display: flex;
                align-items: center;
                justify-content: center;
                line-height: 1;
            }

            #mobile-step-note-panel .close-btn:hover {
                background: rgba(239, 68, 68, 0.2);
                border-color: #ef4444;
                color: #ef4444;
            }

            @keyframes slideDown {
                from {
                    transform: translateY(-100%);
                    opacity: 0;
                }

                to {
                    transform: translateY(0);
                    opacity: 1;
                }
            }
        }

        /* --- Bottom HUD (Controls) --- */
        #hud-container {
            position: absolute;
            bottom: 30px;
            left: 50%;
            transform: translateX(-50%);
            display: flex;
            gap: 15px;
            z-index: 20;
            align-items: flex-end;
            opacity: 0.7;
        }

        .control-cluster {
            display: flex;
            flex-direction: column;
            gap: 8px;
        }

        /* HUD Row wrappers - horizontal on desktop */
        .hud-row {
            display: flex;
            gap: 15px;
            align-items: flex-end;
        }

        .cluster-label {
            font-size: 0.7rem;
            text-transform: uppercase;
            letter-spacing: 1px;
            color: var(--text-muted);
            font-weight: 700;
            text-align: center;
            text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
        }

        .control-bar {
            padding: 8px 12px;
            display: flex;
            gap: 8px;
            align-items: center;
            height: 48px;
            box-sizing: border-box;
        }

        /* Form Inputs in HUD */
        .hud-select {
            background: rgba(0, 0, 0, 0.3);
            border: 1px solid rgba(255, 255, 255, 0.1);
            color: white;
            padding: 6px 20px 6px 10px;
            border-radius: 6px;
            font-size: 0.85rem;
            font-family: inherit;
            cursor: pointer;
            outline: none;
        }

        .hud-select:hover {
            border-color: var(--text-muted);
        }

        /* Buttons */
        .btn-ui {
            background: rgba(255, 255, 255, 0.08);
            border: 1px solid rgba(255, 255, 255, 0.05);
            color: var(--text-main);
            height: 32px;
            padding: 0 12px;
            border-radius: 6px;
            cursor: pointer;
            transition: all 0.2s;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 0.9rem;
            gap: 6px;
        }

        .btn-ui:hover {
            background: rgba(255, 255, 255, 0.15);
            transform: translateY(-1px);
        }

        .btn-ui.primary {
            background: var(--accent-primary);
            color: #0f172a;
            font-weight: 700;
            border: none;
            box-shadow: 0 0 10px rgba(56, 189, 248, 0.3);
        }

        .btn-ui.primary:hover {
            background: #7dd3fc;
            box-shadow: 0 0 15px rgba(56, 189, 248, 0.5);
        }

        .btn-ui.danger {
            color: var(--accent-danger);
        }

        .btn-ui.danger:hover {
            background: rgba(244, 114, 182, 0.15);
        }

        .btn-icon {
            width: 32px;
            padding: 0;
        }

        .step-counter {
            font-family: 'Inter', sans-serif;
            font-variant-numeric: tabular-nums;
            font-weight: 700;
            font-size: 0.85rem;
            color: var(--accent-primary);
            min-width: 28px;
            display: flex;
            flex-direction: column;
            align-items: center;
            line-height: 1;
            gap: 1px;
        }

        .step-counter .step-divider {
            font-size: 0.6rem;
            opacity: 0.6;
            line-height: 0.8;
        }

        /* --- Birdie Hit Toggle (Icon Button) --- */
        .birdie-hit-toggle {
            display: flex;
            align-items: center;
            justify-content: center;
            width: 32px;
            height: 32px;
            padding: 0;
            border: none;
            border-radius: 6px;
            background: rgba(255, 255, 255, 0.06);
            cursor: pointer;
            color: var(--text-muted);
            font-size: 0.85rem;
            transition: all 0.2s ease;
        }

        .birdie-hit-toggle:hover {
            background: rgba(255, 255, 255, 0.12);
        }

        .birdie-hit-toggle.active {
            opacity: 1;
        }

        .birdie-hit-toggle.active:hover {
            background: rgba(255, 255, 255, 0.15);
        }

        .birdie-hit-toggle:not(.active) {
            opacity: 0.35;
        }

        .birdie-hit-icon {
            width: 20px;
            height: 20px;
            object-fit: contain;
        }

        /* --- Footwork Toggle (Icon Button) --- */
        .footwork-toggle {
            display: flex;
            align-items: center;
            justify-content: center;
            width: 32px;
            height: 32px;
            padding: 0;
            border: none;
            border-radius: 6px;
            background: rgba(255, 255, 255, 0.06);
            cursor: pointer;
            color: var(--text-muted);
            font-size: 0.85rem;
            transition: all 0.2s ease;
        }

        .footwork-toggle:hover {
            background: rgba(255, 255, 255, 0.12);
            color: var(--text-primary);
        }

        .footwork-toggle.active {
            color: #4ade80;
        }

        .footwork-toggle.active:hover {
            color: #86efac;
        }

        /* --- Audio Toggle --- */
        .audio-toggle {
            display: flex;
            align-items: center;
            justify-content: center;
            width: 32px;
            height: 32px;
            padding: 0;
            border: none;
            border-radius: 6px;
            background: rgba(255, 255, 255, 0.06);
            cursor: pointer;
            color: var(--text-muted);
            font-size: 0.85rem;
            transition: all 0.2s ease;
        }

        .audio-toggle:hover {
            background: rgba(255, 255, 255, 0.12);
            color: var(--text-primary);
        }

        .audio-toggle.active {
            color: #4ade80;
        }

        .audio-toggle.active:hover {
            color: #86efac;
        }

        /* --- Step Note Overlay (Refined) --- */
        .step-note-overlay {
            margin-top: 4px;
            color: var(--accent-primary);
            font-size: 0.9rem;
            font-weight: 500;
            text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
            opacity: 0.9;
            max-width: 400px;
            text-overflow: ellipsis;
            white-space: nowrap;
            overflow: hidden;
        }

        .step-note-overlay:empty {
            display: none;
        }

        /* --- Responsive --- */
        @media (max-width: 1200px) {

            /* Mobile Sidebar (Off-canvas) */
            #sidebar {
                display: flex !important;
                /* Override inline style or hiding */
                position: fixed;
                top: 0;
                right: 0;
                height: 100vh;
                width: 280px;
                background: rgba(15, 23, 42, 0.98);
                backdrop-filter: blur(15px);
                z-index: 2500;
                transform: translateX(110%);
                transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
                border-left: 1px solid var(--panel-border);
                box-shadow: -5px 0 25px rgba(0, 0, 0, 0.5);
                padding-top: 0;
                /* Close button now inline with feedback */
            }

            /* Show note on mobile */
            .sidebar-note {
                display: block;
            }

            #sidebar.sidebar-open {
                transform: translateX(0);
            }

            /* Hide sidebar on small screens initially (handled by transform, but ensure flex layout) */

            #hud-container {
                width: 98%;
                flex-wrap: nowrap;
                justify-content: center;
                gap: 5px;
            }

            /* Toggle Button visible on mobile */
            #mobile-sidebar-toggle {
                display: flex !important;
            }
        }

        /* Sidebar Toggle Button (Desktop: Hidden) */
        #mobile-sidebar-toggle {
            position: absolute;
            top: 15px;
            right: 15px;
            z-index: 2501;
            /* Above sidebar */
            display: none;
            width: 40px;
            height: 40px;
            border-radius: 8px;
            background: rgba(30, 41, 59, 0.8);
            border: 1px solid var(--panel-border);
            color: var(--text-main);
            align-items: center;
            justify-content: center;
            cursor: pointer;
            backdrop-filter: blur(4px);
            transition: all 0.2s;
        }

        #mobile-sidebar-toggle:hover {
            background: var(--accent-primary);
            color: #0f172a;
        }

        .cluster-label {
            display: none;
            /* Save vertical space */
        }

        .control-bar {
            padding: 4px 8px;
        }

        /* JavaScript-controlled responsive visibility (for setupResponsiveToolbar) */
        .responsive-hidden {
            display: none !important;
        }

        .responsive-visible {
            display: flex !important;
        }

        /* Default: hide mobile-only elements on desktop */
        .mobile-only {
            display: none;
        }

        /* CSS-based desktop/mobile visibility - activated by media query above */
        @media (max-width: 900px) {

            /* Two-row mobile HUD layout */
            #hud-container {
                flex-direction: column;
                gap: 12px;
                bottom: 15px;
                padding-bottom: env(safe-area-inset-bottom, 10px);
                width: 95%;
                max-width: 420px;
            }

            /* Mobile row wrappers */
            .hud-row {
                display: flex;
                justify-content: center;
                gap: 8px;
                width: 100%;
            }

            /* Show all control clusters on mobile */
            #fileCluster.desktop-only {
                display: flex !important;
            }

            /* Make clusters fit in rows */
            .control-cluster {
                flex: 0 1 auto;
            }

            /* Larger buttons on mobile (15% increase from 36px) */
            .btn-ui {
                height: 42px;
                padding: 0 12px;
                font-size: 0.85rem;
            }

            .btn-ui.btn-icon {
                width: 42px;
                padding: 0;
            }

            /* Control bars with more spacing */
            .control-bar {
                padding: 5px 8px;
                gap: 6px;
                height: 52px;
            }

            /* Step counter */
            .step-counter {
                min-width: 26px;
                font-size: 0.8rem;
            }

            /* Select dropdown */
            .hud-select {
                padding: 6px 18px 6px 10px;
                font-size: 0.8rem;
            }




            /* Show edit buttons that were desktop-only, BUT NOT when hidden for readonly */
            #btnEditNote.desktop-only:not(.hidden-readonly),
            #btnAddStep.desktop-only:not(.hidden-readonly),
            #btnDelStep.desktop-only:not(.hidden-readonly),
            #editDivider1.desktop-only:not(.hidden-readonly),
            #editDivider2.desktop-only:not(.hidden-readonly) {
                display: flex !important;
            }

            /* Hide +Step text on mobile, keep icon only */
            #btnAddStep span,
            #btnAddStep:not(.btn-icon)::after {
                display: none;
            }

            /* Make Add Step button icon-only on mobile */
            #btnAddStep {
                width: 42px;
                padding: 0;
            }

            /* Hide old mobile-only hamburger elements */
            .mobile-only {
                display: none !important;
            }
        }

        /* Mobile Tools Panel */
        #mobile-tools-panel {
            position: absolute;
            bottom: 90px;
            right: 15px;
            width: 200px;
            padding: 15px;
            display: none;
            flex-direction: column;
            gap: 15px;
            z-index: 100;
        }

        #mobile-tools-panel.active {
            display: flex;
        }

        .mobile-group {
            display: flex;
            flex-direction: column;
            gap: 8px;
        }

        .mobile-label {
            font-size: 0.75rem;
            color: var(--text-muted);
            font-weight: 700;
            text-transform: uppercase;
        }

        .mobile-row {
            display: flex;
            gap: 8px;
        }

        /* ==================== VIDEO EXPORT OPTIONS ==================== */
        .video-option-row {
            display: flex;
            align-items: center;
            gap: 10px;
            color: var(--text-primary);
            cursor: pointer;
            padding: 10px 0;
        }

        .video-option-row input[type="checkbox"] {
            width: 18px;
            height: 18px;
            accent-color: var(--accent-primary);
            cursor: pointer;
        }

        .video-speed-select {
            flex: 1;
            padding: 8px 12px;
            background: rgba(0, 0, 0, 0.3);
            border: 1px solid rgba(255, 255, 255, 0.2);
            border-radius: 6px;
            color: var(--text-main);
            font-family: 'Inter', sans-serif;
            font-size: 0.85rem;
            cursor: pointer;
            outline: none;
        }

        .video-speed-select:hover {
            border-color: var(--text-muted);
        }

        /* ==================== EXPORT ==================== */
        .export-cluster {
            position: relative;
            display: inline-flex;
        }

        .export-dropdown {
            position: absolute;
            bottom: calc(100% + 8px);
            left: 50%;
            transform: translateX(-50%);
            background: rgba(15, 23, 42, 0.98);
            backdrop-filter: blur(20px);
            -webkit-backdrop-filter: blur(20px);
            border: 1px solid var(--panel-border);
            border-radius: 12px;
            padding: 6px;
            min-width: 200px;
            box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
            display: none;
            z-index: 100;
        }

        .export-dropdown.visible {
            display: block;
        }

        .export-option {
            display: flex;
            align-items: center;
            gap: 10px;
            width: 100%;
            padding: 10px 14px;
            background: none;
            border: none;
            color: var(--text-main);
            font-family: 'Inter', sans-serif;
            font-size: 0.82rem;
            cursor: pointer;
            border-radius: 8px;
            transition: background 0.15s;
            text-align: left;
        }

        .export-option:hover {
            background: rgba(56, 189, 248, 0.1);
        }

        .export-option i {
            width: 18px;
            text-align: center;
            color: var(--accent-primary, #38bdf8);
        }

        .export-divider {
            height: 1px;
            background: var(--panel-border);
            margin: 4px 8px;
        }

        .export-spinner {
            width: 40px;
            height: 40px;
            border: 3px solid rgba(56, 189, 248, 0.2);
            border-top-color: var(--accent-primary, #38bdf8);
            border-radius: 50%;
            animation: exportSpin 1s linear infinite;
            margin: 0 auto;
        }

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

        .export-progress-bar {
            width: 100%;
            height: 4px;
            background: rgba(255, 255, 255, 0.1);
            border-radius: 2px;
            margin-top: 12px;
            overflow: hidden;
        }

        .export-progress-bar-fill {
            height: 100%;
            background: linear-gradient(90deg, #38bdf8, #818cf8);
            border-radius: 2px;
            transition: width 0.3s ease;
        }

        .export-toast {
            position: fixed;
            bottom: 100px;
            left: 50%;
            transform: translateX(-50%) translateY(20px);
            background: rgba(16, 185, 129, 0.9);
            color: white;
            padding: 10px 24px;
            border-radius: 10px;
            font-size: 0.85rem;
            font-weight: 600;
            font-family: 'Inter', sans-serif;
            z-index: 9999;
            opacity: 0;
            transition: all 0.3s ease;
            pointer-events: none;
            box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
        }

        .export-toast.visible {
            opacity: 1;
            transform: translateX(-50%) translateY(0);
        }