:root {
  --paper: #fffaf1;
  --paper-deep: #f0e9dd;
  --ink: #211b15;
  --ink-soft: #5b554b;
  --ink-faint: #7b7468;
  --rule: rgba(28, 25, 20, 0.82);
  --hairline: rgba(28, 25, 20, 0.17);
  --orange: #ef5b2a;
  --orange-soft: #f5d8c9;
  --yellow: #f6c945;
  --yellow-deep: #dfa522;
  --character-line: #79501c;
  --face-line: #413425;
  --safe: #287554;
  --safe-soft: #d8eadf;
  --white: #fffdf8;
  --sans: Pretendard, "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  --serif: "Noto Serif KR", "Nanum Myeongjo", serif;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--paper-deep);
}

body {
  min-width: 320px;
  height: 100dvh;
  margin: 0;
  overflow: hidden;
  background: var(--paper-deep);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  word-break: keep-all;
}

button,
textarea {
  color: inherit;
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
textarea:focus-visible {
  outline: 3px solid var(--orange);
  outline-offset: 3px;
}

.app-shell {
  display: flex;
  width: min(100%, 480px);
  height: 100dvh;
  min-height: 0;
  flex-direction: column;
  margin: 0 auto;
  overflow: hidden;
  background: var(--paper);
  border-inline: 1px solid var(--hairline);
}

.topbar {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: space-between;
  min-height: 78px;
  padding: max(16px, env(safe-area-inset-top)) 20px 11px;
  border-bottom: 1px solid var(--hairline);
}

.topbar::after {
  display: none;
}

.micro-label,
.control-label,
.ai-label,
.stage-meta,
.latest-message > span {
  color: var(--ink-faint);
  font-family: var(--mono);
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.brand-copy {
  min-width: 0;
}

.brand-line {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-top: 2px;
}

h1 {
  margin: 0;
  font-family: var(--serif);
  font-family: var(--sans);
  font-size: 1.6rem;
  font-weight: 950;
  letter-spacing: -0.065em;
  line-height: 1;
}

.brand-kicker {
  display: block;
  margin-bottom: 4px;
  color: var(--orange);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.icon-button {
  display: grid;
  width: 44px;
  height: 44px;
  padding: 9px;
  place-items: center;
  background: transparent;
  border: 1px solid var(--hairline);
  border-radius: 14px;
  cursor: pointer;
}

.icon-button svg {
  width: 23px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.icon-button:hover {
  background: var(--ink);
  color: var(--paper);
}

.privacy-banner {
  margin: 10px 16px 0;
  padding: 8px 0 10px;
  border-bottom: 1px solid var(--hairline);
}

.privacy-heading {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 38px;
}

.safe-mark {
  width: 9px;
  height: 9px;
  background: var(--safe);
  animation: safe-pulse 2.4s ease-out infinite;
}

.privacy-toggle {
  display: flex;
  min-width: 0;
  min-height: 38px;
  flex: 1;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0;
  background: transparent;
  border: 0;
  cursor: pointer;
  text-align: left;
}

.privacy-toggle strong {
  display: block;
  font-size: 0.82rem;
  line-height: 1.35;
}

.privacy-toggle svg {
  width: 19px;
  flex: 0 0 19px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
  transition: transform 180ms ease;
}

.privacy-banner-body {
  display: grid;
  max-height: 56px;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  margin-left: 19px;
  overflow: hidden;
  opacity: 1;
  transition: max-height 180ms ease, opacity 140ms ease;
}

.privacy-banner-body p {
  margin: 1px 0 0;
  color: var(--ink-soft);
  font-size: 0.71rem;
  line-height: 1.4;
}

.privacy-banner.collapsed {
  padding-bottom: 5px;
}

.privacy-banner.collapsed .privacy-toggle svg {
  transform: rotate(180deg);
}

.privacy-banner.collapsed .privacy-banner-body {
  max-height: 0;
  opacity: 0;
}

.text-button {
  min-width: 48px;
  min-height: 44px;
  padding: 0;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--ink-soft);
  color: var(--ink-soft);
  font-size: 0.72rem;
  cursor: pointer;
}

main {
  display: flex;
  min-height: 0;
  flex: 1;
  flex-direction: column;
}

.character-stage {
  position: relative;
  display: flex;
  min-height: 0;
  flex: 1;
  flex-direction: column;
  justify-content: center;
  padding: 8px 20px 0;
  overflow: hidden;
  isolation: isolate;
}

.character-stage::before {
  position: absolute;
  z-index: -1;
  top: 38%;
  left: 50%;
  width: 330px;
  height: 330px;
  background:
    radial-gradient(circle at 50% 50%, rgba(255, 216, 92, 0.34) 0 38%, rgba(239, 91, 42, 0.11) 38.5% 58%, transparent 58.5%),
    radial-gradient(circle at 35% 30%, rgba(255, 255, 255, 0.9), transparent 52%);
  border-radius: 50%;
  content: "";
  transform: translate(-50%, -50%);
}

.speech-bubble {
  position: relative;
  z-index: 3;
  width: min(100%, 350px);
  min-height: 82px;
  margin: 8px auto 0;
  padding: 13px 16px 14px;
  background: rgba(255, 253, 248, 0.96);
  border: 1px solid rgba(89, 63, 34, 0.19);
  border-radius: 18px;
  box-shadow: 0 12px 30px rgba(111, 69, 15, 0.1);
}

.speech-bubble::after {
  position: absolute;
  bottom: -13px;
  left: calc(50% - 12px);
  width: 22px;
  height: 22px;
  background: var(--white);
  border-right: 1px solid rgba(89, 63, 34, 0.19);
  border-bottom: 1px solid rgba(89, 63, 34, 0.19);
  content: "";
  transform: rotate(45deg);
}

.speech-bubble p {
  min-height: 2.75em;
  margin: 6px 0 0;
  font-size: 1rem;
  font-weight: 780;
  letter-spacing: -0.025em;
  line-height: 1.4;
  text-align: center;
}

.speech-bubble.thinking p {
  color: var(--ink-faint);
  font-family: var(--mono);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
}

.speech-bubble.safety {
  background: var(--safe-soft);
  border-color: var(--safe);
}

.speech-bubble.safety::after {
  background: var(--safe-soft);
  border-color: var(--safe);
}

.character-button {
  position: relative;
  display: block;
  width: 252px;
  height: 248px;
  margin: -4px auto 0;
  padding: 0;
  background: transparent;
  border: 0;
  cursor: grab;
  perspective: 700px;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.character-button::after {
  position: absolute;
  z-index: -1;
  top: 48%;
  left: 50%;
  width: 205px;
  height: 205px;
  border: 2px solid rgba(239, 91, 42, 0.5);
  border-radius: 50%;
  content: "";
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -50%) scale(0.45);
}

.character-button.grabbing {
  cursor: grabbing;
}

.floor-shadow {
  position: absolute;
  right: 35px;
  bottom: 10px;
  left: 35px;
  height: 27px;
  background: radial-gradient(ellipse, rgba(70, 42, 8, 0.34) 0%, rgba(70, 42, 8, 0.14) 48%, transparent 74%);
  filter: blur(3px);
  transform: scaleX(1);
  transform-origin: center;
  transition: filter 160ms ease, opacity 160ms ease, transform 160ms ease;
}

.character-button.depth-active .floor-shadow {
  filter: blur(5px);
  transform: scaleX(0.86);
}

.character-button.grabbing .floor-shadow {
  opacity: 0.45;
  transform: scaleX(0.64);
}

.creature-wrap {
  --blob: var(--yellow);
  --blob-deep: var(--yellow-deep);
  --drag-x: 0px;
  --drag-y: 0px;
  --release-x: 0px;
  --release-y: 0px;
  --tilt-x: 0deg;
  --tilt-y: 0deg;
  display: block;
  width: 100%;
  height: 100%;
  transform-origin: 50% 90%;
  animation: idle 3.2s ease-in-out infinite;
}

.creature-depth {
  display: block;
  width: 100%;
  height: 100%;
  transform: rotateX(var(--tilt-x)) rotateY(var(--tilt-y)) translateZ(0);
  transform-origin: 50% 58%;
  transform-style: preserve-3d;
  transition: transform 160ms cubic-bezier(0.2, 0.75, 0.3, 1), filter 160ms ease;
  will-change: transform;
}

.creature {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.character-button.depth-active .creature-depth {
  filter: drop-shadow(0 7px 4px rgba(82, 48, 4, 0.15));
  transition-duration: 70ms;
}

.character-button.depth-pressed .creature-depth {
  filter: drop-shadow(0 4px 3px rgba(82, 48, 4, 0.12));
  transform: rotateX(var(--tilt-x)) rotateY(var(--tilt-y)) translateZ(10px) scale(0.985);
}

.body,
.foot,
.arm,
.sprout-stem,
.sprout-leaf {
  stroke: var(--character-line);
  stroke-linecap: round;
  stroke-linejoin: round;
}

.body {
  fill: url(#blobSurface);
  filter: url(#blobDepth);
  stroke: rgba(109, 66, 17, 0.72);
  stroke-width: 1.35;
}

.foot {
  fill: url(#limbSurface);
  filter: url(#limbDepth);
  stroke: rgba(109, 66, 17, 0.68);
  stroke-width: 1.5;
}

.arm {
  fill: none;
  filter: url(#limbDepth);
  stroke: url(#limbSurface);
  stroke-width: 13;
}

.sprout-stem {
  fill: none;
  stroke: #5d7f35;
  stroke-width: 3.2;
}

.sprout-leaf {
  fill: #89aa4b;
  stroke: #58712f;
  stroke-width: 1.3;
}

.brow,
.lid,
.mouth,
.mouth-open,
.tooth {
  fill: none;
  stroke: var(--face-line);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 3;
}

.mouth,
.mouth-open {
  stroke-width: 3.3;
}

.tooth {
  stroke-width: 1.4;
}

.surface-shade {
  fill: url(#sideShade);
}

.surface-bounce {
  fill: rgba(255, 255, 255, 0.3);
  filter: url(#softGlow);
}

.surface-gloss {
  fill: rgba(255, 255, 255, 0.26);
}

.surface-rim {
  fill: rgba(111, 57, 0, 0.16);
  filter: url(#softGlow);
}

.potato-dimple {
  fill: rgba(135, 74, 8, 0.22);
  stroke: rgba(255, 235, 153, 0.24);
  stroke-width: 1;
}

.creature-wrap.is-grabbed {
  animation: none;
  filter: drop-shadow(0 12px 4px rgba(28, 25, 20, 0.16));
  transform: translate(var(--drag-x), var(--drag-y)) scaleX(1.08) scaleY(0.9);
}

.eye {
  fill: url(#eyeSurface);
  filter: url(#eyeDepth);
  stroke: #766248;
  stroke-width: 1.4;
  transform-box: fill-box;
  transform-origin: center;
  animation: blink 4.8s infinite;
}

.pupil {
  fill: url(#pupilSurface);
  transform-box: fill-box;
  transform-origin: center;
}

.eye-glint {
  fill: rgba(255, 255, 255, 0.94);
  pointer-events: none;
  transform-box: fill-box;
  transform-origin: center;
}

.cheek {
  fill: rgba(225, 112, 26, 0.14);
  filter: url(#softGlow);
}

.nose {
  fill: none;
  stroke: rgba(82, 45, 4, 0.55);
  stroke-linecap: round;
  stroke-width: 2.2;
}

.mouth-open {
  display: none;
  fill: var(--ink);
}

.tooth {
  display: none;
  fill: var(--white);
}

.gesture-hit {
  animation: fall-and-rise 0.82s linear both;
}

.gesture-swipe-left {
  animation: swipe-left 0.68s linear both;
}

.gesture-swipe-right {
  animation: swipe-right 0.68s linear both;
}

.gesture-swipe-up {
  animation: swipe-up 0.72s linear both;
}

.gesture-swipe-down {
  animation: swipe-down 0.72s linear both;
}

.character-button.motion-gesture-hit::after,
.character-button.motion-gesture-drop::after {
  animation: impact-ring 0.56s cubic-bezier(0.12, 0.72, 0.18, 1) both;
}

.character-button.motion-gesture-hit .floor-shadow {
  animation: hit-shadow 0.82s linear both;
}

.character-button.motion-gesture-drop .floor-shadow {
  animation: drop-shadow-impact 0.74s linear both;
}

.gesture-hit .face {
  animation: hit-face 0.82s linear both;
  transform-box: view-box;
  transform-origin: 50% 54%;
}

.gesture-hit .eye {
  animation: hit-eyes 0.82s linear both;
}

.gesture-hit .mouth {
  animation: hit-mouth 0.82s linear both;
}

.gesture-swipe-left .eye,
.gesture-swipe-right .eye,
.gesture-swipe-up .eye,
.gesture-swipe-down .eye {
  animation: none;
}

.gesture-swipe-left .pupil,
.gesture-swipe-left .eye-glint {
  transform: translateX(-6px);
}

.gesture-swipe-right .pupil,
.gesture-swipe-right .eye-glint {
  transform: translateX(6px);
}

.gesture-swipe-left .mouth,
.gesture-swipe-right .mouth {
  transform: scaleY(-1);
  transform-box: fill-box;
  transform-origin: center;
}

.gesture-swipe-left .brow-left,
.gesture-swipe-right .brow-right {
  transform: rotate(-14deg) translateY(-2px);
  transform-box: fill-box;
  transform-origin: center;
}

.gesture-swipe-left .brow-right,
.gesture-swipe-right .brow-left {
  transform: rotate(14deg) translateY(2px);
  transform-box: fill-box;
  transform-origin: center;
}

.gesture-swipe-left .lid-left,
.gesture-swipe-right .lid-right {
  transform: translateY(4px) rotate(8deg);
  transform-box: fill-box;
  transform-origin: center;
}

.gesture-swipe-left .lid-right,
.gesture-swipe-right .lid-left {
  transform: translateY(-2px) rotate(-6deg);
  transform-box: fill-box;
  transform-origin: center;
}

.gesture-swipe-up .eye {
  transform: scale(1.22);
  transform-box: fill-box;
  transform-origin: center;
}

.gesture-swipe-up .pupil,
.gesture-swipe-up .eye-glint {
  transform: translateY(-5px);
}

.gesture-swipe-up .mouth {
  display: none;
}

.gesture-swipe-up .mouth-open,
.gesture-swipe-up .tooth {
  display: block;
}

.gesture-swipe-down .eye {
  transform: scaleY(0.22);
  transform-box: fill-box;
  transform-origin: center;
}

.gesture-swipe-down .pupil,
.gesture-swipe-down .eye-glint {
  opacity: 0;
}

.gesture-swipe-down .mouth {
  transform: scaleX(0.42);
  transform-box: fill-box;
  transform-origin: center;
}

.gesture-drop {
  animation: grab-drop 0.74s linear both;
}

.reply-scoff {
  animation: opponent-scoff 0.78s ease-out both;
}

.reply-calm {
  animation: calm 0.85s ease-out both;
}

.latest-message {
  position: relative;
  z-index: 6;
  margin: -18px 0 8px;
  padding: 8px 10px;
  background: rgba(255, 253, 248, 0.88);
  border: 1px solid rgba(239, 91, 42, 0.22);
  border-radius: 12px;
  box-shadow: 0 8px 22px rgba(90, 55, 12, 0.07);
}

.latest-message p {
  max-width: 100%;
  margin: 3px 0 0;
  overflow: hidden;
  font-size: 0.76rem;
  font-weight: 600;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.controls {
  flex: 0 0 auto;
  margin: 0 12px 8px;
  padding: 0;
  background: transparent;
  border: 0;
}

.quick-prompts {
  display: flex;
  gap: 7px;
  margin-top: 12px;
  overflow-x: auto;
  scrollbar-width: none;
}

.quick-prompts::-webkit-scrollbar {
  display: none;
}

.quick-prompts button {
  min-height: 37px;
  flex: 0 0 auto;
  padding: 0 10px;
  background: transparent;
  border: 1px solid var(--hairline);
  color: var(--ink-soft);
  font-size: 0.72rem;
  cursor: pointer;
}

.quick-prompts button:hover {
  border-color: var(--orange);
  color: var(--orange);
}

.composer {
  margin-top: 0;
  padding: 13px 14px 14px;
  background: var(--white);
  border: 1px solid rgba(89, 63, 34, 0.16);
  border-radius: 20px;
  box-shadow: 0 12px 30px rgba(97, 58, 9, 0.09);
}

.composer label {
  display: block;
  color: var(--ink-faint);
  font-family: var(--mono);
  font-size: 0.63rem;
  font-weight: 600;
  letter-spacing: 0.12em;
}

.composer textarea {
  display: block;
  width: 100%;
  min-height: 42px;
  max-height: 94px;
  margin-top: 4px;
  padding: 6px 0;
  resize: none;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--hairline);
  outline: 0;
  font-size: 0.97rem;
  font-weight: 600;
  line-height: 1.45;
}

.composer textarea::placeholder {
  color: #999185;
}

.voice-button {
  display: grid;
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  padding: 0;
  place-items: center;
  background: transparent;
  border: 1px solid rgba(40, 117, 84, 0.25);
  border-radius: 12px;
  color: var(--safe);
  font-size: 0.72rem;
  font-weight: 800;
  cursor: pointer;
}

.voice-button svg {
  width: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.voice-button.available:hover,
.voice-button.listening {
  background: var(--safe);
  color: var(--white);
}

.voice-button.listening svg {
  animation: mic-pulse 0.8s ease-in-out infinite alternate;
}

.voice-button.unavailable {
  display: none;
  border-color: var(--hairline);
  color: var(--ink-faint);
}

.composer-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}

.character-count {
  min-width: 39px;
  color: var(--safe);
  font-family: var(--mono);
  font-size: 0.64rem;
  white-space: nowrap;
}

.composer-footer b {
  font-weight: 600;
}

.send-button,
.dialog-primary {
  display: inline-flex;
  min-height: 46px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 14px;
  background: var(--orange);
  border: 1px solid var(--orange);
  border-radius: 14px;
  color: var(--paper);
  font-size: 0.78rem;
  font-weight: 800;
  cursor: pointer;
}

.send-button {
  margin-left: auto;
}

.send-button svg {
  width: 17px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.send-button:hover,
.dialog-primary:hover {
  background: #d9471d;
  border-color: #d9471d;
}

.send-button:disabled {
  background: var(--paper-deep);
  border-color: var(--paper-deep);
  color: var(--ink-faint);
  cursor: not-allowed;
}

footer {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 14px;
  flex: 0 0 auto;
  padding: 0 16px env(safe-area-inset-bottom);
  background: var(--paper);
  color: var(--ink-faint);
  font-size: 0.63rem;
}

footer button {
  min-height: 44px;
  padding: 0;
  background: transparent;
  border: 0;
  border-bottom: 0;
  color: var(--ink-soft);
  font-size: 0.68rem;
  cursor: pointer;
}

dialog {
  width: min(calc(100% - 32px), 432px);
  max-height: calc(100dvh - 32px);
  margin: auto;
  padding: 21px;
  overflow: auto;
  background: var(--paper);
  border: 3px solid var(--ink);
  color: var(--ink);
}

dialog::backdrop {
  background: rgba(28, 25, 20, 0.62);
}

.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--rule);
}

dialog h2 {
  margin: 24px 0 22px;
  font-family: var(--serif);
  font-size: 1.82rem;
  font-weight: 900;
  letter-spacing: -0.045em;
  line-height: 1.28;
}

.privacy-list {
  border-top: 3px solid var(--rule);
}

.privacy-list > div {
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 8px;
  padding: 14px 0;
  border-bottom: 1px solid var(--hairline);
}

.privacy-list > div > span {
  color: var(--orange);
  font-family: var(--mono);
  font-size: 0.74rem;
  font-weight: 700;
}

.privacy-list p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.79rem;
  line-height: 1.55;
}

.privacy-list strong {
  display: block;
  margin-bottom: 3px;
  color: var(--ink);
  font-size: 0.84rem;
}

.dialog-primary {
  width: 100%;
}

.exit-dialog > p:not(.micro-label) {
  margin: -8px 0 24px;
  color: var(--ink-soft);
  font-size: 0.86rem;
  line-height: 1.55;
}

.exit-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.exit-actions .dialog-primary,
.dialog-secondary {
  min-height: 48px;
  border: 1px solid var(--ink);
  font-size: 0.82rem;
  font-weight: 800;
  cursor: pointer;
}

.dialog-secondary {
  background: var(--paper);
  color: var(--ink);
}

.dialog-secondary:hover {
  background: var(--paper-deep);
}

.toast {
  position: fixed;
  bottom: calc(22px + env(safe-area-inset-bottom));
  left: 50%;
  z-index: 30;
  width: min(calc(100% - 40px), 400px);
  padding: 13px 16px;
  background: var(--ink);
  border: 1px solid var(--paper);
  color: var(--paper);
  font-size: 0.78rem;
  font-weight: 700;
  text-align: center;
  transform: translateX(-50%);
}

@keyframes idle {
  0%, 100% { transform: translateY(0) rotate(-1deg); }
  42% { transform: translateY(-5px) rotate(0.5deg); }
  58% { transform: translateY(-5px) rotate(1.4deg); }
}

@keyframes blink {
  0%, 44%, 48%, 100% { transform: scaleY(1); }
  46% { transform: scaleY(0.08); }
}

@keyframes safe-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

@keyframes mic-pulse {
  from { transform: scale(0.9); }
  to { transform: scale(1.12); }
}

@keyframes fall-and-rise {
  0% { transform: perspective(430px) rotateX(0) translateY(0) scale(1); }
  7% { transform: perspective(430px) rotateX(-15deg) translateY(-11px) scale(1.06, 0.94); }
  22% { transform: perspective(430px) rotateX(34deg) translateY(15px) scale(0.94, 1.04); }
  36% { transform: perspective(430px) rotateX(88deg) translateY(61px) scale(1.18, 0.68); }
  48% { transform: perspective(430px) rotateX(86deg) translateY(63px) scale(1.22, 0.64); }
  63% { transform: perspective(430px) rotateX(-18deg) translateY(-22px) scale(0.88, 1.16); }
  78% { transform: perspective(430px) rotateX(10deg) translateY(7px) scale(1.08, 0.92); }
  90% { transform: perspective(430px) rotateX(-4deg) translateY(-3px) scale(0.98, 1.03); }
  100% { transform: perspective(430px) rotateX(0) translateY(0) scale(1); }
}

@keyframes swipe-left {
  0% { transform: translateX(0) skewY(0) scale(1); }
  11% { transform: translateX(8px) skewY(-3deg) scale(1.04, 0.96); }
  32% { transform: translateX(-104px) rotate(-13deg) skewY(14deg) scale(0.75, 1.12); }
  48% { transform: translateX(-83px) rotate(-8deg) skewY(8deg) scale(0.82, 1.06); }
  66% { transform: translateX(26px) rotate(5deg) skewY(-6deg) scale(1.12, 0.9); }
  84% { transform: translateX(-9px) rotate(-2deg) skewY(2deg); }
  100% { transform: translateX(0) skewY(0) scale(1); }
}

@keyframes swipe-right {
  0% { transform: translateX(0) skewY(0) scale(1); }
  11% { transform: translateX(-8px) skewY(3deg) scale(1.04, 0.96); }
  32% { transform: translateX(104px) rotate(13deg) skewY(-14deg) scale(0.75, 1.12); }
  48% { transform: translateX(83px) rotate(8deg) skewY(-8deg) scale(0.82, 1.06); }
  66% { transform: translateX(-26px) rotate(-5deg) skewY(6deg) scale(1.12, 0.9); }
  84% { transform: translateX(9px) rotate(2deg) skewY(-2deg); }
  100% { transform: translateX(0) skewY(0) scale(1); }
}

@keyframes swipe-up {
  0% { transform: translateY(0) scale(1); }
  10% { transform: translateY(8px) scale(1.08, 0.92); }
  33% { transform: translateY(-91px) scale(0.8, 1.18); }
  48% { transform: translateY(-73px) scale(0.88, 1.1); }
  66% { transform: translateY(24px) scale(1.18, 0.8); }
  83% { transform: translateY(-9px) scale(0.95, 1.06); }
  100% { transform: translateY(0) scale(1); }
}

@keyframes swipe-down {
  0% { transform: translateY(0) scale(1); }
  12% { transform: translateY(-8px) scale(0.94, 1.06); }
  34% { transform: translateY(62px) scale(1.34, 0.56); }
  49% { transform: translateY(55px) scale(1.27, 0.64); }
  67% { transform: translateY(-31px) scale(0.82, 1.22); }
  84% { transform: translateY(10px) scale(1.08, 0.92); }
  100% { transform: translateY(0) scale(1); }
}

@keyframes grab-drop {
  0% { transform: translate(var(--release-x), var(--release-y)) scale(1.08, 0.9); }
  20% { transform: translate(0, 66px) scale(1.38, 0.5); }
  34% { transform: translate(0, 61px) scale(1.3, 0.58); }
  52% { transform: translate(0, -35px) scale(0.78, 1.27); }
  70% { transform: translate(0, 13px) scale(1.13, 0.86); }
  86% { transform: translate(0, -6px) scale(0.96, 1.05); }
  100% { transform: translate(0) scale(1); }
}

@keyframes impact-ring {
  0%, 18% { opacity: 0; transform: translate(-50%, -50%) scale(0.38); }
  28% { opacity: 0.85; }
  70%, 100% { opacity: 0; transform: translate(-50%, -50%) scale(1.42); }
}

@keyframes hit-shadow {
  0%, 8%, 100% { opacity: 1; transform: scaleX(1); filter: blur(3px); }
  20% { opacity: 0.45; transform: scaleX(0.7); filter: blur(6px); }
  38%, 49% { opacity: 0.8; transform: scaleX(1.38); filter: blur(2px); }
  64% { opacity: 0.38; transform: scaleX(0.62); filter: blur(7px); }
  80% { opacity: 0.9; transform: scaleX(1.12); filter: blur(3px); }
}

@keyframes drop-shadow-impact {
  0% { opacity: 0.4; transform: scaleX(0.55); filter: blur(6px); }
  20%, 34% { opacity: 0.9; transform: scaleX(1.5); filter: blur(2px); }
  52% { opacity: 0.35; transform: scaleX(0.55); filter: blur(7px); }
  100% { opacity: 1; transform: scaleX(1); filter: blur(3px); }
}

@keyframes hit-face {
  0%, 100% { transform: translate(0); }
  9% { transform: translateY(-4px); }
  25% { transform: translateY(7px); }
  45% { transform: translateY(11px); }
  64% { transform: translateY(-5px); }
}

@keyframes hit-eyes {
  0%, 100% { transform: scaleY(1); }
  8% { transform: scaleY(0.18); }
  24% { transform: scale(1.2); }
  38%, 52% { transform: scaleY(0.12); }
  68% { transform: scale(1.16); }
}

@keyframes hit-mouth {
  0%, 100% { transform: scale(1); }
  12% { transform: scaleX(0.55) scaleY(-0.7); }
  38%, 52% { transform: scaleX(0.4) scaleY(-1.1); }
  68% { transform: scale(1.18); }
}

@keyframes opponent-scoff {
  0%, 100% { transform: translateX(0) rotate(0); }
  24% { transform: translateX(-8px) rotate(-5deg); }
  48% { transform: translateX(11px) rotate(5deg); }
  70% { transform: translateX(-5px) rotate(-2deg); }
  84% { transform: translateX(3px) rotate(1deg); }
}

@keyframes calm {
  0%, 100% { transform: scale(1); }
  30% { transform: scale(0.96) translateY(4px); }
  65% { transform: scale(1.03) translateY(-3px); }
}

@media (max-width: 370px) {
  .topbar {
    padding-inline: 14px;
  }

  .privacy-banner,
  .controls,
  footer {
    margin-inline: 0;
    padding-inline: 12px;
  }

  .character-stage {
    padding-inline: 14px;
  }

}

/* Apps in Toss already owns the device status bar and the app navigation bar.
   Use only the WebView's visible rectangle here so the conversation stays intact. */
.apps-in-toss,
.apps-in-toss body,
.apps-in-toss .app-shell {
  height: 100%;
  min-height: 100%;
}

.apps-in-toss .app-shell {
  position: relative;
  border: 0;
}

.apps-in-toss .topbar {
  position: absolute;
  z-index: 20;
  top: 10px;
  right: 12px;
  min-height: 0;
  padding: 0;
  border: 0;
  pointer-events: none;
}

.apps-in-toss .brand-copy {
  display: none;
}

.apps-in-toss .topbar .icon-button {
  width: 36px;
  height: 36px;
  padding: 7px;
  background: rgba(255, 250, 241, 0.88);
  border-color: rgba(89, 63, 34, 0.2);
  border-radius: 13px;
  box-shadow: 0 7px 20px rgba(97, 58, 9, 0.08);
  pointer-events: auto;
}

.apps-in-toss main {
  height: 100%;
  min-height: 0;
}

.apps-in-toss .character-stage {
  justify-content: center;
  padding: 0 12px;
  overflow: hidden;
}

.apps-in-toss .character-stage::before {
  top: 50%;
  width: min(84vw, 302px);
  height: min(84vw, 302px);
}

.apps-in-toss .speech-bubble {
  width: calc(100% - 46px);
  min-height: 74px;
  margin: 0 auto 0 0;
  padding: 11px 14px 12px;
  border-radius: 17px;
}

.apps-in-toss .speech-bubble::after {
  left: calc(60% - 12px);
}

.apps-in-toss .speech-bubble p {
  min-height: 2.6em;
  margin-top: 4px;
  font-size: 0.94rem;
  line-height: 1.32;
}

.apps-in-toss .character-button {
  width: 226px;
  height: 222px;
  margin-top: -2px;
}

.apps-in-toss .latest-message {
  margin: -12px 0 5px;
  padding: 7px 10px;
}

.apps-in-toss .controls {
  margin: 0 12px 6px;
}

.apps-in-toss .composer {
  padding: 11px 12px 12px;
  border-radius: 18px;
}

.apps-in-toss .composer textarea {
  min-height: 36px;
  max-height: 72px;
  padding: 4px 0;
  font-size: 0.92rem;
}

.apps-in-toss .composer-footer {
  margin-top: 6px;
}

.apps-in-toss .send-button {
  min-height: 42px;
}

.apps-in-toss footer {
  min-height: 40px;
  padding: 0 12px;
}

.apps-in-toss footer button {
  min-height: 40px;
}

.apps-in-toss dialog {
  width: min(calc(100% - 24px), 420px);
  max-height: calc(100% - 16px);
  padding: 16px;
  border-width: 2px;
}

.apps-in-toss .dialog-head {
  padding-bottom: 8px;
}

.apps-in-toss dialog h2 {
  margin: 14px 0;
  font-size: 1.5rem;
  line-height: 1.22;
}

.apps-in-toss .privacy-list {
  border-top-width: 2px;
}

.apps-in-toss .privacy-list > div {
  grid-template-columns: 27px 1fr;
  gap: 6px;
  padding: 8px 0;
}

.apps-in-toss .privacy-list p {
  font-size: 0.72rem;
  line-height: 1.38;
}

.apps-in-toss .privacy-list strong {
  margin-bottom: 1px;
  font-size: 0.76rem;
}

.apps-in-toss .privacy-list + .dialog-primary {
  min-height: 42px;
  margin-top: 10px;
}

@media (max-height: 620px) {
  .apps-in-toss .character-stage {
    padding-block: 0;
  }

  .apps-in-toss .speech-bubble {
    min-height: 68px;
    padding-block: 9px 10px;
  }

  .apps-in-toss .character-button {
    width: 204px;
    height: 200px;
  }

  .apps-in-toss .latest-message {
    margin-top: -10px;
  }

  .apps-in-toss .composer {
    padding-block: 9px 10px;
  }

  .apps-in-toss footer,
  .apps-in-toss footer button {
    min-height: 36px;
  }
}

@media (min-width: 700px) {
  html:not(.apps-in-toss) body {
    padding-block: 18px;
  }

  html:not(.apps-in-toss) .app-shell {
    min-height: calc(100dvh - 36px);
    border-block: 1px solid var(--rule);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
