   :root{
     --bg:#0b1220;
     --card-gradient-start: rgba(255,255,255,0.02);
     --card-gradient-end: rgba(255,255,255,0.01);
     --muted:#94a3b8;
     --accent:#7c3aed;
     --accent-600:#6d28d9;
     --white:#ffffff;
   }

   * {
      margin: 0;
      padding: 0;
      box-sizing: border-box;
    }
    
    body {
      padding: 10px;
      font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
      background: linear-gradient(180deg,var(--bg) 0%, #071026 100%);
      min-height: 100vh;
      display: flex;
      gap:10px;
      align-items: center;
      justify-content: center;
      color: #cbd5e1;
      position: relative;
      overflow-x: hidden;
    }

    /* ===================================
       MOBILE HAMBURGER MENU
       =================================== */
    .mobile-menu-toggle {
      display: none;
      position: fixed;
      top: 20px;
      left: 20px;
      z-index: 10000;
      background: linear-gradient(135deg, var(--accent), var(--accent-600));
      border: none;
      border-radius: 12px;
      width: 50px;
      height: 50px;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      gap: 6px;
      cursor: pointer;
      box-shadow: 0 4px 15px rgba(124, 58, 237, 0.4);
      transition: all 0.3s ease;
    }

    .mobile-menu-toggle:hover {
      transform: scale(1.05);
      box-shadow: 0 6px 20px rgba(124, 58, 237, 0.6);
    }

    .mobile-menu-toggle.active {
      background: linear-gradient(135deg, #ef4444, #dc2626);
    }

    .hamburger-line {
      width: 24px;
      height: 3px;
      background: white;
      border-radius: 3px;
      transition: all 0.3s ease;
    }

    .mobile-menu-toggle.active .hamburger-line:nth-child(1) {
      transform: rotate(45deg) translateY(9px);
    }

    .mobile-menu-toggle.active .hamburger-line:nth-child(2) {
      opacity: 0;
    }

    .mobile-menu-toggle.active .hamburger-line:nth-child(3) {
      transform: rotate(-45deg) translateY(-9px);
    }

    /* Mobile Header (Hidden on Desktop) */
    .mobile-header {
      display: none;
      align-items: center;
      justify-content: space-between;
      padding: 12px 16px;
      background: linear-gradient(180deg, var(--card-gradient-start), var(--card-gradient-end));
      backdrop-filter: blur(10px);
      border: 1px solid rgba(255, 255, 255, 0.04);
      border-radius: 15px;
      margin-bottom: 10px;
      box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
      gap: 10px;
    }

    .mobile-header-right {
      display: flex;
      align-items: center;
      gap: 10px;
    }

    .mobile-menu-btn {
      background: transparent;
      border: none;
      color: white;
      font-size: 1.5rem;
      cursor: pointer;
      padding: 8px;
      display: flex;
      align-items: center;
      justify-content: center;
      flex-shrink: 0;
    }

    .mobile-title {
      color: white;
      font-size: 1.2rem;
      font-weight: 700;
      margin: 0;
      flex: 1;
    }

    .mobile-login-btn {
      padding: 6px 12px !important;
      font-size: 0.85rem !important;
      white-space: nowrap;
      border-radius: 8px;
      background: transparent;
      border: 1px solid rgba(255, 255, 255, 0.08);
      color: var(--white);
      text-decoration: none;
      display: inline-flex;
      align-items: center;
      gap: 6px;
      min-width: auto;
    }

    .mobile-login-btn:hover {
      background: rgba(255, 255, 255, 0.05);
    }

    .mobile-header .auth-dropdown {
      position: relative;
    }

    .mobile-header .auth-menu {
      right: 0;
      left: auto;
      transform: translateX(0);
      min-width: 160px;
    }

    .status-badge-mobile {
      font-size: 1.2rem;
      line-height: 1;
      flex-shrink: 0;
    }

    .status-badge-mobile.disconnected {
      color: #ef4444;
    }

    .status-badge-mobile.connected {
      color: #10b981;
    }

    .status-badge-mobile.connecting {
      color: #f59e0b;
      animation: pulse 1.5s infinite;
    }

    .status-badge-mobile.recording {
      color: #f97316;
      animation: pulse 1.5s infinite;
    }
    
.sidebar{
  display: flex;
  height: 95vh;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 10px;
  transition: transform 0.3s ease, opacity 0.3s ease;
}

   /* Hide mobile persona selector on desktop */
   .sidebar-persona-mobile {
     display: none;
   }

   .sidebar-logo {
      display: flex;
      justify-content: center;
      align-items: center;
      width: 40px;
    }

    .sidebar-logo img {
      max-width: 100%;
      height: auto;
      max-height: 60px;
    }

   .sidebar-buttons{
      display: flex;
      flex-direction: column;
      gap: 10px;
    }
    .sidebar-buttons span{
      display: none;
    }

    .container {
      width: 100%;
    }
    
    /* Header Styles */
  header {
      text-align: center;
      margin-bottom: 10px;
      background: linear-gradient(180deg, var(--card-gradient-start), var(--card-gradient-end));
      backdrop-filter: blur(10px);
      border: 1px solid rgba(255, 255, 255, 0.04);
      border-radius: 20px;
      box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
      padding: 8px;
      display:flex;
      justify-content:space-between;
      align-items:center;
    }
    
    header .persona-selector, header select option{
      color: white;
      padding: 8px 14px;
      background: #0b1220;
      border: 1px solid rgba(255, 255, 255, 0.2);
      border-radius:20px;
      font-size: 0.9rem;
      font-weight: 500;
      cursor: pointer;
      transition: all 0.3s ease;
      margin-right: 30px;
      margin-top: 5px;
    }
    
    header h1 {
      color: white;
      font-weight: 700;
      text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
      margin-left: 200px;
    }
   

  .card {
     background: linear-gradient(180deg, var(--card-gradient-start), var(--card-gradient-end));
      backdrop-filter: blur(12px);
      border: 1px solid rgba(255, 255, 255, 0.04);
      border-radius: 20px;
      padding: 10px;
      height: 85vh;
      box-shadow: 0 10px 40px rgba(0, 0, 0, 0.45);
      text-align: center;
      transition: transform 0.3s ease, box-shadow 0.3s ease;
      display: flex;
      flex-direction: column;
      gap: 10px;
      position: relative;
    }
    
    .card .topbar {
      display: flex;
      justify-content: space-between;
      align-items: center;
    }
    
    .card .topbar .topbar-buttons {
      display: flex;
      gap: 10px;
      position: relative;
    }
    
    .status-indicator {
      display: flex;
      align-items: center;
      gap: 10px;
    }
    
    .status-badge {
      padding: 6px 12px;
      border-radius: 20px;
      font-size: 0.9rem;
      font-weight: 600;
      text-transform: uppercase;
      letter-spacing: 0.5px;
      margin-left: 20px;
    }
    
    .status-badge.disconnected {
      background-color: #f8d7da;
      color: #721c24;
      border: 1px solid #f5c6cb;
    }
    
    .status-badge.connecting {
      background-color: #fff3cd;
      color: #856404;
      border: 1px solid #ffeaa7;
      animation: pulse 1.5s infinite;
    }
    
    .status-badge.connected {
      background-color: #d4edda;
      color: #155724;
      border: 1px solid #c3e6cb;
    }
    
    .status-badge.recording {
      background-color: #fee2d1;
      color: #8a4a00;
      border: 1px solid #fdcba4;
      animation: pulse 1.5s infinite;
    }
    
    .status-badge.error {
      background-color: #f8d7da;
      color: #721c24;
      border: 1px solid #f5c6cb;
    }
    
    .streaming-session {
      font-size: 0.8rem;
    display: none;
      color: #6c757d;
      font-family: 'Courier New', monospace;
    }
    
    .btn-toggle {
      background: rgba(103, 126, 234, 0.2);
      color: #fff;
      border: 1px solid #a5b2eb;
      padding: 14px;
      border-radius:20px;
      font-size: 0.9rem;
      font-weight: 500;
      cursor: pointer;
      transition: all 0.3s ease;
      text-decoration: none;
    }
    
    .btn-toggle:hover {
      background: rgba(103, 126, 234, 0.3);
      transform: translateY(-1px);
    }

    /* Shared nav button used in header */
    .nav-btn{
      background: transparent;
      border: 1px solid rgba(255,255,255,0.08);
      padding: 8px 12px;
      border-radius: 8px;
      color: var(--white);
      text-decoration: none;
      display: inline-flex;
      align-items: center;
      gap: 8px;
    }

    /* Auth dropdown menu (profile/logout) */
  .auth-dropdown {
    position: relative;
    display: inline-flex; /* ensure positioning is relative to the button and alignment is consistent */
    align-items: center;
    overflow: visible;
  }

  /* Dropdown menu that appears below the account button */
  .auth-menu {
    position: absolute;
    left: 50%; /* center under the parent */
    right: auto;
    top: calc(100% + 8px); /* slightly tighter spacing */
    background: linear-gradient(180deg, var(--card-gradient-start), var(--card-gradient-end));
    border: 1px solid rgba(255,255,255,0.06);
    padding: 6px;
    border-radius: 10px;
    min-width: 180px;
    box-shadow: 0 12px 40px rgba(2, 6, 23, 0.7);
    z-index: 100000;
    transform-origin: top center;
    transform: translateX(-50%); /* center the menu horizontally under the account button */
    box-sizing: border-box;
  }

  /* Auth menu items use a consistent flex layout so icons and text align */
  .auth-menu-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    color: var(--white);
    text-decoration: none;
    border-radius: 8px;
    background: transparent;
    text-align: left;
    border: none;
    cursor: pointer;
    width: 100%;
    box-sizing: border-box;
    font-weight: 600;
  }

  .auth-menu-item:hover {
    background: rgba(255, 255, 255, 0.02);
  }

  /* Make logout visually distinct and full-width */
  .logout-button {
    width: 100%;
    text-align: left;
    padding: 10px 12px;
    border-radius: 8px;
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: #fff;
    border: none;
    box-shadow: 0 6px 18px rgba(220, 38, 38, 0.18);
    transition: transform 0.12s ease, filter 0.12s ease;
    display: flex;
    align-items: center;
    gap: 8px;
  }

  .logout-button:hover {
    transform: translateY(-2px);
    filter: brightness(1.03);
  }

  .logout-inline {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.06);
    color: var(--white);
    padding: 6px 10px;
    border-radius: 8px;
    cursor: pointer;
  }

  /* Visible inline logout that appears next to the account pill */
  .logout-inline-visible{
    margin-left: 8px;
    background: transparent;
    border: 1px solid rgba(255,255,255,0.08);
    color: var(--white);
    padding: 6px 10px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 8px;
  }

  .logout-inline-visible:hover{ background: rgba(255,255,255,0.02); transform: translateY(-1px); }
    
    /* Chat history container */
    .chat-history-container {
      padding: 10px;
      margin-bottom: 20px;
      height: 70vh;
      overflow-y: auto;
      display: block;
      flex: 1;
      display: flex;
      flex-direction: column;
      overflow: hidden;
    }
    
    .chat-history-container h4 {
      color: #4a5568;
      font-size: 1.1rem;
      font-weight: 600;
      text-align: left;
      margin-bottom: 10px;
    }
    
    .chat-history-list {
      flex: 1;
      display: flex;
      flex-direction: column;
      gap: 5px;
      overflow-y: auto;
    }
    
    .chat-message {
      background: rgba(255,255,255,0.02);
      transition: all 0.2s ease;
      position: relative;
      box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
      animation: fadeIn 0.3s ease-out;
      border-radius: 8px;
      padding: 8px;
      min-width: 300px;
      width: fit-content;
      transition: all 0.2s ease;
      max-width: 400px;
      color: #cbd5e1;
      margin-bottom:10px;
    }
    
    .chat-message.user {
      align-self: flex-end;
      color: #cbd5e1;
      border-bottom-right-radius: 4px;
      border-right: 4px solid #667eea;
      background: rgba(103, 126, 234, 0.06);
    }
    
    .chat-message.assistant {
      align-self: flex-start;
      color: #cbd5e1;
      border-bottom-left-radius: 4px;
      background: rgba(72, 187, 120, 0.06);
      border-left: 4px solid #48bb78;
    }
    
    .message-header {
      display: flex;
      justify-content: space-between;
      align-items: center;
      margin-bottom: 8px;
    }
    
    .message-role {
      font-weight: 600;
      font-size: 0.9rem;
      color: gray;
    }
    
    .message-time {
      font-size: 0.8rem;
      opacity: 0.8;
      font-family: 'Courier New', monospace;
      color: gray;
    }
    .message-content{
      font-size: 14px;
      word-wrap: break-word;
      margin: 0;
      color:white;
      padding: 0;
      text-align: start;
    }
    .message-content p {
      font-size: 14px;
      word-wrap: break-word;
      margin: 0;
      color: white;
      padding: 0;
      text-align: start;
    }

    /* Smooth text streaming animation */
    .ai-response-text {
      display: inline-block;
      transition: all 0.1s ease-out;
      will-change: contents;
    }

    .ai-response-text.smooth-update {
      animation: textReveal 0.2s ease-out;
    }

    @keyframes textReveal {
      from {
        opacity: 0.8;
        transform: translateY(2px);
      }
      to {
        opacity: 1;
        transform: translateY(0);
      }
    }
    
    .no-history {
      text-align: center;
      color: #718096;
      font-style: italic;
      padding: 20px;
    }
    
    /* Dots loader for AI responses */
    .dots-loader {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      padding: 10px;
    }
    
    .dots-loader span {
      width: 8px;
      height: 8px;
      margin: 0 3px;
      background-color: #48bb78;
      border-radius: 50%;
      display: inline-block;
      animation: bounce 1.3s infinite ease-in-out both;
    }
    
    .dots-loader span:nth-child(1) {
      animation-delay: -0.32s;
    }
    
    .dots-loader span:nth-child(2) {
      animation-delay: -0.16s;
    }
    
    @keyframes bounce {
      0%, 80%, 100% {
        transform: scale(0);
      }
      40% {
        transform: scale(1);
      }
    }
    
    /* Streaming logs container */
  .streaming-status-container {
  background: linear-gradient(180deg, var(--card-gradient-start), var(--card-gradient-end));
      padding: 10px;
      border: 1px solid rgba(255,255,255,0.04);
      border-radius: 8px;
      max-height:90vh;
      width: 500px;
      overflow-y: auto;
      z-index: 10;
      box-shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
      display: none;
    }
    
    .streaming-status-container h5 {
      color: #4a5568;
      font-size: 1rem;
      margin-bottom: 10px;
      text-align: left;
    }
    
    .status-log {
      font-family: 'Courier New', monospace;
      font-size: 0.85rem;
      line-height: 1.4;
    }
    
    .streaming-status {
      padding: 5px 10px;
      margin: 5px 0;
      border-left: 4px solid;
      border-radius: 3px;
      font-size: 0.8rem;
    }
    
    .streaming-status.success {
      border-left-color: #28a745;
      background-color: #d4edda;
      color: #155724;
    }
    
    .streaming-status.info {
      border-left-color: #17a2b8;
      background-color: #d1ecf1;
      color: #0c5460;
    }
    
    .streaming-status.warning {
      border-left-color: #ffc107;
      background-color: #fff3cd;
      color: #856404;
    }
    
    .streaming-status.error {
      border-left-color: #dc3545;
      background-color: #f8d7da;
      color: #721c24;
    }
    
    .streaming-status.recording {
      border-left-color: #fd7e14;
      background-color: #fee2d1;
      color: #8a4a00;
      animation: pulse 1.5s infinite;
    }

    /* Conversation History Popup */
  .conversation-history-popup {
  background: linear-gradient(180deg, var(--card-gradient-start), var(--card-gradient-end));
      border: 1px solid rgba(255,255,255,0.04);
      border-radius: 20px;
      box-shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
      width: 550px;
      max-height: 100%;
      overflow-y: auto;
      z-index: 1000;
      display: none; /* Hidden by default */
      padding: 10px;
    }

    .conversation-popup-header {
      display: flex;
      justify-content: space-between;
      align-items: center;
      margin-bottom: 10px;
    }
