/* ═══════════════════════════════════════════════════════════════
   xuss AI v3.0.0 — AMOLED Black + Orange Theme
   Complete stylesheet for chat, admin, auth pages
   ═══════════════════════════════════════════════════════════════ */

/* ── Design Tokens ─────────────────────────────────────────── */
:root {
    --bg:            #000000;
    --bg-surface:    #050505;
    --bg-card:       #0a0a0a;
    --bg-elevated:   #111111;
    --bg-hover:      #161616;
    --border:        rgba(255,255,255,0.06);
    --border2:       rgba(255,255,255,0.10);
    --border3:       rgba(255,255,255,0.16);
    --white:         #ebebeb;
    --white-bright:  #ffffff;
    --text:          #c8c8c8;
    --text2:         #8e8e93;
    --text3:         #555555;
    --accent:        #ff8c00;
    --accent-dim:    rgba(255,140,0,0.10);
    --accent-glow:   rgba(255,140,0,0.18);
    --red:           #ff453a;
    --red-dim:       rgba(255,69,58,0.10);
    --green:         #30d158;
    --green-dim:     rgba(48,209,88,0.10);
    --sidebar-w:     272px;
    --font:          -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', system-ui, sans-serif;
    --font-mono:     'JetBrains Mono', 'Fira Code', 'SF Mono', Consolas, monospace;
    --radius-sm:     6px;
    --radius:        10px;
    --radius-lg:     14px;
    --radius-xl:     18px;
    --shadow:        0 8px 40px rgba(0,0,0,0.85);
    --transition:    0.15s ease;
}

/* ── Reset ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }
body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}
::selection { background: var(--accent); color: #fff; }
a { color: inherit; }

/* ── Scrollbar ─────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.07); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.14); }


/* ══════════════════════════════════════════════════════════════
   LAYOUT
   ══════════════════════════════════════════════════════════════ */
.app { display: flex; height: 100vh; overflow: hidden; position: relative; }
.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; }


/* ══════════════════════════════════════════════════════════════
   SIDEBAR
   ══════════════════════════════════════════════════════════════ */
.sidebar {
    width: var(--sidebar-w);
    min-width: var(--sidebar-w);
    background: var(--bg-surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    transition: transform 0.25s ease;
    z-index: 50;
}
.sidebar-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px;
    gap: 8px;
}
.new-chat-btn {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: var(--white-bright);
    color: #000;
    border: none;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    font-family: var(--font);
    transition: opacity var(--transition);
    -webkit-tap-highlight-color: transparent;
}
.new-chat-btn:hover { opacity: 0.88; }
.new-chat-btn:active { opacity: 0.75; }
.new-chat-btn svg { opacity: 0.7; }
.sidebar-close { display: none; }

.sidebar-search { padding: 0 12px 10px; }
.sidebar-search input {
    width: 100%;
    padding: 8px 12px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--white);
    font-size: 13px;
    outline: none;
    font-family: var(--font);
    transition: border-color var(--transition);
}
.sidebar-search input:focus { border-color: var(--border2); }
.sidebar-search input::placeholder { color: var(--text3); }

.conv-list { flex: 1; overflow-y: auto; padding: 0 8px; }
.conv-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-radius: var(--radius);
    margin-bottom: 2px;
    transition: background var(--transition);
}
.conv-item:hover { background: var(--bg-hover); }
.conv-item.active { background: var(--bg-hover); }
.conv-body {
    flex: 1;
    padding: 8px 12px;
    cursor: pointer;
    min-width: 0;
    -webkit-tap-highlight-color: transparent;
}
.conv-title {
    font-size: 13px;
    color: var(--text2);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
    transition: color var(--transition);
}
.conv-item.active .conv-title { color: var(--white); }
.conv-item:hover .conv-title { color: var(--text); }
.conv-actions {
    display: flex;
    gap: 2px;
    opacity: 0;
    padding-right: 6px;
    transition: opacity var(--transition);
}
.conv-item:hover .conv-actions { opacity: 1; }

.sidebar-footer {
    padding: 10px 12px;
    border-top: 1px solid var(--border);
    position: relative;
}
.user-row {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    padding: 8px;
    border-radius: var(--radius);
    transition: background var(--transition);
    -webkit-tap-highlight-color: transparent;
}
.user-row:hover { background: var(--bg-hover); }
.user-avatar {
    width: 28px; height: 28px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 12px;
    flex-shrink: 0;
    overflow: hidden;
}
.user-avatar img { width: 100%; height: 100%; object-fit: cover; }
.user-name { font-size: 13px; color: var(--text2); flex: 1; }

