:root {
  --background: #121212;
  --surface: #1a1a1a;
  --surface-elevated: #242424;
  --surface-user: #2f2f2f;
  --border: #2a2a2a;
  --text-primary: #ececec;
  --text-secondary: #8e8e8e;
  --accent: #10a37f;
  --danger: #ff6b6b;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.24);
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: dark;
  background: var(--background);
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top, rgba(16, 163, 127, 0.1), transparent 26%),
    linear-gradient(180deg, #141414 0%, var(--background) 22%, var(--background) 100%);
  color: var(--text-primary);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
textarea,
input {
  font: inherit;
}

button {
  border: 0;
}

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

.app-shell {
  min-height: 100vh;
}

.chat-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: min(100%, 720px);
  margin: 0 auto;
  padding: 24px 20px 18px;
  backdrop-filter: blur(16px);
  background: linear-gradient(180deg, rgba(18, 18, 18, 0.96) 0%, rgba(18, 18, 18, 0.82) 100%);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  box-shadow: var(--shadow);
}

.brand h1 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.brand p {
  margin: 2px 0 0;
  color: var(--text-secondary);
  font-size: 13px;
}

.header-action {
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
  cursor: pointer;
  transition: background-color 180ms ease, transform 180ms ease;
}

.header-action:hover {
  background: rgba(255, 255, 255, 0.08);
  transform: translateY(-1px);
}

.chat-main {
  width: min(100%, 720px);
  margin: 0 auto;
  padding: 8px 20px 188px;
}

.chat-frame {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.prompt-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.prompt-chip {
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-secondary);
  cursor: pointer;
  transition: background-color 180ms ease, color 180ms ease, transform 180ms ease;
}

.prompt-chip:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
  transform: translateY(-1px);
}

.status-line {
  min-height: 18px;
  color: var(--text-secondary);
  font-size: 13px;
}

.messages {
  display: flex;
  flex-direction: column;
  gap: 26px;
  padding-bottom: 24px;
}

.message {
  display: flex;
  gap: 12px;
  opacity: 0;
  transform: translateY(4px);
  animation: message-in 200ms ease forwards;
}

.message.assistant,
.message.streaming {
  align-items: flex-start;
}

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

.message.system {
  justify-content: center;
}

.message-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  flex: 0 0 30px;
  margin-top: 2px;
}

.message-card {
  max-width: min(100%, 620px);
}

.message.assistant .message-card,
.message.streaming .message-card {
  padding: 4px 0;
  color: var(--text-primary);
}

.message.user .message-card {
  max-width: min(100%, 520px);
  padding: 14px 16px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 20px;
  border-bottom-right-radius: 8px;
  background: var(--surface-user);
  box-shadow: var(--shadow);
}

.message.system .message-card {
  padding: 10px 14px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-secondary);
  text-align: center;
  font-size: 14px;
}

.message-text {
  white-space: pre-wrap;
  word-break: break-word;
}

.message-markdown {
  color: var(--text-primary);
}

.message-markdown > :first-child {
  margin-top: 0;
}

.message-markdown > :last-child {
  margin-bottom: 0;
}

.message-markdown p,
.message-markdown ul,
.message-markdown ol {
  margin: 0 0 12px;
  line-height: 1.65;
}

.message-markdown ul,
.message-markdown ol {
  padding-left: 20px;
}

.message-markdown li + li {
  margin-top: 6px;
}

.message-markdown strong {
  font-weight: 600;
}

.message-markdown a {
  color: #8fdccb;
}

.attachment-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.attachment-chip {
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-secondary);
  font-size: 12px;
}

.typing-indicator {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  padding: 10px 0 6px;
}

.typing-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-secondary);
  animation: typing-pulse 1s infinite ease-in-out;
}

.typing-dot:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
  animation-delay: 0.4s;
}

.stream-cursor {
  display: inline-block;
  margin-left: 2px;
  color: var(--text-secondary);
  animation: cursor-blink 1s steps(2, start) infinite;
}

.composer-shell {
  position: fixed;
  inset: auto 0 0;
  z-index: 30;
  padding: 20px;
  background: linear-gradient(180deg, rgba(18, 18, 18, 0) 0%, rgba(18, 18, 18, 0.92) 32%, rgba(18, 18, 18, 1) 100%);
}

.composer {
  width: min(100%, 720px);
  margin: 0 auto;
}

.attachment-preview {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.03);
}

.attachment-thumb {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  object-fit: cover;
  flex: 0 0 52px;
}

.attachment-meta {
  flex: 1;
  min-width: 0;
}

.attachment-name {
  margin: 0 0 4px;
  font-size: 14px;
}

.attachment-subtitle {
  margin: 0;
  color: var(--text-secondary);
  font-size: 12px;
}

.attachment-remove {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
  cursor: pointer;
}

.composer-row {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 24px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.icon-button,
.send-button {
  position: relative;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.06);
  cursor: pointer;
  flex: 0 0 40px;
  transition: background-color 180ms ease, transform 180ms ease;
}

.icon-button:hover,
.send-button:hover {
  background: rgba(255, 255, 255, 0.1);
  transform: translateY(-1px);
}

.send-button {
  background: var(--accent);
  color: #04110e;
}

.send-button:hover {
  background: #14b78f;
}

.send-button:disabled,
.icon-button.is-disabled {
  cursor: wait;
  opacity: 0.8;
}

.send-button.is-busy .send-icon {
  opacity: 0;
}

.send-button.is-busy::after {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(4, 17, 14, 0.28);
  border-top-color: #04110e;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

#image-input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

#message-input {
  flex: 1;
  min-height: 24px;
  max-height: calc(1.55em * 6);
  padding: 8px 0;
  border: 0;
  resize: none;
  background: transparent;
  color: var(--text-primary);
  outline: none;
  line-height: 1.55;
}

#message-input::placeholder {
  color: var(--text-secondary);
}

@keyframes typing-pulse {
  0%,
  100% {
    opacity: 0.3;
    transform: translateY(0);
  }
  50% {
    opacity: 1;
    transform: translateY(-1px);
  }
}

@keyframes cursor-blink {
  0%,
  49% {
    opacity: 1;
  }
  50%,
  100% {
    opacity: 0;
  }
}

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

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 760px) {
  .chat-header,
  .chat-main,
  .composer-shell {
    padding-left: 16px;
    padding-right: 16px;
  }

  .chat-main {
    padding-bottom: 176px;
  }

  .brand p {
    display: none;
  }

  .message-card,
  .message.user .message-card {
    max-width: 100%;
  }
}
