* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

/* ===== DESIGN TOKENS (CSS Variables) ===== */
:root {
    /* Primary Colors */
    --primary: #667eea;
    --primary-dark: #764ba2;
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --primary-gradient-reverse: linear-gradient(135deg, #764ba2 0%, #667eea 100%);

    /* Semantic Colors */
    --success: #28a745;
    --success-dark: #218838;
    --warning: #ffc107;
    --error: #dc3545;
    --info: #0066cc;

    /* Text Colors */
    --text: #333;
    --text-light: #666;
    --text-muted: #999;

    /* Background Colors */
    --bg-light: #f8f9fa;
    --bg-white: #fff;
    --border: #ddd;
    --border-light: #e9ecef;

    /* Spacing Scale (8pt grid) */
    --space-xs: 0.5rem;   /* 8px */
    --space-sm: 0.75rem;  /* 12px */
    --space-md: 1rem;     /* 16px */
    --space-lg: 1.5rem;   /* 24px */
    --space-xl: 2rem;     /* 32px */
    --space-2xl: 3rem;    /* 48px */

    /* Border Radius */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;

    /* Shadows */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.12);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.15);
    --shadow-xl: 0 20px 60px rgba(0, 0, 0, 0.2);

    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.2s ease;
    --transition-slow: 0.3s ease;

    /* Touch Target Size */
    --touch-target: 48px;
}

/* ===== LOGIN SCREEN STYLES ===== */
.login-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}

.login-container {
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-width: 450px;
    width: 90%;
    padding: 3rem 2rem;
    text-align: center;
}

.login-header h1 {
    color: #667eea;
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

.login-subtitle {
    color: #666;
    font-size: 1rem;
    margin-bottom: 2rem;
}

.login-content {
    margin-top: 2rem;
}

.login-description {
    color: #666;
    font-size: 1rem;
    line-height: 1.6;
    margin-bottom: 2rem;
}

.btn-google-signin {
    background: white;
    color: #444;
    border: 2px solid #ddd;
    border-radius: 12px;
    padding: 1rem 2rem;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 1rem;
    transition: all 0.3s ease;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    width: 100%;
    justify-content: center;
}

.btn-google-signin:hover {
    background: #f8f9fa;
    border-color: #667eea;
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.btn-google-signin:active {
    transform: translateY(0);
}

.google-icon {
    width: 24px;
    height: 24px;
}

.login-privacy {
    margin-top: 1.5rem;
    font-size: 0.85rem;
    color: #999;
    font-style: italic;
}

/* User Profile Display in Header */
.user-profile-display {
    display: flex;
    align-items: center;
}

.user-menu {
    position: relative;
}

.user-menu-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(255, 255, 255, 0.95);
    padding: 0.4rem 0.75rem;
    border-radius: 25px;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.user-menu-btn:hover {
    background: rgba(255, 255, 255, 1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.user-photo {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 2px solid #667eea;
}

.user-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: #333;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dropdown-arrow {
    font-size: 0.6rem;
    color: #666;
    transition: transform 0.2s ease;
}

.user-menu.open .dropdown-arrow {
    transform: rotate(180deg);
}

.user-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 5px);
    right: 0;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
    min-width: 140px;
    z-index: 1000;
    overflow: hidden;
}

.user-menu.open .user-dropdown {
    display: block;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.75rem 1rem;
    background: none;
    border: none;
    text-align: left;
    cursor: pointer;
    font-size: 0.9rem;
    color: #333;
    transition: background 0.2s ease;
}

.dropdown-item:hover {
    background: #f5f5f5;
}

.dropdown-item#sign-out-btn:hover {
    color: #dc3545;
}

.dropdown-icon {
    font-size: 1rem;
}

.dropdown-divider {
    height: 1px;
    background: #e9ecef;
    margin: 0.25rem 0;
}

/* Hide login screen when authenticated */
.login-screen.hidden {
    display: none;
}

/* ===== LOADING SCREEN STYLES ===== */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.loading-container {
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-width: 400px;
    width: 90%;
    padding: 3rem 2rem;
    text-align: center;
}

.loading-header h1 {
    color: #667eea;
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.loading-subtitle {
    color: #666;
    font-size: 0.9rem;
    margin-bottom: 2rem;
}

.loading-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #e9ecef;
    border-top-color: #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.loading-status {
    color: #666;
    font-size: 0.95rem;
    margin: 0;
}

.loading-screen.hidden {
    display: none;
}

/* Highlight Section Loading Overlay */
.highlight-loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.97);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    border-radius: 12px;
}

.highlight-loading-content {
    text-align: center;
    padding: 2rem;
    max-width: 320px;
}

.highlight-loading-content h3 {
    color: #667eea;
    font-size: 1.4rem;
    margin: 1rem 0 0.5rem;
    font-weight: 600;
}

.highlight-loading-content > p {
    color: #666;
    font-size: 0.95rem;
    margin-bottom: 1.5rem;
}

.highlight-loading-spinner {
    width: 60px;
    height: 60px;
    border: 5px solid #e9ecef;
    border-top-color: #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto;
}

.highlight-loading-steps {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    text-align: left;
    background: #f8f9fa;
    padding: 1rem 1.25rem;
    border-radius: 8px;
}

.loading-step {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.9rem;
    color: #999;
    transition: color 0.3s ease;
}

.loading-step.active {
    color: #333;
    font-weight: 500;
}

.loading-step.completed {
    color: #28a745;
}

.step-indicator {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #e9ecef;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.step-indicator.active {
    background: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.3);
}

.step-indicator.active::after {
    content: '';
    width: 8px;
    height: 8px;
    background: white;
    border-radius: 50%;
    animation: pulse 1s ease-in-out infinite;
}

.step-indicator.completed {
    background: #28a745;
}

.step-indicator.completed::after {
    content: '✓';
    color: white;
    font-size: 0.7rem;
    font-weight: bold;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(0.8); opacity: 0.7; }
}

/* Make image-section position relative for overlay positioning */
#image-section {
    position: relative;
}

/* API Usage Display */
.api-usage-display {
    background: #f8f9fa;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    padding: 0.5rem 0.75rem;
    font-size: 0.75rem;
}

.usage-title {
    color: #666;
    font-weight: 600;
    margin-bottom: 0.25rem;
    text-align: center;
    font-size: 0.7rem;
}

.usage-stats {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
}

.usage-item {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    background: white;
}

.usage-icon {
    font-size: 0.9rem;
}

.usage-value {
    font-weight: 600;
    font-size: 0.75rem;
}

