:root {
    /* Claude.ai-inspired Light theme variables */
    --bg-primary: #FFF8F0;
    --bg-secondary: #FFFFFF;
    --bg-sidebar: #F5F2ED;
    --bg-header: #FFFFFF;
    --text-primary: #2D2D2D;
    --text-secondary: #666666;
    --text-accent: #FF6B35;
    --text-sidebar: #4A4A4A;
    --border-color: #E8E3DC;
    --border-sidebar: #DAD4CC;
    --shadow-color: rgba(0, 0, 0, 0.08);
    --shadow-sidebar: rgba(0, 0, 0, 0.05);
    --message-user-bg: #FF6B35;
    --message-assistant-bg: #FFFFFF;
    --message-assistant-border: #E8E3DC;
    --input-bg: #FFFFFF;
    --input-border: #E8E3DC;
    --button-primary: #FF6B35;
    --button-secondary: #F5F2ED;
    --button-danger: #E85D2C;
    --session-info-bg: #F5F2ED;
    --session-info-border: #DAD4CC;
    --session-info-text: #666666;
    --sidebar-hover: #EDE8E0;
    --summary-bg: #FFF3E0;
    --summary-border: #FFCC80;
    --summary-text: #E65100;
    --sidebar-width: 280px;
}

[data-theme="dark"] {
    /* Claude.ai-inspired Dark theme variables */
    --bg-primary: #1A1A1A;
    --bg-secondary: #2D2D2D;
    --bg-sidebar: #242424;
    --bg-header: #2D2D2D;
    --text-primary: #F0F0F0;
    --text-secondary: #B0B0B0;
    --text-accent: #E85D2C;
    --text-sidebar: #D0D0D0;
    --border-color: #404040;
    --border-sidebar: #353535;
    --shadow-color: rgba(0, 0, 0, 0.4);
    --shadow-sidebar: rgba(0, 0, 0, 0.3);
    --message-user-bg: #E85D2C;
    --message-assistant-bg: #2D2D2D;
    --message-assistant-border: #404040;
    --input-bg: #2D2D2D;
    --input-border: #404040;
    --button-primary: #E85D2C;
    --button-secondary: #353535;
    --button-danger: #D84315;
    --session-info-bg: #353535;
    --session-info-border: #505050;
    --session-info-text: #B0B0B0;
    --sidebar-hover: #333333;
    --summary-bg: #3E2723;
    --summary-border: #6D4C41;
    --summary-text: #FFCC80;
    --sidebar-width: 280px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    height: 100vh;
    display: flex;
    background: var(--bg-primary);
    color: var(--text-primary);
    transition: background 0.3s ease, color 0.3s ease;
    overflow: hidden;
}

.app-container {
    display: flex;
    height: 100vh;
    width: 100%;
}

.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-sidebar);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: all 0.3s ease;
    overflow: hidden;
    position: relative;
    min-width: 200px;
    max-width: 500px;
}

.sidebar-resize-handle {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: transparent;
    cursor: ew-resize;
    z-index: 101;
}

.sidebar-resize-handle:hover {
    background: var(--text-accent);
    opacity: 0.5;
}

.sidebar-header {
    padding: 16px;
    border-bottom: 1px solid var(--border-sidebar);
    background: var(--bg-sidebar);
}

