/* ═══════════════════════════════════════════════════════════════════
   MUSEFIT — NATIVE APP THEME v2.0
   Dark, focused, purple-accented. Built for WebView on PC & mobile.
   ═══════════════════════════════════════════════════════════════════ */

/* ── Design tokens ─────────────────────────────────────────────── */
:root {
    /* Brand */
    --primary:       #7c4dff;
    --primary-hover: #6a3de8;
    --primary-light: rgba(124, 77, 255, 0.14);
    --primary-ring:  rgba(124, 77, 255, 0.28);
    --primary-glow:  rgba(124, 77, 255, 0.42);

    /* Surfaces */
    --bg:    #0b0917;
    --bg-2:  #100e1c;
    --bg-3:  #171328;
    --bg-4:  #1e1a34;
    --bg-5:  #26213f;

    /* Borders */
    --line:        rgba(255, 255, 255, 0.055);
    --line-strong: rgba(255, 255, 255, 0.10);
    --line-brand:  rgba(124, 77, 255, 0.22);

    /* Text */
    --ink:   #ede8ff;
    --ink-2: #9790b5;
    --ink-3: #5a546e;

    /* Semantic status */
    --success:    #4cd964;
    --success-bg: rgba(76, 217, 100, 0.12);
    --warning:    #ff9f0a;
    --warning-bg: rgba(255, 159, 10, 0.12);
    --error:      #ff3b30;
    --error-bg:   rgba(255, 59, 48, 0.12);
    --info:       #0a84ff;
    --info-bg:    rgba(10, 132, 255, 0.12);

    /* Text aliases (backward compat with JS) */
    --text-dark: var(--ink);
    --text-gray: var(--ink-2);

    /* Layout */
    --sidebar-w:    80px;
    --bottom-nav-h: 68px;
    --content-pad:  16px;
    --gap:          16px;

    /* Radii */
    --r-xs: 6px;
    --r-sm: 8px;
    --r-md: 12px;
    --r-lg: 16px;
    --r-xl: 20px;
    --border-radius: 16px;

    /* Motion */
    --ease:      cubic-bezier(0.25, 1, 0.5, 1);
    --ease-fast: cubic-bezier(0.16, 1, 0.3, 1);

    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* ── Reset ──────────────────────────────────────────────────────── */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html { height: 100%; scroll-behavior: smooth; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 1rem;
    line-height: 1.5;
    background: var(--bg) !important;
    background-image: none !important;
    color: var(--ink);
    min-height: 100%;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

/* ── Global selection & focus ───────────────────────────────────── */
::selection {
    background: var(--primary-light);
    color: var(--ink);
}

:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* ── App root ───────────────────────────────────────────────────── */
#app-root {
    width: 100%;
    min-height: 100svh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0;
    overflow-y: auto;
}

/* ── Loader overlay ─────────────────────────────────────────────── */
#loader-overlay {
    position: fixed;
    inset: 0;
    background: var(--bg);
    z-index: 10000;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 20px;
    backdrop-filter: none;
}

#loader-overlay h3 {
    color: var(--ink-2);
    font-size: 15px;
    font-weight: 500;
    margin: 0;
}

.loader-ring {
    width: 44px;
    height: 44px;
    border: 2.5px solid var(--bg-4);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* ── Card base (replaces glass-panel) ──────────────────────────── */
.glass-panel {
    background: var(--bg-3);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    box-shadow: none;
}

/* ─────────────────────────────────────────────────────────────────
   AUTH SCREENS  (login, register, mode)
   ─────────────────────────────────────────────────────────────────*/

.login-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 48px 36px;
    width: 100%;
    max-width: 420px;
    gap: 14px;
    text-align: center;
    animation: screenEnter 0.28s var(--ease) both;
}

/* Logo square in auth screens */
.login-container .logo {
    width: 76px;
    height: 76px;
    background: var(--primary);
    border-radius: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 32px;
    margin-bottom: 10px;
    flex-shrink: 0;
    box-shadow: 0 14px 36px var(--primary-glow);
}

.logo-img {
    width: 82%;
    height: 82%;
    object-fit: contain;
    filter: brightness(0) invert(1);
}

.login-container h2 {
    font-size: 24px;
    font-weight: 700;
    color: var(--ink);
    letter-spacing: -0.03em;
    text-wrap: balance;
    margin: 0;
}

.login-container > p {
    font-size: 14px;
    color: var(--ink-2);
    line-height: 1.55;
    margin: 0;
    text-wrap: pretty;
}

/* ── Form inputs ────────────────────────────────────────────────── */
.input-group {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 10px;
    text-align: left;
    margin-top: 8px;
}

.input-group input {
    width: 100%;
    padding: 14px 16px;
    border-radius: var(--r-md);
    border: 1.5px solid var(--line-strong);
    font-size: 15px;
    font-family: inherit;
    background: var(--bg-2);
    color: var(--ink);
    outline: none;
    transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

.input-group input::placeholder {
    color: var(--ink-3);
}

.input-group input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--primary-light);
}

.error-message {
    color: var(--error);
    font-size: 12px;
    display: none;
    margin-left: 2px;
    font-weight: 500;
}

/* ── Buttons ────────────────────────────────────────────────────── */
.login-btn {
    width: 100%;
    padding: 15px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--r-md);
    font-size: 15px;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    letter-spacing: -0.01em;
    transition: background 0.2s var(--ease), transform 0.12s var(--ease-fast), box-shadow 0.2s;
    box-shadow: 0 8px 24px var(--primary-ring);
    margin-top: 6px;
}

.login-btn:hover {
    background: var(--primary-hover);
    box-shadow: 0 12px 30px var(--primary-glow);
    transform: translateY(-2px);
}

.login-btn:active {
    transform: scale(0.97);
    transition-duration: 0.08s;
}

