/* --- Core App Layout & Theme --- */
    :root {
      --primary-color: #007aff; /* A more modern blue */
      --secondary-color: #1c1c1e; /* App-like dark grey */
      --accent-color: #34c759; /* Bright green for success */
      --listen-color: #af52de; /* Purple for listen */
      --light-bg: #f2f2f7; /* System-style light grey */
      --white-bg: #ffffff;
      --text-primary: #000000;
      --text-secondary: #6e6e73;
      --border-color: #c6c6c8;
      --header-height: 60px;
      --footer-height: 70px;
    }

    html, body {
      height: 100%;
      margin: 0;
      padding: 0;
      font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
      background-color: var(--light-bg);
      color: var(--text-primary);
      font-size: 17px;
      line-height: 1.5;
    }
    
    /* --- Header & Footer --- */
    .header-bar, .nav-container {
      position: fixed;
      left: 0;
      right: 0;
      background-color: var(--white-bg);
      box-shadow: 0 1px 2px rgba(0,0,0,0.05);
      z-index: 1000;
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 0 16px;
      box-sizing: border-box;
      border-bottom: 1px solid #e5e5ea;
    }

    .header-bar {
      top: 0;
      height: var(--header-height);
      color: var(--text-primary);
    }
    .header-title { font-size: 1.1em; font-weight: 600; }
    .header-right { display: flex; align-items: center; gap: 12px; }
    #scoreDisplay { background-color: var(--accent-color); color: white; padding: 4px 12px; border-radius: 20px; font-weight: 500; font-size: 0.8em; }
    .header-right .progress-bar { width: 100px; height: 8px; background-color: #e5e5ea; border-radius: 4px; overflow: hidden; }
    .header-right .progress { height: 100%; background-color: var(--primary-color); transition: width 0.4s ease-in-out; }

    .nav-container {
      bottom: 0;
      height: var(--footer-height);
      border-top: 1px solid #e5e5ea;
    }
    #pageCounter { font-size: 0.9em; color: var(--text-secondary); }

    /* --- Main Content Area --- */
    main {
      padding: var(--header-height) 16px var(--footer-height);
      box-sizing: border-box;
    }

    .page { display: none; animation: fadeIn 0.4s; padding-top: 20px; }
    .active { display: block; }
    
    h2 { font-size: 1.8em; text-align: center; color: var(--text-primary); margin-bottom: 24px; border-bottom: none; }
    h3 { font-size: 1.2em; margin-top: 32px; margin-bottom: 12px; color: var(--text-primary); border-bottom: 1px solid var(--border-color); padding-bottom: 8px;}

    /* --- Interactive Elements (Mobile-Friendly) --- */
    button { 
      border: none; 
      padding: 12px 24px; 
      border-radius: 12px; 
      font-size: 1em;
      font-weight: 600;
      cursor: pointer; 
      margin: 10px 5px 10px 0; 
      transition: background-color 0.2s, transform 0.1s; 
      background-color: var(--primary-color);
      color: white;
    }
    button:hover { transform: scale(1.02); }
    button:disabled { background-color: #c7c7cc; transform: none; cursor: not-allowed; }
    /* UPDATED: Smaller footer buttons */
    .nav-container button {
      font-size: 0.9em;
      padding: 8px 16px;
      font-weight: 500;
    }
    button.nav-btn { background-color: var(--accent-color); }
    button.listen-btn { background-color: var(--listen-color); margin-top: 15px; }
    
    /* MCQ Options as Tappable Cards */
    .mcq-options label {
        display: block; 
        padding: 16px; 
        margin: 10px 0; 
        background-color: var(--white-bg); 
        border: 1px solid var(--border-color);
        border-radius: 12px; 
        cursor: pointer; 
        transition: border-color 0.2s, box-shadow 0.2s;
    }
    .mcq-options label:has(input:checked) {
        border-color: var(--primary-color);
        background-color: #f0f8ff;
        box-shadow: 0 0 0 2px var(--primary-color);
    }
    .mcq-options input { margin-right: 12px; }

    /* Other Question Types */
    select { font-size: 1em; padding: 12px; border-radius: 8px; border: 1px solid var(--border-color); }
    .code-question pre { padding-left: 15px; line-height: 1.6; }
    .code-input {
        font-family: 'SF Mono', 'Courier New', monospace;
        font-size: 1em;
        border: 1px solid var(--border-color);
        border-radius: 6px;
        background-color: #f8f9fa;
        text-align: center;
        padding: 6px 8px;
        width: 80px;
    }
    .code-input:focus { outline: 2px solid var(--primary-color); }

    /* Code Blocks */
    textarea, pre {
        width: 100%; box-sizing: border-box; padding: 16px; border: 1px solid var(--border-color); border-radius: 12px; font-family: 'SF Mono', 'Courier New', monospace; font-size: 0.9em; margin: 10px 0;
    }
    textarea { resize: vertical; min-height: 150px; }
    pre { background-color: #f8f9fa; line-height: 1.6; }

    /* Feedback & Certificate */
    .feedback { margin: 16px 0; padding: 12px; border-radius: 8px; font-weight: 500; }
    .feedback.correct { background-color: #e5f9e9; color: #1e6c31; }
    .feedback.incorrect { background-color: #ffeded; color: #c50e0e; }
    #certificate { border: 2px solid var(--primary-color); padding: 24px; margin-top: 20px; }
    #certNameInput { font-size: 1.1em; width: 100%; padding: 12px; box-sizing: border-box; border: 1px solid var(--border-color); border-radius: 8px; margin: 20px 0; }
    
    /* Loader Styles */
    #loader-overlay {
        position: fixed; top: 0; left: 0; width: 100%; height: 100%;
        background-color: rgba(0, 0, 0, 0.7);
        z-index: 2000; display: flex; justify-content: center; align-items: center; flex-direction: column; color: white;
    }
    .spinner {
        border: 6px solid #f3f3f3; border-top: 6px solid var(--primary-color); border-radius: 50%;
        width: 50px; height: 50px; animation: spin 1.5s linear infinite; margin-bottom: 20px;
    }
    @keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

    @keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
    
    @media print {
      body { padding-bottom: 0; }
      main { padding: 0; display: block !important; }
      .header-bar, .nav-container, button, #certNameInput, #certificateFeedback, #loader-overlay, #user-dashboard-container, #feedback-modal, .page { display: none !important; }
      #page-cert { display: block !important; }
      #certificate { border: 2px solid black; margin: 0 auto; }
    }

    /* --- Sleek Compact Dashboard Layout Overrides --- */
    .layout-navbar {
      --navbar-height: 56px !important;
    }
    #main {
      padding-top: 0 !important;
    }
    .navbar-top {
      height: 56px !important;
      min-height: 56px !important;
      padding: 0.25rem 1.5rem !important;
      border-bottom: 1px solid rgba(0,0,0,0.06);
    }
    [data-bs-theme="dark"] .navbar-top {
      border-bottom: 1px solid rgba(255,255,255,0.06);
    }
    #main #main-content {
      padding-top: 0.5rem !important;
    }
    .page-heading {
      margin-bottom: 1rem !important;
    }
    .page-heading h3 {
      margin-top: 0 !important;
      margin-bottom: 4px !important;
    }
    header.mb-3 {
      margin-bottom: 0.5rem !important;
    }

    /* --- Sleek Typography & Theme Alignment Overrides --- */
    body, html {
      font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif !important;
    }
    h1, h2, h3, h4, h5, h6, .font-bold, .font-extrabold {
      font-family: 'Outfit', sans-serif !important;
    }
    .page-heading h3 {
      font-size: 1.75rem !important;
      font-weight: 800 !important;
      letter-spacing: -0.025em;
    }

    /* --- Stats Card Icon Centering & Coloring Overrides --- */
    .stats-icon {
      display: flex !important;
      align-items: center !important;
      justify-content: center !important;
      float: none !important;
      padding: 0 !important;
      margin: 0 !important;
    }
    .stats-icon i {
      display: inline-flex !important;
      align-items: center !important;
      justify-content: center !important;
      line-height: 1 !important;
      margin: 0 !important;
      padding: 0 !important;
      color: inherit !important;
      font-size: 1.35rem !important;
    }

    /* --- Global Icon Vertical Alignment & Centering Corrections --- */
    .sidebar-link i,
    .auth-input-group i,
    .stats-icon i,
    .verify-icon-pulse i,
    .verify-input-wrapper i,
    .success-card i,
    .error-card i,
    .btn i {
      display: inline-flex !important;
      align-items: center !important;
      justify-content: center !important;
      line-height: 1 !important;
      vertical-align: middle !important;
    }

    .sidebar-link i::before,
    .auth-input-group i::before,
    .stats-icon i::before,
    .verify-icon-pulse i::before,
    .verify-input-wrapper i::before,
    .success-card i::before,
    .error-card i::before,
    .btn i::before {
      vertical-align: 0 !important;
      line-height: 1 !important;
    }

    /* --- Premium Certificate Verification Modal Overrides --- */
    #verify-modal .modal-content-custom {
      background: var(--bs-body-bg) !important;
      color: var(--bs-body-color) !important;
      border: 1px solid var(--bs-border-color) !important;
      padding: 35px !important;
      border-radius: 24px !important;
      width: 440px !important;
      max-width: 90% !important;
      box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25) !important;
      position: relative !important;
      transition: all 0.3s ease !important;
    }

    .verify-icon-container {
      display: flex;
      justify-content: center;
      margin-bottom: 24px;
    }

    .verify-icon-pulse {
      display: flex;
      align-items: center;
      justify-content: center;
      width: 64px;
      height: 64px;
      border-radius: 50%;
      background: rgba(67, 94, 190, 0.1);
      color: #435ebe;
      font-size: 1.8rem;
      animation: verifyPulse 2s infinite ease-in-out;
    }

    @keyframes verifyPulse {
      0% {
        box-shadow: 0 0 0 0 rgba(67, 94, 190, 0.4);
      }
      70% {
        box-shadow: 0 0 0 16px rgba(67, 94, 190, 0);
      }
      100% {
        box-shadow: 0 0 0 0 rgba(67, 94, 190, 0);
      }
    }

    .verify-input-wrapper {
      position: relative;
    }

    .verify-input-wrapper i.input-icon {
      position: absolute;
      left: 16px;
      top: 50%;
      transform: translateY(-50%);
      color: #94a3b8;
      font-size: 1.2rem;
      pointer-events: none;
      transition: color 0.3s ease;
    }

    .verify-input {
      padding-left: 48px !important;
      height: 52px !important;
      border-radius: 14px !important;
      background-color: var(--bs-body-bg) !important;
      border: 1px solid var(--bs-border-color) !important;
      color: var(--bs-body-color) !important;
      transition: all 0.3s ease !important;
      font-size: 0.95rem !important;
    }

    .verify-input:focus {
      border-color: #435ebe !important;
      box-shadow: 0 0 0 4px rgba(67, 94, 190, 0.15) !important;
    }

    .verify-input:focus + i.input-icon {
      color: #435ebe;
    }

    .animate-shake {
      animation: shake 0.5s cubic-bezier(.36,.07,.19,.97) both;
    }

    @keyframes shake {
      10%, 90% { transform: translate3d(-1px, 0, 0); }
      20%, 80% { transform: translate3d(2px, 0, 0); }
      30%, 50%, 70% { transform: translate3d(-4px, 0, 0); }
      40%, 60% { transform: translate3d(4px, 0, 0); }
    }

    /* Modal Capsule Buttons */
    .btn-capsule {
      height: 46px !important;
      border-radius: 23px !important;
      padding: 0 24px !important;
      font-weight: 700 !important;
      font-size: 0.9rem !important;
      display: inline-flex !important;
      align-items: center !important;
      justify-content: center !important;
      transition: all 0.2s ease !important;
      box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05) !important;
    }

    .btn-capsule:hover {
      transform: translateY(-2px) !important;
      box-shadow: 0 6px 12px rgba(0, 0, 0, 0.1) !important;
    }

    .btn-capsule:active {
      transform: translateY(0) !important;
    }