/* ─────────────────────────────────────────────────────────────────────
   schindel — public agent UI
   Warm paper palette, single accent, dot-grid backdrop.
   ───────────────────────────────────────────────────────────────────── */

:root {
  --bg: #f4efe6;
  --bg-tint: #ece6da;
  --ink: #1f1d1b;
  --ink-soft: #5a544c;
  --ink-mute: #8a8377;
  --rule: #d9d1c2;
  --accent: #b36a4a;
  --accent-soft: #ddc6b4;
  --bubble-user: #e9e3d5;
  --bubble-assistant: transparent;
  --dot: rgba(31, 29, 27, 0.06);

  --font-sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --font-serif: "Iowan Old Style", "Palatino Linotype", "Georgia", ui-serif, serif;
  --radius: 10px;
  --radius-sm: 6px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
}

body {
  background-color: var(--bg);
  background-image:
    radial-gradient(var(--dot) 1px, transparent 1px),
    radial-gradient(var(--dot) 1px, transparent 1px);
  background-position: 0 0, 12px 12px;
  background-size: 24px 24px, 24px 24px;
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ─── Page shell ───────────────────────────────────────────────────── */

.page {
  width: 100%;
  max-width: 760px;
  min-height: 100vh;
  margin: 0 auto;
  padding: 1.75rem 1.25rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

/* ─── Brand band ───────────────────────────────────────────────────── */

.brand {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--rule);
}

.wordmark {
  font-family: var(--font-serif);
  font-size: 1.75rem;
  font-weight: 500;
  letter-spacing: -0.015em;
  color: var(--ink);
  text-decoration: none;
}

.wordmark:hover {
  color: var(--accent);
}

.tagline {
  font-size: 0.85rem;
  color: var(--ink-mute);
  letter-spacing: 0.005em;
  font-style: italic;
}

/* ─── Chat ─────────────────────────────────────────────────────────── */

.chat {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.messages {
  flex: 1;
  min-height: 240px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 1rem;
  padding: 0.25rem 0 1rem;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--rule) transparent;
}

.messages::-webkit-scrollbar {
  width: 8px;
}

.messages::-webkit-scrollbar-thumb {
  background: var(--rule);
  border-radius: 4px;
}

.message {
  font-size: 1rem;
  line-height: 1.65;
  max-width: 100%;
}

.message.assistant {
  color: var(--ink);
  padding: 0.25rem 0;
}

.message.user {
  align-self: flex-end;
  background: var(--bubble-user);
  color: var(--ink);
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  max-width: 85%;
}

.message a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.message strong,
.message b {
  font-weight: 600;
}

.message code {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.92em;
  background: var(--bg-tint);
  padding: 0.05em 0.35em;
  border-radius: 4px;
}

.message p {
  margin: 0 0 0.75rem;
}

.message p:last-child {
  margin-bottom: 0;
}

.message ul,
.message ol {
  margin: 0.5rem 0 0.75rem 1.25rem;
}

.message li {
  margin-bottom: 0.25rem;
}

.message pre {
  background: var(--bg-tint);
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  margin: 0.5rem 0 0.75rem;
  overflow-x: auto;
  font-size: 0.9em;
  line-height: 1.45;
}

.message pre code {
  background: transparent;
  padding: 0;
}

/* ─── Composer ─────────────────────────────────────────────────────── */

.composer {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  background: var(--bg-tint);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 0.5rem 0.5rem 0.5rem 0.75rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.composer:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

#input {
  flex: 1;
  resize: none;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-family: inherit;
  font-size: 1rem;
  line-height: 1.5;
  padding: 0.5rem 0.25rem;
  outline: 0;
  max-height: 12rem;
  min-height: 1.5rem;
}

#input::placeholder {
  color: var(--ink-mute);
}

.icon-btn {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
  color: var(--ink-soft);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.icon-btn:hover {
  background: var(--bg);
  color: var(--ink);
  border-color: var(--ink-mute);
}

.icon-btn.recording {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
}

.send-btn {
  flex: 0 0 auto;
  height: 36px;
  padding: 0 1rem;
  background: var(--ink);
  color: var(--bg);
  border: 1px solid var(--ink);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s ease, opacity 0.15s ease;
}

.send-btn:hover {
  background: var(--accent);
  border-color: var(--accent);
}

.send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.send-btn .spinner {
  display: none;
}

.send-btn.loading #send-text {
  display: none;
}

.send-btn.loading .spinner {
  display: inline-block;
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ─── Chips ────────────────────────────────────────────────────────── */

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.75rem;
}

.chip {
  background: transparent;
  border: 1px solid var(--rule);
  color: var(--ink-soft);
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  font-family: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.chip:hover {
  background: var(--bg-tint);
  color: var(--ink);
  border-color: var(--ink-mute);
}

/* ─── Footer ───────────────────────────────────────────────────────── */

.site-footer {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: var(--ink-mute);
  padding-top: 1rem;
  border-top: 1px solid var(--rule);
}

.site-footer a {
  color: var(--ink-mute);
  text-decoration: none;
}

.site-footer a:hover {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* ─── Streaming + tool affordances (JS-driven classes) ────────────── */

.thinking-indicator {
  display: inline-flex;
  gap: 4px;
  padding: 0.4rem 0;
}

.thinking-indicator span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ink-mute);
  animation: thinking 1.2s ease-in-out infinite;
}

.thinking-indicator span:nth-child(2) {
  animation-delay: 0.2s;
}

.thinking-indicator span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes thinking {
  0%, 60%, 100% {
    opacity: 0.3;
    transform: translateY(0);
  }
  30% {
    opacity: 1;
    transform: translateY(-3px);
  }
}

.assistant-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.5rem;
}

.tool-badge {
  display: inline-flex;
  align-items: center;
  font-size: 0.75rem;
  color: var(--ink-mute);
  background: var(--bg-tint);
  border: 1px solid var(--rule);
  padding: 0.15rem 0.6rem;
  border-radius: var(--radius-sm);
  white-space: normal;
  word-break: break-word;
}

.tool-badge.done {
  color: var(--ink-soft);
}

.tool-badge.error {
  color: var(--accent);
  border-color: var(--accent-soft);
}

.reentrance-notice {
  font-size: 0.85rem;
  color: var(--ink-mute);
  font-style: italic;
  padding: 0.5rem 0;
}

.message.error {
  color: var(--accent);
  background: var(--bg-tint);
  border-left: 3px solid var(--accent);
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
}

.chip.entering {
  animation: chip-in 0.3s ease both;
}

@keyframes chip-in {
  from {
    opacity: 0;
    transform: translateY(3px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ─── Mobile ───────────────────────────────────────────────────────── */

@media (max-width: 540px) {
  .page {
    padding: 1.25rem 1rem 1.5rem;
  }

  .brand {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.15rem;
  }

  .wordmark {
    font-size: 1.35rem;
  }

  .tagline {
    font-size: 0.85rem;
  }

  .message {
    font-size: 0.97rem;
  }
}
