
        :root {
            --primary: #6e41e2;
            --primary-light: #8b5cf6;
            --primary-dark: #5b21b6;
            --sidebar-width: 280px;
            --header-height: 70px;
            --input-height: 120px;
            --input-height-dynamic: 120px;
            --sidebar-bg: #0f172a;
            --sidebar-text: #e2e8f0;
            --sidebar-hover: #1e293b;
            --sidebar-active: #334155;
            --chat-bg: #f8fafc;
            --message-bg: #ffffff;
            --user-message-bg: #f5f3ff;
            --border-color: #e2e8f0;
            --text-primary: #1e293b;
            --text-secondary: #64748b;
            --error-color: #ef4444;
            --success-color: #10b981;
            --warning-color: #f59e0b;
            --code-bg: #1e1e1e;
            --code-text: #f8f8f2;
            --gradient: linear-gradient(135deg, #6e41e2 0%, #4f46e5 100%);
            --transition-speed: 0.3s;
            --transition-easing: cubic-bezier(0.4, 0, 0.2, 1);
            --input-glow: 0 18px 48px rgba(15, 23, 42, 0.14);
            --input-glow-strong: 0 24px 60px rgba(110, 65, 226, 0.24);
            --input-border: rgba(148, 163, 184, 0.24);
            --input-sheen: linear-gradient(120deg, rgba(139, 92, 246, 0.12), rgba(79, 70, 229, 0.08), rgba(34, 211, 238, 0.12));
            --tool-tray-width: 320px;
            --tool-tray-width-mobile: 280px;
            --app-height: 100vh;

/* Model-specific colors */
            --aether-base-color: #06b6d4;
            --aether-pro-color: #a855f7;
            --vanta-color: #3b82f6;
            --mnemox-color: #6e41e2;
            --inova-color: #ec4899;
            --nerfedjerky-color: #f59e0b;
            --nicholas-color: #0ea5e9;
            --logicengine-color: #14b8a6;
            --imagica-color: #34d399;
            
            /* Fonts */
            --main-font: 'Poppins', 'Geist', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
            --code-font: 'SF Mono', 'Roboto Mono', monospace;
        }

        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: var(--main-font);
        }

        .visually-hidden {
            position: absolute !important;
            width: 1px;
            height: 1px;
            padding: 0;
            margin: -1px;
            overflow: hidden;
            clip: rect(0, 0, 0, 0);
            white-space: nowrap;
            border: 0;
        }
        
        body {
            display: flex;
            min-height: var(--app-height);
            height: var(--app-height);
            background: var(--chat-bg);
            color: var(--text-primary);
            line-height: 1.6;
            overflow: hidden;
        }
        
        /* Auth Screen Styles */
        .auth-screen {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;
            z-index: 2000;
            transition: opacity 0.5s ease, visibility 0.5s ease;
            padding: 20px;
        }
        
        .auth-container {
            background: rgba(15, 23, 42, 0.9);
            backdrop-filter: blur(10px);
            border-radius: 16px;
            padding: 40px;
            width: 100%;
            max-width: 500px;
            box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
            border: 1px solid rgba(255, 255, 255, 0.1);
            position: relative;
            animation: fadeInUp 0.5s ease-out;
        }
        
        .auth-logo {
            text-align: center;
            margin-bottom: 20px;
        }
        
        .auth-logo img {
            height: 60px;
            margin-bottom: 10px;
            transition: transform 0.3s ease;
        }
        
        .auth-logo:hover img {
            transform: scale(1.05);
        }
        
        .auth-title {
            font-size: 28px;
            font-weight: 700;
            color: white;
            margin-bottom: 10px;
            text-align: center;
            background: linear-gradient(90deg, #8b5cf6, #ec4899);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            background-clip: text;
        }
        
        .auth-subtitle {
            font-size: 14px;
            color: rgba(255, 255, 255, 0.7);
            margin-bottom: 30px;
            text-align: center;
        }

        /* Auth animation overlay */
        .auth-animation-overlay {
            position: fixed;
            inset: 0;
            display: flex;
            align-items: center;
            justify-content: center;
            background: radial-gradient(120% 120% at 50% 10%, rgba(110, 65, 226, 0.15) 0%, rgba(15, 23, 42, 0.92) 45%, rgba(15, 23, 42, 0.98) 100%);
            backdrop-filter: blur(12px);
            z-index: 4000;
            opacity: 0;
            pointer-events: none;
            transition: opacity var(--transition-speed) ease;
        }

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

        .auth-animation-overlay::before {
            content: "";
            position: absolute;
            width: 420px;
            height: 420px;
            border-radius: 50%;
            background: radial-gradient(circle at center, rgba(139, 92, 246, 0.2), rgba(59, 130, 246, 0));
            animation: auth-orbit 6s ease-in-out infinite alternate;
            filter: blur(10px);
        }

        .auth-animation-card {
            position: relative;
            background:
                linear-gradient(180deg, rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0.04) 22%, rgba(255, 255, 255, 0.02) 100%),
                rgba(17, 24, 39, 0.78);
            border: 1px solid rgba(255, 255, 255, 0.14);
            box-shadow: 0 30px 80px rgba(15, 23, 42, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.12);
            border-radius: 30px;
            padding: 52px 52px 46px;
            width: min(560px, 92vw);
            text-align: center;
            color: #e2e8f0;
            overflow: hidden;
            transform: translateY(24px) scale(0.98);
            opacity: 0;
            backdrop-filter: blur(22px) saturate(135%);
        }

        .auth-animation-card::before {
            content: "";
            position: absolute;
            inset: 1px 1px auto 1px;
            height: 42%;
            border-radius: 29px 29px 120px 120px;
            background: linear-gradient(180deg, rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0));
            opacity: 0.8;
            pointer-events: none;
        }

        .auth-animation-overlay.active .auth-animation-card {
            animation: auth-card-pop 0.7s cubic-bezier(0.21, 0.94, 0.27, 1) forwards;
        }

        .auth-animation-card.auth-animation-reveal {
            animation: auth-card-pop 0.7s cubic-bezier(0.21, 0.94, 0.27, 1) forwards;
        }

        .auth-animation-card::after {
            content: "";
            position: absolute;
            inset: 0;
            background: linear-gradient(135deg, rgba(110, 65, 226, 0.25), rgba(236, 72, 153, 0.2));
            opacity: 0;
            transition: opacity 0.4s ease;
            pointer-events: none;
        }

        .auth-animation-card.auth-animation-welcome::after {
            opacity: 1;
        }

        .auth-animation-card.auth-animation-signout::after {
            opacity: 1;
            background: linear-gradient(135deg, rgba(59, 130, 246, 0.3), rgba(45, 212, 191, 0.2));
        }

        .auth-animation-card.auth-animation-subscription::after {
            opacity: 1;
            background:
                radial-gradient(circle at top, rgba(255, 255, 255, 0.14), transparent 42%),
                linear-gradient(145deg, rgba(245, 247, 250, 0.08), rgba(110, 65, 226, 0.16) 45%, rgba(16, 185, 129, 0.14) 100%);
        }

        .auth-animation-icon {
            position: relative;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            width: 92px;
            height: 92px;
            margin: 0 auto 22px;
            border-radius: 50%;
            background: linear-gradient(180deg, rgba(255,255,255,0.18), rgba(255,255,255,0.04)), rgba(110, 65, 226, 0.18);
            border: 1px solid rgba(255,255,255,0.18);
            font-size: 40px;
            color: #f8fafc;
            box-shadow: 0 16px 50px rgba(110, 65, 226, 0.28), inset 0 1px 0 rgba(255,255,255,0.18);
            animation: auth-icon-pulse 2.4s ease-in-out infinite;
        }

        .auth-animation-card.auth-animation-signout .auth-animation-icon {
            background: rgba(59, 130, 246, 0.18);
            box-shadow: 0 0 35px rgba(59, 130, 246, 0.35);
        }

        .auth-animation-title {
            font-size: clamp(31px, 4vw, 40px);
            font-weight: 700;
            margin-bottom: 10px;
            letter-spacing: -0.035em;
            line-height: 1.06;
            color: #f8fafc;
            text-wrap: balance;
        }

        .auth-animation-message {
            font-size: 15px;
            line-height: 1.55;
            color: rgba(226, 232, 240, 0.74);
            max-width: 430px;
            margin: 0 auto;
            text-wrap: balance;
        }

        .auth-animation-details {
            display: none;
            margin-top: 26px;
            padding: 0;
            border-radius: 0;
            background: transparent;
            border: 0;
            text-align: left;
        }

        .auth-animation-card.auth-animation-subscription .auth-animation-details {
            display: block;
        }

        .auth-animation-plan-label {
            display: inline-flex;
            align-items: center;
            gap: 8px;
            margin-bottom: 16px;
            padding: 8px 14px;
            border-radius: 999px;
            background: linear-gradient(180deg, rgba(255,255,255,0.16), rgba(255,255,255,0.06));
            border: 1px solid rgba(255,255,255,0.14);
            color: rgba(255,255,255,0.9);
            font-size: 11px;
            font-weight: 700;
            letter-spacing: 0.14em;
            text-transform: uppercase;
            box-shadow: inset 0 1px 0 rgba(255,255,255,0.12);
        }

        .auth-animation-feature-list {
            list-style: none;
            display: grid;
            grid-template-columns: repeat(2, minmax(0, 1fr));
            gap: 12px;
        }

        .auth-animation-feature-list li {
            position: relative;
            min-height: 86px;
            padding: 16px 16px 16px 44px;
            border-radius: 22px;
            background:
                linear-gradient(180deg, rgba(255,255,255,0.14), rgba(255,255,255,0.04)),
                rgba(255,255,255,0.04);
            border: 1px solid rgba(255,255,255,0.1);
            color: rgba(241, 245, 249, 0.94);
            font-size: 13px;
            line-height: 1.45;
            letter-spacing: -0.01em;
            box-shadow: inset 0 1px 0 rgba(255,255,255,0.08);
        }

        .auth-animation-feature-list li::before {
            content: "●";
            position: absolute;
            left: 18px;
            top: 18px;
            width: 12px;
            height: 12px;
            border-radius: 50%;
            background: linear-gradient(135deg, #ffffff, #cbd5e1);
            color: transparent;
            box-shadow: 0 0 0 4px rgba(255,255,255,0.08), 0 6px 16px rgba(255,255,255,0.16);
        }

        .auth-animation-card.auth-animation-subscription .auth-animation-progress {
            margin-top: 28px;
            background: rgba(255,255,255,0.1);
        }

        .auth-animation-card.auth-animation-subscription .auth-animation-progress span {
            background: linear-gradient(90deg, rgba(255,255,255,0.92), rgba(216, 180, 254, 0.92), rgba(167, 243, 208, 0.92));
        }

        @media (max-width: 640px) {
            .auth-animation-card {
                padding: 40px 24px 34px;
                width: min(94vw, 520px);
                border-radius: 26px;
            }

            .auth-animation-title {
                font-size: 30px;
            }

            .auth-animation-feature-list {
                grid-template-columns: 1fr;
            }

            .auth-animation-feature-list li {
                min-height: 0;
            }
        }

        .auth-animation-progress {
            margin-top: 32px;
            height: 4px;
            border-radius: 999px;
            background: rgba(148, 163, 184, 0.15);
            overflow: hidden;
        }

        .auth-animation-progress span {
            display: block;
            height: 100%;
            width: 100%;
            background: linear-gradient(90deg, rgba(139, 92, 246, 0.9), rgba(236, 72, 153, 0.9));
            transform: scaleX(0);
            transform-origin: left;
        }

        .auth-animation-overlay.active .auth-animation-progress span {
            animation: auth-progress 2.8s ease forwards;
        }

        @keyframes auth-card-pop {
            0% { opacity: 0; transform: translateY(24px) scale(0.96); }
            55% { opacity: 1; transform: translateY(-6px) scale(1.01); }
            100% { opacity: 1; transform: translateY(0) scale(1); }
        }

        @keyframes auth-icon-pulse {
            0%, 100% { transform: scale(1); box-shadow: 0 0 30px rgba(110,65,226,0.35); }
            45% { transform: scale(1.08); box-shadow: 0 0 55px rgba(110,65,226,0.55); }
        }

        @keyframes auth-progress {
            0% { transform: scaleX(0); }
            12% { transform: scaleX(0.2); }
            55% { transform: scaleX(0.65); }
            100% { transform: scaleX(1); }
        }

        @keyframes auth-orbit {
            0% { transform: translate(-40px, -20px) scale(1); opacity: 0.6; }
            100% { transform: translate(40px, 30px) scale(1.15); opacity: 0.85; }
        }
        
        .auth-form {
            display: flex;
            flex-direction: column;
            gap: 20px;
        }
        
        .auth-input-group {
            position: relative;
        }
        
        .auth-input {
            width: 100%;
            padding: 14px 16px;
            background: rgba(30, 41, 59, 0.7);
            border: 1px solid rgba(255, 255, 255, 0.1);
            border-radius: 8px;
            color: white;
            font-size: 15px;
            transition: all var(--transition-speed) var(--transition-easing);
        }
        
        .auth-input:focus {
            outline: none;
            border-color: var(--primary-light);
            box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.2);
        }
        
        .auth-input::placeholder {
            color: rgba(255, 255, 255, 0.5);
        }
        
        .password-strength {
            height: 4px;
            background: rgba(255, 255, 255, 0.1);
            border-radius: 2px;
            margin-top: 8px;
            overflow: hidden;
        }
        
        .password-strength-bar {
            height: 100%;
            width: 0%;
            transition: width 0.3s ease;
        }
        
        .password-strength-weak {
            background-color: #ef4444;
        }
        
        .password-strength-medium {
            background-color: #f59e0b;
        }
        
        .password-strength-strong {
            background-color: #10b981;
        }
        
        .password-requirements {
            font-size: 12px;
            color: rgba(255, 255, 255, 0.6);
            margin-top: 8px;
        }
        
        .auth-btn {
            padding: 14px;
            border-radius: 8px;
            background: var(--gradient);
            color: white;
            border: none;
            font-weight: 600;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 10px;
            transition: all var(--transition-speed) var(--transition-easing);
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
        }

/* Stepper styles */
.stepper {
   display: flex;
   justify-content: space-between;
   margin: 30px 0 25px; /* adds space from buttons above */
   padding-top: 10px;
   position: relative; /* allow baseline under circles */
}
.step {
  flex: 1;
  text-align: center;
  padding: 10px 0;
  color: rgba(255,255,255,0.6);
  font-weight: 600;
  position: relative;
}
.step.active {
  color: white;
  border-color: var(--primary-light);
}
/* Grey baseline under the circles (desktop only) */
@media (min-width: 601px){
  .stepper::before{
    content: "";
    position: absolute;
    left: 8px; right: 8px;
    top: -6px;               /* sits just under the number bubbles */
    height: 2px;
    background: rgba(255,255,255,0.12);
    border-radius: 2px;
    z-index: 0;
  }
  .step::after{ z-index: 1; } /* bubbles sit above the baseline */
}
.step::after {
  content: attr(data-step);
  position: absolute;
  top: -35px; /* move higher above text */
  left: 50%;
  transform: translateX(-50%);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid var(--primary-light);
  background: rgba(255,255,255,0.05);
  color: white;
  line-height: 28px;
  font-size: 15px;
  font-weight: 600;
}
.step-content { display: none; }
.step-content.active { display: block; animation: fadeInUp 0.4s ease; }

.step {
  font-size: 15px;
  letter-spacing: 0.5px;
}
.step.active {
  font-weight: 700;
}

