@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,500;0,700;1,500&family=Lora:ital,wght@0,400;0,500;1,400&family=DM+Mono:wght@300;400&display=swap');

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

/* ─── DESIGN TOKENS ──────────────────────────────────────── */
:root {
    --bg-deep:        #07090f;
    --bg-surface:     #0c1018;
    --bg-card:        #10151f;
    --bg-input:       #0d1320;
    --topbar-bg:      rgba(7,9,15,0.97);
    --border:         rgba(255,255,255,0.055);
    --border-accent:  rgba(129,140,248,0.22);
    --accent:         #818cf8;
    --accent-dim:     rgba(129,140,248,0.10);
    --accent-glow:    rgba(129,140,248,0.18);
    --gold:           #b8975a;
    --text:           #ddd8ce;
    --text-muted:     #555e72;
    --text-dim:       #2b3040;
    --font-serif:     'Playfair Display', Georgia, serif;
    --font-body:      'Lora', Georgia, serif;
    --font-mono:      'DM Mono', 'Courier New', monospace;
}

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

/* ─── RADIANT BACKGROUND ─────────────────────────────────── */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background:
        radial-gradient(ellipse 60% 38% at 12% 6%,  rgba(129,140,248,0.07)  0%, transparent 60%),
        radial-gradient(ellipse 50% 32% at 88% 90%, rgba(184,151,90,0.05)   0%, transparent 55%),
        radial-gradient(ellipse 42% 30% at 78% 15%, rgba(99,102,241,0.04)   0%, transparent 52%),
        radial-gradient(ellipse 35% 25% at 5%  80%, rgba(129,140,248,0.03)  0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

/* Grain texture */
body::after {
    content: '';
    position: fixed;
    inset: 0;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 256 256'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.038'/%3E%3C/svg%3E");
    background-size: 180px;
    pointer-events: none;
    z-index: 0;
    opacity: 0.45;
}

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

/* ─── TOP BAR ────────────────────────────────────────────── */
.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);
}

.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.7;
}

/* Menu & refresh buttons */
.menu-btn,
.refresh-btn {
    width: 36px;
    height: 36px;
    background: none;
    border: 1px solid var(--border);
    border-radius: 9px;
    color: var(--text-muted);
    font-size: 18px;
    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 {
    color: var(--text);
    border-color: var(--border-accent);
    background: var(--accent-dim);
}

/* Title group */
.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-serif);
    font-size: 17px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: 0.02em;
    line-height: 1;
}

.title-main span {
    color: var(--accent);
    font-style: italic;
}

.title-sub {
    font-family: var(--font-mono);
    font-size: 8.5px;
    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-family: var(--font-body);
    font-size: 14.5px;
    border-bottom: 1px solid var(--border);
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 10px;
    letter-spacing: 0.01em;
}

.side-menu a:hover {
    color: var(--text);
    background: var(--accent-dim);
    padding-left: 28px;
    border-left: 2px solid var(--accent);
}

/* ─── CHAT AREA ──────────────────────────────────────────── */
.chat {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 18px 15px 12px;
    scroll-behavior: smooth;
}

.chat::-webkit-scrollbar { width: 3px; }
.chat::-webkit-scrollbar-track { background: transparent; }
.chat::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* ─── WELCOME MESSAGE ────────────────────────────────────── */
#welcomeMsg {
    align-self: center;
    text-align: center;
    margin-top: auto;
    margin-bottom: 8px;
    padding: 28px 22px 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    animation: fadeUp 0.55s ease both;
    max-width: 320px;
}

.welcome-orb {
    width: 60px;
    height: 60px;
    border-radius: 16px;
    background: linear-gradient(135deg, #141b2a 0%, #0c1018 100%);
    border: 1px solid var(--border-accent);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 18px;
    box-shadow:
        0 0 28px rgba(129,140,248,0.11),
        0 0 0 1px rgba(129,140,248,0.05),
        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-family: var(--font-serif);
    font-size: 20px;
    font-weight: 700;
    color: var(--text);
    line-height: 1.25;
    margin-bottom: 10px;
}

.welcome-title em {
    color: var(--accent);
    font-style: italic;
}

.welcome-sub {
    font-family: var(--font-body);
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.7;
    font-style: italic;
    margin-bottom: 20px;
}

/* Suggestion chips */
.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);
}

/* ─── MESSAGE BUBBLES ────────────────────────────────────── */
.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(129,140,248,0.45); }
.msg.user .msg-label { color: rgba(255,255,255,0.2); text-align: right; }

.bubble {
    padding: 12px 16px;
    border-radius: 15px;
    font-family: var(--font-body);
    font-size: 14.5px;
    line-height: 1.78;
    position: relative;
}

/* AI bubble */
.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(129,140,248,0.14), transparent);
}

/* User bubble */
.msg.user .bubble {
    background: linear-gradient(135deg, #1c2440 0%, #192038 100%);
    border: 1px solid rgba(129,140,248,0.18);
    color: var(--text);
    border-bottom-right-radius: 4px;
    box-shadow: 0 3px 18px rgba(0,0,0,0.3);
}

.msg.ai .bubble b {
    color: #c8c4f5;
    font-weight: 600;
}

/* ─── TYPING INDICATOR ───────────────────────────────────── */
.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 AREA ─────────────────────────────────────────── */
.input-box {
    flex-shrink: 0;
    padding: 11px 14px 13px;
    background: rgba(7,9,15,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(184,151,90,0.28), 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(129,140,248,0.32);
    box-shadow: 0 0 0 3px rgba(129,140,248,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-body);
    font-size: 14.5px;
    line-height: 1.5;
    padding: 10px 0;
    caret-color: var(--accent);
}

#input::placeholder {
    color: var(--text-dim);
    font-style: italic;
}

.send-btn {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    border: none;
    background: linear-gradient(135deg, var(--accent) 0%, #6366f1 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(129,140,248,0.25);
}

.send-btn:hover  { transform: scale(1.07); box-shadow: 0 4px 20px rgba(129,140,248,0.4); }
.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 — EXACT, UNCHANGED ─────────────────────── */
.buukey-bottom-nav {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: #111;
    border-top: 1px solid #222;
    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: #aaa;
    font-size: 10px;
    font-weight: 600;
    gap: 4px;
    padding: 8px 4px;
    border-radius: 12px;
    transition: all 0.2s ease;
}

.buukey-nav-item:hover { color: #fff; background: #1a1a1a; }
.buukey-nav-item.active { color: #818cf8; }

.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: #1a1a1a;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 2px 12px rgba(129,140,248,0.2);
    border: 1px solid #555;
}

.buukey-nav-item.ai-item .ai-icon svg {
    stroke: #818cf8; width: 20px; height: 20px;
    fill: none; stroke-linecap: round; stroke-linejoin: round;
}

.buukey-nav-item.ai-item span { color: #818cf8; }
