#rox-chat {
  --chat-frame: #141914;
  --chat-canvas: #0f130f;
  --chat-line: #2d382c;
  --chat-bright: #eef4e9;
  --chat-muted: #aab8a8;
  --chat-accent: #bcf36b;
  --chat-assistant: #232d23;
  --chat-user: #2c4228;
  width: 100%;
  min-width: 0;
  container-type: inline-size;
  color: var(--chat-bright);
  text-align: left;
}

#rox-chat *, #rox-chat *::before, #rox-chat *::after { box-sizing: border-box; }
#rox-chat [hidden] { display: none; }

.rox-chat__panel {
  overflow: hidden;
  border: 1px solid var(--chat-line);
  border-radius: 16px;
  background: var(--chat-frame);
  box-shadow: 0 17px 37px #10171050;
  font-size: 0.9375rem;
  line-height: 1.45;
  color-scheme: dark;
}

.rox-chat__header {
  display: grid;
  grid-template-columns: 45px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  min-height: 75px;
  background: #192319;
  padding: 12px 16px;
}

.rox-chat__avatar {
  display: grid;
  width: 45px;
  aspect-ratio: 1;
  place-items: center;
  border-radius: 50%;
  border: 1px solid #526446;
  background: #293e21;
}

.rox-chat__avatar img { display: block; width: 56%; height: auto; }

.rox-chat__identity { display: grid; gap: 1px; }
.rox-chat__identity strong { font-size: 0.98rem; font-weight: 720; }
.rox-chat__identity span { font-size: 0.77rem; color: var(--chat-muted); }

.rox-chat__reset, .rox-chat__action, .rox-chat__send {
  appearance: none;
  border: 1px solid var(--chat-line);
  background: transparent;
  color: var(--chat-bright);
  font: inherit;
  cursor: pointer;
}

.rox-chat__reset {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px;
  min-height: 44px;
  border: 0;
  border-radius: 6px;
  color: var(--chat-muted);
  font-size: 0.75rem;
}

.rox-chat__context {
  display: flex;
  align-items: center;
  min-height: 41px;
  padding: 10px 16px;
  border-block: 1px solid var(--chat-line);
  background: #1a2119;
  font-size: 0.72rem;
}

.rox-chat__phase { font-weight: 670; }
.rox-chat__panel[data-stage="customer"] .rox-chat__context {
  color: #dceeb9;
  background: #263421;
}

.rox-chat__thread {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 11px;
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: #52654a #161e15;
  height: clamp(240px, 53cqw, 324px);
  padding: 17px 16px;
  background-color: var(--chat-canvas);
  background-image: radial-gradient(circle, rgb(189 213 174 / 0.10) 1px, transparent 1.5px);
  background-size: 22px 22px;
}

.rox-chat__message {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  max-width: min(87%, 40ch);
  min-width: 0;
  padding: 9px 10px;
  border-radius: 3px 11px 11px;
  background: var(--chat-assistant);
  font-size: 0.89rem;
  line-height: 1.43;
}

.rox-chat__message--user {
  align-self: flex-end;
  background: var(--chat-user);
  border-radius: 11px 3px 11px 11px;
}