.usage-good {
    border-left: 3px solid #28a745;
}

.usage-good .usage-value {
    color: #28a745;
}

.usage-warning {
    border-left: 3px solid #ffc107;
}

.usage-warning .usage-value {
    color: #ffc107;
}

.usage-danger {
    border-left: 3px solid #dc3545;
}

.usage-danger .usage-value {
    color: #dc3545;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
    -webkit-font-smoothing: antialiased;
}

.container {
    max-width: 100%;
    min-height: 100vh;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.95);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

header h1 {
    font-size: 1.5rem;
    color: #667eea;
    margin: 0;
}

.header-logo-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    color: inherit;
    transition: opacity 0.2s ease;
}

.header-logo-link:hover {
    opacity: 0.8;
}

.header-logo {
    height: 45px;
    width: auto;
    object-fit: contain;
}

.header-title {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.subtitle {
    font-size: 0.75rem;
    color: #999;
    margin: 0;
    font-weight: 400;
}

.word-count-header {
    color: #667eea;
    font-size: 1rem;
    font-weight: 700;
    text-align: right;
}

.word-count-header span {
    font-size: 2.25rem;
    font-weight: 800;
    display: block;
    line-height: 1;
}

/* Breadcrumb Navigation */
.breadcrumb-nav {
    background: rgba(255, 255, 255, 0.95);
    padding: 1rem;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
    display: none; /* Hidden initially, shown after setup */
}

.breadcrumb-nav.visible {
    display: block;
}

.breadcrumb-container {
    max-width: 900px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.breadcrumb-step {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    background: #f5f5f5;
    color: #999;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: not-allowed;
    transition: all 0.3s ease;
    position: relative;
}

.breadcrumb-step .step-icon {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #ddd;
    color: #999;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: bold;
    flex-shrink: 0;
}

.breadcrumb-step .step-label {
    white-space: nowrap;
}

/* Completed step */
.breadcrumb-step.completed {
    background: #d4edda;
    color: #155724;
    cursor: pointer;
}

.breadcrumb-step.completed .step-icon {
    background: #28a745;
    color: white;
}

.breadcrumb-step.completed:hover {
    background: #c3e6cb;
    transform: translateY(-2px);
    box-shadow: 0 2px 8px rgba(40, 167, 69, 0.2);
}

/* Current step */
.breadcrumb-step.current {
    background: #667eea;
    color: white;
    cursor: default;
}

.breadcrumb-step.current .step-icon {
    background: white;
    color: #667eea;
}

/* Available step (can be clicked but not reached yet) */
.breadcrumb-step.available {
    background: #f5f5f5;
    color: #666;
    cursor: pointer;
}

.breadcrumb-step.available .step-icon {
    background: #999;
    color: white;
}

.breadcrumb-step.available:hover {
    background: #e8e8e8;
    transform: translateY(-2px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Locked step (prerequisites not met) */
.breadcrumb-step.locked {
    position: relative;
}

.breadcrumb-step.locked::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: white;
    padding: 0.5rem;
    border-radius: 8px;
    font-size: 0.75rem;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    margin-bottom: 0.5rem;
    z-index: 1000;
}

.breadcrumb-step.locked:hover::after {
    opacity: 1;
}

.breadcrumb-arrow {
    color: #ccc;
    font-size: 1.2rem;
    user-select: none;
}

/* Mobile responsive */
@media (max-width: 768px) {
    .breadcrumb-container {
        gap: 0.25rem;
    }

    .breadcrumb-step {
        padding: 0.4rem 0.6rem;
        font-size: 0.75rem;
    }

    .breadcrumb-step .step-label {
        display: none;
    }

    .breadcrumb-step .step-icon {
        width: 28px;
        height: 28px;
        font-size: 0.875rem;
    }

    .breadcrumb-arrow {
        font-size: 1rem;
    }
}

main {
    padding: 1rem;
}

/* Step Header Styles */
.step-header {
    text-align: center;
    background: rgba(255, 255, 255, 0.95);
    padding: 1.5rem;
    border-radius: 12px;
    max-width: 700px;
    margin: 0 auto 1.5rem;
    box-shadow: 0 2px 15px rgba(0, 0, 0, 0.1);
}

.step-badge {
    display: inline-block;
    background: #667eea;
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.step-header h2 {
    color: #333;
    font-size: 1.75rem;
    margin: 0.5rem 0 0.25rem;
}

.step-subtitle {
    color: #666;
    font-size: 1rem;
    margin: 0;
}

/* Highlight Instructions */
.highlight-instructions {
    background: #fff9e6;
    border-left: 4px solid #ffc107;
    padding: 0.75rem 1rem;
    margin: 0 auto 1rem;
    max-width: 700px;
    border-radius: 8px;
}

.highlight-instructions p {
    margin: 0;
    font-size: 0.9rem;
    color: #333;
}

/* Requirements Checklist */
.requirements-checklist {
    background: rgba(255, 255, 255, 0.95);
    padding: 1rem;
    border-radius: 8px;
    max-width: 700px;
    margin: 0 auto 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.requirement-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.95rem;
}

.req-icon {
    font-size: 1.2rem;
    flex-shrink: 0;
}

.requirement-item.complete .req-icon {
    color: #28a745;
}

.requirement-item.incomplete .req-icon {
    color: #dc3545;
}

.link-btn {
    background: none;
    border: none;
    color: #667eea;
    text-decoration: underline;
    cursor: pointer;
    font-size: 0.875rem;
    padding: 0 0.5rem;
}

.link-btn:hover {
    color: #5568d3;
}

/* Audio Recording Container */
.audio-recording-container {
    max-width: 700px;
    margin: 0 auto 1.5rem;
    background: rgba(255, 255, 255, 0.95);
    padding: 2rem;
    border-radius: 12px;
    box-shadow: 0 2px 15px rgba(0, 0, 0, 0.1);
}

.image-preview {
    text-align: center;
    margin-bottom: 2rem;
}

.preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding: 0 1rem;
}

.preview-header h4 {
    color: #667eea;
    margin: 0;
    font-size: 1rem;
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

#mini-preview-canvas {
    max-width: 100%;
    max-height: 400px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    transition: max-height 0.3s ease, box-shadow 0.3s ease;
}

#mini-preview-canvas.expanded {
    max-height: 800px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

/* Image preview modal */
.image-preview-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    z-index: 10000;
    justify-content: center;
    align-items: flex-start;
    padding-top: 2rem;
    pointer-events: none; /* Allow clicks to pass through */
}

.image-preview-modal.active {
    display: flex;
}

.image-preview-modal img {
    max-width: 70%;
    max-height: 60vh;
    border-radius: 8px;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.5);
    cursor: pointer;
    pointer-events: auto; /* Re-enable clicks on image */
}

.image-preview-close-hint {
    position: absolute;
    top: 1rem;
    right: 1rem;
    color: white;
    background: rgba(0, 0, 0, 0.7);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-size: 0.9rem;
    pointer-events: none;
}

.audio-controls-center {
    text-align: center;
    margin: 2rem 0;
}

.btn-large {
    font-size: 1.1rem;
    padding: 1rem 2rem;
}

.audio-player-section {
    text-align: center;
    margin-top: 2rem;
    padding: 1.5rem;
    background: #f8f9fa;
    border-radius: 8px;
}

.audio-player-section h4 {
    color: #28a745;
    margin-bottom: 1rem;
}

.audio-player-section audio {
    width: 100%;
    max-width: 500px;
    margin-bottom: 1rem;
}

.audio-actions-inline {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

/* Step Navigation */
.step-navigation {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
    max-width: 700px;
    margin: 1.5rem auto;
}

.step-navigation .btn {
    min-width: 150px;
}

/* Results Section */
/* Historical Assessment Banner */
.historical-assessment-banner {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
    padding: 1rem 1.5rem;
    border-radius: 12px;
    margin: 0 auto 1.5rem;
    max-width: 800px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.historical-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.historical-info .icon {
    font-size: 2rem;
}

.historical-info strong {
    font-size: 1.1rem;
}

.results-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
    max-width: 700px;
    margin: 0 auto 1.5rem;
}

.results-container {
    max-width: 900px;
    margin: 0 auto;
}

/* Word Count Only Results */
.word-count-results {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    padding: 2rem;
    max-width: 800px;
    margin: 0 auto;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.word-count-results h3 {
    color: #667eea;
    text-align: center;
    margin-bottom: 1.5rem;
}

.word-count-results h4 {
    color: #333;
    margin: 2rem 0 1rem 0;
    text-align: center;
}

.word-count-results .info-box {
    background: #e7f3ff;
    border-left: 4px solid #0066cc;
    padding: 1rem;
    border-radius: 8px;
}

.word-count-results .info-box p {
    margin: 0.5rem 0;
    color: #333;
}

.word-count-results .selected-words-display {
    background: #f8f9fa;
    padding: 1.5rem;
    border-radius: 8px;
    margin-top: 2rem;
}

.word-count-results .words-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 1rem;
}

.word-count-results .word-item {
    background: white;
    padding: 0.5rem 0.75rem;
    border-radius: 4px;
    border: 1px solid #ddd;
    font-size: 0.9rem;
    color: #333;
}

/* Button Disabled State with Tooltip */
.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    position: relative;
}

.btn:disabled::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: white;
    padding: 0.5rem;
    border-radius: 8px;
    font-size: 0.75rem;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    margin-bottom: 0.5rem;
    z-index: 1000;
}

