/* MyAI Tutor Main Styles */

/* Enhanced Result Formatting Styles */
.formatted-content {
    text-align: justify;
    text-justify: inter-word;
    line-height: 1.4;
    word-wrap: break-word;
    overflow-wrap: break-word;
    white-space: normal;
}

/* Index page: professional UI polish (scoped) */
.auth-container {
  /* Layout */
  width: 100%;
  max-width: 400px;
  margin: 0 auto;
  padding: 10px; /* compact to help fit 100dvh */
}

/* Brand logo sizing */
.auth-container .logo {
  width: 72px;
  height: auto;
}

.auth-container .welcome-banner,
.auth-container .tab-content {
  border: 1px solid #e5e7eb !important; /* subtle card border */
  border-radius: 12px !important;
}

/* Typography hierarchy */
.auth-container .welcome-title { line-height: 1.2 !important; letter-spacing: 0.2px; }
.auth-container .welcome-subtitle { line-height: 1.35 !important; color: #4b5563 !important; }
.auth-container .form-group label { color: #374151 !important; line-height: 1.25; }

/* Inputs */
.auth-container .form-group input,
.auth-container .form-group select,
.auth-container .form-group textarea {
  height: 42px;
  padding: 10px 12px !important;
  border: 1px solid #d1d5db !important;
  border-radius: 10px !important;
  background: #fff !important;
  color: #111827 !important;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.auth-container .form-group textarea { height: auto; min-height: 90px; }
.auth-container .form-group input::placeholder { color: #9ca3af; }
.auth-container .form-group input:focus,
.auth-container .form-group select:focus,
.auth-container .form-group textarea:focus {
  outline: none !important;
  border-color: #1d4ed8 !important; /* deeper blue */
  box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.20) !important; /* refined blue ring */
}

/* Buttons & tabs – keep violet theme but refine states */
.auth-container .tab-btn,
.auth-container button[type="submit"],
.auth-container button[type="button"],
.auth-container .btn-primary,
.auth-container .btn-secondary {
  border-radius: 10px !important;
  font-weight: 600 !important;
  line-height: 1.1 !important;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.auth-container .tab-btn:hover,
.auth-container button[type="submit"]:hover,
.auth-container button[type="button"]:hover { transform: translateY(-1px); }
.auth-container .tab-btn:active,
.auth-container button[type="submit"]:active,
.auth-container button[type="button"]:active { transform: translateY(0); }
.auth-container .tab-btn:focus-visible,
.auth-container button[type="submit"]:focus-visible,
.auth-container button[type="button"]:focus-visible {
  outline: 2px solid #93c5fd; /* light blue */
  outline-offset: 2px;
}
.auth-container button[disabled],
.auth-container .tab-btn[disabled] {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Tabs container spacing */
.auth-container .tabs { gap: 8px !important; margin: 8px 0 !important; }
.auth-container .tab-btn { min-height: 38px !important; }

/* Messages spacing and polish */
.auth-container .message { border-radius: 10px !important; padding: 10px 12px !important; }
.auth-container .message + .message { margin-top: 6px; }

/* Micro spacing using 8px rhythm */
.auth-container .form-group { margin: 8px 0 !important; }
.auth-container p { margin: 6px 0 !important; }

/* Ensure fit within 100dvh layout: keep key blocks compact */
@media (max-width: 768px) {
  .auth-container .logo { width: 60px !important; height: auto; }
  .auth-container .welcome-banner { padding: 8px !important; }
  .auth-container .tab-content { padding: 8px !important; }
}
/* Force AI Tutor panel text/content to start at top on mobile */
@media (max-width: 768px) {
  .ai-tutor-panel .panel-content {
    justify-content: flex-start !important;
    align-items: flex-start !important;
    text-align: left !important;
    min-height: auto !important;
    gap: 0.5rem !important;
    padding-top: 0.25rem !important;
  }
  .ai-tutor-panel .panel-center {
    justify-content: flex-start !important;
    align-items: flex-start !important;
    text-align: left !important;
    padding: 0 0.5rem !important;
  }
}

@media (max-width: 480px) {
  .ai-tutor-panel .panel-content {
    gap: 0.4rem !important;
    padding-top: 0.2rem !important;
  }
}

/* Prefer small viewport unit when supported to account for browser UI (iOS/Android) */
@media (max-width: 768px) {
    @supports (height: 100svh) {
        .container {
            height: calc(100svh - 48px);
        }
        .tab-content {
            height: calc(100svh - 48px - 72px);
        }
        #subject-content {
            height: calc(100svh - 48px - 72px);
        }
    }
}

/* Subject tab mobile-first layout */
@media (max-width: 768px) {
  #subject-content .tab-main-content {
    padding: 0.5rem 0.5rem 0.25rem;
  }
  .subjects-container {
    padding: 0.25rem 0.25rem 0;
  }
  .subjects-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
  }
  .subjects-grid .subject-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 48px; /* >=44px tap target */
    padding: 0.5rem 0.6rem;
    font-size: 0.95rem;
    line-height: 1.1;
    border-radius: 10px;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
  }
  .subjects-grid .subject-btn span,
  .subjects-grid .subject-btn i {
    pointer-events: none;
  }
}

@media (max-width: 480px) {
  .subjects-grid { gap: 0.45rem; }
  .subjects-grid .subject-btn {
    min-height: 46px;
    font-size: 0.9rem;
    padding: 0.45rem 0.55rem;
  }
}

/* Extra compact rules for short landscape phones */
@media (max-width: 768px) and (orientation: landscape) and (max-height: 420px) {
    .ai-tutor-panel {
        margin: 0.25rem 0.4rem;
        padding: 0.35rem 0.35rem;
    }
    .panel-title {
        font-size: 0.95rem !important;
    }
    .ai-tutor-panel .panel-title {
        font-size: 0.9rem !important;
    }
    .ai-tutor-panel .panel-subtitle {
        font-size: 0.8rem !important;
    }
    .robot-icon { font-size: 0.9rem !important; }
    .subjects-container { padding: 0.5rem 0.4rem; }
    .subjects-grid { gap: 0.4rem; }
}

/* Answer content styling */
.answer-content {
    line-height: 1.3;
    text-align: justify;
    text-justify: inter-word;
}

/* Center subscription/trial notice in search tab */
#subscriptionNotice {
  width: 100%;
}
#subscriptionNotice .free-trial-notification {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
  text-align: center;
  flex-wrap: wrap;
}

/* Make search tab header compact */
#search-content .search-only-area { padding: 0.5rem 0.75rem 0.25rem; }
#search-content .search-welcome { text-align: center; }
#search-content .search-welcome h2 { margin: 0.25rem 0 0.15rem; font-size: 1.05rem; }
#search-content .search-welcome p { margin: 0; font-size: 0.9rem; color: #556; }
/* Ensure welcome message text is justified for better readability */
#search-content #welcomeMessage { 
  text-align: justify; 
  text-justify: inter-word; 
}
/* Compact input area */
#search-content .input-container { padding: 0.5rem 0.75rem 0.5rem; }
#search-content .input-group { gap: 0.4rem; }
#search-content #questionInput { min-height: 28px; line-height: 1.25; font-size: 0.95rem; padding: 6px 8px; }
#search-content .input-buttons-right { gap: 0.3rem; }

@media (max-width: 768px) {
  #search-content .search-only-area { padding: 0.4rem 0.6rem 0.2rem; }
  #search-content .search-welcome h2 { font-size: 1rem; }
  #search-content .search-welcome p { font-size: 0.85rem; }
  #search-content .input-container { padding: 0.4rem 0.6rem 0.4rem; }
  #search-content #questionInput { font-size: 0.9rem; padding: 6px 8px; }
}

@media (max-width: 480px) {
  #search-content .search-only-area { padding: 0.35rem 0.5rem 0.15rem; }
  #search-content .search-welcome h2 { font-size: 0.95rem; }
  #search-content .search-welcome p { font-size: 0.8rem; }
  #search-content .input-container { padding: 0.35rem 0.5rem; }
  #search-content #questionInput { font-size: 0.88rem; padding: 5px 7px; min-height: 26px; }
}

/* Bottom tabs fixed with safe-area support */
@media (max-width: 768px) {
  .bottom-tabs {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    height: 74px;
    padding-bottom: max(env(safe-area-inset-bottom, 0px), 0px);
    background: rgba(255,255,255,0.98);
    backdrop-filter: blur(10px);
    border-top: 1px solid #e2e8f0;
    z-index: 1500;
  }
  .tab-content { 
    padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px));
  }
}

