@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Fraunces:opsz,wght@9..144,500;9..144,700&display=swap');

* {
    box-sizing: border-box;
    outline: none !important;
}

*:focus {
    outline: none !important;
}

/* --- ROOT VARIABLES --- */
:root {
    --gray: #222222;
    --bg: #0a0a0c;
    --card-bg: #111114;
    --text: #ffffff;
    --primary: #00ff88;
    --vibrant: #00ffcc;
    --sidebar-bg: #0d1a14;
    --active-tab-bg: rgba(0, 255, 136, 0.15);
    
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --radius-xl: 28px;
    --shadow-soft: 0 8px 32px rgba(0,0,0,0.4);
    --shadow-glow: 0 0 24px color-mix(in srgb, var(--primary) 35%, transparent);
    --blur: blur(20px) saturate(1.8);
    --glass-blur: blur(16px) saturate(1.5);
    --font-body: 'Inter', system-ui, sans-serif;
    --font-display: 'Fraunces', Georgia, serif;
}

/* --- THEMES --- */
body[data-theme="dark-2"] {
    --bg: #0a1428;
    --card-bg: #121e38;
    --primary: #3b9eff;
    --vibrant: #5bb8ff;
    --sidebar-bg: #0f1d35;
    --active-tab-bg: rgba(59, 158, 255, 0.15);
}

body[data-theme="dark-3"] {
    --bg: #100515;
    --card-bg: #1a0a20;
    --primary: #aa00ff;
    --vibrant: #df00ff;
    --sidebar-bg: #1c0728;
    --active-tab-bg: rgba(170, 0, 255, 0.15);
}

body[data-theme="dark-4"] {
    --bg: #150505;
    --card-bg: #200a0a;
    --primary: #ff0044;
    --vibrant: #ff0088;
    --sidebar-bg: #280707;
    --active-tab-bg: rgba(255, 0, 68, 0.15);
}

body[data-theme="light-1"] {
    --bg: #f4f7f6;
    --card-bg: #ffffff;
    --text: #111111;
    --primary: #00cc6a;
    --vibrant: #00aa55;
    --sidebar-bg: #e8f0ec;
    --active-tab-bg: rgba(0, 204, 106, 0.2);
    --shadow-soft: 0 8px 32px rgba(0,0,0,0.08);
}

body[data-theme="light-2"] {
    --bg: #f5f9ff;
    --card-bg: #ffffff;
    --text: #1a1a1a;
    --primary: #4d9fff;
    --vibrant: #68afff;
    --sidebar-bg: #ebf3ff;
    --active-tab-bg: rgba(77, 159, 255, 0.15);
    --shadow-soft: 0 8px 32px rgba(0,0,0,0.06);
}

body[data-theme="light-3"] {
    --bg: #fdf0ff;
    --card-bg: #ffffff;
    --text: #111111;
    --primary: #9900ff;
    --vibrant: #7700cc;
    --sidebar-bg: #f5e0ff;
    --active-tab-bg: rgba(153, 0, 255, 0.2);
    --shadow-soft: 0 8px 32px rgba(0,0,0,0.08);
}

body[data-theme="light-4"] {
    --bg: #fff5f0;
    --card-bg: #ffffff;
    --text: #111111;
    --primary: #ff6600;
    --vibrant: #cc4400;
    --sidebar-bg: #ffe8e0;
    --active-tab-bg: rgba(255, 102, 0, 0.2);
    --shadow-soft: 0 8px 32px rgba(0,0,0,0.08);
}

/* --- GLOBAL STYLES --- */
body {
    margin: 0;
    font-family: var(--font-body);
    background-color: var(--bg);
    color: var(--text);
    overflow: hidden;
    transition: background 0.4s, color 0.4s;
    position: relative;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -2;
    background: 
        radial-gradient(1200px 800px at 10% 10%, color-mix(in srgb, var(--primary) 12%, transparent), transparent 60%),
        radial-gradient(1000px 600px at 90% 20%, color-mix(in srgb, var(--vibrant) 10%, transparent), transparent 60%),
        radial-gradient(800px 800px at 50% 100%, color-mix(in srgb, var(--primary) 6%, transparent), transparent 60%);
    opacity: 0.5;
    filter: blur(40px);
}

