/*
 * Beeple customer-research interview — a small, warm, mobile-first stylesheet.
 * No framework, no external fonts (works offline, honours a strict CSP).
 */

:root {
  --bg: #fbf9f4;
  --surface: #ffffff;
  --ink: #23211c;
  --muted: #6b665c;
  --line: #e7e1d6;
  --accent: #2e6e5e;
  --accent-ink: #ffffff;
  --accent-soft: #eaf1ee;
  --danger: #a23b2c;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(35, 33, 28, 0.05), 0 6px 20px rgba(35, 33, 28, 0.06);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--bg);
}

.page {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  max-width: 720px;
  margin: 0 auto;
  padding: 0 clamp(16px, 4vw, 28px);
}

/* --- header / footer --- */
.site-header {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 20px 2px 8px;
}
.wordmark { font-weight: 700; letter-spacing: -0.01em; color: var(--accent); }
.site-header__tag { color: var(--muted); font-size: 0.9rem; }

.site-main { flex: 1; padding: 12px 0 28px; }

.site-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding: 16px 2px 24px;
  color: var(--muted);
  font-size: 0.85rem;
  border-top: 1px solid var(--line);
}
.site-footer a { color: var(--muted); }

/* --- typography --- */
h1 { font-size: 1.6rem; line-height: 1.2; letter-spacing: -0.02em; margin: 0 0 0.4em; }
h2 { font-size: 1.2rem; margin: 1.4em 0 0.4em; }
p { margin: 0 0 1em; }
a { color: var(--accent); }
.lead { font-size: 1.08rem; color: var(--ink); }
.muted { color: var(--muted); }

/* --- cards --- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: clamp(20px, 5vw, 32px);
}

/* --- consent list --- */
.consent {
  list-style: none;
  margin: 0 0 1.2em;
  padding: 0;
  display: grid;
  gap: 10px;
}
.consent li {
  position: relative;
  padding-left: 26px;
  color: var(--ink);
}
.consent li::before {
  content: "";
  position: absolute;
  left: 4px;
  top: 0.62em;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
}

.consent-check {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin: 1.2em 0;
  padding: 14px;
  background: var(--accent-soft);
  border-radius: var(--radius-sm);
}
.consent-check input { margin-top: 3px; width: 20px; height: 20px; accent-color: var(--accent); flex: none; }
.consent-check label { color: var(--ink); }

/* --- buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font: inherit;
  font-weight: 600;
  padding: 13px 22px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  text-decoration: none;
  min-height: 48px;
}
.btn--primary { background: var(--accent); color: var(--accent-ink); }
.btn--primary:disabled { opacity: 0.55; cursor: not-allowed; }
.btn--ghost { border-color: var(--line); color: var(--muted); background: transparent; }
.btn--block { width: 100%; }

.field-error { color: var(--danger); margin: 0 0 1em; }

/* --- chat --- */
.chat { display: flex; flex-direction: column; gap: 0; }
.chat__intro { color: var(--muted); font-size: 0.9rem; margin-bottom: 12px; }

.messages {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-bottom: 12px;
}

.msg {
  max-width: 85%;
  padding: 12px 16px;
  border-radius: var(--radius);
  overflow-wrap: anywhere;
}
.msg > :first-child { margin-top: 0; }
.msg > :last-child { margin-bottom: 0; }
.msg ul, .msg ol { margin: 0.4em 0; padding-left: 1.2em; }

.msg--assistant {
  align-self: flex-start;
  background: var(--surface);
  border: 1px solid var(--line);
  border-bottom-left-radius: 4px;
}
.msg--user {
  align-self: flex-end;
  background: var(--accent);
  color: var(--accent-ink);
  border-bottom-right-radius: 4px;
  white-space: pre-wrap; /* preserve the customer's line breaks, safely escaped */
}

/* typing / streaming indicator */
.dots { display: inline-flex; gap: 4px; padding: 4px 2px; }
.dots span {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--muted); opacity: 0.5;
  animation: blink 1.4s infinite both;
}
.dots span:nth-child(2) { animation-delay: 0.2s; }
.dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%, 80%, 100% { opacity: 0.25; } 40% { opacity: 0.9; } }

/* composer */
.composer {
  position: sticky;
  bottom: 0;
  background: linear-gradient(to top, var(--bg) 72%, rgba(251, 249, 244, 0));
  padding: 12px 0 16px;
}
.composer__row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px;
  box-shadow: var(--shadow);
}
.composer textarea {
  flex: 1;
  font: inherit;
  border: none;
  resize: none;
  padding: 8px;
  max-height: 160px;
  background: transparent;
  color: var(--ink);
}
.composer textarea:focus { outline: none; }
.composer__meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 8px;
  font-size: 0.8rem;
  color: var(--muted);
}
.composer__send { flex: none; padding: 11px 18px; min-height: 44px; }

.finish-form { margin: 0; }
.finish-link {
  background: none; border: none; color: var(--muted);
  font: inherit; text-decoration: underline; cursor: pointer; padding: 0;
}

/* centered single-purpose screens (landing/done/dead-end) */
.screen { padding: 12px 0; }
.screen--center { text-align: center; padding-top: 8vh; }
.badge {
  display: inline-flex; align-items: center; justify-content: center;
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent);
  font-size: 1.6rem; margin-bottom: 12px;
}

@media (max-width: 480px) {
  body { font-size: 16px; }
  .msg { max-width: 90%; }
}

/* --- admin --- */
.admin-nav { margin-left: auto; display: flex; gap: 14px; font-size: 0.9rem; }
.admin-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.flash { padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 16px; }
.flash--notice { background: var(--accent-soft); color: var(--accent); }
.flash--alert { background: #f7e6e2; color: var(--danger); }
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.table th, .table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table th { color: var(--muted); font-weight: 600; }
.status { font-size: 0.8rem; padding: 2px 8px; border-radius: 999px; background: var(--line); text-transform: capitalize; }
.status--active { background: var(--accent-soft); color: var(--accent); }
.status--completed { background: #e3ecff; color: #2f5bd0; }
.status--revoked, .status--expired { background: #f7e6e2; color: var(--danger); }
.link-box {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 10px 12px; overflow-x: auto; word-break: break-all;
}
.meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 8px 20px; margin: 16px 0; }
.meta div { display: flex; flex-direction: column; }
.meta dt { color: var(--muted); font-size: 0.8rem; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.btn--danger { background: var(--danger); color: #fff; }
.card--narrow { max-width: 520px; }
.form-row { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.form-row input { font: inherit; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.transcript { display: flex; flex-direction: column; gap: 10px; }
.turn { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px; background: var(--surface); }
.turn__who { display: inline-block; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); margin-bottom: 4px; }
.turn--user { background: var(--accent-soft); }
.turn--system { background: #fbf3e6; }
.report {
  white-space: pre-wrap; overflow-x: auto;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 16px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.85rem; line-height: 1.5;
}
