/* STUDY (temporary): the popup for the Study block (public/study/study.js). */
html.study-is-open { overflow: hidden; }
.study-block { margin: 0; }
/* A window of its own: placed by script (left, top, width, height). */
.study-dialog {
  position: fixed; inset: auto; margin: 0; padding: 0; border: 1px solid var(--border); border-radius: 12px;
  max-width: none; max-height: none; background: var(--bg-elevated); color: var(--text); overflow: hidden; box-sizing: border-box;
}
/* Filling the screen, which is how it opens. */
.study-dialog.study-max { inset: 0; width: 100vw; height: 100vh; height: 100dvh; border: 0; border-radius: 0; }
.study-dialog[open] { display: flex; flex-direction: column; }
.study-dialog::backdrop { background: rgba(0, 0, 0, 0.85); }
.study-bar { display: flex; align-items: center; gap: 6px; padding: 6px 12px 6px 16px; border-bottom: 1px solid var(--border); flex: none; touch-action: none; }
.study-dialog:not(.study-max) .study-bar { cursor: move; }
.study-title { margin: 0; margin-right: auto; font-size: 1rem; line-height: 1.3; user-select: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.study-saved { font-size: 0.8rem; color: var(--text-dim); margin-right: 6px; user-select: none; white-space: nowrap; }
.study-saved[hidden], .study-tool[hidden] { display: none; }
.study-tool {
  display: grid; place-items: center; min-width: 44px; min-height: 44px; padding: 0 6px; border: 1px solid var(--border); border-radius: 22px;
  background: transparent; color: var(--text); font: inherit; font-size: 1.1rem; line-height: 1; cursor: pointer; flex: none;
}
.study-close { font-size: 1.6rem; }
.study-tool:hover { background: var(--border); }
.study-tool:focus-visible, .study-input:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.study-opening { margin: 0; padding: 24px 20px; color: var(--text-dim); }
.study-opening[hidden] { display: none; }
.study-gate { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; padding: 24px 20px; max-width: 420px; }
.study-lead { margin: 0 0 4px; color: var(--text-dim); }
.study-label { font-weight: 600; }
.study-input { width: 100%; min-height: 44px; padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); color: var(--text); font: inherit; box-sizing: border-box; }
.study-status { margin: 0; min-height: 1.4em; color: var(--text-dim); }
.study-stage { flex: 1 1 auto; min-height: 0; }
.study-stage[hidden], .study-gate[hidden] { display: none; }
.study-frame { display: block; width: 100%; height: 100%; border: 0; background: #10141b; }
/* The "close the study?" question, over everything else in the popup. */
.study-confirm { position: absolute; inset: 0; z-index: 3; display: grid; place-items: center; padding: 16px; background: rgba(0, 0, 0, 0.6); }
.study-confirm[hidden] { display: none; }
.study-confirm-box { max-width: 420px; padding: 20px; border: 1px solid var(--border); border-radius: 12px; background: var(--bg-elevated); color: var(--text); }
.study-confirm-box p { margin: 0 0 16px; line-height: 1.5; }
.study-confirm-actions { display: flex; flex-wrap: wrap; gap: 10px; }
/* While it is being moved or resized the study page must not swallow the pointer. */
.study-dragging { user-select: none; }
.study-dragging .study-frame { pointer-events: none; }
/* Edges and corners to grab (inside the window, so nothing is clipped). */
.study-handle { position: absolute; z-index: 2; touch-action: none; }
.study-handle-n, .study-handle-s { left: 12px; right: 12px; height: 8px; cursor: ns-resize; }
.study-handle-e, .study-handle-w { top: 12px; bottom: 12px; width: 8px; cursor: ew-resize; }
.study-handle-n { top: 0; } .study-handle-s { bottom: 0; } .study-handle-e { right: 0; } .study-handle-w { left: 0; }
.study-handle-ne, .study-handle-nw, .study-handle-se, .study-handle-sw { width: 14px; height: 14px; }
.study-handle-ne { top: 0; right: 0; cursor: nesw-resize; } .study-handle-sw { bottom: 0; left: 0; cursor: nesw-resize; }
.study-handle-nw { top: 0; left: 0; cursor: nwse-resize; } .study-handle-se { bottom: 0; right: 0; cursor: nwse-resize; }
.study-max .study-handle { display: none; }
/* A phone always gets the whole screen. */
@media (max-width: 640px) {
  .study-dialog { inset: 0 !important; left: 0 !important; top: 0 !important; width: 100vw !important; height: 100vh !important; height: 100dvh !important; border: 0 !important; border-radius: 0 !important; }
  .study-size, .study-handle, .study-saved { display: none !important; }
  .study-bar { padding-left: 12px; }
}
@media print { .study-dialog { display: none !important; } }
