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

:root {
    --bg: #1a1a1a;
    --surface: #1f1f1f;
    --border: #2a2a2a;
    --text: #ffffff;
    --text-light: #a0a0a0;
    --accent: #ffffff;
    --accent-hover: #e5e5e5;
    --user-bg: #ffffff;
    --accent-strong: #15803d;
    --active-surface: #2a2a2a;
    --transition: cubic-bezier(0.4, 0, 0.2, 1);
    --sidebar-width: 280px;
    --sidebar-collapsed-width: 60px;
    --sidebar-current-width: 280px;
    --content-max-width: 720px;
    --content-inline-gutter: clamp(14px, 3vw, 24px);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', sans-serif;
    background: var(--bg);
    color: var(--text);
    height: 100vh;
    overflow: hidden;
}

.container {
    display: flex;
    height: 100vh;
    position: relative;
    z-index: 1;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    transition: width 0.3s var(--transition), transform 0.3s var(--transition);
    position: fixed;
    left: 0;
    top: 0;
    height: 100vh;
    z-index: 10;
}

.sidebar.hidden {
    transform: translateX(-100%);
}

.sidebar.collapsed {
    width: var(--sidebar-collapsed-width);
}

.sidebar-full {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.sidebar-header {
    padding: 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.sidebar-header-top {
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-logo {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
    cursor: pointer;
    text-decoration: none;
}

.sidebar-logo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.sidebar-logo:focus-visible {
    outline: 1px solid var(--accent);
    outline-offset: 4px;
}

.sidebar-spacer {
    flex: 1;
}

.collapse-btn {
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    cursor: pointer;
    border-radius: 8px;
    color: var(--text);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    align-self: flex-start;
}

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

.collapse-btn svg {
    width: 20px;
    height: 20px;
}

.sidebar-section {
    padding: 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.sidebar-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.new-chat-btn {
    width: 100%;
    padding: 10px 16px;
    background: transparent;
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.new-chat-btn:hover {
    background: rgba(255, 255, 255, 0.05);
}

.new-chat-btn svg {
    width: 18px;
    height: 18px;
}

.history-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.history-item {
    padding: 8px 12px;
    margin-bottom: 4px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    color: var(--text);
    transition: none;
    display: flex;
    align-items: center;
    gap: 8px;
    position: relative;
    min-height: 36px;
}

.history-item:hover {
    background: inherit;
}

.history-item.active {
    background: var(--active-surface);
    color: var(--text);
    font-weight: 500;
}

.history-search {
    width: 100%;
    padding: 8px 10px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--text);
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s, background 0.2s;
}

.history-search:focus {
    border-color: var(--border);
    background: var(--bg);
}

.history-item-text {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-item-input {
    flex: 1;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 4px 8px;
    color: var(--text);
    font-size: 14px;
    font-family: inherit;
    outline: none;
}

.history-item-input:focus {
    border-color: var(--text-light);
}

.history-item-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
    opacity: 0;
    transition: opacity 0.1s;
}

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

.history-action-btn {
    width: 24px;
    height: 24px;
    border: none;
    background: transparent;
    color: var(--text-light);
    cursor: pointer;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, color 0.2s;
    padding: 0;
}

.history-action-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text);
}

.history-action-btn svg {
    width: 14px;
    height: 14px;
}

.sidebar-footer {
    padding: 12px;
    border-top: 1px solid var(--border);
    margin-top: auto;
}

.profile-section {
    position: relative;
}

.profile-btn {
    width: 100%;
    padding: 8px 12px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    transition: background 0.2s;
    color: var(--text);
}

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

.profile-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    background: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
}

.profile-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.profile-avatar svg {
    width: 20px;
    height: 20px;
    stroke: var(--bg);
}

.profile-info {
    flex: 1;
    text-align: left;
    min-width: 0;
}

.profile-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.profile-email {
    font-size: 12px;
    color: var(--text-light);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.profile-dropdown {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 0;
    right: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 8px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(8px);
    transition: opacity 0.2s var(--transition), transform 0.2s var(--transition), visibility 0.2s;
    z-index: 100;
}

.profile-dropdown.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.profile-menu-item {
    width: 100%;
    padding: 10px 12px;
    background: transparent;
    border: none;
    border-radius: 8px;
    color: var(--text);
    font-size: 14px;
    text-align: left;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: background 0.15s;
}

.profile-menu-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.profile-menu-item svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.profile-menu-divider {
    height: 1px;
    background: var(--border);
    margin: 4px 0;
}

.sidebar-mini {
    display: none;
    flex-direction: column;
    height: 100%;
    padding: 16px 8px;
    gap: 12px;
    align-items: center;
}

.mini-logo {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
}

.mini-logo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.mini-spacer {
    flex: 1;
}

.mini-action {
    width: 44px;
    height: 44px;
    border-radius: 8px;
    border: none;
    background: transparent;
    color: var(--text);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s;
    flex-shrink: 0;
}

.mini-action:hover {
    background: rgba(255, 255, 255, 0.05);
}

.mini-action svg {
    width: 20px;
    height: 20px;
}

.mini-profile {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    overflow: hidden;
    cursor: pointer;
    flex-shrink: 0;
    position: relative;
    background: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: none;
}

.mini-profile:hover {
    transform: none;
}

.mini-profile img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.mini-profile svg {
    width: 18px;
    height: 18px;
    stroke: var(--bg);
}

.mini-profile-dropdown {
    position: fixed;
    bottom: 16px;
    left: calc(var(--sidebar-collapsed-width) + 8px);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 8px;
    opacity: 0;
    visibility: hidden;
    transform: translateX(-8px);
    transition: opacity 0.2s var(--transition), transform 0.2s var(--transition), visibility 0.2s;
    z-index: 100;
    min-width: 200px;
}

.mini-profile-dropdown.open {
    opacity: 1;
    visibility: visible;
    transform: translateX(0);
}

.sidebar.collapsed .sidebar-full {
    display: none;
}

.sidebar.collapsed .sidebar-mini {
    display: flex;
}

/* Main Area */
.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    margin-left: var(--sidebar-current-width);
    transition: margin-left 0.3s var(--transition);
}

/* Toolbar */
.toolbar {
    padding: 12px 24px;
    background: transparent;
    display: flex;
    align-items: center;
    gap: 16px;
    position: relative;
}

.toolbar-logo {
    font-size: 18px;
    font-weight: 600;
    color: var(--text);
    letter-spacing: -0.5px;
}

.toolbar-upgrade-btn {
    background: transparent;
    color: var(--text);
    border: 1px solid var(--border);
    padding: 8px 14px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s var(--transition), border-color 0.2s var(--transition);
    box-shadow: none;
    margin-left: auto;
}

.toolbar-upgrade-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--text-light);
}

