/* ========================================
   Design System — Knowledge Pipeline
   ======================================== */

:root {
    --sidebar-width: 240px;
    --color-bg: #f8f9fb;
    --color-surface: #ffffff;
    --color-sidebar: #0f172a;
    --color-sidebar-hover: rgba(255, 255, 255, 0.08);
    --color-sidebar-active: rgba(99, 102, 241, 0.2);
    --color-sidebar-active-text: #a5b4fc;
    --color-sidebar-text: #94a3b8;
    --color-sidebar-section: #475569;
    --color-primary: #6366f1;
    --color-primary-soft: #eef2ff;
    --color-success: #10b981;
    --color-success-soft: #ecfdf5;
    --color-warning: #f59e0b;
    --color-warning-soft: #fffbeb;
    --color-danger: #ef4444;
    --color-danger-soft: #fef2f2;
    --color-info: #3b82f6;
    --color-info-soft: #eff6ff;
    --color-text: #1e293b;
    --color-text-secondary: #64748b;
    --color-text-muted: #94a3b8;
    --color-border: #e2e8f0;
    --color-border-light: #f1f5f9;
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-lg: 0 4px 12px rgba(0, 0, 0, 0.08);
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-mono: 'SF Mono', 'Fira Code', 'Fira Mono', Menlo, monospace;
}

/* ── Reset & Base ── */

* { box-sizing: border-box; }

body {
    font-family: var(--font-sans);
    font-size: 13.5px;
    color: var(--color-text);
    background: var(--color-bg);
    margin: 0;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* ── Layout ── */

.app-layout {
    display: flex;
    min-height: 100vh;
}

.main-content {
    flex: 1;
    min-width: 0;
    padding: 28px 32px;
    max-width: calc(100vw - var(--sidebar-width));
}

/* ── Sidebar ── */

.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    background: var(--color-sidebar);
    color: var(--color-sidebar-text);
    padding: 20px 12px;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 12px 20px;
    color: #fff;
    font-size: 15px;
    font-weight: 600;
    letter-spacing: -0.01em;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    margin-bottom: 16px;
}

.sidebar-section {
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: 0.08em;
    color: var(--color-sidebar-section);
    padding: 16px 12px 6px;
    text-transform: uppercase;
}

.sidebar-nav {
    list-style: none;
    padding: 0;
    margin: 0 0 4px;
}

.sidebar-nav li a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    color: var(--color-sidebar-text);
    text-decoration: none;
    font-size: 13.5px;
    font-weight: 450;
    border-radius: var(--radius-sm);
    transition: all 0.15s ease;
}

.sidebar-nav li a:hover {
    background: var(--color-sidebar-hover);
    color: #e2e8f0;
}

.sidebar-nav li a.active {
    background: var(--color-sidebar-active);
    color: var(--color-sidebar-active-text);
    font-weight: 550;
}

.sidebar-nav li a svg {
    opacity: 0.7;
    flex-shrink: 0;
}

.sidebar-nav li a.active svg {
    opacity: 1;
}

/* ── Page Headers ── */

.page-header {
    margin-bottom: 24px;
}

.page-header h1 {
    font-size: 22px;
    font-weight: 650;
    color: var(--color-text);
    margin: 0;
    letter-spacing: -0.02em;
}

.page-header p {
    color: var(--color-text-secondary);
    margin: 4px 0 0;
    font-size: 13.5px;
}

h2 {
    font-size: 22px;
    font-weight: 650;
    color: var(--color-text);
    letter-spacing: -0.02em;
    margin: 0 0 20px;
}

h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--color-text);
    letter-spacing: -0.01em;
}

/* ── Stat Cards ── */

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.15s ease;
}

.stat-card:hover {
    box-shadow: var(--shadow-md);
}

.stat-card .stat-value {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.03em;
    line-height: 1.1;
}

.stat-card .stat-label {
    font-size: 12.5px;
    color: var(--color-text-secondary);
    font-weight: 500;
    margin-top: 4px;
}

