:root {
  color-scheme: dark;
  --bg: #11100e;
  --surface: #1a1815;
  --surface-raised: #23201c;
  --border: #34302a;
  --text: #f2eee7;
  --muted: #9e978d;
  --accent: #eea84b;
  --accent-dark: #1f160a;
  --danger: #ffb4a7;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background:
    radial-gradient(circle at 15% 0%, rgba(238, 168, 75, .08), transparent 34rem),
    var(--bg);
  color: var(--text);
}

button, textarea { font: inherit; }
button { color: inherit; }

.app-shell {
  display: grid;
  grid-template-rows: auto 1fr auto;
  height: 100dvh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 68px;
  padding: .75rem clamp(1rem, 4vw, 2.5rem);
  border-bottom: 1px solid rgba(255, 255, 255, .07);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: .7rem;
  color: var(--text);
  font-weight: 700;
  letter-spacing: -.02em;
  text-decoration: none;
}

.brand-mark {
  width: 1.1rem;
  height: 1.1rem;
  border: 3px solid var(--accent);
  border-radius: 50% 50% 50% 15%;
  transform: rotate(-12deg);
}

.topbar-actions { display: flex; align-items: center; gap: .7rem; }

.model-badge {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  color: var(--muted);
  font-size: .78rem;
}

.model-badge span {
  width: .45rem;
  height: .45rem;
  border-radius: 50%;
  background: #70c993;
  box-shadow: 0 0 0 3px rgba(112, 201, 147, .12);
}

.ghost-button, .prompt-chips button, .copy-button, .error-panel button {
  border: 1px solid var(--border);
  border-radius: .65rem;
  background: transparent;
  cursor: pointer;
}

.ghost-button { padding: .55rem .8rem; font-size: .82rem; }
.ghost-button:hover, .prompt-chips button:hover { border-color: #5b5348; background: rgba(255, 255, 255, .035); }

.chat {
  width: min(100%, 820px);
  min-height: 0;
  margin: 0 auto;
  padding: 2rem clamp(1rem, 4vw, 2rem) 1rem;
  overflow-y: auto;
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 55vh;
  text-align: center;
}

.empty-state[hidden] { display: none; }
.empty-state > * { margin: 0; }
.eyebrow { color: var(--accent); font-size: .72rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; }

.empty-state h1 {
  max-width: 650px;
  margin-top: .8rem;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.2rem, 7vw, 4.4rem);
  font-weight: 400;
  line-height: 1.03;
  letter-spacing: -.045em;
}

.empty-state p { max-width: 540px; margin-top: 1.15rem; color: var(--muted); line-height: 1.65; }

.prompt-chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: .55rem;
  margin-top: 2rem;
}

.prompt-chips button { padding: .65rem .9rem; color: #c9c2b8; font-size: .82rem; }

.messages { display: grid; gap: 1.6rem; padding-bottom: 1rem; }
.message { display: grid; gap: .55rem; max-width: 86%; }
.message.user { justify-self: end; }
.message.assistant { justify-self: start; }

.message-label {
  color: var(--muted);
  font-size: .69rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
}

.message.user .message-label { text-align: right; }

.message-content {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.65;
}

.message.user .message-content {
  padding: .85rem 1.05rem;
  border: 1px solid #423c33;
  border-radius: 1.1rem 1.1rem .25rem 1.1rem;
  background: var(--surface-raised);
}

.message.assistant .message-content { color: #ded8cf; }

.copy-button {
  justify-self: start;
  padding: .35rem .55rem;
  color: var(--muted);
  font-size: .72rem;
}

.copy-button:hover { color: var(--text); }

.pending-dots { display: inline-flex; gap: .28rem; padding: .5rem 0; }
.pending-dots span { width: .38rem; height: .38rem; border-radius: 50%; background: var(--muted); animation: pulse 1.1s infinite ease-in-out; }
.pending-dots span:nth-child(2) { animation-delay: .15s; }
.pending-dots span:nth-child(3) { animation-delay: .3s; }

@keyframes pulse { 0%, 60%, 100% { opacity: .25; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }

.composer-wrap {
  width: min(100%, 820px);
  margin: 0 auto;
  padding: .65rem clamp(1rem, 4vw, 2rem) 1rem;
  background: linear-gradient(transparent, var(--bg) 25%);
}

.composer {
  display: flex;
  align-items: flex-end;
  gap: .75rem;
  padding: .65rem .65rem .65rem 1rem;
  border: 1px solid var(--border);
  border-radius: 1rem;
  background: var(--surface);
  box-shadow: 0 16px 45px rgba(0, 0, 0, .25);
}

.composer:focus-within { border-color: #665d51; box-shadow: 0 0 0 3px rgba(238, 168, 75, .08), 0 16px 45px rgba(0, 0, 0, .25); }

textarea {
  flex: 1;
  max-height: 160px;
  padding: .4rem 0;
  border: 0;
  outline: 0;
  resize: none;
  overflow-y: auto;
  background: transparent;
  color: var(--text);
  line-height: 1.5;
}

textarea::placeholder { color: #756e65; }
textarea:disabled { opacity: .55; cursor: not-allowed; }

.send-button {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  border: 0;
  border-radius: .72rem;
  background: var(--accent);
  color: var(--accent-dark);
  cursor: pointer;
}

.send-button:hover { filter: brightness(1.08); }
button:disabled { opacity: .38; cursor: not-allowed; }
.send-button svg { width: 1.25rem; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 2; }

.composer-note { margin: .5rem 0 0; color: #6f685f; font-size: .7rem; text-align: center; }

.error-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: .5rem;
  padding: .65rem .8rem;
  border: 1px solid rgba(255, 180, 167, .25);
  border-radius: .75rem;
  background: rgba(255, 180, 167, .07);
  color: var(--danger);
  font-size: .8rem;
}

.error-panel[hidden] { display: none; }
.error-panel button { padding: .35rem .55rem; border-color: rgba(255, 180, 167, .35); color: var(--danger); }

.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; }

button:focus-visible, textarea:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

@media (max-width: 600px) {
  .topbar { min-height: 60px; }
  .model-badge { display: none; }
  .chat { padding-top: 1.25rem; }
  .empty-state { min-height: 52vh; }
  .empty-state h1 { font-size: clamp(2.25rem, 12vw, 3.4rem); }
  .prompt-chips { display: grid; width: 100%; }
  .prompt-chips button { text-align: left; }
  .message { max-width: 92%; }
  .composer-note { display: none; }
  .composer-wrap { padding-bottom: max(.75rem, env(safe-area-inset-bottom)); }
}

@media (prefers-reduced-motion: reduce) {
  .pending-dots span { animation: none; opacity: .65; }
}
