:root {
  color-scheme: dark;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  background: #080b12;
  color: #eef3ff;
  --bg: #080b12;
  --panel: rgba(13, 18, 30, 0.84);
  --panel-strong: rgba(18, 25, 40, 0.96);
  --border: rgba(159, 177, 210, 0.18);
  --muted: #9aa8bf;
  --text: #eef3ff;
  --ai: #151d2c;
  --user: #f2f6ff;
  --user-text: #101521;
  --accent: #78e6d0;
  --accent-strong: #4cb7ff;
  --danger: #ff7b91;
  --shadow: 0 28px 90px rgba(0, 0, 0, 0.34);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 15% -10%, rgba(76, 183, 255, 0.22), transparent 34rem),
    radial-gradient(circle at 92% 0%, rgba(120, 230, 208, 0.12), transparent 30rem),
    linear-gradient(145deg, #080b12 0%, #0c111d 48%, #05070c 100%);
}

button,
textarea {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  width: min(960px, calc(100vw - 32px));
  height: min(860px, calc(100vh - 32px));
  min-height: 560px;
  margin: 16px auto;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.055), transparent 18rem),
    var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px);
}

.app-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 24px 26px 20px;
  border-bottom: 1px solid var(--border);
  background: rgba(7, 10, 17, 0.38);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(2rem, 6vw, 4rem);
  line-height: 0.96;
  letter-spacing: 0;
}

.tagline {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 1rem;
}

.status-pill {
  flex: 0 0 auto;
  max-width: 180px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.055);
  font-size: 0.82rem;
  white-space: nowrap;
}

.status-pill.is-active {
  color: var(--accent);
  border-color: rgba(120, 230, 208, 0.34);
}

.status-pill.is-error {
  color: var(--danger);
  border-color: rgba(255, 123, 145, 0.36);
}

.chat-panel {
  min-height: 0;
  background:
    linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px);
  background-size: 42px 42px;
}

.message-list {
  height: 100%;
  overflow-y: auto;
  padding: 24px 26px;
  scrollbar-color: rgba(160, 180, 210, 0.42) transparent;
}

.message {
  display: grid;
  gap: 6px;
  max-width: min(78%, 680px);
  margin-bottom: 18px;
}

.message-user {
  margin-left: auto;
  justify-items: end;
}

.message-ai {
  margin-right: auto;
  justify-items: start;
}

.message-meta {
  color: var(--muted);
  font-size: 0.76rem;
}

.bubble {
  width: fit-content;
  max-width: 100%;
  padding: 13px 15px;
  border: 1px solid var(--border);
  border-radius: 16px;
  line-height: 1.5;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.message-ai .bubble {
  background: var(--ai);
  border-top-left-radius: 4px;
}

.message-user .bubble {
  color: var(--user-text);
  background: var(--user);
  border-color: rgba(255, 255, 255, 0.5);
  border-top-right-radius: 4px;
}

.message.is-pending .bubble::after {
  content: "";
  display: inline-block;
  width: 0.5em;
  height: 1em;
  margin-left: 3px;
  border-right: 2px solid var(--accent);
  transform: translateY(2px);
  animation: caret 0.9s steps(1) infinite;
}

.composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  padding: 18px;
  border-top: 1px solid var(--border);
  background: var(--panel-strong);
}

textarea {
  width: 100%;
  max-height: 160px;
  resize: none;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 13px 14px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
  outline: none;
  line-height: 1.35;
}

textarea:focus {
  border-color: rgba(120, 230, 208, 0.52);
  box-shadow: 0 0 0 4px rgba(120, 230, 208, 0.11);
}

textarea:disabled {
  cursor: not-allowed;
  opacity: 0.68;
}

button {
  min-width: 88px;
  border: 0;
  border-radius: 14px;
  padding: 0 18px;
  color: #061016;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  font-weight: 800;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  filter: grayscale(0.45);
  opacity: 0.58;
}

.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 caret {
  50% {
    opacity: 0;
  }
}

@media (max-width: 640px) {
  .app-shell {
    width: 100vw;
    height: 100vh;
    min-height: 100vh;
    margin: 0;
    border: 0;
    border-radius: 0;
  }

  .app-header {
    padding: 20px 18px 18px;
  }

  .status-pill {
    display: none;
  }

  .message-list {
    padding: 18px;
  }

  .message {
    max-width: 88%;
  }

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

  button {
    min-height: 46px;
  }
}
