* {
    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: 60px;
    --content-max-width: 720px;
    --content-inline-gutter: clamp(14px, 3vw, 24px);
}

html {
    background: var(--bg);
}

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

/* Disable global text selection; allow only conversation content and form inputs */
body,
body * {
    -webkit-user-select: none;
    user-select: none;
}

/* Keep editable/selectable areas working */
input,
textarea,
select,
[contenteditable="true"],
.chat-container,
.chat-container *,
#messages,
#messages *,
.message-content,
.message-content * {
    -webkit-user-select: text;
    user-select: text;
}

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

button,
a,
input,
textarea,
select {
    touch-action: manipulation;
}

/* 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;
    height: 100dvh;
    max-height: 100dvh;
    z-index: 60;
    overflow: hidden;
}

.sidebar.hidden {
    transform: translateX(-100%);
    border-right-color: transparent;
}

.sidebar.collapsed {
    width: var(--sidebar-collapsed-width);
    border-right-color: transparent;
}

.no-transition,
.no-transition * {
    transition: none !important;
}

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

.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: 22px;
    height: 22px;
}

.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: 10px 8px;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
    scrollbar-gutter: stable both-edges;
    overscroll-behavior: contain;
}

.history-item {
    padding: 10px 10px 10px 12px;
    border-radius: 10px;
    border: 1px solid transparent;
    background: rgba(255, 255, 255, 0.01);
    cursor: pointer;
    font-size: 14px;
    color: var(--text);
    transition: background 0.16s ease, border-color 0.16s ease, transform 0.16s ease;
    display: flex;
    align-items: center;
    gap: 10px;
    position: relative;
    min-height: 40px;
}

.history-item.renaming {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
}

.history-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 8px;
    bottom: 8px;
    width: 2px;
    border-radius: 2px;
    background: transparent;
}

.history-item:hover {
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(255, 255, 255, 0.08);
}

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

.history-item.active::before {
    background: rgba(255, 255, 255, 0.72);
}

.history-item:focus-visible {
    outline: none;
    border-color: rgba(255, 255, 255, 0.35);
    background: rgba(255, 255, 255, 0.05);
}

.history-search-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.history-search-icon {
    position: absolute;
    left: 11px;
    width: 15px;
    height: 15px;
    color: var(--text-light);
    opacity: 0.85;
    pointer-events: none;
}

.history-search {
    width: 100%;
    padding: 9px 36px 9px 34px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text);
    font-size: 13.5px;
    outline: none;
    transition: border-color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
}

.history-search::placeholder {
    color: #969696;
}

.history-search:focus {
    border-color: rgba(255, 255, 255, 0.26);
    background: rgba(255, 255, 255, 0.035);
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.06);
}

.history-search::-webkit-search-cancel-button {
    -webkit-appearance: none;
    appearance: none;
}

.history-search-clear {
    position: absolute;
    right: 6px;
    width: 24px;
    height: 24px;
    border: none;
    border-radius: 7px;
    background: transparent;
    color: var(--text-light);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    pointer-events: none;
    transform: scale(0.9);
    transition: opacity 0.15s ease, transform 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.history-search-wrap.has-value .history-search-clear {
    opacity: 1;
    pointer-events: auto;
    transform: scale(1);
}

.history-search-clear:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text);
}

.history-search-clear:focus-visible {
    outline: none;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.25);
}

.history-search-clear svg {
    width: 13px;
    height: 13px;
}

.history-item-text {
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 13.5px;
    letter-spacing: 0.1px;
    padding-right: 4px;
}

.history-item-input {
    flex: 1;
    min-width: 0;
    background: rgba(0, 0, 0, 0.28);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 7px 9px;
    color: var(--text);
    font-size: 13px;
    font-family: inherit;
    outline: none;
    width: 100%;
}

.history-item.renaming .history-item-input {
    width: 100%;
}

.history-item-input:focus {
    border-color: rgba(255, 255, 255, 0.35);
    background: rgba(0, 0, 0, 0.38);
}

.history-item-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
    opacity: 0;
    transform: translateX(4px);
    transition: opacity 0.16s ease, transform 0.16s ease;
}

.history-item:hover .history-item-actions,
.history-item.active .history-item-actions,
.history-item:focus-within .history-item-actions {
    opacity: 1;
    transform: translateX(0);
}

.history-action-btn {
    width: 26px;
    height: 26px;
    border: 1px solid transparent;
    background: rgba(255, 255, 255, 0.02);
    color: var(--text-light);
    cursor: pointer;
    border-radius: 7px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.16s ease, color 0.16s ease, border-color 0.16s ease;
    padding: 0;
}

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

.history-action-btn:focus-visible {
    outline: none;
    border-color: rgba(255, 255, 255, 0.3);
    color: var(--text);
}

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

.history-rename-controls {
    display: flex;
    gap: 6px;
    margin-top: 8px;
    width: 100%;
}

.history-item.renaming .history-rename-controls {
    margin-top: 0;
}

.history-action-btn.history-action-btn-text {
    width: auto;
    min-width: 58px;
    height: 30px;
    padding: 0 10px;
    font-size: 12px;
    font-weight: 500;
}

.history-empty {
    margin: 2px;
    padding: 12px 10px;
    border: 1px dashed var(--border);
    border-radius: 10px;
    color: var(--text-light);
    font-size: 12px;
    text-align: center;
    background: rgba(255, 255, 255, 0.01);
}

.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-signin,
.profile-signout {
    font-weight: 500;
}

.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);
    min-width: 0;
    min-height: 0;
    background: transparent;
}

/* 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.is-free-tier {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.toolbar-upgrade-icon {
    width: 14px;
    height: 14px;
    opacity: 0.9;
}

.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 {
    margin-left: auto;
}

.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;
    z-index: 1;
}

.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: 200;
    pointer-events: none;
}

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

.model-dropdown.portaled {
    position: fixed !important;
    top: 0;
    left: 0;
    transform: translateX(-50%) translateY(-8px);
    z-index: 2147483000 !important;
    pointer-events: none;
}

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

.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: 44px;
    height: 44px;
    padding: 6px;
    border-radius: 0;
    border: none;
    background: transparent;
    color: var(--text);
    display: none;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s;
}

.menu-launcher:hover {
    background: transparent;
}

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

/* 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;
}

/* Disable animation for pre-loaded messages */
.message.no-animate {
    animation: none;
    opacity: 1;
    transform: none;
}

