:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #07090d;
  color: #f3f6fb;
  --panel: rgba(18, 22, 31, 0.82);
  --border: rgba(255, 255, 255, 0.09);
  --muted: #94a0b5;
  --accent: #86a8ff;
  --accent-2: #79e6c7;
  --danger: #ffb884;
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: radial-gradient(circle at 20% 0%, rgba(67, 91, 151, .20), transparent 35%), #07090d; }
button, textarea { font: inherit; }
a { color: inherit; }
.ambient { position: fixed; width: 30rem; height: 30rem; border-radius: 999px; filter: blur(110px); opacity: .14; pointer-events: none; }
.ambient-a { background: #6e92ff; top: -12rem; left: -8rem; }
.ambient-b { background: #53d1af; right: -12rem; top: 18rem; }
.app-shell { width: min(1440px, calc(100% - 40px)); margin: 0 auto; padding: 42px 0 36px; position: relative; }
.topbar { display: flex; justify-content: space-between; gap: 24px; align-items: flex-start; margin-bottom: 26px; }
.eyebrow { color: var(--accent); letter-spacing: .14em; font-size: 11px; font-weight: 800; }
h1 { font-size: clamp(40px, 6vw, 72px); margin: 4px 0 4px; letter-spacing: -.055em; }
h2 { margin: 4px 0 0; font-size: 23px; letter-spacing: -.025em; }
h3 { font-size: 14px; margin: 0 0 12px; color: #dce4f5; }
p { color: var(--muted); margin: 0; line-height: 1.6; }
.status-block, .pill { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--border); background: rgba(255,255,255,.035); border-radius: 999px; padding: 9px 13px; font-size: 12px; color: #cad4e6; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--danger); box-shadow: 0 0 18px rgba(255,184,132,.75); }
.hero-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 12px; }
.metric-card, .panel { border: 1px solid var(--border); background: var(--panel); backdrop-filter: blur(18px); border-radius: 18px; }
.metric-card { padding: 18px; display: grid; gap: 5px; }
.metric-card strong { font-size: 34px; letter-spacing: -.04em; }
.metric-label { color: #d4def0; font-weight: 700; font-size: 12px; }
.metric-note, .muted { color: var(--muted); font-size: 12px; }
.panel { padding: 22px; margin-bottom: 12px; }
.section-heading { display: flex; justify-content: space-between; gap: 18px; align-items: flex-end; margin-bottom: 18px; }
.section-heading.compact { margin-bottom: 12px; }
.chain { display: flex; align-items: stretch; gap: 8px; overflow-x: auto; padding: 4px 2px 8px; }
.chain-node { min-width: 124px; text-align: left; padding: 14px; border: 1px solid var(--border); background: rgba(255,255,255,.025); color: inherit; border-radius: 14px; cursor: pointer; transition: .18s ease; }
.chain-node:hover, .chain-node.active { transform: translateY(-2px); border-color: rgba(134,168,255,.6); background: rgba(134,168,255,.09); }
.chain-node.cross-cutting { border-style: dashed; }
.chain-node strong, .chain-node small { display: block; }
.chain-node small { color: var(--muted); margin-top: 4px; line-height: 1.25; }
.chain-index { color: var(--accent-2); font-size: 10px; font-weight: 800; display: block; margin-bottom: 8px; }
.chain-arrow { align-self: center; color: #546079; }
.content-grid { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 12px; }
.sidebar, .detail-panel { margin-bottom: 12px; }
.capability-nav { display: grid; gap: 6px; }
.capability-link { display: flex; justify-content: space-between; align-items: center; gap: 12px; border: 1px solid transparent; background: transparent; color: #bdc8da; border-radius: 11px; padding: 11px 12px; cursor: pointer; text-align: left; }
.capability-link small { color: #67748c; }
.capability-link:hover, .capability-link.active { border-color: var(--border); background: rgba(255,255,255,.045); color: white; }
.detail-panel { min-height: 360px; }
.detail-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; }
.detail-header h2 { font-size: 38px; margin-top: 2px; }
.ref-box { margin: 18px 0; padding: 12px 14px; background: rgba(0,0,0,.22); border: 1px solid rgba(255,255,255,.06); border-radius: 10px; color: #9fb2d4; font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; overflow-wrap: anywhere; }
.ref-box.small { font-size: 10px; margin: 10px 0 12px; }
.detail-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.object-list { margin: 0; padding-left: 22px; color: #8f9bb0; }
.object-list li { padding: 6px 0; }
code { color: #d6e0f4; }
.projection-source { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; margin: -4px 0 16px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 11px; background: rgba(0,0,0,.16); color: #7f8ba0; font: 10px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; overflow-wrap: anywhere; }
.projection-source strong { color: var(--accent-2); }
.ui-chain { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.ui-card { position: relative; border: 1px solid var(--border); border-radius: 14px; padding: 16px; background: linear-gradient(145deg, rgba(121,230,199,.055), rgba(134,168,255,.035)); min-width: 0; }
.ui-card h3 { font-size: 16px; margin-top: 4px; }
.ui-step { color: var(--accent-2); font-size: 10px; font-weight: 800; }
.ui-operations { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 14px; }
.ui-operations code { padding: 5px 7px; background: rgba(255,255,255,.035); border-radius: 7px; font-size: 10px; }
.interface-card { border-top: 1px solid var(--border); padding-top: 13px; margin-top: 13px; }
.interface-title { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; align-items: center; margin-bottom: 10px; }
.interface-title code { color: #e2e9f7; font-size: 11px; }
.interface-title span { color: var(--accent); font-size: 9px; font-weight: 800; letter-spacing: .08em; }
.layer-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; }
.layer-grid > div { display: flex; flex-direction: column; gap: 4px; min-width: 0; padding: 9px; border-radius: 9px; background: rgba(0,0,0,.17); }
.layer-grid b { color: #6f809e; font-size: 8px; letter-spacing: .08em; margin-bottom: 3px; }
.layer-grid code { display: block; color: #aab7cc; font-size: 9px; overflow-wrap: anywhere; }
.authority-grid { display: grid; gap: 7px; }
.authority-item { display: grid; grid-template-columns: 56px minmax(0, 1fr); gap: 12px; padding: 10px 12px; border-radius: 10px; background: rgba(255,255,255,.025); }
.authority-item strong { color: var(--accent); font-size: 11px; }
.authority-item span { color: #9da9bc; font: 11px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; overflow-wrap: anywhere; }
footer { display: flex; justify-content: space-between; gap: 16px; color: #657188; font-size: 11px; padding: 8px 4px; }
.footer-link { color: #9ca8bb; text-decoration: none; }
.footer-link:hover { color: #fff; }

/* Interactive Q home */
.chat-page { height: 100vh; min-height: 100vh; overflow: hidden; background: #0c0e13; }
.chat-page::before { content: ""; position: fixed; inset: 0; pointer-events: none; background: radial-gradient(circle at 50% -10%, rgba(134,168,255,.10), transparent 34%); }
.chat-shell { width: min(900px, 100%); height: 100vh; margin: 0 auto; padding: 0 22px; display: grid; grid-template-rows: 64px minmax(0, 1fr) auto; position: relative; }
.chat-topbar { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; border-bottom: 1px solid rgba(255,255,255,.055); }
.brand { justify-self: start; width: 34px; height: 34px; display: grid; place-items: center; border-radius: 10px; background: #f4f6fb; color: #0a0c10; text-decoration: none; font-weight: 800; font-size: 17px; }
.system-link { justify-self: end; color: #8f9aab; text-decoration: none; font-size: 12px; padding: 8px 10px; border-radius: 9px; }
.system-link:hover { color: #f2f5fa; background: rgba(255,255,255,.04); }
.runtime-state { display: inline-flex; align-items: center; gap: 7px; color: #8490a2; font-size: 11px; white-space: nowrap; }
.runtime-dot { width: 7px; height: 7px; border-radius: 50%; background: #8b6670; }
.runtime-state.ready .runtime-dot { background: var(--accent-2); }
.runtime-state.ready { color: #9fb5ae; }
.runtime-state.unavailable .runtime-dot { background: var(--danger); }
.conversation { min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; padding: 30px 4px 24px; }
.welcome { max-width: 680px; margin: 12vh auto 0; text-align: center; }
.welcome[hidden] { display: none; }
.welcome-mark { width: 48px; height: 48px; margin: 0 auto 20px; display: grid; place-items: center; border-radius: 15px; background: #f4f6fb; color: #0a0c10; font-weight: 800; font-size: 22px; }
.welcome h1 { margin: 0; font-size: clamp(30px, 5vw, 46px); letter-spacing: -.045em; }
.welcome p { max-width: 560px; margin: 12px auto 0; color: #788496; font-size: 14px; }
.prompt-suggestions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 24px; }
.suggestion { border: 1px solid rgba(255,255,255,.08); background: rgba(255,255,255,.025); color: #aab4c4; border-radius: 999px; padding: 9px 13px; font-size: 12px; cursor: pointer; }
.suggestion:hover { background: rgba(255,255,255,.055); color: #eef2f8; }
.messages { width: min(760px, 100%); margin: 0 auto; display: grid; gap: 26px; }
.message { display: grid; grid-template-columns: 32px minmax(0, 1fr); gap: 13px; align-items: start; }
.message-badge { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; background: rgba(255,255,255,.055); color: #bcc6d5; font-size: 10px; font-weight: 700; }
.message-assistant .message-badge { background: #f1f4fa; color: #101217; font-size: 13px; }
.message-body { min-width: 0; padding-top: 3px; }
.message-content { color: #e8ecf3; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.68; font-size: 15px; }
.message-user .message-content { color: #c7cfdb; }
.message.error .message-content { color: #e1b8ad; }
.message-details { margin-top: 12px; color: #727f93; font-size: 11px; }
.message-details summary { cursor: pointer; width: fit-content; }
.message-details pre { max-width: 100%; overflow: auto; padding: 11px; border: 1px solid rgba(255,255,255,.06); background: rgba(0,0,0,.18); border-radius: 10px; color: #8996aa; font: 10px/1.55 ui-monospace, SFMono-Regular, Menlo, monospace; white-space: pre-wrap; overflow-wrap: anywhere; }
.pending .message-content { display: flex; gap: 5px; padding-top: 8px; }
.thinking-dot { width: 6px; height: 6px; border-radius: 50%; background: #697488; animation: pulse 1s infinite ease-in-out; }
.thinking-dot:nth-child(2) { animation-delay: .14s; }
.thinking-dot:nth-child(3) { animation-delay: .28s; }
@keyframes pulse { 0%, 70%, 100% { opacity: .28; transform: translateY(0); } 35% { opacity: 1; transform: translateY(-2px); } }
.composer-wrap { width: min(780px, 100%); justify-self: center; padding: 10px 0 18px; background: linear-gradient(to bottom, rgba(12,14,19,0), #0c0e13 16%); }
.composer { border: 1px solid rgba(255,255,255,.105); background: #151820; border-radius: 18px; padding: 13px 13px 10px; box-shadow: 0 10px 34px rgba(0,0,0,.16); }
.composer textarea { display: block; width: 100%; min-height: 28px; max-height: 180px; resize: none; overflow-y: auto; border: 0; outline: none; background: transparent; color: #f0f3f8; padding: 2px 3px 10px; font-size: 15px; line-height: 1.5; }
.composer textarea::placeholder { color: #626e81; }
.composer textarea:disabled { opacity: .65; }
.composer-actions { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 8px; }
.icon-button, .send-button { border: 0; cursor: pointer; display: grid; place-items: center; }
.icon-button { width: 32px; height: 32px; border-radius: 10px; background: rgba(255,255,255,.045); color: #9ba6b6; font-size: 12px; }
.icon-button:hover { background: rgba(255,255,255,.075); color: #fff; }
.icon-button.listening { background: rgba(255,184,132,.12); color: var(--danger); }
.send-button { justify-self: end; width: 32px; height: 32px; border-radius: 10px; background: #f3f5f9; color: #121419; font-size: 18px; font-weight: 800; }
.send-button:hover { background: #fff; }
.send-button:disabled { opacity: .35; cursor: default; }
.composer-hint { color: #596578; font-size: 10px; }
.boundary-note { text-align: center; margin-top: 8px; color: #4f5a6b; font-size: 9px; line-height: 1.4; }

@media (max-width: 1100px) { .layer-grid { grid-template-columns: 1fr; } }
@media (max-width: 980px) { .hero-grid, .ui-chain { grid-template-columns: repeat(2, 1fr); } .content-grid { grid-template-columns: 1fr; } .capability-nav { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 640px) {
  .app-shell { width: min(100% - 22px, 1440px); padding-top: 24px; }
  .topbar, .section-heading, footer { flex-direction: column; }
  .hero-grid, .ui-chain, .detail-columns { grid-template-columns: 1fr; }
  .capability-nav { grid-template-columns: repeat(2, 1fr); }
  .panel { padding: 16px; }
  .chat-shell { padding: 0 12px; grid-template-rows: 56px minmax(0, 1fr) auto; }
  .chat-topbar { grid-template-columns: auto 1fr auto; gap: 10px; }
  .runtime-state { justify-self: center; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
  .welcome { margin-top: 8vh; }
  .welcome p { font-size: 13px; }
  .prompt-suggestions { display: grid; }
  .suggestion { border-radius: 12px; }
  .conversation { padding-top: 20px; }
  .message { grid-template-columns: 28px minmax(0, 1fr); gap: 10px; }
  .message-badge { width: 27px; height: 27px; }
  .composer-wrap { padding-bottom: max(10px, env(safe-area-inset-bottom)); }
  .composer-hint { display: none; }
}
