/* Shiori, the character (spec §16.3). Ported from the UI mockups, draft 6. */
.av { display: inline-block; position: relative; }
.avsvg { width: 100%; height: 100%; overflow: visible; display: block; }
.avsvg .eye, .avsvg .nose { fill: var(--eye); }
.avsvg .closed { stroke: var(--eye); }
.avsvg .twig { stroke: var(--twig); }
.avsvg .fox, .avsvg .face, .avsvg .eyes, .avsvg .ear-l, .avsvg .ear-r, .avsvg .marker, .avsvg .tails {
  transform-box: view-box; transition: transform .6s cubic-bezier(.3, .7, .2, 1), opacity .5s ease, filter .5s ease; }
.avsvg .fox { transform-origin: 32px 56px; }
.avsvg .ear-l { transform-origin: 21px 20px; }
.avsvg .ear-r { transform-origin: 43px 20px; }
.avsvg .fox .tails { transform-origin: 9px 9px; }
.avsvg .marker .tails { transform-origin: 33px 27px; }
.avsvg .eyes { transition-duration: .3s; }
.avsvg .lid { transform-box: fill-box; transform-origin: center; transition: transform .1s ease; }
.avsvg .closed { opacity: 0; transition: opacity .25s; }
.avsvg .marker { opacity: 0; transform: translateY(12px); }
.av.blink .lid { transform: scaleY(.1); }

/* asleep: eyes closed, head lowered, ears relaxed, slow breathing (the only loop) */
.av[data-state="sleeping"] .lid { transform: scaleY(0); }
.av[data-state="sleeping"] .closed { opacity: 1; }
.av[data-state="sleeping"] .fox { transform: translateY(3px); animation: breathe 5s ease-in-out infinite; }
.av[data-state="sleeping"] .ear-l { transform: rotate(-14deg); }
.av[data-state="sleeping"] .ear-r { transform: rotate(14deg); }
/* ready for you: facing you, ears up */
.av[data-state="listening"] .ear-l { transform: rotate(5deg) scale(1.05); }
.av[data-state="listening"] .ear-r { transform: rotate(-5deg) scale(1.05); }
.av[data-state="hearing"] .ear-l { transform: rotate(9deg) scale(1.1); }
.av[data-state="hearing"] .ear-r { transform: rotate(-9deg) scale(1.1); }
.av[data-state="waiting"] .fox { transform: rotate(-7deg); }
.av[data-state="waiting"] .ear-l { transform: rotate(6deg) scale(1.06); }
.av[data-state="waiting"] .ear-r { transform: rotate(-3deg) scale(1.03); }
/* working out a reply: looks up and away */
.av[data-state="thinking"] .face { transform: translate(-3.5px, -1px); }
.av[data-state="thinking"] .eyes { transform: translate(-1.5px, -2.4px); }
.av[data-state="thinking"] .ear-l { transform: rotate(-7deg); }
.av[data-state="thinking"] .ear-r { transform: rotate(-3deg); }
/* talking: the tape on her hairpin moves with her voice */
.av[data-state="speaking"] .fox .tails { transform: rotate(calc(var(--amp, 0) * -18deg)); transition-duration: .12s; }
/* working in the background: she steps out and leaves her marker */
.av[data-state="away"] .fox { transform: translateY(64px); opacity: 0; }
.av[data-state="away"] .marker { opacity: 1; transform: none; }
.av[data-state="away"] .marker .tails { animation: drift 3.4s ease-in-out infinite; }
/* offline: still here, muted */
.av[data-state="offline"] .fox { filter: grayscale(1); opacity: .6; }
.av[data-state="offline"] .ear-l { transform: rotate(-12deg); }
.av[data-state="offline"] .ear-r { transform: rotate(12deg); }

@keyframes breathe { 0%, 100% { transform: translateY(3px) scale(1); } 50% { transform: translateY(3px) scale(1.02); } }
@keyframes drift { 0%, 100% { transform: rotate(0); } 50% { transform: rotate(-9deg); } }

/* her seat: the glow follows sound, her voice (accent) or yours (grey) */
.seat { border-radius: 50%; display: inline-grid; place-items: center; background: var(--ai-wash); overflow: hidden; flex: none;
  box-shadow: 0 0 0 calc(var(--amp, 0) * 8px) color-mix(in srgb, var(--ai) 38%, transparent); transition: box-shadow .12s linear; }
.seat[data-glow="you"] { box-shadow: 0 0 0 calc(var(--amp, 0) * 8px) color-mix(in srgb, var(--ink-2) 32%, transparent); }
.seat.sm { width: 40px; height: 40px; }
.seat.sm .av { width: 36px; height: 36px; }
.seat.md { width: 86px; height: 86px; }
.seat.md .av { width: 72px; height: 72px; }
.seat.dock { width: 64px; height: 64px; }
.seat.dock .av { width: 52px; height: 52px; }
.seat.big { width: 176px; height: 176px; }
.seat.big .av { width: 150px; height: 150px; }

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