/* Mobile: sticky All Results header and full-height results list (override inline with !important) */
@media (max-width: 768px) {
  #resultHeader {
    display: block !important;
    position: fixed !important;
    top: env(safe-area-inset-top, 0px) !important;
    left: 0 !important;
    right: 0 !important;
    z-index: 1000 !important;
    height: 48px !important;
    padding: 0.5rem 0.9rem !important;
    background: #ffffff !important;
    border-bottom: 1px solid #e2e8f0 !important;
  }
  #resultMessages {
    position: fixed !important;
    top: calc(48px + env(safe-area-inset-top, 0px)) !important;
    left: 0 !important;
    right: 0 !important;
    bottom: calc(74px + env(safe-area-inset-bottom, 0px)) !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    background: #f8fafc !important;
  }
  
  /* Keep bottom tabs visible even when on the results tab */
  body.result-tab-active .bottom-tabs {
    display: flex !important;
  }
}

/* Force result action buttons into a single row */
#resultMessages .result-actions,
#resultMessages .action-buttons,
#resultMessages .actions,
#resultMessages .btn-group,
#resultMessages .actions-container {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.4rem;
}
#resultMessages .result-actions > *,
#resultMessages .action-buttons > *,
#resultMessages .actions > *,
#resultMessages .btn-group > *,
#resultMessages .actions-container > * {
  white-space: nowrap;
}

.answer-content p {
    margin: 0.4rem 0;
    line-height: 1.3;
}

.answer-content br {
    line-height: 1.3;
}

/* Code Block Styling */
.code-block {
    background: #1e293b;
    color: #e2e8f0;
    padding: 1rem;
    border-radius: 8px;
    margin: 1rem 0;
    overflow-x: auto;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.9rem;
    line-height: 1.5;
    border: 1px solid #374151;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    position: relative;
}

.code-block::before {
    content: 'Code';
    position: absolute;
    top: -10px;
    left: 12px;
    background: #1e293b;
    color: #94a3b8;
    padding: 2px 8px;
    font-size: 0.75rem;
    border-radius: 4px;
    border: 1px solid #374151;
}

.code-block pre {
    margin: 0;
    white-space: pre-wrap;
    word-wrap: break-word;
}

/* Inline Code Styling */
.inline-code {
    background: #f1f5f9;
    color: #1e293b;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.9em;
    border: 1px solid #e2e8f0;
}

/* Math Formula Container */
.math-formula {
    background: #ffffff;
    border: 2px solid #d8b4fe;
    border-radius: 8px;
    padding: 1.5rem 1rem 1rem 1rem;
    margin: 1rem 0;
    text-align: center;
    font-family: 'Times New Roman', serif;
    font-size: 1.1rem;
    position: relative;
    box-shadow: 0 2px 8px rgba(139, 92, 246, 0.1);
    color: #000000;
    overflow: hidden;
}

.math-formula::before {
    position: absolute;
    top: 4px;
    left: 8px;
    background: #fef7ff;
    color: #7c3aed;
    padding: 2px 8px;
    font-size: 0.75rem;
    border-radius: 4px;
    font-weight: 600;
    z-index: 1;
}

/* Math Equation Container */
.math-equation {
    background: #ffffff;
    border: 2px solid #7dd3fc;
    border-radius: 8px;
    padding: 1.5rem 1rem 1rem 1rem;
    margin: 1rem 0;
    text-align: center;
    font-family: 'Times New Roman', serif;
    font-size: 1.1rem;
    position: relative;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.1);
    color: #000000;
    overflow: hidden;
}

.math-equation::before {
    content: '🧮 Equation';
    position: absolute;
    top: 4px;
    left: 8px;
    background: #f0f9ff;
    color: #0369a1;
    padding: 2px 8px;
    font-size: 0.75rem;
    border-radius: 4px;
    font-weight: 600;
    z-index: 1;
}

/* Step-by-step Solution Container */
.solution-steps {
    background: #f0fdf4;
    border: 2px solid #86efac;
    border-radius: 8px;
    padding: 1rem;
    margin: 1rem 0;
    position: relative;
    box-shadow: 0 2px 8px rgba(34, 197, 94, 0.1);
}

.solution-steps::before {
    content: '📝 Solution Steps';
    position: absolute;
    top: -12px;
    left: 12px;
    background: #f0fdf4;
    color: #059669;
    padding: 2px 8px;
    font-size: 0.75rem;
    border-radius: 4px;
    font-weight: 600;
}

.solution-step {
    margin: 0.8rem 0;
    padding: 0.5rem;
    border-left: 3px solid #10b981;
    background: rgba(16, 185, 129, 0.05);
    border-radius: 0 4px 4px 0;
}

.step-number {
    font-weight: 700;
    color: #059669;
    margin-right: 0.5rem;
}

/* Definition/Concept Box */
.definition-box {
    background: #fffbeb;
    border: 2px solid #fbbf24;
    border-radius: 8px;
    padding: 1rem;
    margin: 1rem 0;
    position: relative;
    box-shadow: 0 2px 8px rgba(245, 158, 11, 0.1);
}

.definition-box::before {
    content: '💡 Definition';
    position: absolute;
    top: -12px;
    left: 12px;
    background: #fffbeb;
    color: #d97706;
    padding: 2px 8px;
    font-size: 0.75rem;
    border-radius: 4px;
    font-weight: 600;
}

/* Important Note Container */
.important-note {
    background: #fef2f2;
    border: 2px solid #fca5a5;
    border-radius: 8px;
    padding: 1rem;
    margin: 1rem 0;
    position: relative;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.1);
}

.important-note::before {
    content: '⚠️ Important';
    position: absolute;
    top: -12px;
    left: 12px;
    background: #fef2f2;
    color: #dc2626;
    padding: 2px 8px;
    font-size: 0.75rem;
    border-radius: 4px;
    font-weight: 600;
}

/* Table Styling */
.formatted-table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.formatted-table th {
    background: #374151;
    color: white;
    padding: 0.75rem;
    text-align: left;
    font-weight: 600;
}

.formatted-table td {
    padding: 0.75rem;
    border-bottom: 1px solid #e5e7eb;
}

.formatted-table tr:nth-child(even) {
    background: #f9fafb;
}



/* Quote/Example Container */
.example-box {
    background: #f8fafc;
    border-left: 4px solid #64748b;
    padding: 1.5rem 1rem 1rem 1rem;
    margin: 1rem 0;
    font-style: italic;
    border-radius: 0 8px 8px 0;
    position: relative;
    overflow: hidden;
}

.example-box::before {
    content: '📋 Example';
    position: absolute;
    top: 4px;
    left: 8px;
    background: #f8fafc;
    color: #475569;
    padding: 2px 8px;
    font-size: 0.75rem;
    border-radius: 4px;
    font-weight: 600;
    font-style: normal;
    z-index: 1;
}

/* Responsive Design */
@media (max-width: 768px) {
    .code-block {
        font-size: 0.8rem;
        padding: 0.75rem;
    }
    
    .math-formula, .math-equation {
        font-size: 1rem;
        padding: 0.75rem;
    }
    
    .formatted-table {
        font-size: 0.9rem;
    }
    
    .formatted-table th,
    .formatted-table td {
        padding: 0.5rem;
    }
}

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

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

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

@keyframes gradientShift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(-10px);
    }
    60% {
        transform: translateY(-5px);
    }
}

.results-tab-btn.active {
    color: white !important;
    border-bottom-color: #ffd700 !important;
    background: rgba(255,255,255,0.2) !important;
}

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

html {
    overflow-x: hidden;
}

body {
    overflow-x: hidden;
    width: 100%;
    max-width: 100vw;
    position: relative;
}

html {
    font-size: 20px;
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
    height: 100%;
    height: 100vh;
    height: 100dvh;
    height: -webkit-fill-available;
}

body {
    height: 100dvh;
    height: -webkit-fill-available;
    overflow: hidden;
    user-select: none;
    position: relative;
    -webkit-tap-highlight-color: transparent;
    margin: 0;
    padding: 0;
}

.header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 3rem 2rem;
    position: relative;
    overflow: hidden;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 100%;
}

.header-text {
    text-align: center;
    flex: 1;
}

.header h1 {
    font-size: 0.85rem;
    font-weight: 700;
    margin: 0 0 0.5rem 0;
    text-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.header p {
    font-size: 1.5rem;
    opacity: 0.9;
    margin: 0;
}

.header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.1);
    pointer-events: none;
}