.btn:disabled:hover::after {
    opacity: 1;
}

.section {
    display: none;
}

.section.active {
    display: block;
}

/* Explicitly hide Class Overview and Student Profile sections unless active */
#class-overview-section,
#student-profile-section {
    display: none;
}

#class-overview-section.active,
#student-profile-section.active {
    display: block;
}

.section-header {
    text-align: center;
    background: rgba(255, 255, 255, 0.95);
    padding: 1rem;
    border-radius: 12px;
    max-width: 600px;
    margin: 0 auto 1rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.section-header h3 {
    color: #667eea;
    font-size: 1.2rem;
    margin: 0;
}

.camera-container {
    width: 100%;
    max-width: 700px;
    max-height: 50vh;
    margin: 0 auto 1rem;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    background: #000;
}

#camera {
    width: 100%;
    height: auto;
    display: block;
}

.image-wrapper {
    width: 100%;
    max-width: 600px;
    margin: 0 auto 1rem;
    position: relative;
}

.image-container {
    width: 100%;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    background: #fff;
}

.zoom-controls {
    position: absolute;
    top: 10px;
    right: 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    z-index: 1000;
}

.zoom-btn {
    width: 32px;
    height: 32px;
    border-radius: 4px;
    border: none;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    font-size: 1.2rem;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
    transition: all 0.2s ease;
    line-height: 1;
}

.zoom-btn:hover {
    background: rgba(0, 0, 0, 0.8);
    transform: scale(1.1);
}

.zoom-btn:active {
    transform: scale(0.95);
}

#selection-canvas {
    width: 100%;
    height: auto;
    display: block;
    touch-action: pan-y;
    cursor: crosshair;
    border-radius: 8px;
}

.controls {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-width: 700px;
    margin: 0 auto 1rem;
}

.btn {
    padding: 1rem;
    font-size: 1rem;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    -webkit-user-select: none;
    user-select: none;
}

.btn-primary {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
    transition: all var(--transition-normal);
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-gradient-reverse);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn-primary:active:not(:disabled) {
    transform: scale(0.98);
}

.btn-secondary {
    background: var(--bg-white);
    color: var(--primary);
    box-shadow: var(--shadow-sm);
    border: 2px solid var(--border);
    transition: all var(--transition-normal);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--bg-light);
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn-secondary:active:not(:disabled) {
    transform: scale(0.98);
}

.btn-export {
    background: var(--success);
    color: white;
    box-shadow: 0 2px 10px rgba(40, 167, 69, 0.3);
    transition: all var(--transition-normal);
}

