:root {
  --canvas: #f1f3ee;
  --sheet: #fcfdf9;
  --ink: #1c241f;
  --muted: #69736c;
  --line: #d9ded8;
  --working: #416aa3;
  --needs: #b35c2e;
  --idle: #879188;
  --focus: #335f50;
  --rail: 3px;
  --type: ui-sans-serif, system-ui, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", menlo, monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--type);
  font-size: 15px;
  line-height: 1.45;
}

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

button {
  border: 1px solid var(--line);
  background: var(--sheet);
  padding: 0.35rem 0.7rem;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

#lock-screen,
#shell {
  min-height: 100vh;
}

#lock-screen {
  max-width: 22rem;
  margin: 0 auto;
  padding: 3rem 1rem;
}

#access-form {
  display: grid;
  gap: 0.5rem;
}

#access-key,
#message,
#steer-message {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--sheet);
  padding: 0.5rem 0.6rem;
}

.pane-header {
  border-bottom: 1px solid var(--line);
  padding: 0.85rem 1rem;
}

.product {
  margin: 0;
  color: var(--muted);
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  text-transform: none;
}

.header-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-top: 0.6rem;
}

#chat-pane > .pane-header {
  display: grid;
  gap: 0.35rem;
}

#chat-pane > .pane-header .header-actions {
  margin-top: 0;
}

h1,
h2 {
  font-size: 1.05rem;
  font-weight: 600;
  margin: 0.15rem 0 0;
}

.muted {
  color: var(--muted);
  margin: 0.2rem 0 0;
}

#goal-list {
  display: flex;
  flex-direction: column;
}

#goal-repository {
  min-width: 0;
  padding: 0.8rem 1rem;
  border-bottom: 1px solid var(--line);
  overflow-wrap: anywhere;
}

#goal-repository-select {
  display: block;
  width: 100%;
  max-width: 32rem;
  margin-top: 0.35rem;
}

#repositories {
  min-width: 0;
  padding: 0.8rem 1rem;
  border-bottom: 1px solid var(--line);
}

.repository-heading,
.repository-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  justify-content: space-between;
}

.repository-row,
.repository-candidate {
  min-width: 0;
  padding: 0.65rem 0;
  border-top: 1px solid var(--line);
  overflow-wrap: anywhere;
}

.repository-row p,
.repository-candidate p {
  margin: 0.15rem 0;
}

.repository-row select {
  max-width: 100%;
}

.goal-row {
  display: grid;
  grid-template-columns: var(--rail) 1fr auto;
  gap: 0.75rem;
  align-items: center;
  width: 100%;
  text-align: left;
  background: var(--sheet);
  border: 0;
  border-bottom: 1px solid var(--line);
  padding: 0.85rem 1rem;
  cursor: pointer;
}

.goal-row .rail {
  align-self: stretch;
  width: var(--rail);
  background: var(--idle);
}

.goal-row.needs .rail {
  background: var(--needs);
}

.goal-row.working .rail {
  background: var(--working);
}

.goal-row .state {
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--muted);
}

.empty {
  padding: 1rem;
  color: var(--muted);
}

#needs-you-inbox {
  min-width: 0;
  max-width: 100%;
  border-bottom: 1px solid var(--line);
}

#needs-you-inbox[hidden] {
  display: none;
}

#needs-you-inbox h2 {
  padding: 0.7rem 1rem 0.2rem;
}

.needs-you-row {
  display: grid;
  grid-template-columns: var(--rail) minmax(0, 1fr);
  gap: 0.75rem;
  align-items: center;
  width: 100%;
  min-height: 44px;
  min-width: 0;
  max-width: 100%;
  text-align: left;
  background: var(--sheet);
  border: 0;
  border-bottom: 1px solid var(--line);
  padding: 0.7rem 1rem;
  cursor: pointer;
}

.needs-you-row .rail {
  align-self: stretch;
  width: var(--rail);
  background: var(--needs);
}

.needs-you-copy {
  display: grid;
  gap: 0.15rem;
  min-width: 0;
}

.needs-you-question,
.needs-you-copy .muted {
  overflow-wrap: anywhere;
}

#transcript,
#current-work,
#composer {
  padding: 0.85rem 1rem;
  border-top: 1px solid var(--line);
  background: var(--sheet);
}

.message {
  max-width: 38rem;
  margin: 0.45rem 0;
  white-space: pre-wrap;
}

