        /* ========== Light Theme (Default) ========== */
        :root {
            --sa-top-detect: 0px;
            --sa-bottom-detect: 0px;
            --ice-blue: #E0F2FE;
            --deep-blue: #0F4C81;
            --accent-blue: #2563EB;
            --team-primary: #0F4C81;
            --team-accent: #4A90D9;
            --team-light: #E8F0FE;
            --team-name: '朝阳';
            --speed-red: #DC2626;
            --gold: #F59E0B;
            --silver: #94A3B8;
            --bronze: #D97706;
            --success: #16A34A;
            --bg: #F1F5F9;
            --card: #FFFFFF;
            --text: #1E293B;
            --text-light: #64748B;
            --border: #E2E8F0;
            --glass: rgba(255,255,255,0.72);
            --glass-border: rgba(255,255,255,0.3);
            --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
            --shadow-md: 0 4px 16px rgba(0,0,0,0.08), 0 2px 4px rgba(0,0,0,0.04);
            --shadow-lg: 0 10px 40px rgba(0,0,0,0.1), 0 4px 12px rgba(0,0,0,0.05);
            --chart-grid: rgba(226,232,240,0.5);
            --chart-tick: #94A3B8;
            --hero-gradient: linear-gradient(135deg, #0C3C6E 0%, #0F4C81 50%, #1D6FB5 100%);
            --login-gradient: linear-gradient(135deg, #0C3C6E 0%, #0F4C81 25%, #1D6FB5 60%, #2563EB 100%);
            --radius-sm: 10px;
            --radius-md: 16px;
            --radius-lg: 24px;
            --transition-fast: 0.15s cubic-bezier(0.4,0,0.2,1);
            --transition-normal: 0.25s cubic-bezier(0.4,0,0.2,1);
        }

        /* ========== Dark Theme (Ice Arena — Enhanced Tech Blue) ========== */
        [data-theme="dark"] {
            --bg: #0A1628;
            --card: #132238;
            --text: #E8F0FE;
            --text-light: #8BA3C7;
            --border: rgba(59,130,246,0.12);
            --ice-blue: #00D4FF;
            --deep-blue: #3B82F6;
            --accent-blue: #60A5FA;
            --speed-red: #FF3B5C;
            --gold: #FFB800;
            --silver: #94A3B8;
            --bronze: #D97706;
            --success: #00E676;
            --glass: rgba(19,34,56,0.85);
            --glass-border: rgba(59,130,246,0.15);
            --shadow-sm: 0 1px 3px rgba(0,0,0,0.3), 0 0 0 1px rgba(59,130,246,0.05);
            --shadow-md: 0 4px 16px rgba(0,0,0,0.4), 0 0 0 1px rgba(59,130,246,0.08);
            --shadow-lg: 0 10px 40px rgba(0,0,0,0.5), 0 0 0 1px rgba(59,130,246,0.1);
            --chart-grid: rgba(59,130,246,0.08);
            --chart-tick: #8BA3C7;
            --hero-gradient: linear-gradient(135deg, #050E1F 0%, #0A1628 40%, #0F2440 100%);
            --login-gradient: linear-gradient(135deg, #050E1F 0%, #0A1628 25%, #0F2440 55%, #162D50 100%);
            color-scheme: dark;
        }
        * { margin: 0; padding: 0; box-sizing: border-box; }
        html { overflow-x: hidden; }
        body { font-family: 'Noto Sans SC', -apple-system, 'Segoe UI Emoji', 'Apple Color Emoji', 'Noto Color Emoji', sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; overflow-x: hidden; padding-left: env(safe-area-inset-left, 0px); padding-right: env(safe-area-inset-right, 0px); padding-bottom: max(env(safe-area-inset-bottom, 0px), var(--sa-bottom-detect, 0px)); transition: background 0.3s, color 0.3s; }

        /* Compact Header Bar */
        .hero { background: var(--hero-gradient); color: white; position: sticky; top: 0; z-index: 100; padding-top: max(env(safe-area-inset-top, 0px), var(--sa-top-detect, 0px)); }
        .hero::before, .hero::after { display: none; }
        .hero-content { position: relative; z-index: 1; padding: 10px 20px; max-width: 1200px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 52px; }
        .hero-left { display: flex; align-items: center; gap: 10px; }
        .hero-badge { display: none; }
        .hero h1 { font-size: 18px; font-weight: 700; letter-spacing: 1px; margin: 0; white-space: nowrap; }
        .hero-subtitle { display: none; }
        .hero-right { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
        .update-text { font-size: 11px; opacity: 0.7; white-space: nowrap; }
        .update-btn { background: rgba(255,255,255,0.2); color: white; border: 1px solid rgba(255,255,255,0.3); padding: 5px 12px; border-radius: 8px; cursor: pointer; font-size: 12px; transition: all 0.2s; white-space: nowrap; }
        .update-btn:hover { background: rgba(255,255,255,0.3); }
        .update-btn:disabled { opacity: 0.5; cursor: not-allowed; }

        /* Compact Stats KPI Bar */
        .stats-row { display: flex; gap: 0; background: var(--card); border-bottom: 1px solid var(--border); padding: 0; max-width: 100%; position: relative; z-index: 2; }
        .stat-card { flex: 1; min-width: 0; padding: 12px 8px; text-align: center; border-right: 1px solid var(--border); transition: background 0.15s; overflow: hidden; }
        .stat-card:last-child { border-right: none; }
        .stat-card:hover { background: var(--ice-blue); }
        .stat-clickable { cursor: pointer; }
        .stat-clickable:active { background: var(--ice-blue); }
        .stat-icon { display: none; }
        .stat-value { font-size: 22px; font-weight: 700; color: var(--deep-blue); line-height: 1.2; }
        .stat-label { font-size: 11px; color: var(--text-light); margin-top: 2px; }

        html { scroll-padding-top: 120px; }
        .main-content { max-width: 1200px; margin: 0 auto; padding: 8px 16px; padding-bottom: calc(72px + max(env(safe-area-inset-bottom, 0px), var(--sa-bottom-detect, 16px))); }
        /* Bottom Tab Bar (Mobile-First) */
        .tab-nav { display: none; }
        .bottom-tab-bar { position: fixed; bottom: 0; left: 0; right: 0; z-index: 9990; background: var(--card); border-top: 1px solid var(--border); display: flex; justify-content: space-around; align-items: center; padding: 0 max(env(safe-area-inset-right, 0px), 0px) max(env(safe-area-inset-bottom, 0px), var(--sa-bottom-detect, 16px)) max(env(safe-area-inset-left, 0px), 0px); box-shadow: 0 -2px 12px rgba(0,0,0,0.08); transition: transform 0.3s cubic-bezier(0.4,0,0.2,1); overscroll-behavior: contain; -webkit-overflow-scrolling: auto; pointer-events: auto; }
        .bottom-tab-bar.hidden { transform: translateY(100%); }
        .bottom-tab-item { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; padding: 8px 0; min-height: 48px; min-width: 0; flex: 1; cursor: pointer; border: none; background: none; color: var(--text-light); font-size: 10px; font-weight: 500; transition: all 0.2s; -webkit-tap-highlight-color: transparent; position: relative; touch-action: manipulation; -webkit-user-select: none; user-select: none; }
        .bottom-tab-item .bottom-tab-icon { font-size: 22px; line-height: 1; transition: transform 0.2s cubic-bezier(0.4,0,0.2,1); }
        .bottom-tab-item .bottom-tab-label { white-space: nowrap; transition: color 0.2s; }
        .bottom-tab-item.active { color: var(--deep-blue); font-weight: 600; }
        .bottom-tab-item.active .bottom-tab-icon { transform: scale(1.15); }
        .bottom-tab-item.active::after { content: ''; position: absolute; top: -1px; left: 25%; right: 25%; height: 3px; background: var(--deep-blue); border-radius: 0 0 3px 3px; }
        .bottom-tab-item:active .bottom-tab-icon { transform: scale(0.9); }
        .bottom-tab-badge { position: absolute; top: 2px; right: calc(50% - 16px); min-width: 16px; height: 16px; border-radius: 8px; background: var(--speed-red); color: white; font-size: 9px; font-weight: 700; display: flex; align-items: center; justify-content: center; padding: 0 4px; line-height: 1; }
        /* Desktop/tablet: show horizontal tabs + keep bottom bar visible */
        @media (min-width: 769px) {
            .tab-nav { display: flex; gap: 0; margin-bottom: 20px; background: var(--card); border-bottom: 2px solid var(--border); border-radius: 0; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; position: sticky; top: 52px; z-index: 50; padding: 0 8px; }
            .tab-nav::-webkit-scrollbar { display: none; }
            .main-content { padding-bottom: calc(80px + max(env(safe-area-inset-bottom, 0px), var(--sa-bottom-detect, 16px))); }
        }
        .tab-btn { flex-shrink: 0; padding: 12px 18px; border: none; background: transparent; font-size: 14px; font-weight: 500; color: var(--text-light); cursor: pointer; transition: all 0.2s; display: flex; align-items: center; justify-content: center; gap: 6px; border-bottom: 3px solid transparent; margin-bottom: -2px; white-space: nowrap; }
        .tab-btn:hover { color: var(--deep-blue); background: rgba(15,76,129,0.04); }
        .tab-btn.active { color: var(--deep-blue); border-bottom-color: var(--deep-blue); font-weight: 600; background: transparent; }
        .section { display: none; }
        .section.active { display: block; }

        .sub-tab-nav { display: flex; gap: 4px; margin-bottom: 24px; background: var(--bg); padding: 4px; border-radius: 10px; border: 1px solid var(--border); }
        .sub-tab-btn { padding: 8px 16px; border: none; background: transparent; border-radius: 8px; font-size: 13px; font-weight: 500; color: var(--text-light); cursor: pointer; transition: all 0.2s; white-space: nowrap; display: flex; align-items: center; gap: 6px; }
        .sub-tab-btn:hover { background: var(--ice-blue); color: var(--deep-blue); }
        .sub-tab-btn.active { background: var(--card); color: var(--deep-blue); box-shadow: 0 1px 4px rgba(0,0,0,0.1); font-weight: 600; }
        .sub-section { display: none; }
        .sub-section.active { display: block; }

        .card { background: var(--card); border-radius: var(--radius-lg); padding: 28px; box-shadow: var(--shadow-md); margin-bottom: 24px; border: 1px solid var(--border); transition: box-shadow var(--transition-normal); }
        .card:hover { box-shadow: var(--shadow-lg); }
        .card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; flex-wrap: wrap; gap: 12px; }
        .card-title { font-size: 17px; font-weight: 600; color: var(--deep-blue); display: flex; align-items: center; gap: 10px; }
        .card-title .icon { width: 36px; height: 36px; border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; font-size: 18px; }

        .athlete-controls { display: flex; gap: 12px; flex-wrap: wrap; }
        .search-input { flex: 1; min-width: 200px; padding: 12px 16px; border: 2px solid var(--border); border-radius: 12px; font-size: 15px; transition: border-color 0.2s; }
        .search-input:focus { outline: none; border-color: var(--deep-blue); }
        .filter-select { padding: 12px 16px; border: 2px solid var(--border); border-radius: 12px; font-size: 15px; background: var(--card); cursor: pointer; min-width: 140px; color: var(--text); }

        .athlete-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 16px; }
        .athlete-card { background: var(--bg); border: 2px solid transparent; border-radius: 16px; padding: 20px; cursor: pointer; transition: all 0.25s; position: relative; overflow: visible; text-align: center; }
        .athlete-card::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 4px; background: linear-gradient(90deg, var(--deep-blue), #4299E1); opacity: 0; transition: opacity 0.2s; }
        .athlete-card:hover { border-color: var(--deep-blue); transform: translateY(-3px); box-shadow: 0 8px 24px rgba(26,54,93,0.12); }
        .athlete-card:hover::before { opacity: 1; }
        .athlete-card.selected { border-color: var(--deep-blue); background: var(--ice-blue); }
        .athlete-card.selected::before { opacity: 1; }
        .athlete-avatar-card { width: 64px; height: 64px; border-radius: 50%; background: linear-gradient(135deg, var(--deep-blue), var(--accent-blue)); color: white; display: flex; align-items: center; justify-content: center; font-size: 24px; font-weight: 600; margin: 0 auto 10px; overflow: visible; position: relative; isolation: isolate; }
        .athlete-avatar-card img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; position: relative; z-index: 1; border: 2px solid rgba(255,255,255,0.92); }
        /* ========== 荣耀头像框 ========== */
        /*
         * Design: Single elegant ring via ::before pseudo-element.
         * The pseudo-element extends outside the avatar, and the
         * avatar's circular background covers the inner portion,
         * leaving a clean metallic ring visible.
         * No overflow:hidden clipping because parent containers
         * use overflow:visible (border-radius handles clipping).
         */

        /* Gold ring — 一级运动员+ (level 1-3) */
        .athlete-avatar-card.honor-frame::before,
        .profile-avatar-wrap.honor-frame::before,
        .detail-avatar.honor-frame::before {
            content: '';
            position: absolute;
            inset: -4px;
            border-radius: 50%;
            border: 2.5px solid #DAA520;
            box-shadow: 0 0 8px rgba(218,165,32,0.28), 0 0 2px rgba(218,165,32,0.15);
            z-index: -1;
            pointer-events: none;
        }

        /* Silver ring — 二级运动员 (level 4) */
        .athlete-avatar-card.honor-frame.level-2-frame::before,
        .profile-avatar-wrap.level-2-frame::before,
        .detail-avatar.level-2-frame::before,
        .athlete-list-avatar.honor-frame.level-2-frame::before {
            border-color: #9CA3AF;
            box-shadow: 0 0 8px rgba(156,163,175,0.28), 0 0 2px rgba(156,163,175,0.15);
        }

        /* Bronze ring — 三级运动员 (level 5) */
        .athlete-avatar-card.honor-frame.level-3-frame::before,
        .profile-avatar-wrap.level-3-frame::before,
        .detail-avatar.level-3-frame::before,
        .athlete-list-avatar.honor-frame.level-3-frame::before {
            border-color: #CD7F32;
            box-shadow: 0 0 8px rgba(205,127,50,0.28), 0 0 2px rgba(205,127,50,0.15);
        }

        /* athlete-list avatar (44px) — tighter ring */
        .athlete-list-avatar.honor-frame::before {
            content: '';
            position: absolute;
            inset: -3px;
            border-radius: 50%;
            border: 2px solid #DAA520;
            box-shadow: 0 0 6px rgba(218,165,32,0.25);
            z-index: -1;
            pointer-events: none;
        }

        .athlete-card.has-honor {
            border: 2px solid #DAA520;
            box-shadow: 0 0 0 1px rgba(218,165,32,0.3), 0 2px 12px rgba(218,165,32,0.12);
        }
        .athlete-card.has-honor::before { display: none; }
        .athlete-rank { position: absolute; top: 8px; left: 8px; width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; color: white; }
        .athlete-rank.rank-1 { background: linear-gradient(135deg, #F6AD55, #DD6B20); }
        .athlete-rank.rank-2 { background: linear-gradient(135deg, #A0AEC0, #718096); }
        .athlete-rank.rank-3 { background: linear-gradient(135deg, #ED8936, #C05621); }
        .athlete-rank.rank-other { background: var(--border); color: var(--text-light); }
        .athlete-name { font-size: 16px; font-weight: 600; color: var(--deep-blue); margin-bottom: 6px; cursor: pointer; }
        .athlete-name:hover { text-decoration: underline; }
        .athlete-meta { font-size: 13px; color: var(--text-light); }
        .athlete-medals { display: flex; gap: 6px; margin-top: 12px; flex-wrap: wrap; justify-content: center; }
        .medal-badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 10px; font-size: 13px; font-weight: 600; color: white; }
        .medal-badge .medal-emoji { font-size: 14px; line-height: 1; }
        .medal-badge.gold { background: linear-gradient(135deg, #F6AD55, #DD6B20); }
        .medal-badge.silver { background: linear-gradient(135deg, #A0AEC0, #718096); }
        .medal-badge.bronze { background: linear-gradient(135deg, #FC8181, #C53030); }
        .honor-badge { display: inline-flex; align-items: center; gap: 3px; padding: 4px 12px; border-radius: 12px; font-size: 12px; font-weight: 700; margin-top: 6px; letter-spacing: 0.5px; position: relative; }
        .honor-badge .honor-emoji { font-size: 14px; line-height: 1; filter: drop-shadow(0 0 2px currentColor); }
        .honor-badge.level-1 {
            background: linear-gradient(135deg, #B8860B 0%, #DAA520 30%, #FFD700 65%, #FFA500 100%);
            color: #5C3D08;
            box-shadow: 0 0 0 1px rgba(184,134,11,0.6), 0 0 10px rgba(255,215,0,0.35), 0 2px 4px rgba(0,0,0,0.15);
            text-shadow: 0 1px 0 rgba(255,255,255,0.2);
        }
        .honor-badge.level-2 {
            background: linear-gradient(135deg, #717D8C 0%, #9BA4B5 30%, #C0C7D3 65%, #D5DAE2 100%);
            color: #2D3748;
            box-shadow: 0 0 0 1px rgba(156,163,175,0.5), 0 0 8px rgba(192,199,211,0.3), 0 2px 4px rgba(0,0,0,0.12);
            text-shadow: 0 1px 0 rgba(255,255,255,0.25);
        }
        .honor-badge.level-3 {
            background: linear-gradient(135deg, #8B4513 0%, #A0522D 30%, #CD7F32 65%, #D2691E 100%);
            color: #FFE4C4;
            box-shadow: 0 0 0 1px rgba(205,127,50,0.5), 0 0 8px rgba(205,127,50,0.3), 0 2px 4px rgba(0,0,0,0.15);
            text-shadow: 0 1px 0 rgba(0,0,0,0.2);
        }
        .honor-badge.other { background: linear-gradient(135deg, #63B3ED, #3182CE); color: #FFF; }
        .athlete-card.has-honor { border: 2px solid #DAA520; box-shadow: 0 0 0 1px rgba(218,165,32,0.3), 0 2px 12px rgba(218,165,32,0.12); }
        .athlete-card.has-honor::before { display: none; }
        .medal-badge.bronze { background: linear-gradient(135deg, #ED8936, #C05621); }

        /* Training Records */
        .training-form { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; margin-bottom: 20px; }
        .training-form label { font-size: 13px; color: var(--text-light); font-weight: 500; display: block; margin-bottom: 4px; }
        .training-form input, .training-form select, .training-form textarea {
            width: 100%; padding: 10px 12px; border: 2px solid var(--border); border-radius: 10px; font-size: 14px; font-family: inherit;
        }
        .training-form input:focus, .training-form select:focus, .training-form textarea:focus { outline: none; border-color: var(--deep-blue); }
        .training-table { width: 100%; border-collapse: collapse; font-size: 14px; }
        .training-table th { text-align: left; padding: 10px 12px; background: var(--bg); color: var(--text-light); font-weight: 600; font-size: 12px; }
        .training-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); }
        .training-table tr:hover td { background: var(--ice-blue); }
        .type-badge { display: inline-block; padding: 3px 10px; border-radius: 10px; font-size: 12px; font-weight: 500; }
        .type-badge.class { background: #C6F6D5; color: #276749; }
        .type-badge.custom { background: #E9D8FD; color: #553C9A; }
        .attendance-table { width: 100%; border-collapse: collapse; font-size: 14px; }
        .attendance-table th { text-align: center; padding: 10px 8px; background: var(--bg); color: var(--text-light); font-weight: 600; font-size: 12px; }
        .attendance-table td { text-align: center; padding: 10px 8px; border-bottom: 1px solid var(--border); }
        .attendance-table td:first-child { text-align: left; font-weight: 600; }
        .attendance-table tr:hover td { background: var(--ice-blue); }
        .attendance-bar { height: 8px; border-radius: 4px; background: #E2E8F0; overflow: hidden; min-width: 60px; }
        .attendance-bar-fill { height: 100%; border-radius: 4px; transition: width 0.3s; }
        .attendance-bar-fill.class { background: linear-gradient(90deg, #48BB78, #38A169); }
        .attendance-bar-fill.custom { background: linear-gradient(90deg, #9F7AEA, #805AD5); }
        .stat-number { font-size: 22px; font-weight: 700; }
        .stat-label { font-size: 12px; color: var(--text-light); }
        .fee-table { width: 100%; border-collapse: collapse; font-size: 14px; }
        .fee-table th { text-align: center; padding: 10px 8px; background: var(--bg); color: var(--text-light); font-weight: 600; font-size: 12px; }
        .fee-table td { text-align: center; padding: 10px 8px; border-bottom: 1px solid var(--border); }
        .fee-table td:first-child { text-align: left; font-weight: 600; }
        .fee-table tr:hover td { background: var(--ice-blue); }
        .fee-exempt { text-decoration: line-through; color: var(--text-light); }
        .fee-total { font-weight: 700; color: var(--speed-red); }
        .athlete-checkbox-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 6px; }
        .athlete-checkbox-item { display: flex; align-items: center; gap: 6px; padding: 6px 10px; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; cursor: pointer; font-size: 13px; transition: all 0.15s; user-select: none; }
        .athlete-checkbox-item:hover { background: var(--ice-blue); border-color: var(--deep-blue); }
        .athlete-checkbox-item.checked { background: #EBF8FF; border-color: var(--deep-blue); color: var(--deep-blue); font-weight: 600; }
        .schedule-day { background: var(--bg); border-radius: 12px; padding: 12px; border: 1px solid var(--border); }
        .schedule-day-title { font-weight: 700; font-size: 14px; color: var(--deep-blue); margin-bottom: 8px; }
        .schedule-type-tag { display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; border-radius: 8px; font-size: 12px; margin: 2px; }
        .schedule-type-tag.class { background: #C6F6D5; color: #276749; }
        .schedule-type-tag.custom { background: #E9D8FD; color: #553C9A; }
        .today-training-tag { display: inline-block; padding: 6px 14px; border-radius: 10px; font-size: 13px; margin: 4px; cursor: pointer; border: 2px solid transparent; transition: all 0.15s; }
        .today-training-tag.selected { border-color: var(--deep-blue); font-weight: 600; background: #EBF8FF; }
        .select-all-btn { padding: 4px 12px; border-radius: 8px; font-size: 12px; border: 1px solid var(--border); background: var(--bg); cursor: pointer; color: var(--deep-blue); }

        /* Custom Calendar Picker */
        .calendar-picker { position: relative; }
        .calendar-picker-input { cursor: pointer; background: var(--card); }
        .calendar-picker-input:focus { outline: none; border-color: var(--deep-blue); }
        .calendar-dropdown { position: absolute; top: calc(100% + 4px); left: 0; z-index: 9999; background: var(--card); border: 2px solid var(--border); border-radius: 14px; padding: 16px; box-shadow: var(--shadow-lg); min-width: 300px; transition: none; }
        .calendar-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
        .calendar-header span { font-weight: 700; font-size: 15px; color: var(--deep-blue); cursor: pointer; padding: 4px 8px; border-radius: 6px; transition: background 0.15s; }
        .calendar-header span:hover { background: var(--ice-blue); }
        .calendar-nav { width: 32px; height: 32px; border: none; background: var(--bg); border-radius: 8px; cursor: pointer; font-size: 16px; display: flex; align-items: center; justify-content: center; transition: all 0.15s; }
        .calendar-nav:hover { background: var(--ice-blue); color: var(--deep-blue); }
        .calendar-weekdays { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; margin-bottom: 4px; }
        .calendar-weekday { text-align: center; font-size: 12px; color: var(--text-light); font-weight: 600; padding: 4px 0; }
        .calendar-days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; min-height: 260px; align-content: start; }
        .calendar-day { text-align: center; padding: 6px 2px; border-radius: 8px; font-size: 13px; cursor: pointer; transition: all 0.15s; position: relative; min-height: 36px; display: flex; flex-direction: column; align-items: center; justify-content: center; }
        .calendar-day:hover { background: var(--ice-blue); }
        .calendar-day.other-month { color: var(--text-light); opacity: 0.4; }
        .calendar-day.today { font-weight: 700; color: var(--deep-blue); }
        .calendar-day.today::after { content: ''; position: absolute; bottom: 2px; left: 50%; transform: translateX(-50%); width: 4px; height: 4px; border-radius: 50%; background: var(--deep-blue); }
        /* Year-Month Wheel Picker */
        .ym-picker-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; z-index: 10000; background: rgba(0,0,0,0.3); display: flex; align-items: center; justify-content: center; animation: fadeIn 0.15s; }
        .ym-picker-panel { background: var(--card); border-radius: 16px; padding: 20px; min-width: 280px; box-shadow: var(--shadow-lg); }
        .ym-picker-title { font-size: 16px; font-weight: 700; color: var(--deep-blue); text-align: center; margin-bottom: 16px; }
        .ym-picker-columns { display: flex; gap: 0; justify-content: center; height: 200px; position: relative; overflow: hidden; }
        .ym-picker-col { flex: 1; overflow-y: auto; scroll-snap-type: y mandatory; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
        .ym-picker-col::-webkit-scrollbar { display: none; }
        .ym-picker-item { height: 40px; display: flex; align-items: center; justify-content: center; font-size: 16px; cursor: pointer; scroll-snap-align: center; transition: all 0.15s; border-radius: 8px; }
        .ym-picker-item:hover { background: var(--ice-blue); }
        .ym-picker-item.selected { font-weight: 700; color: var(--deep-blue); background: rgba(66,153,225,0.1); }
        .ym-picker-highlight { position: absolute; top: 50%; left: 0; right: 0; transform: translateY(-50%); height: 40px; border-top: 2px solid var(--border); border-bottom: 2px solid var(--border); pointer-events: none; background: rgba(66,153,225,0.04); }
        .ym-picker-col-label { text-align: center; font-size: 12px; color: var(--text-light); margin-bottom: 4px; font-weight: 600; }
        .ym-picker-actions { display: flex; gap: 8px; margin-top: 16px; }
        .ym-picker-actions button { flex: 1; padding: 10px; border: none; border-radius: 10px; font-size: 14px; font-weight: 600; cursor: pointer; }
        .ym-picker-cancel { background: var(--bg); color: var(--text-light); }
        .ym-picker-cancel:hover { background: #E2E8F0; }
        .ym-picker-confirm { background: var(--deep-blue); color: white; }
        .ym-picker-confirm:hover { background: #2B6CB0; }
        .calendar-day.selected { background: var(--deep-blue); color: white !important; font-weight: 700; }
        .calendar-day.selected::after { background: var(--card); }
        .calendar-day.has-training { font-weight: 600; }
        .calendar-day.has-class { background: #C6F6D5; color: #276749; }
        .calendar-day.has-class:hover { background: #9AE6B4; }
        .calendar-day.has-custom { background: #E9D8FD; color: #553C9A; }
        .calendar-day.has-custom:hover { background: #D6BCFA; }
        .calendar-day.has-both { background: linear-gradient(135deg, #C6F6D5 50%, #E9D8FD 50%); color: var(--deep-blue); }
        .calendar-day.has-both:hover { background: linear-gradient(135deg, #9AE6B4 50%, #D6BCFA 50%); }
        .calendar-day.selected.has-class, .calendar-day.selected.has-custom, .calendar-day.selected.has-both { background: var(--deep-blue); color: white !important; }
        .training-dot { width: 5px; height: 5px; border-radius: 50%; position: absolute; bottom: 1px; }
        .training-dot.class-dot { background: #38A169; }
        .training-dot.custom-dot { background: #805AD5; }
        .calendar-day.selected .training-dot { background: rgba(255,255,255,0.7); }
        .select-all-btn:hover { background: var(--ice-blue); }
        /* 个人中心页面样式 */
        .profile-page { position: fixed; inset: 0; z-index: 1000; background: var(--bg); overflow-y: auto; animation: profileSlideIn 0.3s ease; padding-bottom: calc(70px + env(safe-area-inset-bottom, 0px)); }
        @keyframes profileSlideIn { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
        .profile-cover { height: 180px; background: linear-gradient(135deg, #0C3C6E 0%, #0F4C81 40%, #2563EB 100%); position: relative; overflow: hidden; }
        .profile-cover::before { content: ''; position: absolute; inset: 0; background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M30 0 L30 60 M0 30 L60 30' stroke='%23ffffff08' stroke-width='1'/%3E%3C/svg%3E"); opacity: 0.4; }
        .profile-cover::after { content: ''; position: absolute; bottom: 0; left: 0; right: 0; height: 60px; background: linear-gradient(to top, var(--bg), transparent); }
        .profile-close { position: absolute; top: calc(16px + env(safe-area-inset-top, 0px)); height: 40px; min-width: 40px; border-radius: 20px; background: rgba(0,0,0,0.4); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); color: white; border: none; font-size: 14px; cursor: pointer; display: flex; align-items: center; justify-content: center; z-index: 10; transition: background 0.2s; -webkit-tap-highlight-color: transparent; touch-action: manipulation; padding: 0 14px; font-weight: 500; gap: 2px; }
        .profile-close:hover { background: rgba(0,0,0,0.6); }
        .profile-close:active { background: rgba(0,0,0,0.7); transform: scale(0.92); }
        .profile-header { max-width: 640px; margin: -60px auto 0; padding: 0 24px; position: relative; z-index: 1; }
        .profile-avatar-wrap { width: 120px; height: 120px; border-radius: 50%; margin: 0 auto 16px; position: relative; overflow: visible; isolation: isolate; }
        .profile-avatar-wrap img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; border: 4px solid rgba(255,255,255,0.96); position: relative; z-index: 1; box-shadow: 0 10px 24px rgba(15,23,42,0.12); }
        .profile-avatar-wrap .avatar-placeholder { width: 100%; height: 100%; border-radius: 50%; background: linear-gradient(135deg, var(--deep-blue), var(--accent-blue)); color: white; display: flex; align-items: center; justify-content: center; font-size: 42px; font-weight: 600; border: 4px solid rgba(255,255,255,0.96); position: relative; z-index: 1; box-shadow: 0 10px 24px rgba(15,23,42,0.12); }
        .profile-avatar-edit { position: absolute; bottom: 4px; right: 4px; width: 36px; height: 36px; border-radius: 50%; background: var(--deep-blue); color: white; border: 3px solid var(--card); font-size: 14px; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: transform 0.2s; z-index: 2; }
        .profile-avatar-edit:hover { transform: scale(1.1); }
        .profile-name { font-size: 24px; font-weight: 700; color: var(--deep-blue); text-align: center; margin-bottom: 4px; }
        .profile-meta { font-size: 14px; color: var(--text-light); text-align: center; margin-bottom: 8px; }
        .profile-honors-row { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-bottom: 8px; }
        .profile-bio { font-size: 14px; color: var(--text); text-align: center; padding: 0 16px; line-height: 1.6; white-space: pre-wrap; }
        .profile-tabs { display: flex; gap: 0; border-bottom: 2px solid var(--border); margin-top: 24px; max-width: 640px; margin-left: auto; margin-right: auto; padding: 0 24px; }
        .profile-tab { flex: 1; padding: 14px 0; text-align: center; font-size: 15px; font-weight: 500; color: var(--text-light); cursor: pointer; border-bottom: 3px solid transparent; margin-bottom: -2px; transition: all 0.2s; background: none; border-top: none; border-left: none; border-right: none; }
        .profile-tab:hover { color: var(--deep-blue); }
        .profile-tab.active { color: var(--deep-blue); border-bottom-color: var(--deep-blue); font-weight: 600; }
        .profile-body { max-width: 640px; margin: 24px auto; padding: 0 24px; min-height: 200px; }
        .profile-section { margin-bottom: 24px; }
        .profile-section-title { font-size: 16px; font-weight: 600; color: var(--deep-blue); display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
        .profile-section-title button { font-size: 13px; color: var(--accent); background: none; border: none; cursor: pointer; font-weight: 500; }
        .profile-item { display: flex; align-items: center; gap: 10px; padding: 12px 16px; background: var(--bg); border-radius: 12px; margin-bottom: 8px; transition: background 0.15s; }
        .profile-item:hover { background: var(--ice-blue); }
        .profile-item-date { font-size: 12px; color: var(--text-light); white-space: nowrap; min-width: 80px; }
        .profile-item-name { font-size: 14px; font-weight: 500; color: var(--deep-blue); flex: 1; }
        .profile-item-result { font-size: 13px; color: var(--text); }
        .profile-item-actions { margin-left: auto; display: flex; gap: 4px; }
        .profile-empty { text-align: center; padding: 32px; color: var(--text-light); font-size: 14px; }
        .profile-edit-form { padding: 16px; background: var(--ice-blue); border-radius: 12px; margin-bottom: 12px; opacity: 0.9; }
        .profile-edit-form input, .profile-edit-form textarea { width: 100%; padding: 10px 12px; border: 2px solid var(--border); border-radius: 10px; font-size: 14px; font-family: inherit; margin-bottom: 8px; }
        .profile-edit-form input:focus, .profile-edit-form textarea:focus { outline: none; border-color: var(--deep-blue); }
        .profile-edit-form .form-actions { display: flex; gap: 8px; justify-content: flex-end; }
        .profile-edit-form .btn-cancel { padding: 8px 16px; border: 1px solid var(--border); border-radius: 8px; background: var(--card); cursor: pointer; font-size: 13px; }
        .profile-edit-form .btn-save { padding: 8px 16px; border: none; border-radius: 8px; background: var(--deep-blue); color: white; cursor: pointer; font-size: 13px; }
        .profile-badge-row { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 4px; }

        /* Skeleton Loading */
        .skeleton { background: linear-gradient(90deg, #E2E8F0 25%, #F1F5F9 50%, #E2E8F0 75%); background-size: 200% 100%; animation: skeletonShimmer 1.5s ease-in-out infinite; border-radius: 6px; }
        @keyframes skeletonShimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
        .skeleton-text { height: 14px; margin-bottom: 8px; }
        .skeleton-text.w60 { width: 60%; }
        .skeleton-text.w40 { width: 40%; }
        .skeleton-text.w80 { width: 80%; }
        .skeleton-circle { width: 48px; height: 48px; border-radius: 50%; }
        .skeleton-card { height: 120px; border-radius: 16px; margin-bottom: 12px; }

        /* Pull-to-Refresh */
        .pull-indicator { position: fixed; top: 0; left: 0; right: 0; z-index: 200; display: flex; align-items: center; justify-content: center; padding: 8px; background: var(--card); box-shadow: 0 2px 8px rgba(0,0,0,0.08); transform: translateY(-100%); transition: transform 0.2s; font-size: 13px; color: var(--text-light); gap: 6px; }
        .pull-indicator.show { transform: translateY(0); }
        .pull-indicator .pull-spinner { width: 16px; height: 16px; border: 2px solid var(--border); border-top-color: var(--deep-blue); border-radius: 50%; animation: spin 0.6s linear infinite; }
        @keyframes spin { to { transform: rotate(360deg); } }

        /* Micro-animations */
        @keyframes toastSlideIn { from { transform: translateY(20px) scale(0.95); opacity: 0; } to { transform: translateY(0) scale(1); opacity: 1; } }
        @keyframes toastSlideOut { from { transform: translateY(0) scale(1); opacity: 1; } to { transform: translateY(20px) scale(0.95); opacity: 0; } }
        @keyframes likeBounce { 0% { transform: scale(1); } 30% { transform: scale(1.4); } 60% { transform: scale(0.9); } 100% { transform: scale(1); } }
        @keyframes fadeInUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
        @keyframes countUp { from { opacity: 0.5; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }
        @keyframes badgeUnlock { 0% { transform: scale(0) rotate(-15deg); opacity: 0; } 60% { transform: scale(1.15) rotate(5deg); opacity: 1; } 100% { transform: scale(1) rotate(0deg); opacity: 1; } }
        .anim-bounce { animation: likeBounce 0.4s cubic-bezier(0.4,0,0.2,1); }
        .anim-fade-in { animation: fadeInUp 0.3s cubic-bezier(0.4,0,0.2,1); }
        .anim-count { animation: countUp 0.3s ease-out; }
        .anim-badge { animation: badgeUnlock 0.5s cubic-bezier(0.4,0,0.2,1); }

        /* Section transition */
        .section { display: none; }
        .section.active { display: block; }

        /* Athlete List Item (for modal) */
        .athlete-list-item { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 12px; cursor: pointer; transition: background 0.15s; border-bottom: 1px solid var(--border); }
        .athlete-list-item:last-child { border-bottom: none; }
        .athlete-list-item:hover { background: var(--ice-blue); }
        .athlete-list-item:active { background: #DBEAFE; }
        .athlete-list-avatar { width: 44px; height: 44px; border-radius: 50%; background: linear-gradient(135deg, var(--deep-blue), var(--accent-blue)); color: white; display: flex; align-items: center; justify-content: center; font-size: 18px; font-weight: 600; flex-shrink: 0; overflow: visible; position: relative; }
        .athlete-list-avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
        .athlete-list-info { flex: 1; min-width: 0; }
        .athlete-list-name { font-weight: 600; font-size: 15px; color: var(--deep-blue); }
        .athlete-list-meta { font-size: 12px; color: var(--text-light); margin-top: 2px; }
        .athlete-list-medals { font-size: 12px; margin-top: 2px; }
        .athlete-list-arrow { color: var(--text-light); font-size: 14px; flex-shrink: 0; }
        .modal-search { width: 100%; padding: 10px 14px; border: 2px solid var(--border); border-radius: 10px; font-size: 14px; margin-bottom: 14px; }
        .modal-search:focus { outline: none; border-color: var(--deep-blue); }

        /* Auth Modal */
        .modal-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.5); z-index: 99997; display: flex; align-items: center; justify-content: center; padding: env(safe-area-inset-top, 16px) env(safe-area-inset-right, 16px) env(safe-area-inset-bottom, 16px) env(safe-area-inset-left, 16px); }
        .modal-overlay[style*="display:none"],
        .modal-overlay.is-hidden { pointer-events: none; visibility: hidden; }
        .modal-box { background: var(--card); border-radius: 20px; padding: 32px; max-width: 400px; width: 90%; max-height: 90vh; overflow-y: auto; box-shadow: var(--shadow-lg); }
        .modal-title { font-size: 20px; font-weight: 700; color: var(--deep-blue); margin-bottom: 20px; text-align: center; }
        .modal-input { width: 100%; padding: 12px 16px; border: 2px solid var(--border); border-radius: 12px; font-size: 15px; margin-bottom: 12px; }
        .modal-input:focus { outline: none; border-color: var(--deep-blue); }
        .pw-input-wrap { position: relative; }
        .pw-input-wrap .modal-input { margin-bottom: 12px; }
        .pw-toggle { position: absolute; right: 12px; top: 12px; cursor: pointer; opacity: 0.5; transition: opacity 0.15s; user-select: none; font-size: 18px; line-height: 1; }
        .pw-toggle:hover { opacity: 1; }
        .modal-btn { width: 100%; padding: 14px; background: var(--deep-blue); color: white; border: none; border-radius: 12px; font-size: 16px; font-weight: 600; cursor: pointer; transition: background 0.2s; }
        .modal-btn:hover { background: #2C5282; }
        .modal-btn:disabled { opacity: 0.5; cursor: not-allowed; }
        .modal-link { color: var(--deep-blue); cursor: pointer; font-size: 14px; text-align: center; display: block; margin-top: 12px; }
        .modal-link:hover { text-decoration: underline; }
        .user-badge { display: inline-flex; align-items: center; gap: 6px; background: var(--glass); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); padding: 6px 14px; border-radius: 20px; font-size: 13px; cursor: pointer; transition: all var(--transition-fast); position: relative; border: 1px solid var(--glass-border); }
        .user-badge:hover { background: rgba(255,255,255,0.35); }
        .user-menu { position: fixed; background: var(--card); border-radius: var(--radius-md); box-shadow: var(--shadow-lg); min-width: 200px; max-width: calc(100vw - 32px); max-height: calc(100vh - 80px); overflow-y: auto; z-index: 99998; display: none; border: 1px solid var(--border); }
        .user-menu.show { display: block; animation: menuSlideIn 0.2s ease-out; }
        @keyframes menuSlideIn { from { opacity: 0; transform: translateY(-8px) scale(0.96); } to { opacity: 1; transform: translateY(0) scale(1); } }
        .user-menu-header { padding: 14px 16px; background: linear-gradient(135deg, var(--deep-blue), var(--accent-blue)); color: white; border-radius: var(--radius-md) var(--radius-md) 0 0; }
        .user-menu-header .menu-name { font-weight: 700; font-size: 15px; }
        .user-menu-header .menu-role { font-size: 12px; opacity: 0.8; margin-top: 2px; }
        .user-menu-item { display: flex; align-items: center; gap: 10px; padding: 12px 16px; cursor: pointer; transition: background 0.15s; font-size: 14px; color: var(--text); border: none; background: none; width: 100%; text-align: left; }
        .user-menu-item:hover { background: var(--ice-blue); }
        .user-menu-item .menu-icon { font-size: 18px; width: 24px; text-align: center; }
        .user-menu-divider { height: 1px; background: var(--border); margin: 4px 0; }
        .user-menu-item.danger { color: var(--speed-red); }
        .user-menu-item.danger:hover { background: #FFF5F5; }
        .role-badge { display: inline-block; padding: 2px 8px; border-radius: 8px; font-size: 11px; font-weight: 600; }
        .role-badge.admin { background: #FED7D7; color: #9B2C2C; }
        .role-badge.superadmin { background: #FEFCBF; color: #975A16; }
        .role-badge.user { background: #C6F6D5; color: #276749; }

        /* Message Board */
        .msg-form { display: flex; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; align-items: flex-end; }
        .msg-form .msg-input-name { width: 120px; padding: 10px 12px; border: 2px solid var(--border); border-radius: 10px; font-size: 14px; }
        .msg-form .msg-input-content { flex: 1; min-width: 200px; padding: 10px 12px; border: 2px solid var(--border); border-radius: 10px; font-size: 14px; }
        .msg-form .msg-input-name:focus, .msg-form .msg-input-content:focus { outline: none; border-color: var(--deep-blue); }
        .msg-list { display: flex; flex-direction: column; gap: 12px; max-height: min(600px, 70vh); overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior-y: contain; }
        .msg-thread { display: flex; flex-direction: column; gap: 10px; }
        .msg-children { display: flex; flex-direction: column; gap: 10px; margin-left: 18px; padding-left: 14px; border-left: 2px solid rgba(37,99,235,0.14); }
        .msg-item.reply-item { background: linear-gradient(180deg, rgba(37,99,235,0.04), rgba(37,99,235,0.02)); }
        .msg-item.orphan-reply { border: 1px dashed rgba(226,104,106,0.35); }
        .msg-reply-quote { background: rgba(49,130,206,0.08); padding: 6px 10px; border-radius: 6px; margin-bottom: 6px; font-size: 12px; border-left: 3px solid var(--deep-blue); }
        .msg-item { background: var(--bg); border-radius: 12px; padding: 14px 18px; position: relative; transition: all 0.2s; overflow: hidden; }
        .msg-item:hover { background: var(--ice-blue); }
        .msg-item .swipe-delete-bg { position: absolute; top: 0; right: 0; bottom: 0; width: 80px; background: var(--speed-red); display: flex; align-items: center; justify-content: center; color: white; font-weight: 600; font-size: 14px; border-radius: 0 12px 12px 0; opacity: 0; transition: opacity 0.2s; }
        .msg-item.swiping .swipe-delete-bg { opacity: 1; }
        .msg-header { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
        .msg-username { font-weight: 600; color: var(--deep-blue); font-size: 14px; cursor: pointer; transition: color 0.15s; }
        .msg-username:hover { color: var(--accent); text-decoration: underline; }
        .msg-time { font-size: 12px; color: var(--text-light); }
        .msg-content { font-size: 14px; line-height: 1.6; color: var(--text); word-break: break-word; }
        .msg-photo-thumb { display: inline-block; max-width: 160px; max-height: 160px; border-radius: 8px; margin-top: 6px; cursor: pointer; object-fit: cover; border: 1px solid var(--border); transition: transform 0.2s, box-shadow 0.2s; }
        .msg-photo-thumb:hover { transform: scale(1.05); box-shadow: 0 4px 12px rgba(0,0,0,0.15); }
        .msg-content img.msg-sticker { max-width: 120px; max-height: 120px; border-radius: 8px; margin-top: 4px; cursor: pointer; transition: transform 0.2s; }
        .msg-content img.msg-sticker:hover { transform: scale(1.3); }
        .msg-photo-lightbox { position: fixed; top: 0; left: 0; right: 0; bottom: 0; z-index: 99999; background: rgba(0,0,0,0.92); display: flex; align-items: center; justify-content: center; cursor: pointer; animation: fadeIn 0.2s; }
        .msg-photo-lightbox img { max-width: 95vw; max-height: 90vh; object-fit: contain; border-radius: 8px; }
        @keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
        .msg-delete { position: absolute; top: 8px; right: 10px; background: none; border: none; color: var(--text-light); cursor: pointer; font-size: 14px; opacity: 0; transition: opacity 0.2s; }
        .msg-item:hover .msg-delete { opacity: 1; }
        .msg-delete:hover { color: var(--speed-red); }
        .msg-edit-bar { position: absolute; top: 8px; right: 8px; display: flex; gap: 2px; opacity: 0; transition: opacity 0.2s; }
        .msg-item:hover .msg-edit-bar { opacity: 1; }
        .msg-edit-bar .msg-action-btn { font-size: 12px; padding: 2px 6px; }
        .msg-actions { display: flex; gap: 12px; margin-top: 8px; }
        .msg-action-btn { background: none; border: none; cursor: pointer; font-size: 13px; color: var(--text-light); display: flex; align-items: center; gap: 4px; padding: 4px 8px; border-radius: 6px; transition: all 0.15s; }
        .msg-action-btn:hover { background: var(--ice-blue); color: var(--deep-blue); }
        .msg-action-btn.liked { color: var(--speed-red); }
        .msg-emoji-bar { display: flex; gap: 4px; flex-wrap: wrap; padding: 8px; background: var(--bg); border-radius: 10px; margin-top: 8px; border: 1px solid var(--border); }
        .msg-emoji-btn { background: none; border: none; font-size: 22px; cursor: pointer; padding: 4px; border-radius: 6px; transition: transform 0.15s; }
        .msg-emoji-btn:hover { transform: scale(1.3); background: var(--ice-blue); }
        .msg-compose { position: relative; }
        .msg-compose-row { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
        .msg-compose-actions { display: flex; gap: 6px; align-items: center; flex-shrink: 0; }
        .msg-input-name { flex: 0 0 120px; padding: 10px 12px; border: 2px solid var(--border); border-radius: 10px; font-size: 14px; }
        .msg-input-content { flex: 1; min-width: 200px; padding: 10px 12px; border: 2px solid var(--border); border-radius: 10px; font-size: 14px; }
        .msg-input-name:focus, .msg-input-content:focus { outline: none; border-color: var(--deep-blue); }
        .msg-sticker-preview { max-width: 80px; max-height: 80px; border-radius: 8px; margin-top: 4px; }
        .msg-sticker-remove { position: absolute; top: -6px; right: -6px; background: var(--speed-red); color: white; border: none; border-radius: 50%; width: 20px; height: 20px; font-size: 12px; cursor: pointer; display: flex; align-items: center; justify-content: center; }

        /* Visit Stats */
        .visit-stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 24px; }
        .visit-stat { background: var(--bg); border-radius: 14px; padding: 20px; text-align: center; }
        .visit-stat-value { font-size: 32px; font-weight: 700; color: var(--deep-blue); }
        .visit-stat-label { font-size: 13px; color: var(--text-light); margin-top: 4px; }

        @media (max-width: 768px) {
            .msg-form { flex-direction: column; }
            .msg-form .msg-input-name { width: 100%; }
            .msg-compose-row { flex-wrap: wrap; }
            .msg-compose-row .msg-input-content { min-width: 0; flex: 1 1 120px; }
            .msg-compose-actions { flex-wrap: nowrap; }
            .visit-stats-grid { grid-template-columns: repeat(3, 1fr); gap: 10px; }
            .visit-stat { padding: 14px 10px; }
            .visit-stat-value { font-size: 24px; }
            .visit-stat-label { font-size: 11px; }
        }

        /* Search results dropdown */
        .search-dropdown { position: absolute; top: 100%; left: 0; right: 0; background: var(--card); border: 1px solid var(--border); border-radius: 10px; max-height: 160px; overflow-y: auto; z-index: 100; box-shadow: var(--shadow-md); }
        .search-dropdown div { padding: 8px 14px; cursor: pointer; font-size: 14px; border-bottom: 1px solid var(--border); }
        .search-dropdown div:last-child { border-bottom: none; }
        .search-dropdown div:hover { background: var(--ice-blue); }

        .detail-panel { display: none; margin-top: 24px; }
        .detail-panel.show { display: block; }
        .detail-header { display: flex; align-items: center; gap: 20px; margin-bottom: 24px; padding-bottom: 20px; border-bottom: 2px solid var(--border); }
        .detail-avatar { width: 72px; height: 72px; border-radius: 50%; background: linear-gradient(135deg, var(--deep-blue), var(--accent-blue)); color: white; display: flex; align-items: center; justify-content: center; font-size: 28px; font-weight: 600; }
        .detail-info h3 { font-size: 24px; color: var(--deep-blue); margin-bottom: 4px; }
        .detail-info p { color: var(--text-light); font-size: 14px; }

        .event-tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 20px; }
        .event-tab { padding: 10px 18px; border: 2px solid var(--border); border-radius: 25px; background: var(--card); cursor: pointer; font-size: 14px; font-weight: 500; transition: all 0.2s; color: var(--text); }
        .event-tab:hover { border-color: var(--deep-blue); }
        .event-tab.active { background: var(--deep-blue); color: white; border-color: var(--deep-blue); }

        .chart-container { position: relative; height: 420px; margin: 16px 0; }

        .results-table { width: 100%; border-collapse: collapse; font-size: 14px; table-layout: auto; }
        .results-table th { text-align: left; padding: 12px 16px; background: var(--bg); color: var(--text-light); font-weight: 600; font-size: 12px; white-space: nowrap; }
        .results-table td { padding: 14px 16px; border-bottom: 1px solid var(--border); white-space: nowrap; }
        .results-table tr:hover td { background: var(--ice-blue); }
        .round-badge { display: inline-block; padding: 4px 10px; border-radius: 6px; font-size: 12px; font-weight: 500; }
        .round-badge.final-a { background: linear-gradient(135deg, #F6AD55, #ED8936); color: white; }
        .round-badge.final-b { background: var(--silver); color: white; }
        .round-badge.semi { background: var(--accent-blue); color: white; }
        .round-badge.other { background: var(--border); color: var(--text-light); }

        .medal-table { width: 100%; border-collapse: collapse; }
        .medal-table th { text-align: left; padding: 12px 16px; background: var(--bg); color: var(--text-light); font-weight: 600; font-size: 12px; }
        .medal-table td { padding: 14px 16px; border-bottom: 1px solid var(--border); }
        .medal-gold { color: #DD6B20; font-weight: 700; font-size: 24px; }
        .medal-silver { color: #718096; font-weight: 700; font-size: 24px; }
        .medal-bronze { color: #C05621; font-weight: 700; font-size: 24px; }

        /* Live Match Banner */
        .match-banner { background: linear-gradient(135deg, #FFF5E6 0%, #FEEBC8 100%); border: 2px solid #F6AD55; border-radius: 16px; padding: 20px 24px; margin-bottom: 24px; display: flex; align-items: center; gap: 16px; }
        .live-dot { width: 12px; height: 12px; background: var(--speed-red); border-radius: 50%; animation: pulse 1.5s infinite; }
        @keyframes pulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.5; transform: scale(1.2); } }

        /* Live Race Groups */
        .race-group { background: var(--bg); border-radius: 12px; padding: 16px 20px; margin-bottom: 12px; border-left: 4px solid var(--deep-blue); }
        .race-group-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
        .race-group-title { font-weight: 600; font-size: 16px; color: var(--deep-blue); }
        .race-sub-group { padding: 10px 0; border-bottom: 1px solid var(--border); }
        .race-sub-group:last-child { border-bottom: none; }
        .race-sub-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; font-size: 14px; color: var(--text); }
        .race-sub-place { font-size: 13px; color: var(--text-light); font-weight: 500; }
        .race-athletes { display: flex; flex-wrap: wrap; gap: 8px; }
        .race-athlete { padding: 6px 14px; border-radius: 20px; font-size: 13px; font-weight: 500; cursor: pointer; transition: all 0.2s; }
        .race-athlete.chaoyang { background: linear-gradient(135deg, var(--deep-blue), var(--accent-blue)); color: white; }
        .race-athlete.opponent { background: var(--card); border: 1px solid var(--border); color: var(--text); }
        .race-athlete.opponent:hover { border-color: var(--accent-blue); background: var(--ice-blue); }
        .race-athlete.opponent.selected { background: var(--speed-red); color: white; border-color: var(--speed-red); }

        /* Compare Chart Controls */
        .compare-controls { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
        .compare-controls .filter-select { min-width: 160px; }
        .compare-label { font-size: 13px; color: var(--text-light); font-weight: 500; }

        .toast { position: fixed; bottom: calc(80px + max(env(safe-area-inset-bottom, 0px), var(--sa-bottom-detect, 16px))); right: calc(16px + env(safe-area-inset-right, 0px)); left: calc(16px + env(safe-area-inset-left, 0px)); padding: 14px 24px; border-radius: 12px; color: white; font-size: 14px; z-index: 99999; transform: translateY(100px); opacity: 0; transition: all 0.3s; max-width: 400px; margin-left: auto; pointer-events: none; }
        .toast.show { transform: translateY(0); opacity: 1; pointer-events: auto; }
        .toast.success { background: var(--success); }
        .toast.error { background: var(--speed-red); }

        /* Dynamic content responsive helpers */
        .match-list { display: grid; gap: 12px; }
        .match-item { display: flex; align-items: center; gap: 16px; padding: 16px; background: var(--bg); border-radius: 12px; cursor: pointer; transition: all 0.2s; }
        .match-item:hover { background: var(--ice-blue); }
        .opp-summary-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; }
        .opp-card { padding: 8px 12px; border-radius: 8px; background: var(--bg); }

        @media (min-width: 769px) and (max-width: 1024px) {
            .match-list { grid-template-columns: repeat(2, 1fr); }
            .opp-summary-grid { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
            .match-item { flex-wrap: wrap; gap: 8px; }
            .match-item > div { min-width: 0; }
        }
        @media (min-width: 769px) and (max-width: 1024px) and (orientation: landscape) {
            .opp-summary-grid { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
        }

        /* iPad / Tablet portrait: 769px ~ 1024px */
        @media (min-width: 769px) and (max-width: 1024px) {
            .main-content { max-width: 960px; padding: 0 24px; }
            .athlete-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
            .chart-container { height: 400px; }
            .tab-btn { font-size: 14px; padding: 12px 16px; }
            .card { padding: 24px 20px; }
            .compare-controls { flex-wrap: wrap; }
            .compare-controls > div { min-width: 180px; flex: 1; }
            .detail-header { flex-wrap: nowrap; }
            .stat-card { padding: 10px 8px; }
            .stat-value { font-size: 20px; }
            .race-group { padding: 14px 18px; }
        }

        /* iPad landscape: wider layout */
        @media (min-width: 769px) and (max-width: 1024px) and (orientation: landscape) {
            .main-content { max-width: 100%; padding: 0 32px; }
            .chart-container { height: 380px; }
            .athlete-grid { grid-template-columns: repeat(auto-fill, minmax(155px, 1fr)); }
        }

        /* Phone: <= 768px */
        @media (max-width: 768px) {
            .stat-card { padding: 10px 4px; }
            .stat-value { font-size: 17px; }
            .stat-label { font-size: 10px; }
            .hero-content { padding: 8px 12px; }
            .hero h1 { font-size: 16px; }
            .main-content { padding: 8px 12px calc(80px + max(env(safe-area-inset-bottom, 0px), var(--sa-bottom-detect, 0px))) 12px; }
            .tab-nav { margin-bottom: 12px; top: 44px; }
            html { scroll-padding-top: calc(68px + env(safe-area-inset-top, 0px) + 16px); }
            .tab-btn { font-size: 13px; padding: 10px 14px; }
            .bottom-tab-bar { padding-bottom: max(env(safe-area-inset-bottom, 0px), var(--sa-bottom-detect, 0px)); }
            .bottom-tab-item { padding: 8px 0; }
            .bottom-tab-icon { font-size: 20px; }
            .bottom-tab-label { font-size: 9px; }
            .athlete-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
            .card { padding: 20px 16px; border-radius: 16px; }
            .detail-header { flex-direction: column; align-items: flex-start; gap: 12px; }
            .detail-header > button { align-self: flex-end; }
            .detail-avatar { width: 56px; height: 56px; font-size: 22px; }
            .detail-info h3 { font-size: 20px; }
            .chart-container { height: 320px; }
            .compare-controls { flex-direction: column; }
            .compare-controls > div { width: 100%; }
            .filter-select { width: 100%; min-width: unset; }
            .search-input { min-width: unset; }
            .results-table { font-size: 12px; width: auto; min-width: 100%; }
            .results-table th, .results-table td { padding: 10px 8px; }
            /* Mobile: hide season & events columns in athlete detail results table */
            #resultsTable th:nth-child(2), #resultsTable td:nth-child(2),
            #resultsTable th:nth-child(4), #resultsTable td:nth-child(4) { display: none; }
            .match-banner { flex-direction: column; align-items: flex-start; padding: 16px; }
            .hero-right { gap: 4px; }
            .update-text { display: none; }
            .race-group { padding: 12px 14px; }
            .match-list { grid-template-columns: 1fr; }
            .opp-summary-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
            .match-item { gap: 12px; padding: 14px; }
            .modal-box { padding: 24px 20px; width: 95%; max-height: 85vh; }
            .user-menu { min-width: 180px; max-width: calc(100vw - 24px); }
            .sub-tab-btn { font-size: 12px; padding: 7px 12px; }
        }

        @media (max-width: 480px) {
            .hero h1 { font-size: 15px; letter-spacing: 0; }
            .hero-right { gap: 4px; }
            .update-btn { padding: 4px 8px; font-size: 11px; }
            .user-badge { padding: 5px 10px; font-size: 12px; }
            .tab-btn { font-size: 12px; padding: 10px 12px; gap: 4px; }
            .tab-nav { top: 40px; }
            .stat-value { font-size: 15px; }
            .stat-label { font-size: 9px; }
            .stat-card { padding: 8px 3px; }
            .athlete-grid { grid-template-columns: repeat(2, 1fr); }
            .athlete-card { padding: 14px; }
            .athlete-name { font-size: 14px; }
            .chart-container { height: 280px; }
            .card { padding: 16px 12px; }
            .card-title { font-size: 16px; }
            .opp-summary-grid { grid-template-columns: 1fr; }
            .match-item { gap: 8px; padding: 12px; }
            /* Phone: shrink padding, let table scroll naturally */
            .results-table { font-size: 11px; width: auto; min-width: 100%; }
            .results-table th, .results-table td { padding: 6px 4px; }
            /* Hide date column in popup results table */
            #athleteResultsContent .results-table th:nth-child(1),
            #athleteResultsContent .results-table td:nth-child(1) { display: none; }
            /* Hide group/category & remarks in match detail table */
            #matchDetailContent .results-table th:nth-child(4),
            #matchDetailContent .results-table td:nth-child(4),
            #matchDetailContent .results-table th:nth-child(7),
            #matchDetailContent .results-table td:nth-child(7) { display: none; }
            .msg-compose-row .msg-input-name { width: 100%; }
            .msg-compose-row { gap: 6px; }
            .msg-compose-actions button, .msg-compose-actions label { padding: 6px 10px !important; font-size: 16px !important; }
            .profile-tabs { padding: 0 12px; }
            .profile-body { padding: 0 12px; }
        }

        /* Settings Menu Items */
        .settings-menu-group { background: var(--card); border-radius: 16px; overflow: hidden; box-shadow: var(--shadow-sm); margin-bottom: 16px; border: 1px solid var(--border); }
        .settings-menu-item { display: flex; align-items: center; gap: 12px; padding: 14px 16px; cursor: pointer; border: none; background: none; width: 100%; text-align: left; font-size: 15px; color: var(--text); transition: background 0.15s; font-family: inherit; }
        .settings-menu-item:hover { background: var(--ice-blue); }
        .settings-menu-item-danger { color: var(--speed-red); }
        .settings-menu-item-danger:hover { background: rgba(255,59,92,0.1); }
        .settings-menu-row { display: flex; align-items: center; gap: 12px; padding: 14px 16px; font-size: 15px; color: var(--text); }
        .settings-menu-icon { font-size: 20px; width: 28px; text-align: center; flex-shrink: 0; }
        .settings-menu-label { flex: 1; }
        .settings-menu-arrow { color: var(--text-light); font-size: 18px; }
        .settings-menu-divider { height: 1px; background: var(--border); margin: 0 16px; }

        /* Empty State */
        .empty-state { text-align: center; padding: 40px 20px; color: var(--text-light); }
        .empty-state-icon { font-size: 48px; margin-bottom: 12px; opacity: 0.6; }
        .empty-state-title { font-size: 16px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
        .empty-state-desc { font-size: 13px; max-width: 280px; margin: 0 auto; line-height: 1.6; }

        .export-btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border: 1px solid var(--border); border-radius: 10px; background: var(--card); color: var(--text); cursor: pointer; font-size: 13px; font-family: inherit; transition: all 0.15s; }
        .export-btn:hover { background: var(--ice-blue); border-color: var(--deep-blue); color: var(--deep-blue); }

        /* Prevent fixed elements from being obscured by virtual keyboard on mobile */
        @supports (height: 1dvh) {
            .modal-overlay { height: 100dvh; }
            #loginPage > div { min-height: 100dvh; }
        }

        /* Ensure touch targets are at least 44px for accessibility */
        @media (pointer: coarse) {
            .tab-btn { min-height: 44px; }
            .user-badge { min-height: 44px; padding: 8px 14px; }
            .update-btn { min-height: 44px; }
            .msg-compose-actions button, .msg-compose-actions label { min-height: 44px; min-width: 44px; }
            .modal-btn { min-height: 48px; }
            .filter-select { min-height: 48px; }
            .search-input { min-height: 48px; }
            .msg-emoji-btn { min-width: 44px; min-height: 44px; }
            .user-menu-item { min-height: 48px; }
            .event-tab { min-height: 44px; }
        }

        /* ========== Dark Theme Overrides ========== */
        [data-theme="dark"] .sub-tab-btn.active { background: var(--card); }
        [data-theme="dark"] .search-input,
        [data-theme="dark"] .modal-input,
        [data-theme="dark"] .filter-select,
        [data-theme="dark"] .training-form input,
        [data-theme="dark"] .training-form select,
        [data-theme="dark"] .training-form textarea {
            background: var(--card); color: var(--text); border-color: var(--border);
        }
        [data-theme="dark"] .search-input::placeholder,
        [data-theme="dark"] .modal-input::placeholder { color: var(--text-light); }
        [data-theme="dark"] .attendance-bar { background: var(--border); }
        [data-theme="dark"] .profile-edit-form { background: rgba(59,130,246,0.1); }
        [data-theme="dark"] .match-banner { background: linear-gradient(135deg, rgba(255,183,0,0.12) 0%, rgba(255,183,0,0.06) 100%); border-color: rgba(255,183,0,0.3); }
        [data-theme="dark"] .skeleton { background: linear-gradient(90deg, var(--border) 25%, var(--card) 50%, var(--border) 75%); background-size: 200% 100%; }
        [data-theme="dark"] .tab-btn:hover { background: rgba(59,130,246,0.08); }
        [data-theme="dark"] .card { border-color: var(--border); }
        [data-theme="dark"] .athlete-card:hover { box-shadow: 0 8px 24px rgba(0,0,0,0.3); }
        [data-theme="dark"] .bottom-tab-bar { background: rgba(22,32,64,0.95); border-color: rgba(255,255,255,0.06); box-shadow: 0 -2px 16px rgba(0,0,0,0.4); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }
        [data-theme="dark"] .bottom-tab-item.active::after { background: var(--accent-blue); }
        [data-theme="dark"] .bottom-tab-item.active { color: var(--accent-blue); }
        [data-theme="dark"] .more-menu-item:hover { background: rgba(59,130,246,0.08); }
        [data-theme="dark"] .card { border-color: rgba(59,130,246,0.12); box-shadow: 0 4px 16px rgba(0,0,0,0.3), 0 0 0 1px rgba(59,130,246,0.06); }
        [data-theme="dark"] .card:hover { box-shadow: 0 8px 24px rgba(0,0,0,0.4), 0 0 0 1px rgba(59,130,246,0.12), 0 0 20px rgba(59,130,246,0.05); }
        [data-theme="dark"] .stat-card:hover { background: rgba(59,130,246,0.08); }
        [data-theme="dark"] .hero { background: linear-gradient(135deg, #050E1F 0%, #0A1628 40%, #0F2440 100%); box-shadow: 0 2px 12px rgba(0,0,0,0.3); }
        [data-theme="dark"] .sparkline-canvas { opacity: 0.8; }
        /* Login page dark overrides for inline styles */
        [data-theme="dark"] #loginPage input,
        [data-theme="dark"] #loginPage select { background: var(--card); color: var(--text); border-color: var(--border); }
        [data-theme="dark"] #loginPage input::placeholder { color: var(--text-light); }
        [data-theme="dark"] #loginPage button[type="submit"],
        [data-theme="dark"] #loginPage button[onclick*="doPageRegister"] { background: linear-gradient(135deg, var(--deep-blue), var(--accent-blue)); }
        /* Monospace font for timing data */
        .time-result { font-family: 'JetBrains Mono', 'Menlo', 'Consolas', monospace; font-variant-numeric: tabular-nums; font-weight: 600; color: var(--deep-blue); }
        [data-theme="dark"] .time-result { color: var(--ice-blue); text-shadow: 0 0 8px rgba(0,212,255,0.3); }
        /* Dark mode glow for card hover */
        [data-theme="dark"] .card:hover { box-shadow: 0 0 20px rgba(0,212,255,0.08), var(--shadow-lg); }

        /* ========== Comprehensive Dark Theme Fixes ========== */
        /* Badges & Tags with light backgrounds */
        [data-theme="dark"] .type-badge.class { background: rgba(38,111,71,0.25); color: #68D391; }
        [data-theme="dark"] .type-badge.custom { background: rgba(85,60,154,0.25); color: #B794F4; }
        [data-theme="dark"] .schedule-type-tag.class { background: rgba(38,111,71,0.25); color: #68D391; }
        [data-theme="dark"] .schedule-type-tag.custom { background: rgba(85,60,154,0.25); color: #B794F4; }
        [data-theme="dark"] .athlete-checkbox-item.checked { background: rgba(59,130,246,0.15); border-color: var(--deep-blue); color: var(--accent-blue); }
        [data-theme="dark"] .today-training-tag.selected { background: rgba(59,130,246,0.15); border-color: var(--deep-blue); color: var(--accent-blue); }
        [data-theme="dark"] .role-badge.admin { background: rgba(155,44,44,0.25); color: #FC8181; }
        [data-theme="dark"] .role-badge.superadmin { background: rgba(151,90,22,0.25); color: #F6E05E; }
        [data-theme="dark"] .role-badge.user { background: rgba(38,111,71,0.25); color: #68D391; }
        /* Calendar days with light backgrounds */
        [data-theme="dark"] .calendar-day.has-class { background: rgba(38,111,71,0.2); color: #68D391; }
        [data-theme="dark"] .calendar-day.has-class:hover { background: rgba(38,111,71,0.35); }
        [data-theme="dark"] .calendar-day.has-custom { background: rgba(85,60,154,0.2); color: #B794F4; }
        [data-theme="dark"] .calendar-day.has-custom:hover { background: rgba(85,60,154,0.35); }
        [data-theme="dark"] .calendar-day.has-both { background: linear-gradient(135deg, rgba(38,111,71,0.2) 50%, rgba(85,60,154,0.2) 50%); color: var(--accent-blue); }
        [data-theme="dark"] .calendar-day.has-both:hover { background: linear-gradient(135deg, rgba(38,111,71,0.35) 50%, rgba(85,60,154,0.35) 50%); }
        /* Attendance bar */
        [data-theme="dark"] .attendance-bar { background: rgba(255,255,255,0.08); }
        /* Hover/active states with light backgrounds */
        [data-theme="dark"] .athlete-list-item:active { background: rgba(59,130,246,0.15); }
        [data-theme="dark"] .user-menu-item.danger:hover { background: rgba(255,59,92,0.12); }
        [data-theme="dark"] .ym-picker-cancel:hover { background: var(--card); }
        /* Login page dark overrides - text colors */
        [data-theme="dark"] #loginPage label { color: var(--text-light); }
        [data-theme="dark"] #loginPage p { color: var(--text-light); }
        [data-theme="dark"] #loginPage a { color: var(--accent-blue); }
        [data-theme="dark"] #loginPage select { background: var(--card); color: var(--text); }
        [data-theme="dark"] #loginPage input { background: var(--card); color: var(--text); border-color: var(--border); }
        [data-theme="dark"] #loginPage .border-sep { border-color: var(--border); }
        /* Card icon backgrounds */
        [data-theme="dark"] .card-title .icon { opacity: 0.85; }
        /* Profile edit form */
        [data-theme="dark"] .profile-edit-form input,
        [data-theme="dark"] .profile-edit-form textarea { background: var(--card); color: var(--text); border-color: var(--border); }
        [data-theme="dark"] .profile-edit-form .btn-cancel { background: var(--card); color: var(--text); border-color: var(--border); }
        /* Settings page - white card backgrounds */
        [data-theme="dark"] #settingsUserCard,
        [data-theme="dark"] #settingsPage div[style*="background:white"] { background: var(--card) !important; box-shadow: 0 2px 8px rgba(0,0,0,0.3) !important; }
        /* Modal/overlay backgrounds that are hardcoded white */
        [data-theme="dark"] .modal-box { background: var(--card); }
        /* Search dropdown results */
        [data-theme="dark"] div[style*="background:white"][style*="position:absolute"] { background: var(--card) !important; border-color: var(--border) !important; }
        /* Force all inline background:white to use card color in dark mode */
        [data-theme="dark"] [style*="background:white"],
        [data-theme="dark"] [style*="background: white"] { background: var(--card) !important; }
        [data-theme="dark"] [style*="background:#f7fafc"],
        [data-theme="dark"] [style*="background:#F7FAFC"] { background: var(--bg) !important; }
        /* Force inline color:#718096 to use text-light */
        [data-theme="dark"] [style*="color:#718096"] { color: var(--text-light) !important; }
        [data-theme="dark"] [style*="color:#4A5568"] { color: var(--text-light) !important; }
        [data-theme="dark"] [style*="color:#64748B"] { color: var(--text-light) !important; }
        [data-theme="dark"] [style*="color:#94A3B8"] { color: var(--text-light) !important; }
        [data-theme="dark"] [style*="color:#0F4C81"] { color: var(--accent-blue) !important; }
        [data-theme="dark"] [style*="color:#795548"] { color: var(--gold) !important; }
        /* Stat number colors that work in both themes */
        [data-theme="dark"] [style*="color:#38A169"] { color: #68D391 !important; }
        [data-theme="dark"] [style*="color:#805AD5"] { color: #B794F4 !important; }
        [data-theme="dark"] [style*="color:#2B6CB0"] { color: var(--accent-blue) !important; }
        [data-theme="dark"] [style*="color:#9B2C2C"] { color: #FC8181 !important; }
        [data-theme="dark"] [style*="color:#C53030"] { color: #FC8181 !important; }
        [data-theme="dark"] [style*="color:#DD6B20"] { color: #F6AD55 !important; }
        [data-theme="dark"] [style*="color:#6B46C1"] { color: #B794F4 !important; }
        [data-theme="dark"] [style*="color:#E53E3E"] { color: #FC8181 !important; }
        /* Light background badges/buttons in JS-generated content */
        [data-theme="dark"] [style*="background:#FED7D7"] { background: rgba(155,44,44,0.25) !important; }
        [data-theme="dark"] [style*="background:#BEE3F8"] { background: rgba(49,130,206,0.25) !important; }
        [data-theme="dark"] [style*="background:#EDE9FE"] { background: rgba(85,60,154,0.2) !important; }
        [data-theme="dark"] [style*="background:#EBF8FF"] { background: rgba(49,130,206,0.15) !important; }
        [data-theme="dark"] [style*="background:#FFF5F5"] { background: rgba(155,44,44,0.15) !important; }
        [data-theme="dark"] [style*="background:#FFFBEB"] { background: rgba(151,90,22,0.2) !important; }
        /* Border overrides for dark mode */
        [data-theme="dark"] [style*="border:1px solid #E2E8F0"],
        [data-theme="dark"] [style*="border:1px solid #FED7D7"],
        [data-theme="dark"] [style*="border:2px solid #E2E8F0"] { border-color: var(--border) !important; }
        /* Avatar crop preview area */
        [data-theme="dark"] [style*="background:#f7fafc"] { background: rgba(255,255,255,0.03) !important; }
        /* Chart stats labels */
        [data-theme="dark"] [style*="color:#10B981"] { color: #68D391 !important; }
        [data-theme="dark"] [style*="color:#2563EB"] { color: var(--accent-blue) !important; }
        [data-theme="dark"] [style*="color:#F59E0B"] { color: #F6AD55 !important; }
        /* Update toast button - white bg in dark mode */
        [data-theme="dark"] [style*="background:white"][style*="color:#1a365d"] { background: var(--card) !important; color: var(--accent-blue) !important; }
        /* Login page theme toggle button */
        [data-theme="dark"] #loginThemeToggle { background: rgba(255,255,255,0.1); border-color: rgba(255,255,255,0.2); }
        /* Fee-exempt strikethrough text */
        [data-theme="dark"] .fee-exempt { color: var(--text-light); }
        [data-theme="dark"] .fee-total { color: var(--speed-red); }
        /* Training table header background */
        [data-theme="dark"] .training-table th { background: rgba(0,0,0,0.2); }
        [data-theme="dark"] .attendance-table th { background: rgba(0,0,0,0.2); }
        [data-theme="dark"] .fee-table th { background: rgba(0,0,0,0.2); }
        [data-theme="dark"] .results-table th { background: rgba(0,0,0,0.2); }
        [data-theme="dark"] .medal-table th { background: rgba(0,0,0,0.2); }

        /* ========== Auto Dark Mode Detection ========== */
        @media (prefers-color-scheme: dark) {
            :root:not([data-theme="light"]) {
                --bg: #0B1426;
                --card: #162040;
                --text: #F1F5F9;
                --text-light: #94A3B8;
                --border: rgba(255,255,255,0.08);
                --ice-blue: #00D4FF;
                --deep-blue: #3B82F6;
                --accent-blue: #60A5FA;
                --speed-red: #FF3B5C;
                --gold: #FFB800;
                --glass: rgba(22,32,64,0.72);
                --glass-border: rgba(255,255,255,0.1);
                --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
                --shadow-md: 0 4px 16px rgba(0,0,0,0.4);
                --shadow-lg: 0 10px 40px rgba(0,0,0,0.5);
                --chart-grid: rgba(255,255,255,0.06);
                --hero-gradient: linear-gradient(135deg, #060D1F 0%, #0B1426 50%, #162040 100%);
                --login-gradient: linear-gradient(135deg, #060D1F 0%, #0B1426 30%, #0F1D3A 60%, #162040 100%);
                color-scheme: dark;
            }
        }

        /* ========== Page Transition Animations ========== */
        .section.active { animation: sectionFadeIn 0.2s ease-out forwards; }
        @keyframes sectionFadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
        .sub-section.active { animation: sectionFadeIn 0.15s ease-out; }

        /* ========== Improved Card Hover ========== */
        .athlete-card { transition: all 0.25s cubic-bezier(0.4,0,0.2,1); }
        .card { transition: box-shadow var(--transition-normal), transform 0.2s ease; }

        /* ========== Focus-visible for Accessibility ========== */
        .tab-btn:focus-visible, .sub-tab-btn:focus-visible, .modal-btn:focus-visible,
        .update-btn:focus-visible, .event-tab:focus-visible {
            outline: 2px solid var(--accent-blue);
            outline-offset: 2px;
        }

        /* ========== Smooth Scroll ========== */
        html { scroll-behavior: smooth; }

        /* ========== Offline Banner ========== */
        .offline-banner { position: fixed; top: 0; left: 0; right: 0; z-index: 99999; background: linear-gradient(135deg, #DD6B20, #C05621); color: white; text-align: center; padding: 8px 16px; font-size: 13px; font-weight: 500; transform: translateY(-100%); transition: transform 0.3s ease; pointer-events: none; }
        .offline-banner.visible { transform: translateY(0); pointer-events: auto; }

        /* ========== Loading & Error States ========== */
        @keyframes skeletonShimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
        @keyframes spin { to { transform: rotate(360deg); } }
        .loading-skeleton { background: linear-gradient(90deg, var(--border) 25%, var(--card) 50%, var(--border) 75%); background-size: 200% 100%; animation: skeletonShimmer 1.5s ease-in-out infinite; border-radius: 8px; }
        .skeleton-card { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 20px; background: var(--card); border-radius: 16px; }
        .skeleton-avatar { width: 64px; height: 64px; border-radius: 50%; }
        .skeleton-line { height: 14px; border-radius: 7px; }
        .skeleton-line-sm { height: 12px; border-radius: 6px; width: 60%; }
        .skeleton-line-xs { height: 10px; border-radius: 5px; width: 80%; }
        .skeleton-sparkline { width: 120px; height: 28px; margin-top: 6px; }
        .skeleton-chart { width: 100%; height: 280px; }
        .chart-container { position: relative; }
        .chart-placeholder { position: absolute; top: 0; left: 0; right: 0; bottom: 0; z-index: 1; pointer-events: none; }
        .loading-overlay { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 40px; gap: 12px; color: var(--text-light); }
        .loading-spinner { width: 32px; height: 32px; border: 3px solid var(--border); border-top-color: var(--deep-blue); border-radius: 50%; animation: spin 0.8s linear infinite; }
        .error-state, .empty-state { text-align: center; padding: 48px 24px; }
        .empty-state-icon { font-size: 52px; margin-bottom: 14px; opacity: 0.7; }
        .empty-state-title { font-size: 17px; font-weight: 600; color: var(--text); margin-bottom: 8px; }
        .empty-state-desc { font-size: 14px; color: var(--text-light); margin-bottom: 16px; max-width: 300px; margin-left: auto; margin-right: auto; line-height: 1.5; }
        .error-icon, .empty-icon { font-size: 48px; margin-bottom: 12px; }
        .error-message, .empty-text { color: var(--text-light); font-size: 14px; }
        .retry-btn { display: inline-flex; align-items: center; gap: 6px; margin-top: 12px; padding: 10px 22px; background: var(--deep-blue); color: white; border: none; border-radius: 10px; cursor: pointer; font-size: 14px; font-weight: 500; transition: opacity 0.2s, transform 0.15s; }
        .retry-btn:hover { opacity: 0.9; transform: scale(1.03); }
        .retry-btn:active { transform: scale(0.97); }

        /* ========== Image Fade-in ========== */
        .img-fade-in { opacity: 0; transition: opacity 0.35s ease; }
        .img-fade-in.loaded { opacity: 1; }

        /* ========== Table Scroll Hint ========== */
        .table-scroll-wrap { position: relative; overflow-x: auto; -webkit-overflow-scrolling: touch; }
        [data-scroll-hint] { position: relative; }
        [data-scroll-hint]::after { content: ''; position: absolute; right: 0; top: 0; bottom: 0; width: 28px; background: linear-gradient(to right, transparent, var(--bg) 80%); pointer-events: none; transition: opacity 0.3s; z-index: 1; }
        [data-scroll-hint].scrolled-end::after { opacity: 0; }
        .table-scroll-wrap::after { content: ''; position: absolute; right: 0; top: 0; bottom: 0; width: 28px; background: linear-gradient(to right, transparent, var(--bg) 80%); pointer-events: none; transition: opacity 0.3s; }
        .table-scroll-wrap.scrolled-end::after { opacity: 0; }

        /* ========== Back to Top Button ========== */
        .back-to-top { position: fixed; bottom: 90px; right: 16px; z-index: 9980; width: 44px; height: 44px; border-radius: 50%; background: var(--deep-blue); color: white; border: none; box-shadow: 0 4px 14px rgba(0,0,0,0.2); cursor: pointer; font-size: 18px; display: flex; align-items: center; justify-content: center; opacity: 0; transform: translateY(20px); transition: opacity 0.25s, transform 0.25s; pointer-events: none; }
        .back-to-top.visible { opacity: 0.9; transform: translateY(0); pointer-events: auto; }
        .back-to-top:hover { opacity: 1; transform: translateY(-2px); }
        .back-to-top:active { transform: scale(0.93); }

        /* ========== Bottom Nav Active Animation ========== */
        .bottom-tab-item { transition: color 0.2s, transform 0.15s; }
        .bottom-tab-item:active { transform: scale(0.92); }
        .bottom-tab-item.active { transform: scale(1.05); }

        /* ========== Form Validation ========== */
        input.input-valid, select.input-valid { border-color: var(--success) !important; background: rgba(22,163,74,0.04) !important; }
        input.input-invalid, select.input-invalid { border-color: var(--speed-red) !important; background: rgba(220,38,38,0.04) !important; animation: inputShake 0.4s ease; }
        @keyframes inputShake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
        .validation-feedback { font-size: 12px; margin-top: 3px; min-height: 16px; transition: color 0.2s; }
        .validation-feedback.valid { color: var(--success); }
        .validation-feedback.invalid { color: var(--speed-red); }
        .validation-feedback.info { color: var(--text-light); }

        /* ========== Print Styles ========== */
        @media print {
            .hero, .tab-nav, .user-badge, .update-btn, .theme-toggle, #themeToggle { display: none !important; }
            .card { box-shadow: none; border: 1px solid #ddd; break-inside: avoid; }
            body { background: white; color: black; }
        }
