:root {
  color-scheme: dark;
  --canvas: #090909;
  --sidebar: #141414;
  --sidebar-hover: #242424;
  --sidebar-selected: #343434;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.14);
  --text: #f4f2ef;
  --muted: #9a9896;
  --faint: #696765;
  --user-bubble: #4b4b4b;
  --assistant-bubble: #262626;
  --accent: #76e0a0;
  --accent-deep: #3aa367;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  width: 100%;
  min-width: 0;
  min-height: 100%;
  margin: 0;
  background: var(--canvas);
}

body {
  overflow: hidden;
  color: var(--text);
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(278px, 344px) minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  width: 100%;
  height: 100dvh;
  overflow: hidden;
}

.sidebar {
  position: relative;
  z-index: 3;
  display: flex;
  min-width: 0;
  flex-direction: column;
  overflow: hidden;
  background: var(--sidebar);
  border-right: 1px solid var(--line);
}

.sidebar-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  height: 64px;
  padding: 12px 14px 10px 18px;
}

.wordmark {
  color: #ebebe9;
  font-size: 18px;
  font-weight: 710;
  letter-spacing: -0.035em;
}

.new-agent-button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 36px;
  padding: 0 10px;
  border-radius: 10px;
  background: transparent;
  color: #e6e5e2;
  font-size: 13px;
  font-weight: 650;
  transition: background 150ms ease, color 150ms ease;
}

.new-agent-button > span:first-child {
  color: var(--accent);
  font-size: 24px;
  font-weight: 320;
  line-height: 0;
}

.new-agent-button:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.search-field {
  position: relative;
  display: flex;
  align-items: center;
  height: 45px;
  margin: 5px 12px 12px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #202020;
  transition: border-color 160ms ease, background 160ms ease;
}

.search-field:focus-within {
  border-color: rgba(118, 224, 160, 0.55);
  background: #232323;
}

.search-field input {
  width: 100%;
  height: 100%;
  padding: 0 12px 0 38px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-size: 15px;
}

.search-field input::placeholder {
  color: #898785;
}

.search-glyph {
  position: absolute;
  left: 14px;
  width: 14px;
  height: 14px;
  border: 2px solid #8b8987;
  border-radius: 50%;
}

.search-glyph::after {
  position: absolute;
  right: -5px;
  bottom: -4px;
  width: 6px;
  height: 2px;
  border-radius: 2px;
  background: #8b8987;
  content: "";
  transform: rotate(45deg);
}

.agent-list-wrap {
  min-height: 0;
  flex: 1;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #454545 transparent;
}

.agent-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0 7px 14px;
}

.agent-row {
  display: grid;
  grid-template-columns: 43px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 65px;
  padding: 8px 9px;
  border-radius: 12px;
  background: transparent;
  color: var(--text);
  text-align: left;
  transition: background 130ms ease;
}

.agent-row:hover {
  background: var(--sidebar-hover);
}

.agent-row[aria-selected="true"] {
  background: var(--sidebar-selected);
}

