/* r20: two segmented rows (Held, Market cap), no knobs; Borrow always sits over the Max tick. r19 had three. Lab-only: from 768 px the panel is its own row under the shell; below that it follows the panels in the page.
   Scale: type 14 (labels, buttons, ideas) and 14/600 (legends). Gaps 4 / 8 / 16 / 32. Radii 16 (card), 999 (controls).
   emil-ui-polish: constant weight across states, press 0.97, touch 44 on coarse pointers. */
.lab {
  display: flex; flex-direction: column; gap: 16px;
  padding: 16px; border-radius: 16px; isolation: isolate;
  background: oklch(var(--surface-raised)); box-shadow: var(--shadow-raised);
  font-size: 14px; line-height: 20px; color: oklch(var(--ink));
  -webkit-tap-highlight-color: transparent;
}
.dark .lab { background: oklch(var(--surface-card)); box-shadow: inset 0 0 0 1px oklch(var(--ink) / 0.1), 0 12px 32px -12px oklch(0 0 0 / 0.6); }
@media (min-width: 1200px) {
  .stage > .shell-chart { grid-column: 1; grid-row: 1; }
  .stage > section[aria-label="Leverage panel"] { grid-column: 2; grid-row: 1; }
  .stage > section[aria-label="Borrow panel"] { grid-column: 3; grid-row: 1; }
}
@media (min-width: 768px) { .stage > .lab { grid-column: 1 / -1; grid-row: 2; } }

/* the rows: stacked on a phone, two across from 768, four across from 1200 */
.lab-rows { display: grid; grid-template-columns: 1fr; gap: 16px; align-items: start; }
@media (min-width: 768px) { .lab-rows { grid-template-columns: 1fr 1fr; column-gap: 32px; } }
@media (min-width: 1200px) { .lab-rows { grid-template-columns: repeat(4, 1fr); } } /* r42: four rows, one line */
.lab-group { display: flex; flex-direction: column; gap: 8px; margin: 0; padding: 0; border: 0; min-width: 0; }
.lab-group legend { padding: 0; margin-bottom: 8px; font-weight: 600; }
.lab-idea { margin: 0; color: oklch(var(--ink-muted)); text-wrap: pretty; }

/* a segmented capsule, as the held modes */
.lab-modes { display: flex; flex-wrap: wrap; padding: 2px; border-radius: 18px;
  box-shadow: inset 0 0 0 1px oklch(var(--line)); }
.dark .lab-modes { box-shadow: inset 0 0 0 1px oklch(var(--ink) / 0.1); }
.lab button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
.lab-modes button { flex: 1 0 auto; height: 32px; padding: 0 10px; border-radius: 999px; color: oklch(var(--ink-muted)); font-weight: 500;
  transition: background-color 150ms ease-out, color 150ms ease-out; white-space: nowrap; }
.lab-modes button[aria-pressed="true"] { background: oklch(var(--surface-thumb)); color: oklch(var(--ink)); box-shadow: var(--cap-lift); }
.dark .lab-modes button[aria-pressed="true"] { background: oklch(var(--ink) / 0.12); }
@media (hover: hover) { .lab-modes button:not([aria-pressed="true"]):hover { color: oklch(var(--ink)); background: oklch(var(--ink) / 0.045); } }