::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, var(--primary), var(--vibrant));
    border-radius: 10px;
}

.hidden {
    display: none !important;
}

@keyframes breathe {
    0%, 100% { opacity: 0.9; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.02); }
}

/* --- NAVIGATION --- */
.top-nav {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 64px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 24px;
    box-sizing: border-box;
    background: color-mix(in srgb, var(--sidebar-bg) 70%, transparent);
    backdrop-filter: var(--blur);
    border-bottom: 1px solid color-mix(in srgb, var(--primary) 15%, transparent);
    z-index: 1000;
}

.top-nav button {
    background: none;
    border: none;
    color: var(--primary);
    font-size: 1.5rem;
    cursor: pointer;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    transition: all 0.2s;
    display: grid;
    place-items: center;
}

.top-nav button:hover {
    background: var(--active-tab-bg);
    transform: scale(1.05);
}

.nav-title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.3rem;
    background: linear-gradient(135deg, var(--primary), var(--vibrant));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

#status {
    color: #888;
    margin-left: 8px;
    font-size: 0.9rem;
    font-weight: 500;
}

#status.online {
    color: var(--primary);
}

/* --- SIDEBAR --- */
#sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 300px;
    height: 100dvh;
    background: color-mix(in srgb, var(--sidebar-bg) 75%, transparent);
    backdrop-filter: var(--blur);
    border-right: 1px solid color-mix(in srgb, var(--primary) 15%, transparent);
    z-index: 2500;
    transform: translateX(0);
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar-hidden {
    transform: translateX(-100%) !important;
}

.sidebar-header {
    padding: 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid color-mix(in srgb, var(--primary) 15%, transparent);
}

.sidebar-header h2 {
    margin: 0;
    font-family: var(--font-display);
    background: linear-gradient(135deg, var(--primary), var(--vibrant));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

#close-sidebar {
    background: none;
    border: none;
    color: var(--text);
    font-size: 1.5rem;
    cursor: pointer;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    transition: all 0.2s;
    display: grid;
    place-items: center;
}

#close-sidebar:hover {
    background: var(--active-tab-bg);
}

.sidebar-tabs {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 12px;
    overflow-y: auto;
    gap: 4px;
}

.sidebar-bottom {
    border-top: 1px solid color-mix(in srgb, var(--primary) 10%, transparent);
    padding: 12px;
    background: color-mix(in srgb, var(--bg) 40%, transparent);
}

.sidebar-tab {
    padding: 12px 16px;
    cursor: pointer;
    border-radius: var(--radius-md);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    border-left: 3px solid transparent;
    font-weight: 500;
    display: flex;
    align-items: center;
}

.sidebar-tab:hover {
    background: color-mix(in srgb, var(--primary) 8%, transparent);
    color: var(--primary);
    transform: translateX(2px);
}

.sidebar-tab i {
    margin-right: 12px;
    width: 20px;
    text-align: center;
    opacity: 0.8;
}

.sidebar-tab.active {
    background: var(--active-tab-bg);
    color: var(--primary);
    border-left: 3px solid var(--primary);
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--primary) 20%, transparent);
}

/* --- MAIN CONTENT & SCREENS --- */
main {
    padding-top: 64px;
    height: 100dvh;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    animation: fadeIn 0.6s forwards;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.screen {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: calc(100dvh - 64px);
}

.hidden-screen {
    display: none !important;
}

/* --- CHAT MESSAGES - Liquid Glass Floating Bubbles --- */
#chat-messages {
    flex: 1;
    padding: 24px 16px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 18px;
    background: transparent;
}

