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

:root {
    --bg: #fafafa;
    --surface: #ffffff;
    --surface-raised: #f4f4f5;
    --border: #e4e4e7;
    --border-light: #f0f0f2;
    --text-primary: #18181b;
    --text-secondary: #52525b;
    --text-muted: #a1a1aa;
    --accent: #18181b;
    --accent-hover: #27272a;
    --accent-subtle: #f4f4f5;
    --blue: #3b82f6;
    --blue-light: #eff6ff;
    --green: #10b981;
    --green-light: #ecfdf5;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.06);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.08);
    --transition: 150ms ease;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

#app {
    height: 100vh;
    display: flex;
    flex-direction: column;
    max-width: 900px;
    margin: 0 auto;
}

.screen {
    display: none;
    height: 100vh;
    flex-direction: column;
}

.screen.active {
    display: flex;
}

/* ── Brand Selection ── */
.brand-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 2rem;
}

.brand-container h1 {
    font-size: 1.5rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--text-primary);
    margin-bottom: 0.35rem;
}

.brand-container p {
    color: var(--text-muted);
    margin-bottom: 2.5rem;
    font-size: 0.9rem;
    font-weight: 400;
}

.brand-buttons {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    justify-content: center;
}

.brand-btn {
    padding: 1.75rem 2.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
    cursor: pointer;
    transition: all var(--transition);
    text-align: center;
    min-width: 200px;
    box-shadow: var(--shadow-sm);
}

.brand-btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.brand-btn.ids:hover {
    border-color: var(--blue);
}

.brand-btn.cbs:hover {
    border-color: var(--green);
}

.brand-name {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 0.25rem;
}

.ids .brand-name { color: var(--text-primary); }
.cbs .brand-name { color: var(--text-primary); }

.brand-sub {
    display: block;
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 400;
}

/* ── Chat Header ── */
header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.875rem 1.25rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.back-btn {
    background: none;
    border: none;
    font-size: 1.1rem;
    cursor: pointer;
    color: var(--text-muted);
    padding: 0.25rem 0.4rem;
    border-radius: var(--radius-sm);
    transition: all var(--transition);
}

.back-btn:hover {
    background: var(--surface-raised);
    color: var(--text-primary);
}

header h2 {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

.settings-btn {
    background: none;
    border: none;
    font-size: 1.15rem;
    cursor: pointer;
    color: var(--text-muted);
    padding: 0.25rem 0.4rem;
    border-radius: var(--radius-sm);
    transition: all var(--transition);
}

.settings-btn:hover {
    background: var(--surface-raised);
    color: var(--text-primary);
}

/* ── Settings Panel ── */
.settings-panel {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 1rem 1.25rem;
    flex-shrink: 0;
}

.settings-panel.hidden { display: none; }

.settings-panel h3 {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.75rem;
    color: var(--text-muted);
}

.setting-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.setting-row label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    min-width: 60px;
    font-weight: 500;
}

.setting-row select,
.setting-row input {
    flex: 1;
    padding: 0.4rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-family: inherit;
    background: var(--surface);
    color: var(--text-primary);
    transition: border-color var(--transition);
}

.setting-row select:focus,
.setting-row input:focus {
    outline: none;
    border-color: var(--text-muted);
}

.save-btn {
    margin-top: 0.75rem;
    padding: 0.45rem 1rem;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 500;
    font-family: inherit;
    transition: background var(--transition);
}

.save-btn:hover { background: var(--accent-hover); }

/* ── Status Bar ── */
.status-bar {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.35rem 1.25rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border-light);
    flex-shrink: 0;
}

.badge {
    padding: 0.1rem 0.45rem;
    border-radius: 100px;
    font-weight: 500;
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.badge.metadata {
    background: #fef9c3;
    color: #854d0e;
}

.badge.vector {
    background: #dcfce7;
    color: #166534;
}

.pipeline-status {
    color: var(--text-muted);
    font-size: 0.7rem;
}

/* ── Chat Messages ── */
#chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    background: var(--bg);
}

#chat-messages::-webkit-scrollbar {
    width: 4px;
}

#chat-messages::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 100px;
}

.message {
    max-width: 88%;
    padding: 0.875rem 1.1rem;
    border-radius: var(--radius-lg);
    line-height: 1.6;
    font-size: 0.875rem;
}

