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

:root {
    --navy:   #0d1b2a;
    --navy2:  #1b2d42;
    --gold:   #b8962e;
    --gold-l: #d4b04a;
    --bg:     #f5f5f3;
    --surface:#ffffff;
    --border: #e2e2de;
    --text:   #1a1a1a;
    --muted:  #6b7280;
    --user-bg:#0d1b2a;
    --radius: 18px;
    --sidebar-w: 260px;
}

html, body { height: 100%; }

body {
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 15px;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
}

/* ── Layout ── */
.layout {
    display: flex;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
}

/* ── Sidebar ── */
.sidebar {
    width: var(--sidebar-w);
    background: var(--navy);
    color: #e8e8e8;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    padding: 24px 16px;
    gap: 24px;
    overflow-y: auto;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 4px;
}

.brand-mark {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--gold), var(--gold-l));
    color: var(--navy);
    font-family: 'Playfair Display', serif;
    font-weight: 600;
    font-size: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    letter-spacing: 0.5px;
}

.brand-text {
    display: flex;
    flex-direction: column;
}

.brand-name {
    font-family: 'Playfair Display', serif;
    font-weight: 600;
    font-size: 1.05rem;
    color: #ffffff;
    line-height: 1.2;
}

.brand-sub {
    font-size: 0.7rem;
    color: rgba(255,255,255,0.45);
    letter-spacing: 0.3px;
}

#new-chat-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255,255,255,0.07);
    border: 1px solid rgba(255,255,255,0.12);
    color: #e8e8e8;
    padding: 10px 14px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 0.85rem;
    font-family: inherit;
    transition: background 0.15s, border-color 0.15s;
    width: 100%;
    text-align: left;
}

#new-chat-btn:hover {
    background: rgba(255,255,255,0.13);
    border-color: rgba(255,255,255,0.22);
}

#new-chat-btn svg {
    width: 16px;
    height: 16px;
    opacity: 0.7;
}

.sidebar-section { padding: 0 4px; }

.sidebar-label {
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    color: rgba(255,255,255,0.35);
    margin-bottom: 10px;
}

.sidebar-topics {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.sidebar-topics li {
    font-size: 0.8rem;
    color: rgba(255,255,255,0.55);
    padding-left: 10px;
    border-left: 2px solid rgba(184,150,46,0.4);
}

.sidebar-footer {
    margin-top: auto;
    padding: 0 4px;
    font-size: 0.7rem;
    color: rgba(255,255,255,0.25);
    line-height: 1.5;
}

/* ── Chat panel ── */
.chat-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: var(--bg);
}

/* ── Chat header (mobile) ── */
.chat-header {
    display: none;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.chat-header-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text);
}

.menu-btn, #new-chat-mobile {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text);
    padding: 4px;
    display: flex;
    align-items: center;
}

.menu-btn svg, #new-chat-mobile svg {
    width: 20px;
    height: 20px;
}

/* ── Messages ── */
#chat-box {
    flex: 1;
    overflow-y: auto;
    padding: 32px 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    scroll-behavior: smooth;
}

/* Welcome screen */
.welcome {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 60px 24px 0;
    max-width: 540px;
    margin: 0 auto;
    gap: 14px;
}

.welcome-mark {
    width: 56px;
    height: 56px;
    border-radius: 14px;
    background: linear-gradient(135deg, var(--navy), var(--navy2));
    color: var(--gold-l);
    font-family: 'Playfair Display', serif;
    font-weight: 600;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(13,27,42,0.2);
    letter-spacing: 0.5px;
}

.welcome h2 {
    font-family: 'Playfair Display', serif;
    font-size: 1.5rem;
    color: var(--navy);
    font-weight: 600;
}

.welcome p {
    font-size: 0.9rem;
    color: var(--muted);
    max-width: 420px;
    line-height: 1.65;
}

.suggestions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    margin-top: 8px;
}

.suggestion-chip {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 8px 16px;
    font-size: 0.8rem;
    color: var(--navy2);
    cursor: pointer;
    font-family: inherit;
    transition: border-color 0.15s, box-shadow 0.15s;
    text-align: left;
}

.suggestion-chip:hover {
    border-color: var(--gold);
    box-shadow: 0 2px 8px rgba(184,150,46,0.15);
}

/* Message rows */
.msg-row {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    max-width: 760px;
    width: 100%;
    margin: 0 auto;
}

.msg-row.user {
    flex-direction: row-reverse;
}

.avatar {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--navy), var(--navy2));
    color: var(--gold-l);
    font-family: 'Playfair Display', serif;
    font-size: 11px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-top: 2px;
}

.bubble {
    padding: 12px 16px;
    border-radius: var(--radius);
    max-width: calc(100% - 44px);
    font-size: 0.92rem;
    line-height: 1.65;
}

.msg-row.user .bubble {
    background: var(--user-bg);
    color: #f0f0f0;
    border-bottom-right-radius: 5px;
}

.msg-row.assistant .bubble {
    background: var(--surface);
    color: var(--text);
    border-bottom-left-radius: 5px;
    box-shadow: 0 1px 6px rgba(0,0,0,0.06);
    border: 1px solid var(--border);
}

.bubble p { margin-bottom: 10px; }
.bubble p:last-child { margin-bottom: 0; }
.bubble ul { padding-left: 20px; margin-bottom: 10px; }
.bubble li { margin-bottom: 4px; }
.bubble strong { font-weight: 600; color: var(--navy); }

.msg-row.user .bubble strong { color: rgba(255,255,255,0.9); }

/* Typing indicator */
.typing-dots {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 2px 0;
}

.typing-dots span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--muted);
    animation: dot-bounce 1.2s infinite ease-in-out;
}

.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes dot-bounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30%            { transform: translateY(-6px); opacity: 1; }
}

.error-text { color: #c0392b; font-style: normal; font-size: 0.88rem; }

/* ── Input area ── */
.input-area {
    padding: 16px 24px 20px;
    background: var(--bg);
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

.input-wrap {
    max-width: 760px;
    margin: 0 auto;
    display: flex;
    align-items: flex-end;
    gap: 10px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 10px 10px 10px 16px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.06);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.input-wrap:focus-within {
    border-color: var(--navy2);
    box-shadow: 0 2px 16px rgba(13,27,42,0.12);
}

#user-input {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    font-family: inherit;
    font-size: 0.92rem;
    color: var(--text);
    resize: none;
    min-height: 24px;
    max-height: 140px;
    line-height: 1.5;
}

#user-input::placeholder { color: #aaa; }

#send-btn {
    width: 36px;
    height: 36px;
    border-radius: 9px;
    background: var(--navy);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.15s, transform 0.1s;
}

#send-btn:hover:not(:disabled) {
    background: var(--navy2);
    transform: scale(1.05);
}

#send-btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

#send-btn svg { width: 15px; height: 15px; }

/* ── Mobile overlay ── */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 40;
}

/* ── Responsive ── */
@media (max-width: 700px) {
    .sidebar {
        position: fixed;
        left: 0; top: 0; bottom: 0;
        z-index: 50;
        transform: translateX(-100%);
        transition: transform 0.25s ease;
    }

    .sidebar.open { transform: translateX(0); }

    .sidebar-overlay.visible { display: block; }

    .chat-header { display: flex; }

    #chat-box { padding: 20px 16px; }

    .input-area { padding: 12px 16px 16px; }

    .welcome { padding-top: 32px; }
}
