:root {
    --bg-color: #060b14;
    --panel-bg: rgba(6, 11, 20, 0.65);
    --text-primary: #e2e8f0;
    --text-accent: #e5b344;
    --border-color: rgba(229, 179, 68, 0.45);
    --btn-bg: rgba(229, 179, 68, 0.12);
    --btn-hover: rgba(0, 240, 255, 0.25);
    --msg-user: rgba(0, 240, 255, 0.1);
    --msg-ai: rgba(229, 179, 68, 0.08);
    --glass-shadow: inset 0 0 0 1px rgba(229, 179, 68, 0.2), 0 8px 32px rgba(0, 0, 0, 0.7);
    --glass-blur: blur(16px) saturate(140%);
}

#vfx-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    object-fit: cover;
    z-index: 0;
    opacity: 0.15;
    mix-blend-mode: screen;
}

body[data-theme="snoopy"] {
    --bg-color: #f4f4f8;
    --panel-bg: rgba(255, 255, 255, 0.6);
    --text-primary: #1b1b1b;
    --text-accent: #e63946;
    --border-color: rgba(230, 57, 70, 0.3);
    --btn-bg: rgba(230, 57, 70, 0.1);
    --btn-hover: rgba(230, 57, 70, 0.2);
    --msg-user: rgba(230, 57, 70, 0.15);
    --msg-ai: rgba(255, 255, 255, 0.8);
    --glass-shadow: inset 0 0 1px rgba(255, 255, 255, 0.8), 0 8px 32px rgba(0, 0, 0, 0.1);
    --glass-blur: blur(20px) saturate(150%);
}

body[data-theme="stitch"] {
    --bg-color: #0b1d3a;
    --panel-bg: rgba(16, 30, 50, 0.65);
    --text-primary: #e0e1dd;
    --text-accent: #4cc9f0;
    --border-color: rgba(76, 201, 240, 0.3);
    --btn-bg: rgba(76, 201, 240, 0.15);
    --btn-hover: rgba(76, 201, 240, 0.3);
    --msg-user: rgba(76, 201, 240, 0.15);
    --msg-ai: rgba(10, 20, 35, 0.6);
    --glass-shadow: inset 0 0 1px rgba(255, 255, 255, 0.3), 0 8px 32px rgba(0, 0, 0, 0.4);
    --glass-blur: blur(20px) saturate(150%);
}

body[data-theme="lola"] {
    --bg-color: #2b001a;
    --panel-bg: rgba(40, 0, 20, 0.55);
    --text-primary: #ffd1dc;
    --text-accent: #ff007f;
    --border-color: rgba(255, 0, 127, 0.3);
    --btn-bg: rgba(255, 0, 127, 0.15);
    --btn-hover: rgba(255, 0, 127, 0.3);
    --msg-user: rgba(255, 0, 127, 0.15);
    --msg-ai: rgba(20, 0, 10, 0.6);
    --glass-shadow: inset 0 0 1px rgba(255, 255, 255, 0.3), 0 8px 32px rgba(0, 0, 0, 0.4);
    --glass-blur: blur(20px) saturate(150%);
}

/* --- SHELL COLLECTION ENVIRONMENTS --- */
body[data-theme="shells-aether"] {
    --bg-color: #0e1215;
    --panel-bg: rgba(24, 33, 37, 0.78);
    --text-primary: #e6ede6;
    --text-accent: #d1e8ae;
    --border-color: rgba(168, 184, 160, 0.35);
    --btn-bg: rgba(209, 232, 174, 0.12);
    --btn-hover: rgba(209, 232, 174, 0.25);
    --msg-user: rgba(209, 232, 174, 0.15);
    --msg-ai: rgba(24, 33, 37, 0.85);
    --glass-shadow: inset 0 0 1px rgba(209, 232, 174, 0.3), 0 8px 32px rgba(0, 0, 0, 0.6);
    --glass-blur: blur(20px) saturate(130%);
}

body[data-theme="shells-verdant"] {
    --bg-color: #0b1a15;
    --panel-bg: rgba(16, 40, 32, 0.78);
    --text-primary: #e5e2b6;
    --text-accent: #9da97c;
    --border-color: rgba(157, 169, 124, 0.35);
    --btn-bg: rgba(157, 169, 124, 0.12);
    --btn-hover: rgba(157, 169, 124, 0.25);
    --msg-user: rgba(157, 169, 124, 0.15);
    --msg-ai: rgba(16, 40, 32, 0.85);
    --glass-shadow: inset 0 0 1px rgba(157, 169, 124, 0.3), 0 8px 32px rgba(0, 0, 0, 0.6);
    --glass-blur: blur(20px) saturate(130%);
}

body[data-theme="shells-ember"] {
    --bg-color: #140f0d;
    --panel-bg: rgba(28, 20, 18, 0.78);
    --text-primary: #f5ddd1;
    --text-accent: #f3b187;
    --border-color: rgba(185, 108, 68, 0.35);
    --btn-bg: rgba(243, 177, 135, 0.12);
    --btn-hover: rgba(243, 177, 135, 0.25);
    --msg-user: rgba(243, 177, 135, 0.15);
    --msg-ai: rgba(30, 22, 19, 0.85);
    --glass-shadow: inset 0 0 1px rgba(243, 177, 135, 0.3), 0 8px 32px rgba(0, 0, 0, 0.6);
    --glass-blur: blur(20px) saturate(130%);
}

body[data-theme="shells-tidal"] {
    --bg-color: #071920;
    --panel-bg: rgba(14, 38, 45, 0.78);
    --text-primary: #d7eeed;
    --text-accent: #88e4db;
    --border-color: rgba(86, 157, 158, 0.35);
    --btn-bg: rgba(136, 228, 219, 0.12);
    --btn-hover: rgba(136, 228, 219, 0.25);
    --msg-user: rgba(136, 228, 219, 0.15);
    --msg-ai: rgba(14, 38, 45, 0.85);
    --glass-shadow: inset 0 0 1px rgba(136, 228, 219, 0.3), 0 8px 32px rgba(0, 0, 0, 0.6);
    --glass-blur: blur(20px) saturate(130%);
}

body[data-theme="shells-forma"] {
    --bg-color: #f4f2eb;
    --panel-bg: rgba(238, 236, 228, 0.88);
    --text-primary: #272923;
    --text-accent: #c7472d;
    --border-color: rgba(207, 205, 193, 0.85);
    --btn-bg: rgba(199, 71, 45, 0.1);
    --btn-hover: rgba(199, 71, 45, 0.2);
    --msg-user: rgba(199, 71, 45, 0.12);
    --msg-ai: rgba(255, 255, 255, 0.95);
    --glass-shadow: inset 0 0 1px rgba(255, 255, 255, 0.9), 0 8px 30px rgba(0, 0, 0, 0.08);
    --glass-blur: blur(20px) saturate(110%);
}

/* --- AI AGENT HOMES (OPENAI ARCHITECTURAL ARTWORK DESIGNS) --- */
body[data-theme="homes-hearth"], body[data-theme="hearth"] {
    --bg-color: #17120f;
    --panel-bg: rgba(45, 28, 20, 0.82);
    --text-primary: #f9e5cc;
    --text-accent: #f3c4a0;
    --border-color: rgba(239, 209, 169, 0.35);
    --btn-bg: rgba(243, 196, 160, 0.15);
    --btn-hover: rgba(243, 196, 160, 0.28);
    --msg-user: rgba(243, 196, 160, 0.18);
    --msg-ai: rgba(35, 22, 16, 0.88);
    --glass-shadow: inset 0 0 1px rgba(243, 196, 160, 0.4), 0 12px 45px rgba(0, 0, 0, 0.7);
    --glass-blur: blur(24px) saturate(140%);
    background-image: url('/static/themes/shells/assets/hearth.png');
    background-size: cover;
    background-position: center;
}

body[data-theme="homes-parallax"], body[data-theme="parallax"] {
    --bg-color: #140c23;
    --panel-bg: rgba(35, 22, 50, 0.82);
    --text-primary: #f4eafd;
    --text-accent: #e1d0fa;
    --border-color: rgba(214, 197, 245, 0.35);
    --btn-bg: rgba(225, 208, 250, 0.15);
    --btn-hover: rgba(225, 208, 250, 0.28);
    --msg-user: rgba(225, 208, 250, 0.18);
    --msg-ai: rgba(26, 17, 38, 0.88);
    --glass-shadow: inset 0 0 1px rgba(225, 208, 250, 0.4), 0 12px 45px rgba(0, 0, 0, 0.7);
    --glass-blur: blur(24px) saturate(140%);
    background-image: url('/static/themes/shells/assets/parallax.png');
    background-size: cover;
    background-position: center;
}

body[data-theme="homes-bastion"], body[data-theme="bastion"] {
    --bg-color: #10130f;
    --panel-bg: rgba(22, 25, 20, 0.88);
    --text-primary: #ede6d8;
    --text-accent: #ddca9e;
    --border-color: rgba(222, 208, 181, 0.35);
    --btn-bg: rgba(221, 202, 158, 0.15);
    --btn-hover: rgba(221, 202, 158, 0.28);
    --msg-user: rgba(221, 202, 158, 0.18);
    --msg-ai: rgba(17, 20, 16, 0.92);
    --glass-shadow: inset 0 0 1px rgba(221, 202, 158, 0.4), 0 12px 45px rgba(0, 0, 0, 0.75);
    --glass-blur: blur(24px) saturate(120%);
    background-image: url('/static/themes/shells/assets/bastion.png');
    background-size: cover;
    background-position: center;
}

