/* Global Styles */
@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700;800&display=swap');

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

:root {
    --primary: #4a90d9;
    --primary-dark: #357abd;
    --secondary: #7c3aed;
    --accent: #f59e0b;
    --success: #10b981;
    --text: #1f2937;
    --text-light: #6b7280;
    --bg-light: #f8fafc;
    --white: #ffffff;
}

body {
    font-family: 'Nunito', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #f59e0b 100%);
    min-height: 100vh;
    color: var(--text);
}

/* Unified Header - Single header bar */
.unified-header {
    background: linear-gradient(135deg, #4fc3f7 0%, #29b6f6 100%);
    padding: 0.5rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    position: relative;
    z-index: 100002;
}

.unified-header .header-left {
    display: flex;
    align-items: center;
}

.unified-header .header-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    color: white;
}

.unified-header .header-logo {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.unified-header .header-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: white;
    margin: 0;
}

.unified-header .header-ai-text {
    background: linear-gradient(90deg, #fbbf24, #f59e0b);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-weight: 800;
}

.unified-header .header-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.nav-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 700;
    text-decoration: none;
    transition: all 0.2s ease;
    cursor: pointer;
    border: 2px dashed transparent;
    background: white;
    color: #0288d1;
    border-color: #0288d1;
}

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

.nav-btn-icon {
    font-size: 1rem;
}

/* Legacy top-nav-bar support */
.top-nav-bar {
    background: linear-gradient(135deg, #4fc3f7 0%, #29b6f6 100%);
    padding: 0.5rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    position: relative;
    z-index: 100002;
}

.top-nav-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.top-nav-left a {
    color: white;
    text-decoration: none;
    font-weight: 700;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: opacity 0.2s;
}

.top-nav-left a:hover {
    opacity: 0.9;
}

.top-nav-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.container {
    max-width: 100vw;
    height: calc(100vh - 56px);
    display: flex;
    flex-direction: column;
}

/* Header Styles - Legacy */
.header {
    background: rgba(255, 255, 255, 0.95);
    padding: 1rem 2rem;
    text-align: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
    position: relative;
    z-index: 100001;
}

/* Compact Header for Desktop */
.header.compact-header {
    padding: 0.5rem 1rem;
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    max-width: 100%;
    margin: 0 auto;
}

.compact-header-content {
    justify-content: space-between;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.header-title {
    font-size: 1.1rem;
    margin: 0;
    color: #333;
    font-weight: 700;
}

.header-ai-text {
    background: linear-gradient(90deg, #f59e0b, #d97706);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-weight: 800;
}

.logo {
    width: 60px;
    height: 60px;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.compact-logo {
    width: 36px;
    height: 36px;
}

.header-text {
    text-align: left;
}

.header-text h1 {
    font-size: 1rem;
    margin: 0;
    line-height: 1.2;
}

.header-text p {
    font-size: 4px;
    margin: 0.4rem 0 0 0;
    opacity: 0.6;
    line-height: 1;
}

/* User Menu Dropdown */
.user-menu {
    position: absolute;
    top: 50%;
    right: 1.5rem;
    transform: translateY(-50%);
    z-index: 100000;
}

.user-menu-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: linear-gradient(135deg, #4a90d9 0%, #357abd 100%);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(74, 144, 217, 0.3);
}

.user-menu-btn:hover {
    background: linear-gradient(135deg, #357abd 0%, #2868a5 100%);
    box-shadow: 0 4px 12px rgba(74, 144, 217, 0.4);
}

.user-avatar {
    font-size: 1.1rem;
}

.user-name {
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.menu-arrow {
    font-size: 0.7rem;
    transition: transform 0.2s ease;
}

.user-menu.open .menu-arrow {
    transform: rotate(180deg);
}

.user-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 180px;
    background: white;
    border-radius: 10px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.2s ease;
    z-index: 100000;
    overflow: hidden;
}

.user-menu.open .user-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    padding: 0.75rem 1rem;
    border: none;
    background: transparent;
    color: #333;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background 0.15s ease;
    text-align: left;
}

.dropdown-item:hover {
    background: #f5f7fa;
}

.dropdown-item .item-icon {
    font-size: 1rem;
}

.dropdown-item.admin-item:hover {
    background: #e8f4fd;
    color: #357abd;
}

.dropdown-item.logout-item:hover {
    background: #fef2f2;
    color: #dc3545;
}

.dropdown-divider {
    height: 1px;
    background: #e5e7eb;
    margin: 0.25rem 0;
}

/* Make header-content position relative for user menu positioning */
.header-content {
    position: relative;
}

/* Compact header for better space utilization */
@media (max-width: 100%) {
    .header {
        padding: 0.8rem 1.5rem;
    }
    
    .header-text h1 {
        font-size: 0.8rem;
    }
    
    .header-text p {
        font-size: 0.6rem;
    }
    
    .logo {
        width: 50px;
        height: 50px;
    }
}

.header h1 {
    font-size: 2rem;
    color: #4a5568;
    margin-bottom: 0.5rem;
    margin: 0 0 0.5rem 0;
}

.header p {
    font-size: 0.8rem;
    color: #718096;
    margin: 0;
}

/* Main Content Layout - Three Panel Design */
.main-content {
    display: flex;
    flex: 1;
    height: calc(100vh - 100px);
    overflow: hidden;
    position: relative;
}

/* Left Panel: Chat + Board Info - Modern Design */
.left-panel {
    width: 320px;
    min-width: 200px;
    max-width: 500px;
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
    border-right: none;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.08);
    position: relative;
    z-index: 10;
}

/* Center Panel: Blockly Workspace */
.center-panel {
    flex: 1;
    background: linear-gradient(135deg, #e8f4fc 0%, #f0f9ff 50%, #e0f2fe 100%);
    display: flex;
    flex-direction: column;
    min-width: 300px;
}

/* Right Panel: Generated Code + Results - Modern Design */
.right-panel {
    width: 350px;
    min-width: 200px;
    max-width: 600px;
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
    border-left: none;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.08);
    position: relative;
    z-index: 10;
    padding-bottom: 80px;
    transition: width 0.3s ease, min-width 0.3s ease, opacity 0.3s ease;
}

/* Right Panel Collapsed State */
.right-panel.collapsed {
    width: 0 !important;
    min-width: 0 !important;
    padding: 0 !important;
    overflow: hidden;
    opacity: 0;
}

/* Panel Collapse Toggle Button */
.panel-collapse-toggle {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 50px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    border-radius: 6px 0 0 6px;
    cursor: pointer;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: -2px 0 8px rgba(0, 0, 0, 0.15);
    transition: all 0.2s ease;
}

.panel-collapse-toggle:hover {
    width: 24px;
    background: linear-gradient(135deg, #5a67d8 0%, #6b46c1 100%);
}

.panel-collapse-toggle .toggle-icon {
    color: white;
    font-size: 12px;
    transition: transform 0.3s ease;
}

.panel-collapse-toggle.right-toggle {
    right: 350px;
    border-radius: 6px 0 0 6px;
}

/* Adjust toggle position based on panel width */
.main-content:has(.right-panel:not(.collapsed)) .panel-collapse-toggle.right-toggle {
    right: 350px;
}

.main-content:has(.right-panel.collapsed) .panel-collapse-toggle.right-toggle,
.panel-collapse-toggle.right-toggle.collapsed {
    right: 0;
}

/* When panel is collapsed, flip the arrow */
.panel-collapse-toggle.collapsed .toggle-icon {
    transform: rotate(180deg);
}

/* Custom Scrollbar for Panels */
.left-panel::-webkit-scrollbar,
.right-panel::-webkit-scrollbar {
    width: 8px;
}

.left-panel::-webkit-scrollbar-track,
.right-panel::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 4px;
}

.left-panel::-webkit-scrollbar-thumb,
.right-panel::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, #29b6f6 0%, #0288d1 100%);
    border-radius: 4px;
}

.left-panel::-webkit-scrollbar-thumb:hover,
.right-panel::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, #4fc3f7 0%, #29b6f6 100%);
}

/* Resizable Handle */
.resize-handle {
    width: 5px;
    background: linear-gradient(45deg, #4299e1, #667eea);
    cursor: col-resize;
    position: relative;
    flex-shrink: 0;
    transition: background 0.2s;
}

.resize-handle:hover {
    background: linear-gradient(45deg, #3182ce, #5a67d8);
    box-shadow: 0 0 10px rgba(66, 153, 225, 0.5);
}

.resize-handle::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 3px;
    height: 30px;
    background: white;
    border-radius: 1px;
    opacity: 0.7;
}

/* Left Panel Tabs */
.left-panel-tabs {
    display: flex;
    gap: 0;
    padding: 0.5rem 0.75rem 0;
    background: transparent;
    border-bottom: 1px solid #e5e7eb;
}

.panel-tab {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.6rem 0.5rem;
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 600;
    color: #6b7280;
    transition: all 0.2s ease;
    position: relative;
}

.panel-tab:hover {
    color: #4b5563;
    background: rgba(0, 0, 0, 0.02);
}

.panel-tab.active {
    color: #667eea;
    border-bottom-color: #667eea;
}

.panel-tab .tab-icon {
    font-size: 1rem;
}

.panel-tab .tab-label {
    display: none;
}

@media (min-width: 400px) {
    .panel-tab .tab-label {
        display: inline;
    }
}

.panel-tab .tab-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    background: #ef4444;
    color: white;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 0.1rem 0.4rem;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
}

.panel-tab-content {
    display: none;
    flex: 1;
    overflow: hidden;
}

.panel-tab-content.active {
    display: flex;
    flex-direction: column;
}

/* Chat Panel Styles - Modern Design */
.chat-panel {
    font-size: 0.85rem;
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 1rem;
    background: white;
    border-radius: 16px;
    margin: 0.75rem;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(0, 0, 0, 0.05);
}

/* Library Panel Styles */
.library-panel, .assignments-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 1rem;
    background: white;
    border-radius: 16px;
    margin: 0.75rem;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.library-header, .assignments-header {
    margin-bottom: 1rem;
}

.library-header h3, .assignments-header h3 {
    font-size: 1rem;
    font-weight: 700;
    color: #1f2937;
    margin: 0 0 0.25rem 0;
}

.library-subtitle, .assignments-subtitle {
    font-size: 0.8rem;
    color: #6b7280;
    margin: 0;
}

.library-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-bottom: 1rem;
}

.library-filter-select {
    flex: 1 1 auto;
    min-width: 80px;
    max-width: 100%;
    padding: 0.4rem 0.5rem;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    font-size: 0.75rem;
    background: white;
    cursor: pointer;
}

.library-filter-select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.library-list, .assignments-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.library-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 2rem;
    color: #6b7280;
    font-size: 0.85rem;
}