/* --- Mobile stepper (line version) --- */
@media (max-width: 600px) {
    .stepper {
    position: relative;
    margin: 20px 0 16px;
    padding: 0;              /* override desktop padding */
    justify-content: space-between;
    gap: 0;
  }

  /* Base track */
  .stepper::before{
    content: "";
    position: absolute;
    left: 12px; right: 12px; top: 6px;
    height: 3px;
    background: rgba(255,255,255,0.14);
    border-radius: 999px;
  }

  /* Animated progress fill */
  .stepper::after{
    content: "";
    position: absolute;
    left: 12px; top: 6px;
    height: 3px;
    width: calc((100% - 24px) * (var(--step-index, 1) - 1) / (var(--step-count, 3) - 1));
    background: linear-gradient(90deg, #0fa47f, #0b7d61);
    border-radius: 999px;
    transition: width 260ms ease;
  }

  /* Labels with small dot markers (no numbers) */
  .step{
    flex: 1;
    text-align: center;
    border-bottom: none;
    padding: 18px 0 0;
    font-size: 13px;
    font-weight: 600;
    color: rgba(255,255,255,0.72);
    position: relative;
  }

  .step::after{
    content: "";
    position: absolute;
    left: 50%; transform: translateX(-50%);
    top: 0px;
    width: 10px; height: 10px; border-radius: 50%;
    background: #0b1513; border: 2px solid rgba(255,255,255,0.4);
    box-shadow: 0 0 0 3px rgba(15,164,127,0.10);
  }

  .step.active{ color: #e6f1ec; text-shadow: 0 0 6px rgba(15,164,127,0.35); }
  .step.active::after{ border-color: #67e3c1; box-shadow: 0 0 0 4px rgba(103,227,193,0.18); }

  @media (max-width: 380px){
    .step{ font-size: 12px; }
    .step::after{ width: 8px; height: 8px; top: 1px; }
  }

  /* Hide the numbered circles */
  .step::after {
    display: none;
  }

  /* Turn steps into a connected line */
  .step {
    flex: 1;
    position: relative;
    text-align: center;
    font-size: 13px;
    font-weight: 500;
    color: rgba(255,255,255,0.6);
  }

  .step::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 2px;
    background: rgba(255,255,255,0.1);
    transform: translateY(-50%);
  }

  /* Active step line highlight */
  .step.active::before {
    background: linear-gradient(90deg, #0fa47f, #0b7d61);
  }

  /* Hide text labels if needed for ultra-small screens */
  @media (max-width: 380px) {
    .step {
      font-size: 12px;
      letter-spacing: 0.3px;
    }
  }
}

.review-list {
  list-style: none;
  color: white;
  font-size: 14px;
  line-height: 1.8;
  margin-bottom: 20px;
}
.review-list strong { color: var(--primary-light); }
.step-controls {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}
        
        .auth-btn:hover {
            transform: translateY(-2px);
            box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
        }
        
        .auth-btn:active {
            transform: translateY(0);
        }
        
        .auth-btn:disabled {
            opacity: 0.6;
            cursor: not-allowed;
            transform: none;
            box-shadow: none;
        }
        
        .auth-footer {
            margin-top: 20px;
            text-align: center;
            font-size: 14px;
            color: rgba(255, 255, 255, 0.6);
        }
        
        .auth-link {
            color: var(--primary-light);
            text-decoration: none;
            font-weight: 500;
            transition: all 0.2s ease;
        }
        
        .auth-link:hover {
            text-decoration: underline;
            color: white;
        }
        
        .terms-checkbox {
            display: flex;
            align-items: flex-start;
            gap: 10px;
            margin-top: 10px;
        }
        
        .terms-checkbox input {
            margin-top: 3px;
            accent-color: var(--primary);
        }
        
        .terms-text {
            font-size: 12px;
            color: rgba(255, 255, 255, 0.7);
            line-height: 1.5;
        }
        
        .terms-link {
            color: var(--primary-light);
            text-decoration: none;
            font-weight: 500;
        }
        
        .terms-link:hover {
            text-decoration: underline;
        }

        .auth-tabs {
            display: flex;
            margin-bottom: 20px;
            border-bottom: 1px solid rgba(255, 255, 255, 0.1);
            border-radius: 8px 8px 0 0;
            overflow: hidden;
        }
        
        .auth-tab {
            flex: 1;
            text-align: center;
            padding: 12px;
            cursor: pointer;
            color: rgba(255, 255, 255, 0.6);
            font-weight: 500;
            transition: all var(--transition-speed) var(--transition-easing);
            position: relative;
            background: rgba(30, 41, 59, 0.5);
        }
        
        .auth-tab.active {
            color: white;
            background: rgba(124, 58, 237, 0.2);
        }
        
        .auth-tab.active::after {
            content: '';
            position: absolute;
            bottom: -1px;
            left: 0;
            right: 0;
            height: 2px;
            background: var(--primary-light);
        }
        
        .auth-form-container {
            display: none;
        }
        
        .auth-form-container.active {
            display: block;
            animation: fadeIn 0.3s ease-out;
        }
        
        /* Launch Screen Styles — refreshed */
        .launch-screen {
            position: fixed;
            inset: 0;
            display: grid;
            place-items: center;
            z-index: 2000;
            /* Animated soft gradient background */
            background: radial-gradient(1200px 800px at 10% 10%, rgba(139,92,246,0.12), transparent 60%),
                        radial-gradient(900px 700px at 90% 30%, rgba(236,72,153,0.12), transparent 60%),
                        linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
            background-size: 120% 120%;
            animation: bg-pan 12s ease-in-out infinite alternate;
        }

        .launch-screen.hidden {
            opacity: 0;
            visibility: hidden;
            transition: opacity 500ms ease, visibility 500ms ease;
        }

        /* Card with subtle glass effect */
        .launch-card {
            width: min(560px, 92vw);
            padding: 32px 28px;
            border-radius: 18px;
            background: rgba(255,255,255,0.06);
            -webkit-backdrop-filter: blur(14px);
            backdrop-filter: blur(14px);
            border: 1px solid rgba(255,255,255,0.12);
            box-shadow: 0 20px 50px rgba(0,0,0,0.35);
            transform: translateY(8px) scale(0.98);
            opacity: 0;
            animation: card-in 700ms var(--transition-easing) forwards;
        }

        .launch-logo {
            height: 60px;
            width: auto;
            display: block;
            margin: 0 auto 14px auto;
            opacity: 0.95;
        }

        .launch-title {
            font-size: 36px;
            font-weight: 800;
            text-align: center;
            margin-bottom: 8px;
            background: linear-gradient(90deg, #3b82f6, #06b6d4);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            background-clip: text;
        }

        .launch-subtitle {
            font-size: 16px;
            line-height: 1.7;
            color: rgba(255,255,255,0.85);
            text-align: center;
            max-width: 520px;
            margin: 0 auto 22px auto;
        }

        .launch-progress {
            width: min(420px, 90%);
            height: 8px;
            margin: 0 auto 18px auto;
            background: rgba(255,255,255,0.16);
            border-radius: 999px;
            overflow: hidden;
            position: relative;
        }

        /* Indeterminate sweep by default; if JS sets width, that will override the animation */
        .launch-progress-bar {
            height: 100%;
            width: 40%;
            border-radius: inherit;
            background: linear-gradient(90deg, #8b5cf6, #ec4899);
            filter: saturate(1.1);
            animation: bar-sweep 1.6s ease-in-out infinite;
        }

        .launch-version {
            text-align: center;
            color: rgba(255,255,255,0.6);
            font-size: 12px;
        }

        /* Keyframes */
        @keyframes bg-pan {
            0% { background-position: 0% 0%, 100% 0%, 0% 0%; }
            100% { background-position: 100% 100%, 0% 100%, 100% 100%; }
        }

        @keyframes card-in {
            to { opacity: 1; transform: translateY(0) scale(1); }
        }

        @keyframes bar-sweep {
            0%   { transform: translateX(-60%); }
            50%  { transform: translateX(10%); }
            100% { transform: translateX(120%); }
        }

        /* Respect reduced motion */
        @media (prefers-reduced-motion: reduce) {
            .launch-screen { animation: none; }
            .launch-card { animation: none; opacity: 1; transform: none; }
            .launch-progress-bar { animation: none; }
        }
        
        /* Sidebar Overlay (Mobile) */
        .sidebar-overlay {
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: rgba(0, 0, 0, 0.5);
            z-index: 999;
            display: none;
            backdrop-filter: blur(5px);
        }
        
        .sidebar-overlay.active {
            display: block;
        }
        
        /* Sidebar Styles */
        .sidebar {
            width: var(--sidebar-width);
            height: 100%;
            background: radial-gradient(circle at 20% 20%, rgba(139, 92, 246, 0.12), transparent 32%), 
                        radial-gradient(circle at 80% 0%, rgba(45, 212, 191, 0.14), transparent 34%),
                        var(--sidebar-bg);
            color: var(--sidebar-text);
            display: flex;
            flex-direction: column;
            transition: transform var(--transition-speed) var(--transition-easing);
            box-shadow: 2px 0 24px rgba(0, 0, 0, 0.35);
            z-index: 1000;
            position: relative;
            overflow: hidden;
        }

        .sidebar::after {
            content: "";
            position: absolute;
            inset: 0;
            pointer-events: none;
            background: linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.01));
            opacity: 0.8;
        }
        
        .sidebar-header {
            padding: 18px 18px 12px;
            border-bottom: 1px solid rgba(255, 255, 255, 0.1);
            display: flex;
            flex-direction: column;
            gap: 14px;
            position: relative;
            z-index: 1;
        }
        
        .logo-container {
            display: flex;
            align-items: center;
            justify-content: center;
            padding: 8px 0 6px;
        }
        
        .logo-img {
            height: 42px;
            width: auto;
            transition: transform var(--transition-speed) var(--transition-easing);
        }
        
        .logo-container:hover .logo-img {
            transform: scale(1.05);
        }
        
        .new-chat-btn {
            width: 100%;
            padding: 2px;
            border: none;
            border-radius: 12px;
            background: linear-gradient(135deg, rgba(34, 211, 238, 0.8) 0%, rgba(16, 185, 129, 0.85) 45%, rgba(139, 92, 246, 0.9) 100%);
            cursor: pointer;
            display: flex;
            transition: transform var(--transition-speed) var(--transition-easing), box-shadow var(--transition-speed) var(--transition-easing);
            box-shadow: 0 0 0 0 rgba(34, 211, 238, 0.15);
            position: relative;
            isolation: isolate;
        }
        
        .new-chat-btn::before {
            content: "";
            position: absolute;
            inset: -6px;
            border-radius: 16px;
            background: linear-gradient(135deg, rgba(34, 211, 238, 0.55), rgba(16, 185, 129, 0.4), rgba(139, 92, 246, 0.55));
            filter: blur(18px);
            opacity: 0.75;
            transition: opacity var(--transition-speed) var(--transition-easing), filter var(--transition-speed) var(--transition-easing);
            pointer-events: none;
            z-index: -1;
        }
        
        .new-chat-btn::after {
            content: "";
            position: absolute;
            inset: 3px;
            border-radius: 10px;
            background: rgba(15, 23, 42, 0.75);
            backdrop-filter: blur(10px);
            transition: background var(--transition-speed) var(--transition-easing);
            z-index: 0;
        }
        
        .new-chat-btn-inner {
            position: relative;
            z-index: 1;
            width: 100%;
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 10px;
            padding: 12px 16px;
            border-radius: 10px;
            background: linear-gradient(120deg, rgba(15, 23, 42, 0.8), rgba(15, 23, 42, 0.65));
            color: #f8fafc;
            font-weight: 600;
            letter-spacing: 0.01em;
            text-transform: none;
        }
        
        .new-chat-label {
            font-size: 14px;
        }
        
        .new-chat-icon {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            width: 32px;
            height: 32px;
            border-radius: 10px;
            background: linear-gradient(135deg, rgba(34, 211, 238, 0.25), rgba(139, 92, 246, 0.35));
            color: #a5f3fc;
            box-shadow: inset 0 1px 10px rgba(255, 255, 255, 0.1);
        }
        
        .new-chat-btn svg {
            width: 20px;
            height: 20px;
        }
        
        .new-chat-btn:hover {
            transform: translateY(-1px) scale(1.01);
            box-shadow: 0 12px 30px rgba(34, 211, 238, 0.25);
        }
        
        .new-chat-btn:hover::after {
            background: rgba(15, 23, 42, 0.55);
        }
        
        .new-chat-btn:hover::before {
            filter: blur(20px);
            opacity: 1;
        }
        
        .new-chat-btn:active {
            transform: translateY(0);
            box-shadow: 0 10px 22px rgba(34, 211, 238, 0.2);
        }
        
        .new-chat-btn:focus-visible {
            outline: none;
            box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.4);
        }

        .sidebar-search {
            position: relative;
            width: 100%;
            margin-top: 6px;
        }

        .sidebar-search input {
            width: 100%;
            padding: 11px 12px 11px 42px;
            border-radius: 12px;
            border: 1px solid rgba(255, 255, 255, 0.08);
            background: linear-gradient(135deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.02));
            color: var(--sidebar-text);
            font-size: 14px;
            outline: none;
            transition: border var(--transition-speed) var(--transition-easing), box-shadow var(--transition-speed) var(--transition-easing), background var(--transition-speed) var(--transition-easing);
            backdrop-filter: blur(8px);
            box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
        }

        .sidebar-search input::placeholder {
            color: rgba(255, 255, 255, 0.55);
        }

        .sidebar-search input:focus {
            border-color: rgba(139, 92, 246, 0.45);
            box-shadow: 0 0 0 2px rgba(110, 65, 226, 0.15), inset 0 1px 0 rgba(255, 255, 255, 0.08);
            background: rgba(255, 255, 255, 0.08);
        }

        .sidebar-search .search-icon {
            position: absolute;
            left: 14px;
            top: 50%;
            transform: translateY(-50%);
            color: rgba(255, 255, 255, 0.65);
            pointer-events: none;
        }
        
        .conversation-list {
            flex: 1;
            overflow-y: auto;
            padding: 6px 10px 12px;
            scrollbar-width: thin;
            position: relative;
            z-index: 1;
        }
        
        .conversation-item {
            padding: 12px 14px;
            cursor: pointer;
            display: flex;
            align-items: center;
            gap: 12px;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            transition: all var(--transition-speed) var(--transition-easing);
            border-left: 3px solid transparent;
            margin: 4px 0;
            border-radius: 12px;
            position: relative;
            background: rgba(255, 255, 255, 0.02);
            border: 1px solid rgba(255, 255, 255, 0.04);
            box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
        }
        
        .conversation-item:hover {
            background: var(--sidebar-hover);
            border-color: rgba(255, 255, 255, 0.08);
        }
        
        .conversation-item.active {
            background: var(--sidebar-active);
            border-left: 3px solid var(--primary);
            border-color: rgba(139, 92, 246, 0.35);
            box-shadow: 0 12px 24px rgba(110, 65, 226, 0.25);
        }

        .conversation-empty {
            padding: 18px 12px;
            text-align: center;
            color: rgba(255, 255, 255, 0.65);
            font-size: 14px;
            border-radius: 12px;
            border: 1px dashed rgba(255, 255, 255, 0.08);
            background: rgba(255, 255, 255, 0.02);
            margin: 8px 0;
        }
        
        .conversation-actions {
            position: absolute;
            right: 10px;
            display: none;
            gap: 5px;
        }
        
        .conversation-item:hover .conversation-actions {
            display: flex;
        }
        
        .conversation-action-btn {
            background: none;
            border: none;
            color: rgba(255, 255, 255, 0.5);
            cursor: pointer;
            padding: 2px;
            border-radius: 4px;
            transition: all var(--transition-speed) var(--transition-easing);
        }
        
        .conversation-action-btn:hover {
            color: var(--primary-light);
            background: rgba(124, 58, 237, 0.1);
        }
        
        .conversation-action-btn.delete:hover {
            color: var(--error-color);
            background: rgba(239, 68, 68, 0.1);
        }
        
        .sidebar-footer {
            padding: 15px 20px;
            border-top: 1px solid rgba(255, 255, 255, 0.1);
        }
        
        .user-profile {
            display: flex;
            align-items: center;
            gap: 12px;
            padding: 10px;
            border-radius: 8px;
            transition: all var(--transition-speed) var(--transition-easing);
            cursor: pointer;
        }
        
        .user-profile:hover {
            background: var(--sidebar-hover);
        }
        
        .user-avatar {
            width: 36px;
            height: 36px;
            border-radius: 50%;
            background: var(--gradient);
            color: white;
            display: flex;
            align-items: center;
            justify-content: center;
            font-weight: 600;
            flex-shrink: 0;
        }
        
        .user-avatar.has-photo {
            background: none;
            color: transparent;
        }
        
        .user-avatar.has-photo img {
            width: 100%;
            height: 100%;
            border-radius: 50%;
            object-fit: cover;
        }
        
        .user-info {
            display: flex;
            flex-direction: column;
            overflow: hidden;
        }
        
        .user-name {
            font-weight: 500;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }
        
        .user-email {
            font-size: 12px;
            color: rgba(255, 255, 255, 0.6);
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }
        
        /* Main Content Styles */
        .main-content {
            flex: 1;
            display: flex;
            flex-direction: column;
            height: 100%;
            min-height: 0;
            position: relative;
        }
        
        .chat-header {
            height: var(--header-height);
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 18px;
            padding: 0 25px;
            border-bottom: 1px solid var(--border-color);
            background: var(--message-bg);
            box-shadow: 0 1px 10px rgba(0, 0, 0, 0.05);
            position: relative;
            z-index: 10;
        }

        .chat-header-left,
        .chat-header-right {
            display: flex;
            align-items: center;
            gap: 12px;
        }
        
        .chat-header-right {
            gap: 14px;
            flex-wrap: nowrap;
        }

        
        .chat-title {
            font-size: 18px;
            font-weight: 700;
            color: var(--text-primary);
            background: var(--gradient);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            background-clip: text;
            text-fill-color: transparent;
        }
        
        .menu-btn {
            background: none;
            border: none;
            cursor: pointer;
            display: none;
            color: var(--text-secondary);
            padding: 8px;
            border-radius: 6px;
            transition: all var(--transition-speed) var(--transition-easing);
        }
        
        .menu-btn:hover {
            background: rgba(0, 0, 0, 0.05);
            color: var(--primary);
        }

        #open-settings-btn {
            display: flex;
            align-items: center;
            justify-content: center;
            width: 36px;
            height: 36px;
            border-radius: 999px;
            border: 1px solid var(--border-color);
            background: var(--message-bg);
            color: var(--text-secondary);
            margin-right: 10px;
            box-shadow: 0 10px 20px rgba(15, 23, 42, 0.12);
        }

        #open-settings-btn:hover {
            color: var(--primary);
            border-color: rgba(79, 70, 229, 0.45);
            box-shadow: 0 12px 26px rgba(15, 23, 42, 0.18);
        }

        
        .chat-container {
            flex: 1;
            min-height: 0;
            overflow-y: auto;
            overflow-x: hidden;
            padding: 25px;
            background: var(--chat-bg);
            position: relative;
            scrollbar-width: thin;
        }
        
        .welcome-container {
            max-width: 800px;
            margin: 0 auto;
            text-align: center;
            padding: 40px 20px;
            animation: fadeIn 0.5s ease-out;
        }
        
        .welcome-logo {
            height: 80px;
            margin-bottom: 20px;
            opacity: 0.9;
            transition: transform 0.5s ease;
        }
        
        .welcome-logo:hover {
            transform: scale(1.05);
        }
        
        
        .welcome-title {
            font-size: 28px;
            font-weight: 700;
            margin-bottom: 16px;
            background: var(--gradient);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            background-clip: text;
        }
        
        .welcome-subtitle {
            font-size: 16px;
            color: var(--text-secondary);
            margin-bottom: 30px;
            max-width: 600px;
            margin-left: auto;
            margin-right: auto;
            line-height: 1.7;
        }
        
        .prompt-suggestions {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
            gap: 12px;
            margin-top: 30px;
        }
        
        .prompt-suggestion {
            padding: 12px 18px;
            background: var(--message-bg);
            border-radius: 12px;
            cursor: pointer;
            border: 1px solid var(--border-color);
            transition: all var(--transition-speed) var(--transition-easing);
            font-size: 14px;
            color: var(--text-secondary);
            box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
            text-align: left;
        }
        
        .prompt-suggestion:hover {
            border-color: var(--primary);
            color: var(--primary);
            transform: translateY(-2px);
            box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
        }

        /* --- Prose / Markdown styling (headings, lists, tables, quotes) --- */
