:root {
  color-scheme: light;
  --ink: #172033;
  --muted: #667085;
  --line: #d8dee8;
  --paper: #f6f8fb;
  --panel: #ffffff;
  --blue: #175cd3;
  --green: #087443;
  --amber: #b54708;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.shell {
  max-width: 1180px;
  margin: 0 auto;
  padding: 28px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}

.eyebrow,
.label {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .04em;
}

h1,
h2 {
  margin: 0;
  line-height: 1.15;
}

h1 {
  font-size: 34px;
}

h2 {
  font-size: 18px;
}

.actions {
  display: flex;
  gap: 8px;
}

input,
button {
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 12px;
  font: inherit;
}

button {
  background: var(--ink);
  color: white;
  cursor: pointer;
}

#refresh {
  background: var(--blue);
}

.status-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--line);
  margin-bottom: 18px;
}

.status-strip > div {
  background: var(--panel);
  padding: 14px 16px;
}

.status-strip strong {
  display: block;
  margin-top: 4px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.panel-head p {
  margin: 0;
  color: var(--muted);
}

.events {
  min-height: 420px;
}

.event {
  display: grid;
  grid-template-columns: 150px 130px 1fr;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.event:last-child {
  border-bottom: 0;
}

.badge {
  display: inline-flex;
  width: fit-content;
  border-radius: 999px;
  padding: 2px 8px;
  background: #e7f0ff;
  color: var(--blue);
  font-size: 12px;
  font-weight: 700;
}

.badge.echo {
  background: #e7f8ef;
  color: var(--green);
}

.badge.postback {
  background: #fff3e0;
  color: var(--amber);
}

.meta {
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

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

.inbox-layout {
  display: grid;
  grid-template-columns: minmax(260px, 34%) 1fr;
  min-height: 520px;
}

.conversation-list {
  display: grid;
  align-content: start;
  border-right: 1px solid var(--line);
  background: #fbfcfe;
}

.conversation-item {
  display: grid;
  gap: 5px;
  height: auto;
  min-height: 82px;
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  padding: 13px 14px;
  text-align: left;
}

.conversation-item:hover,
.conversation-item.active {
  background: #eef4ff;
}

.conversation-title,
.conversation-preview,
.conversation-meta {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation-title {
  font-weight: 700;
}

.conversation-preview,
.conversation-meta,
.bubble-meta,
.thread-head span {
  color: var(--muted);
  font-size: 12px;
}

.thread {
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-width: 0;
}

.thread-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.thread-head h3 {
  margin: 2px 0 0;
  font-size: 18px;
  overflow-wrap: anywhere;
}

.messages {
  display: grid;
  align-content: end;
  gap: 12px;
  padding: 18px;
}

.bubble {
  max-width: min(680px, 86%);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fff;
}

.bubble.outbound {
  justify-self: end;
  background: #ecfdf3;
  border-color: #abefc6;
}

.bubble.inbound {
  justify-self: start;
  background: #f8fbff;
}

.bubble-meta {
  margin-bottom: 4px;
}

.reply-form {
  display: grid;
  gap: 10px;
  padding: 14px 16px;
  border-top: 1px solid var(--line);
  background: #fbfcfe;
}

.reply-form textarea {
  width: 100%;
  min-height: 82px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  font: inherit;
  color: var(--ink);
}

.reply-form textarea:focus,
input:focus {
  outline: 2px solid #b2ccff;
  outline-offset: 1px;
}

.reply-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.reply-actions p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

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

.empty {
  padding: 32px 16px;
  color: var(--muted);
}

.doc {
  max-width: 760px;
  margin: 0 auto;
  padding: 44px 24px;
}

.doc h1 {
  margin-bottom: 20px;
}

.doc h2 {
  margin-top: 24px;
}

@media (max-width: 760px) {
  .shell {
    padding: 18px;
  }

  .topbar,
  .panel-head {
    display: block;
  }

  .actions {
    margin-top: 14px;
    flex-wrap: wrap;
  }

  .actions input {
    min-width: 0;
    width: 100%;
  }

  .status-strip,
  .event,
  .inbox-layout {
    grid-template-columns: 1fr;
  }

  .conversation-list {
    max-height: 260px;
    overflow: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .bubble {
    max-width: 100%;
  }

  .reply-actions {
    align-items: stretch;
    flex-direction: column;
  }
}