@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 a,
.message-text-content a,
.message-content a {
    color: #4EA3FF;
    text-decoration: underline;
    text-underline-offset: 2px;
    cursor: pointer;
}

.message-text a:hover,
.message-text-content a:hover,
.message-content a:hover {
    color: #7DBDFF;
}

.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;
    }
}

/* Smooth swap from typing dots to rendered message content */
.message.typing-swap .message-content {
    animation: typingSwapIn 0.26s var(--transition) forwards;
    transform-origin: top left;
}

.message.typing-swap .message-actions {
    animation: typingSwapIn 0.26s var(--transition) forwards;
    animation-delay: 0.06s;
    opacity: 0.2;
    transform: translateY(6px);
    filter: blur(2px);
}

@keyframes typingSwapIn {
    from {
        opacity: 0.2;
        transform: translateY(6px);
        filter: blur(2px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
        filter: blur(0);
    }
}

/* Scroll Navigation Toggle */
.scroll-nav {
    position: fixed;
    left: 50%;
    bottom: 130px;
    transform: translateX(-50%) translateY(10px);
    z-index: 10;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease, transform 0.2s ease;
}

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

.scroll-nav-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(40, 40, 40, 0.8);
    border: 0.5px solid rgba(255, 255, 255, 0.8);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease;
}

.scroll-nav-btn:hover {
    background: rgba(25, 25, 25, 0.9);
}

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

/* Hide scroll-nav on large screens (950px+) */
@media (min-width: 950px) {
    .scroll-nav {
        display: none !important;
    }
}

/* 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;
}

.input-area.no-transition {
    transition: none;
}

.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;
    transform: scale(1);
    transition: opacity 0.3s var(--transition), transform 0.3s var(--transition), visibility 0s 0s;
}

.welcome.hidden {
    display: none;
}

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

.chat-area.has-welcome .chat-container {
    width: min(var(--content-max-width), calc(100% - (2 * var(--content-inline-gutter))));
    max-width: var(--content-max-width);
    margin: 0 auto;
    align-items: center;
    text-align: center;
}

.welcome-title {
    font-size: clamp(36px, 5.4vw, 52px);
    font-weight: 500;
    margin-bottom: 10px;
    color: var(--text);
    letter-spacing: -0.8px;
}

.welcome-subtitle {
    font-size: clamp(17px, 2vw, 22px);
    color: var(--text-light);
    margin-bottom: 96px;
    line-height: 1.35;
}

/* Animated Welcome Text */
.welcome-title:has(.letter),
.welcome-subtitle:has(.letter) {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0;
    overflow: hidden;
}

.welcome-title .letter,
.welcome-subtitle .letter {
    display: inline-block;
    opacity: 0;
    transform: translateY(28px) rotateX(-90deg) scale(0.84);
    animation: letterIn 0.32s cubic-bezier(0.22, 0.65, 0.2, 1) forwards;
    will-change: transform, opacity, filter;
}

.welcome-title .letter.out,
.welcome-subtitle .letter.out {
    animation: letterOut 0.2s ease forwards;
}

.welcome-title .letter.no-blur,
.welcome-subtitle .letter.no-blur {
    animation: letterInNoBlur 0.32s cubic-bezier(0.22, 0.65, 0.2, 1) forwards;
    will-change: transform, opacity;
}

.welcome-title .letter.no-blur.out,
.welcome-subtitle .letter.no-blur.out {
    animation: letterOutNoBlur 0.2s ease forwards;
}

.welcome-title .letter.space,
.welcome-subtitle .letter.space {
    width: 0.3em;
}

@keyframes letterIn {
    0% {
        opacity: 0;
        transform: translateY(28px) rotateX(-90deg) scale(0.78);
        filter: blur(5px);
    }
    65% {
        opacity: 0.85;
        transform: translateY(-4px) rotateX(8deg) scale(1.05);
        filter: blur(0.8px);
    }
    100% {
        opacity: 1;
        transform: translateY(0) rotateX(0deg) scale(1);
        filter: blur(0);
    }
}

@keyframes letterOut {
    0% {
        opacity: 1;
        transform: translateY(0) rotateX(0deg) scale(1);
        filter: blur(0);
    }
    45% {
        opacity: 0.6;
        transform: translateY(-8px) rotateX(26deg) scale(0.94);
        filter: blur(1.5px);
    }
    100% {
        opacity: 0;
        transform: translateY(-18px) rotateX(80deg) scale(0.82);
        filter: blur(4px);
    }
}

@keyframes letterInNoBlur {
    0% {
        opacity: 0;
        transform: translateY(24px) rotateX(-75deg) scale(0.86);
    }
    65% {
        opacity: 0.9;
        transform: translateY(-2px) rotateX(6deg) scale(1.03);
    }
    100% {
        opacity: 1;
        transform: translateY(0) rotateX(0deg) scale(1);
    }
}

@keyframes letterOutNoBlur {
    0% {
        opacity: 1;
        transform: translateY(0) rotateX(0deg) scale(1);
    }
    45% {
        opacity: 0.65;
        transform: translateY(-6px) rotateX(18deg) scale(0.95);
    }
    100% {
        opacity: 0;
        transform: translateY(-14px) rotateX(65deg) scale(0.84);
    }
}