.site-header {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-top: 1px solid #e2e8f0;
    position: fixed;
    bottom: 0;
    z-index: 2000;
    width: 100%;
    overflow: visible;
    box-sizing: border-box;
    height: 48px;
    min-height: 48px;
}

.wrap {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 48px;
    width: 100%;
    box-sizing: border-box;
    position: relative;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    color: #1e293b;
    font-weight: 700;
    font-size: 0.8rem;
}

.brand img {
    width: 18px;
    height: 18px;
    border-radius: 8px;
}

/* Ensure brand text size on all views */
.site-header .brand span {
    font-size: 0.8rem;
}

.nav {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    position: absolute;
    right: 1rem;
    top: 0.5rem;
    z-index: 10;
}

/* Desktop Navigation - Always Visible */
@media (min-width: 769px) {
    .nav {
        display: flex !important;
        position: absolute !important;
        right: 1rem !important;
        top: 0.5rem !important;
        background: none !important;
        border: none !important;
        padding: 0 !important;
        transform: none !important;
        opacity: 1 !important;
        visibility: visible !important;
        flex-direction: row !important;
        gap: 1.5rem !important;
    }
    
    .nav a {
        padding: 0.5rem 1rem !important;
        border: none !important;
        background: rgba(102, 126, 234, 0.1);
        border-radius: 8px;
        transition: all 0.3s ease;
    }
    
    .nav a:hover {
        background: rgba(102, 126, 234, 0.2);
        transform: translateY(-1px);
    }
    
    .menu-toggle {
        display: none !important;
    }
}

.nav a {
    color: #64748b;
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9rem;
    transition: color 0.3s ease;
}

.nav a:hover {
    color: #667eea;
}

.menu-toggle {
    display: none;
    flex-direction: column;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
}

.menu-toggle span {
    width: 20px;
    height: 2px;
    background: #64748b;
    margin: 2px 0;
    transition: 0.3s;
}

/* Mobile Navigation Styles */
@media (max-width: 768px) {
    .site-header {
        overflow: visible;
        position: relative;
    }
    
    .wrap {
        flex-wrap: nowrap;
        min-height: 48px;
        height: 44px;
        padding: 0 1rem;
        justify-content: space-between;
        align-items: center;
    }
    
    .menu-toggle {
        display: flex;
        order: 2;
        z-index: 1001;
        margin-left: auto;
        padding: 0.4rem; /* tighter for smaller header */
    }
    
    .brand {
        order: 1;
        flex-shrink: 0;
    }
    
    .nav {
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: rgba(255, 255, 255, 0.98);
        backdrop-filter: blur(10px);
        border-top: 1px solid #e2e8f0;
        border-bottom: 1px solid #e2e8f0;
        flex-direction: column;
        gap: 0;
        padding: 0;
        transform: translateY(-100%);
        opacity: 0;
        visibility: hidden;
        transition: all 0.3s ease;
        z-index: 1000;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
        max-height: 0;
        overflow: hidden;
    }
    
    .nav.open {
        transform: translateY(0);
        opacity: 1;
        visibility: visible;
        max-height: 200px;
    }
    
    .nav a {
        padding: 1rem 1.5rem;
        border-bottom: 1px solid #f1f5f9;
        display: block;
        width: 100%;
        text-align: left;
        color: #1e293b;
        font-weight: 600;
        font-size: 1rem;
        box-sizing: border-box;
        background: white;
    }
    
    .nav a:last-child {
        border-bottom: none;
    }
    
    .nav a:hover {
        background: rgba(102, 126, 234, 0.1);
        color: #667eea;
    }
}

.user-info {
    display: flex;
    align-items: center;
    gap: 2rem;
    position: absolute;
    top: 0.5rem;
    right: 2rem;
}

.user-mobile {
    font-size: 0.9rem;
    opacity: 0.9;
    color: white;
    text-decoration: none;
    padding: 0.25rem 0.5rem;
    border-radius: 6px;
    transition: all 0.3s ease;
    cursor: pointer;
}

.user-mobile:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-1px);
}

.logout-btn {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.3s ease;
}

.logout-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.5);
}

.free-trial-btn {
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 12px;
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 600;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    backdrop-filter: blur(10px);
    position: relative;
    overflow: hidden;
    z-index: 10;
}

.free-trial-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.5);
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
}

.free-trial-btn:active {
    transform: translateY(0);
}

.profile-btn {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    height: 40px;
}

.profile-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.5);
    transform: translateY(-1px);
}

.profile-icon {
    width: 40px;
    height: 40px;
    background: rgba(255,255,255,0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid transparent;
}

.profile-icon:hover {
    background: rgba(255,255,255,0.3);
    border-color: rgba(255,255,255,0.5);
    transform: scale(1.05);
}

.profile-icon svg {
    width: 20px;
    height: 20px;
    fill: white;
}

.subjects-container {
    padding: 2rem 0.5rem 1rem 0.5rem;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border-bottom: 1px solid #e2e8f0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    flex-shrink: 0;
    display: flex;
    justify-content: center;
    align-items: center;
}

.subjects-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
    box-sizing: border-box;
    padding: 0 0.5rem;
}

/* Mobile Subjects Grid */
@media (max-width: 480px) {
    .subjects-container {
        padding: 1rem 0.5rem;
    }
    
    .subjects-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
        padding: 0 0.5rem;
    }
}

.subject-btn {
    background: white;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    padding: 0.75rem 0.5rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    font-weight: 600;
    font-size: 0.9rem;
    color: #374151;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 65px;
    position: relative;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Mobile Subject Buttons */
@media (max-width: 768px) {
    .subject-btn {
        padding: 0.75rem 0.5rem;
        font-size: 0.9rem;
        min-height: 70px;
    }
}

@media (max-width: 480px) {
    .subject-btn {
        padding: 0.6rem 0.4rem;
        font-size: 0.75rem;
        min-height: 60px;
        border-radius: 8px;
    }
    
    /* Mobile Panel Typography */
    .ai-tutor-panel .panel-title {
        font-size: 1.2rem !important;
        margin-bottom: 0.6rem;
        line-height: 1.2;
        text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
    }
    
    .ai-tutor-panel .panel-subtitle {
        font-size: 0.9rem !important;
        margin-bottom: 0.8rem;
        line-height: 1.3;
        opacity: 0.95;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
    }
    
    .ai-tutor-panel .panel-bsubtitle {
        font-size: 0.7rem !important;
        margin-top: 0.8rem;
        text-align: center;
        line-height: 1.4;
        opacity: 0.8;
    }
    
    .feature-badge {
        font-size: 0.7rem !important;
        padding: 0.3rem 0.7rem !important;
        border-radius: 15px;
        backdrop-filter: blur(15px);
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    }
}

.subject-btn:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 12px 35px rgba(0, 0, 0, 0.25);
    filter: brightness(1.1);
}

.subject-btn.active {
    transform: translateY(-4px) scale(1.05);
    box-shadow: 
        0 15px 40px rgba(0, 0, 0, 0.4),
        0 0 30px rgba(99, 102, 241, 0.5),
        inset 0 2px 10px rgba(255, 255, 255, 0.3);
    filter: brightness(1.3) saturate(1.2);
    border-width: 3px;
    animation: pulseGlow 2s ease-in-out infinite alternate;
}

/* Enhanced shadow effects for each subject when active */
.subject-btn.active[data-subject="general"] {
    box-shadow: 
        0 15px 40px rgba(99, 102, 241, 0.6),
        0 0 30px rgba(99, 102, 241, 0.8),
        inset 0 2px 10px rgba(255, 255, 255, 0.3);
}

.subject-btn.active[data-subject="mathematics"] {
    box-shadow: 
        0 15px 40px rgba(239, 68, 68, 0.6),
        0 0 30px rgba(239, 68, 68, 0.8),
        inset 0 2px 10px rgba(255, 255, 255, 0.3);
}

.subject-btn.active[data-subject="physics"] {
    box-shadow: 
        0 15px 40px rgba(59, 130, 246, 0.6),
        0 0 30px rgba(59, 130, 246, 0.8),
        inset 0 2px 10px rgba(255, 255, 255, 0.3);
}

.subject-btn.active[data-subject="chemistry"] {
    box-shadow: 
        0 15px 40px rgba(16, 185, 129, 0.6),
        0 0 30px rgba(16, 185, 129, 0.8),
        inset 0 2px 10px rgba(255, 255, 255, 0.3);
}