.spinner-small {
    width: 20px;
    height: 20px;
    border: 2px solid #e5e7eb;
    border-top-color: #667eea;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* Library Item Card */
.library-item {
    background: #f8fafc;
    border-radius: 12px;
    padding: 0.75rem;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

.library-item:hover {
    background: #f1f5f9;
    border-color: #667eea;
    transform: translateY(-1px);
}

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

.library-item-level {
    font-size: 0.7rem;
    font-weight: 700;
    padding: 0.2rem 0.5rem;
    border-radius: 10px;
    color: white;
}

.library-item-hardware {
    font-size: 0.7rem;
    color: #6b7280;
}

.library-item-title {
    font-size: 0.9rem;
    font-weight: 700;
    color: #1f2937;
    margin: 0 0 0.25rem 0;
}

.library-item-desc {
    font-size: 0.75rem;
    color: #6b7280;
    margin: 0;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.library-item-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.library-item-btn {
    flex: 1;
    padding: 0.4rem 0.5rem;
    border: none;
    border-radius: 8px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.library-item-btn.load-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.library-item-btn.load-btn:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.library-item-btn.tutorial-btn {
    background: linear-gradient(135deg, #4ade80 0%, #22c55e 100%);
    color: white;
    font-weight: 700;
}

.library-item-btn.tutorial-btn:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 12px rgba(74, 222, 128, 0.4);
}

.library-item-btn.preview-btn {
    background: #e5e7eb;
    color: #374151;
}

.library-item-btn.preview-btn:hover {
    background: #d1d5db;
}

/* Compact Library Item for /app page */
.library-item-compact {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0.5rem;
    background: #f8fafc;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s ease;
    border: 1px solid transparent;
    margin-bottom: 2px;
}

.library-item-compact:hover {
    background: linear-gradient(135deg, #667eea15 0%, #764ba215 100%);
    border-color: #667eea;
    transform: translateX(2px);
}

.library-item-compact .lib-level {
    font-size: 0.6rem;
    font-weight: 700;
    padding: 0.15rem 0.35rem;
    border-radius: 4px;
    color: white;
    flex-shrink: 0;
}

.library-item-compact .lib-lang {
    font-size: 0.55rem;
    font-weight: 700;
    padding: 0.1rem 0.3rem;
    border-radius: 3px;
    color: white;
    flex-shrink: 0;
    text-transform: uppercase;
}

/* Language-specific colors with better contrast */
.library-item-compact .lib-lang[style*="#f7df1e"] {
    color: #1a1a1a !important; /* Dark text for JavaScript yellow */
}

.library-item-compact .lib-name {
    font-size: 0.75rem;
    font-weight: 600;
    color: #374151;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

/* Tutorial button in library items */
.library-item-compact .lib-tutorial-btn {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    font-size: 0.7rem;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(102, 126, 234, 0.3);
}

.library-item-compact .lib-tutorial-btn:hover {
    transform: scale(1.15);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.5);
}

/* Help button in library items */
.library-item-compact .lib-help-btn {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 1px solid #d1d5db;
    background: white;
    color: #6b7280;
    font-size: 0.65rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.library-item-compact .lib-help-btn:hover {
    background: #f3f4f6;
    border-color: #9ca3af;
    color: #374151;
}

.empty-state-small {
    padding: 1rem;
    text-align: center;
    color: #6b7280;
    font-size: 0.8rem;
}

/* Thin scrollbar for library panel */
#appLibraryList {
    max-height: calc(100vh - 280px);
    overflow-y: auto;
    padding-right: 0.25rem;
}

#appLibraryList::-webkit-scrollbar {
    width: 4px;
}

#appLibraryList::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 2px;
}

#appLibraryList::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 2px;
}

#appLibraryList::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Assignment Item Card */
.assignment-item {
    background: #f8fafc;
    border-radius: 12px;
    padding: 0.75rem;
    cursor: pointer;
    transition: all 0.2s ease;
    border-left: 4px solid #667eea;
}

.assignment-item:hover {
    background: #f1f5f9;
    transform: translateY(-1px);
}

.assignment-item.has-bugs {
    border-left-color: #f59e0b;
}

.assignment-item.completed {
    border-left-color: #10b981;
    opacity: 0.8;
}

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

.assignment-item-badge {
    font-size: 0.7rem;
    font-weight: 700;
    padding: 0.2rem 0.5rem;
    border-radius: 10px;
}

.assignment-item-badge.bug-fix {
    background: #fef3c7;
    color: #92400e;
}

.assignment-item-badge.normal {
    background: #dbeafe;
    color: #1e40af;
}

.assignment-item-badge.done {
    background: #d1fae5;
    color: #065f46;
}

.assignment-item-title {
    font-size: 0.9rem;
    font-weight: 700;
    color: #1f2937;
    margin: 0 0 0.25rem 0;
}

.assignment-item-teacher {
    font-size: 0.75rem;
    color: #6b7280;
    margin: 0;
}

.assignment-item-desc {
    font-size: 0.75rem;
    color: #6b7280;
    margin: 0.5rem 0 0 0;
    line-height: 1.4;
}

.empty-state {
    text-align: center;
    padding: 2rem;
    color: #6b7280;
}

.empty-state-icon {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

.empty-state p {
    margin: 0.25rem 0;
    font-size: 0.85rem;
}

/* Board Section Styles - Collapsible */
.board-section {
    font-size: 0.75rem;
    border-top: 1px solid #e0e0e0;
    background: rgba(248, 249, 250, 0.8);
}

.board-section.collapsible-section {
    padding: 0;
}

.collapsible-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    cursor: pointer;
    background: linear-gradient(135deg, #e3f2fd 0%, #f5f5f5 100%);
    border-bottom: 1px solid #e0e0e0;
    user-select: none;
    transition: background 0.2s;
}

.collapsible-header:hover {
    background: linear-gradient(135deg, #bbdefb 0%, #e8e8e8 100%);
}

.collapsible-icon {
    font-size: 10px;
    color: #666;
    transition: transform 0.2s;
}

.collapsible-title {
    font-size: 12px;
    font-weight: 600;
    color: #333;
}

.collapsible-content {
    padding: 12px;
    max-height: 300px;
    overflow-y: auto;
}

.board-section h4 {
    margin: 0 0 1rem 0;
    color: #333;
    font-size: 0.9rem;
}

#boardName {
    font-size: 0.8rem;
    font-weight: bold;
    color: #4285f4;
    margin-bottom: 0.5rem;
}

.pinout-diagram {
    font-size: 0.7rem;
    background: white;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 1rem;
    text-align: center;
    min-height: 90px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    color: #666;
}

/* Control Styles */
.control-select {
    padding: 0.4rem 0.8rem;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: white;
    font-size: 0.8rem;
    margin-right: 0.5rem;
}

/* Center Panel Blockly Styles */
.center-panel .blockly-header {
    background: rgba(255, 255, 255, 0.95);
    padding: 1rem;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.center-panel .blockly-workspace {
    flex: 1;
    background: linear-gradient(135deg, #e8f4fc 0%, #f0f9ff 50%, #e0f2fe 100%);
}

/* Right Panel Styles - Modern Design */
.code-section, .results-section, .wiring-section {
    padding: 1rem;
    margin: 0.75rem;
    background: white;
    border-radius: 16px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.code-section h4, .results-section h4, .wiring-section h4 {
    margin: 0 0 1rem 0;
    color: #1f2937;
    font-size: 0.95rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

#generatedCode, #executionOutput {
    background: #1e293b;
    color: #e2e8f0;
    border: none;
    padding: 1rem;
    border-radius: 12px;
    font-family: 'JetBrains Mono', 'Fira Code', 'Monaco', 'Consolas', monospace;
    font-size: 0.8rem;
    line-height: 1.5;
    max-height: calc(100vh - 350px);
    overflow-y: auto;
    font-size: 0.8rem;
    line-height: 1.4;
    overflow-x: auto;
    max-height: 300px;
    overflow-y: auto;
}

.wiring-diagram {
    background: white;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 1rem;
    text-align: center;
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    color: #666;
}

.chat-header {
    font-size: 0.8rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid #e2e8f0;
}

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

.chat-header h3 {
    color: #4a5568;
    font-size: 1rem;
}

.speech-btn {
    background: #eeeeee;
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.3s ease;
}

.speech-btn:hover {
    background: #3182ce;
    transform: translateY(-2px);
}

.speech-btn.active {
    background: #38a169;
}

/* Provider, Location and Language Selectors */
.provider-selector,
.location-selector,
.language-selector {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
}

.provider-selector label,
.location-selector label,
.language-selector label {
    font-weight: bold;
    color: #4a5568;
    min-width: fit-content;
}

.provider-selector select,
.location-selector select,
.language-selector select {
    background: #f7fafc;
    border: 1px solid #e2e8f0;
    border-radius: 5px;
    padding: 0.3rem 0.5rem;
    font-size: 0.9rem;
    color: #4a5568;
    cursor: pointer;
    transition: border-color 0.3s ease;
}

.provider-selector select:focus,
.location-selector select:focus,
.language-selector select:focus {
    outline: none;
    border-color: #4299e1;
}

/* Mode Selector */
.mode-selector {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-left: 1rem;
}

.mode-selector label {
    font-size: 0.9rem;
    color: #4a5568;
    margin: 0;
}

.mode-selector select {
    padding: 0.3rem;
    border: 1px solid #cbd5e0;
    border-radius: 5px;
    font-size: 0.9rem;
    background: white;
}

.mode-selector select:focus {
    outline: none;
    border-color: #4299e1;
}

/* Chat Messages */
.chat-messages {
    font-size: 0.75rem;
    line-height: 1.2;
    flex: 1;
    overflow-y: auto;
    margin-bottom: 1rem;
    padding: 0.5rem;
    max-height: 300px;
}

.ai-message {
    background: #f7fafc;
    padding: 1rem;
    border-radius: 10px;
    margin-bottom: 1rem;
    border-left: 4px solid #4299e1;
}

.user-message {
    background: #e6fffa;
    padding: 1rem;
    border-radius: 10px;
    margin-bottom: 1rem;
    border-left: 4px solid #38a169;
}

.user-message, .ai-message {
    padding: 0.6rem;        /* reduce bubble size */
    font-size: 0.75rem;
}

.ai-message ul {
    margin: 0.5rem 0;
    padding-left: 1.5rem;
}

.ai-message li {
    margin: 0.3rem 0;
    color: #4a5568;
}

/* Chat Input */
.chat-input-container {
    margin-bottom: 1rem;
}

#userInput {
    width: 100%;
    padding: 1rem;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    font-family: inherit;
    font-size: 0.9rem;
    resize: vertical;
    margin-bottom: 0.5rem;
    transition: border-color 0.3s ease;
}

#userInput:focus {
    outline: none;
    border-color: #4299e1;
}

.generate-btn {
    width: 100%;
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
    border: none;
    padding: 0.65rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 3px 10px rgba(16, 185, 129, 0.25);
}

.generate-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(16, 185, 129, 0.35);
    background: linear-gradient(135deg, #059669, #047857);
}

.generate-btn:disabled {
    background: linear-gradient(135deg, #9ca3af, #6b7280);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Code Section */
.code-section {
    background: #eeeeee;
    color: #eeeeee;
    padding: 1rem;
    border-radius: 10px;
    margin-bottom: 1rem;
}

.code-section h4 {
    margin-bottom: 0.5rem;
    color: #63b3ed;
}

#languageSelect {
    background: #4a5568;
    color: white;
    border: none;
    padding: 0.5rem;
    border-radius: 5px;
    margin-bottom: 0.5rem;
}

#generatedCode {
    background: #ffffff;
    padding: 1rem;
    border-radius: 5px;
    overflow: auto;
    max-height: 400px;
    margin-bottom: 0.5rem;
    font-family: 'Courier New', monospace;
    white-space: pre-wrap;
    word-wrap: break-word;
    line-height: 1.4;
    font-size: 12px;
}

.execute-btn {
    background: #eeeeee;
    color: #000000;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 5px;
    cursor: pointer;
    transition: background 0.3s ease;
}

.execute-btn:hover {
    background: #2f855a;
}

/* Results Section */
.results-section {
    background: #f7fafc;
    padding: 1rem;
    border-radius: 10px;
    border: 2px solid #38a169;
    margin-bottom: 1rem;
}

.results-section h4 {
    color: #2f855a;
    margin-bottom: 0.5rem;
}

#executionOutput {
    background: #1e293b;
    color: #4ade80;
    padding: 1rem;
    border-radius: 8px;
    font-family: 'JetBrains Mono', 'Fira Code', 'Courier New', monospace;
    white-space: pre-wrap;
    max-height: 150px;
    overflow-y: auto;
    font-size: 0.9rem;
    line-height: 1.5;
    min-height: 40px;
}

/* Blockly Panel */
.blockly-panel {
    flex: 1;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 15px;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
}

.blockly-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid #e2e8f0;
    flex-wrap: nowrap;
    gap: 0.5rem;
    min-height: 40px;
}

.blockly-header h3 {
    color: #4a5568;
    font-size: 0.85rem;
    white-space: nowrap;
    margin-right: 0.25rem;
    flex-shrink: 0;
}

/* Toolbar Selectors (Target & Language) - Matching Header Style */
.toolbar-selectors {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-shrink: 1;
    min-width: 0;
}

.toolbar-selector {
    display: flex;
    align-items: center;
    flex-shrink: 1;
    min-width: 0;
    gap: 0.35rem;
}

.toolbar-selector label {
    font-size: 0.8rem;
    font-weight: 600;
    color: #0288d1;
    white-space: nowrap;
    font-family: 'Nunito', sans-serif;
}

.toolbar-selector select {
    padding: 0.4rem 0.75rem;
    border: 2px solid #0288d1;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    font-family: 'Nunito', sans-serif;
    background: white;
    color: #0288d1;
    cursor: pointer;
    min-width: 120px;
    transition: all 0.2s ease;
}

.toolbar-selector select:hover {
    background: #e1f5fe;
}

.toolbar-selector select:focus {
    outline: none;
    background: #e1f5fe;
    box-shadow: 0 0 0 2px rgba(2, 136, 209, 0.2);
}

.toolbar-icon-btn {
    background: linear-gradient(135deg, #7c3aed, #6366f1);
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    box-shadow: 0 2px 6px rgba(124, 58, 237, 0.3);
}

.toolbar-icon-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(124, 58, 237, 0.4);
}

.toolbar-selector select optgroup {
    font-weight: 600;
    color: #374151;
    background: #f3f4f6;
}

.toolbar-selector select option {
    font-weight: 500;
    padding: 8px;
}

.toolbar-selector select option[value^="custom_"] {
    color: #7c3aed;
    font-weight: 600;
}

.controls {
    display: flex;
    gap: 0.35rem;
    flex-shrink: 0;
    flex-wrap: nowrap;
}

.control-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    background: white;
    color: #0288d1;
    border: 2px solid #0288d1;
    padding: 0.4rem 0.75rem;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 600;
    font-family: 'Nunito', sans-serif;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.control-btn.icon-btn {
    padding: 0.4rem 0.6rem;
    font-size: 1rem;
    min-width: 36px;
    justify-content: center;
}

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

/* Blockly Workspace */
.blockly-workspace {
    flex: 1;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    margin-bottom: 1rem;
    background: linear-gradient(135deg, #e8f4fc 0%, #f0f9ff 50%, #e0f2fe 100%);
}

/* Explanation Panel */
.explanation-panel {
    background: #fffbeb;
    border: 1px solid #fbbf24;
    border-radius: 8px;
    padding: 0.5rem 0.75rem;
    box-shadow: 0 2px 8px rgba(251, 191, 36, 0.15);
    position: relative;
}

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

.explanation-panel h4 {
    color: #92400e;
    margin: 0;
    font-size: 0.8rem;
    font-weight: 600;
}

.close-explanation-btn {
    background: transparent;
    border: none;
    color: #92400e;
    font-size: 1rem;
    cursor: pointer;
    padding: 0.15rem 0.35rem;
    border-radius: 4px;
    transition: background 0.2s ease, color 0.2s ease;
    line-height: 1;
}

.close-explanation-btn:hover {
    background: #fbbf24;
    color: #78350f;
}

#explanationContent {
    color: #78350f;
    font-size: 0.8rem;
    line-height: 1.35;
    padding: 0.4rem 0.5rem;
    background: rgba(255, 255, 255, 0.6);
    border-radius: 4px;
    border-left: 2px solid #fbbf24;
    margin: 0;
}

#explanationContent strong {
    color: #92400e;
    font-size: 0.75rem;
}

.explanation-buttons {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    margin-top: 0.4rem;
}

.explanation-btn {
    background: #fbbf24;
    color: #78350f;
    border: none;
    padding: 0.25rem 0.6rem;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 700;
    font-size: 1rem;
    transition: all 0.2s ease;
    min-width: 32px;
}

.explanation-btn:hover:not(:disabled) {
    background: #f59e0b;
    transform: scale(1.1);
}

.explanation-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.explanation-btn:disabled {
    background: #cbd5e0;
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(5px);
}

.loading-content {
    background: white;
    padding: 2rem;
    border-radius: 15px;
    text-align: center;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #e2e8f0;
    border-top: 4px solid #4299e1;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ============================================
   BLOCK EXPLANATION HIGHLIGHTING SYSTEM
   Uses spotlight overlay approach (same as walkthrough)
   ============================================ */

/* Highlighted block indicator arrow (pointing hand) */
.block-highlight-indicator {
    position: fixed;
    font-size: 28px;
    animation: bounce-indicator 1s ease-in-out infinite;
    z-index: 1001;
    pointer-events: none;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.4));
}