.secondary-btn {
    width: 100%;
    padding: 14px;
    background: transparent;
    color: var(--ink-2);
    border: 1.5px solid var(--line-strong);
    border-radius: var(--r-md);
    font-size: 15px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: border-color 0.2s, color 0.2s, transform 0.12s;
    margin-top: 4px;
}

.secondary-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.secondary-btn:active {
    transform: scale(0.97);
}

/* ── Role picker ────────────────────────────────────────────────── */
.role-picker {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    width: 100%;
    margin-top: 10px;
}

.role-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    padding: 16px 10px;
    border-radius: var(--r-md);
    cursor: pointer;
    border: 1.5px solid var(--line-strong);
    background: var(--bg-2);
    transition: border-color 0.2s, background 0.2s, transform 0.12s;
    text-align: center;
    user-select: none;
    position: relative;
}

.role-card:hover {
    border-color: var(--primary);
    background: var(--primary-light);
}

.role-card:active { transform: scale(0.97); }

.role-card--active {
    border-color: var(--primary);
    background: var(--primary-light);
    box-shadow: 0 0 0 3px var(--primary-ring);
}

.role-card__icon { font-size: 24px; line-height: 1; }
.role-card__title { font-size: 13px; font-weight: 700; color: var(--ink); }
.role-card__desc  { font-size: 11px; color: var(--ink-2); line-height: 1.4; }
.role-card__lock-icon { font-size: 14px; margin-top: 2px; }

.role-card--locked {
    cursor: not-allowed;
    opacity: 0.40;
}

.role-card--locked:hover {
    border-color: var(--line-strong);
    background: var(--bg-2);
    transform: none;
}

.role-card__lock-tooltip {
    display: none;
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-5);
    color: var(--ink);
    font-size: 11px;
    line-height: 1.4;
    padding: 8px 12px;
    border-radius: var(--r-sm);
    white-space: normal;
    max-width: 200px;
    text-align: center;
    pointer-events: none;
    z-index: 10;
    border: 1px solid var(--line-strong);
}

.role-card__lock-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: var(--bg-5);
}

.role-card--locked:hover .role-card__lock-tooltip { display: block; }

.verified-banner {
    width: 100%;
    padding: 12px 16px;
    background: var(--success-bg);
    border: 1px solid rgba(76, 217, 100, 0.22);
    border-radius: var(--r-sm);
    color: var(--success);
    font-size: 14px;
    font-weight: 500;
    text-align: center;
}

/* ─────────────────────────────────────────────────────────────────
   APP SHELL
   ─────────────────────────────────────────────────────────────────*/

.app-container {
    width: 100%;
    min-height: 100svh;
    display: none;
    grid-template-columns: var(--sidebar-w) 1fr 255px;
    grid-template-areas: "nav main right";
    gap: var(--gap);
    padding: var(--gap);
    max-width: 100%;
    animation: screenEnter 0.28s var(--ease) both;
}

.app-container.active { display: grid; }

/* ── Sidebar (desktop) ──────────────────────────────────────────── */
.sidebar {
    grid-area: nav;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 14px 8px;
    gap: 4px;
    background: var(--bg-3);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    height: fit-content;
    position: sticky;
    top: var(--gap);
}

.sidebar .logo {
    width: 44px;
    height: 44px;
    background: var(--primary);
    border-radius: var(--r-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 20px;
    margin-bottom: 12px;
    flex-shrink: 0;
    box-shadow: 0 8px 22px var(--primary-ring);
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    color: var(--ink-3);
    text-decoration: none;
    font-size: 10px;
    font-weight: 600;
    gap: 4px;
    padding: 9px 6px;
    border-radius: var(--r-md);
    transition: color 0.2s, background 0.2s;
    text-align: center;
    width: 100%;
}

.nav-item i { font-size: 18px; transition: transform 0.2s var(--ease-fast); display: block; }

.nav-item:hover {
    color: var(--ink);
    background: var(--bg-4);
}

.nav-item.active {
    color: var(--primary);
    background: var(--primary-light);
}

.nav-item.active i {
    filter: drop-shadow(0 0 5px var(--primary));
}

/* ── Main content area ──────────────────────────────────────────── */
.main-content {
    grid-area: main;
    display: flex;
    flex-direction: column;
    gap: var(--gap);
    min-width: 0;
}

/* ── Right sidebar ──────────────────────────────────────────────── */
.right-sidebar {
    grid-area: right;
    display: flex;
    flex-direction: column;
    gap: var(--gap);
    align-self: start;
    position: sticky;
    top: var(--gap);
}

/* ── Top header ─────────────────────────────────────────────────── */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: nowrap;
    gap: 12px;
    padding: 14px 20px;
    position: relative;
    z-index: 50;
}

.greeting h1 {
    font-size: clamp(16px, 1.8vw, 20px);
    margin-bottom: 3px;
    font-weight: 700;
    letter-spacing: -0.03em;
    color: var(--ink);
    text-wrap: balance;
}

.greeting p {
    color: var(--ink-2);
    font-size: 13px;
}

.header-stats {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: nowrap;
}

.stat-group {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg-2);
    padding: 7px 14px;
    border-radius: 100px;
    border: 1px solid var(--line);
    transition: transform 0.22s var(--ease), box-shadow 0.22s var(--ease);
}

.stat-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
}

.level-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 110px;
}

.level-info-top {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    font-weight: 600;
    color: var(--ink);
}

.progress-bar-bg {
    width: 100%;
    height: 4px;
    background: var(--bg-5);
    border-radius: 2px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 2px;
    transition: width 0.6s var(--ease);
}

.level-info-bottom {
    text-align: right;
    font-size: 10px;
    color: var(--ink-3);
}