.msg {
    padding: 12px 18px;
    max-width: 65%;
    font-size: 0.95rem;
    line-height: 1.55;
    position: relative;
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: break-word;
    border-radius: 22px;
    z-index: 1;
    animation: msgIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    backdrop-filter: var(--glass-blur);
    box-shadow: 
        0 4px 16px rgba(0,0,0,0.12),
        inset 0 1px 1px rgba(255,255,255,0.1);
}

@keyframes msgIn {
    from { 
        opacity: 0; 
        transform: translateY(12px) scale(0.9); 
        filter: blur(4px);
    }
    to { 
        opacity: 1; 
        transform: translateY(0) scale(1); 
        filter: blur(0);
    }
}

.bot {
    background: color-mix(in srgb, var(--card-bg) 40%, transparent);
    color: var(--text);
    align-self: flex-start;
    border: 1px solid color-mix(in srgb, var(--primary) 18%, transparent);
    box-shadow: 
        0 8px 24px rgba(0,0,0,0.15),
        inset 0 1px 0 rgba(255,255,255,0.08),
        inset 0 -1px 0 rgba(0,0,0,0.1);
}

.user {
    background: linear-gradient(135deg, 
        color-mix(in srgb, var(--primary) 85%, transparent),
        color-mix(in srgb, var(--vibrant) 85%, transparent)
    );
    backdrop-filter: var(--glass-blur);
    color: #000;
    align-self: flex-end;
    font-weight: 500;
    border: 1px solid color-mix(in srgb, var(--primary) 30%, transparent);
    box-shadow: 
        0 8px 24px color-mix(in srgb, var(--primary) 25%, transparent),
        inset 0 1px 0 rgba(255,255,255,0.2),
        inset 0 -1px 0 rgba(0,0,0,0.15);
}

.user img {
    max-width: 100%;
    max-height: 300px;
    border-radius: var(--radius-md);
}

/* --- CHAT INPUT AREA --- */
.chat-input-area {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px 16px;
    background: transparent;
}

.input-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    background: color-mix(in srgb, var(--card-bg) 60%, transparent);
    backdrop-filter: var(--glass-blur);
    border: 1px solid color-mix(in srgb, var(--primary) 25%, transparent);
    border-radius: 26px;
    padding: 0 8px 0 16px;
    min-height: 52px;
    box-sizing: border-box;
    transition: all 0.2s;
    box-shadow: 
        0 4px 16px rgba(0,0,0,0.1),
        inset 0 1px 0 rgba(255,255,255,0.05);
}

.input-wrapper:focus-within {
    border-color: var(--primary);
    box-shadow: 
        0 0 0 3px color-mix(in srgb, var(--primary) 15%, transparent),
        0 4px 20px rgba(0,0,0,0.15),
        inset 0 1px 0 rgba(255,255,255,0.08);
}

#user-input {
    flex: 1;
    width: 100%;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text);
    font-family: inherit;
    font-size: 1rem;
    line-height: 1.5;
    padding: 10px 0;
    margin: 0;
    resize: none;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-all;
    min-height: 24px;
    max-height: 200px;
}

.fa-plus {
    cursor: pointer;
    font-size: 1.2rem;
    color: color-mix(in srgb, var(--text) 50%, transparent);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.2s;
    margin: auto 0;
    line-height: 1;
    position: relative;
    top: 9px;
    left: 10px;
}

.fa-plus::before {
    display: block;
    line-height: 1;
    transform: translate(1px, 1px);
}

.fa-plus:hover {
    color: var(--primary);
}

.background{
    width: 40px;
    height: 40px;
    border-radius: 50%;

}

.background:hover{
    background: color-mix(in srgb, var(--primary) 15%, transparent);
}

.record-btn {
    color: color-mix(in srgb, var(--text) 50%, transparent);
    width: 40px;
    height: 40px;
    cursor: pointer;
    flex-shrink: 0;
    display: grid !important;
    place-items: center !important;
    font-size: 18px;
    border-radius: 50%;
    transition: all 0.2s;
    margin: auto 0;
}

