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

:root {
    --bg: #f7f6f3;
    --surface: #ffffff;
    --border: #e8e5df;
    --text: #1a1916;
    --text-muted: #9a9690;
    --accent: #2a2a2a;
    --accent-hover: #444;
    --user-bubble: #1a1916;
    --user-text: #f7f6f3;
    --ai-bubble: #ffffff;
    --ai-border: #e8e5df;
    --sidebar-width: 240px;
    --url-bar-height: 64px;
}

body {
    font-family: 'DM Sans', sans-serif;
    background: var(--bg);
    color: var(--text);
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ── URL Bar ── */
#url-bar {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: var(--url-bar-height);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 20px;
    gap: 10px;
    z-index: 100;
    transform: translateY(0);
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.4s ease;
}

#url-bar.hidden {
    transform: translateY(-100%);
    opacity: 0;
    pointer-events: none;
}

#url-bar input {
    flex: 1;
    height: 38px;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0 14px;
    font-family: 'DM Mono', monospace;
    font-size: 13px;
    background: var(--bg);
    color: var(--text);
    outline: none;
    transition: border-color 0.2s;
}

#url-bar input:focus { border-color: var(--accent); }
#url-bar input::placeholder { color: var(--text-muted); }

#ingest-btn {
    height: 38px;
    padding: 0 18px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 6px;
    font-family: 'DM Sans', sans-serif;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
    white-space: nowrap;
}

#ingest-btn:hover { background: var(--accent-hover); }
#ingest-btn:disabled { opacity: 0.5; cursor: not-allowed; }

#ingest-status {
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
}

/* ── Add URL button (shows after first ingest) ── */
#add-url-btn {
    position: fixed;
    top: 14px;
    left: 50%;
    transform: translateX(-50%);
    height: 36px;
    padding: 0 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    font-family: 'DM Sans', sans-serif;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    z-index: 99;
    display: none;
    align-items: center;
    gap: 6px;
    transition: color 0.2s, border-color 0.2s;
}

#add-url-btn:hover { color: var(--text); border-color: var(--accent); }
#add-url-btn.visible { display: flex; }

/* ── Layout ── */
#app {
    display: flex;
    height: 100vh;
    padding-top: var(--url-bar-height);
    transition: padding-top 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

#app.no-bar { padding-top: 0; }

/* ── Sidebar ── */
#sidebar {
    width: var(--sidebar-width);
    border-right: 1px solid var(--border);
    background: var(--surface);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

#sidebar-header {
    padding: 18px 16px 12px;
    font-size: 10px;
    font-weight: 500;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
}

#url-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
}

.url-item {
    padding: 10px 16px;
    font-size: 12px;
    font-family: 'DM Mono', monospace;
    color: var(--text-muted);
    border-bottom: 1px solid transparent;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    animation: fadeSlideIn 0.3s ease;
}

.url-item span {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.url-item .url-domain {
    font-size: 11px;
    color: var(--text);
    font-weight: 500;
    margin-bottom: 2px;
}

.url-item .url-full {
    font-size: 10px;
    color: var(--text-muted);
}

#sidebar-empty {
    padding: 20px 16px;
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.5;
}

/* ── Chat ── */
#chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#messages {
    flex: 1;
    overflow-y: auto;
    padding: 32px 40px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

#empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    gap: 8px;
    text-align: center;
}

#empty-state .hint { font-size: 13px; }

#empty-state .arrow {
    font-size: 20px;
    animation: bounce 2s infinite;
}

.message {
    display: flex;
    flex-direction: column;
    max-width: 680px;
    animation: fadeSlideIn 0.25s ease;
}

.message.user { align-self: flex-end; align-items: flex-end; }
.message.ai   { align-self: flex-start; align-items: flex-start; }

.bubble {
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.6;
}

.message.user .bubble {
    background: var(--user-bubble);
    color: var(--user-text);
    border-bottom-right-radius: 3px;
}

.message.ai .bubble {
    background: var(--ai-bubble);
    color: var(--text);
    border: 1px solid var(--ai-border);
    border-bottom-left-radius: 3px;
}

.typing .bubble {
    display: flex;
    gap: 4px;
    align-items: center;
    padding: 14px 18px;
}

.dot {
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--text-muted);
    animation: typingDot 1.2s infinite;
}
.dot:nth-child(2) { animation-delay: 0.2s; }
.dot:nth-child(3) { animation-delay: 0.4s; }

/* ── Input ── */
#chat-input-wrap {
    padding: 16px 40px 24px;
    border-top: 1px solid var(--border);
    background: var(--bg);
}

#chat-form {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

#chat-input {
    flex: 1;
    min-height: 44px;
    max-height: 140px;
    padding: 11px 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-family: 'DM Sans', sans-serif;
    font-size: 14px;
    background: var(--surface);
    color: var(--text);
    outline: none;
    resize: none;
    line-height: 1.5;
    transition: border-color 0.2s;
    overflow-y: auto;
}

#chat-input:focus { border-color: var(--accent); }
#chat-input::placeholder { color: var(--text-muted); }
#chat-input:disabled { opacity: 0.5; }

#send-btn {
    width: 44px; height: 44px;
    border-radius: 8px;
    background: var(--accent);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s;
}

#send-btn:hover { background: var(--accent-hover); }
#send-btn:disabled { opacity: 0.4; cursor: not-allowed; }
#send-btn svg { width: 16px; height: 16px; fill: white; }

/* ── Animations ── */
@keyframes fadeSlideIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-6px); }
}

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

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }