:root {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #10231b;
  background: #eef3ef;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  min-width: 280px;
  background:
    radial-gradient(circle at 10% 0%, rgba(230, 168, 23, 0.12), transparent 28rem),
    #eef3ef;
}

button,
textarea,
input {
  font: inherit;
}

button,
label {
  -webkit-tap-highlight-color: transparent;
}

.chat-shell {
  width: 100%;
  height: 100dvh;
  min-height: 420px;
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  background: #f8fbf9;
}

.topbar {
  min-height: 72px;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  color: #fff;
  background: #123b2a;
  border-bottom: 3px solid #e6a817;
  box-shadow: 0 6px 20px rgba(10, 41, 28, 0.15);
  z-index: 2;
}

.brand-mark {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.32);
  border-radius: 12px 12px 12px 4px;
  color: #123b2a;
  background: #e6a817;
  font-size: 1.25rem;
  font-weight: 850;
  letter-spacing: -0.04em;
}

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

.brand-copy h1 {
  margin: 0;
  font-size: 1rem;
  line-height: 1.3;
  font-weight: 720;
  letter-spacing: -0.015em;
}

.brand-copy p {
  margin: 3px 0 0;
  display: flex;
  align-items: center;
  gap: 6px;
  color: #c8ddd2;
  font-size: 0.78rem;
  line-height: 1.2;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #edb932;
  box-shadow: 0 0 0 3px rgba(237, 185, 50, 0.14);
}

.is-online .status-dot {
  background: #5bd69a;
  box-shadow: 0 0 0 3px rgba(91, 214, 154, 0.14);
}

.is-offline .status-dot {
  background: #ff8f7d;
  box-shadow: 0 0 0 3px rgba(255, 143, 125, 0.14);
}

.messages {
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 22px max(16px, calc((100% - 780px) / 2)) 30px;
  scrollbar-color: #a7bbb0 transparent;
}

.message {
  display: flex;
  align-items: flex-end;
  gap: 9px;
  margin: 0 0 18px;
}

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

.message-avatar {
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  display: grid;
  place-items: center;
  border-radius: 9px 9px 9px 3px;
  color: #123b2a;
  background: #e6a817;
  font-size: 0.78rem;
  font-weight: 850;
}

.bubble {
  max-width: min(82%, 650px);
  padding: 11px 14px;
  border: 1px solid #d9e4de;
  border-radius: 6px 17px 17px 17px;
  background: #fff;
  box-shadow: 0 4px 14px rgba(17, 56, 39, 0.055);
}

.user .bubble {
  color: #fff;
  border-color: #123b2a;
  border-radius: 17px 6px 17px 17px;
  background: #123b2a;
}

.bubble-content {
  min-height: 1.45em;
  font-size: 1rem;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.bubble-content p {
  margin: 0 0 0.75em;
}

.bubble-content p:last-child {
  margin-bottom: 0;
}

.bubble-content pre {
  margin: 10px 0;
  padding: 12px;
  overflow-x: auto;
  border-radius: 9px;
  color: #eef8f2;
  background: #0d2a1e;
  font: 0.88rem/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.bubble-content code {
  padding: 0.12em 0.32em;
  border-radius: 4px;
  background: #e9f0ec;
  font: 0.9em ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.user .bubble-content code {
  color: #fff;
  background: rgba(255, 255, 255, 0.15);
}

.message-time {
  margin-top: 7px;
  color: #71847a;
  font-size: 0.72rem;
}

.user .message-time {
  color: #bad0c5;
  text-align: right;
}

.attachment-label {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid rgba(111, 137, 123, 0.25);
  font-size: 0.78rem;
  font-weight: 650;
}

.typing .bubble-content::after {
  content: "";
  display: inline-block;
  width: 0.55em;
  height: 1em;
  margin-left: 3px;
  vertical-align: -0.15em;
  background: #e6a817;
  animation: blink 0.85s steps(1) infinite;
}

@keyframes blink {
  50% { opacity: 0; }
}

.error-banner {
  margin: 0 max(14px, calc((100% - 780px) / 2)) 10px;
  padding: 10px 12px;
  border: 1px solid #f3b7ae;
  border-radius: 10px;
  color: #76281d;
  background: #fff0ed;
  font-size: 0.88rem;
}

.composer {
  padding: 12px max(14px, calc((100% - 780px) / 2)) calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid #dce6e0;
  background: rgba(248, 251, 249, 0.96);
  backdrop-filter: blur(12px);
}

.composer-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: end;
  gap: 8px;
  padding: 7px;
  border: 1px solid #cbd9d1;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 6px 22px rgba(17, 56, 39, 0.07);
}

.composer-row:focus-within {
  border-color: #2b6a4d;
  box-shadow: 0 0 0 3px rgba(43, 106, 77, 0.12);
}

textarea {
  width: 100%;
  max-height: 140px;
  min-height: 42px;
  padding: 9px 4px 7px;
  resize: none;
  border: 0;
  outline: 0;
  color: #10231b;
  background: transparent;
  font-size: 1rem;
  line-height: 1.45;
}

textarea::placeholder {
  color: #82948a;
}

.attach-button,
.send-button,
.stop-button {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 12px;
  cursor: pointer;
}

.attach-button {
  color: #234c39;
  background: #edf3ef;
  font-size: 1.45rem;
  line-height: 1;
}

.attach-button:hover {
  background: #e1ebe5;
}

.send-button {
  color: #123b2a;
  background: #e6a817;
}

.send-button:hover {
  background: #f0b925;
}

.send-button:disabled,
.attach-button.is-disabled {
  opacity: 0.48;
  cursor: not-allowed;
}

.send-button svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
}

.stop-button {
  background: #f4e8e5;
}

.stop-button span {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  background: #a34334;
}

.composer-note {
  margin: 7px 4px 0;
  color: #6c8075;
  font-size: 0.74rem;
  text-align: center;
}

.attachment-preview {
  margin: 0 0 8px;
  padding: 8px 10px;
  display: grid;
  grid-template-columns: 42px 1fr auto;
  align-items: center;
  gap: 9px;
  border: 1px solid #d6e2db;
  border-radius: 12px;
  background: #fff;
}

.attachment-preview img {
  width: 42px;
  height: 42px;
  object-fit: cover;
  border-radius: 8px;
}

.attachment-preview strong,
.attachment-preview span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attachment-preview strong {
  font-size: 0.82rem;
}

.attachment-preview span {
  margin-top: 2px;
  color: #71847a;
  font-size: 0.72rem;
}

.attachment-preview button {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 9px;
  color: #6d3a32;
  background: #f8ece9;
  cursor: pointer;
  font-size: 1.3rem;
}

.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;
}

@media (min-width: 850px) {
  body {
    padding: 12px;
  }

  .chat-shell {
    max-width: 980px;
    height: calc(100dvh - 24px);
    min-height: 520px;
    margin: 0 auto;
    overflow: hidden;
    border: 1px solid #d1ded6;
    border-radius: 20px;
    box-shadow: 0 18px 60px rgba(14, 49, 33, 0.12);
  }
}

@media (max-width: 520px) {
  .topbar {
    min-height: 66px;
    padding: 11px 13px;
  }

  .messages {
    padding: 17px 12px 24px;
  }

  .bubble {
    max-width: 88%;
  }

  .composer {
    padding-left: 9px;
    padding-right: 9px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