.conversation-popup-buttons{
  display: flex;
  gap: 10px;

}
    .btn-close-popup {
      background: white;
      border: none;
      font-size: 1.5rem;
      cursor: pointer;
    }


    .conversation-list {
      max-height: 87vh;
      overflow-y: auto;
      padding: 5px;
    }

    .conversation-list-item {
      padding: 5px;
      cursor: pointer;
      transition: background 0.2s;
    }

    .conversation-list-item:hover {
      background: #f1f1f1;
    }

    .conversation-messages-container {
      border-top: 1px solid #dee2e6;
      padding-top: 10px;
    }

    .conversation-messages {
      max-height: 300px;
      overflow-y: auto;
      border: 1px solid #dee2e6;
      border-radius: 4px;
      padding: 5px;
    }

    /* Configuration Modal Styles */
    
    .config-modal {
      display: none;
    }

  .config-modal-content {
  background: linear-gradient(180deg, var(--card-gradient-start), var(--card-gradient-end));
      border-radius: 20px;
      padding: 10px;
      width: 400px;
      max-height: 100%  ;
      overflow-y: auto;
      box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
    }

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

    .config-modal-header h3 {
      color: #2d3748;
      margin: 0;
    }

    .config-modal-body {
      padding: 10px 0;
    }

    .form-group {
      margin-bottom: 5px;
    }

    .form-group label {
      display: block;
      margin-bottom: 5px;
      font-weight: 600;
      font-size: 14px;
      color: white;
      border: 2px solid transparent;
    }

    .form-input {
      width: 100%;
      padding: 10px;
      border: 1px solid #cbd5e0;
      border-radius: 6px;
      font-size: 14px;
      transition: border-color 0.2s ease;
    }

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

  

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

    .form-help {
      display: block;
      margin-top: 4px;
      font-size: 12px;
      color: #718096;
    }

    .form-actions {
      display: flex;
      gap: 15px;
      justify-content: center;
      margin-top: 5px;
      flex-wrap: wrap;
    }

    .form-actions .btn {
      padding: 10px 20px;
      font-size: 14px;
      min-width: auto;
    }

    .config-status {
      margin-top: 15px;
      padding: 10px;
      border-radius: 6px;
      font-size: 14px;
      display: none;
    }

    .config-status.success {
      background-color: #d4edda;
      color: #155724;
      border: 1px solid #c3e6cb;
      display: block;
    }

    .config-status.error {
      background-color: #f8d7da;
      color: #721c24;
      border: 1px solid #f5c6cb;
      display: block;
    }
    
    /* Controls */
    .controls {
      display: flex;
      width: 100%;
      justify-content: center;
      position: absolute;
      bottom: 10px;
      left: 50%;
      right: 50%;
      transform: translateX(-50%);
      flex-direction: column;
      align-items: center;
      gap: 8px;
    }

    .web-search-toggle {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    user-select: none;
    cursor: pointer;
    transition: background 0.3s ease;
  }

  /* Active state */
  .web-search-toggle.active {
    background: #85649d; /* blue when active */
    color: #fff;
  }

  /* Hide the checkbox */
  .web-search-toggle input[type="checkbox"] {
    display: none;
  }
    
    .btn {
      background: linear-gradient(135deg, #1b63ff54 0%, #663174 100%);
      color: white;
      border: none;
      padding: 15px 40px;
      border-radius: 50px;
      font-size: 1.1rem;
      font-weight: 600;
      cursor: pointer;
      transition: all 0.3s ease;
      box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
      display: flex;
      align-items: center;
      gap: 8px;
      justify-content: center;
     text-decoration: none;
     height: 40px;
     margin-right: 20px;
    }
    
    .btn-icon {
      font-size: 1.2rem;
    }
    
    .btn:hover {
      transform: translateY(-3px);
      box-shadow: 0 8px 25px rgba(102, 126, 234, 0.6);
    }
    
    .btn:active {
      transform: translateY(-1px);
    }
    
    .btn:disabled {
      opacity: 0.7;
      cursor: not-allowed;
      transform: none;
    }
    
    .btn.primary {
      background: linear-gradient(135deg, #667eea, #764ba2);
      min-width: 160px;
    }
    
    .btn.danger {
      background: linear-gradient(135deg, #ef4444, #dc2626);
      color: white;
      border: none;
    }
    
    .btn.danger:hover {
      background: linear-gradient(135deg, #dc2626, #b91c1c);
    }
    
    /* Animations */
    @keyframes pulse {
      0% {
        opacity: 1;
      }
      50% {
        opacity: 0.7;
      }
      100% {
        opacity: 1;
      }
    }
    
    @keyframes fadeIn {
      from {
        opacity: 0;
        transform: translateY(10px);
      }
      to {
        opacity: 1;
        transform: translateY(0);
      }
    }
    
    /* Scrollbar styling */
    .chat-history-list::-webkit-scrollbar,
    .status-log::-webkit-scrollbar {
      width: 6px;
    }
    
    .chat-history-list::-webkit-scrollbar-track,
    .status-log::-webkit-scrollbar-track {
      background: #f1f1f1;
      border-radius: 10px;
    }
    
    .chat-history-list::-webkit-scrollbar-thumb,
    .status-log::-webkit-scrollbar-thumb {
      background: #c1c1c1;
      border-radius: 10px;
    }
    
    .chat-history-list::-webkit-scrollbar-thumb:hover,
    .status-log::-webkit-scrollbar-thumb:hover {
      background: #a8a8a8;
    }

::-webkit-scrollbar{
  display: none;
}

.header-controls, .user-menu{
  display:flex;
}

/* ============================================
   RESPONSIVE DESIGN - MOBILE, TABLET, LAPTOP
   ============================================ */

/* Mobile First - Base styles above are for desktop */

/* Tablet Devices (768px - 1024px) */
@media screen and (max-width: 1024px) {
  body {
    padding: 8px;
    gap: 8px;
  }

  .sidebar {
    height: 93vh;
    padding: 8px;
  }

  .streaming-status-container {
    width: 400px;
    max-height: 85vh;
  }

  .conversation-history-popup {
    width: 450px;
  }

  header h1 {
    font-size: 1.5rem;
    margin-left: 100px;
  }

  .card {
    height: 83vh;
  }

  .chat-history-container {
    height: 65vh;
  }

  .config-modal-content {
    width: 350px;
  }

  .btn {
    padding: 12px 35px;
    font-size: 1rem;
  }
}

/* Small Tablets & Large Phones (481px - 767px) */
@media screen and (max-width: 767px) {
  body {
    flex-direction: column;
    padding: 5px;
    gap: 5px;
  }

  /* Show mobile menu toggle */
  .mobile-menu-toggle {
    display: flex;
  }

  /* Show mobile header, hide desktop header */
  .mobile-header {
    display: flex;
  }

  header {
    display: none;
  }

  /* Sidebar becomes overlay menu on mobile */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 280px;
    height: 100vh;
    background: linear-gradient(180deg, var(--bg) 0%, #0a0e1a 100%);
    backdrop-filter: blur(20px);
    border-right: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 2px 0 20px rgba(0, 0, 0, 0.5);
    z-index: 9999;
    transform: translateX(-100%);
    opacity: 0;
    padding: 80px 15px 20px;
    justify-content: flex-start;
    gap: 30px;
  }

  .sidebar.active {
    transform: translateX(0);
    opacity: 1;
  }

  /* Overlay backdrop when menu is open */
  body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    z-index: 9998;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
  }

  body.menu-open::before {
    opacity: 1;
    pointer-events: all;
  }

  .sidebar-logo {
    width: 60px;
  }

  .sidebar-logo img {
    max-height: 50px;
  }

  /* Mobile persona selector in sidebar */
  .sidebar-persona-mobile {
    display: block;
    width: 100%;
    margin-bottom: 10px;
  }

  .persona-selector-mobile {
    width: 100%;
    padding: 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    color: white;
    font-size: 0.95rem;
    cursor: pointer;
    outline: none;
  }

  .persona-selector-mobile option {
    background: #0b1220;
    color: white;
  }

  .sidebar-buttons {
    flex-direction: column;
    gap: 12px;
    width: 100%;
  }

  .sidebar-buttons .btn-toggle {
    padding: 14px 20px;
    font-size: 1rem;
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
    justify-content: flex-start;
    border-radius: 12px;
  }

  .sidebar-buttons .btn-toggle i {
    font-size: 1.2rem;
    width: 24px;
  }

  .sidebar-buttons span {
    display: inline-block;
    font-weight: 600;
  }

  .murf-branding {
    margin-top: auto;
  }

  .murf-branding img {
    width: 30px;
    height: 30px;
  }

  /* Container adjustments */
  .container {
    width: 100%;
    padding: 0;
  }

  /* Card adjustments */
  .card {
    height: auto;
    min-height: calc(100vh - 80px);
    padding: 8px;
    border-radius: 15px;
  }

  .card .topbar {
    flex-direction: column;
    gap: 8px;
  }

  .card .topbar .topbar-buttons {
    width: 100%;
    justify-content: center;
  }

  /* Chat history */
  .chat-history-container {
    height: 55vh;
    padding: 8px;
    margin-bottom: 10px;
  }

  .chat-message {
    min-width: 200px;
    max-width: 90%;
    font-size: 0.9rem;
  }

  .message-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }

  .message-role {
    font-size: 0.85rem;
  }

  .message-time {
    font-size: 0.75rem;
  }

  .message-content,
  .message-content p {
    font-size: 13px;
  }

  /* Controls */
  .controls {
    position: static;
    transform: none;
    margin-top: 10px;
    bottom: auto;
  }

  .btn {
    padding: 12px 30px;
    font-size: 0.95rem;
    min-width: 140px;
  }

  .btn.primary {
    min-width: 140px;
  }

  /* Streaming status */
  .streaming-status-container {
    width: 100%;
    max-width: 100%;
    max-height: 60vh;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    border-radius: 15px 15px 0 0;
    z-index: 1000;
  }

  /* Conversation popup */
  .conversation-history-popup {
    width: 95%;
    max-width: 95%;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    max-height: 85vh;
  }

  .conversation-list {
    max-height: 70vh;
  }

  /* Config modal */
  .config-modal-content {
    width: 95%;
    max-width: 350px;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
  }

  .form-actions {
    flex-direction: column;
  }

  .form-actions .btn {
    width: 100%;
  }

  /* Web search toggle */
  .web-search-toggle {
    padding: 8px 10px;
  }
}

/* Mobile Phones (320px - 480px) */
@media screen and (max-width: 480px) {
  body {
    padding: 3px;
    gap: 3px;
  }

  /* Mobile menu toggle positioning */
  .mobile-menu-toggle {
    top: 15px;
    left: 15px;
    width: 45px;
    height: 45px;
  }

  /* Sidebar overlay on mobile */
  .sidebar {
    width: 260px;
    padding: 70px 12px 15px;
  }

  .sidebar-logo {
    width: 50px;
  }

  .sidebar-logo img {
    max-height: 40px;
  }

  .sidebar-buttons {
    gap: 10px;
  }

  .sidebar-buttons .btn-toggle {
    padding: 12px 16px;
    font-size: 0.95rem;
    border-radius: 10px;
  }

  .sidebar-buttons .btn-toggle i {
    font-size: 1.1rem;
  }

  .murf-branding img {
    width: 26px;
    height: 26px;
  }

  /* Mobile Header */
  .mobile-header {
    padding: 10px 14px;
    border-radius: 12px;
  }

  .mobile-title {
    font-size: 1.1rem;
  }

  /* Card */
  .card {
    min-height: calc(100vh - 70px);
    padding: 6px;
    border-radius: 12px;
  }

  .chat-history-container {
    height: calc(100vh - 180px);
    padding: 6px;
  }

  .chat-message {
    min-width: 150px;
    max-width: 95%;
    padding: 6px;
    font-size: 0.85rem;
  }

  .message-content,
  .message-content p {
    font-size: 12px;
  }

  /* Controls */
  .controls {
    position: static;
    transform: none;
    margin-top: 10px;
    bottom: auto;
  }

  .btn {
    padding: 10px 25px;
    font-size: 0.9rem;
    min-width: 120px;
  }

  .btn.primary {
    min-width: 120px;
  }

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

  /* Streaming status */
  .streaming-status-container {
    width: 100%;
    max-width: 100%;
    max-height: 60vh;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    border-radius: 15px 15px 0 0;
    z-index: 1000;
    padding: 8px;
  }

  .streaming-status-container h5 {
    font-size: 0.9rem;
  }

  .streaming-status {
    font-size: 0.75rem;
    padding: 4px 8px;
  }

  /* Conversation popup */
  .conversation-history-popup {
    width: 98%;
    padding: 8px;
    border-radius: 15px;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
  }

  .conversation-popup-header h3 {
    font-size: 1.1rem;
  }

  .btn-close-popup {
    font-size: 1.3rem;
  }

  /* Config modal */
  .config-modal-content {
    width: 98%;
    padding: 8px;
  }

  .form-group {
    margin-bottom: 8px;
  }

  .form-group label {
    font-size: 13px;
  }

  .form-input {
    padding: 8px;
    font-size: 13px;
  }

  .form-help {
    font-size: 11px;
  }
}

/* Extra Small Devices (below 320px) */
@media screen and (max-width: 320px) {
  header h1 {
    font-size: 1rem;
  }

  .sidebar-buttons .btn-toggle {
    padding: 5px 6px;
  }

  .chat-message {
    max-width: 98%;
  }

  .btn {
    padding: 8px 20px;
    font-size: 0.85rem;
    min-width: 100px;
  }
}

/* Landscape Mode for Mobile Devices */
@media screen and (max-height: 500px) and (orientation: landscape) {
  .sidebar {
    padding: 5px;
  }

  .sidebar-buttons {
    gap: 3px;
  }

  .card {
    min-height: 60vh;
  }

  .chat-history-container {
    height: 45vh;
  }

  header {
    padding: 8px;
  }

  header h1 {
    font-size: 1rem;
  }

  .status-badge {
    font-size: 0.7rem;
    padding: 3px 6px;
  }
}

/* iPad and Tablet Portrait (768px - 834px) */
@media screen and (min-width: 768px) and (max-width: 834px) and (orientation: portrait) {
  /* Hide mobile elements */
  .mobile-menu-toggle {
    display: none;
  }

  .mobile-header {
    display: none;
  }

  /* Show desktop header */
  header {
    display: flex;
  }

  /* Sidebar becomes bottom navigation on tablet portrait */
  .sidebar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    height: auto;
    flex-direction: row;
    justify-content: space-around;
    align-items: center;
    padding: 10px;
    background: linear-gradient(180deg, var(--card-gradient-start), var(--card-gradient-end));
    backdrop-filter: blur(20px);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px 20px 0 0;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.3);
    z-index: 1000;
  }

  .sidebar-logo {
    order: -1;
    width: 50px;
  }

  .sidebar-logo img {
    max-height: 45px;
  }

  .sidebar-buttons {
    flex-direction: row;
    gap: 8px;
    flex-wrap: nowrap;
    flex: 1;
    justify-content: center;
    margin: 0 10px;
  }

  .sidebar-buttons .btn-toggle {
    padding: 10px;
    min-width: 50px;
    border-radius: 12px;
  }

  .sidebar-buttons .btn-toggle i {
    font-size: 1.1rem;
  }

  .sidebar-buttons span {
    display: none;
  }

  .murf-branding {
    order: 1;
  }

  .murf-branding img {
    width: 28px;
    height: 28px;
  }

  /* Adjust body for bottom nav */
  body {
    padding-bottom: 80px;
  }

  header h1 {
    font-size: 1.6rem;
    margin-left: 120px;
  }

  .card {
    height: calc(100vh - 180px);
    margin-bottom: 0;
  }

  .chat-history-container {
    height: calc(100vh - 280px);
  }

  .chat-message {
    max-width: 450px;
  }

  .streaming-status-container {
    width: 500px;
  }

  .conversation-history-popup {
    width: 550px;
  }
}