@keyframes bounce-indicator {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

/* Responsive Design */
@media (max-width: 1024px) {
    .main-content {
        flex-direction: column;
    }
    
    .chat-panel {
        width: 100%;
        max-height: 50vh;
    }
    
    .blockly-panel {
        min-height: 50vh;
    }
}

@media (max-width: 100%) {
    .header-content {
        flex-direction: column;
        text-align: center;
        gap: 0.5rem;
    }
    
    .header-text {
        text-align: center;
    }
    
    .logo {
        width: 50px;
        height: 50px;
    }
    
    .header h1 {
        font-size: 1.3rem;
    }
    
    .header p {
        font-size: 1rem;
    }
    
    .controls {
        flex-wrap: wrap;
    }
    
    .control-btn {
        font-size: 0.8rem;
        padding: 0.4rem 0.8rem;
    }
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Pinout and Wiring Styles */
.pinout-info {
    text-align: left;
}

.pin-group {
    margin-bottom: 0.5rem;
    padding: 0.3rem 0.5rem;
    background: rgba(66, 133, 244, 0.1);
    border-radius: 4px;
    border-left: 3px solid #4285f4;
}

.pin-group strong {
    color: #4285f4;
    font-weight: 600;
}

.board-info h5 {
    margin: 0 0 1rem 0;
    color: #4285f4;
    font-size: 0.9rem;
}

.components-list {
    text-align: left;
}

.component-item {
    margin-bottom: 1rem;
    padding: 0.8rem;
    background: rgba(248, 249, 250, 0.8);
    border-radius: 6px;
    border: 1px solid #e0e0e0;
}

.component-item strong {
    display: block;
    margin-bottom: 0.5rem;
    color: #333;
    font-size: 0.9rem;
}

.component-pins {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.pin-connection {
    background: #4285f4;
    color: white;
    padding: 0.2rem 0.5rem;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 500;
}

/* Board Selection and Flashing Styles */
.board-section {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    padding: 1rem;
    margin-top: 1rem;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.board-selection {
    margin-bottom: 1rem;
}

.board-selection label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: #4a5568;
}

.board-select {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 0.9rem;
    background: white;
    transition: border-color 0.3s ease;
}

.board-select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.board-details {
    margin-bottom: 1rem;
    padding: 0.75rem;
    background: #f7fafc;
    border-radius: 8px;
    border-left: 4px solid #667eea;
}

.board-details #boardName {
    font-weight: 600;
    color: #2d3748;
    margin-bottom: 0.25rem;
}

.board-details #boardDescription {
    font-size: 0.85rem;
    color: #718096;
}

.flash-controls {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.flash-btn {
    flex: 1;
    padding: 0.75rem 1rem;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.flash-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.flash-btn:disabled {
    background: #cbd5e0;
    color: #a0aec0;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.flash-progress {
    margin-bottom: 1rem;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: #e2e8f0;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 0.5rem;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    border-radius: 4px;
    transition: width 0.3s ease;
    width: 0%;
}

.progress-text {
    font-size: 0.85rem;
    color: #4a5568;
    text-align: center;
}

.flash-status {
    padding: 0.75rem;
    border-radius: 8px;
    font-size: 0.9rem;
    margin-top: 0.5rem;
    display: none;
}

.flash-status.success {
    background: #f0fff4;
    color: #22543d;
    border: 1px solid #9ae6b4;
    display: block;
}

.flash-status.error {
    background: #fff5f5;
    color: #742a2a;
    border: 1px solid #feb2b2;
    display: block;
}

.flash-status.info {
    background: #ebf8ff;
    color: #2a4365;
    border: 1px solid #90cdf4;
    display: block;
}

/* Board Controls - Compact Icon Ribbon */
.board-controls-ribbon {
    display: flex;
    gap: 0.25rem;
    padding: 0.5rem;
    border-top: 1px solid #e2e8f0;
    margin-top: 0.5rem;
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    border-radius: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.ribbon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
    border: none;
    border-radius: 6px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 36px;
    min-height: 36px;
}

.ribbon-btn.icon-only {
    width: 36px;
    height: 36px;
    padding: 0;
}

.ribbon-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.4);
}

.ribbon-btn:disabled {
    background: #cbd5e0;
    color: #a0aec0;
    cursor: not-allowed;
}

.ribbon-icon {
    font-size: 1.3rem;
    line-height: 1;
}

/* Download button - green */
#downloadHexBtn {
    background: linear-gradient(135deg, #48bb78 0%, #38a169 100%);
}

#downloadHexBtn:hover:not(:disabled) {
    box-shadow: 0 2px 8px rgba(72, 187, 120, 0.4);
}