.btn-export:hover:not(:disabled) {
    background: var(--success-dark);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn-export:active:not(:disabled) {
    transform: scale(0.98);
}

.btn-audio {
    background: #ff6b6b;
    color: white;
    box-shadow: 0 4px 15px rgba(255, 107, 107, 0.4);
    transition: all var(--transition-normal);
}

.btn-audio:hover:not(:disabled) {
    background: #ff5252;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 107, 107, 0.5);
}

.btn-audio:active:not(:disabled) {
    transform: scale(0.98);
}

/* Beta Feature Button */
.btn-beta {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(240, 147, 251, 0.4);
    position: relative;
    overflow: visible;
}

.btn-beta:hover:not(:disabled) {
    background: linear-gradient(135deg, #f5576c 0%, #f093fb 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(240, 147, 251, 0.5);
}

.btn-beta:disabled {
    background: linear-gradient(135deg, #ccc 0%, #999 100%);
    box-shadow: none;
    cursor: not-allowed;
    opacity: 0.7;
}

.btn-beta:active:not(:disabled) {
    transform: scale(0.98);
}

.beta-badge {
    display: inline-block;
    background: rgba(255, 255, 255, 0.3);
    color: white;
    font-size: 0.6rem;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
    margin-left: 6px;
    vertical-align: middle;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-zoom {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
    border: 2px solid rgba(255, 255, 255, 0.3);
    transition: all var(--transition-normal);
}

.btn-zoom:hover:not(:disabled) {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-zoom:active:not(:disabled) {
    transform: scale(0.98);
}

.zoom-controls-row {
    flex-direction: row !important;
    gap: 0.5rem;
}

.btn-danger {
    background: var(--error);
    color: white;
    box-shadow: 0 4px 15px rgba(220, 53, 69, 0.4);
    transition: all var(--transition-normal);
}

.btn-danger:hover:not(:disabled) {
    background: #c82333;
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn-danger:active:not(:disabled) {
    transform: scale(0.98);
}

.icon {
    font-size: 1.25rem;
}

.export-section {
    max-width: 700px;
    margin: 1.5rem auto 0;
}

.export-output {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 8px;
    padding: 1rem;
    margin-top: 1rem;
    max-height: 300px;
    overflow-y: auto;
    display: none;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.export-output.active {
    display: block;
}

.export-output h3 {
    color: #667eea;
    margin-bottom: 0.75rem;
    font-size: 1rem;
}

.export-output .word-list {
    background: #f8f9fa;
    padding: 1rem;
    border-radius: 4px;
    font-family: monospace;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
    color: #333;
    font-size: 0.9rem;
}

.export-output .export-info {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid #ddd;
    color: #666;
    font-size: 0.85rem;
}

.status {
    text-align: center;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 8px;
    color: #666;
    font-size: 0.9rem;
    max-width: 700px;
    margin: 1rem auto;
}

.status.processing {
    color: #667eea;
    font-weight: 600;
}

.status.error {
    color: #e74c3c;
    font-weight: 600;
}

footer {
    padding: 1rem;
    text-align: center;
    background: rgba(255, 255, 255, 0.9);
}

.hint {
    color: #666;
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

.version {
    color: #999;
    font-size: 0.75rem;
    font-family: monospace;
    margin: 0;
    opacity: 0.7;
}

/* Instructions Box */
.instructions-box {
    background: rgba(102, 126, 234, 0.1);
    border: 2px solid rgba(102, 126, 234, 0.3);
    border-radius: 12px;
    padding: 1.25rem;
    max-width: 600px;
    margin: 1.5rem auto 0;
}

.instructions-box h4 {
    color: #667eea;
    margin: 0 0 0.75rem 0;
    font-size: 1rem;
    font-weight: 600;
}

.instructions-list {
    margin: 0;
    padding-left: 1.5rem;
    color: #333;
}

.instructions-list li {
    margin-bottom: 0.5rem;
    line-height: 1.5;
    font-size: 0.95rem;
}

.instructions-list li:last-child {
    margin-bottom: 0;
}

/* Collapsible Instructions (Step 1) */
.instructions-collapsible {
    background: transparent;
    border: none;
    padding: 0;
    text-align: center;
}

.instructions-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    margin: 0 auto;
    padding: 0.4rem 0.9rem;
    background: rgba(255, 255, 255, 0.15);
    border: none;
    border-radius: 20px;
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.8rem;
    cursor: pointer;
    transition: background var(--transition-fast), color var(--transition-fast);
}

.instructions-toggle:hover {
    background: rgba(255, 255, 255, 0.25);
    color: rgba(255, 255, 255, 0.9);
}

.instructions-toggle:focus {
    outline: none;
    background: rgba(255, 255, 255, 0.25);
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.5);
}

.instructions-toggle:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.7);
}

.instructions-chevron {
    transition: transform var(--transition-slow);
}

.instructions-collapsible.expanded .instructions-chevron {
    transform: rotate(180deg);
}

.instructions-content {
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: max-height var(--transition-slow), opacity var(--transition-slow), margin var(--transition-slow);
}

.instructions-collapsible.expanded .instructions-content {
    max-height: 400px;
    opacity: 1;
    margin-top: 0.75rem;
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .instructions-toggle,
    .instructions-chevron,
    .instructions-content {
        transition: none;
    }
}

.instructions-collapsible .instructions-list {
    background: rgba(255, 255, 255, 0.97);
    border-radius: var(--radius-lg);
    border-left: 3px solid var(--primary);
    padding: 1.1rem 1.25rem 1.1rem 1.5rem;
    margin: 0;
    color: var(--text-light);
    font-size: 0.875rem;
    line-height: 1.6;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
    text-align: left;
    list-style: none;
}

.instructions-collapsible .instructions-list li {
    margin-bottom: 0.6rem;
    padding-left: 1.1rem;
    position: relative;
}

.instructions-collapsible .instructions-list li::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0.55rem;
    width: 5px;
    height: 5px;
    background: var(--primary);
    border-radius: 50%;
    opacity: 0.5;
}

.instructions-collapsible .instructions-list li:last-child {
    margin-bottom: 0;
}

.instructions-collapsible .instructions-list li strong {
    color: var(--text);
    font-weight: 600;
}

.setup-container {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    padding: 2rem;
    max-width: 600px;
    margin: 0 auto;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.setup-container h2 {
    color: #667eea;
    margin-bottom: 0.25rem;
    text-align: center;
}

.setup-description {
    color: #888;
    text-align: center;
    margin-bottom: 1.5rem;
    font-size: 0.95rem;
}

/* Compact step rows */
.setup-steps-compact {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.setup-step-row {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
}

.setup-step-num {
    width: 32px;
    height: 32px;
    min-width: 32px;
    background: #667eea;
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.95rem;
    margin-top: 2px;
}

.setup-step-content {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    flex: 1;
}

.setup-link-btn {
    color: #667eea;
    font-weight: 600;
    font-size: 1rem;
    text-decoration: none;
    border-bottom: 1px solid transparent;
}

.setup-link-btn:hover {
    border-bottom-color: #667eea;
}

.setup-step-detail {
    font-size: 0.85rem;
    color: #888;
}

.setup-step-final .setup-step-num {
    background: #28a745;
}

/* Setup media (video + screenshot) */
.setup-media {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 0.5rem;
}

.setup-media-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.setup-media-label {
    font-size: 0.8rem;
    color: #888;
}

.setup-video,
.setup-screenshot {
    width: 100%;
    max-width: 280px;
    border-radius: 6px;
    border: 1px solid #ddd;
    cursor: pointer;
    transition: max-width 0.3s ease;
}

.setup-video.expanded,
.setup-screenshot.expanded {
    max-width: 100%;
}

/* Copy field */
.setup-copy-field {
    margin-top: 0.75rem;
}

.setup-copy-label {
    font-size: 0.8rem;
    color: #888;
    display: block;
    margin-bottom: 0.25rem;
}

.setup-copy-row {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.setup-copy-input {
    flex: 1;
    padding: 0.4rem 0.6rem;
    font-size: 0.85rem;
    font-family: monospace;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: #f8f9fa;
    color: #333;
}

.setup-copy-btn {
    white-space: nowrap;
    padding: 0.4rem 0.75rem;
    font-size: 0.8rem;
}

.setup-footer-note {
    text-align: center;
    font-size: 0.8rem;
    color: #aaa;
    margin-top: 0.5rem;
}

.api-key-input {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1rem;
}

.api-key-input input {
    padding: 1rem;
    font-size: 1rem;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-family: monospace;
    transition: border-color 0.3s ease;
}

.api-key-input input:focus {
    outline: none;
    border-color: #667eea;
}

.privacy-note {
    text-align: center;
    font-size: 0.85rem;
    color: #999;
    font-style: italic;
}

/* Mobile optimizations */
@media (max-width: 767px) {
    body {
        font-size: 16px;
    }

    .controls {
        flex-direction: row;
    }

    .btn {
        flex: 1;
    }
}

/* Tablet and desktop */
@media (min-width: 768px) {
    .api-key-input {
        flex-direction: row;
    }

    .api-key-input input {
        flex: 1;
    }
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: white;
    padding: 2rem;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    max-width: 400px;
    width: 90%;
    text-align: center;
}

.modal-content h2 {
    color: #667eea;
    margin-bottom: 1rem;
}

.modal-content p {
    color: #666;
    margin-bottom: 1.5rem;
}

.duration-note {
    background: #fff3cd;
    border-left: 4px solid #ff9800;
    padding: 0.75rem 1rem;
    margin: 0.5rem 0 1rem;
    border-radius: 4px;
    color: #856404;
    font-size: 0.9rem;
    text-align: center;
}

.recording-settings {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.setting-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.setting-group label {
    font-weight: 600;
    font-size: 0.95rem;
    color: #333;
}

.setting-group select {
    padding: 0.75rem 1rem;
    font-size: 1rem;
    border: 2px solid #667eea;
    border-radius: 8px;
    background: white;
    cursor: pointer;
    transition: border-color 0.2s;
}

.setting-group select:hover {
    border-color: #5568d3;
}

.setting-group select:focus {
    outline: none;
    border-color: #4c51bf;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.modal-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

/* Recording Indicator (Bottom-Left) */
.recording-indicator {
    display: none;
    position: fixed;
    bottom: 20px;
    left: 20px;
    z-index: 2000;
}

.recording-indicator.active {
    display: block;
}

.recording-indicator-content {
    background: rgba(220, 53, 69, 0.95);
    color: white;
    padding: 1rem;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    min-width: 180px;
}

.recording-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.recording-icon {
    font-size: 1.2rem;
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.recording-label {
    font-size: 0.9rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.recording-timer {
    font-size: 2rem;
    font-weight: bold;
    margin: 0.5rem 0;
    font-family: monospace;
    color: white;
    text-align: center;
}

.recording-progress {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    height: 6px;
    margin: 0.75rem 0;
    overflow: hidden;
}

.progress-bar {
    background: white;
    height: 100%;
    width: 0%;
    transition: width 0.3s ease;
    border-radius: 8px;
}

.btn-stop-compact {
    width: 100%;
    padding: 0.6rem;
    font-size: 0.9rem;
}

/* Audio Playback Section */
.audio-playback-container {
    display: none;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    padding: 1.5rem;
    max-width: 600px;
    margin: 1.5rem auto;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.audio-playback-container.active {
    display: block;
}

.audio-playback-container h3 {
    color: #667eea;
    margin-bottom: 1rem;
    text-align: center;
    font-size: 1.1rem;
}

.audio-playback-container audio {
    width: 100%;
    margin-bottom: 1rem;
    border-radius: 8px;
}

.audio-actions {
    display: flex;
    gap: 0.75rem;
    flex-direction: column;
}

.audio-analysis-result {
    margin-top: 1rem;
}

.audio-analysis-result .stat {
    background: #f8f9fa;
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.audio-analysis-result .stat-label {
    color: #666;
    font-weight: 600;
}

.audio-analysis-result .stat-value {
    color: #667eea;
    font-size: 1.5rem;
    font-weight: bold;
}

.audio-analysis-result .transcript-section {
    margin-top: 1rem;
}

.audio-analysis-result .transcript-section strong {
    color: #667eea;
    display: block;
    margin-bottom: 0.5rem;
}

.comparison-section {
    margin-top: 1rem;
}

.text-comparison {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.comparison-box {
    background: #f8f9fa;
    padding: 1rem;
    border-radius: 8px;
    border-left: 4px solid #667eea;
}

.comparison-box strong {
    color: #667eea;
    display: block;
    margin-bottom: 0.75rem;
    font-size: 0.95rem;
}

.comparison-box .word-list {
    margin-bottom: 0.5rem;
}

.word-count-small {
    color: #999;
    font-size: 0.85rem;
    font-style: italic;
}

.stat-value.match {
    color: #28a745;
}

.stat-value.mismatch {
    color: #dc3545;
}

/* Pronunciation Analysis Styles */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-box {
    background: #f8f9fa;
    padding: 1.25rem;
    border-radius: 8px;
    text-align: center;
    border: 2px solid transparent;
}

.stat-box.stat-correct {
    border-color: #28a745;
}

.stat-box.stat-error {
    border-color: #dc3545;
}

.stat-box.stat-missing {
    border-color: #6c757d;
}

.stat-box.stat-accuracy {
    border-color: #667eea;
}

.stat-box.stat-wpm {
    border-color: #17a2b8;
}

.stat-box.stat-prosody {
    border-color: #ffc107;
}

.stat-number {
    font-size: 2rem;
    font-weight: bold;
    color: #333;
    margin-bottom: 0.25rem;
}

.stat-label {
    font-size: 0.9rem;
    color: #666;
    font-weight: 600;
}

.pronunciation-text {
    background: #f8f9fa;
    padding: 1.5rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
}

.pronunciation-text h4 {
    color: #667eea;
    margin-bottom: 1rem;
    font-size: 1rem;
}

.analyzed-text {
    background: white;
    padding: 1rem;
    border-radius: 8px;
    line-height: 2;
    font-size: 1.1rem;
    margin-bottom: 1rem;
    min-height: 60px;
}

.analyzed-text span {
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    cursor: help;
    transition: all 0.2s ease;
    display: inline-block;
    margin: 0.1rem;
}

.word-correct {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.word-skipped {
    background: #e2e3e5;
    color: #383d41;
    border: 1px solid #d6d8db;
    text-decoration: line-through;
    position: relative;
}

.word-misread {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffeaa7;
    font-weight: 600;
    position: relative;
}

.word-substituted {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    font-weight: 600;
    position: relative;
}

.error-badge {
    display: inline-block;
    font-size: 0.65rem;
    padding: 0.1rem 0.3rem;
    margin-left: 0.2rem;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    border-radius: 4px;
    font-weight: normal;
    vertical-align: super;
}

.analyzed-text span:hover {
    transform: translateY(-2px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

/* Custom Word Tooltip */
.word-tooltip {
    position: fixed;
    z-index: 10000;
    background: #1a1a2e;
    color: white;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    font-size: 0.9rem;
    max-width: 280px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    pointer-events: none;
    opacity: 0;
    transform: translateY(5px);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.word-tooltip.visible {
    opacity: 1;
    transform: translateY(0);
}

.word-tooltip-header {
    font-weight: 600;
    margin-bottom: 0.5rem;
    padding-bottom: 0.4rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.word-tooltip-header.correct { color: #4ade80; }
.word-tooltip-header.skipped { color: #9ca3af; }
.word-tooltip-header.misread { color: #fbbf24; }
.word-tooltip-header.substituted { color: #f87171; }

.word-tooltip-row {
    display: flex;
    justify-content: space-between;
    margin: 0.3rem 0;
    font-size: 0.85rem;
}

.word-tooltip-label {
    color: #9ca3af;
}

.word-tooltip-value {
    font-weight: 500;
    margin-left: 1rem;
}

.word-tooltip-reason {
    margin-top: 0.5rem;
    padding-top: 0.4rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 0.8rem;
    color: #d1d5db;
    font-style: italic;
}

/* Touch indicator for mobile */
@media (hover: none) and (pointer: coarse) {
    .analyzed-text span {
        cursor: pointer;
    }

    .analyzed-text span::after {
        content: '';
        position: absolute;
        top: 50%;
        right: -2px;
        transform: translateY(-50%);
        width: 4px;
        height: 4px;
        background: rgba(0, 0, 0, 0.2);
        border-radius: 50%;
    }
}

.legend {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    font-size: 0.85rem;
    color: #666;
    margin-bottom: 0.5rem;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.legend-item span {
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    font-weight: 600;
}

.hint-text {
    font-size: 0.85rem;
    color: #999;
    font-style: italic;
    margin: 0;
}

/* Download Output Section */
.download-output-section {
    text-align: center;
    margin-bottom: 1.5rem;
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

.download-output-section .btn {
    font-size: 1rem;
}

/* Video Generation Status */
.video-status {
    text-align: center;
    margin: 1rem 0;
    display: none;
}

.video-progress {
    background: #e0e7ff;
    color: #4f46e5;
    padding: 1rem;
    border-radius: 8px;
    font-size: 1.1rem;
    font-weight: 500;
}

.video-complete {
    background: #d1fae5;
    color: #065f46;
    padding: 1rem;
    border-radius: 8px;
    font-size: 1.1rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* Error Breakdown Styles */
.error-breakdown {
    background: #f8f9fa;
    padding: 1.5rem;
    border-radius: 8px;
    margin-top: 1.5rem;
}

.error-breakdown h4 {
    color: #667eea;
    margin-bottom: 1rem;
    font-size: 1rem;
}

.error-category {
    background: white;
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 0.75rem;
    border-left: 4px solid #667eea;
}

.error-category:last-child {
    margin-bottom: 0;
}

.error-category strong {
    display: block;
    color: #333;
    margin-bottom: 0.5rem;
    font-size: 0.95rem;
}

.error-details {
    color: #666;
    font-size: 0.9rem;
    line-height: 1.5;
}

.error-critical {
    border-left-color: #dc3545;
    background: #fff5f5;
}

.error-critical strong {
    color: #dc3545;
}

@media (min-width: 768px) {
    .audio-actions {
        flex-direction: row;
    }

    .audio-actions .btn {
        flex: 1;
    }

    .text-comparison {
        flex-direction: row;
    }

    .comparison-box {
        flex: 1;
    }

    .stats-grid {
        grid-template-columns: repeat(5, 1fr);
    }
}

/* ===== DATABASE / CLASS OVERVIEW STYLES ===== */

/* Student Selection Box in Audio Section */
.student-selection-box {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    padding: 1.5rem;
    max-width: 700px;
    margin: 0 auto 1.5rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.student-selection-box h3 {
    color: #667eea;
    margin: 0 0 1rem 0;
    font-size: 1.1rem;
    text-align: center;
}

.student-select-container {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.student-select-container .student-select-dropdown {
    flex: 1;
}

.selection-note {
    text-align: center;
    font-size: 0.85rem;
    color: #666;
    margin: 0.5rem 0 0 0;
    font-style: italic;
}

/* Selected Student Display */
.selected-student-display {
    background: #e8f4f8;
    border: 2px solid #667eea;
    border-radius: 8px;
    padding: 0;
    margin-bottom: 1rem;
}

.selected-student-badge {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
}

.selected-student-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.5rem;
    font-weight: bold;
    flex-shrink: 0;
}

.selected-student-info {
    flex: 1;
}

.selected-student-name {
    font-size: 1.1rem;
    font-weight: bold;
    color: #333;
    margin-bottom: 0.25rem;
}

.selected-student-grade {
    font-size: 0.85rem;
    color: #666;
}

.btn-link {
    background: none;
    border: none;
    color: #667eea;
    text-decoration: underline;
    cursor: pointer;
    font-size: 0.9rem;
    padding: 0.25rem 0.5rem;
}

.btn-link:hover {
    color: #5568d3;
}

/* Current Student Indicator in Header */
.current-student-indicator {
    background: #f0f4ff;
    border: 2px solid #667eea;
    border-radius: 8px;
    padding: 0.4rem 0.8rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: #333;
}

.current-student-indicator .student-initial {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #667eea;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 0.9rem;
}

.current-student-indicator .student-name-header {
    font-weight: 600;
    color: #667eea;
}

/* Header Actions */
.header-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.btn-header {
    background: white;
    color: #667eea;
    border: 2px solid #667eea;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.35rem;
    transition: all 0.2s ease;
}

.btn-header:hover {
    background: #667eea;
    color: white;
    border-color: #667eea;
    transform: translateY(-2px);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.btn-header .icon {
    font-size: 1.1rem;
}

/* Save Assessment Section */
.save-assessment-section {
    background: rgba(102, 126, 234, 0.1);
    border: 2px solid rgba(102, 126, 234, 0.3);
    border-radius: 12px;
    padding: 1.5rem;
    margin: 2rem auto 0;
    max-width: 700px;
}

.save-assessment-section h3 {
    color: #667eea;
    margin: 0 0 1rem 0;
    font-size: 1.1rem;
    text-align: center;
}

.student-selection {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    align-items: stretch;
}

.student-selection label {
    font-weight: 600;
    color: #333;
    font-size: 0.95rem;
}

.student-select-dropdown {
    padding: 0.75rem 1rem;
    font-size: 1rem;
    border: 2px solid #667eea;
    border-radius: 8px;
    background: white;
    cursor: pointer;
    flex: 1;
}

.student-select-dropdown:focus {
    outline: none;
    border-color: #4c51bf;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.save-status {
    margin-top: 1rem;
    padding: 0.75rem;
    border-radius: 8px;
    text-align: center;
    font-weight: 600;
    display: none;
}

.save-status.success {
    background: #d4edda;
    color: #155724;
    display: block;
}

.save-status.error {
    background: #f8d7da;
    color: #721c24;
    display: block;
}

/* Class Actions */
.class-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
    max-width: 700px;
    margin: 0 auto 1.5rem;
}

.profile-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
    max-width: 700px;
    margin: 0 auto 1.5rem;
}

/* Students Grid */
.students-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem 0;
}

.student-card {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    cursor: pointer;
    border: 2px solid transparent;
}

.student-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.3);
    border-color: #667eea;
}

.student-card-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.student-avatar {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    color: white;
    font-weight: bold;
    flex-shrink: 0;
}

.student-info h3 {
    margin: 0 0 0.25rem 0;
    color: #333;
    font-size: 1.2rem;
}

.student-grade {
    color: #666;
    font-size: 0.85rem;
    margin: 0;
}

.student-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
    margin-top: 1rem;
}

.stat-item {
    background: #f8f9fa;
    padding: 0.75rem;
    border-radius: 8px;
    text-align: center;
}

.stat-item-label {
    font-size: 0.75rem;
    color: #666;
    margin-bottom: 0.25rem;
}

.stat-item-value {
    font-size: 1.3rem;
    font-weight: bold;
    color: #667eea;
}

.stat-item-value.good {
    color: #28a745;
}

.stat-item-value.warning {
    color: #ffc107;
}

.stat-item-value.poor {
    color: #dc3545;
}

/* Student Profile Styles */
.student-stats-summary {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    padding: 2rem;
    max-width: 900px;
    margin: 0 auto 2rem;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.summary-header {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 2px solid #e9ecef;
}

.summary-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    color: white;
    font-weight: bold;
    flex-shrink: 0;
}

.summary-info h3 {
    margin: 0 0 0.5rem 0;
    color: #333;
    font-size: 1.8rem;
}

.summary-meta {
    color: #666;
    font-size: 0.9rem;
}

.summary-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 1rem;
}

.summary-stat-box {
    background: #f8f9fa;
    padding: 1rem;
    border-radius: 8px;
    text-align: center;
    border-left: 4px solid #667eea;
}

.summary-stat-label {
    font-size: 0.85rem;
    color: #666;
    margin-bottom: 0.5rem;
}

.summary-stat-value {
    font-size: 1.8rem;
    font-weight: bold;
    color: #333;
}

/* Progress Chart */
.progress-chart-container {
    margin-top: 2rem;
    background: white;
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

#progress-chart {
    width: 100%;
    height: 200px;
    display: block;
}

/* Pattern Analysis Card */
.pattern-analysis-card {
    margin-top: 2rem;
    background: white;
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.pattern-analysis-card h3 {
    color: #667eea;
    margin-bottom: 1rem;
    font-size: 1.3rem;
}

.pattern-analysis-card h4 {
    color: #374151;
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
    font-size: 1.1rem;
}

.macro-insights {
    background: linear-gradient(135deg, #f0f4ff 0%, #e0e7ff 100%);
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
    border-left: 4px solid #667eea;
}

.insights-list {
    margin: 0.5rem 0 0 1.5rem;
    padding: 0;
}

.insights-list li {
    margin: 0.5rem 0;
    line-height: 1.6;
    color: #374151;
}

.pattern-breakdown {
    margin: 1.5rem 0;
    padding: 1rem;
    background: #f9fafb;
    border-radius: 8px;
}

.pattern-breakdown.speech-patterns {
    background: #fef3f2;
    border-left: 4px solid #f87171;
}

.pattern-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0.75rem;
    margin-top: 0.75rem;
}

.pattern-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0.75rem;
    background: white;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
}

.pattern-label {
    font-size: 0.9rem;
    color: #6b7280;
}

.pattern-value {
    font-size: 1.1rem;
    font-weight: bold;
    color: #667eea;
    background: #f0f4ff;
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
}

.pattern-note {
    font-size: 0.85rem;
    color: #6b7280;
    font-style: italic;
    margin: 0.5rem 0;
}

/* Assessment History */
.assessment-history {
    max-width: 900px;
    margin: 0 auto;
}

.assessment-history h3 {
    color: #667eea;
    margin-bottom: 1.5rem;
    font-size: 1.3rem;
}

.assessment-item {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    transition: all 0.2s ease;
}

.assessment-item:hover {
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.2);
    transform: translateY(-2px);
}

.assessment-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid #e9ecef;
}

.assessment-date {
    font-size: 1rem;
    color: #667eea;
    font-weight: 600;
}

.assessment-score {
    font-size: 1.5rem;
    font-weight: bold;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    background: #f8f9fa;
}

.assessment-score.excellent {
    background: #d4edda;
    color: #155724;
}

.assessment-score.good {
    background: #d1ecf1;
    color: #0c5460;
}

.assessment-score.fair {
    background: #fff3cd;
    color: #856404;
}

.assessment-score.poor {
    background: #f8d7da;
    color: #721c24;
}

.assessment-details {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 1rem;
}

.assessment-detail {
    text-align: center;
}

.assessment-detail-label {
    font-size: 0.8rem;
    color: #666;
    margin-bottom: 0.25rem;
}

.assessment-detail-value {
    font-size: 1.2rem;
    font-weight: bold;
    color: #333;
}

.assessment-actions {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid #e9ecef;
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
}

.btn-small {
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
}

.no-assessments {
    text-align: center;
    padding: 3rem;
    color: #999;
    font-size: 1.1rem;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
}

/* Add Student Form */
.student-form {
    margin: 1.5rem 0;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: #333;
    font-size: 0.95rem;
}

.form-group input {
    width: 100%;
    padding: 0.75rem;
    font-size: 1rem;
    border: 2px solid #ddd;
    border-radius: 8px;
    transition: border-color 0.3s ease;
}

.form-group input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    max-width: 500px;
    margin: 2rem auto;
}

.empty-state-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
}

.empty-state h3 {
    color: #333;
    margin-bottom: 1rem;
}

.empty-state p {
    color: #666;
    margin-bottom: 1.5rem;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .header-actions {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
    }

    .btn-header {
        width: 100%;
        justify-content: center;
    }

    .students-grid {
        grid-template-columns: 1fr;
    }

    .student-selection {
        flex-direction: column;
    }

    .historical-assessment-banner {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }

    .historical-info {
        flex-direction: column;
        gap: 0.5rem;
    }

    .progress-chart-container {
        padding: 1rem;
    }

    #progress-chart {
        height: 300px;
    }

    .pattern-grid {
        grid-template-columns: 1fr;
    }

    .pattern-analysis-card {
        padding: 1rem;
    }

    .summary-header {
        flex-direction: column;
        text-align: center;
    }

    .assessment-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .assessment-actions {
        justify-content: center;
    }

    /* Mobile capture controls - make capture button prominent */
    .capture-controls {
        flex-direction: column !important; /* Capture on top, Browse below */
        gap: 0.75rem;
    }

    .btn-capture-main {
        width: 100%;
        padding: 1.25rem 1.5rem !important;
        font-size: 1.2rem !important;
        font-weight: 600;
        border-radius: 12px !important;
        box-shadow: 0 6px 20px rgba(102, 126, 234, 0.5) !important;
    }

    .btn-capture-main .icon {
        font-size: 1.4rem;
        margin-right: 0.5rem;
    }

    .btn-browse {
        width: 100%;
        padding: 0.75rem 1rem !important;
        font-size: 0.95rem !important;
        background: #f8f9fa !important;
        border: 1px solid #dee2e6 !important;
    }

    /* Highlight page mobile scrolling fix - add scroll gutters on sides */
    .image-wrapper {
        position: relative;
        display: flex;
        align-items: stretch;
    }

    /* Scroll gutters - visible on mobile */
    .scroll-gutter {
        display: flex !important;
        align-items: center;
        justify-content: center;
        width: 32px;
        min-width: 32px;
        background: linear-gradient(180deg, #e0e0e0 0%, #c8c8c8 50%, #e0e0e0 100%);
        color: #888;
        font-size: 1.5rem;
        touch-action: pan-y; /* Only allow vertical scrolling */
        user-select: none;
        flex-shrink: 0;
    }

    .scroll-gutter-left {
        border-radius: 8px 0 0 8px;
        margin-right: 4px;
    }

    .scroll-gutter-right {
        border-radius: 0 8px 8px 0;
        margin-left: 4px;
    }

    /* Make image container fill the space between gutters */
    .image-wrapper .image-container {
        flex: 1;
        min-width: 0;
    }
}

/* Hide scroll gutters on desktop by default */
.scroll-gutter {
    display: none;
}

/* ===== ENHANCED MOBILE/TOUCH STYLES ===== */

/* Touch device detection - improve touch targets and feedback */
@media (hover: none) and (pointer: coarse) {
    /* Ensure all buttons meet minimum touch target size */
    .btn,
    button:not(.word-toggle) {
        min-height: var(--touch-target);
        min-width: var(--touch-target);
    }

    /* Larger zoom buttons for touch */
    .btn-zoom,
    .zoom-btn {
        width: var(--touch-target);
        height: var(--touch-target);
        font-size: 1.4rem;
    }

    /* Better touch feedback (since hover doesn't exist) */
    .btn:active:not(:disabled),
    button:active:not(:disabled) {
        transform: scale(0.95);
        opacity: 0.9;
    }

    /* Larger touch targets for student cards */
    .student-card {
        min-height: 120px;
    }

    /* Increase tap area for word selection hints */
    .word-hint {
        padding: var(--space-md);
    }

    /* More prominent breadcrumb steps */
    .breadcrumb-step {
        min-width: 44px;
        min-height: 44px;
    }

    /* Ensure form inputs are touch-friendly */
    input,
    select,
    textarea {
        min-height: 44px;
        font-size: 16px; /* Prevents iOS zoom on focus */
    }

    /* Touch-friendly instructions toggle */
    .instructions-toggle {
        padding: 0.6rem 1.2rem;
        font-size: 0.875rem;
    }

    /* Larger modal close buttons */
    .modal-close,
    .close-btn {
        min-width: var(--touch-target);
        min-height: var(--touch-target);
        font-size: 1.5rem;
    }
}

/* Small mobile screens (< 480px) */
@media (max-width: 480px) {
    /* Export buttons grid for mobile */
    .download-output-section {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 0.5rem;
    }

    .download-output-section .btn {
        font-size: 0.75rem;
        padding: 0.5rem 0.25rem;
        min-height: 60px;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        text-align: center;
        line-height: 1.2;
    }

    .download-output-section .btn .icon {
        font-size: 1.25rem;
        margin-bottom: 0.25rem;
    }

    /* Stack action buttons vertically */
    .action-buttons,
    .step-nav-buttons {
        flex-direction: column;
        gap: var(--space-sm);
    }

    .action-buttons .btn,
    .step-nav-buttons .btn {
        width: 100%;
    }

    /* Reduce padding on small screens */
    .container {
        padding: var(--space-sm);
    }

    /* Smaller headings on mobile */
    h1 {
        font-size: 1.5rem;
    }

    h2 {
        font-size: 1.25rem;
    }

    /* Ensure modals fit small screens */
    .modal-content {
        width: 95%;
        max-height: 90vh;
        overflow-y: auto;
    }
}

/* Safe area insets for notched phones */
@supports (padding: max(0px)) {
    .container {
        padding-left: max(var(--space-md), env(safe-area-inset-left));
        padding-right: max(var(--space-md), env(safe-area-inset-right));
        padding-bottom: max(var(--space-md), env(safe-area-inset-bottom));
    }

    .modal-content {
        padding-bottom: max(var(--space-xl), env(safe-area-inset-bottom));
    }
}
