:root {
  color-scheme: light;
  --bg: #f5f7f8;
  --panel: #ffffff;
  --line: #d9e0e4;
  --text: #162126;
  --muted: #65747c;
  --accent: #0f766e;
  --accent-dark: #115e59;
  --warn: #b45309;
  --danger: #b91c1c;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
}

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

.dialogs,
.thread {
  background: var(--panel);
}

.dialogs {
  border-right: 1px solid var(--line);
}

.topbar,
.thread-header,
.reply {
  padding: 18px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 24px;
}

h2 {
  font-size: 20px;
}

p,
.mode,
.meta,
.draft {
  color: var(--muted);
}

.mode {
  padding: 0 18px 14px;
  font-size: 14px;
}

.switch input {
  display: none;
}

.switch span {
  display: block;
  width: 52px;
  height: 30px;
  border-radius: 999px;
  background: #c9d3d8;
  position: relative;
  cursor: pointer;
}

.switch span::after {
  content: "";
  position: absolute;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: white;
  top: 3px;
  left: 3px;
  transition: transform .18s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .2);
}

.switch input:checked + span {
  background: var(--accent);
}

.switch input:checked + span::after {
  transform: translateX(22px);
}

.dialog-list {
  border-top: 1px solid var(--line);
}

.dialog {
  width: 100%;
  min-height: 82px;
  padding: 14px 18px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: white;
  text-align: left;
  cursor: pointer;
}

.dialog:hover,
.dialog.active {
  background: #eef7f6;
}

.dialog-title {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-weight: 700;
}

.badge,
.status {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 6px;
  padding: 2px 8px;
  background: #e8eef1;
  color: #34444c;
  font-size: 12px;
}

.status.needs_manager,
.badge.needs_manager {
  background: #fff3d7;
  color: var(--warn);
}

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

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

.messages {
  padding: 22px;
  overflow: auto;
}

.bubble {
  max-width: min(680px, 82%);
  margin-bottom: 14px;
  padding: 12px 14px;
  border-radius: 8px;
  background: #edf2f5;
}

.bubble.outbound {
  margin-left: auto;
  background: #d9f3ef;
}

.bubble.ai {
  border-left: 4px solid var(--accent);
}

.bubble .meta {
  margin-bottom: 5px;
  font-size: 12px;
}

.reply {
  border-top: 1px solid var(--line);
}

textarea {
  width: 100%;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  font: inherit;
}

.reply-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 10px;
}

button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--text);
  padding: 0 14px;
  font: inherit;
  cursor: pointer;
}

button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: white;
}

button.primary:hover {
  background: var(--accent-dark);
}

.draft {
  min-height: 22px;
  margin-top: 8px;
  font-size: 14px;
}

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

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

.legal-page {
  min-height: 100vh;
  background: var(--bg);
  padding: 32px 18px 56px;
}

.legal-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  max-width: 860px;
  margin: 0 auto 18px;
}

.legal-nav a {
  color: var(--accent-dark);
  font-weight: 700;
  text-decoration: none;
}

.legal-nav a:hover {
  text-decoration: underline;
}

.legal-content {
  max-width: 860px;
  margin: 0 auto;
  padding: 28px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.legal-content h1 {
  margin-bottom: 8px;
  font-size: 30px;
}

.legal-content h2 {
  margin-top: 24px;
  margin-bottom: 8px;
}

.legal-content p {
  margin: 0 0 12px;
  color: var(--text);
  line-height: 1.6;
}