/* Legacy board controls (keep for compatibility) */
.board-controls {
    display: flex;
    gap: 0.75rem;
    padding: 1rem 0;
    border-top: 1px solid #e2e8f0;
    margin-top: 1rem;
}

.board-control-btn {
    flex: 1;
    padding: 0.75rem 1rem;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.board-control-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.board-control-btn:disabled {
    background: #cbd5e0;
    color: #a0aec0;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Download button - green */
#downloadHexBtn {
    background: linear-gradient(135deg, #48bb78 0%, #38a169 100%);
}

#downloadHexBtn:hover:not(:disabled) {
    box-shadow: 0 4px 15px rgba(72, 187, 120, 0.3);
}

/* USB Port Info */
.usb-port-info {
    padding: 0.75rem;
    background: #fffbeb;
    border: 1px solid #f59e0b;
    border-radius: 6px;
    margin-top: 0.5rem;
    color: #92400e;
    font-size: 0.85rem;
}

/* Pinout Diagram Styles */
.pinout-diagram {
    margin-top: 1rem;
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e9ecef;
}

.pinout-placeholder {
    text-align: center;
    color: #6c757d;
    font-style: italic;
    padding: 2rem 1rem;
}

/* Board Selector in Header */
.board-selector {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-right: 1rem;
}

.board-selector label {
    font-size: 0.9rem;
    font-weight: 600;
    color: #4a5568;
}

.board-selector select {
    padding: 0.25rem 0.5rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.85rem;
    background: white;
}

/* AI Provider Selector */
.provider-selector {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.5rem;
    padding: 0.5rem;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 6px;
}

.provider-selector label {
    font-size: 0.85rem;
    font-weight: 600;
    color: #4a5568;
}

.provider-selector select {
    padding: 0.25rem 0.5rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.85rem;
    background: white;
}

/* Header Top Layout */
.header-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
}

/* Fix Blockly zoom controls */
.blockly-workspace {
    position: relative;
    overflow: visible !important;
}

/* Ensure Blockly controls are visible */
.blocklyZoom {
    position: absolute !important;
    right: 10px !important;
    bottom: 10px !important;
    z-index: 1000 !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 2px !important;
}

.blocklyZoom > .blocklyZoomButton {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    width: 32px !important;
    height: 32px !important;
    background: #fff !important;
    border: 1px solid #ccc !important;
    border-radius: 4px !important;
    cursor: pointer !important;
    font-size: 18px !important;
    line-height: 30px !important;
    text-align: center !important;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1) !important;
}

.blocklyZoom > .blocklyZoomButton:hover {
    background: #f0f0f0 !important;
    border-color: #999 !important;
}

/* Ensure the blockly div doesn't clip the zoom controls and can contain indicators */
#blocklyDiv {
    position: relative !important;
    overflow: visible !important;
}

/* Explanation active state for workspace */
#blocklyDiv.explanation-active {
    /* Subtle vignette effect to focus attention */
    box-shadow: inset 0 0 100px rgba(0, 0, 0, 0.1);
}

/* Additional zoom button styling */
.blocklyZoomButton {
    margin: 0 !important;
    padding: 0 !important;
}

/* Make sure zoom controls stay on top */
.blocklyZoom {
    pointer-events: auto !important;
}

.blocklyZoom .blocklyZoomButton {
    pointer-events: auto !important;
}

/* ============================================
   Header Actions & Admin Button
   ============================================ */

.header-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    margin-left: auto;
}

.admin-btn {
    background: linear-gradient(135deg, #6c757d 0%, #495057 100%);
    color: white;
    border: none;
    padding: 0.4rem 0.75rem;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

.admin-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(108, 117, 125, 0.4);
    background: linear-gradient(135deg, #5a6268 0%, #3d4246 100%);
}

/* ============================================
   Resizable Panel Handles
   ============================================ */

/* Panel Resize Handles - Thin and functional */
.panel-resize-handle {
    width: 4px;
    background: #cbd5e1;
    cursor: col-resize;
    position: relative;
    flex-shrink: 0;
    transition: all 0.15s ease;
    z-index: 100;
}

.panel-resize-handle:hover {
    background: #3b82f6;
    width: 6px;
}

.panel-resize-handle:active {
    background: #2563eb;
    width: 6px;
}

.panel-resize-handle::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 2px;
    height: 40px;
    background: rgba(255, 255, 255, 0.6);
    border-radius: 2px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s;
}

.panel-resize-handle:hover::before {
    opacity: 1;
}

/* Ensure handles are visible and properly sized */
.left-resize,
.right-resize {
    min-height: 100%;
    align-self: stretch;
}

/* Make handles more visible with a subtle grip pattern */
.panel-resize-handle::after {
    content: '⋮';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #94a3b8;
    font-size: 14px;
    pointer-events: none;
    opacity: 0.5;
    transition: opacity 0.15s;
}

.panel-resize-handle:hover::after {
    opacity: 1;
    color: white;
}

/* Panel smooth transitions */
.left-panel, .right-panel {
    transition: box-shadow 0.3s ease;
}

/* Resizing state - disable transitions */
body.resizing .left-panel,
body.resizing .right-panel,
body.resizing .center-panel {
    transition: none !important;
    user-select: none !important;
}

body.resizing {
    cursor: col-resize !important;
}

/* Monaco Editor Container */
.monaco-container {
    flex: 1;
    min-height: 200px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    overflow: hidden;
}

/* Code section adjustments for Monaco */
.code-section {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    padding: 1rem;
    background: white;
    border-radius: 12px;
    margin: 0.5rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.code-section h4 {
    margin-bottom: 0.75rem;
    color: #374151;
    font-size: 0.9rem;
    font-weight: 700;
}

/* Explanation panel in right panel */
.right-panel .explanation-panel {
    position: relative;
    bottom: auto;
    left: auto;
    right: auto;
    width: auto;
    max-width: none;
    margin: 0.5rem;
    border-radius: 12px;
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.15);
}

/* AI Panel hidden state (for non-AI users) */
.ai-assistant-panel.hidden {
    display: none !important;
}

/* ============================================
   Admin Panel Modal
   ============================================ */

.admin-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    backdrop-filter: blur(4px);
}

.admin-modal {
    background: white;
    border-radius: 12px;
    width: 90%;
    max-width: 900px;
    max-height: 85vh;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
}

.admin-modal-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.admin-modal-header h2 {
    margin: 0;
    font-size: 1.5rem;
}

.admin-close-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    font-size: 1.5rem;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    transition: background 0.2s;
}

.admin-close-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.admin-modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    flex: 1;
}

.admin-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    border-bottom: 2px solid #eee;
    padding-bottom: 0.5rem;
}

.admin-tab {
    padding: 0.75rem 1.5rem;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 1rem;
    color: #666;
    border-radius: 6px 6px 0 0;
    transition: all 0.2s;
}

.admin-tab:hover {
    background: #f5f5f5;
    color: #333;
}

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

.admin-tab-content {
    display: none;
}

.admin-tab-content.active {
    display: block;
}

/* User Management Table */
.users-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
}

.users-table th,
.users-table td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid #eee;
}

.users-table th {
    background: #f8f9fa;
    font-weight: 600;
    color: #555;
}

.users-table tr:hover {
    background: #f8f9fa;
}

.user-status {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: 500;
}

.user-status.active {
    background: #d4edda;
    color: #155724;
}

.user-status.inactive {
    background: #f8d7da;
    color: #721c24;
}

.user-status.admin {
    background: #cce5ff;
    color: #004085;
}

.user-actions {
    display: flex;
    gap: 0.5rem;
}

.user-actions button {
    padding: 0.25rem 0.5rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s;
}

.user-actions button:hover {
    background: #f0f0f0;
}

.user-actions .btn-danger {
    color: #dc3545;
    border-color: #dc3545;
}

.user-actions .btn-danger:hover {
    background: #dc3545;
    color: white;
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 26px;
}

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

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: 0.3s;
    border-radius: 26px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
}

input:checked + .toggle-slider {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

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

/* Settings Section */
.settings-section {
    background: #f8f9fa;
    padding: 1.5rem;
    border-radius: 8px;
    margin-bottom: 1rem;
}

.settings-section h3 {
    margin-bottom: 1rem;
    color: #333;
}

.setting-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 0;
    border-bottom: 1px solid #eee;
}

.setting-row:last-child {
    border-bottom: none;
}

.setting-label {
    font-weight: 500;
}

.setting-description {
    font-size: 0.85rem;
    color: #666;
    margin-top: 0.25rem;
}

/* Admin message */
.admin-message {
    padding: 1rem;
    border-radius: 6px;
    margin-bottom: 1rem;
}

.admin-message.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.admin-message.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* ============================================
   WALKTHROUGH / TOUR STYLES
   ============================================ */

/* Overlay that dims the page */
.walkthrough-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.75);
    z-index: 10100;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.walkthrough-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

/* Highlight box around current element - creates a "window" effect */
.walkthrough-highlight-box {
    position: fixed;
    border: 3px solid #4CAF50;
    border-radius: 8px;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.75),
                0 0 30px rgba(76, 175, 80, 0.6),
                inset 0 0 0 9999px transparent;
    z-index: 10101;
    pointer-events: none;
    transition: all 0.3s ease;
    background: transparent;
}

/* Class to elevate highlighted elements above the overlay */
.walkthrough-highlighted-element {
    position: relative !important;
    z-index: 10102 !important;
    box-shadow: 0 0 20px rgba(76, 175, 80, 0.5) !important;
}

/* Don't change position for fixed elements like chat bubble */
.chat-bubble.walkthrough-highlighted-element {
    position: fixed !important;
    bottom: 20px !important;
    right: 20px !important;
}

/* Blockly toolbox needs special handling during walkthrough */
.blocklyToolboxDiv.walkthrough-highlighted-element {
    position: absolute !important;
    z-index: 10102 !important;
    background: #f5f5f5 !important;
}

/* Ensure the toolbox categories are visible above overlay */
.blocklyToolboxDiv.walkthrough-highlighted-element .blocklyToolboxCategory,
.blocklyToolboxDiv.walkthrough-highlighted-element .blocklyTreeRow {
    position: relative;
    z-index: 10102;
}

/* ============================================
   ONBOARDING SYSTEM STYLES
   ============================================ */

/* Onboarding Modal Base */
.onboarding-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
    z-index: 20000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.onboarding-modal.hidden {
    display: none;
}

.onboarding-modal-content {
    background: white;
    border-radius: 24px;
    max-width: 90vw;
    max-height: 90vh;
    overflow-y: auto;
    overflow-x: hidden;
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.4);
}

/* Enhanced Multi-Step Onboarding Modal */
.welcome-intro-expanded {
    width: 720px;
    max-width: 95vw;
}

/* Step Indicators */
.onboarding-steps-indicator {
    display: flex;
    justify-content: center;
    gap: 12px;
    padding: 16px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 24px 24px 0 0;
}

.step-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transition: all 0.3s;
}