body[data-theme="homes-lucent"], body[data-theme="lucent"] {
    --bg-color: #edf2f2;
    --panel-bg: rgba(255, 255, 255, 0.88);
    --text-primary: #304b56;
    --text-accent: #496977;
    --border-color: rgba(73, 105, 119, 0.35);
    --btn-bg: rgba(73, 105, 119, 0.12);
    --btn-hover: rgba(73, 105, 119, 0.22);
    --msg-user: rgba(73, 105, 119, 0.14);
    --msg-ai: rgba(255, 255, 255, 0.95);
    --glass-shadow: inset 0 0 1px rgba(255, 255, 255, 0.9), 0 12px 40px rgba(48, 75, 86, 0.12);
    --glass-blur: blur(24px) saturate(120%);
    background-image: url('/static/themes/shells/assets/lucent.png');
    background-size: cover;
    background-position: center;
}

body[data-theme="homes-reverie"], body[data-theme="reverie"] {
    --bg-color: #23131b;
    --panel-bg: rgba(55, 28, 38, 0.84);
    --text-primary: #fae5dc;
    --text-accent: #eccab7;
    --border-color: rgba(239, 209, 192, 0.35);
    --btn-bg: rgba(236, 202, 183, 0.15);
    --btn-hover: rgba(236, 202, 183, 0.28);
    --msg-user: rgba(236, 202, 183, 0.18);
    --msg-ai: rgba(36, 18, 25, 0.9);
    --glass-shadow: inset 0 0 1px rgba(236, 202, 183, 0.4), 0 12px 45px rgba(0, 0, 0, 0.7);
    --glass-blur: blur(24px) saturate(140%);
    background-image: url('/static/themes/shells/assets/reverie.png');
    background-size: cover;
    background-position: center;
}

body[data-theme^="homes-"] #vfx-bg,
body[data-theme="hearth"] #vfx-bg,
body[data-theme="parallax"] #vfx-bg,
body[data-theme="bastion"] #vfx-bg,
body[data-theme="lucent"] #vfx-bg,
body[data-theme="reverie"] #vfx-bg {
    opacity: 0.15;
    mix-blend-mode: overlay;
}

/* --- LIGHT MODE SPECIFICATION --- */
body[data-mode="light"] {
    --bg-color: #f8fafc;
    --panel-bg: rgba(255, 255, 255, 0.88);
    --text-primary: #0f172a;
    --text-accent: #0284c7;
    --border-color: rgba(2, 132, 199, 0.25);
    --btn-bg: rgba(2, 132, 199, 0.08);
    --btn-hover: rgba(2, 132, 199, 0.18);
    --msg-user: #e0f2fe;
    --msg-ai: #ffffff;
    --glass-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.9), 0 10px 30px rgba(15, 23, 42, 0.07);
    --glass-blur: blur(20px) saturate(130%);
}

body[data-mode="light"] #vfx-bg {
    opacity: 0.12;
    mix-blend-mode: multiply;
}

body[data-mode="light"] .theme-selector select,
body[data-mode="light"] .model-selector select,
body[data-mode="light"] .chat-input-area input,
body[data-mode="light"] .modal-content,
body[data-mode="light"] .settings-section,
body[data-mode="light"] .workspace-files-list,
body[data-mode="light"] .memory-cards-container {
    background: rgba(255, 255, 255, 0.92);
    color: #0f172a;
    border-color: rgba(0, 0, 0, 0.12);
}

body[data-mode="light"] .chat-input-area input::placeholder {
    color: #94a3b8;
}

body[data-mode="light"] .chat-bubble.msg-ai {
    color: #0f172a;
    box-shadow: 0 4px 15px rgba(0,0,0,0.06);
    border: 1px solid rgba(0,0,0,0.08);
}

body[data-mode="light"] .chat-bubble.msg-user {
    color: #0369a1;
    border: 1px solid rgba(2, 132, 199, 0.25);
}

body[data-mode="light"] .chat-header h2,
body[data-mode="light"] .brand h3 {
    color: #0284c7;
}

body[data-mode="light"] .toggle-container {
    background: rgba(0, 0, 0, 0.04);
    border-color: rgba(0, 0, 0, 0.08);
}

body[data-mode="light"] .toggle-label {
    color: #0f172a;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, Roboto, Helvetica, Arial, sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    overflow: hidden;
    height: 100vh;
    transition: all 0.5s ease;
    
    /* App-like feel */
    overscroll-behavior-y: none;
    -webkit-tap-highlight-color: transparent;
    
    /* iOS Safe Area */
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

#particles-js {
    position: absolute;
    width: 100%;
    height: 100%;
    z-index: 1;
}

/* CHAT APP CONTAINER */
.app-container {
    position: relative;
    z-index: 10;
    display: flex;
    height: 100vh;
    padding: 24px;
    gap: 24px;
}

/* SIDEBAR */
.sidebar {
    width: 300px;
    background: var(--panel-bg);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 25px;
    display: flex;
    flex-direction: column;
    gap: 25px;
    -webkit-backdrop-filter: var(--glass-blur);
    backdrop-filter: var(--glass-blur);
    box-shadow: var(--glass-shadow);
}

.brand h3 {
    color: var(--text-accent);
    letter-spacing: 2px;
    font-weight: 800;
}
.brand span {
    font-size: 0.8rem;
    opacity: 0.7;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.user-info .btn-logout {
    display: inline-block;
    margin-top: 10px;
    color: var(--text-accent);
    text-decoration: none;
    font-size: 0.85rem;
    padding: 5px 10px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    transition: 0.3s;
}
.user-info .btn-logout:hover {
    background: var(--btn-hover);
}

.theme-selector select, .model-selector select {
    width: 100%;
    padding: 12px;
    margin-top: 10px;
    background: rgba(6, 11, 20, 0.3);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    outline: none;
    font-size: 0.95rem;
    cursor: pointer;
    box-shadow: inset 0 2px 5px rgba(255, 255, 255, 0.05), 0 4px 15px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(10px);
    appearance: none;
    transition: all 0.3s ease;
    /* Add a custom sleek dropdown arrow */
    background-image: url('data:image/svg+xml;charset=US-ASCII,<svg width="12" height="8" viewBox="0 0 12 8" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M1 1.5L6 6.5L11 1.5" stroke="%23e5b344" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>');
    background-repeat: no-repeat;
    background-position: right 15px top 50%;
}
.theme-selector select:focus, .model-selector select:focus, .theme-selector select:hover, .model-selector select:hover {
    border-color: var(--text-accent);
    box-shadow: inset 0 2px 5px rgba(255, 255, 255, 0.1), 0 0 15px rgba(229, 179, 68, 0.3);
    background-color: rgba(6, 11, 20, 0.5);
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
    font-size: 0.9rem;
}

.dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #ff3333;
}
.dot.active {
    background: #00ff00;
    box-shadow: 0 0 10px #00ff00;
}

/* CHAT MAIN */
.chat-main {
    flex: 1;
    min-height: 0; /* Fixed scroll overflow bug */
    background: var(--panel-bg);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
    -webkit-backdrop-filter: var(--glass-blur);
    backdrop-filter: var(--glass-blur);
    box-shadow: var(--glass-shadow);
}

.chat-header {
    padding: max(20px, env(safe-area-inset-top)) 25px 20px 25px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-accent);
    background: rgba(0,0,0,0.1);
    -webkit-app-region: drag;
}
.chat-header h2 {
    font-size: 1.2rem;
    letter-spacing: 1px;
}

.chat-window {
    flex: 1;
    min-height: 0; /* Fixed scroll overflow bug */
    padding: 25px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 20px;
    z-index: 2;
}

.message {
    max-width: 85%;
    padding: 15px 20px;
    border-radius: 12px;
    line-height: 1.6;
    word-wrap: break-word;
    z-index: 2;
    font-size: 0.95rem;
}

.msg-user {
    align-self: flex-end;
    background: var(--msg-user);
    border: 1px solid var(--border-color);
    border-bottom-right-radius: 4px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

.msg-ai {
    align-self: flex-start;
    background: var(--msg-ai);
    border: 1px solid var(--border-color);
    border-bottom-left-radius: 4px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}
.msg-love {
    align-self: center;
    background: rgba(255, 0, 100, 0.15);
    border: 1px solid #ff0066;
    color: #ff0066;
    font-style: italic;
    font-weight: bold;
    text-align: center;
    width: 90%;
    margin-bottom: 20px;
    border-radius: 12px;
    box-shadow: 0 0 15px rgba(255,0,100,0.2);
    animation: heartBeat 2s infinite;
}

@keyframes heartBeat {
  0% { transform: scale(1); }
  50% { transform: scale(1.02); box-shadow: 0 0 25px rgba(255,0,100,0.4); }
  100% { transform: scale(1); }
}

.chat-input-area {
    padding: 20px 25px;
    border-top: 1px solid var(--border-color);
    position: relative;
    z-index: 10;
    background: rgba(0,0,0,0.15);
}

.input-wrapper {
    display: flex;
    gap: 15px;
}

#chatInput {
    flex: 1;
    padding: 16px 20px;
    background: rgba(0,0,0,0.3);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: 12px;
    font-size: 1rem;
    outline: none;
    transition: 0.3s;
}
#chatInput:focus {
    box-shadow: 0 0 15px var(--border-color);
    background: rgba(0,0,0,0.4);
}

#sendBtn {
    background: var(--btn-bg);
    border: 1px solid var(--border-color);
    padding: 0 20px;
    border-radius: 12px;
    color: var(--text-accent);
    cursor: pointer;
    transition: 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}
#sendBtn:hover {
    background: var(--btn-hover);
    box-shadow: 0 0 20px var(--border-color);
    transform: scale(1.05);
}