.stat-text {
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.stat-text strong {
    font-size: 14px;
    color: var(--ink);
    font-weight: 700;
}

.stat-text span {
    font-size: 11px;
    color: var(--ink-2);
}

.avatar {
    width: 38px;
    height: 38px;
    background: var(--primary-light);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 700;
    font-family: inherit;
    border: 2px solid var(--line-brand);
    color: var(--primary);
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s, transform 0.12s;
    user-select: none;
    flex-shrink: 0;
}

.avatar:hover {
    background: rgba(124, 77, 255, 0.22);
    border-color: var(--primary);
    animation: avatarWiggle 0.45s var(--ease-fast) both;
}

/* Avatar dropdown */
#avatar-dropdown {
    padding: 8px;
    gap: 6px;
    width: 170px;
}

#avatar-dropdown button {
    padding: 10px 14px;
    font-size: 13px;
    margin: 0;
    width: 100%;
    text-align: left;
    border-radius: var(--r-sm);
}

/* ─────────────────────────────────────────────────────────────────
   TRACKER SCREEN
   ─────────────────────────────────────────────────────────────────*/

.tracker-screen {
    flex-grow: 1;
    min-height: 380px;
    border-radius: var(--r-lg);
    position: relative;
    overflow: hidden;
    background: var(--bg-2);
    background-image: none !important;
    border: 1px solid var(--line);
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: none;
}

.tracker-overlay-top {
    position: absolute;
    top: 16px;
    left: 0;
    right: 0;
    display: flex !important;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    color: white;
    z-index: 5;
    pointer-events: none;
    text-shadow: 0 1px 8px rgba(0,0,0,0.7);
}

.tracker-overlay-top h2 {
    display: flex !important;
    flex-wrap: wrap !important;
    justify-content: center !important;
    align-items: center !important;
    gap: 8px !important;
    width: 100%;
    font-size: 15px;
    font-weight: 700;
    letter-spacing: -0.02em;
}

#current-mode-badge {
    margin-left: 0 !important;
    font-size: 11px !important;
    padding: 3px 10px !important;
    border-radius: 100px !important;
    font-weight: 600 !important;
}

.tracker-overlay-top p {
    font-size: 12px;
    color: rgba(255,255,255,0.55);
}

.tracker-controls {
    position: absolute;
    top: 16px;
    left: 16px;
    z-index: 20;
    display: flex;
    gap: 8px;
}

.control-toggle {
    background: rgba(10, 8, 20, 0.65);
    backdrop-filter: blur(10px);
    color: white;
    padding: 7px 12px;
    border-radius: var(--r-sm);
    font-size: 12px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    border: 1px solid rgba(255,255,255,0.10);
    transition: background 0.2s, transform 0.1s;
}

.control-toggle:hover  { background: rgba(10, 8, 20, 0.85); }
.control-toggle:active { transform: scale(0.96); }

video { display: none; }

#debug_canvas {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    object-fit: cover;
    display: none;
    z-index: 2;
}

/* Start button — pulsing when idle */
#start-btn {
    padding: 14px 32px;
    font-size: 15px;
    font-weight: 700;
    font-family: inherit;
    border-radius: 100px;
    background: var(--primary);
    color: white;
    border: none;
    cursor: pointer;
    box-shadow: 0 12px 36px var(--primary-glow);
    transition: background 0.2s, transform 0.15s var(--ease-fast), box-shadow 0.2s;
    z-index: 10;
    letter-spacing: -0.01em;
    animation: pulseGlow 2.5s ease-in-out infinite;
}

#start-btn:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 18px 44px var(--primary-glow);
    animation: none;
}

#start-btn:active {
    transform: scale(0.95);
    animation: none;
    transition-duration: 0.08s;
}

@keyframes pulseGlow {
    0%, 100% { box-shadow: 0 12px 36px var(--primary-ring); }
    50%       { box-shadow: 0 12px 48px var(--primary-glow), 0 0 72px rgba(124,77,255,0.18); }
}

#stop-btn {
    position: absolute;
    bottom: 16px;
    right: 16px;
    z-index: 10;
    background: rgba(255, 59, 48, 0.82);
    backdrop-filter: blur(8px);
    color: white;
    border: 1px solid rgba(255,255,255,0.10);
    border-radius: var(--r-md);
    padding: 10px 18px;
    font-size: 13px;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    display: none;
    align-items: center;
    gap: 8px;
    transition: background 0.2s, transform 0.1s;
}

#stop-btn:hover  { background: rgba(255, 59, 48, 1); }
#stop-btn:active { transform: scale(0.96); }

#download-report-btn {
    position: absolute;
    bottom: 16px;
    right: 16px;
    z-index: 10;
    background: rgba(124, 77, 255, 0.82);
    backdrop-filter: blur(8px);
    color: white;
    border: 1px solid rgba(255,255,255,0.10);
    border-radius: var(--r-md);
    padding: 10px 18px;
    font-size: 13px;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    display: none;
    align-items: center;
    gap: 8px;
    transition: background 0.2s, transform 0.12s;
}

#download-report-btn:hover  { background: var(--primary); transform: translateY(-1px); }
#download-report-btn:active { transform: scale(0.96); }

/* Media control buttons */
.media-controls {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 12px;
    z-index: 150;
}

.media-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 1px solid rgba(255,255,255,0.10);
    background: rgba(14, 10, 26, 0.72);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    color: white;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, transform 0.12s;
    outline: none;
}

.media-btn:hover  { background: rgba(14, 10, 26, 0.92); }
.media-btn:active { transform: scale(0.96); }

.media-btn.muted {
    background: rgba(255, 59, 48, 0.85);
    border-color: rgba(255, 59, 48, 0.55);
}