.agent-avatar {
  position: relative;
  display: inline-grid;
  width: 39px;
  height: 39px;
  flex: 0 0 auto;
  place-items: center;
  overflow: hidden;
  border-radius: 44% 56% 49% 51% / 59% 43% 57% 41%;
  background: var(--avatar, #5bbf80);
  box-shadow: inset 0 -5px 10px rgba(0, 0, 0, 0.13);
  transform: rotate(-4deg);
}

.agent-avatar::before,
.agent-avatar::after {
  position: absolute;
  top: 15px;
  width: 4px;
  height: 7px;
  border-radius: 50%;
  background: rgba(12, 21, 16, 0.86);
  content: "";
  transform: rotate(5deg);
}

.agent-avatar::before {
  left: 12px;
}

.agent-avatar::after {
  right: 12px;
}

.agent-details {
  min-width: 0;
}

.agent-name,
.agent-preview {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.agent-name {
  color: #f1f0ee;
  font-size: 16px;
  font-weight: 650;
  line-height: 1.25;
}

.agent-preview {
  margin-top: 3px;
  color: #a5a3a0;
  font-size: 13px;
  line-height: 1.3;
}

.agent-meta {
  align-self: start;
  padding-top: 3px;
  color: #8d8b89;
  font-size: 12px;
  white-space: nowrap;
}

.row-working-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-left: 4px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(118, 224, 160, 0.12);
}

.empty-agent-list {
  margin: 24px 18px;
  color: var(--muted);
  font-size: 14px;
  text-align: center;
}

.conversation {
  display: grid;
  min-width: 0;
  min-height: 0;
  grid-template-rows: 64px minmax(0, 1fr) auto;
  overflow: hidden;
  background: #080808;
}

.chat-header {
  display: flex;
  align-items: center;
  min-width: 0;
  padding: 0 26px;
  border-bottom: 1px solid var(--line);
}

.sidebar-toggle {
  display: none;
  margin-right: 12px;
  padding: 8px 9px;
  border-radius: 8px;
  background: #232323;
  color: var(--text);
  font-size: 13px;
  font-weight: 650;
}

.chat-identity {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 11px;
}

.chat-identity .agent-avatar {
  width: 32px;
  height: 32px;
}

.chat-identity .agent-avatar::before,
.chat-identity .agent-avatar::after {
  top: 12px;
  width: 3px;
  height: 5px;
}

.chat-identity .agent-avatar::before {
  left: 10px;
}

.chat-identity .agent-avatar::after {
  right: 10px;
}

.chat-identity h1 {
  max-width: min(46vw, 590px);
  margin: 0;
  overflow: hidden;
  color: #f3f2ef;
  font-size: 17px;
  font-weight: 680;
  letter-spacing: -0.02em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-identity p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.rename-agent-button {
  min-height: 29px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: transparent;
  color: #bab8b5;
  font-size: 12px;
  font-weight: 640;
  transition: background 130ms ease, color 130ms ease, border-color 130ms ease;
}

.rename-agent-button:hover:not(:disabled) {
  border-color: var(--line-strong);
  background: #202020;
  color: #f4f2ef;
}

.rename-agent-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.activity-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 29px;
  padding: 0 10px;
  border: 1px solid rgba(118, 224, 160, 0.2);
  border-radius: 100px;
  background: rgba(79, 155, 104, 0.1);
  color: #b6eeca;
  font-size: 12px;
  font-weight: 610;
}

.activity-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(118, 224, 160, 0.13);
}

.messages-viewport {
  position: relative;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: #404040 transparent;
}

.messages {
  display: flex;
  width: min(100%, 1060px);
  min-height: 100%;
  flex-direction: column;
  gap: 17px;
  margin: 0 auto;
  padding: 30px max(30px, 4.5vw) 42px;
}

.message-row {
  display: flex;
  width: 100%;
}

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

.message-timestamp {
  align-self: center;
  margin: 3px 0 1px;
  color: #8d8b89;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.message-bubble {
  max-width: min(78%, 740px);
  padding: 13px 17px;
  border-radius: 20px;
  color: #f3f2ef;
  font-size: 16px;
  line-height: 1.45;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

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

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

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

.message-bubble.markdown p {
  margin: 0.7em 0;
}

.message-bubble.markdown h1,
.message-bubble.markdown h2,
.message-bubble.markdown h3,
.message-bubble.markdown h4,
.message-bubble.markdown h5,
.message-bubble.markdown h6 {
  margin: 0.9em 0 0.45em;
  color: #fff;
  font-size: 1.08em;
  line-height: 1.3;
}

.message-bubble.markdown ul,
.message-bubble.markdown ol {
  margin: 0.7em 0;
  padding-left: 1.35em;
}

.message-bubble.markdown li + li {
  margin-top: 0.28em;
}

.message-bubble.markdown a {
  color: #9cebbb;
  text-decoration-color: rgba(156, 235, 187, 0.6);
  text-underline-offset: 0.14em;
}

.message-bubble.markdown a:hover {
  color: #c7f6d7;
}

.message-bubble.markdown :not(pre) > code {
  padding: 0.12em 0.32em;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.1);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.88em;
}

.message-bubble.markdown pre {
  margin: 0.75em 0;
  overflow-x: auto;
  padding: 0.75em 0.85em;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.3);
  white-space: pre;
}

.message-bubble.markdown pre code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.85em;
}

.message-bubble.markdown blockquote {
  margin: 0.75em 0;
  padding-left: 0.85em;
  border-left: 3px solid rgba(156, 235, 187, 0.6);
  color: #d0ceca;
}