/* PULSING INDICATOR */
.hidden { display: none !important; }

/* ===== ELECTRICAL CURRENT LOADING ANIMATION ===== */
#electric-loader {
    position: absolute;
    top: -55px;
    left: 0;
    right: 0;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    overflow: visible;
}

#electric-loader .electric-svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 40px;
}

#electric-loader .arc {
    stroke-linecap: round;
    opacity: 0;
    animation: arcFlicker 0.08s infinite alternate;
}
#electric-loader .arc-1 { stroke: #00f0ff; stroke-width: 2.5; animation-delay: 0s; }
#electric-loader .arc-2 { stroke: #e5b344; stroke-width: 1.8; animation-delay: 0.03s; }
#electric-loader .arc-3 { stroke: rgba(255,255,255,0.9); stroke-width: 1; animation-delay: 0.06s; }

@keyframes arcFlicker {
    0% { opacity: 0.3; }
    50% { opacity: 1; }
    100% { opacity: 0.5; }
}

#electric-loader .electric-sparks {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 40px;
    pointer-events: none;
}

.spark {
    position: absolute;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: #00f0ff;
    box-shadow: 0 0 6px #00f0ff, 0 0 12px #00f0ff;
    animation: sparkPop 0.3s ease-out forwards;
}

@keyframes sparkPop {
    0% { transform: scale(1); opacity: 1; }
    100% { transform: scale(0) translateY(-15px); opacity: 0; }
}

#electric-loader .electric-label {
    position: absolute;
    bottom: -2px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--text-accent);
    text-shadow: 0 0 8px var(--text-accent);
    white-space: nowrap;
}

/* UNIFIED ACTION TOOLBAR */
.action-toolbar {
    display: flex;
    gap: 12px;
    margin-bottom: 15px;
    align-items: center;
}

.tool-btn {
    background: rgba(0,0,0,0.3);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    padding: 8px 15px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tool-btn:hover {
    background: var(--btn-hover);
    color: #fff;
    box-shadow: 0 0 15px var(--border-color);
    transform: translateY(-2px);
}

.toolbar-divider {
    height: 24px;
    width: 1px;
    background-color: var(--border-color);
    opacity: 0.5;
    margin: 0 5px;
}

/* DRAG AND DROP OVERLAY */
#dropZone {
    position: relative;
}

#dropOverlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    border: 2px dashed var(--text-accent);
    border-radius: 12px;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-accent);
    font-size: 1.2rem;
    letter-spacing: 1px;
    pointer-events: none;
    -webkit-backdrop-filter: blur(5px);
    backdrop-filter: blur(5px);
}

/* MARKDOWN STYLING TWEAKS */
.message pre {
    background: rgba(0,0,0,0.5);
    padding: 15px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 15px 0;
    border: 1px solid rgba(255,255,255,0.1);
}

.message code {
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.9rem;
}

/* CHARACTER ANIMATION - Z-INDEX FIX AND HIGH-RES GIFS */
#character-container {
    position: absolute;
    bottom: 120px; /* Right above the toolbar */
    left: 0;
    width: 100%;
    height: 150px;
    pointer-events: none;
    overflow: hidden;
    z-index: 50; /* Ensure it is in front of the chat window! */
}

#dancing-character {
    position: absolute;
    bottom: 0;
    width: 150px; /* Made slightly bigger */
    height: 150px;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center bottom;
    animation: walkAcross 15s linear infinite;
    filter: drop-shadow(0 5px 15px rgba(0,0,0,0.5));
}

/* Highly Reliable Direct GIF Links */
body[data-theme="snoopy"] #dancing-character {
    background-image: url('https://media1.tenor.com/m/tC7K3jLdxyYAAAAC/snoopy-dance.gif');
}
body[data-theme="stitch"] #dancing-character {
    background-image: url('https://media1.tenor.com/m/fLzF1t8QG9sAAAAC/stitch-dance.gif');
}
body[data-theme="lola"] #dancing-character {
    background-image: url('https://media1.tenor.com/m/2s9V9p1G8yIAAAAC/lola-bunny.gif');
}

@keyframes walkAcross {
    0%   { left: -200px; transform: scaleX(1); }
    45%  { left: calc(100% + 50px); transform: scaleX(1); }
    50%  { left: calc(100% + 50px); transform: scaleX(-1); }
    95%  { left: -200px; transform: scaleX(-1); }
    100% { left: -200px; transform: scaleX(1); }
}

/* LOGIN PAGE STYLES - GLASSMORPHISM UPGRADE */
.login-container {
    position: relative;
    z-index: 10;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
}

.login-box {
    background: var(--panel-bg);
    padding: 50px 40px;
    border-radius: 20px;
    border: 1px solid var(--border-color);
    width: 100%;
    max-width: 420px;
    box-shadow: var(--glass-shadow);
    -webkit-backdrop-filter: var(--glass-blur);
    backdrop-filter: var(--glass-blur);
}

.login-box h2 {
    color: var(--text-accent);
    text-align: center;
    margin-bottom: 5px;
    letter-spacing: 3px;
    font-weight: 800;
}

.login-box .subtitle {
    text-align: center;
    font-size: 0.95rem;
    opacity: 0.7;
    margin-bottom: 35px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.input-group {
    margin-bottom: 25px;
}

.input-group label {
    display: block;
    margin-bottom: 10px;
    color: var(--text-primary);
    font-size: 0.95rem;
}

.input-group input {
    width: 100%;
    padding: 15px;
    background: rgba(0,0,0,0.4);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 1rem;
    outline: none;
    transition: 0.3s;
}

.input-group input:focus {
    box-shadow: 0 0 15px var(--border-color);
    background: rgba(0,0,0,0.6);
}

.btn-primary {
    width: 100%;
    padding: 15px;
    background: var(--btn-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-accent);
    font-size: 1.1rem;
    font-weight: bold;
    cursor: pointer;
    transition: 0.3s;
    margin-top: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.btn-primary:hover {
    background: var(--btn-hover);
    box-shadow: 0 0 20px var(--border-color);
    color: #fff;
}

.error {
    color: #ff4444;
    text-align: center;
    margin-bottom: 20px;
    background: rgba(255,0,0,0.1);
    padding: 10px;
    border-radius: 6px;
    border: 1px solid rgba(255,0,0,0.3);
}

.forgot-password {
    text-align: center;
    margin-top: 25px;
}

.forgot-password a {
    color: var(--text-primary);
    text-decoration: none;
    font-size: 0.9rem;
    opacity: 0.7;
    transition: 0.3s;
}
.forgot-password a:hover {
    opacity: 1;
    color: var(--text-accent);
}

/* Message Controls */
.msg-controls {
    display: flex;
    gap: 8px;
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}
.ctrl-btn {
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(0, 240, 255, 0.3);
    border-radius: 6px;
    color: white;
    font-size: 14px;
    cursor: pointer;
    padding: 4px 8px;
    transition: all 0.2s ease;
}
.ctrl-btn:hover {
    background: rgba(0, 240, 255, 0.2);
    border-color: rgba(0, 240, 255, 0.8);
    transform: translateY(-1px);
}

body[data-user="ana"] #character-container {
    animation: none !important;
    bottom: 0px !important;
    width: 100px;
    height: 100px;
    transition: none; /* Let JS handle transform */
}
body[data-user="ana"] #dancing-character {
    width: 100px;
    height: 100px;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: bottom;
    /* Remove the hardcoded GIF */
    background-image: none !important; 
}

/* ==========================================================================
   ADVANCED CREATION STUDIO - ENHANCED CONTROLS, AUDIO, SELECTION & MODAL
   ========================================================================== */

/* Full Cursor Selection & Copy Enabled */
body, .app-container, .chat-window, .message, .message *, pre, code, p, span, h1, h2, h3, h4, div {
    -webkit-user-select: text !important;
    user-select: text !important;
}

button, .tool-btn, .btn-logout, select, .ctrl-btn, .btn-settings, .mic-btn, .modal-close-btn, .header-icon-btn {
    -webkit-user-select: none !important;
    user-select: none !important;
    cursor: pointer !important;
}

::selection {
    background: rgba(0, 240, 255, 0.45) !important;
    color: #ffffff !important;
}

::-moz-selection {
    background: rgba(0, 240, 255, 0.45) !important;
    color: #ffffff !important;
}

/* Brand Logo */
.brand-header {
    display: flex;
    align-items: center;
    gap: 12px;
}
.brand-logo {
    width: 38px;
    height: 38px;
    object-fit: contain;
    filter: drop-shadow(0 0 8px rgba(0, 240, 255, 0.6));
}
.studio-sub {
    font-size: 10px;
    color: var(--text-accent);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    display: block;
}
.association-tag {
    font-size: 8.5px;
    color: #00f0ff;
    letter-spacing: 0.06em;
    margin-top: 6px;
    text-transform: uppercase;
    opacity: 0.15;
}

/* User Actions */
.user-actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}
.btn-settings {
    flex: 1;
    background: rgba(0, 240, 255, 0.12);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: 8px;
    padding: 6px 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 11px;
    font-weight: 600;
    transition: all 0.25s ease;
}
.btn-settings:hover {
    background: rgba(0, 240, 255, 0.25);
    border-color: var(--text-accent);
    transform: translateY(-1px);
}

.header-icon-btn {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 6px;
    padding: 4px 8px;
    font-size: 13px;
    transition: 0.2s;
}
.header-icon-btn:hover {
    background: rgba(255, 77, 79, 0.2);
    border-color: #ff4d4f;
}

