:root {
  color-scheme: dark;
  --bg: #100d16;
  --surface: #1a1523;
  --surface-raised: #251d31;
  --border: rgba(255, 255, 255, 0.11);
  --text: #f8f2ff;
  --muted: #b9aec3;
  --accent: #ff7857;
  --accent-strong: #ff4f78;
  --user: #6946d9;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 15% 0%, rgba(255, 120, 87, 0.16), transparent 32rem),
    radial-gradient(circle at 100% 80%, rgba(105, 70, 217, 0.22), transparent 30rem),
    var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button, textarea, select { font: inherit; }

.app-shell {
  width: min(100% - 32px, 820px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 52px 0 28px;
  display: flex;
  flex-direction: column;
}

.app-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  flex: 0 0 auto;
  border: 1px solid rgba(255, 120, 87, 0.45);
  border-radius: 16px;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #1b1114;
  font-weight: 900;
  letter-spacing: -0.08em;
  box-shadow: 0 12px 30px rgba(255, 88, 105, 0.24);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.16em;
}

h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 3px; font-size: clamp(2rem, 5vw, 3.1rem); line-height: 1; letter-spacing: -0.06em; }
.tagline { margin-bottom: 0; color: var(--muted); font-size: 0.98rem; }

.chat-card {
  min-height: 640px;
  display: flex;
  flex: 1;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 26px;
  background: rgba(26, 21, 35, 0.88);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.messages {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 14px;
  min-height: 430px;
  padding: 30px;
  overflow-y: auto;
}

.empty-state {
  display: flex;
  flex: 1;
  min-height: 360px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px;
  text-align: center;
}

.empty-icon { margin-bottom: 18px; font-size: 3rem; filter: drop-shadow(0 0 22px rgba(255, 120, 87, 0.3)); }
.empty-state h2 { max-width: 420px; margin-bottom: 8px; font-size: clamp(1.35rem, 3vw, 1.8rem); letter-spacing: -0.04em; }
.empty-state p { max-width: 390px; margin-bottom: 0; color: var(--muted); }

.message-row { display: flex; width: 100%; animation: appear 180ms ease-out; }
.message-row.user { justify-content: flex-end; }
.message-row.assistant { justify-content: flex-start; }
.message-bubble { max-width: min(86%, 570px); padding: 14px 17px; border-radius: 18px; line-height: 1.5; white-space: pre-wrap; word-break: break-word; }
.message-row.user .message-bubble { border-bottom-right-radius: 5px; background: var(--user); }
.message-row.assistant .message-bubble { border: 1px solid var(--border); border-bottom-left-radius: 5px; background: var(--surface-raised); }
.message-row.error .message-bubble { border-color: rgba(255, 120, 87, 0.5); color: #ffd3c8; }

.loading-bubble { display: inline-flex; align-items: center; gap: 5px; min-width: 64px; }
.loading-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: bounce 1s infinite ease-in-out; }
.loading-dot:nth-child(2) { animation-delay: 120ms; }
.loading-dot:nth-child(3) { animation-delay: 240ms; }

.composer-form { padding: 20px 24px 22px; border-top: 1px solid var(--border); background: rgba(16, 13, 22, 0.35); }
.controls-row { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.controls-row label { color: var(--muted); font-size: 0.82rem; font-weight: 700; }
select { min-width: 250px; padding: 8px 12px; border: 1px solid var(--border); border-radius: 10px; outline: none; background: var(--surface-raised); color: var(--text); cursor: pointer; }
select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(255, 120, 87, 0.15); }
.input-row { display: flex; align-items: flex-end; gap: 10px; }
textarea { width: 100%; min-height: 48px; max-height: 140px; resize: none; padding: 13px 15px; border: 1px solid var(--border); border-radius: 14px; outline: none; background: var(--surface); color: var(--text); line-height: 1.45; }
textarea::placeholder { color: #81768d; }
button { min-height: 48px; padding: 0 20px; border: 0; border-radius: 14px; background: linear-gradient(135deg, var(--accent), var(--accent-strong)); color: #211117; font-weight: 850; cursor: pointer; transition: transform 160ms ease, filter 160ms ease, opacity 160ms ease; }
button:hover:not(:disabled) { transform: translateY(-1px); filter: brightness(1.08); }
button:active:not(:disabled) { transform: translateY(0); }
button:disabled { cursor: wait; opacity: 0.5; }
.form-hint { margin: 9px 0 0; color: #81768d; font-size: 0.75rem; }
.app-footer { padding-top: 18px; color: #81768d; font-size: 0.78rem; text-align: center; }
.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; }

@keyframes appear { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }
@keyframes bounce { 0%, 60%, 100% { transform: translateY(0); opacity: 0.55; } 30% { transform: translateY(-4px); opacity: 1; } }

@media (max-width: 600px) {
  .app-shell { width: min(100% - 20px, 820px); padding-top: 24px; }
  .app-header { align-items: flex-start; margin-bottom: 16px; }
  .brand-mark { width: 46px; height: 46px; border-radius: 13px; }
  .tagline { font-size: 0.88rem; }
  .chat-card { min-height: calc(100vh - 150px); border-radius: 20px; }
  .messages { min-height: 0; padding: 18px 14px; }
  .empty-state { min-height: 300px; padding: 24px 16px; }
  .message-bubble { max-width: 92%; padding: 12px 14px; }
  .composer-form { padding: 14px; }
  .controls-row { align-items: stretch; flex-direction: column; gap: 6px; }
  select { width: 100%; min-width: 0; }
  .input-row { align-items: stretch; }
  button { padding: 0 15px; }
}