.subject-btn.active[data-subject="biology"] {
    box-shadow: 
        0 15px 40px rgba(34, 197, 94, 0.6),
        0 0 30px rgba(34, 197, 94, 0.8),
        inset 0 2px 10px rgba(255, 255, 255, 0.3);
}

.subject-btn.active[data-subject="english"] {
    box-shadow: 
        0 15px 40px rgba(139, 92, 246, 0.6),
        0 0 30px rgba(139, 92, 246, 0.8),
        inset 0 2px 10px rgba(255, 255, 255, 0.3);
}

.subject-btn.active[data-subject="hindi"] {
    box-shadow: 
        0 15px 40px rgba(245, 158, 11, 0.6),
        0 0 30px rgba(245, 158, 11, 0.8),
        inset 0 2px 10px rgba(255, 255, 255, 0.3);
}

.subject-btn.active[data-subject="urdu"] {
    box-shadow: 
        0 15px 40px rgba(6, 182, 212, 0.6),
        0 0 30px rgba(6, 182, 212, 0.8),
        inset 0 2px 10px rgba(255, 255, 255, 0.3);
}

.subject-btn.active[data-subject="geography"] {
    box-shadow: 
        0 15px 40px rgba(132, 204, 22, 0.6),
        0 0 30px rgba(132, 204, 22, 0.8),
        inset 0 2px 10px rgba(255, 255, 255, 0.3);
}

.subject-btn.active[data-subject="computer-science"] {
    box-shadow: 
        0 15px 40px rgba(100, 116, 139, 0.6),
        0 0 30px rgba(100, 116, 139, 0.8),
        inset 0 2px 10px rgba(255, 255, 255, 0.3);
}

/* Pulse glow animation for active buttons */
@keyframes pulseGlow {
    0% {
        filter: brightness(1.3) saturate(1.2);
    }
    100% {
        filter: brightness(1.5) saturate(1.4);
    }
}

/* Individual subject button colors */
.subject-btn[data-subject="general"] {
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    color: white;
    border-color: #6366f1;
}

.subject-btn[data-subject="mathematics"] {
    background: linear-gradient(135deg, #ef4444 0%, #f97316 100%);
    color: white;
    border-color: #ef4444;
}

.subject-btn[data-subject="physics"] {
    background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
    color: white;
    border-color: #3b82f6;
}

.subject-btn[data-subject="chemistry"] {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    border-color: #10b981;
}

.subject-btn[data-subject="biology"] {
    background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
    color: white;
    border-color: #22c55e;
}

.subject-btn[data-subject="english"] {
    background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
    color: white;
    border-color: #8b5cf6;
}

.subject-btn[data-subject="hindi"] {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: white;
    border-color: #f59e0b;
}

.subject-btn[data-subject="urdu"] {
    background: linear-gradient(135deg, #06b6d4 0%, #0891b2 100%);
    color: white;
    border-color: #06b6d4;
}

.subject-btn[data-subject="geography"] {
    background: linear-gradient(135deg, #84cc16 0%, #65a30d 100%);
    color: white;
    border-color: #84cc16;
}

.subject-btn[data-subject="computer-science"] {
    background: linear-gradient(135deg, #64748b 0%, #475569 100%);
    color: white;
    border-color: #64748b;
}

.ai-tutor-panel {
    /* Multicolor animated gradient */
    background: linear-gradient(135deg,
        #ff7eb3 0%,
        #ff758c 10%,
        #ff7eb3 20%,
        #667eea 30%,
        #764ba2 40%,
        #667eea 50%,
        #ff758c 60%,
        #ff7eb3 70%,
        #667eea 80%,
        #764ba2 90%,
        #ff7eb3 100%);
    background-size: 400% 400%;
    animation: gradientShift 8s ease infinite;
    padding: 1.5rem 1rem;
    margin: 1rem 0.5rem;
    border-radius: 16px;
    position: relative;
    overflow: hidden;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.25);
    width: calc(100% - 1rem);
    box-sizing: border-box;
    /* Mobile touch optimization */
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    flex-shrink: 0;
}

/* Mobile AI Tutor Panel */
@media (max-width: 768px) {
    .ai-tutor-panel {
        margin: 0.5rem 0.5rem 0.25rem 0.5rem;
        padding: 0.5rem 0.5rem;
        border-radius: 16px;
        width: calc(100% - 1rem);
        min-height: auto;
        position: static;
        top: auto;
        z-index: auto;
    }
    .panel-content {
        min-height: auto;
        gap: 0.4rem;
        padding-top: 0.15rem;
        justify-content: flex-start;
    }
    .panel-title-row {
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        gap: 1rem !important;
        width: 100% !important;
        margin-bottom: 0.6rem !important;
    }
    .robot-left, .robot-right {
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        justify-content: center !important;
        flex-shrink: 0 !important;
    }
    .robot-icon {
        font-size: 1.2rem !important;
        animation: bounce 2s infinite !important;
    }
    .panel-subtitle-row {
        gap: 0.5rem !important;
    }
    .robot-animation {
        font-size: 0.8rem !important;
        animation: pulse 1.5s infinite !important;
    }
    .panel-title {
        font-size: 1.1rem !important;
        margin: 0 !important;
    }
    .ai-tutor-panel .panel-title {
        font-size: 1.0rem !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
    }
    .ai-tutor-panel .panel-subtitle {
        font-size: 0.85rem !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
    }
}
@media (max-width: 480px) {
    .ai-tutor-panel {
        margin: 0.4rem 0.25rem 0.25rem 0.25rem;
        padding: 0.4rem 0.35rem;
        border-radius: 12px;
        width: calc(100% - 0.5rem);
        position: static;
        top: auto;
        z-index: auto;
    }
    .panel-content {
        min-height: auto;
        gap: 0.35rem;
        padding-top: 0.15rem;
        justify-content: flex-start;
    }
    .panel-title-row {
        gap: 0.6rem !important;
        margin-bottom: 0.6rem !important;
    }
    .robot-icon {
        font-size: 1.0rem !important;
    }
    .panel-subtitle-row {
        gap: 0.3rem !important;
    }
    .robot-animation {
        font-size: 0.7rem !important;
    }
    .panel-title {
        font-size: 1.0rem !important;
    }
    .panel-features {
        gap: 0.4rem;
        justify-content: center;
        flex-wrap: wrap;
    }
}

.panel-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 2;
    min-height: 120px;
    gap: 2rem;
    padding-top: 3rem;
}

.panel-center {
    text-align: center;
    width: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 0 1rem;
}

.panel-title-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10rem;
    width: 100%;
    margin-bottom: 1.5rem;
}

/* Mobile responsive adjustments */
@media (max-width: 768px) {
    .panel-title-row {
        gap: 0.5rem;
    }
    
    .robot-icon {
        font-size: 1.5rem !important;
    }
    
    .robot-animation {
        font-size: 0.8rem !important;
    }
    
    .panel-title {
        font-size: 1.1rem !important;
    }
}

.panel-title {
    font-size: 2.6rem;
    font-weight: 700;
    color: white;
    margin: 0;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.panel-subtitle {
    font-size: 1.4rem;
    color: rgba(255, 255, 255, 0.9);
    margin-bottom: 1rem;
}

.panel-bsubtitle {
    font-size: 1.1rem;
    color: rgba(255, 255, 255, 0.7);
    margin-top: 1rem;
}

.panel-features {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    flex-wrap: wrap;
}

.feature-badge {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    padding: 0.3rem 0.8rem;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 500;
    backdrop-filter: blur(10px);
}

.robot-left {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.robot-right {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.robot-icon {
    font-size: 1.8rem;
    animation: bounce 2s infinite;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    height: calc(100vh - 50px);
    height: calc(100dvh - 50px);
    height: calc(-webkit-fill-available - 50px);
    background: white;
    box-shadow: none;
    border-radius: 0;
    overflow-y: auto;
    backdrop-filter: blur(10px);
    animation: slideIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
    display: flex;
    flex-direction: column;
    width: 100%;
    box-sizing: border-box;
    padding-bottom: 0;
}

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

.header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 3rem 2rem;
    position: relative;
    overflow: hidden;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 100%;
}

.header-text {
    text-align: center;
    flex: 1;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 2rem;
    position: absolute;
    top: 0.5rem;
    right: 2rem;
}

.user-mobile {
    font-size: 0.9rem;
    opacity: 0.9;
    color: white;
    text-decoration: none;
    padding: 0.25rem 0.5rem;
    border-radius: 6px;
    transition: all 0.3s ease;
    cursor: pointer;
}

.user-mobile:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-1px);
}

.logout-btn {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.3s ease;
}

.logout-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.5);
}

