:root {
  color-scheme: dark;
  --ink: #e7f0ea;
  --muted: #8fa398;
  --paper: #0d1411;
  --panel: rgba(18, 28, 23, 0.82);
  --line: rgba(231, 240, 234, 0.12);
  --signal: #2dd4a0;
  --signal-deep: #1fad82;
  --warn: #e08a55;
  --shadow: 0 22px 60px rgba(0, 0, 0, 0.45);
  --bubble: rgba(231, 240, 234, 0.05);
  --bubble-mine: rgba(45, 212, 160, 0.14);
  --radius: 18px;
  --font-display: "Syne", sans-serif;
  --font-body: "IBM Plex Sans", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  color: var(--ink);
  font-family: var(--font-body);
  background:
    radial-gradient(900px 520px at 10% -12%, rgba(45, 212, 160, 0.16), transparent 55%),
    radial-gradient(720px 460px at 100% 8%, rgba(34, 80, 62, 0.35), transparent 52%),
    linear-gradient(165deg, #0a100e 0%, #101a16 42%, #0c1411 100%);
}

.noise {
  pointer-events: none;
  position: fixed;
  inset: 0;
  opacity: 0.055;
  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.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  z-index: 0;
}

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

.top {
  display: grid;
  gap: 1rem;
  animation: rise 0.55s ease both;
}

.brand .mark {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 800;
  letter-spacing: -0.04em;
  font-size: clamp(1.8rem, 5vw, 2.5rem);
  line-height: 0.95;
  color: #f3faf6;
}

.brand h1 {
  margin: 0.35rem 0 0;
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.lede {
  margin: 0.35rem 0 0;
  color: var(--muted);
  max-width: 34ch;
  line-height: 1.4;
}

.nick-field {
  display: grid;
  gap: 0.35rem;
  max-width: 280px;
}

.nick-field span {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

input,
textarea,
button {
  font: inherit;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--panel);
  backdrop-filter: blur(8px);
  border-radius: 12px;
  padding: 0.75rem 0.9rem;
  color: var(--ink);
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input::placeholder,
textarea::placeholder {
  color: rgba(143, 163, 152, 0.75);
}

input:focus,
textarea:focus {
  border-color: rgba(45, 212, 160, 0.55);
  box-shadow: 0 0 0 3px rgba(45, 212, 160, 0.16);
}

.stage {
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
  display: grid;
  grid-template-rows: 1fr auto;
  overflow: hidden;
  animation: rise 0.7s ease both;
}

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

.msg {
  display: grid;
  gap: 0.2rem;
  max-width: 92%;
  animation: fade-in 0.28s ease both;
}

.msg.mine {
  margin-left: auto;
  text-align: right;
}

.msg .meta {
  display: flex;
  gap: 0.5rem;
  align-items: baseline;
  font-size: 0.78rem;
  color: var(--muted);
}

.msg.mine .meta {
  justify-content: flex-end;
}

.msg .nick {
  font-weight: 600;
  color: var(--signal);
}

.msg .bubble {
  display: inline-block;
  padding: 0.65rem 0.85rem;
  border-radius: 14px;
  background: var(--bubble);
  border: 1px solid var(--line);
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.4;
}

.msg.mine .bubble {
  background: var(--bubble-mine);
  border-color: rgba(45, 212, 160, 0.28);
}

.empty {
  margin: auto;
  color: var(--muted);
  text-align: center;
  padding: 2rem 1rem;
}

.status {
  margin: 0;
  padding: 0.55rem 0.9rem;
  border-top: 1px solid var(--line);
  font-size: 0.85rem;
  color: var(--warn);
  background: rgba(224, 138, 85, 0.1);
}

.composer {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.65rem;
  align-items: end;
  animation: rise 0.85s ease both;
}

textarea {
  resize: none;
  min-height: 3.2rem;
}

button {
  border: 0;
  border-radius: 12px;
  padding: 0.85rem 1.1rem;
  background: var(--signal);
  color: #062117;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.2s ease, opacity 0.2s ease;
}

button:hover {
  background: var(--signal-deep);
  color: #03140e;
}

button:active {
  transform: translateY(1px);
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

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

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

@keyframes fade-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@media (max-width: 640px) {
  .app {
    padding: 0.9rem 0.75rem 0.75rem;
  }

  .composer {
    grid-template-columns: 1fr;
  }

  button {
    width: 100%;
  }
}
