:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #182230;
  background: #f5f7fb;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  --muted: #718096;
  --line: #e6eaf0;
  --blue: #3659c9;
  --blue-light: #eef2ff;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  min-width: 320px;
  margin: 0;
  background: #f5f7fb;
  font-size: 14px;
}

button, input, textarea { font: inherit; }
button { cursor: pointer; }

.topbar {
  height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 max(28px, calc((100vw - 1200px) / 2));
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #1d2a42;
  font-size: 17px;
  font-weight: 750;
  letter-spacing: -.3px;
  text-decoration: none;
}

.brand-mark {
  width: 31px;
  height: 31px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  background: #3659c9;
  color: white;
  font-weight: 800;
}

.brand-light { font-weight: 450; color: #58657a; }
.environment-tag, .eyebrow { color: #586cbb; font-size: 10px; font-weight: 800; letter-spacing: 1.1px; }
.environment-tag { padding: 7px 9px; border-radius: 6px; background: #eef2ff; }
.page { width: min(1200px, calc(100% - 48px)); margin: 34px auto 24px; }

.notice {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 17px;
  border: 1px solid #cbd7ff;
  border-radius: 10px;
  background: #f0f4ff;
  color: #293d78;
}

.notice-icon {
  width: 20px;
  height: 20px;
  flex: 0 0 20px;
  display: grid;
  place-items: center;
  margin-top: 1px;
  border-radius: 50%;
  background: #dce5ff;
  font-size: 12px;
  font-weight: 800;
}

.notice strong { font-size: 13px; }
.notice p { margin: 4px 0 0; color: #55678e; font-size: 12px; line-height: 1.5; }
.intro { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin: 29px 0 19px; }
.eyebrow { margin: 0 0 7px; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 5px; font-size: 27px; letter-spacing: -.8px; }
.subtitle { margin-bottom: 0; color: var(--muted); }
.intro-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 9px; }
.subtitle #agent-session-status { color: #5265aa; font-size: 11px; font-weight: 650; }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 38px;
  padding: 0 13px;
  border: 1px solid transparent;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 700;
  transition: background .15s ease, border-color .15s ease;
}

.button:focus-visible, input:focus-visible, textarea:focus-visible {
  outline: 3px solid #b9c8ff;
  outline-offset: 2px;
}
.button-primary { background: var(--blue); color: #fff; }
.button-primary:hover { background: #2948ae; }
.button-secondary { border-color: #dce2eb; background: #fff; color: #354258; }
.button-secondary:hover, .button-tertiary:hover { background: #f3f5f9; }
.button-tertiary { border-color: #e1e6ee; background: #fff; color: #657188; }
.button:disabled { cursor: wait; opacity: .6; }

.workspace { display: grid; grid-template-columns: 345px minmax(0, 1fr); gap: 16px; min-height: 500px; }
.panel { overflow: hidden; border: 1px solid var(--line); border-radius: 11px; background: #fff; box-shadow: 0 2px 8px rgb(27 42 77 / 3%); }
.inbox { position: relative; }
.inbox-heading { display: flex; align-items: center; justify-content: space-between; padding: 18px 17px 15px; border-bottom: 1px solid #edf0f4; }
.inbox-heading h2 { margin: 0 0 3px; font-size: 14px; }
.muted { color: var(--muted); font-size: 11px; }
.online-indicator { display: flex; align-items: center; gap: 6px; color: #627084; font-size: 10px; }
.online-indicator span { width: 7px; height: 7px; border-radius: 50%; background: #37ad7a; }
.conversation-list { max-height: 450px; overflow-y: auto; }
.conversation-card { display: flex; width: 100%; gap: 11px; padding: 14px 15px; border: 0; border-bottom: 1px solid #f0f2f6; background: #fff; text-align: left; }
.conversation-card:hover { background: #f8f9fc; }
.conversation-card.selected { background: #f0f3ff; box-shadow: inset 3px 0 var(--blue); }
.conversation-avatar, .customer-avatar { display: grid; flex: 0 0 37px; width: 37px; height: 37px; place-items: center; border-radius: 50%; background: #eef1f6; color: #58657a; font-size: 12px; font-weight: 750; }
.conversation-card-main { min-width: 0; flex: 1; }
.conversation-card-top { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.conversation-customer { overflow: hidden; color: #283349; font-size: 12px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.conversation-time { flex: 0 0 auto; color: #929bad; font-size: 10px; }
.conversation-preview { overflow: hidden; margin: 5px 0 7px; color: #778196; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.badge { display: inline-block; padding: 3px 6px; border-radius: 4px; background: #eef2ff; color: #4e62a8; font-size: 9px; font-weight: 800; letter-spacing: .25px; }
.badge-simulated { background: #fff3dc; color: #8d5d12; }
.badge-closed { margin-left: 4px; background: #eef0f3; color: #6f7888; }
.empty-list { display: flex; min-height: 250px; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 24px; color: var(--muted); text-align: center; }
.empty-list strong { color: #47536a; font-size: 12px; }
.empty-list span:last-child { max-width: 190px; font-size: 11px; line-height: 1.5; }
.empty-icon { color: #9aa6bc; font-size: 26px; }

.thread { display: flex; min-height: 500px; flex-direction: column; }
.thread-empty { display: flex; flex: 1; flex-direction: column; align-items: center; justify-content: center; padding: 30px; text-align: center; }
.thread-empty-icon { display: grid; width: 51px; height: 51px; place-items: center; margin-bottom: 15px; border-radius: 16px; background: #f0f3fa; color: #8896af; font-size: 22px; }
.thread-empty h2 { margin-bottom: 6px; font-size: 15px; }
.thread-empty p { max-width: 280px; margin: 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
#thread-content { display: flex; min-height: 498px; flex: 1; flex-direction: column; }
.thread-header { display: flex; align-items: center; gap: 11px; padding: 14px 18px; border-bottom: 1px solid #edf0f4; }
.customer-avatar { width: 39px; height: 39px; flex-basis: 39px; background: #edf0fb; color: #586cb2; }
.thread-person { min-width: 0; flex: 1; }
.thread-person h2 { margin: 0 0 4px; font-size: 13px; }
.thread-person span { color: var(--muted); font-size: 10px; }
.synthetic-strip { padding: 8px 14px; background: #fff9eb; color: #92631d; font-size: 9px; font-weight: 800; letter-spacing: .6px; text-align: center; }
.messages { display: flex; flex: 1; flex-direction: column; gap: 14px; overflow-y: auto; padding: 19px; }
.message-row { display: flex; max-width: 86%; flex-direction: column; align-items: flex-start; gap: 5px; }
.message-row.agent { align-self: flex-end; align-items: flex-end; }
.message-meta { color: #8993a5; font-size: 10px; }
.message-bubble { padding: 10px 12px; border: 1px solid #e9edf3; border-radius: 4px 12px 12px; background: #f6f7fa; color: #374258; font-size: 12px; line-height: 1.55; overflow-wrap: anywhere; white-space: pre-wrap; }
.message-row.agent .message-bubble { border-color: #dce4ff; border-radius: 12px 4px 12px 12px; background: #f0f3ff; }
.message-label { color: #a3772f; font-size: 9px; font-weight: 750; }
.composer { display: flex; gap: 9px; padding: 12px 16px 8px; border-top: 1px solid #edf0f4; }
.composer input, .dialog input, .dialog textarea, .dialog select { width: 100%; min-width: 0; border: 1px solid #dfe4ec; border-radius: 7px; background: #fff; color: #283349; }
.composer input { height: 38px; padding: 0 11px; font-size: 12px; }
.composer-note { margin: 0; padding: 0 16px 13px; color: #929bad; font-size: 10px; }
.agents { display: flex; align-items: center; justify-content: space-between; gap: 24px; margin-top: 16px; padding: 16px 18px; }
.agents-title { display: flex; align-items: center; gap: 11px; }
.agents-icon { color: #6174bc; font-size: 21px; }
.agents-title h2 { margin: 0 0 3px; font-size: 12px; }
.agents-title p { margin: 0; color: var(--muted); font-size: 10px; }
.agent-list { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 7px; }
.agent-chip { padding: 7px 9px; border: 1px solid #e8ebf0; border-radius: 20px; color: #5c677a; font-size: 10px; }
.agent-chip::before { display: inline-block; width: 6px; height: 6px; margin-right: 6px; border-radius: 50%; background: #37ad7a; content: ""; }
.footer { display: flex; justify-content: space-between; gap: 12px; padding: 14px 2px 0; color: #929bad; font-size: 10px; }
.error-banner { margin: 0 0 14px; padding: 10px 12px; border: 1px solid #efc7c7; border-radius: 7px; background: #fff3f3; color: #9a3434; font-size: 12px; }
.success-banner { margin: 0 0 14px; padding: 10px 12px; border: 1px solid #b8dfcb; border-radius: 7px; background: #effaf4; color: #286344; font-size: 12px; }

.dialog { width: min(470px, calc(100% - 32px)); padding: 0; border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 18px 70px rgb(22 35 67 / 20%); }
.dialog::backdrop { background: rgb(21 31 51 / 36%); }
.dialog form { padding: 22px; }
.dialog-heading { display: flex; justify-content: space-between; align-items: start; margin-bottom: 19px; }
.dialog-heading h2 { margin: 0; font-size: 18px; }
.dialog-close { width: 30px; height: 30px; border: 0; border-radius: 6px; background: transparent; color: #758095; font-size: 22px; }
.dialog label { display: block; margin: 13px 0 6px; color: #49556a; font-size: 11px; font-weight: 700; }
.dialog input, .dialog textarea, .dialog select { padding: 10px; font-size: 12px; }
.dialog textarea { resize: vertical; }
.dialog-note { margin: 10px 0 0; color: #929bad; font-size: 10px; line-height: 1.5; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; clip-path: inset(50%); }

@media (max-width: 760px) {
  .topbar { height: 60px; padding: 0 18px; }
  .page { width: calc(100% - 28px); margin-top: 19px; }
  .intro { align-items: flex-start; flex-direction: column; margin-top: 22px; }
  .intro-actions { width: 100%; }
  .intro-actions .button { flex: 1; }
  .workspace { grid-template-columns: 1fr; }
  .inbox { min-height: 180px; }
  .conversation-list { max-height: 300px; }
  .thread { min-height: 420px; }
  #thread-content { min-height: 418px; }
  .agents { align-items: flex-start; flex-direction: column; gap: 13px; }
  .agent-list { justify-content: flex-start; }
  .footer { flex-direction: column; }
}

@media (max-width: 450px) {
  .environment-tag { padding: 6px; font-size: 8px; }
  h1 { font-size: 24px; }
  .button { padding: 0 9px; font-size: 11px; }
  .thread-header { padding: 12px; }
  .thread-header .button { max-width: 100px; white-space: normal; }
  .messages { padding: 13px; }
}
