:root {
  --paper: #faf8f3;
  --ink: #1a1a1a;
  --ink-muted: #4a4a4a;
  --ink-faint: #8a8a8a;
  --slate: #14324a;
  --accent: #a36b36;
  --accent-soft: #c89466;
  --divider: #e4ddcf;
  --panel: #f3ede0;
  --panel-strong: #ece4d2;
  --good: #3a6b3a;
  --bad: #8d3f3f;
  --warn: #906a22;
  --max: 1180px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Charter", "Iowan Old Style", "Palatino", "Georgia", serif;
  font-size: 17px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button,
textarea,
input {
  font: inherit;
}

.sitebar {
  border-bottom: 1px solid var(--divider);
  background: rgba(250, 248, 243, 0.97);
  position: sticky;
  top: 0;
  z-index: 20;
}

.sitebar-inner {
  max-width: var(--max);
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.brand,
.nav,
.mark,
h2,
.pill,
button,
input,
textarea,
.task-card,
.facts,
pre,
.microcopy {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", "Helvetica Neue", Helvetica, Arial, sans-serif;
}

.brand {
  color: var(--slate);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0;
  text-decoration: none;
  white-space: nowrap;
}

.nav {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 6px;
}

.nav-chip,
.pill {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  border: 1px solid var(--divider);
  border-radius: 3px;
  padding: 4px 9px;
  color: var(--ink-muted);
  background: var(--panel);
  font-size: 12px;
  white-space: nowrap;
}

.pill.ok {
  color: var(--good);
  border-color: rgba(58, 107, 58, 0.35);
}

.pill.warn {
  color: var(--warn);
  border-color: rgba(144, 106, 34, 0.35);
}

.wrap {
  max-width: var(--max);
  margin: 0 auto;
  padding: 34px 24px 56px;
}

.mast {
  margin-bottom: 18px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--divider);
}

.mark {
  font-size: 12px;
  letter-spacing: 0;
  font-weight: 700;
  color: var(--accent);
  margin: 0 0 12px;
  text-transform: uppercase;
}

h1 {
  max-width: 900px;
  font-size: 28px;
  line-height: 1.12;
  margin: 0;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: 0;
}

.deck {
  max-width: 760px;
  margin: 10px 0 0;
  color: var(--ink-muted);
  font-size: 15px;
}

h2 {
  font-size: 12px;
  letter-spacing: 0;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 12px;
  font-weight: 700;
}

p {
  margin: 0 0 16px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--divider);
  padding: 20px 24px;
  border-radius: 4px;
}

.panel.strong {
  background: var(--panel-strong);
}

.panel p:last-child {
  margin-bottom: 0;
}

.consent-panel {
  max-width: 760px;
}

.consent-form {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.field {
  display: grid;
  gap: 6px;
}

.field span {
  color: var(--ink-muted);
  font-size: 13px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

input,
textarea {
  width: 100%;
  min-width: 0;
  color: var(--ink);
  background: #fffdf8;
  border: 1px solid var(--divider);
  border-radius: 4px;
  padding: 11px 12px;
}

select {
  min-width: 0;
  color: var(--ink);
  background: #fffdf8;
  border: 1px solid var(--divider);
  border-radius: 4px;
  padding: 7px 8px;
  font: inherit;
}

textarea {
  resize: vertical;
}

.check {
  display: grid;
  grid-template-columns: 20px 1fr;
  gap: 10px;
  align-items: start;
  color: var(--ink-muted);
  font-size: 15px;
}

.check input {
  width: auto;
  margin-top: 6px;
}

button {
  border: 1px solid var(--slate);
  border-radius: 4px;
  padding: 10px 13px;
  cursor: pointer;
  font-weight: 650;
}

button.primary {
  color: #fffdf8;
  background: var(--slate);
}

button.primary:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

button.ghost {
  color: var(--slate);
  background: transparent;
  border-color: var(--divider);
}

.microcopy {
  color: var(--ink-faint);
  font-size: 13px;
  line-height: 1.45;
}

.start-status {
  min-height: 20px;
  margin: 0;
  color: var(--ink-muted);
}

.start-status[data-kind="error"] {
  color: var(--bad);
  font-weight: 650;
}

.research-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 440px);
  gap: 14px;
  align-items: stretch;
  height: calc(100vh - 178px);
  min-height: 560px;
}

