/* Chatudex · Midnight Iris design system */
:root {
    color-scheme: dark;
    --base: #0b0f18;
    --mantle: #111724;
    --crust: #080c13;
    --text: #f2f4f8;
    --subtext0: #8f9aae;
    --subtext1: #b9c1d0;
    --surface0: #1a2232;
    --surface1: #273247;
    --surface2: #39465e;
    --overlay0: #9aa5b9;
    --overlay1: #aeb8c8;
    --border: rgba(255, 255, 255, 0.09);
    --border-strong: rgba(255, 255, 255, 0.15);
    --blue: #8b7cff;
    --lavender: #afa5ff;
    --mauve: #c29cff;
    --green: #61d095;
    --peach: #f4ae79;
    --red: #ff788a;
    --yellow: #f4c877;
    --user-bubble: #252359;
    --user-border: rgba(154, 139, 255, 0.35);
    --selection-bg: #3a3d70;
    --selection-text: #f8fafc;
    --thinking-bg: rgba(139, 124, 255, 0.09);
    --thinking-border: rgba(139, 124, 255, 0.2);
    --thinking-box-bg: #0d1220;
    --font-sans: 'Inter', 'Microsoft YaHei UI', 'Microsoft YaHei', 'PingFang SC', 'Noto Sans SC', system-ui, sans-serif;
    --font-title: 'Outfit', 'Inter', 'Microsoft YaHei UI', system-ui, sans-serif;
    --font-mono: 'JetBrains Mono', 'Cascadia Code', 'Consolas', monospace;
    --shadow-sm: 0 8px 28px rgba(0, 0, 0, 0.18);
    --shadow-lg: 0 28px 80px rgba(0, 0, 0, 0.5);
    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

body.font-mode-system {
    --font-sans: 'Segoe UI', 'Microsoft YaHei UI', 'Microsoft YaHei', system-ui, sans-serif;
    --font-title: 'Segoe UI', 'Microsoft YaHei UI', system-ui, sans-serif;
    --font-mono: 'Cascadia Code', 'Consolas', monospace;
}

*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }
html { background: var(--base); }
body {
    width: 100vw;
    width: 100dvw;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    background:
        radial-gradient(circle at 68% -20%, rgba(139, 124, 255, 0.1), transparent 38%),
        var(--base);
    color: var(--text);
    font-family: var(--font-sans);
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}
button, input, textarea, select { font: inherit; }
button, select { -webkit-tap-highlight-color: transparent; }
button:disabled, input:disabled, select:disabled { cursor: not-allowed; opacity: 0.55; }
a { color: inherit; }
::selection { background: var(--selection-bg); color: var(--selection-text); }
:focus { outline: none; }
:focus-visible {
    outline: 2px solid var(--lavender);
    outline-offset: 2px;
}
.hidden { display: none !important; }
.skip-link {
    position: fixed;
    top: 10px;
    left: 50%;
    z-index: 20000;
    translate: -50% -160%;
    padding: 9px 14px;
    border: 1px solid var(--border-strong);
    border-radius: 10px;
    background: var(--surface1);
    color: var(--text);
    text-decoration: none;
    transition: translate 160ms ease;
}
.skip-link:focus { translate: -50% 0; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface1); border: 2px solid transparent; border-radius: 999px; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: var(--surface2); background-clip: padding-box; }

