/* 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) { --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 .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; }

/* Full view: phones only, over Whole body. */
.home.full { display: none; }
.home.full .fv-in, .home.full[aria-pressed="true"] .fv-out { display: none; }
.home.full[aria-pressed="true"] .fv-in { display: inline; }

@media (max-width: 860px) {
  .home.full { display: grid; bottom: 62px; }
  .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; }
}
