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

      body {
        font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        min-height: 100vh;
      }

      /* Auth Pages */
      .auth-container {
        display: flex;
        justify-content: center;
        align-items: center;
        min-height: 100vh;
        padding: 20px;
      }

      .auth-card {
        background: white;
        border-radius: 20px;
        box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
        padding: 40px;
        width: 100%;
        max-width: 450px;
        animation: slideUp 0.5s ease-out;
      }

      @keyframes slideUp {
        from {
          opacity: 0;
          transform: translateY(30px);
        }

        to {
          opacity: 1;
          transform: translateY(0);
        }
      }

      .auth-header {
        text-align: center;
        margin-bottom: 30px;
      }

      .auth-header i {
        font-size: 3rem;
        color: #667eea;
        margin-bottom: 15px;
      }

      .auth-header h1 {
        font-size: 2rem;
        font-weight: 700;
        color: #2d3748;
        margin-bottom: 8px;
      }

      .auth-header p {
        color: #718096;
        font-size: 0.95rem;
      }

      .auth-form .form-group {
        margin-bottom: 20px;
      }

      .auth-form label {
        display: block;
        margin-bottom: 8px;
        font-weight: 600;
        color: #2d3748;
        font-size: 0.9rem;
      }

      .auth-form label i {
        margin-right: 8px;
        color: #667eea;
      }

      .form-control {
        width: 100%;
        padding: 12px 16px;
        border: 2px solid #e2e8f0;
        border-radius: 10px;
        font-size: 0.95rem;
        transition: all 0.3s;
      }

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

      .btn {
        padding: 12px 24px;
        border: none;
        border-radius: 10px;
        font-weight: 600;
        cursor: pointer;
        transition: all 0.3s;
        font-size: 0.95rem;
      }

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

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

      .btn-block {
        width: 100%;
        display: block;
      }

      .auth-footer {
        text-align: center;
        margin-top: 20px;
        padding-top: 20px;
        border-top: 1px solid #e2e8f0;
      }

      .auth-footer a {
        color: #667eea;
        font-weight: 600;
        text-decoration: none;
      }

      .alert {
        padding: 12px 16px;
        border-radius: 10px;
        margin-bottom: 20px;
      }

      .alert-danger {
        background: #fee;
        color: #c53030;
        border: 1px solid #fc8181;
      }

      /* Chat Interface */
      .chat-container {
        display: flex;
        height: 100vh;
        background: #f7fafc;
      }

      .sidebar {
        width: 300px;
        background: white;
        border-right: 1px solid #e2e8f0;
        display: flex;
        flex-direction: column;
        box-shadow: 2px 0 10px rgba(0, 0, 0, 0.05);
      }

      .sidebar-header {
        padding: 20px;
        border-bottom: 1px solid #e2e8f0;
      }

      .sidebar-header h2 {
        font-size: 1.3rem;
        color: #2d3748;
        margin-bottom: 15px;
      }

      .btn-new-chat {
        width: 100%;
        padding: 12px;
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        color: white;
        border-radius: 10px;
        text-align: center;
        text-decoration: none;
        display: block;
        font-weight: 600;
        transition: all 0.3s;
      }

      .btn-new-chat:hover {
        transform: translateY(-2px);
        box-shadow: 0 5px 15px rgba(102, 126, 234, 0.3);
      }

      .sidebar-content {
        flex: 1;
        overflow-y: auto;
        padding: 10px;
      }

      .conversation-item {
        background: linear-gradient(135deg, #ffffff 0%, #dbb7ff 100%);
        padding: 15px;
        margin-bottom: 8px;
        border-radius: 10px;
        text-decoration: none;
        color: #2d3748;
        display: block;
        transition: all 0.2s;
      }

      .conversation-item:hover {
        background: #f7fafc;
      }

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

      .conversation-info {
        display: flex;
        align-items: center;
        margin-bottom: 8px;
      }

      .conversation-info i {
        margin-right: 10px;
        margin-left: 10px;
      }

      .conversation-meta {
        color: black;
        display: flex;
        justify-content: space-between;
        align-items: center;
        font-size: 0.8rem;
        opacity: 0.7;
      }

      .btn-delete {
        background: none;
        border: none;
        cursor: pointer;
        padding: 4px 8px;
        color: inherit;
      }

      .sidebar-footer {
        padding: 20px;
        border-top: 1px solid #e2e8f0;
      }

      .user-info {
        display: flex;
        align-items: center;
        margin-bottom: 12px;
        font-size: 0.9rem;
        color: #4a5568;
      }

      .user-info i {
        font-size: 1.5rem;
        margin-right: 10px;
      }

      .btn-logout {
        width: 100%;
        padding: 10px;
        background: #f7fafc;
        color: #4a5568;
        border-radius: 8px;
        text-align: center;
        text-decoration: none;
        display: block;
        font-weight: 500;
        transition: all 0.2s;
      }

      .btn-logout:hover {
        background: #e2e8f0;
      }

      /* Main Chat */
      .chat-main {
        flex: 1;
        display: flex;
        flex-direction: column;
        background: #ffffff;
      }

      .chat-header {
        padding: 20px 30px;
        border-bottom: 1px solid #e2e8f0;
        background: white;
        display: flex;
        justify-content: space-between;
        align-items: center;
      }

      .chat-header h3 {
        font-size: 1.3rem;
        color: #2d3748;
      }

      .rate-limits {
        display: flex;
        gap: 20px;
      }

      .rate-limit-item {
        display: flex;
        align-items: center;
        gap: 10px;
      }

      .rate-limit-item .label {
        font-weight: 600;
        font-size: 0.85rem;
        color: #4a5568;
      }

      .progress-bar {
        width: 100px;
        height: 8px;
        background: #e2e8f0;
        border-radius: 10px;
        overflow: hidden;
      }

      .progress-fill {
        height: 100%;
        background: linear-gradient(90deg, #48bb78, #38a169);
        transition: width 0.3s;
      }

      .rate-limit-item .count {
        font-size: 0.85rem;
        color: #718096;
      }

      .messages-container {
        flex: 1;
        overflow-y: auto;
        padding: 30px;
        background: #f7fafc;
      }

      .message {
        display: flex;
        margin-bottom: 30px;
        animation: fadeIn 0.3s;
      }

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

        to {
          opacity: 1;
          transform: translateY(0);
        }
      }

      .message-avatar {
        width: 40px;
        height: 40px;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        margin-right: 15px;
        flex-shrink: 0;
      }

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

      .message.assistant .message-avatar {
        background: #48bb78;
        color: white;
      }

      .message-content {
        flex: 1;
        max-width: 80%;
      }

      .message-header {
        display: flex;
        align-items: center;
        gap: 10px;
        margin-bottom: 8px;
      }

      .message-header .role {
        font-weight: 600;
        font-size: 0.9rem;
        color: #2d3748;
      }

      .message-header .time {
        font-size: 0.8rem;
        color: #a0aec0;
      }

      .message-text {
        background: white;
        padding: 15px 20px;
        border-radius: 15px;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
        line-height: 1.6;
        word-wrap: break-word;
        /* Ensure long, non-space characters wrap */
        /* white-space: pre-wrap; */
        /* Preserve formatting and wrap text */
        color: #2d3748;
      }

      .btn-menu {
        display: none;
        /* Hide toggle button by default on desktop */
      }

      .sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.4);
        z-index: 999;
        /* Below sidebar (1000) but above chat content */
        display: none;
      }

      .chat-container.sidebar-open .sidebar-overlay {
        display: block;
      }

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

      .chat-input-container {
        padding: 20px 30px;
        border-top: 1px solid #e2e8f0;
        background: white;
      }

      .input-wrapper {
        display: flex;
        gap: 12px;
        align-items: flex-end;
      }

      #message-input {
        flex: 1;
        padding: 12px 16px;
        border: 2px solid #e2e8f0;
        border-radius: 12px;
        font-family: inherit;
        font-size: 0.95rem;
        resize: none;
        max-height: 120px;
        transition: all 0.3s;
      }

      #message-input:focus {
        outline: none;
        border-color: #667eea;
      }

      .btn-send {
        width: 50px;
        height: 50px;
        border-radius: 12px;
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        color: white;
        border: none;
        cursor: pointer;
        transition: all 0.3s;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 1.2rem;
      }

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

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

      .empty-state {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        height: 100%;
        text-align: center;
        color: #718096;
      }

      .empty-state i {
        font-size: 5rem;
        margin-bottom: 20px;
        color: #cbd5e0;
      }

      .empty-state h2 {
        font-size: 1.8rem;
        color: #2d3748;
        margin-bottom: 10px;
      }

      .error-toast {
        position: fixed;
        top: 20px;
        right: 20px;
        background: #fc8181;
        color: white;
        padding: 16px 24px;
        border-radius: 10px;
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
        display: flex;
        align-items: center;
        gap: 12px;
        animation: slideIn 0.3s ease-out;
        z-index: 1000;
      }

      .error-toast i {
        font-size: 1.2rem;
      }

      @keyframes slideIn {
        from {
          opacity: 0;
          transform: translateX(100px);
        }

        to {
          opacity: 1;
          transform: translateX(0);
        }
      }

      @keyframes slideOut {
        from {
          opacity: 1;
          transform: translateX(0);
        }

        to {
          opacity: 0;
          transform: translateX(100px);
        }
      }

      /* #################################################################### */
      /* ## MOBILE MEDIA QUERY: Styles for screens <= 768px wide ## */
      /* #################################################################### */
      @media (max-width: 768px) {
        .btn-menu {
          display: inline-flex;
          /* Show toggle button on mobile */
          margin-right: 15px;
          background: none;
          color: #2d3748;
          border: 1px solid #e2e8f0;
          width: 40px;
          height: 40px;
          align-items: center;
          justify-content: center;
          border-radius: 8px;
        }

        /* --- Chat Header (Mobile adjustments to prevent stacking) --- */
        .chat-header {
          /* CHANGED: Use flex for a horizontal layout */
          flex-direction: row;
          align-items: center;
          justify-content: flex-start;
          /* Start elements from the left */
        }

        /* --- Message Content Fix (Fill Width) --- */
        .message-content {
          /* Mobile: Use most of the screen width */
          max-width: 90%;
        }

        /* Hide the rate limits again for small screens */
        .rate-limits {
          display: none;
        }

        /* Hide conversation info in the header to save space */
        .chat-header h3 {
          /* Allow title to take remaining space */
          flex: 1;
          margin-bottom: 0;
          font-size: 1.1rem;
          /* Ensure title wraps if too long */
          overflow: hidden;
          text-overflow: ellipsis;
          /* white-space: pre-wrap; */
        }

        /* Add a close button area inside the sidebar-header (optional, but good practice) */
        .sidebar-header {
          display: flex;
          justify-content: space-between;
          align-items: center;
        }

        .chat-container {
          /* Mobile view: No longer a row, as the sidebar is hidden or toggled */
          flex-direction: column;
          height: auto;
        }

        /* --- Sidebar Handling --- */
        .sidebar {
          /* By default, hide the sidebar entirely on mobile */
          position: fixed;
          top: 0;
          left: -300px;
          /* Hide off-screen */
          width: 300px;
          height: 100vh;
          z-index: 1000;
          transition: left 0.3s ease;
          /* Smooth slide-in effect */
          box-shadow: 2px 0 5px rgba(0, 0, 0, 0.1);
          border-right: none;
        }

        /* JavaScript will add this class to reveal the sidebar */
        .chat-container.sidebar-open .sidebar {
          left: 0;
          /* Slide sidebar into view */
        }

        /* --- Chat Main Area --- */
        .chat-main {
          /* The main chat area takes up the full width */
          width: 100vw;
          height: 100vh;
          /* Make it full height for chat viewing */
          margin-left: 0;
        }

        /* --- Chat Header (Mobile adjustments) --- */
        .chat-header {
          /* Keep header content aligned, but may need to shrink elements */
          padding: 10px 15px;
          flex-direction: column;
          /* Stack title and rate limits */
          align-items: flex-start;
          position: sticky;
          /* Keep it visible at the top */
          top: 0;
          background: white;
          /* Ensure background hides scrolling messages */
          z-index: 100;
        }

        /* Rate limits usually take up too much space, let's stack them or hide them */
        .chat-header h3 {
          margin-bottom: 5px;
        }

        .rate-limits {
          display: none;
          /* Hide rate limits on very small screens to save space */
          /* If you want to keep them: display: flex; flex-wrap: wrap; */
        }

        /* --- Messages Container --- */
        .messages-container {
          /* Ensure message area uses all available height */
          height: calc(100vh - 120px);
          /* Adjust based on header/input height */
          /* Must be explicitly set to allow scrolling inside */
          overflow-y: auto;
        }

        /* --- Chat Input --- */
        .chat-input-container {
          padding: 10px;
          /* Pin to the bottom on mobile */
          position: fixed;
          bottom: 0;
          left: 0;
          right: 0;
          background: #f8f8f8;
          /* Match background */
          border-top: 1px solid #ddd;
        }
      }
