:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #080c18;
  color: #eef2ff;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 12% 0%, rgba(81, 96, 255, 0.21), transparent 32rem),
    radial-gradient(circle at 90% 92%, rgba(28, 183, 166, 0.12), transparent 30rem),
    #080c18;
}

button,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(100%, 1040px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 28px 18px;
  display: grid;
  align-items: center;
}

.chat-card {
  overflow: hidden;
  border: 1px solid rgba(157, 171, 255, 0.18);
  border-radius: 28px;
  background: rgba(15, 21, 39, 0.92);
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.38), 0 0 0 1px rgba(255, 255, 255, 0.02) inset;
  backdrop-filter: blur(18px);
}

.topbar {
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 26px 28px 22px;
  border-bottom: 1px solid rgba(157, 171, 255, 0.12);
}

.brand-mark {
  width: 58px;
  height: 58px;
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 18px;
  background: transparent;
  filter: drop-shadow(0 9px 15px rgba(63, 96, 255, 0.28));
}

.brand-mark img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
}

.brand-copy {
  min-width: 0;
}

.eyebrow {
  margin: 0 0 4px;
  color: #8f9bca;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
}

h1 {
  margin: 0;
  color: #ffffff;
  font-size: clamp(22px, 4vw, 30px);
  letter-spacing: -0.03em;
}

.subtitle {
  margin: 5px 0 0;
  color: #9aa5c7;
  font-size: 15px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  padding: 8px 12px;
  border: 1px solid rgba(109, 225, 184, 0.2);
  border-radius: 999px;
  color: #a9e8d0;
  background: rgba(39, 147, 113, 0.11);
  font-size: 13px;
  white-space: nowrap;
}

.status-pill.offline {
  border-color: rgba(255, 141, 141, 0.22);
  color: #ffb2b2;
  background: rgba(177, 54, 54, 0.12);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #5ee0af;
  box-shadow: 0 0 12px rgba(94, 224, 175, 0.8);
}

.offline .status-dot {
  background: #ff7777;
  box-shadow: 0 0 12px rgba(255, 119, 119, 0.8);
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 16px;
  padding: 16px 28px;
  background: rgba(9, 13, 26, 0.34);
}

.provider-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: #d9def5;
  font-size: 14px;
}

.chip-label {
  color: #7f8bb3;
}

.chip-muted {
  color: #7580a3;
}

.ghost-button,
.quick-prompts button {
  border: 1px solid rgba(158, 171, 255, 0.18);
  border-radius: 10px;
  color: #aeb8d9;
  background: rgba(116, 132, 255, 0.07);
  transition: border-color 160ms ease, background 160ms ease, color 160ms ease;
}

.ghost-button {
  padding: 8px 12px;
  font-size: 13px;
}

.ghost-button:hover,
.quick-prompts button:hover {
  border-color: rgba(151, 164, 255, 0.48);
  color: #eef2ff;
  background: rgba(116, 132, 255, 0.14);
}

.messages {
  min-height: 420px;
  max-height: min(56vh, 650px);
  overflow-y: auto;
  padding: 28px;
  scroll-behavior: smooth;
}

.message-row {
  display: flex;
  margin: 0 0 18px;
  animation: appear 180ms ease-out;
}

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

.message-bubble {
  max-width: min(82%, 760px);
  padding: 15px 17px;
  border: 1px solid rgba(149, 162, 243, 0.13);
  border-radius: 18px;
  color: #e7ebff;
  background: rgba(29, 38, 67, 0.76);
  line-height: 1.58;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.message-bubble.markdown {
  white-space: normal;
}

.message-bubble.markdown p,
.message-bubble.markdown h1,
.message-bubble.markdown h2,
.message-bubble.markdown h3,
.message-bubble.markdown h4,
.message-bubble.markdown blockquote,
.message-bubble.markdown pre {
  margin: 0 0 12px;
}

.message-bubble.markdown p:last-child,
.message-bubble.markdown h1:last-child,
.message-bubble.markdown h2:last-child,
.message-bubble.markdown h3:last-child,
.message-bubble.markdown h4:last-child,
.message-bubble.markdown blockquote:last-child,
.message-bubble.markdown pre:last-child,
.message-bubble.markdown ul:last-child,
.message-bubble.markdown ol:last-child {
  margin-bottom: 0;
}

.message-bubble.markdown h1,
.message-bubble.markdown h2,
.message-bubble.markdown h3,
.message-bubble.markdown h4 {
  color: #ffffff;
  line-height: 1.3;
}

.message-bubble.markdown h1 { font-size: 1.28em; }
.message-bubble.markdown h2 { font-size: 1.18em; }
.message-bubble.markdown h3,
.message-bubble.markdown h4 { font-size: 1.06em; }

.message-bubble.markdown ul,
.message-bubble.markdown ol {
  margin: 0 0 12px;
  padding-left: 22px;
}

.message-bubble.markdown li {
  margin: 4px 0;
}

.message-bubble.markdown blockquote {
  padding: 8px 12px;
  border-left: 3px solid #6f80ff;
  color: #b9c2e4;
  background: rgba(113, 128, 255, 0.08);
}

.message-bubble.markdown code {
  padding: 2px 5px;
  border-radius: 5px;
  color: #c3d2ff;
  background: rgba(4, 8, 19, 0.62);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.9em;
}

.message-bubble.markdown pre {
  overflow-x: auto;
  padding: 12px 14px;
  border: 1px solid rgba(151, 165, 255, 0.16);
  border-radius: 10px;
  background: rgba(4, 8, 19, 0.72);
}

.message-bubble.markdown pre code {
  padding: 0;
  color: #d2dcff;
  background: transparent;
  font-size: 0.86em;
  white-space: pre;
}

.message-bubble.markdown a {
  color: #aab6ff;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.message-bubble.markdown hr {
  margin: 16px 0;
  border: 0;
  border-top: 1px solid rgba(151, 165, 255, 0.18);
}

.message-row.user .message-bubble {
  border-color: rgba(128, 142, 255, 0.35);
  border-bottom-right-radius: 6px;
  background: linear-gradient(135deg, rgba(87, 103, 219, 0.95), rgba(64, 84, 174, 0.95));
  color: #ffffff;
}

.message-row.assistant .message-bubble {
  border-bottom-left-radius: 6px;
}

.message-label {
  margin: 0 0 6px 3px;
  color: #8290bd;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.message-stack {
  max-width: min(82%, 760px);
}

.message-actions {
  display: flex;
  justify-content: flex-start;
  margin: 7px 0 0 3px;
}

.copy-button {
  padding: 4px 7px;
  border: 0;
  border-radius: 6px;
  color: #7f8cb6;
  background: transparent;
  font-size: 12px;
  transition: color 160ms ease, background 160ms ease;
}

.copy-button:hover {
  color: #d8deff;
  background: rgba(116, 132, 255, 0.12);
}

.copy-button:disabled {
  cursor: default;
  opacity: 0.8;
}

.typing .message-bubble {
  display: inline-flex;
  gap: 5px;
  padding: 18px 20px;
}

.typing i {
  width: 6px;
  height: 6px;
  display: block;
  border-radius: 50%;
  background: #8e9bce;
  animation: bounce 900ms infinite ease-in-out;
}

.typing i:nth-child(2) { animation-delay: 120ms; }
.typing i:nth-child(3) { animation-delay: 240ms; }

.quick-prompts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 28px 17px;
}

