:root {
  --ink: #152029;
  --ink-soft: #3a4a56;
  --fog: #d7e2ea;
  --paper: #eef3f6;
  --panel: rgba(255, 255, 255, 0.72);
  --line: rgba(21, 32, 41, 0.12);
  --accent: #0f6e6a;
  --accent-deep: #0a4f4c;
  --user: #1f3340;
  --warn: #8a4b16;
  --shadow: 0 18px 50px rgba(21, 32, 41, 0.1);
  --radius: 18px;
  --font-display: "Fraunces", Georgia, serif;
  --font-body: "IBM Plex Sans", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--paper);
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
}

.atmosphere {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(900px 500px at 12% -10%, rgba(15, 110, 106, 0.18), transparent 60%),
    radial-gradient(700px 420px at 100% 0%, rgba(31, 51, 64, 0.14), transparent 55%),
    linear-gradient(165deg, #e8f0f4 0%, #dfe8ee 45%, #d2dde5 100%);
  background-attachment: fixed;
}

.atmosphere::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.35;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)' opacity='0.35'/%3E%3C/svg%3E");
  mix-blend-mode: soft-light;
  pointer-events: none;
}

.top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1.5rem;
  padding: 1.75rem clamp(1.25rem, 4vw, 3rem) 0.75rem;
  animation: rise 0.7s ease both;
}

.brand-block { max-width: 40rem; }

.eyebrow {
  margin: 0 0 0.35rem;
  font-size: 0.75rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-soft);
  font-weight: 600;
}

.brand {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(2.4rem, 6vw, 3.6rem);
  line-height: 0.95;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.tagline {
  margin: 0.7rem 0 0;
  color: var(--ink-soft);
  font-size: 1.05rem;
  max-width: 34rem;
  line-height: 1.45;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.55rem 0.9rem;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--line);
  backdrop-filter: blur(10px);
  font-size: 0.85rem;
  color: var(--ink-soft);
  white-space: nowrap;
  margin-top: 0.35rem;
}

.status-pill .dot {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background: var(--warn);
  box-shadow: 0 0 0 0 rgba(138, 75, 22, 0.45);
  animation: pulse 1.4s ease infinite;
}

.status-pill[data-state="ready"] .dot {
  background: var(--accent);
  box-shadow: none;
  animation: none;
}

.status-pill[data-state="error"] .dot {
  background: #a12828;
  animation: none;
}

.stage {
  display: grid;
  grid-template-rows: 1fr auto;
  gap: 1rem;
  width: min(860px, 100%);
  margin: 0 auto;
  padding: 0.5rem clamp(1rem, 3vw, 1.5rem) 1rem;
  min-height: 0;
}

.transcript {
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 0.25rem 0.15rem 1rem;
  min-height: 42vh;
  max-height: calc(100vh - 280px);
  scroll-behavior: smooth;
}

.empty {
  margin: auto;
  text-align: center;
  color: var(--ink-soft);
  max-width: 26rem;
  animation: rise 0.8s ease 0.15s both;
}

.empty strong {
  display: block;
  font-family: var(--font-display);
  font-size: 1.45rem;
  color: var(--ink);
  margin-bottom: 0.4rem;
}

.bubble {
  max-width: min(92%, 640px);
  padding: 0.95rem 1.1rem;
  border-radius: var(--radius);
  line-height: 1.55;
  animation: rise 0.35s ease both;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.bubble.user {
  align-self: flex-end;
  background: var(--user);
  color: #f3f7fa;
  border-color: transparent;
}

.bubble.assistant {
  align-self: flex-start;
  background: var(--panel);
  backdrop-filter: blur(12px);
}

.bubble .role {
  display: block;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 600;
  opacity: 0.7;
  margin-bottom: 0.4rem;
}

.bubble.assistant .content {
  white-space: pre-wrap;
}

.bubble.assistant .content strong {
  font-weight: 600;
}

.bubble.thinking {
  align-self: flex-start;
  color: var(--ink-soft);
  font-style: italic;
  box-shadow: none;
  background: transparent;
  border-style: dashed;
}

.composer {
  display: grid;
  gap: 0.75rem;
  padding: 0.9rem;
  border-radius: calc(var(--radius) + 4px);
  background: var(--panel);
  border: 1px solid var(--line);
  backdrop-filter: blur(14px);
  box-shadow: var(--shadow);
  animation: rise 0.7s ease 0.1s both;
}

.composer textarea {
  width: 100%;
  resize: vertical;
  min-height: 72px;
  max-height: 220px;
  border: none;
  outline: none;
  background: transparent;
  font: inherit;
  color: var(--ink);
  line-height: 1.45;
}

.composer textarea::placeholder {
  color: rgba(58, 74, 86, 0.7);
}

.composer-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
}

button {
  font: inherit;
  cursor: pointer;
  border-radius: 999px;
  border: 1px solid transparent;
  padding: 0.65rem 1.15rem;
  transition: transform 0.15s ease, background 0.15s ease, opacity 0.15s ease;
}

button:active { transform: translateY(1px); }
button:disabled { opacity: 0.5; cursor: not-allowed; }

.ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--ink-soft);
}

.send {
  background: var(--accent);
  color: #f4fffe;
  font-weight: 600;
}

.send:hover:not(:disabled) {
  background: var(--accent-deep);
}

.foot {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem clamp(1.25rem, 4vw, 3rem) 1.25rem;
  color: var(--ink-soft);
  font-size: 0.8rem;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(138, 75, 22, 0.4); }
  70% { box-shadow: 0 0 0 8px rgba(138, 75, 22, 0); }
  100% { box-shadow: 0 0 0 0 rgba(138, 75, 22, 0); }
}

@media (max-width: 720px) {
  .top { flex-direction: column; align-items: stretch; }
  .transcript { max-height: calc(100vh - 340px); }
  .bubble { max-width: 100%; }
}
