:root {
  --night: #071018;
  --ink: #f4e7c8;
  --muted: #cbb992;
  --brass: #d4a84b;
  --brass-deep: #8a6420;
  --teal: #1c6f68;
  --terracotta: #b85c38;
  --glass: rgba(10, 18, 24, 0.55);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: #0b1c1d;
  color: var(--ink);
  font-family: "IBM Plex Sans Arabic", "Segoe UI", sans-serif;
}

body {
  overflow: hidden;
}

#world {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 50% 48%, transparent 30%, rgba(8, 24, 24, 0.22) 78%, rgba(8, 24, 24, 0.5) 100%);
}

.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.08;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.55'/%3E%3C/svg%3E");
}

.shell {
  position: relative;
  z-index: 2;
  height: 100dvh;
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  gap: 0.75rem;
  padding: 0.9rem 1.1rem 1.1rem;
  max-width: 760px;
  margin: 0 auto;
  pointer-events: none;
}

.shell > * {
  pointer-events: auto;
}

.brand {
  position: relative;
  z-index: 6;
  text-align: center;
  padding: 0.2rem 0.6rem 0.85rem;
  background: linear-gradient(180deg, rgba(11, 28, 29, 0.55) 0%, rgba(11, 28, 29, 0.18) 55%, transparent 100%);
}

.status {
  position: relative;
  z-index: 6;
  margin: 0 auto;
  width: fit-content;
  max-width: 100%;
  padding: 0.45rem 0.9rem;
  border: 1px solid rgba(212, 168, 75, 0.35);
  background: rgba(8, 16, 22, 0.82);
  border-radius: 999px;
  font-size: 0.92rem;
}

.kicker {
  margin: 0;
  letter-spacing: 0.18em;
  font-size: 0.72rem;
  color: var(--brass);
  text-transform: uppercase;
}

.brand h1 {
  margin: 0.15rem 0 0;
  font-family: "Noto Naskh Arabic", serif;
  font-size: clamp(1.8rem, 4.6vw, 2.8rem);
  font-weight: 700;
  line-height: 1.1;
}

.brand h1 span {
  color: var(--brass);
}

.tag {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-weight: 300;
}

.status.listening {
  border-color: #7ee0d3;
  background: rgba(28, 111, 104, 0.4);
}

.status.thinking {
  border-color: var(--brass);
}

.status.speaking {
  border-color: var(--terracotta);
  background: rgba(184, 92, 56, 0.25);
}

.log {
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 0.2rem 0.1rem 0.6rem;
}

.bubble {
  max-width: 92%;
  padding: 0.9rem 1rem;
  border-radius: 1.1rem;
  background: var(--glass);
  border: 1px solid rgba(244, 231, 200, 0.12);
  backdrop-filter: blur(10px);
  line-height: 1.7;
  white-space: pre-wrap;
}

.bubble.user {
  align-self: start;
  background: rgba(28, 111, 104, 0.28);
}

.bubble.assistant {
  align-self: end;
  border-color: rgba(212, 168, 75, 0.28);
}

.bubble small {
  display: block;
  margin-bottom: 0.25rem;
  color: var(--brass);
  font-size: 0.75rem;
}

.composer {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.65rem;
  align-items: center;
  padding: 0.65rem;
  border-radius: 1.6rem;
  background: rgba(8, 16, 22, 0.72);
  border: 1px solid rgba(212, 168, 75, 0.28);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
}

.mic {
  position: relative;
  width: 64px;
  height: 64px;
  border: 0;
  border-radius: 50%;
  color: var(--night);
  background: radial-gradient(circle at 35% 30%, #f3d27a, var(--brass) 42%, var(--brass-deep));
  cursor: pointer;
}

.mic svg {
  width: 26px;
  height: 26px;
}

.mic-ring {
  position: absolute;
  inset: -7px;
  border-radius: 50%;
  border: 1px solid rgba(212, 168, 75, 0.5);
  animation: pulse 2.4s ease-out infinite;
}

.mic.active .mic-ring {
  animation-duration: 0.9s;
  border-color: #7ee0d3;
}

.field {
  min-width: 0;
}

.field input {
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  outline: none;
  padding: 0.4rem 0.2rem;
}

.send {
  border: 0;
  border-radius: 999px;
  padding: 0.7rem 1.1rem;
  background: var(--teal);
  color: var(--ink);
  font: inherit;
  cursor: pointer;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

@keyframes pulse {
  0% {
    transform: scale(0.92);
    opacity: 0.9;
  }
  100% {
    transform: scale(1.18);
    opacity: 0;
  }
}

@media (max-width: 640px) {
  .composer {
    grid-template-columns: auto 1fr;
  }

  .send {
    grid-column: 1 / -1;
  }
}
