:root {
  --paper: #f3eee4;
  --card: #fffaf3;
  --ink: #1c2430;
  --muted: #5c6570;
  --line: #e0d5c4;
  --navy: #1b3654;
  --navy-2: #14283f;
  --coral: #9d3b26;
  --gold: #e7b143;
  --sage: #145443;
  --sage-bg: #e5f2ec;
  --gold-bg: #fde7c2;
  --serif: "Iowan Old Style", Palatino, "Palatino Linotype", "Liberation Serif", "Times New Roman", serif;
  --sans: Cantarell, "Segoe UI", "Liberation Sans", "Noto Sans", sans-serif;
  --shadow: 0 16px 40px rgba(27, 54, 84, 0.08);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1.05rem;
  line-height: 1.5;
  background:
    radial-gradient(900px 420px at 0% -10%, #fff 0%, transparent 55%),
    linear-gradient(180deg, #f7f3eb 0%, #efe6d6 100%);
}

img { display: block; max-width: 100%; }

:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 2px;
}

.site-header {
  background: var(--navy);
  color: #f6f0e6;
  border-bottom: 4px solid var(--gold);
}

.header-inner,
.wrap,
.site-footer {
  width: min(1100px, calc(100% - 28px));
  margin-left: auto;
  margin-right: auto;
}

.header-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  padding: 16px 0;
}

.brand,
.header-buddy,
.chat-head {
  display: flex;
  align-items: center;
  gap: 12px;
}

.mark {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  background: var(--coral);
  color: #fff8ee;
  display: grid;
  place-items: center;
  font-family: var(--serif);
  font-size: 22px;
  line-height: 1;
  letter-spacing: -0.03em;
}