.sidebar-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-sidebar);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.header {
    background: var(--bg-header);
    color: var(--text-primary);
    padding: 12px 20px;
    box-shadow: 0 1px 3px var(--shadow-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    transition: background 0.3s ease;
    min-height: 60px;
    flex-shrink: 0;
    border-bottom: 1px solid var(--border-color);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.header h1 {
    font-size: 20px;
    font-weight: 600;
    white-space: nowrap;
}

.token-counter {
    background: var(--session-info-bg);
    border: 1px solid var(--session-info-border);
    border-radius: 6px;
    padding: 4px 8px;
    font-size: 12px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
    transition: all 0.2s;
    color: var(--session-info-text);
}

.token-counter:hover {
    background: var(--sidebar-hover);
}

.token-icon {
    font-size: 12px;
}

.token-count {
    font-weight: 600;
}

.token-threshold-warning {
    background: rgba(251, 191, 36, 0.2);
    border-color: rgba(251, 191, 36, 0.4);
    color: #fef3c7;
}

.token-threshold-critical {
    background: rgba(239, 68, 68, 0.2);
    border-color: rgba(239, 68, 68, 0.4);
    color: #fecaca;
}

/* Session controls */
.session-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    justify-content: flex-end;
}

/* Sidebar session controls */
.sidebar-session-controls {
    padding: 16px;
    border-bottom: 1px solid var(--border-sidebar);
}

.sidebar-new-session-btn {
    width: 100%;
    background: var(--button-primary);
    color: white;
    border: none;
    padding: 10px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s ease;
}

.sidebar-new-session-btn:hover {
    background: #E85D2C;
    transform: translateY(-1px);
}

/* Session groups */
.session-groups {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.session-group {
    margin-bottom: 16px;
}

.session-group-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    cursor: pointer;
    border-radius: 6px;
    transition: background 0.2s ease;
    user-select: none;
}

.session-group-header:hover {
    background: var(--sidebar-hover);
}

.session-group-name {
    font-weight: 500;
    color: var(--text-sidebar);
    display: flex;
    align-items: center;
    gap: 6px;
}

.session-group-toggle {
    color: var(--text-secondary);
    transition: transform 0.2s ease;
}

.session-group-toggle.collapsed {
    transform: rotate(-90deg);
}

.group-actions {
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.session-group-header:hover .group-actions {
    opacity: 1;
}

.group-rename-btn, .group-delete-btn {
    width: 20px;
    height: 20px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    font-size: 12px;
}

.group-rename-btn:hover, .group-delete-btn:hover {
    background: var(--button-primary);
    color: white;
    transform: scale(1.1);
}

.session-list {
    padding-left: 8px;
    transition: all 0.3s ease;
}

.session-list.collapsed {
    max-height: 0;
    overflow: hidden;
}

.session-item {
    padding: 1px 4px;
    margin: 1px 0;
    border-radius: 2px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 4px;
    color: var(--text-sidebar);
    border: 1px solid transparent;
    font-size: 11px;
}

.session-item:hover {
    background: var(--sidebar-hover);
    border-color: var(--border-color);
}

.session-item.active {
    background: var(--sidebar-hover);
    color: var(--text-primary);
    border-color: rgba(255, 107, 53, 0.3); /* Reduced opacity for orange accent */
}

.session-item-name {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 11px;
    font-weight: 400;
}

.session-item-actions {
    display: flex;
    gap: 2px;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.session-item:hover .session-item-actions {
    opacity: 1;
}

.session-item-action {
    width: 18px;
    height: 18px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    font-size: 11px;
    opacity: 0.7;
}

.session-item-action:hover {
    background: var(--button-primary);
    color: white;
    opacity: 1;
    transform: scale(1.1);
}

.session-item.active .session-item-action:hover {
    background: var(--button-primary);
    color: white;
    opacity: 1;
}

.session-meta {
    font-size: 9px;
    color: var(--text-secondary);
    opacity: 0.8;
}

/* Add group button */
.add-group-btn {
    width: 100%;
    background: var(--button-primary);
    border: none;
    color: white;
    padding: 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s ease;
    margin-top: 16px;
    box-shadow: 0 2px 4px rgba(255, 107, 53, 0.2);
}

.add-group-btn:hover {
    background: #E85D2C;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(255, 107, 53, 0.3);
}

.add-group-btn span {
    font-size: 18px;
    font-weight: bold;
}

/* Drag and drop styles */
.session-item.dragging {
    opacity: 0.5;
    transform: rotate(2deg);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.session-list.drag-over {
    background: var(--sidebar-hover);
    border: 2px dashed var(--text-accent);
    border-radius: 6px;
    padding: 2px;
}

.session-group.drag-over {
    background: var(--sidebar-hover);
    border-radius: 6px;
}

.session-selector {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    min-width: 120px;
    outline: none;
    transition: background 0.2s;
}

.session-selector:hover {
    background: rgba(255, 255, 255, 0.25);
}

.session-selector:focus {
    background: rgba(255, 255, 255, 0.3);
}

.session-selector option {
    background: #4c51bf;
    color: white;
}

.new-session-btn {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    padding: 6px 10px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: background 0.2s;
}

.new-session-btn:hover {
    background: rgba(255, 255, 255, 0.25);
}

.theme-toggle-btn {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    padding: 8px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    width: 36px;
    height: 36px;
}

.theme-toggle-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.05);
}

.theme-icon {
    font-size: 16px;
    transition: transform 0.3s ease;
}

[data-theme="dark"] .theme-icon {
    content: "☀️";
}

/* Main chat container */
.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    min-height: 600px; /* Increased minimum height */
}

.session-info {
    background: var(--session-info-bg);
    border: 1px solid var(--session-info-border);
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 12px;
    color: var(--session-info-text);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: background 0.3s ease, border-color 0.3s ease, color 0.3s ease;
}

.session-info::before {
    content: "💬";
    font-size: 14px;
}

.session-info.summarized {
    background: var(--summary-bg);
    border-color: var(--summary-border);
    color: var(--summary-text);
}

.session-info.summarized::before {
    content: "📝";
}

.messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px; /* Increased padding for better readability */
    scroll-behavior: smooth;
    min-height: 400px; /* Ensure minimum height for messages area */
}

