:root {
  color-scheme: light;
  --bg: #f5f2ec;
  --panel: #ffffff;
  --ink: #1e1a17;
  --muted: #6d675f;
  --line: #ddd6cc;
  --accent: #c47a12;
  --accent-ink: #ffffff;
  --ai: #f1ece4;
  --human: #e8f3ea;
  --error: #a3261b;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
}

.demo-inbox {
  max-width: 1180px;
  margin: 0 auto;
  padding: 24px 18px 40px;
}

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

.topbar h1 { margin: 0 0 4px; font-size: 24px; }
.topbar p { margin: 0; color: var(--muted); }
.topbar code { font-size: 13px; }
.top-actions { display: flex; align-items: center; gap: 14px; }
.top-actions a { color: var(--accent); font-weight: 650; text-decoration: none; }

button {
  border: 0;
  border-radius: 9px;
  background: var(--accent);
  color: var(--accent-ink);
  padding: 10px 16px;
  font: inherit;
  font-weight: 650;
  cursor: pointer;
}
button:disabled { opacity: .55; cursor: default; }

.login-panel {
  max-width: 380px;
  margin: 8vh auto 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 24px;
}
.login-panel h2 { margin: 0 0 18px; font-size: 19px; }
.login-panel label { display: block; margin: 12px 0 6px; font-weight: 600; }
.login-panel input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  font: inherit;
  background: #fff;
}
.login-panel button { width: 100%; margin-top: 18px; }
.error { color: var(--error); min-height: 1.4em; margin: 10px 0 0; font-size: 13px; }

.inbox-panel {
  display: grid;
  grid-template-columns: 330px minmax(0, 1fr);
  gap: 16px;
  min-height: 62vh;
}

.list-pane, .thread-pane {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
}

.list-pane { padding: 16px; }
.list-pane h2 { margin: 0 0 12px; font-size: 15px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }

.conv-list { display: flex; flex-direction: column; gap: 6px; }
.conv-item {
  width: 100%;
  text-align: left;
  background: transparent;
  color: var(--ink);
  border: 1px solid transparent;
  padding: 11px 12px;
  border-radius: 10px;
  font-weight: 500;
}
.conv-item:hover { background: #faf7f2; }
.conv-item.active { background: #f7efe2; border-color: #e6d3b2; }
.conv-item strong { display: block; font-size: 13px; }
.conv-item span { display: block; color: var(--muted); font-size: 12px; margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-empty { color: var(--muted); font-size: 13px; padding: 8px 2px; }

.thread-pane { display: flex; flex-direction: column; }
.thread-head {
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  font-weight: 650;
  display: flex;
  justify-content: space-between;
  gap: 12px;
}
.thread-head span { color: var(--muted); font-weight: 500; font-size: 13px; }

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #fcfaf7;
}
.message { max-width: 76%; padding: 10px 13px; border-radius: 12px; white-space: pre-wrap; overflow-wrap: anywhere; }
.message .meta { display: block; margin-top: 4px; font-size: 11px; color: var(--muted); }
.message-images { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.message-images img { width: 72px; height: 72px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); background: #fff; }
.message.user { align-self: flex-start; background: #fff; border: 1px solid var(--line); }
.message.ai { align-self: flex-end; background: var(--ai); }
.message.human { align-self: flex-end; background: var(--human); }
.messages-empty { margin: auto; color: var(--muted); font-size: 14px; }

.reply-form {
  border-top: 1px solid var(--line);
  padding: 12px;
  display: flex;
  gap: 10px;
  align-items: flex-end;
}
.reply-form textarea {
  flex: 1;
  resize: vertical;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 10px 12px;
  font: inherit;
}
.status { min-height: 1.5em; margin: 14px 0 0; color: var(--muted); font-size: 13px; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 760px) {
  .inbox-panel { grid-template-columns: 1fr; }
  .list-pane { max-height: 38vh; overflow-y: auto; }
  .thread-pane { min-height: 52vh; }
}