.user-menu {
    position: absolute;
    bottom: 60px; left: 12px; right: 12px;
    background: var(--bg-card);
    border: 1px solid var(--border2);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    z-index: 10;
}
.menu-item {
    display: block;
    padding: 10px 14px;
    color: var(--text2);
    font-size: 13px;
    text-decoration: none;
    transition: all var(--transition);
}
.menu-item:hover { background: var(--bg-hover); color: var(--white); }

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 40;
}
.sidebar-overlay.open { display: block; }


/* ══════════════════════════════════════════════════════════════
   TOPBAR
   ══════════════════════════════════════════════════════════════ */
.topbar {
    height: 48px;
    display: flex;
    align-items: center;
    padding: 0 8px;
    gap: 4px;
    flex-shrink: 0;
    background: transparent;
    position: relative;
    z-index: 10;
}

/* ── Generic Icon Buttons ──────────────────────────────────── */
.icon-btn {
    width: 36px; height: 36px;
    border-radius: var(--radius);
    background: transparent;
    border: none;
    color: var(--text2);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition);
    -webkit-tap-highlight-color: transparent;
    flex-shrink: 0;
}
.icon-btn:hover { background: var(--bg-hover); color: var(--white); }
.icon-btn:active { background: var(--bg-elevated); transform: scale(0.93); }

.icon-btn-sm {
    width: 34px; height: 34px;
    border-radius: var(--radius-sm);
    background: transparent;
    border: none;
    color: var(--text2);
    cursor: pointer;
    transition: all var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
    flex-shrink: 0;
}
.icon-btn-sm:hover { color: var(--white); background: var(--bg-hover); }
.icon-btn-sm:active { background: var(--bg-elevated); transform: scale(0.92); }

/* ── Model Selector ────────────────────────────────────────── */
.model-selector { position: relative; flex: 1; max-width: 280px; }
.model-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: transparent;
    border: none;
    color: var(--white);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    font-family: var(--font);
    width: 100%;
    border-radius: var(--radius);
    transition: background var(--transition);
    -webkit-tap-highlight-color: transparent;
}
.model-btn:hover { background: var(--bg-hover); }
.model-btn:active { background: var(--bg-elevated); }
.model-btn svg { color: var(--text3); }

.model-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    left: -6px; right: -6px;
    background: var(--bg-card);
    border: 1px solid var(--border2);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    z-index: 100;
    max-height: 320px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.model-search {
    padding: 10px 14px;
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--border);
    color: var(--white);
    font-size: 13px;
    outline: none;
    font-family: var(--font);
}
.model-search::placeholder { color: var(--text3); }
.model-list { overflow-y: auto; max-height: 280px; padding: 4px; }
.model-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background var(--transition);
    font-size: 13px;
    color: var(--text2);
    -webkit-tap-highlight-color: transparent;
}
.model-option:hover { background: var(--bg-hover); color: var(--white); }
.model-option.selected { color: var(--white); }
.model-name { flex: 1; }
.model-badge { display: flex; align-items: center; color: var(--accent); }
.model-check { display: flex; align-items: center; color: var(--accent); }

#settingsBtn { margin-left: auto; }


/* ══════════════════════════════════════════════════════════════
   WELCOME SCREEN
   ══════════════════════════════════════════════════════════════ */
.welcome {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
}
.welcome-icon {
    width: 72px; height: 72px;
    border-radius: 50%;
    background: var(--bg-card);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 20px;
    color: var(--accent);
}
.welcome h1 { font-size: 28px; font-weight: 600; margin-bottom: 6px; color: var(--white-bright); }
.welcome p { color: var(--text2); margin-bottom: 32px; font-size: 15px; }
.quick-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; max-width: 500px; width: 100%; }
.quick-btn {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 14px 16px;
    color: var(--text2);
    font-size: 13px;
    text-align: left;
    cursor: pointer;
    font-family: var(--font);
    transition: all var(--transition);
    line-height: 1.4;
    -webkit-tap-highlight-color: transparent;
}
.quick-btn:hover { border-color: var(--border2); color: var(--white); background: var(--bg-elevated); }
.quick-btn:active { background: var(--bg-hover); }


/* ══════════════════════════════════════════════════════════════
   CHAT AREA
   ══════════════════════════════════════════════════════════════ */
.chat-area {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    scroll-behavior: smooth;
}
.messages {
    max-width: 780px;
    margin: 0 auto;
    padding: 16px 20px 40px;
    width: 100%;
}

