/* Final layers of the workbench stylesheet, moved out of styles.css verbatim.
   Load this file immediately after styles.css: the rules below rely on coming
   last in the cascade. They cover the feedback report overlay with its native
   modal and tab capture, the authenticated launcher, the Reader feedback
   inspector heading and the review decision chain. */

/* ScriptSaver feedback report overlay. */
.feedback-report-overlay {
  position: fixed;
  top: 8px;
  right: 0;
  z-index: 210;
  display: flex;
  align-items: center;
  transform: none;
}

.feedback-report-tab {
  display: flex;
  min-width: 44px;
  min-height: 44px;
  padding: 10px 12px;
  align-items: center;
  gap: 8px;
  border: 1px solid #264158;
  border-right: 0;
  border-radius: 4px 0 0 4px;
  background: #071523;
  color: #eef7ff;
  box-shadow: -4px 4px 18px rgb(7 21 35 / 18%);
  cursor: pointer;
  font: inherit;
  font-weight: 700;
}

.feedback-report-tab[aria-expanded="true"] {
  display: none;
}

/* A foreign native modal owns the complete interaction and attention boundary.
   Keep the shared launcher out of that boundary instead of competing with a
   dialog close control. The feedback panel is excluded because its own toggle
   already follows aria-expanded while that panel is open. */
body:has(dialog:modal:not(.feedback-report-panel)) .feedback-report-tab {
  visibility: hidden;
  pointer-events: none;
}

.feedback-report-tab:hover,
.feedback-report-tab:focus-visible,
.feedback-report-close:focus-visible,
.feedback-report-submit:focus-visible,
.feedback-report-secondary-action:focus-visible,
.feedback-report-capture-preview button:focus-visible,
.feedback-report-diagnostic-summary summary:focus-visible,
.feedback-report-diagnostics-choice input:focus-visible {
  border-color: #45d6bd;
  outline: 2px solid #45d6bd;
  outline-offset: 2px;
}

.feedback-report-panel {
  position: fixed;
  top: 16px;
  right: 0;
  left: auto;
  width: 440px;
  max-width: calc(100vw - 32px);
  height: calc(100vh - 32px);
  height: calc(100dvh - 32px);
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px);
  margin: 0;
  overflow: hidden;
  padding: 0;
  border: 1px solid #c8d4de;
  border-right: 0;
  background: #fff;
  box-shadow: -12px 16px 36px rgb(7 21 35 / 22%);
  color: #142638;
  transform: none;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.feedback-report-panel::backdrop {
  background: transparent;
}

.feedback-report-panel[hidden] {
  display: none;
}

.feedback-report-panel > header {
  display: flex;
  flex: 0 0 auto;
  padding: 18px 20px 14px;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid #d9e1e8;
}

.feedback-report-panel h2 {
  margin: 2px 0 0;
  font-size: 20px;
  line-height: 1.25;
}

.feedback-report-close {
  display: grid;
  width: 40px;
  min-width: 40px;
  min-height: 40px;
  padding: 0;
  place-items: center;
  border: 1px solid transparent;
  background: transparent;
  color: #294256;
  cursor: pointer;
}

.feedback-report-panel form {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.feedback-report-scroll-region {
  display: grid;
  flex: 1 1 auto;
  min-height: 0;
  padding: 18px 20px;
  gap: 9px;
  overflow: auto;
  overscroll-behavior: contain;
}

.feedback-report-form-footer {
  display: grid;
  padding: 10px 20px 20px;
  gap: 7px;
  border-top: 1px solid #d9e1e8;
  background: #fff;
}

.feedback-report-panel label {
  margin-top: 5px;
  color: #20384c;
  font-size: 13px;
  font-weight: 700;
}

.feedback-report-panel select,
.feedback-report-panel textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid #9eafbd;
  border-radius: 3px;
  background: #fff;
  color: #142638;
  font: inherit;
  font-size: 14px;
}

.feedback-report-panel select {
  min-height: 42px;
  padding: 8px 10px;
}

.feedback-report-panel textarea {
  min-height: 146px;
  padding: 10px;
  resize: vertical;
  line-height: 1.45;
}

.feedback-report-panel select:focus-visible,
.feedback-report-panel textarea:focus-visible {
  border-color: #16796c;
  outline: 2px solid #45d6bd;
  outline-offset: 1px;
}

.feedback-report-context {
  display: grid;
  margin-top: 5px;
  gap: 3px;
  color: #536879;
  font-size: 12px;
}

.feedback-report-diagnostics {
  display: grid;
  min-width: 0;
  margin: 7px 0 0;
  padding: 12px;
  gap: 9px;
  border: 1px solid #c8d4de;
  border-radius: 4px;
  background: #f6f9fb;
}

