:root {
  --bg: #0a0810;
  --bg2: #12101a;
  --line: rgba(255, 200, 220, 0.12);
  --text: #f4eef2;
  --muted: #9a8f98;
  --rose: #ff6b9d;
  --rose-dim: rgba(255, 107, 157, 0.18);
  --violet: #a78bfa;
  --user: #1c1624;
  --luna: #16121f;
  --radius: 18px;
  --font: "DM Sans", system-ui, sans-serif;
  --serif: "Instrument Serif", Georgia, serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font);
  background: radial-gradient(1200px 600px at 10% -10%, #2a1528 0%, transparent 55%),
    radial-gradient(900px 500px at 100% 0%, #1a1430 0%, transparent 50%),
    var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

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

.top {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
  background: rgba(10, 8, 16, 0.72);
}

.brand { display: flex; gap: 0.85rem; align-items: center; }
.mark {
  width: 2.75rem;
  height: 2.75rem;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--rose-dim);
  color: var(--rose);
  font-size: 1.1rem;
  box-shadow: 0 0 40px rgba(255, 107, 157, 0.25);
}
.brand h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.65rem;
  font-weight: 400;
  letter-spacing: 0.02em;
}
.brand p { margin: 0.1rem 0 0; color: var(--muted); font-size: 0.8rem; }

.controls { display: flex; gap: 0.75rem; align-items: flex-end; }
.field { display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.7rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }
select, textarea, button {
  font: inherit;
  color: inherit;
}
select {
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.45rem 0.75rem;
  min-width: 11rem;
}
.ghost {
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.5rem 0.9rem;
  cursor: pointer;
}
.ghost:hover { border-color: var(--rose); color: var(--rose); }

.layout {
  flex: 1;
  display: flex;
  flex-direction: column;
  max-width: 52rem;
  width: 100%;
  margin: 0 auto;
  padding: 1rem 1.25rem 0.5rem;
  position: relative;
  z-index: 1;
}

.thread {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  padding-bottom: 1rem;
  scroll-behavior: smooth;
}

.bubble {
  max-width: 92%;
  padding: 0.85rem 1rem;
  border-radius: var(--radius);
  line-height: 1.55;
  font-size: 0.95rem;
  white-space: pre-wrap;
  word-break: break-word;
  animation: rise 0.35s ease;
}
@keyframes rise {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}
.bubble.user {
  align-self: flex-end;
  background: var(--user);
  border: 1px solid var(--line);
}
.bubble.luna {
  align-self: flex-start;
  background: linear-gradient(135deg, var(--luna), #1a1326);
  border: 1px solid rgba(167, 139, 250, 0.2);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
}
.bubble .tag {
  display: block;
  font-family: var(--serif);
  font-style: italic;
  color: var(--rose);
  margin-bottom: 0.35rem;
  font-size: 1.05rem;
}
.thought {
  margin-top: 0.5rem;
  padding: 0.55rem 0.7rem;
  border-left: 2px solid var(--violet);
  color: var(--muted);
  font-size: 0.82rem;
  background: rgba(167, 139, 250, 0.06);
  border-radius: 0 8px 8px 0;
}

.composer {
  display: flex;
  gap: 0.6rem;
  align-items: flex-end;
  padding: 0.75rem 0 1rem;
  border-top: 1px solid var(--line);
}
.composer textarea {
  flex: 1;
  resize: none;
  min-height: 2.75rem;
  max-height: 10rem;
  padding: 0.75rem 1rem;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--bg2);
  outline: none;
}
.composer textarea:focus {
  border-color: rgba(255, 107, 157, 0.45);
  box-shadow: 0 0 0 3px var(--rose-dim);
}
#send {
  border: none;
  border-radius: 14px;
  padding: 0.75rem 1.15rem;
  background: linear-gradient(135deg, var(--rose), #c44d7a);
  color: #1a0810;
  font-weight: 600;
  cursor: pointer;
}
#send:disabled { opacity: 0.45; cursor: not-allowed; }

.foot {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: space-between;
  padding: 0.6rem 1.25rem 1rem;
  color: var(--muted);
  font-size: 0.78rem;
  border-top: 1px solid var(--line);
  background: rgba(10, 8, 16, 0.85);
}
.foot a { color: var(--violet); text-decoration: none; }
.foot a:hover { text-decoration: underline; }