.toolbar-upgrade-btn:active {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--text);
}

.toolbar-signin {
}

.toolbar-signin-btn {
    background: #ffffff;
    color: #1a1a1a;
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
}

.toolbar-signin-btn:hover {
    background: #e5e5e5;
    transform: translateY(-1px);
}

body[data-auth="user"] .toolbar-signin {
    display: none;
}

.model-selector-wrapper {
    position: relative;
}

.model-dropdown-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
}

.model-dropdown-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--text-light);
}

.model-dropdown-btn svg {
    width: 16px;
    height: 16px;
    transition: transform 0.2s;
}

.model-dropdown-btn.open svg {
    transform: rotate(180deg);
}

.model-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    min-width: 240px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 8px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: opacity 0.2s var(--transition), transform 0.2s var(--transition), visibility 0.2s;
    z-index: 100;
}

.model-dropdown.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.model-option {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 10px 12px;
    border-radius: 8px;
    background: transparent;
    border: none;
    cursor: pointer;
    text-align: left;
    transition: background 0.15s;
    width: 100%;
}

.model-option:hover {
    background: rgba(255, 255, 255, 0.05);
}

.model-option.active {
    background: var(--active-surface);
    border: 1px solid var(--border);
}

.model-option-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 8px;
}

.model-option-desc {
    font-size: 12px;
    color: var(--text-light);
}

.model-check {
    width: 16px;
    height: 16px;
    margin-left: auto;
    opacity: 0;
}

.model-option.active .model-check {
    opacity: 1;
    color: var(--text);
}

.menu-launcher {
    position: absolute;
    left: 24px;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text);
    display: none;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s;
}

.menu-launcher:hover {
    background: rgba(255, 255, 255, 0.05);
}

.menu-launcher svg {
    width: 18px;
    height: 18px;
}

/* Chat Area */
.chat-area {
    flex: 1;
    overflow-y: auto;
    padding: 32px 24px 180px;
    scroll-behavior: smooth;
    transition: padding 0.4s var(--transition);
    position: relative;
}

/* Removed bottom fade overlay to keep the chat background flat */

.chat-container {
    width: min(var(--content-max-width), calc(100% - (2 * var(--content-inline-gutter))));
    max-width: var(--content-max-width);
    min-width: 0;
    margin: 0 auto;
    position: relative;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
}

#messages {
    width: 100%;
}

.message {
    margin-bottom: 24px;
    opacity: 0;
    transform: translateY(10px);
    animation: messageIn 0.3s var(--transition) forwards;
}

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

.message-role {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-light);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.message.user .message-role {
    display: none;
}

.message-content {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px 18px;
    line-height: 1.6;
    font-size: 15px;
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow-wrap: break-word;
    max-width: 100%;
    box-sizing: border-box;
}

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

.message.user .message-content {
    background: var(--user-bg);
    color: #000;
    border-color: #e5e5e5;
    max-width: 70%;
}

.message-content.editing {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 1px var(--accent);
}

.message-actions {
    display: flex;
    gap: 8px;
    margin-top: 8px;
    opacity: 1;
}

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

.message-action-btn {
    padding: 4px 10px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-light);
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: background 0.2s, color 0.2s, border-color 0.2s;
}

.message-action-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text);
    border-color: var(--text-light);
}

.message-action-btn svg {
    width: 12px;
    height: 12px;
}

/* Message Attachments */
.message-attachments {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 10px;
}

.message-attachment {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: rgba(0, 0, 0, 0.15);
    border-radius: 8px;
    font-size: 12px;
    max-width: 200px;
}

.message.user .message-attachment {
    background: rgba(0, 0, 0, 0.08);
}

.attachment-icon {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 600;
    flex-shrink: 0;
}

.attachment-icon.pdf {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

.attachment-icon.img {
    background: rgba(16, 185, 129, 0.2);
    color: #10b981;
}

.attachment-info {
    flex: 1;
    min-width: 0;
}

.attachment-name {
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.message.user .attachment-name {
    color: #000;
}

.attachment-size {
    font-size: 10px;
    opacity: 0.7;
}

.attachment-remove {
    width: 18px;
    height: 18px;
    border: none;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 50%;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: inherit;
    opacity: 0.6;
    transition: opacity 0.15s ease, background 0.15s ease;
}

.message-attachment:hover .attachment-remove {
    display: flex;
}

.attachment-remove:hover {
    opacity: 1;
    background: rgba(239, 68, 68, 0.3);
}

.attachment-remove svg {
    width: 10px;
    height: 10px;
}

/* Edit Mode Attachments */
.edit-controls {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
}

.edit-attachments {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.edit-attachment {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 6px;
    font-size: 11px;
}

.edit-attachment .attachment-icon {
    width: 22px;
    height: 22px;
    font-size: 9px;
}

.edit-attachment .attachment-name {
    max-width: 100px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.remove-attachment-btn {
    background: none;
    border: none;
    color: var(--text-light);
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    padding: 0 2px;
    opacity: 0.6;
    transition: opacity 0.15s, color 0.15s;
}

.remove-attachment-btn:hover {
    opacity: 1;
    color: #ef4444;
}

.edit-btn-group {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.add-file-btn {
    display: flex;
    align-items: center;
    gap: 4px;
}

.add-file-btn svg {
    flex-shrink: 0;
}

.save-btn {
    background: var(--accent) !important;
    color: #000 !important;
}

.save-btn:hover {
    filter: brightness(1.1);
}

/* Voice Input Button */
.voice-btn {
    background: transparent;
    border: none;
    color: var(--text-light);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    transition: background 0.15s ease, color 0.15s ease;
    flex-shrink: 0;
    margin-right: 4px;
}

.voice-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text);
}

.voice-btn.recording {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
    animation: voicePulse 1.5s ease-in-out infinite;
}

@keyframes voicePulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

.voice-btn:disabled {
    opacity: 0.7;
    cursor: wait;
}

.voice-btn .spin {
    animation: spin 1s linear infinite;
}

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

.voice-btn svg {
    width: 18px;
    height: 18px;
}

.message-version-nav {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
    font-size: 12px;
    color: var(--text-light);
}

.version-nav-btn {
    width: 20px;
    height: 20px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-light);
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, color 0.2s;
    padding: 0;
}

.version-nav-btn:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text);
}