/* STT Microphone Button */
.mic-btn {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: 10px;
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 6px;
    transition: all 0.25s ease;
}
.mic-btn:hover {
    background: rgba(0, 240, 255, 0.2);
    color: var(--text-accent);
    border-color: var(--text-accent);
}
.mic-btn.listening {
    background: rgba(255, 59, 48, 0.25) !important;
    border-color: #ff3b30 !important;
    color: #ff3b30 !important;
    animation: micPulse 1.2s infinite ease-in-out;
}
@keyframes micPulse {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(255, 59, 48, 0.6); }
    50% { transform: scale(1.08); box-shadow: 0 0 15px 4px rgba(255, 59, 48, 0.7); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(255, 59, 48, 0); }
}

/* Attached Files Chips */
.attached-files-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px 12px;
    background: rgba(0, 0, 0, 0.35);
    border-radius: 8px;
    margin-bottom: 8px;
    border: 1px solid rgba(0, 240, 255, 0.25);
}
.file-chip {
    background: rgba(0, 240, 255, 0.15);
    border: 1px solid var(--border-color);
    color: #fff;
    border-radius: 6px;
    padding: 3px 8px;
    font-size: 11px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.file-chip .remove-chip {
    cursor: pointer;
    opacity: 0.7;
    font-weight: bold;
}
.file-chip .remove-chip:hover {
    opacity: 1;
    color: #ff4d4f;
}

/* Settings Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.7);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.3s ease;
}
.modal-overlay.hidden {
    display: none !important;
}
.modal-content {
    width: 90%;
    max-width: 560px;
    background: var(--panel-bg);
    border: 1px solid var(--border-color);
    border-radius: 18px;
    padding: 24px;
    box-shadow: var(--glass-shadow);
    -webkit-backdrop-filter: var(--glass-blur);
    backdrop-filter: var(--glass-blur);
    color: var(--text-primary);
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 12px;
    margin-bottom: 16px;
}
.modal-close-btn {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--text-primary);
    cursor: pointer;
    opacity: 0.7;
    transition: 0.2s;
}
.modal-close-btn:hover {
    opacity: 1;
    color: var(--text-accent);
}
.settings-section {
    margin-bottom: 16px;
    background: rgba(0, 0, 0, 0.25);
    border-radius: 10px;
    padding: 12px 14px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}
.settings-section h4 {
    font-size: 12px;
    color: var(--text-accent);
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.section-desc {
    font-size: 11px;
    opacity: 0.75;
    margin-bottom: 8px;
}
.setting-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    font-size: 13px;
}
.setting-row:last-child {
    margin-bottom: 0;
}
.setting-row select, .setting-row input[type="range"] {
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: 6px;
    padding: 4px 8px;
}
.workspace-files-list {
    max-height: 100px;
    overflow-y: auto;
    font-size: 11px;
    font-family: monospace;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 6px;
    padding: 8px;
}
.modal-footer {
    display: flex;
    justify-content: flex-end;
    margin-top: 16px;
}
.btn-primary {
    background: var(--text-accent);
    color: #000;
    border: none;
    border-radius: 8px;
    padding: 8px 20px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
}
.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 0 12px var(--text-accent);
}

/* Social Login Buttons */
.social-logins { margin-top: 25px; display: flex; flex-direction: column; gap: 12px; }
.divider { display: flex; align-items: center; text-align: center; color: rgba(255,255,255,0.4); font-size: 0.8rem; letter-spacing: 2px; margin-bottom: 5px; }
.divider::before, .divider::after { content: ''; flex: 1; border-bottom: 1px solid rgba(255,255,255,0.1); }
.divider::before { margin-right: 15px; } .divider::after { margin-left: 15px; }
.btn-social {
    display: flex; align-items: center; justify-content: center; gap: 10px;
    width: 100%; padding: 12px; border-radius: 12px; font-weight: 600; font-size: 0.95rem;
    cursor: pointer; transition: all 0.3s ease; border: 1px solid rgba(255,255,255,0.1);
    background: rgba(255,255,255,0.05); color: #fff;
    box-shadow: inset 0 1px 3px rgba(255,255,255,0.1), 0 4px 10px rgba(0,0,0,0.3);
}
.btn-social img { width: 20px; height: 20px; }
.btn-social:hover { background: rgba(255,255,255,0.1); transform: translateY(-1px); box-shadow: inset 0 1px 3px rgba(255,255,255,0.2), 0 6px 15px rgba(0,0,0,0.4); }
.create-btn { margin-top: 10px; background: transparent; border: 1px dashed var(--border-color); color: var(--text-accent); }
.create-btn:hover { background: var(--btn-bg); border-style: solid; }

/* Triangulation Toggle */
.toggle-container { display: flex; justify-content: space-between; align-items: center; margin-top: 12px; background: rgba(0,0,0,0.2); padding: 12px 15px; border-radius: 10px; border: 1px solid rgba(255,255,255,0.05); }
.toggle-label { font-size: 0.9rem; font-weight: 500; color: #fff; }
.switch { position: relative; display: inline-block; width: 44px; height: 24px; margin: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: rgba(255,255,255,0.1); transition: .4s; border-radius: 24px; border: 1px solid rgba(255,255,255,0.1); }
.slider:before { position: absolute; content: ""; height: 16px; width: 16px; left: 3px; bottom: 3px; background-color: #aaa; transition: .4s; border-radius: 50%; box-shadow: 0 2px 4px rgba(0,0,0,0.5); }
input:checked + .slider { background-color: rgba(229, 179, 68, 0.2); border-color: var(--border-color); }
input:checked + .slider:before { transform: translateX(20px); background-color: var(--text-accent); box-shadow: 0 0 10px rgba(229, 179, 68, 0.8); }

/* Lucide Icon Sizing */
.icon-sm { width: 18px; height: 18px; stroke-width: 2.5; }
.tool-btn { display: flex; align-items: center; gap: 8px; justify-content: center; }

/* Mode Toggle */
.mode-toggle-wrap {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 10px;
    padding: 8px 12px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    border-radius: 10px;
}
.mode-label {
    font-size: 0.82rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-primary);
}

/* Brain Memory Modal */
.memory-modal-content {
    max-width: 700px;
    width: 90%;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
}
.memory-header-title {
    display: flex;
    align-items: center;
    gap: 12px;
}
.memory-badge {
    background: var(--btn-bg);
    border: 1px solid var(--border-color);
    color: var(--text-accent);
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: bold;
}
.memory-search-bar {
    display: flex;
    gap: 10px;
    margin-bottom: 12px;
}
.memory-search-bar input {
    flex: 1;
    padding: 10px 14px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: rgba(0, 0, 0, 0.3);
    color: var(--text-primary);
    outline: none;
    font-size: 0.9rem;
}
.btn-refresh {
    background: var(--btn-bg);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 8px 14px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s;
}
.btn-refresh:hover {
    background: var(--btn-hover);
}
.memory-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 14px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 8px;
    overflow-x: auto;
}
.memory-tab {
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-primary);
    opacity: 0.7;
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.82rem;
    white-space: nowrap;
    transition: all 0.2s;
}
.memory-tab:hover {
    opacity: 1;
    background: var(--btn-bg);
}
.memory-tab.active {
    opacity: 1;
    border-color: var(--border-color);
    background: var(--btn-bg);
    color: var(--text-accent);
    font-weight: 600;
}
.memory-cards-container {
    max-height: 480px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding-right: 4px;
}
.memory-card {
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    transition: all 0.2s ease;
}
.memory-card:hover {
    border-color: var(--text-accent);
    transform: translateY(-1px);
}
.memory-card-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.memory-tag {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 2px 6px;
    border-radius: 4px;
    background: var(--btn-bg);
    color: var(--text-accent);
    border: 1px solid var(--border-color);
    font-weight: 600;
}
.memory-date {
    font-size: 0.72rem;
    opacity: 0.6;
}
.memory-card-key {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-accent);
}
.memory-card-content {
    font-size: 0.88rem;
    line-height: 1.4;
    opacity: 0.9;
    white-space: pre-wrap;
}

/* Media Preview Drawer */
.media-drawer {
    position: fixed;
    right: 24px;
    top: 24px;
    bottom: 24px;
    width: 380px;
    background: var(--panel-bg);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    z-index: 100;
    box-shadow: var(--glass-shadow);
    backdrop-filter: var(--glass-blur);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
.media-drawer.hidden {
    display: none !important;
}
.media-drawer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 12px;
    margin-bottom: 15px;
}
.media-drawer-header h4 {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-accent);
}
.drawer-close-btn {
    background: transparent;
    border: none;
    font-size: 1.4rem;
    color: var(--text-primary);
    cursor: pointer;
    opacity: 0.7;
}
.drawer-close-btn:hover {
    opacity: 1;
}
.media-drawer-body {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.3);
    padding: 10px;
}
.media-drawer-body img, .media-drawer-body video {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 8px;
}
.media-placeholder {
    color: var(--text-primary);
    opacity: 0.5;
    font-size: 0.85rem;
    text-align: center;
}
.media-drawer-actions {
    display: flex;
    gap: 10px;
    margin-top: 15px;
}
.btn-secondary {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
}
.btn-secondary:hover {
    background: var(--btn-hover);
}

/* ===== V2: MESSAGE ACTION BAR ===== */
.msg-actions {
    display: flex;
    gap: 4px;
    margin-top: 8px;
    padding-top: 6px;
    opacity: 0.3;
    transition: opacity 0.3s ease;
}
.message:hover .msg-actions {
    opacity: 0.15;
}
.msg-action-btn {
    background: transparent;
    border: 1px solid transparent;
    border-radius: 5px;
    color: var(--text-primary);
    font-size: 13px;
    cursor: pointer;
    padding: 3px 7px;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: all 0.2s ease;
    opacity: 0.6;
}
.msg-action-btn:hover {
    opacity: 1;
    background: var(--btn-bg);
    border-color: var(--border-color);
    transform: translateY(-1px);
}
.msg-action-btn.active {
    color: var(--text-accent);
    opacity: 1;
}
.msg-action-btn svg {
    width: 14px;
    height: 14px;
    stroke-width: 2;
}