.prose { font-size: 15px; line-height: 1.75; }
.prose h1,.prose h2,.prose h3,.prose h4{
  font-weight:800;letter-spacing:.2px;margin:16px 0 8px;
  background:linear-gradient(90deg,#8b5cf6,#ec4899);
  -webkit-background-clip:text; background-clip:text; -webkit-text-fill-color:transparent;
}
.prose h1{font-size:26px}.prose h2{font-size:22px}.prose h3{font-size:18px}.prose h4{font-size:16px}
.prose p{margin:10px 0}
.prose ul,.prose ol{margin:8px 0 12px 20px}
.prose li{margin:6px 0}
.prose blockquote{margin:10px 0;padding:10px 14px;border-left:3px solid var(--primary);
  background:rgba(124,58,237,.08);border-radius:6px}
.prose table{width:100%;border-collapse:collapse;margin:12px 0;border:1px solid var(--border-color);
  border-radius:8px;overflow:hidden}
.prose th,.prose td{padding:10px 12px;border-bottom:1px solid var(--border-color);text-align:left}
.prose thead th{background:rgba(124,58,237,.08);font-weight:700}
.prose code{background:rgba(0,0,0,.14);padding:2px 6px;border-radius:4px;font-family:var(--code-font);font-size:90%}
.prose pre code{background:none;padding:0}
.prose hr{border:none;border-top:1px solid var(--border-color);margin:14px 0}
        
        .message {
            max-width: 800px;
            margin: 0 auto 25px;
            display: flex;
            gap: 20px;
            animation: fadeInUp 0.4s ease-out;
        }
        
        .message-avatar {
            width: 40px;
            height: 40px;
            border-radius: 10px;
            background: var(--gradient);
            color: white;
            display: flex;
            align-items: center;
            justify-content: center;
            flex-shrink: 0;
            font-weight: 600;
            box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
            transition: transform 0.3s ease;
        }

        .message-avatar.has-image {
            background: transparent;
            color: transparent;
            padding: 0;
        }

        .message-avatar.has-image img {
            width: 100%;
            height: 100%;
            border-radius: 10px;
            object-fit: cover;
            display: block;
        }
        
        .message:hover .message-avatar {
            transform: scale(1.05);
        }
        
        .message-content {
            flex: 1;
            padding-top: 5px;
        }
        
        .message-text {
            background: var(--message-bg);
            padding: 18px 22px;
            border-radius: 14px;
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
            font-size: 15px;
            color: var(--text-primary);
            line-height: 1.7;
            position: relative;
            overflow-x: auto;
            overflow-y: visible;
        }
        
        .message-text p {
            margin-bottom: 12px;
        }
        
        .message-text p:last-child {
            margin-bottom: 0;
        }
        
        .message-text a {
            color: var(--primary);
            text-decoration: none;
            font-weight: 500;
        }
        
        .message-text a:hover {
            text-decoration: underline;
        }
        
        .user-message .message-avatar:not(.has-image) {
            background: var(--success-color);
        }
        
        .user-message .message-text {
            background: var(--user-message-bg);
            border-bottom-right-radius: 4px;
        }
        
        .assistant-message .message-text {
            border-bottom-left-radius: 4px;
        }

        .message-text .katex {
            font-size: 1.16em;
            font-variant-numeric: lining-nums;
        }

        .message-text .katex,
        .message-text .katex * {
            font-family: "KaTeX_Main", "KaTeX_Math", "Times New Roman", serif !important;
        }

        .message-text .katex .mathnormal,
        .message-text .katex .mathit {
            font-family: "KaTeX_Math", "KaTeX_Main", "Times New Roman", serif !important;
        }

        .message-text .katex .mathrm,
        .message-text .katex .textord,
        .message-text .katex .mord,
        .message-text .katex .mnum {
            font-family: "KaTeX_Main", "Times New Roman", serif !important;
        }

        .message-text .katex-display {
            margin: 0.8rem 0;
            overflow-x: auto;
            overflow-y: hidden;
            padding: 0.2rem 0.1rem;
        }

        .message-text .katex-display > .katex {
            display: inline-block;
            max-width: 100%;
        }

        .message-text .markdown-body.math-text {
            display: block;
            margin: 0.9rem 0;
            padding: 0.15rem 0;
            background: transparent;
            border: 0;
            box-shadow: none;
        }

        .message-text .markdown-body.math-text.inline {
            display: inline;
            margin: 0 0.08rem;
            padding: 0;
            border-radius: 0;
            border: 0;
            background: transparent;
            box-shadow: none;
        }

        .message-text .markdown-body.math-text .katex-display {
            margin: 0;
            text-align: center;
        }

        .message-text .markdown-body.math-text .mord,
        .message-text .markdown-body.math-text .mord .mtight,
        .message-text .markdown-body.math-text .mord.text,
        .message-text .katex .mord {
            font-variant-numeric: lining-nums;
        }

        .ai-generated-gallery {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
            gap: 14px;
            margin: 4px 0 12px;
        }

        .ai-generated-image {
            position: relative;
            border-radius: 14px;
            overflow: hidden;
            border: 1px solid rgba(15, 23, 42, 0.12);
            background: rgba(15, 23, 42, 0.03);
            box-shadow: 0 12px 28px rgba(15, 23, 42, 0.12);
        }

        .ai-generated-image img {
            display: block;
            width: 100%;
            height: auto;
        }

        .ai-generated-caption {
            font-size: 12px;
            color: var(--text-secondary);
            margin-top: 4px;
        }

        .ai-image-toolbar {
            position: absolute;
            left: 10px;
            right: 10px;
            bottom: 10px;
            display: flex;
            gap: 8px;
            flex-wrap: wrap;
            opacity: 0;
            transform: translateY(6px);
            transition: opacity 0.25s ease, transform 0.25s ease;
        }

        .ai-generated-image:hover .ai-image-toolbar {
            opacity: 1;
            transform: translateY(0);
        }

        .ai-image-btn {
            border: 0;
            padding: 6px 10px;
            border-radius: 999px;
            font-size: 11px;
            font-weight: 600;
            letter-spacing: 0.3px;
            cursor: pointer;
            color: #0f172a;
            background: rgba(255, 255, 255, 0.92);
            box-shadow: 0 6px 16px rgba(15, 23, 42, 0.18);
            transition: transform 0.2s ease, box-shadow 0.2s ease;
        }

        .ai-image-btn:hover {
            transform: translateY(-1px);
            box-shadow: 0 10px 20px rgba(15, 23, 42, 0.22);
        }

        .ai-image-btn.primary {
            background: linear-gradient(135deg, rgba(52, 211, 153, 0.95), rgba(16, 185, 129, 0.95));
            color: white;
        }

        .ai-generation-shell {
            display: grid;
            gap: 14px;
        }

        .ai-generation-card {
            border-radius: 16px;
            padding: 18px;
            background: rgba(15, 23, 42, 0.04);
            border: 1px solid rgba(15, 23, 42, 0.08);
            box-shadow: inset 0 0 0 1px rgba(255,255,255,0.5);
            position: relative;
            overflow: hidden;
        }

        .ai-generation-spinner {
            width: 64px;
            height: 64px;
            border-radius: 50%;
            border: 6px solid rgba(148, 163, 184, 0.3);
            border-top-color: rgba(52, 211, 153, 0.95);
            animation: spin 1s linear infinite;
            margin: 24px auto;
        }

        .ai-generation-footer {
            display: flex;
            align-items: center;
            justify-content: space-between;
            margin-top: 12px;
            font-size: 12px;
            color: var(--text-secondary);
        }

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

        .ai-image-watermark {
            position: absolute;
            left: 6px;
            bottom: 6px;
            width: 36px;
            height: auto;
            opacity: 0.8;
            pointer-events: none;
            filter: drop-shadow(0 6px 12px rgba(15, 23, 42, 0.4));
        }

        .image-lightbox {
            position: fixed;
            inset: 0;
            background: rgba(8, 12, 24, 0.88);
            display: flex;
            align-items: center;
            justify-content: center;
            z-index: 3000;
            opacity: 0;
            pointer-events: none;
            transition: opacity 0.3s ease;
            padding: 24px;
        }

        .image-lightbox.active {
            opacity: 1;
            pointer-events: auto;
        }

        .image-lightbox-content {
            position: relative;
            max-width: min(92vw, 1100px);
            max-height: 86vh;
            width: auto;
            height: auto;
            border-radius: 18px;
            overflow: hidden;
            box-shadow: 0 30px 80px rgba(5, 10, 20, 0.6);
            background: rgba(15, 23, 42, 0.8);
            border: 1px solid rgba(148, 163, 184, 0.2);
        }

        .image-lightbox-content img {
            display: block;
            width: 100%;
            height: auto;
            max-height: 86vh;
            object-fit: contain;
        }

        .image-lightbox-close {
            position: absolute;
            top: 10px;
            right: 10px;
            background: rgba(15, 23, 42, 0.8);
            color: #f8fafc;
            border: 0;
            width: 36px;
            height: 36px;
            border-radius: 50%;
            font-size: 20px;
            cursor: pointer;
            display: grid;
            place-items: center;
            box-shadow: 0 8px 20px rgba(15, 23, 42, 0.4);
        }
        
        .typing-cursor {
            display: inline-block;
            width: 8px;
            height: 18px;
            background: var(--primary);
            margin-left: 4px;
            animation: blink 1s infinite;
            vertical-align: middle;
        }
        
        .code-block {
    margin: 15px 0;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.code-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background-color: #2d2d2d;
    color: #f8f8f2;
    font-family: var(--main-font);
    font-size: 12px;
}

.copy-code-btn {
    background: rgba(255, 255, 255, 0.1);
    color: #f8f8f2;
    border: none;
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: all 0.2s ease;
}

.copy-code-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.code-block pre {
    margin: 0;
    border-radius: 0;
}

.code-block code {
    display: block;
    padding: 12px;
    overflow-x: auto;
}

.message-text strong {
    font-weight: 600;
    color: var(--text-primary);
}

.message-text em {
    font-style: italic;
}
       
        /* Code block styling */
        pre {
            background: var(--code-bg);
            color: var(--code-text);
            padding: 16px;
            border-radius: 8px;
            overflow-x: auto;
            margin: 12px 0;
            font-family: var(--code-font);
            font-size: 14px;
            line-height: 1.5;
            position: relative;
            tab-size: 2;
        }
        
        .code-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 8px;
            color: var(--code-text);
            font-family: var(--main-font);
        }
        
        .code-language {
            font-size: 12px;
            text-transform: uppercase;
            letter-spacing: 0.5px;
            opacity: 0.7;
        }
        
        .copy-btn {
            background: rgba(255, 255, 255, 0.1);
            color: var(--code-text);
            border: none;
            padding: 4px 8px;
            border-radius: 4px;
            cursor: pointer;
            font-size: 12px;
            transition: all 0.2s ease;
        }
        
        .copy-btn:hover {
            background: rgba(255, 255, 255, 0.2);
        }
        
        .copy-btn.copied {
            background: var(--success-color);
            color: white;
        }
        
        /* Run code button */
        .run-code-btn {
            background: rgba(255, 255, 255, 0.1);
            color: var(--code-text);
            border: none;
            padding: 4px 8px;
            border-radius: 4px;
            cursor: pointer;
            font-size: 12px;
            transition: all 0.2s ease;
            margin-right: 8px;
        }
        
        .run-code-btn:hover {
            background: rgba(255, 255, 255, 0.2);
        }
        
        .run-code-btn.running {
            background: var(--primary);
            color: white;
        }
        
        /* Code output */
        .code-output {
            background: #2a2a2a;
            color: #f8f8f2;
            padding: 12px;
            border-radius: 0 0 8px 8px;
            margin-top: -8px;
            border-top: 1px solid #444;
            font-family: var(--code-font);
            font-size: 14px;
            line-height: 1.5;
            white-space: pre-wrap;
        }
        
        /* Message actions */
        .message-actions {
            position: absolute;
            right: 10px;
            top: 10px;
            display: none;
            gap: 5px;
            background: rgba(255, 255, 255, 0.9);
            padding: 4px;
            border-radius: 6px;
            box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
        }
        
        .message:hover .message-actions {
            display: flex;
        }
        
        .message-action-btn {
            background: none;
            border: none;
            cursor: pointer;
            color: var(--text-secondary);
            padding: 4px;
            border-radius: 4px;
            transition: all var(--transition-speed) var(--transition-easing);
        }
        
        .message-action-btn:hover {
            color: var(--primary);
            background: rgba(124, 58, 237, 0.1);
        }
        
        /* Feedback buttons */
        .feedback-buttons {
            display: flex;
            gap: 8px;
            margin-top: 10px;
            justify-content: flex-end;
        }
        
        .feedback-btn {
            background: none;
            border: none;
            cursor: pointer;
            color: var(--text-secondary);
            font-size: 14px;
            display: flex;
            align-items: center;
            gap: 4px;
            padding: 4px 8px;
            border-radius: 4px;
            transition: all 0.2s ease;
        }
        
        .feedback-btn:hover {
            background: rgba(0, 0, 0, 0.05);
        }
        
        .feedback-btn.liked {
            color: var(--success-color);
        }
        
        .feedback-btn.disliked {
            color: var(--error-color);
        }
        
        /* Credit system */
        .credit-counter {
            position: absolute;
            right: 25px;
            top: 50%;
            transform: translateY(-50%);
            display: flex;
            align-items: center;
            gap: 14px;
            padding: 10px 16px;
            border-radius: 18px;
            background: rgba(15, 23, 42, 0.05);
            border: 1px solid rgba(148, 163, 184, 0.35);
            box-shadow: 0 8px 20px rgba(15, 23, 42, 0.08);
            color: var(--text-primary);
            min-width: 190px;
            backdrop-filter: blur(10px);
        }

        .chat-header .credit-counter {
            position: static;
            right: auto;
            top: auto;
            transform: none;
        }
        
        body.dark-mode .credit-counter {
            background: rgba(15, 23, 42, 0.6);
            border-color: rgba(148, 163, 184, 0.4);
            color: var(--sidebar-text);
            box-shadow: 0 10px 25px rgba(2, 6, 23, 0.55);
        }
        
        .credit-counter.credit-low {
            border-color: var(--warning-color);
        }
        
        .credit-counter.credit-empty {
            border-color: var(--error-color);
        }
        
        .credit-usage {
            position: relative;
            display: flex;
            align-items: center;
            justify-content: center;
            width: 48px;
            height: 48px;
            flex-shrink: 0;
        }
        
        .credit-ring {
            width: 48px;
            height: 48px;
            transform: rotate(-90deg);
        }
        
        .credit-ring-track,
        .credit-ring-progress {
            fill: none;
            stroke-width: 6;
            stroke-linecap: round;
        }
        
        .credit-ring-track {
            stroke: rgba(148, 163, 184, 0.3);
        }
        
        .credit-ring-progress {
            stroke: var(--primary);
            stroke-dasharray: 119.38;
            stroke-dashoffset: 0;
            transition: stroke-dashoffset 0.4s ease, stroke 0.3s ease;
        }
        
        .credit-ring-progress.credit-progress-low {
            stroke: var(--warning-color);
        }
        
        .credit-ring-progress.credit-progress-empty {
            stroke: var(--error-color);
        }
        
        .credit-usage-text {
            position: absolute;
            inset: 0;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            font-size: 14px;
            font-weight: 600;
        }
        
        .credit-usage-text span {
            line-height: 1;
        }

        #credit-count {
            font-size: 18px;
            color: var(--text-primary);
        }
        
        body.dark-mode #credit-count {
            color: var(--sidebar-text);
        }
        
        .credit-details {
            display: flex;
            flex-direction: column;
            gap: 4px;
        }
        
        .credit-label {
            font-size: 12px;
            font-weight: 600;
            letter-spacing: 0.3px;
            text-transform: uppercase;
            color: var(--text-secondary);
        }
        
        body.dark-mode .credit-label {
            color: rgba(226, 232, 240, 0.75);
        }
        
        .credit-reset {
            font-size: 12px;
            color: var(--text-secondary);
            opacity: 0.8;
        }
        
        body.dark-mode .credit-reset {
            color: rgba(226, 232, 240, 0.65);
        }
        
        .model-indicator {
            position: absolute;
            right: 25px;
            bottom: 5px;
            font-size: 12px;
            color: var(--text-secondary);
            opacity: 0.7;
        }
        
        .input-container {
            width: 100%;
            padding: 20px;
            border-top: 1px solid var(--border-color);
            background: var(--message-bg);
            position: relative;
        }

        .input-container.drag-active {
            border-top-color: rgba(79, 70, 229, 0.9);
            box-shadow: inset 0 0 0 1px rgba(79, 70, 229, 0.55), 0 -8px 20px rgba(79, 70, 229, 0.15);
        }
        
        .input-box {
            max-width: 800px;
            margin: 0 auto;
            position: relative;
        }

        .input-toolbar {
            display: flex;
            align-items: center;
            gap: 12px;
            margin-bottom: 12px;
            flex-wrap: wrap;
        }

        .pill-button {
            position: relative;
            display: inline-flex;
            align-items: center;
            gap: 12px;
            padding: 12px 18px 12px 14px;
            border-radius: 16px;
            border: 1px solid rgba(126, 132, 255, 0.45);
            background: linear-gradient(135deg, rgba(15, 23, 42, 0.9) 0%, rgba(79, 70, 229, 0.78) 55%, rgba(139, 92, 246, 0.9) 100%);
            color: #f8fafc;
            font-size: 14px;
            font-weight: 600;
            cursor: pointer;
            transition: all var(--transition-speed) var(--transition-easing);
            box-shadow: 0 12px 28px rgba(79, 70, 229, 0.35);
            overflow: hidden;
            isolation: isolate;
        }

        .pill-button::before {
            content: '';
            position: absolute;
            inset: 0;
            background: radial-gradient(circle at 20% 20%, rgba(255, 255, 255, 0.12), transparent 35%),
                        radial-gradient(circle at 80% 30%, rgba(56, 189, 248, 0.18), transparent 40%);
            opacity: 0.7;
            pointer-events: none;
            z-index: 0;
        }

        .pill-button::after {
            content: '';
            position: absolute;
            inset: -1px;
            border-radius: 18px;
            background: conic-gradient(from 0deg, rgba(139, 92, 246, 0.3), rgba(45, 212, 191, 0.35), rgba(79, 70, 229, 0.4), rgba(139, 92, 246, 0.3));
            opacity: 0;
            filter: blur(14px);
            transform: scale(0.95);
            transition: opacity var(--transition-speed) var(--transition-easing), transform var(--transition-speed) var(--transition-easing);
            z-index: 0;
            pointer-events: none;
        }

        .pill-group.deepthink-active .pill-button::after {
            opacity: 0.7;
            transform: scale(1);
            animation: deepthinkOrbit 7s linear infinite;
        }

        .pill-group.deepthink-processing .pill-button::after {
            opacity: 1;
            animation-duration: 3.6s;
        }

        .pill-group.deepthink-processing .pill-button {
            box-shadow: 0 18px 38px rgba(79, 70, 229, 0.45);
        }

        .pill-group.deepthink-deep .pill-button {
            box-shadow: 0 20px 42px rgba(15, 23, 42, 0.4);
            border-color: rgba(72, 89, 255, 0.65);
        }

        .pill-group.deepthink-processing-deep .pill-button {
            border-color: rgba(34, 211, 238, 0.8);
        }

        @keyframes deepthinkOrbit {
            0% { transform: scale(1) rotate(0deg); opacity: 0.55; }
            50% { transform: scale(1.03) rotate(180deg); opacity: 0.95; }
            100% { transform: scale(1) rotate(360deg); opacity: 0.55; }
        }

        @keyframes deepthinkPulse {
            0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(79, 70, 229, 0.35); }
            50% { transform: scale(1.04); box-shadow: 0 0 0 8px rgba(79, 70, 229, 0.1); }
            100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(79, 70, 229, 0.35); }
        }

        @keyframes deepthinkDot {
            0%, 80%, 100% { transform: scale(0.9); opacity: 0.35; }
            40% { transform: scale(1.1); opacity: 1; }
        }

        .pill-button:hover {
            transform: translateY(-2px);
            box-shadow: 0 16px 32px rgba(79, 70, 229, 0.4);
            border-color: rgba(126, 132, 255, 0.65);
        }

        .pill-button:active {
            transform: scale(0.98);
            box-shadow: 0 12px 28px rgba(79, 70, 229, 0.32);
        }

        .pill-button .pill-icon {
            position: relative;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            width: 32px;
            height: 32px;
            border-radius: 12px;
            background: linear-gradient(145deg, rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0.08));
            color: #f8fafc;
            font-size: 14px;
            box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 10px 20px rgba(15, 23, 42, 0.28);
            z-index: 1;
        }

        .pill-button .pill-text {
            position: relative;
            display: flex;
            flex-direction: column;
            align-items: flex-start;
            gap: 2px;
            z-index: 1;
        }

        .pill-button .pill-label {
            letter-spacing: 0.4px;
            text-transform: uppercase;
            font-size: 11px;
            color: rgba(241, 245, 249, 0.88);
        }

        .pill-button .pill-value {
            font-size: 14px;
            font-weight: 700;
            color: #fff;
        }

        .pill-button .pill-subtext {
            font-size: 12px;
            color: rgba(241, 245, 249, 0.75);
        }

        .pill-button .pill-chip {
            position: relative;
            margin-left: auto;
            padding: 6px 10px;
            border-radius: 999px;
            font-size: 11px;
            letter-spacing: 0.4px;
            color: #0f172a;
            background: linear-gradient(135deg, #f8fafc 0%, #c7d2fe 100%);
            box-shadow: 0 8px 16px rgba(15, 23, 42, 0.18);
            z-index: 1;
        }

        .pill-button[aria-expanded="true"],
        .pill-group.open .pill-button {
            box-shadow: 0 20px 40px rgba(79, 70, 229, 0.45);
            border-color: rgba(126, 132, 255, 0.75);
        }

        .pill-group.deepthink-processing .pill-icon {
            animation: deepthinkPulse 2s ease-in-out infinite;
        }

        .pill-group {
            position: relative;
        }

        #websearch-control .pill-button {
            background: linear-gradient(135deg, rgba(15, 23, 42, 0.92) 0%, rgba(13, 148, 136, 0.78) 55%, rgba(20, 184, 166, 0.9) 100%);
            border-color: rgba(20, 184, 166, 0.5);
            box-shadow: 0 12px 28px rgba(13, 148, 136, 0.28);
        }

        #websearch-control .pill-button:hover {
            box-shadow: 0 16px 32px rgba(13, 148, 136, 0.35);
            border-color: rgba(20, 184, 166, 0.7);
        }

        #websearch-control .pill-chip {
            background: linear-gradient(135deg, #ecfeff 0%, #99f6e4 100%);
            color: #0f172a;
        }

        #websearch-control.websearch-active .pill-button::after {
            opacity: 0.75;
        }

        #websearch-control.websearch-inactive .pill-button {
            filter: saturate(0.8);
            opacity: 0.88;
        }

        .websearch-card {
            display: flex;
            flex-direction: column;
            gap: 12px;
            padding: 16px 18px;
            border-radius: 18px;
            border: 1px solid rgba(45, 212, 191, 0.22);
            background:
                radial-gradient(circle at top right, rgba(45, 212, 191, 0.16), transparent 34%),
                radial-gradient(circle at top left, rgba(59, 130, 246, 0.12), transparent 28%),
                linear-gradient(145deg, rgba(15, 23, 42, 0.96) 0%, rgba(10, 37, 64, 0.88) 54%, rgba(15, 23, 42, 0.92) 100%);
            color: #e2e8f0;
            box-shadow: 0 22px 44px rgba(15, 23, 42, 0.32);
            transition: all 220ms var(--transition-easing);
        }

        .websearch-header {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 12px;
            font-weight: 600;
            font-size: 14px;
        }

        .websearch-header-main {
            display: flex;
            align-items: center;
            gap: 10px;
        }

        .websearch-query {
            font-size: 12px;
            color: rgba(226, 232, 240, 0.92);
            font-weight: 500;
        }

        .websearch-meta {
            font-size: 11px;
            color: rgba(148, 163, 184, 0.95);
            letter-spacing: 0.04em;
            text-transform: uppercase;
        }

        .websearch-spinner {
            width: 16px;
            height: 16px;
            border-radius: 50%;
            border: 2px solid rgba(226, 232, 240, 0.3);
            border-top-color: #5eead4;
            animation: websearchSpin 0.8s linear infinite;
        }

        .websearch-actions {
            display: inline-flex;
            gap: 8px;
            align-items: center;
        }

        .websearch-action-btn {
            border: 1px solid rgba(148, 163, 184, 0.35);
            background: rgba(15, 23, 42, 0.55);
            color: #e2e8f0;
            border-radius: 999px;
            font-size: 11px;
            padding: 4px 8px;
            cursor: pointer;
            transition: all 160ms ease;
        }

        .websearch-action-btn:hover {
            border-color: rgba(94, 234, 212, 0.6);
            color: #e0f2fe;
        }

        @keyframes websearchSpin {
            from { transform: rotate(0deg); }
            to { transform: rotate(360deg); }
        }

        .websearch-sites {
            list-style: none;
            margin: 0;
            padding: 0;
            display: grid;
            gap: 10px;
        }

        .websearch-site {
            display: flex;
            align-items: flex-start;
            gap: 10px;
            padding: 12px 12px;
            border-radius: 12px;
            background: rgba(15, 23, 42, 0.48);
            border: 1px solid rgba(148, 163, 184, 0.15);
            backdrop-filter: blur(8px);
        }

        .websearch-site a {
            color: #e0f2fe;
            text-decoration: none;
            font-weight: 600;
            font-size: 13px;
        }

        .websearch-site a:hover {
            text-decoration: underline;
        }

        .websearch-site-domain {
            font-size: 11px;
            color: rgba(148, 163, 184, 0.85);
        }

        .websearch-site-snippet {
            font-size: 12px;
            color: rgba(226, 232, 240, 0.8);
            line-height: 1.5;
        }

        .websearch-site-icon {
            width: 28px;
            height: 28px;
            border-radius: 8px;
            background: rgba(15, 23, 42, 0.7);
            border: 1px solid rgba(148, 163, 184, 0.25);
            display: inline-flex;
            align-items: center;
            justify-content: center;
            overflow: hidden;
            flex: 0 0 28px;
        }

        .websearch-site-icon img {
            width: 18px;
            height: 18px;
            object-fit: contain;
        }

        .websearch-site-content {
            display: flex;
            flex-direction: column;
            gap: 2px;
            flex: 1 1 auto;
        }

        .websearch-card.revealing .websearch-site {
            opacity: 0;
            transform: translateY(6px);
            animation: websearchReveal 720ms ease forwards;
        }

        .websearch-card.revealing .websearch-site:nth-child(1) { animation-delay: 120ms; }
        .websearch-card.revealing .websearch-site:nth-child(2) { animation-delay: 260ms; }
        .websearch-card.revealing .websearch-site:nth-child(3) { animation-delay: 400ms; }
        .websearch-card.revealing .websearch-site:nth-child(4) { animation-delay: 540ms; }
        .websearch-card.revealing .websearch-site:nth-child(5) { animation-delay: 680ms; }

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

        .websearch-card.revealing .websearch-media-card,
        .websearch-card.revealing .websearch-news-item {
            opacity: 0;
            transform: translateY(6px);
            animation: websearchReveal 780ms ease forwards;
        }

        .websearch-card.revealing .websearch-media-card:nth-child(1),
        .websearch-card.revealing .websearch-news-item:nth-child(1) { animation-delay: 160ms; }
        .websearch-card.revealing .websearch-media-card:nth-child(2),
        .websearch-card.revealing .websearch-news-item:nth-child(2) { animation-delay: 320ms; }
        .websearch-card.revealing .websearch-media-card:nth-child(3),
        .websearch-card.revealing .websearch-news-item:nth-child(3) { animation-delay: 480ms; }
        .websearch-card.revealing .websearch-media-card:nth-child(4),
        .websearch-card.revealing .websearch-news-item:nth-child(4) { animation-delay: 640ms; }

        .websearch-card.minimized {
            padding: 10px 12px;
            gap: 6px;
            border-color: rgba(148, 163, 184, 0.25);
            background: rgba(15, 23, 42, 0.7);
        }

        .websearch-card.minimized .websearch-sites,
        .websearch-card.minimized .websearch-site-snippet {
            display: none;
        }

        .websearch-card.minimized .websearch-header {
            font-size: 12px;
        }

        .websearch-card.minimized .websearch-query {
            font-size: 11px;
            color: rgba(148, 163, 184, 0.9);
        }

        .websearch-summary {
            display: flex;
            gap: 8px;
            flex-wrap: wrap;
            align-items: center;
        }

        .websearch-summary-item {
            display: inline-flex;
            align-items: center;
            gap: 6px;
            padding: 4px 8px;
            border-radius: 999px;
            background: rgba(15, 23, 42, 0.62);
            border: 1px solid rgba(148, 163, 184, 0.16);
            font-size: 11px;
            color: rgba(226, 232, 240, 0.85);
            max-width: 100%;
        }

        .websearch-summary-item img {
            width: 14px;
            height: 14px;
            object-fit: contain;
        }

        .websearch-media {
            display: grid;
            gap: 10px;
        }

        .websearch-media-title {
            font-size: 12px;
            font-weight: 600;
            color: rgba(226, 232, 240, 0.85);
            text-transform: uppercase;
            letter-spacing: 0.4px;
        }

        .websearch-media-grid {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
            gap: 8px;
        }

        .websearch-news-list {
            list-style: none;
            margin: 0;
            padding: 0;
            display: grid;
            gap: 8px;
        }

        .websearch-news-item {
            display: flex;
            flex-direction: column;
            gap: 4px;
            padding: 10px 12px;
            border-radius: 12px;
            background: rgba(15, 23, 42, 0.55);
            border: 1px solid rgba(148, 163, 184, 0.2);
        }

        .websearch-news-item a {
            color: #e0f2fe;
            text-decoration: none;
            font-weight: 600;
            font-size: 13px;
        }

        .websearch-news-item a:hover {
            text-decoration: underline;
        }

        .websearch-news-meta {
            font-size: 11px;
            color: rgba(148, 163, 184, 0.85);
        }

        .websearch-media-card {
            position: relative;
            border-radius: 10px;
            overflow: hidden;
            background: rgba(15, 23, 42, 0.6);
            border: 1px solid rgba(148, 163, 184, 0.2);
            aspect-ratio: 16 / 10;
        }

        .websearch-media-card img {
            width: 100%;
            height: 100%;
            object-fit: cover;
            display: block;
        }

        .websearch-media-card .media-label {
            position: absolute;
            inset: auto 6px 6px 6px;
            background: rgba(15, 23, 42, 0.72);
            color: #e2e8f0;
            font-size: 10px;
            padding: 4px 6px;
            border-radius: 8px;
            line-height: 1.2;
        }

        .websearch-card.minimized .websearch-media {
            display: none;
        }

        .websearch-card.minimized .websearch-meta {
            font-size: 10px;
        }

        .deepthink-popover {
            position: absolute;
            top: auto;
            bottom: calc(100% + 16px);
            left: 0;
            min-width: 320px;
            padding: 20px;
            border-radius: 18px;
            background: radial-gradient(circle at 15% 20%, rgba(126, 132, 255, 0.12), transparent 32%),
                        radial-gradient(circle at 80% 0%, rgba(45, 212, 191, 0.12), transparent 35%),
                        var(--message-bg);
            border: 1px solid rgba(148, 163, 184, 0.28);
            box-shadow: 0 18px 40px rgba(15, 23, 42, 0.18);
            opacity: 0;
            pointer-events: none;
            transform: translateY(12px);
            transition: all var(--transition-speed) var(--transition-easing);
            z-index: 50;
        }

        .pill-group.open .deepthink-popover {
            opacity: 1;
            pointer-events: auto;
            transform: translateY(0);
        }

        .deepthink-popover::after {
            content: '';
            position: absolute;
            top: auto;
            bottom: -8px;
            left: 26px;
            width: 16px;
            height: 16px;
            background: inherit;
            border-right: inherit;
            border-bottom: inherit;
            transform: rotate(45deg);
        }

        .deepthink-popover-header {
            display: flex;
            align-items: baseline;
            justify-content: space-between;
            gap: 12px;
            margin-bottom: 8px;
        }

        .deepthink-popover-title {
            font-size: 13px;
            text-transform: uppercase;
            letter-spacing: 0.6px;
            font-weight: 700;
            color: var(--text-secondary);
        }

        .deepthink-value {
            font-size: 14px;
            font-weight: 700;
            color: var(--primary);
        }

        .deepthink-progress {
            display: inline-flex;
            align-items: center;
            gap: 10px;
            padding: 10px 12px;
            border-radius: 12px;
            background: rgba(15, 23, 42, 0.04);
            border: 1px solid rgba(148, 163, 184, 0.22);
            color: var(--text-secondary);
            font-size: 12px;
            margin: 8px 0 12px;
        }

        .deepthink-progress strong {
            color: var(--text-primary);
        }

        .deepthink-progress .progress-dots {
            display: inline-flex;
            gap: 6px;
        }

        .deepthink-progress .progress-dots span {
            width: 8px;
            height: 8px;
            border-radius: 50%;
            background: var(--primary);
            animation: deepthinkDot 1.2s ease-in-out infinite;
        }

        .deepthink-progress .progress-dots span:nth-child(2) {
            animation-delay: 0.15s;
        }

        .deepthink-progress .progress-dots span:nth-child(3) {
            animation-delay: 0.3s;
        }

        .deepthink-stat-row {
            display: flex;
            align-items: center;
            gap: 10px;
            margin-bottom: 12px;
            padding: 10px 12px;
            border-radius: 12px;
            background: rgba(79, 70, 229, 0.06);
        }

        .deepthink-signal {
            width: 10px;
            height: 10px;
            border-radius: 50%;
            background: #22d3ee;
            box-shadow: 0 0 0 6px rgba(34, 211, 238, 0.12);
        }

        .deepthink-stat-copy {
            display: flex;
            flex-direction: column;
            gap: 2px;
        }

        .deepthink-stat-title {
            font-size: 12px;
            font-weight: 700;
            color: var(--text-primary);
        }

        .deepthink-stat-sub {
            font-size: 11px;
            color: var(--text-secondary);
        }

        .deepthink-hint {
            font-size: 12px;
            color: var(--text-secondary);
            margin-bottom: 14px;
        }

        .deepthink-scale {
            display: flex;
            justify-content: space-between;
            font-size: 12px;
            margin-top: 10px;
            color: var(--text-secondary);
        }

        .deepthink-scale span {
            position: relative;
            font-weight: 600;
            transition: color var(--transition-speed) var(--transition-easing);
            padding: 6px 10px;
            border-radius: 10px;
            cursor: pointer;
        }

        .deepthink-scale span.active {
            color: #0f172a;
            background: linear-gradient(135deg, #c7d2fe, #a5b4fc);
            box-shadow: 0 8px 16px rgba(79, 70, 229, 0.15);
        }

        .deepthink-scale span.active::before {
            content: '';
            position: absolute;
            left: 50%;
            bottom: -10px;
            transform: translateX(-50%);
            width: 18px;
            height: 4px;
            border-radius: 999px;
            background: linear-gradient(135deg, #4f46e5, #22d3ee);
        }

        #deepthink-slider {
            -webkit-appearance: none;
            appearance: none;
            width: 100%;
            height: 8px;
            border-radius: 999px;
            background: linear-gradient(90deg, rgba(99, 102, 241, 0.15), rgba(45, 212, 191, 0.18));
            outline: none;
            cursor: pointer;
            transition: background var(--transition-speed) var(--transition-easing);
            margin: 4px 0;
            box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.16);
        }

        #deepthink-slider::-webkit-slider-thumb {
            -webkit-appearance: none;
            appearance: none;
            width: 22px;
            height: 22px;
            border-radius: 12px;
            background: radial-gradient(circle at 30% 30%, #fff, #c7d2fe);
            box-shadow: 0 8px 16px rgba(79, 70, 229, 0.25);
            border: 2px solid rgba(79, 70, 229, 0.4);
            transition: transform var(--transition-speed) var(--transition-easing);
        }

        #deepthink-slider::-moz-range-thumb {
            width: 22px;
            height: 22px;
            border-radius: 12px;
            background: radial-gradient(circle at 30% 30%, #fff, #c7d2fe);
            border: 2px solid rgba(79, 70, 229, 0.4);
            box-shadow: 0 8px 16px rgba(79, 70, 229, 0.25);
            transition: transform var(--transition-speed) var(--transition-easing);
        }

        #deepthink-slider:active::-webkit-slider-thumb,
        #deepthink-slider:active::-moz-range-thumb {
            transform: scale(1.1);
        }

        #deepthink-slider:disabled {
            opacity: 0.35;
            cursor: not-allowed;
        }

        #deepthink-slider:disabled::-webkit-slider-thumb,
        #deepthink-slider:disabled::-moz-range-thumb {
            background: rgba(148, 163, 184, 0.6);
            box-shadow: none;
        }

        #deepthink-control.deepthink-disabled .deepthink-scale span {
            opacity: 0.4;
            pointer-events: none;
        }

        .deepthink-tools {
            margin-top: 14px;
            border-top: 1px solid rgba(148, 163, 184, 0.28);
            padding-top: 14px;
        }

        .deepthink-tools-title {
            font-size: 12px;
            font-weight: 700;
            text-transform: uppercase;
            letter-spacing: 0.4px;
            color: var(--text-secondary);
            margin-bottom: 10px;
        }

        .deepthink-tool-grid {
            display: grid;
            grid-template-columns: repeat(2, minmax(0, 1fr));
            gap: 10px;
        }

        .deepthink-tool {
            display: flex;
            align-items: flex-start;
            gap: 10px;
            padding: 10px 12px;
            border-radius: 12px;
            border: 1px solid rgba(148, 163, 184, 0.28);
            background: rgba(248, 250, 252, 0.85);
            cursor: pointer;
            transition: all var(--transition-speed) var(--transition-easing);
        }

        .deepthink-tool i {
            color: var(--primary);
            font-size: 14px;
            margin-top: 1px;
        }

        .deepthink-tool .tool-copy {
            display: flex;
            flex-direction: column;
            gap: 3px;
        }

        .deepthink-tool .tool-title {
            font-size: 12px;
            font-weight: 700;
            color: var(--text-primary);
        }

        .deepthink-tool .tool-desc {
            font-size: 11px;
            color: var(--text-secondary);
            line-height: 1.4;
        }

        .deepthink-tool.active {
            border-color: rgba(79, 70, 229, 0.55);
            box-shadow: 0 12px 24px rgba(79, 70, 229, 0.18);
            background: linear-gradient(135deg, rgba(199, 210, 254, 0.4), rgba(16, 185, 129, 0.12));
        }

        body.dark-mode .pill-button {
            background: linear-gradient(135deg, rgba(30, 41, 59, 0.95) 0%, rgba(88, 80, 236, 0.9) 60%, rgba(139, 92, 246, 0.95) 100%);
            border-color: rgba(148, 163, 254, 0.55);
            color: rgba(248, 250, 252, 0.95);
            box-shadow: 0 18px 32px rgba(2, 6, 23, 0.75);
        }

        body.dark-mode .pill-group.open .pill-button {
            box-shadow: 0 24px 42px rgba(2, 6, 23, 0.85);
        }

        body.dark-mode .pill-button .pill-icon {
            background: linear-gradient(145deg, rgba(255, 255, 255, 0.22), rgba(255, 255, 255, 0.12));
            color: rgba(248, 250, 252, 0.95);
        }

        body.dark-mode .pill-button .pill-chip {
            background: linear-gradient(135deg, #e0e7ff, #c7d2fe);
            color: #0f172a;
        }

        #deepthink-control.deepthink-disabled .pill-button {
            background: rgba(148, 163, 184, 0.18);
            border-color: rgba(148, 163, 184, 0.35);
            color: var(--text-secondary);
            box-shadow: none;
        }

        #deepthink-control.deepthink-disabled .pill-button .pill-icon {
            background: rgba(148, 163, 184, 0.25);
            color: var(--text-secondary);
        }

        #deepthink-control.deepthink-disabled .pill-button .pill-label,
        #deepthink-control.deepthink-disabled .pill-button .pill-value,
        #deepthink-control.deepthink-disabled .pill-button .pill-subtext {
            color: #0f172a;
        }

        #deepthink-control.deepthink-disabled .pill-button .pill-chip {
            background: rgba(255, 255, 255, 0.85);
            color: var(--text-secondary);
            box-shadow: none;
        }

        #deepthink-control.deepthink-disabled .pill-button:hover,
        #deepthink-control.deepthink-disabled .pill-button:active {
            transform: none;
            box-shadow: none;
        }

        body.dark-mode #deepthink-control.deepthink-disabled .pill-button {
            background: rgba(30, 41, 59, 0.8);
            border-color: rgba(71, 85, 105, 0.5);
            color: rgba(226, 232, 240, 0.6);
        }

        body.dark-mode #deepthink-control.deepthink-disabled .pill-button .pill-icon {
            background: rgba(71, 85, 105, 0.45);
            color: rgba(226, 232, 240, 0.7);
        }

        body.dark-mode #deepthink-control.deepthink-disabled .pill-button .pill-label,
        body.dark-mode #deepthink-control.deepthink-disabled .pill-button .pill-value,
        body.dark-mode #deepthink-control.deepthink-disabled .pill-button .pill-subtext {
            color: #e2e8f0;
        }

        body.dark-mode #deepthink-control.deepthink-disabled .pill-button .pill-chip {
            background: rgba(148, 163, 184, 0.35);
            color: rgba(226, 232, 240, 0.75);
        }

        #deepthink-control.deepthink-model-blocked .deepthink-hint {
            color: var(--warning-color);
        }

        #deepthink-control.deepthink-model-blocked .pill-button {
            border-color: rgba(239, 68, 68, 0.45);
        }

        .deepthink-toggle-row {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 14px;
            margin-bottom: 14px;
        }

        .deepthink-toggle-label {
            font-size: 12px;
            font-weight: 600;
            letter-spacing: 0.5px;
            text-transform: uppercase;
            color: var(--text-secondary);
        }

        .deepthink-switch {
            position: relative;
            width: 44px;
            height: 24px;
            border-radius: 999px;
            border: none;
            cursor: pointer;
            background: rgba(148, 163, 184, 0.35);
            transition: all var(--transition-speed) var(--transition-easing);
            padding: 0;
        }

        .deepthink-switch::after {
            content: '';
            position: absolute;
            top: 4px;
            left: 4px;
            width: 16px;
            height: 16px;
            border-radius: 50%;
            background: #ffffff;
            box-shadow: 0 2px 6px rgba(15, 23, 42, 0.3);
            transition: all var(--transition-speed) var(--transition-easing);
        }

        .deepthink-switch.active {
            background: var(--primary);
            box-shadow: 0 8px 16px rgba(79, 70, 229, 0.25);
        }

        .deepthink-switch.active::after {
            transform: translateX(20px);
        }

        .deepthink-switch:focus-visible {
            outline: 2px solid rgba(79, 70, 229, 0.4);
            outline-offset: 2px;
        }

        body.dark-mode .deepthink-switch {
            background: rgba(71, 85, 105, 0.55);
        }

        body.dark-mode .deepthink-switch.active {
            background: rgba(129, 140, 248, 0.85);
        }

        #deepthink-control.deepthink-disabled .deepthink-switch {
            opacity: 0.8;
        }

        body.dark-mode .deepthink-popover {
            background: radial-gradient(circle at 15% 20%, rgba(126, 132, 255, 0.2), transparent 34%),
                        radial-gradient(circle at 80% 0%, rgba(34, 211, 238, 0.16), transparent 35%),
                        rgba(15, 23, 42, 0.96);
            border-color: rgba(71, 85, 105, 0.5);
            box-shadow: 0 24px 44px rgba(2, 6, 23, 0.8);
        }

        body.dark-mode .deepthink-popover::after {
            background: rgba(15, 23, 42, 0.96);
            border-right-color: rgba(71, 85, 105, 0.5);
            border-bottom-color: rgba(71, 85, 105, 0.5);
        }

        body.dark-mode .deepthink-popover-title {
            color: rgba(226, 232, 240, 0.75);
        }

        body.dark-mode .deepthink-hint {
            color: rgba(226, 232, 240, 0.6);
        }

        body.dark-mode .deepthink-progress {
            background: rgba(30, 41, 59, 0.7);
            border-color: rgba(71, 85, 105, 0.45);
            color: rgba(226, 232, 240, 0.7);
        }

        body.dark-mode .deepthink-progress strong {
            color: rgba(226, 232, 240, 0.92);
        }

        body.dark-mode .deepthink-stat-row {
            background: rgba(79, 70, 229, 0.15);
        }

        body.dark-mode .deepthink-stat-title {
            color: rgba(226, 232, 240, 0.9);
        }

        body.dark-mode .deepthink-stat-sub {
            color: rgba(226, 232, 240, 0.65);
        }

        body.dark-mode .deepthink-scale span {
            color: rgba(226, 232, 240, 0.55);
        }

        body.dark-mode #deepthink-slider {
            background: rgba(226, 232, 240, 0.2);
        }

        body.dark-mode .deepthink-scale span.active {
            color: #0f172a;
        }

        body.dark-mode .deepthink-tool {
            background: rgba(30, 41, 59, 0.75);
            border-color: rgba(71, 85, 105, 0.5);
            color: rgba(226, 232, 240, 0.95);
        }

        body.dark-mode .deepthink-tool .tool-title {
            color: rgba(226, 232, 240, 0.9);
        }

        body.dark-mode .deepthink-tool .tool-desc {
            color: rgba(226, 232, 240, 0.65);
        }

        body.dark-mode .deepthink-tool.active {
            background: linear-gradient(135deg, rgba(129, 140, 248, 0.25), rgba(16, 185, 129, 0.18));
            border-color: rgba(148, 163, 254, 0.6);
            box-shadow: 0 14px 26px rgba(2, 6, 23, 0.65);
        }
        
        .textarea-container {
            position: relative;
            border-radius: 18px;
            padding: 18px calc(var(--tool-tray-width) + 12px) 18px 20px;
            background: linear-gradient(145deg, rgba(255, 255, 255, 0.95), rgba(248, 250, 252, 0.98));
            border: 1px solid var(--input-border);
            box-shadow: var(--input-glow);
            transition: all var(--transition-speed) var(--transition-easing);
            isolation: isolate;
            overflow: hidden;
        }
        
        .textarea-container::before {
            content: "";
            position: absolute;
            inset: -30% auto auto -35%;
            width: 70%;
            height: 180%;
            background: radial-gradient(circle at 30% 30%, rgba(110, 65, 226, 0.2), rgba(110, 65, 226, 0));
            filter: blur(28px);
            z-index: 0;
            opacity: 0.8;
        }
        
        .textarea-container::after {
            content: "";
            position: absolute;
            inset: 0;
            background: var(--input-sheen);
            opacity: 0;
            transition: opacity var(--transition-speed) var(--transition-easing);
            z-index: 0;
        }
        
        .textarea-container:focus-within {
            border-color: rgba(110, 65, 226, 0.35);
            box-shadow: var(--input-glow-strong);
            transform: translateY(-1px);
        }
        
        .textarea-container:focus-within::after {
            opacity: 0.8;
        }
        
        #user-input {
            position: relative;
            z-index: 1;
            width: 100%;
            min-height: 60px;
            max-height: 220px;
            padding: 6px 0;
            border: none;
            border-radius: 12px;
            resize: none;
            outline: none;
            font-size: 16px;
            color: var(--text-primary);
            background: transparent;
            transition: all var(--transition-speed) var(--transition-easing);
            line-height: 1.6;
        }
        
        #user-input::placeholder {
            color: rgba(100, 116, 139, 0.7);
            letter-spacing: 0.01em;
        }
        
        .input-tools {
            position: absolute;
            right: 14px;
            top: 50%;
            transform: translateY(-50%);
            display: flex;
            gap: 10px;
            align-items: center;
            padding: 8px;
            background: rgba(255, 255, 255, 0.7);
            border-radius: 999px;
            border: 1px solid rgba(148, 163, 184, 0.25);
            box-shadow: 0 12px 30px rgba(15, 23, 42, 0.12);
            backdrop-filter: blur(12px);
            z-index: 1;
        }
        
        .tool-btn {
            background: none;
            border: none;
            cursor: pointer;
            color: var(--text-secondary);
            width: 38px;
            height: 38px;
            display: flex;
            align-items: center;
            justify-content: center;
            border-radius: 12px;
            transition: all var(--transition-speed) var(--transition-easing);
        }
        
        .tool-btn:hover {
            color: var(--primary);
            background: rgba(124, 58, 237, 0.12);
            transform: translateY(-1px) scale(1.05);
            box-shadow: 0 10px 24px rgba(124, 58, 237, 0.18);
        }
        
        .tool-btn:active {
            transform: scale(0.95);
        }
        
        .tool-btn.recording {
            color: var(--error-color);
            animation: pulse 1.5s infinite;
        }
        
        .submit-btn {
            position: relative;
            background: radial-gradient(circle at 25% 25%, #9d7bff, #4338ca 70%);
            color: white;
            border: none;
            width: 46px;
            height: 46px;
            border-radius: 14px;
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            transition: all var(--transition-speed) ease;
            box-shadow: 0 14px 30px rgba(67, 56, 202, 0.35), 0 0 0 1px rgba(255, 255, 255, 0.35) inset;
            overflow: hidden;
        }
        
        .submit-btn::after {
            content: "";
            position: absolute;
            inset: 0;
            background: linear-gradient(135deg, rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0));
            opacity: 0.8;
            transition: opacity var(--transition-speed) ease;
        }
        
        .submit-btn svg {
            position: relative;
            z-index: 1;
            transition: transform 0.2s ease;
        }

        .submit-btn-icon {
            position: relative;
            z-index: 1;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            transition: opacity 0.18s ease, transform 0.18s ease;
        }

        .submit-btn .stop-icon {
            position: absolute;
            opacity: 0;
            transform: scale(0.7);
        }

        .submit-btn.is-streaming {
            background: radial-gradient(circle at 25% 25%, #7c3aed, #312e81 70%);
        }

        .submit-btn.is-streaming .send-icon {
            opacity: 0;
            transform: scale(0.7);
        }

        .submit-btn.is-streaming .stop-icon {
            opacity: 1;
            transform: scale(1);
        }
        
        .submit-btn:hover {
            transform: translateY(-1px) scale(1.03);
            box-shadow: 0 18px 40px rgba(67, 56, 202, 0.4);
        }
        
        .submit-btn:hover svg {
            transform: translateX(1px) rotate(4deg);
        }

        .submit-btn.is-streaming:hover svg {
            transform: none;
        }
        
        .submit-btn:active {
            transform: scale(0.96);
        }
        
        .submit-btn:disabled {
            opacity: 0.6;
            cursor: not-allowed;
            transform: none;
            box-shadow: none;
        }
        
        @media (max-width: 768px) {
            .textarea-container {
                padding: 16px;
                padding-top: 18px;
                margin-bottom: 6px;
            }
            
            .input-tools {
                position: relative;
                top: auto;
                right: auto;
                transform: none;
                width: 100%;
                justify-content: flex-end;
                flex-wrap: wrap;
                gap: 8px;
                padding: 8px;
                margin-top: 10px;
            }
            
            .tool-btn {
                width: 34px;
                height: 34px;
            }
            
            #user-input {
                padding: 4px 0;
            }
        }
        
        body.dark-mode .textarea-container {
            background: linear-gradient(145deg, rgba(17, 24, 39, 0.95), rgba(15, 23, 42, 0.97));
            border-color: rgba(148, 163, 184, 0.18);
            box-shadow: 0 14px 40px rgba(0, 0, 0, 0.35);
        }
        
        body.dark-mode .textarea-container::before {
            background: radial-gradient(circle at 30% 30%, rgba(139, 92, 246, 0.28), rgba(59, 130, 246, 0));
        }
        
        body.dark-mode #user-input {
            color: #e2e8f0;
        }
        
        body.dark-mode #user-input::placeholder {
            color: rgba(226, 232, 240, 0.5);
        }
        
        body.dark-mode .input-tools {
            background: rgba(30, 41, 59, 0.75);
            border-color: rgba(148, 163, 184, 0.18);
            box-shadow: 0 12px 30px rgba(0, 0, 0, 0.4);
        }
        
        .typing-indicator {
            max-width: 800px;
            margin: 0 auto 20px;
            display: flex;
            gap: 20px;
            animation: fadeIn 0.3s ease-out;
        }
        
        .typing-dots {
            display: flex;
            gap: 8px;
            padding-top: 15px;
        }
        
        .typing-dot {
            width: 10px;
            height: 10px;
            border-radius: 50%;
            background: var(--primary);
            animation: typingAnimation 1.4s infinite ease-in-out;
        }
        
        .typing-dot:nth-child(1) {
            animation-delay: 0s;
        }
        
        .typing-dot:nth-child(2) {
            animation-delay: 0.2s;
        }
        
        .typing-dot:nth-child(3) {
            animation-delay: 0.4s;
        }

        .ai-response {
            display: block;
            font-size: 15px;
            line-height: 1.75;
            color: var(--text-primary);
        }

        .ai-response > * {
            margin: 0 0 16px;
        }

        .ai-response > *:last-child {
            margin-bottom: 0;
        }

        .ai-response > * + *:not(hr.ai-divider) {
            border-top: 1px solid rgba(100, 116, 139, 0.18);
            padding-top: 14px;
        }

        .ai-response p {
            margin: 0 0 12px;
        }

        .ai-response h1,
        .ai-response h2,
        .ai-response h3 {
            font-weight: 700;
            letter-spacing: 0.3px;
            margin: 18px 0 10px;
            background: linear-gradient(90deg, var(--primary), #ec4899);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            background-clip: text;
            text-fill-color: transparent;
        }

        .ai-response h1 { font-size: 24px; }
        .ai-response h2 { font-size: 20px; }
        .ai-response h3 { font-size: 17px; }

        .ai-response ul,
        .ai-response ol {
            margin: 0 0 12px 22px;
            padding: 0;
        }

        .ai-response li {
            margin-bottom: 6px;
        }

        .ai-response hr.ai-divider {
            border: none;
            border-top: 1px solid var(--border-color);
            margin: 18px 0;
        }

        .ai-code-block {
            margin: 16px 0;
            border-radius: 12px;
            overflow: hidden;
            background: #0f172a;
            color: #e2e8f0;
            border: 1px solid rgba(30, 64, 175, 0.35);
            box-shadow: 0 18px 44px rgba(7, 11, 23, 0.6);
        }

        .ai-code-header {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 10px;
            padding: 12px 16px;
            background: rgba(15, 23, 42, 0.92);
            border-bottom: 1px solid rgba(37, 99, 235, 0.25);
        }

        .ai-code-language {
            font-weight: 600;
            font-size: 12px;
            text-transform: uppercase;
            letter-spacing: 0.08em;
            color: rgba(191, 219, 254, 0.85);
        }

        .ai-code-block pre {
            margin: 0;
            padding: 16px 18px;
            overflow-x: auto;
            background: #0b1220;
        }

        .ai-code-block code {
            display: block;
            font-family: var(--code-font);
            font-size: 13px;
        }

        .ai-code-block code:not(.hljs) {
            color: #e2e8f0;
        }

        .streaming-pending {
            margin: 0;
            padding: 0;
            background: transparent;
            border: none;
            font-family: var(--code-font);
            font-size: 13px;
            color: inherit;
            white-space: pre-wrap;
            word-break: break-word;
        }

        .ai-code-block code:not(.hljs) * {
            color: inherit !important;
        }

        .ai-copy-code {
            display: inline-flex;
            align-items: center;
            gap: 6px;
            padding: 6px 12px;
            border-radius: 6px;
            border: 1px solid rgba(139, 92, 246, 0.6);
            background: rgba(124, 58, 237, 0.18);
            color: var(--code-text);
            font-size: 12px;
            font-weight: 500;
            transition: background var(--transition-speed) var(--transition-easing), border-color var(--transition-speed) var(--transition-easing), transform var(--transition-speed) var(--transition-easing);
        }

        .ai-copy-code:hover:not(:disabled) {
            background: rgba(124, 58, 237, 0.3);
            border-color: rgba(139, 92, 246, 0.9);
            transform: translateY(-1px);
        }

        .ai-copy-code:disabled {
            opacity: 0.6;
            cursor: default;
            transform: none;
        }

        .inline-code {
            background: rgba(37, 99, 235, 0.18);
            padding: 2px 6px;
            border-radius: 4px;
            font-family: var(--code-font);
            font-size: 90%;
            color: #e0f2ff;
        }

        .ai-response blockquote {
            margin: 14px 0;
            padding: 12px 16px;
            border-left: 3px solid var(--primary);
            background: rgba(124, 58, 237, 0.08);
            border-radius: 10px;
        }

        .ai-response blockquote p {
            margin: 0;
        }

        .ai-kv {
            margin: 14px 0;
            border: 1px solid var(--border-color);
            border-radius: 12px;
            overflow: hidden;
        }

        .ai-kv-row {
            display: grid;
            grid-template-columns: minmax(120px, 200px) 1fr;
            gap: 12px;
            padding: 10px 16px;
            align-items: baseline;
            background: var(--message-bg);
        }

        .ai-kv-row:nth-child(odd) {
            background: rgba(124, 58, 237, 0.04);
        }

        .ai-kv-key {
            font-weight: 600;
            color: var(--text-secondary);
            text-transform: uppercase;
            font-size: 12px;
            letter-spacing: 0.6px;
        }

        .ai-kv-value {
            color: var(--text-primary);
            font-size: 14px;
        }

        .ai-response table {
            width: 100%;
            border-collapse: collapse;
            margin: 18px 0;
            font-size: 14px;
        }

        .ai-response th,
        .ai-response td {
            border: 1px solid var(--border-color);
            padding: 10px 12px;
            text-align: left;
        }

        .ai-response thead th {
            background: rgba(124, 58, 237, 0.08);
            font-weight: 600;
        }

        .ai-response a {
            color: var(--primary);
            text-decoration: none;
        }

        .ai-response a:hover {
            text-decoration: underline;
        }

        @media (max-width: 520px) {
            .ai-kv-row {
                grid-template-columns: 1fr;
                gap: 4px;
            }

            .ai-kv-key {
                font-size: 11px;
            }
        }
        
        .document-preview {
            margin-bottom: 15px;
            padding: 14px 18px;
            background: var(--message-bg);
            border-radius: 12px;
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 10px;
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
            border: 1px solid var(--border-color);
            animation: fadeIn 0.3s ease-out;
        }
        
        .document-meta {
            display: flex;
            flex-direction: column;
            gap: 2px;
        }
        
        .document-helper,
        .document-status {
            font-size: 12px;
            color: var(--text-secondary);
        }
        
        .document-status.document-status-loading {
            color: var(--warning-color);
        }
        
        .document-info {
            display: flex;
            align-items: center;
            gap: 12px;
            font-size: 14px;
            color: var(--text-secondary);
        }
        
        .document-icon {
            color: var(--primary);
        }

        .document-image-preview {
            margin-top: 12px;
        }

        .document-image-preview img {
            max-width: 220px;
            max-height: 150px;
            border-radius: 10px;
            border: 1px solid var(--border-color);
            object-fit: cover;
            display: block;
        }
        
        .document-snippet {
            margin-top: 8px;
            padding: 8px 10px;
            background: rgba(99, 102, 241, 0.08);
            border-left: 3px solid var(--primary);
            border-radius: 10px;
            font-size: 12px;
            color: var(--text-primary);
            word-break: break-word;
            max-width: 420px;
        }
        
        .document-snippet-label {
            display: block;
            font-size: 11px;
            text-transform: uppercase;
            letter-spacing: 0.05em;
            color: var(--text-secondary);
            margin-bottom: 4px;
        }
        
        .remove-doc {
            cursor: pointer;
            color: var(--error-color);
            font-size: 20px;
            font-weight: bold;
            padding: 4px;
            border-radius: 4px;
            transition: all var(--transition-speed) var(--transition-easing);
        }
        
        .remove-doc:hover {
            background: rgba(239, 68, 68, 0.1);
            transform: rotate(90deg);
        }
        
        /* Modal Styles */
        .modal-overlay {
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: rgba(0, 0, 0, 0.5);
            display: flex;
            justify-content: center;
            align-items: center;
            z-index: 1000;
            opacity: 0;
            visibility: hidden;
            transition: all var(--transition-speed) var(--transition-easing);
            backdrop-filter: blur(5px);
        }
        
        .modal-overlay.active {
            opacity: 1;
            visibility: visible;
        }
        
        .modal {
            background: var(--message-bg);
            border-radius: 12px;
            box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
            width: 90%;
            max-width: 500px;
            transform: translateY(20px);
            transition: all var(--transition-speed) var(--transition-easing);
            max-height: 90vh;
            overflow-y: auto;
        }
        
        .modal-overlay.active .modal {
            transform: translateY(0);
        }
        
        .modal-header {
            padding: 16px 20px;
            border-bottom: 1px solid var(--border-color);
            display: flex;
            justify-content: space-between;
            align-items: center;
            position: sticky;
            top: 0;
            background: var(--message-bg);
            z-index: 10;
        }
        
        .modal-title {
            font-size: 18px;
            font-weight: 600;
            color: var(--text-primary);
        }
        
        .modal-close {
            background: none;
            border: none;
            cursor: pointer;
            color: var(--text-secondary);
            font-size: 20px;
            line-height: 1;
            padding: 4px;
            border-radius: 4px;
            transition: all var(--transition-speed) var(--transition-easing);
        }
        
        .modal-close:hover {
            color: var(--primary);
            background: rgba(124, 58, 237, 0.1);
        }
        
        .modal-body {
            padding: 20px;
        }
        
        .modal-input {
            width: 100%;
            padding: 12px 16px;
            border: 1px solid var(--border-color);
            border-radius: 8px;
            font-size: 15px;
            margin-bottom: 20px;
            transition: all var(--transition-speed) var(--transition-easing);
        }
        
        .modal-input:focus {
            border-color: var(--primary);
            box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.2);
            outline: none;
        }
        
        .modal-footer {
            padding: 16px 20px;
            border-top: 1px solid var(--border-color);
            display: flex;
            justify-content: flex-end;
            gap: 10px;
            position: sticky;
            bottom: 0;
            background: var(--message-bg);
        }
        
        .modal-btn {
            padding: 10px 16px;
            border-radius: 8px;
            font-weight: 500;
            cursor: pointer;
            transition: all var(--transition-speed) var(--transition-easing);
            text-decoration: none;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            gap: 8px;
        }
        
        .modal-btn-primary {
            background: var(--primary);
            color: white;
            border: none;
        }
        
        .modal-btn-primary:hover {
            background: var(--primary-dark);
        }
        
        .modal-btn-secondary {
            background: var(--message-bg);
            color: var(--text-primary);
            border: 1px solid var(--border-color);
        }
        
        .modal-btn-secondary:hover {
            background: var(--chat-bg);
        }
        
        .modal-critical {
            background: #0b1220;
            border: 1px solid rgba(248, 113, 113, 0.35);
            color: #f8fafc;
        }
        
        .modal-critical .modal-header,
        .modal-critical .modal-body,
        .modal-critical .modal-footer {
            background: transparent;
            border-color: rgba(148, 163, 184, 0.2);
        }
        
        .modal-critical-header {
            justify-content: space-between;
            gap: 16px;
        }
        
        .modal-critical-heading {
            display: flex;
            gap: 14px;
            align-items: center;
        }
        
        .modal-kicker {
            font-size: 12px;
            text-transform: uppercase;
            letter-spacing: 0.08em;
            color: #f97316;
            margin-bottom: 4px;
        }
        
        .modal-critical .modal-title {
            color: #fee2e2;
            font-size: 20px;
        }
        
        .modal-icon,
        .callout-icon,
        .btn-icon {
            display: inline-flex;
            width: 36px;
            height: 36px;
            border-radius: 50%;
            align-items: center;
            justify-content: center;
            background: rgba(248, 113, 113, 0.12);
            color: #f87171;
        }
        
        .modal-icon svg,
        .callout-icon svg,
        .btn-icon svg {
            width: 22px;
            height: 22px;
        }
        
        .modal-icon {
            border: 1px solid rgba(248, 113, 113, 0.3);
        }
        
        .risk-callout {
            display: flex;
            gap: 14px;
            padding: 14px 16px;
            border: 1px solid rgba(248, 113, 113, 0.3);
            border-radius: 10px;
            background: rgba(248, 113, 113, 0.08);
            margin-bottom: 16px;
        }
        
        .callout-title {
            color: #fecaca;
            font-weight: 600;
            margin-bottom: 4px;
        }

        .callout-text {
            font-size: 14px;
            color: rgba(248, 250, 252, 0.8);
        }
        
        .modal-critical-body p {
            color: rgba(248, 250, 252, 0.85);
            margin-bottom: 12px;
        }
        
        .risk-list {
            list-style: disc;
            padding-left: 20px;
            margin-bottom: 14px;
            color: rgba(248, 250, 252, 0.9);
        }
        
        .risk-list li {
            margin-bottom: 6px;
        }
        
        .audit-note {
            font-size: 13px;
            color: rgba(148, 163, 184, 0.9);
            border-top: 1px solid rgba(148, 163, 184, 0.2);
            padding-top: 12px;
            margin-top: 12px;
        }
        
        .modal-critical-footer {
            justify-content: flex-end;
            gap: 12px;
        }
        
        .modal-critical .modal-btn-primary {
            background: linear-gradient(120deg, #dc2626, #b91c1c);
            border: none;
        }
        
        .modal-critical .modal-btn-primary:hover {
            background: #991b1b;
        }
        
        .modal-btn-exit {
            background: rgba(15, 23, 42, 0.6);
            border: 1px solid rgba(248, 113, 113, 0.4);
            color: #fecaca;
        }
        
        .modal-btn-exit:hover {
            background: rgba(248, 113, 113, 0.15);
        }
        
        .btn-icon {
            width: 28px;
            height: 28px;
            margin-right: 8px;
            background: transparent;
            border: 1px solid rgba(248, 113, 113, 0.3);
        }
        
        .btn-icon svg {
            width: 16px;
            height: 16px;
        }

        .modal-btn-primary .btn-icon {
            color: #fff;
            border-color: rgba(255, 255, 255, 0.5);
        }

        .modal-btn-exit .btn-icon {
            color: #f87171;
            border-color: rgba(248, 113, 113, 0.6);
        }
        
        /* Credit modal */
        .credit-modal-body {
            text-align: center;
            padding: 20px;
        }
        
        .credit-icon-large {
            width: 48px;
            height: 48px;
            margin-bottom: 16px;
            color: var(--primary);
        }
        
        .credit-modal-text {
            margin-bottom: 20px;
            color: var(--text-primary);
        }

        .credit-modal-upgrade {
            margin-top: -8px;
            margin-bottom: 18px;
            color: var(--text-secondary);
        }

        .credit-modal-upgrade a {
            color: var(--primary);
            font-weight: 600;
            text-decoration: none;
        }

        .credit-modal-upgrade a:hover {
            text-decoration: underline;
        }
        
        .credit-reset-timer {
            font-size: 16px;
            font-weight: 600;
            color: var(--primary);
            margin-top: 10px;
        }
        
        /* Edit message modal */
        .edit-message-textarea {
            width: 100%;
            min-height: 150px;
            padding: 12px;
            border: 1px solid var(--border-color);
            border-radius: 8px;
            font-size: 15px;
            margin-bottom: 15px;
            resize: vertical;
        }
        
        /* Settings Modal */
        .settings-modal {
            max-width: 860px;
            width: calc(100% - 40px);
        }
        
        .settings-modal .modal-body {
            padding: 0;
        }
        
        .settings-body {
            padding: 28px;
            display: flex;
            flex-direction: column;
            gap: 24px;
            background: var(--chat-bg);
        }
        
        .settings-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
            gap: 20px;
        }
        
        .settings-section {
            margin: 0;
        }
        
        .settings-card {
            background: var(--message-bg);
            border: 1px solid var(--border-color);
            border-radius: 18px;
            padding: 20px 22px;
            box-shadow: 0 15px 30px rgba(15, 23, 42, 0.08);
        }
        
        .settings-card--profile {
            display: flex;
            flex-direction: column;
            gap: 16px;
            background: linear-gradient(135deg, rgba(110,65,226,0.08), rgba(59,130,246,0.05)), var(--message-bg);
        }
        
        .settings-card--models {
            background: linear-gradient(135deg, rgba(15,23,42,0.92), rgba(51,65,85,0.75));
            border-color: rgba(255,255,255,0.08);
            color: #e2e8f0;
        }
        
        .settings-card--models .model-option {
            border-color: rgba(255,255,255,0.15);
            background: rgba(15,23,42,0.6);
        }
        
        .settings-card--models .model-option.active {
            background: rgba(255,255,255,0.08);
        }
        
        .settings-card--models .model-description {
            color: rgba(226,232,240,0.8);
        }
        
        .settings-card--models .settings-description,
        .settings-card--models .settings-label {
            color: rgba(226,232,240,0.8);
        }

        /* Light-mode readability for AI Stack card */
        body:not(.dark-mode) .settings-card--models {
            background: linear-gradient(135deg, #f8fafc, #eef2ff);
            border-color: rgba(148, 163, 184, 0.45);
            color: var(--text-primary);
        }
        
        body:not(.dark-mode) .settings-card--models .settings-card-header h3,
        body:not(.dark-mode) .settings-card--models .model-name,
        body:not(.dark-mode) .settings-card--models .settings-chip {
            color: var(--text-primary);
        }
        
        body:not(.dark-mode) .settings-card--models .settings-eyebrow {
            color: rgba(100, 116, 139, 0.9);
        }
        
        body:not(.dark-mode) .settings-card--models .settings-description,
        body:not(.dark-mode) .settings-card--models .model-description,
        body:not(.dark-mode) .settings-card--models .model-feature span,
        body:not(.dark-mode) .settings-card--models .settings-label {
            color: var(--text-secondary);
        }
        
        body:not(.dark-mode) .settings-card--models .model-option {
            background: #ffffff;
            border-color: var(--border-color);
        }
        
        body:not(.dark-mode) .settings-card--models .model-option.active {
            background: #f1f5f9;
            border-color: rgba(79, 70, 229, 0.35);
            box-shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
        }
        
        .settings-profile {
            display: flex;
            align-items: flex-start;
            justify-content: space-between;
            gap: 24px;
            flex-wrap: wrap;
        }

        .settings-profile-main {
            display: flex;
            align-items: center;
            gap: 16px;
            flex: 1 1 260px;
            min-width: 0;
        }

        .settings-profile-details {
            min-width: 0;
        }
        
        .settings-profile-avatar {
            width: 56px;
            height: 56px;
            border-radius: 50%;
            background: var(--gradient);
            color: #fff;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 22px;
            font-weight: 600;
        }
        
        .settings-profile-avatar.has-photo {
            padding: 0;
            background: transparent;
        }
        
        .settings-profile-avatar.has-photo img {
            width: 100%;
            height: 100%;
            border-radius: 50%;
            object-fit: cover;
        }
        
        .settings-profile-name {
            font-size: 20px;
            font-weight: 600;
            color: var(--text-primary);
        }
        
        .settings-card--models .settings-profile-name {
            color: #fff;
        }
        
        .settings-profile-email {
            font-size: 14px;
            color: var(--text-secondary);
        }

        .settings-profile-id {
            margin-top: 0;
            flex: 0 1 260px;
        }

        .settings-client-id-display {
            margin-top: 8px;
            padding: 10px 14px;
            border-radius: 10px;
            border: 1px dashed rgba(255, 255, 255, 0.2);
            background: rgba(15, 23, 42, 0.6);
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 12px;
            font-family: 'JetBrains Mono', 'SFMono-Regular', Menlo, monospace;
            font-size: 14px;
            letter-spacing: 0.08em;
        }

        .settings-client-id-display[data-empty="1"] {
            letter-spacing: normal;
            opacity: 0.7;
        }

        .settings-client-id-copy {
            border: none;
            border-radius: 8px;
            padding: 6px 12px;
            background: rgba(255, 255, 255, 0.15);
            color: inherit;
            font-weight: 500;
            cursor: pointer;
            transition: background 0.2s ease, transform 0.2s ease;
        }

        .settings-client-id-copy:hover:not(:disabled) {
            background: rgba(255, 255, 255, 0.25);
            transform: translateY(-1px);
        }

        .settings-client-id-copy:disabled {
            opacity: 0.5;
            cursor: not-allowed;
            transform: none;
        }

        @media (max-width: 640px) {
            .settings-profile {
                flex-direction: column;
                align-items: stretch;
            }
            .settings-profile-main {
                width: 100%;
            }
            .settings-profile-id {
                width: 100%;
                flex: 1 1 auto;
            }
        }
        
        .settings-pill-row {
            display: flex;
            flex-wrap: wrap;
            gap: 8px;
        }
        
        .settings-pill {
            padding: 6px 14px;
            border-radius: 999px;
            font-size: 12px;
            letter-spacing: 0.04em;
            background: rgba(15,23,42,0.06);
            color: var(--text-secondary);
        }

        .settings-links {
            display: flex;
            flex-direction: column;
            gap: 12px;
            margin-top: 8px;
        }

        .settings-link {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 12px;
            padding: 12px 14px;
            border: 1px solid var(--border-color);
            border-radius: 12px;
            background: var(--message-bg);
            color: inherit;
            text-decoration: none;
            transition: border-color var(--transition-speed) ease, box-shadow var(--transition-speed) ease, transform var(--transition-speed) ease;
        }

        .settings-link:hover {
            border-color: rgba(79, 70, 229, 0.45);
            box-shadow: 0 12px 24px rgba(15, 23, 42, 0.08);
            transform: translateY(-1px);
        }
        
        .settings-card--models .settings-pill {
            background: rgba(255,255,255,0.08);
            color: #f8fafc;
        }
        
        .settings-card-header {
            display: flex;
            align-items: flex-start;
            justify-content: space-between;
            gap: 12px;
            margin-bottom: 18px;
        }
        
        .settings-eyebrow {
            font-size: 11px;
            text-transform: uppercase;
            letter-spacing: 0.3em;
            color: var(--text-secondary);
            margin: 0 0 6px;
        }
        
        .settings-card--models .settings-eyebrow {
            color: rgba(148,163,184,0.95);
        }
        
        .settings-card-header h3,
        .settings-card-header h4 {
            margin: 0;
            font-size: 20px;
            color: var(--text-primary);
        }
        
        .settings-card--models .settings-card-header h3 {
            color: #fff;
        }
        
        .settings-description {
            font-size: 13px;
            color: var(--text-secondary);
            margin-top: 6px;
            line-height: 1.5;
        }
        
        .settings-card--models .settings-description {
            margin-top: 0;
        }
        
        .settings-chip {
            padding: 6px 12px;
            border-radius: 999px;
            border: 1px solid var(--border-color);
            font-size: 12px;
            letter-spacing: 0.08em;
            text-transform: uppercase;
            color: var(--text-secondary);
        }
        
        .settings-card--models .settings-chip {
            border-color: rgba(255,255,255,0.3);
            color: #f8fafc;
        }
        
        .settings-option {
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 12px 0;
            border-top: 1px solid rgba(148,163,184,0.2);
        }
        
        .settings-option:first-of-type {
            border-top: none;
        }

        .settings-option.stack {
            flex-direction: column;
            align-items: flex-start;
            gap: 12px;
        }
        
        .theme-colors {
            display: flex;
            gap: 10px;
            margin-top: 8px;
            flex-wrap: wrap;
        }
        
        .theme-color-btn {
            width: 28px;
            height: 28px;
            border-radius: 50%;
            border: none;
            cursor: pointer;
            transition: transform 0.2s ease, box-shadow 0.2s ease;
        }
        
        .theme-color-btn:hover {
            transform: translateY(-2px);
        }

        .theme-color-btn.active {
            transform: scale(1.1);
            box-shadow: 0 0 0 3px var(--primary);
        }

        .settings-pill-toggle {
            display: flex;
            flex-wrap: wrap;
            gap: 8px;
        }
        
        .pill-toggle-btn {
            padding: 6px 16px;
            border-radius: 999px;
            border: 1px solid var(--border-color);
            background: rgba(255,255,255,0.05);
            color: var(--text-primary);
            font-size: 13px;
            letter-spacing: 0.05em;
            text-transform: uppercase;
            cursor: pointer;
            transition: all 0.2s ease;
        }
        
        .pill-toggle-btn.active {
            border-color: var(--primary);
            background: rgba(104,117,245,0.15);
            color: var(--primary);
            box-shadow: 0 8px 20px rgba(104,117,245,0.15);
        }
        
        .settings-label {
            font-size: 15px;
            font-weight: 500;
            color: var(--text-primary);
        }
        
        .settings-card--models .settings-label {
            color: #f1f5f9;
        }
        
        .settings-footer {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 12px;
            flex-wrap: wrap;
        }
        
        .settings-modal .modal-footer {
            border-top: 1px solid var(--border-color);
            padding: 20px 24px;
            background: var(--message-bg);
        }
        
        .settings-footer-status {
            display: flex;
            align-items: center;
            gap: 8px;
            font-size: 13px;
            color: var(--text-secondary);
        }
        
        .settings-sync-dot {
            width: 8px;
            height: 8px;
            border-radius: 50%;
            background: var(--success-color);
            box-shadow: 0 0 10px rgba(16,185,129,0.5);
        }
        
        .settings-footer-actions {
            display: flex;
            gap: 10px;
            flex-wrap: wrap;
        }
        
        @media (max-width: 640px) {
            .settings-body {
                padding: 20px;
            }
            
            .settings-card-header {
                flex-direction: column;
                align-items: flex-start;
            }
            
            .settings-footer {
                flex-direction: column;
                align-items: flex-start;
            }
        }

        /* Settings redesign overrides */
        .settings-modal {
            max-width: 1040px;
            width: calc(100% - 32px);
            border: 1px solid rgba(255, 255, 255, 0.08);
            background: #2b2d31;
            box-shadow: 0 30px 70px rgba(0, 0, 0, 0.45);
            font-family: 'Geist', 'Poppins', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
        }

        .settings-modal .modal-header {
            border-bottom: 1px solid rgba(255, 255, 255, 0.06);
            background: #2b2d31;
        }

        .settings-modal .modal-footer {
            background: #2b2d31;
            border-top: 1px solid rgba(255, 255, 255, 0.06);
        }

        body:not(.dark-mode) .settings-modal .modal-footer {
            background: #f8fafc;
        }

        .settings-body {
            background: #2b2d31;
        }

        .settings-layout {
            display: grid;
            grid-template-columns: 200px 1fr;
            gap: 24px;
        }

        .settings-nav {
            display: flex;
            flex-direction: column;
            gap: 10px;
            position: sticky;
            top: 12px;
            align-self: flex-start;
        }

        .settings-nav-btn {
            display: flex;
            align-items: center;
            gap: 12px;
            border: none;
            border-radius: 16px;
            padding: 12px 14px;
            background: #3a3b3f;
            color: #f3f4f6;
            font-size: 14px;
            font-weight: 600;
            cursor: pointer;
            transition: background 0.2s ease, transform 0.2s ease;
        }

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

        .settings-nav-btn.active {
            background: #4b4e55;
            color: #ffffff;
            box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
        }

        body:not(.dark-mode) .settings-nav-btn {
            background: #e2e8f0;
            color: var(--text-primary);
        }

        body:not(.dark-mode) .settings-nav-btn.active {
            background: #cbd5f5;
        }

        @media (max-width: 900px) {
            .settings-layout {
                grid-template-columns: 1fr;
            }

            .settings-nav {
                flex-direction: row;
                flex-wrap: wrap;
                position: static;
            }
        }

        .settings-card {
            background: #2f3136;
            border: 1px solid rgba(255, 255, 255, 0.08);
            color: #e5e7eb;
        }

        .settings-card--models,
        .settings-card--profile {
            background: #2f3136;
            border-color: rgba(255, 255, 255, 0.08);
            color: #e5e7eb;
        }

        .settings-card--models .model-option {
            background: #3a3b3f;
            border-color: rgba(255, 255, 255, 0.1);
        }

        .settings-card--models .model-option.active {
            background: #42444b;
            border-color: rgba(255, 255, 255, 0.2);
            box-shadow: none;
        }

        .settings-card--models .model-description,
        .settings-card--models .settings-description,
        .settings-card--models .settings-label {
            color: rgba(226, 232, 240, 0.78);
        }

        body:not(.dark-mode) .settings-modal {
            border-color: rgba(15, 23, 42, 0.08);
            background: #f4f6f9;
            box-shadow: 0 24px 60px rgba(15, 23, 42, 0.12);
        }

        body:not(.dark-mode) .settings-modal .modal-header,
        body:not(.dark-mode) .settings-body {
            background: #f4f6f9;
        }

        body:not(.dark-mode) .settings-content {
            background: #ffffff;
            border-color: rgba(15, 23, 42, 0.08);
        }

        body:not(.dark-mode) .settings-card,
        body:not(.dark-mode) .settings-card--models,
        body:not(.dark-mode) .settings-card--profile {
            background: #ffffff;
            border-color: rgba(15, 23, 42, 0.08);
            color: var(--text-primary);
        }

        body:not(.dark-mode) .settings-panel-block {
            background: #ffffff;
            border-color: rgba(15, 23, 42, 0.08);
        }

        body:not(.dark-mode) .settings-theme-card {
            background: #f8fafc;
            border-color: rgba(15, 23, 42, 0.12);
            color: var(--text-primary);
        }

        body:not(.dark-mode) .settings-theme-card.active {
            background: #e5e7eb;
            border-color: rgba(15, 23, 42, 0.2);
        }

        body:not(.dark-mode) .settings-select {
            background: #ffffff;
            border-color: rgba(15, 23, 42, 0.12);
        }

        body:not(.dark-mode) .settings-panel-heading {
            color: var(--text-primary);
        }

        body:not(.dark-mode) .settings-row-label {
            color: var(--text-secondary);
        }

        body:not(.dark-mode) .settings-card {
            background: var(--message-bg);
            color: var(--text-primary);
        }

        .settings-card-header h3,
        .settings-card-header h4 {
            font-size: 21px;
        }

        .settings-section-header {
            align-items: center;
        }

        .settings-subsection-title {
            font-size: 12px;
            text-transform: uppercase;
            letter-spacing: 0.24em;
            color: rgba(148, 163, 184, 0.9);
            margin: 14px 0 6px;
        }

        body:not(.dark-mode) .settings-subsection-title {
            color: rgba(71, 85, 105, 0.9);
        }

        .settings-divider {
            height: 1px;
            background: rgba(148, 163, 184, 0.2);
            margin: 14px 0;
        }

        .settings-select {
            width: 100%;
            max-width: 260px;
            padding: 10px 12px;
            border-radius: 10px;
            border: 1px solid rgba(255, 255, 255, 0.12);
            background: #3a3b3f;
            color: inherit;
            font-size: 14px;
        }

        body:not(.dark-mode) .settings-select {
            background: #fff;
        }

        .settings-inline-actions {
            display: flex;
            align-items: center;
            gap: 12px;
            flex-wrap: wrap;
        }

        .settings-inline-note {
            font-size: 12px;
            color: rgba(148, 163, 184, 0.9);
        }

        body:not(.dark-mode) .settings-inline-note {
            color: var(--text-secondary);
        }

        .settings-danger-btn {
            padding: 10px 16px;
            border-radius: 10px;
            border: 1px solid rgba(248, 113, 113, 0.6);
            background: rgba(248, 113, 113, 0.12);
            color: #fecaca;
            font-weight: 600;
            cursor: pointer;
            transition: transform 0.2s ease, box-shadow 0.2s ease;
        }

        .settings-danger-btn:hover {
            transform: translateY(-1px);
            box-shadow: 0 12px 24px rgba(248, 113, 113, 0.18);
        }

        body:not(.dark-mode) .settings-danger-btn {
            color: #b91c1c;
            background: rgba(248, 113, 113, 0.16);
        }

        .settings-shared-links-panel {
            border-radius: 12px;
            border: 1px dashed rgba(148, 163, 184, 0.3);
            padding: 12px;
            background: #32343a;
        }

        body:not(.dark-mode) .settings-shared-links-panel {
            background: #f8fafc;
        }

        .settings-shared-link {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 12px;
            padding: 8px 0;
            font-size: 13px;
            border-bottom: 1px solid rgba(148, 163, 184, 0.2);
        }

        .settings-shared-link:last-child {
            border-bottom: none;
        }

        .settings-content {
            background: #2f3136;
            border-radius: 20px;
            padding: 18px;
            border: 1px solid rgba(255, 255, 255, 0.06);
        }

        .settings-panel {
            display: none;
            animation: settingsFade 0.25s ease;
        }

        .settings-panel.active {
            display: block;
        }

        .settings-panel-block {
            padding: 18px;
            border-radius: 16px;
            border: 1px solid rgba(255, 255, 255, 0.06);
            background: #32343a;
        }

        .settings-panel-block + .settings-panel-block {
            margin-top: 18px;
        }

        .settings-panel-heading {
            font-size: 16px;
            font-weight: 600;
            color: #f8fafc;
            margin-bottom: 12px;
        }

        .settings-row {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 12px;
            flex-wrap: wrap;
        }

        .settings-row-label {
            font-size: 14px;
            color: rgba(226, 232, 240, 0.75);
        }

        .settings-theme-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
            gap: 16px;
        }

        .settings-theme-card {
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            gap: 8px;
            padding: 18px 16px;
            border-radius: 16px;
            border: 1px solid rgba(255, 255, 255, 0.12);
            background: #2f3136;
            color: #f3f4f6;
            font-weight: 600;
            cursor: pointer;
            transition: border-color 0.2s ease, transform 0.2s ease, background 0.2s ease;
        }

        .settings-theme-card:hover {
            border-color: rgba(255, 255, 255, 0.25);
            transform: translateY(-2px);
        }

        .settings-theme-card.active {
            background: #42444b;
            border-color: rgba(255, 255, 255, 0.3);
        }

        @keyframes settingsFade {
            from { opacity: 0; transform: translateY(6px); }
            to { opacity: 1; transform: translateY(0); }
        }
        
        /* Enhanced Model Selector */
        .model-selector {
            display: flex;
            flex-direction: column;
            gap: 12px;
            margin-top: 15px;
        }
        
        .model-option {
            display: flex;
            align-items: center;
            padding: 15px;
            border-radius: 10px;
            border: 1px solid var(--border-color);
            cursor: pointer;
            transition: all var(--transition-speed) var(--transition-easing);
            position: relative;
            overflow: hidden;
        }
        
        .model-option::before {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            width: 4px;
            height: 100%;
            background: var(--primary);
            transform: scaleY(0);
            transform-origin: bottom;
            transition: transform 0.3s ease;
        }
        
        .model-option:hover {
            border-color: var(--primary);
            transform: translateY(-2px);
            box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
        }
        
        .model-option.active {
            border-color: var(--primary);
            background-color: rgba(124, 58, 237, 0.05);
            box-shadow: 0 4px 12px rgba(124, 58, 237, 0.1);
        }

        /* Use model-specific colors for the active card */