.message-bubble.markdown hr {
  margin: 1em 0;
  border: 0;
  border-top: 1px solid var(--line-strong);
}

.message-bubble.markdown table {
  display: block;
  max-width: 100%;
  overflow-x: auto;
  border-collapse: collapse;
}

.message-bubble.markdown th,
.message-bubble.markdown td {
  padding: 0.38em 0.55em;
  border: 1px solid rgba(255, 255, 255, 0.16);
  text-align: left;
}

.message-row.user .message-bubble {
  border-bottom-right-radius: 6px;
  background: var(--user-bubble);
}

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

.message-bubble.pending {
  opacity: 0.72;
}

.message-bubble.failed {
  border: 1px solid rgba(236, 103, 103, 0.5);
}

.thinking-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 39px;
}

.thinking-avatar {
  width: 33px;
  height: 33px;
}

.thinking-avatar::before,
.thinking-avatar::after {
  top: 13px;
  width: 3px;
  height: 6px;
}

.thinking-avatar::before {
  left: 10px;
}

.thinking-avatar::after {
  right: 10px;
}

.thinking-bubble {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 35px;
  padding: 0 13px;
  border-radius: 17px 17px 17px 5px;
  background: var(--assistant-bubble);
  color: #c8c6c3;
  font-size: 14px;
}

.thinking-dots {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  height: 14px;
}

.thinking-dots > span {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #9f9d9a;
  animation: thinking-bounce 1.05s ease-in-out infinite;
  animation-delay: calc(var(--dot-index) * 120ms);
}