/* ── Messages ──────────────────────────────────────────────── */
.msg { display: flex; gap: 12px; margin-bottom: 24px; }
.msg-avatar {
    width: 30px; height: 30px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-top: 2px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text2);
}
.msg.user .msg-avatar { background: var(--accent); color: #fff; border-color: transparent; }
.msg-content { flex: 1; min-width: 0; }
.msg-meta {
    font-size: 12px;
    color: var(--text3);
    margin-bottom: 4px;
    display: flex;
    gap: 8px;
    align-items: center;
}
.msg-role { font-weight: 600; color: var(--text2); font-size: 13px; }
.msg.user .msg-role { color: var(--white); }

/* User message bubble */
.msg.user .msg-body {
    background: var(--bg-elevated);
    padding: 10px 16px;
    border-radius: var(--radius-lg);
    border-top-left-radius: var(--radius-sm);
    border: 1px solid var(--border);
    white-space: pre-wrap;
    word-break: break-word;
}

/* Assistant message */
.msg.assistant .msg-body { padding: 4px 0; color: var(--text); }

/* Tool message */
.msg.tool .msg-body pre {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px;
    font-size: 12px;
    color: var(--text2);
    max-height: 200px;
    overflow: auto;
    font-family: var(--font-mono);
}

/* ── Message Footer ────────────────────────────────────────── */
.msg-footer { display: flex; gap: 4px; margin-top: 8px; opacity: 0; transition: opacity var(--transition); }
.msg:hover .msg-footer { opacity: 1; }
.msg-act {
    width: 30px; height: 30px;
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text3);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition);
    -webkit-tap-highlight-color: transparent;
}
.msg-act:hover { color: var(--white); border-color: var(--border2); background: var(--bg-elevated); }
.msg-act:active { transform: scale(0.9); }
.msg-act svg { width: 13px; height: 13px; }

/* ── Message Images ────────────────────────────────────────── */
.msg-images { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.msg-img {
    max-width: 200px; max-height: 200px;
    border-radius: var(--radius);
    cursor: pointer;
    object-fit: cover;
    border: 1px solid var(--border);
    transition: transform var(--transition);
}
.msg-img:hover { transform: scale(1.02); }


/* ══════════════════════════════════════════════════════════════
   INLINE CODE
   ══════════════════════════════════════════════════════════════ */
.inline-code {
    background: var(--red-dim);
    padding: 1px 6px;
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 0.85em;
    color: var(--red);
    cursor: pointer;
    border: 1px solid rgba(255,69,58,0.12);
    transition: all var(--transition);
}
.inline-code:hover { background: rgba(255,69,58,0.18); }
.inline-code.copied { color: var(--green); border-color: var(--green); background: var(--green-dim); }


/* ══════════════════════════════════════════════════════════════
   THINKING / REASONING BLOCK
   ══════════════════════════════════════════════════════════════ */
.think-block {
    margin-bottom: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--bg-card);
    border-left: 3px solid var(--accent);
}
.think-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    color: var(--text2);
    user-select: none;
    transition: background var(--transition);
    -webkit-tap-highlight-color: transparent;
}
.think-header:hover { background: var(--bg-hover); }
.think-arrow { transition: transform 0.25s ease; display: flex; align-items: center; color: var(--text3); }
.think-block.expanded .think-arrow svg { transform: rotate(90deg); }
.think-label { flex: 1; }
.think-count { color: var(--text3); font-size: 11px; font-family: var(--font-mono); }
.think-body { max-height: 0; overflow: hidden; transition: max-height 0.4s ease; }
.think-block.expanded .think-body { max-height: 6000px; }
.think-text-wrap { padding: 12px 16px; border-top: 1px solid var(--border); }
.think-text {
    font-size: 12px;
    line-height: 1.75;
    color: var(--text2);
    white-space: pre-wrap;
    word-wrap: break-word;
    word-break: break-word;
    margin: 0;
    background: transparent;
    border: none;
    padding: 0;
    font-family: var(--font-mono);
}
.think-dots { display: inline-flex; gap: 3px; margin-left: 8px; }
.think-dots span { width: 4px; height: 4px; border-radius: 50%; background: var(--accent); animation: dotPulse 1.4s ease infinite; }
.think-dots span:nth-child(2) { animation-delay: 0.2s; }
.think-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes dotPulse { 0%,60%,100% { opacity: 0.3; transform: scale(0.8); } 30% { opacity: 1; transform: scale(1.3); } }