.free-trial-btn {
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 50px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    display: inline-flex;
    align-items: left;
    gap: 0.5rem;
    position: absolute;
    top: 0.5rem;
    left: 2rem;
    z-index: 10;
}

.free-trial-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.5);
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
}

.free-trial-btn:active {
    transform: translateY(0);
}

.profile-btn {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    padding: 0.5rem;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.3s ease;
    text-decoration: none;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
}

.profile-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.5);
    transform: translateY(-1px);
}

.header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><defs><pattern id="grain" width="100" height="100" patternUnits="userSpaceOnUse"><circle cx="50" cy="50" r="1" fill="%23ffffff" opacity="0.1"/></pattern></defs><rect width="100" height="100" fill="url(%23grain)"/></svg>') repeat;
    pointer-events: none;
}

.header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
    text-shadow: 0 2px 4px rgba(0,0,0,0.1);
    position: relative;
    z-index: 1;
}

.header p {
    opacity: 0.95;
    font-size: 1.0rem;
    font-weight: 400;
    position: relative;
    z-index: 1;
}

.subjects-container {
    padding: 2.5rem 1rem 1.5rem 1rem;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    justify-content: center;
    align-items: center;
}

.subjects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 2rem;
    max-width: 800px;
    margin: 0 auto;
}

.subject-btn {
    background: white;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    padding: 1rem;
    font-size: 0.9rem;
    font-weight: 600;
    color: #475569;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

/* Individual subject button colors */
.subject-btn[data-subject="general"] {
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    color: white;
    border-color: #6366f1;
}

.subject-btn[data-subject="mathematics"] {
    background: linear-gradient(135deg, #ef4444 0%, #f97316 100%);
    color: white;
    border-color: #ef4444;
}

.subject-btn[data-subject="physics"] {
    background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
    color: white;
    border-color: #3b82f6;
}

.subject-btn[data-subject="chemistry"] {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    border-color: #10b981;
}

.subject-btn[data-subject="biology"] {
    background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
    color: white;
    border-color: #22c55e;
}

.subject-btn[data-subject="english"] {
    background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
    color: white;
    border-color: #8b5cf6;
}

.subject-btn[data-subject="hindi"] {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: white;
    border-color: #f59e0b;
}

.subject-btn[data-subject="urdu"] {
    background: linear-gradient(135deg, #06b6d4 0%, #0891b2 100%);
    color: white;
    border-color: #06b6d4;
}

.subject-btn[data-subject="geography"] {
    background: linear-gradient(135deg, #84cc16 0%, #65a30d 100%);
    color: white;
    border-color: #84cc16;
}

.subject-btn[data-subject="computer-science"] {
    background: linear-gradient(135deg, #64748b 0%, #475569 100%);
    color: white;
    border-color: #64748b;
}

.subject-btn:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 12px 35px rgba(0, 0, 0, 0.25);
    filter: brightness(1.1);
}

.subject-btn.active {
    transform: translateY(-4px) scale(1.05);
    box-shadow: 
        0 15px 40px rgba(0, 0, 0, 0.4),
        0 0 30px rgba(99, 102, 241, 0.5),
        inset 0 2px 10px rgba(255, 255, 255, 0.3);
    filter: brightness(1.3) saturate(1.2);
    border-width: 3px;
    animation: pulseGlow 2s ease-in-out infinite alternate;
}

.ai-tutor-panel {
    /* Multicolor animated gradient */
    background: linear-gradient(135deg,
        #ff7eb3 0%,
        #ff758c 15%,
        #f9d423 30%,
        #8ec5fc 50%,
        #764ba2 70%,
        #a18cd1 85%,
        #fbc2eb 100%
    );
    background-size: 300% 300%;
    animation: gradientShift 16s ease infinite;

    margin: 1rem;
    border-radius: 20px;
    padding: 2rem;
    position: relative;
    overflow: hidden;
    box-shadow: 0 12px 36px rgba(102, 126, 234, 0.28), 0 8px 20px rgba(0, 0, 0, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.25);
}

.panel-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 2;
    min-height: 120px;
    gap: 2rem;
    padding-top: 3rem;
}

.panel-center {
    text-align: center;
    width: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 0 1rem;
}

.panel-title-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6rem;
    width: 100%;
    margin-bottom: 1.5rem;
}

/* Mobile responsive adjustments */
@media (max-width: 768px) {
    .panel-title-row {
        gap: 0.5rem;
    }
    
    .robot-icon {
        font-size: 1.5rem !important;
    }
    
    .robot-animation {
        font-size: 0.8rem !important;
    }
    
    .panel-title {
        font-size: 1.5rem !important;
    }
}

.panel-title {
    font-size: 2.6rem;
    font-weight: 700;
    color: white;
    margin: 0;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.panel-subtitle {
    font-size: 1.4rem;
    color: rgba(255, 255, 255, 0.9);
    margin-bottom: 1rem;
}

.panel-bsubtitle {
    font-size: 1.1rem;
    color: rgba(255, 255, 255, 0.7);
    margin-top: 1rem;
}

.panel-features {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    flex-wrap: wrap;
}

.feature-badge {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    padding: 0.3rem 0.8rem;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 500;
    backdrop-filter: blur(10px);
}

.robot-left {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.robot-right {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.robot-icon {
    font-size: 1.8rem;
    animation: bounce 2s infinite;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.panel-subtitle-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4.5rem;
    width: 100%;
    margin-bottom: 1rem;
}

.robot-animation {
    font-size: 1rem;
    animation: pulse 1.5s infinite;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-10px); }
    60% { transform: translateY(-5px); }
}

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

/* Animated multi-color gradient for AI Tutor panel */
@keyframes gradientShift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.panel-gradient {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(circle at 30% 70%, rgba(255, 255, 255, 0.1) 0%, transparent 50%);
    pointer-events: none;
}

.tab-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    height: calc(100vh - 110px);
    position: relative;
    background: #f8fafc;
}

.tab-main-content {
    padding: 1rem;
    min-height: calc(100vh - 150px);
    display: flex;
    flex-direction: column;
}

.search-only-area {
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    margin: 1rem;
    margin-top: 3rem;
    padding: 1rem;
    border-radius: 16px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: calc(100vh - 400px);
}

.search-welcome h2 {
    color: #1e293b;
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 0.3rem;
}

.search-welcome p {
    color: #64748b;
    font-size: 0.8rem;
    line-height: 1.3;
    max-width: 1000px;
    margin: 0 auto;
}

.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #f8fafc;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
    -webkit-overflow-scrolling: touch;
}

.welcome-message, .result-welcome-message {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 1rem;
    border-radius: 12px;
    text-align: center;
    font-weight: 500;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.ai-result-text {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 12px;
    padding: 1.5rem;
    margin: 3rem 0 1rem 0;
    border-left: 4px solid #007bff;
    font-size: 1rem;
    line-height: 1.6;
    color: #333;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.formatted-response {
    text-align: justify;
    text-justify: inter-word;
}

.formatted-response .response-paragraph {
    margin-bottom: 1rem;
    text-align: justify;
    line-height: 1.8;
}

.formatted-response .response-header {
    color: #007bff;
    margin: 1.5rem 0 1rem 0;
    font-weight: 600;
    border-bottom: 2px solid #e9ecef;
    padding-bottom: 0.5rem;
}

.formatted-response .bullet-list,
.formatted-response .numbered-list {
    margin: 1rem 0;
    padding-left: 1.5rem;
}

.formatted-response .bullet-point,
.formatted-response .numbered-point {
    margin-bottom: 1.5rem;
    line-height: 1.6;
    text-align: justify;
}

.formatted-response .code-block {
    background: #f1f3f4;
    border: 1px solid #e1e5e9;
    border-radius: 8px;
    padding: 1rem;
    margin: 1rem 0;
    overflow-x: auto;
    font-family: 'Courier New', monospace;
}

.formatted-response .inline-code {
    background: #f1f3f4;
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
}

.formatted-response strong {
    color: #495057;
    font-weight: 600;
}

.formatted-response em {
    color: #6c757d;
    font-style: italic;
}

.input-container {
    background: white;
    border-top: 1px solid #e2e8f0;
    padding: 1rem;
    position: sticky;
    bottom: 0;
    z-index: 100;
}

/* Mobile keyboard optimization */
@media (max-width: 768px) {
    .input-container {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        padding: 0.75rem;
        background: white;
        border-top: 1px solid #e2e8f0;
        z-index: 1000;
        box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
    }
    
    /* Adjust content area to account for fixed input */
    #search-content {
        padding-bottom: 120px !important;
    }
    
    /* Ensure textarea doesn't zoom on iOS */
    #questionInput {
        font-size: 16px !important;
        -webkit-appearance: none;
        appearance: none;
        border-radius: 12px;
    }
    
    /* Prevent viewport jumping when keyboard appears */
    body.keyboard-open {
        position: fixed;
        width: 100%;
    }
}