.quick-prompts button {
  padding: 9px 12px;
  font-size: 13px;
  text-align: left;
}

.composer {
  margin: 0 18px 18px;
  padding: 13px 14px 10px;
  border: 1px solid rgba(151, 165, 255, 0.22);
  border-radius: 18px;
  background: rgba(8, 12, 25, 0.7);
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.composer:focus-within {
  border-color: rgba(125, 142, 255, 0.65);
  box-shadow: 0 0 0 4px rgba(102, 120, 255, 0.1);
}

textarea {
  width: 100%;
  resize: vertical;
  min-height: 72px;
  border: 0;
  outline: 0;
  color: #eef2ff;
  background: transparent;
  font-size: 16px;
  line-height: 1.5;
}

textarea::placeholder {
  color: #68749d;
}

.attachment-bar {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 30px;
  padding-top: 8px;
}

.attach-button,
.remove-attachment {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 9px;
  border: 1px solid rgba(151, 165, 255, 0.2);
  border-radius: 8px;
  color: #aeb8d9;
  background: rgba(116, 132, 255, 0.07);
  font-size: 12px;
  cursor: pointer;
}

.attach-button:hover,
.remove-attachment:hover {
  color: #ffffff;
  border-color: rgba(151, 164, 255, 0.48);
  background: rgba(116, 132, 255, 0.14);
}

#attachment-input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}

.attachment-name {
  max-width: 240px;
  overflow: hidden;
  color: #7f8bb3;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attachment-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-top: 9px;
}

.attachment-item {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  max-width: 280px;
  min-height: 38px;
  padding: 5px 7px;
  border: 1px solid rgba(151, 165, 255, 0.2);
  border-radius: 9px;
  color: #c4ccef;
  background: rgba(116, 132, 255, 0.08);
  font-size: 12px;
}

.attachment-thumb {
  display: block;
  width: 32px;
  height: 32px;
  border: 1px solid rgba(151, 165, 255, 0.22);
  border-radius: 6px;
  object-fit: contain;
}

.attachment-file-icon {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border-radius: 6px;
  color: #ffb1b1;
  background: rgba(214, 74, 74, 0.18);
  font-size: 10px;
  font-weight: 800;
}

.attachment-item-name {
  max-width: 190px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.remove-one-attachment {
  width: 22px;
  height: 22px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  color: #9ca8d0;
  background: transparent;
  font-size: 18px;
  line-height: 1;
}

.remove-one-attachment:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.1);
}

.composer-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding-top: 8px;
}

.hint {
  color: #68749d;
  font-size: 12px;
}

.send-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 16px;
  border: 0;
  border-radius: 12px;
  color: #ffffff;
  background: linear-gradient(135deg, #6878ff, #3ab9ae);
  box-shadow: 0 8px 22px rgba(78, 110, 255, 0.23);
  font-weight: 700;
  transition: transform 160ms ease, filter 160ms ease, opacity 160ms ease;
}

.send-button:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
}

.send-button:disabled {
  cursor: wait;
  opacity: 0.58;
  transform: none;
}

.send-icon {
  font-size: 18px;
  line-height: 1;
}

.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 appear {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.65; }
  30% { transform: translateY(-4px); opacity: 1; }
}

@media (max-width: 680px) {
  .app-shell { padding: 0; }
  .chat-card { min-height: 100vh; border-radius: 0; border-left: 0; border-right: 0; }
  .topbar { padding: 21px 18px 18px; align-items: flex-start; }
  .status-pill { padding: 7px 9px; font-size: 0; }
  .status-pill .status-dot { width: 8px; height: 8px; }
  .toolbar { padding: 13px 18px; }
  .provider-chip { display: block; max-width: 62%; line-height: 1.4; }
  .messages { min-height: 0; max-height: none; padding: 22px 18px; }
  .message-bubble, .message-stack { max-width: 92%; }
  .quick-prompts { padding: 0 18px 14px; overflow-x: auto; flex-wrap: nowrap; }
  .quick-prompts button { flex: 0 0 auto; }
  .composer { margin: 0 12px 12px; }
  .hint { display: none; }
}