/* RTL Support for Arabic */
.welcome-title.rtl,
.welcome-subtitle.rtl {
    direction: rtl;
    flex-direction: row-reverse;
}

/* Input positioning when on welcome screen */
.main:has(.chat-area.has-welcome) .input-area {
    transform: translateY(calc(-1 * var(--welcome-input-shift, clamp(148px, 25vh, 320px))));
}

/* 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%);
    pointer-events: none;
    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: 14px;
    }

    .sidebar {
        left: 0;
        width: min(84vw, 300px);
        max-width: 300px;
        top: 0;
        height: 100dvh;
        max-height: 100dvh;
        padding-top: env(safe-area-inset-top);
        z-index: 1200;
    }

    .sidebar-full {
        height: 100%;
        min-height: 0;
    }

    .sidebar-header {
        padding: 14px 14px 12px;
    }

    .sidebar-section {
        padding: 16px 14px;
    }

    .history-list {
        padding: 8px;
    }

    .sidebar-footer {
        padding: 12px 14px calc(12px + env(safe-area-inset-bottom));
    }

    .main {
        margin-left: 0;
    }

    .input-area {
        left: 0;
        padding: 14px 14px calc(20px + env(safe-area-inset-bottom));
    }

    .model-note {
        bottom: calc(2px + env(safe-area-inset-bottom));
    }

    .chat-area {
        padding: 20px 14px 170px;
    }

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

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

    .input-wrapper {
        width: calc(100% - 28px);
        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: 52px;
    }

    .main:has(.chat-area.has-welcome) .input-area {
        transform: translateY(calc(-1 * var(--welcome-input-shift, 2px)));
    }

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

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

    .profile-dropdown {
        position: absolute;
        bottom: calc(100% + 8px);
        left: 0;
        right: 0;
        width: 100%;
        max-height: min(46dvh, 280px);
        overflow-y: auto;
        z-index: 150;
    }

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

    .profile-menu-item {
        padding: 9px 10px;
        font-size: 13px;
    }

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

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

    /* Welcome screen adjustments */
    .welcome-title {
        font-size: 34px;
        line-height: 1.08;
    }

    .welcome-subtitle {
        font-size: 18px;
        margin-bottom: 56px;
    }

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

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

    .message-action-btn {
        padding: 6px 12px;
        font-size: 12px;
        min-height: 34px;
    }

    #messageInput {
        font-size: 16px;
    }

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

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

    /* Toolbar adjustments */
    .toolbar {
        padding: calc(12px + env(safe-area-inset-top)) 16px 12px;
        gap: 10px;
        min-height: 62px;
    }

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

    .menu-launcher {
        left: 16px;
        width: 44px;
        height: 44px;
        border-radius: 0;
        border: none;
        background: transparent;
        padding: 6px;
    }

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

    .toolbar-upgrade-btn {
        padding: 9px 14px;
        font-size: 14px;
        border-radius: 12px;
        min-height: 40px;
    }

    .toolbar-signin-btn {
        padding: 10px 16px;
        font-size: 14px;
        border-radius: 12px;
        min-height: 40px;
    }

    /* Model selector adjustments */
    .model-dropdown-btn {
        padding: 8px 12px;
        font-size: 14px;
        border-radius: 12px;
        min-height: 40px;
    }

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

    .model-dropdown {
        min-width: 200px;
        left: 50%;
        right: auto;
        max-width: calc(100vw - 28px);
    }

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

    .settings-content {
        min-height: 0;
    }

    .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: 10px 16px;
        min-height: 40px;
        font-size: 14px;
    }

    .settings-header {
        padding: 16px;
    }

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

    #settingsBody {
        padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
    }

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

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

    .setting-title {
        font-size: 15px;
    }

    .setting-sub {
        font-size: 14px;
    }

    .chip-btn,
    .link-btn {
        min-height: 36px;
        font-size: 13px;
    }

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

    .plan-modal-content {
        padding: 20px 16px calc(20px + env(safe-area-inset-bottom));
    }

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

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

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

    .plan-hero h2 {
        font-size: 24px;
    }

    .plan-hero p {
        font-size: 14px;
    }

    .plan-card {
        padding: 18px;
        gap: 14px;
    }

    .plan-name {
        font-size: 19px;
    }

    .plan-price {
        font-size: 30px;
    }

    .plan-features li {
        font-size: 14px;
    }

    .plan-btn {
        min-height: 42px;
        font-size: 14px;
    }

    .plan-close {
        width: 42px;
        height: 42px;
    }

    /* Auth modal mobile */
    .auth-modal {
        width: min(420px, 95vw);
        max-width: 95vw;
        margin: 0 10px;
        padding: 20px 17px 17px;
        border-radius: 12px;
    }

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

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

    .auth-btn {
        min-height: 42px;
        font-size: 14px;
    }

    .auth-email input {
        min-height: 44px;
        font-size: 16px;
    }

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

    .notification {
        min-width: auto;
    }

    .confirm-modal {
        width: min(420px, 94vw);
        padding: 20px 16px;
    }

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

    .confirm-modal-actions {
        flex-direction: column-reverse;
        gap: 10px;
    }

    .confirm-btn {
        width: 100%;
        min-height: 40px;
    }

    /* Scroll navigation */
    .scroll-nav {
        bottom: 115px;
    }

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

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

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

    .chat-area {
        padding: 18px 10px 166px;
    }

    .input-area {
        padding: 12px 10px calc(16px + env(safe-area-inset-bottom));
    }

    .input-container {
        padding: 9px 10px 9px 14px;
        border-radius: 24px;
    }

    #messageInput {
        font-size: 16px;
        padding: 7px 8px;
        min-height: 24px;
    }

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

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

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

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

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

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

    /* Welcome adjustments */
    .welcome-title {
        font-size: 30px;
        line-height: 1.1;
    }

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

    .main:has(.chat-area.has-welcome) .input-area {
        transform: translateY(calc(-1 * var(--welcome-input-shift, 2px)));
    }

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

    .message-content {
        padding: 11px 13px;
        font-size: 14px;
        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: 5px 10px;
        font-size: 12px;
    }

    /* Toolbar */
    .toolbar {
        padding: calc(12px + env(safe-area-inset-top)) 14px 12px;
    }

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

    .menu-launcher {
        left: 10px;
        width: 44px;
        height: 44px;
        border-radius: 0;
        border: none;
        background: transparent;
        padding: 6px;
    }

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

    .toolbar-upgrade-btn {
        padding: 9px 12px;
        font-size: 14px;
        min-height: 40px;
    }

    .model-dropdown-btn {
        padding: 8px 12px;
        font-size: 14px;
        min-height: 40px;
        gap: 5px;
    }

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

    .settings-header {
        padding: 14px 12px;
    }

    #settingsBody {
        padding: 14px 12px calc(14px + env(safe-area-inset-bottom));
    }

    .settings-nav {
        padding: 10px 12px;
    }

    .settings-nav button {
        padding: 9px 14px;
    }

    .plan-modal-content {
        padding: 18px 12px calc(18px + env(safe-area-inset-bottom));
    }

    .plan-hero h2 {
        font-size: 22px;
    }

    .plan-price {
        font-size: 28px;
    }

    .plan-price-trial .trial-price {
        font-size: 28px;
    }

    .plan-btn {
        min-height: 40px;
        font-size: 13px;
    }

    .auth-modal {
        margin: 0 8px;
        padding: 20px 16px 17px;
    }

    /* 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: min(82vw, 286px);
        max-width: 286px;
    }

    .sidebar-header {
        padding: 14px 10px 10px;
    }

    .sidebar-section {
        padding: 12px 10px;
    }

    .history-list {
        padding: 5px;
    }

    .sidebar-footer {
        padding: 10px 10px calc(10px + env(safe-area-inset-bottom));
    }

    /* Scroll nav */
    .scroll-nav {
        bottom: 105px;
    }

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

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

    /* 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: 18px 15px 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: calc(2px + env(safe-area-inset-bottom));
    }
}

/* Extra small screens (phones in portrait) */
@media (max-width: 375px) {
    .sidebar {
        width: min(80vw, 270px);
        max-width: 270px;
    }

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

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

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

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

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

    .welcome-title {
        font-size: 26px;
        line-height: 1.12;
    }

    .welcome-subtitle {
        font-size: 16px;
    }

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

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

    .model-dropdown-btn {
        padding: 7px 11px;
        font-size: 13px;
    }
}

