:root {
  --night: #0c090e;
  --ink: rgba(255, 255, 255, 0.88);
  --ink-soft: rgba(255, 255, 255, 0.58);
  --frost: rgba(255, 255, 255, 0.38);
  --sans: "Source Sans 3", system-ui, "Segoe UI", "Helvetica Neue", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--night);
  color: var(--ink);
}

html { color-scheme: dark; }

body {
  min-height: 100dvh;
  font-family: var(--sans);
  font-size: 1.0625rem;
  line-height: 1.55;
  letter-spacing: 0.01em;
}

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

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

.notice {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 4;
  margin: 0;
  padding: 1.2rem 1rem 0;
  text-align: center;
  font-family: var(--sans);
  font-size: 0.68rem;
  font-weight: 400;
  letter-spacing: 0.22em;
  text-transform: lowercase;
  color: rgba(255, 255, 255, 0.28);
}

#app {
  position: relative;
  z-index: 2;
  width: min(100%, 40rem);
  margin: 0 auto;
  min-height: 100dvh;
  padding: 0.6rem 1.25rem 2.25rem;
  padding-bottom: calc(2.25rem + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.1rem;
}

#app.home {
  justify-content: flex-end;
  padding-top: 3.25rem;
  padding-bottom: max(12vh, calc(2.5rem + env(safe-area-inset-bottom)));
  gap: 1.55rem;
}

#app.talking {
  justify-content: flex-end;
  min-height: 100dvh;
  padding-top: 2.8rem;
  padding-bottom: max(12vh, calc(2.5rem + env(safe-area-inset-bottom)));
  gap: 0.7rem;
}

#app.talking::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: linear-gradient(
    to bottom,
    rgba(8, 6, 8, 0.12) 0%,
    rgba(8, 6, 8, 0.38) 42%,
    rgba(8, 6, 10, 0.7) 100%
  );
}

.hero {
  position: relative;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  text-align: center;
}

#app.talking .hero {
  position: absolute;
  top: 2.6rem;
  left: 0;
  right: 0;
  padding: 0.15rem 0 0.1rem;
}

.hero-photo {
  position: fixed;
  inset: 0;
  z-index: 0;
  display: block;
  width: 100vw;
  height: 100dvh;
  max-width: none;
  max-height: none;
  object-fit: cover;
  object-position: center top;
  pointer-events: none;
  background: var(--night);
}

h1 {
  position: relative;
  z-index: 3;
  margin: 0;
  font-family: var(--sans);
  font-weight: 300;
  font-size: clamp(2.6rem, 9vw, 4.4rem);
  letter-spacing: 0.34em;
  line-height: 1;
  color: rgba(176, 208, 230, 0.92);
  text-indent: 0.34em;
  text-transform: uppercase;
}

.hero-photo,
.notice,
h1 {
  opacity: 0;
  visibility: hidden;
  transition: none;
}

body.revealed .hero-photo,
body.revealed .notice,
body.revealed h1 {
  opacity: 1;
  visibility: visible;
  transition: opacity 2.2s ease;
}


.thread {
  position: relative;
  z-index: 2;
  flex: 0 1 auto;
  width: min(100%, 26rem);
  max-height: 28vh;
  min-height: 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0.15rem 0.15rem 0.15rem;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

.messages {
  display: flex;
  flex-direction: column;
  gap: 1.15rem;
  padding-bottom: 0.5rem;
}

.line {
  max-width: 34rem;
  animation: rise 0.55s ease both;
}

.line.user {
  align-self: center;
  text-align: center;
  color: var(--ink-soft);
  font-style: italic;
  font-size: 0.98rem;
  max-width: 100%;
}

.line.agnetha {
  align-self: center;
  text-align: center;
  color: var(--ink);
  font-size: 1.12rem;
  line-height: 1.6;
  max-width: 100%;
}

.line.agnetha p,
.line.user p { margin: 0 0 0.55em; }

.line.agnetha p:last-child,
.line.user p:last-child { margin-bottom: 0; }

.waiting {
  display: inline-flex;
  gap: 0.28rem;
  align-items: center;
  min-height: 1.4em;
  padding-top: 0.15rem;
}

.waiting i {
  width: 0.38rem;
  height: 0.38rem;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.7);
  opacity: 0.35;
  animation: breath 1.4s ease-in-out infinite;
}

.waiting i:nth-child(2) { animation-delay: 0.18s; }
.waiting i:nth-child(3) { animation-delay: 0.36s; }

.composer {
  position: relative;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  width: min(100%, 26rem);
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: 999px;
  padding: 0.18rem 0.18rem 0.18rem 1.05rem;
  box-shadow: none;
}

#app.talking .composer {
  width: min(100%, 26rem);
  margin-top: 0;
}

.composer:focus-within {
  border-color: rgba(255, 255, 255, 0.75);
  outline: none;
}

.composer input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  color: #1a1618;
  font-family: var(--sans);
  font-size: 1.02rem;
  font-weight: 400;
  line-height: 1.3;
  padding: 0.55rem 0.2rem;
  caret-color: #1a1618;
}

.composer input:focus { outline: none; }

.composer input::placeholder { color: rgba(26, 22, 24, 0.32); }

button, input { -webkit-tap-highlight-color: transparent; }

.send {
  flex: none;
  width: 2.35rem;
  height: 2.35rem;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #1a1618;
  display: grid;
  place-items: center;
  cursor: pointer;
}

.send:hover { background: rgba(0, 0, 0, 0.05); }
.send:active { transform: translateY(1px); }
.send:focus-visible { outline: 1px solid rgba(26, 22, 24, 0.35); outline-offset: 2px; }
.send:disabled { opacity: 0.35; cursor: default; }

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

@keyframes breath {
  0%, 100% { opacity: 0.25; transform: translateY(0); }
  50% { opacity: 0.9; transform: translateY(-2px); }
}

@media (min-width: 640px) {
  #app { padding-left: 2rem; padding-right: 2rem; }
  h1 { font-size: clamp(3rem, 6.4vw, 4.6rem); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}

::selection {
  background: rgba(255, 255, 255, 0.22);
  color: #fff;
}
