:root {
  color-scheme: dark;
  --bg: #08090d;
  --panel: rgba(18, 20, 29, .82);
  --line: rgba(255, 255, 255, .1);
  --muted: #9699a8;
  --text: #f5f6fb;
  --violet: #9d7bff;
  --cyan: #72e6d1;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% -20%, #25213a 0, transparent 44%),
    linear-gradient(145deg, #08090d 0%, #0c0d14 100%);
  color: var(--text);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .25;
  background-image: linear-gradient(rgba(255,255,255,.025) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.025) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: linear-gradient(to bottom, black, transparent 80%);
}

.glow { position: fixed; width: 28rem; height: 28rem; border-radius: 50%; filter: blur(100px); opacity: .12; pointer-events: none; }
.glow-one { top: 8%; left: -12rem; background: var(--violet); }
.glow-two { right: -13rem; bottom: -12rem; background: var(--cyan); }

.shell { position: relative; display: grid; grid-template-rows: auto 1fr auto; width: min(100%, 1240px); height: 100vh; margin: auto; padding: 0 28px 24px; }
.topbar { display: flex; align-items: center; justify-content: space-between; min-height: 82px; border-bottom: 1px solid var(--line); }
.brand { display: flex; gap: 11px; align-items: center; color: inherit; text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 38px; height: 38px; border: 1px solid rgba(157,123,255,.7); border-radius: 12px; background: linear-gradient(145deg, rgba(157,123,255,.3), rgba(114,230,209,.08)); box-shadow: inset 0 0 18px rgba(157,123,255,.12); font: 700 18px/1 ui-monospace, monospace; }
.brand strong, .brand small { display: block; }
.brand strong { letter-spacing: -.02em; }
.brand small { margin-top: 2px; color: var(--muted); font-size: 10px; letter-spacing: .16em; text-transform: uppercase; }
.actions { display: flex; align-items: center; gap: 14px; }
.status { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12px; }
.status i { width: 7px; height: 7px; border-radius: 50%; background: #e9b04b; box-shadow: 0 0 9px currentColor; }
.status.online i { background: #61dc9e; }
.status.offline i { background: #ff6b75; }
.ghost-button { padding: 8px 12px; border: 1px solid var(--line); border-radius: 9px; background: rgba(255,255,255,.035); color: #d7d9e2; cursor: pointer; }
.ghost-button:hover { border-color: rgba(157,123,255,.55); background: rgba(157,123,255,.1); }

.stage { min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) 0; transition: grid-template-columns .28s ease; }
.stage.tracing { grid-template-columns: minmax(0, 1fr) 310px; }
.chat { overflow-y: auto; scrollbar-width: thin; scrollbar-color: #343541 transparent; }
.welcome { min-height: 100%; display: flex; flex-direction: column; justify-content: center; padding: 40px 8% 68px; }
.eyebrow { margin-bottom: 16px; color: var(--cyan); font: 600 11px/1 ui-monospace, monospace; letter-spacing: .2em; }
h1 { margin: 0; max-width: 720px; font-size: clamp(38px, 6vw, 68px); line-height: 1.06; letter-spacing: -.055em; }
h1 span { color: transparent; background: linear-gradient(90deg, var(--violet), #d8c9ff 48%, var(--cyan)); background-clip: text; -webkit-background-clip: text; }
.welcome p { max-width: 620px; margin: 22px 0 28px; color: var(--muted); font-size: 15px; line-height: 1.8; }
.suggestions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.suggestions button { min-height: 78px; padding: 15px; text-align: left; border: 1px solid var(--line); border-radius: 13px; background: rgba(255,255,255,.025); color: #cdd0db; line-height: 1.45; cursor: pointer; transition: .2s ease; }
.suggestions button:hover { transform: translateY(-2px); border-color: rgba(157,123,255,.55); background: rgba(157,123,255,.08); color: white; }

.messages { display: none; padding: 42px 5% 32px; }
.chat.active .welcome { display: none; }
.chat.active .messages { display: block; }
.message { display: grid; grid-template-columns: 32px 1fr; gap: 13px; margin-bottom: 30px; }
.avatar { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 10px; background: #20222d; color: #c9cbd4; font: 700 12px/1 ui-monospace, monospace; }
.message.assistant .avatar { border: 1px solid rgba(157,123,255,.45); background: rgba(157,123,255,.13); color: #cbbaff; }
.message-body { min-width: 0; padding-top: 4px; white-space: pre-wrap; overflow-wrap: anywhere; color: #e7e8ee; font-size: 15px; line-height: 1.75; }
.message.user .message-body { color: #b9bbc6; }
.thinking { display: inline-flex; gap: 5px; padding-top: 8px; }
.thinking i { width: 5px; height: 5px; border-radius: 50%; background: var(--violet); animation: pulse 1.2s infinite; }
.thinking i:nth-child(2) { animation-delay: .15s; }
.thinking i:nth-child(3) { animation-delay: .3s; }
@keyframes pulse { 0%, 75%, 100% { opacity: .25; transform: translateY(0); } 35% { opacity: 1; transform: translateY(-3px); } }

.composer { position: relative; margin: 0 4%; padding: 5px 64px 28px 5px; border: 1px solid rgba(255,255,255,.13); border-radius: 17px; background: var(--panel); box-shadow: 0 18px 60px rgba(0,0,0,.35); backdrop-filter: blur(18px); }
.composer:focus-within { border-color: rgba(157,123,255,.62); box-shadow: 0 18px 60px rgba(0,0,0,.35), 0 0 0 3px rgba(157,123,255,.08); }
textarea { display: block; width: 100%; max-height: 180px; padding: 13px 12px; resize: none; border: 0; outline: 0; background: transparent; color: white; font: inherit; line-height: 1.5; }
textarea::placeholder { color: #737684; }
.send-button { position: absolute; right: 12px; top: 10px; display: grid; place-items: center; width: 39px; height: 39px; padding: 0; border: 0; border-radius: 11px; background: linear-gradient(135deg, var(--violet), #7454dd); color: white; cursor: pointer; box-shadow: 0 8px 24px rgba(116,84,221,.32); }
.send-button:disabled { opacity: .35; cursor: wait; }
.send-button svg { width: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.composer-note { position: absolute; left: 17px; right: 16px; bottom: 9px; display: flex; justify-content: space-between; color: #696c79; font-size: 10px; }
.run-panel { overflow: hidden; width: 0; margin: 24px 0 24px 0; border-left: 1px solid transparent; opacity: 0; transition: .28s ease; }
.stage.tracing .run-panel { width: 310px; margin-left: 18px; padding-left: 18px; border-color: var(--line); opacity: 1; }
.run-heading { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 18px; }
.run-heading small, .run-heading strong { display: block; }
.run-heading small { margin-bottom: 5px; color: var(--cyan); font: 600 9px/1 ui-monospace, monospace; letter-spacing: .18em; }
.run-heading strong { font-size: 15px; }
.run-heading > span { padding: 5px 7px; border: 1px solid var(--line); border-radius: 7px; color: var(--muted); font-size: 10px; }
.metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; margin-bottom: 20px; }
.metrics div { padding: 10px 8px; border: 1px solid var(--line); border-radius: 10px; background: rgba(255,255,255,.025); }
.metrics span, .metrics small { display: block; }
.metrics span { margin-bottom: 4px; font: 600 13px/1 ui-monospace, monospace; }
.metrics small { color: var(--muted); font-size: 9px; }
.timeline { max-height: calc(100vh - 250px); overflow-y: auto; }
.timeline-empty { color: #6f7280; font-size: 11px; line-height: 1.6; }
.trace-item { position: relative; margin: 0 0 10px 6px; padding: 10px 10px 10px 22px; border: 1px solid var(--line); border-radius: 10px; background: rgba(255,255,255,.02); }
.trace-item::before { content: ""; position: absolute; left: 9px; top: 14px; width: 6px; height: 6px; border-radius: 50%; background: var(--violet); box-shadow: 0 0 8px rgba(157,123,255,.6); }
.trace-item.done::before { background: var(--cyan); }
.trace-item strong, .trace-item span { display: block; }
.trace-item strong { padding-right: 50px; font-size: 11px; overflow-wrap: anywhere; }
.trace-item span { margin-top: 5px; color: var(--muted); font-size: 10px; line-height: 1.45; }
.trace-item time { position: absolute; right: 9px; top: 9px; color: #666977; font: 9px/1 ui-monospace, monospace; }
.auth-overlay { position: fixed; z-index: 20; inset: 0; display: grid; place-items: center; padding: 20px; background: rgba(6,7,10,.86); backdrop-filter: blur(20px); }
.auth-overlay[hidden] { display: none; }
.auth-card { width: min(100%, 390px); padding: 30px; border: 1px solid rgba(157,123,255,.3); border-radius: 20px; background: #11131b; box-shadow: 0 28px 90px rgba(0,0,0,.6); }
.auth-card > small { display: block; margin: 20px 0 8px; color: var(--cyan); font: 600 10px/1 ui-monospace, monospace; letter-spacing: .18em; }
.auth-card h2 { margin: 0; font-size: 27px; }
.auth-card p { margin: 10px 0 22px; color: var(--muted); font-size: 13px; line-height: 1.6; }
.auth-card label { display: block; margin-bottom: 7px; color: #c8cad4; font-size: 11px; }
.auth-card input, .auth-card select { width: 100%; margin-bottom: 12px; padding: 12px; border: 1px solid var(--line); border-radius: 10px; outline: 0; background: #090a0f; color: white; }
.auth-card input:focus, .auth-card select:focus { border-color: var(--violet); }
.auth-card button { width: 100%; margin-top: 12px; padding: 12px; border: 0; border-radius: 10px; background: linear-gradient(135deg, var(--violet), #7454dd); color: white; cursor: pointer; }
.auth-card .text-button { margin-top: 6px; background: transparent; color: var(--cyan); }
.auth-error { display: block; min-height: 16px; margin-top: 10px; color: #ff7983; font-size: 11px; }
.setting-hint { display: block; color: var(--muted); font-size: 11px; }
.setting-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.setting-actions .ghost-button { border: 1px solid var(--line); background: transparent; }
.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: 650px) {
  .shell { padding: 0 14px 14px; }
  .topbar { min-height: 68px; }
  .status span { display: none; }
  .welcome { padding: 32px 2px 44px; justify-content: flex-start; padding-top: 14vh; }
  h1 { font-size: 41px; }
  .suggestions { grid-template-columns: 1fr; }
  .suggestions button { min-height: 54px; }
  .messages { padding: 28px 2px 20px; }
  .composer { margin: 0; }
  .stage.tracing { grid-template-columns: 1fr; }
  .stage.tracing .run-panel { display: none; }
}