.record-btn:hover {
    color: var(--primary);
    background: color-mix(in srgb, var(--primary) 15%, transparent);
}

#send-btn.send-button {
    background: linear-gradient(135deg, var(--primary), var(--vibrant));
    border: none;
    color: #000;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    cursor: pointer;
    flex-shrink: 0;
    font-weight: 600;
    transition: all 0.2s;
    box-shadow: 0 2px 8px color-mix(in srgb, var(--primary) 30%, transparent);
}

#send-btn.send-button:hover {
    transform: scale(1.08);
    box-shadow: 0 4px 16px color-mix(in srgb, var(--primary) 45%, transparent);
}

#send-btn.send-button:active {
    transform: scale(0.95);
}

/* --- MARKDOWN STYLING --- */
.msg p {
    margin: 4px 0;
}

.msg p:first-child {
    margin-top: 0;
}

.msg p:last-child {
    margin-bottom: 0;
}

.msg code {
    background: color-mix(in srgb, var(--primary) 15%, transparent);
    padding: 2px 6px;
    border-radius: 6px;
    font-family: 'JetBrains Mono', 'Courier New', monospace;
    font-size: 0.88em;
    border: 1px solid color-mix(in srgb, var(--primary) 25%, transparent);
    color: var(--vibrant);
}

.msg pre {
    background: rgba(0,0,0,0.4);
    backdrop-filter: var(--glass-blur);
    padding: 14px;
    border-radius: var(--radius-md);
    overflow-x: auto;
    margin: 10px 0;
    border: 1px solid color-mix(in srgb, var(--primary) 25%, transparent);
    position: relative;
    color: #ffffff;
    box-shadow: inset 0 2px 8px rgba(0,0,0,0.4);
}

.msg pre code {
    background: none;
    padding: 0;
    border: none;
    margin: 0;
    color: #ffffff !important;
}

.msg h1, .msg h2, .msg h3 {
    font-family: var(--font-display);
    color: var(--primary);
    margin: 12px 0 6px 0;
    font-weight: 700;
    line-height: 1.3;
}

.msg h1 { font-size: 1.5em; }
.msg h2 { font-size: 1.3em; }
.msg h3 { font-size: 1.15em; }

.msg ul, .msg ol {
    padding-left: 20px;
    margin: 8px 0;
}

.msg li {
    margin: 4px 0;
}

.msg strong {
    font-weight: 700;
    color: var(--vibrant);
}

.msg em {
    font-style: italic;
}

.msg blockquote {
    border-left: 3px solid var(--primary);
    margin: 10px 0;
    padding: 6px 14px;
    background: color-mix(in srgb, var(--primary) 5%, transparent);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    font-style: italic;
}

.code-header {
    background: color-mix(in srgb, var(--primary) 15%, transparent);
    padding: 8px 12px;
    border-radius: var(--radius-md) var(--radius-md) 0 0;
    font-size: 0.85em;
    color: var(--vibrant);
    font-family: 'JetBrains Mono', monospace;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid color-mix(in srgb, var(--primary) 20%, transparent);
}

.copy-btn {
    background: color-mix(in srgb, var(--primary) 20%, transparent);
    border: none;
    color: var(--vibrant);
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.75em;
    font-family: inherit;
    font-weight: 600;
    transition: all 0.2s;
}

.copy-btn:hover {
    background: color-mix(in srgb, var(--primary) 30%, transparent);
}

/* --- VOICE & PLACEHOLDER SCREENS --- */
.voice-body, 
.placeholder-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: transparent;
    gap: 24px;
    text-align: center;
    padding: 40px;
}