.version-nav-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.version-nav-btn svg {
    width: 10px;
    height: 10px;
}

.version-count {
    font-size: 11px;
    color: var(--text-light);
}

.message.assistant .message-content {
    background: transparent;
    border: none;
    padding: 0;
}

.code-terminal {
    background: #0c0c0f;
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    max-width: 100%;
    box-sizing: border-box;
}

.code-terminal:hover {
    transform: translateY(-1px);
    box-shadow: 0 12px 35px rgba(0, 0, 0, 0.45);
}

.code-terminal.copied {
    animation: copyFlash 0.6s ease;
}

@keyframes copyFlash {
    0%, 100% {
        border-color: var(--border);
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
    }
    50% {
        border-color: #27c93f;
        box-shadow: 0 0 0 2px rgba(39, 201, 63, 0.3), 0 10px 30px rgba(0, 0, 0, 0.35);
    }
}

.code-terminal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    background: linear-gradient(120deg, #15151b, #0f1014);
    border-bottom: 1px solid var(--border);
}

.code-terminal-dots {
    display: flex;
    gap: 6px;
}

.code-terminal-dots span {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}

.code-terminal-dots .dot-red { background: #ff5f56; }
.code-terminal-dots .dot-yellow { background: #ffbd2e; }
.code-terminal-dots .dot-green { background: #27c93f; }

.code-terminal-language {
    font-size: 12px;
    color: var(--text-light);
    letter-spacing: 0.3px;
}

.code-terminal-copy-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-light);
    padding: 4px 8px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, color 0.2s, border-color 0.2s;
    position: sticky;
    right: 12px;
    font-size: 12px;
}

.code-terminal-copy-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text);
    border-color: var(--text-light);
}

.code-terminal-copy-btn:active {
    background: rgba(255, 255, 255, 0.15);
}

.code-terminal-copy-btn svg {
    width: 14px;
    height: 14px;
}

.code-terminal-body {
    background: radial-gradient(circle at top left, rgba(255, 255, 255, 0.03), transparent 60%), #0b0c10;
    padding: 14px 16px;
    overflow-x: auto;
    overflow-y: hidden;
    max-width: 100%;
}

.code-terminal-body pre {
    margin: 0;
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
    font-size: 14px;
    line-height: 1.6;
    color: #e5e7eb;
    white-space: pre-wrap;
    word-break: break-word;
}

.message-content p {
    margin-bottom: 12px;
    color: var(--text);
}

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

/* Message Text (Markdown formatting) */
.message-text h1, .message-text h2, .message-text h3 {
    color: var(--text);
    margin: 16px 0 8px 0;
    font-weight: 600;
}

.message-text h1 {
    font-size: 24px;
}

.message-text h2 {
    font-size: 20px;
}

.message-text h3 {
    font-size: 16px;
}

.message-text p {
    margin: 8px 0;
    line-height: 1.6;
    color: var(--text);
}

.message-text code {
    background: rgba(255, 255, 255, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
    font-size: 13px;
    color: #e5e7eb;
}

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

.message-text hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 24px 0;
    opacity: 0.5;
}

.message-text blockquote {
    border-left: 3px solid var(--border);
    padding-left: 16px;
    margin: 12px 0;
    color: var(--text-light);
    font-style: italic;
}

.message-text ol,
.message-text ul {
    margin: 12px 0;
    padding-left: 24px;
    color: var(--text);
}

.message-text ol li,
.message-text ul li {
    margin: 6px 0;
    line-height: 1.6;
}

.message-text ul li {
    list-style-type: disc;
}

.message-text ol li {
    list-style-type: decimal;
}

.message-text table {
    border-collapse: collapse;
    margin: 12px 0;
    width: 100%;
}

.message-text td {
    border: 1px solid var(--border);
    padding: 8px 12px;
    color: var(--text);
}

.code-terminal + .message-text,
.message-text + .code-terminal {
    margin-top: 16px;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    gap: 6px;
    padding: 16px;
}

.typing-dot {
    width: 8px;
    height: 8px;
    background: var(--text-light);
    border-radius: 50%;
    opacity: 0.4;
    animation: typing 1.4s infinite;
}

.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.4;
    }
    30% {
        opacity: 1;
    }
}

/* Scroll Navigation Toggle */
.scroll-nav {
    position: fixed;
    right: 24px;
    bottom: 120px;
    z-index: 10;
    display: flex;
    flex-direction: column;
    gap: 8px;
    opacity: 0;
    visibility: hidden;
    transform: translateX(20px);
    transition: opacity 0.2s ease, visibility 0.2s ease, transform 0.2s ease;
}

.scroll-nav.visible {
    opacity: 1;
    visibility: visible;
    transform: translateX(0);
}

.scroll-nav-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-light);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.scroll-nav-btn:hover {
    background: var(--surface-hover);
    color: var(--text);
    border-color: var(--text-light);
}

.scroll-nav-btn svg {
    width: 18px;
    height: 18px;
}

/* Input Area */
.input-area {
    padding: 20px var(--content-inline-gutter) 32px;
    position: fixed;
    bottom: 0;
    left: var(--sidebar-current-width);
    right: 0;
    transition: transform 0.5s var(--transition), left 0.3s var(--transition);
    z-index: 2;
    display: flex;
    justify-content: center;
    background: linear-gradient(to top, var(--bg) 85%, transparent);
}

.conversation-title {
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-light);
    margin-bottom: 16px;
    text-align: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.main:has(.chat-area.has-welcome) .conversation-title {
    opacity: 1;
}

.input-wrapper {
    width: min(var(--content-max-width), calc(100% - (2 * var(--content-inline-gutter))));
    max-width: var(--content-max-width);
    min-width: 0;
    margin: 0 auto;
    position: relative;
    transition: transform 0.3s var(--transition);
    box-sizing: border-box;
}

/* Only center input on full viewport when sidebar is collapsed */
.input-container {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
    border: 1px solid var(--border);
    background: #3a3a3a;
    border-radius: 999px;
    padding: 10px 12px 10px 16px;
    transition: border-color 0.2s;
    box-shadow: none;
    min-width: 0;
    width: 100%;
    box-sizing: border-box;
}

.attach-btn {
    background: transparent;
    border: none;
    color: var(--text-light);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    transition: background 0.2s, color 0.2s;
    flex-shrink: 0;
}

.attach-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text);
}

.attach-btn svg {
    width: 18px;
    height: 18px;
}

