/* Frejya - interface styles.
   Sections: tokens, base, stage, top bar, chat, bubbles, prose, composer,
   overlays (sheets, dialogs), forms, toasts, wide layout, motion. */

/* ---------- tokens ---------- */
:root {
  --night-950: #060709;
  --night-900: #0c0e12;
  --night-800: #14171d;
  --night-700: #1e222b;
  --night-600: #2a303c;
  /* her colours: the pink and violet of her eyes */
  --accent: #f062b0;
  --accent-deep: #6a40d2;
  --accent-soft: #c9a8ff;
  --gold: #ffd54a;
  --gold-deep: #f5a524;
  --cream: #f7f5f0;
  --paper: #fbfaf7;
  --ink: #15171c;
  --ink-soft: #4d5261;
  --mist: #b4bac8;
  --danger: #ff8080;
  --glass: rgba(16, 18, 24, .76);
  --glass-strong: rgba(12, 14, 18, .92);
  --line: rgba(255, 255, 255, .14);
  --shadow: 0 8px 24px rgba(0, 0, 0, .4);
  --font: ui-rounded, "SF Pro Rounded", "Hiragino Maru Gothic ProN", "Nunito", "Quicksand", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --app-h: 100dvh;
  --ease: cubic-bezier(.2, .8, .2, 1);
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  display: grid;
  place-items: center;
  background: radial-gradient(120% 90% at 50% 0%, #20242d 0%, var(--night-950) 62%);
  color: var(--cream);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; touch-action: manipulation; }
button:disabled { cursor: default; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap; border: 0;
}
.noscript { position: absolute; inset: 40% 10% auto; text-align: center; }
.elsewhere {
  position: absolute; inset: 0; z-index: 30;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  padding: 28px; text-align: center;
  background: rgba(6, 7, 9, .92);
}
.elsewhere p { margin: 0 0 8px; max-width: 30ch; color: var(--mist); }
.elsewhere p:first-child { color: var(--cream); font-size: 19px; font-weight: 800; }
svg.icon { width: 22px; height: 22px; display: block; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }

.app {
  position: relative;
  width: 100%;
  max-width: 540px;
  height: var(--app-h);
  overflow: hidden;
  background: var(--night-900);
  isolation: isolate;
}
.app[data-ready="false"] .topbar,
.app[data-ready="false"] .dock { opacity: 0; }
.app[data-welcome="true"] .topbar,
.app[data-welcome="true"] .dock { opacity: 0; visibility: hidden; }
.topbar, .dock { transition: opacity .4s ease; }

/* ---------- stage: Frejya's picture ---------- */
.stage { position: absolute; inset: 0; z-index: 0; overflow: hidden; background: linear-gradient(#23272e, #0e1013); }
.actor {
  position: absolute; left: 0; right: 0; top: 0; height: 100%;
  overflow: hidden;
  transition: height .5s var(--ease);
  animation: breathe 7s ease-in-out infinite alternate;
  transform-origin: 50% 40%;
}
.actor__bob, .actor__par { position: absolute; inset: 0; }
.actor__par {
  transform: translate(calc(var(--par-x, 0) * -7px), calc(var(--par-y, 0) * -5px)) scale(1.035);
  transition: transform .7s ease-out;
}
.actor__layer { position: absolute; inset: 0; z-index: 0; opacity: 0; transition: opacity .45s ease; }
.actor__layer.is-on { z-index: 2; opacity: 1; }
.actor__layer.is-leaving { z-index: 1; opacity: 1; transition: none; } /* stays put underneath while the next one fades in */
.actor__media {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; object-position: 50% 0; opacity: 0;
  user-select: none; -webkit-user-drag: none; pointer-events: none;
}
.actor__layer[data-kind="video"] video.actor__media,
.actor__layer[data-kind="image"] img.actor__media { opacity: 1; }
.actor__layer.is-panning .actor__media { transition: object-position .7s ease; }
/* the drawn character moves by herself (css/avatar.css), so the slow zoom used for pictures is off */
.actor[data-look="none"] { animation: none; }
.actor[data-talking="true"] .actor__bob { animation: talk .46s ease-in-out infinite; }
.actor__bob.kick-pop { animation: kick-pop .5s var(--ease); }
.actor__bob.kick-sink { animation: kick-sink .7s var(--ease); }
.actor__bob.kick-nod { animation: kick-nod .5s var(--ease); }
.app[data-chat="expanded"] .actor { height: 62%; }
/* darker top and bottom edges so the controls and the chat stay readable */
.stage::before {
  content: ""; position: absolute; inset: 0 0 auto; height: 120px; z-index: 1; pointer-events: none;
  background: linear-gradient(rgba(6, 7, 9, .6), rgba(6, 7, 9, 0));
}
.stage::after {
  content: ""; position: absolute; inset: 40% 0 0; z-index: 1; pointer-events: none;
  background: linear-gradient(rgba(6, 7, 9, 0), rgba(6, 7, 9, .55) 45%, rgba(6, 7, 9, .82));
}

/* mood marks beside her head */
.emote { position: absolute; left: 0; top: 0; z-index: 1; width: 0; height: 0; pointer-events: none; transform: translate(var(--emote-x, 75%), var(--emote-y, 120px)); }
.emote__inner {
  position: absolute; left: -24px; top: -24px; width: 48px; height: 48px;
  display: grid; place-items: center;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, .5));
  animation: emote-in .4s var(--ease) both;
}
.emote__inner svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.emote--spark svg { animation: twinkle 1.4s ease-in-out infinite; }
.emote--double svg:last-child { inset: auto -14px -10px auto; width: 24px; height: 24px; animation-delay: .5s; }
.emote--float svg { animation: drift 1.8s ease-in-out infinite alternate; }
.emote--badge { width: 42px; height: 42px; left: -21px; top: -21px; border-radius: 50%; background: #fff; color: var(--ink); font: 900 25px/1 var(--font); }
.emote--bang { background: var(--accent); color: #fff; }
.emote--dots { gap: 4px; grid-auto-flow: column; }
.emote--dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--ink-soft); animation: blink 1.2s infinite ease-in-out; }
.emote--dots i:nth-child(2) { animation-delay: .18s; }
.emote--dots i:nth-child(3) { animation-delay: .36s; }
.emote--drop svg { animation: drip 1.6s ease-in infinite; }
.emote--zzz { font: 900 20px/1 var(--font); color: #fff; }
.emote--zzz b { position: absolute; left: 4px; bottom: 0; opacity: 0; animation: zzz 2.4s ease-in-out infinite; text-shadow: 0 1px 4px rgba(0, 0, 0, .7); }
.emote--zzz b:nth-child(2) { animation-delay: .8s; font-size: 16px; }
.emote--zzz b:nth-child(3) { animation-delay: 1.6s; font-size: 13px; }

.thought {
  position: absolute;
  right: 4%;
  top: calc(62px + var(--safe-top));
  max-width: 42%;
  padding: 9px 13px;
  border-radius: 18px;
  background: rgba(255, 255, 255, .93);
  color: var(--ink-soft);
  font-size: 12.5px;
  line-height: 1.35;
  box-shadow: var(--shadow);
  z-index: 1;
  animation: pop .25s var(--ease);
}
.thought::before, .thought::after {
  content: ""; position: absolute; background: rgba(255, 255, 255, .93); border-radius: 50%;
}
.thought::before { width: 12px; height: 12px; left: 4px; bottom: -9px; }
.thought::after { width: 7px; height: 7px; left: -6px; bottom: -18px; }
.thought__text { display: -webkit-box; -webkit-line-clamp: 4; line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; font-style: italic; }

/* ---------- top bar ---------- */
.topbar {
  position: absolute; z-index: 3;
  left: 0; right: 0; top: 0;
  padding: calc(10px + var(--safe-top)) 12px 0;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  pointer-events: none;
}
.topbar > * { pointer-events: auto; }
.topbar__right { display: flex; align-items: center; gap: 8px; flex: none; }
.pill {
  display: inline-flex; align-items: center; gap: 7px;
  min-height: 36px; padding: 6px 13px;
  border-radius: 999px;
  background: rgba(250, 249, 246, .95);
  color: var(--ink);
  font-weight: 700; font-size: 14px; line-height: 1;
  box-shadow: 0 3px 12px rgba(0, 0, 0, .3);
  white-space: nowrap;
}
.pill--bond { padding-right: 10px; min-width: 0; }
.pill__name { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
/* the rune on her badge, repeated beside her name (on a phone her badge is behind the conversation) */
.pill__rune { flex: none; width: 22px; height: 22px; margin: -2px -1px -2px -3px; }
.pill__rune svg { display: block; width: 100%; height: 100%; }
.pill__rune.is-changing { animation: rune-turn .6s var(--ease); }
@keyframes rune-turn { from { transform: scale(.5) rotate(-40deg); opacity: .2; } to { transform: none; opacity: 1; } }
.pill__level, .pill__xp { flex: none; }
.pill__level { font-size: 11.5px; font-weight: 800; color: #7a4a00; background: linear-gradient(135deg, var(--gold), #ffe7a8); padding: 4px 7px; border-radius: 999px; }
.pill__xp { width: 34px; height: 6px; border-radius: 3px; background: rgba(21, 23, 28, .16); overflow: hidden; }
.pill__xp i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--gold)); border-radius: 3px; transition: width .6s var(--ease); }
.pill--streak { font-size: 13px; }
.pill--demo { background: var(--gold); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; min-height: 28px; padding: 4px 10px; }
.iconbtn {
  width: 40px; height: 40px; flex: none;
  display: grid; place-items: center;
  border-radius: 50%;
  color: var(--mist);
  transition: background .15s, color .15s, transform .15s;
}
.iconbtn:hover { color: var(--cream); background: rgba(255, 255, 255, .08); }
.iconbtn:active { transform: scale(.94); }
.iconbtn--glass { background: var(--glass); border: 1px solid var(--line); color: var(--cream); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.iconbtn--toggle[aria-pressed="true"] { color: #fff; background: linear-gradient(135deg, var(--accent), var(--accent-deep)); }

/* ---------- dock: chat + composer ---------- */
.dock {
  position: absolute; z-index: 2;
  left: 0; right: 0; bottom: 0;
  height: max(52%, min(330px, 100%));
  display: flex; flex-direction: column;
  transition: height .45s var(--ease);
}
.app[data-chat="expanded"] .dock { height: calc(100% - 31%); }
.chat { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; }
.app[data-chat="expanded"] .chat {
  background: linear-gradient(rgba(12, 14, 18, 0), rgba(12, 14, 18, .88) 34px);
}
.chat__handle {
  position: absolute; z-index: 2; left: 50%; top: 0; transform: translateX(-50%);
  width: 64px; height: 26px; display: grid; place-items: center;
}
.chat__handle::before {
  content: ""; width: 38px; height: 5px; border-radius: 3px; background: rgba(255, 255, 255, .5);
  box-shadow: 0 1px 4px rgba(0, 0, 0, .4); transition: background .15s, width .15s;
}
.chat__handle:hover::before { background: #fff; width: 46px; }
.log {
  flex: 1; min-height: 0;
  overflow-y: auto; overflow-x: hidden;
  padding: 30px 12px 8px;
  display: flex; flex-direction: column; gap: 6px;
  overscroll-behavior: contain;
  scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, .25) transparent;
  -webkit-mask-image: linear-gradient(transparent 0, #000 34px);
  mask-image: linear-gradient(transparent 0, #000 34px);
  outline: none;
}
.log > :first-child { margin-top: auto; } /* short conversations sit at the bottom */
.chat__latest {
  position: absolute; left: 50%; bottom: 8px; transform: translateX(-50%);
  padding: 7px 14px; border-radius: 999px;
  background: var(--gold); color: var(--ink); font-size: 13px; font-weight: 700;
  box-shadow: var(--shadow);
}

/* ---------- messages and bubbles ---------- */
.msg { display: flex; flex-direction: column; gap: 5px; max-width: 88%; min-width: 0; }
.msg--her { align-self: flex-start; align-items: flex-start; }
.msg--me { align-self: flex-end; align-items: flex-end; }
.msg + .msg--me, .msg--me + .msg--her { margin-top: 6px; }
/* the small speaker under her reply; only shown once her voice is set up */
.saybtn {
  display: none; place-items: center; width: 30px; height: 30px; margin: -1px 0 0 2px; border-radius: 50%;
  background: var(--glass); border: 1px solid var(--line); color: var(--mist);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); transition: color .15s, background .15s;
}
.saybtn .icon { width: 17px; height: 17px; }
.saybtn:hover { color: var(--cream); }
.saybtn[aria-pressed="true"] { color: #fff; background: linear-gradient(135deg, var(--accent), var(--accent-deep)); border-color: transparent; }
.app[data-voice="on"] .saybtn { display: grid; }
.bubble {
  position: relative;
  max-width: 100%;
  padding: 9px 14px;
  border-radius: 20px;
  font-size: 15.5px; line-height: 1.45;
  overflow-wrap: anywhere;
  box-shadow: 0 5px 16px rgba(0, 0, 0, .3);
  animation: pop .28s var(--ease) both;
}
.msg--her .bubble { background: rgba(250, 249, 246, .97); color: var(--ink); }
.msg--her .bubble:last-of-type { border-bottom-left-radius: 7px; }
.msg--me .bubble { background: linear-gradient(135deg, #7b4fe6, #5a35bf); color: #fff; }
.msg--me .bubble:last-of-type { border-bottom-right-radius: 7px; }
.bubble--plain { white-space: pre-wrap; }
.earlier { align-self: center; margin-bottom: 6px; }
.bubble--code, .bubble--wide { width: 100%; }
.msg:has(.bubble--code), .msg:has(.bubble--wide) { max-width: 100%; width: 100%; }
.msg--her .bubble--code { padding: 0; background: #14171d; color: #e9ebf1; border: 1px solid rgba(255, 255, 255, .12); overflow: hidden; }
.bubble--typing { display: inline-flex; gap: 5px; align-items: center; padding: 14px 16px; }
.bubble--typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--ink-soft); opacity: .45; animation: blink 1.2s infinite ease-in-out; }
.bubble--typing i:nth-child(2) { animation-delay: .18s; }
.bubble--typing i:nth-child(3) { animation-delay: .36s; }
.msg__photos { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.msg__photos img { width: 132px; height: 132px; object-fit: cover; border-radius: 16px; box-shadow: var(--shadow); background: var(--night-700); }
.msg__meta { font-size: 11px; color: rgba(255, 255, 255, .62); padding: 0 6px; text-shadow: 0 1px 3px rgba(0, 0, 0, .6); }
.daymark { align-self: center; margin: 8px 0 4px; padding: 3px 11px; border-radius: 999px; font-size: 11.5px; font-weight: 600; color: var(--mist); background: rgba(12, 14, 18, .62); }
.note {
  align-self: center; max-width: 92%;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px 10px;
  margin: 4px 0; padding: 8px 14px;
  border-radius: 16px;
  background: rgba(12, 14, 18, .78); border: 1px solid var(--line);
  color: var(--mist); font-size: 13px; text-align: center;
  animation: pop .28s var(--ease) both;
}
.note--error { border-color: rgba(255, 128, 128, .45); color: #ffd9d9; }
.note button { color: var(--gold); font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }

/* ---------- rendered Markdown inside bubbles ---------- */
.prose > :first-child { margin-top: 0; }
.prose > :last-child { margin-bottom: 0; }
.prose p { margin: 0 0 .5em; }
.prose ul, .prose ol { margin: .2em 0 .5em; padding-left: 1.35em; }
.prose li { margin: .15em 0; }
.prose li > p { margin: 0 0 .3em; }
.prose strong { font-weight: 750; }
.prose a { color: #b3243f; text-decoration: underline; text-underline-offset: 2px; }
.prose blockquote { margin: .3em 0; padding: .1em 0 .1em .8em; border-left: 3px solid var(--accent); color: var(--ink-soft); }
.prose h1, .prose h2, .prose h3, .prose h4, .prose h5, .prose h6 { margin: .2em 0 .35em; font-size: 1.02em; font-weight: 800; }
.prose hr { border: 0; border-top: 1px solid rgba(21, 23, 28, .18); margin: .6em 0; }
.prose code { font-family: var(--mono); font-size: .88em; padding: .1em .35em; border-radius: 6px; background: rgba(21, 23, 28, .1); }
.prose pre {
  position: relative; margin: 0; padding: 12px 14px;
  overflow-x: auto; font-size: 13px; line-height: 1.5; tab-size: 2;
  background: #14171d; color: #e9ebf1; border-radius: 12px;
  scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, .3) transparent;
}
.bubble--code .prose pre { border-radius: 0; padding: 34px 14px 14px; }
.prose pre code { padding: 0; background: none; font-size: inherit; color: inherit; white-space: pre; }
.prose pre[data-lang]::before {
  content: attr(data-lang); position: absolute; left: 14px; top: 9px;
  font: 600 11px/1 var(--mono); letter-spacing: .04em; color: #8b93a6; text-transform: lowercase;
}
.copybtn {
  position: absolute; right: 8px; top: 5px;
  padding: 5px 9px; border-radius: 8px;
  font: 600 11.5px/1 var(--font); color: #cfd4df; background: rgba(255, 255, 255, .08);
}
.copybtn:hover { background: rgba(255, 255, 255, .18); color: #fff; }
.prose table { border-collapse: collapse; font-size: .92em; display: block; overflow-x: auto; max-width: 100%; }
.prose th, .prose td { padding: 5px 9px; border: 1px solid rgba(21, 23, 28, .2); text-align: left; }
.prose th { background: rgba(21, 23, 28, .08); }
.math--display { display: block; overflow-x: auto; overflow-y: hidden; padding: 4px 0; max-width: 100%; }
.math--display .katex-display { margin: 0; }
.katex { font-size: 1.06em; }
/* syntax colours (dark code blocks) */
.hljs-comment, .hljs-quote { color: #7d8494; font-style: italic; }
.hljs-keyword, .hljs-selector-tag, .hljs-literal, .hljs-section, .hljs-doctag { color: #ff8fa0; }
.hljs-string, .hljs-regexp, .hljs-addition, .hljs-attribute, .hljs-meta .hljs-string { color: #ffd77a; }
.hljs-number, .hljs-symbol, .hljs-bullet, .hljs-link { color: #ffb86b; }
.hljs-title, .hljs-title.function_, .hljs-title.class_, .hljs-name { color: #8ec8ff; }
.hljs-built_in, .hljs-type, .hljs-params, .hljs-variable.language_ { color: #9be8c5; }
.hljs-attr, .hljs-variable, .hljs-template-variable, .hljs-selector-class, .hljs-selector-id { color: #f7c8a0; }
.hljs-meta, .hljs-deletion { color: #ff9db0; }
.hljs-emphasis { font-style: italic; }
.hljs-strong { font-weight: 700; }

/* ---------- composer ---------- */
.composer {
  flex: none;
  display: flex; flex-direction: column; gap: 8px;
  padding: 6px 10px calc(10px + var(--safe-bottom));
}
.chips { display: flex; gap: 7px; overflow-x: auto; padding: 2px 2px 3px; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; padding: 7px 12px; border-radius: 999px;
  background: var(--glass); border: 1px solid var(--line);
  color: var(--cream); font-size: 13px; font-weight: 600; white-space: nowrap;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  transition: background .15s, transform .15s;
}
.chip:hover { background: rgba(42, 48, 60, .9); }
.chip:active { transform: scale(.96); }
.attachments { display: flex; gap: 8px; padding: 0 4px; overflow-x: auto; }
.attachment { position: relative; flex: none; }
.attachment img { width: 62px; height: 62px; object-fit: cover; border-radius: 12px; display: block; border: 1px solid var(--line); }
.attachment button {
  position: absolute; right: -6px; top: -6px; width: 22px; height: 22px; border-radius: 50%;
  background: var(--night-900); border: 1px solid var(--line); color: var(--cream); display: grid; place-items: center;
}
.attachment button svg.icon { width: 13px; height: 13px; }
.composer__row {
  display: flex; align-items: flex-end; gap: 4px;
  padding: 5px;
  border-radius: 27px;
  background: var(--glass); border: 1px solid var(--line);
  backdrop-filter: blur(14px) saturate(1.2); -webkit-backdrop-filter: blur(14px) saturate(1.2);
  box-shadow: var(--shadow);
}
.composer__row:focus-within { border-color: rgba(255, 209, 102, .65); }
.composer__input {
  flex: 1; min-width: 0;
  max-height: 132px;
  padding: 9px 6px;
  border: 0; outline: 0; resize: none;
  background: transparent; color: var(--cream);
  font-size: 16px; line-height: 1.4;
}
.composer__input::placeholder { color: rgba(180, 186, 200, .8); }
.sendbtn {
  width: 42px; height: 42px; flex: none; border-radius: 50%;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-deep)); color: #fff;
  box-shadow: 0 3px 10px rgba(106, 64, 210, .45);
  transition: transform .15s, filter .15s, opacity .15s;
}
.sendbtn:hover { filter: brightness(1.06); }
.sendbtn:active { transform: scale(.93); }
.sendbtn:disabled { opacity: .45; filter: grayscale(.6); box-shadow: none; }
.sendbtn[data-mode="stop"] { background: var(--cream); color: var(--ink); }

/* ---------- overlays: sheets and dialogs ---------- */
.backdrop {
  position: absolute; inset: 0; z-index: 10;
  background: rgba(3, 4, 6, .58);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fade .2s ease both;
}
.sheet {
  width: 100%; max-height: 92%;
  display: flex; flex-direction: column;
  background: linear-gradient(#1b1f27, #13161c);
  border: 1px solid var(--line); border-bottom: 0;
  border-radius: 26px 26px 0 0;
  box-shadow: 0 -10px 40px rgba(0, 0, 0, .45);
  animation: rise .32s var(--ease) both;
}
.sheet--dialog { max-width: 400px; width: calc(100% - 32px); margin: auto; border-radius: 24px; border-bottom: 1px solid var(--line); animation: pop .25s var(--ease) both; }
.sheet__head { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 16px 10px 20px; }
.sheet__title { margin: 0; font-size: 19px; font-weight: 800; letter-spacing: .01em; }
.sheet__body { flex: 1; min-height: 0; overflow-y: auto; padding: 4px 20px calc(22px + var(--safe-bottom)); overscroll-behavior: contain; }
.sheet__foot { flex: none; display: flex; gap: 10px; justify-content: flex-end; padding: 12px 20px calc(16px + var(--safe-bottom)); border-top: 1px solid var(--line); }
.tabs { flex: none; display: flex; gap: 4px; padding: 0 14px 8px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { flex: none; padding: 8px 13px; border-radius: 999px; font-size: 14px; font-weight: 700; color: var(--mist); }
.tab[aria-selected="true"] { background: var(--cream); color: var(--ink); }
.panel > h3 { margin: 18px 0 8px; font-size: 13px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--gold); }
.panel > h3:first-child { margin-top: 6px; }
.panel p { margin: 0 0 10px; color: var(--mist); font-size: 14px; }
.panel p strong { color: var(--cream); }
.panel a { color: var(--gold); }
.panel code { font-family: var(--mono); font-size: .9em; background: rgba(255, 255, 255, .08); padding: .1em .35em; border-radius: 5px; }

/* onboarding */
.welcome { position: absolute; inset: 0; z-index: 9; display: flex; align-items: flex-end; background: linear-gradient(rgba(6, 7, 9, 0) 30%, rgba(6, 7, 9, .7) 55%, rgba(6, 7, 9, .94)); animation: fade .4s ease both; }
.welcome__card { width: 100%; padding: 22px 22px calc(22px + var(--safe-bottom)); }
.welcome__card h1 { margin: 0 0 6px; font-size: 27px; line-height: 1.15; font-weight: 800; }
.welcome__card h1 span { background: linear-gradient(90deg, var(--gold), var(--accent-soft)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.welcome__card p { margin: 0 0 14px; color: var(--mist); font-size: 15px; }
.welcome__card .field { margin-bottom: 12px; }
.welcome__steps { display: flex; gap: 6px; margin-bottom: 14px; }
.welcome__steps i { width: 26px; height: 4px; border-radius: 2px; background: rgba(255, 255, 255, .22); }
.welcome__steps i.on { background: var(--gold); }
.welcome__actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.welcome__fine { font-size: 12.5px !important; color: rgba(180, 186, 200, .85) !important; margin-top: 12px !important; }

/* ---------- forms ---------- */
.field { display: block; margin: 0 0 14px; }
.field__label { display: block; margin-bottom: 6px; font-size: 14px; font-weight: 700; color: var(--cream); }
.field__hint { display: block; margin-top: 5px; font-size: 12.5px; color: var(--mist); }
.input, .textarea {
  width: 100%; padding: 11px 13px;
  border-radius: 14px; border: 1px solid var(--line);
  background: rgba(6, 7, 9, .5); color: var(--cream);
  font-size: 16px; outline: none;
}
.input:focus, .textarea:focus { border-color: var(--gold); }
.textarea { resize: vertical; min-height: 78px; line-height: 1.4; }
.input-row { display: flex; gap: 8px; align-items: stretch; }
.input-row .input { flex: 1; min-width: 0; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 44px; padding: 10px 18px;
  border-radius: 999px;
  font-size: 15px; font-weight: 750; white-space: nowrap;
  transition: transform .15s, filter .15s, background .15s;
}
.btn:active { transform: scale(.97); }
.btn--primary { background: linear-gradient(135deg, var(--gold), var(--gold-deep)); color: var(--ink); box-shadow: 0 4px 14px rgba(240, 169, 58, .3); }
.btn--primary:hover { filter: brightness(1.06); }
.btn--ghost { background: rgba(255, 255, 255, .08); color: var(--cream); border: 1px solid var(--line); }
.btn--ghost:hover { background: rgba(255, 255, 255, .15); }
.btn--danger { background: rgba(255, 128, 128, .14); color: #ffb3b3; border: 1px solid rgba(255, 128, 128, .4); }
.btn--small { min-height: 36px; padding: 6px 13px; font-size: 13.5px; }
.btn:disabled { opacity: .5; }
.btnrow { display: flex; flex-wrap: wrap; gap: 9px; margin: 0 0 12px; }
.choice { display: grid; gap: 8px; margin: 0 0 14px; }
.choice__item { position: relative; display: block; }
.choice__item input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; cursor: pointer; margin: 0; }
.choice__card { display: block; padding: 11px 14px; border-radius: 16px; border: 1px solid var(--line); background: rgba(6, 7, 9, .35); transition: border-color .15s, background .15s; }
.choice__item input:checked + .choice__card { border-color: var(--gold); background: rgba(255, 209, 102, .1); }
.choice__item input:focus-visible + .choice__card { outline: 2px solid var(--gold); outline-offset: 2px; }
.choice__top { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; font-weight: 800; font-size: 15px; }
.choice__top small { font-weight: 600; font-size: 12.5px; color: var(--gold); white-space: nowrap; }
.choice__blurb { display: block; margin-top: 3px; font-size: 13px; color: var(--mist); }
.choice--row { grid-template-columns: repeat(3, 1fr); }
.choice--row .choice__card { text-align: center; padding: 10px 6px; }
.choice--row .choice__top { display: block; font-size: 14px; }
.switch { display: flex; align-items: flex-start; gap: 12px; margin: 0 0 14px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch__track { flex: none; width: 46px; height: 28px; border-radius: 14px; background: rgba(255, 255, 255, .16); position: relative; transition: background .2s; margin-top: 1px; }
.switch__track::after { content: ""; position: absolute; left: 3px; top: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: transform .2s var(--ease); }
.switch input:checked + .switch__track { background: var(--gold); }
.switch input:checked + .switch__track::after { background: var(--ink); }
.switch input:checked + .switch__track::after { transform: translateX(18px); }
.switch input:focus-visible + .switch__track { outline: 2px solid var(--gold); outline-offset: 2px; }
.switch__text { font-size: 14.5px; font-weight: 700; }
.switch__text small { display: block; font-weight: 500; font-size: 12.5px; color: var(--mist); margin-top: 2px; }
.meter { margin: 0 0 14px; padding: 14px; border-radius: 18px; background: rgba(6, 7, 9, .4); border: 1px solid var(--line); }
.meter__big { font-size: 26px; font-weight: 800; }
.meter__big small { font-size: 14px; font-weight: 600; color: var(--mist); }
.meter__bar { height: 9px; border-radius: 5px; background: rgba(255, 255, 255, .12); overflow: hidden; margin: 10px 0 8px; }
.meter__bar i { display: block; height: 100%; border-radius: 5px; background: linear-gradient(90deg, var(--gold), var(--accent)); }
.meter__rows { display: grid; grid-template-columns: 1fr auto; gap: 3px 12px; font-size: 13px; color: var(--mist); }
.meter__rows b { color: var(--cream); font-weight: 700; text-align: right; }
.memlist { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 7px; }
.memlist li { display: flex; gap: 8px; align-items: flex-start; padding: 9px 8px 9px 13px; border-radius: 14px; background: rgba(6, 7, 9, .4); border: 1px solid var(--line); font-size: 14px; }
.memlist li span { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.memlist li small { display: block; color: var(--mist); font-size: 11.5px; margin-top: 2px; }
.memlist .iconbtn { width: 32px; height: 32px; }
.memlist .iconbtn svg.icon { width: 17px; height: 17px; }
.empty { padding: 14px; border-radius: 14px; border: 1px dashed var(--line); color: var(--mist); font-size: 14px; text-align: center; margin-bottom: 12px; }
.bond { text-align: center; padding: 4px 0 6px; }
.bond__level { font-size: 44px; font-weight: 800; line-height: 1; background: linear-gradient(135deg, var(--gold), var(--accent-soft)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.bond__title { font-size: 17px; font-weight: 800; margin: 6px 0 12px; }
.bond__bar { height: 9px; border-radius: 5px; background: rgba(255, 255, 255, .12); overflow: hidden; margin: 0 0 6px; }
.bond__bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--gold)); border-radius: 5px; }
.bond__stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 16px 0 6px; }
.bond__stats div { padding: 11px 4px; border-radius: 14px; background: rgba(6, 7, 9, .4); border: 1px solid var(--line); }
.bond__stats b { display: block; font-size: 19px; }
.bond__stats span { font-size: 12px; color: var(--mist); }
.bond__runes { margin-top: 16px; text-align: left; }
/* the runes on her badge, explained */
.runes { list-style: none; margin: 4px 0 0; padding: 0; display: grid; gap: 6px; }
.rune { display: flex; align-items: center; gap: 11px; padding: 7px 9px; border-radius: 14px; border: 1px solid var(--line); background: rgba(6, 7, 9, .35); font-size: 13.5px; color: var(--mist); }
.rune b { display: block; color: var(--cream); font-size: 14.5px; }
.rune[aria-current="true"], .rune--now { border-color: var(--gold); background: rgba(255, 209, 102, .09); }
.rune__icon { flex: none; width: 40px; height: 40px; }
.rune__icon svg { display: block; width: 100%; height: 100%; }

/* ---------- toasts ---------- */
.toasts { position: absolute; z-index: 20; left: 0; right: 0; top: calc(58px + var(--safe-top)); display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; padding: 0 16px; }
.toast { padding: 8px 15px; border-radius: 999px; background: var(--glass-strong); border: 1px solid var(--line); color: var(--cream); font-size: 13.5px; font-weight: 600; box-shadow: var(--shadow); animation: pop .25s var(--ease) both; max-width: 100%; text-align: center; }
.toast--gold { border-color: rgba(255, 209, 102, .6); color: var(--gold); }
.toast.out { animation: fadeout .3s ease both; }

/* ---------- wardrobe ---------- */
.wardrobe { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 6px; }
.wardrobe--three { grid-template-columns: repeat(3, 1fr); }
.wardrobe--three .wardrobe__label { font-size: 13px; padding: 20px 6px 7px; text-align: center; }
.wardrobe--three .wardrobe__label small { display: none; }
.wardrobe__item {
  position: relative; aspect-ratio: 3 / 4; overflow: hidden;
  border-radius: 18px; border: 2px solid var(--line); background: #0e1013; text-align: left;
  transition: border-color .15s, transform .15s;
}
.wardrobe__item:active { transform: scale(.98); }
.wardrobe__item[aria-pressed="true"] { border-color: var(--gold); box-shadow: 0 0 0 2px rgba(255, 213, 74, .25); }
.wardrobe__pics { position: absolute; inset: 0; display: flex; }
.wardrobe__pics img { flex: 1; min-width: 0; height: 100%; object-fit: cover; object-position: 46% 12%; }
.wardrobe__label {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 26px 11px 9px;
  background: linear-gradient(rgba(6, 7, 9, 0), rgba(6, 7, 9, .92));
  color: var(--cream); font-weight: 800; font-size: 14.5px;
}
.wardrobe__label small { display: block; margin-top: 1px; font-weight: 500; font-size: 11.5px; color: var(--mist); }

select.input { appearance: none; -webkit-appearance: none; padding-right: 34px; background-image: linear-gradient(45deg, transparent 50%, var(--mist) 50%), linear-gradient(135deg, var(--mist) 50%, transparent 50%); background-position: calc(100% - 19px) 55%, calc(100% - 13px) 55%; background-size: 6px 6px; background-repeat: no-repeat; }
select.input option { color: #15171c; background: #fff; }
.range { width: 100%; accent-color: var(--gold); }

/* the mood reader's answer for a sentence */
.moodbars { display: grid; gap: 6px; margin: 0 0 14px; min-height: 12px; }
.moodbar { display: grid; grid-template-columns: 84px 1fr 44px; align-items: center; gap: 10px; font-size: 14px; font-weight: 700; }
.moodbar i { height: 9px; border-radius: 5px; background: rgba(255, 255, 255, .1); overflow: hidden; }
.moodbar b { display: block; height: 100%; border-radius: 5px; background: linear-gradient(90deg, var(--gold), var(--accent)); }
.moodbar span:last-child { text-align: right; color: var(--mist); font-weight: 600; }
.moodbars small { color: var(--mist); font-size: 12.5px; }

/* ---------- her look: choosing files, scenes ---------- */
.dropzone {
  width: 100%; display: grid; justify-items: center; gap: 4px; padding: 22px 14px; margin-bottom: 12px;
  border-radius: 18px; border: 2px dashed var(--line); background: rgba(255, 255, 255, .03); color: var(--cream); font-size: 15px;
}
.dropzone:hover { border-color: var(--gold); }
.dropzone small { color: var(--mist); font-size: 12.5px; }
.scenes { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 7px; }
.scene {
  display: flex; align-items: center; gap: 11px; width: 100%; padding: 7px;
  border-radius: 14px; border: 1px solid var(--line); background: rgba(255, 255, 255, .03); color: var(--cream); text-align: left;
}
.scene:hover { border-color: var(--gold); }
.scene img, .scene__blank { flex: none; width: 48px; height: 64px; border-radius: 9px; object-fit: cover; object-position: 50% 15%; background: #0e1013; }
.scene__text { min-width: 0; font-size: 14px; font-weight: 700; }
.scene__text small { display: block; margin-top: 2px; color: var(--mist); font-weight: 500; font-size: 12.5px; }
.moodchips { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 14px; }
.chip[aria-pressed="true"] { background: var(--accent-deep); border-color: var(--accent); color: #fff; }
.facepick {
  position: relative; display: block; width: min(100%, 210px); margin: 0 auto 8px; padding: 0; overflow: hidden;
  border-radius: 16px; border: 1px solid var(--line); background: #0e1013; cursor: crosshair;
}
.facepick img { display: block; width: 100%; height: 100%; object-fit: cover; }
.facepick__dot { position: absolute; width: 30px; height: 30px; margin: -15px 0 0 -15px; border-radius: 50%; border: 3px solid var(--gold); box-shadow: 0 0 0 2px rgba(0, 0, 0, .55); pointer-events: none; }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tips { margin: 6px 0 12px; font-size: 14px; color: var(--mist); }
.tips summary { cursor: pointer; font-weight: 700; color: var(--cream); padding: 6px 0; }
.tips ul { margin: 0 0 10px; padding-left: 20px; }
.tips li { margin-bottom: 4px; }
.tips strong { color: var(--cream); }
/* ---------- larger screens ---------- */
@media (min-width: 541px) {
  .app { height: min(var(--app-h), 960px); border-radius: 30px; box-shadow: 0 30px 80px rgba(0, 0, 0, .55), 0 0 0 1px rgba(255, 255, 255, .08); }
}
@media (min-width: 1000px) and (min-height: 560px) {
  .app { max-width: min(1180px, calc(100vw - 48px)); height: min(var(--app-h) - 48px, 900px); background: linear-gradient(120deg, #171a21, #0b0d10 70%); }
  .stage { right: 52%; border-radius: 30px 0 0 30px; }
  .stage::after { inset: 70% 0 0; }
  .actor, .app[data-chat="expanded"] .actor { height: 100%; }
  .thought { left: auto; right: 5%; top: 78px; max-width: 40%; }
  .topbar { right: 52%; }
  .dock, .app[data-chat="expanded"] .dock { left: 48%; top: 0; height: auto; padding: 14px 16px 10px 8px; }
  .chat, .app[data-chat="expanded"] .chat { background: rgba(10, 12, 16, .55); border: 1px solid var(--line); border-radius: 24px; }
  .chat__handle { display: none; }
  .log { padding: 22px 18px 12px; -webkit-mask-image: none; mask-image: none; }
  .msg { max-width: 82%; }
  .composer { padding: 10px 0 4px; }
  .backdrop { align-items: center; }
  .sheet { max-width: 560px; max-height: 86%; border-radius: 26px; border-bottom: 1px solid var(--line); animation: pop .25s var(--ease) both; }
  .welcome { left: 48%; align-items: center; background: linear-gradient(90deg, rgba(11, 13, 17, .9), rgba(11, 13, 17, .97)); border-radius: 0 30px 30px 0; }
  .welcome__card { max-width: 520px; margin: 0 auto; }
  .toasts { left: 48%; top: 22px; }
}
/* narrow phones: a long name shortens with an ellipsis instead of pushing the buttons away */
@media (max-width: 400px) {
  .topbar, .topbar__right { gap: 6px; }
  .pill__xp { display: none; }
}
@media (max-height: 520px) {
  .app[data-chat="collapsed"] .dock { height: 74%; }
  .chips { display: none; }
}

/* ---------- motion ---------- */
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes rise { from { transform: translateY(100%); } to { transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeout { to { opacity: 0; transform: translateY(-6px); } }
@keyframes breathe { from { transform: scale(1); } to { transform: scale(1.014); } }
@keyframes talk { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-3px); } }
@keyframes kick-pop { 0% { transform: scale(1); } 40% { transform: scale(1.03) translateY(-6px); } 100% { transform: none; } }
@keyframes kick-sink { 0% { transform: none; } 45% { transform: translateY(7px) scale(.992); } 100% { transform: none; } }
@keyframes kick-nod { 0% { transform: none; } 40% { transform: translateY(4px); } 100% { transform: none; } }
@keyframes emote-in { from { opacity: 0; transform: scale(.4) translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes twinkle { 0%, 100% { transform: scale(1) rotate(0); opacity: 1; } 50% { transform: scale(.72) rotate(18deg); opacity: .75; } }
@keyframes drift { from { transform: translateY(2px) rotate(-8deg); } to { transform: translateY(-6px) rotate(8deg); } }
@keyframes drip { 0% { transform: translateY(-4px); opacity: 0; } 30% { opacity: 1; } 100% { transform: translateY(10px); opacity: 0; } }
@keyframes zzz { 0% { transform: translate(0, 0); opacity: 0; } 25% { opacity: 1; } 100% { transform: translate(16px, -30px); opacity: 0; } }
@keyframes blink { 0%, 80%, 100% { opacity: .3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
