/* Bit, the lab mascot. Roof mode (home) and corner mode (other pages). */

.mx-bit {
  --mx-ink: #f0ebe2;
  --mx-bg: rgba(18, 16, 14, 0.92);
  --mx-line: rgba(255, 255, 255, 0.16);
  --mx-ac: var(--ac, #ff4655);
  position: absolute;
  z-index: 62;
  width: 112px;
  height: 104px;
  pointer-events: none;
  transition: translate var(--mx-ms, 0ms) var(--mx-ease, linear);
}
.mx-bit[data-held] {
  transition: none;
}
.mx-bit[data-mode="roof"] {
  left: 0;
  top: 0;
}
.mx-bit[data-mode="roof"]:not([data-ready]),
.mx-bit[data-away="1"] {
  visibility: hidden;
}
/* the terminal has been picked up and floats over the page: so does its roof */
.mx-bit[data-mode="roof"][data-roof="free"] {
  position: fixed;
  z-index: 151;
}
/* phones: the CRT is scaled to the viewport, so Bit shrinks with it and keeps standing on the roof */
.mx-bit[data-mode="roof"] {
  transform-origin: 0 100%;
  scale: var(--mx-scale, 1);
}

/* corner guide: bottom of the viewport, moves aside or hides rather than cover a control */
.mx-bit[data-mode="corner"] {
  position: fixed;
  bottom: calc(14px + var(--m-dock-h, 0px));
  z-index: 45;
  width: 84px;
  height: 78px;
  transition: translate var(--mx-ms, 0ms) var(--mx-ease, linear), opacity 0.25s ease, visibility 0s;
}
.mx-bit[data-mode="corner"][data-corner="br"] {
  right: 14px;
}
.mx-bit[data-mode="corner"][data-corner="bl"] {
  left: 14px;
}
.mx-bit[data-mode="corner"][data-hidden="1"] {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.25s ease, visibility 0s 0.25s;
}
@media (max-width: 519px) {
  .mx-bit[data-mode="corner"] {
    display: none;
  }
}


.mx-bit {
  --mx-c: 96px; /* canvas size */
  --mx-b: 1px; /* canvas distance from the bottom of the box */
}
.mx-bit[data-mode="corner"] {
  --mx-c: 78px;
  --mx-b: 0px;
}
.mx-sprite {
  pointer-events: auto;
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  appearance: none;
  background: transparent;
  border: 0;
  border-radius: 12px;
  padding: 0;
  margin: 0;
  display: block;
  position: relative;
  width: 100%;
  height: 100%;
}
.mx-bit[data-held] .mx-sprite {
  cursor: grabbing;
}
.mx-sprite:focus-visible {
  outline: 2px dashed var(--mx-ac);
  outline-offset: 2px;
}
.mx-gl {
  position: absolute;
  left: 50%;
  bottom: var(--mx-b);
  width: var(--mx-c);
  height: var(--mx-c);
  translate: -50% 0;
  pointer-events: none;
  opacity: 0;
}
.mx-bit[data-gl="1"] .mx-gl {
  opacity: 1;
}

/* stand-in until the 3D sphere is ready (and the fallback if WebGL is unavailable) */
.mx-ph {
  position: absolute;
  left: 50%;
  bottom: calc(var(--mx-b) + var(--mx-c) * 0.156);
  width: calc(var(--mx-c) * 0.57);
  height: calc(var(--mx-c) * 0.57);
  translate: -50% 0;
  border-radius: 50%;
  background: radial-gradient(circle at 36% 30%, #fff 0, #f4f6fa 55%, #c9d0de 100%);
  box-shadow: 0 8px 7px -4px #00000073, 0 0 7px #ffffff2e;
  pointer-events: none;
  animation: mx-bob 3.6s ease-in-out infinite;
}
.mx-ph i {
  position: absolute;
  top: 17%;
  width: 12.5%;
  height: 20%;
  border-radius: 999px;
  background: #16161a;
}
/* round glasses */
.mx-ph i::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 290%;
  height: 130%;
  translate: -50% -50%;
  border: 4px solid #17171b;
  border-radius: 50%;
  background: #ffffff1a;
  box-shadow: inset 0 1px 1px #ffffff40, 0 3px 3px #00000059;
  filter: drop-shadow(2px 4px 2px #0000004d);
  box-sizing: border-box;
}
.mx-ph i:first-child {
  left: 52%;
}
.mx-ph i:last-child {
  left: 76%;
  width: 8%;
  height: 17.6%;
  top: 14%;
}
.mx-ph i:last-child::before {
  width: 285%;
  height: 130%;
}
.mx-bit[data-gl="1"] .mx-ph {
  display: none;
}
@keyframes mx-bob {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-3px);
  }
}

