@font-face {
  font-family: Bricolage;
  src: url('/fonts/bricolage.woff2') format('woff2');
  font-weight: 200 800;
  font-display: swap;
}
:root {
  color-scheme: light;
  --ink: #292333;
  --paper: #fffdf5;
  --line: #d3cfc7;
  --violet: #c5aff7;
  --muted: #625e68;
  --mono: ui-monospace, 'Liberation Mono', monospace;
  color: var(--ink);
  font: 16px/1.48 Bricolage, system-ui, sans-serif;
  font-optical-sizing: auto;
  background: #edece3;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: clamp(16px, 4vh, 44px) clamp(14px, 4vw, 64px);
  background: radial-gradient(circle, #77726354 .8px, transparent 1px) 1px 1px/10px 10px;
}
button, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
:focus-visible { outline: 3px solid #6e44b4; outline-offset: 3px; }
.chat {
  width: min(100%, 1056px);
  height: min(844px, 92dvh);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  border: 2px solid var(--ink);
  border-radius: 18px;
  background: var(--paper);
  box-shadow: 5px 6px 0 var(--ink);
  overflow: hidden;
}
.chat-header {
  padding: 17px clamp(20px, 3vw, 40px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 2px solid var(--ink);
}
.brand { display: flex; gap: 11px; align-items: center; min-width: 0; }
.brand h1 { font-size: 2.1rem; font-weight: 800; line-height: 1; margin: 0; letter-spacing: -.075em; }
.brand h1 span { color: #7850af; }
.brand p { margin: 0 0 0 8px; padding-left: 18px; border-left: 1px solid #c5bfcb; color: var(--muted); font: .875rem/1.4 var(--mono); }
.brand-mark, .key-icon {
  display: grid; place-items: center;
  border: 1.5px solid var(--ink);
  border-radius: 9px;
  flex-shrink: 0;
}
.brand-mark { width: 43px; height: 43px; background: #c6b0f6; }
canvas { image-rendering: pixelated; display: block; }
.brand-mark canvas { width: 32px; }
#reset, #send, .starters button {
  border: 1.5px solid var(--ink); border-radius: 8px; font-weight: 720;
  transition: transform .13s ease-out, box-shadow .13s ease-out, background-color .13s;
}
#reset { padding: 8px 13px; background: var(--paper); font-size: .94rem; }
#reset span { font-size: 1.2rem; vertical-align: -.02em; line-height: 0; margin-right: 3px; }
#reset:disabled { color: #726d77; border-color: #aaa4ad; }
.thread { overflow: auto; padding: clamp(18px, 3.4vh, 32px) clamp(20px, 3vw, 40px); scrollbar-color: #a69abb transparent; }
.thread:focus-visible { outline-offset: -4px; }
.thread:has(.welcome:not([hidden])) { display: flex; flex-direction: column; }
.welcome { margin-block: auto; flex-shrink: 0; }
.hero {
  isolation: isolate; overflow: hidden; position: relative;
  display: grid; grid-template-columns: 1.05fr 1fr; align-items: center;
  min-height: clamp(235px, 34vh, 338px); border: 2px solid var(--ink); border-radius: 12px;
  padding: clamp(22px, 4vh, 40px) clamp(24px, 4vw, 60px);
  background: linear-gradient(115deg, #e4dafa 8%, #d2bef6 64%, #b8a5ec);
}
.hero::before {
  content: ''; z-index: -1; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(#5a427944 .8px, transparent .9px) 0 0 / 5px 5px;
  mask-image: linear-gradient(90deg, #0002, #0008 70%, black);
}
.hero-copy { z-index: 1; }
.hero h2 { font-weight: 800; font-variation-settings: 'wdth' 97; font-size: clamp(3.9rem, 6.8vw, 6.25rem); line-height: .85; letter-spacing: -.055em; margin: 0; }
.hero h2 span { color: #7847ae; }
.hero p { max-width: 31ch; font-size: clamp(1rem, 1.3vw, 1.18rem); line-height: 1.38; font-weight: 520; margin: 18px 0 0; }
.rivet { width: 6px; height: 6px; position: absolute; z-index: 2; border: 1px solid #5b496b; border-radius: 50%; background: linear-gradient(135deg, transparent 41%, #5b496b 43% 56%, transparent 58%); }
.tl,.tr { top: 10px; } .bl,.br { bottom: 10px; } .tl,.bl { left: 10px; } .tr,.br { right: 10px; }
.character { display: grid; place-items: center; position: relative; align-self: stretch; min-width: 0; }
.character canvas { position: absolute; width: auto; height: 115%; max-width: 115%; object-fit: contain; z-index: 1; }
.orbit { width: 89%; aspect-ratio: 1.42; border: 1px dashed #75648973; border-radius: 50%; transform: rotate(-20deg); position: absolute; }
.orbit::before { content: ''; position: absolute; inset: -7% 8%; border-radius: 50%; background: #ebdef957; }
.starter-heading { display: flex; align-items: center; gap: 14px; margin: clamp(18px, 3.1vh, 30px) 0 12px; }
.starter-heading h2 { font: 680 1.08rem/1.3 Bricolage, sans-serif; margin: 0; }
.starter-heading span { flex: 1; height: 1px; background: var(--line); }
.starters { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 12px; }
.starters button { padding: 13px 12px; display: flex; gap: 11px; align-items: center; text-align: left; line-height: 1.18; font-size: 1rem; background: #fffef9; box-shadow: 0 2px 0 var(--ink); }
.key-icon { width: 35px; height: 35px; border: 0; border-radius: 7px; }
.key-icon canvas { width: 28px; }
.peach { background: #ffd4bf; } .butter { background: #f6e4a1; } .sage { background: #ccdfac; }
@media (hover: hover) {
  .starters button:hover, #reset:not(:disabled):hover { transform: translateY(-2px); box-shadow: 0 3px 0 var(--ink); background: #f5effe; }
  #send:not(:disabled):hover { background: #514065; }
}
.starters button:active, #send:active { transform: translateY(1px); }
footer { border-top: 1px solid var(--line); padding: 15px clamp(20px, 3vw, 40px) 10px; background: #f6f3eb; }
.composer { display: flex; align-items: flex-end; gap: 8px; padding: 7px; background: #fffef9; border: 2px solid var(--ink); border-radius: 10px; box-shadow: 0 2px 0 #292333; }
.composer:focus-within { border-color: #6c4a95; box-shadow: 0 2px 0 #6c4a95; }
textarea { flex: 1; min-width: 0; field-sizing: content; resize: none; min-height: 44px; max-height: 15dvh; border: 0; outline: none; background: transparent; padding: 10px; line-height: 1.45; font-size: 1rem; }
textarea::placeholder { color: #706a77; }
#send { background: var(--ink); color: var(--paper); min-height: 44px; padding: 8px 18px; }
#send span { color: #d8bdfa; font-family: var(--mono); margin-left: 6px; }
#send:disabled { opacity: .6; }
.key-hint { margin: 8px 2px 0; font: .78rem/1.3 var(--mono); color: var(--muted); }
.key-hint span { margin: 0 4px; } kbd { font: inherit; }
#status { margin: 0 0 10px; color: #604173; font: .9rem/1.4 var(--mono); }
.turn { margin: 0 0 22px; width: fit-content; max-width: min(87%, 47rem); }
.turn h2 { margin: 0 0 5px 2px; display: flex; align-items: center; gap: 7px; font: 720 .94rem/1.4 Bricolage, sans-serif; }
.turn.assistant h2::before { content: ''; width: 10px; height: 10px; background: var(--violet); border: 1.5px solid var(--ink); border-radius: 3px; transform: rotate(8deg); }
.turn p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; background: #f4edfc; border: 1px solid #cdbbda; border-radius: 3px 14px 14px; padding: 12px 16px; line-height: 1.55; }
.turn.user { margin-left: auto; }
.turn.user h2 { justify-content: flex-end; }
.turn.user p { background: #eef1d9; border-color: #c5c8a6; border-radius: 14px 3px 14px 14px; }
.turn em { color: #624977; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
@media (max-width: 700px) {
  body { padding: 12px; }
  .chat { height: calc(100dvh - 28px); }
  .brand p { display: none; }
  .starters { gap: 8px; }
  .starters button { gap: 7px; padding: 10px; font-size: .94rem; }
  .hero { padding-inline: 24px; min-height: 235px; }
}
@media (max-width: 540px) {
  body { padding: 0; }
  .chat { height: 100dvh; border: 0; border-radius: 0; box-shadow: none; }
  .chat-header { padding: 13px 16px; }
  .brand-mark { width: 35px; height: 35px; }
  .brand h1 { font-size: 1.85rem; }
  .thread { padding: 16px; }
  .welcome { margin-block: auto; }
  .hero { min-height: 200px; padding: 24px 16px; grid-template-columns: 1.1fr 1fr; }
  .hero h2 { font-size: clamp(2.8rem,11vw,3.75rem); }
  .hero p { margin-top: 12px; font-size: 1rem; }
  .character canvas { max-width: 121%; height: 100%; }
  .starter-heading { margin-top: 16px; }
  .starters { grid-template-columns: 1fr; }
  .starters button { padding: 7px 10px; gap: 12px; }
  .key-icon { width: 29px; height: 29px; }
  .key-icon canvas { width: 24px; }
  footer { padding: 12px 16px max(14px,env(safe-area-inset-bottom)); }
  .key-hint { display: none; }
  .turn { max-width: 94%; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
