:root {
  --ink: #ececec;
  --muted: #b4b4b4;
  --subtle: #8f8f98;
  --line: #3d3d3f;
  --soft: #2f2f2f;
  --sidebar: #171717;
  --white: #212121;
  --accent: #10a37f;
  --accent-dark: #4ec9aa;
  --danger: #ff8585;
  --shadow: 0 10px 35px rgba(0, 0, 0, .28);
}

* { box-sizing: border-box; }
[hidden], .hidden { display: none !important; }
html { scroll-behavior: smooth; }
body { margin: 0; min-height: 100dvh; color: var(--ink); background: var(--white); font: 14px/1.5 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; -webkit-tap-highlight-color: transparent; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }

.app-shell { min-height: 100dvh; display: flex; }
.sidebar { width: 260px; height: 100dvh; flex: 0 0 260px; display: flex; flex-direction: column; padding: 12px; background: var(--sidebar); border-right: 1px solid #292929; position: sticky; top: 0; }
.sidebar-top { display: grid; gap: 18px; }
.brand { min-height: 42px; display: flex; align-items: center; gap: 11px; padding: 5px 8px; color: var(--ink); text-decoration: none; }
.brand-mark { width: 29px; height: 29px; display: grid; place-items: center; position: relative; flex: 0 0 auto; }
.brand-mark i { width: 18px; height: 18px; position: absolute; border: 1.7px solid var(--ink); border-radius: 50%; }
.brand-mark i:nth-child(1) { transform: translate(-5px, -2px); }
.brand-mark i:nth-child(2) { transform: translate(5px, -2px); }
.brand-mark i:nth-child(3) { transform: translateY(6px); background: var(--accent); border-color: var(--accent); }
.brand-copy { display: grid; line-height: 1.15; }
.brand-copy strong { font-size: 15px; letter-spacing: -.01em; }
.brand-copy small { margin-top: 3px; color: var(--subtle); font-size: 11px; font-weight: 400; }
.sidebar-button, .account-button, .mobile-settings { min-height: 42px; width: 100%; display: flex; align-items: center; gap: 10px; border: 0; border-radius: 8px; padding: 9px 10px; background: transparent; text-align: left; }
.sidebar-button:hover, .account-button:hover, .mobile-settings:hover { background: #2a2a2a; }
.new-chat-button { border: 1px solid var(--line); background: transparent; font-weight: 600; }
.new-chat-button span:first-child { font-size: 20px; font-weight: 300; line-height: 1; }
.sidebar-section { flex: 1; min-height: 0; margin-top: 27px; overflow-y: auto; }
.sidebar-label { display: flex; align-items: center; justify-content: space-between; padding: 0 8px 7px; color: var(--subtle); font-size: 11px; font-weight: 600; }
.sidebar-label button { border: 0; padding: 5px; background: none; color: var(--muted); letter-spacing: 1px; }
.sidebar-label button:hover { color: var(--ink); }
.colleague-grid { display: grid; gap: 2px; }
.colleague-card { min-width: 0; display: grid; grid-template-columns: 30px 1fr auto; grid-template-rows: auto auto; column-gap: 9px; align-items: center; padding: 8px; border-radius: 8px; }
.colleague-card:hover { background: #2a2a2a; }
.avatar { width: 30px; height: 30px; grid-row: 1 / 3; display: grid; place-items: center; border-radius: 50%; background: var(--color); font-size: 12px; font-weight: 700; }
.colleague-card h3 { min-width: 0; margin: 0; overflow: hidden; color: var(--ink); font-size: 13px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.role { min-width: 0; overflow: hidden; color: var(--subtle); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.perspective { display: none; }
.model-badge { grid-row: 1 / 3; grid-column: 3; }
.model-badge span { display: none; }
.model-badge i { width: 7px; height: 7px; display: block; border-radius: 50%; background: var(--accent); }
.sidebar-bottom { display: grid; gap: 4px; padding-top: 10px; border-top: 1px solid var(--line); }
.account-button { font-weight: 550; }
.account-avatar-mini { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 50%; background: #444; color: var(--ink); font-size: 11px; font-weight: 700; }
.account-button.signed-in .account-avatar-mini { background: var(--accent); color: white; }

.workspace { min-width: 0; flex: 1; }
.mobile-bar { display: none; }
.mobile-actions { display: flex; align-items: center; gap: 3px; }
.mobile-icon-button, .mobile-account-button { width: 36px; height: 36px; display: grid; place-items: center; border: 0; border-radius: 8px; background: transparent; }
.mobile-icon-button { font-size: 20px; font-weight: 300; }
.mobile-account-button { border-radius: 50%; background: #444; color: var(--ink); font-size: 11px; font-weight: 700; }
.mobile-account-button.signed-in { background: var(--accent); color: white; }
.mobile-icon-button:hover, .mobile-account-button:hover { background-color: #383838; }
.chat-main { min-height: 100dvh; display: flex; flex-direction: column; overflow-x: hidden; }
.conversation { width: min(780px, calc(100% - 40px)); margin: 0 auto; flex: 1; }
.welcome { min-height: calc(100dvh - 190px); display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 60px 0 30px; text-align: center; }
.welcome-mark { width: 52px; height: 52px; position: relative; margin-bottom: 24px; }
.welcome-mark span { width: 31px; height: 31px; position: absolute; border: 2px solid var(--ink); border-radius: 50%; }
.welcome-mark span:nth-child(1) { left: 0; top: 1px; }
.welcome-mark span:nth-child(2) { right: 0; top: 1px; }
.welcome-mark span:nth-child(3) { left: 10px; bottom: 0; border-color: var(--accent); background: var(--accent); }
h1 { margin: 0; font-size: clamp(27px, 4vw, 34px); line-height: 1.15; letter-spacing: -.035em; font-weight: 600; }
.welcome p { max-width: 500px; margin: 13px auto 0; color: var(--muted); font-size: 15px; }

.composer-wrap { width: 100%; position: sticky; bottom: 0; z-index: 5; padding: 12px 20px max(16px, env(safe-area-inset-bottom)); background: linear-gradient(to bottom, rgba(33,33,33,0), var(--white) 22%); }
.composer { width: min(780px, 100%); margin: 0 auto; padding: 12px 12px 10px 16px; border: 1px solid #424242; border-radius: 18px; background: #303030; box-shadow: 0 3px 18px rgba(0,0,0,.22); }
.composer:focus-within { border-color: #5b5b5b; box-shadow: 0 4px 20px rgba(0,0,0,.28); }
.composer textarea { width: 100%; max-height: 160px; min-height: 28px; resize: none; border: 0; outline: 0; padding: 2px 4px 7px; background: transparent; font-size: 16px; line-height: 1.5; }
.composer textarea::placeholder, .composer input::placeholder { color: #929399; }
.composer-tools { display: flex; align-items: center; gap: 10px; }
.composer-tools input { min-width: 0; flex: 1; border: 0; outline: 0; padding: 5px 4px; background: transparent; color: var(--muted); font-size: 12px; }
.send-button { min-height: 34px; display: inline-flex; align-items: center; gap: 9px; border: 0; border-radius: 9px; padding: 7px 10px 7px 13px; background: #f4f4f4; color: #171717; font-size: 12px; font-weight: 650; }
.send-button:hover { background: #d9d9d9; }
.send-button:disabled { opacity: .45; cursor: wait; }
.send-button span:last-child { width: 20px; height: 20px; display: grid; place-items: center; border-radius: 6px; background: #171717; color: white; font-size: 15px; }
.composer-note { margin: 7px 0 0; color: var(--subtle); font-size: 10px; text-align: center; }

.session-active .welcome { display: none; }
.process, .results { padding: 48px 0 8px; }
.user-prompt { width: fit-content; max-width: 78%; margin: 0 0 42px auto; padding: 12px 17px; border-radius: 18px; background: var(--soft); font-size: 15px; white-space: pre-wrap; }
.assistant-row { display: grid; grid-template-columns: 30px 1fr; gap: 14px; align-items: start; }
.assistant-avatar { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 50%; background: var(--accent); color: white; font-size: 12px; font-weight: 700; }
.assistant-content { min-width: 0; }
.process-heading { min-height: 30px; display: flex; align-items: baseline; gap: 10px; }
.process-heading strong { font-size: 14px; }
.process-heading span { color: var(--muted); font-size: 12px; }
.process-track { max-width: 580px; display: flex; align-items: center; margin: 25px 0 20px; }
.process-track > i { height: 1px; flex: 1; background: var(--line); }
.process-step { display: flex; align-items: center; gap: 8px; color: #a0a1a5; }
.process-step > span { width: 25px; height: 25px; display: grid; place-items: center; border: 1px solid #d6d6d6; border-radius: 50%; font-size: 10px; }
.process-step b, .process-step small { display: block; line-height: 1.35; }
.process-step b { font-size: 10px; text-transform: uppercase; letter-spacing: .04em; }
.process-step small { font-size: 10px; }
.process-step.active { color: var(--ink); }
.process-step.active > span { border-color: var(--accent); background: #18352f; color: var(--accent-dark); }
.live-conversation { margin-top: 24px; }
.chat-turn { display: grid; grid-template-columns: 30px 1fr; gap: 14px; padding: 22px 0; border-top: 1px solid var(--line); }
.turn-avatar, .thinking-avatar { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 50%; background: var(--turn-color, #565869); color: white; font-size: 11px; font-weight: 750; }
.turn-body { min-width: 0; }
.turn-meta { display: flex; align-items: baseline; gap: 9px; margin-bottom: 7px; }
.turn-meta strong { font-size: 14px; }
.turn-meta span { color: var(--subtle); font-size: 10px; text-transform: capitalize; }
.turn-body > p { margin: 0; color: #dedee3; font-size: 14px; line-height: 1.7; white-space: pre-wrap; }
.chat-turn.error .turn-body > p { color: var(--danger); }
.chat-question { margin-top: 13px; padding: 12px 14px; border: 1px solid #4b4b4e; border-radius: 12px; background: #292929; color: var(--ink); font-size: 14px; line-height: 1.55; }
.chat-question::before { content: "Question for you"; display: block; margin-bottom: 5px; color: var(--accent-dark); font-size: 9px; font-weight: 750; letter-spacing: .07em; text-transform: uppercase; }
.chat-user-reply { width: fit-content; max-width: 78%; margin: 12px 0 16px auto; padding: 12px 17px; border-radius: 18px; background: var(--soft); font-size: 14px; line-height: 1.55; white-space: pre-wrap; }
.thinking-row { display: grid; grid-template-columns: 30px 1fr; gap: 14px; align-items: center; padding: 18px 0; border-top: 1px solid var(--line); }
.thinking { min-height: 46px; display: flex; align-items: center; gap: 5px; color: var(--muted); }
.thinking p { margin: 0 0 0 8px; font-size: 12px; }
.typing-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--subtle); animation: pulse 1.3s ease-in-out infinite; }
.typing-dot:nth-child(2) { animation-delay: .16s; }
.typing-dot:nth-child(3) { animation-delay: .32s; }
@keyframes pulse { 0%, 60%, 100% { opacity: .3; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }
.awaiting-user .composer { border-color: var(--accent); }
.awaiting-user .composer-tools #context { display: none; }
.awaiting-user .composer-note { color: var(--accent-dark); }

.results { padding-top: 30px; padding-bottom: 30px; }
.result-row { padding-top: 28px; border-top: 1px solid var(--line); }
.consensus-top { display: grid; grid-template-columns: 1fr auto; gap: 28px; align-items: start; }
.eyebrow { margin-bottom: 7px; color: var(--accent-dark); font-size: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.consensus-card h3 { margin: 0 0 16px; font-size: 25px; line-height: 1.25; letter-spacing: -.025em; }
.answer { color: #d7d7dc; font-size: 15px; line-height: 1.7; white-space: pre-wrap; }
.score { min-width: 76px; padding: 12px; border-radius: 12px; background: var(--soft); text-align: center; }
.score strong { display: block; color: var(--accent-dark); font-size: 22px; }
.score span { color: var(--subtle); font-size: 9px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; }
.consensus-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 30px; margin-top: 27px; padding-top: 22px; border-top: 1px solid var(--line); }
.consensus-columns h4 { margin: 0; font-size: 12px; }
.consensus-columns ul { margin: 10px 0 0; padding: 0; list-style: none; }
.consensus-columns li { margin: 8px 0; padding-left: 18px; position: relative; color: #d0d0d5; font-size: 13px; }
.consensus-columns li::before { content: "•"; position: absolute; left: 2px; color: var(--accent); }
.result-note { margin: 22px 0 0; color: var(--muted); font-size: 11px; }
.transcript { margin-top: 26px; border-top: 1px solid var(--line); }
.transcript summary { display: flex; justify-content: space-between; padding: 17px 0; cursor: pointer; color: var(--muted); font-size: 12px; font-weight: 600; list-style: none; }
.transcript summary::-webkit-details-marker { display: none; }
.message { display: grid; grid-template-columns: 130px 1fr; gap: 18px; padding: 20px 0; border-top: 1px solid var(--line); }
.message-meta b, .message-meta span, .message-meta small { display: block; }
.message-meta b { font-size: 13px; }
.message-meta span { color: var(--accent-dark); font-size: 9px; font-weight: 700; text-transform: uppercase; }
.message-meta small { margin-top: 4px; color: var(--subtle); font-size: 10px; text-transform: capitalize; }
.message p { margin: 0; color: #d0d0d5; font-size: 13px; line-height: 1.65; white-space: pre-wrap; }
.message.error p { color: var(--danger); }

.primary-button, .ghost-button, .icon-button { border: 0; background: none; }
.primary-button { min-height: 40px; display: inline-flex; align-items: center; justify-content: space-between; gap: 22px; border-radius: 8px; padding: 9px 13px; background: #f4f4f4; color: #171717; font-weight: 650; }
.primary-button:hover { background: #d9d9d9; }
.primary-button:disabled { opacity: .5; cursor: wait; }
.ghost-button { min-height: 38px; border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; background: #2a2a2a; font-size: 12px; }
.ghost-button:hover { background: var(--soft); }

dialog { width: min(780px, 94vw); max-height: 90dvh; padding: 0; border: 1px solid var(--line); border-radius: 16px; background: var(--white); color: var(--ink); box-shadow: 0 30px 100px rgba(0,0,0,.22); }
dialog::backdrop { background: rgba(0,0,0,.42); backdrop-filter: blur(2px); }
.dialog-shell { padding: 28px; }
.dialog-header { display: flex; align-items: start; justify-content: space-between; }
.dialog-header h2 { margin: 0; font-size: 25px; letter-spacing: -.02em; }
.dialog-header .eyebrow { margin-bottom: 5px; }
.icon-button { width: 34px; height: 34px; border-radius: 8px; font-size: 25px; line-height: 1; }
.icon-button:hover { background: var(--soft); }
.dialog-intro { max-width: 640px; color: var(--muted); }
.local-setup { display: flex; align-items: center; gap: 8px; margin: 20px 0 5px; padding: 14px; border-radius: 10px; background: #18352f; }
.local-setup > div { flex: 1; }
.local-setup strong, .local-setup span { display: block; }
.local-setup strong { font-size: 12px; }
.local-setup span { color: var(--muted); font-size: 11px; }
.config-card { padding: 20px 0; border-top: 1px solid var(--line); }
.config-title { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.config-title h3 { margin: 0; font-size: 16px; }
.remove-button { border: 0; background: none; color: var(--muted); font-size: 12px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; }
.form-grid label { color: var(--muted); font-size: 10px; font-weight: 600; letter-spacing: .03em; text-transform: uppercase; }
.form-grid input, .form-grid select { width: 100%; display: block; margin-top: 4px; padding: 9px 10px; border: 1px solid var(--line); border-radius: 7px; outline: 0; background: #2a2a2a; }
.form-grid input:focus, .form-grid select:focus, .auth-form input:focus, .key-entry input:focus { border-color: #9d9ea1; }
.form-grid .wide { grid-column: 1 / -1; }
.provider-fields { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.model-picker { display: grid; grid-template-columns: 1fr auto; gap: 6px; align-items: end; }
.discover-button { height: 38px; border: 1px solid var(--line); border-radius: 7px; background: var(--soft); padding: 0 11px; font-size: 11px; font-weight: 650; }
.discover-button:disabled { opacity: .55; cursor: wait; }
.model-status { grid-column: 1 / -1; margin: 0; color: var(--muted); font-size: 10px; }
.moderator-box { margin-top: 8px; padding: 17px; border-radius: 10px; background: var(--soft); }
.moderator-box h3 { margin: 0 0 12px; font-size: 15px; }
.dialog-actions { display: flex; justify-content: space-between; margin-top: 24px; }
.save-group { display: flex; align-items: center; gap: 11px; }
.save-group span { color: var(--muted); font-size: 10px; }
.save-group span.confirmed { color: var(--accent-dark); }
.provider-endpoint { grid-column: 1 / -1; margin: 0; color: var(--muted); font-size: 10px; }
.key-callout { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px; border-radius: 8px; background: var(--soft); color: var(--muted); font-size: 11px; }

.account-dialog { width: min(620px, 94vw); }
.google-button { min-height: 46px; display: flex; align-items: center; justify-content: center; gap: 11px; margin-top: 22px; border: 1px solid var(--line); border-radius: 8px; background: #2a2a2a; color: var(--ink); text-decoration: none; font-weight: 650; }
.google-button:hover { background: var(--soft); }
.google-button svg { width: 18px; height: 18px; }
.google-button.disabled { opacity: .5; cursor: not-allowed; }
.google-setup-note { margin: 7px 0 0; color: var(--muted); font-size: 11px; text-align: center; }
.auth-divider { display: flex; align-items: center; gap: 10px; margin: 18px 0; color: var(--subtle); font-size: 9px; text-transform: uppercase; }
.auth-divider::before, .auth-divider::after { content: ""; height: 1px; flex: 1; background: var(--line); }
.auth-tabs { display: flex; gap: 3px; margin: 20px 0 17px; padding: 3px; border-radius: 9px; background: var(--soft); }
.auth-tab { flex: 1; border: 0; border-radius: 7px; padding: 9px; background: transparent; color: var(--muted); font-weight: 650; }
.auth-tab.active { background: var(--white); color: var(--ink); box-shadow: 0 1px 4px rgba(0,0,0,.08); }
.auth-form { display: grid; gap: 12px; }
.auth-form label { color: var(--muted); font-size: 10px; font-weight: 600; text-transform: uppercase; }
.auth-form input { width: 100%; min-height: 43px; display: block; margin-top: 4px; padding: 10px; border: 1px solid var(--line); border-radius: 7px; outline: 0; background: #2a2a2a; font-size: 16px; }
.form-help { margin: -3px 0 2px; color: var(--muted); font-size: 11px; }
.form-error { min-height: 18px; margin: 0; color: var(--danger); font-size: 12px; }
.full-button { width: 100%; }
.account-summary { display: grid; grid-template-columns: auto 1fr auto; gap: 13px; align-items: center; margin: 23px 0 27px; padding-bottom: 23px; border-bottom: 1px solid var(--line); }
.account-avatar { width: 46px; height: 46px; display: grid; place-items: center; border-radius: 50%; background: var(--accent); color: white; font-size: 18px; font-weight: 700; }
.account-summary strong, .account-summary span { display: block; }
.account-summary span { color: var(--muted); font-size: 12px; }
.vault-heading { display: flex; align-items: start; justify-content: space-between; gap: 14px; }
.vault-heading h3 { margin: 0; font-size: 20px; }
.vault-heading p { margin: 5px 0 0; color: var(--muted); font-size: 12px; }
.secure-badge { padding: 5px 8px; border-radius: 99px; background: #e8f6f2; color: var(--accent-dark); font-size: 9px; font-weight: 700; text-transform: uppercase; }
.key-vault { display: grid; gap: 9px; margin-top: 17px; }
.key-card { padding: 14px; border: 1px solid var(--line); border-radius: 9px; }
.key-card-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 9px; }
.key-card-top strong { font-size: 15px; }
.key-status { color: var(--muted); font-size: 9px; font-weight: 650; text-transform: uppercase; }
.key-status.saved { color: var(--accent-dark); }
.key-entry { display: grid; grid-template-columns: 1fr auto auto; gap: 7px; }
.key-entry input { min-width: 0; padding: 9px 10px; border: 1px solid var(--line); border-radius: 7px; background: #2a2a2a; }
.install-dialog { width: min(500px, 92vw); }
.install-steps { margin: 26px 0; }
.install-steps p { margin: 8px 0; padding: 13px; border-radius: 8px; background: var(--soft); }
.install-steps strong { margin-right: 7px; color: var(--accent-dark); }
.install-done { width: 100%; }

@media (max-width: 760px) {
  .sidebar { display: none; }
  .workspace { width: 100%; }
  .mobile-bar { height: calc(56px + env(safe-area-inset-top)); display: flex; align-items: center; justify-content: space-between; padding: env(safe-area-inset-top) 13px 0; border-bottom: 1px solid var(--line); background: rgba(33,33,33,.94); backdrop-filter: blur(12px); position: sticky; top: 0; z-index: 10; }
  .mobile-bar .brand { padding: 3px; }
  .mobile-settings { width: auto; min-height: 36px; padding: 7px 10px; font-size: 12px; }
  .conversation { width: min(100% - 28px, 680px); }
  .welcome { min-height: calc(100dvh - 245px); padding-top: 40px; }
  .welcome-mark { transform: scale(.85); margin-bottom: 16px; }
  .welcome p { font-size: 13px; }
  .composer-wrap { padding-left: 10px; padding-right: 10px; }
  .composer { border-radius: 16px; }
  .send-button span:first-child { display: none; }
  .send-button { padding: 7px; }
  .user-prompt { max-width: 88%; }
  .process, .results { padding-top: 28px; }
  .process-track { margin-left: -44px; }
  .process-step div { display: none; }
  .consensus-top, .consensus-columns { grid-template-columns: 1fr; }
  .score { width: fit-content; min-width: 86px; text-align: left; }
  .message { grid-template-columns: 1fr; gap: 8px; }
  .form-grid, .provider-fields { grid-template-columns: 1fr; }
  .form-grid .wide { grid-column: auto; }
  .form-grid input, .form-grid select { min-height: 44px; font-size: 16px; }
  dialog { width: 100vw; max-width: none; height: 100dvh; max-height: none; margin: 0; border: 0; border-radius: 0; }
  .dialog-shell { min-height: 100%; padding: calc(21px + env(safe-area-inset-top)) 19px calc(21px + env(safe-area-inset-bottom)); }
  .dialog-actions { position: sticky; bottom: calc(-21px - env(safe-area-inset-bottom)); padding: 13px 0 calc(13px + env(safe-area-inset-bottom)); background: var(--white); }
  .save-group span { display: none; }
  .local-setup { align-items: stretch; flex-wrap: wrap; }
  .local-setup > div { flex-basis: 100%; }
  .key-entry { grid-template-columns: 1fr auto; }
  .key-entry .remove-key { grid-column: 1 / -1; }
}

@media (max-width: 430px) {
  .composer-tools input { max-width: 70%; }
  .assistant-row { grid-template-columns: 26px 1fr; gap: 10px; }
  .assistant-avatar { width: 26px; height: 26px; }
  .chat-turn, .thinking-row { grid-template-columns: 26px 1fr; gap: 10px; }
  .turn-avatar, .thinking-avatar { width: 26px; height: 26px; }
  h1 { font-size: 25px; }
}

@media (display-mode: standalone) {
  #installButton { display: none !important; }
}