.message.assistant {
  margin-right: auto;
}

.message.human,
.message.user {
  margin-left: auto;
  background: var(--canvas);
  border: 1px solid var(--line);
  padding: 0.5rem 0.7rem;
}

.message.pending {
  opacity: 0.65;
}

.envelope {
  display: grid;
  gap: 0.25rem;
  border-top: 1px solid var(--line);
  padding: 0.7rem 0;
}

.envelope.warning {
  border-left: var(--rail) solid var(--needs);
  padding-left: 0.7rem;
}

.envelope button {
  justify-self: start;
  background: var(--focus);
  color: var(--sheet);
  border: 1px solid var(--focus);
  padding: 0.35rem 0.7rem;
}

#composer,
#steer-composer {
  display: grid;
  gap: 0.4rem;
}

#send,
#steer {
  justify-self: end;
  background: var(--focus);
  color: var(--sheet);
  border: 1px solid var(--focus);
  padding: 0.4rem 0.85rem;
}

#send:disabled,
#steer:disabled {
  opacity: 0.5;
}

.live {
  min-height: 1.2em;
  color: var(--muted);
  padding: 0 1rem 1rem;
}

details.thread {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.7rem;
}

.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0.35rem 0 0;
}

.badge {
  border: 1px solid var(--line);
  padding: 0.1rem 0.45rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.badge.working {
  color: var(--working);
}

.badge.idle {
  color: var(--idle);
}

#room-pane {
  display: none;
  background: var(--sheet);
  min-width: 0;
  max-width: 100%;
  overflow-x: hidden;
}

#room-pane:not([hidden]) {
  display: block;
}

#room-pane > .pane-header,
#room-title,
#room-goal,
#room-needs-you,
#room-checkpoint,
#room-log,
#room-result,
#steer-composer,
#steer-message {
  min-width: 0;
  max-width: 100%;
}

#room-title,
#room-goal,
#room-needs-you p,
#room-checkpoint p,
#room-result p {
  overflow-wrap: anywhere;
}

#room-pane .header-actions {
  flex-wrap: wrap;
}

#room-needs-you {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--line);
  border-left: var(--rail) solid var(--needs);
  background: color-mix(in oklch, var(--needs) 14%, var(--sheet));
}

#room-needs-you[hidden] {
  display: none;
}

#room-needs-you #steer-composer {
  margin-top: 0.7rem;
}

#room-pane.room-needs-you-active #room-title {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
  max-height: calc(1.45em * 2);
}

#room-checkpoint,
#room-log,
#room-working,
#room-result {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--line);
}

#room-working {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--working);
}

#room-working[hidden] {
  display: none;
}

.room-working-dots {
  display: flex;
  gap: 0.28rem;
}

.room-working-dots span {
  width: 0.4rem;
  height: 0.4rem;
  border-radius: 50%;
  background: var(--working);
  animation: room-working-pulse 1.2s ease-in-out infinite;
}

.room-working-dots span:nth-child(2) {
  animation-delay: 0.2s;
}

.room-working-dots span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes room-working-pulse {
  0%,
  80%,
  100% {
    opacity: 0.28;
  }
  40% {
    opacity: 1;
  }
}

@media (min-width: 840px) {
  #shell:not([hidden]) {
    min-height: 100vh;
  }

  body:not(.chat-open) #goals-pane {
    max-width: 780px;
    margin: 0 auto;
    width: 100%;
  }

  body.chat-open #shell:not([hidden]),
  body.room-open #shell:not([hidden]) {
    display: grid;
    grid-template-columns: 320px minmax(0, 1fr);
  }
}

body.chat-open #lock-goals,
body.room-open #lock-goals {
  display: none;
}

@media (max-width: 839px) {
  body.chat-open #goals-pane,
  body.room-open #goals-pane {
    display: none;
  }

  body.chat-open #chat-pane {
    display: block;
  }

  body.room-open #room-pane {
    display: block;
  }

  body:not(.chat-open) #goals-status {
    display: block;
  }

  #chat-pane {
    min-width: 0;
  }

  #room-pane.room-needs-you-active > .pane-header {
    padding: 0.5rem 1rem;
  }

  #room-pane.room-needs-you-active #room-needs-you {
    padding: 0.55rem 1rem;
  }

  #room-pane.room-needs-you-active #room-needs-you #steer-composer {
    margin-top: 0.4rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }
}