.message.bot {
    background: var(--surface);
    align-self: flex-start;
    border: 1px solid var(--border-light);
    box-shadow: var(--shadow-sm);
    color: var(--text-secondary);
}

.message.user {
    background: var(--accent);
    color: white;
    align-self: flex-end;
    box-shadow: var(--shadow-sm);
}

.message-content p {
    margin-bottom: 0.5rem;
}

.message-content p:last-child {
    margin-bottom: 0;
}

.message-content ul {
    margin: 0.5rem 0;
    padding-left: 1.25rem;
}

.message-content li {
    margin-bottom: 0.2rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.message-content strong {
    color: var(--text-primary);
    font-weight: 600;
}

.message-content a {
    color: var(--blue);
    text-decoration: none;
    font-weight: 500;
}

.message-content a:hover {
    text-decoration: underline;
}

/* ── Video Results ── */
.video-results {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.video-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 1rem 1.1rem;
    margin: 0.5rem 0;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.video-card:hover {
    border-color: var(--text-muted);
    box-shadow: var(--shadow-sm);
}

.video-card h4 {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.2rem;
    letter-spacing: -0.01em;
}

.video-card .meta {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 0.6rem;
    font-weight: 400;
}

.video-card .reason {
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.55;
    font-style: normal;
}

.video-card .watch-link {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    margin-top: 0.75rem;
    padding: 0.35rem 0.85rem;
    background: var(--accent);
    color: white;
    border-radius: var(--radius-sm);
    text-decoration: none;
    font-size: 0.75rem;
    font-weight: 500;
    letter-spacing: 0.01em;
    transition: background var(--transition);
}

.video-card .watch-link:hover {
    background: var(--accent-hover);
    text-decoration: none;
}

.hidden-card {
    display: none;
}

.show-more-btn {
    width: 100%;
    padding: 0.6rem;
    margin-top: 0.25rem;
    background: var(--surface);
    border: 1px dashed var(--border);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: all var(--transition);
}

.show-more-btn:hover {
    background: var(--surface-raised);
    border-color: var(--text-muted);
    color: var(--text-primary);
}

/* ── Loading ── */
.loading {
    display: flex;
    gap: 0.25rem;
    padding: 0.5rem 0;
}

.loading span {
    width: 6px;
    height: 6px;
    background: var(--text-muted);
    border-radius: 50%;
    animation: bounce 1.4s ease-in-out infinite;
}

.loading span:nth-child(2) { animation-delay: 0.16s; }
.loading span:nth-child(3) { animation-delay: 0.32s; }

@keyframes bounce {
    0%, 80%, 100% { transform: scale(0); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

/* ── Input Area ── */
.input-area {
    padding: 0.875rem 1.25rem;
    background: var(--surface);
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

.input-row {
    display: flex;
    gap: 0.5rem;
    align-items: flex-end;
}

.input-row:first-child {
    margin-bottom: 0.5rem;
}

.industry-field {
    flex: 1;
    padding: 0.45rem 0.7rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-family: inherit;
    max-width: 240px;
    color: var(--text-primary);
    background: var(--surface);
    transition: border-color var(--transition);
}

.industry-field:focus {
    outline: none;
    border-color: var(--text-muted);
}

.industry-field::placeholder {
    color: var(--text-muted);
}

.main-input {
    display: flex;
}

#message-input {
    flex: 1;
    padding: 0.6rem 0.85rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    resize: none;
    font-family: inherit;
    line-height: 1.5;
    color: var(--text-primary);
    background: var(--surface);
    transition: border-color var(--transition), box-shadow var(--transition);
}

#message-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(24, 24, 27, 0.06);
}

#message-input::placeholder {
    color: var(--text-muted);
}

#send-btn {
    padding: 0.6rem 1.25rem;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 500;
    font-family: inherit;
    align-self: flex-end;
    transition: background var(--transition), transform var(--transition);
    letter-spacing: 0.01em;
}

#send-btn:hover {
    background: var(--accent-hover);
}

#send-btn:active {
    transform: scale(0.97);
}

#send-btn:disabled {
    background: var(--border);
    cursor: not-allowed;
}

/* ── Responsive ── */
@media (max-width: 640px) {
    #app {
        max-width: 100%;
    }
    .brand-btn {
        min-width: 160px;
        padding: 1.5rem 2rem;
    }
    .brand-name { font-size: 1.3rem; }
    .message { max-width: 94%; }
    .industry-field { max-width: 100%; }
}

/* ── Load Inter font ── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');
