:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --bg: #f7f8fa;
  --panel: #ffffff;
  --subtle: #f8fafc;
  --hover: #f3f4f6;
  --active: #eff6f3;
  --line: #eaecf0;
  --line-strong: #d0d5dd;
  --text: #1f2937;
  --muted: #667085;
  --muted-2: #98a2b3;
  --green: #16a34a;
  --green-dark: #15803d;
  --green-soft: #ecfdf3;
  --green-line: #abefc6;
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled,
textarea:disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

.shell {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  min-height: 100vh;
  background: var(--panel);
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  border-right: 1px solid var(--line);
  background: var(--panel);
  padding: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 38px;
}

.brand img {
  width: 28px;
  height: 28px;
}

.brand strong,
.brand span,
.row strong,
.row small {
  display: block;
}

.brand strong {
  font-size: 14px;
}

.brand span,
.field span,
small,
time,
.chatHeader p {
  color: var(--muted);
  font-size: 12px;
}

.internalHeader {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 60px;
  border-bottom: 1px solid var(--line);
  padding: 0 16px;
}

.internalHeader strong,
.internalHeader span {
  display: block;
}

.internalHeader strong {
  color: var(--text);
  font-size: 15px;
  font-weight: 650;
}

.internalHeader span {
  max-width: 220px;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.field {
  display: grid;
  gap: 6px;
}

select,
input,
textarea {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--subtle);
  color: var(--text);
  padding: 8px 10px;
  outline: none;
}

select:focus,
input:focus,
textarea:focus {
  border-color: var(--green);
  background: #fff;
  box-shadow: 0 0 0 2px rgba(22, 163, 74, 0.12);
}

textarea {
  resize: none;
  line-height: 1.35;
  max-height: 120px;
}

.panel {
  min-height: 0;
}

.hidden {
  display: none;
}

.searchBox {
  display: grid;
}

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  border: 0;
  border-radius: var(--radius);
  background: #f2f4f7;
  padding: 4px;
}

.tabs button {
  min-height: 32px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.tabs button.active {
  background: #fff;
  color: var(--text);
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.08);
}

.panelHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 28px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 15px;
  font-weight: 650;
}

h2 {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.internalHeader button,
.composer button,
.dialogActions button {
  min-height: 34px;
  border: 1px solid var(--green-dark);
  border-radius: var(--radius);
  background: var(--green-dark);
  color: #fff;
  padding: 7px 11px;
}

.internalHeader button {
  display: grid;
  place-items: center;
  width: 32px;
  min-height: 32px;
  padding: 0;
  border-radius: 6px;
  font-size: 20px;
  line-height: 1;
}

.dialogActions button:first-child {
  border-color: var(--line-strong);
  background: #fff;
  color: var(--text);
}

.list {
  display: grid;
  gap: 1px;
  max-height: calc(100vh - 245px);
  overflow: auto;
}

.row {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  width: 100%;
  min-height: 58px;
  border: 1px solid transparent;
  border-radius: 0;
  background: transparent;
  padding: 8px;
  color: inherit;
  text-align: left;
  position: relative;
}

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

.row.active {
  border-color: var(--green-line);
  border-radius: var(--radius);
  background: var(--active);
}

.row strong,
.row small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row strong {
  color: var(--text);
  font-size: 14px;
  font-weight: 620;
}

.row time {
  align-self: start;
  padding-top: 3px;
}

.unreadPill {
  position: absolute;
  right: 8px;
  bottom: 7px;
  min-width: 18px;
  height: 18px;
  border-radius: 999px;
  background: var(--green-dark);
  color: #fff;
  display: grid;
  place-items: center;
  padding: 0 5px;
  font-size: 11px;
  font-style: normal;
  font-weight: 700;
}

.avatar {
  position: relative;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1px solid #d0d5dd;
  border-radius: 50%;
  background: #f9fafb;
  color: #475467;
  font-size: 12px;
  font-weight: 700;
}

.avatar.online::after {
  content: "";
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: 9px;
  height: 9px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: #16a34a;
}

.avatar.group {
  border-color: var(--green-line);
  background: var(--green-soft);
  color: var(--green-dark);
}

.chat {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-width: 0;
  min-height: 100vh;
  background: var(--panel);
}

.chatHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 60px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  padding: 10px 20px;
}

.messages {
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow: auto;
  background: #f7f8fa;
  padding: 20px 24px;
}

.conversationEmpty,
.emptyState {
  color: var(--muted);
  font-size: 13px;
}

.conversationEmpty {
  display: grid;
  place-items: center;
  min-height: 100%;
  text-align: center;
}

