:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --ink: #1e293b;
  --muted: #64748b;
  --line: #e2e8f0;
  --accent: #4f46e5;
  --accent-soft: #eef2ff;
  --user-bubble: #4f46e5;
  --agent-bubble: #f1f5f9;
  --radius: 12px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.55;
}

.app {
  max-width: 860px;
  margin: 0 auto;
  padding: 24px 16px 48px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.hero {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}
.hero-icon {
  font-size: 40px;
  line-height: 1;
  background: var(--accent-soft);
  border-radius: 12px;
  padding: 12px;
}
.hero h1 { margin: 4px 0 6px; font-size: 24px; }
.hero p { margin: 0; color: var(--muted); font-size: 15px; }

.controls {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 20px;
  padding: 16px;
}
.control label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.hint { font-size: 12px; color: var(--muted); margin: 6px 0 0; }
.hint a { color: var(--accent); }
input[type="text"], input[type="password"] {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
  font-size: 14px;
  background: #fff;
}
input:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.token-row { display: flex; gap: 10px; align-items: center; }
.remember { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); white-space: nowrap; }

.chat {
  min-height: 320px;
  max-height: 520px;
  overflow-y: auto;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.chat .empty {
  margin: auto;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}
.msg { max-width: 85%; padding: 10px 14px; border-radius: var(--radius); font-size: 14px; }
.msg.user {
  align-self: flex-end;
  background: var(--user-bubble);
  color: #fff;
  white-space: pre-wrap;
}
.msg.agent {
  align-self: flex-start;
  background: var(--agent-bubble);
}
.msg.agent ul { margin: 6px 0; padding-left: 20px; }
.msg.agent h4 { margin: 10px 0 4px; font-size: 14px; }
.msg.agent code { background: #e2e8f0; border-radius: 4px; padding: 0 4px; }
.step {
  align-self: flex-start;
  color: var(--muted);
  font-size: 12px;
  font-style: italic;
  padding-left: 6px;
}
.typing { align-self: flex-start; color: var(--muted); font-size: 13px; }

.examples { display: flex; flex-wrap: wrap; gap: 8px; }
.examples button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--accent);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 13px;
  cursor: pointer;
}
.examples button:hover { background: var(--accent-soft); border-color: var(--accent); }

.composer {
  display: flex;
  gap: 10px;
  padding: 10px;
  align-items: flex-end;
}
.composer textarea {
  flex: 1;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  font: inherit;
  font-size: 14px;
  resize: vertical;
}
.composer button {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 11px 20px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.composer button:disabled { opacity: 0.5; cursor: not-allowed; }

.budget-panel { padding: 12px 16px; }
.budget-panel summary { cursor: pointer; font-weight: 600; font-size: 14px; }
.budget-table table { width: 100%; border-collapse: collapse; margin-top: 12px; font-size: 13px; }
.budget-table th, .budget-table td {
  text-align: left;
  border-bottom: 1px solid var(--line);
  padding: 7px 10px;
}
.budget-table th { background: var(--accent-soft); }
.budget-table td.num { text-align: right; font-variant-numeric: tabular-nums; }

@media (max-width: 640px) {
  .controls { grid-template-columns: 1fr; }
  .hero { flex-direction: column; }
  .msg { max-width: 100%; }
}