:root {
  --ink: #1d241d;
  --moss: #263226;
  --clay: #b85f38;
  --paper: #fbf4e6;
  --field: #fffaf0;
  --muted: #6a6f62;
  --line: #263226;
  color: var(--ink);
  background: var(--paper);
  font-family: Georgia, "Times New Roman", serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(184, 95, 56, 0.22), transparent 34rem),
    linear-gradient(135deg, #fbf4e6 0%, #e7dcc4 100%);
}

button,
textarea,
input {
  font: inherit;
}

button {
  appearance: none;
  background: var(--moss);
  border: 0;
  color: var(--paper);
  cursor: pointer;
  font-weight: 700;
  padding: 0.85rem 1rem;
}

button:disabled {
  cursor: wait;
  opacity: 0.55;
}

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

textarea,
input {
  background: var(--field);
  border: 2px solid var(--line);
  color: var(--ink);
  display: block;
  margin-top: 0.5rem;
  padding: 0.75rem;
  width: 100%;
}

label {
  display: block;
  font-weight: 700;
  margin-top: 1rem;
}

.app-shell {
  margin: 0 auto;
  max-width: 960px;
  padding: max(1rem, env(safe-area-inset-top)) 1rem 2rem;
}

.hero-card,
.panel {
  background: rgba(255, 250, 240, 0.92);
  border: 2px solid var(--line);
  box-shadow: 0.5rem 0.5rem 0 var(--clay);
}

.hero-card {
  align-items: start;
  display: flex;
  gap: 1rem;
  justify-content: space-between;
  margin: 1rem 0 1.5rem;
  padding: 1.25rem;
}

.hero-card h1 {
  font-size: clamp(2rem, 7vw, 4.5rem);
  letter-spacing: -0.05em;
  line-height: 0.9;
  margin: 0;
  max-width: 11ch;
}

.eyebrow {
  color: var(--clay);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.18em;
  margin: 0 0 0.75rem;
  text-transform: uppercase;
}

.panel {
  padding: 1.25rem;
}

.panel h2 {
  font-size: clamp(1.5rem, 4vw, 2.25rem);
  margin: 0 0 0.5rem;
}

.chat-header {
  align-items: start;
  display: flex;
  gap: 1rem;
  justify-content: space-between;
}

.header-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: end;
}

.header-actions button {
  padding: 0.55rem 0.7rem;
}

.connection-badge {
  border: 2px solid var(--line);
  display: inline-block;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.8rem;
  font-weight: 800;
  padding: 0.35rem 0.55rem;
  text-transform: uppercase;
}

.connection-badge--online {
  background: #d6f6c1;
}

.connection-badge--offline,
.connection-badge--error {
  background: #ffd2c5;
}

.connection-badge--connecting {
  background: #ffe9a8;
}

.connection-badge--unpaired {
  background: #e7dcc4;
}

.note {
  color: var(--muted);
  font-size: 0.95rem;
}

.debug-line {
  background: rgba(38, 50, 38, 0.08);
  border: 1px dashed rgba(38, 50, 38, 0.45);
  color: var(--moss);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.78rem;
  padding: 0.45rem;
  overflow-wrap: anywhere;
}

.help-box {
  border-top: 1px solid rgba(38, 50, 38, 0.35);
  color: var(--muted);
  margin-top: 1rem;
  padding-top: 1rem;
}

.help-box summary {
  color: var(--ink);
  cursor: pointer;
  font-weight: 800;
}

.pair-preview {
  border: 2px dashed var(--line);
  display: grid;
  gap: 0.5rem;
  margin: 1rem 0;
  padding: 0.75rem;
}

.pair-preview div {
  display: grid;
  gap: 0.25rem;
}

.pair-preview dt {
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
}

.pair-preview dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.message-list {
  display: grid;
  gap: 0.75rem;
  list-style: none;
  margin: 1rem 0;
  min-height: 14rem;
  padding: 0;
}

.message {
  background: var(--field);
  border: 1px solid var(--line);
  display: grid;
  gap: 0.5rem;
  padding: 0.75rem;
  white-space: pre-wrap;
}

.message button {
  justify-self: start;
  padding: 0.35rem 0.6rem;
}

.message--user {
  justify-self: end;
  max-width: min(90%, 42rem);
}

.message--assistant {
  background: #f4ead5;
  justify-self: start;
  max-width: min(90%, 42rem);
}

.message--system {
  color: var(--muted);
  font-style: italic;
}

.message[data-status="streaming"]::after {
  content: " ...";
  color: var(--clay);
}

.message[data-status="queued"]::after {
  content: " queued";
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.75rem;
  margin-left: 0.5rem;
}

.message[data-status="error"] {
  border-color: var(--clay);
}

.composer {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: 1fr auto;
}

.composer textarea {
  margin: 0;
}

@media (max-width: 640px) {
  .hero-card {
    display: grid;
  }

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

  .chat-header,
  .header-actions {
    display: grid;
    justify-content: stretch;
  }
}