.message {
    margin-bottom: 16px;
    display: flex;
    flex-direction: column;
}

.message.user {
    align-items: flex-end;
}

.message.assistant {
    align-items: flex-start;
}

.message-bubble {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 18px;
    word-wrap: break-word;
    white-space: normal;
    line-height: 1.6;
    transition: background 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

.message.user .message-bubble {
    background: var(--message-user-bg);
    color: white;
    border-bottom-right-radius: 6px;
}

.message.assistant .message-bubble {
    background: var(--message-assistant-bg);
    border: 1px solid var(--message-assistant-border);
    border-bottom-left-radius: 6px;
    box-shadow: 0 1px 3px var(--shadow-color);
    color: var(--text-primary);
}

/* Markdown formatting styles for assistant messages */
.message.assistant .message-bubble h1,
.message.assistant .message-bubble h2,
.message.assistant .message-bubble h3,
.message.assistant .message-bubble h4,
.message.assistant .message-bubble h5,
.message.assistant .message-bubble h6 {
    margin-top: 12px;
    margin-bottom: 6px;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.4;
}

.message.assistant .message-bubble h1 { font-size: 1.4em; }
.message.assistant .message-bubble h2 { font-size: 1.2em; }
.message.assistant .message-bubble h3 { font-size: 1.1em; }

.message.assistant .message-bubble p {
    margin-bottom: 6px;
    line-height: 1.6;
}

.message.assistant .message-bubble p:first-child {
    margin-top: 0;
}

.message.assistant .message-bubble p:last-child {
    margin-bottom: 0;
}

.message.assistant .message-bubble p:last-child {
    margin-bottom: 0;
}

.message.assistant .message-bubble ul,
.message.assistant .message-bubble ol {
    margin-left: 20px;
    margin-bottom: 6px;
    margin-top: 6px;
    line-height: 1.6;
}

.message.assistant .message-bubble li {
    margin-bottom: 1px;
    line-height: 1.5;
    padding: 1px 0;
}

.message.assistant .message-bubble code {
    background: var(--bg-secondary);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.9em;
    color: var(--text-accent);
    border: 1px solid var(--border-color);
}

.message.assistant .message-bubble pre {
    background: var(--bg-secondary);
    color: var(--text-primary);
    padding: 12px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 6px 0;
    border: 1px solid var(--border-color);
    line-height: 1.4;
}

.message.assistant .message-bubble pre code {
    background: transparent;
    color: inherit;
    padding: 0;
    font-size: 0.9em;
    line-height: 1.4;
}


.message.assistant .message-bubble blockquote {
    border-left: 4px solid var(--text-accent);
    padding-left: 16px;
    margin: 6px 0;
    color: var(--text-secondary);
    font-style: italic;
    background: var(--bg-secondary);
    padding: 8px 16px;
    border-radius: 0 4px 4px 0;
    line-height: 1.6;
}

.message.assistant .message-bubble strong {
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.6;
}

.message.assistant .message-bubble em {
    font-style: italic;
    color: var(--text-primary);
    line-height: 1.6;
}

.message.assistant .message-bubble a {
    color: var(--text-accent);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: border-color 0.2s;
    line-height: 1.6;
}

.message.assistant .message-bubble a:hover {
    border-bottom-color: var(--text-accent);
}

.message.assistant .message-bubble hr {
    margin: 10px 0;
    border: none;
    border-top: 1px solid var(--border-color);
}

.message.assistant .message-bubble table {
    border-collapse: collapse;
    margin: 6px 0;
    width: 100%;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    overflow: hidden;
}

.message.assistant .message-bubble th,
.message.assistant .message-bubble td {
    border: 1px solid var(--border-color);
    padding: 8px 12px;
    text-align: left;
    color: var(--text-primary);
}

.message.assistant .message-bubble th {
    background: var(--bg-secondary);
    font-weight: 600;
    color: var(--text-primary);
}

.message.assistant .message-bubble img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin: 6px 0;
}