.placeholder-content i {
    font-size: 5rem;
    background: linear-gradient(135deg, var(--primary), var(--vibrant));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.placeholder-content h2 {
    font-family: var(--font-display);
    font-size: 2.5rem;
    margin: 0;
}

.placeholder-content p {
    color: color-mix(in srgb, var(--text) 60%, transparent);
    font-size: 1.1rem;
    max-width: 500px;
}

#mic-btn {
    width: 180px;
    height: 180px;
    border-radius: 50%;
    background: color-mix(in srgb, var(--card-bg) 40%, transparent);
    backdrop-filter: var(--glass-blur);
    border: 3px solid var(--primary);
    color: var(--primary);
    font-size: 4rem;
    cursor: pointer;
    transition: all 0.3s;
    outline: none;
    box-shadow: 
        0 8px 32px rgba(0,0,0,0.2),
        inset 0 1px 0 rgba(255,255,255,0.1);
    display: grid;
    place-items: center;
}

#mic-btn:hover {
    transform: scale(1.05);
    box-shadow: 
        0 12px 40px color-mix(in srgb, var(--primary) 30%, transparent),
        inset 0 1px 0 rgba(255,255,255,0.15);
}

#mic-btn.listening {
    background: linear-gradient(135deg, var(--primary), var(--vibrant));
    color: #000;
    box-shadow: 
        0 0 60px color-mix(in srgb, var(--primary) 60%, transparent),
        inset 0 1px 0 rgba(255,255,255,0.3);
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.08); }
}

#voice-status {
    font-size: 1.3rem;
    color: var(--text);
    max-width: 80%;
    font-weight: 500;
}

/* --- MODALS --- */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 3000;
    animation: modalFade 0.3s;
}

@keyframes modalFade {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background: color-mix(in srgb, var(--bg) 70%, transparent);
    backdrop-filter: var(--blur);
    width: 90%;
    max-width: 560px;
    height: auto;
    max-height: 80vh;
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid color-mix(in srgb, var(--primary) 20%, transparent);
    box-shadow: 
        0 20px 60px rgba(0,0,0,0.6),
        inset 0 1px 0 rgba(255,255,255,0.08);
    animation: modalSlide 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes modalSlide {
    from { transform: translateY(20px) scale(0.95); }
    to { transform: translateY(0) scale(1); }
}

.modal-header {
    padding: 24px 28px;
    display: flex;
    justify-content: space-between;
    background: color-mix(in srgb, var(--sidebar-bg) 60%, transparent);
    border-bottom: 1px solid color-mix(in srgb, var(--primary) 15%, transparent);
    font-size: 1.2rem;
    font-weight: 600;
    font-family: var(--font-display);
}

.close-modal {
    background: none;
    border: none;
    color: var(--text);
    font-size: 1.8rem;
    cursor: pointer;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    transition: all 0.2s;
    display: grid;
    place-items: center;
}

.close-modal:hover {
    background: var(--active-tab-bg);
    color: var(--primary);
}

/* --- THEME GRID --- */
.theme-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 16px;
    padding: 28px;
    overflow-y: auto;
}

.theme-btn {
    padding: 24px 16px;
    border-radius: var(--radius-md);
    cursor: pointer;
    text-align: center;
    font-weight: 600;
    font-size: 0.95rem;
    border: 2px solid transparent;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(10px);
}

.theme-btn.dark {
    background: color-mix(in srgb, #1a1a1a 80%, transparent);
    color: white;
}

.theme-btn.light {
    background: color-mix(in srgb, #ffffff 80%, transparent);
    color: black;
}

.theme-btn:hover {
    border-color: var(--primary);
    transform: translateY(-4px);
    box-shadow: var(--shadow-glow);
}

/* --- MOBILE & RESET --- */
@media (max-width: 768px) {
    #sidebar {
        width: 100%;
    }
    .msg {
        max-width: 80%;
    }
    .chat-input-area {
        padding: 10px 12px 14px;
    }
    #chat-messages {
        padding: 20px 12px;
        gap: 14px;
    }
}

.chat-input-area * {
    list-style: none !important;
    list-style-type: none !important;
}