#fileInput {
    display: none;
}

#messageInput {
    flex: 1;
    border: none;
    background: transparent;
    padding: 8px 12px;
    font-size: 15px;
    font-family: inherit;
    color: var(--text);
    resize: none;
    outline: none;
    max-height: 120px;
    line-height: 1.5;
    min-width: 0;
    width: 100%;
    box-sizing: border-box;
}

#messageInput::placeholder {
    color: var(--text-light);
}

.model-note {
    display: none;
    position: fixed;
    left: calc(50% + (var(--sidebar-current-width) / 2));
    bottom: 8px;
    transform: translateX(-50%);
    gap: 6px;
    color: var(--text-light);
    font-size: 12px;
    align-items: center;
    justify-content: center;
    text-align: center;
    pointer-events: none;
    z-index: 3;
    width: min(
        var(--content-max-width),
        calc(100% - var(--sidebar-current-width) - (2 * var(--content-inline-gutter)))
    );
    padding: 0 var(--content-inline-gutter);
    transition: left 0.3s var(--transition), width 0.3s var(--transition), transform 0.3s var(--transition);
}

.main:has(.chat-area.has-welcome) .model-note {
    display: flex;
}

#sendBtn {
    background: #e0e0e0;
    color: #0d0d0d;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, opacity 0.2s, transform 0.2s;
    flex-shrink: 0;
}

#sendBtn:hover:not(:disabled) {
    background: #ededed;
}

#sendBtn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

#sendBtn.is-pausing {
    background: #f5f5f5;
    color: #0d0d0d;
}

#sendBtn.is-pausing:hover {
    background: #eaeaea;
}

#sendBtn svg {
    width: 16px;
    height: 16px;
    stroke: #0d0d0d;
}

#sendBtn.is-pausing svg {
    stroke: #0d0d0d;
}

/* Welcome */
.welcome {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 0;
    margin-bottom: 120px;
    opacity: 1;
    transition: opacity 0.3s var(--transition);
}

.welcome.hidden {
    opacity: 0;
    pointer-events: none;
    position: absolute;
}

.chat-area.has-welcome {
    padding: var(--content-inline-gutter);
    overflow: hidden;
    display: grid;
    place-items: center;
}

.chat-area.has-welcome .chat-container {
    align-items: center;
    text-align: center;
}

.welcome-title {
    font-size: 32px;
    font-weight: 400;
    margin-bottom: 8px;
    color: var(--text);
    letter-spacing: -0.5px;
}

.welcome-subtitle {
    font-size: 15px;
    color: var(--text-light);
    margin-bottom: 100px;
}

/* Input positioning when on welcome screen */
.main:has(.chat-area.has-welcome) .input-area {
    transform: translateY(-25vh);
}

/* Animated Background */
#request-bg {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    display: block;
    background-color: var(--bg);
    opacity: 1;
    transition: opacity .35s ease, filter .35s ease;
}

#request-bg::after {
    content: '';
    position: absolute;
    inset: -8%;
    filter: blur(28px) saturate(115%);
    opacity: 0;
    background-image:
        radial-gradient(60% 60% at 20% 10%, rgba(255,255,255,0.12), transparent 60%),
        radial-gradient(55% 55% at 80% 20%, rgba(200,200,200,0.10), transparent 60%),
        radial-gradient(50% 50% at 50% 80%, rgba(120,120,120,0.10), transparent 60%),
        conic-gradient(from 0deg at 50% 50%, rgba(255,255,255,0.05), rgba(0,0,0,0), rgba(255,255,255,0.05));
    background-size: 100% 100%, 100% 100%, 100% 100%, 260% 260%;
    background-position: center, center, center, var(--wave-start, 0% 50%);
    transition: opacity .35s ease;
}

#request-bg.loading {
    opacity: 0.94;
}

#request-bg.loading::after {
    opacity: 1;
    animation: waveMove 7.5s cubic-bezier(.36,.07,.19,.97) infinite;
}

#request-bg.solid::after {
    opacity: 0;
    animation: none;
}

@keyframes waveMove {
    0%   { background-position: center, center, center,   var(--wave-start, 0% 50%); }
    50%  { background-position: center, center, center, var(--wave-end, 100% 52%); }
    100% { background-position: center, center, center,   var(--wave-start, 0% 50%); }
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

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

::-webkit-scrollbar-thumb:hover {
    background: #4b5563;
}

/* Mobile */
@media (max-width: 768px) {
    :root {
        --content-inline-gutter: 12px;
    }

    .sidebar {
        left: 0;
        width: 280px;
    }

    .main {
        margin-left: 0;
    }

    .input-area {
        left: 0;
        padding: 16px 12px 24px;
    }

    .chat-area {
        padding: 24px 12px 160px;
    }

    .chat-area::after {
        left: 0;
    }

    .chat-container {
        transform: none;
        width: calc(100% - 24px);
    }

    .input-wrapper {
        width: calc(100% - 24px);
        max-width: 100%;
    }

    .sidebar.hidden ~ .main .menu-launcher {
        display: flex;
    }

    /* Shift toolbar-logo right when hamburger menu is visible */
    .sidebar.hidden ~ .main .toolbar-logo {
        margin-left: 48px;
    }

    .main:has(.chat-area.has-welcome) .input-area {
        transform: translateY(-25vh);
    }

    .model-dropdown {
        left: 50%;
        transform: translateX(-50%) translateY(-8px);
    }

    .model-dropdown.open {
        transform: translateX(-50%) translateY(0);
    }

    .profile-dropdown {
        position: fixed;
        bottom: 70px;
        left: 12px;
        right: 12px;
        width: auto;
        z-index: 150;
    }

    .mini-profile-dropdown {
        position: fixed;
        bottom: 70px;
        left: 12px;
        right: auto;
        width: auto;
        min-width: 250px;
        z-index: 150;
    }

    .overlay {
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.4);
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.3s;
        z-index: 50;
    }

    .overlay.visible {
        opacity: 1;
        pointer-events: auto;
    }

    /* Hide right navigation on mobile */
    .right-nav {
        display: none;
    }

    /* Welcome screen adjustments */
    .welcome-title {
        font-size: 24px;
    }

    .welcome-subtitle {
        font-size: 14px;
        margin-bottom: 60px;
    }

    /* Message content adjustments */
    .message.user .message-content {
        max-width: 85%;
    }

    .message-content {
        padding: 12px 14px;
        font-size: 14px;
    }

    /* Code terminal adjustments */
    .code-terminal-body {
        padding: 12px;
    }

    .code-terminal-body pre {
        font-size: 12px;
    }

    /* Toolbar adjustments */
    .toolbar {
        padding: 12px 16px;
        gap: 10px;
    }

    .toolbar-logo {
        font-size: 16px;
    }

    .toolbar-upgrade-btn {
        padding: 6px 12px;
        font-size: 13px;
    }

    /* Model selector adjustments */
    .model-dropdown-btn {
        padding: 5px 10px;
        font-size: 13px;
    }

    .model-dropdown {
        min-width: 200px;
        left: 50%;
        right: auto;
    }

    /* Settings modal mobile */
    .settings-modal {
        width: 100%;
        height: 100%;
        border-radius: 0;
        flex-direction: column;
    }

    .settings-nav {
        width: 100%;
        flex-direction: row;
        overflow-x: auto;
        padding: 12px;
        border-right: none;
        border-bottom: 1px solid #2a2a2a;
        gap: 8px;
    }

    .settings-nav h3 {
        display: none;
    }

    .settings-nav button {
        white-space: nowrap;
        padding: 8px 16px;
    }

    .settings-header {
        padding: 16px;
    }

    #settingsBody {
        padding: 16px;
    }

    .settings-row {
        flex-direction: column;
        gap: 12px;
    }

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

    /* Plan modal mobile */
    .plan-modal {
        width: 100%;
        height: 100%;
        border-radius: 0;
    }

    .plan-modal-content {
        padding: 20px;
    }

    .plan-hero {
        flex-direction: column;
        gap: 16px;
    }

    .plan-hero-meta {
        align-items: flex-start;
    }

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

    /* Auth modal mobile */
    .auth-modal {
        width: 100%;
        max-width: 100%;
        margin: 0 12px;
        border-radius: 12px;
    }

    /* Notification adjustments */
    .notification-container {
        right: 12px;
        left: 12px;
        max-width: none;
    }

    .notification {
        min-width: auto;
    }

    /* Scroll navigation */
    .scroll-nav {
        right: 12px;
        bottom: 100px;
    }

    .scroll-nav-btn {
        width: 36px;
        height: 36px;
    }
}