/* Layout */
.app-container { display: flex; width: 100%; height: 100%; overflow: hidden; }
.sidebar {
    position: relative;
    z-index: 20;
    display: flex;
    flex: 0 0 264px;
    width: 264px;
    min-width: 0;
    flex-direction: column;
    border-right: 1px solid var(--border);
    background: rgba(13, 18, 29, 0.94);
}
.sidebar::before {
    position: absolute;
    inset: 0 0 auto;
    height: 170px;
    background: radial-gradient(circle at 35% 0, rgba(139, 124, 255, 0.12), transparent 72%);
    content: '';
    pointer-events: none;
}
.sidebar-header { position: relative; display: grid; gap: 14px; padding: 22px 18px 16px; }
.brand { display: flex; align-items: center; gap: 11px; min-height: 38px; }
.brand-logo {
    display: grid;
    width: 36px;
    height: 36px;
    flex: 0 0 36px;
    place-items: center;
    border: 1px solid rgba(255,255,255,.16);
    border-radius: 12px;
    background: linear-gradient(145deg, #a497ff, #6e5ee8);
    box-shadow: 0 9px 24px rgba(111, 94, 232, .3), inset 0 1px rgba(255,255,255,.32);
    color: #fff;
    font-family: var(--font-title);
    font-size: 17px;
    font-weight: 700;
}
.brand-copy { display: flex; min-width: 0; flex-direction: column; gap: 1px; }
.brand-name { font-family: var(--font-title); font-size: 16px; font-weight: 650; letter-spacing: .01em; }
.brand-subtitle { color: var(--subtext0); font-size: 10px; letter-spacing: .13em; text-transform: uppercase; }
.new-chat-btn { width: 100%; min-height: 42px; justify-content: center; gap: 8px; box-shadow: 0 10px 28px rgba(107, 89, 227, .24); }
.button-icon { font-size: 19px; font-weight: 400; line-height: 1; }
.sidebar-search {
    display: flex;
    height: 38px;
    align-items: center;
    gap: 8px;
    padding: 0 11px;
    border: 1px solid var(--border);
    border-radius: 11px;
    background: rgba(255,255,255,.025);
    color: var(--subtext0);
    transition: border-color 150ms ease, background 150ms ease;
}
.sidebar-search:focus-within { border-color: rgba(139, 124, 255, .65); background: rgba(139,124,255,.05); }
.sidebar-search-icon { font-size: 17px; line-height: 1; rotate: -12deg; }
.sidebar-search input { width: 100%; min-width: 0; border: 0; background: transparent; color: var(--text); font-size: 12px; }
.sidebar-search input::placeholder { color: #747f93; }
.sidebar-search input::-webkit-search-cancel-button { filter: invert(1); opacity: .55; }
.sidebar-section-heading { display: flex; align-items: center; justify-content: space-between; padding: 8px 20px 7px; color: #7d8799; font-size: 10px; font-weight: 650; letter-spacing: .11em; text-transform: uppercase; }
.sidebar-section-dot { width: 3px; height: 3px; border-radius: 50%; background: var(--surface2); box-shadow: 6px 0 var(--surface2), 12px 0 var(--surface2); margin-right: 12px; }
.conv-list-container { min-height: 0; flex: 1; overflow-y: auto; padding: 3px 10px 16px; }
.conv-list { display: flex; flex-direction: column; gap: 3px; }
.conv-item {
    position: relative;
    display: flex;
    min-height: 43px;
    align-items: center;
    padding: 0 6px 0 0;
    border: 1px solid transparent;
    border-radius: 11px;
    background: transparent;
    transition: background 140ms ease, border-color 140ms ease, transform 140ms ease;
}
.conv-item:hover { background: rgba(255,255,255,.04); }
.conv-item.active { border-color: rgba(139,124,255,.16); background: linear-gradient(90deg, rgba(139,124,255,.15), rgba(139,124,255,.055)); }
.conv-item.active::before { position: absolute; inset: 9px auto 9px -1px; width: 2px; border-radius: 99px; background: var(--lavender); box-shadow: 0 0 11px var(--blue); content: ''; }
.conv-select-btn { display: flex; min-width: 0; min-height: 41px; flex: 1; align-items: center; padding: 0 6px 0 12px; border: 0; border-radius: 10px; background: transparent; color: inherit; cursor: pointer; font: inherit; text-align: left; }
.conv-select-btn:active { transform: scale(.985); }
.conv-title { min-width: 0; flex: 1; overflow: hidden; color: var(--subtext1); font-size: 12.5px; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.conv-item.active .conv-title { color: var(--text); }
.delete-conv-btn {
    display: grid;
    width: 28px;
    height: 28px;
    flex: 0 0 28px;
    place-items: center;
    margin-right: -6px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--subtext0);
    cursor: pointer;
    font-size: 18px;
    opacity: 0;
    transition: color 120ms ease, background 120ms ease, opacity 120ms ease;
}
.conv-item:hover .delete-conv-btn, .conv-item:focus-within .delete-conv-btn { opacity: 1; }
.delete-conv-btn:hover { background: rgba(255,120,138,.12); color: var(--red); }
.conversation-empty { padding: 32px 12px; color: var(--subtext0); font-size: 12px; line-height: 1.6; text-align: center; }
.sidebar-footer { display: flex; min-height: 46px; align-items: center; gap: 8px; padding: 0 18px; border-top: 1px solid var(--border); color: #778296; font-size: 10.5px; }
.privacy-indicator { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 9px rgba(97,208,149,.5); }

.main-content { position: relative; display: flex; min-width: 0; flex: 1; flex-direction: column; overflow: hidden; background: transparent; }
.top-bar {
    position: relative;
    z-index: 15;
    display: grid;
    min-height: 66px;
    flex: 0 0 66px;
    grid-template-columns: minmax(150px, 1fr) minmax(380px, auto) minmax(150px, 1fr);
    align-items: center;
    gap: 16px;
    padding: 0 20px;
    border-bottom: 1px solid var(--border);
    background: rgba(11, 15, 24, .78);
    backdrop-filter: blur(18px);
}
.top-bar-left, .top-bar-right, .top-bar-center { display: flex; min-width: 0; align-items: center; }
.top-bar-left { gap: 10px; }
.top-bar-center { justify-content: center; gap: 7px; }
.top-bar-right { justify-content: flex-end; gap: 6px; }
.conversation-context { display: flex; min-width: 0; flex-direction: column; gap: 2px; }
.conversation-context-label, .toolbar-field-label { color: #778296; font-size: 9px; font-weight: 650; letter-spacing: .08em; text-transform: uppercase; }
.conversation-context-title { max-width: 220px; overflow: hidden; font-size: 13px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.toolbar-field {
    position: relative;
    display: flex;
    min-width: 0;
    height: 38px;
    flex-direction: column;
    justify-content: center;
    gap: 0;
    padding: 3px 28px 3px 11px;
    border: 1px solid rgba(255,255,255,.075);
    border-radius: 12px;
    background: rgba(7,11,19,.52);
    box-shadow: inset 0 1px rgba(255,255,255,.025);
    transition: border-color 140ms ease, background 140ms ease, box-shadow 140ms ease;
}
.toolbar-field:hover { border-color: rgba(255,255,255,.13); background: rgba(255,255,255,.04); }
.toolbar-field:focus-within { border-color: rgba(139,124,255,.28); background: rgba(139,124,255,.09); box-shadow: 0 0 0 2px rgba(139,124,255,.06); }
.platform-select-wrapper { width: 144px; margin: 0; }
.model-select-wrapper { width: clamp(170px, 20vw, 260px); }
.system-prompt-wrapper { width: 156px; margin: 0; }
.select-menu {
    width: 100%;
    min-width: 0;
    border: 0;
    outline: 0;
    appearance: none;
    background: transparent;
    color: var(--text);
    color-scheme: dark;
    cursor: pointer;
    font-family: var(--font-sans);
    font-size: 11.75px;
    font-weight: 560;
    line-height: 17px;
    text-overflow: ellipsis;
}
.select-menu option, .select-menu optgroup { background: #151c2a; color: var(--text); font-size: 12px; }
.model-select-native { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); opacity: 0; pointer-events: none; }
.model-select-wrapper > .toolbar-field-label { position: absolute; top: 4px; left: 11px; pointer-events: none; }
.model-picker-trigger {
    position: absolute;
    inset: 0;
    width: 100%;
    min-width: 0;
    overflow: hidden;
    border: 0;
    outline: 0;
    padding: 16px 28px 3px 11px;
    background: transparent;
    color: var(--text);
    cursor: pointer;
    font-family: var(--font-sans);
    font-size: 11.75px;
    font-weight: 560;
    line-height: 17px;
    text-align: left;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.model-picker-trigger:disabled { color: var(--subtext0); cursor: wait; }
.model-picker-trigger > span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.model-picker-panel {
    position: fixed;
    z-index: 120;
    display: flex;
    max-height: min(430px, calc(100vh - 16px));
    flex-direction: column;
    gap: 7px;
    padding: 8px;
    border: 1px solid rgba(255,255,255,.11);
    border-radius: 13px;
    background: rgba(18,24,36,.98);
    box-shadow: 0 20px 55px rgba(0,0,0,.42), inset 0 1px rgba(255,255,255,.035);
    backdrop-filter: blur(18px);
}
.model-picker-search {
    display: flex;
    min-height: 36px;
    align-items: center;
    gap: 8px;
    padding: 0 10px;
    border: 1px solid rgba(255,255,255,.09);
    border-radius: 9px;
    background: rgba(4,8,15,.62);
}
.model-picker-search:focus-within { border-color: rgba(139,124,255,.42); box-shadow: 0 0 0 2px rgba(139,124,255,.08); }
.model-picker-search svg { width: 15px; height: 15px; flex: 0 0 15px; fill: none; stroke: var(--subtext0); stroke-linecap: round; stroke-width: 1.7; }
.model-picker-search input {
    width: 100%;
    min-width: 0;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--text);
    font-family: var(--font-sans);
    font-size: 12px;
}
.model-picker-search input::placeholder { color: #6f7b8f; }
.model-picker-search input::-webkit-search-cancel-button { cursor: pointer; filter: invert(.72); }
.model-picker-results { min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; }
.model-picker-option {
    display: flex;
    width: 100%;
    min-height: 40px;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    border: 0;
    border-radius: 8px;
    padding: 6px 9px;
    background: transparent;
    color: var(--text);
    cursor: pointer;
    font-family: var(--font-sans);
    text-align: left;
}
.model-picker-option:hover, .model-picker-option:focus-visible { outline: 0; background: rgba(139,124,255,.11); }
.model-picker-option[aria-selected="true"] { background: rgba(139,124,255,.16); }
.model-picker-option-text { display: flex; min-width: 0; flex-direction: column; gap: 1px; }
.model-picker-option-label, .model-picker-option-id { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.model-picker-option-label { font-size: 12.5px; font-weight: 590; }
.model-picker-option-id { color: var(--subtext0); font-family: var(--font-mono); font-size: 10px; }
.model-picker-option-check { color: var(--lavender); font-size: 13px; opacity: 0; }
.model-picker-option[aria-selected="true"] .model-picker-option-check { opacity: 1; }
.model-picker-empty { padding: 24px 12px; color: var(--subtext0); font-size: 12px; text-align: center; }
.toolbar-field::after { position: absolute; right: 11px; bottom: 13px; width: 6px; height: 6px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; color: #8792a6; content: ''; pointer-events: none; transform: rotate(45deg); transition: color 140ms ease, transform 140ms ease; }
.toolbar-field:focus-within::after { color: var(--lavender); }
.model-select-wrapper::after { right: 24px; }
.status-led { position: absolute; right: 10px; bottom: 14px; width: 6px; height: 6px; border: 1px solid rgba(255,255,255,.18); border-radius: 50%; background: var(--peach); pointer-events: none; }
.status-led.online { background: var(--green); box-shadow: 0 0 7px rgba(97,208,149,.6); }
.toolbar-divider { width: 1px; height: 24px; margin: 0 3px; background: var(--border); }
.icon-btn {
    display: inline-grid;
    width: 38px;
    height: 38px;
    flex: 0 0 38px;
    place-items: center;
    border: 1px solid rgba(255,255,255,.065);
    border-radius: 11px;
    background: rgba(255,255,255,.018);
    color: var(--subtext0);
    cursor: pointer;
    line-height: 1;
    transition: color 130ms ease, background 130ms ease, border-color 130ms ease, transform 130ms ease;
}
.icon-btn svg { width: 18px; height: 18px; overflow: visible; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.icon-btn:hover { border-color: var(--border-strong); background: rgba(255,255,255,.055); color: var(--text); }
.icon-btn:active { transform: scale(.94); }
.icon-btn.active, #web-search-btn.active { border-color: rgba(139,124,255,.28); background: rgba(139,124,255,.13); color: var(--lavender); box-shadow: inset 0 0 0 1px rgba(139,124,255,.04); }
.danger-icon-btn:hover { border-color: rgba(255,120,138,.18); background: rgba(255,120,138,.1); color: var(--red); }
.sidebar-toggle-btn { display: none; }
.sidebar-overlay { display: none; }

/* Conversation */
.chat-stage { position: relative; min-height: 0; flex: 1; }
.chat-viewport { height: 100%; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 32px 0 24px; scroll-behavior: auto; }
.scroll-to-bottom-btn { position: absolute; right: 22px; bottom: 18px; z-index: 13; display: grid; width: 38px; height: 38px; place-items: center; border: 1px solid var(--border-strong); border-radius: 12px; background: rgba(26,34,50,.94); box-shadow: var(--shadow-sm); color: var(--subtext1); cursor: pointer; font-size: 18px; backdrop-filter: blur(12px); transition: background 130ms ease, color 130ms ease, transform 130ms ease; }
.scroll-to-bottom-btn:hover { background: var(--surface1); color: var(--text); transform: translateY(-1px); }
.chat-empty-state { display: flex; width: min(760px, calc(100% - 48px)); min-height: min(520px, 70vh); align-items: center; justify-content: center; flex-direction: column; margin: 0 auto; padding: 42px 0 28px; text-align: center; animation: message-in 320ms var(--ease-out) both; }
.empty-state-mark { display: grid; width: 48px; height: 48px; place-items: center; margin-bottom: 18px; border: 1px solid rgba(255,255,255,.15); border-radius: 16px; background: linear-gradient(145deg,#9d91ff,#6857df); box-shadow: 0 14px 34px rgba(104,87,223,.28), inset 0 1px rgba(255,255,255,.3); color: #fff; font-family: var(--font-title); font-size: 21px; font-weight: 700; }
.empty-state-eyebrow { margin-bottom: 8px; color: #8174e7; font-size: 9px; font-weight: 700; letter-spacing: .13em; text-transform: uppercase; }
.chat-empty-state h1 { color: var(--text); font-family: var(--font-title); font-size: clamp(27px,3.3vw,38px); font-weight: 560; letter-spacing: -.035em; line-height: 1.18; }
.chat-empty-state > p { max-width: 540px; margin-top: 11px; color: var(--subtext0); font-size: 13px; line-height: 1.65; }
.prompt-suggestions { display: grid; width: min(620px,100%); grid-template-columns: repeat(2,minmax(0,1fr)); gap: 9px; margin-top: 28px; }
.prompt-suggestion { display: flex; min-height: 46px; align-items: center; justify-content: space-between; gap: 12px; padding: 0 14px; border: 1px solid var(--border); border-radius: 12px; background: rgba(255,255,255,.022); color: var(--subtext1); cursor: pointer; font-size: 11.5px; text-align: left; transition: border-color 140ms ease, background 140ms ease, color 140ms ease, transform 140ms ease; }
.prompt-suggestion span { color: #7467dc; font-size: 14px; }
.prompt-suggestion:hover { border-color: rgba(139,124,255,.3); background: rgba(139,124,255,.07); color: var(--text); transform: translateY(-1px); }
.message-list { display: flex; width: min(900px, calc(100% - 48px)); flex-direction: column; gap: 24px; margin: 0 auto; }
.load-older-messages-btn { align-self: center; padding: 8px 14px; border: 1px solid var(--border-strong); border-radius: 999px; background: var(--surface0); color: var(--subtext1); cursor: pointer; font-size: 12px; transition: all 140ms ease; }
.load-older-messages-btn:hover { border-color: rgba(139,124,255,.55); color: var(--text); transform: translateY(-1px); }
.message-row { display: flex; width: 100%; animation: message-in 260ms var(--ease-out) both; }
.message-row.user { justify-content: flex-end; }
.message-row.assistant { justify-content: flex-start; }
.message-card { min-width: 0; max-width: min(78%, 690px); padding: 14px 16px; border-radius: 18px; }
.message-row.user .message-card { border: 1px solid var(--user-border); border-bottom-right-radius: 6px; background: linear-gradient(145deg, rgba(51,47,116,.95), rgba(36,33,83,.96)); box-shadow: 0 12px 34px rgba(0,0,0,.14); }
.message-row.assistant .message-card { width: min(100%, 820px); max-width: 100%; padding: 0 2px; }
.message-header { display: flex; min-height: 24px; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 7px; }
.sender-info { display: flex; align-items: center; gap: 7px; color: var(--subtext1); font-size: 11.5px; font-weight: 650; }
.sender-info::before { display: grid; width: 18px; height: 18px; place-items: center; border: 1px solid var(--border); border-radius: 6px; background: var(--surface0); color: var(--subtext1); content: 'AI'; font-family: var(--font-title); font-size: 7px; font-weight: 700; letter-spacing: -.02em; }
.sender-info[data-role='user']::before { background: rgba(175,165,255,.13); color: #c8c1ff; content: 'Y'; font-size: 8px; }
.message-row.user .sender-info { color: #c3bcff; }
.message-row.assistant .sender-info { color: var(--mauve); }
.meta-info { display: flex; min-width: 0; align-items: center; gap: 2px; color: #778296; font-size: 10.5px; }
.copy-btn { display: grid; width: 27px; height: 27px; place-items: center; margin-left: 0 !important; border: 0; border-radius: 7px; background: transparent; color: var(--subtext0); cursor: pointer; font-size: 11px; opacity: .24; transition: opacity 120ms ease, color 120ms ease, background 120ms ease; }
.message-card:hover .copy-btn, .copy-btn:focus-visible { opacity: 1; }
.copy-btn:hover { background: var(--surface0); color: var(--text); }
.message-body { overflow-wrap: anywhere; color: #e4e8f0; font-size: 14px; line-height: 1.72; }
.message-body.plain-text { white-space: pre-wrap; }
.message-body.message-error { color: var(--red); }
.message-body > :first-child { margin-top: 0 !important; }
.message-body > :last-child { margin-bottom: 0 !important; }
.message-body p { margin: 0 0 10px; }
.message-body h1, .message-body h2, .message-body h3 { margin: 20px 0 10px; color: var(--text); font-family: var(--font-title); line-height: 1.25; }
.message-body h1 { font-size: 23px; } .message-body h2 { font-size: 19px; } .message-body h3 { font-size: 16px; }
.message-body a { color: #a99dff; text-decoration-color: rgba(169,157,255,.4); text-underline-offset: 3px; }
.message-body a:hover { text-decoration-color: currentColor; }
.message-body strong { color: var(--text); }
.message-body ul, .message-body ol { margin: 8px 0 10px 22px; }
.message-body li { margin: 3px 0; }
.message-body blockquote { margin: 12px 0; padding: 4px 0 4px 14px; border-left: 2px solid var(--mauve); color: var(--subtext1); }
.message-body hr { margin: 20px 0; border: 0; border-top: 1px solid var(--border); }
.message-body code { padding: 2px 5px; border: 1px solid var(--border); border-radius: 6px; background: var(--crust); color: #efb995; font-family: var(--font-mono); font-size: .88em; }
.message-body pre { position: relative; max-width: 100%; overflow: auto; margin: 14px 0; padding-top: 34px; border: 1px solid var(--border); border-radius: 13px; background: #090d15; box-shadow: inset 0 1px rgba(255,255,255,.02); }
.message-body pre code { display: block; min-width: max-content; padding: 15px; border: 0; background: transparent; color: var(--text); font-size: 12px; line-height: 1.62; }
.code-header { position: absolute; inset: 0 0 auto; display: flex; height: 34px; align-items: center; justify-content: space-between; padding: 0 11px; border-bottom: 1px solid var(--border); border-radius: 13px 13px 0 0; background: #101621; color: var(--subtext0); font-family: var(--font-sans); font-size: 10.5px; }
.code-header-actions { display: flex; gap: 8px; }
.code-copy-btn, .code-save-btn, .code-run-btn { border: 0; background: transparent; color: var(--subtext0); cursor: pointer; font-size: 10.5px; }
.code-copy-btn:hover, .code-save-btn:hover, .code-run-btn:hover { color: var(--text); }
.message-body table { display: block; width: 100%; overflow-x: auto; margin: 14px 0; border-collapse: collapse; font-size: 12.5px; }
.message-body th, .message-body td { min-width: 110px; padding: 9px 11px; border: 1px solid var(--border); text-align: left; }
.message-body th { background: var(--mantle); color: var(--text); }
.message-body img { display: block; max-width: 100%; max-height: 440px; margin: 12px 0; border: 1px solid var(--border); border-radius: 13px; cursor: zoom-in; object-fit: contain; transition: opacity 140ms ease, transform 140ms ease; }
.message-body img:hover { opacity: .9; transform: scale(.995); }

.thinking-container { max-width: 100%; overflow: hidden; margin: 3px 0 12px; border: 1px solid var(--thinking-border); border-radius: 12px; background: var(--thinking-bg); }
.thinking-toggle { width: 100%; padding: 9px 12px; border: 0; background: transparent; color: #b8aaff; cursor: pointer; font-size: 11px; font-weight: 600; text-align: left; }
.thinking-toggle:hover { background: rgba(139,124,255,.075); }
.thinking-box { max-height: 240px; overflow: auto; padding: 11px 12px; border-top: 1px solid var(--thinking-border); background: var(--thinking-box-bg); color: var(--subtext1); font-family: var(--font-mono); font-size: 11px; line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; }

/* Attachments */
.message-attachments { display: grid; width: min(360px, 70vw); max-width: 100%; gap: 8px; margin: 10px 0 2px; }
.attachment-card-shell { display: flex; min-width: 0; align-items: stretch; gap: 7px; }
.message-attachment-shell, .composer-attachment { width: 100%; }
.message-attachment { display: flex; width: 100%; min-width: 0; align-items: center; gap: 10px; padding: 9px 10px; border: 1px solid var(--border); border-radius: 12px; background: rgba(17,23,36,.9); color: inherit; text-align: left; }
.message-attachment.is-previewable { cursor: pointer; transition: border-color 150ms ease, background 150ms ease, transform 150ms ease; }
.message-attachment.is-previewable:hover { border-color: rgba(139,124,255,.5); background: var(--surface0); transform: translateY(-1px); }
.message-attachment-icon { display: grid; width: 38px; height: 38px; flex: 0 0 38px; place-items: center; border-radius: 10px; background: var(--surface0); color: var(--subtext1); font-family: var(--font-mono); font-size: 9px; font-weight: 700; }
.message-attachment-icon.kind-image { background: rgba(97,208,149,.12); color: var(--green); }
.message-attachment-icon.kind-document { background: rgba(255,120,138,.12); color: var(--red); }
.message-attachment-icon.kind-code { background: rgba(139,124,255,.13); color: var(--lavender); }
.message-attachment-icon.kind-text { background: rgba(244,200,119,.12); color: var(--yellow); }
.message-attachment-details { display: flex; min-width: 0; flex: 1; flex-direction: column; gap: 2px; }
.message-attachment-name, .message-attachment-meta { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.message-attachment-name { color: var(--text); font-size: 12px; font-weight: 600; }
.message-attachment-meta { color: var(--subtext0); font-size: 10.5px; }
.message-attachment-arrow { color: var(--overlay1); font-size: 20px; }
.remove-att-btn { width: 36px; flex: 0 0 36px; border: 1px solid var(--border); border-radius: 11px; background: var(--mantle); color: var(--subtext0); cursor: pointer; font-size: 18px; }
.remove-att-btn:hover { border-color: rgba(255,120,138,.4); background: rgba(255,120,138,.1); color: var(--red); }

/* Composer */
.input-section { position: relative; z-index: 12; display: flex; width: min(900px, calc(100% - 48px)); flex: 0 0 auto; flex-direction: column; gap: 8px; margin: 0 auto; padding: 8px 0 max(18px, env(safe-area-inset-bottom)); }
.input-section::before { position: fixed; right: 0; bottom: 0; left: 264px; z-index: -1; height: 116px; background: linear-gradient(transparent, var(--base) 48%); content: ''; pointer-events: none; }
.attachments-area { display: grid; max-height: 160px; overflow-y: auto; grid-template-columns: repeat(auto-fill, minmax(min(260px,100%),320px)); gap: 8px; padding: 2px 0; }
.composer-attachment .message-attachment { padding: 7px 9px; }
.composer-attachment .message-attachment-icon { width: 34px; height: 34px; flex-basis: 34px; }
.input-capsule { display: flex; min-height: 58px; align-items: flex-end; gap: 9px; padding: 10px; border: 1px solid var(--border-strong); border-radius: 18px; background: rgba(19,25,39,.95); box-shadow: 0 15px 44px rgba(0,0,0,.26), inset 0 1px rgba(255,255,255,.025); transition: border-color 160ms ease, box-shadow 160ms ease; }
.input-capsule:focus-within { border-color: rgba(139,124,255,.65); box-shadow: 0 15px 44px rgba(0,0,0,.28), 0 0 0 3px rgba(139,124,255,.08); }
.input-action-btn { display: grid; width: 38px; height: 38px; flex: 0 0 38px; place-items: center; border: 1px solid transparent; border-radius: 11px; background: transparent; color: var(--subtext0); cursor: pointer; font-size: 22px; font-weight: 300; transition: all 130ms ease; }
.input-action-btn:hover { border-color: var(--border); background: var(--surface0); color: var(--text); }
.input-box { min-height: 38px; max-height: 190px; flex: 1; resize: none; overflow-y: auto; padding: 8px 4px 4px; border: 0; background: transparent; color: var(--text); font-size: 14px; line-height: 22px; }
.input-box::placeholder { color: #778296; }
.markdown-switch { display: flex; height: 38px; flex: 0 0 auto; align-items: center; gap: 6px; padding: 0 4px; color: var(--subtext0); cursor: pointer; font-size: 10px; user-select: none; }
.markdown-switch input { position: absolute; width: 1px; height: 1px; overflow: hidden; opacity: 0; pointer-events: none; }
.markdown-switch-track { position: relative; width: 27px; height: 16px; flex: 0 0 27px; border: 1px solid var(--border-strong); border-radius: 999px; background: var(--surface0); transition: border-color 140ms ease, background 140ms ease; }
.markdown-switch-track span { position: absolute; top: 2px; left: 2px; width: 10px; height: 10px; border-radius: 50%; background: var(--subtext0); transition: transform 140ms ease, background 140ms ease; }
.markdown-switch input:checked + .markdown-switch-track { border-color: rgba(139,124,255,.7); background: rgba(139,124,255,.32); }
.markdown-switch input:checked + .markdown-switch-track span { background: #d8d3ff; transform: translateX(11px); }
.markdown-switch input:focus-visible + .markdown-switch-track { outline: 2px solid var(--lavender); outline-offset: 2px; }
.markdown-switch:has(input:checked) .markdown-switch-label { color: var(--text); }
.send-btn { display: grid; width: 38px; height: 38px; flex: 0 0 38px; place-items: center; border: 0; border-radius: 12px; background: linear-gradient(145deg, #9b8dff, #7563ed); box-shadow: 0 7px 18px rgba(110,92,232,.32); color: #fff; cursor: pointer; transition: filter 130ms ease, transform 130ms ease, box-shadow 130ms ease; }
.send-btn:hover { filter: brightness(1.08); transform: translateY(-1px); box-shadow: 0 10px 24px rgba(110,92,232,.4); }
.send-btn:active { transform: scale(.95); }
.send-btn:disabled { background: var(--surface1); box-shadow: none; color: var(--subtext0); }
.send-btn.stop-active { background: var(--red) !important; color: #fff !important; }
.send-icon { font-size: 19px; font-weight: 600; line-height: 1; }
.composer-meta { display: flex; min-height: 18px; align-items: center; justify-content: space-between; gap: 12px; padding: 0 4px; }
.composer-meta-right { display: flex; align-items: center; gap: 14px; }
.status-label { display: flex; min-width: 0; align-items: center; gap: 7px; overflow: hidden; color: #7d899c; font-size: 10.5px; text-overflow: ellipsis; white-space: nowrap; }
.status-label::before { width: 5px; height: 5px; flex: 0 0 5px; border-radius: 50%; background: var(--green); box-shadow: 0 0 7px rgba(97,208,149,.45); content: ''; }
.token-label { color: #7d899c; font-family: var(--font-mono); font-size: 9.5px; }
.composer-shortcut { display: flex; align-items: center; gap: 4px; color: #707b8e; font-size: 9.5px; }
kbd { min-width: 22px; padding: 2px 5px; border: 1px solid var(--border); border-bottom-color: rgba(255,255,255,.17); border-radius: 5px; background: var(--mantle); color: var(--subtext0); font-family: var(--font-sans); font-size: 9px; text-align: center; }

/* Buttons and controls */
.btn { display: inline-flex; min-height: 36px; align-items: center; justify-content: center; border: 1px solid transparent; border-radius: 10px; padding: 7px 13px; cursor: pointer; font-size: 12px; font-weight: 650; transition: background 130ms ease, border-color 130ms ease, color 130ms ease, transform 100ms ease; }
.btn:active { transform: scale(.975); }
.btn-primary { border-color: rgba(255,255,255,.1); background: linear-gradient(145deg,#9688ff,#725fe9); color: #fff; }
.btn-primary:hover { filter: brightness(1.07); }
.btn-secondary { border-color: var(--border); background: var(--surface0); color: var(--subtext1); }
.btn-secondary:hover { border-color: var(--border-strong); background: var(--surface1); color: var(--text); }
.btn-danger { border-color: rgba(255,255,255,.08); background: var(--red); color: #171019; }
.btn-danger:hover { filter: brightness(1.07); }
.btn-sm { min-height: 30px; padding: 4px 9px; border-radius: 8px; font-size: 11px; }
.btn-capsule { border-radius: 999px; }

/* Settings and dialogs */
.modal-overlay { position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center; padding: 20px; background: rgba(3,6,11,.72); backdrop-filter: blur(14px); animation: overlay-in 180ms ease both; }
.modal-overlay.hidden { display: none; }
.modal-card { display: flex; width: min(500px, 100%); max-height: calc(100vh - 40px); max-height: calc(100dvh - 40px); flex-direction: column; overflow: hidden; border: 1px solid var(--border-strong); border-radius: 18px; background: #111722; box-shadow: var(--shadow-lg); animation: modal-in 240ms var(--ease-out) both; }
.modal-header { display: flex; min-height: 64px; flex: 0 0 auto; align-items: center; justify-content: space-between; gap: 18px; padding: 15px 18px; border-bottom: 1px solid var(--border); background: rgba(255,255,255,.018); }
.modal-heading { display: flex; min-width: 0; flex-direction: column; gap: 2px; }
.modal-eyebrow { color: #8174e7; font-size: 9px; font-weight: 700; letter-spacing: .11em; text-transform: uppercase; }
.modal-header h2 { color: var(--text); font-family: var(--font-title); font-size: 16px; font-weight: 650; }
.modal-heading p { color: var(--subtext0); font-size: 11px; }
.close-modal-btn, .attachment-preview-close-btn { display: grid; width: 36px; height: 36px; flex: 0 0 36px; place-items: center; border: 1px solid transparent; border-radius: 10px; background: transparent; color: var(--subtext0); cursor: pointer; font-size: 22px; line-height: 1; transition: all 130ms ease; }
.close-modal-btn:hover, .attachment-preview-close-btn:hover { border-color: rgba(255,120,138,.16); background: rgba(255,120,138,.09); color: var(--red); }
.modal-body { display: flex; min-height: 0; flex: 1; flex-direction: column; gap: 14px; overflow-y: auto; padding: 18px; }
.modal-footer { display: flex; min-height: 62px; flex: 0 0 auto; align-items: center; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--border); background: rgba(255,255,255,.018); }
.modal-footer-leading { margin-right: auto; }
.delete-card { width: min(430px,100%); }
#image-modal .modal-card { border: 0; }
.auth-overlay { z-index: 10005; }
.auth-card { width: min(410px, 100%); }
.auth-modal-body { gap: 16px; padding: 20px; }
.auth-description { color: var(--subtext1); font-size: 12px; line-height: 1.65; }
.auth-error { display: none; color: var(--red); font-size: 11px; }
.auth-footer { padding: 12px 18px; }
.auth-footer .btn { width: 100%; min-height: 42px; }

.settings-modal-card { width: min(1040px, calc(100vw - 40px)); height: min(820px, calc(100vh - 40px)); height: min(820px, calc(100dvh - 40px)); }
.settings-modal-card > .modal-header { min-height: 78px; padding: 15px 22px; }
.settings-modal-body { display: grid; min-height: 0; grid-template-columns: 200px minmax(0,1fr); gap: 0; padding: 0; overflow: hidden; }
.settings-nav { display: flex; min-height: 0; flex-direction: column; gap: 4px; overflow-y: auto; padding: 15px 10px; border-right: 1px solid var(--border); background: rgba(7,11,18,.35); }
.settings-nav-item { display: flex; min-height: 49px; align-items: center; gap: 10px; padding: 7px 10px; border: 1px solid transparent; border-radius: 11px; background: transparent; color: var(--subtext0); cursor: pointer; text-align: left; transition: all 130ms ease; }
.settings-nav-item:hover { background: rgba(255,255,255,.035); color: var(--subtext1); }
.settings-nav-item.active { border-color: rgba(139,124,255,.16); background: rgba(139,124,255,.11); color: var(--text); }
.settings-nav-icon { display: grid; width: 28px; height: 28px; flex: 0 0 28px; place-items: center; border-radius: 8px; background: rgba(255,255,255,.035); color: var(--subtext0); font-size: 13px; }
.settings-nav-item.active .settings-nav-icon { background: rgba(139,124,255,.17); color: var(--lavender); }
.settings-nav-item > span:last-child { display: flex; min-width: 0; flex-direction: column; gap: 2px; }
.settings-nav-item strong { color: inherit; font-size: 11.5px; font-weight: 600; }
.settings-nav-item small { color: #707b8f; font-size: 9.5px; }
.settings-content { min-height: 0; overflow-y: auto; padding: 20px 22px 30px; scroll-behavior: smooth; }
.settings-section-card { display: flex; flex-direction: column; gap: 14px; margin-bottom: 18px; padding: 18px; border: 1px solid var(--border); border-radius: 15px; background: rgba(255,255,255,.018); scroll-margin-top: 18px; }
.settings-section-card:last-child { margin-bottom: 0; }
.settings-section-header { display: flex; min-height: 42px; align-items: flex-start; justify-content: space-between; gap: 14px; padding-bottom: 12px; border-bottom: 1px solid var(--border); }
.settings-section-header-wrap { flex-wrap: wrap; }
.settings-section-kicker { display: block; margin-bottom: 3px; color: #8174e7; font-size: 8.5px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }
.settings-section-title { color: var(--text); font-size: 14px; font-weight: 650; }
.settings-section-badge { padding: 4px 8px; border: 1px solid rgba(97,208,149,.18); border-radius: 999px; background: rgba(97,208,149,.08); color: var(--green); font-size: 9.5px; }
.platform-tabs { display: flex; gap: 4px; padding: 4px; border: 1px solid var(--border); border-radius: 11px; background: var(--crust); }
.platform-tabs .tab-btn { min-height: 34px; flex: 1; padding: 5px 10px; border: 1px solid transparent; border-radius: 8px; background: transparent !important; color: var(--subtext0) !important; cursor: pointer; font-size: 11.5px; transition: all 130ms ease; }
.platform-tabs .tab-btn:hover { color: var(--text) !important; }
.platform-tabs .tab-btn.active { border-color: var(--border); background: var(--surface0) !important; box-shadow: var(--shadow-sm); color: var(--text) !important; }
.platform-panel { display: flex; flex-direction: column; gap: 12px; }
.form-group { display: flex; flex-direction: column; gap: 7px; }
.form-group label { color: var(--subtext1); font-size: 11.5px; font-weight: 500; line-height: 1.5; }
.form-group input[type='text'], .form-group input[type='number'], .form-group input[type='password'], .form-group select, #preset-content-input {
    width: 100% !important;
    min-height: 40px;
    padding: 8px 11px !important;
    border: 1px solid var(--border) !important;
    border-radius: 10px !important;
    background-color: var(--crust) !important;
    color: var(--text) !important;
    font-size: 12px !important;
    transition: border-color 130ms ease, box-shadow 130ms ease;
}
.form-group input:focus, .form-group select:focus, #preset-content-input:focus { border-color: rgba(139,124,255,.65) !important; box-shadow: 0 0 0 3px rgba(139,124,255,.08); }
.form-group input::placeholder, #preset-content-input::placeholder { color: #667286; }
.form-group select {
    padding-right: 34px !important;
    appearance: none;
    color-scheme: dark;
    cursor: pointer;
    background-image: linear-gradient(45deg, transparent 50%, #8792a6 50%), linear-gradient(135deg, #8792a6 50%, transparent 50%) !important;
    background-position: calc(100% - 15px) 17px, calc(100% - 10px) 17px !important;
    background-repeat: no-repeat !important;
    background-size: 5px 5px, 5px 5px !important;
}
.form-group select:hover { background-color: rgba(15,21,32,.98) !important; }
.form-group select option, .form-group select optgroup { background: #151c2a; color: var(--text); }
.form-group input[type='checkbox'], .radio-label input[type='radio'] { width: 16px !important; height: 16px !important; flex: 0 0 16px; accent-color: var(--blue); cursor: pointer; }
.input-row { display: flex; gap: 8px; }
.input-row input { min-width: 0; flex: 1; }
.radio-group { display: flex; flex-wrap: wrap; gap: 12px; }
.radio-column { display: flex; flex-direction: column; gap: 9px; }
.radio-label { display: flex; align-items: center; gap: 7px; color: var(--text); cursor: pointer; font-size: 12px; }
input[type='range'] { width: 100%; height: 5px; appearance: none; border-radius: 999px; background: var(--surface1); accent-color: var(--blue); }
input[type='range']::-webkit-slider-thumb { width: 17px; height: 17px; appearance: none; border: 3px solid var(--mantle); border-radius: 50%; background: var(--lavender); box-shadow: 0 0 0 1px var(--blue); cursor: pointer; }
.preset-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 7px; padding: 9px 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface0); font-size: 12px; }
.preset-info { display: flex; min-width: 0; max-width: 72%; flex-direction: column; gap: 2px; }
.preset-name { color: var(--text); font-weight: 600; }
.preset-desc { overflow: hidden; color: var(--subtext0); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.preset-actions { display: flex; gap: 5px; }
.preset-actions button { border: 0; background: transparent; cursor: pointer; }

/* Context, drag/drop and tool cards */
.context-menu { position: fixed; z-index: 10000; display: flex; min-width: 220px; flex-direction: column; gap: 2px; padding: 6px; border: 1px solid var(--border-strong); border-radius: 13px; background: var(--mantle); box-shadow: var(--shadow-lg); backdrop-filter: blur(18px); }
.context-menu-item { min-height: 36px; padding: 7px 10px; border: 0; border-radius: 8px; background: transparent; color: var(--subtext1); cursor: pointer; font-size: 12px; text-align: left; }
.context-menu-item:hover { background: var(--surface0); color: var(--text); }
.context-menu-item:disabled { opacity: .4; }
.drag-drop-overlay { position: fixed; inset: 0; z-index: 9999; display: flex; align-items: center; justify-content: center; background: rgba(4,7,12,.78); opacity: 0; backdrop-filter: blur(14px); pointer-events: none; transition: opacity 180ms ease; }
.drag-drop-overlay.active, .drag-drop-overlay:not(.hidden) { opacity: 1; pointer-events: auto; }
.drag-drop-content { width: min(420px, calc(100% - 40px)); padding: 40px 28px; border: 1px dashed rgba(175,165,255,.65); border-radius: 20px; background: var(--mantle); box-shadow: var(--shadow-lg); text-align: center; transform: scale(.97); transition: transform 180ms var(--ease-out); }
.drag-drop-overlay.active .drag-drop-content, .drag-drop-overlay:not(.hidden) .drag-drop-content { transform: scale(1); }
.drag-drop-icon { display: block; margin-bottom: 14px; color: var(--lavender); font-size: 48px; }
.drag-drop-sub { display: block; margin-top: 7px; color: var(--subtext0); font-size: 11px; }
.search-card { max-width: 100%; overflow: hidden; margin: 10px 0 13px; border: 1px solid var(--border); border-radius: 13px; background: rgba(17,23,36,.72); transition: border-color 140ms ease, box-shadow 140ms ease; }
.search-card:hover { border-color: rgba(139,124,255,.3); box-shadow: var(--shadow-sm); }
.search-card-header { display: flex; min-height: 42px; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 12px; background: rgba(255,255,255,.018); color: #aaa0ff; cursor: pointer; font-size: 11.5px; font-weight: 600; user-select: none; }
.search-status-wrapper { display: flex; min-width: 0; align-items: center; gap: 8px; }
.search-radar { width: 14px; height: 14px; flex: 0 0 14px; border: 2px dashed var(--blue); border-radius: 50%; animation: spin 2s linear infinite; }
.search-radar-done { color: var(--green); }
.search-card-toggle-icon { color: var(--subtext0); font-size: 9px; transition: transform 160ms ease; }
.search-card.collapsed .search-card-toggle-icon { transform: rotate(-90deg); }
.search-card.collapsed .search-card-body { display: none; }
.search-card-body { display: flex; max-height: 300px; flex-direction: column; gap: 7px; overflow-y: auto; padding: 10px; border-top: 1px solid var(--border); }
.search-result-item { padding: 8px 9px; border: 1px solid transparent; border-radius: 9px; background: rgba(255,255,255,.02); transition: all 130ms ease; }
.search-result-item:hover { border-color: var(--border); background: var(--surface0); }
.search-result-title { display: flex; align-items: center; gap: 5px; margin-bottom: 3px; color: var(--text); font-size: 11.5px; font-weight: 600; }
.search-result-title a { overflow-wrap: anywhere; text-decoration: none; }
.search-result-title a:hover { color: var(--lavender); text-decoration: underline; }
.search-result-url { display: block; margin-bottom: 4px; color: #748096; font-size: 9.5px; overflow-wrap: anywhere; }
.search-result-snippet { color: var(--subtext1); font-size: 11px; line-height: 1.5; }
.search-engine-info { display: flex; align-items: center; justify-content: flex-end; gap: 6px; margin-top: 4px; padding-top: 7px; border-top: 1px dashed var(--border); color: var(--subtext0); font-size: 10px; }
.search-engine-badge { padding: 2px 6px; border-radius: 5px; background: var(--surface1); color: var(--lavender); font-size: 9px; font-weight: 600; }

/* Artifacts */
.artifacts-panel { position: relative; z-index: 25; display: flex; width: clamp(420px, 36vw, 600px); height: 100%; flex: 0 0 clamp(420px,36vw,600px); flex-direction: column; border-left: 1px solid var(--border); background: var(--mantle); box-shadow: -18px 0 50px rgba(0,0,0,.18); animation: panel-in 220ms var(--ease-out) both; }
.artifacts-panel.collapsed { display: none; }
.artifacts-panel.fullscreen { position: fixed; inset: 0; z-index: 9999; width: 100%; height: 100%; }
.artifacts-header { display: flex; height: 58px; flex: 0 0 58px; align-items: center; justify-content: space-between; padding: 0 15px; border-bottom: 1px solid var(--border); background: var(--crust); }
.artifacts-title, .artifacts-header-actions { display: flex; align-items: center; gap: 8px; }
.artifacts-title { font-family: var(--font-title); font-size: 14px; font-weight: 600; }
.artifacts-icon { color: var(--lavender); }
.artifacts-tabs { display: flex; padding: 5px; border-bottom: 1px solid var(--border); background: var(--crust); }
.artifacts-tab-btn { min-height: 35px; flex: 1; border: 0; border-radius: 8px; background: transparent; color: var(--subtext0); cursor: pointer; font-size: 11.5px; }
.artifacts-tab-btn:hover { background: var(--surface0); color: var(--text); }
.artifacts-tab-btn.active { background: var(--surface0); color: var(--lavender); font-weight: 600; }
.artifacts-body { position: relative; min-height: 0; flex: 1; overflow: hidden; background: var(--base); }
.artifacts-tab-content { display: none; width: 100%; height: 100%; overflow: auto; }
.artifacts-tab-content.active { display: block; }
#artifacts-preview-container { display: flex; width: 100%; height: 100%; flex-direction: column; padding: 16px; background: #fff; color: #222; }
#artifacts-preview-container.svg-mode, #artifacts-preview-container.mermaid-mode { align-items: center; justify-content: center; background: var(--base); color: var(--text); }
#artifacts-preview-container iframe { width: 100%; height: 100%; border: 0; background: #fff; }
#artifacts-code-view { display: block; padding: 16px; font-family: var(--font-mono); font-size: 12px; white-space: pre-wrap; }
.show-artifact-btn { display: inline-flex; align-items: center; gap: 5px; margin-top: 8px; padding: 7px 11px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface0); color: var(--lavender); cursor: pointer; font-size: 11px; }
.show-artifact-btn:hover { background: var(--surface1); color: var(--text); }

/* Attachment preview */
.attachment-preview-dialog { width: min(1080px, calc(100vw - 40px)); height: min(86vh, 820px); height: min(86dvh, 820px); }
.attachment-preview-heading { display: flex; min-width: 0; flex-direction: column; gap: 3px; }
.attachment-preview-heading h2, .attachment-preview-meta { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attachment-preview-meta { color: var(--subtext0); font-size: 10.5px; }
.attachment-preview-status { flex: 0 0 auto; padding: 0 18px; color: var(--subtext0); font-size: 11px; }
.attachment-preview-status:not(:empty) { padding-top: 9px; padding-bottom: 9px; border-bottom: 1px solid var(--border); }
.attachment-preview-status.is-loading::before { display: inline-block; width: 11px; height: 11px; margin-right: 7px; border: 2px solid var(--surface2); border-top-color: var(--blue); border-radius: 50%; content: ''; vertical-align: -1px; animation: spin .8s linear infinite; }
.attachment-preview-status.is-warning { color: var(--yellow); } .attachment-preview-status.is-error { color: var(--red); }
.attachment-preview-body { display: flex; min-height: 0; flex: 1; align-items: center; justify-content: center; overflow: auto; padding: 18px; background: var(--crust); overscroll-behavior: contain; }
html.attachment-preview-open, html.attachment-preview-open body { overflow: hidden; }
.attachment-preview-image { display: block; max-width: 100%; max-height: 100%; border-radius: 12px; box-shadow: var(--shadow-lg); object-fit: contain; }
.attachment-preview-text { width: 100%; min-height: 100%; margin: 0; padding: 16px; overflow: auto; border: 1px solid var(--border); border-radius: 12px; background: var(--mantle); color: var(--text); font-family: var(--font-mono); font-size: 12px; line-height: 1.65; tab-size: 4; white-space: pre-wrap; overflow-wrap: anywhere; }
.attachment-preview-text.is-code { background: #090d15; white-space: pre; overflow-wrap: normal; }
.attachment-preview-text.is-code code.hljs { display: block; min-width: max-content; padding: 0; overflow: visible; background: transparent; }
.preset-modal-overlay { z-index: 10001; }
.attachment-preview-overlay { z-index: 10004; }
.image-modal-overlay { z-index: 10003; }
.preset-content-input { width: 100%; min-height: 150px; resize: vertical; }
.image-preview-card { display: flex; width: min(1100px, 94vw); max-width: 94vw; max-height: 92vh; align-items: center; flex-direction: column; border: 0; background: transparent; box-shadow: none; }
.image-preview-actions { display: flex; width: 100%; justify-content: flex-end; gap: 8px; margin-bottom: 10px; }
.preview-image { max-width: 100%; max-height: 80vh; border-radius: 12px; box-shadow: 0 20px 55px rgba(0,0,0,.5); object-fit: contain; }

@keyframes message-in { from { opacity: 0; transform: translateY(8px); } }
@keyframes modal-in { from { opacity: 0; transform: translateY(12px) scale(.975); } }
@keyframes overlay-in { from { opacity: 0; } }
@keyframes panel-in { from { opacity: 0; transform: translateX(18px); } }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 1260px) {
    .top-bar { grid-template-columns: minmax(40px,.4fr) minmax(520px,auto) minmax(150px,.6fr); padding-inline: 14px; }
    .conversation-context { display: none; }
    .artifacts-panel { position: fixed; inset: 0 0 0 auto; width: min(620px, 92vw); height: 100%; flex-basis: auto; }
}

@media (max-width: 1100px) {
    .sidebar { position: fixed; inset: 0 auto 0 0; width: min(284px, 86vw); transform: translateX(-102%); transition: transform 220ms var(--ease-out); }
    .app-container.sidebar-open .sidebar { transform: translateX(0); box-shadow: 20px 0 60px rgba(0,0,0,.45); }
    .sidebar-overlay { position: fixed; inset: 0; z-index: 19; display: block; background: rgba(2,4,8,.58); opacity: 0; backdrop-filter: blur(4px); pointer-events: none; transition: opacity 180ms ease; }
    .app-container.sidebar-open .sidebar-overlay { opacity: 1; pointer-events: auto; }
    .sidebar-toggle-btn { display: inline-grid; }
    .top-bar { grid-template-columns: auto minmax(0,1fr) auto; }
    .top-bar-center { justify-content: flex-start; overflow-x: auto; scrollbar-width: none; }
    .top-bar-center::-webkit-scrollbar { display: none; }
    .toolbar-field { flex: 0 0 auto; }
    .input-section::before { left: 0; }
    .settings-modal-card { width: calc(100vw - 20px); height: calc(100dvh - 20px); max-height: none; }
}

@media (max-width: 720px) {
    .top-bar { min-height: 104px; flex-basis: 104px; grid-template-areas: 'left center' 'right right'; grid-template-columns: auto minmax(0,1fr); grid-template-rows: 58px 46px; gap: 0 8px; padding: 0 10px; }
    .top-bar-left { grid-area: left; }
    .top-bar-center { grid-area: center; justify-content: flex-start; overflow-x: auto; scrollbar-width: none; }
    .top-bar-center::-webkit-scrollbar { display: none; }
    .top-bar-right { grid-area: right; justify-content: flex-start; gap: 4px; border-top: 1px solid var(--border); }
    .conversation-context { display: none; }
    .toolbar-field { height: 40px; flex: 0 0 auto; }
    .platform-select-wrapper { display: flex; width: 128px; }
    .model-select-wrapper { width: 210px; }
    .system-prompt-wrapper { display: flex; width: 150px; }
    .icon-btn { width: 40px; height: 40px; flex-basis: 40px; }
    .chat-viewport { padding-top: 22px; }
    .chat-empty-state { width: calc(100% - 28px); min-height: min(500px, 68vh); padding-top: 28px; }
    .prompt-suggestions { grid-template-columns: minmax(0,1fr); }
    .message-list, .input-section { width: calc(100% - 28px); }
    .message-list { gap: 19px; }
    .message-card { max-width: 88%; }
    .message-row.assistant .message-card { width: 100%; }
    .input-section { padding-bottom: max(10px, env(safe-area-inset-bottom)); }
    .composer-shortcut { display: none; }
    .settings-modal-card { position: fixed; inset: 0; width: 100%; height: 100dvh; border: 0; border-radius: 0; }
    .settings-modal-body { display: flex; flex-direction: column; }
    .settings-nav { flex: 0 0 auto; flex-direction: row; overflow-x: auto; padding: 8px 10px; border-right: 0; border-bottom: 1px solid var(--border); }
    .settings-nav-item { min-width: max-content; min-height: 40px; padding: 5px 9px; }
    .settings-nav-item small, .settings-nav-icon { display: none; }
    .settings-content { padding: 14px 12px 24px; }
    .settings-section-card { padding: 14px; }
    .modal-overlay { padding: 10px; }
    .modal-card { max-height: calc(100dvh - 20px); }
    .attachment-preview-dialog { width: calc(100vw - 12px); height: calc(100dvh - 12px); max-height: none; border-radius: 13px; }
    .attachment-preview-body { padding: 10px; }
}

@media (max-width: 480px) {
    .platform-select-wrapper { width: 112px; }
    .model-select-wrapper { width: 190px; }
    .system-prompt-wrapper { width: 142px; }
    .message-list, .input-section { width: calc(100% - 22px); }
    .chat-empty-state { width: calc(100% - 32px); }
    .chat-empty-state h1 { font-size: 27px; }
    .chat-empty-state > p { font-size: 12px; }
    .prompt-suggestions { margin-top: 22px; }
    .message-card { max-width: 91%; padding: 12px 13px; }
    .message-header { gap: 5px; }
    .meta-info > span:first-child { display: none; }
    .copy-btn { opacity: .8; }
    .message-body { font-size: 13.5px; }
    .input-capsule { min-height: 55px; padding: 8px; border-radius: 16px; }
    .input-action-btn, .send-btn { width: 40px; height: 40px; flex-basis: 40px; }
    .markdown-switch { padding: 0 1px; }
    .markdown-switch-label { display: none; }
    .token-label { display: none; }
    .attachments-area { grid-template-columns: minmax(0,1fr); }
    .message-attachments { width: 100%; }
    .remove-att-btn, .attachment-preview-close-btn { min-width: 44px; min-height: 44px; }
    .modal-footer { flex-wrap: wrap; }
    .modal-footer-leading { width: 100%; margin: 0 0 4px; }
}

@media (hover: none) {
    .delete-conv-btn { opacity: .72; }
    .copy-btn { opacity: .7; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* Shared searchable selectors use the model picker surface. */
.unified-select-native { display: none !important; }
.unified-toolbar-field > .toolbar-field-label { position: absolute; top: 4px; left: 11px; pointer-events: none; }
.settings-picker-trigger { position: relative; inset: auto; display: block; min-height: 36px; padding: 8px 32px 8px 11px; border: 1px solid var(--border-strong); border-radius: 8px; background: var(--crust); font-size: 12px; }
.settings-picker-trigger::after { position: absolute; top: 12px; right: 12px; width: 6px; height: 6px; border-right: 1.5px solid var(--subtext0); border-bottom: 1.5px solid var(--subtext0); transform: rotate(45deg); content: ''; }
.model-picker-trigger:focus-visible { outline: 2px solid var(--lavender); outline-offset: 2px; border-radius: 8px; }
.unified-picker-panel { z-index: 1100; }
.model-picker-option:disabled { opacity: .4; cursor: not-allowed; }
.custom-params-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 18px; }
.custom-params-help { color: var(--subtext0); font-size: 12px; line-height: 1.6; margin: 8px 0; }
.custom-param-row { display: grid; grid-template-columns: minmax(100px, 1fr) 100px minmax(110px, 1.5fr) auto; gap: 8px; margin-top: 8px; align-items: start; }
.custom-param-row input, .custom-param-row textarea { width: 100%; min-width: 0; min-height: 36px; padding: 8px; border: 1px solid var(--border-strong); border-radius: 8px; background: var(--crust); color: var(--text); font: inherit; font-size: 12px; }
.custom-param-row textarea { resize: vertical; }
.custom-params-error { color: var(--red); font-size: 12px; margin-top: 8px; }
@media (max-width: 600px) { .custom-param-row { grid-template-columns: minmax(0,1fr) 90px auto; } .custom-param-row textarea { grid-column: 1 / 3; grid-row: 2; } .custom-param-row .remove-param { grid-column: 3; grid-row: 1 / 3; } }

.model-param-enabled { display: flex !important; align-items: center; gap: 8px; margin: 6px 0; font-size: 12px; color: var(--subtext0); }
.model-param-enabled input { width: 14px !important; height: 14px; accent-color: var(--lavender); }
#model-temp-input { margin-bottom: 8px; }
.model-request-editor { margin-top: 20px; padding-top: 14px; border-top: 1px solid var(--border-strong); }
.model-request-editor summary { cursor: pointer; font-size: 13px; font-weight: 600; }
.model-json-toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
#model-request-json { box-sizing: border-box; width: 100%; min-height: 230px; padding: 14px; border: 1px solid var(--border-strong); border-radius: 10px; background: var(--crust); color: var(--text); font: 12px/1.7 var(--font-mono); resize: vertical; tab-size: 2; }
#model-request-json:focus { outline: 2px solid var(--lavender); outline-offset: 1px; }