/* Accuracy widget */
.accuracy-widget {
    position: absolute;
    bottom: 16px;
    left: 16px;
    background: rgba(14, 10, 26, 0.82);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    padding: 10px 16px;
    border-radius: var(--r-lg);
    display: flex;
    align-items: center;
    gap: 12px;
    color: white;
    border: 1px solid rgba(255,255,255,0.08);
    opacity: 0;
    transition: opacity 0.3s var(--ease);
    z-index: 5;
}

.circular-progress {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: conic-gradient(var(--success) 100%, #333 0);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.circular-progress::before {
    content: "";
    position: absolute;
    width: 30px;
    height: 30px;
    background: rgba(14, 10, 26, 0.88);
    border-radius: 50%;
}

.circular-progress i {
    position: relative;
    color: var(--success);
    font-size: 14px;
}

.accuracy-info h3 {
    font-size: 18px;
    margin: 0;
    font-family: monospace;
    font-weight: 700;
}

.accuracy-info p {
    font-size: 11px;
    color: rgba(255,255,255,0.45);
    margin: 0;
}

/* AI zone panel overlay */
#teacher-zone-panel {
    background: rgba(14, 10, 26, 0.90) !important;
    border: 1px solid var(--line-strong) !important;
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
}

/* ─────────────────────────────────────────────────────────────────
   STATUS PANEL
   ─────────────────────────────────────────────────────────────────*/

.status-panel {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    flex-wrap: wrap;
    gap: 12px;
    animation: slideUp 0.3s var(--ease) both;
}

.status-left {
    display: flex;
    align-items: center;
    gap: 14px;
    flex: 1;
    min-width: 220px;
}

.status-icon {
    width: 44px;
    height: 44px;
    background: var(--success-bg);
    color: var(--success);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
    transition: background 0.35s var(--ease), color 0.35s var(--ease);
}

.status-text h3 {
    margin-bottom: 3px;
    font-size: 15px;
    font-weight: 700;
    color: var(--ink);
    letter-spacing: -0.02em;
    transition: none;
}

.status-text p {
    color: var(--ink-2);
    font-size: 13px;
    line-height: 1.4;
    transition: none;
}

.status-metrics {
    display: flex;
    gap: 24px;
    flex-wrap: wrap;
}

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

.metric span {
    font-size: 11px;
    color: var(--ink-3);
    font-weight: 500;
}

.metric strong {
    font-size: 15px;
    color: var(--success);
    transition: color 0.3s;
    font-weight: 700;
}

/* ─────────────────────────────────────────────────────────────────
   TIP CARD
   ─────────────────────────────────────────────────────────────────*/

.tip-card {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.tip-header {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.tip-header .icon { color: var(--warning); font-size: 22px; }
.tip-header h3 { font-size: 15px; font-weight: 700; color: var(--ink); }

.tip-text {
    font-size: 13px;
    line-height: 1.55;
    color: var(--ink-2);
    margin: 0;
}

.tip-visual {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    margin-top: 8px;
}

.tip-image-placeholder {
    width: 90px;
    height: 90px;
    background: var(--bg-2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 38px;
    border: 1px solid var(--line);
}

.pagination { display: flex; gap: 6px; }
.dot { width: 6px; height: 6px; background: var(--bg-5); border-radius: 50%; transition: background 0.2s; }
.dot.active { background: var(--primary); }

/* ─────────────────────────────────────────────────────────────────
   STATISTICS
   ─────────────────────────────────────────────────────────────────*/

.stats-top-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--gap);
    margin-bottom: var(--gap);
    margin-top: 4px;
}

.stat-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 18px 20px;
}

.stat-card i {
    font-size: 22px;
    background: var(--bg-2);
    padding: 12px;
    border-radius: var(--r-md);
    flex-shrink: 0;
}

.stat-card p { margin: 0; color: var(--ink-2); font-size: 12px; font-weight: 500; }
.stat-card h3 { margin: 4px 0 0 0; font-size: 22px; color: var(--ink); font-weight: 700; letter-spacing: -0.03em; }

.stats-middle-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: var(--gap);
}

.chart-box, .weak-points-box, .history-box { padding: 20px; }

.chart-box h3, .weak-points-box h3, .history-box h3 {
    margin-top: 0;
    margin-bottom: 16px;
    color: var(--ink);
    font-size: 15px;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.weak-point { margin-bottom: 16px; }

.wp-header {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    margin-bottom: 7px;
    color: var(--ink-2);
    font-weight: 500;
}

.error-fill   { background: var(--error)   !important; }
.warning-fill { background: var(--warning) !important; }
.primary-fill { background: var(--primary) !important; }

.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--gap); }
.exercises-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: var(--gap); }
.achievements-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: var(--gap); }

/* History table */
.history-table { width: 100%; border-collapse: collapse; text-align: left; }
.history-table th { padding: 10px; border-bottom: 2px solid var(--line); color: var(--ink-3); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.4px; }
.history-table td { padding: 13px 10px; border-bottom: 1px solid var(--line); color: var(--ink-2); font-size: 14px; }

/* ─────────────────────────────────────────────────────────────────
   TEACHER ROLE OVERRIDES
   ─────────────────────────────────────────────────────────────────*/

body.student .student-bypass { display: none !important; }

body.teacher a[href="#/stats"],
body.teacher .right-sidebar {
    display: none !important;
}

body.teacher #app-screen {
    grid-template-columns: var(--sidebar-w) 1fr !important;
    grid-template-areas: "nav main" !important;
}

/* ─────────────────────────────────────────────────────────────────
   PIANO KEYBOARD
   ─────────────────────────────────────────────────────────────────*/

#piano-section {
    width: 100%;
    margin-top: 4px;
}

body.teacher #piano-section { margin-top: 0; }

.piano-panel {
    padding: 14px 18px 18px;
    border-radius: var(--r-lg);
    user-select: none;
    -webkit-user-select: none;
}

.piano-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
    flex-wrap: wrap;
    gap: 8px;
}