/* ══════════════════════════════════════════════════════════════
   CODE BLOCKS
   ══════════════════════════════════════════════════════════════ */
.msg-body pre.code-block {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin: 12px 0;
    overflow: hidden;
}
.code-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 12px;
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border);
}
.code-lang {
    color: var(--text3);
    font-family: var(--font-mono);
    font-size: 11px;
    text-transform: lowercase;
    letter-spacing: 0.3px;
}
.code-copy-btn {
    background: none;
    border: 1px solid var(--border);
    color: var(--text3);
    padding: 3px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 11px;
    font-family: var(--font);
    display: flex;
    align-items: center;
    gap: 4px;
    transition: all var(--transition);
    -webkit-tap-highlight-color: transparent;
}
.code-copy-btn:hover { color: var(--white); border-color: var(--border2); }
.code-copy-btn:active { transform: scale(0.95); }
.code-copy-btn.copied { color: var(--green); border-color: var(--green); }

.code-content { display: flex; overflow-x: auto; }
.line-nums {
    padding: 14px 0 14px 14px;
    padding-right: 14px;
    text-align: right;
    color: var(--text3);
    font-family: var(--font-mono);
    font-size: 12px;
    line-height: 1.6;
    border-right: 1px solid var(--border);
    flex-shrink: 0;
    user-select: none;
    opacity: 0.5;
}
.code-content pre { margin: 0 !important; border: none !important; border-radius: 0 !important; background: transparent !important; }
.code-content code {
    display: block;
    padding: 14px 16px !important;
    font-family: var(--font-mono) !important;
    font-size: 13px !important;
    line-height: 1.6 !important;
    background: transparent !important;
    border: none !important;
    color: var(--text) !important;
    tab-size: 4;
}


/* ══════════════════════════════════════════════════════════════
   MARKDOWN CONTENT
   ══════════════════════════════════════════════════════════════ */
.msg-body {
    user-select: text;
    -webkit-user-select: text;
    cursor: text;
    line-height: 1.7;
    font-size: 14.5px;
}
.msg-body h1, .msg-body h2, .msg-body h3, .msg-body h4 { margin: 16px 0 8px; font-weight: 600; line-height: 1.35; color: var(--white-bright); }
.msg-body h1 { font-size: 1.4em; }
.msg-body h2 { font-size: 1.25em; }
.msg-body h3 { font-size: 1.1em; }
.msg-body h4 { font-size: 1em; }
.msg-body p { margin-bottom: 10px; }
.msg-body p:last-child { margin-bottom: 0; }
.msg-body ul, .msg-body ol { margin: 8px 0; padding-left: 24px; }
.msg-body li { margin-bottom: 4px; }
.msg-body li > ul, .msg-body li > ol { margin: 4px 0; }
.msg-body blockquote {
    border-left: 3px solid var(--accent);
    padding: 8px 16px;
    margin: 10px 0;
    color: var(--text2);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    background: var(--accent-dim);
}
.msg-body a { color: var(--accent); text-decoration: none; border-bottom: 1px solid var(--accent-dim); transition: border-color var(--transition); }
.msg-body a:hover { border-color: var(--accent); }
.msg-body strong { font-weight: 600; color: var(--white); }
.msg-body em { color: var(--text2); font-style: italic; }
.msg-body table { width: 100%; border-collapse: collapse; margin: 10px 0; font-size: 13px; }
.msg-body th, .msg-body td { padding: 8px 12px; border: 1px solid var(--border); text-align: left; }
.msg-body th { background: var(--bg-elevated); color: var(--white); font-weight: 600; }
.msg-body td { color: var(--text); }
.msg-body hr { border: none; border-top: 1px solid var(--border); margin: 16px 0; }
.msg-body img { max-width: 100%; border-radius: var(--radius); margin: 8px 0; cursor: pointer; border: 1px solid var(--border); }

/* ── KaTeX Math ────────────────────────────────────────────── */
.msg-body .katex-display { margin: 14px 0; padding: 14px 16px; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); overflow-x: auto; text-align: center; }
.msg-body .katex { font-size: 1.05em; color: var(--white); }
.msg-body .katex-display .katex { font-size: 1.15em; }
.msg-body .katex-error { color: var(--red); font-family: var(--font-mono); font-size: 12px; background: var(--red-dim); padding: 4px 8px; border-radius: 4px; }


/* ══════════════════════════════════════════════════════════════
   IMAGE PREVIEW (input area)
   ══════════════════════════════════════════════════════════════ */