/* Landscape mode on mobile */
@media (max-height: 500px) and (orientation: landscape) {
    .main:has(.chat-area.has-welcome) .input-area {
        transform: translateY(calc(-1 * var(--welcome-input-shift, 2px)));
    }

    .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;
    }

    .history-action-btn.history-action-btn-text {
        width: auto;
        min-width: 70px;
        height: 32px;
        padding: 0 12px;
    }

    .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 - only visible on large screens (950px+) */
.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);
}

/* Hide right navigation on small screens */
@media (max-width: 949px) {
    .right-nav {
        display: none !important;
    }
}

.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;
    padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
    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(420px, calc(100vw - 24px));
    padding: 22px 20px 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: 10px;
}

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

.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: 14px;
}

.auth-mode-switch {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    margin-bottom: 14px;
    background: #252525;
    border: 1px solid #2f2f2f;
    border-radius: 12px;
    padding: 4px;
}

.auth-mode-btn {
    border: none;
    background: transparent;
    color: var(--text-light);
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.16s ease, color 0.16s ease;
}

.auth-mode-btn.active {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text);
}

.auth-field-label {
    display: block;
    font-size: 12px;
    color: var(--text-light);
    margin-bottom: 4px;
}

.auth-field-label[for="authRegisterDob"]::after {
    content: "";
}

.auth-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    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: 12px;
    min-height: 56px;
    padding: 0 18px;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
}

.auth-btn.provider .auth-provider-label {
    display: inline-flex;
    align-items: center;
    line-height: 1.2;
    font-size: 16px;
    font-weight: 700;
}

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

.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: 0;
}

.auth-selected-email {
    border: 1px solid #3a3a3a;
    background: #202326;
    border-radius: 14px;
    padding: 10px 12px;
}

.auth-selected-email-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #9aa0a6;
    margin-bottom: 4px;
}

.auth-selected-email-value {
    font-size: 14px;
    color: var(--text);
    line-height: 1.3;
    word-break: break-word;
}

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

.auth-email input::placeholder {
    color: #9aa0a6;
}

.auth-email input[type="date"],
.auth-email input.auth-date-input {
    appearance: auto;
    -webkit-appearance: auto;
    color-scheme: dark;
    box-sizing: border-box;
    min-height: 52px;
    max-height: 52px;
    height: 52px;
    padding: 13px 46px 13px 14px;
    line-height: 1.15;
    text-align: left;
    letter-spacing: 0.01em;
    background-repeat: no-repeat;
    background-position: right 14px center;
    background-size: 18px 18px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%23b5bbc5' stroke-width='1.9' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='5' width='18' height='16' rx='3'/%3E%3Cpath d='M16 3v4M8 3v4M3 10h18'/%3E%3C/svg%3E");
}

.auth-email input[type="date"]::-webkit-date-and-time-value,
.auth-email input.auth-date-input::-webkit-date-and-time-value {
    text-align: left;
    min-height: 1em;
}