.octave-ctrl { display: flex; align-items: center; gap: 8px; }

.octave-btn {
    width: 28px;
    height: 28px;
    border-radius: var(--r-xs);
    border: 1px solid var(--line-brand);
    background: var(--bg-2);
    color: var(--primary);
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, transform 0.1s;
    padding: 0;
    font-weight: 700;
}

.octave-btn:hover  { background: var(--primary-light); }
.octave-btn:active { transform: scale(0.90); }

.octave-label { font-size: 13px; font-weight: 600; color: var(--ink); }

.piano-legend { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--ink-2); }
.piano-legend-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex-shrink: 0; }

.piano-keys-outer {
    position: relative;
    width: 100%;
    height: clamp(100px, 14vw, 145px);
}

.piano-white-keys {
    display: flex;
    width: 100%;
    height: 100%;
    position: relative;
    z-index: 1;
    gap: 1px;
}

.piano-black-keys {
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 62%;
    pointer-events: none;
    z-index: 2;
}

.pkey {
    cursor: pointer;
    touch-action: none;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
    padding-bottom: 5px;
    gap: 2px;
    transition: background 0.05s ease, transform 0.05s ease;
}

.white-key {
    flex: 1;
    background: #f4f0ff;
    border: 1px solid #c0b4e0;
    border-top: none;
    border-radius: 0 0 7px 7px;
    box-shadow: inset -1px 0 0 rgba(0,0,0,0.05), 0 4px 10px rgba(0,0,0,0.35);
    min-width: 0;
}