.image-preview { display: flex; flex-wrap: wrap; gap: 8px; padding: 8px 14px; border-bottom: 1px solid var(--border); align-items: center; }
.preview-thumb { position: relative; }
.preview-thumb img { max-width: 52px; max-height: 52px; border-radius: var(--radius-sm); object-fit: cover; border: 1px solid var(--border); }
.remove-thumb {
    position: absolute; top: -5px; right: -5px;
    width: 18px; height: 18px; border-radius: 50%;
    background: var(--red); color: #fff;
    border: 2px solid var(--bg-card);
    font-size: 10px; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: transform var(--transition);
}
.remove-thumb:hover { transform: scale(1.15); }


/* ══════════════════════════════════════════════════════════════
   ACTIVITY BAR
   ══════════════════════════════════════════════════════════════ */
.activity-bar { max-width: 780px; margin: 0 auto; padding: 0 20px 12px; width: 100%; }
.activity-item {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 14px;
    background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
    font-size: 12px; color: var(--text2);
    margin-bottom: 6px;
    animation: fadeSlideIn 0.2s ease;
}
@keyframes fadeSlideIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.activity-spinner {
    width: 12px; height: 12px;
    border: 2px solid var(--border2);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }


/* ══════════════════════════════════════════════════════════════
   INPUT AREA
   ══════════════════════════════════════════════════════════════ */
.input-area { padding: 8px 16px 14px; flex-shrink: 0; }
.input-box {
    max-width: 780px;
    margin: 0 auto;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    overflow: visible;
}
.input-box:focus-within {
    border-color: var(--border2);
    box-shadow: 0 0 0 1px rgba(255,255,255,0.02);
}
.input-box textarea {
    width: 100%;
    padding: 12px 16px 4px;
    background: transparent;
    border: none;
    color: var(--white);
    font-size: 14.5px;
    line-height: 1.55;
    resize: none;
    outline: none;
    max-height: 140px;
    overflow-y: auto;
    font-family: var(--font);
}
.input-box textarea::placeholder { color: var(--text3); }
.input-controls {
    display: flex;
    align-items: center;
    padding: 4px 10px 10px;
    gap: 6px;
    position: relative;
    z-index: 2;
}
.send-btn {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: var(--white-bright);
    border: none;
    color: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: opacity var(--transition), transform var(--transition);
    -webkit-tap-highlight-color: transparent;
    flex-shrink: 0;
}
.send-btn:hover { opacity: 0.85; }
.send-btn:active { transform: scale(0.9); }
.stop-btn {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: var(--red);
    border: none;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    flex-shrink: 0;
}
.stop-btn:active { transform: scale(0.9); }
.mic-active { color: var(--red) !important; animation: micPulse 1s ease infinite; }
@keyframes micPulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }
.tts-stop { background: var(--white-bright) !important; color: #000 !important; border: none !important; }


/* ══════════════════════════════════════════════════════════════
   SETTINGS DRAWER
   ══════════════════════════════════════════════════════════════ */
.drawer-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 80;
}
.drawer-overlay.open { display: block; }
.drawer {
    position: fixed; right: 0; top: 0;
    height: 100vh; width: 320px; max-width: 90vw;
    background: var(--bg-surface);
    border-left: 1px solid var(--border);
    z-index: 90;
    display: flex; flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.25s ease;
}
.drawer.open { transform: translateX(0); }
.drawer-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}
.drawer-head h3 { font-size: 16px; font-weight: 600; color: var(--white); }
.drawer-body { flex: 1; overflow-y: auto; padding: 20px; }
.drawer-body label { display: block; font-size: 12px; color: var(--text2); margin-bottom: 6px; margin-top: 18px; font-weight: 500; }
.drawer-body label:first-child { margin-top: 0; }
.drawer-foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; gap: 8px; }

/* ── Form Elements ─────────────────────────────────────────── */
.sel, .num-input {
    width: 100%; padding: 9px 12px;
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--white); font-size: 13px;
    outline: none; font-family: var(--font);
    transition: border-color var(--transition);
    -webkit-appearance: none; appearance: none;
}
.sel:focus, .num-input:focus { border-color: var(--border2); }
.sel {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23555' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
}
.sel option { background: var(--bg-card); color: var(--white); }

input[type="range"] {
    -webkit-appearance: none; width: 100%; height: 4px;
    background: var(--border2); border-radius: 99px;
    outline: none; margin: 8px 0;
}
input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none; width: 18px; height: 18px;
    border-radius: 50%; background: var(--white-bright);
    cursor: pointer; border: 3px solid var(--bg);
}