.rox-chat__message p {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  color: inherit;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.rox-chat__message-meta {
  display: flex;
  align-self: stretch;
  justify-content: space-between;
  align-items: baseline;
  gap: 6px 10px;
  flex-wrap: wrap;
  color: var(--chat-muted);
  line-height: 1.1;
}

.rox-chat__message-meta time:only-child { margin-left: auto; }
.rox-chat__message-source { font-size: 0.64rem; font-weight: 650; }
.rox-chat__message-source[data-mode="ai"] { color: #c8ef9c; }
.rox-chat__message-source[data-mode="fallback"] { color: #e2c990; }

.rox-chat__message time {
  color: var(--chat-muted);
  font-size: 0.63rem;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.rox-chat__typing {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 11px;
  border-radius: 5px;
  background: var(--chat-assistant);
  color: var(--chat-muted);
  font-size: 0.78rem;
}

.rox-chat__typing-dots { display: inline-flex; gap: 3px; }
.rox-chat__typing-dots i {
  display: block;
  width: 4px;
  height: 4px;
  background: currentColor;
  border-radius: 50%;
  animation: rox-chat-dot .9s ease-in-out infinite alternate;
}
.rox-chat__typing-dots i:nth-child(2) { animation-delay: .15s; }
.rox-chat__typing-dots i:nth-child(3) { animation-delay: .3s; }
@keyframes rox-chat-dot {
  from { opacity: .3; transform: translateY(1px); }
  to { opacity: 1; transform: translateY(-1px); }
}
@media (prefers-reduced-motion: reduce) {
  .rox-chat__typing-dots i { animation: none; }
}

.rox-chat__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 12px;
}

.rox-chat__actions:not(:empty) { padding-block: 9px 3px; }

.rox-chat__action {
  min-height: 38px;
  max-width: 100%;
  padding: 6px 10px;
  border-radius: 6px;
  color: var(--chat-bright);
  font-size: 0.78rem;
  font-weight: 580;
  line-height: 1.2;
  text-align: left;
  overflow-wrap: anywhere;
}

.rox-chat__action--primary {
  border-color: var(--chat-accent);
  background: var(--chat-accent);
  color: #15210b;
  font-weight: 730;
}

.rox-chat__composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 44px;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 9px 12px 12px;
}

.rox-chat__composer[hidden] + .rox-chat__notice:empty { display: none; }
.rox-chat__panel:has(.rox-chat__composer[hidden]) .rox-chat__typing-dots { display: inline-flex; gap: 3px; }
.rox-chat__typing-dots i {
  display: block;
  width: 4px;
  height: 4px;
  background: currentColor;
  border-radius: 50%;
  animation: rox-chat-dot .9s ease-in-out infinite alternate;
}
.rox-chat__typing-dots i:nth-child(2) { animation-delay: .15s; }
.rox-chat__typing-dots i:nth-child(3) { animation-delay: .3s; }
@keyframes rox-chat-dot {
  from { opacity: .3; transform: translateY(1px); }
  to { opacity: 1; transform: translateY(-1px); }
}
@media (prefers-reduced-motion: reduce) {
  .rox-chat__typing-dots i { animation: none; }
}

.rox-chat__actions { padding-bottom: 12px; }

.rox-chat__composer input {
  width: 100%;
  min-height: 44px;
  padding: 8px 11px;
  border: 1px solid var(--chat-line);
  border-radius: 7px;
  color: var(--chat-bright);
  background: #263025;
  font: inherit;
  font-size: 1rem;
  caret-color: var(--chat-accent);
}

.rox-chat__composer input::placeholder { color: var(--chat-muted); opacity: 1; }
.rox-chat__composer input[readonly] { cursor: progress; }

.rox-chat__send {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border-color: var(--chat-accent);
  border-radius: 50%;
  background: var(--chat-accent);
  color: #15210b;
}

.rox-chat__send:disabled {
  border-color: #41533d;
  background: #243123;
  color: #a6b9a1;
  cursor: default;
}

.rox-chat__notice {
  margin: 0;
  padding: 6px 12px 12px;
  color: var(--chat-muted);
  font-size: 0.8rem;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

#rox-chat :focus-visible {
  outline: 2px solid var(--chat-accent);
  outline-offset: 2px;
}

#rox-chat .rox-chat__thread:focus-visible { outline-offset: -3px; }
#rox-chat ::selection { background: var(--chat-accent); color: #15210b; }

.rox-chat__visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

@media (hover: hover) {
  .rox-chat__reset:hover {
    color: var(--chat-bright);
    background: #243123;
  }

  .rox-chat__action:hover {
    border-color: #7d966e;
    background: #22301f;
  }

  .rox-chat__action--primary:hover, .rox-chat__send:not(:disabled):hover {
    border-color: #d9ffa5;
    background: #d9ffa5;
  }
}

@container (max-width: 365px) {
  .rox-chat__header, .rox-chat__context, .rox-chat__thread { padding-inline: 12px; }
  .rox-chat__header { grid-template-columns: 39px minmax(0, 1fr) auto; gap: 9px; }
  .rox-chat__avatar { width: 39px; }
  .rox-chat__reset { padding-inline: 4px; }
  .rox-chat__message { max-width: 94%; }
  .rox-chat__action { min-height: 41px; }
}
