/* The browser draws the track, thumb and buttons as one native control. */

/* The outer frame paints the border and clips the inner scroll region. */
.table-scroll, .table-preview {
  overflow: hidden;
}
.table-viewport {
  overflow: auto;
  max-width: 100%;
  max-height: inherit;
  min-width: 0;
}
.table-scroll > .table-viewport {
  max-height: none;
}

/* Keep the header and content in one scroll region inside the modal frame. */
#dialog[open] {
  display: grid;
  grid-template: minmax(0, 1fr) / minmax(0, 1fr);
  overflow: hidden;
}
.dialog-viewport {
  overflow: auto;
  overscroll-behavior: contain;
}
#dialog .modal-head {
  position: static;
}
.table-viewport:focus-visible, .dialog-viewport:focus-visible {
  outline-offset: -3px;
}

/* These scroll regions also draw their own rounded frame. */
.text-preview {
  clip-path: inset(0 round 8px);
}

html.modal-open {
  overflow: hidden;
}

/* The textarea scrolls flush with the inner edge of its clipped frame. */
.textarea-frame {
  display: block;
  overflow: hidden;
  border: 1px solid var(--control-border);
  border-radius: var(--radius-control);
  background: var(--surface);
}
.textarea-frame > textarea {
  display: block;
  width: 100%;
  border: 0;
  border-radius: 0;
  background: transparent;
}

/* Keep the focus indicator on the border of the active field. */
input:is([type=text], [type=search], [type=email], [type=password], [type=number],
         [type=url], [type=tel], [type=date], [type=time], :not([type])):focus,
select:focus, .textarea-frame:focus-within {
  border-color: var(--focus);
  outline: none;
}
.textarea-frame > textarea:focus {
  outline: none;
}
@media (forced-colors: active) {
  input:focus-visible, select:focus-visible, .textarea-frame:focus-within {
    outline: 1px solid Highlight;
    outline-offset: 1px;
  }
}

/* Paint a single border above the clipped scrolling area. */
:is(#dialog[open], .table-scroll, .table-preview, .textarea-frame, .calendar-dialog, .text-preview-frame, .check-list-frame) {
  isolation: isolate;
}
:is(.table-scroll,.table-preview,.textarea-frame,.text-preview-frame,.check-list-frame) {
  position: relative;
}
:is(#dialog[open], .table-scroll, .table-preview, .text-preview-frame, .check-list-frame)::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  border-radius: inherit;
  border: 1px solid var(--scroll-frame-line, transparent);
}
:is(#dialog, .table-preview, .panel.table-scroll, .listing > .table-scroll, .check-list-frame) {
  --scroll-frame-line: var(--line);
  border: 0;
}
.text-preview-frame {
  border-radius: 8px;
  overflow: hidden;
}
.text-preview-frame > .text-preview {
  margin: 0;
  border-radius: 0;
}
.check-list-frame {
  border-radius: 10px;
  overflow: hidden;
}
.check-list-frame > .check-list {
  border: 0;
  border-radius: 0;
}