/* glasses are opt-in (bit glasses on) */
.mx-bit:not([data-glasses="1"]) .mx-ph i::before {
  display: none;
}

/* ---------- moves: pieces shared by the 3D and the CSS-only fallback ---------- */

/* glitch: a quick RGB split and jitter */
.mx-bit[data-glitch="1"] .mx-gl,
.mx-bit[data-glitch="1"] .mx-ph {
  animation: mx-glitch 0.6s steps(1, end) 1;
}
@keyframes mx-glitch {
  0% { filter: drop-shadow(3px 0 0 #ff2e63cc) drop-shadow(-3px 0 0 #00e5ffcc); translate: -48% 0; }
  20% { filter: drop-shadow(-4px 1px 0 #ff2e63cc) drop-shadow(4px -1px 0 #00e5ffcc); translate: -53% 1px; }
  40% { filter: drop-shadow(2px 0 0 #ff2e63aa) drop-shadow(-2px 0 0 #00e5ffaa); translate: -50% -1px; clip-path: inset(30% 0 40% 0); }
  55% { filter: drop-shadow(-2px 0 0 #ff2e63aa) drop-shadow(2px 0 0 #00e5ffaa); translate: -47% 0; clip-path: none; }
  75% { filter: drop-shadow(1px 0 0 #ff2e6380) drop-shadow(-1px 0 0 #00e5ff80); translate: -50% 0; }
  100% { filter: none; translate: -50% 0; }
}

/* peek: the roof edge hides the lower half */
.mx-bit[data-peek] .mx-gl {
  clip-path: inset(0 0 14% 0);
}

/* swallowed the cursor */
.mx-bit[data-gulp] .mx-sprite {
  cursor: none;
}
.mx-spit {
  position: absolute;
  left: 50%;
  top: 46%;
  width: 14px;
  height: 20px;
  margin-left: -7px;
  pointer-events: none;
  filter: drop-shadow(0 2px 2px #0008);
}
.mx-spit svg {
  display: block;
  width: 100%;
  height: 100%;
}

/* asleep: slow breathing and drifting z's */
.mx-zz {
  position: absolute;
  right: 8%;
  top: 4%;
  pointer-events: none;
  font: 700 11px/1 "Geist Mono", "Geist Mono Fallback", ui-monospace, monospace;
  color: #cfd8ff;
  display: none;
}
.mx-bit[data-zz] .mx-zz {
  display: block;
}
.mx-zz i {
  position: absolute;
  font-style: normal;
  opacity: 0;
  animation: mx-z 3.6s ease-out infinite;
}
.mx-zz i:nth-child(2) {
  animation-delay: 1.2s;
  font-size: 9px;
}
.mx-zz i:nth-child(3) {
  animation-delay: 2.4s;
  font-size: 7px;
}
@keyframes mx-z {
  0% { opacity: 0; transform: translate(0, 10px) rotate(-8deg); }
  20% { opacity: 0.9; }
  100% { opacity: 0; transform: translate(14px, -22px) rotate(12deg); }
}
.mx-bit[data-zz] .mx-gl {
  transform-origin: 50% 85%;
  animation: mx-breathe 4.2s ease-in-out infinite;
}
@keyframes mx-breathe {
  0%, 100% { scale: 1 1; }
  50% { scale: 1.025 0.97; }
}
@media (prefers-reduced-motion: reduce) {
  .mx-zz i {
    opacity: 0.8;
  }
  .mx-zz i:nth-child(2) { transform: translate(7px, -9px); }
  .mx-zz i:nth-child(3) { transform: translate(13px, -17px); }
}

/* ---------- CSS-only versions (no WebGL): dot shrink, three dots, "!", badge ---------- */
.mx-fb {
  display: none;
  position: absolute;
  left: 50%;
  bottom: calc(var(--mx-b) + var(--mx-c) * 0.156);
  width: calc(var(--mx-c) * 0.57);
  height: calc(var(--mx-c) * 0.57);
  translate: -50% 0;
  pointer-events: none;
}
.mx-fb b {
  position: absolute;
  bottom: 0;
  width: 26%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle at 36% 30%, #fff 0, #eef1f7 55%, #b9c2d4 100%);
  box-shadow: 0 4px 4px -2px #0007;
}
.mx-bit:not([data-gl="1"])[data-fx="split"] .mx-fb,
.mx-bit:not([data-gl="1"])[data-fx="alert"] .mx-fb,
.mx-bit:not([data-gl="1"])[data-fx="panic"] .mx-fb {
  display: block;
}
.mx-bit:not([data-gl="1"])[data-fx="split"] .mx-ph,
.mx-bit:not([data-gl="1"])[data-fx="alert"] .mx-ph,
.mx-bit:not([data-gl="1"])[data-fx="panic"] .mx-ph {
  animation: mx-fb-out 0.25s ease-in forwards;
}
@keyframes mx-fb-out {
  to { scale: 0; opacity: 0; }
}
/* three loading dots */
.mx-bit[data-fx="split"] .mx-fb b {
  animation: mx-fb-dot 0.9s ease-in-out infinite;
}
.mx-bit[data-fx="split"] .mx-fb b:nth-child(1) { left: -8%; }
.mx-bit[data-fx="split"] .mx-fb b:nth-child(2) { left: 37%; animation-delay: 0.12s; }
.mx-bit[data-fx="split"] .mx-fb b:nth-child(3) { left: 82%; animation-delay: 0.24s; }
@keyframes mx-fb-dot {
  0%, 60%, 100% { translate: 0 0; }
  30% { translate: 0 -40%; }
}
/* "!" */
.mx-bit[data-fx="alert"] .mx-fb,
.mx-bit[data-fx="panic"] .mx-fb {
  transform-origin: 50% 100%;
  animation: mx-fb-bang 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
.mx-bit[data-fx="panic"] .mx-fb {
  animation: mx-fb-bang 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both, mx-fb-out 0.3s 1.4s ease-in forwards;
}
.mx-bit[data-fx="alert"] .mx-fb b:nth-child(1),
.mx-bit[data-fx="panic"] .mx-fb b:nth-child(1) {
  left: 40%;
  bottom: 34%;
  width: 22%;
  height: 100%;
  aspect-ratio: auto;
  border-radius: 999px 999px 40% 40% / 30% 30% 70% 70%;
}
.mx-bit[data-fx="alert"] .mx-fb b:nth-child(2),
.mx-bit[data-fx="panic"] .mx-fb b:nth-child(2) {
  left: 38%;
}
.mx-bit[data-fx="alert"] .mx-fb b:nth-child(3),
.mx-bit[data-fx="panic"] .mx-fb b:nth-child(3) {
  display: none;
}
@keyframes mx-fb-bang {
  from { scale: 0.2 0; rotate: -12deg; }
  to { scale: 1; rotate: 6deg; }
}
/* shrink to a dot and pop back */
.mx-bit:not([data-gl="1"])[data-fx="shrink"] .mx-ph {
  transform-origin: 50% 100%;
  animation: mx-fb-shrink 1.3s both;
}
@keyframes mx-fb-shrink {
  0% { scale: 1; }
  14% { scale: 1.1 0.9; animation-timing-function: ease-in; }
  34% { scale: 0.1; }
  60% { scale: 0.1; animation-timing-function: cubic-bezier(0.2, 0.9, 0.3, 1.3); }
  74% { scale: 1.2 0.8; }
  86% { scale: 0.95 1.06; }
  100% { scale: 1; }
}
/* unread badge on the fallback orb */
.mx-ph::after {
  content: "";
  position: absolute;
  right: -2%;
  top: -2%;
  width: 24%;
  height: 24%;
  border-radius: 50%;
  background: #ff4f6d;
  box-shadow: 0 0 0 2px #fff;
  scale: 0;
  transition: scale 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.mx-bit[data-badge="1"] .mx-ph::after {
  scale: 1;
}

/* off-screen or hidden tab: freeze the css motion (the 3D loop stops on its own) */
.mx-bit[data-paused="1"] *,
.mx-bit[data-paused="1"] {
  animation-play-state: paused !important;
}
@media (prefers-reduced-motion: reduce) {
  .mx-bit,
  .mx-bit * {
    animation: none !important;
    transition: none !important;
  }
}


/* speech balloon */
.mx-stack {
  pointer-events: auto;
  position: absolute;
  width: 232px;
  max-width: calc(100vw - 28px);
  z-index: 2;
  bottom: calc(100% + 6px);
  left: -60px;
}
.mx-bit[data-mode="corner"] .mx-stack[data-side="left"] {
  left: 0;
}
.mx-bit[data-mode="corner"] .mx-stack[data-side="right"] {
  right: 0;
}
.mx-stack[data-side="right"] {
  left: auto;
  right: -60px;
}
.mx-stack[data-v="below"] {
  bottom: auto;
  top: calc(100% + 6px);
}
.mx-balloon {
  position: relative;
  border: 1px solid var(--mx-line);
  background: var(--mx-bg);
  color: var(--mx-ink);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  font: 12px/17px "Geist Mono", "Geist Mono Fallback", "Departure Mono", ui-monospace, monospace;
  border-radius: 10px;
  padding: 10px 12px 12px;
  box-shadow: 0 14px 34px #00000073;
  animation: mx-pop 0.4s cubic-bezier(0.2, 0.9, 0.25, 1.2) both;
  text-align: left;
}
.mx-balloon::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 84px;
  width: 10px;
  height: 10px;
  background: var(--mx-bg);
  border-right: 1px solid var(--mx-line);
  border-bottom: 1px solid var(--mx-line);
  rotate: 45deg;
  translate: 0 -5px;
}
.mx-bit[data-mode="corner"] .mx-stack[data-side="left"] .mx-balloon::after {
  left: 36px;
}
.mx-stack[data-side="right"] .mx-balloon::after {
  left: auto;
  right: 84px;
}
.mx-bit[data-mode="corner"] .mx-stack[data-side="right"] .mx-balloon::after {
  right: 36px;
}
.mx-stack[data-v="below"] .mx-balloon::after {
  top: auto;
  bottom: 100%;
  rotate: 225deg;
  translate: 0 5px;
}
@keyframes mx-pop {
  from {
    opacity: 0;
    transform: translateY(6px) scale(0.94);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
.mx-ref {
  color: var(--mx-ac);
  text-underline-offset: 3px;
  background: transparent;
  border: 0;
  padding: 0;
  font: inherit;
  text-decoration: underline;
  cursor: pointer;
}
.mx-ref:hover,
.mx-ref:focus-visible {
  color: #ffd08a;
}
.mx-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
  font-size: 10px;
  color: #ffffff80;
}
.mx-more {
  font: inherit;
  color: var(--mx-ink);
  background: transparent;
  border: 1px solid var(--mx-line);
  border-radius: 6px;
  padding: 3px 8px;
  cursor: pointer;
}
.mx-more:hover,
.mx-more:focus-visible {
  background: #ffffff1a;
}

/* ---------- emotes, off duty ---------- */
.mx-bit[data-off="1"] { display: none; }
.mx-emote { position: absolute; left: 50%; bottom: calc(var(--mx-c) + 2px); transform: translateX(-50%); font: 700 13px/1 "JetBrains Mono", monospace; color: var(--mx-ac); pointer-events: none; animation: mx-emote 1.4s ease-out forwards; white-space: nowrap; }
@keyframes mx-emote { from { opacity: 0; translate: 0 6px; } 20% { opacity: 1; translate: 0 0; } to { opacity: 0; translate: 0 -22px; } }

/* ---------- what bit sees ---------- */
.bit-sees { position: fixed; left: 16px; bottom: 96px; z-index: 64; width: min(340px, calc(100vw - 32px)); padding: 10px 12px; background: rgba(14, 12, 10, .94); color: #f0ebe2; border: 1px solid rgba(255, 255, 255, .16); border-radius: 8px; font: 12px/1.4 "JetBrains Mono", monospace; }
.bit-sees header { display: flex; justify-content: space-between; margin-bottom: 8px; color: var(--ac, #ff4655); }
.bit-sees header button { background: none; border: 0; color: inherit; cursor: pointer; font: inherit; padding: 0 2px; }
.bit-sees-row { display: grid; grid-template-columns: 84px 1fr 64px 34px; gap: 6px; align-items: center; padding: 2px 0; opacity: .6; }
.bit-sees-row.is-chosen { opacity: 1; color: var(--ac, #ff4655); }
.bit-sees-what { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bit-sees-bar { height: 5px; background: rgba(255, 255, 255, .12); border-radius: 3px; overflow: hidden; }
.bit-sees-bar i { display: block; height: 100%; background: currentColor; }
.bit-sees-pct { text-align: right; }
.bit-sees-why { margin: 8px 0 2px; }
.bit-sees-foot { margin: 0; opacity: .55; }

/* ---------- snacks ---------- */
.bit-shelf { position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 64; display: flex; align-items: center; gap: 8px; padding: 8px 10px; background: rgba(14, 12, 10, .94); border: 1px solid rgba(255, 255, 255, .16); border-radius: 10px; color: #f0ebe2; font: 12px/1 "JetBrains Mono", monospace; }
.bit-snack { padding: 6px 8px; background: #2a2622; color: inherit; border: 1px solid rgba(255, 255, 255, .2); border-radius: 6px; cursor: grab; font: inherit; touch-action: none; }
.bit-snack.is-tossed { animation: bit-toss .4s ease-out; }
.bit-shelf-x { background: none; border: 0; color: inherit; cursor: pointer; font: inherit; }
@keyframes bit-toss { to { translate: 0 -40px; opacity: .2; } }

/* ---------- out on the page: the real Bit away from its roof or corner, and every copy ---------- */
.mx-roam { position: absolute; left: 0; top: 0; width: 0; height: 0; z-index: 44; pointer-events: none; }
.mx-bit[data-mode="roam"] { left: 0; top: 0; width: 84px; height: 78px; --mx-c: 78px; --mx-b: 0px; z-index: 1; transition: opacity .25s ease; }
.mx-bit.mx-clone { width: 70px; height: 66px; --mx-c: 66px; }
@media (max-width: 759px), (pointer: coarse) {
  .mx-bit[data-mode="roam"] { width: 64px; height: 60px; --mx-c: 60px; }
  .mx-bit.mx-clone { width: 56px; height: 52px; --mx-c: 52px; }
}
.mx-bit[data-mode="roam"][data-hidden="1"] { opacity: 0; visibility: hidden; pointer-events: none; transition: opacity .25s ease, visibility 0s .25s; }
/* only the orb itself takes the pointer, so the empty corners of the box never block the page */
.mx-hit { position: absolute; left: 50%; bottom: calc(var(--mx-b) + var(--mx-c) * 0.12); width: calc(var(--mx-c) * 0.64); height: calc(var(--mx-c) * 0.64); translate: -50% 0; border-radius: 50%; }
.mx-bit[data-mode="roam"] .mx-sprite { pointer-events: none; }
.mx-bit[data-mode="roam"] .mx-hit { pointer-events: auto; cursor: grab; }
.mx-bit[data-mode="roam"][data-held] .mx-hit { cursor: grabbing; }
/* half hidden behind the edge of something */
.mx-bit[data-peek] .mx-sprite { transition: clip-path .35s ease; }
.mx-bit[data-peek="l"] .mx-sprite { clip-path: inset(-40% 50% -10% -40%); }
.mx-bit[data-peek="r"] .mx-sprite { clip-path: inset(-40% -40% -10% 50%); }
.mx-bit[data-mode="roam"] .mx-stack { left: var(--mx-bx, -60px); right: auto; }
.mx-bit[data-mode="roam"] .mx-balloon::after { left: var(--mx-ax, 84px); right: auto; }
/* a copy: same orb in one colour, with its name underneath */
.mx-clone .mx-ph { background: radial-gradient(circle at 36% 30%, #fff 0, var(--mx-tone) 46%, color-mix(in srgb, var(--mx-tone) 62%, #000) 100%); }
.mx-clone .mx-sprite:focus-visible { outline-color: var(--mx-tone); }
.mx-clone.is-in { animation: mx-in .45s cubic-bezier(.2, 1.4, .4, 1); }
@keyframes mx-in { from { scale: .2; opacity: 0; } }
.mx-tag { position: absolute; left: 50%; top: 100%; translate: -50% 0; padding: 2px 6px; background: rgba(14, 12, 10, .9); color: var(--mx-tone); font: 11px/1.2 "JetBrains Mono", monospace; border-radius: 4px; opacity: 0; transition: opacity .15s; pointer-events: none; white-space: nowrap; }
.mx-clone .mx-sprite:hover .mx-tag, .mx-clone .mx-sprite:focus-visible .mx-tag { opacity: 1; }
.mx-clone .mx-balloon { border-color: color-mix(in srgb, var(--mx-tone) 70%, transparent); }
.mx-clone .mx-balloon::after { border-color: color-mix(in srgb, var(--mx-tone) 70%, transparent); }
.mx-who { display: block; margin-bottom: 2px; color: var(--mx-tone, var(--mx-ac)); }
.mx-ask { margin: 8px 0 0; }
.mx-ask input { width: 100%; box-sizing: border-box; padding: 5px 7px; background: #1e1b18; border: 1px solid rgba(255, 255, 255, .18); border-radius: 5px; color: inherit; font: inherit; }
.mx-ask input:focus-visible { outline: 2px solid var(--mx-tone, var(--mx-ac)); outline-offset: 1px; }
/* what Bit hands over: a link it carried to the visitor */
.mx-gift { display: inline-block; margin-top: 4px; padding: 3px 8px; border: 1px solid var(--mx-ac); border-radius: 6px; color: var(--mx-ac); text-decoration: none; }
.mx-gift:hover, .mx-gift:focus-visible { background: var(--mx-ac); color: #141414; }
@media (prefers-reduced-motion: reduce) {
  .mx-clone.is-in, .mx-emote { animation: none; }
  .mx-bit[data-peek] .mx-sprite { transition: none; }
  .mx-emote { opacity: 1; }
}

/* ---------- duo: the folding handheld ---------- */
html[data-duo="1"] { overflow: hidden; }
.bd-stage { position: fixed; inset: 0; z-index: 1000; display: grid; place-items: center; padding: 20px; background: radial-gradient(circle at 50% 38%, #24201c, #0a0908 72%); font: 13px/1.4 "JetBrains Mono", monospace; color: #f0ebe2; }
.bd-device { position: relative; display: grid; grid-template-rows: auto 18px auto; width: min(460px, 100%); padding: 12px; background: #26231f; border: 1px solid #3a352e; border-radius: 18px; box-shadow: 0 30px 60px rgba(0, 0, 0, .55), inset 0 1px 0 rgba(255, 255, 255, .08); transition: transform .45s cubic-bezier(.3, .9, .3, 1); }
.bd-half { background: #1b1916; border-radius: 10px; padding: 10px; }
.bd-glass { border-radius: 6px; border: 1px solid #000; }
.bd-mirror { display: flex; flex-direction: column; height: min(38vh, 300px); background: #0d120e; color: #b6e8c4; }
.bd-mirror-lines { flex: 1; overflow: hidden auto; padding: 8px; font-size: 11.5px; }
.bd-mirror-line { min-height: 1em; white-space: pre-wrap; overflow-wrap: anywhere; }
.bd-mirror-form { border-top: 1px solid #243028; }
.bd-mirror-input { width: 100%; box-sizing: border-box; padding: 6px 8px; background: transparent; border: 0; color: inherit; font: inherit; outline: none; }
.bd-hinge { position: relative; align-self: center; height: 8px; margin: 0 24px; background: linear-gradient(#3a352e, #1a1815); border-radius: 4px; }
.bd-led { position: absolute; top: 2px; left: 50%; width: 5px; height: 4px; border-radius: 2px; background: var(--ac, #ff4655); }
.bd-life { position: relative; height: min(24vh, 180px); background: #f2ecdf; overflow: hidden; }
.bd-pet { position: absolute; left: 0; bottom: 10px; width: 64px; height: 64px; border-radius: 50%; background: radial-gradient(circle at 34% 28%, #fff, #dbd5c8 76%); translate: var(--px, 10px) 0; transition: translate 1.2s cubic-bezier(.45, .05, .3, 1), filter .3s; display: flex; align-items: center; justify-content: center; gap: 12px; }
.bd-pet i { width: 8px; height: 16px; border-radius: 5px; background: #16161a; }
.bd-pet[data-mood="tired"] i { height: 5px; }
.bd-pet[data-mood="bright"] { filter: saturate(1.3); }
.bd-pet[data-mood="blue"] { filter: brightness(.9); }
.bd-pet.is-hop { animation: bd-hop .5s ease-out; }
.bd-pet.is-nap i { height: 3px; }
@keyframes bd-hop { 40% { transform: translateY(-34px); } }
.bd-pet-say { position: absolute; left: 10px; right: 10px; top: 8px; margin: 0; color: #2a2622; font-size: 12px; }
.bd-panel { margin-top: 10px; display: grid; gap: 6px; }
.bd-meter { display: grid; grid-template-columns: 60px 1fr; align-items: center; gap: 8px; font-size: 11.5px; }
.bd-meter-bar { height: 6px; background: #3a352e; border-radius: 3px; overflow: hidden; }
.bd-meter-fill { display: block; height: 100%; background: var(--ac, #ff4655); transition: width .3s; }
.bd-buttons { display: flex; gap: 8px; margin-top: 2px; }
.bd-btn { flex: 1; padding: 7px 0; background: #2f2b26; color: inherit; border: 1px solid #4a433a; border-radius: 6px; cursor: pointer; font: inherit; }
.bd-btn:hover { border-color: var(--ac, #ff4655); }
.bd-x, .bd-foldbtn { position: fixed; top: 14px; right: 14px; background: #2f2b26; color: #f0ebe2; border: 1px solid #4a433a; border-radius: 6px; padding: 6px 10px; cursor: pointer; font: inherit; }
.bd-foldbtn { right: 60px; }
.bd-closed { display: none; }
.bd-stage[data-folded="1"] .bd-device { grid-template-rows: 1fr; width: 280px; }
.bd-stage[data-folded="1"] .bd-half, .bd-stage[data-folded="1"] .bd-hinge { display: none; }
.bd-stage[data-folded="1"] .bd-closed { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; height: 150px; cursor: pointer; }
.bd-closed-mark { font-weight: 700; letter-spacing: .1em; color: var(--ac, #ff4655); }
.bd-closed-hint { opacity: .6; font-size: 11px; }
@media (prefers-reduced-motion: reduce) { .bd-device, .bd-pet { transition: none; } .bd-pet.is-hop { animation: none; } }

/* a copy glows in its own colour, past the edge of its canvas */
.mx-clone .mx-sprite::before { content: ""; position: absolute; left: 50%; bottom: calc(var(--mx-b) - var(--mx-c) * .3); width: calc(var(--mx-c) * 1.6); height: calc(var(--mx-c) * 1.6); translate: -50% 0; z-index: -1; border-radius: 50%; pointer-events: none; background: radial-gradient(circle, color-mix(in srgb, var(--mx-tone) 26%, transparent) 0%, color-mix(in srgb, var(--mx-tone) 12%, transparent) 30%, color-mix(in srgb, var(--mx-tone) 4%, transparent) 52%, transparent 68%); animation: mx-halo 6s ease-in-out infinite; }
@keyframes mx-halo { 0%, 100% { opacity: .8; scale: .98; } 50% { opacity: 1; scale: 1.02; } }
@media (prefers-reduced-motion: reduce) { .mx-clone .mx-sprite::before { animation: none; opacity: .85; } }

/* voice: a small speaker on each balloon; it lights while Bit is speaking */
.mx-voice {
  position: absolute; top: 4px; right: 4px; width: 16px; height: 16px; padding: 0; border: 0; border-radius: 4px;
  background: transparent; color: inherit; opacity: 0.45; cursor: pointer;
}
.mx-voice::before {
  content: ''; position: absolute; inset: 3px;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 10'%3E%3Cpath d='M1 3.5h2l2.5-2v7L3 6.5H1z'/%3E%3Cpath d='M7 3a3 3 0 0 1 0 4' stroke='%23000' fill='none'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 10'%3E%3Cpath d='M1 3.5h2l2.5-2v7L3 6.5H1z'/%3E%3Cpath d='M7 3a3 3 0 0 1 0 4' stroke='%23000' fill='none'/%3E%3C/svg%3E") center / contain no-repeat;
}
html:not(.bit-voice-on) .mx-voice::after {
  content: ''; position: absolute; left: 2px; right: 2px; top: 7px; height: 1.5px; background: currentColor; transform: rotate(-45deg);
}
.mx-voice:hover, .mx-voice:focus-visible { opacity: 1; }
.mx-voice:focus-visible { outline: 1px solid var(--mx-ac, #ff4655); outline-offset: 1px; }
.bit-voice-on .mx-voice { opacity: 0.8; }
.mx-speaking .mx-voice { opacity: 1; color: var(--mx-tone, var(--mx-ac, #ff4655)); animation: mx-voice-pulse 0.9s ease-in-out infinite; }
.mx-speaking .mx-balloon { box-shadow: 0 0 0 1px color-mix(in srgb, var(--mx-tone, var(--mx-ac, #ff4655)) 55%, transparent); }
@keyframes mx-voice-pulse { 50% { opacity: 0.55; } }
@media (prefers-reduced-motion: reduce) { .mx-speaking .mx-voice { animation: none; } }
.mx-balloon:has(> .mx-voice) { padding-right: 24px; }
