#surface, #full-document, #lens-text, #type-sample {
  word-spacing: var(--read-word-spacing, 0);
  letter-spacing: var(--read-letter-spacing, 0);
}
#type-dialog { width: min(29rem, calc(100% - 1.25rem)); max-height: 88dvh; }
.type-controls {
  padding: 0;
  display: grid;
  grid-template-columns: repeat(2,minmax(0,1fr));
  gap: .85rem .75rem;
  color: #233b2d;
}
.type-controls label, .type-size {
  display: grid; gap: .3rem; align-content: start;
  font: 650 .9rem/1.35 "DM Sans", Arial, sans-serif;
}
.type-controls select { width: 100%; min-width: 0; min-height: 44px; font-size: 1rem; }
.type-controls .stepper { width: fit-content; min-height: 44px; }
.type-controls .stepper button { width: 44px; height: 44px; }
.type-controls .stepper output { min-width: 3rem; font-variant-numeric: tabular-nums; }
.type-spaces { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: .45rem; grid-column: 1/-1; }
.type-spaces select { padding-inline: .4rem; }
#type-help, #type-sample { grid-column: 1/-1; margin: 0; }
#type-sample {
  max-height: 8rem; overflow: auto; border-inline-start: 3px solid #d3ac4e;
  background: #faf8ef; padding: .35rem .65rem;
  font: 400 var(--read-size)/var(--read-line-height) var(--read-font);
  overflow-wrap: anywhere;
}
#type-done { grid-column: 1/-1; min-height: 44px; }
#reading-lens {
  display:flex;
  flex: 0 0 max(calc(var(--read-size) * 1.4), clamp(76px, 16vh, 136px));
  max-height: max(45%, min(52%, calc(var(--read-size) * 1.4)));
  min-height: 0;
  border-block-start: 2px solid #b1aa8a;
  background: #fffdf5;
  color: #17231a;
}
#lens-scroll {
  flex: 1;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  overflow-anchor: none;
  padding-inline: .6rem;
  cursor: pointer;
}
#lens-scroll::before, #lens-scroll::after { content:""; display:block; height:var(--reading-center-space,0px); }
#lens-text { margin:0; overflow-wrap: anywhere; font: 400 var(--read-size)/var(--read-line-height) var(--read-font); }
#lens-text mark {
  background: var(--mark); color: inherit;
  box-decoration-break: clone; -webkit-box-decoration-break: clone;
}
@media (max-width: 560px) {
  .reader-tools { gap: .25rem; }
  .reader-tools #text-options { padding-inline: .45rem; }
  .reader-tools #format-export { padding-inline: .4rem; }
  .type-controls { gap:.7rem .5rem; }
  #type-dialog { padding: 16px; }
  #type-layout-label, #type-zoom-label, .type-controls > label:has(#type-font), .type-size {
    grid-column: 1 / -1;
    grid-template-columns: minmax(0, .85fr) minmax(0, 1.4fr);
    align-items: center;
  }
  .type-spaces { grid-template-columns: 1fr; }
  .type-spaces label { grid-template-columns: minmax(0, .85fr) minmax(0, 1.4fr); align-items: center; }
}

#focus-lines .reader-modes { display: grid; gap: .45rem; width: 100%; margin: 0 0 .7rem; }
#focus-lines .reader-modes .seg { max-width: 100%; }
#focus-lines .reader-modes button { color: #263d30; }
#focus-lines #view-options button[aria-pressed=true] { color:white; }
@media (max-height: 640px), (max-width: 410px) {
  .focused .paper-footer label { display: none; } /* Page zoom is in Text & spacing. */
  .focused .paper-footer { min-height: 44px; }
  .focused .reader-tools #text-options { width: 44px; padding: 0; }
  .focused #text-options > span:last-child { display: none; }
  .focused #text-options [data-i] { width: 21px; height: 21px; }
  .focused .paper-choice select { max-width: 100%; }
}