.model-option[data-model="aether_base"].active {
  border-color: var(--aether-base-color);
  background-color: rgba(6,182,212,0.08);
  box-shadow: 0 4px 12px rgba(6,182,212,0.18);
}
.model-option[data-model="aether_pro"].active {
  border-color: var(--aether-pro-color);
  background-color: rgba(168,85,247,0.08);
  box-shadow: 0 4px 12px rgba(168,85,247,0.18);
}
.model-option[data-model="vanta"].active {
  border-color: var(--vanta-color);
  background-color: rgba(59,130,246,0.08);
  box-shadow: 0 4px 12px rgba(59,130,246,0.18);
}
.model-option[data-model="mnemox"].active {
  border-color: var(--mnemox-color);
  background-color: rgba(110,65,226,0.08);
  box-shadow: 0 4px 12px rgba(110,65,226,0.18);
}
.model-option[data-model="inova"].active {
  border-color: var(--inova-color);
  background-color: rgba(236,72,153,0.08);
  box-shadow: 0 4px 12px rgba(236,72,153,0.18);
}
.model-option[data-model="nerfedjerky"].active {
  border-color: var(--nerfedjerky-color);
  background-color: rgba(245,158,11,0.08);
  box-shadow: 0 4px 12px rgba(245,158,11,0.18);
}
.model-option[data-model="nicholas_tech_life_support"].active {
  border-color: var(--nicholas-color);
  background-color: rgba(14,165,233,0.08);
  box-shadow: 0 4px 12px rgba(14,165,233,0.18);
}
.model-option[data-model="logicengine_pro"].active {
  border-color: var(--logicengine-color);
  background-color: rgba(20,184,166,0.1);
  box-shadow: 0 4px 12px rgba(20,184,166,0.2);
}
.model-option[data-model="imagica_vision"].active {
  border-color: var(--imagica-color);
  background-color: rgba(52,211,153,0.1);
  box-shadow: 0 4px 12px rgba(52,211,153,0.2);
}
        
        .model-option.active::before {
            transform: scaleY(1);
        }
        
        .model-radio {
            appearance: none;
            -webkit-appearance: none;
            width: 18px;
            height: 18px;
            border: 2px solid var(--border-color);
            border-radius: 50%;
            margin-right: 12px;
            position: relative;
            transition: all 0.2s ease;
        }
        
        .model-radio:checked {
            border-color: var(--primary);
        }
        
        .model-radio:checked::after {
            content: '';
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            width: 10px;
            height: 10px;
            background: var(--primary);
            border-radius: 50%;
        }
        
        .model-info {
            flex: 1;
        }
        
        .model-name {
            font-weight: 600;
            margin-bottom: 4px;
            display: flex;
            align-items: center;
        }
        
        .model-description {
            font-size: 13px;
            color: var(--text-secondary);
            line-height: 1.5;
        }
        
        .model-badge {
            padding: 4px 8px;
            border-radius: 4px;
            font-size: 11px;
            font-weight: 600;
            margin-left: 10px;
            text-transform: uppercase;
            letter-spacing: 0.5px;
        }
        