/* Copy button for code blocks */
.code-block-wrapper {
    position: relative;
}

.copy-button {
    position: absolute;
    top: 8px;
    right: 8px;
    background: #475569;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 12px;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.copy-button:hover {
    opacity: 1;
}

.copy-button.copied {
    background: #10b981;
}

.message-time {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 4px;
    margin-bottom: 4px;
}

/* Message action buttons positioning */
.message {
    position: relative;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
}

.message-actions {
    display: flex;
    gap: 6px;
    margin-top: 6px;
    opacity: 0;
    transition: opacity 0.2s;
    position: relative;
    width: 100%;
    flex-shrink: 0; /* Prevent container from shrinking */
}

.message:hover .message-actions {
    opacity: 1;
}

.message.user .message-actions {
    justify-content: flex-end;
}

.message.assistant .message-actions {
    justify-content: flex-start;
}

.message.system .message-actions {
    justify-content: center;
}

/* Ensure buttons are always positioned under the message bubble */
.message .message-actions {
    position: relative;
    display: flex;
    gap: 6px;
    margin-top: 6px;
}


.message-delete-btn,
.message-edit-btn {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: none;
    color: white;
    font-size: 12px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    position: relative; /* Ensure buttons are positioned relative to their container */
    flex-shrink: 0; /* Prevent buttons from shrinking */
}

.message-delete-btn {
    background: rgba(239, 68, 68, 0.9);
}

.message-edit-btn {
    background: rgba(99, 102, 241, 0.9);
}

.message-delete-btn:hover {
    background: rgba(239, 68, 68, 1);
    transform: scale(1.1);
}

.message-edit-btn:hover {
    background: rgba(99, 102, 241, 1);
    transform: scale(1.1);
}

.message-delete-btn:active,
.message-edit-btn:active {
    transform: scale(0.9);
}

.message.user .message-delete-btn,
.message.user .message-edit-btn {
    background: rgba(99, 102, 241, 0.9);
}

.message.assistant .message-delete-btn,
.message.assistant .message-edit-btn {
    background: rgba(99, 102, 241, 0.9);
}

.message.system .message-delete-btn,
.message.system .message-edit-btn {
    background: rgba(156, 163, 175, 0.9);
}

.message.system .message-delete-btn:hover,
.message.system .message-edit-btn:hover {
    background: rgba(156, 163, 175, 1);
}

/* Welcome message */
.welcome-message {
    text-align: center;
    color: var(--text-secondary);
    padding: 40px 20px;
    font-size: 14px;
}

.welcome-message h2 {
    font-size: 18px;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.quick-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-top: 20px;
    flex-wrap: wrap;
}

.quick-action-btn {
    background: var(--button-primary);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 8px 16px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

.quick-action-btn:hover {
    background: #5855eb;
    transform: translateY(-1px);
}

/* Input container */
.input-container {
    padding: 16px 20px;
    background: var(--input-bg);
    border-top: 1px solid var(--border-color);
    box-shadow: 0 -2px 10px var(--shadow-color);
    transition: background 0.3s ease, border-color 0.3s ease;
    flex-shrink: 0;
}

.input-wrapper {
    display: flex;
    flex-direction: column;
    gap: 8px;
    position: relative;
}

.input-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
}

.button-row {
    display: flex;
    align-items: center;
    gap: 8px;
    justify-content: flex-start;
}

.message-input {
    flex: 1;
    border: 1px solid var(--input-border);
    border-radius: 20px;
    padding: 12px 16px;
    font-family: inherit;
    font-size: 14px;
    resize: none;
    max-height: 180px;
    min-height: 52px;
    outline: none;
    transition: border-color 0.2s;
    background: var(--input-bg);
    color: var(--text-primary);
}

