:root {
  color-scheme: dark;
  --bg: #04050a;
  --panel: rgba(10, 12, 20, 0.96);
  --panel-strong: #121725;
  --text: #f4f6fb;
  --muted: #8d97b4;
  --accent: #8d7bff;
  --accent-2: #4fd1c5;
  --border: rgba(255, 255, 255, 0.08);
  --shadow: 0 16px 34px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: 'Inter', sans-serif;
  background: linear-gradient(180deg, #05060b 0%, #080a12 100%);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  overflow: hidden;
}

.app-shell {
  width: min(920px, 100%);
  display: grid;
  gap: 0;
  opacity: 0;
  animation: appEnter 0.75s ease forwards 1.2s;
}

@keyframes appEnter {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.splash-screen {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: #05060b;
  z-index: 20;
  opacity: 1;
  animation: splashFade 1.45s ease forwards;
}

.splash-screen span {
  color: white;
  font-size: clamp(3.25rem, 7vw, 5.5rem);
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  opacity: 0;
  transform: translateY(22px) scale(0.96);
  animation: splashText 1.05s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes splashText {
  0% {
    opacity: 0;
    transform: translateY(22px) scale(0.96);
  }
  55% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes splashFade {
  0%, 72% {
    opacity: 1;
    pointer-events: auto;
  }
  100% {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
  }
}

.chat-card {
  position: relative;
  overflow: hidden;
  min-height: calc(100vh - 48px);
  border-radius: 0;
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 54px;
  height: 54px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: white;
  font-weight: 700;
  letter-spacing: 0.04em;
  box-shadow: 0 10px 24px rgba(139, 124, 255, 0.24);
}

.brand-meta h1 {
  margin: 0 0 4px;
  font-size: 1.15rem;
}

.brand-meta p {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.model-pill {
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(139, 124, 255, 0.14);
  color: #e9e4ff;
  font-weight: 600;
  border: 1px solid rgba(139, 124, 255, 0.24);
}

.chat-card {
  overflow: hidden;
  min-height: calc(100vh - 48px);
  border-radius: 0;
  background: rgba(10, 12, 18, 0.98);
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(12px) scale(0.99);
  animation: cardEnter 0.85s ease forwards 0.1s;
}

@keyframes cardEnter {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.99);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.chat-window {
  min-height: calc(100vh - 196px);
  max-height: none;
  overflow-y: auto;
  padding: 0 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  justify-content: center;
  align-items: center;
}

.chat-card:not(.empty) .chat-window {
  justify-content: flex-start;
  align-items: stretch;
  padding-top: 18px;
}

.message {
  opacity: 0;
  animation: fadeIn 0.28s ease forwards;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.message {
  display: flex;
  max-width: 82%;
}

.message.user {
  margin-left: auto;
  justify-content: flex-end;
}

.message.ai {
  margin-right: auto;
}

.message.user .bubble {
  background: linear-gradient(135deg, var(--accent), #9a6dff);
  color: white;
  border-radius: 20px 20px 4px 20px;
}

.message.ai .bubble {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  border-radius: 20px 20px 20px 4px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.bubble {
  padding: 14px 16px;
  border-radius: 20px;
  max-width: 100%;
  line-height: 1.65;
  font-size: 1rem;
}

.bubble strong {
  display: block;
  margin-bottom: 4px;
}

.bubble p {
  margin: 0;
}

.status-bar {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  top: 26%;
  width: calc(100% - 40px);
  max-width: 830px;
  text-align: center;
  z-index: 1;
  padding: 0;
  opacity: 0;
  animation: statusFadeIn 0.9s ease forwards;
}

@keyframes statusFadeIn {
  from { opacity: 0; transform: translateX(-50%) translateY(-10px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.status-text {
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.6;
}

.composer {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: calc(100% - 36px);
  display: flex;
  gap: 10px;
  padding: 14px 18px 18px;
  background: rgba(2, 3, 7, 0.96);
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  transition: top 0.75s cubic-bezier(0.22, 1, 0.36, 1), transform 0.75s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.35s ease;
  will-change: top, transform, opacity;
  opacity: 1;
}

.composer::before {
  content: '';
  position: absolute;
  top: 0;
  left: 10px;
  right: 10px;
  height: 100%;
  border-radius: 30px;
  background: rgba(255, 255, 255, 0.02);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04);
  pointer-events: none;
}

.chat-card.empty .composer {
  top: 50%;
  transform: translate(-50%, -50%);
}

.chat-card.empty .status-bar {
  top: 32%;
}

.chat-card:not(.empty) .status-bar {
  top: 8px;
}

.chat-card:not(.empty) .composer {
  top: calc(100% - 96px);
  bottom: auto;
  transform: translateX(-50%);
  opacity: 1;
}

.composer input {
  position: relative;
  z-index: 1;
  flex: 1;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  border-radius: 999px;
  padding: 16px 18px;
  outline: none;
  font-size: 0.98rem;
  min-height: 60px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.composer input:focus {
  border-color: rgba(255, 255, 255, 0.2);
  box-shadow: 0 0 0 5px rgba(141, 123, 255, 0.12);
  transform: translateY(-1px);
}

.composer button {
  position: relative;
  z-index: 1;
  width: 56px;
  min-height: 56px;
  border: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: white;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  cursor: pointer;
  transition: transform 0.18s ease, filter 0.18s ease, box-shadow 0.2s ease;
  box-shadow: 0 10px 24px rgba(141, 123, 255, 0.16);
}

.composer button:hover {
  filter: brightness(1.06);
  transform: translateY(-1px);
  box-shadow: 0 12px 28px rgba(141, 123, 255, 0.2);
}

.composer button svg {
  display: block;
}

.typing {
  display: flex;
  gap: 6px;
  align-items: center;
  padding: 6px 0 0 2px;
}

.typing span {
  width: 7px;
  height: 7px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-radius: 50%;
  animation: blink 1s infinite ease-in-out;
}

.typing span:nth-child(2) {
  animation-delay: 0.15s;
}

.typing span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes blink {
  0%, 80%, 100% { transform: scale(0.8); opacity: 0.45; }
  40% { transform: scale(1); opacity: 1; }
}

@media (max-width: 640px) {
  body {
    padding: 12px;
  }

  .splash-screen {
    padding: 22px;
  }

  .splash-screen span {
    font-size: clamp(2.5rem, 18vw, 4rem);
    letter-spacing: 0.12em;
  }

  .chat-card {
    min-height: 100vh;
  }

  .chat-window {
    min-height: calc(100vh - 188px);
    padding: 18px 14px 12px;
  }

  .composer {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    width: calc(100% - 24px);
    padding: 14px 14px 14px;
  }

  .composer input {
    width: auto;
    flex: 1;
    min-width: 0;
  }

  .composer button {
    width: 56px;
    min-height: 56px;
    margin-top: 0;
  }
}