.model-badge.aether-base {
            background-color: rgba(6, 182, 212, 0.1);
            color: var(--aether-base-color);
        }

        .model-badge.aether-pro {
            background-color: rgba(168, 85, 247, 0.1);
            color: var(--aether-pro-color);
        }

        .model-badge.vanta {
            background-color: rgba(59, 130, 246, 0.1);
            color: var(--vanta-color);
        }
        
        .model-badge.mnemox {
            background-color: rgba(110, 65, 226, 0.1);
            color: var(--mnemox-color);
        }
        
        .model-badge.inova {
            background-color: rgba(236, 72, 153, 0.1);
            color: var(--inova-color);
        }

        .model-badge.nerfedjerky {
    background-color: rgba(245, 158, 11, 0.1);
    color: var(--nerfedjerky-color);
}

.model-badge.nicholas {
    background-color: rgba(14, 165, 233, 0.12);
    color: var(--nicholas-color);
}

.model-badge.ragebait {
    background-color: rgba(220, 38, 38, 0.1);
    color: #dc2626;
}

.model-badge.logicengine {
    background-color: rgba(20, 184, 166, 0.12);
    color: var(--logicengine-color);
}

.model-badge.imagica {
    background-color: rgba(52, 211, 153, 0.12);
    color: var(--imagica-color);
}

        .model-warning {
            margin-top: 10px;
            padding: 8px 10px;
            border-radius: 6px;
            font-size: 12px;
            display: flex;
            align-items: center;
            gap: 6px;
            background-color: rgba(245, 158, 11, 0.12);
            color: var(--warning-color);
        }

        .model-warning i {
            color: var(--warning-color);
        }
        
        .model-features {
            margin-top: 8px;
            font-size: 12px;
            color: var(--text-secondary);
        }
        
        .model-feature {
            display: flex;
            align-items: center;
            gap: 6px;
            margin-bottom: 4px;
        }
        
        .model-feature-icon {
            color: var(--primary);
            font-size: 12px;
        }
        
        /* Privacy Policy and Terms Content */
        .terms-content {
            max-height: 400px;
            overflow-y: auto;
            padding: 15px;
            background: rgba(0, 0, 0, 0.02);
            border-radius: 8px;
            margin-bottom: 20px;
            font-size: 13px;
            line-height: 1.6;
        }
        
        .terms-content h3 {
            margin: 15px 0 8px;
            font-size: 15px;
            color: var(--text-primary);
        }
        
        .terms-content p {
            margin-bottom: 10px;
        }
        
        .terms-content ul {
            margin-bottom: 15px;
            padding-left: 20px;
        }
        
        /* Animations */
        @keyframes typingAnimation {
            0%, 60%, 100% { transform: translateY(0); opacity: 0.6; }
            30% { transform: translateY(-5px); opacity: 1; }
        }
        
        @keyframes pulse {
            0% { transform: scale(1); }
            50% { transform: scale(1.1); }
            100% { transform: scale(1); }
        }
        
        @keyframes fadeIn {
            from { opacity: 0; }
            to { opacity: 1; }
        }
        
        @keyframes fadeInUp {
            from { 
                opacity: 0;
                transform: translateY(10px);
            }
            to { 
                opacity: 1;
                transform: translateY(0);
            }
        }
        
        @keyframes blink {
            0%, 100% { opacity: 1; }
            50% { opacity: 0; }
        }
        
        .text-stream {
            display: inline;
        }
        
        /* Loading spinner */
        .loading-spinner {
            display: inline-block;
            width: 20px;
            height: 20px;
            border: 3px solid rgba(124, 58, 237, 0.3);
            border-radius: 50%;
            border-top-color: var(--primary);
            animation: spin 1s ease-in-out infinite;
            margin-right: 8px;
        }
        
        @keyframes spin {
            to { transform: rotate(360deg); }
        }
        
        
        /* Scrollbar styling */
        ::-webkit-scrollbar {
            width: 8px;
            height: 8px;
        }
        
        ::-webkit-scrollbar-track {
            background: rgba(0, 0, 0, 0.05);
            border-radius: 10px;
        }
        
        ::-webkit-scrollbar-thumb {
            background: rgba(0, 0, 0, 0.2);
            border-radius: 10px;
        }
        
        ::-webkit-scrollbar-thumb:hover {
            background: rgba(0, 0, 0, 0.3);
        }
        
        /* Toast notification styling */
        .toast-notification {
            position: fixed;
            bottom: 20px;
            left: 50%;
            transform: translateX(-50%) translateY(100%);
            background-color: var(--sidebar-bg);
            color: white;
            padding: 12px 24px;
            border-radius: 8px;
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
            z-index: 1001;
            transition: transform 0.3s ease;
            display: flex;
            align-items: center;
            gap: 8px;
        }
        
        .toast-notification.show {
            transform: translateX(-50%) translateY(0);
        }
        
        .toast-icon {
            font-size: 18px;
        }

        .scholar-study-popup {
            position: fixed;
            top: 20px;
            right: 20px;
            width: min(360px, calc(100vw - 32px));
            padding: 20px;
            border-radius: 20px;
            background: linear-gradient(145deg, rgba(79, 70, 229, 0.97), rgba(15, 23, 42, 0.98));
            color: #fff;
            box-shadow: 0 24px 60px rgba(15, 23, 42, 0.3);
            border: 1px solid rgba(255, 255, 255, 0.14);
            z-index: 2100;
            opacity: 0;
            transform: translateY(-16px);
            pointer-events: none;
            transition: opacity 0.25s ease, transform 0.25s ease;
            cursor: pointer;
        }

        .scholar-study-popup.show {
            opacity: 1;
            transform: translateY(0);
            pointer-events: auto;
        }

        .scholar-study-popup-close {
            position: absolute;
            top: 12px;
            right: 12px;
            width: 32px;
            height: 32px;
            border: 0;
            border-radius: 999px;
            background: rgba(255, 255, 255, 0.12);
            color: #fff;
            cursor: pointer;
            font-size: 18px;
        }

        .scholar-study-popup-kicker {
            display: inline-flex;
            align-items: center;
            gap: 6px;
            padding: 6px 10px;
            border-radius: 999px;
            background: rgba(255, 255, 255, 0.12);
            font-size: 12px;
            font-weight: 600;
            letter-spacing: 0.04em;
            text-transform: uppercase;
        }

        .scholar-study-popup h3 {
            margin: 14px 0 8px;
            font-size: 24px;
            line-height: 1.15;
        }

        .scholar-study-popup p {
            margin: 0;
            color: rgba(255, 255, 255, 0.84);
            font-size: 14px;
        }

        .scholar-study-popup-actions {
            display: flex;
            align-items: center;
            gap: 10px;
            margin-top: 18px;
            flex-wrap: wrap;
        }

        .scholar-study-popup-cta,
        .scholar-study-popup-dismiss {
            border: 0;
            border-radius: 999px;
            padding: 11px 16px;
            font-size: 14px;
            font-weight: 600;
            cursor: pointer;
        }

        .scholar-study-popup-cta {
            background: #fff;
            color: #312e81;
        }

        .scholar-study-popup-dismiss {
            background: rgba(255, 255, 255, 0.12);
            color: #fff;
        }

        @media (max-width: 768px) {
            .scholar-study-popup {
                top: auto;
                right: 16px;
                bottom: 16px;
                left: 16px;
                width: auto;
            }
        }

        /* Live banner from admin */
        .live-banner {
            position: fixed;
            top: 14px;
            left: 50%;
            transform: translateX(-50%) translateY(-12px);
            width: min(1100px, calc(100% - 24px));
            background: rgba(15, 23, 42, 0.96);
            border: 1px solid rgba(148, 163, 184, 0.25);
            border-radius: 14px;
            box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
            padding: 14px 16px;
            z-index: 2400;
            opacity: 0;
            pointer-events: none;
            transition: opacity 0.25s ease, transform 0.25s ease;
            backdrop-filter: blur(6px);
        }

        .live-banner.active {
            opacity: 1;
            pointer-events: auto;
            transform: translateX(-50%) translateY(0);
        }

        .live-banner-meta {
            display: flex;
            gap: 10px;
            align-items: center;
            margin-bottom: 8px;
            flex-wrap: wrap;
        }

        .live-banner-pill {
            display: inline-flex;
            align-items: center;
            gap: 6px;
            padding: 6px 10px;
            border-radius: 999px;
            font-size: 12px;
            font-weight: 700;
            text-transform: uppercase;
            letter-spacing: 0.08em;
        }

        .live-banner-pill.announcement { background: rgba(110,231,183,0.14); color: #34d399; }
        .live-banner-pill.maintenance { background: rgba(250,204,21,0.18); color: #facc15; }
        .live-banner-pill.incident { background: rgba(251,113,133,0.2); color: #fb7185; }

        .live-banner-timer {
            font-size: 12px;
            color: rgba(226, 232, 240, 0.7);
        }

        .live-banner-content {
            display: flex;
            gap: 14px;
            align-items: flex-start;
            justify-content: space-between;
            flex-wrap: wrap;
        }

        .live-banner-copy {
            flex: 1;
            min-width: 220px;
        }

        .live-banner-title {
            font-size: 18px;
            margin: 0 0 4px;
            color: #f8fafc;
        }

        .live-banner-body {
            margin: 0;
            color: rgba(226, 232, 240, 0.8);
            line-height: 1.5;
        }

        .live-banner-actions {
            display: flex;
            gap: 8px;
            flex-wrap: wrap;
        }

        .live-banner-cta,
        .live-banner-close {
            border: 1px solid rgba(255,255,255,0.14);
            color: #f1f5f9;
            background: rgba(255,255,255,0.05);
            padding: 10px 12px;
            border-radius: 10px;
            cursor: pointer;
            font-weight: 600;
            text-decoration: none;
            transition: border-color 0.2s ease, background 0.2s ease, transform 0.2s ease;
        }

        .live-banner-cta {
            background: linear-gradient(135deg, #6ee7b7, #3b82f6);
            color: #02101b;
            border: none;
        }

        .live-banner-cta:hover,
        .live-banner-close:hover {
            transform: translateY(-1px);
            border-color: rgba(255,255,255,0.3);
        }

        @media (max-width: 640px) {
            .live-banner {
                top: 10px;
                width: calc(100% - 14px);
                padding: 12px;
            }
            .live-banner-content {
                flex-direction: column;
                align-items: flex-start;
            }
        }

        /* Launch announcement */
        .zos-announcement-overlay {
            position: fixed;
            inset: 0;
            display: flex;
            justify-content: flex-end;
            align-items: flex-end;
            padding: 32px;
            background: linear-gradient(120deg, rgba(3, 6, 23, 0.45), rgba(3, 6, 23, 0));
            backdrop-filter: blur(6px);
            opacity: 0;
            pointer-events: none;
            transition: opacity 0.25s ease;
            z-index: 2500;
        }

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

        @keyframes zosCardReveal {
            from { opacity: 0; transform: translate(40px, 30px) scale(0.98); }
            to { opacity: 1; transform: translate(0, 0) scale(1); }
        }

        .zos-announcement-card {
            width: min(420px, calc(100vw - 48px));
            border-radius: 24px;
            padding: 26px 28px;
            background: rgba(11, 16, 28, 0.95);
            border: 1px solid rgba(148, 163, 184, 0.3);
            box-shadow: 0 30px 60px rgba(5, 7, 18, 0.6), 0 8px 20px rgba(2, 3, 10, 0.7);
            color: #e2e8f0;
            position: relative;
            overflow: hidden;
            display: flex;
            flex-direction: column;
            gap: 16px;
        }

        .zos-announcement-overlay.active .zos-announcement-card {
            animation: zosCardReveal 420ms cubic-bezier(0.21, 0.9, 0.32, 1) forwards;
        }

        .zos-announcement-card::before {
            content: '';
            position: absolute;
            inset: 1px;
            border-radius: 22px;
            border: 1px solid rgba(99, 102, 241, 0.35);
            opacity: 0.4;
            pointer-events: none;
        }

        .zos-announcement-heading {
            font-size: 1.45rem;
            font-weight: 600;
            background: linear-gradient(120deg, #c084fc, #60a5fa);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
        }

        .zos-announcement-subtitle {
            font-size: 0.95rem;
            color: rgba(226, 232, 240, 0.8);
        }

        .zos-announcement-pill {
            align-self: flex-start;
            display: inline-flex;
            align-items: center;
            gap: 6px;
            padding: 6px 14px;
            font-size: 0.72rem;
            text-transform: uppercase;
            letter-spacing: 0.12em;
            color: #c4b5fd;
            background: rgba(139, 92, 246, 0.25);
            border-radius: 999px;
            border: 1px solid rgba(139, 92, 246, 0.35);
        }

        .zos-announcement-header {
            display: flex;
            flex-direction: column;
            gap: 6px;
        }

        .zos-announcement-list {
            list-style: none;
            padding: 0;
            margin: 6px 0 12px 0;
            display: flex;
            flex-direction: column;
            gap: 10px;
        }

        .zos-announcement-list li {
            display: flex;
            gap: 12px;
            padding: 10px 12px;
            border-radius: 14px;
            background: rgba(255, 255, 255, 0.02);
            border: 1px solid rgba(226, 232, 240, 0.08);
            font-size: 0.92rem;
            align-items: flex-start;
        }

        .zos-announcement-bullet {
            flex-shrink: 0;
            color: #7dd3fc;
        }

        .zos-announcement-footer {
            display: flex;
            flex-direction: column;
            gap: 8px;
            color: rgba(226, 232, 240, 0.75);
            font-size: 0.85rem;
        }

        .announcement-close-btn {
            width: 100%;
            border: none;
            border-radius: 14px;
            padding: 13px;
            font-weight: 600;
            background: linear-gradient(135deg, #7c3aed, #4f46e5);
            color: white;
            cursor: pointer;
            transition: transform 0.2s ease, box-shadow 0.2s ease;
            font-size: 1rem;
        }

        .announcement-close-btn:hover {
            transform: translateY(-1px);
            box-shadow: 0 12px 30px rgba(79, 70, 229, 0.35);
        }

        @media (max-width: 520px) {
            .zos-announcement-overlay {
                justify-content: center;
                align-items: flex-end;
                padding: 24px 16px;
            }

            .zos-announcement-card {
                width: 100%;
            }
        }
        
        /* Toggle switch */
        .switch {
            position: relative;
            display: inline-block;
            width: 50px;
            height: 24px;
        }
        
        .switch input {
            opacity: 0;
            width: 0;
            height: 0;
        }
        
        .slider {
            position: absolute;
            cursor: pointer;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background-color: #ccc;
            transition: .4s;
            border-radius: 24px;
        }
        
        .slider:before {
            position: absolute;
            content: "";
            height: 16px;
            width: 16px;
            left: 4px;
            bottom: 4px;
            background-color: white;
            transition: .4s;
            border-radius: 50%;
        }
        
        input:checked + .slider {
            background-color: var(--primary);
        }
        
        input:checked + .slider:before {
            transform: translateX(26px);
        }
        
        /* Dark mode styles (aligned to new neutral palette) */
        body.dark-mode {
            --sidebar-bg: #0b0d12;
            --sidebar-text: #e8edf5;
            --sidebar-hover: #151b26;
            --sidebar-active: #1a2331;
            --chat-bg: #0b1220;
            --message-bg: #0f172a;
            --user-message-bg: #0c1c32;
            --border-color: #1f2937;
            --text-primary: #e8edf5;
            --text-secondary: #b6c0d2;
            --code-bg: #0b0e14;
        }
        
        body.dark-mode .auth-container {
            background: #0f172a;
            border-color: #1f2937;
            box-shadow: 0 20px 50px rgba(0,0,0,0.55);
        }
        
        body.dark-mode .auth-panel {
            background: #0f172a;
        }
        
        body.dark-mode .auth-tabs {
            background: #0b1220;
            border-color: #1f2937;
        }
        
        body.dark-mode .auth-tab {
            background: #0b1220;
            color: #b6c0d2;
        }
        body.dark-mode .auth-tab.active {
            background: #111c2e;
            color: #ffffff;
            border-color: #233044;
            box-shadow: 0 8px 20px rgba(0,0,0,0.35);
        }
        
        body.dark-mode .auth-input {
            background: #0b1220;
            border-color: #1f2937;
            color: #e8edf5;
        }
        
        body.dark-mode .terms-content {
            background: #0b1220;
        }
        
        body.dark-mode .auth-heading h1,
        body.dark-mode .auth-heading p,
        body.dark-mode .auth-footer {
            color: #e8edf5;
        }
        
        body.dark-mode .auth-google-note {
            color: #cbd5e1;
            background: transparent;
        }
        
        /* Mobile Responsiveness */

/* Mobile-specific improvements */
@media (max-width: 768px) {
    /* Ensure body takes full height */
    body {
        min-height: 100dvh;
        height: 100dvh;
        overflow: hidden;
    }
    
    /* Main content area should fill screen */
    .main-content {
        min-height: 0;
        height: 100dvh;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }
    
    /* Chat container should use available space */
    .chat-container {
        flex: 1 1 auto;
        min-height: 0;
        padding: 15px 10px calc(var(--input-height-dynamic) + 40px);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        scroll-padding-bottom: calc(var(--input-height-dynamic) + 40px);
        touch-action: pan-y;
    }
    
    /* Input container adjustments */
    .input-container {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        padding: 12px;
        background: var(--message-bg);
        border-top: 1px solid var(--border-color);
        z-index: 100;
    }
    
    /* Welcome message adjustments */
    .welcome-container {
        padding: 20px 10px;
    }
    
    .welcome-logo {
        height: 60px;
    }
    
    .welcome-title {
        font-size: 22px;
    }
    
    .welcome-subtitle {
        font-size: 14px;
    }
    
    /* Message adjustments */
    .message {
        gap: 10px;
        margin-bottom: 15px;
    }
    
    .message-avatar {
        width: 32px;
        height: 32px;
        font-size: 14px;
    }
    
    .message-text {
        padding: 12px 16px;
        font-size: 14px;
    }
    
    /* Textarea adjustments */
    textarea {
        font-size: 16px; /* Prevents zoom on iOS */
        padding: 12px 50px 12px 12px;
    }
    
    /* Hide model indicator on mobile to save space */
    .model-indicator {
        display: none;
    }
    
    /* Credit counter adjustments */
    .credit-counter {
        font-size: 12px;
        right: 15px;
        padding: 8px 12px;
        gap: 10px;
        min-width: 160px;
    }

    .chat-header .credit-counter {
        right: auto;
    }
    
    .credit-usage {
        width: 42px;
        height: 42px;
    }
    
    .credit-ring {
        width: 42px;
        height: 42px;
    }

    @supports(padding: max(0px)) {
        .chat-container {
            padding-left: max(10px, env(safe-area-inset-left));
            padding-right: max(10px, env(safe-area-inset-right));
            padding-bottom: max(calc(var(--input-height-dynamic) + 40px), calc(env(safe-area-inset-bottom) + var(--input-height-dynamic) + 40px));
            scroll-padding-bottom: max(calc(var(--input-height-dynamic) + 40px), calc(env(safe-area-inset-bottom) + var(--input-height-dynamic) + 40px));
        }
    }
    
    /* Sidebar full height */
    .sidebar {
        height: var(--app-height);
    }
}

/* Prevent horizontal scrolling */
html, body {
    max-width: 100%;
    overflow-x: hidden;
}

/* Safe area insets for notched devices */
@supports(padding: max(0px)) {
    .sidebar, .input-container, .chat-header {
        padding-left: max(15px, env(safe-area-inset-left));
        padding-right: max(15px, env(safe-area-inset-right));
    }
    
    .input-container {
        padding-bottom: max(10px, env(safe-area-inset-bottom));
    }

}

        @media (max-width: 768px) {
            .sidebar {
                position: fixed;
                top: 0;
                left: 0;
                transform: translateX(-100%);
                height: var(--app-height);
                width: 85%;
                max-width: 300px;
                z-index: 1000;
            }
            
            .sidebar.open {
                transform: translateX(0);
                box-shadow: 2px 0 20px rgba(0, 0, 0, 0.3);
            }
            
            .menu-btn {
                display: flex;
            }

            #open-settings-btn {
                position: relative;
                right: auto;
                bottom: auto;
                z-index: 1200;
                margin-right: 6px;
                background: var(--message-bg);
                border: 1px solid var(--border-color);
                box-shadow: 0 8px 18px rgba(15, 23, 42, 0.18);
            }
            
            .chat-header {
                padding: 0 15px;
            }

            .chat-title {
                display: none;
            }
            
            .chat-container {
                padding-left: 15px;
                padding-right: 15px;
            }
            
            @supports(padding: max(0px)) {
                .chat-container {
                    padding-left: max(15px, env(safe-area-inset-left));
                    padding-right: max(15px, env(safe-area-inset-right));
                }
            }
            
            .message {
                gap: 12px;
            }
            
            .input-container {
                padding: 15px;
            }
            
            .welcome-title {
                font-size: 24px;
            }
            
            .welcome-subtitle {
                font-size: 15px;
            }
            
            .prompt-suggestions {
                grid-template-columns: 1fr;
                gap: 8px;
            }
            
            .prompt-suggestion {
                padding: 10px 14px;
                font-size: 13px;
            }
            
            .credit-counter {
                right: 15px;
                font-size: 13px;
            }
            
            .model-indicator {
                right: 15px;
                font-size: 11px;
            }
            
            .input-tools {
                right: 12px;
                bottom: 12px;
            }
            
            textarea {
                padding: 15px 60px 15px 15px;
            }
            
            .sidebar-overlay {
                position: fixed;
                top: 0;
                left: 0;
                right: 0;
                bottom: 0;
                background: rgba(0, 0, 0, 0.5);
                z-index: 999;
                display: none;
            }
            
            .sidebar-overlay.active {
                display: block;
            }
            
            .settings-modal {
                width: 90%;
            }
            
            .auth-container {
                padding: 30px 20px;
            }
            
            .auth-title {
                font-size: 24px;
            }
        }

        @media (max-width: 600px) {
            .settings-modal {
                width: 100%;
                height: 100dvh;
                max-height: 100dvh;
                border-radius: 0;
            }

            .settings-modal .modal-header,
            .settings-modal .modal-footer {
                position: sticky;
                z-index: 2;
            }

            .settings-modal .modal-header {
                top: 0;
            }

            .settings-modal .modal-footer {
                bottom: 0;
            }

            .settings-modal .modal-body {
                max-height: calc(100dvh - 140px);
                overflow-y: auto;
                -webkit-overflow-scrolling: touch;
            }

            .settings-body {
                padding: 16px;
                gap: 16px;
            }

            .settings-layout {
                grid-template-columns: 1fr;
                gap: 16px;
            }

            .settings-nav {
                flex-direction: row;
                flex-wrap: nowrap;
                overflow-x: auto;
                gap: 8px;
                padding-bottom: 6px;
            }

            .settings-nav::-webkit-scrollbar {
                display: none;
            }

            .settings-nav-btn {
                flex: 0 0 auto;
                border-radius: 999px;
                padding: 10px 14px;
                font-size: 12px;
                white-space: nowrap;
            }

            .settings-card {
                padding: 16px;
                border-radius: 16px;
            }

            .settings-card-header {
                flex-direction: column;
                align-items: flex-start;
                gap: 10px;
            }

            .settings-option {
                flex-direction: column;
                align-items: flex-start;
                gap: 10px;
            }

            .settings-option > label.switch,
            .settings-option .settings-pill-toggle {
                align-self: stretch;
            }

            .settings-pill-toggle {
                width: 100%;
                justify-content: flex-start;
            }

            .settings-client-id-display {
                flex-direction: column;
                align-items: flex-start;
                gap: 8px;
            }
        }

        .report-problem-btn {
            margin-top: 12px;
            width: 100%;
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 10px;
            padding: 10px 12px;
            border-radius: 12px;
            border: 1px solid rgba(148, 163, 184, 0.28);
            background: rgba(30, 41, 59, 0.6);
            color: var(--sidebar-text);
            font-weight: 600;
            cursor: pointer;
            transition: transform var(--transition-speed), background var(--transition-speed), border var(--transition-speed);
        }

        .report-problem-btn:hover {
            background: rgba(51, 65, 85, 0.7);
            transform: translateY(-1px);
        }