@media (max-width: 540px) {
    :root {
        --content-inline-gutter: 8px;
    }

    .chat-container,
    .input-wrapper {
        width: calc(100% - 16px);
    }

    .chat-area {
        padding: 16px 8px 150px;
    }

    .input-area {
        padding: 12px 8px 20px;
    }

    .input-container {
        padding: 8px 8px 8px 12px;
        border-radius: 24px;
    }

    #messageInput {
        font-size: 14px;
        padding: 6px 8px;
        min-height: 24px;
    }

    .attach-btn {
        width: 28px;
        height: 28px;
    }

    .attach-btn svg {
        width: 16px;
        height: 16px;
    }

    #sendBtn {
        width: 34px;
        height: 34px;
    }

    #sendBtn svg {
        width: 14px;
        height: 14px;
    }

    .voice-btn {
        width: 32px;
        height: 32px;
        margin-right: 2px;
    }

    .voice-btn svg {
        width: 16px;
        height: 16px;
    }

    /* Welcome adjustments */
    .welcome-title {
        font-size: 20px;
    }

    .welcome-subtitle {
        font-size: 13px;
        margin-bottom: 40px;
        padding: 0 16px;
    }

    .main:has(.chat-area.has-welcome) .input-area {
        transform: translateY(-20vh);
    }

    /* Message adjustments */
    .message {
        margin-bottom: 16px;
    }

    .message-content {
        padding: 10px 12px;
        font-size: 13px;
        border-radius: 10px;
    }

    .message.user .message-content {
        max-width: 90%;
    }

    .message-role {
        font-size: 11px;
        margin-bottom: 6px;
    }

    .message-actions {
        gap: 6px;
    }

    .message-action-btn {
        padding: 3px 8px;
        font-size: 11px;
    }

    /* Toolbar */
    .toolbar {
        padding: 10px 12px;
    }

    .toolbar-logo {
        font-size: 14px;
    }

    .menu-launcher {
        left: 12px;
        width: 32px;
        height: 32px;
    }

    .menu-launcher svg {
        width: 16px;
        height: 16px;
    }

    .toolbar-upgrade-btn {
        padding: 5px 10px;
        font-size: 12px;
    }

    .model-dropdown-btn {
        padding: 4px 8px;
        font-size: 12px;
        gap: 4px;
    }

    .model-dropdown-btn svg {
        width: 14px;
        height: 14px;
    }

    /* Code blocks */
    .code-terminal {
        border-radius: 10px;
    }

    .code-terminal-header {
        padding: 8px 10px;
    }

    .code-terminal-dots span {
        width: 8px;
        height: 8px;
    }

    .code-terminal-language {
        font-size: 11px;
    }

    .code-terminal-body {
        padding: 10px 12px;
    }

    .code-terminal-body pre {
        font-size: 11px;
        line-height: 1.5;
    }

    /* File dock */
    .file-dock-icon {
        width: 28px;
        height: 28px;
    }

    .file-emoji {
        font-size: 8px;
    }

    /* Sidebar on very small screens */
    .sidebar {
        width: 100%;
    }

    .sidebar-header {
        padding: 12px;
    }

    .sidebar-section {
        padding: 16px;
    }

    .history-list {
        padding: 6px;
    }

    /* Scroll nav */
    .scroll-nav {
        right: 8px;
        bottom: 90px;
    }

    .scroll-nav-btn {
        width: 32px;
        height: 32px;
    }

    .scroll-nav-btn svg {
        width: 16px;
        height: 16px;
    }

    /* Drop zone */
    .drop-zone-content {
        padding: 32px 24px;
    }

    .drop-zone-icon {
        width: 40px;
        height: 40px;
    }

    .drop-zone-text {
        font-size: 16px;
    }

    .drop-zone-subtext {
        font-size: 12px;
    }

    /* Modals */
    .auth-modal {
        margin: 0 8px;
        padding: 16px;
    }

    .auth-modal-header h2 {
        font-size: 18px;
    }

    .auth-subtitle {
        font-size: 13px;
    }

    .auth-btn {
        padding: 10px;
        font-size: 13px;
    }

    .confirm-modal {
        margin: 0 8px;
        padding: 20px;
    }

    .confirm-modal-title {
        font-size: 16px;
    }

    .confirm-modal-message {
        font-size: 13px;
    }

    .confirm-btn {
        padding: 8px 16px;
        font-size: 13px;
    }

    /* Model note */
    .model-note {
        font-size: 11px;
        bottom: 4px;
    }
}

