/* Evolab-style PetSurface — transparent desktop companion HUD. */

.pet-surface {
  --pet-stage-width: 820px;
  --pet-stage-height: 360px;
  --pet-slot-size: 160px;
  --pet-anchor-right: 132px;
  --pet-anchor-bottom: 44px;
  --pet-accent: #3b82f6;
  --pet-action: #f7c948;
  --pet-ink: #ffffff;
  --pet-glass: rgba(37, 40, 50, 0.88);
  --pet-glass-strong: rgba(37, 40, 50, 0.94);
  --pet-border: rgba(255, 255, 255, 0.16);
  --pet-shadow: 0 18px 46px rgba(2, 6, 23, 0.28);
  position: absolute;
  inset: 0;
  width: var(--pet-stage-width);
  height: var(--pet-stage-height);
  overflow: visible;
  color: var(--pet-ink);
  opacity: 1;
  pointer-events: none;
  transition: opacity 0.16s ease-out;
}

.pet-surface[data-hidden="true"] {
  opacity: 0;
}

.pet-surface__stage {
  position: relative;
  width: var(--pet-stage-width);
  height: var(--pet-stage-height);
  overflow: visible;
}

.pet-surface__interactive {
  pointer-events: auto;
}

.pet-surface * {
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.pet-surface *::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}

.pet-surface__pet {
  position: absolute;
  right: var(--pet-anchor-right);
  bottom: var(--pet-anchor-bottom);
  z-index: 12;
  display: grid;
  width: calc(var(--pet-slot-size) * var(--pet-scale, 0.72));
  height: calc(var(--pet-slot-size) * var(--pet-scale, 0.72));
  place-items: end center;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: grab;
}

.pet-surface[data-anchor-x="left"] .pet-surface__pet {
  right: auto;
  left: var(--pet-anchor-right);
}

.pet-surface[data-anchor-y="top"] .pet-surface__pet {
  top: var(--pet-anchor-bottom);
  bottom: auto;
}

.pet-surface__pet:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.72);
  outline-offset: 2px;
  border-radius: 18px;
}

.pet-surface__pet[data-dragging="true"] {
  cursor: grabbing;
}

.pet-surface__sprite-shell {
  position: relative;
  display: grid;
  width: 100%;
  height: 100%;
  place-items: end center;
}

.pet-surface__pet .sprite-canvas,
.pet-surface__pet .mascot-image {
  display: block;
  pointer-events: none;
}

.sprite-canvas {
  flex: 0 0 auto;
  image-rendering: crisp-edges;
  image-rendering: pixelated;
}

.pet-surface__loading {
  display: grid;
  width: 68%;
  height: 68%;
  place-items: center;
  border: 2px dashed rgba(255, 255, 255, 0.45);
  border-radius: 50%;
  background: radial-gradient(circle at 50% 40%, rgba(247, 201, 72, 0.58), rgba(59, 130, 246, 0.22) 62%, transparent 76%);
  color: rgba(255, 255, 255, 0.86);
  font-size: 22px;
  font-weight: 900;
  letter-spacing: 3px;
  animation: pet-loading-pulse 1.4s ease-in-out infinite;
}

.pet-surface__badges {
  position: absolute;
  top: 18%;
  right: 7%;
  z-index: 6;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transform: translate(30%, -30%);
}

.pet-surface__badge {
  display: inline-flex;
  min-width: 24px;
  height: 24px;
  align-items: center;
  justify-content: center;
  border: 2px solid #fff;
  border-radius: 999px;
  padding: 0 6px;
  font-size: 11px;
  font-weight: 950;
  line-height: 1;
  box-shadow: 0 8px 18px rgba(2, 6, 23, 0.26);
}

.pet-surface__badge--session {
  background: var(--pet-accent);
  color: #fff;
}

.pet-surface__badge--action {
  background: var(--pet-action);
  color: #17130a;
}

.pet-surface__update-badge {
  position: absolute;
  top: 18%;
  left: 7%;
  z-index: 6;
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  gap: 5px;
  border-radius: 999px;
  border: 2px solid #fff;
  padding: 3px 7px 3px 5px;
  background: rgba(255, 255, 255, 0.95);
  color: #ff3b30;
  box-shadow: 0 8px 18px rgba(2, 6, 23, 0.3);
  transform: translate(-30%, -30%);
  pointer-events: none;
}