.white-key:active,
.white-key:hover { background: #e8e0ff; }

.black-key {
    position: absolute;
    top: 0; bottom: 0;
    background: linear-gradient(to bottom, #1a1428 0%, #251d3a 100%);
    border: 1px solid rgba(0,0,0,0.85);
    border-top: none;
    border-radius: 0 0 6px 6px;
    box-shadow: 2px 5px 12px rgba(0,0,0,0.65), inset 0 -1px 0 rgba(255,255,255,0.05);
    pointer-events: all;
    transition: background 0.06s;
}

.black-key:active,
.black-key:hover { background: linear-gradient(to bottom, #2a2050 0%, #3a2870 100%); }

.pkey-note { font-size: clamp(7px, 0.8vw, 10px); font-weight: 500; color: #8880a0; line-height: 1; pointer-events: none; }
.black-key .pkey-note { color: #42405a; }
.pkey-kb { font-size: clamp(8px, 0.9vw, 11px); font-weight: 700; color: var(--primary); font-family: monospace; line-height: 1; pointer-events: none; }

@media (max-width: 768px) {
    .piano-keys-outer { height: clamp(110px, 22vw, 160px); }
    .pkey-note, .pkey-kb { display: none; }
    .piano-panel { padding: 10px 12px 14px; }
}

/* ─────────────────────────────────────────────────────────────────
   METRONOME
   ─────────────────────────────────────────────────────────────────*/

.metronome-btn {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    font-size: 13px;
    border-radius: var(--r-sm);
    border: 1px solid var(--line-brand);
    background: var(--bg-2);
    color: var(--ink-2);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.metronome-btn.active {
    background: var(--primary-light);
    border-color: var(--primary);
    color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-ring);
}

.metronome-panel {
    display: none;
    padding: 12px 2px 14px;
    border-bottom: 1px solid var(--line);
    margin-bottom: 12px;
}

.metronome-panel.open {
    display: block;
    animation: metroOpen 0.22s var(--ease);
}

@keyframes metroOpen {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: none; }
}

.metro-controls { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.metro-group { display: flex; flex-direction: column; gap: 5px; }

.metro-label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--ink-3);
    user-select: none;
}

.metro-bpm-row { display: flex; align-items: center; gap: 4px; }

.metro-small-btn {
    width: 26px;
    height: 26px;
    border-radius: var(--r-xs);
    border: 1px solid var(--line-brand);
    background: var(--bg-2);
    color: var(--primary);
    font-size: 16px;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, transform 0.1s;
    padding: 0;
    flex-shrink: 0;
}

.metro-small-btn:hover  { background: var(--primary-light); }
.metro-small-btn:active { transform: scale(0.96); }

.metro-bpm-input {
    width: 54px;
    text-align: center;
    border: 1px solid var(--line-brand);
    border-radius: var(--r-xs);
    padding: 3px 4px;
    font-size: 15px;
    font-weight: 700;
    font-family: inherit;
    color: var(--ink);
    outline: none;
    background: var(--bg-2);
    -moz-appearance: textfield;
}

.metro-bpm-input::-webkit-inner-spin-button,
.metro-bpm-input::-webkit-outer-spin-button { -webkit-appearance: none; }
.metro-bpm-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }

.metro-slider { width: 110px; accent-color: var(--primary); cursor: pointer; display: block; margin-top: 2px; }

.metro-select {
    height: 30px;
    padding: 0 8px;
    border: 1px solid var(--line-brand);
    border-radius: var(--r-xs);
    background: var(--bg-2);
    color: var(--ink);
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    outline: none;
}

.metro-select:focus { border-color: var(--primary); }

.metro-play-group { margin-left: auto; }

.metro-play-btn {
    height: 32px;
    padding: 0 16px;
    border-radius: var(--r-sm);
    border: none;
    background: var(--primary);
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 7px;
    transition: background 0.2s, transform 0.1s;
    white-space: nowrap;
}

.metro-play-btn:hover    { background: var(--primary-hover); }
.metro-play-btn:active   { transform: scale(0.96); }
.metro-play-btn.is-running { background: var(--error); }
.metro-play-btn.is-running:hover { background: #cc2020; }

.metro-beats {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    align-items: center;
    flex-wrap: wrap;
}

.metro-beat-dot {
    display: block;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--bg-4);
    border: 2px solid var(--line-strong);
    transition: background 0.07s, box-shadow 0.07s, transform 0.07s;
    flex-shrink: 0;
}

.metro-beat-dot.is-accent {
    width: 18px;
    height: 18px;
    border-color: var(--line-brand);
}

.metro-beat-dot.lit {
    background: var(--primary);
    border-color: var(--primary);
    box-shadow: 0 0 12px var(--primary-ring);
    transform: scale(1.22);
}

.metro-beat-dot.is-accent.lit {
    background: #ff6b35;
    border-color: #ff6b35;
    box-shadow: 0 0 14px rgba(255,107,53,0.6);
}

@media (max-width: 768px) {
    .metro-controls { gap: 10px; }
    .metro-slider { width: 80px; }
    .metro-play-group { margin-left: 0; width: 100%; }
    .metro-play-btn { width: 100%; justify-content: center; }
    .metro-small-btn { width: 32px; height: 32px; }
    .octave-btn { width: 36px; height: 36px; }
}

/* ─────────────────────────────────────────────────────────────────
   SCHEDULE
   ─────────────────────────────────────────────────────────────────*/

.schedule-section {
    padding: 18px 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.schedule-header { display: flex; justify-content: space-between; align-items: center; }

.schedule-title { display: flex; align-items: center; gap: 10px; color: var(--primary); }
.schedule-title i { font-size: 17px; }
.schedule-title h3 { margin: 0; font-size: 15px; font-weight: 700; }

.schedule-add-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--r-sm);
    font-size: 13px;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}

.schedule-add-btn:hover  { background: var(--primary-hover); }
.schedule-add-btn:active { transform: scale(0.96); }

.schedule-add-form {
    display: none;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    background: var(--primary-light);
    border: 1px solid var(--line-brand);
    border-radius: var(--r-md);
    animation: fadeIn 0.2s var(--ease);
}

.schedule-add-form.visible { display: flex; }

.schedule-add-form input[type="date"],
.schedule-add-form input[type="time"],
.schedule-add-form input[type="email"] {
    padding: 8px 12px;
    border-radius: var(--r-sm);
    border: 1px solid var(--line-strong);
    background: var(--bg-2);
    font-family: inherit;
    font-size: 13px;
    outline: none;
    transition: border-color 0.2s;
    color: var(--ink);
}

.schedule-add-form input[type="date"] { flex: 0 0 auto; }
.schedule-add-form input[type="time"] { flex: 0 0 auto; width: 120px; }
.schedule-add-form input[type="email"] { flex: 1 1 180px; min-width: 180px; }
.schedule-add-form input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }

.schedule-form-actions { display: flex; gap: 8px; flex-shrink: 0; }

.schedule-save-btn {
    display: flex; align-items: center; gap: 6px;
    padding: 8px 14px;
    background: var(--success);
    color: white;
    border: none;
    border-radius: var(--r-sm);
    font-size: 13px;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.2s;
}

.schedule-save-btn:hover { background: #3aad40; }
.schedule-save-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.schedule-cancel-btn {
    padding: 8px 12px;
    background: transparent;
    color: var(--ink-2);
    border: 1px solid var(--line-strong);
    border-radius: var(--r-sm);
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.2s;
}

.schedule-cancel-btn:hover { background: var(--bg-4); }

.schedule-form-error { width: 100%; font-size: 12px; color: var(--error); margin-top: -4px; }

.schedule-week-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.schedule-day-col { display: flex; flex-direction: column; gap: 5px; min-width: 0; }

.schedule-day-header {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--ink-3);
    padding: 4px 2px;
    text-align: center;
    border-bottom: 2px solid transparent;
}

.schedule-day-col .day-full { display: none; }
.schedule-day-col.today .schedule-day-header { color: var(--primary); border-bottom-color: var(--primary); }
.schedule-empty { font-size: 11px; color: var(--ink-3); text-align: center; padding: 8px 4px; }

.schedule-entry {
    position: relative;
    background: var(--primary-light);
    border: 1px solid var(--line-brand);
    border-radius: var(--r-xs);
    padding: 6px 7px;
    cursor: pointer;
    transition: background 0.15s, box-shadow 0.15s;
}

.schedule-entry:hover { background: rgba(124,77,255,0.22); box-shadow: 0 2px 10px var(--primary-ring); }
.schedule-entry.lesson-soon { background: var(--success-bg); border-color: rgba(76,217,100,0.22); }
.schedule-entry-time { font-size: 11px; font-weight: 700; color: var(--primary); line-height: 1; margin-bottom: 3px; }
.schedule-entry.lesson-soon .schedule-entry-time { color: var(--success); }
.schedule-entry-email { font-size: 10px; color: var(--ink-2); word-break: break-all; line-height: 1.3; padding-right: 16px; }

.schedule-entry-delete {
    position: absolute; top: 3px; right: 3px;
    background: none; border: none;
    color: var(--ink-3); cursor: pointer;
    font-size: 10px; padding: 2px 4px;
    border-radius: 3px; line-height: 1;
    transition: color 0.15s, background 0.15s;
}

.schedule-entry-delete:hover { color: var(--error); background: var(--error-bg); }

.schedule-week-nav { display: flex; align-items: center; gap: 10px; margin: 4px 0; }

.schedule-week-btn {
    display: flex; align-items: center; justify-content: center;
    width: 26px; height: 26px; border: none; border-radius: var(--r-xs);
    background: var(--primary-light); color: var(--primary);
    cursor: pointer; font-size: 12px;
    transition: background 0.15s;
    flex-shrink: 0;
}

.schedule-week-btn:hover { background: rgba(124,77,255,0.25); }
.schedule-week-label { flex: 1; text-align: center; font-size: 12px; font-weight: 600; color: var(--ink-2); }

.day-date-num { display: block; font-size: 14px; font-weight: 700; color: var(--ink); line-height: 1.1; margin-top: 1px; }
.schedule-day-col.today .day-date-num { color: var(--primary); }

.schedule-entry-badge { display: inline-block; margin-top: 4px; padding: 1px 6px; border-radius: 4px; font-size: 9px; font-weight: 700; letter-spacing: 0.3px; color: white; }
.badge-soon { background: var(--success); }
.badge-now  { background: #ff6b35; }

.schedule-entry.lesson-now { background: rgba(255,107,53,0.12); border-color: rgba(255,107,53,0.35); }
.schedule-entry.lesson-now .schedule-entry-time { color: #ff6b35; }

.schedule-entry.lesson-done { background: var(--bg-2); border-color: var(--line); opacity: 0.45; cursor: default; }
.schedule-entry.lesson-done .schedule-entry-time,
.schedule-entry.lesson-done .schedule-entry-email { color: var(--ink-3); }

#call-btn:disabled { cursor: not-allowed !important; transform: none !important; box-shadow: none !important; }

@media (max-width: 1100px) { .schedule-week-grid { grid-template-columns: repeat(4, 1fr); } }
@media (max-width: 700px)  { .schedule-week-grid { grid-template-columns: repeat(2, 1fr); } .schedule-day-col .day-short { display: none; } .schedule-day-col .day-full { display: inline; } .schedule-day-header { font-size: 10px; } }
@media (max-width: 420px)  { .schedule-week-grid { grid-template-columns: 1fr; } .schedule-add-form { flex-direction: column; } .schedule-add-form input[type="date"], .schedule-add-form input[type="time"], .schedule-add-form input[type="email"] { width: 100%; } }

/* ─────────────────────────────────────────────────────────────────
   BOTTOM NAVIGATION (mobile only)
   ─────────────────────────────────────────────────────────────────*/

.bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-3);
    border-top: 1px solid var(--line-strong);
    z-index: 900;
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

.bottom-nav-inner {
    display: flex;
    align-items: center;
    justify-content: space-around;
    height: var(--bottom-nav-h);
    padding: 0 8px;
}

.bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--ink-3);
    text-decoration: none;
    font-size: 10px;
    font-weight: 600;
    gap: 4px;
    padding: 8px 20px;
    border-radius: var(--r-md);
    transition: color 0.2s, background 0.2s;
    flex: 1;
    position: relative;
}