/* ── Toggle Switch ─────────────────────────────────────────── */
.toggle-row { display: flex !important; align-items: center; justify-content: space-between; cursor: pointer; margin-top: 18px !important; }
.toggle-row input[type="checkbox"] { display: none; }
.toggle {
    width: 40px; height: 22px;
    background: var(--border2); border-radius: 99px;
    position: relative; transition: background var(--transition);
    flex-shrink: 0;
}
.toggle::after {
    content: ''; position: absolute;
    width: 16px; height: 16px;
    background: var(--white); border-radius: 50%;
    top: 3px; left: 3px;
    transition: transform var(--transition);
}
.toggle-row input:checked + .toggle { background: var(--accent); }
.toggle-row input:checked + .toggle::after { transform: translateX(18px); }

/* ── Buttons ───────────────────────────────────────────────── */
.btn-primary {
    padding: 10px 20px;
    background: var(--white-bright); color: #000;
    border: none; border-radius: var(--radius);
    font-size: 13px; font-weight: 600;
    cursor: pointer; font-family: var(--font); width: 100%;
    transition: opacity var(--transition);
    -webkit-tap-highlight-color: transparent;
}
.btn-primary:hover { opacity: 0.9; }
.btn-primary:active { opacity: 0.75; }


/* ══════════════════════════════════════════════════════════════
   ALERTS / BADGES
   ══════════════════════════════════════════════════════════════ */
.alert { padding: 10px 14px; border-radius: var(--radius); margin-bottom: 14px; font-size: 13px; }
.alert-error { background: var(--red-dim); border: 1px solid rgba(255,69,58,0.2); color: var(--red); }
.alert-success { background: var(--green-dim); border: 1px solid rgba(48,209,88,0.2); color: var(--green); }
.badge { display: inline-block; padding: 2px 7px; border-radius: 99px; font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.4px; background: var(--bg-elevated); color: var(--text3); }
.badge-admin { background: var(--accent-dim); color: var(--accent); }


/* ══════════════════════════════════════════════════════════════
   AUTH PAGES
   ══════════════════════════════════════════════════════════════ */
.auth-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; background: var(--bg); }
.auth-container { width: 100%; max-width: 400px; }
.auth-card { background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius-xl); padding: 32px; }
.auth-logo { font-size: 40px; text-align: center; margin-bottom: 8px; }
.auth-card h1 { text-align: center; font-size: 22px; margin-bottom: 4px; color: var(--white-bright); }
.auth-card > p { text-align: center; color: var(--text2); font-size: 14px; margin-bottom: 24px; }
.auth-form .form-group { margin-bottom: 14px; }
.auth-form label { display: block; font-size: 12px; color: var(--text2); margin-bottom: 6px; font-weight: 500; }
.auth-form input {
    width: 100%; padding: 10px 14px;
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); color: var(--white);
    font-size: 14px; outline: none; font-family: var(--font);
    transition: border-color var(--transition);
}
.auth-form input:focus { border-color: var(--border2); }
.auth-footer { text-align: center; margin-top: 18px; font-size: 13px; color: var(--text3); }
.auth-footer a { color: var(--accent); text-decoration: none; }


/* ══════════════════════════════════════════════════════════════
   ADMIN PANEL
   ══════════════════════════════════════════════════════════════ */
.admin-body { overflow: auto; background: var(--bg); }
.admin-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 24px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-surface);
    position: sticky; top: 0; z-index: 10;
    flex-wrap: wrap; gap: 10px;
}
.admin-header-left { display: flex; align-items: center; gap: 12px; }
.admin-header h1 { font-size: 18px; font-weight: 600; color: var(--white); }
.admin-header-right { display: flex; align-items: center; gap: 10px; }