.feedback-report-diagnostics legend {
  padding: 0 4px;
  color: #20384c;
  font-size: 13px;
  font-weight: 800;
}

.feedback-report-diagnostics-choice {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  margin: 0 !important;
  align-items: start;
  gap: 9px;
  cursor: pointer;
}

.feedback-report-diagnostics-choice input {
  width: 18px;
  height: 18px;
  margin: 2px 0 0;
  accent-color: #0f6d62;
}

.feedback-report-diagnostics-choice span,
.feedback-report-diagnostics-choice small {
  display: grid;
  gap: 2px;
}

.feedback-report-diagnostics-choice small,
.feedback-report-privacy-note,
.feedback-report-capture-actions span,
.feedback-report-diagnostic-summary {
  color: #536879;
  font-size: 12px;
  line-height: 1.45;
}

.feedback-report-privacy-note {
  margin: 0;
  padding-left: 29px;
}

.feedback-report-capture-actions {
  display: grid;
  grid-template-columns: minmax(150px, max-content) minmax(0, 1fr);
  align-items: center;
  gap: 8px;
}

.feedback-report-secondary-action,
.feedback-report-capture-preview button {
  min-height: 38px;
  padding: 7px 10px;
  border: 1px solid #6f8799;
  border-radius: 3px;
  background: #fff;
  color: #173246;
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  font-weight: 750;
}

.feedback-report-secondary-action:disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

.feedback-report-capture-preview {
  display: grid;
  margin: 0;
  overflow: hidden;
  border: 1px solid #b7c6d1;
  border-radius: 3px;
  background: #fff;
}

.feedback-report-capture-preview[hidden] {
  display: none;
}

.feedback-report-capture-preview img {
  display: block;
  width: 100%;
  max-height: 190px;
  object-fit: contain;
  background: #e9eff4;
}

.feedback-report-capture-confirmation {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  min-height: 44px;
  padding: 8px;
  align-items: start;
  gap: 8px;
  border-top: 1px solid #d9e1e8;
  color: #173246;
  font-size: 12px;
  line-height: 1.45;
}

.feedback-report-capture-confirmation input {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: #0f6d62;
}

.feedback-report-capture-preview figcaption {
  display: flex;
  padding: 7px 8px;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border-top: 1px solid #d9e1e8;
  color: #536879;
  font-size: 11px;
}

.feedback-report-capture-preview button {
  min-height: 32px;
  padding: 5px 8px;
}

.feedback-report-diagnostic-summary summary {
  min-height: 32px;
  padding: 6px 0;
  cursor: pointer;
  font-weight: 750;
}

.feedback-report-diagnostic-summary ul {
  margin: 3px 0 0;
  padding-left: 20px;
}

.feedback-report-diagnostic-summary li + li {
  margin-top: 3px;
}

/* A tab capture is explicit and previewed. Form values are masked before the
   browser creates a frame; the diagnostic overlay itself is never in the image. */
body.feedback-capture-redaction-active .feedback-report-overlay {
  display: none !important;
}