.message-input:focus {
    border-color: var(--text-accent);
}

.send-button {
    background: var(--button-primary);
    color: white;
    border: none;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.2s;
    flex-shrink: 0;
}

.send-button:hover:not(:disabled) {
    background: #5855eb;
}

.send-button:disabled {
    background: var(--text-secondary);
    cursor: not-allowed;
}

.send-button svg {
    width: 18px;
    height: 18px;
}

/* Button styles */
.import-page-btn {
    background: #10b981;
    border: 1px solid #059669;
    color: white;
    padding: 6px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    width: 32px;
    height: 32px;
    font-size: 14px;
}

.import-page-btn:hover {
    background: #059669;
    transform: scale(1.05);
}

.page-icon {
    font-size: 16px;
}

.file-upload-btn {
    background: var(--button-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 6px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    width: 32px;
    height: 32px;
    font-size: 14px;
}

.file-upload-btn:hover {
    background: var(--bg-secondary);
    border-color: var(--text-accent);
    transform: scale(1.05);
}

.file-upload-btn:active {
    transform: scale(0.95);
}

.file-icon {
    font-size: 16px;
}

.model-selector-btn {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 6px 8px;
    display: flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    outline: none;
    transition: all 0.2s;
    color: var(--text-accent);
    font-size: 12px;
    position: relative;
    height: 32px;
}

.model-selector-btn:hover {
    background: var(--bg-primary);
    border-color: var(--text-accent);
}

.model-selector-btn.active {
    background: var(--text-accent);
    color: white;
    border-color: var(--text-accent);
}

.model-selector-btn .robot-icon {
    font-size: 16px;
}

.model-selector-btn .model-name {
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 60px;
}

.model-selector-btn .dropdown-arrow {
    font-size: 10px;
    transition: transform 0.2s;
    margin-left: 2px;
}

.model-selector-btn.active .dropdown-arrow {
    transform: rotate(180deg);
}

.clear-session-icon-btn {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: rgba(239, 68, 68, 0.8);
    width: 32px;
    height: 32px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    margin-left: auto;
    flex-shrink: 0;
}

.clear-session-icon-btn:hover {
    background: rgba(239, 68, 68, 0.2);
    border-color: rgba(239, 68, 68, 0.5);
    color: rgba(239, 68, 68, 1);
    transform: scale(1.1);
}

.clear-session-icon-btn:active {
    transform: scale(0.95);
}

.clear-session-icon-btn svg {
    width: 14px;
    height: 14px;
    stroke: currentColor;
    stroke-width: 2.5;
}

/* Typing indicator */
.typing-indicator {
    display: none;
    align-items: flex-start;
    margin-bottom: 16px;
    padding: 0 20px;
}

.typing-indicator.show {
    display: flex;
}

.typing-bubble {
    background: var(--message-assistant-bg);
    border: 1px solid var(--message-assistant-border);
    border-radius: 18px;
    border-bottom-left-radius: 6px;
    padding: 12px 16px;
    box-shadow: 0 1px 3px var(--shadow-color);
    color: var(--text-primary);
}

.typing-dots {
    display: flex;
    gap: 3px;
}

.typing-dot {
    width: 6px;
    height: 6px;
    background: var(--text-secondary);
    border-radius: 50%;
    animation: typing 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; }

@keyframes typing {
    0%, 60%, 100% { opacity: 0.3; transform: scale(0.8); }
    30% { opacity: 1; transform: scale(1); }
}

/* Modal styles */
.model-modal,
.page-context-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    animation: fadeIn 0.2s ease-out;
}

.model-modal.show,
.page-context-modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
}

.model-modal-content,
.page-context-modal-content {
    background: var(--bg-secondary);
    border-radius: 12px;
    box-shadow: 0 10px 40px var(--shadow-color);
    max-width: 400px;
    width: 90%;
    max-height: 80vh;
    animation: slideUp 0.3s ease-out;
    border: 1px solid var(--border-color);
}

.model-modal-header,
.page-context-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
}

.model-modal-header h3,
.page-context-modal-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

.close-modal-btn {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s;
}

.close-modal-btn:hover {
    background: var(--bg-primary);
    color: var(--text-primary);
}

.model-list {
    padding: 12px;
    max-height: 300px;
    overflow-y: auto;
}

.model-option {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 4px;
}