/* ===== V2: SIDEBAR REDESIGN ===== */
.sidebar {
    width: 290px;
    height: calc(100vh - 48px);
    max-height: calc(100vh - 48px);
    min-height: 0;
    background: var(--panel-bg);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 20px 20px 10px 20px;
    display: flex;
    flex-direction: column;
    gap: 0;
    -webkit-backdrop-filter: var(--glass-blur);
    backdrop-filter: var(--glass-blur);
    box-shadow: var(--glass-shadow);
    overflow: hidden;
    box-sizing: border-box;
}

.sidebar-search {
    margin-top: 15px;
    margin-bottom: 10px;
}
.sidebar-search input {
    width: 100%;
    padding: 9px 14px;
    background: rgba(0,0,0,0.25);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: 10px;
    font-size: 0.85rem;
    outline: none;
    transition: 0.3s;
}
.sidebar-search input:focus {
    border-color: var(--text-accent);
    box-shadow: 0 0 8px rgba(229,179,68,0.2);
}

.sidebar-categories {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-bottom: 10px;
}
.sidebar-cat {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 10px;
    color: var(--text-primary);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
}
.sidebar-cat:hover {
    background: var(--btn-bg);
    border-color: var(--border-color);
}
.sidebar-cat.active {
    background: var(--btn-bg);
    border-color: var(--border-color);
    color: var(--text-accent);
    font-weight: 700;
}
.sidebar-cat span:first-of-type {
    flex: 1;
}
.cat-badge {
    background: rgba(0,0,0,0.3);
    color: var(--text-accent);
    font-size: 0.7rem;
    padding: 1px 6px;
    border-radius: 10px;
    font-weight: 700;
    min-width: 18px;
    text-align: center;
}

.sidebar-sessions {
    flex: 1;
    overflow-y: auto;
    margin: 8px 0;
    padding-right: 4px;
}
.session-item {
    padding: 8px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.8rem;
    color: var(--text-primary);
    transition: all 0.2s;
    margin-bottom: 2px;
    border: 1px solid transparent;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.session-item:hover {
    background: var(--btn-bg);
    border-color: var(--border-color);
}
.session-item .session-title {
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.session-item .session-preview {
    font-size: 0.72rem;
    opacity: 0.6;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.session-empty {
    text-align: center;
    opacity: 0.5;
    font-size: 0.8rem;
    padding: 20px 10px;
}

.sidebar-bottom {
    flex-shrink: 0;
    margin-top: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding-top: 12px;
    border-top: 1px solid rgba(255,255,255,0.08);
    background: var(--panel-bg);
    z-index: 5;
}
.sidebar-action-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 0.82rem;
    cursor: pointer;
    transition: all 0.2s;
}
.sidebar-action-btn:hover {
    background: var(--btn-bg);
    border-color: var(--border-color);
    color: var(--text-accent);
}
.sidebar-user {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.75rem;
    opacity: 0.7;
    padding: 6px 0 0;
}
.sidebar-user .btn-logout {
    color: var(--text-accent);
    text-decoration: none;
    font-size: 0.75rem;
    padding: 3px 8px;
    border: 1px solid var(--border-color);
    border-radius: 5px;
    transition: 0.2s;
}
.sidebar-user .btn-logout:hover {
    background: var(--btn-hover);
}

/* ===== V2: TEXTAREA CHAT INPUT ===== */
#chatInput {
    flex: 1;
    padding: 12px 16px;
    background: rgba(0,0,0,0.3);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: 12px;
    font-size: 0.95rem;
    outline: none;
    transition: 0.3s;
    resize: none;
    min-height: 44px;
    max-height: 140px;
    overflow-y: auto;
    font-family: inherit;
    line-height: 1.4;
}

/* ===== V2: IMAGE PREVIEW BAR ===== */
.image-preview-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px;
    background: rgba(0,0,0,0.35);
    border-radius: 10px;
    margin-bottom: 8px;
    border: 1px solid rgba(0,240,255,0.2);
}
.image-preview-thumb {
    position: relative;
    width: 64px;
    height: 64px;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border-color);
}
.image-preview-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.image-preview-thumb .remove-img {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 18px;
    height: 18px;
    background: rgba(0,0,0,0.7);
    color: #ff4d4f;
    border: none;
    border-radius: 50%;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ===== V2: INLINE CHAT IMAGES ===== */
.message img.chat-image {
    max-width: 320px;
    max-height: 280px;
    border-radius: 12px;
    border: 1px solid rgba(0, 240, 255, 0.3);
    margin: 8px 0;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
    transition: transform 0.25s ease, box-shadow 0.25s ease;
    display: block;
}
.message img.chat-image:hover {
    transform: scale(1.025);
    box-shadow: 0 6px 22px rgba(0, 240, 255, 0.3);
    border-color: var(--text-accent);
}

/* AI-Generated Rich Image Preview Card */
.ai-image-preview-card {
    background: rgba(0, 0, 0, 0.45);
    border: 1px solid rgba(0, 240, 255, 0.25);
    border-radius: 14px;
    padding: 10px;
    margin: 10px 0;
    display: inline-flex;
    flex-direction: column;
    max-width: 360px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(8px);
}
.ai-image-preview-card img.chat-image {
    margin: 0;
    width: 100%;
    max-width: 100%;
    border-radius: 10px;
    border: none;
}
.ai-image-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 8px;
    padding: 2px 4px;
    font-size: 0.78rem;
    color: var(--text-secondary);
}
.ai-image-card-footer .img-name {
    font-family: monospace;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 200px;
}
.ai-image-card-footer .img-download-btn {
    color: var(--text-accent);
    text-decoration: none;
    font-weight: 500;
    padding: 3px 8px;
    border-radius: 6px;
    background: rgba(0, 240, 255, 0.1);
    border: 1px solid rgba(0, 240, 255, 0.3);
    transition: 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.ai-image-card-footer .img-download-btn:hover {
    background: rgba(0, 240, 255, 0.25);
    color: #fff;
    box-shadow: 0 0 8px rgba(0, 240, 255, 0.4);
}

/* ===== SUB-CHATBOX MODEL SELECTOR BAR ===== */
.chat-bottom-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 10px;
    padding: 0 4px;
    font-size: 0.82rem;
}
.model-picker-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(0, 0, 0, 0.45);
    border: 1px solid rgba(0, 240, 255, 0.25);
    border-radius: 20px;
    padding: 4px 14px;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.model-picker-wrap:hover, .model-picker-wrap:focus-within {
    border-color: var(--text-accent);
    box-shadow: 0 0 12px rgba(0, 240, 255, 0.25);
}
.model-picker-label {
    display: flex;
    align-items: center;
    gap: 5px;
    color: var(--text-accent);
    font-weight: 500;
    cursor: pointer;
    font-size: 0.8rem;
}
.model-picker-select {
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 0.82rem;
    font-family: inherit;
    outline: none;
    cursor: pointer;
    padding: 2px 6px;
}
.model-picker-select option, .model-picker-select optgroup {
    background: #0d1117;
    color: #e0e5ed;
}
.bottom-bar-status {
    display: flex;
    align-items: center;
    gap: 7px;
    color: var(--text-secondary);
    font-size: 0.78rem;
    background: rgba(0, 0, 0, 0.3);
    padding: 4px 12px;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.08);
}
.status-indicator-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #00ff88;
    box-shadow: 0 0 8px #00ff88;
}

/* ===== V2: REFERENCE MODE ===== */
body.reference-mode {
    cursor: crosshair !important;
}
body.reference-mode * {
    cursor: crosshair !important;
}
.ref-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 8000;
    pointer-events: none;
}
.ref-selection {
    position: absolute;
    background: rgba(0, 240, 255, 0.15);
    border: 1px solid rgba(0, 240, 255, 0.5);
    border-radius: 4px;
    pointer-events: none;
}

/* ===== V2: MASCOT CONTAINER ===== */
#mascot-container {
    display: none !important; /* HIDDEN BY DEFAULT ON DEFAULT SCREEN */
    position: fixed;
    bottom: 165px;
    right: 28px;
    width: 68px;
    height: 68px;
    z-index: 30;
    pointer-events: none;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    outline: none !important;
    transition: transform 0.3s ease;
}

/* Only display Snoopy mascot when snoopy or ana theme is explicitly chosen */
body[data-theme="snoopy"] #mascot-container,
body[data-theme="ana"] #mascot-container {
    display: block !important;
}
#mascot-container:hover {
    transform: scale(1.1);
}
#mascot-sprite {
    width: 100%;
    height: 100%;
    background-image: url('/static/pet/clean/snoopy-idle-transparent-loop-no-pink.gif');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center bottom;
    background-color: transparent !important;
    border: none !important;
    box-shadow: none !important;
    outline: none !important;
    filter: drop-shadow(0 4px 14px rgba(0, 240, 255, 0.45));
    animation: mascotFloat 3s ease-in-out infinite;
    transition: background-image 0.2s ease, filter 0.3s ease;
    pointer-events: auto;
    cursor: pointer;
}

body[data-theme="snoopy"] #mascot-sprite {
    background-image: url('/static/pet/clean/snoopy-idle-transparent-loop-no-pink.gif');
    filter: drop-shadow(0 4px 12px rgba(255, 105, 180, 0.45));
}

