:root {
  color-scheme: light;
  --bg: #f6f4ef;
  --panel: #fffaf1;
  --panel-2: #ffffff;
  --text: #211f1a;
  --muted: #6f675c;
  --line: #ded6ca;
  --accent: #2f7d74;
  --danger: #b84a4a;
  --shadow: 0 14px 40px rgba(49, 42, 30, .10);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

button,
textarea {
  font: inherit;
}

.shell {
  display: grid;
  grid-template-columns: 300px 1fr;
  height: 100vh;
  min-height: 0;
}

.chats {
  display: flex;
  flex-direction: column;
  min-width: 0;
  border-right: 1px solid var(--line);
  background: var(--panel);
}

.topbar,
.dialog-head {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 76px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.topbar {
  justify-content: space-between;
}

.eyebrow {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.2;
}

h1,
h2 {
  margin: 2px 0 0;
  font-size: 22px;
  line-height: 1.15;
  letter-spacing: 0;
}

h2 {
  font-size: 19px;
}

.icon-btn,
.attach-btn {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--text);
  cursor: pointer;
}

.icon-btn:active,
.attach-btn:active,
#sendBtn:active {
  transform: translateY(1px);
}

.chat-list {
  overflow: auto;
  padding: 10px;
}

.chat-item {
  width: 100%;
  margin: 0 0 8px;
  padding: 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.chat-item.active {
  border-color: var(--accent);
  background: #e7f3ef;
}

.chat-title {
  display: block;
  overflow: hidden;
  color: var(--text);
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-meta {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.dialog {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--panel-2);
}

.messages {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 18px;
}

.empty {
  max-width: 520px;
  margin: 20vh auto 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.empty b,
.empty span {
  display: block;
}

.empty span {
  margin-top: 8px;
  color: var(--muted);
}

.message {
  max-width: min(760px, 92%);
  margin: 0 0 14px;
  padding: 12px 14px;
  border-radius: 8px;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.message.user {
  margin-left: auto;
  background: #dbefe9;
}

.message.assistant {
  background: #f7efe0;
}

.message-meta {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.file-chip {
  display: inline-flex;
  max-width: 100%;
  margin: 6px 6px 0 0;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  font-size: 12px;
}

.composer {
  padding: 12px;
  border-top: 1px solid var(--line);
  background: var(--panel);
}

.composer-row {
  display: grid;
  grid-template-columns: 42px 1fr auto;
  gap: 8px;
  align-items: end;
}

.attach-btn input {
  display: none;
}

textarea {
  width: 100%;
  max-height: 150px;
  min-height: 42px;
  resize: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  outline: none;
}

textarea:focus {
  border-color: var(--accent);
}

#sendBtn {
  height: 42px;
  border: 0;
  border-radius: 8px;
  padding: 0 16px;
  background: var(--accent);
  color: white;
  cursor: pointer;
  font-weight: 700;
}

#sendBtn:disabled {
  cursor: wait;
  opacity: .65;
}

.attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.attachment {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 8px;
  background: var(--panel-2);
  color: var(--muted);
  font-size: 12px;
}

.attachment button {
  border: 0;
  background: transparent;
  color: var(--danger);
  cursor: pointer;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  z-index: 10;
  max-width: min(420px, calc(100vw - 28px));
  transform: translateX(-50%) translateY(20px);
  border-radius: 8px;
  padding: 10px 12px;
  background: rgba(33, 31, 26, .92);
  color: #fff;
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.mobile-only {
  display: none;
}

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

  .chats {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 5;
    width: min(86vw, 340px);
    box-shadow: var(--shadow);
    transform: translateX(-105%);
    transition: transform .18s ease;
  }

  body.show-chats .chats {
    transform: translateX(0);
  }

  .mobile-only {
    display: inline-grid;
  }

  .messages {
    padding: 12px;
  }

  .message {
    max-width: 96%;
  }

  .composer-row {
    grid-template-columns: 42px 1fr;
  }

  #sendBtn {
    grid-column: 1 / -1;
  }
}

