:root {
    --theme-color: #15ff00;
    --theme-bg: rgba(21, 255, 0, 0.05);
    --theme-hover: rgba(21, 255, 0, 0.15);
    --solid-bg: #0f0f0f;
    --panel-bg: #1a1a1a;
    --text-main: #ffffff;
    --text-muted: rgba(255, 255, 255, 0.6);
    --msg-user: var(--theme-hover);
    --msg-bot: #212121;
    --border-color: rgba(255, 255, 255, 0.1);
    --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

[data-theme="green"]  { --theme-color: #15ff00; --theme-bg: rgba(21, 255, 0, 0.05); --theme-hover: rgba(21, 255, 0, 0.15); --msg-user: rgba(21, 255, 0, 0.15); }
[data-theme="orange"] { --theme-color: #ff9900; --theme-bg: rgba(255, 153, 0, 0.05); --theme-hover: rgba(255, 153, 0, 0.15); --msg-user: rgba(255, 153, 0, 0.15); }
[data-theme="red"]    { --theme-color: #ff4444; --theme-bg: rgba(255, 68, 68, 0.05); --theme-hover: rgba(255, 68, 68, 0.15); --msg-user: rgba(255, 68, 68, 0.15); }
[data-theme="blue"]   { --theme-color: #3399ff; --theme-bg: rgba(51, 153, 255, 0.05); --theme-hover: rgba(51, 153, 255, 0.15); --msg-user: rgba(51, 153, 255, 0.15); }
[data-theme="pink"]   { --theme-color: #ff33cc; --theme-bg: rgba(255, 51, 204, 0.05); --theme-hover: rgba(255, 51, 204, 0.15); --msg-user: rgba(255, 51, 204, 0.15); }
[data-theme="white"]  { --theme-color: #ffffff; --theme-bg: rgba(255, 255, 255, 0.05); --theme-hover: rgba(255, 255, 255, 0.15); --msg-user: rgba(255, 255, 255, 0.15); }

body.light-mode {
    --solid-bg: #f5f5f5;
    --panel-bg: #ffffff;
    --theme-bg: rgba(0, 0, 0, 0.03);
    --text-main: #1f1f1f;
    --text-muted: rgba(0, 0, 0, 0.5);
    --msg-user: rgba(0, 0, 0, 0.05);
    --msg-bot: #ffffff;
    --border-color: rgba(0, 0, 0, 0.1);
    --theme-color: #009900;
    --theme-hover: rgba(0, 153, 0, 0.1);
}

body.light-mode[data-theme="green"]  { --theme-color: #009900; --theme-hover: rgba(0, 153, 0, 0.1); }
body.light-mode[data-theme="orange"] { --theme-color: #cc6600; --theme-hover: rgba(204, 102, 0, 0.1); }
body.light-mode[data-theme="red"]    { --theme-color: #cc0000; --theme-hover: rgba(204, 0, 0, 0.1); }
body.light-mode[data-theme="blue"]   { --theme-color: #0055cc; --theme-hover: rgba(0, 85, 204, 0.1); }
body.light-mode[data-theme="pink"]   { --theme-color: #cc0099; --theme-hover: rgba(204, 0, 153, 0.1); }
body.light-mode[data-theme="white"]  { --theme-color: #222222; --theme-hover: rgba(0, 0, 0, 0.05); }

* { box-sizing: border-box; margin: 0; padding: 0; font-family: var(--font-family); }

body { background-color: var(--solid-bg); color: var(--text-main); display: flex; height: 100dvh; width: 100vw; overflow: hidden; transition: 0.3s ease; }

#auth-screen { position: absolute; inset: 0; background-color: var(--solid-bg); z-index: 1000; display: flex; flex-direction: column; align-items: center; justify-content: center; }

.login-face-container { position: relative; z-index: 999; margin-bottom: 20px; animation: authJump 0.5s infinite alternate cubic-bezier(0.5, 0.05, 1, 0.5); transition: transform 0.2s ease-out; display: flex; justify-content: center; }
.login-face-container img { width: 90px; object-fit: contain; }

@keyframes authJump { from { top: 0; } to { top: -25px; } }

.auth-box { position: relative; z-index: 2; background: var(--panel-bg); padding: 40px; border-radius: 16px; text-align: center; width: 340px; max-width: 90%; box-shadow: 0 8px 30px rgba(0,0,0,0.1); border: 1px solid var(--border-color); }
.auth-box h1 { margin-bottom: 24px; color: var(--theme-color); font-weight: 600; letter-spacing: 1px;}
.auth-box input { width: 100%; margin-bottom: 12px; padding: 14px; background: var(--solid-bg); border: 1px solid var(--border-color); color: var(--text-main); border-radius: 8px; outline: none; transition: 0.2s; }
.auth-box input:focus { border-color: var(--theme-color); }

.legal-terms { font-size: 0.7em; color: var(--text-muted); margin-bottom: 14px; line-height: 1.4; text-align: justify; }

.btn-primary { width: 100%; padding: 14px; background: var(--theme-color); color: var(--solid-bg); border: none; font-weight: 600; cursor: pointer; border-radius: 8px; margin-top: 4px; transition: 0.2s; }
.btn-link { width: 100%; margin-top: 12px; background: none; color: var(--text-muted); border: none; padding: 8px; cursor: pointer; transition: 0.2s; font-size: 0.9em; }
.btn-link:hover, .btn-primary:hover { opacity: 0.8; }
.footer-auth { position: absolute; bottom: 20px; font-size: 0.75em; color: var(--text-muted); }

.sidebar { width: 280px; min-width: 280px; border-right: 1px solid var(--border-color); display: flex; flex-direction: column; padding: 16px; background: var(--panel-bg); transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1); z-index: 10; }
.sidebar.closed { margin-left: -280px; }

.sidebar-actions { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.btn-sidebar-action { background: transparent; color: var(--text-main); border: 1px solid var(--border-color); padding: 10px; border-radius: 8px; cursor: pointer; transition: 0.2s; font-size: 0.85em; font-weight: 500; text-align: center; }
.btn-sidebar-action:hover { background: var(--theme-hover); border-color: var(--theme-color); color: var(--theme-color); }
.btn-nuke-core { color: var(--theme-color) !important; border-color: var(--theme-color) !important; font-weight: bold; }
.btn-nuke-core:hover { background: #ff4444 !important; color: #fff !important; border-color: #ff4444 !important; }

#chat-list { flex-grow: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; margin-bottom: 15px; }
.cat-title { font-size: 0.75em; color: var(--text-muted); margin: 0px 8px 8px; font-weight: 600; letter-spacing: 0.5px; }
.chat-item-wrapper { position: relative; display: flex; align-items: center; }
.chat-item { flex-grow: 1; background: none; color: var(--text-main); border: none; padding: 10px 32px 10px 12px; text-align: left; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; border-radius: 8px; transition: 0.2s; font-size: 0.95em; }
.chat-item:hover { background: var(--theme-hover); }
.chat-item.active { background: var(--theme-bg); color: var(--theme-color); font-weight: 500; }
.chat-options-btn { position: absolute; right: 8px; background: none; color: var(--text-muted); border: none; cursor: pointer; padding: 6px; border-radius: 4px; transition: 0.2s; }
.chat-options-btn:hover { color: var(--text-main); background: var(--border-color); }

.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.8); z-index: 2000; display: flex; align-items: center; justify-content: center; backdrop-filter: blur(5px); }
.modal-content { background: var(--panel-bg); padding: 30px; border-radius: 16px; border: 1px solid var(--border-color); width: 340px; text-align: center; box-shadow: 0 10px 40px rgba(0,0,0,0.3); }
.modal-content h2 { color: var(--text-main); margin-bottom: 24px; font-size: 1.3em; font-weight: 600; }
.modal-input { width: 100%; margin-top: 4px; margin-bottom: 8px; padding: 12px; background: var(--solid-bg); border: 1px solid var(--border-color); color: var(--text-main); border-radius: 8px; outline: none; transition: 0.2s; font-size: 0.9em; }
.modal-input:focus { border-color: var(--theme-color); }

.main-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    width: 100%;
    min-width: 0;
    background-color: var(--solid-bg);
    background-image:
        linear-gradient(to bottom, transparent 60%, var(--solid-bg) 60%),
        radial-gradient(circle, color-mix(in srgb, var(--theme-color) 20%, transparent) 0%, color-mix(in srgb, var(--theme-color) 20%, transparent) 50%, transparent 50.5%),
        radial-gradient(color-mix(in srgb, var(--theme-color) 25%, transparent) 1.5px, transparent 1.5px);
    background-size:
        100% 100%,
        240px 240px,
        24px 24px;
    background-position:
        0 0,
        center var(--celestial-y, 100%),
        0 0;
    background-repeat:
        no-repeat,
        no-repeat,
        repeat;
    overflow: hidden;
}

body.light-mode .main-content {
    background-image:
        linear-gradient(to bottom, transparent 60%, var(--solid-bg) 60%),
        radial-gradient(circle, color-mix(in srgb, var(--theme-color) 15%, transparent) 0%, color-mix(in srgb, var(--theme-color) 15%, transparent) 50%, transparent 50.5%),
        radial-gradient(color-mix(in srgb, var(--theme-color) 35%, transparent) 1.5px, transparent 1.5px);
}

.main-content::after {
    content: '';
    position: absolute;
    top: 60%;
    left: -50%;
    width: 200%;
    height: 40%;
    z-index: 0;
    background-image:
        repeating-linear-gradient(to bottom, color-mix(in srgb, var(--theme-color) 25%, transparent) 0, color-mix(in srgb, var(--theme-color) 25%, transparent) 1px, transparent 1px, transparent 30px),
        repeating-linear-gradient(to right, color-mix(in srgb, var(--theme-color) 25%, transparent) 0, color-mix(in srgb, var(--theme-color) 25%, transparent) 1px, transparent 1px, transparent 40px);
    transform: perspective(300px) rotateX(70deg);
    transform-origin: center top;
    border-top: 2px solid color-mix(in srgb, var(--theme-color) 60%, transparent);
    pointer-events: none;
    -webkit-mask-image: linear-gradient(to bottom, black 0%, transparent 90%);
    mask-image: linear-gradient(to bottom, black 0%, transparent 90%);
}

header { display: grid; grid-template-columns: 1fr auto 1fr; padding: 12px 24px; border-bottom: 1px solid var(--border-color); align-items: center; background: var(--solid-bg); z-index: 5; position: relative; }
.header-left { display: flex; align-items: center; gap: 16px; }
.app-title { font-size: 1.2em; font-weight: 600; color: var(--text-main); letter-spacing: 1px; }
.header-center { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.header-right { display: flex; justify-content: flex-end; gap: 12px; align-items: center; }

.btn-icon { background: none; border: none; color: var(--text-muted); cursor: pointer; padding: 8px; border-radius: 8px; display: flex; align-items: center; justify-content: center; transition: 0.2s; }
.btn-icon:hover { background: var(--theme-hover); color: var(--theme-color); }
.theme-select { background: transparent; color: var(--text-muted); border: 1px solid var(--border-color); padding: 6px 12px; border-radius: 8px; outline: none; cursor: pointer; transition: 0.2s; }
.theme-select:hover { border-color: var(--theme-color); color: var(--text-main); }
.theme-select option { background-color: var(--panel-bg); color: var(--text-main); }

.battery-label { font-size: 0.65em; letter-spacing: 1px; color: var(--text-muted); font-weight: 600; }
.battery-bar { width: 140px; height: 14px; border: 2px solid #555; position: relative; border-radius: 6px; padding: 1px; background: var(--panel-bg); }
.battery-bar::after { content: ''; position: absolute; right: -5px; top: 2px; width: 3px; height: 6px; background: #555; border-radius: 0 2px 2px 0; }
body.light-mode .battery-bar { border: 2px solid #aaa; }
body.light-mode .battery-bar::after { background: #aaa; }
.battery-level { height: 100%; background: #15ff00; width: 100%; transition: width 0.3s ease, background-color 0.3s ease, box-shadow 0.3s ease; border-radius: 3px; }

.user-profile { display: flex; align-items: center; gap: 12px; padding: 12px; background: var(--theme-bg); border-radius: 12px; border: 1px solid var(--border-color); position: relative; }
.user-initial { width: 32px; height: 32px; background: var(--theme-color); color: var(--solid-bg); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 1em; }
.user-name { color: var(--text-main); font-weight: 500; font-size: 0.9em; flex-grow: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.chat-menu { display: none; position: absolute; top: 100%; right: 0; margin-top: 8px; background: var(--panel-bg); border: 1px solid var(--border-color); z-index: 100; flex-direction: column; width: 180px; border-radius: 12px; overflow: hidden; box-shadow: 0 4px 20px rgba(0,0,0,0.15); padding: 4px; }
.chat-menu button { background: transparent; color: var(--text-main); border: none; padding: 10px 16px; text-align: left; cursor: pointer; border-radius: 8px; font-size: 0.9em; transition: 0.2s; }
.chat-menu button:hover { background: var(--theme-hover); color: var(--theme-color); }

.chat-container { flex-grow: 1; overflow-y: auto; padding: 40px 20px; display: flex; flex-direction: column; align-items: center; scroll-behavior: smooth; position: relative; z-index: 1; }
.chat-wrapper { width: 100%; max-width: 800px; display: flex; flex-direction: column; gap: 24px; }

.welcome-screen { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; margin-top: 15vh; z-index: 0; }
.welcome-screen h1 { font-size: 3em; margin-bottom: 12px; color: var(--theme-color); font-weight: 600; }
.welcome-screen p { font-size: 1.1em; color: var(--text-muted); padding: 0 20px; }

.msg { display: flex; width: 100%; gap: 16px; line-height: 1.5; font-size: 1em; z-index: 1; }
.user-msg { justify-content: flex-end; }
.msg.other-user { justify-content: flex-start; }
.user-bubble { background: var(--panel-bg); border: 1px solid var(--theme-color); color: var(--text-main); padding: 14px 20px; border-radius: 20px 20px 4px 20px; max-width: 75%; position: relative; word-wrap: break-word; }
.other-user .user-bubble { background: var(--panel-bg); border: 1px solid var(--border-color); border-radius: 20px 20px 20px 4px; }
.sender-name { font-size: 0.75em; color: var(--text-muted); margin-bottom: 4px; display: block; font-weight: 600; }

.bot-msg { justify-content: flex-start; }
.bot-avatar { width: 60px; height: 60px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; border-radius: 50%; background: var(--panel-bg); border: 1px solid var(--border-color); overflow: hidden;}
.bot-face-img { width: 44px; height: 44px; object-fit: contain; filter: invert(1); transition: 0.3s; }
body.light-mode .bot-face-img { filter: invert(0); }

.bot-bubble { background: var(--panel-bg); border: 1px solid var(--border-color); color: var(--text-main); max-width: 75%; padding: 14px 20px; border-radius: 20px 20px 20px 4px; position: relative; word-wrap: break-word; }

.code-block { border: 1px solid var(--border-color); border-radius: 12px; margin: 12px 0; background: #111111; overflow: hidden; }
body.light-mode .code-block { background: #1e1e1e; }
.code-header { background: rgba(255,255,255,0.05); padding: 8px 16px; font-size: 0.8em; color: #a0a0a0; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid rgba(255,255,255,0.1); }
.code-actions { display: flex; gap: 8px; }
.copy-btn { background: transparent; color: #a0a0a0; border: 1px solid rgba(255,255,255,0.2); border-radius: 6px; padding: 4px 12px; cursor: pointer; transition: 0.2s; }
.copy-btn:hover { background: rgba(255,255,255,0.1); color: #fff; }
.code-block pre { padding: 16px; overflow-x: auto; margin: 0; }
.code-block code { color: #e8e8e8; font-family: 'Courier New', Courier, monospace; font-size: 0.9em; }
.inline-code { background: var(--border-color); padding: 2px 6px; border-radius: 4px; font-family: monospace; font-size: 0.9em; }

.thinking-bubble { display: flex; align-items: center; justify-content: center; gap: 6px; padding: 14px 24px; min-width: 60px; }
.dot { width: 6px; height: 6px; background: var(--theme-color); border-radius: 50%; animation: bounce 1.4s infinite ease-in-out both; }
.dot:nth-child(1) { animation-delay: -0.32s; }
.dot:nth-child(2) { animation-delay: -0.16s; }
@keyframes bounce { 0%, 80%, 100% { transform: scale(0); } 40% { transform: scale(1); } }

.input-area { padding: 20px 24px 30px; display: flex; justify-content: center; background: transparent; position: relative; z-index: 2; }
.input-box { width: 100%; max-width: 800px; display: flex; gap: 12px; border: 1px solid var(--border-color); padding: 10px 10px 10px 20px; border-radius: 24px; align-items: flex-end; background: var(--panel-bg); box-shadow: 0 8px 30px rgba(0,0,0,0.05); transition: 0.3s; }
.input-box:focus-within { border-color: var(--theme-color); box-shadow: 0 8px 30px var(--theme-bg); }
textarea { flex-grow: 1; background: none; border: none; color: var(--text-main); outline: none; resize: none; min-height: 24px; max-height: 200px; padding: 10px 0; overflow-y: auto; font-size: 1em; line-height: 1.5; }

.btn-new-chat { background: var(--theme-bg); color: var(--theme-color); border: 1px solid var(--theme-color); padding: 12px; margin-bottom: 12px; cursor: pointer; font-weight: 600; width: 100%; border-radius: 12px; transition: 0.2s; }
.btn-new-chat:hover { background: var(--theme-color); color: var(--solid-bg); }
.send-btn { background: var(--theme-color); border: none; color: var(--solid-bg); width: 44px; height: 44px; border-radius: 50%; display: flex; align-items: center; justify-content: center; cursor: pointer; transition: 0.3s; flex-shrink: 0; }
.send-btn:hover { transform: scale(1.05); }
.btn-stop { background: #ff4444 !important; color: #fff !important; }

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--theme-color); }

.bot-text-face { white-space: nowrap; font-size: 1.2em; letter-spacing: -1px; }
#profile-menu { top: auto; bottom: 100%; margin-top: 0; margin-bottom: 8px; }
em { font-style: italic; opacity: 0.9; color: var(--theme-color); }

.asix-widget { position: fixed; top: 80px; right: 20px; background: var(--panel-bg); border: 1px solid var(--theme-color); border-radius: 16px; padding: 16px; width: 280px; box-shadow: 0 10px 30px rgba(0,0,0,0.5); z-index: 9999; transform: translateX(150%); transition: transform 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275); display: flex; flex-direction: column; gap: 8px; }
.asix-widget.show { transform: translateX(0); }
.widget-header { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border-color); padding-bottom: 6px; }
.widget-title { font-weight: bold; color: var(--theme-color); font-size: 0.9em; letter-spacing: 0.5px; }
.btn-close-widget { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 1.4em; line-height: 1; padding: 0 4px; }
.btn-close-widget:hover { color: #ff4444; }
.widget-body { font-size: 0.95em; line-height: 1.5; color: var(--text-main); font-style: italic; }

@media (max-width: 768px) {
    .sidebar { position: absolute; height: 100%; box-shadow: 4px 0 20px rgba(0,0,0,0.5); z-index: 1000; }
    .sidebar.closed { margin-left: -280px; box-shadow: none; }
    .main-content { min-width: 100vw; }
    header { display: flex; flex-wrap: wrap; padding: 10px 12px; justify-content: space-between; align-items: center; gap: 10px 0; }
    .header-left { order: 1; }
    .header-right { order: 2; gap: 8px; }
    .header-center { order: 3; width: 100%; padding-top: 10px; border-top: 1px dashed var(--border-color); flex-direction: row; justify-content: center; }
    .app-title { display: inline-block; font-size: 1.2em; margin-left: 8px; } 
    .theme-select { width: 105px; padding: 6px; font-size: 0.8em; }
    .btn-icon { padding: 6px; font-size: 1.1em; }
    .battery-label { display: none; } 
    #user-tokens-label { display: none !important; }
    .battery-bar { width: 160px; height: 12px; } 
    #admin-infinity { font-size: 1.5em; margin-right: 4px; }
    #countdown-timer { font-size: 0.9em; }
    .chat-container { padding: 16px 10px; }
    .user-bubble { max-width: 90%; padding: 12px 16px; font-size: 0.95em; word-wrap: break-word; }
    .bot-bubble { max-width: 90%; padding: 12px 16px; font-size: 0.95em; word-wrap: break-word; }
    .bot-avatar { width: 44px; height: 44px; }
    .bot-face-img { width: 30px; height: 30px; }
    .msg { gap: 10px; }
    .input-area { padding: 10px 10px 15px; }
    .input-box { border-radius: 20px; padding: 6px 6px 6px 14px; }
    .send-btn { width: 38px; height: 38px; }
    .send-btn svg { width: 20px; height: 20px; }
    .auth-box { width: 90%; padding: 24px 20px; }
    .asix-widget { width: calc(100% - 32px); right: 16px; top: 120px; }
}

.effect-overlay { position: fixed; inset: 0; pointer-events: none; z-index: 9999; animation: fadeEffect 4s ease-out forwards; }
.effect-abrazo { box-shadow: inset 0 0 30px rgba(255, 105, 180, 0.3); }
.effect-luz { box-shadow: inset 0 0 40px var(--theme-color); }
.effect-chispas { background-image: radial-gradient(circle, var(--theme-color) 2px, transparent 2px); background-size: 50px 50px; animation: chispasAnim 4s ease-out forwards; }
@keyframes fadeEffect { 0% { opacity: 0; } 20% { opacity: 0.15; } 80% { opacity: 0.15; } 100% { opacity: 0; } }
@keyframes chispasAnim { 0% { background-position: 0 0; opacity: 0; } 20% { opacity: 0.15; } 100% { background-position: 0 300px; opacity: 0; } }