:root {
  color-scheme: dark;
  --bg: #090a0f;
  --panel: #10131b;
  --panel-strong: #151a24;
  --line: rgba(255, 255, 255, 0.09);
  --text: #f2f5f8;
  --muted: #93a0af;
  --accent: #5eead4;
  --user: #2563eb;
  --hermes: #1d2430;
  --danger: #fb7185;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(94, 234, 212, 0.14), transparent 34rem),
    linear-gradient(145deg, #090a0f 0%, #111827 48%, #0b0f17 100%);
  color: var(--text);
}

button,
textarea {
  font: inherit;
}

.shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.chat {
  width: min(880px, 100%);
  height: min(780px, calc(100vh - 48px));
  min-height: 520px;
  display: grid;
  grid-template-rows: auto 1fr auto;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(16, 19, 27, 0.88);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.38);
  backdrop-filter: blur(18px);
  animation: rise 420ms ease-out both;
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(21, 26, 36, 0.82);
}

.chat-header h1 {
  margin: 0;
  font-size: 1.05rem;
  line-height: 1.2;
  letter-spacing: 0;
}

.chat-header p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.status {
  width: 11px;
  height: 11px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 0 6px rgba(94, 234, 212, 0.12), 0 0 24px rgba(94, 234, 212, 0.55);
}

.messages {
  overflow-y: auto;
  padding: 24px;
  scroll-behavior: smooth;
}

.message {
  display: flex;
  margin: 0 0 14px;
  animation: fade-in 180ms ease-out both;
}

.message.user {
  justify-content: flex-end;
}

.message.hermes {
  justify-content: flex-start;
}

.bubble {
  max-width: min(680px, 82%);
  padding: 13px 15px;
  border: 1px solid var(--line);
  border-radius: 16px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.48;
  font-size: 0.96rem;
}

.user .bubble {
  border-bottom-right-radius: 5px;
  background: linear-gradient(145deg, var(--user), #1d4ed8);
  color: white;
}

.hermes .bubble {
  border-bottom-left-radius: 5px;
  background: var(--hermes);
  color: var(--text);
}

.bubble.error {
  border-color: rgba(251, 113, 133, 0.45);
  color: #fecdd3;
}

.composer {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  padding: 16px;
  border-top: 1px solid var(--line);
  background: rgba(21, 26, 36, 0.92);
}

textarea {
  width: 100%;
  max-height: 150px;
  resize: none;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 13px 14px;
  outline: none;
  background: #0b0f17;
  color: var(--text);
  line-height: 1.4;
}

textarea:focus {
  border-color: rgba(94, 234, 212, 0.58);
  box-shadow: 0 0 0 4px rgba(94, 234, 212, 0.09);
}

button {
  min-width: 82px;
  border: 0;
  border-radius: 14px;
  padding: 0 18px;
  background: var(--accent);
  color: #042f2e;
  font-weight: 700;
  cursor: pointer;
  transition: transform 150ms ease, opacity 150ms ease;
}

button:hover {
  transform: translateY(-1px);
}

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

.dots {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-width: 42px;
}

.dots span {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--muted);
  animation: pulse 900ms infinite ease-in-out;
}

.dots span:nth-child(2) {
  animation-delay: 120ms;
}

.dots span:nth-child(3) {
  animation-delay: 240ms;
}

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

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

@keyframes pulse {
  0%,
  80%,
  100% {
    opacity: 0.35;
    transform: translateY(0);
  }
  40% {
    opacity: 1;
    transform: translateY(-3px);
  }
}

@media (max-width: 640px) {
  .shell {
    padding: 0;
  }

  .chat {
    height: 100vh;
    min-height: 100vh;
    border: 0;
    border-radius: 0;
  }

  .messages {
    padding: 18px 14px;
  }

  .bubble {
    max-width: 88%;
  }

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

  button {
    height: 44px;
  }
}
