:root {
  color-scheme: light;
  --ink: #17211f;
  --muted: #5e6b67;
  --line: #d8dfdc;
  --surface: #f8faf9;
  --panel: #ffffff;
  --accent: #246b61;
  --accent-strong: #17483f;
  --warn: #8a5b12;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--surface);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--ink);
  min-height: 34px;
  padding: 6px 10px;
  cursor: pointer;
}

button:hover {
  border-color: var(--accent);
}

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.brand {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-logo {
  width: 42px;
  height: 42px;
  object-fit: contain;
  display: block;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 22px;
}

.topbar p,
.thread-header p,
.thread-item span,
.message header span {
  color: var(--muted);
  font-size: 13px;
}

.token {
  display: grid;
  gap: 6px;
  min-width: min(420px, 50vw);
  font-size: 12px;
  color: var(--muted);
}

input,
select,
textarea {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--ink);
  padding: 8px 10px;
}

.workspace {
  display: grid;
  grid-template-columns: 340px 1fr;
  min-height: 0;
}

.sidebar {
  border-right: 1px solid var(--line);
  padding: 14px;
  min-height: 0;
  overflow: auto;
}

.control-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  margin-bottom: 8px;
}

.wide {
  width: 100%;
  margin-bottom: 8px;
}

.status-line {
  min-height: 18px;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 12px;
}

.thread-list {
  display: grid;
  gap: 8px;
}

.thread-item {
  display: grid;
  gap: 4px;
  text-align: left;
  width: 100%;
  padding: 10px;
}

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

.thread-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.actions {
  display: flex;
  gap: 8px;
}

.messages {
  overflow: auto;
  padding: 18px;
  display: grid;
  align-content: start;
  gap: 12px;
}

.message {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.message header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.message h3 {
  margin: 0 0 8px;
  font-size: 17px;
}

.message h4 {
  margin: 12px 0 4px;
  font-size: 14px;
}

code {
  background: #eef3f1;
  border-radius: 4px;
  padding: 1px 4px;
}

.reply {
  display: grid;
  grid-template-columns: 120px 150px 180px 1fr auto;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--line);
  background: var(--panel);
}

.reply textarea {
  min-height: 44px;
  resize: vertical;
}

@media (max-width: 860px) {
  .topbar,
  .thread-header {
    align-items: stretch;
    flex-direction: column;
  }

  .brand {
    grid-template-columns: 36px minmax(0, 1fr);
  }

  .brand-logo {
    width: 36px;
    height: 36px;
  }

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

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    max-height: 280px;
  }

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