/* UI Lab page: open button, caption, and the "about this study" dialog. */
.lab-open { position: absolute; top: 12px; right: 12px; z-index: 2; width: 32px; height: 32px; padding: 0; border: 0; border-radius: 8px; background: #4a4a4a; color: #fff; display: grid; place-items: center; cursor: pointer; }
.lab-open svg { display: block; }
.lab-open:hover { background: #5c5c5c; }
.lab-open:focus-visible, .lab-name:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.lab-name { margin: 0; padding: 0; border: 0; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.lab-name:hover { color: var(--text); }

html.lab-modal-open { overflow: hidden; }

/* the viewer: one screen, the study on the left and everything about it on the right */
.lab-modal {
  position: fixed; inset: 0; z-index: 1000; padding: 12px; gap: 12px;
  display: grid; grid-template-columns: minmax(0, 1fr) 400px;
  background: var(--bg, #0a0a0a); color: var(--text, #fff);
  animation: lm-fade .2s ease-out;
}
.lm-stage { position: relative; min-width: 0; min-height: 0; border-radius: 24px; overflow: hidden; background: #000; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .1); }
.lm-stage iframe { position: absolute; left: 0; top: 0; width: 100%; height: 100%; border: 0; background: transparent; transform-origin: 0 0; }
.lm-panel {
  display: flex; flex-direction: column; min-width: 0; min-height: 0;
  background: var(--card-2, #141414); border-radius: 24px; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .1);
  overflow: hidden; animation: lm-in .34s cubic-bezier(.22, 1, .36, 1);
}
.lm-head { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 18px 6px 24px; }
.lm-head h2 { margin: 0; font-size: 22px; line-height: 28px; font-weight: 500; letter-spacing: -.02em; }
.lm-close { flex: none; width: 36px; height: 36px; border: 0; border-radius: 50%; background: rgba(255, 255, 255, .1); color: #fff; display: grid; place-items: center; cursor: pointer; }
.lm-close:hover { background: rgba(255, 255, 255, .18); }
.lm-close:focus-visible, .lm-reset:focus-visible, .lm-s input:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.lm-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 0 24px 24px; }
.lm-sec { margin-top: 20px; }
.lm-sec:first-child { margin-top: 12px; }
.lm-sec h3 { margin: 0 0 4px; font-size: 14px; line-height: 20px; font-weight: 500; letter-spacing: 0; color: #fff; }
.lm-sec p { margin: 0; font-size: 15px; line-height: 23px; color: rgba(255, 255, 255, .68); text-wrap: pretty; }
.lm-set { margin-top: 28px; padding-top: 24px; border-top: 1px solid rgba(255, 255, 255, .1); }
.lm-sec.lm-set h3 { font-size: 18px; line-height: 26px; letter-spacing: -.015em; }
.lm-set-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 30px; }
.lm-set-head h3 { margin-bottom: 0 !important; }
.lm-reset { padding: 4px 12px; border: 0; border-radius: 999px; background: rgba(255, 255, 255, .1); color: #fff; font: inherit; font-size: 13px; line-height: 20px; cursor: pointer; }
.lm-reset:hover { background: rgba(255, 255, 255, .18); }
.lm-reset[hidden] { display: none; }
.lm-sec p.lm-tip { margin-top: 6px; font-size: 13px; line-height: 19px; color: var(--muted, rgba(255, 255, 255, .5)); }
.lm-controls { margin-top: 16px; display: flex; flex-direction: column; gap: 10px; }
.lm-row { margin: 0; padding: 14px 16px 16px; border-radius: 16px; background: rgba(255, 255, 255, .05); display: grid; gap: 10px; min-width: 0; }
.lm-row h4 { margin: 0; font-size: 15px; line-height: 20px; font-weight: 500; letter-spacing: -.005em; color: #fff; }
.lm-s { display: grid; grid-template-columns: 1fr auto; row-gap: 6px; align-items: baseline; }
.lm-s input { grid-column: 1 / -1; }
.lm-cap { font-size: 13px; line-height: 18px; letter-spacing: 0; color: var(--muted, rgba(255, 255, 255, .5)); }
.lm-out { font-size: 13px; line-height: 18px; color: rgba(255, 255, 255, .86); font-variant-numeric: tabular-nums; }
.lm-row-one { grid-template-columns: 1fr auto; align-items: baseline; row-gap: 10px; }
.lm-row-one .lm-s { display: contents; }
.lm-row-one .lm-cap { display: none; }
.lm-row-one .lm-s input { grid-column: 1 / -1; }

/* slider: a thin track that fills, a round thumb */
.lm-s input[type="range"] { -webkit-appearance: none; appearance: none; width: 100%; height: 20px; margin: 0; background: transparent; cursor: pointer; --fill: 50%; }
.lm-s input[type="range"]::-webkit-slider-runnable-track { height: 4px; border-radius: 2px; background: linear-gradient(to right, #fff var(--fill), rgba(255, 255, 255, .18) var(--fill)); }
.lm-s input[type="range"]::-moz-range-track { height: 4px; border-radius: 2px; background: rgba(255, 255, 255, .18); }
.lm-s input[type="range"]::-moz-range-progress { height: 4px; border-radius: 2px; background: #fff; }
.lm-s input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; margin-top: -7px; border-radius: 50%; background: #fff; border: 0; box-shadow: 0 1px 4px rgba(0, 0, 0, .4); }
.lm-s input[type="range"]::-moz-range-thumb { width: 18px; height: 18px; border-radius: 50%; background: #fff; border: 0; box-shadow: 0 1px 4px rgba(0, 0, 0, .4); }

@keyframes lm-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes lm-in { from { opacity: 0; transform: translateX(24px); } to { opacity: 1; transform: none; } }

/* narrow screens: the study on top, the panel below it */
@media (max-width: 900px) {
  .lab-modal { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 52fr) minmax(0, 48fr); padding: 8px; gap: 8px; }
  .lm-stage, .lm-panel { border-radius: 20px; }
  .lm-panel { animation: none; }
  .lm-head { padding: 14px 14px 4px 20px; }
  .lm-body { padding: 0 20px 20px; }
}
@media (prefers-reduced-motion: reduce) {
  .lab-modal, .lm-panel { animation: none; }
}

/* The name and the short hint live inside the card, bottom left. The open button stays top right. */
.lab-label { position: absolute; left: 20px; right: 20px; bottom: 16px; z-index: 2; display: flex; flex-direction: column; align-items: flex-start; gap: 1px; pointer-events: none; }
.lab-label .lab-name { pointer-events: auto; max-width: 100%; font-size: 16px; line-height: 22px; font-weight: 500; letter-spacing: -.005em; color: rgba(255,255,255,.92); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; transition: color .2s; }
.lab-label .lab-name:hover { color: #fff; }
.lab-hint { max-width: 100%; font-size: 14px; line-height: 20px; color: rgba(255,255,255,.5); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