.step-dot.active {
    background: rgba(255, 255, 255, 0.7);
}

.step-dot.current {
    background: white;
    transform: scale(1.3);
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
}

/* Onboarding Steps */
.onboarding-step {
    display: none;
    padding: 24px 32px;
    min-height: 400px;
}

.onboarding-step.active {
    display: block;
    animation: stepFadeIn 0.4s ease-out;
}

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

/* Step 1: Welcome */
.welcome-header {
    text-align: center;
    padding-bottom: 20px;
}

.welcome-logo {
    width: 80px;
    height: auto;
    margin-bottom: 12px;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.15));
    animation: logoFloat 3s ease-in-out infinite;
}

@keyframes logoFloat {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

.welcome-title {
    font-size: 2rem;
    font-weight: 800;
    margin: 0 0 8px;
    font-family: 'Nunito', sans-serif;
    color: #1f2937;
}

.welcome-subtitle {
    font-size: 1rem;
    margin: 0;
    color: #6b7280;
    font-family: 'Nunito', sans-serif;
}

.welcome-intro-text {
    color: #4b5563;
    line-height: 1.6;
    margin: 0 0 20px;
    font-family: 'Nunito', sans-serif;
    text-align: center;
    font-size: 1rem;
}

.welcome-features {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.feature-card {
    background: linear-gradient(135deg, #f0f4ff 0%, #e8f0fe 100%);
    padding: 20px 16px;
    border-radius: 16px;
    text-align: center;
    transition: transform 0.3s, box-shadow 0.3s;
}

.feature-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 25px rgba(102, 126, 234, 0.2);
}

.feature-icon {
    font-size: 36px;
    display: block;
    margin-bottom: 10px;
}

.feature-card h3 {
    font-size: 0.95rem;
    color: #1f2937;
    margin: 0 0 6px;
    font-family: 'Nunito', sans-serif;
    font-weight: 700;
}

.feature-card p {
    font-size: 0.8rem;
    color: #6b7280;
    margin: 0;
    line-height: 1.4;
    font-family: 'Nunito', sans-serif;
}

/* Step 2: Languages */
.step-header {
    text-align: center;
    margin-bottom: 24px;
}

.step-header h2 {
    font-size: 1.6rem;
    color: #1f2937;
    margin: 0 0 8px;
    font-family: 'Nunito', sans-serif;
    font-weight: 800;
}

.step-subtitle {
    color: #6b7280;
    font-size: 1rem;
    margin: 0;
    font-family: 'Nunito', sans-serif;
}

.languages-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.language-card {
    border-radius: 16px;
    padding: 20px;
    text-align: center;
    transition: transform 0.3s, box-shadow 0.3s;
}

.language-card:hover {
    transform: translateY(-4px);
}

.python-card {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    border: 2px solid #f59e0b;
}

.javascript-card {
    background: linear-gradient(135deg, #fef9c3 0%, #fef08a 100%);
    border: 2px solid #eab308;
}

.cpp-card {
    background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
    border: 2px solid #3b82f6;
}

.language-icon {
    font-size: 40px;
    margin-bottom: 8px;
}

.language-card h3 {
    font-size: 1.1rem;
    color: #1f2937;
    margin: 0 0 4px;
    font-family: 'Nunito', sans-serif;
    font-weight: 700;
}

.language-tagline {
    font-size: 0.8rem;
    color: #6b7280;
    margin: 0 0 12px;
    font-family: 'Nunito', sans-serif;
    font-style: italic;
}

.language-description {
    text-align: left;
    font-size: 0.8rem;
}

.language-description p {
    margin: 0 0 8px;
    color: #374151;
    font-family: 'Nunito', sans-serif;
}

.language-description ul {
    margin: 0 0 10px;
    padding-left: 0;
    list-style: none;
}

.language-description li {
    margin: 4px 0;
    color: #4b5563;
    font-family: 'Nunito', sans-serif;
    font-size: 0.75rem;
}

.language-example {
    background: rgba(0, 0, 0, 0.1);
    padding: 8px 12px;
    border-radius: 8px;
}

.language-example code {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.7rem;
    color: #1f2937;
}

/* Step 3: Microcontroller Demo */
.microcontroller-demo {
    text-align: center;
}

.mcu-scene {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 30px;
    margin: 20px 0;
    min-height: 200px;
}

.mcu-inputs, .mcu-outputs {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.input-item, .output-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px;
    border-radius: 12px;
    background: #f3f4f6;
    transition: all 0.3s;
}

.output-item.active {
    background: #dcfce7;
    transform: scale(1.1);
    box-shadow: 0 0 20px rgba(34, 197, 94, 0.5);
}

.input-icon, .output-icon {
    font-size: 28px;
}

.input-label, .output-label {
    font-size: 0.7rem;
    color: #6b7280;
    font-family: 'Nunito', sans-serif;
    margin-top: 4px;
}

.mcu-container {
    position: relative;
    width: 180px;
    height: 220px;
}

.mcu-chip {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 140px;
    height: 180px;
    background: linear-gradient(135deg, #1e3a5f 0%, #0f172a 100%);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
    transition: transform 0.1s;
}

.mcu-chip.vibrating {
    animation: mcuVibrate 0.1s linear 15;
}

.mcu-chip.vibrating-long {
    animation: mcuVibrate 0.08s linear 45;
}

@keyframes mcuVibrate {
    0%, 100% { transform: translate(-50%, -50%) rotate(0deg); }
    25% { transform: translate(-48%, -50%) rotate(1deg); }
    75% { transform: translate(-52%, -50%) rotate(-1deg); }
}

.mcu-pins {
    position: absolute;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.mcu-pins.left { left: -8px; }
.mcu-pins.right { right: -8px; }

.mcu-body {
    text-align: center;
    color: white;
    padding: 10px;
}

.mcu-label {
    font-size: 0.9rem;
    font-weight: 700;
    font-family: 'Nunito', sans-serif;
    margin-bottom: 10px;
    color: #60a5fa;
}

.mcu-code-display {
    min-height: 80px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.55rem;
    text-align: left;
    color: #4ade80;
    overflow: hidden;
}

.mcu-code-display.processing {
    opacity: 0.5;
}

.code-line {
    opacity: 0;
    animation: codeEnter 0.3s ease-out forwards;
}

.code-line.entering {
    opacity: 1;
}

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

.mcu-processing {
    display: none;
    margin-top: 10px;
}

.mcu-processing.active {
    display: block;
}

.processing-dots span {
    display: inline-block;
    width: 8px;
    height: 8px;
    margin: 0 3px;
    background: #fbbf24;
    border-radius: 50%;
    animation: processingDot 0.6s ease-in-out infinite;
}

.processing-dots span:nth-child(2) { animation-delay: 0.2s; }
.processing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes processingDot {
    0%, 100% { transform: scale(1); opacity: 0.5; }
    50% { transform: scale(1.5); opacity: 1; }
}

.falling-inputs, .rising-outputs {
    position: absolute;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.falling-input {
    position: absolute;
    top: -30px;
    font-size: 20px;
    animation: fallIn 0.8s ease-in forwards;
}

@keyframes fallIn {
    0% { top: -30px; opacity: 1; }
    100% { top: 50%; opacity: 0; }
}

.rising-output {
    position: absolute;
    bottom: -30px;
    font-size: 20px;
    animation: riseOut 0.8s ease-out forwards;
}

@keyframes riseOut {
    0% { bottom: 30%; opacity: 0; }
    100% { bottom: 100%; opacity: 1; }
}

.mcu-explanation {
    margin: 16px 0;
    padding: 12px 20px;
    background: #f0f9ff;
    border-radius: 12px;
    border-left: 4px solid #3b82f6;
}

.mcu-explanation p {
    margin: 0;
    color: #1e40af;
    font-family: 'Nunito', sans-serif;
    font-size: 0.9rem;
}

.mcu-demo-controls {
    display: flex;
    justify-content: center;
    gap: 12px;
}

.demo-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border: 2px solid #3b82f6;
    background: white;
    color: #3b82f6;
    border-radius: 10px;
    font-family: 'Nunito', sans-serif;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
}

.demo-btn:hover {
    background: #3b82f6;
    color: white;
}

/* Step 4: Ready */
.ready-content {
    text-align: center;
    padding: 20px 0;
}

.ready-icon {
    font-size: 64px;
    margin-bottom: 16px;
    animation: readyBounce 1s ease-out;
}

@keyframes readyBounce {
    0% { transform: scale(0); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

.ready-content h2 {
    font-size: 2rem;
    color: #1f2937;
    margin: 0 0 12px;
    font-family: 'Nunito', sans-serif;
    font-weight: 800;
}

.ready-text {
    color: #4b5563;
    font-size: 1rem;
    line-height: 1.6;
    margin: 0 0 24px;
    font-family: 'Nunito', sans-serif;
    max-width: 500px;
    margin-left: auto;
    margin-right: auto;
}

.ready-tips {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: 450px;
    margin: 0 auto;
}

.ready-tip {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: #f9fafb;
    border-radius: 12px;
    text-align: left;
}

.ready-tip span {
    font-size: 24px;
    flex-shrink: 0;
}

.ready-tip p {
    margin: 0;
    color: #4b5563;
    font-family: 'Nunito', sans-serif;
    font-size: 0.9rem;
}

.ready-tip strong {
    color: #1f2937;
}

/* Onboarding Footer */
.onboarding-footer {
    padding: 16px 32px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid #e5e7eb;
}

.onboarding-nav-btns {
    display: flex;
    gap: 12px;
}

/* Onboarding Buttons */
.onboarding-btn {
    padding: 14px 28px;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 700;
    font-family: 'Nunito', sans-serif;
    cursor: pointer;
    transition: all 0.3s;
    border: none;
}

.onboarding-btn.primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.onboarding-btn.primary:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.5);
}

.onboarding-btn.secondary {
    background: #f3f4f6;
    color: #4b5563;
}

.onboarding-btn.secondary:hover {
    background: #e5e7eb;
}

/* Tip of the Day Modal */
.tip-of-day {
    width: 480px;
    max-width: 90vw;
    overflow: hidden;
}

.tip-header {
    background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
    padding: 20px 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-radius: 24px 24px 0 0;
    position: relative;
}

.tip-icon {
    font-size: 36px;
    animation: tipGlow 2s ease-in-out infinite;
}

@keyframes tipGlow {
    0%, 100% { filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.5)); }
    50% { filter: drop-shadow(0 0 15px rgba(255, 255, 255, 0.8)); }
}

.tip-title {
    font-size: 1.4rem;
    color: white;
    margin: 0;
    font-family: 'Nunito', sans-serif;
    font-weight: 700;
    text-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.tip-close-btn {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    width: 32px;
    height: 32px;
    border: none;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.tip-close-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.tip-body {
    padding: 24px;
}

.tip-content {
    text-align: center;
}

.tip-emoji {
    font-size: 60px;
    margin-bottom: 16px;
    animation: tipEmojiBounce 1s ease-out;
}

@keyframes tipEmojiBounce {
    0% { transform: scale(0); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

.tip-name {
    font-size: 1.3rem;
    color: #1f2937;
    margin: 0 0 12px;
    font-family: 'Nunito', sans-serif;
    font-weight: 700;
}

.tip-description {
    color: #4b5563;
    line-height: 1.6;
    margin: 0 0 16px;
    font-family: 'Nunito', sans-serif;
    font-size: 0.95rem;
}

.tip-example {
    background: linear-gradient(135deg, #e0f2fe 0%, #bae6fd 100%);
    padding: 14px 18px;
    border-radius: 12px;
    margin-bottom: 12px;
    text-align: left;
    overflow-x: auto;
}

.tip-example strong {
    color: #0369a1;
    font-family: 'Nunito', sans-serif;
    display: block;
    margin-bottom: 8px;
}

.tip-example pre {
    margin: 0;
    padding: 0;
    background: transparent;
    overflow-x: auto;
}

.tip-example code {
    display: block;
    color: #0c4a6e;
    font-family: 'Fira Code', 'Courier New', monospace;
    font-size: 0.85rem;
    line-height: 1.6;
    white-space: pre-wrap;
    word-wrap: break-word;
    background: rgba(255, 255, 255, 0.5);
    padding: 8px 12px;
    border-radius: 6px;
    border-left: 3px solid #0369a1;
}

.tip-example p {
    margin: 6px 0 0;
    color: #0c4a6e;
    font-family: 'Nunito', sans-serif;
    font-size: 0.9rem;
}

.tip-fun-fact {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    padding: 14px 18px;
    border-radius: 12px;
    text-align: left;
}

.tip-fun-fact strong {
    color: #92400e;
    font-family: 'Nunito', sans-serif;
}

.tip-fun-fact p {
    margin: 6px 0 0;
    color: #78350f;
    font-family: 'Nunito', sans-serif;
    font-size: 0.9rem;
}

.tip-footer {
    padding: 16px 24px 24px;
    border-top: 1px solid #e5e7eb;
}

.tip-checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
    cursor: pointer;
    font-family: 'Nunito', sans-serif;
    font-size: 0.9rem;
    color: #6b7280;
}

.tip-checkbox-label input {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.tip-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
}

/* Tip highlight pulse animation for "Try It" */
.tip-highlight-pulse {
    animation: highlightPulse 0.5s ease-out 3;
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.5) !important;
}

@keyframes highlightPulse {
    0%, 100% { box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.5); }
    50% { box-shadow: 0 0 0 12px rgba(102, 126, 234, 0.2); }
}

/* Animations */
@keyframes modalBounceIn {
    0% { transform: scale(0.8); opacity: 0; }
    50% { transform: scale(1.02); }
    100% { transform: scale(1); opacity: 1; }
}

@keyframes tipSlideIn {
    0% { transform: translateY(-30px); opacity: 0; }
    100% { transform: translateY(0); opacity: 1; }
}

@keyframes tipFadeOut {
    0% { opacity: 1; transform: translateX(0); }
    100% { opacity: 0; transform: translateX(-20px); }
}

@keyframes tipFadeIn {
    0% { opacity: 0; transform: translateX(20px); }
    100% { opacity: 1; transform: translateX(0); }
}

/* Header Button Styles for Tour and Tip */
.header-btn-tour,
.nav-btn-tour {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
    color: white !important;
    border: none !important;
}

.header-btn-tour:hover,
.nav-btn-tour:hover {
    background: linear-gradient(135deg, #5a67d8 0%, #6b46c1 100%) !important;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.header-btn-tip,
.nav-btn-tip {
    background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%) !important;
    color: #78350f !important;
    border: none !important;
    animation: tipPulse 3s ease-in-out infinite;
}

.header-btn-tip:hover,
.nav-btn-tip:hover {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%) !important;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.4);
    animation: none;
}

@keyframes tipPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(251, 191, 36, 0.4); }
    50% { box-shadow: 0 0 0 8px rgba(251, 191, 36, 0); }
}

/* Responsive Onboarding */
@media (max-width: 768px) {
    .onboarding-modal-content.welcome-intro {
        width: 100%;
    }
    
    .welcome-header {
        padding: 20px 16px;
    }
    
    .welcome-logo {
        width: 50px;
    }
    
    .welcome-title {
        font-size: 1.4rem;
    }
    
    .welcome-body {
        padding: 16px;
    }
    
    .welcome-features {
        grid-template-columns: 1fr;
        gap: 8px;
    }
    
    .path-steps-row {
        gap: 6px;
    }
    
    .path-chip {
        padding: 4px 10px;
        font-size: 0.75rem;
    }
    
    .welcome-footer {
        flex-direction: column;
        padding: 16px;
        gap: 8px;
    }
    
    .tip-of-day {
        width: 100%;
    }
    
    .tip-emoji {
        font-size: 48px;
    }
}

/* Tooltip - must be above chat modal (10001) */
.walkthrough-tooltip {
    position: fixed;
    width: 380px;
    max-width: 90vw;
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    z-index: 10102;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    font-family: 'Nunito', sans-serif;
}

.walkthrough-tooltip.active {
    opacity: 1;
    visibility: visible;
}

.walkthrough-tooltip-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 12px 12px 0 0;
    color: white;
}

.walkthrough-step-indicator {
    font-size: 0.85rem;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.2);
    padding: 4px 10px;
    border-radius: 12px;
}

