@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;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  background: #edece3;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
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, #stop, .header-action, .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[aria-hidden] { font-size: 1.2rem; vertical-align: -.02em; line-height: 0; }
.reset-label { margin-inline-start: 4px; }
#reset:disabled { color: #726d77; border-color: #aaa4ad; }
.header-action { display: inline-flex; gap: 7px; align-items: center; justify-content: center; padding: 8px 11px; background: var(--paper); font-size: .94rem; }
.header-action:disabled { opacity: .55; }
.history-icon { width: 15px; height: 16px; border: 1.5px solid currentColor; border-radius: 3px; }
.history-icon::after { content: ''; display: block; width: 7px; height: 5px; margin: 3px auto 0; border-block: 1.5px solid currentColor; }
.chat-controls { display: flex; align-items: center; gap: 8px; min-width: 0; }
.model-control { display: flex; align-items: center; gap: 7px; }
.model-control label { font: .8rem/1.2 var(--mono); white-space: nowrap; color: var(--muted); }
#model {
  min-width: 0; max-width: 100%; padding: 9px 25px 9px 10px; border: 1.5px solid var(--ink);
  border-radius: 8px; color: var(--ink); font: 720 .875rem/1.3 Bricolage, system-ui, sans-serif;
  background: linear-gradient(45deg, transparent 50%, #594578 51%) calc(100% - 12px) center/5px 5px no-repeat,
              linear-gradient(135deg, #594578 50%, transparent 51%) calc(100% - 7px) center/5px 5px no-repeat, #f0e7fa;
  appearance: none; cursor: pointer;
}
#model:disabled { opacity: .7; cursor: default; }
.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; background: transparent; border: 0; border-radius: 14px; padding: 0; touch-action: manipulation; }
.character canvas { position: absolute; width: auto; height: 115%; max-width: 115%; object-fit: contain; z-index: 1; }
.boop-label {
  position: absolute; z-index: 2; top: 3%; right: 0;
  max-width: 10em; padding: 5px 9px; border: 1.5px solid var(--ink);
  border-radius: 9px 9px 9px 2px; background: #fff7df; box-shadow: 2px 2px var(--ink);
  font: 700 .875rem/1.15 var(--mono); transform: rotate(4deg);
}
.character.booped .boop-label { background: #ffd2ce; }
.character.booped canvas { animation: boop-bounce .42s ease-out; }
@keyframes boop-bounce { 35% { transform: translateY(-5px) rotate(-4deg); } 70% { transform: rotate(2deg); } }
.phone-label { display: none; }
.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; } .lilac { background: #c6b0f6; border: 1.5px solid var(--ink); }
.desktop-banner {
  margin-top: 14px; padding: 10px 14px;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 14px;
  border: 1.5px solid var(--ink); border-radius: 10px; background: #f6f0fd; box-shadow: 0 2px 0 var(--ink);
}
.desktop-copy { display: flex; align-items: center; gap: 10px; min-width: 0; }
.desktop-copy h3 { margin: 0; font-size: .98rem; line-height: 1.2; }
.desktop-copy p { margin: 1px 0 0; font: .8rem/1.3 var(--mono); color: var(--muted); }
.desktop-links { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.download-app {
  display: inline-flex; align-items: center; justify-content: center; min-height: 36px; padding: 6px 12px;
  border: 1.5px solid var(--ink); border-radius: 8px; background: #fffef9; color: var(--ink);
  font-size: .9rem; font-weight: 720; text-decoration: none; box-shadow: 0 2px 0 var(--ink);
  transition: transform .13s ease-out, box-shadow .13s ease-out, background-color .13s;
}
.download-app:hover { transform: translateY(-1px); box-shadow: 0 3px 0 var(--ink); background: #e8dcf9; }
.download-app:active { transform: translateY(1px); }
.inline-link {
  border: 0; padding: 0; background: transparent; color: #593386; font: inherit;
  text-decoration: underline; text-underline-offset: .16em;
}
.inline-link:hover { color: #38214f; }
.desktop-dialog-body { padding: 16px; display: grid; gap: 14px; }
.desktop-dialog-body p { margin: 0; }
.download-gate { display: grid; gap: 10px; }
#download-code {
  width: 100%; padding: 10px 12px; border: 1.5px solid var(--ink); border-radius: 8px;
  background: #fffef9; color: var(--ink); font: 1rem/1.4 var(--mono);
}
#download-status { font: .875rem/1.4 var(--mono); color: #604173; }
.desktop-note { font: .82rem/1.45 var(--mono); color: var(--muted); }
.desktop-note code { font: inherit; background: #f0e7fa; padding: 1px 4px; border-radius: 4px; }
@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; }
#stop { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 8px 13px; background: #ffd9ce; color: #522e29; }
#stop span { width: 9px; height: 9px; border-radius: 2px; background: currentColor; }
#stop:disabled { opacity: .65; }
#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); }
#status:not([hidden]) { display: flex; align-items: center; gap: 8px; }
.chat-visor { box-sizing: content-box; width: 32px; height: auto; padding: 1px; background: var(--violet); border: 1px solid var(--ink); border-radius: 6px; flex: none; }
#status .chat-visor { animation: visor-think 1.2s ease-in-out infinite; }
@keyframes visor-think { 50% { transform: translateY(-2px) rotate(-4deg); } }
.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-body { overflow-wrap: anywhere; background: #f4edfc; border: 1px solid #cdbbda; border-radius: 3px 14px 14px; padding: 12px 16px; line-height: 1.55; }
.turn p { margin: 0; white-space: pre-wrap; }
.turn-body > * + * { margin-top: 10px; }
.turn pre { margin-bottom: 0; padding: 10px 12px; border-radius: 8px; background: #31263d; color: #fff6fb; white-space: pre-wrap; }
.turn code { font: .9em/1.5 var(--mono); }
.turn.user { margin-left: auto; }
.turn.user h2 { justify-content: flex-end; }
.turn.user .turn-body { background: #eef1d9; border-color: #c5c8a6; border-radius: 14px 3px 14px 14px; }
.turn em { color: #624977; }
.turn a { color: #593386; text-decoration: underline; text-underline-offset: .16em; }
.turn a:hover { color: #38214f; text-decoration-thickness: 2px; }
.file-card {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 14px;
  min-width: min(230px, 100%); padding: 8px 10px; border: 1px solid #bcabd0; border-radius: 8px; background: #fffaf2;
}
.file-card span { min-width: 0; font: 700 .875rem/1.4 var(--mono); }
.file-controls, .reply-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.reply-actions { margin-top: 6px; }
.file-download, .copy-action, .preview-action, .continue-reply, .dialog-actions button {
  display: inline-flex; align-items: center; min-height: 40px; padding: 6px 11px;
  border: 1px solid #564267; border-radius: 7px; background: #e8dcf9; color: #3d2950;
  font-family: inherit; font-size: .92rem; font-weight: 720; text-decoration: none;
}
.turn .file-download { color: #3d2950; }
.file-download:hover, .copy-action:hover, .preview-action:hover, .continue-reply:not(:disabled):hover, .dialog-actions button:hover { background: #dcccfa; }
.copy-action, .preview-action { background: #fff9f3; }
.reply-actions .copy-action { border-color: transparent; color: #624977; background: transparent; padding-inline: 7px; }
.reply-actions .copy-action:hover { background: #f4edfc; }
.code-panel { border: 1px solid #59486c; border-radius: 8px; background: #31263d; padding: 4px; }
.code-panel pre { margin: 0; }
.code-panel .copy-action { min-height: 34px; margin: 0 7px 6px; }
.continue-reply:disabled { opacity: .65; }
.panel-dialog {
  width: min(680px, calc(100% - 24px)); max-height: calc(100dvh - 24px);
  padding: 0; color: var(--ink); background: var(--paper); border: 2px solid var(--ink);
  border-radius: 14px; box-shadow: 4px 5px 0 var(--ink);
}
.panel-dialog[open] { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; }
.panel-dialog::backdrop { background: #29233375; }
.dialog-header, .dialog-actions { display: flex; align-items: center; gap: 10px; padding: 13px 16px; }
.dialog-header { justify-content: space-between; background: #f0e7fa; border-bottom: 1px solid var(--line); }
.dialog-header h2 { margin: 0; font-size: 1.15rem; overflow-wrap: anywhere; }
.dialog-header p { margin: 0; font-size: .875rem; color: var(--muted); }
.close-dialog { width: 40px; height: 40px; border: 1px solid var(--ink); border-radius: 7px; background: var(--paper); font-size: 1.3rem; }
.dialog-actions { justify-content: flex-end; flex-wrap: wrap; border-top: 1px solid var(--line); }
#file-preview pre, #history-list { margin: 0; padding: 14px 16px; overflow: auto; }
#file-preview pre { min-height: 110px; font: .875rem/1.55 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; }
#history-list { list-style: none; }
#history-list li { display: flex; align-items: baseline; gap: 6px; margin-bottom: 4px; }
.history-entry, .history-delete { padding: 8px; border: 1px solid transparent; border-radius: 6px; text-align: left; background: transparent; }
.history-entry { flex: 1; overflow-wrap: anywhere; }
.history-entry[aria-current="true"], .history-entry:hover { background: #f0e7fa; }
.history-delete { color: #794350; font-size: .875rem; }
.history-delete:hover { border-color: #a97683; }
.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; }
}
/* On a handset the welcome screen becomes a handheld console with three physical keys. */
@media (max-width: 600px), (pointer: coarse) and (max-height: 520px) {
  body { display: block; padding: 0; min-height: 0; }
  .chat {
    height: var(--phone-height, 100dvh); width: 100%; border: 0; border-radius: 0; box-shadow: none;
    padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right);
  }
  .chat-header { padding: calc(9px + env(safe-area-inset-top)) 16px 9px; background: #fcf8ee; }
  .brand { display: grid; grid-template-columns: auto auto; column-gap: 8px; row-gap: 1px; }
  .brand-mark { grid-row: span 2; width: 37px; height: 37px; }
  .brand h1 { font-size: 1.65rem; }
  .brand p { display: block; border: 0; margin: 0; padding: 0; font: .75rem/1.1 var(--mono); }
  #reset { min-height: 44px; }
  .model-control { position: relative; }
  .model-control label { position: absolute; top: 4px; left: 9px; pointer-events: none; font-size: .7rem; }
  #model { min-height: 44px; font-size: 1rem; padding: 16px 22px 3px 8px; }
  .chat-controls { gap: 6px; }
  .header-action { min-width: 44px; min-height: 44px; padding: 0; }
  .history-label { display: none; }
  #reset { display: grid; place-items: center; min-width: 44px; padding: 0; }
  #reset span[aria-hidden] { font-size: 1.45rem; line-height: 1; }
  .reset-label { display: none; }
  .thread { padding: 14px 16px; overscroll-behavior-y: contain; }
  .hero {
    grid-template-columns: minmax(0, 1fr); padding: 0; min-height: 0;
    background-color: #cebef2;
  }
  .character {
    grid-row: 1; width: 100%; height: clamp(132px, 26dvh, 238px);
    border-radius: 11px 11px 0 0;
    background: linear-gradient(#5d467110 1px, transparent 1px) 0 0/16px 16px,
                linear-gradient(90deg, #5d467110 1px, transparent 1px) 0 0/16px 16px;
  }
  .character:focus-visible { outline-offset: -5px; }
  .character canvas { width: auto; height: 94%; max-width: 90%; }
  .orbit { width: min(58%, 220px); aspect-ratio: 1.7; }
  .boop-label { top: 15%; right: 7%; }
  .hero-copy { padding: 15px 18px 17px; border-top: 1.5px solid var(--ink); background: #f0e7fa; }
  .hero h2 { font-size: clamp(2rem, 8.4vw, 3rem); line-height: 1.03; }
  .hero h2 br { display: none; }
  .hero p { margin: 6px 0 0; max-width: 34ch; font-size: 1rem; line-height: 1.32; }
  .bl,.br { display: none; }
  .starter-heading { margin: 17px 0 10px; }
  .starters { grid-template-columns: repeat(3,minmax(0,1fr)); gap: 8px; padding-bottom: 3px; }
  .starters button {
    flex-direction: column; justify-content: center; align-items: center;
    padding: 9px 4px; gap: 6px; text-align: center;
    min-height: 76px; font-size: .94rem; box-shadow: 0 3px 0 var(--ink);
  }
  .starters .full-label { display: none; }
  .starters .phone-label { display: inline; }
  .key-icon { width: 34px; height: 30px; }
  .key-icon canvas { width: 26px; }
  footer { padding: 10px 14px calc(10px + env(safe-area-inset-bottom)); }
  .key-hint { display: none; }
  .turn { max-width: 96%; margin-bottom: 18px; }
  .turn-body { padding: 10px 13px; }
  .turn.user { max-width: 88%; }
  .reply-actions button, .file-controls > *, .dialog-actions > *, .close-dialog, .download-app { min-height: 44px; }
  .desktop-banner { padding: 10px 12px; }
  .desktop-links { width: 100%; }
  .desktop-links .download-app { flex: 1 1 130px; }
}
@media (max-width: 375px) {
  #reset { display: none; }
}
@media (max-width: 360px) {
  #send { padding-inline: 12px; }
  #send span { display: none; }
  .starters button { font-size: .875rem; }
}
@media (max-width: 600px) and (max-height: 620px) {
  .character { height: 116px; }
  .hero-copy { padding-block: 10px 12px; }
  .starter-heading { margin-block: 11px 7px; }
  .starters button { padding-block: 6px; min-height: 65px; }
}
@media (pointer: coarse) and (orientation: landscape) and (max-height: 520px) {
  .chat-header { padding-block: max(3px, env(safe-area-inset-top)) 3px; }
  .hero { grid-template-columns: 1fr 1fr; align-items: stretch; }
  .hero-copy { grid-column: 1; grid-row: 1; border-top: 0; display: grid; align-content: center; }
  .character { grid-column: 2; height: 122px; }
  .hero h2 { font-size: 2.1rem; }
  .starter-heading { margin: 10px 0 6px; }
  .starters button { flex-direction: row; min-height: 44px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