.eyebrow {
  margin: 0;
  color: #d9cbb8;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1, h2, h3 { font-family: var(--serif); font-weight: 700; }

h1 {
  margin: 0;
  font-size: 2rem;
  line-height: 1;
  letter-spacing: -0.03em;
}

.header-buddy strong { display: block; font-size: 1rem; }
.header-buddy span { color: #d9cbb8; font-size: 0.88rem; }
.header-buddy img,
.chat-head img {
  border-radius: 50%;
  background: #f8e7d8;
}

.wrap { padding: 22px 0 36px; }

.layout {
  display: grid;
  grid-template-columns: minmax(280px, 390px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.layout > * { min-width: 0; }

.sheet {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 18px 16px 16px;
}

.form-card h2,
.chat-head h2 {
  margin: 0;
  font-size: 1.55rem;
}

.lede {
  margin: 8px 0 14px;
  color: var(--muted);
}

label {
  display: block;
  margin: 12px 0 6px;
  font-weight: 700;
}

.prompt-label-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}

.prompt-label-row label { margin-bottom: 6px; }

.word-count,
.alias,
.help,
.form-hint,
.blurb,
.caption,
.site-footer,
.noscript {
  color: var(--muted);
}

.word-count { font-size: 0.85rem; }

select,
textarea,
input[type="number"] {
  width: 100%;
  font: inherit;
  font-size: 1rem;
  color: var(--ink);
  background: #fff;
  border: 1px solid #d9cdb8;
  border-radius: 12px;
  padding: 12px 12px;
}

textarea {
  min-height: 180px;
  resize: vertical;
  line-height: 1.45;
}

.alias,
.form-hint,
.grade-note { margin: 8px 0 0; font-size: 0.92rem; }

.grade-note { color: var(--sage); font-weight: 700; min-height: 1.2em; }

.form-hint { min-height: 1.2em; }

.facts { margin-top: 10px; }

.pills { display: flex; flex-wrap: wrap; gap: 6px; }

.pill {
  background: var(--sage-bg);
  color: var(--sage);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.82rem;
  font-weight: 700;
}

.pill-hot { background: var(--gold-bg); color: #6a4a10; }

.blurb { margin: 8px 0 0; font-size: 0.95rem; }

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 12px;
}

button {
  font: inherit;
  cursor: pointer;
  min-height: 48px;
  border-radius: 12px;
}

.primary {
  grid-column: 1 / -1;
  border: 0;
  background: var(--coral);
  color: #fff8ee;
  font-weight: 700;
  padding: 0 16px;
}

.primary:hover { background: #872f1d; }

.ghost {
  border: 1px solid #d9cdb8;
  background: transparent;
  color: var(--ink);
  padding: 0 14px;
}

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

.help {
  margin: 14px 0 0;
  font-size: 0.88rem;
}

.experience {
  margin: 16px 0 0;
  padding: 4px 12px 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
}

.experience legend {
  padding: 0 6px;
  font-family: var(--serif);
  font-size: 1.15rem;
  font-weight: 700;
}

.quiet {
  margin: 4px 0 8px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 400;
}

.pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 10px;
}

.experience label {
  margin-top: 8px;
  font-size: 0.92rem;
}

.experience input,
.experience select {
  margin-top: 4px;
  min-height: 44px;
}

.odds {
  margin-top: 12px;
  padding: 12px 12px 14px;
  border-radius: 14px;
  background: var(--sage-bg);
}

.odds-kicker {
  margin: 0;
  color: var(--sage);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.odds-score {
  margin: 4px 0 0;
  font-family: var(--serif);
  font-size: 1.7rem;
  line-height: 1.15;
}

.odds-sub {
  display: block;
  margin-top: 2px;
  font-family: var(--sans);
  font-size: 1rem;
  font-weight: 700;
}

.odds p { margin: 8px 0 0; }

.odds-note {
  color: var(--sage);
  font-size: 0.88rem;
}

.chat { min-height: 560px; }

.chat-head {
  padding-bottom: 10px;
  border-bottom: 1px dashed var(--line);
  margin-bottom: 12px;
}

.empty p { margin: 0 0 12px; }

.ballot-legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: 0.92rem;
}

.ballot-legend span {
  width: 1.7rem;
  height: 1.7rem;
  border: 1.5px solid var(--navy);
  border-radius: 4px;
  display: grid;
  place-items: center;
  font-weight: 700;
  color: var(--navy);
}

#log { display: grid; gap: 14px; }

.turn { scroll-margin-top: 12px; }

.user-bubble {
  margin-left: auto;
  width: min(100%, 520px);
  background: var(--navy);
  color: #f7f1e6;
  border-radius: 16px 16px 6px 16px;
  padding: 12px 14px;
  overflow-wrap: anywhere;
}

.kicker {
  margin: 0 0 4px;
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  opacity: 0.75;
}

.user-bubble p { margin: 0; white-space: pre-wrap; }

.buddy-bubble {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px 18px 18px 18px;
  padding: 12px 14px 14px;
  overflow-wrap: anywhere;
}

.buddy-id {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
}

.buddy-id img { border-radius: 50%; background: #f8e7d8; }

.greeting {
  font-family: var(--serif);
  font-size: 1.22rem;
  line-height: 1.35;
  margin: 8px 0 10px;
}

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }

.chip {
  background: #f3eee4;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 0.78rem;
  color: var(--navy);
  font-weight: 700;
}

.section + .section {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px dashed var(--line);
}

.section h3 { margin: 0 0 6px; font-size: 1.18rem; }

.section p { margin: 0 0 8px; }
.section p:last-child { margin-bottom: 0; }

.steps-title {
  margin: 14px 0 8px;
  font-family: var(--serif);
  font-size: 1.18rem;
}

.steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.steps li {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: start;
}

.num {
  width: 1.7rem;
  height: 1.7rem;
  border-radius: 50%;
  background: var(--navy);
  color: #fff8ee;
  display: grid;
  place-items: center;
  font-size: 0.85rem;
  font-weight: 700;
}

.notice {
  margin: 10px 0 0;
  background: var(--gold-bg);
  border-radius: 10px;
  padding: 8px 10px;
  color: #5c4312;
  font-size: 0.92rem;
}

.caption { margin: 10px 0 0; font-size: 0.82rem; }

.site-footer {
  padding-bottom: 28px;
  font-size: 0.88rem;
}

.site-footer a { color: var(--navy); }

.noscript {
  width: min(1100px, calc(100% - 28px));
  margin: 12px auto;
}

@media (max-width: 800px) {
  .layout { grid-template-columns: 1fr; }
  .chat { min-height: 0; }
  .header-inner { align-items: flex-start; }
  h1 { font-size: 1.35rem; }
  .header-buddy span { display: none; }
  textarea { min-height: 150px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}