.admin-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
    padding: 20px 24px;
    max-width: 1200px;
}
.stat-card {
    background: var(--bg-surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 16px; text-align: center;
    transition: border-color var(--transition);
}
.stat-card:hover { border-color: var(--border2); }
.stat-icon { color: var(--accent); margin-bottom: 6px; }
.stat-val { font-size: 26px; font-weight: 700; color: var(--white-bright); }
.stat-label { font-size: 11px; color: var(--text3); text-transform: uppercase; letter-spacing: 0.5px; }

.admin-tabs {
    display: flex; padding: 0 24px;
    border-bottom: 1px solid var(--border);
    max-width: 1200px; overflow-x: auto;
}
.admin-tab {
    padding: 12px 18px; background: none; border: none;
    border-bottom: 2px solid transparent;
    color: var(--text3); font-size: 13px; font-weight: 500;
    cursor: pointer; font-family: var(--font);
    white-space: nowrap;
    display: flex; align-items: center; gap: 6px;
    transition: all var(--transition);
    -webkit-tap-highlight-color: transparent;
}
.admin-tab:hover { color: var(--white); }
.admin-tab.active { color: var(--white); border-bottom-color: var(--accent); }

.admin-panel { display: none; padding: 20px 24px; max-width: 1200px; }
.admin-panel.active { display: block; }

.panel-card {
    background: var(--bg-surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 20px; margin-bottom: 14px;
}
.panel-card h3 { font-size: 15px; margin-bottom: 14px; color: var(--white); }
.panel-card-title {
    display: flex; align-items: center; gap: 10px; margin-bottom: 14px;
}
.panel-card-title h3 { margin: 0; font-size: 15px; color: var(--white); }
.panel-card-title svg { color: var(--text3); flex-shrink: 0; }

.table-wrap { overflow-x: auto; }
.admin-table { width: 100%; border-collapse: collapse; }
.admin-table th, .admin-table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); font-size: 13px; }
.admin-table th {
    background: var(--bg-card); font-weight: 600;
    font-size: 10px; text-transform: uppercase;
    letter-spacing: 0.5px; color: var(--text3);
}
.admin-table tr:hover td { background: var(--bg-hover); }
.actions-cell { display: flex; gap: 4px; flex-wrap: wrap; }

.btn-sm {
    padding: 5px 12px; font-size: 11px;
    background: var(--bg-elevated); border: 1px solid var(--border);
    color: var(--text2); border-radius: var(--radius-sm);
    cursor: pointer; font-family: var(--font);
    transition: all var(--transition);
    display: inline-flex; align-items: center; gap: 4px;
    -webkit-tap-highlight-color: transparent;
}
.btn-sm:hover { color: var(--white); border-color: var(--border2); }
.btn-sm:active { transform: scale(0.95); }
.btn-sm-danger { background: var(--red-dim); border-color: rgba(255,69,58,0.2); color: var(--red); }
.btn-sm-danger:hover { background: var(--red); color: #fff; border-color: var(--red); }
.btn-sm-primary { background: var(--white-bright); color: #000; border-color: var(--white-bright); font-weight: 600; }
.btn-sm-primary:hover { opacity: 0.9; }

.conn-result { margin-top: 12px; padding: 10px 14px; border-radius: var(--radius); font-size: 13px; }
.conn-ok { background: var(--green-dim); border: 1px solid rgba(48,209,88,0.2); color: var(--green); }
.conn-err { background: var(--red-dim); border: 1px solid rgba(255,69,58,0.2); color: var(--red); }

.prompt-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; margin-bottom: 10px; transition: border-color var(--transition); }
.prompt-card:hover { border-color: var(--border2); }
.prompt-card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.prompt-preview { font-size: 11px; color: var(--text3); background: var(--bg-elevated); padding: 8px 10px; border-radius: var(--radius-sm); font-family: var(--font-mono); white-space: pre-wrap; max-height: 60px; overflow: hidden; }

.tool-category { margin-bottom: 16px; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.tool-cat-title { font-size: 13px; padding: 10px 14px; background: var(--bg-card); border-bottom: 1px solid var(--border); font-weight: 600; color: var(--white); display: flex; align-items: center; gap: 8px; }
.tool-item { padding: 10px 14px; border-bottom: 1px solid var(--border); }
.tool-item:last-child { border-bottom: none; }
.tool-item-config { margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--border); display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 8px; }
.tool-toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.tool-toggle-info { flex: 1; min-width: 0; }
.tool-toggle-name { font-size: 13px; font-weight: 500; color: var(--white); }
.tool-toggle-desc { font-size: 11px; color: var(--text3); }
.tool-toggle-status { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; min-width: 40px; text-align: right; }
.tool-toggle-status.on { color: var(--white); }
.tool-toggle-status.off { color: var(--text3); }

.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text3); margin-left: 8px; flex-shrink: 0; transition: background 0.2s; }
.status-dot.on { background: var(--green); }
.status-dot.off { background: var(--text3); }

