:root {
  --bg: #040302;
  --gold: #f0b450;
  --gold-soft: #f3dcae;
  --gold-dim: rgba(240, 180, 80, 0.55);
  --gold-faint: rgba(243, 220, 174, 0.4);
  --line: rgba(240, 180, 80, 0.32);
  --blue: #a9bdd8;
  --blue-dim: rgba(150, 180, 220, 0.6);
  --panel: rgba(6, 4, 2, 0.8);
  --mono: "JetBrains Mono", "IBM Plex Mono", Menlo, Consolas, monospace;
  --log-top: 56vh;
  --dock-h: 150px;
  --col: min(720px, calc(100vw - 32px));
  --stage: 58vw;
  --band: 20vh;
  --art-y: 32vh;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--gold-soft);
  font-family: var(--mono);
  font-size: 15px;
  line-height: 1.7;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

#ascii, #glow {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
}
#glow {
  filter: blur(9px) saturate(1.25);
  opacity: 0.62;
  mix-blend-mode: screen;
}

/* ---------- the stage: the eyes and the art, clickable ---------- */
.art {
  display: none;
  position: fixed;
  padding: 0;
  background: none;
  border: 0;
  cursor: pointer;
  z-index: 1;
}
body.sides:not(.intro):not(.static) .art { display: block; }
/* The eyes can be clicked on narrow screens too. */
body.chatting:not(.intro):not(.static) #art-right { display: block; }
#art-left { left: 0; top: var(--art-y); bottom: 0; width: var(--stage); cursor: crosshair; touch-action: none; }
body:not(.painted) #art-left { display: none !important; }
.art:focus-visible { outline-offset: -10px; }
.art .hint {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 12px;
  font: inherit;
  font-size: 10.5px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--gold-faint);
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.25s ease, transform 0.25s ease;
}
#art-right .hint { bottom: -18px; }
.art:hover .hint, .art:focus-visible .hint { opacity: 1; transform: none; }

#flash {
  position: fixed;
  inset: 0;
  background: #fff1cf;
  opacity: 0;
  pointer-events: none;
  z-index: 6;
}
#flash.go { animation: flash 0.55s ease-out; }
@keyframes flash {
  0% { opacity: 0.85; }
  100% { opacity: 0; }
}

#top {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: baseline;
  gap: 14px;
  padding: 16px 22px;
  font-size: 11px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  z-index: 3;
  pointer-events: none;
}
#top .mark { color: var(--gold-dim); }
/* A small label under the painting, like the card beside a picture in a museum. */
#caption {
  position: fixed;
  left: 0;
  bottom: 14px;
  width: var(--stage);
  text-align: center;
  color: var(--gold-faint);
  letter-spacing: 0.22em;
  opacity: 0;
  transition: opacity 0.25s ease;
}
#caption.on { opacity: 1; }
/* On narrow screens the eyes take the top of the page, with no room for labels. */
body.chatting:not(.sides) #top { display: none; }
.art:hover ~ #top #caption { opacity: 0; }

/* ---------- conversation ---------- */
#log {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  width: var(--col);
  top: var(--log-top);
  bottom: var(--dock-h);
  overflow: hidden;
  overscroll-behavior: contain;
  padding: 0 4px 8px;
  z-index: 2;
  transition: top 1.1s cubic-bezier(0.2, 0.7, 0.2, 1), left 0.9s cubic-bezier(0.2, 0.7, 0.2, 1), width 0.9s cubic-bezier(0.2, 0.7, 0.2, 1), opacity 0.25s ease;
}
/* Before the first question the greeting just sits centered, with nothing to scroll. */
body:not(.chatting) #log {
  display: flex;
  flex-direction: column;
  justify-content: center;
}
body.chatting #log {
  overflow-y: auto;
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 40px, #000 calc(100% - 22px), transparent 100%);
  mask-image: linear-gradient(to bottom, transparent 0, #000 40px, #000 calc(100% - 22px), transparent 100%);
  padding-top: 44px;
  padding-bottom: 26px;
}

/* A slim scrollbar with no arrow buttons, for the transcript and a long question. */
#log::-webkit-scrollbar, #q::-webkit-scrollbar { width: 5px; }
#log::-webkit-scrollbar-button, #q::-webkit-scrollbar-button { display: none; width: 0; height: 0; }
#log::-webkit-scrollbar-track, #q::-webkit-scrollbar-track { background: transparent; }
#log::-webkit-scrollbar-thumb, #q::-webkit-scrollbar-thumb { background: rgba(240, 180, 80, 0.22); border-radius: 3px; }
#log::-webkit-scrollbar-thumb:hover, #q::-webkit-scrollbar-thumb:hover { background: rgba(240, 180, 80, 0.42); }
@supports not selector(::-webkit-scrollbar) {
  #log, #q { scrollbar-width: thin; scrollbar-color: rgba(240, 180, 80, 0.25) transparent; }
}

