/* The split opens only on desktops with room for both reading surfaces. */
.workspace.with-source {
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  grid-template-areas: "reader source" "settings source";
  --source-focus-width: clamp(360px, 42vw, 840px);
}
.with-source > .reader { grid-area: reader; }
.with-source > .settings { grid-area: settings; }
.with-source > .source-panel { grid-area: source; }
.desk:has(.with-source) { width: min(1600px, 94%); }
.source-panel {
  position: sticky;
  top: 12px;
  display: flex;
  flex-direction: column;
  align-self: start;
  height: clamp(26rem, 72vh, 58rem);
  max-height: calc(100dvh - 24px);
  overflow: hidden;
}
.source-heading, .source-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .6rem;
  padding: .65rem 1rem;
}
.source-title, .source-position { min-width: 0; }
.source-title h2 {
  display: flex;
  align-items: center;
  gap: .45rem;
  color: var(--ink);
  font-size: 1.15rem;
  letter-spacing: -.03em;
}
.source-title h2 [data-i] { color: #4e6a59; }
#source-name {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  color: var(--soft);
  font-size: .91rem;
  margin-top: .15rem;
}
.source-actions { display: flex; align-items: center; gap: .35rem; flex-shrink: 0; }
#source-locate, #source-dismiss {
  flex: none;
  color: var(--green);
  padding: 0 .65rem;
  border: 1px solid var(--rule);
}
#source-scroll {
  flex: 1;
  min-height: 0;
  overflow: auto;
  overflow-anchor: none;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  border-block: 1px solid var(--rule);
  background: #e6eae3;
  padding: 15px;
}
#source-scroll:focus-visible { outline: 3px solid #146da5; outline-offset: -4px; }
#source-content { min-width: 0; }
#source-content.source-pdf { width: calc(100% * var(--source-scale,1)); }
.pdf-page, .source-paper {
  background: white;
  box-shadow: 0 1px 4px #23392f28;
}
.pdf-word-marker {
  background: color-mix(in srgb, var(--mark) 48%, transparent);
  outline: 2px solid #163e37;
  border-radius: 2px;
  box-shadow: 0 0 0 3px #ffffffbc;
  pointer-events: none;
}
.source-panel[data-complete] .pdf-word-marker { visibility: hidden; }
.source-paper {
  padding: clamp(16px, 1.8vw, 32px);
  color: #212b26;
  font-family: Georgia, "Times New Roman", serif;
  font-size: calc(1.09rem * var(--source-scale,1));
  line-height: 1.65;
  overflow-wrap: anywhere;
}
.source-paper > :first-child { margin-top: 0; }
.source-paper > :last-child { margin-bottom: 0; }
.source-paper :is(h3,h4,h5,h6) { line-height: 1.25; margin: 1em 0 .4em; }
.source-paper h3 { font-size: 1.45em; }
.source-paper h4 { font-size: 1.23em; }
.source-paper :is(p,ul,ol,blockquote,table) { margin: 0 0 .85em; }
.source-paper blockquote { border-inline-start: 3px solid #acbdab; padding-inline-start: .9em; }
.source-paper ul, .source-paper ol { padding-inline-start: 1.5em; }
.source-paper table { border-collapse: collapse; width: 100%; }
.source-paper td { border: 1px solid #becabf; padding: .25em .45em; white-space: pre-line; vertical-align: top; }
.source-caption { font-style: italic; }
.source-paper [aria-current="true"] {
  color: #18251d;
  background: var(--mark);
  outline: 2px solid #23483e;
  border-radius: 2px;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}
.source-footer { flex-shrink: 0; }
.source-position { display: grid; gap: .12rem; font-size: .9rem; }
#source-format { color: var(--ink); font-weight: 650; }
#source-location { color: var(--soft); font-variant-numeric: tabular-nums; }
.source-zoom { display: inline-flex; align-items: center; gap: .35rem; }
.source-zoom output { min-width: 3.1rem; text-align: center; font-variant-numeric: tabular-nums; }
#source-message { padding: 0 1rem .65rem; margin: 0; }
#source-toggle[aria-expanded="true"] { background: #e9f0e5; color: #204232; border-color: #89a18e; }
#source-toggle[aria-expanded="true"] [data-i] { color: inherit; }
.is-focused .with-source > .source-panel {
  position: fixed;
  z-index: 6;
  inset: 0 0 0 auto;
  width: var(--source-focus-width);
  height: 100vh;
  height: 100dvh;
  max-height: none;
  border-radius: 0;
  border: 0;
  border-left: 1px solid #77877a;
}
.is-focused .with-source > .reader {
  right: var(--source-focus-width);
  padding-inline: clamp(6px, 1.25vw, 24px);
}
.is-focused .with-source .reader .panel-heading { padding-inline: 4px; gap: 4px; }
.is-focused .with-source .reader-tools { gap: 5px; }
.is-focused .with-source .panel-heading h2 [data-i] { display: none; }

#source-pick-help {
  margin: 0;
  padding: 0 1rem .55rem;
  color: var(--soft);
  font-size: .9rem;
}
#source-browse { min-height: 44px; max-width: 100%; width: 100%; }
.pdf-page, .source-paper [data-word-index] { cursor: pointer; }
.source-paper [data-word-index]:hover { text-decoration: underline; }
.source-panel[data-browsing] .pdf-word-marker { visibility: hidden; }
.source-panel[data-browsing] .source-paper [aria-current="true"] { outline: none; background: none; }
.jump-results, .jump-controls {
  display: flex;
  align-items: center;
  gap: .75rem;
  justify-content: space-between;
}
.jump-results { color: var(--soft); }
.jump-controls { align-items: end; flex-wrap: wrap; }
.jump-controls label { flex: 1 1 11rem; min-width: 0; }
#jump-position { width: 100%; min-height: 44px; padding: 0; }
#jump-place { width: 100%; min-height: 44px; }
.jump-selection { border: 1px solid var(--rule); border-radius: .75rem; padding: .7rem .9rem; }
#jump-location { color: var(--soft); font-size: .9rem; font-variant-numeric: tabular-nums; }
#find-preview { margin-top: .3rem; }
#find-preview .jump-word {
  display: inline-block;
  min-width: 32px;
  padding: .25rem .15rem;
  min-height: 44px;
  font-size: 1.18rem;
  line-height: 1.55;
  border-radius: .25rem;
  overflow-wrap: anywhere;
  max-width: 100%;
}
.jump-word:hover { background: #ebefe7; }
.jump-word[aria-pressed="true"] { color: var(--ink); background: var(--mark); outline: 2px solid var(--green); }
.jump-word mark { color: inherit; background: none; }
.jump-location-line { display: flex; align-items: center; flex-wrap: wrap; gap: .35rem; color: var(--soft); font-size: .9rem; }
#dialog-body .jump-number { display: inline-flex; align-items: center; flex-direction: row; gap: .35rem; }
#jump-word { width: 5.5em; max-width: 100%; min-height: 44px; padding: .3rem .45rem; font-variant-numeric: tabular-nums; }

#jump-word { border: 1px solid #b9c7b9; border-radius: 8px; color: var(--ink); background: white; font-size: 1rem; }
@media (pointer: coarse) { #find-preview .jump-word { min-width: 44px; } }
#dialog-title[tabindex="-1"]:focus { outline: none; }
@media (max-width: 600px) {
  dialog:has(#jump-position) { width: calc(100% - 16px); max-height: calc(100dvh - 16px); padding: 16px; }
  #jump-controls label { flex-basis: 8rem; }
  #find-actions { position: sticky; bottom: 0; background: white; padding-block: .25rem; }
  #find-actions .primary { width: 100%; }
}

#source-dismiss { gap: .3rem; }
#source-content.source-scan { width: calc(100% * var(--source-scale, 1)); }
.scan-photo { position: relative; }
.scan-photo img { display: block; width: 100%; height: auto; }
.scan-photo .pdf-word-marker { position: absolute; }
.scan-transcript { white-space: pre-wrap; }
.scan-coordinate-fallback { margin: .5rem 0 0; }
.scan-coordinate-fallback mark { color: var(--ink); background: var(--mark); }
@media (max-width: 1150px) {
  .source-heading { flex-wrap: wrap; }
  .source-title { flex: 1 1 8rem; }
}