.stat-card.stat-primary .stat-value { color: var(--color-primary); }
.stat-card.stat-success .stat-value { color: var(--color-success); }
.stat-card.stat-warning .stat-value { color: var(--color-warning); }
.stat-card.stat-info .stat-value { color: var(--color-info); }
.stat-card.stat-danger .stat-value { color: var(--color-danger); }

/* ── Cards ── */

.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--color-border-light);
    padding: 14px 20px;
    font-weight: 600;
    font-size: 13.5px;
    color: var(--color-text);
}

.card-body {
    padding: 20px;
}

.card-footer {
    background: transparent;
    border-top: 1px solid var(--color-border-light);
    padding: 12px 20px;
}

/* ── Tables ── */

.table {
    font-size: 13px;
    margin-bottom: 0;
}

.table thead th {
    background: var(--color-bg);
    border-bottom: 1px solid var(--color-border);
    font-weight: 600;
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--color-text-secondary);
    padding: 10px 16px;
    white-space: nowrap;
}

.table tbody td {
    padding: 10px 16px;
    border-bottom: 1px solid var(--color-border-light);
    vertical-align: middle;
    color: var(--color-text);
}

.table tbody tr:last-child td {
    border-bottom: none;
}

.table-hover tbody tr:hover {
    background-color: #f8fafc;
}

.table-hover tbody tr:hover td {
    color: var(--color-text);
}

/* ── Badges ── */

.badge {
    font-weight: 550;
    font-size: 11px;
    letter-spacing: 0.02em;
    padding: 3px 8px;
    border-radius: 4px;
}

.badge-status {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 11.5px;
    font-weight: 550;
    padding: 3px 10px;
    border-radius: 20px;
}

.badge-status::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
}

