/* Personal companions share the app's surfaces, focus rings, and theme tokens. */
.pet-open img {
  width: 36px;
  height: 36px;
}
.pet-widget {
  position: fixed;
  inset: 0 auto auto 0;
  width: 132px;
  height: 140px;
  z-index: 25;
  pointer-events: none;
  will-change: transform;
}
.pet-widget-body {
  display: flex;
  align-items: end;
  height: 112px;
}
.pet-body {
  position: relative;
  width: 104px;
  height: 112px;
  padding: 4px;
  border: 0;
  background: transparent;
  touch-action: none;
  pointer-events: auto;
  cursor: grab;
}
.pet-body:active {
  cursor: grabbing;
}
.pet-facing {
  width: 100px;
  height: 100px;
  position: relative;
  z-index: 1;
  display: block;
  transform: scaleX(1);
}
.pet-widget.is-walking[data-facing='left'] .pet-facing {
  transform: scaleX(-1);
}
.pet-image {
  object-fit: contain;
  user-select: none;
  transform-origin: 50% 90%;
  animation: pet-breathe 5s ease-in-out infinite;
}
.pet-body .pet-image {
  display: block;
  width: 100px;
  height: 100px;
  filter: drop-shadow(0 5px 6px rgb(30 50 30 / 0.1));
}
.pet-chat-launch {
  width: 40px;
  height: 40px;
  margin-inline-start: -12px;
  margin-bottom: 8px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--accent);
  color: var(--surface);
  display: grid;
  place-items: center;
  pointer-events: auto;
}
.pet-chat-launch svg {
  width: 18px;
  height: 18px;
}
.pet-widget-name {
  display: block;
  max-width: 108px;
  margin-top: 4px;
  padding: 0 8px;
  font-size: 12px;
  line-height: 1.5;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
  background: var(--surface);
  border-radius: 8px;
}
.pet-bubble {
  position: absolute;
  bottom: 144px;
  width: 184px;
  max-height: 160px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  line-height: 1.65;
  box-shadow: var(--shadow);
  overflow-wrap: anywhere;
}
.pet-widget.is-walking {
  transition: none;
}
.pet-widget.is-walking .pet-body::after {
  content: '';
  position: absolute;
  left: 28px;
  bottom: 10px;
  width: 44px;
  height: 6px;
  background: rgb(40 61 49 / 0.14);
  border-radius: 50%;
  transform: scaleX(var(--pet-shadow-scale, 1));
  pointer-events: none;
}
.pet-toolstrip {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-left: -12px;
  margin-bottom: 6px;
}
.pet-toolstrip .pet-chat-launch {
  margin: 0;
}
.pet-toolstrip .pet-switch-launch {
  background: var(--surface);
  color: var(--accent);
}
.pet-library-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0;
}
.pet-library-filters button {
  min-height: 44px;
}
.pet-library-filters button[aria-pressed='true'] {
  background: var(--accent-soft);
  border-color: var(--accent);
}
.pet-choices.pet-library {
  max-height: min(42dvh, 352px);
  overflow-y: auto;
  padding: 4px;
  align-content: start;
}
.pet-library .pet-choice {
  min-width: 0;
}
.pet-library .pet-choice img {
  height: 88px;
  width: 100%;
}
.pet-library .pet-choice > span {
  font-size: 11px;
  text-align: center;
  overflow-wrap: anywhere;
}
.pet-widget.is-walking .pet-image {
  animation: pet-step 0.4s ease-in-out infinite;
}
.pet-walk-sprite {
  position: absolute;
  display: none;
  width: 100px;
  height: 100px;
  background-repeat: no-repeat;
}
.pet-widget.is-walking .pet-body .pet-image {
  display: none;
}
.pet-widget.is-walking .pet-walk-sprite {
  display: block;
}
.pet-widget.is-dragging .pet-image {
  animation: none;
  transform: rotate(-6deg);
}
[data-reaction='pat'] .pet-image {
  animation: pet-hop 0.6s ease-in-out 2;
}
[data-reaction='snack'] .pet-image {
  animation: pet-nibble 0.3s ease-in-out 4;
}
[data-reaction='celebrate'] .pet-image {
  animation: pet-hop 0.4s ease-in-out 3;
}
body:has(dialog[open]) .pet-widget {
  visibility: hidden;
}
.pet-dialog {
  width: min(520px, calc(100% - 32px));
  margin: auto;
  max-height: calc(100dvh - 48px);
  overflow-y: auto;
}
.pet-dialog .dialog-header {
  padding: 20px 24px 12px;
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 1;
}
.pet-dialog .dialog-header h2 {
  font-size: 22px;
  overflow-wrap: anywhere;
}
.pet-dialog.pet-chat-view[open] {
  display: flex;
  flex-direction: column;
  height: min(760px, calc(100dvh - 32px));
  overflow: hidden;
}
.pet-chat-view .dialog-header {
  flex-shrink: 0;
}
.pet-home,
.pet-settings {
  padding: 0 24px 24px;
}
.pet-home {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}
.pet-profile {
  display: flex;
  gap: 24px;
  align-items: center;
  padding-bottom: 16px;
}
.pet-stage {
  flex: 0 0 96px;
  height: 104px;
  display: grid;
  place-items: center;
  background: var(--hero);
  border-radius: 50% 50% 40% 40%;
}
.pet-stage img {
  width: 96px;
  height: 104px;
}
.pet-profile-copy {
  flex: 1;
  min-width: 0;
}
.pet-mood {
  font-size: 15px;
  font-weight: 500;
}
.pet-affection {
  font-size: 12px;
  margin-top: 8px;
  color: var(--muted);
}
.pet-profile progress {
  width: 100%;
  height: 6px;
  border: 0;
  border-radius: 6px;
  display: block;
  margin-top: 8px;
  accent-color: var(--accent);
}
.pet-profile progress::-webkit-progress-bar {
  background: var(--accent-soft);
  border-radius: 6px;
}
.pet-profile progress::-webkit-progress-value {
  background: var(--accent);
  border-radius: 6px;
}
.pet-settings-button {
  margin-top: 12px;
  font-size: 12px;
  text-align: start;
}
.pet-actions {
  display: flex;
  gap: 8px;
}
.pet-actions > button {
  flex: 1;
  justify-content: center;
  padding: 10px 8px;
  font-size: 13px;
  gap: 8px;
  min-height: 44px;
}
.pet-actions svg {
  width: 17px;
  height: 17px;
}
.pet-preview-dialog.pet-chat-view[open] {
  display: block;
  height: fit-content;
  overflow-y: auto;
}
.pet-preview-note {
  padding-top: 12px;
  border-top: 1px solid var(--line);
  color: var(--muted);
}
.pet-test-link {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  margin-bottom: 8px;
}
.pet-preferences {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 12px 0 16px;
  font-size: 12px;
  color: var(--muted);
}
.pet-preferences label {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  cursor: pointer;
}
.pet-preferences input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}
.pet-reset {
  font-size: 12px;
}
.pet-conversation {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 260px;
  border-top: 1px solid var(--line);
  padding-top: 16px;
}
.pet-conversation h3 {
  font-size: 16px;
}
.pet-private {
  color: var(--muted);
  font-size: 12px;
  margin-top: 4px;
}
.pet-messages {
  flex: 1;
  min-height: 80px;
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  align-items: start;
  gap: 12px;
  margin: 12px 0;
  padding: 4px;
  border-radius: 8px;
}
.pet-chat-empty {
  color: var(--muted);
  align-self: center;
  text-align: center;
  margin: auto;
  max-width: 240px;
  font-size: 14px;
}
.pet-message {
  max-width: 88%;
  border-radius: 12px;
  padding: 12px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 14px;
}
.pet-message span {
  display: block;
  font-size: 11px;
  margin-bottom: 4px;
  color: var(--muted);
}
.pet-message-user {
  align-self: end;
  background: var(--accent-soft);
}
.pet-message-friend {
  background: var(--surface-alt);
}
.pet-chat-status {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 12px;
}
.pet-chat-status::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-inline-end: 8px;
  border-radius: 50%;
  background: var(--accent);
  animation: pet-breathe 1s infinite;
}
.pet-chat-error {
  margin-bottom: 12px;
  font-size: 13px;
}
.pet-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}
.pet-suggestions button {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  padding: 8px 12px;
  border-radius: 12px;
  font-size: 12px;
  min-height: 36px;
}
.pet-chat-label {
  display: block;
  margin-bottom: 8px;
  font-size: 12px;
  color: var(--muted);
}
.pet-compose {
  display: flex;
  align-items: end;
  gap: 8px;
}
.pet-compose textarea {
  flex: 1;
  width: 0;
  min-height: 52px;
  max-height: 160px;
  resize: vertical;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  font-size: 14px;
}
.pet-send {
  min-width: 48px;
  min-height: 48px;
  padding: 12px;
}
.pet-settings > .muted {
  font-size: 14px;
  margin: 8px 0 20px;
}
.pet-choices {
  border: 0;
  padding: 0;
  margin: 0 0 24px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
.pet-choices legend {
  margin-bottom: 12px;
  font-size: 13px;
  font-weight: 500;
}
.pet-choice {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  position: relative;
  padding: 16px 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  cursor: pointer;
  font-size: 13px;
}
.pet-choice input {
  position: absolute;
  top: 8px;
  left: 8px;
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}
.pet-choice:has(input:checked) {
  background: var(--accent-soft);
  border-color: var(--accent);
}
.pet-choice:has(input:focus-visible) {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}
.pet-choice img {
  width: 104px;
  height: 112px;
}
.pet-settings-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 24px;
}
.pet-settings-footer .primary {
  margin-inline-start: auto;
}
.pet-save-error {
  margin-top: 12px;
}
@keyframes pet-breathe {
  0%,
  100% {
    transform: translateY(0) scale(1);
  }
  50% {
    transform: translateY(-3px) scale(1.02, 0.99);
  }
}
@keyframes pet-step {
  0%,
  100% {
    transform: translateY(0) rotate(-2deg);
  }
  50% {
    transform: translateY(-5px) rotate(2deg);
  }
}
@keyframes pet-hop {
  0%,
  100% {
    transform: translateY(0) scale(1);
  }
  25% {
    transform: translateY(2px) scale(1.06, 0.94);
  }
  55% {
    transform: translateY(-16px) scale(0.98, 1.03);
  }
}
@keyframes pet-nibble {
  0%,
  100% {
    transform: rotate(0) scale(1);
  }
  50% {
    transform: rotate(3deg) scale(1.04, 0.96);
  }
}
@media (max-width: 599px) {
  .pet-dialog {
    width: calc(100% - 16px);
    max-height: calc(100dvh - 24px);
  }
  .pet-dialog .dialog-header {
    padding: 16px 16px 8px;
  }
  .pet-home,
  .pet-settings {
    padding: 0 16px 20px;
  }
  .pet-profile {
    gap: 16px;
  }
  .pet-stage {
    flex-basis: 88px;
    height: 96px;
  }
  .pet-stage img {
    width: 88px;
    height: 96px;
  }
  .pet-mood {
    font-size: 14px;
  }
  .pet-actions > button {
    font-size: 12px;
    gap: 4px;
  }
  .pet-choices {
    gap: 8px;
  }
  .pet-choice {
    padding: 24px 4px 12px;
  }
  .pet-choice img {
    height: 88px;
  }
  .pet-preferences {
    flex-wrap: wrap;
    margin-bottom: 16px;
  }
}
.pet-personality,
.pet-personality-label {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.7;
}
.pet-personality {
  margin-bottom: 8px;
}
.pet-personality-label {
  display: block;
  margin-top: 4px;
}
@media (prefers-reduced-motion: reduce) {
  .pet-image,
  .pet-chat-status::before {
    animation: none !important;
  }
  .pet-widget {
    transition: none !important;
  }
}