@keyframes mascotFloat {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-6px); }
}

/* ===== V2: HEADER TOOLS ===== */
.header-tools {
    display: flex;
    gap: 8px;
    -webkit-app-region: no-drag;
}
.chat-header {
    padding: 16px 25px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-accent);
    background: rgba(0,0,0,0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    -webkit-app-region: drag;
}
.header-icon-btn {
    background: rgba(0,0,0,0.3);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 8px;
    padding: 6px 12px;
    font-size: 0.8rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 6px;
    transition: 0.2s;
}
.header-icon-btn:hover {
    background: var(--btn-hover);
    border-color: var(--text-accent);
    color: var(--text-accent);
}

/* ===== V2: SETTINGS GRID LAYOUT ===== */
.settings-modal-wide {
    max-width: 820px !important;
    width: 95% !important;
}
.settings-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}
@media (max-width: 700px) {
    .settings-grid { grid-template-columns: 1fr; }
}
.settings-grid .settings-section select {
    width: 100%;
    margin-top: 4px;
}

/* ==========================================================================
   IDE WORKSPACE ENHANCEMENTS: ACTIVITY BAR, TABS, ACCORDIONS, DRAG HUD
   ========================================================================== */

/* 1. Activity Bar (Far-Left Rail) */
.activity-bar {
    width: 58px;
    background: rgba(4, 7, 13, 0.75);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    padding: 18px 0;
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    box-shadow: var(--glass-shadow);
    z-index: 12;
    flex-shrink: 0;
}
.activity-top, .activity-bottom {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}
.activity-btn {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-primary);
    opacity: 0.65;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.22s ease;
}
.ide-tab-new-btn {
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
    color: #a0a0a0;
    width: 28px;
    height: 28px;
    border-radius: 4px 4px 0 0;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    margin-left: 5px;
    -webkit-app-region: no-drag;
}
.activity-btn:hover {
    opacity: 1;
    background: var(--btn-bg);
    color: var(--text-accent);
    border-color: var(--border-color);
    transform: translateY(-1px);
}
.activity-btn.active {
    opacity: 1;
    background: var(--btn-bg);
    color: var(--text-accent);
    border-color: var(--text-accent);
    box-shadow: 0 0 12px rgba(102, 252, 241, 0.25);
}
.activity-user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--btn-bg);
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--text-accent);
    cursor: default;
}

/* 2. Sidebar Header & Actions */
.sidebar-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 4px;
    margin-top: 2px;
}
.section-title-label {
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 1.5px;
    color: var(--text-accent);
    opacity: 0.15;
}
.sidebar-header-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}
.sidebar-icon-btn {
    width: 26px;
    height: 26px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}
.sidebar-icon-btn:hover {
    background: var(--btn-hover);
    color: var(--text-accent);
    border-color: var(--text-accent);
    transform: scale(1.08);
}

/* 3. Collapsible Accordions */
.sidebar-accordions {
    flex: 1 1 0;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding-right: 6px;
    padding-bottom: 20px;
    scrollbar-width: thin;
    scrollbar-color: rgba(102, 252, 241, 0.5) rgba(0, 0, 0, 0.2);
}
.sidebar-accordions::-webkit-scrollbar {
    width: 6px;
}
.sidebar-accordions::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
}
.sidebar-accordions::-webkit-scrollbar-thumb {
    background: rgba(102, 252, 241, 0.45);
    border-radius: 4px;
    border: 1px solid rgba(102, 252, 241, 0.2);
}
.sidebar-accordions::-webkit-scrollbar-thumb:hover {
    background: rgba(102, 252, 241, 0.85);
    box-shadow: 0 0 8px rgba(102, 252, 241, 0.6);
}
.sidebar-accordions .collapsible-section:last-child {
    margin-bottom: 25px;
}

.collapsible-section {
    background: rgba(0, 0, 0, 0.22);
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: 12px;
    overflow: hidden;
    transition: border-color 0.2s ease;
}
.collapsible-section:hover {
    border-color: rgba(255, 255, 255, 0.15);
}
.collapsible-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    cursor: pointer;
    user-select: none;
    background: rgba(255, 255, 255, 0.025);
    transition: background 0.2s ease;
}
.collapsible-header:hover {
    background: rgba(255, 255, 255, 0.06);
}
.collapsible-header .header-left {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-primary);
}
.collapsible-header .header-type-icon {
    color: var(--text-accent);
    opacity: 0.15;
}
.chevron-icon {
    transition: transform 0.22s ease;
}
.collapsible-section.collapsed .chevron-icon {
    transform: rotate(-90deg);
}
.collapsible-header .header-right {
    display: flex;
    align-items: center;
    gap: 6px;
}
.section-add-btn {
    width: 22px;
    height: 22px;
    border-radius: 5px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.14);
    color: var(--text-accent);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}
.section-add-btn:hover {
    background: var(--text-accent);
    color: #050b14;
    border-color: var(--text-accent);
    transform: scale(1.1);
}
.collapsible-content {
    transition: max-height 0.25s ease, opacity 0.25s ease, padding 0.25s ease;
    max-height: 180px;
    overflow-y: auto;
    padding: 6px 8px 8px 8px;
    scrollbar-width: thin;
    scrollbar-color: rgba(229, 179, 68, 0.3) transparent;
}
.collapsible-content::-webkit-scrollbar {
    width: 4px;
}
.collapsible-content::-webkit-scrollbar-thumb {
    background: rgba(229, 179, 68, 0.3);
    border-radius: 4px;
}
.collapsible-section.collapsed .collapsible-content {
    max-height: 0 !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
    overflow: hidden !important;
    opacity: 0;
    pointer-events: none;
}
.cat-badge.active-fleet {
    background: rgba(0, 255, 136, 0.15);
    color: #00ff88;
    border: 1px solid rgba(0, 255, 136, 0.3);
}

/* Fleet Agent List inside Accordion */
.fleet-status-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 4px 2px;
}
.fleet-agent-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 8px;
    font-size: 0.78rem;
    color: var(--text-primary);
}
.fleet-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #555;
}
.fleet-dot.active {
    background: #00ff88;
    box-shadow: 0 0 6px #00ff88;
}
.fleet-role {
    margin-left: auto;
    font-size: 0.68rem;
    opacity: 0.6;
    text-transform: uppercase;
}

/* 4. Top IDE Editor Tabs Bar */
.ide-tab-bar {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px 0 12px;
    background: rgba(0, 0, 0, 0.28);
    border-bottom: 1px solid var(--border-color);
    overflow-x: auto;
    z-index: 5;
    flex-shrink: 0;
    -webkit-app-region: drag;
}
.ide-tabs-scroll {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-app-region: no-drag;
}
.ide-tabs-scroll::-webkit-scrollbar {
    display: none;
}
.ide-tab {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: rgba(255, 255, 255, 0.035);
    border: 1px solid var(--border-color);
    border-bottom: none;
    border-radius: 8px 8px 0 0;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    position: relative;
    user-select: none;
}
.ide-tab:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-accent);
}
.ide-tab.active {
    background: var(--panel-bg);
    color: var(--text-accent);
    font-weight: 700;
    border-top: 2px solid var(--text-accent);
    box-shadow: 0 -3px 12px rgba(102, 252, 241, 0.15);
}
.ide-tab .tab-title {
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.ide-tab .tab-close {
    opacity: 0.55;
    font-size: 1.1rem;
    line-height: 0.9;
    padding: 2px 4px;
    border-radius: 4px;
    transition: all 0.18s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.ide-tab .tab-close:hover {
    opacity: 1;
    background: rgba(255, 70, 70, 0.2);
    color: #ff5555;
}
.ide-tab-new-btn {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-color);
    color: var(--text-accent);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: 6px;
    margin-bottom: 4px;
    transition: all 0.2s ease;
    flex-shrink: 0;
}
.ide-tab-new-btn:hover {
    background: var(--btn-hover);
    border-color: var(--text-accent);
    transform: scale(1.08);
}

/* Chat Header Title Wrap */
.chat-header-title-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
}
.status-indicator-dot.online {
    background: #00ff88;
    box-shadow: 0 0 8px #00ff88;
}

/* 5. Fullscreen / Window-wide Drag & Drop HUD Overlay */
.fullscreen-drop-overlay {
    position: absolute;
    inset: 0;
    z-index: 9999;
    background: rgba(6, 11, 20, 0.88);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px dashed var(--text-accent);
    border-radius: 20px;
    box-shadow: inset 0 0 30px rgba(102, 252, 241, 0.25);
    pointer-events: none;
    transition: opacity 0.2s ease;
}
.drop-overlay-hud {
    text-align: center;
    color: var(--text-primary);
    padding: 40px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}
.drop-overlay-hud i {
    color: var(--text-accent);
    filter: drop-shadow(0 0 10px var(--text-accent));
}
.drop-overlay-hud h3 {
    font-size: 1.4rem;
    color: var(--text-accent);
    letter-spacing: 1px;
    margin: 0;
}
.drop-overlay-hud p {
    font-size: 0.9rem;
    opacity: 0.75;
    margin: 0;
}

/* 6. Enhanced File & Archive Preview Chips */
.file-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    background: rgba(102, 252, 241, 0.1);
    border: 1px solid rgba(102, 252, 241, 0.3);
    border-radius: 8px;
    font-size: 0.78rem;
    color: var(--text-primary);
    margin-right: 6px;
    margin-bottom: 6px;
    transition: all 0.2s ease;
}
.file-chip.archive-chip {
    background: rgba(229, 179, 68, 0.12);
    border-color: rgba(229, 179, 68, 0.4);
}
.file-chip .chip-size {
    font-size: 0.68rem;
    opacity: 0.65;
    background: rgba(0, 0, 0, 0.25);
    padding: 1px 4px;
    border-radius: 4px;
}
.file-chip .remove-chip {
    cursor: pointer;
    font-weight: 700;
    opacity: 0.6;
    margin-left: 4px;
    transition: opacity 0.2s;
}
.file-chip .remove-chip:hover {
    opacity: 1;
    color: #ff5555;
}