@media (max-width: 410px) {
  .focused .panel-heading { padding-inline: 0; }
  .focused .panel-heading h2 { position:absolute; width:1px; height:1px; overflow:hidden; clip-path:inset(50%); }
  .focused .reader-tools { flex:1; justify-content:space-between; flex-wrap:nowrap; }
}
/* Keep the paper and the lens in reading order at every orientation. */
.reader:not(.focused):not(.both-views) .document-surface { height: clamp(21rem, 68svh, 60rem); }
.reader:not(.focused).paper-only { --guide-gap: .45rem; }
#reader.focused #settings-toggle { display: none; }
#edit { padding-inline: .45rem; gap: .25rem; white-space: nowrap; }
.stage-top { flex-wrap: wrap; gap: .35rem .65rem; }
.stage-top .stage-count { margin-inline-start: auto; }
.quick-spacing { display: inline-flex; align-items: center; flex: none; gap: 0; font: 600 .82rem/1.15 "DM Sans", Arial, sans-serif; }
#quick-spacing-label { margin-inline-end: .4rem; }
.quick-spacing button, .quick-spacing output {
  display: inline-grid; place-items: center; min-height: 38px; padding-inline: .35rem;
  background: #fff; color: #25452f; border-block: 1px solid #b7c2b3;
}
.quick-spacing button { min-width: 38px; }
.quick-spacing button:first-of-type { border-inline-start: 1px solid #b7c2b3; border-radius: .5rem 0 0 .5rem; }
.quick-spacing button:last-of-type { border-inline-end: 1px solid #b7c2b3; border-radius: 0 .5rem .5rem 0; }
.quick-spacing button:disabled { opacity: 1; color: #7e887b; background: #f3f4f0; }
.quick-spacing button:hover:enabled { background: #e8efe4; }
.quick-spacing button [data-i] { width: 15px; height: 15px; }
.quick-spacing output { min-width: 4.7em; font-variant-numeric: tabular-nums; }
@media (pointer: coarse) {
  .quick-spacing button { min-width: 44px; }
  .quick-spacing button, .quick-spacing output { min-height: 44px; }
}
@container reading-stage (max-width: 37rem) {
  .stage-top .quick-spacing { order: 1; }
  .stage-top { justify-content: start; }
  .stage-foot .sample-badge { display: none; }
}
@container reading-stage (max-width: 25rem) {
  #quick-spacing-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .stage-top .quick-spacing::before { content: "Spacing"; margin-inline-end: .35rem; }
  .stage-top .stage-count { font-size: .77rem; }
  .stage-top .paper-choice { margin-inline-start: auto; }
}

@media (orientation: landscape) and (max-height: 520px), (max-width: 410px) and (max-height: 640px) {
  .reader.focused .stage { grid-template-rows: minmax(0, 1fr) 4px; }
  .reader.focused .reading-panes { grid-area: 1 / 1; }
  .reader.focused .progress-track { grid-row: 2; }
  .reader.focused .transport { min-height: 44px; padding-block: 0; }
  .reader.focused #focus-lines .stage-foot,
  .reader.focused #focus-lines .stage-top { width: 100%; min-height: 44px; color: #25382b; background: #f5f7f1; }
  .reader.focused #focus-lines :is(.stage-label,.stage-count,.stage-edit) { color: #293e2e; }
  .reader.focused #focus-lines #source-label { display: none; }
  .reader.focused .reader-tools > .quick-spacing { margin-inline-end: .3rem; }
  .reader.focused:not(.paper-only) .reader-tools > .quick-spacing { color: white; }
}

@media (max-width: 410px) and (max-height: 640px) {
  .reader.focused .reader-tools { display: grid; grid-template-columns: auto 1fr auto; }
  .reader.focused .reader-tools > .quick-spacing { grid-row: 2; grid-column: 1 / -1; justify-self: center; }
  .reader.focused .reader-tools #focus-lines { justify-self: center; }
}
.reader.focused .inline-editor:not([hidden]) {
  position: absolute;
  inset: auto 0 0;
  max-height: 100%;
  overflow-y: auto;
  overscroll-behavior: contain;
  z-index: 3;
  box-shadow: 0 -4px 14px #23352824;
}