/* Extra small screens (phones in portrait) */
@media (max-width: 375px) {
    .input-container {
        padding: 6px 6px 6px 10px;
    }

    #messageInput {
        font-size: 13px;
        padding: 4px 6px;
    }

    .attach-btn {
        width: 26px;
        height: 26px;
    }

    #sendBtn {
        width: 32px;
        height: 32px;
    }

    .voice-btn {
        width: 30px;
        height: 30px;
    }

    .welcome-title {
        font-size: 18px;
    }

    .message-content {
        font-size: 12px;
        padding: 8px 10px;
    }

    .toolbar-logo {
        font-size: 13px;
    }

    .model-dropdown-btn {
        padding: 3px 6px;
        font-size: 11px;
    }
}

/* Landscape mode on mobile */
@media (max-height: 500px) and (orientation: landscape) {
    .main:has(.chat-area.has-welcome) .input-area {
        transform: translateY(-10vh);
    }

    .welcome {
        margin-bottom: 60px;
    }

    .welcome-subtitle {
        margin-bottom: 30px;
    }

    .chat-area {
        padding-bottom: 120px;
    }

    .input-area {
        padding-bottom: 12px;
    }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    /* Larger touch targets */
    .history-item {
        min-height: 44px;
        padding: 10px 12px;
    }

    .history-action-btn {
        width: 32px;
        height: 32px;
    }

    .message-action-btn {
        padding: 6px 12px;
        min-height: 36px;
    }

    .version-nav-btn {
        width: 28px;
        height: 28px;
    }

    /* Always show action buttons on touch */
    .history-item-actions {
        opacity: 1;
    }

    /* Disable hover effects that don't work on touch */
    .nav-message-item .message-preview {
        display: none;
    }

    .code-terminal:hover {
        transform: none;
    }

    /* Better tap feedback */
    .auth-btn:active,
    .plan-btn:active,
    .new-chat-btn:active,
    .profile-btn:active {
        transform: scale(0.98);
    }
}

/* Icons */
svg {
    width: 20px;
    height: 20px;
}

/* Right Navigation */
.right-nav {
    position: fixed;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 5;
    max-height: 70vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 6px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 12px;
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.nav-messages {
    display: flex;
    flex-direction: column;
    gap: 2px;
    align-items: center;
    padding: 0;
    line-height: 1;
    overflow-y: auto;
    max-height: calc(70vh - 16px);
    scrollbar-width: none;
}

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

.nav-message-item {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px 6px;
    width: auto;
    height: auto;
    transition: all 0.15s ease;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    color: transparent;
    border-radius: 4px;
}

.nav-message-item:hover {
    background: rgba(255, 255, 255, 0.06);
}

.nav-message-item.active {
    background: rgba(255, 255, 255, 0.1);
}

.nav-tick {
    display: block;
    width: var(--tick-width, 12px);
    height: 2px;
    background: rgba(255, 255, 255, 0.25);
    border-radius: 999px;
    transition: all 0.15s ease;
}

.nav-message-item.user .nav-tick {
    background: rgba(255, 255, 255, 0.4);
}

.nav-message-item.loading .nav-tick {
    display: none;
}

.nav-dots {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2px;
    width: var(--tick-width, 12px);
    height: 8px;
}

.nav-dot {
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background: var(--text-light);
    animation: navDotBounce 1.05s ease-in-out infinite;
}

.nav-dot:nth-child(2) { animation-delay: 0.08s; }
.nav-dot:nth-child(3) { animation-delay: 0.16s; }

.nav-message-item:hover .nav-tick {
    width: calc(var(--tick-width, 12px) + 4px);
    background: rgba(255, 255, 255, 0.5);
}

.nav-message-item.active .nav-tick {
    width: calc(var(--tick-width, 12px) + 4px);
    background: var(--text);
}

.nav-message-item:focus-visible {
    outline: 1px solid var(--accent);
    outline-offset: 2px;
}

@keyframes navDotBounce {
    0%, 70%, 100% { transform: translateY(0); opacity: 0.4; }
    35% { transform: translateY(-2px); opacity: 1; }
}

.message-preview {
    position: absolute;
    right: calc(100% + 8px);
    top: 50%;
    transform: translateY(-50%);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 10px;
    width: 160px;
    max-width: 160px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.15s ease, visibility 0.15s ease;
    z-index: 100;
    pointer-events: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.nav-message-item:hover .message-preview {
    opacity: 1;
    visibility: visible;
}

.message-preview-title {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-light);
    margin-bottom: 2px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.message-preview-text {
    font-size: 12px;
    color: var(--text);
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
}

/* Auth Modal */
.auth-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(12px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 200;
    pointer-events: none;
}

.auth-modal-backdrop.open {
    display: flex;
    pointer-events: auto;
}

.auth-modal {
    background: #1f1f1f;
    border: 1px solid #2a2a2a;
    border-radius: 16px;
    width: min(360px, 90vw);
    padding: 18px;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.32);
}

.auth-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.auth-modal-header h2 {
    font-size: 20px;
    font-weight: 700;
    color: var(--text);
}

.auth-close {
    border: none;
    background: transparent;
    color: var(--text);
    font-size: 18px;
    cursor: pointer;
    padding: 6px;
    border-radius: 8px;
}

.auth-close:hover {
    background: rgba(255, 255, 255, 0.06);
}

.auth-subtitle {
    color: var(--text-light);
    font-size: 14px;
    line-height: 1.5;
    margin-bottom: 12px;
}

.auth-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
}

.auth-btn {
    width: 100%;
    border: 1px solid #3a3a3a;
    background: #252525;
    color: var(--text);
    padding: 11px 12px;
    border-radius: 999px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s, transform 0.1s;
}

.auth-btn:hover {
    background: #2c2c2c;
    border-color: #4a4a4a;
}

.auth-btn:active {
    transform: translateY(1px);
}

.auth-btn.primary {
    background: #ffffff;
    color: #111;
    border-color: transparent;
}

.auth-btn.primary:hover {
    background: #e9e9e9;
}

