        /* --- THEME SYSTEM CSS --- */
        :root {
            --theme-bg-primary: #000000;
            --theme-bg-secondary: #161616;
            --theme-bg-tertiary: #202020;
            --theme-border: #333333;
            --theme-text-primary: #ffffff;
            --theme-text-secondary: #888888;
            --theme-accent: #1d9bf0;
            --theme-glass: rgba(22, 22, 22, 0.75);
            --sidebar-width: 260px;
        }
        body.theme-default {
            --theme-bg-primary: #000000;
            --theme-bg-secondary: #111111;
            --theme-bg-tertiary: #1a1a1a;
            --theme-border: #333333;
            --theme-text-primary: #ffffff;
            --theme-text-secondary: #888888;
            --theme-accent: #1d9bf0;
        }
        body {
            background-color: var(--theme-bg-primary) !important;
            color: var(--theme-text-primary);
            font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
            overflow: hidden;
            margin: 0;
            height: 100vh;
            display: flex;
            box-sizing: border-box;
            overflow-x: hidden; 
        }
        
        .nav-icon-small {
            width: 24px;
            height: 24px;
            fill: currentColor;
            flex-shrink: 0;
            vertical-align: middle;
        }
        

    .sidebar a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  color: var(--theme-text-secondary);
  text-decoration: none;
  border-radius: 12px;
  transition: all 0.2s ease;
  font-size: 0.95rem;
  font-weight: 500;
  position: relative;
  overflow: hidden;
    }
    .sidebar a:hover {

  color: #ffffff !important;
  transform: translateX(4px);
    }