/* The dock (spec §16.2): camera · Shiori · type, at the bottom of every screen. */
body { padding-bottom: 170px; }
.dock { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: var(--paper); border-top: 1px solid var(--line);
  padding: 8px 16px calc(10px + env(safe-area-inset-bottom)); }
.dock-row { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; max-width: 560px; margin: 0 auto; }
.ib { justify-self: center; width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; color: var(--ink-2);
  border: 1px solid var(--line); background: var(--sheet); cursor: pointer; font-size: 20px; }
.talk { display: flex; flex-direction: column; align-items: center; gap: 2px; font: inherit; font-size: 12px; color: var(--ink-2); background: none; border: 0; cursor: pointer; min-width: 120px; }
.talk-label { white-space: nowrap; max-width: 60vw; overflow: hidden; text-overflow: ellipsis; }
.ib:focus-visible, .talk:focus-visible { outline: 2px solid var(--ai); outline-offset: 2px; }
.type-sheet { max-width: 560px; margin: 0 auto 8px; display: flex; flex-direction: column; gap: 6px; }
.type-sheet textarea { width: 100%; font: inherit; border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; background: var(--sheet); color: var(--ink); }

/* Voice (spec §16.2): the chip row on the dock; while voice is on, the dock grows, and never moves. */
.voice-row { display: flex; justify-content: center; align-items: center; gap: 8px; max-width: 560px; margin: 0 auto 6px; flex-wrap: wrap; }
.voice-chip-wrap { position: relative; }
.voice-chip, .voice-row .chip { min-height: 32px; border: 1px solid var(--line); cursor: pointer; font: inherit; font-size: 13px; }
.voice-menu { position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%); display: flex; gap: 6px; padding: 6px;
  background: var(--sheet); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 4px 16px rgb(0 0 0 / .12); }
.voice-menu .btn { min-height: 44px; min-width: 64px; }
.voice-menu .btn[aria-pressed='true'] { background: var(--ai-wash); color: var(--ai); border-color: var(--ai); }
.live-chip.on { border-color: var(--ai); color: var(--ai); }
.live-menu { flex-direction: column; align-items: stretch; min-width: 260px; max-height: 60vh; overflow-y: auto; }
.live-menu .sub { margin: 4px 6px 0; }
.caption { max-width: 560px; margin: 0 auto 6px; padding: 8px 12px; border-radius: 12px; background: var(--sheet); border: 1px solid var(--line); white-space: pre-line; overflow-wrap: anywhere; }
.dock.voice .seat.dock { width: 92px; height: 92px; }
.dock.voice .seat.dock .av { width: 76px; height: 76px; }
.dock.voice .ib { width: 56px; height: 56px; }
.dock.voice .talk { font-size: 13px; font-weight: 700; color: var(--ink); }
.convo .shiori.said .btn { align-self: flex-start; }

/* The conversation: speech bubbles carry a SHIORI label instead of a second avatar. */
.convo { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.convo .you { align-self: flex-end; max-width: 85%; background: var(--ai-wash); border-radius: 16px 16px 4px 16px; padding: 8px 12px; }
.convo .shiori { align-self: flex-start; max-width: 92%; background: var(--sheet); border: 1px solid var(--line); border-radius: 16px 16px 16px 4px; padding: 8px 12px; display: flex; flex-direction: column; gap: 6px; }
.convo .you .photo { display: block; padding: 0; border: 0; background: none; margin-top: 6px; }
.convo .you img { max-width: 100%; border-radius: 10px; display: block; }
.convo .you p, .convo .shiori p { margin: 0; white-space: pre-line; overflow-wrap: anywhere; }
.who { font-size: 11px; font-weight: 700; letter-spacing: .06em; color: var(--ai); }
.system-line { align-self: center; font-size: 12px; color: var(--ink-2); }
.convo .system { align-self: stretch; border: 1px solid var(--amber); background: var(--amber-wash); border-radius: 12px; padding: 8px 12px; }
.card { display: flex; flex-direction: column; gap: 6px; }
.card-title { font-family: var(--f-display); }
.card-image { max-width: 100%; border-radius: 10px; }
.card-place { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.md p { margin: 0 0 6px; white-space: pre-line; overflow-wrap: anywhere; }
.md .md-h { font-weight: 700; }
.md ul, .md ol { margin: 0 0 6px; padding-left: 20px; }

/* System cards sit above the dock, so their buttons can be reached. */
body:has(.dock) .notices { bottom: calc(140px + env(safe-area-inset-bottom)); z-index: 25; }