.input-area {
    background: #f8fafc;
    border: 2px solid #e2e8f0;
    border-radius: 16px;
    padding: 0.75rem;
    transition: all 0.3s ease;
}

.input-area:focus-within {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.input-group {
    display: flex;
    align-items: flex-end;
    gap: 0.75rem;
}

.input-group textarea {
    flex: 1;
    border: none;
    background: transparent;
    outline: none;
    resize: none;
    font-size: 1rem;
    line-height: 1.5;
    padding: 0;
    min-height: 24px;
    max-height: none;
    color: #1e293b;
    overflow-y: scroll;
    height: auto;
    transition: height 0.2s ease;
}

.input-group textarea::placeholder {
    color: #94a3b8;
}

.input-buttons-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.file-input-label, .send-btn {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 1.2rem;
    border: none;
    outline: none;
}

.file-input-label {
    background: #f1f5f9;
    color: #64748b;
}

.file-input-label:hover {
    background: #e2e8f0;
    color: #475569;
}

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

.send-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.file-input {
    display: none;
}

.image-preview {
    margin-top: 0.75rem;
    position: relative;
    display: inline-block;
}

.preview-image {
    max-width: 200px;
    max-height: 200px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.remove-image {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #ef4444;
    color: white;
    border: none;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.bottom-tabs {
    position: fixed !important;
    bottom: 0 !important;
    left: 0;
    right: 0;
    width: 100%;
    background: white;
    border-top: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 0.75rem 0;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    z-index: 1500;
    height: 74px;
    min-height: 74px;
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

.tab-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    transition: all 0.3s ease;
    border-radius: 8px;
    min-width: 60px;
    user-select: none;
}

.tab-item:hover {
    background: #f8fafc;
}

.tab-item.active {
    color: #667eea;
}

.tab-item.active .tab-icon {
transform: scale(1.1);
}

.tab-icon {
font-size: 1.8rem;
margin-bottom: 0.2rem;
transition: transform 0.3s ease;
}

.tab-label {
font-size: 1.1rem;
font-weight: 500;
color: #64748b;
margin-top: 0.25rem;
text-align: center;
}

.tab-item.active .tab-label {
color: #667eea;
font-weight: 600;
}

.container {
    padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px)) !important; /* 60px bar + spacing */
    position: relative;
}

/* Ensure all tab contents clear the fixed bottom tabs */
.tab-content {
    padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px));
}

.tab-main-content {
    padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px));
}

.free-trial-notification {
    background: linear-gradient(135deg, #fef2f2 0%, #eff6ff 100%);
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 0.5rem 1rem;
    margin: 0.5rem 1rem 1rem 1rem;
    font-size: 0.75rem;
    font-weight: 500;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    animation: slideIn 0.3s ease-out;
    text-align: center;
    white-space: nowrap;
    flex-wrap: wrap;
}

.trial-text-red {
    color: #dc2626;
    font-weight: 600;
}

.trial-text-blue {
    color: #2563eb;
}

.trial-upgrade {
    color: #059669;
    font-weight: 600;
    cursor: pointer;
}

/* Tablet and small desktop styles */
@media (max-width: 1024px) {
    .header {
        padding: 2rem 1.5rem;
    }
    
    .ai-tutor-panel {
        margin: 1.75rem 0.75rem 0.75rem 0.75rem;
        padding: 1.5rem;
    }
    
    .subjects-container {
        padding: 1.25rem 0.75rem;
    }
}

/* Mobile landscape and tablet portrait */
@media (max-width: 768px) {
    .header {
        padding: 1.5rem 1rem;
    }

    .header h1 {
        font-size: 1.8rem;
    }

    .header p {
        font-size: 0.9rem;
    }

    .user-info {
        top: 0.25rem;
        right: 1rem;
        gap: 0.5rem;
    }

    .free-trial-btn {
        top: 0.25rem;
        left: 1rem;
        padding: 0.5rem 1rem;
        font-size: 0.85rem;
    }

    .subjects-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }

    .subject-btn {
        padding: 0.75rem 0.5rem;
        font-size: 0.9rem;
        min-height: 60px;
    }

    .ai-tutor-panel {
        margin: 0.5rem;
        padding: 1.25rem;
        box-shadow: 0 8px 25px rgba(102, 126, 234, 0.2), 0 4px 15px rgba(0, 0, 0, 0.1);
    }

    .panel-title {
        font-size: 1.2rem;
    }

    .panel-subtitle {
        font-size: 1rem;
    }

    .robot-left, .robot-right {
        display: flex;
        font-size: 0.9rem;
    }

    .robot-icon {
        font-size: 1.5rem;
    }

    .robot-animation {
        font-size: 1rem;
    }

    .feature-badge {
        font-size: 0.7rem;
        padding: 0.25rem 0.6rem;
    }

    .bottom-tabs {
        padding: 0.5rem 0;
        padding-bottom: max(0.5rem, env(safe-area-inset-bottom, 0px));
    }

    .container {
        padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px)) !important;
    }

    .tab-content,
    .tab-main-content {
        padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px));
    }

    /* Subject tab spacing so last row isn't hidden */
    #subject-content .tab-main-content {
        padding-bottom: calc(88px + env(safe-area-inset-bottom, 0px));
    }

    /* Make results scroller stop above bottom tabs */
    #resultMessages {
        bottom: calc(74px + env(safe-area-inset-bottom, 0px)) !important;
    }

    .tab-item {
        padding: 0.5rem;
        min-width: 60px;
    }

    .tab-icon {
        font-size: 1.4rem;
    }

    .tab-label {
        font-size: 0.95rem;
    }
}

/* Mobile portrait */
@media (max-width: 480px) {
    body {
        font-size: 18px;
    }

    .header {
        padding: 1rem 0.75rem;
    }

    .header h1 {
        font-size: 1.6rem;
        margin-bottom: 1.5rem;
    }

    .header p {
        font-size: 0.85rem;
    }

    .user-info {
        position: static;
        justify-content: flex-end;
        margin-top: 0.75rem;
        gap: 0.4rem;
    }

    .free-trial-btn {
        position: static;
        margin-bottom: 0.75rem;
        padding: 0.4rem 0.8rem;
        font-size: 0.9rem;
    }

    .header-content {
        flex-direction: column;
        align-items: stretch;
    }

    .subjects-container {
        padding: 1rem 0.5rem;
    }

    .subjects-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.5rem;
    }

    .subject-btn {
        padding: 0.6rem 0.4rem;
        font-size: 0.75rem;
        min-height: 55px;
    }

    .ai-tutor-panel {
        margin: 0.5rem;
        padding: 1rem;
        border-radius: 16px;
        box-shadow: 0 6px 20px rgba(102, 126, 234, 0.15), 0 3px 10px rgba(0, 0, 0, 0.08);
    }

    .panel-title {
        font-size: 1.1rem;
        margin-bottom: 0.4rem;
    }

    .panel-subtitle {
        font-size: 0.9rem;
        margin-bottom: 0.75rem;
    }

    .panel-bsubtitle {
        font-size: 0.7rem;
        margin-top: 0.75rem;
    }

    .panel-features {
        gap: 0.4rem;
    }

    .feature-badge {
        font-size: 0.65rem;
        padding: 0.2rem 0.5rem;
    }

    .input-container {
        position: relative !important;
        padding: 0.5rem;
        background: white;
        border-top: 2px solid #e2e8f0;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
    }

    .input-area {
        border-radius: 12px;
        padding: 0.5rem;
    }

    .input-group textarea {
        font-size: 0.9rem;
        min-height: 20px;
    }

    .file-input-label, .send-btn {
        width: 36px;
        height: 36px;
        font-size: 1rem;
    }

    .bottom-tabs {
        padding: 0.5rem 0;
        padding-bottom: max(0.5rem, env(safe-area-inset-bottom, 0px));
    }

    .tab-item {
        padding: 0.4rem;
        min-width: 50px;
    }
    .tab-item {
        padding: 0.4rem;
        min-width: 50px;
    }

    .tab-icon {
        font-size: 1.3rem;
        margin-bottom: 0.15rem;
    }

    .tab-label {
        font-size: 0.9rem;
    }

    .logout-btn, .profile-btn {
        padding: 0.4rem;
        font-size: 0.9rem;
        width: 36px;
        height: 36px;
    }
}