.auth-btn.provider {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.auth-icon {
    width: 18px;
    height: 18px;
    display: inline-block;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    flex-shrink: 0;
}

.auth-icon.google { background-image: url('../icon/google.webp'); }
.auth-icon.apple { background-image: url('../icon/apple.webp'); }
.auth-icon.microsoft { background-image: url('../icon/microsoft.webp'); }
.auth-icon.phone { background-image: url('../icon/phone.webp'); }

.auth-divider {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-light);
    font-size: 12px;
    letter-spacing: 0.3px;
    margin: 6px 0 10px;
}

.auth-divider::before,
.auth-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: #303030;
}

.auth-email {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.auth-email input {
    width: 100%;
    border: 1px solid #3a3a3a;
    background: #252525;
    color: var(--text);
    border-radius: 12px;
    padding: 12px;
    font-size: 14px;
}

.auth-email input:focus {
    outline: none;
    border-color: #555;
}

body.modal-open {
    overflow: hidden;
}

/* Settings Modal */
.settings-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(12px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 200;
    pointer-events: none;
}

.settings-modal-backdrop.open {
    display: flex;
    pointer-events: auto;
}

.settings-modal {
    background: #1a1a1a;
    border: 1px solid #2a2a2a;
    border-radius: 16px;
    width: min(800px, 95vw);
    height: min(600px, 90vh);
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.32);
    display: flex;
    overflow: hidden;
}

.settings-nav {
    width: 200px;
    background: #1f1f1f;
    border-right: 1px solid #2a2a2a;
    padding: 20px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.settings-nav h3 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-light);
    padding: 8px 12px;
    margin-bottom: 8px;
}

.settings-nav button {
    background: transparent;
    border: none;
    color: var(--text);
    padding: 10px 12px;
    text-align: left;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.15s;
}

.settings-nav button:hover {
    background: rgba(255, 255, 255, 0.05);
}

.settings-nav button.active {
    background: rgba(255, 255, 255, 0.1);
    font-weight: 500;
}

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

.settings-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid #2a2a2a;
}

.settings-header h2 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text);
}

.settings-close {
    border: none;
    background: transparent;
    color: var(--text);
    font-size: 24px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 8px;
    line-height: 1;
}

.settings-close:hover {
    background: rgba(255, 255, 255, 0.05);
}

#settingsBody {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

.settings-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 16px 0;
    border-bottom: 1px solid #2a2a2a;
    gap: 20px;
}

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

.setting-title {
    font-size: 14px;
    font-weight: 500;
    color: var(--text);
    margin-bottom: 4px;
}

.setting-sub {
    font-size: 13px;
    color: var(--text-light);
    line-height: 1.4;
}

.settings-value {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.setting-value-text {
    font-size: 14px;
    color: var(--text-light);
}

.chip-btn {
    background: transparent;
    border: 1px solid #3a3a3a;
    color: var(--text);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.15s;
}

.chip-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: #4a4a4a;
}

.link-btn {
    background: transparent;
    border: none;
    color: #ffffff;
    font-size: 14px;
    cursor: pointer;
    text-decoration: underline;
    padding: 0;
}

.link-btn:hover {
    color: var(--text-light);
}

.settings-pill {
    background: #2a2a2a;
    color: var(--text);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
}

.settings-pill.slim {
    padding: 4px 10px;
    font-size: 12px;
}

.settings-pill.subtle {
    background: transparent;
    border: 1px solid #3a3a3a;
}

.plan-cta {
    display: flex;
    align-items: center;
    gap: 10px;
}

.settings-toggle {
    width: 44px;
    height: 24px;
    background: #3a3a3a;
    border-radius: 12px;
    position: relative;
    cursor: pointer;
    transition: background 0.2s;
}

.settings-toggle::after {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    background: white;
    border-radius: 50%;
    top: 3px;
    left: 3px;
    transition: transform 0.2s;
}

.settings-toggle.active {
    background: #ffffff;
}

.settings-toggle.active::after {
    transform: translateX(20px);
    background: #1a1a1a;
}

/* Plan Modal */
.plan-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(12px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 200;
    pointer-events: none;
}

.plan-modal-backdrop.open {
    display: flex;
    pointer-events: auto;
}

.plan-modal {
    position: relative;
    background: #1a1a1a;
    border: 1px solid #2a2a2a;
    border-radius: 16px;
    width: min(900px, 95vw);
    max-height: 90vh;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.32);
    overflow: hidden;
}

.plan-modal-content {
    display: flex;
    flex-direction: column;
    padding: 32px;
    overflow-y: auto;
    max-height: 90vh;
}

.plan-close {
    align-self: flex-end;
    margin: 0 0 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.06);
    color: var(--text);
    font-size: 22px;
    cursor: pointer;
    padding: 0;
    border-radius: 8px;
    line-height: 1;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.35);
    transition: background 0.2s var(--transition), border-color 0.2s var(--transition), transform 0.12s ease;
}

.plan-close:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.16);
    transform: translateY(-1px);
}

.plan-close:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
}

.plan-hero {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 32px;
    gap: 20px;
}

.plan-hero h2 {
    font-size: 28px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 8px;
}

.plan-hero p {
    font-size: 14px;
    color: var(--text-light);
}

.plan-hero-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 12px;
    margin-top: 12px;
}

.plan-billing-toggle {
    background: #252525;
    border: 1px solid #2a2a2a;
    border-radius: 8px;
    padding: 4px;
    display: flex;
    gap: 4px;
}

.plan-billing-btn {
    background: transparent;
    border: none;
    color: var(--text-light);
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.15s;
}

.plan-billing-btn.active {
    background: #ffffff;
    color: #1a1a1a;
    font-weight: 500;
}

.plan-country-badge {
    font-size: 12px;
    color: var(--text-light);
    background: #252525;
    border: 1px solid #2a2a2a;
    padding: 4px 10px;
    border-radius: 6px;
}

.plan-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}

@media (max-width: 800px) {
    .plan-grid {
        grid-template-columns: 1fr;
    }
}

.plan-card {
    background: #1f1f1f;
    border: 1px solid #2a2a2a;
    border-radius: 12px;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    transition: all 0.2s;
}

.plan-card:hover {
    border-color: #3a3a3a;
}

.plan-card.selected {
    border-color: #ffffff;
    background: #252525;
}

.plan-badge {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: #000;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 6px 12px;
    border-radius: 20px;
    display: inline-block;
    width: fit-content;
    margin-bottom: -8px;
}