/* iPad and Tablet Landscape (1024px - 1366px) */
@media screen and (min-width: 1024px) and (max-width: 1366px) and (orientation: landscape) {
  .sidebar {
    height: 94vh;
  }

  .card {
    height: 86vh;
  }

  .chat-history-container {
    height: 72vh;
  }
}

/* Touch Device Optimizations */
@media (hover: none) and (pointer: coarse) {
  /* Larger touch targets for mobile */
  .btn-toggle,
  .btn,
  .auth-menu-item,
  .logout-button {
    min-height: 44px;
    min-width: 44px;
  }

  .sidebar-buttons .btn-toggle {
    min-height: 40px;
    min-width: 40px;
  }

  /* Prevent text selection on buttons */
  .btn,
  .btn-toggle,
  button {
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    user-select: none;
  }

  /* Improve scrolling on touch devices */
  .chat-history-list,
  .conversation-list,
  .status-log {
    -webkit-overflow-scrolling: touch;
  }
}

/* High DPI Displays (Retina) */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  .sidebar-logo img {
    image-rendering: -webkit-optimize-contrast;
  }
}

/* Print Styles */
@media print {
  .sidebar,
  .controls,
  header .header-controls,
  .streaming-status-container,
  .conversation-history-popup,
  .config-modal {
    display: none !important;
  }

  .chat-history-container {
    height: auto;
    max-height: none;
  }

  .card {
    box-shadow: none;
    border: 1px solid #ddd;
  }
}