.auth-email input[type="date"]::-webkit-datetime-edit,
.auth-email input[type="date"]::-webkit-datetime-edit-year-field,
.auth-email input[type="date"]::-webkit-datetime-edit-month-field,
.auth-email input[type="date"]::-webkit-datetime-edit-day-field,
.auth-email input[type="date"]::-webkit-datetime-edit-text,
.auth-email input.auth-date-input::-webkit-datetime-edit,
.auth-email input.auth-date-input::-webkit-datetime-edit-year-field,
.auth-email input.auth-date-input::-webkit-datetime-edit-month-field,
.auth-email input.auth-date-input::-webkit-datetime-edit-day-field,
.auth-email input.auth-date-input::-webkit-datetime-edit-text {
    color: var(--text);
    line-height: 1;
}

.auth-email input[type="date"]::-webkit-calendar-picker-indicator,
.auth-email input.auth-date-input::-webkit-calendar-picker-indicator {
    filter: none;
    opacity: 0.02;
    width: 20px;
    height: 20px;
    cursor: pointer;
}

.auth-email input[type="date"]:invalid,
.auth-email input.auth-date-input:invalid {
    color: #9aa0a6;
}

@media (max-width: 768px) {
    .auth-email input[type="date"],
    .auth-email input.auth-date-input {
        width: 100%;
        max-width: 100%;
        min-width: 0;
        min-height: 50px;
        max-height: 50px;
        height: 50px;
        padding: 12px 44px 12px 13px;
        font-size: 16px;
        line-height: 1.1;
        background-position: right 13px center;
        background-size: 17px 17px;
    }

    .auth-email input[type="date"]::-webkit-datetime-edit,
    .auth-email input.auth-date-input::-webkit-datetime-edit {
        padding: 0;
        min-height: 1em;
    }

    .auth-email input[type="date"]::-webkit-date-and-time-value,
    .auth-email input.auth-date-input::-webkit-date-and-time-value {
        min-height: 1em;
    }
}

@media (max-width: 420px) {
    .auth-email input[type="date"],
    .auth-email input.auth-date-input {
        font-size: 15px;
        padding-right: 40px;
    }
}

.auth-email input:focus {
    outline: none;
    border-color: #616161;
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.06);
}

.auth-email input:-webkit-autofill,
.auth-email input:-webkit-autofill:hover,
.auth-email input:-webkit-autofill:focus,
.auth-email input:-webkit-autofill:active {
    -webkit-text-fill-color: var(--text) !important;
    box-shadow: 0 0 0 1000px #202326 inset !important;
    -webkit-box-shadow: 0 0 0 1000px #202326 inset !important;
    caret-color: var(--text);
    border: 1px solid #3a3a3a;
}

.auth-email input:autofill {
    color: var(--text);
    box-shadow: 0 0 0 1000px #202326 inset;
}

.auth-inline-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 12px;
    justify-content: space-between;
    margin-top: 2px;
}

.auth-inline-actions .link-btn {
    border: none;
    background: transparent;
    color: #d0d0d0;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    padding: 0;
}

.auth-inline-actions .link-btn:hover {
    color: #ffffff;
    text-decoration: underline;
}

body.modal-open {
    overflow: hidden;
}