.model-option:hover {
    background: var(--bg-primary);
}

.model-option.selected {
    background: var(--text-accent);
    color: white;
}

.model-option-icon {
    width: 20px;
    height: 20px;
    margin-right: 12px;
    opacity: 0.7;
}

.model-option.selected .model-option-icon {
    opacity: 1;
}

.model-option-text {
    font-weight: 500;
    color: var(--text-primary);
}

.model-option-description {
    font-size: 12px;
    opacity: 0.7;
    margin-top: 2px;
    color: var(--text-secondary);
}

.model-option.selected .model-option-description {
    opacity: 0.9;
    color: white;
}

.model-option.selected .model-option-text {
    color: white;
}

/* Page context modal styles */
.page-context-content {
    padding: 20px;
}

.url-input-group,
.text-input-group {
    margin-bottom: 20px;
}

.url-input-group label,
.text-input-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-primary);
}

.url-input-group input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    margin-bottom: 12px;
    background: var(--input-bg);
    color: var(--text-primary);
}

.text-input-group textarea {
    width: 100%;
    min-height: 120px;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    margin-bottom: 12px;
    resize: vertical;
    background: var(--input-bg);
    color: var(--text-primary);
}

.analyze-url-btn,
.import-text-btn {
    background: var(--button-primary);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 10px 16px;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.2s;
    width: 100%;
}

.analyze-url-btn:hover,
.import-text-btn:hover {
    background: #5855eb;
}

.or-divider {
    text-align: center;
    margin: 20px 0;
    color: var(--text-secondary);
    font-size: 14px;
    position: relative;
}

.or-divider::before,
.or-divider::after {
    content: "";
    position: absolute;
    top: 50%;
    width: 45%;
    height: 1px;
    background: var(--border-color);
}

.or-divider::before {
    left: 0;
}

.or-divider::after {
    right: 0;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Error message */
.error-message {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #dc2626;
    padding: 12px 16px;
    border-radius: 8px;
    margin: 16px 20px;
    font-size: 14px;
}

/* Empty session message */
.empty-session-message {
    text-align: center;
    color: var(--text-secondary);
    padding: 40px 20px;
    font-size: 14px;
}

.empty-session-message h2 {
    font-size: 18px;
    color: var(--text-primary);
    margin-bottom: 12px;
}

/* Responsive design */
@media (max-width: 768px) {
    .header {
        flex-wrap: wrap;
        padding: 10px 16px;
    }

    .header-left {
        width: 100%;
        margin-bottom: 8px;
        justify-content: space-between;
    }

    .header h1 {
        font-size: 18px;
    }

    .header-right {
        width: 100%;
        justify-content: space-between;
    }

    .session-controls {
        flex: 1;
        justify-content: flex-start;
    }

    .token-counter {
        font-size: 11px;
        padding: 3px 6px;
    }

    .session-selector {
        min-width: 100px;
        font-size: 12px;
        padding: 5px 8px;
    }

    .new-session-btn {
        padding: 5px 8px;
        font-size: 12px;
    }

    .theme-toggle-btn {
        width: 32px;
        height: 32px;
        padding: 6px;
    }

    .input-container {
        padding: 12px 16px;
    }

    .input-row {
        gap: 6px;
    }

    .message-input {
        min-height: 44px;
        max-height: 120px;
    }

    .button-row {
        flex-wrap: wrap;
        gap: 6px;
    }

    .send-button {
        width: 40px;
        height: 40px;
    }

    .import-page-btn,
    .file-upload-btn,
    .model-selector-btn,
    .clear-session-icon-btn {
        width: 28px;
        height: 28px;
        font-size: 12px;
    }

    .model-selector-btn .model-name {
        max-width: 50px;
        font-size: 11px;
    }

    .messages {
        padding: 16px;
    }

    .message-bubble {
        max-width: 90%;
        font-size: 14px;
    }

    .quick-actions {
        gap: 8px;
    }

    .quick-action-btn {
        padding: 6px 12px;
        font-size: 12px;
    }
}

@media (max-width: 480px) {
    .header h1 {
        font-size: 16px;
    }

    .token-counter {
        display: none;
    }

    .session-selector {
        min-width: 80px;
        font-size: 11px;
    }

    .new-session-btn {
        padding: 4px 6px;
        font-size: 11px;
    }

    .new-session-btn svg {
        width: 10px;
        height: 10px;
    }

    .message-input {
        font-size: 13px;
    }

    .send-button {
        width: 36px;
        height: 36px;
    }

    .send-button svg {
        width: 16px;
        height: 16px;
    }

    .import-page-btn,
    .file-upload-btn,
    .model-selector-btn,
    .clear-session-icon-btn {
        width: 24px;
        height: 24px;
        font-size: 10px;
    }

    .model-selector-btn .model-name {
        max-width: 40px;
        font-size: 10px;
    }

    .model-selector-btn .robot-icon {
        font-size: 14px;
    }

    .welcome-message h2 {
        font-size: 16px;
    }

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

    .quick-action-btn {
        padding: 5px 10px;
        font-size: 11px;
    }
}

/* File content display styles */
.file-content {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 12px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 13px;
    line-height: 1.5;
    white-space: pre-wrap;
    word-wrap: break-word;
    max-height: 300px;
    overflow-y: auto;
    transition: all 0.3s ease;
    color: var(--text-primary);
}

.file-content.preview {
    max-height: 150px;
    overflow: hidden;
    position: relative;
}

.file-content.preview::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 30px;
    background: linear-gradient(transparent, var(--bg-primary));
    pointer-events: none;
}