::selection { background: rgba(240, 180, 80, 0.3); color: #fff4dc; }

/* Each new message settles in, so the transcript never jumps. */
.msg { margin: 0 0 26px; animation: settle 0.45s var(--ease) both; }
.msg.greeting { animation: none; }
@keyframes settle { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.msg .who {
  display: block;
  font-size: 10.5px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--gold-dim);
  margin-bottom: 4px;
}
.msg .who .model { letter-spacing: 0.08em; text-transform: none; opacity: 0.7; margin-left: 8px; }
.msg .body p { margin: 0 0 0.75em; }
.msg .body p:last-child { margin-bottom: 0; }
.msg.karyon .body {
  color: var(--gold-soft);
  text-shadow: 0 0 14px rgba(240, 170, 60, 0.22);
}
.msg.you .who { color: var(--blue-dim); }
.msg.you .body { color: var(--blue); }
.msg.error .body { color: var(--gold-faint); font-style: italic; }
.msg em { color: #ffe7b8; }

.msg.greeting {
  text-align: center;
  font-size: clamp(15px, 1.55vw, 18px);
  line-height: 1.75;
  max-width: 640px;
  margin: 0 auto;
}
.msg.greeting .who { display: none; }
.ghost { visibility: hidden; }
.caret::after {
  content: "▍";
  color: var(--gold);
  position: absolute;
  animation: blink 1s steps(1) infinite;
}
body.chatting .msg.greeting {
  text-align: left;
  font-size: 15px;
  max-width: none;
  margin: 0 0 22px;
}
body.chatting .msg.greeting .who { display: block; }

.cursor::after {
  content: "▍";
  color: var(--gold);
  margin-left: 1px;
  animation: blink 1s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

/* ---------- dock: suggestions, input, footer ---------- */
#dock {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: var(--col);
  padding: 10px 0 max(12px, env(safe-area-inset-bottom));
  z-index: 4;
  transition: left 0.9s cubic-bezier(0.2, 0.7, 0.2, 1), width 0.9s cubic-bezier(0.2, 0.7, 0.2, 1), opacity 0.25s ease;
}
/* Wide screens: the stage on the left, and the conversation on the right. */
body.sides #log, body.sides #dock, body.sides #static {
  left: var(--stage);
  transform: none;
  width: calc(100vw - var(--stage));
  padding-left: 32px;
  padding-right: 32px;
}
body.sides #rail { opacity: 1; }
#rail {
  position: fixed;
  left: var(--stage);
  top: 8vh;
  bottom: 8vh;
  width: 1px;
  background: linear-gradient(to bottom, transparent, rgba(240, 180, 80, 0.2) 18%, rgba(240, 180, 80, 0.2) 82%, transparent);
  opacity: 0;
  transition: opacity 1s ease 0.4s;
  pointer-events: none;
}

/* Wider than the input, so the suggestions stay on one line on most screens. */
#chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  position: relative;
  left: 50%;
  width: min(940px, calc(100vw - 32px));
  transform: translateX(-50%);
  margin-bottom: 10px;
  transition: opacity 0.4s ease;
}
#chips button {
  font: inherit;
  font-size: 12.5px;
  line-height: 1.3;
  color: var(--gold-soft);
  background: rgba(8, 6, 3, 0.55);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 13px;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}
#chips button:hover { border-color: rgba(240, 180, 80, 0.7); background: rgba(240, 180, 80, 0.1); }
body.chatting #chips { display: none; }

#ask {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  border: 1px solid rgba(240, 180, 80, 0.45);
  background: var(--panel);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border-radius: 12px;
  padding: 5px 5px 5px 16px;
  box-shadow: 0 0 30px rgba(240, 170, 60, 0.12);
  transition: border-color 0.2s, box-shadow 0.2s;
}
#ask:focus-within { border-color: rgba(240, 180, 80, 0.85); box-shadow: 0 0 36px rgba(240, 170, 60, 0.22); }
#q {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: 0;
  outline: none;
  resize: none;
  color: var(--gold-soft);
  font: inherit;
  font-size: 15px;
  line-height: 1.5;
  padding: 9px 0;
  max-height: 140px;
  overflow-y: hidden;
  caret-color: var(--gold);
}
#q::placeholder { color: rgba(243, 220, 174, 0.38); }
#send {
  flex: none;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 9px;
  background: rgba(240, 180, 80, 0.16);
  color: var(--gold);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background 0.2s, opacity 0.2s;
}
#send:hover { background: rgba(240, 180, 80, 0.28); }
#send:disabled { opacity: 0.4; cursor: default; }

#note {
  min-height: 1.2em;
  margin: 6px 2px 0;
  font-size: 12px;
  line-height: 1.4;
  color: var(--gold-faint);
}
#note:empty { display: none; }

footer {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px 16px;
  margin-top: 8px;
  font-size: 11px;
  line-height: 1.4;
  color: rgba(243, 220, 174, 0.34);
}
footer a, footer button {
  color: inherit;
  font: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: rgba(243, 220, 174, 0.2);
}
footer a:hover, footer button:hover { color: var(--gold-soft); }