.badge-status.status-success { background: var(--color-success-soft); color: #065f46; }
.badge-status.status-success::before { background: var(--color-success); }
.badge-status.status-warning { background: var(--color-warning-soft); color: #92400e; }
.badge-status.status-warning::before { background: var(--color-warning); }
.badge-status.status-danger { background: var(--color-danger-soft); color: #991b1b; }
.badge-status.status-danger::before { background: var(--color-danger); }
.badge-status.status-info { background: var(--color-info-soft); color: #1e40af; }
.badge-status.status-info::before { background: var(--color-info); }
.badge-status.status-primary { background: var(--color-primary-soft); color: #3730a3; }
.badge-status.status-primary::before { background: var(--color-primary); }

.badge-tag {
    background: var(--color-bg);
    color: var(--color-text-secondary);
    border: 1px solid var(--color-border);
    font-size: 11px;
    font-weight: 500;
    padding: 2px 8px;
    border-radius: 4px;
}

/* ── Buttons ── */

.btn {
    font-size: 13px;
    font-weight: 550;
    border-radius: var(--radius-sm);
    padding: 7px 14px;
    transition: all 0.15s ease;
}

.btn-primary {
    background: var(--color-primary);
    border-color: var(--color-primary);
}

.btn-primary:hover {
    background: #4f46e5;
    border-color: #4f46e5;
}

.btn-sm {
    font-size: 12px;
    padding: 4px 10px;
}

.btn-outline-secondary {
    color: var(--color-text-secondary);
    border-color: var(--color-border);
}

.btn-outline-secondary:hover {
    background: var(--color-bg);
    border-color: var(--color-border);
    color: var(--color-text);
}

/* ── Forms ── */

.form-control, .form-select {
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    padding: 8px 12px;
    color: var(--color-text);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-control:focus, .form-select:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
}

.form-control-lg {
    padding: 10px 14px;
    font-size: 14px;
}

.form-check-input:checked {
    background-color: var(--color-primary);
    border-color: var(--color-primary);
}

/* ── Nav Tabs ── */

.nav-tabs {
    border-bottom: 1px solid var(--color-border);
    gap: 0;
}

.nav-tabs .nav-link {
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--color-text-secondary);
    font-weight: 500;
    font-size: 13.5px;
    padding: 10px 16px;
    border-radius: 0;
    transition: all 0.15s ease;
}

.nav-tabs .nav-link:hover {
    color: var(--color-text);
    border-bottom-color: var(--color-border);
    background: transparent;
}

.nav-tabs .nav-link.active {
    color: var(--color-primary);
    border-bottom-color: var(--color-primary);
    background: transparent;
    font-weight: 600;
}

/* ── Pagination ── */

.pagination {
    gap: 4px;
}

.pagination .page-link {
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm) !important;
    color: var(--color-text-secondary);
    font-size: 13px;
    font-weight: 500;
    padding: 6px 12px;
    min-width: 36px;
    text-align: center;
}

.pagination .page-item.active .page-link {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: #fff;
}

.pagination .page-item.disabled .page-link {
    background: transparent;
    border-color: var(--color-border-light);
    color: var(--color-text-muted);
}

.pagination .page-link:hover {
    background: var(--color-bg);
    border-color: var(--color-border);
    color: var(--color-text);
}

/* ── Alerts ── */

.alert {
    border-radius: var(--radius-md);
    font-size: 13.5px;
    border: none;
}

/* ── Code / Pre ── */

code {
    font-family: var(--font-mono);
    font-size: 12px;
    background: var(--color-bg);
    padding: 2px 6px;
    border-radius: 4px;
    color: var(--color-primary);
}

pre {
    font-family: var(--font-mono);
    background: #fafbfc;
    border: 1px solid var(--color-border-light);
    padding: 16px;
    border-radius: var(--radius-md);
    overflow-x: auto;
    font-size: 12.5px;
    line-height: 1.6;
}

/* ── Search ── */

.search-wrapper {
    position: relative;
    margin-bottom: 20px;
}

.search-wrapper .input-group {
    box-shadow: var(--shadow-sm);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.search-wrapper .input-group-text {
    background: var(--color-surface);
    border-color: var(--color-border);
    color: var(--color-text-muted);
}

.search-wrapper .form-control {
    border-color: var(--color-border);
}

.search-wrapper .form-control:focus {
    box-shadow: none;
}

.search-wrapper .input-group:focus-within {
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
}

#searchDropdown {
    border-radius: 0 0 var(--radius-md) var(--radius-md) !important;
    border: 1px solid var(--color-border);
    border-top: none;
    box-shadow: var(--shadow-lg) !important;
}

.search-result-item {
    padding: 12px 16px;
    border-bottom: 1px solid var(--color-border-light);
    cursor: pointer;
    transition: background-color 0.1s;
}

.search-result-item:hover {
    background-color: var(--color-bg);
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-score {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 12px;
    font-weight: 600;
    font-family: var(--font-mono);
}

.score-high { background: var(--color-success-soft); color: #065f46; }
.score-med { background: var(--color-warning-soft); color: #92400e; }
.score-low { background: var(--color-bg); color: var(--color-text-muted); }

.search-snippet {
    font-size: 12.5px;
    color: var(--color-text-secondary);
    line-height: 1.4;
    margin-top: 4px;
}

/* ── Trigger Pipeline form ── */

.trigger-form {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr auto;
    gap: 12px;
    align-items: end;
}

.trigger-form .form-group label {
    font-size: 11.5px;
    font-weight: 600;
    color: var(--color-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 6px;
    display: block;
}

/* ── Meta / Detail rows ── */

.meta-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.meta-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.meta-item .meta-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--color-text-muted);
}

.meta-item .meta-value {
    font-size: 13.5px;
    color: var(--color-text);
    font-weight: 500;
}

/* ── Empty State ── */

.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: var(--color-text-muted);
}

.empty-state svg {
    opacity: 0.3;
    margin-bottom: 12px;
}

/* ── Utility overrides ── */

.text-muted { color: var(--color-text-secondary) !important; }

.bg-success { background-color: var(--color-success) !important; }
.bg-danger { background-color: var(--color-danger) !important; }
.bg-warning { background-color: var(--color-warning) !important; }
.bg-info { background-color: var(--color-info) !important; }
.bg-primary { background-color: var(--color-primary) !important; }
.bg-secondary { background-color: #475569 !important; }

/* ── Relationship Graph ── */

#graph {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
}

/* ── Misc ── */

.card-title {
    font-size: inherit;
    margin-bottom: 0;
}

small, .small { font-size: 12.5px; }

hr { border-color: var(--color-border-light); }

/* ========================================
   Chat Interface
   ======================================== */

.chat-layout {
    display: flex;
    height: calc(100vh - 56px);
    margin: -28px -32px;
    overflow: hidden;
}

/* ── Chat Sidebar ── */

.chat-sidebar {
    width: 280px;
    min-width: 280px;
    background: var(--color-surface);
    border-right: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 16px;
    border-bottom: 1px solid var(--color-border-light);
}

.chat-conversation-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.chat-conversation-item {
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    position: relative;
    transition: background 0.15s ease;
    margin-bottom: 2px;
}

.chat-conversation-item:hover {
    background: var(--color-bg);
}

.chat-conversation-item.active {
    background: var(--color-primary-soft);
}

.chat-conv-title {
    font-size: 13px;
    font-weight: 500;
    color: var(--color-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding-right: 48px;
}

.chat-conv-meta {
    font-size: 11px;
    color: var(--color-text-muted);
    margin-top: 2px;
}

.chat-conv-actions {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    display: none;
    gap: 2px;
}

.chat-conversation-item:hover .chat-conv-actions {
    display: flex;
}

.chat-conv-action-btn {
    background: none;
    border: none;
    padding: 4px;
    cursor: pointer;
    color: var(--color-text-muted);
    border-radius: 4px;
    transition: all 0.15s;
}

.chat-conv-action-btn:hover {
    background: var(--color-border-light);
    color: var(--color-text);
}

/* ── Chat Main Area ── */

.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: var(--color-bg);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px 32px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* ── Welcome Screen ── */

.chat-welcome {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 60px 20px;
    flex: 1;
}

.chat-welcome h2 {
    font-size: 22px;
    font-weight: 650;
    margin: 0 0 8px;
    color: var(--color-text);
}

.chat-welcome p {
    color: var(--color-text-secondary);
    max-width: 480px;
    font-size: 14px;
    margin: 0;
}

.chat-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 28px;
    justify-content: center;
    max-width: 600px;
}

.chat-suggestion-chip {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 20px;
    padding: 9px 18px;
    font-size: 13px;
    color: var(--color-text-secondary);
    cursor: pointer;
    transition: all 0.15s;
    font-family: var(--font-sans);
}

.chat-suggestion-chip:hover {
    border-color: var(--color-primary);
    color: var(--color-primary);
    background: var(--color-primary-soft);
}

/* ── Messages ── */

.chat-message {
    display: flex;
    gap: 12px;
    max-width: 760px;
    width: 100%;
    animation: fadeInMsg 0.2s ease;
}

@keyframes fadeInMsg {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.chat-message-user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.chat-message-assistant {
    align-self: flex-start;
}

.chat-message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-message-user .chat-message-avatar {
    background: var(--color-primary);
    color: #fff;
}

.chat-message-assistant .chat-message-avatar {
    background: var(--color-success-soft);
    color: var(--color-success);
}

.chat-message-body {
    flex: 1;
    min-width: 0;
}

.chat-message-content {
    padding: 12px 16px;
    border-radius: var(--radius-lg);
    font-size: 13.5px;
    line-height: 1.65;
    word-wrap: break-word;
}

.chat-message-user .chat-message-content {
    background: var(--color-primary);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.chat-message-assistant .chat-message-content {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-bottom-left-radius: 4px;
    color: var(--color-text);
}

.chat-message-assistant .chat-message-content h3,
.chat-message-assistant .chat-message-content h4 {
    margin: 12px 0 4px;
    font-size: 14px;
}

.chat-message-assistant .chat-message-content code {
    font-size: 12px;
    background: var(--color-bg);
    padding: 1px 5px;
    border-radius: 3px;
}

.chat-message-assistant .chat-message-content pre {
    margin: 8px 0;
    padding: 12px;
    font-size: 12px;
    background: var(--color-bg);
    border: 1px solid var(--color-border-light);
    border-radius: var(--radius-sm);
}

.chat-message-assistant .chat-message-content pre code {
    background: none;
    padding: 0;
}

.chat-typing {
    color: var(--color-text-muted);
    font-style: italic;
}

/* ── Source Citations ── */

.chat-sources {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
}

.chat-sources-label {
    font-size: 10.5px;
    color: var(--color-text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.chat-source-chip {
    font-size: 11.5px;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: 4px;
    padding: 2px 8px;
    color: var(--color-text-secondary);
    text-decoration: none;
    transition: all 0.15s;
}

.chat-source-chip:hover {
    border-color: var(--color-primary);
    color: var(--color-primary);
}

/* ── Input Area ── */

.chat-input-area {
    border-top: 1px solid var(--color-border);
    background: var(--color-surface);
    padding: 16px 32px;
}

.chat-input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 8px 12px;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.chat-input-wrapper:focus-within {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
}

.chat-input {
    flex: 1;
    border: none;
    background: transparent;
    font-family: var(--font-sans);
    font-size: 14px;
    color: var(--color-text);
    resize: none;
    outline: none;
    max-height: 120px;
    line-height: 1.5;
    padding: 4px 0;
}

.chat-input::placeholder {
    color: var(--color-text-muted);
}

.chat-send-btn, .chat-voice-btn, .chat-voice-mode-btn {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.15s;
}

.chat-send-btn {
    background: var(--color-primary);
    color: #fff;
}

.chat-send-btn:hover {
    background: #4f46e5;
}

.chat-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.chat-voice-btn {
    background: transparent;
    color: var(--color-text-muted);
    border: 1px solid var(--color-border);
}

.chat-voice-btn:hover {
    color: var(--color-text);
    background: var(--color-surface);
}

.chat-voice-btn.recording {
    background: var(--color-danger-soft);
    border-color: var(--color-danger);
    color: var(--color-danger);
    animation: pulse-recording 1.5s infinite;
}

@keyframes pulse-recording {
    0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.3); }
    50% { box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); }
}

/* ─── Voice Overlay ─── */

.voice-overlay {
    position: fixed;
    inset: 0;
    background: rgba(10, 15, 30, 0.92);
    backdrop-filter: blur(20px);
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
}

.voice-overlay.active {
    display: flex;
}

.voice-overlay-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
    color: #fff;
    text-align: center;
    max-width: 400px;
    padding: 40px;
}

.voice-status {
    font-size: 18px;
    font-weight: 500;
    opacity: 0.9;
    min-height: 28px;
}

.voice-orb-container {
    position: relative;
    width: 140px;
    height: 140px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.voice-orb {
    width: 88px;
    height: 88px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 2;
    position: relative;
}

.voice-orb-idle {
    background: var(--color-primary);
    box-shadow: 0 0 30px rgba(99, 102, 241, 0.4);
}

.voice-orb-idle:hover {
    transform: scale(1.08);
    box-shadow: 0 0 40px rgba(99, 102, 241, 0.6);
}

.voice-orb-listening {
    background: #ef4444;
    box-shadow: 0 0 30px rgba(239, 68, 68, 0.5);
    animation: orb-pulse 1.5s ease-in-out infinite;
}

.voice-orb-processing {
    background: #f59e0b;
    box-shadow: 0 0 30px rgba(245, 158, 11, 0.5);
    animation: orb-spin 2s linear infinite;
}

.voice-orb-speaking {
    background: #10b981;
    box-shadow: 0 0 30px rgba(16, 185, 129, 0.5);
    animation: orb-speak 0.8s ease-in-out infinite;
}

.voice-ripple {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    z-index: 1;
}

.voice-ripple-listening {
    border: 2px solid rgba(239, 68, 68, 0.3);
    animation: ripple-expand 1.5s ease-out infinite;
}

.voice-ripple-speaking {
    border: 2px solid rgba(16, 185, 129, 0.3);
    animation: ripple-expand 1.2s ease-out infinite;
}

.voice-transcript {
    font-size: 14px;
    opacity: 0.7;
    min-height: 24px;
    max-width: 350px;
    line-height: 1.5;
}

.voice-end-btn {
    padding: 10px 32px;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
    border-radius: 24px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    margin-top: 16px;
}

.voice-end-btn:hover {
    background: rgba(239, 68, 68, 0.3);
    border-color: rgba(239, 68, 68, 0.5);
}

@keyframes orb-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

@keyframes orb-spin {
    0% { box-shadow: 0 0 30px rgba(245, 158, 11, 0.5); }
    50% { box-shadow: 0 0 50px rgba(245, 158, 11, 0.3); }
    100% { box-shadow: 0 0 30px rgba(245, 158, 11, 0.5); }
}

@keyframes orb-speak {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.06); }
}

@keyframes ripple-expand {
    0% { transform: scale(0.7); opacity: 1; }
    100% { transform: scale(1.6); opacity: 0; }
}

.chat-input-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 8px;
    font-size: 11px;
    color: var(--color-text-muted);
}

.chat-voice-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--color-danger);
    display: inline-block;
    animation: pulse-recording 1.5s infinite;
}

