:root {
  --bg: #f5f6f9;
  --surface: #ffffff;
  --ink: #172033;
  --muted: #687086;
  --faint: #939bad;
  --line: #dde2eb;
  --accent: #4356c7;
  --accent-dark: #3344a5;
  --accent-soft: #e9edfb;
  --phase: #dfe8fa;
  --warning: #9a641d;
  --data: "Cascadia Code", "SFMono-Regular", Consolas, monospace;
  font-family: Aptos, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: var(--bg);
}
* { box-sizing: border-box; }
body { margin: 0; }
button, textarea { font: inherit; }
button { cursor: pointer; }
button:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.app-shell { min-height: 100vh; display: grid; grid-template-columns: 226px minmax(480px, 1fr) 368px; }
.sidebar { height: 100vh; min-height: 0; display: flex; flex-direction: column; background: var(--surface); border-right: 1px solid var(--line); }
.brand { min-height: 72px; display: flex; align-items: center; gap: 11px; padding: 0 20px; border-bottom: 1px solid var(--line); color: var(--accent); }
.brand-mark { width: 36px; height: 34px; flex: 0 0 auto; }
.brand strong { display: block; color: var(--ink); font-size: 15px; font-weight: 650; letter-spacing: .02em; }
.brand span { display: block; margin-top: 3px; color: var(--muted); font-size: 10px; }
.new-session { margin: 22px 18px 14px; padding: 11px 13px; border: 1px solid var(--accent); border-radius: 4px; background: var(--accent); color: white; text-align: left; font-size: 13px; font-weight: 600; }
.new-session:hover { background: var(--accent-dark); }
.new-session span { margin-right: 7px; font-weight: 400; }
.project-heading { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px 8px 20px; color: var(--muted); font-size: 11px; }
.project-heading button { padding: 2px 0; border: 0; background: transparent; color: var(--accent); font-size: 10px; }
.project-list { max-height: 168px; overflow-y: auto; padding: 0 10px 8px; }
.project-item { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 10px; border: 0; border-radius: 4px; background: transparent; color: #596176; text-align: left; font-size: 11px; }
.project-item span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.project-item small { color: var(--faint); font: 10px var(--data); }
.project-item:hover { background: #f3f5fa; color: var(--ink); }
.project-item.active { background: var(--accent-soft); color: var(--accent-dark); font-weight: 600; }
.section-label { padding: 12px 20px 8px; color: var(--muted); font-size: 11px; }
.session-list { flex: 1; min-height: 80px; display: flex; flex-direction: column; overflow-y: auto; }
.session-empty { margin: 14px 20px; color: var(--faint); font-size: 11px; line-height: 1.7; }
.session-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; }
.session-row .session-item { min-width: 0; }
.session-actions { display: flex; align-items: center; margin-right: 8px; opacity: 0; }
.session-row:hover .session-actions, .session-row:focus-within .session-actions { opacity: 1; }
.session-action { width: 21px; height: 23px; padding: 0; border: 0; border-radius: 3px; background: transparent; color: #a0a8b8; font-size: 12px; line-height: 1; }
.session-action:hover { background: #edf0f7; color: var(--accent); }
.session-action.pinned { color: var(--accent); }
.session-action.delete:hover { background: #f3e7e7; color: #9a4545; }
.session-action:disabled { opacity: 0; cursor: default; }
.session-item { position: relative; border: 0; border-left: 3px solid transparent; padding: 12px 8px 12px 20px; background: transparent; color: #596176; text-align: left; font-size: 12px; line-height: 1.5; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.session-item:hover { background: #f3f5fa; color: var(--ink); }
.session-item.active { border-left-color: var(--accent); background: var(--accent-soft); color: var(--accent-dark); font-weight: 600; }
.project-select { max-width: 150px; padding: 5px 7px; border: 1px solid var(--line); border-radius: 4px; background: white; color: var(--muted); font-size: 10px; }
.project-select:disabled { opacity: .5; }
.sidebar-foot { margin-top: auto; min-height: 54px; display: flex; align-items: center; gap: 8px; padding: 0 20px; border-top: 1px solid var(--line); color: var(--muted); font-size: 10px; }
.logout-button { margin-left: auto; border: 0; background: transparent; color: var(--faint); font-size: 11px; padding: 2px 4px; }
.logout-button:hover { color: var(--accent); }
.identity { color: var(--faint); font-size: 11px; white-space: nowrap; }
.login-body { display: grid; place-items: center; min-height: 100vh; background: var(--bg); }
.login-card { width: min(400px, calc(100vw - 40px)); padding: 32px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); box-shadow: 0 16px 44px #17203310; }
.login-brand { display: flex; align-items: center; gap: 11px; margin-bottom: 26px; color: var(--accent); }
.login-brand .brand-mark { width: 34px; height: 31px; }
.login-brand strong { display: block; color: var(--ink); font-size: 15px; font-weight: 650; }
.login-brand span { display: block; margin-top: 2px; color: var(--muted); font-size: 10px; }
.login-card h1 { margin: 0 0 8px; font-size: 21px; font-weight: 600; }
.login-copy { margin: 0 0 22px; color: var(--muted); font-size: 12px; line-height: 1.7; }
#login-form label { display: block; margin: 14px 0 6px; color: #455069; font-size: 12px; font-weight: 600; }
#login-form input { width: 100%; padding: 10px 11px; border: 1px solid #cbd3e0; border-radius: 4px; background: white; color: var(--ink); font-size: 13px; }
#login-form input:focus { border-color: var(--accent); outline: 2px solid #4356c71a; }
#login-form button { width: 100%; margin-top: 20px; padding: 11px; border: 0; border-radius: 4px; background: var(--accent); color: white; font-size: 13px; font-weight: 600; }
#login-form button:hover { background: var(--accent-dark); }
#login-form button:disabled { opacity: .5; cursor: wait; }
.login-error { min-height: 20px; margin: 12px 0 0; color: #9a4545; font-size: 11px; line-height: 1.6; }
.login-foot { margin: 22px 0 0; padding-top: 16px; border-top: 1px solid var(--line); color: var(--muted); font-size: 11px; line-height: 1.7; }
.status-dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: #4c9a84; flex: 0 0 auto; }
.main-panel { height: 100vh; min-width: 0; display: flex; flex-direction: column; background: var(--surface); }
.topbar { min-height: 72px; padding: 0 34px; display: flex; align-items: center; justify-content: space-between; gap: 20px; border-bottom: 1px solid var(--line); }
.session-heading { min-width: 0; display: flex; align-items: baseline; gap: 14px; }
.session-heading > span { color: var(--faint); font-size: 11px; white-space: nowrap; }
h1 { margin: 0; max-width: 52vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 17px; font-weight: 600; }
.request-state { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 11px; white-space: nowrap; }
.request-state:has(.running) .status-dot { background: var(--accent); }
.request-status.running { color: var(--accent); }
.conversation { flex: 1; overflow-y: auto; padding: 36px 40px 24px; }
.welcome { max-width: 700px; margin: 7vh auto 0; }
.welcome h2 { margin: 0 0 18px; font-size: 29px; font-weight: 600; line-height: 1.35; letter-spacing: -.025em; }
.welcome-copy { max-width: 610px; margin: 0; color: var(--muted); font-size: 14px; line-height: 1.9; }
.capability-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 34px; margin: 36px 0 24px; }
.boundary { margin: 0; padding-top: 16px; border-top: 1px solid #edf0f5; color: var(--muted); font-size: 11px; line-height: 1.7; }
.message { max-width: 820px; margin: 0 auto 30px; display: grid; grid-template-columns: 28px 1fr; gap: 15px; }
.avatar { width: 28px; height: 28px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 50%; color: var(--accent); background: white; font: 11px var(--data); }
.message.user .avatar { border-color: var(--accent); background: var(--accent); color: white; }
.message-role { margin: 2px 0 9px; color: var(--faint); font-size: 10px; }
.message-content { color: #283248; font-size: 14px; line-height: 1.9; white-space: pre-wrap; overflow-wrap: anywhere; }
.message.user .message-content { padding-left: 13px; border-left: 2px solid var(--accent-soft); color: #35405a; }
.live-trace { margin: 0 34px 14px; border-top: 1px solid #ccd5eb; border-bottom: 1px solid #ccd5eb; background: #f7f8fc; max-height: 210px; overflow-y: auto; }
.hidden { display: none !important; }
.trace-heading { position: sticky; top: 0; z-index: 1; display: flex; justify-content: space-between; padding: 10px 4px; background: #f7f8fc; color: var(--accent); font-size: 11px; font-weight: 600; }
.trace-heading #trace-step { color: var(--muted); font-weight: 400; font-family: var(--data); }
.trace-event { position: relative; padding: 10px 4px 10px 18px; border-top: 1px solid #e7ebf3; color: #4c5871; font: 11px/1.65 var(--data); overflow-wrap: anywhere; }
.trace-event::before { content: ""; position: absolute; left: 3px; top: 16px; width: 5px; height: 5px; border-radius: 50%; background: var(--accent); }
.trace-event.error { color: #965040; }
.trace-event.error::before { background: #a45b47; }
.composer { margin: 0 34px 24px; padding: 13px 15px 11px; border: 1px solid #cbd3e0; border-radius: 5px; background: var(--surface); }
.composer:focus-within { border-color: var(--accent); }
.composer textarea { width: 100%; min-height: 72px; max-height: 190px; padding: 0; border: 0; outline: 0; resize: vertical; background: transparent; color: var(--ink); font-size: 14px; line-height: 1.7; }
.composer textarea::placeholder { color: #929bad; }
.composer-bottom { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding-top: 8px; color: var(--faint); font-size: 10px; }
.composer-bottom button { min-width: 74px; padding: 9px 18px; border: 0; border-radius: 4px; background: var(--accent); color: white; font-size: 12px; font-weight: 600; }
.composer-bottom button:hover { background: var(--accent-dark); }
.composer-bottom button:disabled { opacity: .45; cursor: wait; }
.evidence-panel { height: 100vh; display: flex; flex-direction: column; border-left: 1px solid var(--line); background: #f7f8fa; }
.evidence-head { min-height: 72px; padding: 0 24px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.evidence-head h2 { margin: 0; font-size: 15px; font-weight: 600; }
.evidence-head > span { min-width: 22px; color: var(--muted); font: 12px var(--data); text-align: right; }
.artifacts { flex: 1; overflow-y: auto; padding: 22px; }
.empty-artifacts { margin-top: 8vh; padding: 12px 16px; text-align: center; color: var(--muted); }
.phase-figure { width: 100%; max-width: 290px; margin-bottom: 22px; }
.empty-artifacts strong { display: block; color: #4a546a; font-size: 13px; font-weight: 600; }
.empty-artifacts p { max-width: 260px; margin: 10px auto 0; font-size: 11px; line-height: 1.8; }
.artifact { margin-bottom: 18px; border: 1px solid var(--line); border-radius: 4px; background: var(--surface); overflow: hidden; }
.artifact-title { padding: 13px 14px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid #e9edf3; font-size: 12px; }
.artifact-title strong { font-weight: 600; }
.artifact-title span { color: var(--faint); font: 9px var(--data); }
.artifact-body { padding: 8px 14px 14px; }
.metric-grid { display: grid; grid-template-columns: 1fr 1fr; column-gap: 18px; }
.metric { padding: 12px 0 10px; border-bottom: 1px solid #edf0f4; }
.metric span { display: block; margin-bottom: 6px; color: var(--faint); font: 9px var(--data); }
.metric strong { color: #263553; font: 16px var(--data); font-weight: 500; }
.artifact-note { margin: 13px 0 0; color: var(--warning); font-size: 10px; line-height: 1.7; }
.record { padding: 12px 0; border-bottom: 1px solid #edf0f4; font-size: 11px; line-height: 1.7; }
.record:last-child { border-bottom: 0; }
.record code { color: var(--accent); font: 10px var(--data); overflow-wrap: anywhere; }
.record dl { display: grid; grid-template-columns: 56px 1fr; gap: 4px 8px; margin: 9px 0 0; }
.record dt { color: var(--faint); }
.record dd { margin: 0; overflow-wrap: anywhere; }
.evidence-note { margin: 0 22px; padding: 16px 2px 20px; border-top: 1px solid var(--line); color: var(--muted); }
.evidence-note strong { color: #566178; font-size: 11px; font-weight: 600; }
.evidence-note p { margin: 7px 0 0; font-size: 10px; line-height: 1.75; }
.residue-profile { display: block; width: 100%; height: 76px; margin-top: 14px; border-bottom: 1px solid #dfe4ec; }
.profile-line { fill: none; stroke: var(--accent); stroke-width: 1.7; stroke-linejoin: round; stroke-linecap: round; }
.profile-threshold { stroke: #a9b3c5; stroke-width: 1; stroke-dasharray: 4 4; }
.artifact-download { margin: 13px 0 3px; padding: 7px 10px; border: 1px solid #cbd3e0; border-radius: 4px; background: white; color: var(--accent); font-size: 11px; }
.artifact-download:hover { border-color: var(--accent); background: var(--accent-soft); }
.record code { display: block; white-space: pre-wrap; }
.record p { margin: 7px 0 0; color: var(--muted); }
.artifact-citation { margin: 13px 0 0; color: var(--accent); font: 10px/1.7 var(--data); overflow-wrap: anywhere; }
.message-content.markdown-body { white-space: normal; }
.markdown-body > :first-child { margin-top: 0; }
.markdown-body > :last-child { margin-bottom: 0; }
.markdown-body p { margin: 0 0 12px; }
.markdown-body h1, .markdown-body h2, .markdown-body h3, .markdown-body h4 { margin: 20px 0 10px; font-weight: 600; line-height: 1.45; }
.markdown-body h1 { font-size: 18px; }
.markdown-body h2 { font-size: 16px; }
.markdown-body h3 { font-size: 14px; }
.markdown-body h4 { font-size: 13px; }
.markdown-body strong { font-weight: 650; }
.markdown-body ul, .markdown-body ol { margin: 0 0 14px; padding-left: 22px; }
.markdown-body li { margin: 5px 0; }
.markdown-body li > p { margin-bottom: 6px; }
.markdown-body table { width: 100%; margin: 14px 0; border-collapse: collapse; table-layout: auto; font-size: 12px; line-height: 1.65; }
.markdown-body th, .markdown-body td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; overflow-wrap: anywhere; }
.markdown-body th { background: var(--accent-soft); color: #2e3e93; font-weight: 600; }
.markdown-body tr:last-child td { border-bottom: 0; }
.markdown-body code { padding: 1px 4px; border-radius: 3px; background: #eef1f7; font: .9em var(--data); overflow-wrap: anywhere; }
.markdown-body pre { margin: 14px 0; padding: 12px 14px; border: 1px solid var(--line); border-radius: 4px; background: #f6f7fa; overflow-x: auto; line-height: 1.65; }
.markdown-body pre code { padding: 0; background: transparent; white-space: pre; }
.markdown-body a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.markdown-body blockquote { margin: 14px 0; padding-left: 14px; border-left: 3px solid var(--accent-soft); color: var(--muted); }
.markdown-body hr { margin: 18px 0; border: 0; border-top: 1px solid var(--line); }
.topbar-actions { display: flex; align-items: center; gap: 16px; }
.settings-button { padding: 6px 10px; border: 1px solid var(--line); border-radius: 4px; background: white; color: var(--muted); font-size: 11px; }
.settings-button:hover { border-color: var(--accent); color: var(--accent); }
.settings-dialog { width: min(480px, calc(100vw - 40px)); padding: 0; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); box-shadow: 0 18px 50px #17203324; }
.settings-dialog::backdrop { background: #17203355; }
#settings-form, .dialog-form { padding: 26px; }
.settings-head { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 24px; }
.settings-head h2 { margin: 0 0 8px; font-size: 20px; font-weight: 600; }
.settings-head p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.6; }
.dialog-close { width: 28px; height: 28px; border: 0; border-radius: 4px; background: transparent; color: var(--muted); font-size: 22px; line-height: 1; }
.dialog-close:hover { background: #eef1f6; }
#settings-form label, .dialog-form label { display: block; margin: 16px 0 7px; color: #455069; font-size: 12px; font-weight: 600; }
#settings-form input, .dialog-form input, .dialog-form textarea { width: 100%; padding: 10px 11px; border: 1px solid #cbd3e0; border-radius: 4px; background: white; color: var(--ink); font-size: 13px; resize: vertical; }
#settings-form input:focus, .dialog-form input:focus, .dialog-form textarea:focus { border-color: var(--accent); outline: 2px solid #4356c71a; }
.settings-privacy { margin: 12px 0 0; color: var(--muted); font-size: 11px; line-height: 1.65; }
.settings-status { min-height: 38px; margin: 16px 0 0; color: var(--accent); font-size: 11px; line-height: 1.65; }
.settings-status.error { color: #9a4545; }
.settings-actions { display: flex; gap: 10px; margin-top: 20px; }
.settings-actions button { padding: 9px 14px; border: 1px solid #cbd3e0; border-radius: 4px; background: white; color: #455069; font-size: 12px; }
.settings-actions .settings-save { border-color: var(--accent); background: var(--accent); color: white; }
.settings-actions button:hover { border-color: var(--accent); color: var(--accent); }
.settings-actions .settings-save:hover { background: var(--accent-dark); color: white; }
@media (hover: none) { .session-actions { opacity: .72; } }
.catalogue { margin: 30px 0 0; }
.catalogue-loading { color: var(--muted); font-size: 12px; padding: 20px 0; }
.tool-group { margin: 0 0 30px; }
.tool-group h3 { margin: 0 0 14px; padding-bottom: 8px; border-bottom: 1px solid var(--line); color: #3d4a63; font-size: 12px; font-weight: 600; letter-spacing: .02em; }
.tool-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 14px; }
.tool-card { display: flex; flex-direction: column; padding: 15px 16px 13px; border: 1px solid var(--line); border-radius: 5px; background: var(--surface); }
.tool-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.tool-head strong { font-size: 13px; font-weight: 600; }
.tool-runtime { flex: 0 0 auto; padding: 2px 6px; border-radius: 3px; background: var(--accent-soft); color: #3344a5; font: 9px var(--data); }
.tool-summary { margin: 9px 0 0; color: #4d5568; font-size: 12px; line-height: 1.65; }
.tool-facts { margin: 12px 0 0; display: grid; grid-template-columns: 62px 1fr; gap: 5px 10px; font-size: 11px; line-height: 1.6; }
.tool-facts dt { color: var(--faint); }
.tool-facts dd { margin: 0; color: #475066; overflow-wrap: anywhere; }
.tool-example { margin-top: 13px; padding: 0; border: 0; background: transparent; color: var(--accent); font-size: 11px; text-align: left; }
.tool-example:hover { text-decoration: underline; text-underline-offset: 2px; }
.tool-card.compact .tool-summary { display: none; }
.tool-card.compact { padding: 11px 13px 10px; }
.catalogue-dialog { width: min(940px, calc(100vw - 40px)); }
.catalogue-dialog-body { max-height: 68vh; overflow-y: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; }
.catalog-dialog-body .tool-card { border-color: #e3e7ef; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
@media (max-width: 1180px) {
  .app-shell { grid-template-columns: 206px minmax(460px, 1fr); }
  .evidence-panel { display: none; }
}
@media (max-width: 760px) {
  .app-shell { display: block; }
  .sidebar { display: none; }
  .main-panel { min-height: 100vh; }
  .topbar { padding: 0 20px; }
  .session-heading > span { display: none; }
  .project-select { display: none; }
  h1 { max-width: 68vw; }
  .conversation { padding: 26px 20px 18px; }
  .welcome { margin-top: 4vh; }
  .welcome h2 { font-size: 25px; }
  .capability-grid { grid-template-columns: 1fr; gap: 0; }
  .composer, .live-trace { margin-left: 20px; margin-right: 20px; }
  .composer-bottom > span { display: none; }
  .composer-bottom { justify-content: flex-end; }
}
