@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@300;400;500&display=swap');

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --bg-deep: #080c14;
    --bg-surface: #0d1117;
    --bg-card: #111820;
    --bg-input: #0d1420;
    --topbar-bg: rgba(8,12,20,0.98);
    --border: rgba(255,255,255,0.1);
    --border-accent: rgba(99,179,237,0.3);
    --accent: #63b3ed;
    --accent-dim: rgba(99,179,237,0.12);
    --gold: #14a800;
    --text: #f0f4ff;
    --text-muted: #8899bb;
    --text-dim: #3a4560;
    --font-main: 'Inter', sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
}

html, body {
    width: 100%; height: 100%;
    overflow: hidden;
    position: fixed;
    inset: 0;
    background: var(--bg-deep);
    color: var(--text);
    font-family: var(--font-main);
    -webkit-font-smoothing: antialiased;
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    background:
        radial-gradient(ellipse 60% 40% at 15% 8%, rgba(99,179,237,0.06) 0%, transparent 60%),
        radial-gradient(ellipse 50% 35% at 85% 88%, rgba(20,168,0,0.04) 0%, transparent 55%);
    pointer-events: none;
    z-index: 0;
}

.app {
    position: absolute;
    inset: 0 0 65px 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 1;
}

/* TOPBAR */
.topbar {
    height: 56px;
    background: var(--topbar-bg);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 14px;
    position: relative;
    flex-shrink: 0;
    backdrop-filter: blur(28px);
    -webkit-backdrop-filter: blur(28px);
    z-index: 2;
}

.topbar::after {
    content: '';
    position: absolute;
    bottom: -1px; left: 50%;
    transform: translateX(-50%);
    width: 120px; height: 1px;
    background: linear-gradient(90deg, transparent, var(--accent), transparent);
    opacity: 0.5;
}

.menu-btn, .refresh-btn, .theme-toggle {
    width: 36px; height: 36px;
    background: none;
    border: 1px solid var(--border);
    border-radius: 9px;
    color: var(--text-muted);
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    font-family: inherit;
    line-height: 1;
}
.menu-btn:hover, .refresh-btn:hover, .theme-toggle:hover {
    color: var(--text);
    border-color: var(--border-accent);
    background: var(--accent-dim);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.title {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    pointer-events: none;
}
.title-main {
    font-family: var(--font-main);
    font-size: 17px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.02em;
    line-height: 1;
}
.title-main span { color: var(--accent); font-weight: 700; }
.title-sub {
    font-family: var(--font-mono);
    font-size: 8px;
    color: var(--text-muted);
    letter-spacing: 0.14em;
    text-transform: uppercase;
    display: flex;
    align-items: center;
    gap: 5px;
}
.title-sub::before {
    content: '';
    width: 5px; height: 5px;
    border-radius: 50%;
    background: #34d399;
    box-shadow: 0 0 6px rgba(52,211,153,0.7);
    animation: blink 2.2s ease-in-out infinite;
}
@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* OVERLAY */
.overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.6);
    display: none;
    z-index: 10;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