/* Extra small mobile devices */
@media (max-width: 360px) {
    .subjects-grid {
        grid-template-columns: 1fr 1fr;
        gap: 0.4rem;
    }

    .subject-btn {
        padding: 0.5rem 0.3rem;
        font-size: 0.7rem;
        min-height: 50px;
    }

    .ai-tutor-panel {
        margin: 0.5rem 0.25rem;
        padding: 1rem 0.75rem;
        border-radius: 12px;
        width: calc(100% - 0.5rem);
    }

    .panel-title {
        font-size: 1.1rem !important;
        margin-bottom: 1.5rem;
    }

    .panel-subtitle {
        font-size: 0.9rem !important;
        margin-bottom: 0.6rem;
    }

    .panel-bsubtitle {
        font-size: 0.65rem !important;
        margin-top: 0.6rem;
        line-height: 1.3;
    }

    .feature-badge {
        font-size: 0.65rem !important;
        padding: 0.25rem 0.5rem !important;
        margin: 0.1rem;
    }

    .robot-icon {
        font-size: 1.8rem !important;
    }

    .robot-animation {
        font-size: 1.1rem !important;
    }

    .tab-item {
        padding: 0.3rem;
        min-width: 45px;
    }

    .tab-icon {
        font-size: 1.2rem;
    }

    .tab-label {
        font-size: 0.85rem;
    }
}

/* Landscape orientation adjustments */
@media (max-height: 500px) and (orientation: landscape) {
    .header {
        padding: 0.75rem 1rem;
    }

    .ai-tutor-panel {
        margin: 0.25rem;
        padding: 0.75rem;
        border-radius: 12px;
        box-shadow: 0 4px 15px rgba(102, 126, 234, 0.12), 0 2px 8px rgba(0, 0, 0, 0.06);
    }

    .panel-title {
        font-size: 1.0rem;
    }

    .panel-subtitle {
        font-size: 0.9rem;
        margin-bottom: 1.5rem;
    }

    .subjects-container {
        padding: 0.75rem 0.5rem;
    }

    .bottom-tabs {
        padding: 1rem 0;
        padding-bottom: max(1rem, env(safe-area-inset-bottom, 0px) + 0.5rem);
    }
}

/* Login Page Font Size Improvements */
.welcome-title {
    font-size: 1.5rem !important;
    font-weight: 700 !important;
}

.welcome-subtitle {
    font-size: 1.1rem !important;
    font-weight: 500 !important;
}

.form-group label {
    font-size: 1.2rem !important;
    font-weight: 600 !important;
    margin-bottom: 0.5rem;
    display: block;
}

.form-group input {
    font-size: 1.1rem !important;
    padding: 0.75rem !important;
    border-radius: 12px;
    border: 2px solid #e2e8f0;
    width: 100%;
    box-sizing: border-box;
}

.tab-btn {
    font-size: 1.5rem !important;
    font-weight: 600 !important;
    padding: 0.75rem 1.5rem !important;
}

button[type="submit"], button[type="button"] {
    font-size: 1.2rem !important;
    font-weight: 600 !important;
    padding: 0.75rem 1.5rem !important;
    border-radius: 12px !important;
}

/* Result action buttons - smaller size */
.result-btn, .gated-action {
    min-width: 60px !important;
    height: 28px !important;
    padding: 0 8px !important;
    font-size: 0.75rem !important;
    font-weight: 500 !important;
    border-radius: 12px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 4px !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
    border: 1px solid transparent !important;
}

.message {
    font-size: 1rem !important;
    font-weight: 500 !important;
}

/* Login page specific text */
.login-container p, .login-container a {
    font-size: 1rem !important;
}

.login-container h3 {
    font-size: 1.2rem !important;
    font-weight: 700 !important;
}

/* Index (Login/Register) mobile-first UI */
@media (max-width: 768px) {
  .auth-container {
    width: 100%;
    max-width: 420px;
    margin: 0 auto;
    padding: 12px;
  }
  .logo-container { text-align: center; margin: 6px 0 10px; }
  .logo-container .logo { width: 84px; height: auto; }
  .welcome-banner { 
    padding: 10px; 
    background: rgba(255,255,255,0.9); 
    border-radius: 12px; 
    margin-bottom: 12px; 
  }
  .tabs { display: flex; gap: 8px; justify-content: center; margin: 8px 0; }
  .tab-btn { flex: 1 1 auto; min-height: 42px; border-radius: 10px; }
  .tab-content { padding: 10px; background: rgba(255,255,255,0.9); border-radius: 12px; }
  .form-group { margin: 10px 0; }
  .form-group input { width: 100%; }
  button[type="submit"], button[type="button"], .tab-btn { width: 100%; }
  .message { border-radius: 10px; }
}

@media (max-width: 480px) {
  .auth-container { padding: 10px; max-width: 380px; }
  .logo-container .logo { width: 76px; }
  .tab-content { padding: 8px; }
}