/* Cookie Consent (non-blocking banner) */
.cookie-consent-gate {
    position: fixed;
    inset: 0;
    display: none;
    align-items: flex-end;
    justify-content: center;
    padding: 16px max(16px, env(safe-area-inset-right)) calc(16px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
    background: transparent;
    pointer-events: none;
    z-index: 12050;
}

.cookie-consent-gate.open {
    display: flex;
}

.cookie-consent-panel {
    position: relative;
    pointer-events: auto;
    width: min(980px, 100%);
    background: rgba(31, 31, 31, 0.92);
    border: 1px solid #2a2a2a;
    border-radius: 16px;
    padding: 16px 16px 14px;
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.55);
    color: var(--text);
    backdrop-filter: blur(10px);
    transform: translateY(14px);
    opacity: 0;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.cookie-consent-gate.open .cookie-consent-panel {
    transform: translateY(0);
    opacity: 1;
}

.cookie-consent-title {
    font-size: 16px;
    line-height: 1.2;
    font-weight: 700;
    text-align: left;
    margin: 0 0 6px;
    letter-spacing: -0.01em;
}

.cookie-consent-text {
    margin: 0;
    text-align: left;
    font-size: 14px;
    line-height: 1.4;
    color: #e5e7eb;
}

.cookie-consent-link {
    color: #f8fafc;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.cookie-consent-actions {
    margin-top: 12px;
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 10px;
}

.cookie-consent-btn {
    width: auto;
    min-height: 42px;
    padding: 0 18px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    background: #23272b;
    color: #f8fafc;
    font-size: 15px;
    font-weight: 600;
    line-height: 1;
    cursor: pointer;
    transition: transform 0.16s ease, background 0.16s ease, border-color 0.16s ease;
}

.cookie-consent-btn:hover {
    transform: translateY(-1px);
    border-color: rgba(255, 255, 255, 0.3);
}

.cookie-consent-btn.primary {
    background: #f8fafc;
    border-color: #f8fafc;
    color: #101315;
}

.cookie-consent-btn.secondary {
    background: #23272b;
}

.cookie-consent-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

@media (max-width: 520px) {
    .cookie-consent-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .cookie-consent-btn {
        width: 100%;
    }
}

/* 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);
}

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

.settings-avatar-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.settings-avatar-preview svg {
    width: 18px;
    height: 18px;
    stroke: var(--bg);
}

.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 {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: transparent;
    border: 1px solid #3a3a3a;
    color: var(--text);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    padding: 6px 12px;
    border-radius: 6px;
    line-height: 1.2;
    transition: all 0.15s;
}

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

.link-btn:focus-visible {
    outline: 2px solid var(--text);
    outline-offset: 2px;
}

.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;
}

.settings-device-list {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.settings-device-item {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    width: 100%;
    border: 1px solid #2f2f2f;
    border-radius: 10px;
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.02);
}

.settings-device-main {
    min-width: 0;
}

.settings-device-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 3px;
}

.settings-device-meta {
    font-size: 12px;
    color: var(--text-light);
    line-height: 1.35;
}

.settings-device-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.settings-device-current {
    border: 1px solid #3f3f3f;
    border-radius: 999px;
    padding: 4px 8px;
    font-size: 11px;
    color: var(--text-light);
}

/* Settings Modal - final mobile override (must come after base settings styles) */
@media (max-width: 768px) {
    .settings-modal-backdrop {
        align-items: stretch;
        justify-content: stretch;
        padding: 0;
    }

    .settings-modal {
        width: 100vw;
        height: 100dvh;
        max-height: 100dvh;
        border-radius: 0;
        border-left: none;
        border-right: none;
        flex-direction: column;
    }

    .settings-nav {
        width: 100%;
        flex-direction: row;
        align-items: center;
        overflow-x: auto;
        overflow-y: hidden;
        white-space: nowrap;
        gap: 8px;
        padding: calc(10px + env(safe-area-inset-top)) 12px 10px;
        border-right: none;
        border-bottom: 1px solid #2a2a2a;
        scrollbar-width: none;
        -ms-overflow-style: none;
        flex-shrink: 0;
    }

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

    .settings-nav h3 {
        display: none;
    }

    .settings-nav button {
        flex: 0 0 auto;
        padding: 10px 14px;
        font-size: 13px;
        border-radius: 10px;
    }

    .settings-content {
        flex: 1;
        min-height: 0;
        width: 100%;
    }

    .settings-header {
        position: sticky;
        top: 0;
        z-index: 2;
        background: #1a1a1a;
        padding: 12px 14px;
    }

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

    .settings-close {
        width: 34px;
        height: 34px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        padding: 0;
        font-size: 22px;
    }

    #settingsBody {
        padding: 14px 14px calc(20px + env(safe-area-inset-bottom));
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .settings-row {
        flex-direction: column;
        gap: 10px;
        padding: 14px 0;
    }

    .settings-value {
        width: 100%;
        justify-content: flex-start;
        flex-wrap: wrap;
        gap: 8px;
    }

    .setting-title {
        font-size: 15px;
    }

    .setting-sub {
        font-size: 13px;
    }

    .setting-value-text {
        max-width: 100%;
        overflow-wrap: anywhere;
    }

    .plan-cta {
        flex-wrap: wrap;
        align-items: center;
        gap: 8px;
    }

    .chip-btn,
    .link-btn {
        min-height: 36px;
        font-size: 13px;
    }

    .settings-device-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .settings-device-actions {
        width: 100%;
        justify-content: flex-start;
        flex-wrap: wrap;
    }
}

@media (max-width: 420px) {
    .settings-nav {
        padding: calc(8px + env(safe-area-inset-top)) 10px 8px;
        gap: 6px;
    }

    .settings-nav button {
        padding: 9px 12px;
        font-size: 12px;
    }

    .settings-header {
        padding: 10px 12px;
    }

    #settingsBody {
        padding: 12px 12px calc(18px + env(safe-area-inset-bottom));
    }

    .settings-row {
        gap: 8px;
    }
}

/* 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-quotas {
    display: flex;
    gap: 10px;
    font-size: 12px;
    color: var(--text-light);
    background: #252525;
    border: 1px solid #2a2a2a;
    padding: 6px 10px;
    border-radius: 8px;
    width: fit-content;
}

.plan-quotas .quota-hourly::before {
    content: 'Hourly: ';
    color: #888;
}

.plan-quotas .quota-monthly::before {
    content: 'Monthly: ';
    color: #888;
}

.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-desc {
    font-size: 13px;
    color: var(--text-light);
    margin-top: 4px;
}

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

.plan-price-standard {
    display: block;
}

.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-media {
    width: 100%;
    aspect-ratio: 16 / 9;
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid #2f2f2f;
    background: #151515;
    margin-bottom: 4px;
}

.plan-media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.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;
}

.plan-btn.current {
    background: transparent;
    border-color: #3a3a3a;
    color: var(--text-light);
    cursor: default;
}

.plan-btn.current:hover {
    background: transparent;
    border-color: #3a3a3a;
}

.plan-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.plan-card.current-plan {
    border-color: #4a4a4a;
}

.plan-card.next-plan {
    position: relative;
    border-color: rgba(229, 160, 96, 0.55);
}

.plan-card.next-plan::after {
    content: "";
    position: absolute;
    top: 12px;
    right: 12px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #e5a060;
    box-shadow: 0 0 0 3px rgba(229, 160, 96, 0.18);
}

.plan-billing-info {
    margin-top: 12px;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 6px;
    font-size: 12px;
    color: var(--text-light);
    text-align: center;
}

.plan-billing-info.canceling {
    background: rgba(220, 160, 80, 0.1);
    color: #e5a060;
}

.plan-btn.scheduled {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border-color: rgba(229, 160, 96, 0.45);
    color: #e5a060;
}

.plan-btn.scheduled::before {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
    flex-shrink: 0;
}

.plan-btn.scheduled:disabled {
    opacity: 1;
}


/* 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;
}

/* Upgrade Toast - Centered Top */
.upgrade-toast {
    position: fixed;
    top: 70px;
    left: calc(50% + (var(--sidebar-current-width) / 2));
    transform: translateX(-50%);
    z-index: 10001;
    background: rgba(40, 40, 40, 0.9);
    border: 0.5px solid rgba(255, 255, 255, 0.15);
    border-radius: 10px;
    padding: 10px 10px 10px 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    gap: 12px;
    animation: upgradeToastSlideIn 0.25s ease-out forwards;
}