/* SIDE MENU */
.side-menu {
    position: fixed;
    top: 0; left: -260px;
    width: 260px; height: 100%;
    background: linear-gradient(160deg, #0c1018 0%, #10151f 100%);
    border-right: 1px solid var(--border);
    padding-top: 64px;
    display: flex;
    flex-direction: column;
    transition: left 0.3s cubic-bezier(0.4,0,0.2,1);
    z-index: 11;
}
.side-menu a {
    padding: 15px 22px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 14px;
    border-bottom: 1px solid var(--border);
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 10px;
}
.side-menu a:hover {
    color: var(--text);
    background: var(--accent-dim);
    padding-left: 28px;
    border-left: 2px solid var(--accent);
}

/* CHAT */
.chat {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 12px 15px;
    scroll-behavior: smooth;
    justify-content: flex-end;
}
.chat::-webkit-scrollbar { width: 3px; }
.chat::-webkit-scrollbar-track { background: transparent; }
.chat::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* WELCOME */
#welcomeMsg {
    align-self: center;
    text-align: center;
    margin: auto 0;
    padding: 20px 22px;
    display: flex;
    flex-direction: column;
    align-items: center;
    animation: fadeUp 0.55s ease both;
    max-width: 340px;
    width: 100%;
}
.welcome-orb {
    width: 56px; height: 56px;
    border-radius: 14px;
    background: linear-gradient(135deg, #141b2a 0%, #0c1018 100%);
    border: 1px solid var(--border-accent);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
    box-shadow: 0 0 28px rgba(99,179,237,0.12), inset 0 1px 0 rgba(255,255,255,0.05);
}
.welcome-orb svg {
    width: 26px; height: 26px;
    stroke: var(--accent);
    fill: none;
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.welcome-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
    line-height: 1.25;
    margin-bottom: 8px;
    letter-spacing: -0.03em;
}
.welcome-title em {
    color: var(--accent);
    font-style: normal;
    font-weight: 300;
}
.welcome-sub {
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.7;
    margin-bottom: 18px;
}
.chips {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    justify-content: center;
}
.chip {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 6px 13px;
    font-family: var(--font-mono);
    font-size: 10.5px;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s ease;
    letter-spacing: 0.03em;
    user-select: none;
}
.chip:hover {
    border-color: var(--border-accent);
    color: var(--accent);
    background: var(--accent-dim);
}

/* MESSAGES */
.msg {
    max-width: 82%;
    word-break: break-word;
    animation: fadeUp 0.3s ease both;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.msg-label {
    font-family: var(--font-mono);
    font-size: 9px;
    letter-spacing: 0.13em;
    text-transform: uppercase;
    padding: 0 4px;
}
.msg.ai { align-self: flex-start; }
.msg.user { align-self: flex-end; }
.msg.ai .msg-label { color: rgba(99,179,237,0.5); }
.msg.user .msg-label { color: rgba(255,255,255,0.2); text-align: right; }
.bubble {
    padding: 12px 16px;
    border-radius: 15px;
    font-size: 14.5px;
    line-height: 1.78;
    position: relative;
}
.msg.ai .bubble {
    background: linear-gradient(145deg, #111820 0%, #0e131c 100%);
    border: 1px solid var(--border);
    color: var(--text);
    border-bottom-left-radius: 4px;
    box-shadow: 0 3px 18px rgba(0,0,0,0.28);
}
.msg.ai .bubble::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 1px;
    border-radius: 15px 15px 0 0;
    background: linear-gradient(90deg, transparent, rgba(99,179,237,0.15), transparent);
}
.msg.user .bubble {
    background: linear-gradient(135deg, #0d2b0d 0%, #0a1f0a 100%);
    border: 1px solid rgba(20,168,0,0.2);
    color: #ffffff;
    border-bottom-right-radius: 4px;
    box-shadow: 0 3px 18px rgba(0,0,0,0.3);
}
.msg.ai .bubble b { color: var(--accent); font-weight: 600; }

/* TYPING */
.typing-dots {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 14px 16px;
    background: linear-gradient(145deg, #111820 0%, #0e131c 100%);
    border: 1px solid var(--border);
    border-radius: 15px;
    border-bottom-left-radius: 4px;
    width: fit-content;
}
.typing-dots span {
    width: 5px; height: 5px;
    border-radius: 50%;
    background: var(--accent);
    opacity: 0.35;
    animation: bounce 1.35s ease-in-out infinite;
}
.typing-dots span:nth-child(2) { animation-delay: 0.18s; }
.typing-dots span:nth-child(3) { animation-delay: 0.36s; }
@keyframes bounce {
    0%, 80%, 100% { transform: translateY(0); opacity: 0.3; }
    40% { transform: translateY(-5px); opacity: 1; }
}

/* INPUT */
.input-box {
    flex-shrink: 0;
    padding: 11px 14px 13px;
    background: rgba(8,12,20,0.96);
    border-top: 1px solid var(--border);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    position: relative;
}
.input-box::before {
    content: '';
    position: absolute;
    top: -1px; left: 50%;
    transform: translateX(-50%);
    width: 90px; height: 1px;
    background: linear-gradient(90deg, transparent, rgba(20,168,0,0.25), transparent);
}
.input-row {
    display: flex;
    align-items: center;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 13px;
    padding: 4px 6px 4px 16px;
    gap: 8px;
    transition: border-color 0.22s ease, box-shadow 0.22s ease;
}
.input-row:focus-within {
    border-color: rgba(99,179,237,0.32);
    box-shadow: 0 0 0 3px rgba(99,179,237,0.06), 0 4px 22px rgba(0,0,0,0.32);
}
#input {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    color: var(--text);
    font-family: var(--font-main);
    font-size: 14.5px;
    line-height: 1.5;
    padding: 10px 0;
    caret-color: var(--accent);
}
#input::placeholder { color: var(--text-dim); }
.send-btn {
    width: 38px; height: 38px;
    border-radius: 10px;
    border: none;
    background: linear-gradient(135deg, #14a800 0%, #0d7a00 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.2s ease;
    box-shadow: 0 2px 14px rgba(20,168,0,0.3);
}
.send-btn:hover { transform: scale(1.07); box-shadow: 0 4px 20px rgba(20,168,0,0.45); }
.send-btn:active { transform: scale(0.95); }
.send-btn svg { width: 16px; height: 16px; fill: white; }

/* ANIMATIONS */
@keyframes fadeUp {
    from { opacity: 0; transform: translateY(9px); }
    to { opacity: 1; transform: translateY(0); }
}

/* BOTTOM NAV */
.buukey-bottom-nav {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: #0a0e18;
    border-top: 1px solid rgba(255,255,255,0.08);
    display: flex;
    justify-content: space-around;
    align-items: center;
    height: 65px;
    box-shadow: 0 -4px 30px rgba(0,0,0,0.6);
    z-index: 9999;
    padding: 0 5px;
}
.buukey-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    text-decoration: none;
    color: #5a6a8a;
    font-size: 10px;
    font-weight: 600;
    gap: 4px;
    padding: 8px 4px;
    border-radius: 12px;
    transition: all 0.2s ease;
    font-family: var(--font-main);
}
.buukey-nav-item:hover { color: #8899bb; background: rgba(255,255,255,0.04); }
.buukey-nav-item.active { color: var(--accent); }
.buukey-nav-item svg {
    width: 22px; height: 22px;
    stroke: currentColor; fill: none;
    stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
.buukey-nav-item.ai-item .ai-icon {
    width: 36px; height: 36px;
    border-radius: 10px;
    background: rgba(99,179,237,0.08);
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 2px 12px rgba(99,179,237,0.15);
    border: 1px solid rgba(99,179,237,0.2);
}
.buukey-nav-item.ai-item .ai-icon svg { stroke: var(--accent); width: 20px; height: 20px; }
.buukey-nav-item.ai-item span { color: var(--accent); }

/* LIGHT MODE */
body.light-mode {
    --bg-deep: #f0f4f8;
    --bg-surface: #ffffff;
    --bg-card: #f7f9fc;
    --bg-input: #ffffff;
    --topbar-bg: rgba(255,255,255,0.98);
    --border: rgba(0,0,0,0.08);
    --border-accent: rgba(43,108,176,0.3);
    --accent: #2b6cb0;
    --accent-dim: rgba(43,108,176,0.08);
    --text: #1a202c;
    --text-muted: #718096;
    --text-dim: #a0aec0;
    background: #f0f4f8;
}
body.light-mode .topbar { background: rgba(255,255,255,0.98); border-bottom-color: rgba(0,0,0,0.08); }
body.light-mode .title-main { color: #1a202c; }
body.light-mode .menu-btn, body.light-mode .refresh-btn, body.light-mode .theme-toggle { color: #718096; border-color: rgba(0,0,0,0.1); }
body.light-mode .side-menu { background: #fff; border-right-color: rgba(0,0,0,0.08); }
body.light-mode .side-menu a { color: #718096; border-bottom-color: rgba(0,0,0,0.06); }
body.light-mode .side-menu a:hover { color: #1a202c; background: rgba(43,108,176,0.05); border-left-color: #2b6cb0; }
body.light-mode .msg.ai .bubble { background: #fff; border-color: rgba(0,0,0,0.08); color: #1a202c; box-shadow: 0 2px 12px rgba(0,0,0,0.06); }
body.light-mode .chip { background: #fff; border-color: rgba(0,0,0,0.1); color: #718096; }
body.light-mode .chip:hover { color: #2b6cb0; background: rgba(43,108,176,0.06); border-color: rgba(43,108,176,0.2); }
body.light-mode .welcome-title { color: #1a202c; }
body.light-mode .welcome-orb { background: linear-gradient(135deg, #e8f4fd, #f0f8ff); border-color: rgba(43,108,176,0.2); }
body.light-mode .welcome-orb svg { stroke: #2b6cb0; }
body.light-mode .input-box { background: rgba(255,255,255,0.98); border-top-color: rgba(0,0,0,0.08); }
body.light-mode .input-row { background: #f7f9fc; border-color: rgba(0,0,0,0.1); }
body.light-mode #input { color: #1a202c; }
body.light-mode #input::placeholder { color: #a0aec0; }
body.light-mode .typing-dots { background: #fff; border-color: rgba(0,0,0,0.08); }
body.light-mode .buukey-bottom-nav { background: #fff; border-top-color: rgba(0,0,0,0.08); }
body.light-mode .buukey-nav-item { color: #718096; }
body.light-mode .buukey-nav-item:hover { color: #1a202c; background: #f7f9fc; }
body.light-mode .buukey-nav-item.active { color: #2b6cb0; }
body.light-mode .buukey-nav-item.ai-item .ai-icon { background: #e8f4fd; border-color: rgba(43,108,176,0.2); }
body.light-mode .buukey-nav-item.ai-item .ai-icon svg { stroke: #2b6cb0; }
body.light-mode .buukey-nav-item.ai-item span { color: #2b6cb0; }
body.light-mode .overlay { background: rgba(0,0,0,0.4); }