.bottom-nav-item i { font-size: 22px; }

.bottom-nav-item.active { color: var(--primary); }

.bottom-nav-item.active::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 28px;
    height: 3px;
    background: var(--primary);
    border-radius: 0 0 3px 3px;
}

/* ─────────────────────────────────────────────────────────────────
   PERMISSION MODAL
   ─────────────────────────────────────────────────────────────────*/

#permission-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(0, 0, 0, 0.82);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    justify-content: center;
    align-items: center;
}

#permission-modal > div {
    background: var(--bg-3) !important;
    border: 1px solid var(--line-strong) !important;
    border-radius: 24px !important;
    box-shadow: 0 32px 80px rgba(0,0,0,0.75) !important;
    animation: modalEnter 0.25s var(--ease) both !important;
}

#permission-modal h2 { color: var(--ink) !important; }
#permission-modal p  { color: var(--ink-2) !important; }
#permission-modal strong { color: var(--primary) !important; }

/* ─────────────────────────────────────────────────────────────────
   ANIMATIONS & KEYFRAMES
   ─────────────────────────────────────────────────────────────────*/

@keyframes screenEnter {
    from { opacity: 0; transform: translateY(14px) scale(0.98); }
    to   { opacity: 1; transform: none; }
}

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

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

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

@keyframes tabEnter {
    from { opacity: 0; transform: translateX(12px); }
    to   { opacity: 1; transform: translateX(0); }
}

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

/* Applied by JS when switching tabs */
.tab-enter { animation: tabEnter 0.28s var(--ease) both; }

/* Applied by JS on view transition */
.view-leaving {
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.15s ease-in, transform 0.15s ease-in;
    pointer-events: none;
}

/* Session live chip */
.session-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 11px;
    background: rgba(255, 59, 48, 0.14);
    border: 1px solid rgba(255, 59, 48, 0.28);
    border-radius: 100px;
    font-size: 12px;
    font-weight: 700;
    color: var(--error);
    font-family: monospace;
}

.session-chip::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--error);
    animation: blink 1.2s ease-in-out infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.25; }
}

/* ─────────────────────────────────────────────────────────────────
   RESPONSIVE BREAKPOINTS
   ─────────────────────────────────────────────────────────────────*/

/* Medium — hide right sidebar */
@media (max-width: 1150px) {
    .app-container.active {
        grid-template-columns: var(--sidebar-w) 1fr;
        grid-template-areas: "nav main";
    }
    .right-sidebar { display: none; }
}

