/* Keep the source and editable fields usable in the space available to the review. */
.dfr-root {
  container: document-review / inline-size;
  min-width: 0;
}
.dfr-app-shell > div:first-child { box-sizing: border-box; }

.dfr-root button:focus-visible,
.dfr-root input:focus-visible,
.dfr-root select:focus-visible {
  outline: 2px solid var(--teal-600) !important;
  outline-offset: 2px;
}

.dfr-root button:disabled {
  cursor: not-allowed !important;
}

.dfr-case-id,
.dfr-case-meta {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dfr-case-id { max-width: 29ch; }
.dfr-case-meta { max-width: 34ch; }
.dfr-case-avatar { flex: 0 0 auto; margin-left: 8px; }
.dfr-main { min-width: 0; }
.dfr-splitter { display: flex; flex: 0 0 14px; }
.dfr-splitter > div { width: 14px !important; background: var(--bg-surface-sunken) !important; touch-action: none; }
.dfr-splitter > div > span { width: 4px !important; height: 42px !important; background: var(--teal-500) !important; }
.dfr-splitter > div:hover { background: var(--teal-50) !important; }
.dfr-splitter > div:focus-visible { outline: 2px solid var(--teal-600); outline-offset: -2px; }
.dfr-field-list { min-height: 0; overscroll-behavior: contain; }
.dfr-document-tabs { overflow-y: hidden !important; scrollbar-width: thin; }
.dfr-document-tabs button { flex-shrink: 0; min-height: 56px; }
.dfr-document-tabs button > span:last-child {
  max-width: 245px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dfr-filters {
  flex-wrap: nowrap !important;
  overflow-x: auto;
  padding-bottom: 3px;
  scrollbar-width: thin;
}

.dfr-filters button { flex: 0 0 auto; min-height: 36px; }
.dfr-field-card { min-width: 0; }
.dfr-field-card input,
.dfr-field-card select { min-height: 42px; }
.dfr-field-card > div:first-child button { min-width: 36px; min-height: 36px; }
.dfr-field-card > div:nth-last-child(1) { overflow-wrap: anywhere; }
.dfr-document-finding-mobile { display: none; }
.dfr-case-actions { margin-top: 16px; }
.dfr-case-actions > span { overflow-wrap: anywhere; }
.dfr-document-actions { justify-content: flex-end; }
.dfr-save-feedback { flex: 1 0 100%; overflow-wrap: anywhere; }

@container document-review (max-width: 1100px) {
  .dfr-case-bar {
    flex-wrap: wrap;
    gap: 6px 10px !important;
    padding: 8px 16px !important;
  }

  .dfr-case-spacer { display: none; }
  .dfr-case-id,
  .dfr-case-divider,
  .dfr-flagged-count { display: none; }
  .dfr-case-meta { flex: 1 1 200px; }
  .dfr-fields-header { padding: 12px 16px 10px !important; }
  .dfr-document-actions { padding: 10px 16px !important; }
  .dfr-viewer-toolbar { padding: 8px 12px !important; }
}

@container document-review (max-width: 1100px) {
  .dfr-main { flex-direction: column; }
  .dfr-fields {
    width: 100% !important;
    height: var(--dfr-fields-height) !important;
    flex: 0 0 var(--dfr-fields-height);
    min-width: 0 !important;
    box-sizing: border-box;
    order: 1;
  }
  .dfr-splitter {
    flex: 0 0 14px;
    width: 100%;
    height: 14px;
    order: 2;
  }
  .dfr-splitter > div { width: 100% !important; height: 14px; cursor: row-resize !important; }
  .dfr-splitter > div > span { width: 42px !important; height: 4px !important; }
  .dfr-viewer {
    width: 100%;
    min-width: 0 !important;
    min-height: 0;
    order: 3;
  }
  .dfr-page-canvas { padding: 12px !important; }
  .dfr-page-sheet[data-fit-width="true"] { width: 100%; max-width: 100%; min-width: 0 !important; }
  .dfr-page-sheet[data-fit-width="true"] img { width: 100%; max-width: 100% !important; height: auto; }
  .dfr-viewer-toolbar[data-fit-width="true"] .dfr-zoom-level { display: none; }
  .dfr-case-id { max-width: 20ch; }
}

@container document-review (max-width: 500px) {
  .dfr-case-bar { padding: 6px 12px !important; gap: 3px 8px !important; }
  .dfr-case-id { display: none; }
  .dfr-case-meta { flex: 1 1 0; max-width: none; }
  .dfr-case-divider { display: none; }
  .dfr-flagged-count { display: none; }
  .dfr-document-tabs { padding: 0 8px !important; }
  .dfr-document-tabs button { padding: 7px 10px !important; }
  .dfr-document-tabs button > span:last-child { max-width: 170px; }
  .dfr-fields-header { padding: 8px 12px 6px !important; }
  .dfr-fields-header > div:first-child { align-items: center !important; }
  .dfr-fields-header > div:first-child > span:first-child { font-size: 18px !important; }
  .dfr-fields-header > div:first-child > span:last-child { font-size: 11px !important; white-space: nowrap; }
  .dfr-progress-bar { display: none; }
  .dfr-filters { margin-top: 6px !important; }
  .dfr-filters button { min-height: 44px; }
  .dfr-document-tabs,
  .dfr-filters { scrollbar-width: none; }
  .dfr-document-tabs::-webkit-scrollbar,
  .dfr-filters::-webkit-scrollbar { display: none; }
  .dfr-field-list { display: flex; flex-direction: column; }
  .dfr-field-group { order: 1; }
  .dfr-document-finding-mobile { order: 2; }
  .dfr-case-actions { order: 3; }
  .dfr-field-list > div:not(.dfr-case-actions) { padding-left: 12px !important; padding-right: 12px !important; }
  .dfr-document-finding { display: none; }
  .dfr-document-finding-mobile {
    display: block;
    margin: 8px 12px;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    background: var(--status-warning-bg);
    color: var(--status-warning-fg);
    font: var(--text-body-sm);
  }
  .dfr-document-finding-mobile summary {
    cursor: pointer;
    font: var(--text-label-sm);
    list-style-position: inside;
    padding: 4px 8px;
  }
  .dfr-document-finding-mobile p { margin: 8px 0 0; }
  .dfr-field-card { padding: 10px !important; }
  .dfr-field-path { display: none; }
  .dfr-field-card input,
  .dfr-field-card select { min-height: 44px; font-size: 16px !important; }
  .dfr-field-card > div:first-child button { min-width: 44px; min-height: 44px; }
  .dfr-case-actions { padding: 12px !important; }
  .dfr-case-actions > span { flex-basis: 100% !important; }
  .dfr-case-actions > button { width: 100%; justify-content: center; }
  .dfr-document-actions { padding: 8px 12px max(8px, env(safe-area-inset-bottom)) !important; }
  .dfr-document-actions > button { flex: 1 1 0; justify-content: center; min-width: 0; min-height: 44px; padding: 8px 6px !important; font-size: 12px !important; white-space: nowrap; }
  .dfr-thumbnails,
  .dfr-thumbnails-toggle { display: none !important; }
  .dfr-viewer-toolbar { padding: 6px 8px !important; gap: 5px !important; }
}

@media (max-width: 640px) {
  .dfr-app-shell > div:first-child { display: none !important; }
  .dfr-app-shell { height: 100dvh !important; }
}

@media (max-height: 540px) and (max-width: 1172px) {
  .dfr-root { height: auto !important; min-height: 100%; }
  @container document-review (max-width: 1100px) {
    .dfr-main { flex: none !important; min-height: 400px !important; }
    .dfr-fields { height: var(--dfr-fields-height) !important; }
    .dfr-viewer { height: max(260px, 65dvh) !important; }
  }
}