.walkthrough-close-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.walkthrough-close-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.walkthrough-title {
    margin: 0;
    padding: 16px 20px 8px;
    font-size: 1.2rem;
    color: #333;
    font-weight: 700;
}

.walkthrough-content {
    padding: 0 20px 16px;
    color: #555;
    font-size: 0.95rem;
    line-height: 1.6;
    max-height: 300px;
    overflow-y: auto;
}

.walkthrough-content p {
    margin: 0 0 10px;
}

.walkthrough-content ul, .walkthrough-content ol {
    margin: 8px 0;
    padding-left: 20px;
}

.walkthrough-content li {
    margin: 4px 0;
}

.walkthrough-content strong {
    color: #333;
}

.walkthrough-footer {
    padding: 12px 20px 16px;
    border-top: 1px solid #eee;
}

.walkthrough-controls {
    display: flex;
    gap: 10px;
    align-items: center;
    justify-content: center;
}

.walkthrough-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: 'Nunito', sans-serif;
}

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

.walkthrough-btn-primary {
    background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%);
    color: white;
    min-width: 100px;
}

.walkthrough-btn-primary:hover:not(:disabled) {
    background: linear-gradient(135deg, #45a049 0%, #3d8b40 100%);
    transform: translateY(-1px);
}

.walkthrough-btn-secondary {
    background: #f0f0f0;
    color: #555;
    min-width: 100px;
}

.walkthrough-btn-secondary:hover:not(:disabled) {
    background: #e0e0e0;
}

.walkthrough-btn-voice {
    background: #fff3e0;
    color: #ff9800;
    padding: 10px 14px;
    font-size: 1.1rem;
}

.walkthrough-btn-voice:hover {
    background: #ffe0b2;
}

.walkthrough-skip {
    text-align: center;
    margin-top: 12px;
}

.walkthrough-skip-btn {
    background: none;
    border: none;
    color: #999;
    font-size: 0.85rem;
    cursor: pointer;
    text-decoration: underline;
    font-family: 'Nunito', sans-serif;
}

.walkthrough-skip-btn:hover {
    color: #666;
}

/* Tour prompt modal */
.tour-prompt {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 10001;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease;
}

.tour-prompt-content {
    background: white;
    padding: 30px 40px;
    border-radius: 16px;
    text-align: center;
    max-width: 400px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.3s ease;
}

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

.tour-prompt-content h3 {
    margin: 0 0 12px;
    font-size: 1.5rem;
    color: #333;
}

.tour-prompt-content p {
    margin: 0 0 24px;
    color: #666;
    font-size: 1rem;
}

.tour-prompt-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.tour-prompt-btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: 'Nunito', sans-serif;
}

.tour-prompt-btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.tour-prompt-btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(102, 126, 234, 0.4);
}

.tour-prompt-btn-secondary {
    background: #f5f5f5;
    color: #666;
}

.tour-prompt-btn-secondary:hover {
    background: #eee;
}

/* Help/Tour button in header */
.help-btn {
    background: linear-gradient(135deg, #ff9800 0%, #f57c00 100%) !important;
    color: white !important;
    border: none !important;
    padding: 8px 16px !important;
    border-radius: 20px !important;
    font-weight: 600 !important;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.85rem !important;
}

.help-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(255, 152, 0, 0.4);
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .walkthrough-tooltip {
        width: 90vw;
        max-width: 340px;
    }
    
    .walkthrough-controls {
        flex-wrap: wrap;
    }
    
    .walkthrough-btn {
        padding: 8px 16px;
        font-size: 0.85rem;
    }
    
    .tour-prompt-content {
        padding: 24px;
        margin: 20px;
    }
}

/* ============================================
   GUIDED TUTORIAL SYSTEM - Kid-Friendly Styles
   ============================================ */

/* Main container */
.guided-tutorial-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 100000;
}

/* Speech bubble for guidance */
.tutorial-speech-bubble {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 600px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 20px;
    padding: 0;
    box-shadow: 0 10px 40px rgba(102, 126, 234, 0.4),
                0 0 0 4px rgba(255, 255, 255, 0.3);
    pointer-events: auto;
    z-index: 100001;
    animation: bubbleAppear 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.tutorial-speech-bubble.hidden {
    display: none;
}

@keyframes bubbleAppear {
    0% {
        opacity: 0;
        transform: translateX(-50%) translateY(30px) scale(0.9);
    }
    100% {
        opacity: 1;
        transform: translateX(-50%) translateY(0) scale(1);
    }
}

.tutorial-bubble-content {
    display: flex;
    align-items: flex-start;
    padding: 20px;
    gap: 15px;
}

.tutorial-mascot {
    font-size: 48px;
    animation: mascotBounce 2s ease-in-out infinite;
    flex-shrink: 0;
}

@keyframes mascotBounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

.tutorial-text-container {
    flex: 1;
}

.tutorial-text {
    color: white;
    font-size: 1rem;
    line-height: 1.7;
    font-family: 'Nunito', sans-serif;
    font-weight: 500;
    margin-bottom: 12px;
    max-height: 280px;
    overflow-y: auto;
    padding-right: 8px;
}

.tutorial-text strong {
    color: #fbbf24;
    font-weight: 700;
}

.tutorial-text br + br {
    display: block;
    margin-top: 8px;
    content: "";
}

.tutorial-progress {
    display: flex;
    align-items: center;
    gap: 12px;
}

#tutorial-step-count {
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.85rem;
    font-weight: 600;
    white-space: nowrap;
}

.tutorial-progress-bar {
    flex: 1;
    height: 8px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    overflow: hidden;
}

.tutorial-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #4ade80, #22c55e);
    border-radius: 4px;
    transition: width 0.5s ease;
    box-shadow: 0 0 10px rgba(74, 222, 128, 0.5);
}

