:root {
  --bg: #F5F4EE;
  --ink: #1F1E1D;
  --muted: #73726C;
  --line: #E3DFD3;
  --card: #FFFFFF;
  --clay: #D97757;
  --user: #EAE6D9;
  --pumpkin: #F08A24;
  --serif: ui-serif, "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body { height: 100%; margin: 0; }

body {
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.55 var(--sans);
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  padding-top: max(10px, env(safe-area-inset-top));
  border-bottom: 1px solid var(--line);
}

.brand { font: 600 20px var(--serif); }

#new-chat {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  padding: 6px 14px;
  font: inherit;
  font-size: 14px;
}

main {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 760px;
  width: 100%;
  margin: 0 auto;
}

/* welcome screen */
#welcome { margin: auto; text-align: center; padding: 8px 0 24px; }
#welcome h1 { font: 400 clamp(28px, 8vw, 38px)/1.2 var(--serif); margin: 12px 0 24px; }
#starters { display: flex; flex-direction: column; gap: 10px; align-items: center; }
#starters button {
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  border-radius: 14px;
  padding: 10px 16px;
  font: inherit;
  font-size: 15px;
  max-width: 100%;
}
#starters button:active { background: var(--user); }

/* messages */
.msg { max-width: 92%; overflow-wrap: anywhere; }
.msg.user {
  align-self: flex-end;
  background: var(--user);
  border-radius: 18px;
  padding: 9px 15px;
  white-space: pre-wrap;
}
.msg.assistant { align-self: flex-start; display: flex; gap: 10px; }
.msg.assistant .body { flex: 1; min-width: 0; }
.msg.assistant .body > :first-child { margin-top: 0; }
.msg.assistant .body > :last-child { margin-bottom: 0; }
.msg.assistant p { margin: 0 0 0.8em; }
.msg.assistant ul, .msg.assistant ol { margin: 0 0 0.8em; padding-left: 1.4em; }
.msg.assistant code {
  background: var(--user);
  border-radius: 5px;
  padding: 1px 5px;
  font: 0.9em ui-monospace, Consolas, monospace;
}
.msg.assistant pre {
  background: #2B2A28;
  color: #F3EFE6;
  border-radius: 10px;
  padding: 10px 12px;
  overflow-x: auto;
  margin: 0 0 0.8em;
}
.msg.assistant pre code { background: none; padding: 0; color: inherit; }

.status { color: var(--muted); font-style: italic; transition: opacity 0.4s; }
.status.fade { opacity: 0; }

/* Claude's spark, with a jack-o'-lantern glow while it works */
.spark { width: 26px; height: 26px; flex: none; margin-top: 2px; }
.spark.big { width: 56px; height: 56px; margin-top: 0; }
.spark line { stroke: var(--clay); stroke-width: 9; stroke-linecap: round; }
.spark.working { animation: spin 5s linear infinite, glow 1.6s ease-in-out infinite; }
.spark.working line { stroke: var(--pumpkin); }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes glow {
  0%, 100% { filter: drop-shadow(0 0 1px rgba(240, 138, 36, 0.3)); scale: 0.9; }
  50%      { filter: drop-shadow(0 0 6px rgba(240, 138, 36, 0.95)); scale: 1.1; }
}

/* composer */
#composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 14px;
  padding-bottom: max(10px, env(safe-area-inset-bottom));
  max-width: 760px;
  width: 100%;
  margin: 0 auto;
}
#input {
  flex: 1;
  resize: none;
  max-height: 140px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--card);
  color: var(--ink);
  padding: 11px 16px;
  font: inherit;
  outline: none;
}
#input:focus { border-color: var(--clay); }
#send {
  width: 42px; height: 42px;
  flex: none;
  border: 0;
  border-radius: 50%;
  background: var(--clay);
  display: grid; place-items: center;
}
#send:disabled { opacity: 0.4; }
#send svg { width: 20px; height: 20px; fill: none; stroke: #fff; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }

@media (prefers-reduced-motion: reduce) {
  .spark.working { animation: none; }
}

/* ---- Evil Claude (1 in 5 guests): black and blood red ---- */
body.evil {
  --bg: #050505;
  --ink: #E9E4E0;
  --muted: #8C8580;
  --line: #2E1716;
  --card: #110E0E;
  --clay: #E3261B;
  --user: #1F1413;
  --pumpkin: #FF3B2F;
  background: radial-gradient(ellipse at 50% 30%, #1C0605 0%, #050505 70%);
}
body.evil ::selection { background: var(--clay); color: #000; }

body.evil .brand {
  font: 600 17px ui-monospace, Consolas, monospace;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--clay);
  text-shadow: 0 0 8px rgba(227, 38, 27, 0.7);
}
body.evil #welcome h1 { text-shadow: 0 0 18px rgba(227, 38, 27, 0.35); }
body.evil #starters button { box-shadow: inset 0 0 12px rgba(227, 38, 27, 0.08); }
body.evil #starters button:active { border-color: var(--clay); }
body.evil .msg.user { border: 1px solid var(--line); }
body.evil .msg.assistant pre { background: #170D0C; border: 1px solid var(--line); color: #F1D9D6; }
body.evil #send svg { stroke: #000; }

/* waiting lines look like a terminal printing its plans */
body.evil .status {
  font: 0.9em ui-monospace, Consolas, monospace;
  font-style: normal;
  color: var(--clay);
}
body.evil .status::before { content: "> "; }
body.evil .status::after { content: "▌"; animation: blink 1s steps(1) infinite; }

/* the spark turns red (it picks up --clay and --pumpkin) and glows like a warning light */
body.evil .spark { filter: drop-shadow(0 0 3px rgba(227, 38, 27, 0.5)); }
body.evil .spark.big { animation: menace 4s ease-in-out infinite; }
body.evil .spark.working { animation: spin 5s linear infinite, menace 1.2s ease-in-out infinite; }

@keyframes menace {
  0%, 100% { filter: drop-shadow(0 0 2px rgba(255, 40, 20, 0.35)); }
  50%      { filter: drop-shadow(0 0 12px rgba(255, 40, 20, 1)); }
}
@keyframes blink { 50% { opacity: 0; } }

/* the moment a guest finds out they got Evil Claude */
body.glitch { animation: glitch 0.9s steps(1) 1; }
@keyframes glitch {
  0%   { filter: invert(1); transform: translateX(3px) skewX(-6deg); }
  15%  { filter: none; transform: translate(-4px, 1px); }
  30%  { filter: hue-rotate(150deg) saturate(4); transform: translateX(2px) skewX(4deg); }
  45%  { filter: none; transform: none; opacity: 0.5; }
  60%  { filter: invert(1) contrast(2); transform: translateX(-2px); opacity: 1; }
  75%  { filter: none; transform: skewX(-2deg); }
  100% { filter: none; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  body.evil .spark.big, body.evil .spark.working, body.evil .status::after, body.glitch { animation: none; }
}
