:root {
  color-scheme: light;
  --ink: #17211b;
  --muted: #657168;
  --paper: #f3f1e9;
  --panel: #fffdf7;
  --line: #d8d7cd;
  --accent: #216e49;
  --accent-dark: #145137;
  --accent-soft: #dcecdf;
  --rust: #b45432;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  min-height: 100vh;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .24;
  background-image: radial-gradient(#586158 0.55px, transparent 0.55px);
  background-size: 7px 7px;
}

button, input, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

.site-header {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1240px;
  margin: 0 auto;
  padding: 22px 28px;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex;
  gap: 11px;
  align-items: center;
  color: var(--ink);
  font-weight: 750;
  text-decoration: none;
  letter-spacing: -.02em;
}

.brand-mark {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 9px;
  color: #fff;
  background: var(--ink);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  letter-spacing: -.04em;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.status i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #2b9962;
  box-shadow: 0 0 0 4px rgba(43, 153, 98, .12);
}

main {
  position: relative;
  z-index: 1;
  max-width: 1240px;
  margin: 0 auto;
  padding: 72px 28px 40px;
}

.intro { max-width: 750px; margin-bottom: 52px; }
.eyebrow, .label {
  margin: 0 0 10px;
  color: var(--rust);
  font: 700 11px/1.2 ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: .13em;
  text-transform: uppercase;
}

.intro h1 {
  max-width: 690px;
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(44px, 7vw, 78px);
  font-weight: 500;
  line-height: .98;
  letter-spacing: -.045em;
}

.intro > p:not(.eyebrow) {
  max-width: 650px;
  margin: 25px 0 14px;
  color: #4e5b52;
  font-size: 17px;
  line-height: 1.65;
}

.api-link { color: var(--accent-dark); font-size: 14px; font-weight: 700; text-underline-offset: 4px; }

.board {
  display: grid;
  grid-template-columns: minmax(250px, 340px) minmax(0, 1fr);
  overflow: hidden;
  min-height: 640px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
  box-shadow: 0 20px 60px rgba(34, 41, 36, .08);
}

.conversation-panel { border-right: 1px solid var(--line); background: #eeeee6; }
.panel-heading, .thread-heading {
  display: flex;
  min-height: 90px;
  align-items: center;
  justify-content: space-between;
  padding: 22px 24px;
  border-bottom: 1px solid var(--line);
}

.panel-heading .label, .thread-heading .label { margin-bottom: 6px; color: var(--muted); }
h2 { margin: 0; font: 500 23px/1.2 Georgia, "Times New Roman", serif; }
.icon-button {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--ink);
  background: transparent;
  cursor: pointer;
}
.icon-button:hover { background: var(--panel); }

.conversation-list { padding: 10px; }
.conversation {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  padding: 14px;
  border: 0;
  border-radius: 9px;
  color: var(--ink);
  background: transparent;
  text-align: left;
  cursor: pointer;
}
.conversation:hover { background: rgba(255, 255, 255, .65); }
.conversation.active { color: #fff; background: var(--accent); }
.conversation-name { overflow: hidden; font-weight: 720; text-overflow: ellipsis; white-space: nowrap; }
.conversation-meta { margin-left: 10px; color: var(--muted); font: 12px ui-monospace, SFMono-Regular, Menlo, monospace; }
.conversation.active .conversation-meta { color: #cce4d5; }
.empty-state { padding: 26px 14px; color: var(--muted); font-size: 14px; }

.thread-panel { display: grid; grid-template-rows: auto minmax(310px, 1fr) auto; min-width: 0; }
.count { color: var(--muted); font: 12px ui-monospace, SFMono-Regular, Menlo, monospace; }
.message-list { overflow-y: auto; max-height: 620px; padding: 26px 28px; }
.message-card { padding: 18px 0; border-bottom: 1px solid #e8e5dc; }
.message-card:first-child { padding-top: 0; }
.message-card:last-child { border-bottom: 0; }
.message-meta { display: flex; gap: 12px; margin-bottom: 8px; color: var(--muted); font: 11px ui-monospace, SFMono-Regular, Menlo, monospace; }
.message-id { color: var(--rust); }
.message-text { margin: 0; overflow-wrap: anywhere; white-space: pre-wrap; font-size: 15px; line-height: 1.62; }
.empty-thread { display: grid; min-height: 280px; place-content: center; color: var(--muted); text-align: center; }
.empty-thread span { font-size: 42px; }

.composer { padding: 22px 24px; border-top: 1px solid var(--line); background: #f8f6ee; }
.field { display: flex; flex-direction: column; gap: 7px; }
.field + .field { margin-top: 14px; }
.field label { color: var(--muted); font-size: 12px; font-weight: 700; }
.field input, .field textarea {
  width: 100%;
  border: 1px solid #c9cbc0;
  border-radius: 8px;
  outline: none;
  color: var(--ink);
  background: #fff;
}
.field input { padding: 10px 12px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.field textarea { min-height: 80px; padding: 12px; resize: vertical; line-height: 1.5; }
.field input:focus, .field textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(33, 110, 73, .1); }
.composer-footer { display: flex; min-height: 42px; align-items: end; justify-content: space-between; gap: 20px; margin-top: 14px; }
#form-status { margin: 0; color: var(--muted); font-size: 13px; }
#form-status.error { color: #9b321f; }
.composer button[type="submit"] {
  flex: 0 0 auto;
  padding: 11px 17px;
  border: 0;
  border-radius: 8px;
  color: #fff;
  background: var(--accent);
  font-weight: 750;
  cursor: pointer;
}
.composer button[type="submit"]:hover { background: var(--accent-dark); }
.composer button[type="submit"]:disabled { opacity: .6; cursor: wait; }

footer {
  position: relative;
  z-index: 1;
  display: flex;
  max-width: 1240px;
  margin: 0 auto;
  padding: 8px 28px 38px;
  justify-content: space-between;
  color: var(--muted);
  font-size: 12px;
}
footer a { color: inherit; text-underline-offset: 3px; }

@media (max-width: 760px) {
  .site-header { padding: 18px; }
  main { padding: 50px 14px 28px; }
  .intro { margin: 0 8px 36px; }
  .intro h1 { font-size: clamp(43px, 15vw, 64px); }
  .board { grid-template-columns: 1fr; }
  .conversation-panel { border-right: 0; border-bottom: 1px solid var(--line); }
  .conversation-list { display: flex; overflow-x: auto; gap: 5px; }
  .conversation { width: auto; min-width: max-content; }
  .message-list { max-height: 470px; padding: 22px 18px; }
  .composer { padding: 20px 18px; }
  footer { padding: 8px 18px 30px; }
}