body.feedback-capture-redaction-active :is(
  input,
  textarea,
  select,
  [contenteditable="true"]
) {
  color: transparent !important;
  caret-color: transparent !important;
  text-shadow: none !important;
  background-image: linear-gradient(#263746, #263746) !important;
}

.feedback-report-status {
  min-height: 21px;
  margin: 4px 0 0;
  color: #536879;
  font-size: 13px;
  line-height: 1.45;
}

.feedback-report-status[data-state="success"] {
  color: #146a4f;
  font-weight: 700;
}

.feedback-report-status[data-state="error"] {
  color: #a32929;
  font-weight: 700;
}

.feedback-report-status:focus-visible {
  border-radius: 2px;
  outline: 2px solid #45d6bd;
  outline-offset: 2px;
}

.feedback-report-submit {
  min-height: 44px;
  padding: 10px 16px;
  border: 1px solid #0f6d62;
  border-radius: 3px;
  background: #0f6d62;
  color: #fff;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
}

.feedback-report-submit:disabled {
  border-color: #536879;
  background: #536879;
  cursor: wait;
}

/* The closed authenticated launcher owns a real pointer hit area. Reserve its
   header-utility lane instead of letting adjacent controls render below it. */
.authenticated-dashboard,
.target-author-shell,
.target-review-shell,
.project-command-shell,
.project-import-shell {
  --feedback-report-launcher-gutter: 60px;
}

@media (min-width: 761px) {
  :is(
    .authenticated-dashboard,
    .target-author-shell,
    .target-review-shell,
    .project-command-shell,
    .project-import-shell
  ) :is(
    .author-global-utilities,
    [data-feedback-launcher-reserved-control="true"]
  ) {
    margin-right: var(--feedback-report-launcher-gutter) !important;
  }

  :is(
    .authenticated-dashboard,
    .target-author-shell,
    .target-review-shell,
    .project-command-shell,
    .project-import-shell
  ) .feedback-report-tab {
    width: 44px;
    min-width: 44px;
    padding: 10px;
    justify-content: center;
  }

  :is(
    .authenticated-dashboard,
    .target-author-shell,
    .target-review-shell,
    .project-command-shell,
    .project-import-shell
  ) .feedback-report-tab > span:last-child {
    display: none;
  }
}

/* In the Reader, reserve the feedback-inspector heading for the global problem
   launcher. This keeps the launcher discoverable without covering any document
   or comment action; the open panel remains an intentional temporary overlay. */
.target-document-shell .feedback-report-overlay {
  top: calc(var(--stitch-toolbar) + 69px);
  bottom: auto;
  align-items: flex-start;
  transform: none;
}

.target-document-shell .feedback-report-tab {
  width: 44px;
  min-width: 44px;
  padding: 10px;
  justify-content: center;
}

.target-document-shell .feedback-report-tab > span:last-child {
  display: none;
}

.target-document-shell .comment-workbench-header[data-stitch-feedback-header="true"] {
  padding-right: 60px !important;
}

.target-document-shell .feedback-report-panel {
  top: calc(var(--stitch-toolbar) + 69px);
  height: calc(100dvh - var(--stitch-toolbar) - 85px);
  max-height: calc(100dvh - var(--stitch-toolbar) - 85px);
  transform: none;
}

@media (min-width: 761px) and (max-width: 1180px) {
  .target-document-shell .viewer-workbench-toolbar[data-stitch-viewer-workbench-toolbar="true"] {
    padding-left: 46px !important;
  }
}

@media (max-width: 760px) {
  .feedback-report-overlay {
    top: auto;
    bottom: 12px;
    transform: none;
  }

  .feedback-report-panel {
    top: auto;
    right: 0;
    bottom: 12px;
    width: calc(100vw - 16px);
    max-width: calc(100vw - 16px);
    height: calc(100dvh - 24px);
    max-height: calc(100dvh - 24px);
    transform: none;
  }

  .feedback-report-tab > span:last-child {
    display: none;
  }

  .feedback-report-capture-actions {
    grid-template-columns: 1fr;
  }
}

/* Review decisions are one visible, semantically ordered work chain. The
   document dialog keeps its existing 100-400% zoom contract; these rules only
   rebalance the inspector and its primary editing surface. */
.target-review-shell .review-ai-flow-step {
  display: grid;
  min-width: 0;
  gap: 6px;
}

.target-review-shell .review-ai-flow-heading {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.target-review-shell .review-ai-flow-number {
  display: inline-grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border: 1px solid #7b8a9d;
  border-radius: 50%;
  background: #ffffff;
  color: #172033;
  font-size: 11px;
  font-weight: 850;
  line-height: 1;
}

.target-review-shell .review-ai-flow-title {
  display: grid;
  min-width: 0;
  gap: 1px;
}

.target-review-shell .review-ai-flow-title strong {
  min-width: 0;
  color: #111827;
  font-size: 13px;
  line-height: 1.25;
  overflow-wrap: anywhere;
  hyphens: auto;
}

.target-review-shell .review-ai-flow-title small {
  color: #526071;
  font-size: 11px;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.target-review-shell .review-ai-flow-input .review-ai-flow-heading > .status-badge {
  min-width: 0;
  max-width: 136px;
  padding-inline: 7px;
  line-height: 1.15;
  white-space: normal;
  overflow-wrap: anywhere;
}

.target-review-shell .review-ai-suggestion[data-feedback-ai-suggestion-state="succeeded"] {
  gap: 0;
  padding: 0;
  border-color: #9eabb9;
}

.target-review-shell .review-ai-flow-analysis,
.target-review-shell .review-ai-flow-method {
  padding: 9px 12px;
  border-bottom: 1px solid #d8e0e8;
  background: #ffffff;
}

.target-review-shell .review-ai-finding {
  color: #111827 !important;
  font-size: 14px !important;
  line-height: 1.45 !important;
}

.target-review-shell .review-ai-analysis-details {
  margin-left: 33px;
  color: #475569;
  font-size: 11px;
}

.target-review-shell .review-ai-analysis-details > summary {
  width: fit-content;
  color: #0f5f58;
  font-weight: 750;
  cursor: pointer;
}

.target-review-shell .review-ai-analysis-details .review-ai-rationale {
  margin-top: 7px;
  padding-left: 9px;
  border-left: 2px solid #b8c3d1;
}

.target-review-shell .review-ai-method-control {
  display: block;
  min-width: 0;
}

.target-review-shell .review-ai-method-control select {
  width: 100%;
  min-width: 0;
  min-height: 38px;
  padding: 7px 32px 7px 10px;
  border: 1px solid #67a99f;
  border-radius: 4px;
  background: #f5fffc;
  color: #075e57;
  font: 800 13px/1.3 var(--stitch-ui);
}

.target-review-shell .review-ai-flow-proposal {
  margin: 3px 6px;
  padding: 9px;
  border: 1px solid #67b9ac;
  border-radius: 5px;
  background: #effbf8;
  box-shadow: 0 5px 16px rgb(15 95 88 / 9%);
}

.target-review-shell .review-ai-flow-proposal .review-ai-flow-heading {
  grid-template-columns: auto minmax(0, 1fr);
  align-items: start;
}

.target-review-shell .review-ai-quick-badge {
  grid-column: 2;
  justify-self: start;
  padding: 4px 7px;
  border: 1px solid #08766e;
  border-radius: 999px;
  background: #ffffff;
  color: #075e57;
  font-size: 11px;
  font-weight: 850;
  line-height: 1.2;
  text-transform: uppercase;
  letter-spacing: .03em;
}

.target-review-shell .review-ai-proposed-text {
  margin: 0;
  padding: 12px 13px;
  border: 1px solid #b8dcd5;
  border-left: 4px solid #08766e;
  background: #ffffff;
  color: #102a27;
  font-size: 14px;
  font-weight: 650;
  line-height: 1.5;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.target-review-shell .review-ai-quick-note {
  padding: 7px 9px;
  border: 1px solid #b8dcd5;
  border-radius: 3px;
  background: #ffffff;
  color: #24443f !important;
  font-size: 12px !important;
  line-height: 1.35 !important;
}

.target-review-shell .review-ai-proposal-missing {
  padding: 10px;
  border: 1px dashed #7b8a9d;
  background: #ffffff;
}

.target-review-shell .review-guidance-secondary {
  border-top: 1px solid #d8e0e8;
  background: #f8fafc;
}

@media (min-width: 1181px) {
  .target-review-shell[data-review-focus-mode="true"] .review-ai-flow-method {
    grid-template-columns: minmax(230px, 1fr) minmax(210px, .85fr);
    align-items: center;
  }

  .target-review-shell[data-review-focus-mode="true"]
    [data-review-viewport="fixed-workbench"]
    .review-inspector-form {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .target-review-shell[data-review-focus-mode="true"]
    [data-review-viewport="fixed-workbench"]
    .review-inspection-body {
    grid-template-columns: minmax(360px, .85fr) minmax(540px, 1.15fr) !important;
  }
}

.target-review-shell [data-review-viewport="fixed-workbench"] .review-source-column {
  grid-template-rows: minmax(220px, 1fr) minmax(76px, auto) 160px 34px;
}

.target-review-shell [data-review-viewport="fixed-workbench"] .review-source-passage {
  max-height: 104px;
  overflow-y: auto;
}

.target-review-shell [data-review-viewport="fixed-workbench"] .review-primary-editing {
  display: grid;
  grid-column: 1;
  grid-row: 3;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-rows: auto minmax(0, 1fr);
  min-width: 0;
  min-height: 0;
  gap: 6px 10px;
  align-items: center;
  padding: 9px 13px;
  border-top: 1px solid #c8d1dc;
  background: #ffffff;
}

.target-review-shell [data-review-viewport="fixed-workbench"] .review-primary-editing-heading {
  display: grid;
  min-width: 0;
  gap: 1px;
}

.target-review-shell [data-review-viewport="fixed-workbench"] .review-primary-editing-heading strong {
  color: #172033;
  font-size: 13px;
}

.target-review-shell [data-review-viewport="fixed-workbench"] .review-primary-editing-heading small {
  color: #526174;
  font-size: 11px;
  line-height: 1.25;
}

.target-review-shell [data-review-viewport="fixed-workbench"] .review-primary-editing .review-guidance-toggle {
  display: flex;
  grid-column: 2;
  grid-row: 1;
  align-self: center;
  margin: 0;
  white-space: nowrap;
}

.target-review-shell [data-review-viewport="fixed-workbench"] .review-primary-editing .review-author-note {
  display: grid;
  grid-column: 1 / -1;
  grid-row: 2;
  min-width: 0;
  gap: 3px;
  color: #334155;
  font-size: 11px;
  font-weight: 700;
}

.target-review-shell [data-review-viewport="fixed-workbench"] .review-primary-editing .review-author-note textarea {
  width: 100%;
  min-height: 58px;
  max-height: 70px;
  padding: 7px 9px;
  resize: vertical;
  border: 1px solid #9eabba;
  border-radius: 4px;
  background: #ffffff;
  color: #172033;
  font: 13px/1.35 var(--stitch-ui);
}

.target-review-shell [data-review-viewport="fixed-workbench"] .review-open-document-link {
  grid-row: 4;
}

.target-review-shell [data-review-viewport="fixed-workbench"] .review-decision-column,
.target-review-shell [data-review-viewport="fixed-workbench"] .review-decision-column[data-review-ai-controls="true"] {
  display: block;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.target-review-shell [data-review-viewport="fixed-workbench"] .review-decision-column > .review-ai-suggestion,
.target-review-shell
  [data-review-viewport="fixed-workbench"]
  .review-decision-column[data-review-ai-controls="true"]
  > .review-ai-suggestion {
  max-height: none;
  overflow: visible;
}

.target-review-shell [data-review-viewport="fixed-workbench"] .review-feedback-heading.review-ai-flow-heading {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  justify-content: initial;
  gap: 9px;
}

.target-review-shell [data-review-viewport="fixed-workbench"] .review-inspector-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  min-height: 0;
  gap: 8px;
  align-content: start;
  padding: 10px 12px;
  border-bottom: 1px solid #c8d1dc;
  overflow: visible;
  scroll-padding-block: 11px 28px;
}

.target-review-shell [data-review-viewport="fixed-workbench"] .review-primary-method-fallback {
  grid-column: 1 / -1;
  min-width: 0;
}

.target-review-shell [data-review-viewport="fixed-workbench"] .review-decision-secondary {
  min-width: 0;
  border: 1px solid #c8d1dc;
  border-radius: 4px;
  background: #f8fafc;
}

.target-review-shell [data-review-viewport="fixed-workbench"] .review-decision-secondary > summary {
  display: flex;
  min-height: 36px;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 9px;
  color: #172033;
  cursor: pointer;
  list-style: none;
}

.target-review-shell [data-review-viewport="fixed-workbench"] .review-decision-secondary > summary::-webkit-details-marker {
  display: none;
}

.target-review-shell [data-review-viewport="fixed-workbench"] .review-decision-secondary > summary > span:first-child {
  display: grid;
  min-width: 0;
  gap: 1px;
}

.target-review-shell [data-review-viewport="fixed-workbench"] .review-decision-secondary > summary strong {
  font-size: 12px;
}

.target-review-shell [data-review-viewport="fixed-workbench"] .review-decision-secondary > summary small {
  color: #526174;
  font-size: 11px;
}

.target-review-shell [data-review-viewport="fixed-workbench"] .review-decision-secondary > summary .material-symbols-outlined {
  color: #526174;
  font-size: 18px;
  transition: transform 160ms ease;
}

.target-review-shell [data-review-viewport="fixed-workbench"] .review-decision-secondary[open] > summary .material-symbols-outlined {
  transform: rotate(90deg);
}

.target-review-shell [data-review-viewport="fixed-workbench"] .review-decision-secondary-body {
  display: grid;
  gap: 9px;
  padding: 9px;
  border-top: 1px solid #d9e0e7;
}

.target-review-shell [data-review-viewport="fixed-workbench"] .review-save-note {
  min-height: 36px;
  align-self: stretch;
  white-space: nowrap;
}

@media (min-width: 981px) and (max-width: 1180px) {
  .target-review-shell[data-review-focus-mode="true"]
    [data-review-viewport="fixed-workbench"]
    .review-inspection-body {
    grid-template-columns: minmax(390px, .85fr) minmax(500px, 1.15fr) !important;
    overflow: hidden;
  }
}

@media (max-width: 980px) {
  .target-review-shell [data-review-viewport="fixed-workbench"] .review-source-column {
    grid-template-rows: minmax(300px, 45vh) auto auto 38px;
  }

  .target-review-shell [data-review-viewport="fixed-workbench"] .review-primary-editing {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto minmax(0, 1fr);
    height: auto;
    max-height: none;
  }

  .target-review-shell [data-review-viewport="fixed-workbench"] .review-primary-editing .review-guidance-toggle,
  .target-review-shell [data-review-viewport="fixed-workbench"] .review-primary-editing .review-author-note {
    grid-column: 1;
    grid-row: auto;
  }
}