.pet-surface__update-dot {
  width: 10px;
  height: 10px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #ff3b30;
  box-shadow: 0 0 0 0 rgba(255, 59, 48, 0.45);
  animation: pet-update-dot-pulse 1.8s ease-in-out infinite;
}

.pet-surface__update-label {
  font-size: 11px;
  font-weight: 950;
  letter-spacing: 0;
  line-height: 1;
  white-space: nowrap;
}

@keyframes pet-update-dot-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 59, 48, 0.45); }
  50% { box-shadow: 0 0 0 5px rgba(255, 59, 48, 0); }
}

.pet-surface__drawer,
.pet-surface__toast {
  border: 1px solid var(--pet-border);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.12), transparent 42%),
    var(--pet-glass);
  color: #fff;
  box-shadow: var(--pet-shadow);
  backdrop-filter: blur(18px) saturate(1.35);
  -webkit-backdrop-filter: blur(18px) saturate(1.35);
}

.pet-surface__drawer {
  position: absolute;
  left: var(--pet-panel-left, 0);
  top: var(--pet-panel-top, 0);
  z-index: 5;
  display: grid;
  width: 270px;
  max-height: 206px;
  gap: 3px;
  border-radius: 12px;
  padding: 6px 7px 7px;
  text-align: left;
  box-sizing: border-box;
}

.pet-surface__drawer--empty {
  width: 218px;
  min-height: 46px;
  cursor: pointer;
}

.pet-surface__drawer--detail {
  display: flex;
  width: min(
    520px,
    calc(var(--pet-stage-width) - var(--pet-anchor-right) - (var(--pet-slot-size) * var(--pet-scale, 0.72)) - 56px)
  );
  height: 328px;
  max-height: 328px;
  padding: 0;
  overflow: hidden;
  border-color: var(--island-border);
  border-radius: 18px;
  background: var(--island-bg);
  color: var(--island-text);
  box-shadow: var(--island-shadow);
}

.pet-surface__drawer--sessions {
  display: block;
  width: min(
    520px,
    calc(var(--pet-stage-width) - var(--pet-anchor-right) - (var(--pet-slot-size) * var(--pet-scale, 0.72)) - 56px)
  );
  max-height: 316px;
  padding: 10px 0 6px;
  overflow-x: hidden;
  overflow-y: auto;
  border-color: var(--island-border);
  border-radius: 18px;
  background: var(--island-bg);
  color: var(--island-text);
  box-shadow: var(--island-shadow);
}

.pet-surface__overlay {
  position: absolute;
  left: var(--pet-panel-left, 0);
  top: var(--pet-panel-top, 0);
  z-index: 8;
  width: min(
    520px,
    calc(var(--pet-stage-width) - var(--pet-anchor-right) - (var(--pet-slot-size) * var(--pet-scale, 0.72)) - 56px)
  );
  max-height: 328px;
  overflow: hidden;
  color: var(--island-text);
}

.pet-surface__overlay .overlay-card {
  width: 100%;
  max-height: 328px;
  border-radius: 18px;
  background: var(--island-bg);
  color: var(--island-text);
}

.pet-surface__overlay .overlay-card__secondary {
  display: none;
}

.pet-surface__drawer:hover,
.pet-surface__toast:hover {
  border-color: rgba(255, 255, 255, 0.3);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.16), transparent 42%),
    var(--pet-glass-strong);
}

.pet-surface__drawer--sessions:hover,
.pet-surface__drawer--detail:hover {
  border-color: var(--island-border);
  background: var(--island-bg);
}

.pet-surface__drawer-header {
  display: flex;
  min-height: 18px;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 2px 1px;
}