.emptyState {
  padding: 14px 8px;
}

.emptyCard {
  display: grid;
  justify-items: center;
  gap: 8px;
  width: min(360px, 90%);
  color: var(--muted);
}

.emptyCard strong {
  color: var(--text);
  font-size: 16px;
  font-weight: 650;
}

.emptyCard span {
  line-height: 1.45;
}

.emptyCard button {
  min-height: 34px;
  margin-top: 6px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 7px 12px;
  font-weight: 650;
}

.emptyCard button:hover {
  background: var(--hover);
}

.loadingState {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 100%;
}

.loadingState span {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--muted-2);
  animation: pulse 0.9s ease-in-out infinite;
}

.loadingState span:nth-child(2) {
  animation-delay: 0.12s;
}

.loadingState span:nth-child(3) {
  animation-delay: 0.24s;
}

@keyframes pulse {
  0%,
  80%,
  100% {
    opacity: 0.35;
    transform: translateY(0);
  }

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

.bubble {
  max-width: min(680px, 78%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  padding: 9px 11px;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
}

.bubble.mine {
  align-self: flex-end;
  border-color: var(--green-line);
  background: var(--green-soft);
}

.bubble header {
  display: flex;
  gap: 8px;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

.bubble p {
  white-space: pre-wrap;
  line-height: 1.4;
}

.composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  border-top: 1px solid var(--line);
  background: var(--panel);
  padding: 12px 16px;
}

.composer textarea {
  min-height: 42px;
  border-color: var(--line-strong);
  background: #fff;
  padding: 10px 12px;
}

.composer button {
  align-self: end;
  min-height: 42px;
  border-radius: 6px;
  font-weight: 650;
}

.typingIndicator {
  min-height: 24px;
  border-top: 0;
  background: #f7f8fa;
  color: var(--muted);
  font-size: 12px;
  padding: 4px 24px 0;
}

dialog {
  width: min(440px, calc(100vw - 24px));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0;
  box-shadow: 0 24px 48px rgba(16, 24, 40, 0.18);
}

dialog::backdrop {
  background: rgba(16, 24, 40, 0.32);
}

.dialogBody {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.dialogBody h2 {
  color: var(--text);
  font-size: 15px;
  text-transform: none;
}

.checks {
  display: grid;
  gap: 8px;
  max-height: 260px;
  overflow: auto;
}

.checks label {
  display: flex;
  align-items: center;
  gap: 8px;
}

.checks input {
  width: auto;
}

.dialogActions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.notice {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 10;
  max-width: min(360px, calc(100vw - 36px));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--text);
  box-shadow: 0 12px 30px rgba(16, 24, 40, 0.16);
  font-size: 13px;
  padding: 10px 12px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 0.16s ease, transform 0.16s ease;
}

.notice.show {
  opacity: 1;
  transform: translateY(0);
}

.notice.error {
  border-color: #fecaca;
  background: #fff7f7;
}

.fatalError {
  display: grid;
  place-content: center;
  gap: 8px;
  min-height: 100vh;
  background: #f7f8fa;
  color: var(--muted);
  padding: 24px;
  text-align: center;
}

.fatalError strong {
  color: var(--text);
  font-size: 16px;
}

body.embedded {
  background: #fff;
}

body.embedded .shell {
  grid-template-columns: 340px minmax(0, 1fr);
  min-height: 100vh;
}

body.embedded .sidebar {
  gap: 10px;
  padding: 0;
  background: #fff;
}

body.embedded .brand {
  display: none;
}

body.embedded .field {
  display: none;
}

body.embedded .internalHeader {
  display: flex;
}

body:not(.embedded) .internalHeader {
  display: none;
}

body.embedded .searchBox {
  padding: 12px 12px 0;
}

body.embedded .tabs {
  margin: 0 12px;
}

body.embedded .panel {
  min-height: 0;
  padding: 0 8px;
}

body.embedded .panelHeader {
  padding: 2px 8px;
}

body.embedded .list {
  max-height: calc(100vh - 166px);
}

body.embedded .chatHeader {
  min-height: 60px;
  padding: 10px 20px;
  background: #fff;
}

body.embedded .messages {
  padding: 20px 24px;
}

body.embedded .composer {
  padding: 12px 16px;
}

body.embedded .typingIndicator {
  padding: 4px 24px 0;
}

body.embedded .bubble {
  max-width: 86%;
}

@media (max-width: 840px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .chat {
    min-height: 65vh;
  }
}

@media (max-width: 620px) {
  body.embedded .shell {
    grid-template-columns: 1fr;
  }
}