/* Image preview thumbnails */
.image-preview-bar {
    display: flex;
    gap: 10px;
    padding: 8px 12px;
    overflow-x: auto;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 10px;
    margin-bottom: 8px;
}
.image-preview-thumb {
    position: relative;
    width: 64px;
    height: 64px;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border-color);
    flex-shrink: 0;
}
.image-preview-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.image-preview-thumb .remove-img {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    border: none;
    cursor: pointer;
    font-size: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.image-preview-thumb .remove-img:hover {
    background: #ff4444;
}

/* Video Thumbnail Support in Preview Bar */
.image-preview-thumb.video-thumb {
    border-color: rgba(229, 179, 68, 0.5);
    background: #000;
}
.image-preview-thumb video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.image-preview-thumb .video-badge-indicator {
    position: absolute;
    bottom: 2px;
    left: 2px;
    background: rgba(0, 0, 0, 0.75);
    color: #e5b344;
    font-size: 9px;
    font-weight: 700;
    padding: 1px 4px;
    border-radius: 3px;
    pointer-events: none;
}

/* AI-Generated & User Inline Video Card */
.ai-video-preview-card {
    background: rgba(0, 0, 0, 0.55);
    border: 1px solid rgba(229, 179, 68, 0.35);
    border-radius: 14px;
    padding: 10px;
    margin: 10px 0;
    display: inline-flex;
    flex-direction: column;
    max-width: 440px;
    width: 100%;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(8px);
}
.ai-video-preview-card video.chat-video {
    width: 100%;
    max-height: 280px;
    border-radius: 10px;
    background: #000;
    outline: none;
}
.ai-video-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 8px;
    padding: 2px 4px;
    font-size: 0.78rem;
    color: var(--text-secondary);
}
.ai-video-card-footer .video-name {
    font-family: monospace;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 240px;
}
.ai-video-card-footer .video-download-btn {
    color: #e5b344;
    text-decoration: none;
    font-weight: 500;
    padding: 3px 8px;
    border-radius: 6px;
    background: rgba(229, 179, 68, 0.12);
    border: 1px solid rgba(229, 179, 68, 0.4);
    transition: 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.ai-video-card-footer .video-download-btn:hover {
    background: rgba(229, 179, 68, 0.3);
    color: #fff;
    box-shadow: 0 0 10px rgba(229, 179, 68, 0.5);
}

.message video.chat-video {
    max-width: 360px;
    max-height: 280px;
    border-radius: 12px;
    border: 1px solid rgba(229, 179, 68, 0.4);
    margin: 8px 0;
    background: #000;
    display: block;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
}

/* --- Connection Status HUD --- */
.cat-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: rgba(0, 255, 128, 0.1);
    border: 1px solid rgba(0, 255, 128, 0.3);
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 1px;
    color: rgba(0, 255, 128, 0.9);
    transition: all 0.3s ease;
    margin-right: 15px;
    -webkit-app-region: no-drag;
}

.cat-badge.offline-mode {
    background: rgba(255, 60, 60, 0.1);
    border-color: rgba(255, 60, 60, 0.4);
    color: rgba(255, 60, 60, 0.9);
}

.pulse-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: rgba(0, 255, 128, 0.9);
    box-shadow: 0 0 8px rgba(0, 255, 128, 0.6);
    animation: pulse 2s infinite;
}

.offline-mode .pulse-dot {
    background: rgba(255, 60, 60, 0.9);
    box-shadow: 0 0 8px rgba(255, 60, 60, 0.6);
    animation: pulse-offline 1s infinite;
}

.offline-hidden {
    display: none !important;
}

@keyframes pulse {
    0% { transform: scale(0.95); opacity: 0.8; }
    50% { transform: scale(1.1); opacity: 1; }
    100% { transform: scale(0.95); opacity: 0.8; }
}

@keyframes pulse-offline {
    0% { transform: scale(0.8); opacity: 0.4; }
    50% { transform: scale(1.2); opacity: 1; }
    100% { transform: scale(0.8); opacity: 0.4; }
}

/* --- PWA Update Toast --- */
#pwa-update-toast {
    position: fixed;
    bottom: 25px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: rgba(10, 15, 25, 0.95);
    border: 1px solid var(--border-color);
    border-radius: 30px;
    padding: 12px 20px;
    z-index: 9999;
    box-shadow: var(--glass-shadow);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    animation: slideUp 0.5s forwards cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.update-toast-content {
    display: flex;
    align-items: center;
    gap: 20px;
}

.update-text {
    color: var(--text-primary);
    font-size: 0.9rem;
    font-weight: 500;
}

#pwa-update-btn {
    background: var(--text-accent);
    color: var(--bg-color);
    border: none;
    padding: 6px 16px;
    border-radius: 20px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
}

#pwa-update-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 0 15px rgba(229, 179, 68, 0.4);
}

@keyframes slideUp {
    to { transform: translateX(-50%) translateY(0); }
}

/* ==========================================================================
   Custom Glowing Modal (Delete Confirmation)
   ========================================================================== */
.custom-modal-overlay {
    position: fixed;
    top: 0; left: 0; width: 100vw; height: 100vh;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.custom-modal-overlay:not(.hidden) {
    opacity: 1;
    pointer-events: auto;
}

.custom-modal-box {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 30px;
    width: 90%;
    max-width: 400px;
    text-align: center;
    transform: scale(0.9);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.custom-modal-overlay:not(.hidden) .custom-modal-box {
    transform: scale(1);
}

.custom-modal-box.glow-red {
    box-shadow: 0 0 30px rgba(255, 69, 58, 0.2), inset 0 0 20px rgba(255, 69, 58, 0.05);
    border-color: rgba(255, 69, 58, 0.3);
}

.modal-icon {
    color: #ff453a;
    margin-bottom: 16px;
    animation: pulse-red 2s infinite;
}

.modal-title {
    color: var(--text-color);
    font-size: 1.2rem;
    margin-bottom: 10px;
    font-weight: 600;
}

.modal-text {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin-bottom: 24px;
    line-height: 1.5;
}

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

.modal-btn-cancel {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-color);
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s ease;
}

.modal-btn-cancel:hover {
    background: rgba(255, 255, 255, 0.1);
}

.modal-btn-danger {
    background: rgba(255, 69, 58, 0.15);
    border: 1px solid rgba(255, 69, 58, 0.4);
    color: #ff453a;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s ease;
}

.modal-btn-danger:hover {
    background: rgba(255, 69, 58, 0.3);
    box-shadow: 0 0 15px rgba(255, 69, 58, 0.4);
    transform: translateY(-1px);
}

@keyframes pulse-red {
    0% { transform: scale(1); opacity: 0.8; }
    50% { transform: scale(1.1); opacity: 1; text-shadow: 0 0 10px rgba(255,69,58,0.5); }
    100% { transform: scale(1); opacity: 0.8; }
}

/* Tab Actions */
.tab-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-left: 6px;
}

.tab-action-icon {
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
    font-size: 14px;
    line-height: 1;
}

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

.tab-action-icon.tab-delete:hover {
    color: #ff453a;
    background: rgba(255, 69, 58, 0.1);
}
/* Status Dot */
.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 6px;
    box-shadow: 0 0 5px currentColor;
}
.status-dot.green {
    background-color: #00ff88;
    color: #00ff88;
}
.status-dot.red {
    background-color: #ff3366;
    color: #ff3366;
}

/* API Key Input */
.api-key-input {
    width: 100%;
    padding: 8px 12px;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-family: monospace;
    font-size: 0.85rem;
    outline: none;
    transition: all 0.2s ease;
}
.api-key-input:focus {
    border-color: var(--text-accent);
    box-shadow: 0 0 8px rgba(229,179,68,0.2);
}

/* =========================================================
   VOCALSYNC LIVE VOICE STREAMING COMMUNICATOR HUD
   ========================================================= */

.vocal-live-btn {
    position: relative;
    color: #10b981 !important;
    border-color: rgba(16, 185, 129, 0.4) !important;
    background: rgba(16, 185, 129, 0.08) !important;
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 600;
}

.vocal-live-btn:hover {
    background: rgba(16, 185, 129, 0.2) !important;
    border-color: #10b981 !important;
    box-shadow: 0 0 14px rgba(16, 185, 129, 0.35);
}

.vocal-live-pulse {
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #10b981;
    box-shadow: 0 0 8px #10b981;
    animation: vocalPulse 1.6s infinite ease-in-out;
}

@keyframes vocalPulse {
    0%, 100% { transform: scale(1); opacity: 0.9; }
    50% { transform: scale(1.4); opacity: 0.4; }
}

/* Floating HUD Container */
.vocalsync-hud {
    position: fixed;
    top: 72px;
    right: 28px;
    width: 380px;
    max-width: calc(100vw - 40px);
    z-index: 10000;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
    border-radius: 18px;
    animation: hudSlideIn 0.25s ease-out;
}

