/* E4: a readable, one-column study tray on Explorer's handheld canvas.
   Keep overlay positioning, native scrolling, focus and study state in the existing runtime. */
@layer ar-explorer-study-phone {
  html[data-ar-explorer-handheld] #study-tray-dialog {
    --study-unit: var(--ar-drawer-fit, 1);
    --study-gap: calc(12px * var(--study-unit));
    font-size: calc(15px * var(--study-unit)) !important;
    line-height: 1.45 !important;
    padding: var(--study-gap) !important;
    scroll-padding-block: var(--study-gap);
    overscroll-behavior: contain;
  }

  html[data-ar-explorer-handheld] #study-tray-dialog .study-tray-header {
    align-items: center;
    gap: var(--study-gap);
    padding-block-end: var(--study-gap);
    margin-block-end: var(--study-gap);
  }

  html[data-ar-explorer-handheld] #study-tray-dialog .study-tray-header .eyebrow {
    font-size: calc(11px * var(--study-unit)) !important;
    margin-block: 0 calc(3px * var(--study-unit));
  }

  html[data-ar-explorer-handheld] #study-tray-dialog h2 {
    font-size: calc(23px * var(--study-unit)) !important;
    line-height: 1.14 !important;
    margin: 0;
  }

  html[data-ar-explorer-handheld] #study-tray-dialog .study-tray-layout {
    grid-template-columns: minmax(0, 1fr) !important;
    gap: calc(15px * var(--study-unit)) !important;
  }

  html[data-ar-explorer-handheld] #study-tray-dialog .study-tray-layout > div {
    min-inline-size: 0;
  }

  html[data-ar-explorer-handheld] #study-tray-dialog .study-tray-field {
    margin-block-end: var(--study-gap);
  }

  html[data-ar-explorer-handheld] #study-tray-dialog label {
    font-size: calc(14px * var(--study-unit)) !important;
    line-height: 1.3 !important;
    margin-block-end: calc(5px * var(--study-unit));
  }

  html[data-ar-explorer-handheld] #study-tray-dialog :is(input,textarea) {
    box-sizing: border-box;
    max-inline-size: 100%;
    font-size: calc(16px * var(--study-unit)) !important;
    line-height: 1.4 !important;
    min-block-size: calc(44px * var(--study-unit)) !important;
    padding: calc(9px * var(--study-unit)) !important;
  }

  html[data-ar-explorer-handheld] #study-tray-dialog textarea {
    min-block-size: calc(88px * var(--study-unit)) !important;
  }

  html[data-ar-explorer-handheld] #study-tray-dialog :is(.study-tray-layout p, #study-tray-feedback, #study-copy-fallback p, #study-tray-confirm p) {
    font-size: calc(13px * var(--study-unit)) !important;
    line-height: 1.45 !important;
    margin-block: calc(6px * var(--study-unit)) 0;
  }

  html[data-ar-explorer-handheld] #study-tray-dialog .study-tray-layout > div + div {
    border-block-start: 1px solid currentColor;
    padding-block-start: var(--study-gap);
  }

  html[data-ar-explorer-handheld] #study-tray-dialog h3 {
    font-size: calc(17px * var(--study-unit)) !important;
    line-height: 1.2 !important;
    margin-block: 0 calc(5px * var(--study-unit));
  }

  html[data-ar-explorer-handheld] #study-tray-total {
    font-size: calc(12px * var(--study-unit)) !important;
  }

  html[data-ar-explorer-handheld] #study-tray-list {
    max-block-size: none !important;
    overflow: visible !important;
  }

  html[data-ar-explorer-handheld] #study-tray-list li {
    gap: calc(8px * var(--study-unit));
    padding-block: calc(6px * var(--study-unit));
  }

  html[data-ar-explorer-handheld] #study-tray-list li > span {
    min-inline-size: 0;
    overflow-wrap: anywhere;
    font-size: calc(14px * var(--study-unit)) !important;
  }

  html[data-ar-explorer-handheld] #study-tray-list li .ar-scripture-inline-reference {
    font-size: calc(14px * var(--study-unit)) !important;
    line-height: 1.3 !important;
  }

  html[data-ar-explorer-handheld] #study-tray-list small {
    font-size: calc(12px * var(--study-unit)) !important;
  }

  html[data-ar-explorer-handheld] #study-tray-dialog .study-tray-actions {
    flex-wrap: wrap;
    gap: calc(8px * var(--study-unit));
    margin-block-start: var(--study-gap);
    padding-block-start: var(--study-gap);
  }

  html[data-ar-explorer-handheld] #study-tray-dialog button {
    min-block-size: calc(44px * var(--study-unit)) !important;
    font-size: calc(13px * var(--study-unit)) !important;
    line-height: 1.25 !important;
    padding-inline: calc(11px * var(--study-unit)) !important;
    flex: 0 0 auto;
  }

  html[data-ar-explorer-handheld] #study-tray-dialog :is(button,input,textarea):focus-visible {
    outline: calc(2px * var(--study-unit)) solid currentColor;
    outline-offset: calc(2px * var(--study-unit));
  }
}