/* ── TTS button ── */

.chat-tts-btn {
    background: none;
    border: 1px solid var(--color-border);
    border-radius: 50%;
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--color-text-muted);
    margin-top: 6px;
    transition: all 0.15s;
}

.chat-tts-btn:hover {
    color: var(--color-primary);
    border-color: var(--color-primary);
}

/* ── Voice Agent Page ── */

.voice-agent-page {
    display: flex;
    align-items: stretch;
    justify-content: center;
    height: calc(100vh - 56px);
    background: linear-gradient(145deg, #0a0e1a 0%, #111827 50%, #0f172a 100%);
    margin: -28px -32px;
}

.va-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
    padding: 24px 20px 16px;
}

/* Conversation History */
.va-history {
    flex: 1;
    width: 100%;
    overflow-y: auto;
    padding: 0 8px 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 0;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.1) transparent;
}

.va-history::-webkit-scrollbar { width: 4px; }
.va-history::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }

.va-history-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    flex: 1;
    gap: 12px;
    padding: 40px 20px;
}

.va-welcome-icon { opacity: 0.5; }

.va-welcome-title {
    font-size: 20px;
    font-weight: 600;
    color: rgba(255,255,255,0.8);
    letter-spacing: -0.01em;
}

.va-welcome-sub {
    font-size: 13.5px;
    color: rgba(255,255,255,0.4);
    line-height: 1.6;
}

