:root {
  color-scheme: light;
  font-family: system-ui, -apple-system, sans-serif;
  --border: #d4d4d8;
  --border-focus: #3b82f6;
  --muted: #71717a;
  --bg: #fafafa;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: #18181b;
}

header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: #fff;
}

header h1 {
  font-size: 1.125rem;
  margin: 0;
}

#connect {
  padding: 0.5rem 1rem;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.875rem;
}

#connect:hover {
  background: #f4f4f5;
}

#connect[data-state="connected"] {
  background: #ef4444;
  color: white;
  border-color: #ef4444;
}

main {
  max-width: 640px;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}

form h2 {
  margin: 0 0 0.5rem;
  font-size: 1.5rem;
}

.hint {
  margin: 0 0 1.5rem;
  font-size: 0.9375rem;
  line-height: 1.5;
  color: var(--muted);
}

fieldset {
  margin: 0 0 1.5rem;
  padding: 1rem 1.25rem 1.25rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
}

legend {
  padding: 0 0.5rem;
  font-size: 0.8125rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-top: 0.875rem;
}

.field:first-child {
  margin-top: 0;
}

.field label {
  font-size: 0.875rem;
  font-weight: 500;
  color: #27272a;
}

.field input[type="text"],
.field input[type="email"],
.field input[type="tel"],
.field textarea {
  font: inherit;
  font-size: 1rem;
  padding: 0.5rem 0.625rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  width: 100%;
  scroll-margin-top: 5rem;
  transition:
    border-color 0.15s,
    box-shadow 0.15s,
    background 0.4s;
}

.field input:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

/* Brief flash when the agent fills a field, so the user notices the
   write. The CSS class is added by the set_input_value handler and
   removed after the animation. */
@keyframes field-fill-flash {
  0% {
    background: #fef3c7;
  }
  100% {
    background: #fff;
  }
}

.field input.fill-flash,
.field textarea.fill-flash {
  animation: field-fill-flash 1.2s ease-out;
}

.field textarea {
  resize: vertical;
}

.actions {
  display: flex;
  gap: 1rem;
  align-items: center;
}

#submit {
  font: inherit;
  font-size: 0.9375rem;
  font-weight: 500;
  padding: 0.625rem 1.25rem;
  background: #18181b;
  color: white;
  border: 1px solid #18181b;
  border-radius: 6px;
  cursor: pointer;
}

#submit:hover {
  background: #27272a;
}

#form-status {
  font-size: 0.875rem;
  color: var(--muted);
}

#status {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  font-size: 0.8125rem;
  background: #18181b;
  color: white;
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
}

#status[data-show="1"] {
  opacity: 1;
}
