:root {
  color-scheme: light;
  --background: #f6f6f3;
  --surface: #ffffff;
  --surface-muted: #eeeeea;
  --text: #151515;
  --muted: #767676;
  --line: #d9d9d2;
  --accent: #1f7a5a;
  --accent-strong: #155f45;
  --danger: #a33a2a;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

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

button,
input,
textarea {
  font: inherit;
}

button {
  border: 0;
  background: var(--text);
  color: #fff;
  min-height: 40px;
  padding: 0 16px;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  padding: 11px 12px;
  outline: none;
}

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

textarea {
  min-height: 72px;
  max-height: 180px;
  resize: vertical;
}

.app-shell {
  min-height: 100vh;
}

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(100%, 360px);
  display: grid;
  gap: 14px;
}

.login-panel h1 {
  margin: 0;
  font-size: 34px;
  line-height: 1;
  letter-spacing: 0;
}

.brand {
  margin: 0;
  font-weight: 700;
}

.muted,
.error-text {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.error-text {
  color: var(--danger);
}

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

.thread-pane {
  border-right: 1px solid var(--line);
  background: var(--surface);
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr);
}

.pane-header,
.chat-header {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.chat-header h1 {
  margin: 0 0 4px;
  font-size: 18px;
  line-height: 1.2;
  letter-spacing: 0;
}

.secondary-button {
  background: var(--surface-muted);
  color: var(--text);
}

.filters {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-bottom: 1px solid var(--line);
}

.filter {
  background: var(--surface);
  color: var(--muted);
  border-right: 1px solid var(--line);
}

.filter:last-child {
  border-right: 0;
}

.filter.is-active {
  color: #fff;
  background: var(--accent);
}

.search-box {
  display: grid;
  gap: 6px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}

.thread-list {
  overflow: auto;
}

.thread-item {
  width: 100%;
  min-height: 76px;
  padding: 12px 16px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  text-align: left;
  display: grid;
  gap: 6px;
}

.thread-item.is-active {
  background: #e7f1ec;
}

.thread-topline,
.thread-subline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.thread-name,
.thread-subject,
.thread-preview {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.thread-name {
  font-weight: 700;
}

.thread-time,
.thread-mailbox,
.thread-preview {
  color: var(--muted);
  font-size: 12px;
}

.unread {
  min-width: 22px;
  height: 22px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  display: inline-grid;
  place-items: center;
  padding: 0 6px;
  font-size: 12px;
}

.chat-pane {
  min-width: 0;
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
}

.message-list {
  overflow: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.empty-state {
  margin: auto;
  color: var(--muted);
}

.message {
  width: min(680px, 84%);
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--line);
}

.message.outbound {
  align-self: flex-end;
  background: #17231d;
  color: #fff;
  border-color: #17231d;
}

.message.inbound {
  align-self: flex-start;
}

.message-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  font-size: 12px;
  color: var(--muted);
}

.message.outbound .message-meta {
  color: #b8c6be;
}

.message-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.45;
}

.attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.attachment {
  color: inherit;
  border: 1px solid currentColor;
  padding: 6px 8px;
  text-decoration: none;
  font-size: 12px;
}

.composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  padding: 14px;
  border-top: 1px solid var(--line);
  background: var(--surface);
}

.composer textarea {
  min-height: 48px;
}

[data-state="loading"] .login-view,
[data-state="authed"] .login-view,
[data-state="anonymous"] .workspace,
[data-state="loading"] .workspace {
  display: none;
}

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

  .thread-pane {
    min-height: 42vh;
    max-height: 42vh;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .chat-pane {
    min-height: 58vh;
  }

  .message-list {
    padding: 12px;
  }

  .message {
    width: min(100%, 640px);
  }

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