:root {
  --ink: #1c1917;
  --muted: #57534e;
  --paper: #f6f1e8;
  --card: #fffdf8;
  --line: #e7e0d4;
  --accent: #9a3412;
  --accent-hover: #7c2d12;
  --ok: #166534;
  --bad: #9f1239;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: "Source Serif 4", "Iowan Old Style", Georgia, serif;
  background: var(--paper);
  color: var(--ink);
}

.shell {
  max-width: 720px;
  margin: 0 auto;
  padding: 2.5rem 1.25rem 4rem;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(300px, 420px) 1fr;
  gap: 1.25rem;
  max-width: 1400px;
  margin: 0 auto;
  padding: 1.25rem 1.25rem 2rem;
  min-height: 100vh;
}

.chat-col {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.preview-col {
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 24rem;
}

.preview-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.6rem;
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 0.8rem;
  color: var(--muted);
}

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

.preview-actions a,
.preview-actions button {
  margin-top: 0;
  font-size: 0.8rem;
  padding: 0.35rem 0.8rem;
  text-decoration: none;
}

.preview-placeholder {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  margin: 0;
  padding: 1.5rem;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 14px;
  background: var(--card);
  font-family: ui-sans-serif, system-ui, sans-serif;
}

.preview-frame {
  flex: 1;
  width: 100%;
  min-height: 24rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
}

@media (max-width: 900px) {
  .workspace {
    grid-template-columns: 1fr;
    min-height: auto;
  }
  .preview-frame,
  .preview-placeholder {
    min-height: 20rem;
  }
}

h2 { margin: 0.15rem 0 0; font-weight: 600; font-size: 1.35rem; }

.lede { color: var(--muted); }

.panel, .composer, .bubble, .result {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 1.25rem;
}

label {
  display: block;
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 0.8rem;
  margin-bottom: 0.35rem;
}

input, textarea, button {
  font: inherit;
}

input, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.7rem 0.8rem;
  background: #fff;
  color: var(--ink);
}

textarea { resize: vertical; min-height: 5rem; }

button {
  margin-top: 0.75rem;
  background: var(--accent);
  color: #fff;
  border: 0;
  border-radius: 999px;
  padding: 0.55rem 1.1rem;
  cursor: pointer;
  font-family: ui-sans-serif, system-ui, sans-serif;
}

button:hover { background: var(--accent-hover); }
button:disabled { opacity: 0.55; cursor: not-allowed; }
button.secondary {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}
button.secondary:hover { background: #f3eee4; }

.thread {
  list-style: none;
  margin: 0 0 1rem;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.bubble.user { align-self: flex-end; max-width: 85%; }
.bubble.agent { align-self: flex-start; max-width: 100%; }
.progress-row {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
}
.progress-row p { margin: 0; }
.spinner {
  flex: 0 0 auto;
  width: 0.9rem;
  height: 0.9rem;
  margin-top: 0.35rem;
  border: 2px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
.elapsed {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 0.78rem;
}
.who {
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 0.72rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.status { min-height: 1.2rem; color: var(--muted); font-family: ui-sans-serif, system-ui, sans-serif; font-size: 0.9rem; }
.status.error { color: var(--bad); }
.status.ok { color: var(--ok); }

.files { margin: 0.5rem 0; padding-left: 1.1rem; }
.actions { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 0.75rem; }
.actions a, .actions button { margin-top: 0; text-decoration: none; }
.actions a {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.55rem 1.1rem;
  border: 1px solid var(--line);
  color: var(--ink);
  font-family: ui-sans-serif, system-ui, sans-serif;
}

.user-slot {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 1rem;
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 0.85rem;
}
.user-slot button { margin-top: 0.35rem; }
.hidden { display: none !important; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}
.status.error { color: var(--bad); }
.status.ok { color: var(--ok); }
.bubble p { margin: 0.35rem 0; }
