:root {
  --bg: #0A0F1E;
  --surface: #111829;
  --surface-2: #182136;
  --line: #26304a;
  --text: #f5f7fa;
  --muted: #9aa5bd;
  --accent: #3fa9f5;
  --primary: #6366f1;
  --primary-hover: #7578f3;
  --danger: #f2667a;
  --ok: #3ccf91;
  --warn: #f5b942;
  --radius: 10px;
  --mono: ui-monospace, "JetBrains Mono", "SFMono-Regular", Menlo, Consolas, monospace;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px 20px; border-bottom: 1px solid var(--line); background: #070b16;
}
.brand { display: flex; align-items: center; gap: 14px; min-width: 0; }
.wordmark { font-weight: 700; letter-spacing: .07em; font-size: 18px; position: relative; padding-bottom: 4px; }
.wordmark::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 2px;
  background: linear-gradient(90deg, var(--text) calc(100% - 9px), var(--accent) calc(100% - 9px));
}
.solu { color: var(--text); }
.coder { color: var(--accent); }
.divider { width: 1px; height: 22px; background: var(--line); }
.product { color: var(--muted); font-weight: 500; white-space: nowrap; }

.status { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); white-space: nowrap; }
.status .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.status[data-state="ok"] .dot { background: var(--ok); }
.status[data-state="loading"] .dot { background: var(--warn); }
.status[data-state="error"] .dot { background: var(--danger); }

.layout { flex: 1; display: grid; grid-template-columns: 320px 1fr; min-height: 0; }
.panel { border-right: 1px solid var(--line); padding: 18px; overflow-y: auto; background: var(--surface); }
.group { margin-bottom: 18px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; font-weight: 500; }
label output { color: var(--text); float: right; font-variant-numeric: tabular-nums; }
label.check { display: flex; align-items: center; gap: 8px; color: var(--text); margin: 6px 0; cursor: pointer; }
.key-row { display: flex; gap: 8px; }
.key-row > :first-child { flex: 1; min-width: 0; }

input[type="password"], input[type="text"], input[type="number"], select, textarea {
  width: 100%; background: var(--bg); color: var(--text); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 10px; font: inherit;
}
textarea { resize: vertical; }
input[type="range"] { width: 100%; accent-color: var(--accent); }
input[type="checkbox"] { accent-color: var(--accent); width: 16px; height: 16px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

button {
  font: inherit; border-radius: 8px; padding: 8px 14px; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--text);
}
button:hover { border-color: var(--muted); }
button:disabled { opacity: .5; cursor: not-allowed; }
button.primary { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
button.primary:hover:not(:disabled) { background: var(--primary-hover); }
button.ghost { background: transparent; }
button.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 50%, transparent); }

.snippet summary { cursor: pointer; color: var(--muted); font-size: 13px; font-weight: 500; }
.snippet p { font-size: 13px; color: var(--muted); }
.snippet pre { font-size: 12px; white-space: pre-wrap; word-break: break-all; }
code, pre { font-family: var(--mono); }
code { background: var(--surface-2); padding: 1px 5px; border-radius: 5px; font-size: .9em; }
pre { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; overflow-x: auto; }
pre code { background: none; padding: 0; }

.chat { display: flex; flex-direction: column; min-height: 0; }
.messages { flex: 1; overflow-y: auto; padding: 24px; display: flex; flex-direction: column; gap: 16px; }
.empty { margin: auto; text-align: center; color: var(--muted); max-width: 420px; }
.empty h1 { color: var(--text); font-size: 22px; margin: 0 0 8px; }

.msg { max-width: 860px; width: 100%; margin: 0 auto; display: flex; flex-direction: column; gap: 6px; }
.msg .role { font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.msg.user .role { color: var(--accent); }
.msg .body { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; overflow-wrap: anywhere; }
.msg.user .body { background: var(--surface-2); white-space: pre-wrap; }
.msg.error .body { border-color: var(--danger); color: var(--danger); }
.msg .body p { margin: 0 0 .7em; }
.msg .body p:last-child { margin-bottom: 0; }
.reasoning { border-left: 2px solid var(--line); padding: 2px 0 2px 12px; color: var(--muted); font-size: 14px; }
.reasoning summary { cursor: pointer; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
.reasoning div { white-space: pre-wrap; margin-top: 6px; }
.cursor::after { content: "▍"; color: var(--accent); animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

.composer { border-top: 1px solid var(--line); padding: 14px 24px 18px; background: var(--surface); }
.composer textarea { max-width: 860px; display: block; margin: 0 auto; min-height: 52px; max-height: 40vh; }
.actions { max-width: 860px; margin: 10px auto 0; display: flex; align-items: center; gap: 8px; }
.stats { flex: 1; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }

@media (max-width: 820px) {
  .layout { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .panel { border-right: 0; border-bottom: 1px solid var(--line); max-height: 45vh; padding: 16px; }
  .messages { padding: 16px; }
  .composer { padding: 12px 16px 16px; }
  .topbar { padding: 10px 16px; }
  .product { display: none; }
}
@media (prefers-reduced-motion: reduce) { .cursor::after { animation: none; } }