.va-history-item {
    padding: 10px 14px;
    border-radius: 10px;
    animation: fadeInMsg 0.2s ease;
}

.va-history-user {
    background: rgba(99,102,241,0.12);
    border: 1px solid rgba(99,102,241,0.15);
    align-self: flex-end;
    max-width: 85%;
}

.va-history-ai {
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.06);
    align-self: flex-start;
    max-width: 85%;
}

.va-history-system {
    background: rgba(245,158,11,0.08);
    border: 1px solid rgba(245,158,11,0.15);
    align-self: center;
    max-width: 90%;
    text-align: center;
}

.va-history-label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 4px;
}

.va-history-user .va-history-label { color: rgba(165,180,252,0.7); }
.va-history-ai .va-history-label { color: rgba(110,231,183,0.7); }
.va-history-system .va-history-label { color: rgba(253,186,116,0.7); }

.va-history-text {
    font-size: 13.5px;
    line-height: 1.55;
    color: rgba(255,255,255,0.8);
    word-wrap: break-word;
}

/* Center area: status + orb + live transcript */
.va-center {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 12px 0 8px;
    flex-shrink: 0;
}

.va-status {
    font-size: 14px;
    font-weight: 500;
    color: rgba(255,255,255,0.6);
    letter-spacing: 0.3px;
    text-align: center;
    min-height: 20px;
}