@media (pointer: coarse) { .lab-modes button { height: 44px; } }
.lab :focus-visible { outline: 2px solid oklch(var(--select)); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { .lab * { transition: none !important; } }
/* r17 look: the page's floating toolbar (bottom right) sat over the panel's last row; the stage ends with room for it */
.stage { padding-bottom: 88px; }
/* r31: the toolbar floats top right (lab.js), its 44 px button 20 px in, over the page's empty top margin: on a phone
   the panels start 48 px down, beside the first caption; a short laptop window (1280 x 720) keeps 48 px.
   r31b (critic: at 390 x 664, scrolled to the end, it sat on Borrow's "32.00%"): a fixed band of the canvas runs under
   it, opaque to 68 px and gone by 80, so the page scrolls under the band, never under the button. It is tied to the
   scroll: invisible at rest (it hides nothing there), fully in by 40 px of scroll, so the first caption fades as it
   rises under it. No timer: the browser runs it on scroll. Clicks pass through it */
body::before {
  content: ""; position: fixed; inset: 0 0 auto; height: 80px; z-index: 10; pointer-events: none;
  background: linear-gradient(oklch(var(--surface-canvas)) 68px, oklch(var(--surface-canvas) / 0));
}
@supports (animation-timeline: scroll()) {
  /* r42: a page that does not scroll (390 x 844 once the lab docks) has an inactive timeline, which left the band opaque over
     the first caption ("Leverage" hidden at 390); at rest it is out, and only a scroll brings it in */
  body::before { opacity: 0; animation: lab-band linear both; animation-timeline: scroll(root block); animation-range: 0 40px; }
  @media (max-width: 767px) { .stage { padding-top: 48px; } }
  @media (min-width: 1200px) { .stage { padding-top: clamp(48px, calc((100dvh - 670px) / 2), 96px); } }
}
@keyframes lab-band { from { opacity: 0; } to { opacity: 1; } }
/* without scroll timelines the band is always in, so the stage starts below it */
@supports not (animation-timeline: scroll()) {
  .stage { padding-top: 80px; }
  @media (min-width: 1200px) { .stage { padding-top: clamp(80px, calc((100dvh - 670px) / 2), 96px); } }
}

/* studio fix 11-22: below 768 the lab card matches the panel (it ran 35 px wider than the 360 card, past the column) */
@media (max-width: 767px) { .stage > .lab { width: 100%; max-width: 360px; justify-self: start; } }

/* r40 (look.py on A: the card ran past the window's bottom at 390 and 768, cut mid-row). Below 1200 the card docks 16 px
   above the window's bottom, so it is never cut: closed (r42), the one Options button; open, every row,
   in a sheet that scrolls inside the window. The stage keeps room under its last panel for the closed dock (92 px, 104 on
   a coarse pointer, + 16 + 16). Gaps 8 / 16, radii 16 / 999, type 14: the card's own scale */
.lab-more { flex: none; height: 32px; padding: 0 12px; border-radius: 999px; color: oklch(var(--ink-muted)); font-weight: 500;
  box-shadow: inset 0 0 0 1px oklch(var(--line)); transition: background-color 150ms ease-out, color 150ms ease-out; }
.dark .lab-more { box-shadow: inset 0 0 0 1px oklch(var(--ink) / 0.1); }
@media (hover: hover) { .lab-more:hover { color: oklch(var(--ink)); background: oklch(var(--ink) / 0.045); } }
@media (pointer: coarse) { .lab-more { height: 44px; } }
@media (min-width: 1200px) { .lab-more { display: none; } }
@media (max-width: 1199px) {
  .stage { padding-bottom: 96px; }
  .stage > .lab {
    position: fixed; z-index: 20; inset: auto 16px calc(16px + env(safe-area-inset-bottom, 0px)) 16px;
    width: auto; max-width: 560px; margin-inline: auto; max-height: calc(100dvh - 96px); overflow: auto; overscroll-behavior: contain;
    flex-direction: row; align-items: flex-end; gap: 8px;
  }
  /* r42: with the Controls row gone the round has no switch of its own, so the closed dock is the one Options button at the
     bottom right; open, the sheet holds every row */
  .lab:not([data-open]) { left: auto; padding: 8px; }
  .lab:not([data-open]) .lab-rows { display: none; }
  .lab[data-open] { flex-direction: column; align-items: stretch; gap: 16px; }
  /* open, Close sits first and stays in reach (sticky) while the sheet scrolls, on the card's own surface */
  .lab[data-open] .lab-more { order: -1; align-self: flex-end; position: sticky; top: 0; z-index: 1; background: oklch(var(--surface-raised)); }
  .dark .lab[data-open] .lab-more { background: oklch(var(--surface-card)); }
  .lab[data-open] { padding-top: 16px; }
}
/* r56 (look.py on R55 at 390x844: the fixed Options dock lay 11 px over the Borrow card's foot at load). Below 768, closed,
   the dock sits in the stage's own 96 px bottom room (absolute, not fixed), its top 8 px under the last card at any window
   height (40 px, 4 px round the 32 px button; 52 px on a coarse pointer); open, it is the fixed sheet as before */
@media (max-width: 767px) {
  .stage { position: relative; }
  .stage > .lab:not([data-open]) { position: absolute; inset: calc(100% - 88px) 16px auto auto; padding: 4px; }
}
