.coco-layer {
  --coco-width: 128px;
  --coco-height: 138.667px;
  position: fixed;
  inset: 0;
  z-index: 120;
  pointer-events: none;
  overflow: clip;
  contain: layout style;
}

.coco-layer *, .coco-layer *::before, .coco-layer *::after { box-sizing: border-box; }
.coco-layer [hidden] { display: none !important; }
.coco-character {
  position: absolute;
  top: 0;
  left: 0;
  width: var(--coco-width);
  height: var(--coco-height);
  padding: 0;
  border: 0;
  border-radius: 40%;
  background: none;
  color: inherit;
  cursor: pointer;
  pointer-events: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  will-change: transform;
  transition: opacity .18s ease;
}
.coco-character:focus-visible { outline: 2px solid #4e746a; outline-offset: -15px; }
.coco-body, .coco-art { display: block; width: 100%; height: 100%; }
.coco-art { background-repeat: no-repeat; transform: scaleX(var(--coco-facing, 1)); }
.coco-layer[data-state="idle"]:not([data-still="true"]) .coco-body {
  animation: coco-breathe 4.5s ease-in-out infinite;
}
@keyframes coco-breathe { 50% { transform: translateY(-1px); } }

.coco-tracks { position: absolute; inset: 0; pointer-events: none; transition: opacity .18s ease; }
.coco-layer[data-reading="true"] .coco-tracks { opacity: 0; }
.coco-track {
  position: absolute;
  width: 18px;
  height: 22px;
  color: #79614c;
  opacity: 0;
  pointer-events: none;
  animation: coco-track-fade 16s linear forwards;
}
.coco-track svg {
  display: block;
  width: 100%;
  height: 100%;
  fill: currentColor;
  stroke: #fffaf3;
  stroke-width: .7;
  stroke-linejoin: round;
  paint-order: stroke fill;
}
@keyframes coco-track-fade {
  0%, 50% { opacity: .5; }
  100% { opacity: 0; }
}

.coco-controls {
  position: absolute;
  bottom: 10px;
  right: 18px;
  pointer-events: auto;
  font: 11px/1.5 'Noto Sans JP', sans-serif;
  color: #75695d;
}
.coco-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border: 1px solid rgba(117, 105, 93, .18);
  border-radius: 20px;
  background: rgba(255, 250, 243, .88);
  color: inherit;
  font: inherit;
  cursor: pointer;
  backdrop-filter: blur(8px);
}
.coco-toggle svg { width: 12px; height: 14px; fill: currentColor; }
.coco-toggle:hover { color: #3b5e55; border-color: #4e746a; }
.coco-menu {
  position: absolute;
  right: 0;
  bottom: 38px;
  width: 146px;
  padding: 6px;
  border: 1px solid #d5cbbf;
  border-radius: 10px;
  background: #fffaf3;
  box-shadow: 0 4px 18px rgba(59, 43, 24, .1);
}
.coco-menu button {
  display: block;
  width: 100%;
  padding: 9px;
  border: 0;
  border-radius: 6px;
  background: none;
  color: #2f2924;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.coco-menu button:hover { background: #e4efeb; }
.coco-layer button:focus-visible { outline: 2px solid #4e746a; }
.coco-layer[data-keyboard="true"] { visibility: hidden; }

.coco-preview {
  position: absolute;
  top: 16px;
  left: 16px;
  width: 260px;
  padding: 16px;
  border: 1px solid #d5cbbf;
  border-radius: 12px;
  background: rgba(255, 250, 243, .96);
  color: #2f2924;
  box-shadow: 0 8px 32px rgba(59, 43, 24, .1);
  pointer-events: auto;
  font: 12px/1.7 'Noto Sans JP', sans-serif;
  backdrop-filter: blur(10px);
}
.coco-preview summary { cursor: pointer; font-weight: 700; }
.coco-preview p { margin: 12px 0; font-size: 11px; color: #75695d; }
.coco-preview-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.coco-preview button {
  padding: 6px 9px;
  border: 1px solid #d5cbbf;
  border-radius: 6px;
  background: #fffaf3;
  color: #3b5e55;
  font: inherit;
  cursor: pointer;
}
.coco-preview button:hover { background: #e4efeb; }
.coco-preview-status { display: block; margin-top: 12px; color: #75695d; }

@media (max-width: 767px), (pointer: coarse) {
  .coco-layer { --coco-width: 92px; --coco-height: 99.667px; }
  .coco-controls { right: 12px; bottom: max(8px, env(safe-area-inset-bottom)); }
  .coco-preview { top: 10px; left: 10px; width: 230px; padding: 12px; }
}
@media (pointer: coarse) {
  .coco-character { transition: transform .4s ease, opacity .18s ease; }
}
@media (prefers-reduced-motion: reduce) {
  .coco-body { animation: none !important; }
  .coco-character { transition: none; }
  .coco-track { display: none; }
}