/* Colorful AI-themed, glassmorphic mobile UI for Index (Login/Register) */
@media (max-width: 768px) {
  /* Glassmorphic card */
  .auth-container, .tab-content, .welcome-banner {
    background: radial-gradient(1200px circle at 0% 0%, rgba(102,126,234,0.18), transparent 40%),
                radial-gradient(1200px circle at 100% 0%, rgba(118,75,162,0.18), transparent 40%),
                rgba(255,255,255,0.10);
    border: 1px solid rgba(255,255,255,0.22);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18), 0 6px 12px rgba(102, 126, 234, 0.18);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
  }

  /* Vibrant tabs */
  .tabs { background: transparent; }
  .tab-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff !important;
    border: none !important;
    box-shadow: 0 6px 16px rgba(102,126,234,0.35);
    transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.3s ease;
  }
  .tab-btn:hover { transform: translateY(-1px); box-shadow: 0 8px 20px rgba(102,126,234,0.45); }
  .tab-btn.active {
    background: linear-gradient(135deg, #ff7eb3 0%, #ff758c 40%, #ffd166 100%);
    box-shadow: 0 10px 24px rgba(255, 126, 179, 0.5);
    border: none !important;
  }

  /* Inputs with focus glow */
  .form-group input, .form-group select, .form-group textarea {
    background: rgba(255,255,255,0.92);
    border: 2px solid rgba(226,232,240,0.9);
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
  }
  .form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.25);
  }

  /* Primary button with AI gradient */
  button[type="submit"], .btn-primary {
    background: linear-gradient(135deg, #22d3ee 0%, #a78bfa 50%, #f472b6 100%);
    color: #0b1020 !important;
    border: none !important;
    font-weight: 700 !important;
    box-shadow: 0 10px 20px rgba(167,139,250,0.45), 0 6px 12px rgba(34,211,238,0.35);
    transition: transform 0.18s ease, box-shadow 0.18s ease, filter 0.2s ease;
  }
  button[type="submit"]:hover, .btn-primary:hover { transform: translateY(-1px); filter: brightness(1.05); }
  button[type="submit"]:active, .btn-primary:active { transform: translateY(0); filter: brightness(0.98); }

  /* Secondary button */
  button[type="button"], .btn-secondary {
    background: linear-gradient(135deg, #64748b 0%, #475569 100%);
    color: #fff !important;
    border: none !important;
    box-shadow: 0 6px 14px rgba(100,116,139,0.35);
  }

  /* Info/warning messages with pill look */
  .message {
    background: linear-gradient(135deg, rgba(255,255,255,0.85), rgba(255,255,255,0.75));
    border-left: 4px solid #ffd166;
    color: #1f2937;
    padding: 10px 12px;
  }

  /* Links */
  .login-container a { color: #22d3ee !important; font-weight: 600; }
  .login-container a:hover { color: #38bdf8 !important; }
}

/* Comprehensive Mobile Responsive Design */
@media (max-width: 768px) {
    /* Container adjustments */
    /* Viewport-fitting container minus header (approx 48px) */
    .container {
        height: calc(100dvh - 48px);
        padding: 0;
        overflow: hidden; /* prevent page scroll; content panes handle their own */
    }
    
    /* Tab content mobile optimization */
    /* Each tab fills area between header and bottom tabs (≈72px incl. padding) */
    .tab-content {
        padding: 0;
        height: calc(100dvh - 48px - 72px);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Subject tab: no scrolling, content must fit */
    #subject-content {
        height: calc(100dvh - 48px - 72px);
        overflow: hidden;
    }
    #subject-content .tab-main-content {
        height: 100%;
        overflow: hidden;
        padding-bottom: 0;
        display: flex;
        flex-direction: column;
        justify-content: flex-start;
        gap: 0.5rem;
    }
    #subject-content .subjects-container {
        padding-top: 0.5rem;
        padding-bottom: 0.25rem;
    }
    #subject-content .subjects-grid {
        gap: 0.5rem;
    }
    #subject-content .ai-tutor-panel {
        margin: 0.25rem 0.5rem 0.25rem;
        padding: 0.6rem 0.5rem;
    }
    
    .tab-main-content {
        height: 100%;
        overflow-y: auto;
        padding-bottom: 0.75rem; /* compact; bottom spacing already reserved */
    }
    
    /* Input fixes */
    #questionInput {
        -webkit-appearance: none;
        appearance: none;
    }
    
    /* Mobile safe areas */
    .subjects-container {
        padding-top: max(1rem, env(safe-area-inset-top));
        padding-left: max(0.5rem, env(safe-area-inset-left));
        padding-right: max(0.5rem, env(safe-area-inset-right));
    }
    
    /* Touch-friendly interactions */
    .subject-btn {
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
    }
    
    .nav a {
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
    }
    
    /* AI Tutor Panel touch optimization */
    .ai-tutor-panel {
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
    }
    
    .feature-badge {
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
        transition: all 0.2s ease;
    }
    
    .feature-badge:active {
        transform: scale(0.95);
    }
    
    /* Prevent zoom on input focus */
    input, textarea, select {
        font-size: 16px !important;
    }
    
    /* Mobile scrolling optimization */
    body {
        -webkit-overflow-scrolling: touch;
    }
    
    /* Mobile brand sizing */
    .brand {
        font-size: 0.8rem;
    }
    
    .brand img {
        width: 18px;
        height: 18px;
    }
    
    /* Stronger specificity on mobile to override any larger defaults */
    .site-header .brand span {
        font-size: 0.8rem !important;
        line-height: 1;
    }
    .site-header .brand img {
        width: 18px !important;
        height: 18px !important;
    }
    
    /* Mobile header height adjustment */
    .site-header {
        height: 40px;
    }
    
    /* Mobile menu toggle enhancement */
    .menu-toggle {
        padding: 0.75rem;
        border-radius: 8px;
        background: rgba(100, 116, 139, 0.1);
    }
    
    .menu-toggle:hover {
        background: rgba(100, 116, 139, 0.2);
    }
    
    .menu-toggle span {
        width: 18px;
        height: 2px;
    }
    
    /* Index page mobile override: make auth tabs auto-size instead of using app-wide .tab-content height */
    .auth-container .tab-content {
        height: auto !important;
        overflow: visible !important;
        padding: 10px !important;
    }
    
    /* Index page font-size reduction (scoped to auth container) */
    .auth-container .welcome-title { font-size: 1.40rem !important; color: #2563eb !important; }
    .auth-container .welcome-subtitle { font-size: 0.70rem !important; }
    .auth-container .form-group label { font-size: 1.00rem !important; }
    .auth-container .form-group input { font-size: 1.00rem !important; }
    .auth-container .tab-btn { font-size: 1.05rem !important; padding: 0.5rem 0.9rem !important; min-height: 38px !important; }
    .auth-container button[type="submit"],
    .auth-container button[type="button"] { font-size: 1.05rem !important; }
    .auth-container .message { font-size: 0.95rem !important; }
    .auth-container .login-container p,
    .auth-container .login-container a { font-size: 0.95rem !important; }
    .auth-container .login-container h3 { font-size: 1.10rem !important; }
}

/* Index page: compact vertical spacing and full viewport height on mobile */
@media (max-width: 768px) {
  .auth-container {
    height: 100dvh;
    max-height: 100dvh;
    overflow: hidden; /* no page scroll */
    box-sizing: border-box;
  }
  .auth-container .tabs {
    margin: 4px 0; gap: 6px;
  }
  .auth-container .tab-content {
    flex: 1 1 auto; /* fills remaining space */
    min-height: 0;  /* allow flex children to shrink */
    overflow: hidden !important; /* no internal scroll; override earlier visible rule */
    padding: 8px !important;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
  }
  .auth-container .form-group { margin: 6px 0; }
  .auth-container .form-group input { padding: 0.6rem !important; }
  .auth-container button[type="submit"],
  .auth-container button[type="button"] { padding: 0.6rem 1rem !important; }
  .auth-container .logo { width: 68px; }
  .auth-container .welcome-banner { padding: 6px; margin-bottom: 6px; }
}

/* Extra-tight fit for very short screens */
@media (max-width: 768px) and (max-height: 640px) {
  .auth-container .welcome-title { font-size: 1.1rem !important; }
  .auth-container .welcome-subtitle { font-size: 0.68rem !important; }
  .auth-container .tab-btn { font-size: 1.1rem !important; min-height: 38px; }
  .auth-container .form-group label { font-size: 0.95rem !important; }
  .auth-container .form-group input { font-size: 0.95rem !important; }
}

/* Index page: professional blue theme for buttons and tabs */
.auth-container .tab-btn,
.auth-container button[type="submit"],
.auth-container button[type="button"],
.auth-container .btn-primary,
.auth-container .btn-secondary {
  background: #2563eb !important; /* primary blue */
  color: #ffffff !important;
  border: 1px solid #1d4ed8 !important;
  box-shadow: none !important;
}

.auth-container .tab-btn:hover,
.auth-container button[type="submit"]:hover,
.auth-container button[type="button"]:hover,
.auth-container .btn-primary:hover,
.auth-container .btn-secondary:hover {
  background: #1d4ed8 !important; /* hover deeper */
  border-color: #1e40af !important;
}

.auth-container .tab-btn.active {
  background: #1e40af !important; /* active darkest */
  border-color: #1e3a8a !important;
  color: #ffffff !important;
}

/* Validation and indicators in red */
.auth-container .message.error,
.auth-container #otpMessage.error {
  background: #fee2e2 !important; /* light red bg */
  color: #b91c1c !important;      /* dark red text */
  border-left: 4px solid #ef4444 !important;
}

/* Success state in green (e.g., 'verification code sent') */
.auth-container .message.success,
.auth-container #otpMessage.success {
  background: #dcfce7 !important; /* light green */
  color: #166534 !important;      /* dark green */
  border-left: 4px solid #22c55e !important; /* emerald */
}

/* Welcome title in blue */
.auth-container .welcome-title {
  color: #2563eb !important; /* blue */
}

.auth-container .form-group input:invalid,
.auth-container .form-group select:invalid,
.auth-container .form-group textarea:invalid {
  border-color: #ef4444 !important;
  box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.15) !important;
}

.auth-container .required {
  color: #ef4444 !important; /* asterisk */
}

/* Ensure tab container looks consistent with the violet theme */
.auth-container .tabs {
  background: transparent !important;
}

/* Index page: simple white background + unified heading fonts */
.auth-container,
.auth-container .tab-content,
.auth-container .welcome-banner {
  background: #ffffff !important;
  border: none !important;
  box-shadow: none !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}

/* Make Welcome and Verify OTP headings use the same font styling */
.auth-container .welcome-title,
.auth-container #tabVerify h2,
.auth-container #tabRegister h2 {
  font-size: 1.10rem !important;
  font-weight: 700 !important;
  color: #1f2937 !important; /* neutral dark for consistency */
  margin: 0.25rem 0 0.5rem !important;
}

/* Unify body text, labels and help text across Register and Verify OTP */
.auth-container #tabRegister,
.auth-container #tabVerify {
  font-family: inherit !important;
  line-height: 1.35 !important;
}
.auth-container #tabRegister p,
.auth-container #tabVerify p,
.auth-container #tabRegister .help-text,
.auth-container #tabVerify .help-text,
.auth-container #tabRegister .note,
.auth-container #tabVerify .note,
.auth-container #tabRegister a,
.auth-container #tabVerify a {
  font-size: 0.95rem !important;
}
.auth-container #tabRegister label,
.auth-container #tabVerify label {
  font-size: 1.00rem !important; /* match register label size */
}
.auth-container #tabRegister input,
.auth-container #tabVerify input,
.auth-container #tabRegister select,
.auth-container #tabVerify select,
.auth-container #tabRegister textarea,
.auth-container #tabVerify textarea {
  font-size: 1.00rem !important; /* match register input size */
}
