:root {
  --hue: 28;
  --bg:        oklch(97% 0.006 var(--hue));
  --surface:   oklch(99% 0.004 var(--hue));
  --surface-2: oklch(94% 0.008 var(--hue));
  --border:    oklch(88% 0.01  var(--hue));
  --text:      oklch(22% 0.01  var(--hue));
  --text-dim:  oklch(48% 0.012 var(--hue));
  --accent:    oklch(58% 0.14  var(--hue));
  --accent-ink:oklch(99% 0.005 var(--hue));
  --danger:    oklch(55% 0.16  25);

  --radius: 10px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg:        oklch(19% 0.008 var(--hue));
    --surface:   oklch(23% 0.01  var(--hue));
    --surface-2: oklch(27% 0.012 var(--hue));
    --border:    oklch(34% 0.014 var(--hue));
    --text:      oklch(94% 0.006 var(--hue));
    --text-dim:  oklch(70% 0.01  var(--hue));
    --accent:    oklch(70% 0.13  var(--hue));
    --accent-ink:oklch(15% 0.01  var(--hue));
  }
}

* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%;
  background: var(--bg); color: var(--text);
  font-family: var(--font); font-size: 0.9375rem; line-height: 1.45;
}

/* ── login ─────────────────────────────────────────── */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100dvh; padding: 24px; }
.login-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 32px; width: 100%; max-width: 340px; display: flex; flex-direction: column; gap: 14px;
}
.login-card h1 { margin: 0; font-size: 1.3rem; font-weight: 650; }
.login-card .subtitle { margin: -8px 0 6px; color: var(--text-dim); font-size: 0.875rem; }
.login-card label { display: flex; flex-direction: column; gap: 6px; font-size: 0.8125rem; color: var(--text-dim); }
.login-card input {
  font: inherit; padding: 9px 10px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--bg); color: var(--text);
}
.login-card input:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
.login-card button[type=submit] {
  margin-top: 6px; font: inherit; font-weight: 600; padding: 10px; border: none; border-radius: 8px;
  background: var(--accent); color: var(--accent-ink); cursor: pointer;
  transition: filter 150ms var(--ease);
}
.login-card button[type=submit]:hover { filter: brightness(0.95); }
.login-card button[type=submit]:active { filter: brightness(0.88); }
.login-card button[type=submit]:disabled { opacity: 0.6; cursor: not-allowed; }
.error { color: var(--danger); font-size: 0.8125rem; margin: 0; }

/* ── chat shell ────────────────────────────────────── */
body:not(.login-body) { display: flex; flex-direction: column; height: 100dvh; }

.topbar {
  display: flex; align-items: center; gap: 12px; padding: 10px 16px;
  border-bottom: 1px solid var(--border); background: var(--surface); flex-shrink: 0;
}
.brand { font-weight: 650; }
.quota { margin-left: auto; color: var(--text-dim); font-size: 0.8125rem; }
.link-btn {
  background: none; border: none; color: var(--text-dim); font: inherit; cursor: pointer; padding: 0;
}
.link-btn:hover { color: var(--text); }

.feed {
  flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 8px;
}
.msg {
  max-width: 75%; padding: 9px 12px; border-radius: var(--radius); white-space: pre-wrap; word-break: break-word;
}
.msg.user {
  align-self: flex-end; background: var(--accent); color: var(--accent-ink); border-bottom-right-radius: 4px;
}
.msg.bot {
  align-self: flex-start; background: var(--surface-2); border-bottom-left-radius: 4px;
}
.msg.system {
  align-self: center; color: var(--text-dim); font-size: 0.8125rem; background: none; padding: 4px;
}
.msg.error { align-self: flex-start; color: var(--danger); background: none; padding: 4px 12px; }

.typing { align-self: flex-start; display: flex; gap: 4px; padding: 10px 12px; }
.typing span {
  width: 6px; height: 6px; border-radius: 50%; background: var(--text-dim);
  animation: bounce 1.2s var(--ease) infinite;
}
.typing span:nth-child(2) { animation-delay: 150ms; }
.typing span:nth-child(3) { animation-delay: 300ms; }
@keyframes bounce { 0%, 100% { transform: translateY(0); opacity: 0.5; } 50% { transform: translateY(-4px); opacity: 1; } }
.typing-hint { align-self: flex-start; color: var(--text-dim); font-size: 0.8125rem; padding: 0 12px; }

.commands {
  display: flex; gap: 8px; padding: 8px 16px; overflow-x: auto; border-top: 1px solid var(--border);
  background: var(--surface); flex-shrink: 0;
}
.chip {
  flex-shrink: 0; font: inherit; font-size: 0.8125rem; padding: 7px 12px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text); cursor: pointer;
  transition: border-color 150ms var(--ease);
}
.chip:hover { border-color: var(--accent); }
.chip:disabled { opacity: 0.5; cursor: not-allowed; }

.composer {
  display: flex; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--border);
  background: var(--surface); flex-shrink: 0;
}
.composer input {
  flex: 1; font: inherit; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--bg); color: var(--text);
}
.composer input:focus { outline: none; border-color: var(--accent); }
.composer input:disabled { opacity: 0.6; }
.composer button {
  font: inherit; font-weight: 600; width: 42px; border: none; border-radius: 8px;
  background: var(--accent); color: var(--accent-ink); cursor: pointer;
}
.composer button:disabled { opacity: 0.5; cursor: not-allowed; }

@media (max-width: 767px) {
  .msg { max-width: 85%; }
}
