:root {
  --ink: #121a1f;
  --ink-soft: #3a4a52;
  --paper: #eef2f1;
  --paper-2: #e2e8e6;
  --accent: #0d6b5c;
  --accent-2: #1f6f8b;
  --line: rgba(18, 26, 31, 0.12);
  --shadow: 0 24px 60px rgba(18, 26, 31, 0.12);
  --radius: 18px;
  --font-display: "Instrument Serif", Georgia, serif;
  --font-body: "Manrope", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  color: var(--ink);
  font-family: var(--font-body);
  background: var(--paper);
  overflow: hidden;
}

.bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(900px 500px at 12% -10%, rgba(13, 107, 92, 0.16), transparent 60%),
    radial-gradient(700px 420px at 100% 0%, rgba(31, 111, 139, 0.14), transparent 55%),
    linear-gradient(165deg, #f2f5f4 0%, #e8eeec 48%, #dde5e2 100%);
}
.bg::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.35;
  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.45'/%3E%3C/svg%3E");
  pointer-events: none;
}

.app {
  position: relative;
  z-index: 1;
  height: 100%;
  max-width: 880px;
  margin: 0 auto;
  display: grid;
  grid-template-rows: auto 1fr auto;
  padding: 0 1rem;
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem 0.25rem 0.75rem;
  animation: fade-down 0.6s ease both;
}
.brand { display: flex; align-items: baseline; gap: 0.55rem; }
.logo {
  font-family: var(--font-display);
  font-size: 1.65rem;
  letter-spacing: -0.02em;
  color: var(--ink);
  text-decoration: none;
}
.product {
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}
.top-actions { display: flex; gap: 0.4rem; }

.stage {
  overflow: auto;
  padding: 0.5rem 0 1rem;
  scroll-behavior: smooth;
}

.hero {
  min-height: min(58vh, 520px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  gap: 0.85rem;
  padding: 1rem 0.2rem 2rem;
  animation: rise 0.7s ease both;
}
.brand-hero {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(3.2rem, 10vw, 5.6rem);
  line-height: 0.92;
  letter-spacing: -0.03em;
  font-weight: 400;
}
.lede {
  margin: 0;
  max-width: 34rem;
  font-size: 1.05rem;
  line-height: 1.5;
  color: var(--ink-soft);
}
.suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin-top: 0.6rem;
}
.suggestions button {
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.45);
  backdrop-filter: blur(8px);
  color: var(--ink);
  border-radius: 999px;
  padding: 0.55rem 0.9rem;
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}
.suggestions button:hover {
  transform: translateY(-1px);
  background: rgba(255,255,255,0.75);
  border-color: rgba(15, 110, 86, 0.35);
}

.thread {
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
  padding: 0.5rem 0.15rem 1.5rem;
}
.msg {
  max-width: 92%;
  animation: rise 0.35s ease both;
}
.msg.user { align-self: flex-end; }
.msg.assistant { align-self: flex-start; }
.msg .bubble {
  padding: 0.9rem 1.05rem;
  border-radius: var(--radius);
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.98rem;
}
.msg.user .bubble {
  background: var(--ink);
  color: #f6f1e8;
  border-bottom-right-radius: 6px;
}
.msg.assistant .bubble {
  background: rgba(255,255,255,0.62);
  border: 1px solid var(--line);
  border-bottom-left-radius: 6px;
  box-shadow: var(--shadow);
}
.msg .meta {
  margin-top: 0.35rem;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: rgba(16,35,31,0.55);
}
.msg.user .meta { text-align: right; }
.thinking {
  margin-bottom: 0.65rem;
  padding: 0.65rem 0.75rem;
  border-left: 3px solid rgba(31, 111, 139, 0.55);
  color: rgba(18, 26, 31, 0.72);
  font-size: 0.88rem;
  background: rgba(31, 111, 139, 0.07);
  border-radius: 0 10px 10px 0;
}
.cursor {
  display: inline-block;
  width: 0.45em;
  height: 1em;
  margin-left: 2px;
  background: var(--accent);
  vertical-align: text-bottom;
  animation: blink 1s steps(1) infinite;
}

.composer-wrap {
  padding: 0.4rem 0 1rem;
  animation: fade-up 0.55s ease both;
}
.composer {
  background: rgba(255,255,255,0.72);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow);
  padding: 0.75rem 0.85rem 0.65rem;
  backdrop-filter: blur(10px);
}
.composer textarea {
  width: 100%;
  border: 0;
  resize: none;
  outline: none;
  background: transparent;
  font: inherit;
  font-size: 1rem;
  line-height: 1.45;
  max-height: 180px;
  color: var(--ink);
}
.composer-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 0.35rem;
}
.toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.82rem;
  color: var(--ink-soft);
  cursor: pointer;
  user-select: none;
}
.toggle input { accent-color: var(--accent); }

.send, .ghost {
  font: inherit;
  cursor: pointer;
  border-radius: 999px;
  border: 0;
}
.send {
  background: var(--accent);
  color: #f4fff9;
  font-weight: 600;
  padding: 0.55rem 1.05rem;
  transition: transform 0.15s ease, background 0.15s ease, opacity 0.15s ease;
}
.send:hover { background: #0c5c48; transform: translateY(-1px); }
.send:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink-soft);
  padding: 0.4rem 0.75rem;
  font-size: 0.85rem;
  font-weight: 600;
}
.ghost:hover { background: rgba(255,255,255,0.5); color: var(--ink); }

.fineprint {
  margin: 0.55rem 0 0;
  text-align: center;
  font-size: 0.75rem;
  color: rgba(16,35,31,0.5);
}

.sheet {
  border: 0;
  border-radius: 20px;
  padding: 0;
  width: min(420px, calc(100vw - 2rem));
  background: #f8f4eb;
  box-shadow: var(--shadow);
}
.sheet::backdrop { background: rgba(16, 35, 31, 0.35); backdrop-filter: blur(3px); }
.sheet-inner {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  padding: 1.25rem 1.2rem 1.1rem;
}
.sheet h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.8rem;
  font-weight: 400;
}
.sheet label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink-soft);
}
.sheet input {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.7rem 0.8rem;
  font: inherit;
  font-weight: 500;
  background: #fff;
  color: var(--ink);
}
.sheet-actions { display: flex; gap: 0.5rem; margin-top: 0.25rem; }
.hint { margin: 0; font-size: 0.75rem; color: rgba(16,35,31,0.5); font-weight: 500; }

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

.hero[hidden],
[hidden] {
  display: none !important;
}

.error-banner {
  margin: 0.5rem 0;
  padding: 0.75rem 0.9rem;
  border-radius: 12px;
  background: rgba(196, 92, 38, 0.12);
  border: 1px solid rgba(196, 92, 38, 0.3);
  color: #7a3212;
  font-size: 0.9rem;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes fade-down {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes fade-up {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes blink {
  0%, 50% { opacity: 1; }
  50.01%, 100% { opacity: 0; }
}

@media (max-width: 640px) {
  .brand-hero { font-size: 3rem; }
  .msg { max-width: 100%; }
}