.file-actions {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

.file-action-btn {
    background: var(--button-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.file-action-btn:hover {
    background: var(--bg-secondary);
    border-color: var(--text-accent);
}

.file-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    padding: 8px;
    background: var(--bg-primary);
    border-radius: 6px;
    border: 1px solid var(--border-color);
}

.file-icon-display {
    font-size: 16px;
}

.file-name {
    font-weight: 500;
    color: var(--text-primary);
    flex: 1;
}

.file-meta {
    display: flex;
    gap: 8px;
    font-size: 11px;
    color: var(--text-secondary);
}

/* Page context content styles */
.page-context-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 16px;
    margin: 8px 0;
}

.imported-content {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 12px;
    margin: 12px 0;
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-primary);
    max-height: 400px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.imported-content::-webkit-scrollbar {
    width: 6px;
}

.imported-content::-webkit-scrollbar-track {
    background: var(--bg-secondary);
    border-radius: 3px;
}

.imported-content::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

.imported-content::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

.page-context-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    padding: 8px;
    background: var(--bg-primary);
    border-radius: 6px;
    border-left: 4px solid var(--text-accent);
}

.page-context-icon {
    font-size: 16px;
}

.page-context-label {
    font-weight: 600;
    color: var(--text-accent);
}

/* Summary content styles */
.summary-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    padding: 8px;
    background: var(--bg-primary);
    border-radius: 6px;
    border-left: 4px solid #fbbf24;
}

.summary-icon {
    font-size: 16px;
}

.summary-label {
    font-weight: 600;
    color: #fbbf24;
}

.summary-content {
    font-size: 14px;
    line-height: 1.6;
}

/* Thinking/Thought container styles */
.thinking-container {
    margin: 16px 0;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
    background: var(--bg-secondary);
    box-shadow: 0 2px 8px var(--shadow-color);
    transition: all 0.3s ease;
}

.thinking-container.active {
    border-color: var(--text-accent);
    box-shadow: 0 4px 16px rgba(99, 102, 241, 0.2);
}

.thinking-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: background 0.2s ease;
}

.thinking-header:hover {
    background: var(--bg-secondary);
}