.upgrade-toast.removing {
    animation: upgradeToastSlideOut 0.2s ease-in forwards;
}

@keyframes upgradeToastSlideIn {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(-10px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0) scale(1);
    }
}

@keyframes upgradeToastSlideOut {
    from {
        opacity: 1;
        transform: translateX(-50%) translateY(0) scale(1);
    }
    to {
        opacity: 0;
        transform: translateX(-50%) translateY(-10px) scale(0.95);
    }
}

.upgrade-toast-title {
    font-size: 14px;
    font-weight: 400;
    color: rgba(255, 255, 255, 0.9);
    letter-spacing: -0.01em;
}

.upgrade-toast-btn {
    flex-shrink: 0;
    background: #ffffff;
    border: none;
    border-radius: 6px;
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 500;
    color: #000000;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.upgrade-toast-btn:hover {
    background: #f0f0f0;
    transform: scale(1.02);
}

.upgrade-toast-close {
    flex-shrink: 0;
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.4);
    font-size: 16px;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s;
}

.upgrade-toast-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.8);
}

/* 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;
}

/* Dynamic confirm/prompt modal actions used by JS-generated dialogs */
.confirm-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    flex-wrap: wrap;
}

.confirm-cancel,
.confirm-ok,
.confirm-actions .confirm-cancel,
.confirm-actions .confirm-ok {
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    border: 1px solid #3a3a3a;
}

.confirm-cancel,
.confirm-actions .confirm-cancel {
    background: transparent;
    color: #ffffff;
}

.confirm-cancel:hover,
.confirm-actions .confirm-cancel:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: #4a4a4a;
}

.confirm-ok,
.confirm-actions .confirm-ok {
    background: #ffffff;
    color: #1a1a1a;
    border-color: #ffffff;
}

.confirm-ok:hover,
.confirm-actions .confirm-ok:hover {
    background: #e5e5e5;
    border-color: #e5e5e5;
}

.confirm-cancel:focus-visible,
.confirm-ok:focus-visible,
.confirm-actions .confirm-cancel:focus-visible,
.confirm-actions .confirm-ok:focus-visible {
    outline: 2px solid #ffffff;
    outline-offset: 2px;
}

.prompt-input {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 8px;
}

.prompt-input:focus {
    outline: none;
    border-color: #4a4a4a;
}

.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 {
    display: flex;
    flex-direction: column;
    gap: 10px;
    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);
    }
}

@media (max-width: 768px) {
    .toolbar {
        z-index: 5;
    }

    .model-selector-wrapper {
        z-index: 6;
    }

    .model-dropdown {
        max-width: calc(100vw - 20px);
    }

    .model-dropdown.open {
    }

    .model-option {
        min-height: 44px;
    }

    .notification-container {
        top: calc(10px + env(safe-area-inset-top));
        right: 10px;
        left: auto;
        width: min(320px, calc(100vw - 20px));
        max-width: calc(100vw - 20px);
        align-items: flex-end;
    }

    .notification {
        width: 100%;
        min-width: 0;
        padding: 12px 14px;
        border-radius: 10px;
    }

    .notification-title {
        font-size: 13px;
    }

    .notification-message {
        font-size: 12px;
    }

    .upgrade-toast {
        top: calc(10px + env(safe-area-inset-top));
        left: auto;
        right: 10px;
        width: min(320px, calc(100vw - 20px));
        transform: none;
        padding: 10px 10px 10px 12px;
        animation: upgradeToastSlideInMobile 0.25s ease-out forwards;
    }

    .upgrade-toast.removing {
        animation: upgradeToastSlideOutMobile 0.2s ease-in forwards;
    }
}