.tutorial-bubble-controls {
    display: flex;
    justify-content: center;
    gap: 10px;
    padding: 15px 20px;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 0 0 20px 20px;
}

.tutorial-btn {
    padding: 10px 18px;
    border: none;
    border-radius: 12px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: 'Nunito', sans-serif;
    display: flex;
    align-items: center;
    gap: 6px;
}

.tutorial-voice-btn {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    font-size: 1.2rem;
    padding: 10px 14px;
}

.tutorial-voice-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.05);
}

.tutorial-hint-btn {
    background: #fbbf24;
    color: #92400e;
}

.tutorial-hint-btn:hover {
    background: #f59e0b;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(251, 191, 36, 0.4);
}

.tutorial-next-btn {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    font-weight: 600;
}

.tutorial-next-btn:hover {
    background: linear-gradient(135deg, #059669 0%, #047857 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
}

.tutorial-skip-btn {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

.tutorial-skip-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.tutorial-exit-btn {
    background: rgba(239, 68, 68, 0.8);
    color: white;
    padding: 10px 14px;
}

.tutorial-exit-btn:hover {
    background: #ef4444;
}

/* Floating pointer arrow */
.tutorial-pointer {
    position: fixed;
    z-index: 100002;
    pointer-events: none;
    animation: pointerBounce 1s ease-in-out infinite;
}

.tutorial-pointer.hidden {
    display: none;
}

.tutorial-pointer-arrow {
    font-size: 40px;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.3));
    animation: pointerPulse 1.5s ease-in-out infinite;
}

@keyframes pointerBounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-15px); }
}

@keyframes pointerPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.2); }
}

/* Dancing animation for toolbox categories and elements */
/* Animates the ACTUAL element, not an overlay */
.tutorial-dance {
    animation: tutorialDance 0.6s ease-in-out infinite !important;
}

/* Specific styling for Blockly toolbox rows - direct animation */
.blocklyTreeRow.tutorial-dance,
.blocklyToolboxDiv .blocklyTreeRow.tutorial-dance {
    animation: tutorialDance 0.6s ease-in-out infinite !important;
    background-color: rgba(255, 200, 0, 0.3) !important;
    border-radius: 8px !important;
    outline: 3px solid rgba(255, 165, 0, 0.8) !important;
    outline-offset: 2px !important;
}

@keyframes tutorialDance {
    0%, 100% { 
        transform: translateX(0) scale(1); 
    }
    25% { 
        transform: translateX(-4px) scale(1.02); 
    }
    50% {
        transform: translateX(0) scale(1.04);
    }
    75% { 
        transform: translateX(4px) scale(1.02); 
    }
}

/* Glowing effect for highlighted elements - no overlay, just box-shadow */
.tutorial-glow {
    box-shadow: 0 0 15px rgba(255, 200, 0, 0.9),
                0 0 30px rgba(255, 165, 0, 0.6),
                0 0 45px rgba(255, 140, 0, 0.4) !important;
    border-radius: 8px !important;
}

/* Specific glow for Blockly toolbox rows - bright orange/yellow glow */
.blocklyTreeRow.tutorial-glow,
.blocklyToolboxDiv .blocklyTreeRow.tutorial-glow {
    box-shadow: 0 0 10px rgba(255, 200, 0, 1),
                0 0 20px rgba(255, 165, 0, 0.8),
                0 0 30px rgba(255, 140, 0, 0.6) !important;
    border-radius: 8px !important;
    background-color: rgba(255, 200, 0, 0.25) !important;
}

/* NO ::before pseudo-element - we animate the actual element directly */

@keyframes glowPulse {
    0%, 100% { 
        box-shadow: 0 0 10px rgba(255, 200, 0, 0.8),
                    0 0 20px rgba(255, 165, 0, 0.5);
    }
    50% { 
        box-shadow: 0 0 20px rgba(255, 200, 0, 1),
                    0 0 40px rgba(255, 165, 0, 0.8);
    }
}

/* Flyout block animation - animates the actual SVG block */
.tutorial-flyout-block {
    animation: flyoutBlockDance 0.5s ease-in-out infinite !important;
    filter: drop-shadow(0 0 12px rgba(255, 200, 0, 1)) 
            drop-shadow(0 0 25px rgba(255, 165, 0, 0.8)) !important;
}

/* Highlight block for configuration step (typing text/numbers) */
.tutorial-highlight-block {
    animation: highlightBlockPulse 1s ease-in-out infinite !important;
    filter: drop-shadow(0 0 15px rgba(59, 130, 246, 1)) 
            drop-shadow(0 0 30px rgba(59, 130, 246, 0.8)) !important;
}

@keyframes highlightBlockPulse {
    0%, 100% { 
        filter: drop-shadow(0 0 15px rgba(59, 130, 246, 1)) 
                drop-shadow(0 0 30px rgba(59, 130, 246, 0.8));
    }
    50% {
        filter: drop-shadow(0 0 25px rgba(59, 130, 246, 1)) 
                drop-shadow(0 0 45px rgba(59, 130, 246, 0.9));
    }
}

/* SVG blocks in flyout - direct animation on the block itself */
g.blocklyDraggable.tutorial-flyout-block,
.blocklyFlyout g.blocklyDraggable.tutorial-flyout-block {
    animation: flyoutBlockDance 0.5s ease-in-out infinite !important;
    filter: drop-shadow(0 0 15px rgba(255, 200, 0, 1)) 
            drop-shadow(0 0 30px rgba(255, 165, 0, 0.9)) !important;
}

@keyframes flyoutBlockDance {
    0%, 100% { 
        transform: scale(1) translateY(0); 
    }
    50% { 
        transform: scale(1.06) translateY(-5px); 
    }
}

.tutorial-flyout-active {
    background: rgba(255, 200, 0, 0.1) !important;
}

/* Animated toolbox row - combined dance and pulse */
.blocklyTreeRow[data-tutorial-animated="true"] {
    animation: tutorialDance 0.6s ease-in-out infinite !important;
    outline: 3px solid rgba(255, 165, 0, 0.9) !important;
    outline-offset: 2px !important;
    background-color: rgba(255, 200, 0, 0.3) !important;
}

@keyframes tutorialPulse {
    0%, 100% {
        outline-color: rgba(102, 126, 234, 0.4);
        outline-offset: 0px;
    }
    50% {
        outline-color: rgba(102, 126, 234, 0.9);
        outline-offset: 4px;
    }
}

/* Celebration overlay */
.tutorial-celebration {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100010;
    pointer-events: auto;
}

.tutorial-celebration.hidden {
    display: none;
}

.celebration-content {
    text-align: center;
    padding: 40px;
    background: white;
    border-radius: 30px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: celebrationPop 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
    max-width: 90%;
    width: 400px;
}

@keyframes celebrationPop {
    0% {
        opacity: 0;
        transform: scale(0.5) rotate(-10deg);
    }
    100% {
        opacity: 1;
        transform: scale(1) rotate(0deg);
    }
}

.celebration-emoji {
    font-size: 80px;
    animation: celebrationBounce 1s ease-in-out infinite;
    margin-bottom: 20px;
}

@keyframes celebrationBounce {
    0%, 100% { transform: translateY(0) scale(1); }
    50% { transform: translateY(-20px) scale(1.1); }
}

.celebration-title {
    font-size: 2.5rem;
    font-weight: 800;
    background: linear-gradient(135deg, #667eea, #764ba2, #f093fb);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin: 0 0 10px;
    font-family: 'Nunito', sans-serif;
}

.celebration-text {
    font-size: 1.2rem;
    color: #666;
    margin: 0 0 30px;
    font-family: 'Nunito', sans-serif;
}

.celebration-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.celebration-btn {
    padding: 15px 30px;
    border: none;
    border-radius: 15px;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s;
    font-family: 'Nunito', sans-serif;
}

.celebration-btn.primary {
    background: linear-gradient(135deg, #4ade80 0%, #22c55e 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(74, 222, 128, 0.4);
}

.celebration-btn.primary:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(74, 222, 128, 0.5);
}

.celebration-btn.secondary {
    background: #f3f4f6;
    color: #374151;
}

.celebration-btn.secondary:hover {
    background: #e5e7eb;
    transform: translateY(-2px);
}

/* Confetti animation */
.confetti-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: hidden;
}

.confetti-piece {
    position: absolute;
    width: 12px;
    height: 12px;
    top: -20px;
    animation: confettiFall 4s linear infinite;
    border-radius: 2px;
}

@keyframes confettiFall {
    0% {
        top: -20px;
        transform: rotate(0deg) translateX(0);
        opacity: 1;
    }
    100% {
        top: 100%;
        transform: rotate(720deg) translateX(100px);
        opacity: 0;
    }
}

/* Tutorial start prompt */
.tutorial-start-prompt {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100005;
    pointer-events: auto;
    animation: fadeIn 0.3s ease;
}

.tutorial-start-prompt.hidden {
    display: none;
}

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

.tutorial-start-content {
    background: white;
    padding: 40px;
    border-radius: 24px;
    text-align: center;
    max-width: 90%;
    width: 420px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.tutorial-start-icon {
    font-size: 60px;
    margin-bottom: 20px;
    animation: iconWiggle 2s ease-in-out infinite;
}

@keyframes iconWiggle {
    0%, 100% { transform: rotate(-5deg); }
    50% { transform: rotate(5deg); }
}

.tutorial-start-content h3 {
    font-size: 1.5rem;
    color: #1f2937;
    margin: 0 0 12px;
    font-family: 'Nunito', sans-serif;
    font-weight: 700;
}

.tutorial-start-content p {
    font-size: 1rem;
    color: #6b7280;
    margin: 0 0 25px;
    line-height: 1.5;
    font-family: 'Nunito', sans-serif;
}

.tutorial-start-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.tutorial-start-btn {
    padding: 14px 28px;
    border: none;
    border-radius: 14px;
    font-size: 1.05rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s;
    font-family: 'Nunito', sans-serif;
}

.tutorial-start-btn.primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.tutorial-start-btn.primary:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.5);
}

.tutorial-start-btn.secondary {
    background: #f3f4f6;
    color: #374151;
}

.tutorial-start-btn.secondary:hover {
    background: #e5e7eb;
}

/* Toolbox category highlight for tutorial */
.blocklyTreeRow.tutorial-dance {
    background: linear-gradient(90deg, rgba(102, 126, 234, 0.2), rgba(118, 75, 162, 0.2)) !important;
    border-radius: 8px;
}

.blocklyTreeRow.tutorial-glow {
    box-shadow: 0 0 15px rgba(102, 126, 234, 0.6),
                inset 0 0 10px rgba(102, 126, 234, 0.2) !important;
}

/* Make sure tutorial elements are above everything */
.guided-tutorial-container * {
    font-family: 'Nunito', sans-serif;
}