/* Orb */
.va-orb-wrap {
    position: relative;
    width: 120px;
    height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.va-orb {
    width: 96px;
    height: 96px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.4s ease;
    z-index: 2;
    position: relative;
    border: none;
    outline: none;
}

.va-orb:hover { transform: scale(1.05); }

.va-orb-idle {
    background: linear-gradient(135deg, #3b82f6, #6366f1);
    box-shadow: 0 0 40px rgba(99,102,241,0.3);
}

.va-orb-connecting {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    box-shadow: 0 0 40px rgba(245,158,11,0.3);
    animation: va-pulse 1.5s infinite;
}

.va-orb-listening {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    box-shadow: 0 0 50px rgba(239,68,68,0.4);
    animation: va-pulse 1.2s infinite;
}

.va-orb-processing {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    box-shadow: 0 0 40px rgba(245,158,11,0.3);
    animation: va-spin 2s linear infinite;
}

.va-orb-speaking {
    background: linear-gradient(135deg, #10b981, #059669);
    box-shadow: 0 0 50px rgba(16,185,129,0.4);
    animation: va-speak 0.8s ease-in-out infinite alternate;
}

.va-orb-interrupted {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    box-shadow: 0 0 30px rgba(239,68,68,0.3);
}

.va-orb-error {
    background: linear-gradient(135deg, #6b7280, #4b5563);
    box-shadow: 0 0 20px rgba(107,114,128,0.2);
}

/* Ripple */
.va-ripple {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 96px;
    height: 96px;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    z-index: 1;
    pointer-events: none;
}

.va-ripple-listening {
    border: 2px solid rgba(239,68,68,0.4);
    animation: va-ripple-expand 1.5s ease-out infinite;
}

.va-ripple-speaking {
    border: 2px solid rgba(16,185,129,0.4);
    animation: va-ripple-expand 2s ease-out infinite;
}

/* Live transcript */
.va-live-transcript {
    color: rgba(255,255,255,0.65);
    font-size: 13px;
    line-height: 1.5;
    text-align: center;
    max-width: 400px;
    min-height: 20px;
    font-style: italic;
}

/* Controls */
.va-controls {
    display: flex;
    gap: 12px;
    flex-shrink: 0;
    padding: 4px 0;
}

.va-end-btn {
    background: rgba(239,68,68,0.15);
    color: #f87171;
    border: 1px solid rgba(239,68,68,0.3);
    border-radius: 24px;
    padding: 8px 28px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    font-family: var(--font-sans);
}

.va-end-btn:hover {
    background: rgba(239,68,68,0.25);
    border-color: rgba(239,68,68,0.5);
}

.va-footer {
    color: rgba(255,255,255,0.2);
    font-size: 11px;
    flex-shrink: 0;
    padding-top: 8px;
}

/* Animations */
@keyframes va-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.06); }
}

@keyframes va-spin {
    0% { box-shadow: 0 0 30px rgba(245,158,11,0.3); }
    50% { box-shadow: 0 0 50px rgba(245,158,11,0.5); }
    100% { box-shadow: 0 0 30px rgba(245,158,11,0.3); }
}

@keyframes va-speak {
    0% { transform: scale(1); box-shadow: 0 0 40px rgba(16,185,129,0.3); }
    100% { transform: scale(1.08); box-shadow: 0 0 60px rgba(16,185,129,0.5); }
}

@keyframes va-ripple-expand {
    0% { transform: translate(-50%,-50%) scale(1); opacity: 0.6; }
    100% { transform: translate(-50%,-50%) scale(2); opacity: 0; }
}

/* Inter font (loaded async for performance) */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;450;500;550;600;700&display=swap');