button:focus-visible, a:focus-visible {
  outline: 1px solid var(--gold);
  outline-offset: 2px;
}

#skip {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 22px;
  margin: 0;
  text-align: center;
  font-size: 10.5px;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: rgba(240, 180, 80, 0.35);
  z-index: 7;
  pointer-events: none;
  transition: opacity 0.4s;
}

/* ---------- intro state ---------- */
#top, #log, #dock { transition: opacity 0.9s ease; }
body.intro #top, body.intro #log, body.intro #dock { opacity: 0; pointer-events: none; }
body:not(.intro) #skip { opacity: 0; }
#dock { opacity: 1; }
body.awaiting #dock { opacity: 0; pointer-events: none; }

/* ---------- drawing on the painting ---------- */
#ink-tools {
  position: fixed;
  left: 0;
  bottom: 40px;
  width: var(--stage);
  display: flex;
  justify-content: center;
  gap: 8px;
  z-index: 2;
  animation: rise 0.25s ease both;
}
#ink-tools[hidden] { display: none; }
#ink-tools button {
  font: inherit;
  font-size: 12px;
  color: var(--gold-soft);
  background: rgba(8, 6, 3, 0.8);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 13px;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}
#ink-tools button:hover { border-color: rgba(240, 180, 80, 0.7); background: rgba(240, 180, 80, 0.1); }
#ink-send { border-color: rgba(240, 180, 80, 0.6) !important; }
.msg pre.drawing {
  margin: 8px 0 0;
  font: inherit;
  font-size: 7px;
  line-height: 1.05;
  letter-spacing: 0;
  color: var(--gold-dim);
  overflow: hidden;
}

/* ---------- the page without the chat ---------- */
#static {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  top: var(--log-top);
  bottom: 0;
  width: var(--col);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 44px 4px 64px;
  z-index: 3;
  outline: none;
  animation: rise 0.9s ease both;
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 40px, #000 calc(100% - 40px), transparent 100%);
  mask-image: linear-gradient(to bottom, transparent 0, #000 40px, #000 calc(100% - 40px), transparent 100%);
}
#static[hidden] { display: none; }
@keyframes rise { from { opacity: 0; } to { opacity: 1; } }
body.static #log, body.static #dock { opacity: 0; visibility: hidden; pointer-events: none; }
#static::-webkit-scrollbar { width: 5px; }
#static::-webkit-scrollbar-thumb { background: rgba(240, 180, 80, 0.22); border-radius: 3px; }
#static h2 { margin: 0 0 6px; font-size: 22px; font-weight: 500; letter-spacing: 0.02em; color: var(--gold); text-shadow: 0 0 18px rgba(240, 170, 60, 0.35); }
#static h3 { margin: 0 0 8px; font-size: 11px; font-weight: 500; letter-spacing: 0.24em; text-transform: uppercase; color: var(--gold-dim); }
#static p { margin: 0 0 0.85em; }
#static section { margin-top: 30px; padding-top: 28px; border-top: 1px solid rgba(240, 180, 80, 0.13); }
#static .lede { color: var(--gold-soft); }
#static .links { display: flex; gap: 16px; font-size: 12px; }
#static a, #static .links button {
  color: var(--gold);
  font: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: rgba(240, 180, 80, 0.35);
}
#static .steps { margin: 0 0 1em; padding-left: 1.6em; }
#static .steps b { font-weight: 500; color: var(--gold); }
#static .made { list-style: none; margin: 0; padding: 0; }
#static .made li { display: grid; grid-template-columns: 5.5em 1fr; gap: 10px; padding: 3px 0; }
#static .made span { color: var(--gold-dim); font-size: 12.5px; line-height: 1.95; }
#read-close {
  display: block;
  margin: 0 0 22px;
  padding: 7px 13px;
  font: inherit;
  font-size: 12px;
  color: var(--gold-soft);
  background: rgba(8, 6, 3, 0.55);
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
}
#read-close:hover { border-color: rgba(240, 180, 80, 0.7); }
#read-close[hidden] { display: none; }
#closed-note {
  margin: 0 0 28px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 13.5px;
  color: var(--gold-soft);
}
#closed-note[hidden] { display: none; }
#closed-note p { margin: 0; }
#closed-parting { margin: 10px 0 0; padding-left: 12px; border-left: 2px solid var(--gold-dim); color: var(--gold-faint); font-style: italic; }
#closed-parting[hidden] { display: none; }

/* The bolt lands: the conversation goes with it. */
body.struck #log, body.struck #dock { opacity: 0; filter: blur(3px); transition: opacity 0.18s ease, filter 0.18s ease; }

@media (max-width: 699px) {
  html, body { font-size: 14.5px; }
  #top { padding: 12px 16px; }
  #chips { flex-wrap: nowrap; justify-content: flex-start; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
  #chips::-webkit-scrollbar { display: none; }
  #chips button { flex: none; }
  .msg.greeting { font-size: 14.5px; }
  #q { font-size: 16px; } /* keeps iOS from zooming on focus */
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