.hidden {
  display: none;
}

.chat-pane,
.side-pane {
  min-height: 0;
}

.chat-pane {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  background: #fffdf8;
  border: 1px solid var(--divider);
  border-radius: 4px;
  overflow: hidden;
}

.side-pane {
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr);
  gap: 10px;
  min-height: 0;
  overflow: auto;
  padding-right: 2px;
}

.pane-head {
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--divider);
  background: var(--panel);
}

.pane-head.flat {
  padding: 0 0 14px;
  border: 0;
  background: transparent;
}

.pane-head p {
  margin: 0;
  color: var(--ink-muted);
  font-size: 13px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.status-cluster {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
}

.mini-control {
  display: grid;
  grid-template-columns: auto minmax(88px, 150px);
  align-items: center;
  gap: 6px;
  color: var(--ink-muted);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 12px;
}

.mini-control select {
  height: 30px;
  padding: 4px 7px;
  font-size: 12px;
}

.messages {
  min-height: 0;
  overflow: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.message {
  width: min(720px, 100%);
  border: 1px solid var(--divider);
  border-radius: 4px;
  padding: 12px 13px;
  background: var(--panel);
}

.message.user {
  align-self: flex-end;
  background: #eef0e6;
  border-color: rgba(58, 107, 58, 0.24);
}

.message.assistant {
  align-self: flex-start;
  background: var(--panel-strong);
}

.message .role {
  display: block;
  color: var(--ink-faint);
  font-size: 11px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  text-transform: uppercase;
  font-weight: 700;
  margin-bottom: 4px;
}

.message .text {
  white-space: pre-wrap;
}

.composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  padding: 10px;
  border-top: 1px solid var(--divider);
  background: var(--panel);
}

.composer textarea {
  min-height: 86px;
  max-height: 150px;
}

.task-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
}

.task-card {
  width: 100%;
  text-align: left;
  color: var(--ink);
  background: #fffdf8;
  border-color: var(--divider);
  font-weight: 500;
  padding: 8px 9px;
  min-height: 76px;
}

.task-card strong {
  display: block;
  color: var(--slate);
  font-size: 13px;
}

.task-card span {
  display: block;
  color: var(--ink-muted);
  font-size: 11px;
  line-height: 1.3;
  margin-top: 3px;
}

.task-card.active {
  border-color: var(--accent);
  background: var(--panel-strong);
}

.facts {
  display: grid;
  gap: 10px;
  margin: 0;
}

.facts div {
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr);
  gap: 12px;
  border-bottom: 1px solid var(--divider);
  padding-bottom: 8px;
}

.facts dt {
  color: var(--ink-faint);
  font-size: 11px;
  text-transform: uppercase;
  font-weight: 700;
}

.facts dd {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--slate);
  font-size: 13px;
}

pre {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: var(--ink-muted);
  font-size: 12px;
  line-height: 1.45;
}

.compact-boundary {
  padding: 12px 14px;
}

.compact-boundary p {
  margin: 0;
  color: var(--ink-muted);
  font-size: 13px;
  line-height: 1.4;
}

@media (max-width: 920px) {
  .research-shell {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 0;
  }

  .side-pane {
    min-height: 0;
    overflow: visible;
  }
}

@media (max-width: 640px) {
  .wrap {
    padding: 24px 14px 52px;
  }

  h1 {
    font-size: 25px;
  }

  .sitebar-inner,
  .pane-head {
    align-items: stretch;
    flex-direction: column;
  }

  .mini-control {
    grid-template-columns: 58px minmax(0, 1fr);
  }

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

  .task-list {
    grid-template-columns: 1fr;
  }
}