.plan-price-trial {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.plan-price-trial .trial-price {
    font-size: 32px;
    font-weight: 700;
    color: #10b981;
}

.plan-price-trial .trial-price span {
    font-size: 14px;
    font-weight: 400;
    color: var(--text-light);
}

.plan-price-trial .after-trial {
    font-size: 14px;
    color: var(--text-light);
}

.plan-name {
    font-size: 18px;
    font-weight: 600;
    color: var(--text);
}

.plan-price {
    font-size: 32px;
    font-weight: 700;
    color: var(--text);
}

.plan-price span {
    font-size: 16px;
    font-weight: 400;
    color: var(--text-light);
}

.plan-features {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex: 1;
    padding: 0;
    margin: 0;
    min-height: 140px;
}

.plan-features li {
    font-size: 14px;
    color: var(--text-light);
    padding-left: 24px;
    position: relative;
    line-height: 1.4;
}

.plan-features li::before {
    content: "\2713";
    position: absolute;
    left: 0;
    color: #10b981;
    font-weight: 600;
}

.plan-features li strong {
    color: #ffffff;
}

.plan-btn {
    background: transparent;
    border: 1px solid #3a3a3a;
    color: var(--text);
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
}

.plan-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: #4a4a4a;
}

.plan-btn.primary {
    background: #ffffff;
    color: #1a1a1a;
    border-color: #ffffff;
}

.plan-btn.primary:hover {
    background: #e5e5e5;
}

/* Notification System */
.notification-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: 400px;
    pointer-events: none;
}

.notification {
    background: #1f1f1f;
    border: 1px solid #2a2a2a;
    border-radius: 12px;
    padding: 16px 20px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: flex-start;
    gap: 12px;
    opacity: 0;
    transform: translateX(400px);
    animation: slideIn 0.3s forwards;
    pointer-events: auto;
    min-width: 300px;
}

.notification.removing {
    animation: slideOut 0.3s forwards;
}

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

@keyframes slideOut {
    to {
        opacity: 0;
        transform: translateX(400px);
    }
}

.notification-icon {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
}

.notification.info .notification-icon {
    background: #1e40af;
    color: #60a5fa;
}

.notification.success .notification-icon {
    background: #065f46;
    color: #10b981;
}

.notification.warning .notification-icon {
    background: #92400e;
    color: #fbbf24;
}

.notification.error .notification-icon {
    background: #7f1d1d;
    color: #ef4444;
}

.notification-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.notification-title {
    font-size: 14px;
    font-weight: 600;
    color: #ffffff;
}

.notification-message {
    font-size: 13px;
    color: #a0a0a0;
    line-height: 1.4;
    white-space: pre-line;
}

.notification-close {
    flex-shrink: 0;
    background: transparent;
    border: none;
    color: #a0a0a0;
    font-size: 18px;
    cursor: pointer;
    padding: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.15s;
}

.notification-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
}

/* Confirmation Modal */
.confirm-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(12px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    pointer-events: none;
}

.confirm-modal-backdrop.open {
    display: flex;
    pointer-events: auto;
}

.confirm-modal {
    background: #1f1f1f;
    border: 1px solid #2a2a2a;
    border-radius: 16px;
    width: min(400px, 90vw);
    padding: 24px;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.4);
}

.confirm-modal-header {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 16px;
}

.confirm-modal-icon {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
    background: #92400e;
    color: #fbbf24;
}

.confirm-modal-title {
    font-size: 18px;
    font-weight: 600;
    color: #ffffff;
}

.confirm-modal-message {
    font-size: 14px;
    color: #a0a0a0;
    line-height: 1.5;
    margin-bottom: 20px;
}

.confirm-modal-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

.confirm-btn {
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    border: none;
}

.confirm-btn-cancel {
    background: transparent;
    color: #ffffff;
    border: 1px solid #3a3a3a;
}

.confirm-btn-cancel:hover {
    background: rgba(255, 255, 255, 0.05);
}

.confirm-btn-confirm {
    background: #ef4444;
    color: #ffffff;
}

.confirm-btn-confirm:hover {
    background: #dc2626;
}

.nav-message-item:hover .message-preview {
    opacity: 1;
    visibility: visible;
    transform: translateX(-12px) translateY(-50%);
}

.message-preview-text {
    font-size: 12px;
    color: var(--text);
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Drag and Drop File Upload Styles */
.drop-zone {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

.drop-zone.active {
    opacity: 1;
    visibility: visible;
    pointer-events: all;
}

.drop-zone-content {
    text-align: center;
    padding: 48px 64px;
    border: 2px dashed rgba(255, 255, 255, 0.3);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.03);
}

.drop-zone.active .drop-zone-content {
    border-color: var(--accent);
}

.drop-zone-icon {
    width: 48px;
    height: 48px;
    margin: 0 auto 16px;
    stroke: var(--text-light);
    opacity: 0.7;
}

.drop-zone.active .drop-zone-icon {
    stroke: var(--accent);
    opacity: 1;
}

.drop-zone-text {
    font-size: 18px;
    font-weight: 500;
    color: var(--text);
    margin-bottom: 4px;
}

.drop-zone-subtext {
    font-size: 13px;
    color: var(--text-light);
}

/* File Dock Styles */
.file-dock {
    display: flex;
    align-items: center;
    gap: 8px;
}

.file-dock .attach-btn {
    transition: background 0.15s ease;
}

.file-dock.has-files .attach-btn {
    background: rgba(255, 255, 255, 0.08);
}

.file-dock-items {
    display: flex;
    gap: 6px;
    align-items: center;
}

.file-dock-item {
    position: relative;
    animation: fileSlideIn 0.2s ease-out;
}

@keyframes fileSlideIn {
    from {
        opacity: 0;
        transform: translateX(-8px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.file-dock-icon {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    background: var(--file-color, rgba(255, 255, 255, 0.1));
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: opacity 0.15s ease;
}

.file-dock-item:hover .file-dock-icon {
    opacity: 0.8;
}

.file-emoji {
    font-size: 9px;
    font-weight: 600;
    letter-spacing: 0.5px;
    color: var(--text-light);
    text-transform: uppercase;
}

.file-dock-remove {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 16px;
    height: 16px;
    padding: 0;
    background: var(--text-light);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.15s ease, background 0.15s ease;
    z-index: 2;
}

.file-dock-item:hover .file-dock-remove {
    opacity: 1;
}

.file-dock-remove:hover {
    background: #ef4444;
}

.file-dock-remove svg {
    width: 8px;
    height: 8px;
    stroke: var(--bg);
    stroke-width: 2.5;
}

/* Input area adjustment for file previews */

/* Auth Step Transitions */
.auth-step {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.auth-email input {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    animation: fadeInUp 0.3s ease-out;
}

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