:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f4f6f8;
  color: #1f2933;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
}

button,
input {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  height: 100vh;
  min-height: 620px;
  background: #f4f6f8;
}

.sidebar {
  display: flex;
  min-width: 0;
  flex-direction: column;
  border-right: 1px solid #d9e0e7;
  background: #ffffff;
}

.sidebar-header,
.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 84px;
  padding: 18px 20px;
  border-bottom: 1px solid #d9e0e7;
}

.eyebrow {
  margin: 0 0 4px;
  color: #66788a;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 24px;
}

h2 {
  font-size: 18px;
}

.icon-button,
.send-button {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 8px;
  background: #0b74de;
  color: #ffffff;
  cursor: pointer;
}

.icon-button {
  background: #edf2f7;
  color: #27384a;
}

.icon-button:hover,
.send-button:hover {
  filter: brightness(0.96);
}

.conversation-list {
  overflow-y: auto;
  padding: 8px;
}

.conversation-button {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 12px;
  width: 100%;
  min-height: 68px;
  padding: 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.conversation-button:hover,
.conversation-button.active {
  background: #eef5fc;
}

.avatar {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  overflow: hidden;
  border-radius: 50%;
  background: #dde8f4;
  color: #22577a;
  font-weight: 800;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.conversation-name,
.conversation-preview,
.conversation-time {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation-name {
  font-weight: 750;
}

.conversation-preview {
  margin-top: 4px;
  color: #66788a;
  font-size: 14px;
}

.conversation-time {
  margin-top: 4px;
  color: #8b9aaa;
  font-size: 12px;
}

.chat-panel {
  display: grid;
  min-width: 0;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  background: #f8fafc;
}

.selected-person {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 12px;
}

.selected-person p {
  margin: 4px 0 0;
  color: #66788a;
  font-size: 14px;
}

.automation-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #3c4b5d;
  font-weight: 700;
  cursor: pointer;
}

.automation-toggle input {
  position: absolute;
  opacity: 0;
}

.switch {
  position: relative;
  width: 48px;
  height: 28px;
  border-radius: 999px;
  background: #c6d1dc;
  transition: background 0.16s ease;
}

.switch::after {
  position: absolute;
  top: 4px;
  left: 4px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 1px 4px rgb(15 23 42 / 22%);
  content: "";
  transition: transform 0.16s ease;
}

.automation-toggle input:checked + .switch {
  background: #0b74de;
}

.automation-toggle input:checked + .switch::after {
  transform: translateX(20px);
}

.status-line {
  min-height: 30px;
  padding: 8px 20px 0;
  color: #66788a;
  font-size: 13px;
}

.status-line.error {
  color: #b42318;
}

.message-thread {
  display: flex;
  min-height: 0;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  padding: 20px;
}

.empty-state {
  margin: auto;
  max-width: 360px;
  color: #66788a;
  line-height: 1.5;
  text-align: center;
}

.message-row {
  display: flex;
}

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

.bubble {
  max-width: min(72%, 620px);
  padding: 10px 12px;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 1px 2px rgb(15 23 42 / 10%);
}

.message-row.outgoing .bubble {
  background: #0b74de;
  color: #ffffff;
}

.bubble-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.bubble-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
  color: #66788a;
  font-size: 12px;
}

.message-row.outgoing .bubble-meta {
  color: #d9ecff;
}

.tag {
  border-radius: 999px;
  padding: 2px 7px;
  background: rgb(17 24 39 / 8%);
}

.message-row.outgoing .tag {
  background: rgb(255 255 255 / 18%);
}

.composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 46px;
  gap: 10px;
  padding: 16px 20px 20px;
  border-top: 1px solid #d9e0e7;
  background: #ffffff;
}

.composer input {
  min-width: 0;
  height: 46px;
  border: 1px solid #cbd5df;
  border-radius: 8px;
  padding: 0 14px;
  outline: none;
}

.composer input:focus {
  border-color: #0b74de;
  box-shadow: 0 0 0 3px rgb(11 116 222 / 14%);
}

.composer input:disabled,
.send-button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

@media (max-width: 760px) {
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: 230px minmax(0, 1fr);
    min-height: 100vh;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid #d9e0e7;
  }

  .sidebar-header,
  .chat-header {
    min-height: 72px;
    padding: 14px;
  }

  .conversation-list {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    overflow-y: hidden;
  }

  .conversation-button {
    width: 260px;
    flex: 0 0 260px;
  }

  .chat-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .bubble {
    max-width: 88%;
  }
}