.status-on { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 99px; background: rgba(255,255,255,0.08); color: var(--white); font-size: 11px; font-weight: 600; }
.status-on svg { width: 10px; height: 10px; }
.status-off { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 99px; background: rgba(255,255,255,0.02); color: var(--text3); font-size: 11px; font-weight: 600; }
.status-off svg { width: 10px; height: 10px; }

.think-yes { display: inline-flex; align-items: center; gap: 3px; color: var(--white); font-size: 11px; }
.think-yes svg { width: 12px; height: 12px; }
.think-no { color: var(--text3); font-size: 11px; }

.form-group-sm { margin-bottom: 0; }
.form-group-sm label { font-size: 10px; margin-bottom: 3px; color: var(--text3); }
.form-group-sm input {
    padding: 6px 8px; font-size: 11px;
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius-sm); color: var(--white);
    outline: none; width: 100%; font-family: var(--font);
    transition: border-color var(--transition);
}
.form-group-sm input:focus { border-color: var(--border2); }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ── Modals ────────────────────────────────────────────────── */
.modal-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(0,0,0,0.75);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 200;
    align-items: center; justify-content: center;
}
.modal-overlay[style*="flex"] { display: flex; }
.modal {
    background: var(--bg-surface); border: 1px solid var(--border2);
    border-radius: var(--radius-lg); width: 90%; max-width: 460px;
    max-height: 90vh; display: flex; flex-direction: column;
    box-shadow: var(--shadow);
}
.modal-lg { max-width: 600px; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-header h3 { font-size: 16px; font-weight: 600; color: var(--white); }
.modal-body { flex: 1; overflow-y: auto; padding: 20px; }
.modal-footer { display: flex; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--border); justify-content: flex-end; }

.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 12px; color: var(--text2); margin-bottom: 6px; font-weight: 500; }
.form-group small { display: block; margin-top: 4px; font-size: 11px; color: var(--text3); }
.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="password"],
.form-group input[type="url"],
.form-group input[type="number"],
.form-group textarea {
    width: 100%; padding: 9px 12px;
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); color: var(--white);
    font-size: 13px; outline: none; font-family: var(--font);
    transition: border-color var(--transition);
}
.form-group input:focus, .form-group textarea:focus { border-color: var(--border2); }
.form-group textarea { resize: vertical; min-height: 80px; font-family: var(--font-mono); font-size: 12px; }


/* ══════════════════════════════════════════════════════════════
   TOAST NOTIFICATIONS
   ══════════════════════════════════════════════════════════════ */
.toast-container {
    position: fixed; top: 14px; right: 14px;
    z-index: 9999; display: flex; flex-direction: column; gap: 8px;
    pointer-events: none;
}
.toast {
    padding: 10px 16px;
    border-radius: var(--radius);
    background: var(--bg-surface);
    border: 1px solid var(--border2);
    color: var(--white);
    font-size: 13px;
    animation: toastIn 0.25s ease;
    pointer-events: auto;
    box-shadow: var(--shadow);
}
.toast-success { border-color: var(--green); color: var(--green); }
.toast-error { border-color: var(--red); color: var(--red); }
.toast-info { border-color: var(--accent); color: var(--accent); }
@keyframes toastIn { from { opacity: 0; transform: translateX(30px); } to { opacity: 1; transform: none; } }


/* ══════════════════════════════════════════════════════════════
   RESPONSIVE
   ══════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
    .sidebar {
        position: fixed; left: 0; top: 0;
        height: 100vh;
        transform: translateX(-100%);
        z-index: 60;
    }
    .sidebar.open { transform: translateX(0); }
    .sidebar-close { display: flex; }
    .quick-grid { grid-template-columns: 1fr; }
    .welcome h1 { font-size: 22px; }
    .model-selector { max-width: 160px; }
    .drawer { width: 100%; }
    .messages { padding: 12px 14px 32px; }
    .input-area { padding: 6px 12px 10px; }
    .admin-stats { padding: 14px 16px; }
    .admin-panel { padding: 14px 16px; }
    .msg-img { max-width: 140px; max-height: 140px; }
    .form-row { grid-template-columns: 1fr; }

    /* Bigger touch targets on mobile */
    .icon-btn { width: 42px; height: 42px; }
    .icon-btn-sm { width: 40px; height: 40px; }
    .send-btn { width: 40px; height: 40px; }
    .stop-btn { width: 40px; height: 40px; }
    .msg-act { width: 36px; height: 36px; }
    .msg-footer { opacity: 1; }
    .input-controls { gap: 8px; padding: 6px 12px 12px; }
    .conv-actions { opacity: 1; }
}