.thinking-header span {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.thinking-toggle {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s ease;
}

.thinking-toggle svg {
    width: 16px;
    height: 16px;
    color: var(--text-secondary);
    transition: color 0.2s ease;
}

.thinking-toggle:hover svg {
    color: var(--text-primary);
}

.thinking-toggle.collapsed {
    transform: rotate(-90deg);
}

.thinking-content {
    padding: 16px;
    font-size: 13px;
    line-height: 1.6;
    color: var(--text-secondary);
    background: var(--bg-secondary);
    max-height: 300px;
    overflow-y: auto;
    transition: all 0.3s ease;
    white-space: pre-wrap;
    word-wrap: break-word;
}

/* Compact spacing for all markdown elements */
.message.assistant .message-bubble > *:first-child {
    margin-top: 0 !important;
}

.message.assistant .message-bubble > *:last-child {
    margin-bottom: 0 !important;
}

/* Ensure consistent spacing between elements */
.message.assistant .message-bubble > * + * {
    margin-top: 6px;
}

.message.assistant .message-bubble h1 + *,
.message.assistant .message-bubble h2 + *,
.message.assistant .message-bubble h3 + *,
.message.assistant .message-bubble h4 + *,
.message.assistant .message-bubble h5 + *,
.message.assistant .message-bubble h6 + * {
    margin-top: 4px;
}

.thinking-content.collapsed {
    max-height: 0;
    padding: 0 16px;
    opacity: 0;
    overflow: hidden;
}

.thinking-content::-webkit-scrollbar {
    width: 6px;
}

.thinking-content::-webkit-scrollbar-track {
    background: var(--bg-primary);
    border-radius: 3px;
}

.thinking-content::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

.thinking-content::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* Enhanced styling for the edit textarea */
.message-edit-textarea {
    width: 100%;
    min-height: 100px;
    padding: 12px;
    border: 2px solid var(--text-accent);
    border-radius: 8px;
    font-family: inherit;
    font-size: 14px;
    resize: vertical;
    background-color: var(--input-bg);
    color: var(--text-primary);
    line-height: 1.5;
    box-sizing: border-box;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.message-edit-textarea:focus {
    outline: none;
    border-color: var(--button-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.message-edit-buttons {
    display: flex;
    gap: 10px;
    margin-top: 12px;
}

.message-edit-save-btn,
.message-edit-cancel-btn {
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
}

.message-edit-save-btn {
    background-color: #10b981;
    color: white;
}

.message-edit-cancel-btn {
    background-color: var(--text-secondary);
    color: white;
}

.message-edit-save-btn:hover {
    background-color: #059669;
    transform: translateY(-1px);
}

.message-edit-cancel-btn:hover {
    background-color: #64748b;
    transform: translateY(-1px);
}

.message-edit-save-btn:active,
.message-edit-cancel-btn:active {
    transform: translateY(0);
}

/* Message edit button styling - already defined above with other button styles */

/* Mobile sidebar toggle and overlay */
.sidebar-toggle {
    display: none;
}

.sidebar-overlay {
    display: none;
}

/* Mobile responsive styles */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: -100%;
        top: 0;
        height: 100vh;
        z-index: 1000;
        transition: left 0.3s ease;
        box-shadow: 2px 0 10px var(--shadow-color);
    }

    .sidebar.open {
        left: 0;
    }

    .sidebar-toggle {
        display: flex;
        position: fixed;
        top: 12px;
        left: 12px;
        z-index: 1001;
        background: var(--button-primary);
        color: white;
        border: none;
        border-radius: 8px;
        padding: 8px;
        cursor: pointer;
        width: 36px;
        height: 36px;
        align-items: center;
        justify-content: center;
    }

    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.5);
        z-index: 999;
    }

    .sidebar-overlay.show {
        display: block;
    }

    .main-content {
        margin-left: 0;
    }

    .header {
        padding-left: 60px;
    }
}

/* Image selected indicator styles */
.image-selected-indicator {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 8px 12px;
    margin-bottom: 8px;
    font-size: 13px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.remove-image-link {
    color: var(--text-accent);
    text-decoration: none;
    font-size: 12px;
    margin-left: 8px;
    transition: color 0.2s ease;
}

.remove-image-link:hover {
    color: var(--button-danger);
    text-decoration: underline;
}

/* Chat message images */
.message-image {
    margin: 10px 0;
    text-align: center;
}

.chat-image {
    max-width: 100%;
    max-height: 300px;
    border-radius: var(--border-radius);
    object-fit: contain;
    border: 1px solid var(--border-color);
}

.message-text {
    margin-top: 10px;
}

/* Image upload button */
.image-upload-btn {
    background: var(--button-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 6px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    width: 32px;
    height: 32px;
    font-size: 14px;
}

.image-upload-btn:hover {
    background: var(--bg-secondary);
    border-color: var(--text-accent);
    transform: scale(1.05);
}

.image-upload-btn:active {
    transform: scale(0.95);
}

.image-icon {
    font-size: 16px;
}

/* Mobile responsive for images */
@media (max-width: 768px) {
    .chat-image {
        max-height: 200px;
    }
    
    .image-selected-indicator {
        font-size: 12px;
        padding: 6px 10px;
    }
}