:root {
  --bg: #141414;
  --surface: #1c1c1c;
  --surface-2: #242424;
  --line: rgba(255, 255, 255, 0.08);
  --text: #f7f7f7;
  --muted: #9a9a9a;
  --cream: #f0dcc8;
  --cream-ink: #2b2725;
  --green: #7ee2a8;
  --red: #ff8a7a;
  --amber: #f4c27a;
  --font: "Instrument Sans", system-ui, sans-serif;
  --font-brand: "Comfortaa", var(--font);
  --mono: "JetBrains Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body { background: var(--bg); color: var(--text); font-family: var(--font); -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
button, input, textarea { font: inherit; color: inherit; }
img { display: block; max-width: 100%; }

/* ---------- Nav ---------- */
.nav { display: flex; align-items: center; gap: 32px; padding: 14px 28px; border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 8px; font-family: var(--font-brand); font-weight: 700; font-size: 22px; letter-spacing: -0.02em; }
.brand-icon { width: 34px; height: 34px; object-fit: contain; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.nav-links { display: flex; gap: 22px; font-size: 14px; color: var(--muted); }
.nav-links a:hover { color: var(--text); }
.nav-cta { margin-left: auto; }
.btn { display: inline-flex; align-items: center; justify-content: center; border-radius: 999px; font-weight: 500; cursor: pointer; border: 0; }
.btn-sm { height: 40px; padding: 0 20px; font-size: 15px; }
.btn-cream { background: var(--cream); color: var(--cream-ink); }

/* ---------- Layout ---------- */
.try {
  display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px;
  max-width: 1240px; margin: 0 auto; padding: 20px 28px 28px;
  height: calc(100dvh - 69px);
}
.chat, .sandbox { background: var(--surface); border: 1px solid var(--line); border-radius: 24px; min-height: 0; }
.chat { display: flex; flex-direction: column; padding: 20px 20px 14px; }

.chat-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 0 4px 14px; border-bottom: 1px solid var(--line); }
h1 { font-size: 22px; font-weight: 600; letter-spacing: -0.02em; }
.sub { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; margin-top: 4px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 4px rgba(126, 226, 168, 0.15); flex: none; }
.btn-ghost-sm { background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; padding: 8px 14px; font-size: 13px; cursor: pointer; white-space: nowrap; }
.btn-ghost-sm:hover { border-color: rgba(255, 255, 255, 0.2); }

/* ---------- Log ---------- */
.log { flex: 1; overflow-y: auto; padding: 18px 4px; display: flex; flex-direction: column; gap: 14px; }
.msg { max-width: 85%; font-size: 15px; line-height: 1.55; overflow-wrap: anywhere; }
.msg-user { align-self: flex-end; background: var(--cream); color: var(--cream-ink); padding: 10px 16px; border-radius: 18px 18px 4px 18px; white-space: pre-wrap; }
.msg-bot { align-self: flex-start; }
.bot-text code { font-family: var(--mono); font-size: 13px; background: var(--surface-2); padding: 1px 6px; border-radius: 6px; }
.typing { color: var(--muted); font-size: 14px; }
.typing::after { content: "…"; animation: blink 1.2s infinite; }
@keyframes blink { 50% { opacity: 0.2; } }
.error { color: var(--red); font-size: 14px; }
.note { color: var(--muted); font-size: 14px; }

.steps { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.steps:empty { display: none; }
.thought { color: var(--muted); font-size: 13px; font-style: italic; line-height: 1.5; padding-left: 12px; border-left: 2px solid var(--line); }
.thought:empty { display: none; }
.step { background: var(--bg); border: 1px solid var(--line); border-radius: 12px; font-family: var(--mono); font-size: 12.5px; }
.step summary { display: flex; gap: 10px; align-items: baseline; padding: 7px 12px; cursor: pointer; list-style: none; }
.step summary::-webkit-details-marker { display: none; }
.step summary::before { content: "▸"; color: var(--muted); }
.step[open] summary::before { content: "▾"; }
.step-name { color: var(--green); flex: none; }
.step-write .step-name { color: var(--amber); }
.step-err .step-name { color: var(--red); }
.step-args { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.step-json { padding: 0 12px 10px; color: #cfcfcf; white-space: pre-wrap; max-height: 260px; overflow: auto; }

.intro { margin: auto; max-width: 520px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 14px; color: var(--muted); }
.intro-mascot { width: 96px; height: 96px; object-fit: contain; }
.chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.chip { background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; padding: 8px 14px; font-size: 14px; color: var(--text); cursor: pointer; }
.chip:hover { border-color: var(--cream); }

/* ---------- Composer ---------- */
.composer { display: flex; align-items: flex-end; gap: 8px; background: var(--bg); border: 1px solid var(--line); border-radius: 20px; padding: 8px 8px 8px 16px; }
.composer:focus-within { border-color: rgba(240, 220, 200, 0.45); }
.composer textarea { flex: 1; background: none; border: 0; outline: 0; resize: none; font-size: 15px; line-height: 1.5; padding: 8px 0; max-height: 160px; field-sizing: content; }
.btn-send { width: 40px; height: 40px; border-radius: 50%; border: 0; background: var(--cream); color: var(--cream-ink); display: grid; place-items: center; cursor: pointer; flex: none; }
.btn-send:disabled { opacity: 0.4; cursor: default; }
.btn-stop { height: 40px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface-2); cursor: pointer; font-size: 14px; }
.fine { color: var(--muted); font-size: 12px; line-height: 1.5; margin-top: 10px; padding: 0 4px; }

/* ---------- Sandbox ---------- */
.sandbox { padding: 20px; overflow-y: auto; }
.sandbox h2 { font-size: 17px; font-weight: 600; }
.sandbox h3 { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin: 20px 0 8px; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.stats div { background: var(--bg); border: 1px solid var(--line); border-radius: 14px; padding: 12px; }
.label { display: block; color: var(--muted); font-size: 12px; margin-bottom: 4px; }
.stats b { font-family: var(--mono); font-weight: 500; font-size: 15px; }
.positions { width: 100%; border-collapse: collapse; font-size: 13px; }
.positions th { text-align: left; color: var(--muted); font-weight: 500; padding: 6px 4px; border-bottom: 1px solid var(--line); }
.positions td { padding: 8px 4px; border-bottom: 1px solid var(--line); font-family: var(--mono); font-size: 12.5px; }
.positions .sym { font-family: var(--font); font-weight: 600; }
.orders { list-style: none; display: flex; flex-direction: column; gap: 6px; font-family: var(--mono); font-size: 12px; }
.order { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; }
.order-filled { border-color: rgba(126, 226, 168, 0.35); }
.order-open { border-color: rgba(244, 194, 122, 0.35); }
.empty { color: var(--muted); font-family: var(--font); }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .nav-links { display: none; }
  .try { grid-template-columns: 1fr; height: auto; padding: 16px; }
  .chat { height: calc(100dvh - 100px); }
}
@media (max-width: 520px) {
  .nav { padding: 12px 16px; }
  .chat { padding: 16px 12px 12px; border-radius: 20px; }
  .msg { max-width: 92%; }
}
@media (prefers-reduced-motion: reduce) {
  .typing::after { animation: none; }
}