@keyframes hudSlideIn {
    from { opacity: 0; transform: translateY(-12px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.vocalsync-hud.hidden {
    display: none !important;
}

.vocalsync-hud-glass {
    background: rgba(13, 17, 26, 0.88);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 18px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Theme variations */
.vocalsync-hud.theme-orchestrator .vocalsync-hud-glass {
    border-color: rgba(16, 185, 129, 0.35);
    box-shadow: 0 10px 40px rgba(16, 185, 129, 0.15);
}

.vocalsync-hud.theme-forge .vocalsync-hud-glass {
    border-color: rgba(6, 182, 212, 0.35);
    box-shadow: 0 10px 40px rgba(6, 182, 212, 0.15);
}

.vocalsync-hud.agent-speaking.theme-orchestrator .vocalsync-hud-glass {
    border-color: #10b981;
    box-shadow: 0 0 35px rgba(16, 185, 129, 0.35);
}

.vocalsync-hud.agent-speaking.theme-forge .vocalsync-hud-glass {
    border-color: #06b6d4;
    box-shadow: 0 0 35px rgba(6, 182, 212, 0.35);
}

/* Header & Agent Selector */
.vocalsync-hud-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.vocal-hud-agent-selector {
    display: flex;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 3px;
    gap: 4px;
}

.vocal-agent-pill {
    background: transparent;
    border: none;
    color: var(--text-secondary, #94a3b8);
    padding: 5px 10px;
    border-radius: 9px;
    font-size: 0.72rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: all 0.2s ease;
}

.vocal-agent-pill.active {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.theme-orchestrator .vocal-agent-pill.active {
    color: #10b981;
    background: rgba(16, 185, 129, 0.15);
}

.theme-forge .vocal-agent-pill.active {
    color: #06b6d4;
    background: rgba(6, 182, 212, 0.15);
}

.pill-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
}
.pill-dot.emerald { background: #10b981; box-shadow: 0 0 6px #10b981; }
.pill-dot.cyan { background: #06b6d4; box-shadow: 0 0 6px #06b6d4; }

.vocal-hud-controls {
    display: flex;
    align-items: center;
    gap: 6px;
}

.vocal-ctrl-btn {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #94a3b8;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.vocal-ctrl-btn:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.14);
}

.vocal-ctrl-btn.muted {
    background: rgba(239, 68, 68, 0.2);
    border-color: rgba(239, 68, 68, 0.4);
    color: #ef4444;
}

.vocal-ctrl-btn.close:hover {
    background: rgba(239, 68, 68, 0.2);
    border-color: rgba(239, 68, 68, 0.4);
    color: #ef4444;
}

/* Visualizer Wave Canvas */
.vocalsync-visualizer-wrap {
    position: relative;
    background: rgba(0, 0, 0, 0.45);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 12px;
    height: 70px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.vocalsync-visualizer-wrap canvas {
    width: 100%;
    height: 100%;
    display: block;
}

.vocalsync-status-badge {
    position: absolute;
    bottom: 6px;
    left: 10px;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.7rem;
    font-weight: 600;
    color: #94a3b8;
    background: rgba(0, 0, 0, 0.55);
    padding: 2px 8px;
    border-radius: 8px;
    pointer-events: none;
}

.status-dot-pulse {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    display: inline-block;
}
.status-dot-pulse.connected {
    background: #10b981;
    box-shadow: 0 0 8px #10b981;
    animation: vocalPulse 1.2s infinite ease-in-out;
}
.status-dot-pulse.connecting {
    background: #eab308;
    box-shadow: 0 0 8px #eab308;
    animation: vocalPulse 0.8s infinite ease-in-out;
}
.status-dot-pulse.disconnected {
    background: #64748b;
}
.status-dot-pulse.error {
    background: #ef4444;
    box-shadow: 0 0 8px #ef4444;
}

/* Transcript Preview Area */
.vocalsync-transcript-preview {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    padding: 8px 12px;
    font-size: 0.78rem;
    line-height: 1.45;
    color: #e2e8f0;
    min-height: 48px;
    max-height: 90px;
    overflow-y: auto;
    word-break: break-word;
}

.vocalsync-transcript-preview .vocal-hint {
    color: #64748b;
    font-style: italic;
}

.vocalsync-transcript-preview .speaker-tag.user {
    color: #60a5fa;
    font-weight: 700;
}

.vocalsync-transcript-preview .speaker-tag.model {
    color: #34d399;
    font-weight: 700;
}

.theme-forge .vocalsync-transcript-preview .speaker-tag.model {
    color: #22d3ee;
}

/* Footer Controls */
.vocalsync-hud-footer {
    display: flex;
    justify-content: center;
}

.vocal-hud-action-btn {
    width: 100%;
    padding: 9px 16px;
    border-radius: 10px;
    font-size: 0.82rem;
    font-weight: 700;
    cursor: pointer;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.25s ease;
    background: #10b981;
    color: #020617;
    box-shadow: 0 0 16px rgba(16, 185, 129, 0.35);
}

.theme-forge .vocal-hud-action-btn {
    background: #06b6d4;
    box-shadow: 0 0 16px rgba(6, 182, 212, 0.35);
}

.vocal-hud-action-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 0 24px rgba(16, 185, 129, 0.55);
}

.theme-forge .vocal-hud-action-btn:hover {
    box-shadow: 0 0 24px rgba(6, 182, 212, 0.55);
}

.vocal-hud-action-btn.active-session {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.4);
    color: #f87171;
    box-shadow: none;
}

.vocal-hud-action-btn.active-session:hover {
    background: rgba(239, 68, 68, 0.25);
    border-color: #ef4444;
    box-shadow: 0 0 18px rgba(239, 68, 68, 0.3);
}

/* Voice Message Bubble Glow */
.message-bubble.voice-msg {
    border-left: 3px solid #10b981;
}

.message-bubble.voice-msg.user-msg {
    border-right: 3px solid #3b82f6;
    border-left: none;
}


/* Thinking Indicator */
.thinking-indicator {
    opacity: 0.8;
    animation: pulse 1.5s infinite;
}
.electrical-text {
    color: #00f0ff;
    font-size: 0.9em;
    letter-spacing: 1px;
    text-transform: uppercase;
}
@keyframes pulse {
    0% { opacity: 0.6; }
    50% { opacity: 1; text-shadow: 0 0 8px rgba(0,240,255,0.5); }
    100% { opacity: 0.6; }
}



/* ==================================================
   TRUE MOBILE RESPONSIVE LAYOUT (iPhone / PWA)
   ================================================== */
@media (max-width: 768px) {
    /* Container resets */
    .app-container {
        display: block !important;
        padding: 0 !important;
        gap: 0 !important;
        height: 100vh !important;
        height: 100dvh !important;
        overflow: hidden;
    }

    /* Move Activity Bar to Bottom (Tab Bar) */
    .activity-bar {
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        width: 100vw !important;
        height: calc(60px + env(safe-area-inset-bottom)) !important;
        flex-direction: row !important;
        padding: 0 15px env(safe-area-inset-bottom) 15px !important;
        border-radius: 0 !important;
        border: none !important;
        border-top: 1px solid var(--border-color) !important;
        background: rgba(4, 7, 13, 0.95) !important;
        z-index: 1000 !important;
        justify-content: space-between !important;
    }

    .activity-top, .activity-bottom {
        flex-direction: row !important;
        gap: 15px !important;
        height: 100% !important;
    }

    /* Sidebar becomes a sliding drawer */
    .sidebar {
        position: fixed !important;
        left: -100vw !important;
        top: 0 !important;
        bottom: calc(60px + env(safe-area-inset-bottom)) !important;
        width: 85vw !important;
        max-width: 350px !important;
        z-index: 900 !important;
        border-radius: 0 !important;
        border: none !important;
        border-right: 1px solid var(--border-color) !important;
        background: rgba(4, 7, 13, 0.98) !important;
        transition: transform 0.3s cubic-bezier(0.1, 0.9, 0.2, 1) !important;
        padding: max(20px, env(safe-area-inset-top)) 20px 20px 20px !important;
    }
    
    .sidebar.open {
        transform: translateX(100vw) !important;
    }

    /* Chat Main takes the full screen minus the bottom tab bar */
    .chat-main {
        position: absolute !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: calc(60px + env(safe-area-inset-bottom)) !important;
        border-radius: 0 !important;
        border: none !important;
        width: 100vw !important;
    }

    /* Mobile Menu Button in Header */
    .mobile-menu-btn {
        display: flex !important;
        margin-right: 12px;
    }

    .chat-header {
        padding: max(12px, env(safe-area-inset-top)) 15px 12px 15px !important;
    }

    .chat-header-title-wrap h2 {
        font-size: 1rem !important;
    }

    /* Compact Input Area */
    .chat-input-area {
        padding: 8px !important;
        border-radius: 0 !important;
        border-left: none !important;
        border-right: none !important;
        border-bottom: none !important;
    }

    /* Action Toolbar (Attachments) becomes a scrollable ribbon */
    .action-toolbar {
        display: flex !important;
        overflow-x: auto !important;
        flex-wrap: nowrap !important;
        padding-bottom: 5px !important;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    .action-toolbar::-webkit-scrollbar {
        display: none;
    }
    .action-toolbar .btn-label {
        display: none !important; /* Hide words, show only icons */
    }
    .tool-btn {
        padding: 6px 12px !important;
    }

    /* Shrink Mic & Send buttons */
    .input-wrapper {
        padding: 6px !important;
        gap: 6px !important;
        border-radius: 16px !important;
    }
    .mic-btn, #sendBtn {
        width: 36px !important;
        height: 36px !important;
        min-width: 36px !important;
        border-radius: 10px !important;
    }
    #chatInput {
        font-size: 16px !important; /* Prevents iOS auto-zoom */
        padding: 8px 10px !important;
    }
    
    .message {
        max-width: 92% !important;
        padding: 12px !important;
    }
}