@keyframes thinking-bounce {
  0%,
  60%,
  100% {
    opacity: 0.42;
    transform: translateY(0);
  }

  30% {
    opacity: 1;
    transform: translateY(-3px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .thinking-dots > span {
    animation: none;
  }
}

.blank-chat {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 11px;
  flex-direction: column;
  color: var(--muted);
  text-align: center;
}

.blank-chat p {
  margin: 0;
  font-size: 14px;
}

.blank-orb {
  position: relative;
  width: 48px;
  height: 48px;
  border-radius: 43% 57% 48% 52% / 57% 44% 56% 43%;
  background: linear-gradient(145deg, #9cf0bb, #52ad75);
  box-shadow: 0 12px 36px rgba(72, 190, 111, 0.17);
}

.blank-orb::before,
.blank-orb::after {
  position: absolute;
  top: 19px;
  width: 4px;
  height: 7px;
  border-radius: 50%;
  background: #183325;
  content: "";
}

.blank-orb::before {
  left: 15px;
}

.blank-orb::after {
  right: 14px;
}

.composer {
  width: min(100%, 1060px);
  margin: 0 auto;
  padding: 14px max(30px, 4.5vw) 16px;
}

.composer-box {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  min-height: 58px;
  padding: 8px 8px 8px 17px;
  border: 1px solid var(--line-strong);
  border-radius: 18px;
  background: #272727;
  box-shadow: 0 5px 24px rgba(0, 0, 0, 0.22);
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

.composer-box:focus-within {
  border-color: rgba(118, 224, 160, 0.58);
  box-shadow: 0 0 0 3px rgba(118, 224, 160, 0.08);
}

.composer textarea {
  display: block;
  width: 100%;
  max-height: 154px;
  min-height: 27px;
  padding: 7px 0 6px;
  resize: none;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-size: 16px;
  line-height: 1.38;
}

.composer textarea::placeholder {
  color: #858381;
}

.send-button {
  display: inline-grid;
  width: 41px;
  height: 41px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 50%;
  background: var(--accent);
  color: #102218;
  font-size: 23px;
  font-weight: 770;
  line-height: 1;
  transition: transform 130ms ease, background 130ms ease, opacity 130ms ease;
}

.send-button:hover:not(:disabled) {
  background: #99f1bb;
  transform: translateY(-1px);
}

.send-button:disabled {
  cursor: not-allowed;
  background: #4c4c4c;
  color: #969492;
}

.composer-hint {
  margin: 8px 0 0;
  color: #787674;
  font-size: 11px;
  text-align: center;
}

kbd {
  color: #a19f9d;
  font-family: inherit;
  font-size: 11px;
}

.modal-layer {
  position: fixed;
  z-index: 10;
  inset: 0;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.67);
  backdrop-filter: blur(5px);
}

.agent-modal {
  position: absolute;
  top: 50%;
  left: 50%;
  width: min(calc(100vw - 36px), 446px);
  padding: 31px;
  border: 1px solid var(--line-strong);
  border-radius: 20px;
  background: #232323;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.55);
  transform: translate(-50%, -50%);
}

.modal-close {
  position: absolute;
  top: 15px;
  right: 15px;
  display: grid;
  width: 31px;
  height: 31px;
  place-items: center;
  border-radius: 8px;
  background: transparent;
  color: #aaa8a5;
  font-size: 24px;
  font-weight: 300;
  line-height: 1;
}

.modal-close:hover {
  background: #343434;
  color: #fff;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 760;
  letter-spacing: 0.12em;
}

.agent-modal h2 {
  margin: 0;
  color: #f5f3f0;
  font-size: 24px;
  letter-spacing: -0.035em;
}

.modal-copy {
  margin: 10px 0 24px;
  color: #b1afac;
  font-size: 14px;
  line-height: 1.52;
}

.agent-modal label {
  display: block;
  margin-bottom: 7px;
  color: #e4e2df;
  font-size: 13px;
  font-weight: 630;
}

.agent-modal input {
  width: 100%;
  height: 47px;
  padding: 0 13px;
  border: 1px solid var(--line-strong);
  border-radius: 11px;
  outline: 0;
  background: #181818;
  color: var(--text);
  font-size: 16px;
}

.agent-modal input::placeholder {
  color: #777573;
}

.agent-modal input:focus {
  border-color: rgba(118, 224, 160, 0.7);
}

.form-error {
  min-height: 18px;
  margin: 8px 0 -2px;
  color: #ff9f9f;
  font-size: 12px;
}

.modal-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 25px;
}

.text-button,
.primary-button {
  min-height: 38px;
  padding: 0 14px;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 690;
}

.text-button {
  background: transparent;
  color: #b9b7b4;
}

.text-button:hover {
  background: #303030;
  color: #fff;
}

.primary-button {
  background: var(--accent);
  color: #112218;
}

.primary-button:hover:not(:disabled) {
  background: #9af0bb;
}

.primary-button:disabled {
  cursor: wait;
  opacity: 0.55;
}

.toast {
  position: fixed;
  z-index: 20;
  bottom: 24px;
  left: 50%;
  max-width: min(90vw, 480px);
  padding: 11px 15px;
  border: 1px solid rgba(255, 145, 145, 0.38);
  border-radius: 10px;
  background: #3a2222;
  color: #ffd3d3;
  font-size: 13px;
  line-height: 1.35;
  box-shadow: 0 10px 36px rgba(0, 0, 0, 0.38);
  transform: translateX(-50%);
}

@media (max-width: 720px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(84vw, 340px);
    box-shadow: 22px 0 55px rgba(0, 0, 0, 0.42);
    transform: translateX(-105%);
    transition: transform 180ms ease;
  }

  .app-shell.sidebar-open .sidebar {
    transform: translateX(0);
  }

  .app-shell.sidebar-open::after {
    position: fixed;
    z-index: 2;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    content: "";
  }

  .conversation {
    height: 100dvh;
  }

  .chat-header {
    padding: 0 14px;
  }

  .sidebar-toggle {
    display: block;
  }

  .chat-identity .agent-avatar {
    width: 29px;
    height: 29px;
  }

  .chat-identity h1 {
    max-width: 42vw;
    font-size: 16px;
  }

  .chat-identity p {
    display: none;
  }

  .activity-chip {
    padding: 0;
    border: 0;
    background: transparent;
    color: transparent;
    font-size: 0;
  }

  .activity-dot {
    width: 8px;
    height: 8px;
  }

  .rename-agent-button {
    padding: 0 8px;
  }

  .messages {
    padding: 22px 17px 30px;
  }

  .message-bubble {
    max-width: 88%;
    padding: 12px 14px;
    font-size: 15px;
  }

  .composer {
    padding: 10px 12px 12px;
  }

  .composer-hint {
    display: none;
  }
}

@media (max-width: 380px) {
  .new-agent-button > span:last-child {
    display: none;
  }

  .new-agent-button {
    width: 36px;
    justify-content: center;
    padding: 0;
  }

  .chat-identity h1 {
    max-width: 35vw;
  }
}