/* Responsive styles for tutorial */
@media (max-width: 768px) {
    .tutorial-speech-bubble {
        bottom: 10px;
        width: 95%;
        max-width: none;
    }
    
    .tutorial-bubble-content {
        padding: 15px;
        gap: 10px;
    }
    
    .tutorial-mascot {
        font-size: 36px;
    }
    
    .tutorial-text {
        font-size: 1rem;
    }
    
    .tutorial-bubble-controls {
        flex-wrap: wrap;
        padding: 12px 15px;
    }
    
    .tutorial-btn {
        padding: 8px 14px;
        font-size: 0.85rem;
    }
    
    .celebration-content {
        padding: 30px 20px;
        width: 90%;
    }
    
    .celebration-emoji {
        font-size: 60px;
    }
    
    .celebration-title {
        font-size: 2rem;
    }
    
    .tutorial-start-content {
        padding: 30px 20px;
        width: 90%;
    }
}

/* Tutorial button in library items */
.library-tutorial-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
    color: white !important;
    border: none !important;
    padding: 8px 16px !important;
    border-radius: 8px !important;
    font-weight: 600 !important;
    cursor: pointer !important;
    transition: all 0.2s !important;
    font-size: 0.85rem !important;
    display: inline-flex !important;
    align-items: center !important;
    gap: 6px !important;
}

.library-tutorial-btn:hover {
    transform: translateY(-2px) !important;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4) !important;
}

/* Add sparkle effect to tutorial button */
.library-tutorial-btn::after {
    content: '✨';
    animation: sparkle 1.5s ease-in-out infinite;
}

@keyframes sparkle {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(1.2); }
}

/* ============================================
   FLOATING CHAT BUBBLE & MODAL
   ============================================ */

/* Floating Chat Bubble */
.chat-bubble {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(102, 126, 234, 0.5),
                0 2px 8px rgba(0, 0, 0, 0.2);
    z-index: 10000;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    user-select: none;
}

.chat-bubble:hover {
    transform: scale(1.1);
    box-shadow: 0 8px 35px rgba(102, 126, 234, 0.6),
                0 4px 15px rgba(0, 0, 0, 0.25);
}

.chat-bubble:active {
    transform: scale(0.95);
}

.chat-bubble.dragging {
    cursor: grabbing;
    transform: scale(1.05);
    box-shadow: 0 12px 45px rgba(102, 126, 234, 0.7),
                0 6px 20px rgba(0, 0, 0, 0.3);
}

.chat-bubble-icon {
    font-size: 22px;
    line-height: 1;
}

.chat-bubble-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 20px;
    height: 20px;
    background: #ef4444;
    color: white;
    font-size: 12px;
    font-weight: 700;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

/* Chat Modal - Resizable */
.chat-modal {
    position: fixed;
    bottom: 80px;
    right: 20px;
    width: 360px;
    height: 420px;
    min-width: 280px;
    min-height: 300px;
    max-width: calc(100vw - 48px);
    max-height: calc(100vh - 110px);
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.2),
                0 4px 20px rgba(102, 126, 234, 0.15);
    z-index: 10001;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: slideUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    resize: none; /* We handle resize manually */
}

.chat-modal.hidden {
    display: none;
}

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

/* Compact header */
.chat-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.chat-modal-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    font-size: 0.95rem;
    font-family: 'Nunito', sans-serif;
}

.chat-modal-title span:first-child {
    font-size: 1.1rem;
}

.chat-modal-controls {
    display: flex;
    gap: 4px;
}

.chat-modal-btn {
    width: 28px;
    height: 28px;
    border: none;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.chat-modal-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.05);
}

/* Resize handles */
.chat-resize-handle {
    position: absolute;
    background: transparent;
    z-index: 10;
}

.chat-resize-n {
    top: 0;
    left: 10px;
    right: 10px;
    height: 8px;
    cursor: n-resize;
}

.chat-resize-w {
    left: 0;
    top: 10px;
    bottom: 10px;
    width: 8px;
    cursor: w-resize;
}

.chat-resize-nw {
    top: 0;
    left: 0;
    width: 16px;
    height: 16px;
    cursor: nw-resize;
}

.chat-modal-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0; /* Important for flex children to shrink properly */
}

.chat-modal .chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    min-height: 0; /* Allow shrinking */
}

.chat-modal .ai-message,
.chat-modal .user-message {
    margin-bottom: 12px;
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 0.9rem;
    line-height: 1.5;
    font-family: 'Nunito', sans-serif;
}

.chat-modal .ai-message {
    background: linear-gradient(135deg, #f0f4ff 0%, #e8f0fe 100%);
    border-bottom-left-radius: 4px;
}

.chat-modal .user-message {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    margin-left: 20%;
    border-bottom-right-radius: 4px;
}

.chat-modal .ai-message p {
    margin: 0 0 8px;
}

.chat-modal .ai-message p:last-child {
    margin-bottom: 0;
}

.chat-modal .ai-message ul {
    margin: 8px 0;
    padding-left: 20px;
}

.chat-modal .ai-message li {
    margin: 4px 0;
    color: #4b5563;
}

.chat-modal-input {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid #e5e7eb;
    background: #f9fafb;
    flex-shrink: 0; /* Prevent input area from shrinking */
    margin-top: auto; /* Push to bottom */
}

.chat-modal-input textarea {
    flex: 1;
    padding: 10px 14px;
    border: 2px solid #e5e7eb;
    border-radius: 10px;
    font-size: 0.9rem;
    font-family: 'Nunito', sans-serif;
    resize: vertical;
    min-height: 40px;
    max-height: 120px;
    outline: none;
    transition: border-color 0.2s;
    line-height: 1.4;
}

.chat-modal-input textarea:focus {
    border-color: #667eea;
}

.chat-modal-send {
    width: 40px;
    height: 40px;
    padding: 0;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 10px;
    font-weight: 600;
    font-family: 'Nunito', sans-serif;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
    align-self: flex-end;
}

.chat-modal-send:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.chat-modal-send:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.chat-modal-send .send-icon {
    font-size: 1.3rem;
}

/* ============================================
   CHAT EXPLANATION CONTAINER
   Block explanation displayed inside chat modal
   ============================================ */

.chat-explanation-container {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    border: 2px solid #f59e0b;
    border-radius: 12px;
    margin: 0 12px 8px 12px;
    padding: 12px;
    box-shadow: 0 2px 8px rgba(245, 158, 11, 0.2);
}

.chat-explanation-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(245, 158, 11, 0.3);
}

.chat-explanation-header span {
    font-weight: 700;
    color: #92400e;
    font-size: 0.95rem;
}

.chat-explanation-close {
    background: none;
    border: none;
    color: #92400e;
    font-size: 1.1rem;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    transition: all 0.2s;
}

.chat-explanation-close:hover {
    background: rgba(146, 64, 14, 0.1);
}

.chat-explanation-content {
    color: #78350f;
    font-size: 0.9rem;
    line-height: 1.5;
    padding: 8px 0;
}

.chat-explanation-content strong {
    color: #92400e;
}

.chat-explanation-buttons {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px solid rgba(245, 158, 11, 0.3);
}

.chat-explanation-btn {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: white;
    border: none;
    padding: 8px 20px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s;
}

.chat-explanation-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 3px 10px rgba(245, 158, 11, 0.4);
}

.chat-explanation-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* ============================================
   LIBRARY MODAL
   ============================================ */

.library-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10002;
    display: flex;
    align-items: center;
    justify-content: center;
}

.library-modal.hidden {
    display: none;
}

.library-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.library-modal-content {
    position: relative;
    width: 90%;
    max-width: 800px;
    max-height: 85vh;
    background: white;
    border-radius: 24px;
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: modalSlideIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

.library-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid #e5e7eb;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
}

.library-modal-header h3 {
    margin: 0;
    font-size: 1.4rem;
    font-weight: 700;
    color: #1f2937;
    font-family: 'Nunito', sans-serif;
    display: flex;
    align-items: center;
    gap: 10px;
}

.library-modal-close {
    width: 40px;
    height: 40px;
    border: none;
    background: #f3f4f6;
    color: #6b7280;
    border-radius: 12px;
    cursor: pointer;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.library-modal-close:hover {
    background: #e5e7eb;
    color: #374151;
    transform: scale(1.05);
}

.library-modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px 24px;
}

.library-modal-body .library-subtitle {
    margin: 0 0 16px;
    color: #6b7280;
    font-size: 0.95rem;
    font-family: 'Nunito', sans-serif;
}

.library-modal-body .library-filters {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.library-modal-body .library-filter-select {
    flex: 1;
    min-width: 150px;
    padding: 10px 14px;
    border: 2px solid #e5e7eb;
    border-radius: 10px;
    font-size: 0.9rem;
    font-family: 'Nunito', sans-serif;
    background: white;
    cursor: pointer;
    transition: border-color 0.2s;
}

.library-modal-body .library-filter-select:focus {
    outline: none;
    border-color: #667eea;
}

.library-modal-body .library-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
    max-height: calc(85vh - 250px);
    overflow-y: auto;
    padding-right: 8px;
}

/* ============================================
   TOOLBAR LIBRARY BUTTON
   ============================================ */

.library-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
    color: white !important;
    border: none !important;
}

.library-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4) !important;
}

/* ============================================
   RESPONSIVE ADJUSTMENTS
   ============================================ */

@media (max-width: 768px) {
    .chat-bubble {
        width: 44px;
        height: 44px;
        bottom: 14px;
        right: 14px;
    }
    
    .chat-bubble-icon {
        font-size: 20px;
    }
    
    .chat-modal {
        bottom: 70px;
        right: 14px;
        width: calc(100vw - 28px);
        max-height: calc(100vh - 100px);
    }
    
    .library-modal-content {
        width: 95%;
        max-height: 90vh;
        border-radius: 16px;
    }
    
    .library-modal-body .library-list {
        grid-template-columns: 1fr;
    }
}

/* Hide left panel when using floating chat */
.left-panel.hidden,
.panel-resize-handle.hidden {
    display: none !important;
}

/* Adjust center panel when left panel is hidden */
.main-content:has(.left-panel.hidden) .center-panel {
    flex: 1;
}

/* Modal Library Items */
.modal-library-item {
    background: white;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    padding: 14px 16px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 10px;
}

.modal-library-item:hover {
    border-color: #667eea;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.15);
    transform: translateY(-2px);
}

.modal-library-item .lib-level {
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 700;
    color: white;
}

.modal-library-item .lib-lang {
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    color: white;
}

.modal-library-item .lib-name {
    flex: 1;
    font-weight: 600;
    color: #1f2937;
    font-family: 'Nunito', sans-serif;
}

.modal-library-item .lib-tutorial-btn,
.modal-library-item .lib-help-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: #f3f4f6;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.modal-library-item .lib-tutorial-btn:hover {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.modal-library-item .lib-help-btn:hover {
    background: #e5e7eb;
}

/* Loading state in modal */
.library-modal-body .library-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 40px;
    color: #6b7280;
    font-family: 'Nunito', sans-serif;
}

.library-modal-body .empty-state-small {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    color: #6b7280;
    font-family: 'Nunito', sans-serif;
}
