/* OneStory. Brand: amber #F18314, cream #FFEECE, sky #3A95B5, lavender #9B8FC4, navy #0D2D3F.
   Text is always navy on a light surface or cream on navy (both above 7:1). Amber and sky carry
   navy text, never white, to stay above 4.5:1. */
:root {
  --amber: #F18314; --cream: #FFEECE; --sky: #3A95B5; --lav: #9B8FC4; --navy: #0D2D3F;
  --paper: #FFF8EA; --line: #0D2D3F26;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { font: 1rem/1.5 var(--font); color: var(--navy); background: var(--cream); }
h1, h2, p { margin: 0; }
h1 { font-size: clamp(1.5rem, 6vw, 2.25rem); line-height: 1.15; text-wrap: balance; }
h2 { font-size: 1.25rem; margin-bottom: .5rem; }
button, textarea, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--navy); outline-offset: 2px; }
.bar :focus-visible { outline-color: var(--cream); }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.fine { font-size: .8125rem; opacity: .85; }
.link { background: none; border: 0; padding: .25rem 0; text-decoration: underline; min-height: 24px; }
.demo { background: var(--navy); color: var(--cream); text-align: center; padding: .35rem 1rem; font-size: .8125rem; }

.chip { min-width: 44px; min-height: 44px; padding: 0 .75rem; border: 2px solid currentColor; border-radius: 999px; background: transparent; font-weight: 700; }
.send, .help { min-height: 44px; padding: 0 1.1rem; border: 0; border-radius: 12px; background: var(--amber); color: var(--navy); font-weight: 700; }
.send:disabled { opacity: .5; cursor: default; }

/* ---- picker ---- */
.picker { max-width: 44rem; margin: 0 auto; padding: 1rem 1rem 2rem; display: grid; gap: 1rem; }
.picker-top { display: flex; justify-content: space-between; align-items: center; }
.brand { font-weight: 800; letter-spacing: .02em; color: var(--navy); border-bottom: 4px solid var(--amber); }
.lede { max-width: 34rem; }
.cards { display: grid; gap: 1rem; grid-template-columns: 1fr 1fr; }
.card { display: grid; justify-items: center; gap: .25rem; padding: 1rem .75rem 1.25rem; border: 2px solid var(--navy); border-radius: 20px; background: var(--paper); text-align: center; }
.card:nth-child(1) { box-shadow: 6px 6px 0 var(--lav); }
.card:nth-child(2) { box-shadow: 6px 6px 0 var(--sky); }
.card:hover { transform: translate(-2px, -2px); }
.card img { width: min(100%, 11rem); height: auto; image-rendering: pixelated; }
.card-name { font-size: 1.25rem; font-weight: 800; }
.card-sub { font-size: .875rem; }
.gate { display: grid; gap: .35rem; max-width: 20rem; }
.gate input { min-height: 44px; padding: 0 .75rem; border: 2px solid var(--navy); border-radius: 10px; background: #fff; }
.err { color: #8A1C1C; font-weight: 700; }

/* ---- chat ---- */
.chat { height: 100dvh; display: grid; grid-template-rows: auto 1fr; }
.demo:not([hidden]) ~ .chat { height: calc(100dvh - 1.9rem); }
.bar { display: flex; align-items: center; gap: .5rem; padding: .5rem .75rem; background: var(--navy); color: var(--cream); }
.icon { min-width: 44px; min-height: 44px; border: 0; border-radius: 10px; background: transparent; color: inherit; font-size: 1.25rem; }
.avatar-sm { width: 48px; height: 48px; border-radius: 50%; background: var(--cream); object-fit: cover; object-position: 50% 12%; image-rendering: pixelated; }
.who { flex: 1; min-width: 0; }
.who-name { font-weight: 800; line-height: 1.2; }
.who-label { font-size: .75rem; line-height: 1.25; }
.body { min-height: 0; display: grid; grid-template-columns: 1fr; }
.stage { display: none; }
.talk { min-height: 0; display: grid; grid-template-rows: 1fr auto auto auto; max-width: 46rem; width: 100%; margin: 0 auto; }
.log { overflow-y: auto; padding: 1rem .75rem .5rem; display: flex; flex-direction: column; gap: .6rem; overscroll-behavior: contain; }
.msg { max-width: 85%; padding: .6rem .85rem; border-radius: 16px; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.them { align-self: flex-start; background: #fff; border: 2px solid var(--line); border-bottom-left-radius: 4px; }
.msg.me { align-self: flex-end; background: var(--navy); color: var(--cream); border-bottom-right-radius: 4px; }
.msg.note { align-self: center; max-width: 100%; background: none; font-size: .8125rem; text-align: center; padding: 0; }
.dots { display: inline-flex; gap: 4px; padding: .35rem 0; }
.dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--navy); opacity: .35; animation: dot 1s infinite; }
.dots i:nth-child(2) { animation-delay: .15s; } .dots i:nth-child(3) { animation-delay: .3s; }
@keyframes dot { 30% { opacity: 1; transform: translateY(-3px); } }
.starters { display: flex; flex-wrap: wrap; gap: .4rem; padding: 0 .75rem .5rem; }
.starters button { min-height: 40px; padding: 0 .8rem; border: 2px solid var(--sky); border-radius: 999px; background: var(--paper); font-size: .875rem; }
.composer { display: flex; gap: .5rem; padding: .5rem .75rem; border-top: 2px solid var(--line); background: var(--paper); align-items: flex-end; }
.composer textarea { flex: 1; min-height: 44px; max-height: 8rem; padding: .6rem .75rem; border: 2px solid var(--navy); border-radius: 12px; background: #fff; resize: none; }
.foot { padding: .15rem .75rem .5rem; background: var(--paper); text-align: center; }
.help.pulse { animation: pulse 1.2s 4; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px #F1831480; } }

@media (min-width: 60rem) {
  .body { grid-template-columns: minmax(16rem, 1fr) minmax(0, 46rem) 1fr; }
  .stage { display: grid; place-items: center; align-content: center; padding: 2rem; }
  .stage img { width: min(100%, 18rem); height: auto; image-rendering: pixelated; border-radius: 28px; background: var(--paper); border: 2px solid var(--navy); box-shadow: 8px 8px 0 var(--lav); }
  .chat[data-character="viktor"] .stage img { box-shadow: 8px 8px 0 var(--sky); }
  .avatar-sm { display: none; }
}

/* ---- dialogs ---- */
dialog { width: min(34rem, calc(100% - 2rem)); max-height: calc(100dvh - 2rem); border: 2px solid var(--navy); border-radius: 20px; padding: 1.25rem; background: var(--paper); color: var(--navy); }
dialog::backdrop { background: #0D2D3FB3; }
dialog p, dialog li { margin-bottom: .6rem; }
dialog ul { padding-left: 1.1rem; margin: 0 0 .6rem; }
dialog h3 { margin: .9rem 0 .25rem; font-size: 1rem; }
.emergency { padding: .6rem .8rem; border-radius: 12px; background: var(--amber); font-weight: 700; }
.line { display: grid; grid-template-columns: 7.5rem 1fr; gap: .5rem; align-items: baseline; margin-bottom: .4rem; }
.line a, .emergency a { font-weight: 800; font-size: 1.1rem; color: var(--navy); white-space: nowrap; }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
  .card:hover { transform: none; }
}
@media (forced-colors: active) { .send, .help, .card, .chip { border: 2px solid ButtonText; } }
