/* Body tools: a thin bar of two icon buttons down the stage's end edge — Layers (resting the mouse on it, or a
   click, opens its card beside it: body-tools.js) and the Cun ruler switch. Zoom is the wheel or a pinch, turning is
   a drag or the F B R L T S keys, and line thickness and background are in Settings. "Whole body" stays on screen.
   The bar turns dark with the dark background. */
.tools {
  --bt-card: #fff; --bt-tile: #f1f2f6; --bt-soft: var(--indigo-soft); --bt-ink: var(--ink); --bt-line: var(--line); --bt-acc: var(--indigo);
  position: absolute; inset-inline-end: 12px; top: 12px; z-index: 4; display: grid; gap: 4px; padding: 4px;
  background: color-mix(in srgb, var(--bt-card) 94%, transparent); backdrop-filter: blur(8px);
  border: 1px solid var(--bt-line); border-radius: 14px; box-shadow: 0 6px 24px #0000001a; color: var(--bt-ink);
}
[data-bg="dark"] :is(.tools, .home, .shr) { --bt-card: #141a28; --bt-tile: #1b2233; --bt-soft: #24304a; --bt-ink: #e8ebf2; --bt-line: #2a3248; --bt-acc: #8fb0ff; }
.stage { container-type: inline-size; } /* cards are sized by the stage (narrow in Study and Quiz) */
.stage .labels { z-index: 1; } /* its own stacking order, so 3D labels never draw over an open card */
.tools .g { position: relative; }
.tools:has(.g.show) { z-index: 7; } /* an open flyout draws over the channel chips that wrap under it */
.tools .cun-hint { position: absolute; top: 50px; inset-inline-end: calc(100% + 8px); width: max-content; max-width: 200px; margin: 0; padding: 7px 10px;
  border-radius: 10px; background: var(--bt-card); color: var(--bt-ink); border: 1px solid var(--bt-line); box-shadow: 0 6px 24px #0000002a; font-size: 12.5px; line-height: 1.35; }
.tools .cun-hint[hidden] { display: none; }
.tools .gb { display: grid; place-items: center; width: 40px; height: 40px; padding: 0; border: 0; border-radius: 10px; background: none; color: inherit; cursor: pointer; }
.tools .gb:hover, .tools .g.show .gb { background: var(--bt-soft); }
.tools .gb:focus-visible { outline: 2px solid var(--bt-acc); outline-offset: 1px; }
.tools .pic { width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; overflow: hidden; background: var(--bt-tile); }
.tools .tb[aria-pressed="true"] .pic { background: var(--bt-acc); color: #fff; }
.tools .sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.tools .pic img { width: 100%; height: 100%; object-fit: contain; }
#layerPic img { object-fit: cover; }
.tools svg.ic { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.tools .fly { position: absolute; top: -4px; inset-inline-end: calc(100% + 12px); width: min(300px, calc(100cqw - 120px)); padding: 12px; display: none;
  background: var(--bt-card); border: 1px solid var(--bt-line); border-radius: 18px; box-shadow: 0 10px 30px #0003; }
.tools .fly::before { content: ""; position: absolute; inset-block: 0; inset-inline-end: -16px; width: 16px; } /* bridge for the mouse */
.tools .g.show .fly { display: block; }
.tools .ft { margin: 0 0 8px; font-weight: 600; font-size: 14px; }


.tools .tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.tools .layers.tiles { grid-template-columns: repeat(4, 1fr); } /* Skin, Muscles, Bones, Organs in one row */
.tools .layers.tiles img { height: 64px; }
.tools .tiles > button { min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 6px 4px; border: 2px solid transparent; border-radius: 14px; background: var(--bt-tile); font: 500 12px/1.2 "Plus Jakarta Sans", system-ui, sans-serif; color: inherit; cursor: pointer; text-align: center; }
.tools .tiles > button:hover { border-color: var(--bt-line); }
.tools .tiles > button:is(.on, [aria-checked="true"]) { border-color: var(--bt-acc); background: var(--bt-soft); }
.tools .tiles img { width: 100%; height: 78px; object-fit: contain; }
.tools .layers img { height: 84px; object-fit: cover; border-radius: 10px; }

/* The open layer's styles (layer-toggle.js), the same choice as Settings; swatches are shared with Settings. */
.tools .bstyles { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 6px; font-size: 13px; }
.tools .bstyles[hidden] { display: none; }
.tools .bstyles > span { width: 100%; color: color-mix(in srgb, var(--bt-ink) 62%, transparent); }
.tools .bstyles button { display: flex; align-items: center; gap: 6px; padding: 4px 10px 4px 4px; padding-inline: 4px 10px; border: 1px solid var(--bt-line); border-radius: 999px; background: var(--bt-tile); font: inherit; color: inherit; cursor: pointer; }
.tools .bstyles button.on { border-color: var(--bt-acc); background: var(--bt-soft); }
.bstyles i { width: 20px; height: 20px; border-radius: 50%; box-shadow: inset 0 0 0 1px #0002; }


/* Whole body: centre the body, front view, full size — always on screen, as a quiet viewfinder icon
   (center-button-mockup.html, option 3); its name shows on hover and is read out. */
.home { position: absolute; bottom: 16px; inset-inline-end: 16px; z-index: 3; display: grid; place-items: center; width: 44px; height: 44px; padding: 0;
  border: 1px solid var(--bt-line, var(--line)); border-radius: 12px; background: color-mix(in srgb, var(--bt-card, #fff) 94%, transparent); backdrop-filter: blur(8px);
  color: var(--bt-ink, var(--ink)); box-shadow: 0 4px 14px #0000001f; cursor: pointer; transition: transform .12s, border-color .15s, color .15s; }
.home svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.home circle { fill: currentColor; stroke: none; }
.home:hover { border-color: var(--bt-acc, var(--indigo)); color: var(--bt-acc, var(--indigo)); }
.home:active { transform: scale(.94); }
.home:focus-visible { outline: 2px solid var(--bt-acc, var(--indigo)); outline-offset: 2px; }

/* Computers: Whole body sits under the body tools, Share under it (share.css) — the phone's order */
@media (min-width: 1025px) { .stage > .home[data-zoom="reset"] { top: 114px; bottom: auto; inset-inline-end: 12px; } }

/* Turning (view-turn.js): under Whole body; a camera while the camera moves, a person on blue while the body turns.
   Not over the flow film. Share and the Meridians search sit one place lower for it. */
.stage > .turn-btn { top: 166px; bottom: auto; inset-inline-end: 12px; }
.stage > .turn-btn circle { fill: none; stroke: currentColor; }
.stage > .turn-btn[aria-pressed="true"], .stage > .turn-btn[aria-pressed="true"]:hover { background: #4b5bdc; border-color: #4b5bdc; color: #fff; }
.stage:has(.flow-in) > .turn-btn { display: none; }
/* Reset view (d-orbit.html): under Turning, the same look; Share and the Meridians search one place lower again. */
.stage > .reset-btn { top: 218px; bottom: auto; inset-inline-end: 12px; }
.stage > .reset-btn path { fill: none; stroke: currentColor; }
.stage:has(.flow-in) > .reset-btn, .app.mer .stage > .reset-btn { display: none; } /* Meridians: nothing of Treatment's to reset (owner) */
/* Hide meridians (d-orbit.html): the Meridians page only, under the search; the eye crossed out while they are hidden. */
.stage > .threads-btn { display: none; }
.app.mer .stage:not(:has(.flow-in)) > .threads-btn { display: grid; top: 270px; bottom: auto; inset-inline-end: 12px; }
.stage > .threads-btn :is(path, circle) { fill: none; stroke: currentColor; }
.stage > .threads-btn .off { display: none; }
.stage > .threads-btn[aria-pressed="true"] .off { display: inline; }
.stage > .threads-btn[aria-pressed="true"], .stage > .threads-btn[aria-pressed="true"]:hover { background: #4b5bdc; border-color: #4b5bdc; color: #fff; }
@media (min-width: 1025px) { .stage:not(:has(.flow-in)) > .shr { top: 270px; } }

@media (max-width: 1024px) {
  .tools { inset-inline-end: 8px; top: 8px; padding: 3px; gap: 2px; }
  .tools .cun-hint { top: calc(100% + 6px); inset-inline-end: 0; } /* under the tools: the chip rows fill their side */
  .tools .tiles img { height: 60px; }
  .home { bottom: 10px; inset-inline-end: 10px; }
}

/* Meridians search (explorer.js initMerFind, option 5 of search-bar-mockups.html): a magnifier above Share turns into ✕
   and slides a slim search card out of the column; its note folds open under the field. */
.stage > .mfind-btn, .stage > .mfind { display: none; }
.app.mer .stage:not(:has(.flow-in)) > .mfind-btn { display: grid; top: 218px; bottom: auto; inset-inline-end: 12px; color: var(--bt-acc, var(--indigo)); }
.app.mer .stage:not(:has(.flow-in)) > .shr { top: 322px; }
.stage > .mfind-btn svg { width: 22px; height: 22px; stroke-width: 2.2; transition: rotate .3s, opacity .2s; }
.mfind-btn circle { fill: none; stroke: currentColor; } /* a lens, not the filled dot of the other .home icons */
.mfind-btn .mf-x { position: absolute; opacity: 0; rotate: -90deg; }
.app.mer-find .stage > .mfind-btn, .app.mer-find .stage > .mfind-btn:hover { background: #4b5bdc; border-color: #4b5bdc; color: #fff; }
.stage > .mfind-btn .mf-x { stroke-width: 2.8; }
.app.mer-find .mfind-btn .mf-s { opacity: 0; rotate: 90deg; }
.app.mer-find .mfind-btn .mf-x { opacity: 1; rotate: 0deg; }
.app.mer .stage:not(:has(.flow-in)) > .mfind { display: block; position: absolute; z-index: 5; top: 218px; inset-inline-end: 64px; width: 300px; padding: 3px;
  border: 1px solid var(--d-line, var(--line)); border-radius: 12px; background: var(--d-glass, #ffffffeb); backdrop-filter: blur(12px); box-shadow: 0 16px 40px #14182133;
  opacity: 0; translate: 16px 0; visibility: hidden; transition: opacity .2s, translate .3s cubic-bezier(.2,.9,.25,1), visibility 0s .3s; }
[dir="rtl"] .app.mer .stage > .mfind { translate: -16px 0; }
.app.mer.mer-find .stage:not(:has(.flow-in)) > .mfind { opacity: 1; translate: 0 0; visibility: visible; transition-delay: 0s; }
.mfind .psearch { margin: 0; }
.mfind .psearch input { min-height: 38px; border-radius: 10px; padding: 0 10px; font-size: 13px; }
.mfind .psearch-msg { margin: 6px 8px 2px; }
.mfind-note { margin: 0; padding: 0 8px; max-height: 0; overflow: hidden; opacity: 0; font-size: 11px; color: var(--muted);
  transition: max-height .35s ease .15s, opacity .25s ease .2s, padding .35s ease .15s; }
.app.mer-find .mfind-note { max-height: 40px; opacity: 1; padding: 7px 8px 5px; }
@media (prefers-reduced-motion: reduce) { .mfind, .mfind *, .mfind-btn svg { transition-duration: 0s !important; transition-delay: 0s !important; } }
/* Computers: with no channel picked the points panel held only the search, so it steps aside for the magnifier. */
@media (min-width: 1025px) {
  .app.app.mer:not(:has(.stage .flow-in)) > aside:has(> #merPanel.mer-idle) { display: none; }
  .app.mer:has(#merPanel.mer-idle) .stage:not(:has(.flow-in)) > #merList { display: none; }
}

/* tools-dim.js: the controls beside the body fade 4 s after the last touch; a touch lights them.
   A control in use stays lit: Turning on "body", the Meridians search, an open tools card. */
.stage > :is(.tools, .home, .shr, .mfind-btn) { transition: opacity .25s; } /* back quickly */
:root.tools-dim .stage > :is(.tools, .home, .shr, .mfind-btn) { opacity: .45; transition-duration: .6s; } /* out slowly */
:root.tools-dim .stage > :is(.turn-btn[aria-pressed="true"], .threads-btn[aria-pressed="true"], .tools:has(.g.show)),
:root.tools-dim .app.mer-find .stage > .mfind-btn,
:root.tools-dim .stage > :is(.tools, .home, .shr, .mfind-btn):is(:hover, :focus-visible) { opacity: 1; transition-duration: .1s; }