@keyframes upgradeToastSlideInMobile {
    from {
        opacity: 0;
        transform: translateY(-10px) scale(0.96);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes upgradeToastSlideOutMobile {
    from {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    to {
        opacity: 0;
        transform: translateY(-10px) scale(0.96);
    }
}

/* Plan modal mobile-only polish */
@media (max-width: 900px) {
    .plan-modal {
        width: 100vw;
        max-width: 100vw;
        height: 100dvh;
        max-height: 100dvh;
        border-radius: 0;
        border-left: none;
        border-right: none;
    }

    .plan-modal-content {
        padding: calc(14px + env(safe-area-inset-top)) 14px calc(18px + env(safe-area-inset-bottom));
        max-height: 100dvh;
        overflow-y: auto;
    }

    .plan-close {
        position: sticky;
        top: 0;
        align-self: flex-end;
        margin: 0 0 10px;
        width: 42px;
        height: 42px;
        border-radius: 11px;
        z-index: 3;
        background: rgba(26, 26, 26, 0.9);
        backdrop-filter: blur(8px);
    }

    .plan-hero {
        margin-bottom: 14px;
        gap: 10px;
        flex-direction: column;
        align-items: stretch;
    }

    .plan-hero h2 {
        font-size: 24px;
        line-height: 1.15;
        margin-bottom: 7px;
    }

    .plan-hero p {
        font-size: 14px;
        line-height: 1.45;
    }

    .plan-hero-meta {
        margin-top: 4px;
        width: 100%;
        align-items: stretch;
    }

    .plan-billing-toggle {
        width: 100%;
        padding: 4px;
    }

    .plan-billing-btn {
        flex: 1;
        min-height: 40px;
        font-size: 14px;
        border-radius: 8px;
    }

    .plan-grid {
        gap: 12px;
    }

    .plan-card {
        padding: 16px 14px;
        border-radius: 12px;
        gap: 10px;
    }

    .plan-card.selected {
        border-width: 1px;
        box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.14) inset;
    }

    .plan-badge {
        font-size: 10px;
        padding: 5px 9px;
        margin-bottom: 0;
    }

    .plan-name {
        font-size: 19px;
    }

    .plan-desc {
        font-size: 13px;
        line-height: 1.4;
        margin-top: 0;
    }

    .plan-price,
    .plan-price-trial .trial-price {
        font-size: 30px;
        line-height: 1;
    }

    .plan-price span,
    .plan-price-trial .trial-price span {
        font-size: 14px;
    }

    .plan-price-trial .after-trial {
        font-size: 13px;
    }

    .plan-features {
        gap: 10px;
        min-height: 0;
        margin: 2px 0 4px;
    }

    .plan-features li {
        font-size: 13px;
        line-height: 1.35;
        padding-left: 16px;
    }

    .plan-features li::before {
        top: 0.48em;
    }

    .plan-media {
        border-radius: 10px;
        margin-bottom: 2px;
    }

    .plan-btn {
        width: 100%;
        min-height: 44px;
        font-size: 14px;
        border-radius: 10px;
        margin-top: 2px;
    }

    .plan-billing-info {
        font-size: 12px;
        line-height: 1.35;
        margin-top: 6px;
        padding: 10px 10px;
        border-radius: 9px;
    }
}

@media (max-width: 520px) {
    .plan-modal-content {
        padding: calc(12px + env(safe-area-inset-top)) 12px calc(14px + env(safe-area-inset-bottom));
    }

    .plan-hero h2 {
        font-size: 22px;
    }

    .plan-hero p {
        font-size: 13px;
    }

    .plan-card {
        padding: 14px 12px;
        gap: 9px;
    }

    .plan-name {
        font-size: 18px;
    }

    .plan-price,
    .plan-price-trial .trial-price {
        font-size: 28px;
    }

    .plan-features li {
        font-size: 12.5px;
    }

    .plan-btn {
        min-height: 42px;
        font-size: 13px;
    }
}

/* Final mobile viewport + model dropdown compact overrides */
@media (max-width: 768px) {
    html,
    body {
        max-width: 100%;
        overflow-x: hidden;
    }

    .container,
    .main {
        width: 100%;
        max-width: 100%;
        min-width: 0;
    }

    .toolbar {
        min-width: 0;
        flex-wrap: nowrap;
        align-items: center;
        row-gap: 0;
    }

    .toolbar-logo {
        min-width: 0;
        max-width: 40vw;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .model-selector-wrapper {
        min-width: 0;
        margin-left: 0;
        width: auto;
        max-width: none;
        flex-shrink: 0;
    }

    .toolbar-upgrade-btn {
        margin-left: auto;
    }

    .model-dropdown.portaled {
        padding: 6px;
        border-radius: 12px;
        max-height: min(52dvh, 300px);
        overflow-y: auto;
        overscroll-behavior: contain;
    }

    .model-dropdown.portaled .model-option {
        min-height: 40px;
        padding: 8px 10px;
        gap: 2px;
    }

    .model-dropdown.portaled .model-option-name {
        font-size: 13px;
    }

    .model-dropdown.portaled .model-option-desc {
        font-size: 11px;
        line-height: 1.25;
    }
}

@media (max-width: 520px) {
    .model-dropdown.portaled {
        max-height: min(46dvh, 250px);
    }

    .model-dropdown.portaled .model-option {
        min-height: 38px;
        padding: 9px 10px;
    }

    .model-dropdown.portaled .model-option-desc {
        display: none;
    }
}

/* Mobile top toolbar: remove button borders */
@media (max-width: 768px) {
    .menu-launcher,
    .model-dropdown-btn,
    .toolbar-upgrade-btn,
    .toolbar-signin-btn {
        border: none !important;
        box-shadow: none;
    }

    .toolbar-upgrade-btn {
        background: rgba(255, 255, 255, 0.08) !important;
    }

    .menu-launcher {
        background: transparent !important;
        border: none !important;
        border-radius: 0 !important;
        box-shadow: none !important;
    }

    .model-dropdown-btn,
    .model-dropdown-btn:hover,
    .model-dropdown-btn:active,
    .model-dropdown-btn.open {
        background: transparent !important;
        border: none !important;
        box-shadow: none !important;
    }

    .toolbar-signin-btn {
        background: #ececec;
        color: #1a1a1a;
    }
}

/* Auth form mobile fit/consistency */
@media (max-width: 768px) {
    .auth-modal {
        width: min(430px, calc(100vw - 18px));
        max-height: calc(100dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 18px);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding: 18px 14px calc(14px + env(safe-area-inset-bottom));
        border-radius: 16px;
    }

    .auth-field-label {
        font-size: 13px;
        margin-bottom: 6px;
    }

    .auth-email input {
        min-height: 50px;
        padding: 12px 14px;
        font-size: 16px;
        border-radius: 14px;
    }

    .auth-email input[type="date"],
    .auth-email input.auth-date-input {
        width: 100%;
        min-height: 50px;
        max-height: 50px;
        height: 50px;
        padding: 12px 14px;
        line-height: 1.2;
        color: var(--text);
        background-image: none;
        appearance: none;
        -webkit-appearance: none;
    }

    .auth-email input[type="date"]::-webkit-calendar-picker-indicator,
    .auth-email input.auth-date-input::-webkit-calendar-picker-indicator {
        opacity: 0.72;
        filter: invert(0.84);
        width: 20px;
        height: 20px;
    }
}

@media (max-width: 520px) {
    .auth-email input {
        min-height: 48px;
        padding: 11px 13px;
    }

    .auth-email input[type="date"],
    .auth-email input.auth-date-input {
        min-height: 48px;
        max-height: 48px;
        height: 48px;
        padding: 11px 13px;
    }
}
