/* Helix Assistant – chat layout */
body { background: #fff; }
.chat-app { display: grid; grid-template-columns: 292px 1fr; height: 100vh; overflow: hidden; }

/* ---------------------------------------------------------------- sidebar */
.sidebar { background: #f8f9fc; border-right: 1px solid var(--border); display: flex; flex-direction: column; min-height: 0; }
.sb-top { padding: 18px 18px 14px; }
.new-chat { margin: 0 16px 8px; height: 40px; }
.sb-section { padding: 10px 12px 4px; }
.sb-label { font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--faint); padding: 0 6px 8px; }
.agent-list { display: flex; flex-direction: column; gap: 4px; }
.agent-item { display: flex; gap: 10px; align-items: center; padding: 8px; border-radius: 10px; cursor: pointer; border: 1px solid transparent; transition: background .12s, border-color .12s; }
.agent-item:hover { background: #fff; border-color: var(--border); }
.agent-item.active { background: #fff; border-color: var(--border); box-shadow: var(--shadow-sm); }
.agent-item.active .agent-name::after { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--green); margin-left: 6px; vertical-align: 2px; }
.agent-item .avatar { width: 34px; height: 34px; border-radius: 10px; font-size: 15px; }
.agent-name { font-weight: 650; font-size: 13.5px; }
.agent-role { font-size: 12px; color: var(--muted); }
.grow-section { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.history { overflow: auto; flex: 1; display: flex; flex-direction: column; gap: 2px; }
.hist-item { padding: 8px 10px; border-radius: 8px; cursor: pointer; font-size: 13px; color: var(--text-2); display: flex; align-items: center; gap: 8px; }
.hist-item:hover { background: #eef0f6; }
.hist-item.active { background: #e9ebf5; color: var(--text); font-weight: 600; }
.hist-item .dot { width: 7px; height: 7px; border-radius: 50%; flex: none; }
.hist-empty { color: var(--faint); font-size: 12.5px; padding: 4px 10px; }
.sb-foot { border-top: 1px solid var(--border); padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; }
.sb-link { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--text-2); font-weight: 600; font-size: 13px; }
.sb-link:hover { background: #eef0f6; text-decoration: none; }
.sb-link svg { width: 16px; height: 16px; color: var(--muted); }
.sb-link .ext { margin-left: auto; width: 13px; height: 13px; color: var(--faint); }

/* ------------------------------------------------------------------- main */
.chat-main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.chat-head { height: 64px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 14px; padding: 0 24px; background: rgba(255,255,255,.9); backdrop-filter: blur(8px); }
.head-agent { display: flex; align-items: center; gap: 12px; min-width: 0; }
.head-agent .avatar { width: 36px; height: 36px; }
.head-agent b { font-size: 15px; display: block; }
.head-agent div span { font-size: 12.5px; color: var(--muted); }
.head-right { margin-left: auto; display: flex; align-items: center; gap: 18px; }
.model-pill { display: inline-flex; align-items: center; gap: 8px; padding: 5px 11px; border: 1px solid var(--border); border-radius: 99px; font-size: 12px; font-weight: 600; color: var(--text-2); background: #fff; }
.trace-toggle { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); font-weight: 600; cursor: pointer; }
.mobile-only { display: none; }

.messages { flex: 1; overflow: auto; scroll-behavior: smooth; }
.thread { max-width: 860px; margin: 0 auto; padding: 28px 24px 40px; }

/* welcome */
.welcome { padding: 34px 0 10px; }
.welcome .hero-avatar { width: 56px; height: 56px; border-radius: 16px; font-size: 24px; box-shadow: 0 10px 26px rgba(79,70,229,.25); }
.welcome h1 { font-size: 28px; font-weight: 800; letter-spacing: -.03em; margin-top: 18px; }
.welcome p.lead { color: var(--muted); font-size: 15px; margin: 6px 0 0; max-width: 640px; }
.caps { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.caps .badge { height: 26px; padding: 0 10px; font-size: 12px; }
.prompt-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 26px; }
.prompt-card { text-align: left; border: 1px solid var(--border); background: #fff; border-radius: 12px; padding: 14px 16px; cursor: pointer; transition: border-color .15s, box-shadow .15s, transform .15s; font: inherit; color: inherit; display: flex; flex-direction: column; gap: 6px; }
.prompt-card:hover { border-color: var(--brand-100); box-shadow: 0 6px 20px rgba(79,70,229,.08); transform: translateY(-1px); }
.prompt-card .pc-top { display: flex; align-items: center; gap: 8px; font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--brand); }
.prompt-card .pc-top svg { width: 14px; height: 14px; }
.prompt-card .pc-text { font-size: 13.5px; color: var(--text-2); line-height: 1.45; }

/* messages */
.msg { display: flex; gap: 14px; margin: 22px 0; animation: msgIn .25s ease-out; }
@keyframes msgIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.msg.user { justify-content: flex-end; }
.msg.user .bubble { background: var(--brand); color: #fff; padding: 11px 16px; border-radius: 16px 16px 4px 16px; max-width: 78%; white-space: pre-wrap; word-break: break-word; font-size: 14px; box-shadow: 0 2px 8px rgba(79,70,229,.2); }
.msg.user .bubble.masked { animation: maskFlash 1.6s ease-out; }
@keyframes maskFlash { 0%, 35% { background: #b45309; box-shadow: 0 0 0 4px #fde68a; } 100% { background: var(--brand); } }
.msg.assistant .avatar { width: 34px; height: 34px; margin-top: 2px; }
.msg.assistant .body { flex: 1; min-width: 0; }
.msg-meta { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; font-size: 13px; }
.msg-meta b { font-weight: 700; }
.msg-meta .role { color: var(--muted); font-size: 12px; }
.answer { font-size: 14.5px; }
.answer .md { font-size: 14.5px; }
.cursor::after { content: ""; display: inline-block; width: 7px; height: 16px; background: var(--brand); margin-left: 2px; vertical-align: -3px; border-radius: 2px; animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.thinking { display: inline-flex; gap: 5px; padding: 6px 0; }
.thinking i { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); animation: bounce 1.2s infinite; }
.thinking i:nth-child(2) { animation-delay: .15s; } .thinking i:nth-child(3) { animation-delay: .3s; }
@keyframes bounce { 0%, 60%, 100% { transform: translateY(0); opacity: .5; } 30% { transform: translateY(-5px); opacity: 1; } }

/* trace */
.trace { border: 1px solid var(--border); border-radius: 12px; margin: 2px 0 12px; background: var(--surface-2); overflow: hidden; }
.trace-head { display: flex; align-items: center; gap: 8px; padding: 9px 12px; cursor: pointer; font-size: 12.5px; font-weight: 600; color: var(--text-2); user-select: none; }
.trace-head svg { width: 15px; height: 15px; color: var(--muted); }
.trace-head .chev { margin-left: auto; transition: transform .2s; }
.trace.collapsed .chev { transform: rotate(-90deg); }
.trace.collapsed .trace-steps { display: none; }
.trace-steps { border-top: 1px solid var(--border); padding: 6px 0; }
.step { padding: 6px 12px 6px 14px; }
.step-row { display: flex; align-items: center; gap: 10px; font-size: 13px; cursor: pointer; }
.step-ico { width: 22px; height: 22px; border-radius: 7px; display: grid; place-items: center; flex: none; background: #fff; border: 1px solid var(--border); color: var(--muted); }
.step-ico svg { width: 13px; height: 13px; }
.step.ok .step-ico { color: var(--green); border-color: #a7f3d0; background: var(--green-bg); }
.step.error .step-ico, .step.blocked .step-ico { color: var(--red); border-color: #fecaca; background: var(--red-bg); }
.step.guard .step-ico { color: var(--amber); border-color: #fde68a; background: var(--amber-bg); }
.step.route .step-ico { color: var(--violet); border-color: #ddd6fe; background: var(--violet-bg); }
.step.running .step-ico { color: var(--brand); }
.step-label { font-weight: 600; color: var(--text); }
.step-sum { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; flex: 1; }
.step-cat { font-size: 11px; color: var(--faint); white-space: nowrap; }
.step-ms { font-size: 11.5px; color: var(--faint); font-variant-numeric: tabular-nums; white-space: nowrap; }
.step-detail { display: none; margin: 8px 0 4px 32px; }
.step.open .step-detail { display: block; }
.step-detail .code-block { max-height: 280px; font-size: 11.5px; }
.step-detail .lbl { font-size: 11px; font-weight: 700; text-transform: uppercase; color: var(--faint); margin: 6px 0 4px; letter-spacing: .04em; }
.hide-trace .trace { display: none; }

/* sources & footer */
.sources { margin-top: 14px; display: flex; flex-wrap: wrap; gap: 8px; }
.source { display: inline-flex; align-items: center; gap: 8px; max-width: 100%; padding: 6px 10px 6px 6px; border: 1px solid var(--border); border-radius: 10px; background: #fff; cursor: pointer; font-size: 12.5px; transition: border-color .15s, box-shadow .15s; }
.source:hover { border-color: var(--brand-100); box-shadow: var(--shadow-sm); }
.source .n { width: 20px; height: 20px; border-radius: 6px; background: var(--brand-50); color: var(--brand); font-weight: 700; font-size: 11px; display: grid; place-items: center; flex: none; }
.source .t { font-weight: 600; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 300px; }
.source .s { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 180px; }
.msg-foot { display: flex; align-items: center; gap: 4px; margin-top: 10px; color: var(--faint); font-size: 12px; }
.msg-foot .btn { height: 28px; width: 28px; padding: 0; color: var(--faint); }
.msg-foot .btn.on { color: var(--brand); background: var(--brand-50); }
.msg-foot .btn svg { width: 14px; height: 14px; }
.msg-foot .stats { margin-left: 6px; display: flex; gap: 10px; }
.action-card { margin-top: 12px; border: 1px solid #a7f3d0; background: linear-gradient(180deg, #f0fdf4, #fff); border-radius: 12px; padding: 12px 14px; display: flex; gap: 12px; align-items: center; }
.action-card .ic { width: 34px; height: 34px; border-radius: 10px; background: var(--green); color: #fff; display: grid; place-items: center; flex: none; }
.action-card .ic svg { width: 18px; height: 18px; }
.action-card b { display: block; font-size: 13.5px; }
.action-card span { font-size: 12.5px; color: var(--muted); }
.action-card a { margin-left: auto; }
.guard-card { border-color: #fde68a; background: linear-gradient(180deg, #fffbeb, #fff); }
.guard-card .ic { background: var(--amber); }

/* composer */
.composer-wrap { padding: 12px 24px 16px; background: linear-gradient(180deg, rgba(255,255,255,0), #fff 30%); }
.composer { max-width: 860px; margin: 0 auto; display: flex; gap: 10px; align-items: flex-end; border: 1px solid var(--border-strong); border-radius: 16px; padding: 8px 8px 8px 16px; background: #fff; box-shadow: 0 6px 24px rgba(15,23,42,.06); transition: border-color .15s, box-shadow .15s; }
.composer:focus-within { border-color: var(--brand); box-shadow: 0 0 0 4px rgba(79,70,229,.1), 0 6px 24px rgba(15,23,42,.06); }
.composer textarea { flex: 1; border: 0; outline: 0; resize: none; font: inherit; font-size: 14.5px; padding: 8px 0; max-height: 180px; line-height: 1.5; background: transparent; }
.composer .send { width: 40px; height: 40px; border-radius: 12px; padding: 0; }
.composer-hint { max-width: 860px; margin: 8px auto 0; font-size: 11.5px; color: var(--faint); display: flex; align-items: center; gap: 6px; justify-content: center; text-align: center; }
.composer-hint svg { width: 13px; height: 13px; flex: none; }

/* source modal */
.src-meta { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.src-text { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; }

@media (max-width: 900px) {
  .chat-app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 50; inset: 0 auto 0 0; width: 290px; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: none; }
  .mobile-only { display: inline-flex; }
  .prompt-grid { grid-template-columns: 1fr; }
  .trace-toggle span:first-child, .model-pill { display: none; }
}