/* Mobile — bottom nav, single column */
@media (max-width: 768px) {
    #app-root {
        align-items: flex-start;
        padding-bottom: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom, 0px));
    }

    .app-container.active {
        display: flex !important;
        flex-direction: column !important;
        gap: var(--gap);
        padding: calc(env(safe-area-inset-top, 0px) + var(--content-pad)) var(--content-pad) calc(var(--bottom-nav-h) + env(safe-area-inset-bottom, 0px) + var(--content-pad));
        min-height: calc(100svh - var(--bottom-nav-h));
    }

    .sidebar { display: none !important; }
    .bottom-nav { display: block; }

    /* Auth: full-screen card on mobile */
    .login-container {
        padding: calc(36px + env(safe-area-inset-top, 0px)) 24px calc(36px + env(safe-area-inset-bottom, 0px));
        max-width: 100%;
        border-radius: 0;
        min-height: 100svh;
        border: none;
        justify-content: center;
    }

    .header {
        flex-direction: column;
        align-items: flex-start;
        padding: 14px 16px;
        gap: 12px;
    }

    .greeting { padding-right: 48px; }

    .header-stats {
        flex-direction: column;
        align-items: stretch;
        width: 100%;
        gap: 8px;
    }

    .stat-group {
        width: 100%;
        justify-content: flex-start;
        padding: 10px 14px;
        border-radius: var(--r-md);
    }

    .avatar-wrapper {
        position: static !important;
    }

    .avatar {
        position: absolute !important;
        top: 14px !important;
        right: 16px !important;
        z-index: 100 !important;
    }

    .tracker-screen {
        min-height: 360px !important;
        height: auto !important;
    }

    .tracker-overlay-top {
        padding: 0 60px !important;
        text-align: center !important;
    }

    .tracker-controls {
        top: auto !important;
        bottom: 82px !important;
        left: 10px !important;
        right: 10px !important;
        justify-content: center !important;
    }

    .accuracy-widget {
        bottom: 10px !important;
        left: 10px !important;
        padding: 8px 12px !important;
    }

    #webcam:not([style*="width: 100%"]),
    #remote-video:not([style*="width: 100%"]) {
        width: 100px !important;
        height: 76px !important;
        bottom: 82px !important;
        right: 10px !important;
        border-radius: var(--r-sm) !important;
    }

    .media-controls {
        bottom: 12px !important;
        gap: 10px !important;
    }

    .status-panel {
        flex-direction: column;
        align-items: flex-start;
        padding: 14px 16px;
        gap: 14px;
    }

    .status-metrics {
        width: 100%;
        justify-content: space-between;
        border-top: 1px solid var(--line);
        padding-top: 14px;
    }

    .stats-top-grid,
    .stats-middle-grid,
    .settings-grid {
        grid-template-columns: 1fr !important;
    }

    #teacher-zone-panel {
        width: calc(100% - 30px) !important;
        max-width: 300px !important;
        right: 15px !important;
        top: 15px !important;
        box-sizing: border-box !important;
    }

    /* Teacher mobile header */
    #main-area > .app-container > .glass-panel:first-child {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 12px !important;
    }

    #main-area > .app-container > .glass-panel:first-child > div:first-child {
        padding-right: 50px !important;
    }

    #main-area > .app-container > .glass-panel:first-child > div:nth-child(2) {
        flex-direction: column !important;
        width: 100% !important;
        align-items: stretch !important;
        gap: 10px !important;
    }

    #main-area #room-input {
        width: 100% !important;
        box-sizing: border-box !important;
    }

    #main-area #call-btn {
        width: 100% !important;
        justify-content: center !important;
        margin-left: 0 !important;
    }
}

@media (max-height: 700px) {
    #app-root { align-items: flex-start; }
}

/* ═══════════════════════════════════════════════════════════════════
   DELIGHT LAYER — micro-interactions, earned moments
   ═══════════════════════════════════════════════════════════════════ */

/* ── Ripple click effect ────────────────────────────────────────── */
@keyframes ripple {
    to { transform: scale(5); opacity: 0; }
}
.ripple-burst {
    position: absolute;
    border-radius: 50%;
    width: 10px; height: 10px;
    background: rgba(255, 255, 255, 0.28);
    transform: scale(0);
    animation: ripple 0.55s cubic-bezier(0.25, 1, 0.5, 1) forwards;
    pointer-events: none;
    z-index: 9999;
}

/* ── Stat pill hover lift ───────────────────────────────────────── */
.stat-group:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(124, 77, 255, 0.12);
}

/* ── Nav icon scale on hover ────────────────────────────────────── */
.nav-item:hover i { transform: scale(1.22) translateY(-1px); }
.nav-item.active i { transform: scale(1.08); }

/* ── Sidebar logo soft pulse ────────────────────────────────────── */
@keyframes logoPulse {
    0%, 100% { box-shadow: 0 8px 22px var(--primary-ring); }
    50%       { box-shadow: 0 8px 30px var(--primary-glow), 0 0 44px rgba(124, 77, 255, 0.12); }
}
.sidebar .logo { box-shadow: 0 8px 22px var(--primary-ring); }

/* ── Role card spring-bounce on select ──────────────────────────── */
@keyframes roleSelectBounce {
    0%   { transform: scale(1); }
    35%  { transform: scale(1.05); }
    65%  { transform: scale(0.97); }
    85%  { transform: scale(1.02); }
    100% { transform: scale(1); }
}
.role-card--bounce { animation: roleSelectBounce 0.42s cubic-bezier(0.16, 1, 0.3, 1); }

/* ── Stat number pop ────────────────────────────────────────────── */
@keyframes numPop {
    0%   { transform: scale(1); }
    40%  { transform: scale(1.12); color: var(--primary); }
    100% { transform: scale(1); }
}
.num-pop { animation: numPop 0.38s var(--ease-fast); }

/* ── Tip card hover lift ────────────────────────────────────────── */
.tip-card {
    transition: transform 0.25s var(--ease), box-shadow 0.25s var(--ease);
}
.tip-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 28px rgba(124, 77, 255, 0.10);
}

/* ── Avatar hover wiggle ────────────────────────────────────────── */
@keyframes avatarWiggle {
    0%, 100% { transform: rotate(0deg)  scale(1); }
    20%       { transform: rotate(-8deg) scale(1.05); }
    55%       { transform: rotate(6deg)  scale(1.03); }
    80%       { transform: rotate(-3deg) scale(1.02); }
}

/* ── Confetti canvas (full-screen overlay) ──────────────────────── */
#delight-canvas {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 9999;
}

/* ─────────────────────────────────────────────────────────────────
   REDUCED MOTION
   ─────────────────────────────────────────────────────────────────*/

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