.sidebar a:hover .nav-icon-small,
.mobile-navbar .nav-item:hover .nav-icon-small {

  filter: drop-shadow(0 0 8px var(--theme-accent, #ffffff)); 
  transform: scale(1.1); 
}

.sidebar a:hover,
.mobile-navbar .nav-item:hover {

  color: var(--theme-accent, #ffffff);
}
.sidebar a:hover {

  color: #ffffff !important;
  transform: translateX(4px);
}
.sidebar a:hover svg {
  fill: #ffffff !important;
  stroke: #ffffff !important;
}
    .sidebar a:hover {

  color: #ffffff !important;
  transform: translateX(4px);
    }
    .sidebar a.active {

      color: var(--theme-text-primary);
      font-weight: 700;
    }

        
        .history-sidebar {
            width: 260px;
            background-color: var(--theme-bg-secondary);
            border-left: 1px solid var(--theme-border);
            display: flex;
            flex-direction: column;
            position: fixed;
            right: 0;
            top: 0;
            height: 100vh;
            z-index: 1000;
            transform: translateX(100%);
            transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease;
            box-shadow: -5px 0 25px rgba(0,0,0,0.5);
            opacity: 0; 
            pointer-events: none;
        }
        
        .history-sidebar.active {
            transform: translateX(0);
            opacity: 1;
            pointer-events: auto;
            z-index: 1001;
        }
        
        @media (min-width: 1321px) {
            .close-sidebar-btn {
                display: none !important;
            }
        }
        .history-header {
            padding: 15px;
            border-bottom: 1px solid var(--theme-border);
            display: flex;
            flex-direction: column;
            gap: 10px;
        }
        .history-header-top {
            display: flex;
            justify-content: space-between;
            align-items: center;
        }
        .history-title {
            font-size: 0.9rem;
            font-weight: 700;
            text-transform: uppercase;
            color: var(--theme-text-secondary);
            letter-spacing: 0.5px;
        }
        .history-controls {
            display: flex;
            gap: 8px;
        }
        .control-btn {
            background: transparent;
            border: none;
            color: var(--theme-text-secondary);
            cursor: pointer;
            padding: 6px;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: background 0.2s;
        }
        .control-btn:hover {
            background-color: var(--theme-bg-tertiary);
            color: var(--theme-text-primary);
        }
        .control-btn svg {
            width: 18px;
            height: 18px;
            fill: currentColor;
        }
        .search-container {
            position: relative;
            width: 100%;
        }
        .search-container input {
            width: 100%;
            background-color: var(--theme-bg-tertiary);
            border: 1px solid var(--theme-border);
            border-radius: 20px;
            padding: 8px 12px 8px 32px;
            color: var(--theme-text-primary);
            font-size: 0.85rem;
            outline: none;
            box-sizing: border-box;
            transition: border-color 0.2s;
        }
        .search-container input:focus {
            border-color: var(--theme-accent);
        }
        .search-icon {
            position: absolute;
            left: 10px;
            top: 50%;
            transform: translateY(-50%);
            width: 14px;
            height: 14px;
            fill: var(--theme-text-secondary);
            pointer-events: none;
        }
        .history-list {
            flex: 1;
            overflow-y: auto;
            padding: 10px;
            display: flex;
            flex-direction: column;
            gap: 4px;
        }
        .history-item {
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 10px 12px;
            border-radius: 8px;
            cursor: pointer;
            transition: background 0.2s;
        }
        .history-item:hover {
            background-color: var(--theme-bg-tertiary);
        }
        .history-item.active {
            background-color: rgba(29, 155, 240, 0.15);
            color: var(--theme-accent);
        }
        .history-item-title {
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            font-size: 0.9rem;
            max-width: 180px;
        }
        .delete-btn {
            opacity: 0;
            background: transparent;
            border: none;
            color: #ff4d4d;
            cursor: pointer;
            padding: 4px;
            border-radius: 4px;
            transition: all 0.2s;
            display: flex;
            align-items: center;
            justify-content: center;
        }
        .history-item:hover .delete-btn {
            opacity: 1;
        }
        .delete-btn:hover {
            background-color: rgba(255, 77, 77, 0.1);
        }
        .delete-btn svg {
            width: 16px;
            height: 16px;
            fill: currentColor;
        }
        
        .main-content {
            flex: 1;
            display: flex;
            flex-direction: column;
            position: relative;
            width: 100%;
            height: 100%;
            margin-left: 240px; 
            margin-right: 20px;

            transition: margin-right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        }
        body.has-right-sidebar .main-content {
            margin-right: 260px;
        }
        .top-bar {
            position: absolute;
            top: 15px;
            left: 20px;
            right: 20px;
            display: flex;
            justify-content: space-between;
            z-index: 10;
            pointer-events: none; 
        }
        .top-bar > * {
            pointer-events: auto;
        }
        .model-selector {
            position: relative;
        }
        .selected-model-btn {
            display: inline-block;
            padding: 8px 16px;
            font-size: 14px;
            font-weight: bold;
            color: rgb(255, 255, 255);
            background: rgba(255, 255, 255, 0);
            border-radius: 12px;
            text-align: center;
            text-decoration: none;
            border: 2px solid rgba(255, 255, 255, 0.3);
            box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15), inset 0 0 15px rgba(255, 255, 255, 0.2);
            backdrop-filter: blur(10px);
            transition: all 0.5s cubic-bezier(0.5, 1, 0.5, 1);
            margin-right: 8px;
            white-space: nowrap;
            opacity: 1;
            transform: translateX(0);
        }
        .selected-model-btn:hover {
            border-color: var(--theme-accent);
            transform: translateY(-1px);
        }
        .model-dropdown {
            position: absolute;
            top: 110%;
            left: 0;
            background-color: var(--theme-bg-secondary);
            border: 1px solid var(--theme-border);
            border-radius: 12px;
            width: 220px;
            display: none;
            flex-direction: column;
            overflow: hidden;
            z-index: 100;
            padding: 8px 16px;
            font-size: 14px;
            font-weight: bold;
            color: rgba(255, 255, 255, 0.381);
            background: rgba(255, 255, 255, 0);
            border-radius: 12px;
            text-align: center;
            text-decoration: none;
            border: 2px solid rgba(255, 255, 255, 0.204);
            box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15), inset 0 0 15px rgba(255, 255, 255, 0.2);
            backdrop-filter: blur(10px);
            transition: all 0.5s cubic-bezier(0.5, 1, 0.5, 1);
            margin-right: 8px;
            white-space: nowrap;
            opacity: 1;
            transform: translateX(0);
        }
        .model-dropdown.show { display: flex; }
        .model-option {
            padding: 12px 16px;
            cursor: pointer;
            transition: background 0.2s;
            font-size: 0.9rem;
            
        }
        .model-option:hover { color: var(--theme-text-secondary); }
        .model-option.active { color: var(--theme-accent); }
        .model-option span { display: block; font-size: 0.75rem; color: var(--theme-text-secondary); margin-top: 2px; }
        
        .top-right-actions {
            display: flex;
            gap: 10px;
            align-items: center;
            transition: opacity 0.2s ease;
        }
        
        .action-btn-fixed {
            background-color: var(--theme-glass);
            backdrop-filter: blur(10px);
            border: 1px solid var(--theme-border);
            color: var(--theme-text-primary);
            padding: 8px 14px;
            border-radius: 20px;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 8px;
            font-size: 0.9rem;
            font-weight: 600;
            transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
            box-shadow: 0 2px 5px rgba(0,0,0,0.2);
            overflow: hidden;
            white-space: nowrap;
    color: rgba(255, 255, 255, 0.9);
    background: rgba(255, 255, 255, 0);
    text-align: center;
    text-decoration: none;
    border: 2px solid rgba(255, 255, 255, 0.5);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15), inset 0 0 15px rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
    transition: all 0.5s cubic-bezier(0.5, 1, 0.5, 1);
    margin-right: 8px;
    white-space: nowrap;
    opacity: 1;
    transform: translateX(0);
        }
        .action-btn-fixed:hover {
            border-color: var(--theme-accent);
            transform: translateY(-1px);
        }
        .action-btn-fixed svg {
            width: 18px;
            height: 18px;
            fill: currentColor;
            transition: transform 0.3s ease;
        }
        .action-btn-fixed.new-chat-active {
            padding: 8px;
            width: 36px;
            border-radius: 50%;
        }
        .action-btn-fixed.new-chat-active span {
            opacity: 0;
            width: 0;
            display: none;
        }
        .action-btn-fixed.new-chat-active svg {
            transform: rotate(180deg);
        }
        
        .chat-history {
            flex: 1;
            overflow-y: auto;
            padding: 80px 15px 140px 15px; 
            display: flex;
            flex-direction: column;
            gap: 15px;
            width: 100%;
            max-width: 100%; 
            margin: 0 auto;
            scroll-behavior: smooth;
            box-sizing: border-box;
        }
        .message {
            max-width: 100%;
            width: auto; 
            min-width: 50px; 
            padding: 12px 16px;
            border-radius: 16px;
            line-height: 1.5;
            font-size: 1rem;
            animation: fadeIn 0.3s ease;
            word-wrap: break-word;
            overflow-wrap: break-word; 
            white-space: pre-wrap; 
        }
        .message div {
            max-width: 100%;
            word-break: break-word;
        }
        @keyframes fadeIn {
            from { opacity: 0; transform: translateY(10px); }
            to { opacity: 1; transform: translateY(0); }
        }
        .message.ai {
            background-color: var(--theme-bg-tertiary);
            align-self: flex-start;
            border-bottom-left-radius: 4px;
            border: 1px solid var(--theme-border);
        }
        .message.user {
            background-color: var(--theme-accent);
            color: white;
            align-self: flex-end;
            border-bottom-right-radius: 4px;
        }
        .message.ai .sender-name {
            font-size: 0.75rem;
            color: var(--theme-text-secondary);
            margin-bottom: 4px;
            font-weight: 600;
        }

        .input-area {
            padding: 15px;
            display: flex;
            justify-content: center;
            position: absolute;
            bottom: 0;
            width: 100%;
            z-index: 10;
            padding-bottom: 15px; 
            box-sizing: border-box;
            
        }

        .input-wrapper {
            width: 100%;
            max-width: 100%; 
            border-radius: 24px;
            padding: 8px 12px 8px 8px;
            display: flex;
            align-items: center;
            gap: 8px;
            transition: border-color 0.2s;
            box-sizing: border-box; 

    color: rgba(255, 255, 255, 0.9);
    background: rgba(255, 255, 255, 0);

    border: 2px solid rgba(255, 255, 255, 0.5);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15), inset 0 0 15px rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
    transition: all 0.5s cubic-bezier(0.5, 1, 0.5, 1);

    opacity: 1;
    transform: translateX(0);
        }
        .input-wrapper:focus-within {
            border-color: #00a2ff;
            box-shadow: 0 0 0 1px #555;
        }
        textarea {
            background: transparent;
            border: none;
            color: var(--theme-text-primary);
            resize: none;
            outline: none;
            min-height: 24px;
            max-height: 150px;
            font-size: 1rem;
            width: 100%;
            padding: 4px 0;
            line-height: 1.5;
        }
        #user-input {
            font-family: Arial, Helvetica, sans-serif;
        }
        .input-actions-left {
            display: flex;
            gap: 4px;
        }
        .action-btn {
            background: transparent;
            border: none;
            color: var(--theme-text-primary);
            cursor: pointer;
            padding: 8px;
            display: flex;
            align-items: center;
            justify-content: center;
            border-radius: 50%;
            transition: background 0.2s;
        }
        .action-btn:hover { background-color: rgba(255,255,255,0.1); }
        .action-btn svg { width: 24px; height: 24px; fill: currentColor; }
        .send-btn {
            background-color: var(--theme-accent);
            color: white;
            border: none;
            width: 32px;
            height: 32px;
            border-radius: 50%;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: background 0.2s, opacity 0.2s;
            flex-shrink: 0;
        }
        .send-btn:disabled { background-color: #333; color: #71767b; cursor: not-allowed; opacity: 0.5; }
        .send-btn:not(:disabled):hover { opacity: 0.9; }
        .send-btn svg { width: 16px; height: 16px; fill: currentColor; }
        #fileUpload { display: none; }
        
        ::-webkit-scrollbar { width: 8px; }
        ::-webkit-scrollbar-track { background: transparent; }
        ::-webkit-scrollbar-thumb { background: #333; border-radius: 4px; }
        ::-webkit-scrollbar-thumb:hover { background: #555; }
        

        .nav-items {
            display: flex;
            justify-content: space-around;
            align-items: center;
            width: 100%;
        }
        .nav-item {
            color: var(--theme-text-secondary);
            text-decoration: none;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            font-size: 0.7rem;
            padding: 8px 12px;
            flex: 1;
            border-radius: 16px;
            transition: background 0.2s, color 0.2s;
        }
        .nav-item:hover {
            background-color: rgba(255,255,255,0.05);
            color: var(--theme-text-primary);
        }
        .nav-item svg {
            width: 22px;
            height: 22px;
            margin-bottom: 4px;
            fill: currentColor;
        }
        .nav-item.active {
            color: var(--theme-accent);
        }
        
        @media (max-width: 1320px) {
            .sidebar {
              position: fixed;
              left: -260px; 
              top: 0;
              height: 100%;
              width: 250px;
              box-shadow: 2px 0 10px rgba(0,0,0,0.5);
            }
            .sidebar.active {
              transform: translateX(260px); 
            }
            
            .main-content {
                margin-left: 0;
                margin-right: 0;
            }
            
            .mobile-navbar {
                display: block;
            }
            
            .history-sidebar {
                width: 85%;
                max-width: 300px;
            }
            
            
            .top-right-actions {
                opacity: 1;
                visibility: visible;
                transition: opacity 0.3s ease;
            }
            
            body.sidebar-open .top-right-actions {
                opacity: 0;
                visibility: hidden;
                pointer-events: none;
            }
            
            .top-bar {
                left: 10px;
                right: 10px;
            }

            
            .chat-history {
                padding-bottom: 140px; 
            }

            .input-area {
                bottom: 70px; 
                padding: 10px 15px;
            }

            .input-wrapper {
                max-width: 100%;
                border-radius: 20px;
            }

            textarea {
                font-size: 16px; 
            }
        }
    .typing-indicator {
      display: none;
      align-self: flex-start;
      padding: 12px 16px;
      background-color: var(--theme-bg-tertiary);
      border-radius: 18px;
      border-bottom-left-radius: 4px;
      margin-bottom: 10px;
    }
    .typing-indicator span {
      display: inline-block;
      width: 6px;
      height: 6px;
      background-color: var(--theme-text-secondary);
      border-radius: 50%;
      animation: bounce 1.4s infinite ease-in-out both;
      margin: 0 2px;
    }
    .typing-indicator span:nth-child(1) { animation-delay: -0.32s; }
    .typing-indicator span:nth-child(2) { animation-delay: -0.16s; }
    @keyframes bounce {
      0%, 80%, 100% { transform: scale(0); }
      40% { transform: scale(1); }
    }

body.theme-default {
    --theme-bg-primary: #000000;
    --theme-bg-secondary: #111111;
    --theme-bg-tertiary: #1a1a1a;
    --theme-border: #333333;
    --theme-text-primary: #ffffff;
    --theme-text-secondary: #888888;
    --theme-accent: #1d9bf0;
    --theme-accent-gradient: linear-gradient(135deg, #1d9bf0 0%, #1d9bf0 100%);
}
body.theme-discord {
    --theme-bg-primary: #36393f;
    --theme-bg-secondary: #2f3136;
    --theme-bg-tertiary: #202225;
    --theme-border: #202225;
    --theme-text-primary: #ffffff;
    --theme-text-secondary: #b9bbbe;
    --theme-accent: #5865f2;
    --theme-accent-gradient: linear-gradient(135deg, #5865f2 0%, #7289da 100%);
}
body.theme-amethyst {
    --theme-bg-primary: #1a1a2e;
    --theme-bg-secondary: #16213e;
    --theme-bg-tertiary: #0f3460;
    --theme-border: #333;
    --theme-text-primary: #ffffff;
    --theme-text-secondary: #a0a0a0;
    --theme-accent: #667eea;
    --theme-accent-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}
body.theme-aurora {
    --theme-bg-primary: #0a192f;
    --theme-bg-secondary: #112240;
    --theme-bg-tertiary: #233554;
    --theme-border: #233554;
    --theme-text-primary: #e6f1ff;
    --theme-text-secondary: #8892b0;
    --theme-accent: #00c6ff;
    --theme-accent-gradient: linear-gradient(135deg, #00c6ff 0%, #0072ff 100%);
}
body.theme-sunset {
    --theme-bg-primary: #1a1a1a;
    --theme-bg-secondary: #2d2d2d;
    --theme-bg-tertiary: #3d3d3d;
    --theme-border: #444;
    --theme-text-primary: #ffffff;
    --theme-text-secondary: #aaa;
    --theme-accent: #f093fb;
    --theme-accent-gradient: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}
body.theme-forest {
    --theme-bg-primary: #0d2018;
    --theme-bg-secondary: #142b1f;
    --theme-bg-tertiary: #1b3d2a;
    --theme-border: #1b3d2a;
    --theme-text-primary: #e8f5e9;
    --theme-text-secondary: #81c784;
    --theme-accent: #38ef7d;
    --theme-accent-gradient: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
}
body.theme-ocean {
    --theme-bg-primary: #0f1c3f;
    --theme-bg-secondary: #1a3a6e;
    --theme-bg-tertiary: #2a5298;
    --theme-border: #2a5298;
    --theme-text-primary: #e0efff;
    --theme-text-secondary: #8cb4e8;
    --theme-accent: #2a5298;
    --theme-accent-gradient: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
}
body.theme-midnight {
    --theme-bg-primary: #0f0c29;
    --theme-bg-secondary: #1a1a3a;
    --theme-bg-tertiary: #302b63;
    --theme-border: #302b63;
    --theme-text-primary: #e0e0e0;
    --theme-text-secondary: #9090a0;
    --theme-accent: #764ba2;
    --theme-accent-gradient: linear-gradient(135deg, #0f0c29 0%, #302b63 50%, #24243e 100%);
}
body.theme-fire {
    --theme-bg-primary: #1a0a0a;
    --theme-bg-secondary: #2d1515;
    --theme-bg-tertiary: #4a1f1f;
    --theme-border: #4a1f1f;
    --theme-text-primary: #fff0f0;
    --theme-text-secondary: #d0a0a0;
    --theme-accent: #f5af19;
    --theme-accent-gradient: linear-gradient(135deg, #f12711 0%, #f5af19 100%);
}


#user-input{
    height: fit-content;
}
        .message img {
            max-width: 100%;
            height: auto;
            border-radius: 12px;
            margin-top: 8px;
            display: block;
            box-shadow: 0 2px 8px rgba(0,0,0,0.2);
        }
        
        .file-preview-container {
            position: relative; 
            display: none;
            padding: 5px;
            background: rgba(255,255,255,0.05);
            border-radius: 12px;
            margin-right: 5px;
            align-items: center;
        }
        .file-preview-container img {
            width: 40px;
            height: 40px;
            object-fit: cover;
            border-radius: 8px;
            border: 1px solid var(--theme-border);
        }
        .remove-image-btn {
            position: absolute;
            top: -5px;
            right: -5px;
            background-color: #ff4d4d;
            color: white;
            border: none;
            border-radius: 50%;
            width: 18px;
            height: 18px;
            font-size: 12px;
            line-height: 1;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            box-shadow: 0 2px 4px rgba(0,0,0,0.3);
            transition: transform 0.2s;
            z-index: 10;
        }
        .remove-image-btn:hover {
            transform: scale(1.1);
            background-color: #ff3333;
        }


.code-block {
    background: var(--theme-bg-tertiary);
    border-radius: 12px;
    margin: 12px 0;
    overflow: hidden;
    border: 1px solid var(--theme-border);
}

.code-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 16px;
    background: var(--theme-bg-secondary);
    border-bottom: 1px solid var(--theme-border);
    font-size: 0.8rem;
    color: var(--theme-text-secondary);
}

.code-lang {
    text-transform: uppercase;
    font-weight: 600;
    font-size: 0.7rem;
    letter-spacing: 0.5px;
}

.copy-code-btn {
    background: transparent;
    border: 1px solid var(--theme-border);
    color: var(--theme-text-secondary);
    padding: 4px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.7rem;
    transition: all 0.2s;
}

.copy-code-btn:hover {
    background: var(--theme-accent);
    color: white;
    border-color: var(--theme-accent);
}

.code-block pre {
    margin: 0;
    padding: 16px;
    overflow-x: auto;
    background: transparent;
}

.code-block code {
    font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 0.9rem;
    line-height: 1.6;
    color: var(--theme-text-primary);
    white-space: pre-wrap;
    word-break: break-word;
}

.inline-code {
    background: var(--theme-bg-tertiary);
    color: #f92672;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 0.9em;
    border: 1px solid var(--theme-border);
}

.math-block {
    background: var(--theme-bg-tertiary);
    padding: 16px 20px;
    border-radius: 12px;
    margin: 12px 0;
    text-align: center;
    border: 1px solid var(--theme-border);
    font-family: 'Times New Roman', 'CMU Serif', serif;
    font-size: 1.1rem;
    overflow-x: auto;
    color: var(--theme-text-primary);
}

.math-inline {
    font-family: 'Times New Roman', 'CMU Serif', serif;
    font-style: italic;
    color: var(--theme-accent);
    padding: 0 4px;
}

.content-header {
    margin: 16px 0 8px 0;
    font-weight: 700;
    color: var(--theme-text-primary);
}

.content-header h1 {
    font-size: 1.8rem;
}

.content-header h2 {
    font-size: 1.4rem;
}

.content-header h3 {
    font-size: 1.1rem;
}

.content-list {
    margin: 8px 0;
    padding-left: 24px;
    color: var(--theme-text-primary);
}

.content-list li {
    margin: 4px 0;
    line-height: 1.6;
}

.content-quote {
    border-left: 4px solid var(--theme-accent);
    padding: 12px 16px;
    margin: 12px 0;
    background: var(--theme-bg-tertiary);
    border-radius: 0 8px 8px 0;
    color: var(--theme-text-secondary);
    font-style: italic;
}

.content-divider {
    border: none;
    height: 1px;
    background: var(--theme-border);
    margin: 16px 0;
}

.content-table {
    width: 100%;
    border-collapse: collapse;
    margin: 12px 0;
    font-size: 0.9rem;
    border-radius: 8px;
    overflow: hidden;
}

.content-table th {
    background: var(--theme-bg-secondary);
    color: var(--theme-text-primary);
    font-weight: 600;
    padding: 10px 14px;
    border-bottom: 2px solid var(--theme-border);
}

.content-table td {
    padding: 8px 14px;
    border-bottom: 1px solid var(--theme-border);
    color: var(--theme-text-primary);
}

.content-table tr:hover {
    background: var(--theme-bg-tertiary);
}

.message.ai p {
    margin: 6px 0;
    line-height: 1.7;
}

.message.ai strong {
    color: var(--theme-text-primary);
    font-weight: 700;
}

.message.ai em {
    font-style: italic;
    color: var(--theme-text-secondary);
}

@media (max-width: 768px) {
    .code-block pre {
        padding: 12px;
        font-size: 0.8rem;
    }
    
    .math-block {
        font-size: 0.95rem;
        padding: 12px 16px;
    }
    
    .content-table {
        font-size: 0.8rem;
    }
    
    .content-table th,
    .content-table td {
        padding: 6px 10px;
    }
}


.message {
    position: relative;
    transition: all 0.2s ease;
}

.message-wrapper {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    width: 100%;
}

.message-content-container {
    flex: 1;
    min-width: 0;
}

.message-content {
    word-wrap: break-word;
    overflow-wrap: break-word;
    white-space: pre-wrap;
}

.message-actions {
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.2s ease;
    flex-shrink: 0;
    padding-top: 4px;
}

.message:hover .message-actions {
    opacity: 1;
}

@media (max-width: 768px) {
    .message-actions {
        opacity: 0.6;
    }
}

.message-action-btn {
    background: transparent;
    border: none;
    color: var(--theme-text-secondary);
    cursor: pointer;
    padding: 4px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    width: 28px;
    height: 28px;
}

.message-action-btn:hover {
    background: var(--theme-bg-tertiary);
    color: var(--theme-text-primary);
    transform: scale(1.1);
}

.message-action-btn.delete-btn:hover {
    background: rgba(244, 67, 54, 0.15);
    color: #f44336;
}

.message-action-btn.edit-btn:hover {
    background: rgba(33, 150, 243, 0.15);
    color: #2196F3;
}

.message-action-btn.copy-btn:hover {
    background: rgba(76, 175, 80, 0.15);
    color: #4CAF50;
}

.message.editing .message-content {
    background: var(--theme-bg-tertiary);
    border-radius: 12px;
    padding: 8px;
    border: 2px solid var(--theme-accent);
}

.edit-textarea {
    width: 100%;
    background: transparent;
    border: none;
    color: var(--theme-text-primary);
    resize: vertical;
    outline: none;
    font-size: 1rem;
    line-height: 1.6;
    font-family: inherit;
    padding: 4px;
    min-height: 60px;
}

.edit-textarea:focus {
    outline: none;
}

.edit-action-wrapper {
    display: flex;
    align-items: center;
    margin: 0 2px;
}

.edit-action-wrapper .message-action-btn {
    width: 30px;
    height: 30px;
    font-size: 14px;
    font-weight: bold;
}

.save-edit-btn:hover {
    transform: scale(1.15);
    box-shadow: 0 2px 8px rgba(76, 175, 80, 0.4);
}

.cancel-edit-btn:hover {
    transform: scale(1.15);
    box-shadow: 0 2px 8px rgba(244, 67, 54, 0.4);
}

.message {
    animation: messageSlideIn 0.3s ease;
}

@keyframes messageSlideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message.ai .message-actions .message-action-btn {
    color: var(--theme-text-secondary);
}

.message.ai .message-actions .message-action-btn:hover {
    color: var(--theme-text-primary);
}

.message.user .message-actions .message-action-btn {
    color: rgba(255, 255, 255, 0.6);
}

.message.user .message-actions .message-action-btn:hover {
    color: white;
    background: rgba(255, 255, 255, 0.15);
}

@media (max-width: 480px) {
    .message-actions {
        gap: 2px;
    }
    
    .message-action-btn {
        width: 24px;
        height: 24px;
        padding: 2px;
    }
    
    .message-action-btn svg {
        width: 14px;
        height: 14px;
    }
}