.pet-surface__drawer-header > span {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.pet-surface__drawer-titleline {
  color: rgba(255, 255, 255, 0.48);
  font-size: 9px;
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.pet-surface__icon-button,
.pet-surface__text-button {
  appearance: none;
  border: 0;
  color: rgba(255, 255, 255, 0.76);
  background: rgba(255, 255, 255, 0.09);
  cursor: pointer;
  font: inherit;
}

.pet-surface__icon-button {
  display: grid;
  width: 17px;
  height: 17px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
}

.pet-surface__icon-button--floating {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 3;
  width: 24px;
  height: 24px;
  color: var(--island-text-secondary);
  background: var(--island-btn-bg);
  font-size: 13px;
}

.pet-surface__icon-button--floating:hover {
  color: var(--island-text);
  background: var(--island-btn-hover);
}

.pet-surface__hover-list {
  min-width: 0;
}

.pet-surface__hover-list .hover-list {
  padding: 2px 0 4px;
}

.pet-surface__hover-list .hover-list__card {
  margin: 0 8px;
}

.pet-surface__hover-list .hover-list__card:first-child {
  padding-right: 44px;
}

.pet-surface__hover-list .hover-list__show-all {
  margin-bottom: 4px;
}

.pet-surface__drawer--detail .chat-view {
  width: 100%;
  height: 100%;
  background: var(--island-bg);
  color: var(--island-text);
}

.pet-surface__drawer--detail .chat-header {
  padding-right: 42px;
}

.pet-surface__text-button {
  min-width: 46px;
  height: 24px;
  border-radius: 999px;
  padding: 0 9px;
  font-size: 11px;
  font-weight: 850;
}

.pet-surface__icon-button:hover,
.pet-surface__text-button:hover,
.pet-surface__quick-options button:hover,
.pet-surface__terminal-button:hover {
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
}

.pet-surface__session-list {
  display: grid;
  gap: 1px;
  min-width: 0;
  padding-bottom: 1px;
  overflow: auto;
}

.pet-surface__session-row {
  appearance: none;
  display: grid;
  width: 100%;
  min-height: 39px;
  grid-template-columns: 9px minmax(0, 1fr) auto;
  align-items: start;
  gap: 7px;
  border: 0;
  border-radius: 7px;
  padding: 5px 7px;
  color: inherit;
  background: transparent;
  text-align: left;
  cursor: pointer;
  font: inherit;
  transition: background 0.15s ease, opacity 0.15s ease;
}

.pet-surface__session-row:hover {
  background: rgba(255, 255, 255, 0.09);
}

.pet-surface__dot {
  width: 9px;
  height: 9px;
  margin-top: 2px;
  border-radius: 999px;
  background: #7dd3fc;
  box-shadow: 0 0 0 3px rgba(125, 211, 252, 0.13);
}

.pet-surface__dot--idle,
.pet-surface__dot--dormant {
  background: #9ca3af;
  box-shadow: 0 0 0 4px rgba(156, 163, 175, 0.12);
}

.pet-surface__dot--done {
  background: #34d399;
  box-shadow: 0 0 0 4px rgba(52, 211, 153, 0.14);
}

.pet-surface__dot--working,
.pet-surface__dot--thinking,
.pet-surface__dot--compacting {
  background: #60a5fa;
  box-shadow: 0 0 0 4px rgba(96, 165, 250, 0.14);
}

.pet-surface__dot--attention {
  background: var(--pet-action);
  box-shadow: 0 0 0 4px rgba(247, 201, 72, 0.2);
}

.pet-surface__dot--error {
  background: #fb7185;
  box-shadow: 0 0 0 4px rgba(251, 113, 133, 0.18);
}

.pet-surface__hud-copy {
  display: grid;
  min-width: 0;
  gap: 1px;
}

.pet-surface__hud-title,
.pet-surface__toast-title,
.pet-surface__drawer-title {
  display: block;
  min-width: 0;
  overflow: hidden;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pet-surface__hud-preview,
.pet-surface__toast-preview,
.pet-surface__drawer-preview {
  display: block;
  min-width: 0;
  overflow: hidden;
  color: rgba(255, 255, 255, 0.66);
  font-size: 9.5px;
  font-weight: 600;
  line-height: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pet-surface__hud-meta,
.pet-surface__toast-kicker {
  display: block;
  min-width: 0;
  overflow: hidden;
  color: rgba(255, 255, 255, 0.46);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0;
  line-height: 12px;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.pet-surface__hud-chip {
  align-self: start;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.09);
  color: rgba(255, 255, 255, 0.64);
  padding: 1px 6px;
  font-size: 9px;
  font-weight: 700;
  line-height: 13px;
  text-transform: capitalize;
}

.pet-surface__detail-head {
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: start;
  min-width: 0;
  padding: 4px 2px 0;
}

.pet-surface__detail-copy {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.pet-surface__detail-title {
  overflow: hidden;
  color: #fff;
  font-size: 12px;
  font-weight: 780;
  line-height: 16px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pet-surface__detail-meta {
  overflow: hidden;
  color: rgba(255, 255, 255, 0.46);
  font-size: 10px;
  font-weight: 760;
  line-height: 1.2;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.pet-surface__detail-preview {
  display: -webkit-box;
  min-height: 30px;
  max-height: 47px;
  margin: 0;
  overflow: hidden;
  color: rgba(255, 255, 255, 0.72);
  font-size: 11px;
  font-weight: 620;
  line-height: 1.4;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.pet-surface__quick-options {
  display: flex;
  gap: 6px;
  min-width: 0;
  overflow: hidden;
}

.pet-surface__quick-options button,
.pet-surface__terminal-button {
  appearance: none;
  min-width: 0;
  border: 0;
  border-radius: 999px;
  color: rgba(255, 255, 255, 0.78);
  background: rgba(255, 255, 255, 0.1);
  cursor: pointer;
  font: inherit;
  font-size: 10px;
  font-weight: 850;
}

.pet-surface__quick-options button {
  overflow: hidden;
  padding: 5px 8px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pet-surface__reply {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 54px;
  gap: 7px;
}

.pet-surface__reply input {
  width: 100%;
  min-width: 0;
  height: 32px;
  box-sizing: border-box;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  padding: 0 11px;
  color: #fff;
  background: rgba(0, 0, 0, 0.2);
  font: inherit;
  font-size: 12px;
  outline: none;
}

.pet-surface__reply input:focus {
  border-color: rgba(96, 165, 250, 0.54);
}

.pet-surface__reply input::placeholder {
  color: rgba(255, 255, 255, 0.38);
}

.pet-surface__reply button {
  appearance: none;
  height: 32px;
  border: 0;
  border-radius: 999px;
  color: #111827;
  background: rgba(125, 211, 252, 0.95);
  cursor: pointer;
  font: inherit;
  font-size: 11px;
  font-weight: 950;
}

.pet-surface__reply button:disabled {
  opacity: 0.45;
  cursor: default;
}

.pet-surface__reply-error {
  overflow: hidden;
  color: #fecdd3;
  font-size: 10px;
  font-weight: 750;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pet-surface__terminal-button {
  justify-self: start;
  height: 26px;
  padding: 0 10px;
}

.pet-surface__toast {
  position: absolute;
  left: var(--pet-panel-left, 0);
  top: var(--pet-panel-top, 0);
  z-index: 7;
  display: grid;
  box-sizing: border-box;
  width: 268px;
  gap: 4px;
  border-radius: 16px;
  padding: 11px 12px;
  text-align: left;
  cursor: pointer;
}

.pet-surface__toast--action {
  border-color: rgba(247, 201, 72, 0.36);
}

.pet-surface__idle-tip {
  position: absolute;
  left: var(--pet-panel-left, 0);
  top: var(--pet-panel-top, 0);
  z-index: 4;
  display: grid;
  width: 260px;
  box-sizing: border-box;
  gap: 3px;
  padding: 9px 11px 10px;
  border: 1px solid rgba(59, 130, 246, 0.18);
  border-radius: 14px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.16), transparent 48%),
    rgba(255, 255, 255, 0.9);
  color: #1f2937;
  box-shadow: 0 14px 34px rgba(15, 23, 42, 0.16);
  pointer-events: none;
  text-align: left;
  animation: pet-idle-tip-enter 0.18s ease-out both;
}

.pet-surface__idle-tip::after {
  position: absolute;
  right: -6px;
  bottom: 20px;
  width: 11px;
  height: 11px;
  border-right: 1px solid rgba(59, 130, 246, 0.18);
  border-bottom: 1px solid rgba(59, 130, 246, 0.18);
  background: rgba(255, 255, 255, 0.9);
  content: "";
  transform: rotate(-45deg);
}

.pet-surface__idle-tip-label {
  color: #2563eb;
  font-size: 10px;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.pet-surface__idle-tip-text {
  display: block;
  overflow: hidden;
  color: #253044;
  font-size: 12px;
  font-weight: 750;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pet-surface__toast--message {
  display: block;
  width: min(
    460px,
    calc(var(--pet-stage-width) - var(--pet-anchor-right) - (var(--pet-slot-size) * var(--pet-scale, 0.72)) - 56px)
  );
  max-height: 316px;
  gap: 0;
  padding: 0;
  overflow: hidden;
  border-color: var(--island-border);
  border-radius: 18px;
  background: var(--island-bg);
  color: var(--island-text);
  cursor: default;
}

.pet-surface__toast--message::after {
  position: absolute;
  content: "";
  width: 11px;
  height: 11px;
  background: var(--island-bg);
  border-right: 1px solid var(--island-border);
  border-bottom: 1px solid var(--island-border);
  transform: rotate(45deg);
}

.pet-surface__toast--message:hover {
  border-color: var(--island-border);
  background: var(--island-bg);
}

.pet-surface__toast--message .overlay-feedback,
.pet-surface__toast--message .overlay-compacting {
  width: 100%;
  max-height: 316px;
  background: var(--island-bg);
}

.pet-surface__toast--message .overlay-feedback__detail {
  --overlay-feedback-reader-min-height: 118px;
  margin: 6px 14px 8px;
  width: calc(100% - 28px);
}

.pet-surface__toast--message .overlay-feedback__session {
  align-items: center;
  gap: 9px;
  padding: 8px 14px 6px;
}

.pet-surface__toast--message .overlay-feedback__avatar {
  width: 24px;
  flex: 0 0 24px;
  border-radius: 8px;
}

.pet-surface__toast--message .overlay-feedback__session-copy {
  display: flex;
  align-items: center;
  min-height: 24px;
}

.pet-surface__toast--message .overlay-feedback__user-line,
.pet-surface__toast--message .overlay-feedback__preview {
  display: none;
}

.pet-surface__toast--message .overlay-feedback__scroll {
  padding: 8px 10px 10px;
}

.pet-surface__toast--message .overlay-feedback__message--user {
  font-size: 10.5px;
  padding: 6px 8px;
}

.pet-surface__toast--message .overlay-feedback__message--assistant {
  padding: 8px 9px 10px;
}

.pet-surface__toast--message .overlay-feedback__markdown {
  font-size: 10.5px;
  line-height: 1.5;
}

.pet-surface__toast--message .overlay-feedback__markdown h1 {
  font-size: 13px;
}

.pet-surface__toast--message .overlay-feedback__markdown h2 {
  font-size: 12px;
}

.pet-surface__toast--message .overlay-feedback__markdown h3,
.pet-surface__toast--message .overlay-feedback__markdown h4 {
  font-size: 11px;
}

.pet-surface__toast--message .overlay-feedback__markdown code {
  font-size: 9.5px;
}

.pet-surface__toast--message .overlay-feedback__markdown pre code {
  font-size: 9.8px;
}

.pet-surface__toast--message .overlay-feedback__reply {
  padding: 7px 14px 8px;
}

.pet-surface__toast--message[data-placement="top-left"]::after,
.pet-surface__toast--message[data-placement="top-right"]::after {
  right: 44px;
  bottom: -6px;
  transform: rotate(45deg);
}

.pet-surface__toast--message[data-placement="top-right"]::after {
  right: auto;
  left: 44px;
}

.pet-surface__toast--message[data-placement="bottom-left"]::after,
.pet-surface__toast--message[data-placement="bottom-right"]::after {
  top: -6px;
  right: 44px;
  transform: rotate(225deg);
}

.pet-surface__toast--message[data-placement="bottom-right"]::after {
  right: auto;
  left: 44px;
}

.pet-surface__toast--message[data-placement="left"]::after {
  top: 50%;
  right: -6px;
  transform: translateY(-50%) rotate(-45deg);
}

.pet-surface__toast--message[data-placement="right"]::after {
  top: 50%;
  left: -6px;
  transform: translateY(-50%) rotate(135deg);
}

.pet-surface__idle-tip[data-placement="top-left"]::after,
.pet-surface__idle-tip[data-placement="top-right"]::after {
  right: 34px;
  bottom: -6px;
  transform: rotate(45deg);
}

.pet-surface__idle-tip[data-placement="top-right"]::after {
  right: auto;
  left: 34px;
}

.pet-surface__idle-tip[data-placement="bottom-left"]::after,
.pet-surface__idle-tip[data-placement="bottom-right"]::after {
  top: -6px;
  right: 34px;
  bottom: auto;
  transform: rotate(225deg);
}

.pet-surface__idle-tip[data-placement="bottom-right"]::after {
  right: auto;
  left: 34px;
}

.pet-surface__idle-tip[data-placement="left"]::after {
  top: 50%;
  right: -6px;
  transform: translateY(-50%) rotate(-45deg);
}

.pet-surface__idle-tip[data-placement="right"]::after {
  top: 50%;
  left: -6px;
  transform: translateY(-50%) rotate(135deg);
}

@keyframes pet-idle-tip-enter {
  from {
    opacity: 0;
    transform: translateX(8px) translateY(4px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateX(0) translateY(0) scale(1);
  }
}

@keyframes pet-loading-pulse {
  0%, 100% {
    opacity: 0.84;
    transform: scale(1);
  }
  50% {
    opacity: 1;
    transform: scale(1.06);
  }
}
