:root {
  --ink: #14201a;
  --ink-soft: #3d4f45;
  --paper: #f3efe4;
  --panel: rgba(255, 252, 245, 0.78);
  --line: rgba(20, 32, 26, 0.12);
  --accent: #0f7a5a;
  --accent-deep: #0a5340;
  --amber: #c9782a;
  --user: #17352b;
  --shadow: 0 18px 50px rgba(20, 32, 26, 0.12);
  --radius: 22px;
  --font-display: "Syne", "Noto Sans SC", sans-serif;
  --font-body: "DM Sans", "Noto Sans SC", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  color: var(--ink);
  font-family: var(--font-body);
  background: var(--paper);
  overflow-x: hidden;
}

.atmosphere {
  position: fixed;
  inset: 0;
  z-index: -2;
  background:
    radial-gradient(900px 500px at 12% -10%, rgba(15, 122, 90, 0.28), transparent 60%),
    radial-gradient(700px 480px at 88% 8%, rgba(201, 120, 42, 0.22), transparent 55%),
    linear-gradient(160deg, #efe8d7 0%, #f6f1e6 42%, #e7efe8 100%),
    url("data:image/svg+xml,%3Csvg width='160' height='160' viewBox='0 0 160 160' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' stroke='%2314201a' stroke-opacity='0.035' stroke-width='1'%3E%3Cpath d='M0 40h160M0 80h160M0 120h160M40 0v160M80 0v160M120 0v160'/%3E%3C/g%3E%3C/svg%3E");
}

.grain {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0.18;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.55'/%3E%3C/svg%3E");
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.25rem;
  backdrop-filter: blur(14px);
  background: rgba(243, 239, 228, 0.72);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: inherit;
}

.brand-mark {
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 0.7rem;
  background:
    linear-gradient(145deg, #1aa37a, #0f7a5a 55%, #0a5340),
    radial-gradient(circle at 30% 25%, rgba(255, 255, 255, 0.45), transparent 40%);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.25);
  animation: pulse 4.5s ease-in-out infinite;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.brand-text strong {
  font-family: var(--font-display);
  font-size: 1.05rem;
  letter-spacing: 0.02em;
}

.brand-text small {
  color: var(--ink-soft);
  font-size: 0.75rem;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.model-picker {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--ink-soft);
  font-size: 0.82rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.model-picker label {
  font-weight: 600;
}

.model-picker select {
  appearance: none;
  border: 1px solid var(--line);
  background: rgba(255, 252, 245, 0.9)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%233d4f45' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E")
    no-repeat right 0.7rem center;
  color: var(--ink);
  border-radius: 999px;
  padding: 0.55rem 2rem 0.55rem 0.9rem;
  font: inherit;
  min-width: min(58vw, 240px);
  max-width: min(70vw, 320px);
  cursor: pointer;
}

.model-picker select:disabled {
  opacity: 0.7;
  cursor: wait;
}

.model-status {
  font-size: 0.72rem;
  color: var(--ink-soft);
  max-width: 12rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.model-status.error {
  color: #8a2f1f;
}

.icon-btn {
  padding-inline: 0.8rem;
}

.ghost-btn {
  border: 1px solid var(--line);
  background: rgba(255, 252, 245, 0.7);
  color: var(--ink-soft);
  border-radius: 999px;
  padding: 0.55rem 0.95rem;
  font: inherit;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.ghost-btn:hover {
  background: #fff;
  color: var(--ink);
  transform: translateY(-1px);
}

.stage {
  width: min(860px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 1.5rem 0 9rem;
  min-height: calc(100vh - 5rem);
}

.hero {
  text-align: center;
  padding: 3.5rem 0 2rem;
  animation: rise 0.7s ease both;
}

.hero.hidden {
  display: none;
}

.eyebrow {
  display: inline-block;
  margin: 0 0 0.85rem;
  color: var(--accent-deep);
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.hero h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(2.8rem, 8vw, 4.6rem);
  letter-spacing: -0.03em;
  line-height: 0.95;
}

.lede {
  margin: 1rem auto 0;
  max-width: 28rem;
  color: var(--ink-soft);
  font-size: 1.05rem;
  line-height: 1.6;
}

.suggestions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.65rem;
  margin-top: 1.75rem;
}

.suggestions button {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  border-radius: 999px;
  padding: 0.7rem 1rem;
  font: inherit;
  cursor: pointer;
  backdrop-filter: blur(8px);
  transition: transform 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.suggestions button:hover {
  transform: translateY(-2px);
  border-color: rgba(15, 122, 90, 0.35);
  background: #fff;
}

.transcript {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.msg {
  max-width: min(100%, 680px);
  padding: 1rem 1.15rem;
  border-radius: var(--radius);
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
  animation: rise 0.35s ease both;
  box-shadow: var(--shadow);
}

.msg.user {
  align-self: flex-end;
  background: linear-gradient(160deg, #1d4638, var(--user));
  color: #f4faf7;
  border-bottom-right-radius: 0.55rem;
}

.msg.assistant {
  align-self: flex-start;
  background: var(--panel);
  border: 1px solid var(--line);
  backdrop-filter: blur(10px);
  border-bottom-left-radius: 0.55rem;
}

.msg.assistant.error {
  border-color: rgba(180, 60, 40, 0.35);
  color: #8a2f1f;
}

.msg .meta {
  display: block;
  margin-bottom: 0.35rem;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.7;
}

.typing::after {
  content: "";
  display: inline-block;
  width: 0.55em;
  height: 1.05em;
  margin-left: 0.15em;
  vertical-align: text-bottom;
  background: currentColor;
  animation: blink 1s steps(1) infinite;
}

.composer-wrap {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 0.75rem 1rem 1rem;
  background: linear-gradient(180deg, transparent, rgba(243, 239, 228, 0.92) 28%, #f3efe4);
}

.composer {
  width: min(860px, 100%);
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.65rem;
  align-items: end;
  padding: 0.65rem;
  border: 1px solid var(--line);
  border-radius: 1.35rem;
  background: rgba(255, 252, 245, 0.92);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.composer textarea {
  resize: none;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  line-height: 1.5;
  max-height: 160px;
  padding: 0.55rem 0.65rem;
}

.composer button[type="submit"] {
  width: 2.8rem;
  height: 2.8rem;
  border: 0;
  border-radius: 1rem;
  background: linear-gradient(160deg, #1aa37a, var(--accent-deep));
  color: #fff;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: transform 0.2s ease, filter 0.2s ease;
}

.composer button[type="submit"]:hover:not(:disabled) {
  transform: translateY(-1px) scale(1.02);
}

.composer button[type="submit"]:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.footnote {
  width: min(860px, 100%);
  margin: 0.55rem auto 0;
  text-align: center;
  color: var(--ink-soft);
  font-size: 0.75rem;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes blink {
  50% {
    opacity: 0;
  }
}

@keyframes pulse {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.04);
  }
}

@media (max-width: 640px) {
  .stage {
    padding-top: 0.75rem;
  }

  .hero {
    padding-top: 2rem;
  }

  .msg {
    max-width: 100%;
  }
}
