:root {
  color-scheme: light;
  color: #172033;
  background: #f5f7fb;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

/* Several elements below set an explicit `display`, which outranks the `hidden`
   attribute's user-agent `display: none` and leaves them on screen. */
[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: #f5f7fb;
  transition: color 180ms ease, background 180ms ease;
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  width: min(100% - 32px, 1180px);
  margin-inline: auto;
  padding-block: 24px;
}

.site-header,
.header-actions {
  display: flex;
  align-items: center;
}

.site-header {
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 4px;
  font-size: 1.6rem;
}

h2 {
  font-size: 1.05rem;
}

.subtitle,
.quick-guide,
.privacy-badge {
  color: #64748b;
  font-size: 0.875rem;
}

.subtitle {
  margin-bottom: 0;
}

.app-intro {
  max-width: 720px;
}

.quick-guide {
  max-width: 680px;
  margin: 7px 0 0;
  line-height: 1.45;
}

.header-actions {
  flex-shrink: 0;
  gap: 12px;
}

.language-control select,
select,
input[type="text"],
input[type="number"] {
  border: 1px solid #cbd5e1;
  border-radius: 9px;
  color: #172033;
  background: #fff;
}

.language-control select {
  padding: 8px 30px 8px 10px;
  cursor: pointer;
}

.card {
  padding: 18px;
  border: 1px solid #dbe2ea;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 5px 20px rgb(23 32 51 / 5%);
}

.toolbar {
  display: grid;
  /* minmax(0, ...) lets the column shrink below its widest content. Without
     it, a single long <select> option sets the minimum width of the whole
     toolbar and pushes every button past the edge of a phone screen. */
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
}

.toolbar-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 10px;
}

.theme-toggle {
  width: 42px;
  padding: 0;
  margin-left: auto;
}

.theme-toggle__icon {
  display: grid;
  width: 20px;
  height: 20px;
  place-items: center;
}

.theme-toggle svg {
  grid-area: 1 / 1;
  width: 14px;
  fill: none;
  stroke: currentcolor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
  transition: opacity 180ms ease, transform 180ms ease;
}

.theme-toggle__sun,
.theme-toggle[aria-checked="true"] .theme-toggle__moon {
  opacity: 0;
  transform: rotate(-45deg) scale(0.6);
}

.theme-toggle__moon,
.theme-toggle[aria-checked="true"] .theme-toggle__sun {
  opacity: 1;
  transform: rotate(0) scale(1);
}

.settings-panel {
  padding: 12px;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  background: #f8fafc;
}

.setting {
  display: grid;
  flex: 1 1 180px;
  gap: 5px;
}

.settings-reset {
  margin-left: auto;
}

.setting--range {
  grid-template-columns: minmax(0, 1fr) 4ch;
  align-items: center;
  gap: 5px 10px;
}

.setting--range .field-label {
  grid-column: 1 / -1;
}

.setting--range output {
  color: #172033;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  text-align: right;
}

.setting--hidden {
  display: none;
}

.advanced {
  padding: 4px 0 0;
}

.advanced summary {
  width: fit-content;
  color: #475569;
  font-size: 0.8125rem;
  font-weight: 650;
  cursor: pointer;
}

.advanced summary:focus-visible {
  outline: 3px solid rgb(37 99 235 / 35%);
  outline-offset: 2px;
}

.advanced .settings-panel {
  margin-top: 10px;
}

.field-label {
  color: #475569;
  font-size: 0.8125rem;
  font-weight: 650;
}

.button {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  padding: 10px 14px;
  border: 0;
  border-radius: 10px;
  color: #fff;
  background: #172033;
  font-weight: 650;
  line-height: 1.2;
  cursor: pointer;
}

.button.secondary {
  color: #172033;
  background: #e8edf4;
}

.button[aria-pressed="true"] {
  color: #fff;
  background: #7c3aed;
}

.button:disabled,
input:disabled,
select:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid rgb(37 99 235 / 35%);
  outline-offset: 2px;
}

input[type="file"] {
  display: none;
}

select,
input[type="number"] {
  min-height: 42px;
  padding: 9px 11px;
}

input[type="range"] {
  width: 100%;
  accent-color: #7c3aed;
  cursor: pointer;
}

.status {
  min-height: 1.25rem;
  margin: 12px 0 0;
  color: #475569;
  font-size: 0.8125rem;
}

.progress {
  height: 8px;
  margin-top: 8px;
  overflow: hidden;
  border-radius: 99px;
  background: #e2e8f0;
}

.progress-bar {
  width: 0;
  height: 100%;
  background: #172033;
  transition: width 160ms ease;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 18px;
  margin-top: 18px;
}

.document-card {
  min-width: 0;
}

.panes {
  display: grid;
  /* min(300px, 100%): on the narrowest phones a 300px column is wider than
     the card, so let it shrink rather than overflow. */
  grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr));
  grid-template-rows: auto 1fr auto auto;
  gap: 18px;
}

/* Both panes share the parent's row tracks, so the source and the result
   stages are always exactly the same height even though only the result pane
   carries an exposure slider. */
.pane {
  display: grid;
  grid-row: span 4;
  grid-template-rows: subgrid;
  min-width: 0;
  gap: 8px;
}

.stage {
  display: grid;
  min-height: 280px;
  padding: 12px;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  background: #f8fafc;
  place-items: center;
}

.pane-note {
  min-height: 1rem;
  margin: 0;
  color: #64748b;
  font-size: 0.75rem;
  line-height: 1.45;
}

.pane-note.warning {
  color: #b42318;
}

.page {
  position: relative;
  max-width: 100%;
  overflow: hidden;
  background: #e5e7eb;
  box-shadow: 0 4px 18px rgb(0 0 0 / 13%);
}

.document-canvas,
.page img {
  display: block;
  max-width: 100%;
  max-height: 60vh;
  height: auto;
}

.overlay {
  position: absolute;
  z-index: 2;
  inset: 0;
  cursor: default;
  touch-action: none;
}

/* The previous picture, while the next one decodes (see renderSource). */
.page.is-loading img {
  opacity: 0.35;
  transition: opacity 120ms ease;
}

.overlay:not(.crop-mode) {
  pointer-events: none;
}

.crop-selection {
  position: absolute;
  border: 2px solid #8b5cf6;
  background: rgb(139 92 246 / 16%);
  box-shadow:
    0 0 0 9999px rgb(15 23 42 / 48%),
    inset 0 0 0 1px rgb(255 255 255 / 65%);
  cursor: move;
}

/* Outside crop mode the applied crop stays visible: the kept area is clear,
   the rest dimmed, and it cannot be dragged. */
.crop-selection.crop-applied {
  border-color: rgb(255 255 255 / 75%);
  background: none;
  cursor: default;
  pointer-events: none;
}

.crop-applied .crop-handle {
  display: none;
}

.crop-handle {
  position: absolute;
  z-index: 1;
  width: 14px;
  height: 14px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: #7c3aed;
  box-shadow: 0 1px 5px rgb(15 23 42 / 45%);
  touch-action: none;
}

.crop-handle--nw {
  top: 0;
  left: 0;
  cursor: nwse-resize;
  transform: translate(-50%, -50%);
}

.crop-handle--ne {
  top: 0;
  right: 0;
  cursor: nesw-resize;
  transform: translate(50%, -50%);
}

.crop-handle--se {
  right: 0;
  bottom: 0;
  cursor: nwse-resize;
  transform: translate(50%, 50%);
}

.crop-handle--sw {
  bottom: 0;
  left: 0;
  cursor: nesw-resize;
  transform: translate(-50%, 50%);
}

.queue {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.queue-item {
  position: relative;
  width: 84px;
}

.queue-select {
  display: grid;
  width: 100%;
  padding: 4px;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  background: #fff;
  cursor: pointer;
  gap: 4px;
}

.queue-select[aria-current="true"] {
  border-color: #7c3aed;
  box-shadow: 0 0 0 2px rgb(124 58 237 / 30%);
}

.queue-select img,
.queue-select canvas {
  display: block;
  width: 100%;
  height: 56px;
  border-radius: 6px;
  object-fit: cover;
  background: #e5e7eb;
}

.queue-select span {
  overflow: hidden;
  color: #475569;
  font-size: 0.6875rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* A dark disc with a light rim, so the icon reads on bright and dark
   thumbnails alike; it turns red to say what it does before it is pressed. */
.queue-remove {
  position: absolute;
  top: 9px;
  right: 9px;
  display: grid;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 1px solid rgb(255 255 255 / 35%);
  border-radius: 50%;
  color: #fff;
  background: rgb(15 23 42 / 72%);
  box-shadow: 0 1px 4px rgb(0 0 0 / 35%);
  cursor: pointer;
  place-items: center;
}

.queue-remove svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentcolor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.queue-remove:hover,
.queue-remove:focus-visible {
  border-color: transparent;
  background: #dc2626;
}

.queue-select:focus-visible,
.queue-remove:focus-visible {
  outline: 3px solid rgb(37 99 235 / 45%);
  outline-offset: 2px;
}

.queue-remove:disabled {
  background: rgb(15 23 42 / 72%);
  cursor: not-allowed;
  opacity: 0.45;
}

/* A little more to aim at where the pointer is a finger. */
@media (pointer: coarse) {
  .queue-remove {
    top: 7px;
    right: 7px;
    width: 30px;
    height: 30px;
  }
}

.document-save {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid #e2e8f0;
}

.add-pages-button {
  gap: 7px;
}

.add-pages-button > span:first-child {
  font-size: 1.25rem;
  font-weight: 500;
  line-height: 1;
}

.export-actions {
  display: flex;
  gap: 10px;
}

.empty {
  padding: 60px 20px;
  color: #64748b;
  text-align: center;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

noscript {
  display: block;
  padding: 16px;
  color: #fff;
  background: #b42318;
  text-align: center;
}

/* ------------------------------------------------------- info tooltips */

.field-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.info {
  display: inline-grid;
  width: 16px;
  height: 16px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  color: #fff;
  background: #94a3b8;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  cursor: help;
  place-items: center;
}

.info:hover,
.info[aria-expanded="true"] {
  background: #7c3aed;
}

.info:focus-visible {
  outline: 3px solid rgb(37 99 235 / 35%);
  outline-offset: 2px;
}

.tip {
  position: fixed;
  z-index: 60;
  max-width: 280px;
  padding: 8px 10px;
  border-radius: 8px;
  color: #f8fafc;
  background: #172033;
  box-shadow: 0 6px 20px rgb(0 0 0 / 28%);
  font-size: 0.75rem;
  line-height: 1.45;
  pointer-events: none;
}

.tip[hidden] {
  display: none;
}

/* ------------------------------------------------------- preview actions */

/* Sits in its own row under the preview rather than over the picture, so the
   buttons never cover the image they act on. */
/* Undo and redo sit apart from the actions on the image, at the far left. */
.history-actions {
  display: flex;
  gap: 8px;
  margin-right: auto;
}

.adjust-head .history-actions {
  margin-right: 0;
  margin-left: auto;
}

.stage-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
  min-height: 38px;
}

.icon-button {
  display: inline-grid;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  color: #172033;
  background: #fff;
  box-shadow: 0 1px 3px rgb(15 23 42 / 10%);
  cursor: pointer;
  place-items: center;
}

.icon-button svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentcolor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.icon-button--primary {
  color: #fff;
  border-color: #7c3aed;
  background: #7c3aed;
}

.icon-button:hover {
  transform: translateY(-1px);
}

.icon-button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
  transform: none;
}

.icon-button:focus-visible {
  outline: 3px solid rgb(37 99 235 / 35%);
  outline-offset: 2px;
}

/* --------------------------------------------------------- adjust dialog */

/* Scoped to [open]: setting a display on the dialog itself would override the
   user-agent `display: none` that hides it while closed. */
.adjust-dialog[open] {
  display: flex;
  flex-direction: column;
}

.adjust-dialog {
  width: min(1400px, 96vw);
  max-height: 94vh;
  padding: 0;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 24px 60px rgb(15 23 42 / 28%);
}

.adjust-dialog::backdrop {
  background: rgb(15 23 42 / 45%);
}

.adjust-head {
  display: flex;
  flex: none;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid #e2e8f0;
}

.adjust-head h2 {
  margin: 0;
  font-size: 1rem;
}

/* Checkerboard, so a graded image with transparency reads correctly.
   Pressing it shows the picture without the edits (see pressPeek), so it
   claims touches outright: a held finger must not scroll, zoom or open the
   image menu, which would cancel the hold. */
.adjust-view {
  display: flex;
  flex: none;
  flex-direction: column;
  min-width: 0;
}

.adjust-preview {
  position: relative;
  overflow: hidden;
  cursor: pointer;
  touch-action: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  display: grid;
  flex: none;
  padding: 12px 16px;
  background:
    repeating-conic-gradient(#f1f5f9 0% 25%, #fff 0% 50%) 50% / 16px 16px;
  place-items: center;
}

.adjust-preview canvas {
  display: block;
  max-width: 100%;
  max-height: 46vh;
  height: auto;
  box-shadow: 0 2px 10px rgb(15 23 42 / 20%);
  /* Set by src/zoom.js on the viewport; identity when the picture is fit. */
  transform: translate3d(var(--pan-x, 0px), var(--pan-y, 0px), 0) scale(var(--zoom, 1));
  transform-origin: 50% 50%;
  will-change: transform;
}

/* Zoomed in, a drag moves the picture; holding still still shows it without edits. */
.adjust-preview.is-zoomed {
  cursor: grab;
}

.adjust-preview.is-panning,
.compare-viewport.is-panning {
  cursor: grabbing;
}

/* On a wide screen the picture takes most of the dialog and the controls sit
   in a column beside it, so edits are judged at a useful size. */
@media (min-width: 900px) {
  .adjust-dialog[open] {
    display: grid;
    grid-template:
      "head head" auto
      "preview body" minmax(0, 1fr)
      "preview foot" auto
      / minmax(0, 1fr) minmax(300px, 360px);
    height: min(94vh, 1000px);
  }

  .adjust-head {
    grid-area: head;
  }

  .adjust-view {
    grid-area: preview;
    min-height: 0;
  }

  .adjust-preview {
    flex: 1 1 0;
    /* A definite track, so the canvas's max-height: 100% has something to
       resolve against and tall crops shrink to fit instead of overflowing. */
    grid-template: minmax(0, 1fr) / minmax(0, 1fr);
    min-width: 0;
    min-height: 0;
    padding: 16px;
  }

  .adjust-preview canvas {
    max-height: 100%;
  }

  .adjust-body {
    grid-area: body;
    align-content: start;
    border-top: 0;
    border-left: 1px solid #e2e8f0;
  }

  .adjust-foot {
    flex-direction: column;
    grid-area: foot;
    align-items: stretch;
    border-left: 1px solid #e2e8f0;
  }
}

.adjust-preview:focus-visible {
  outline: 3px solid rgb(37 99 235 / 45%);
  outline-offset: -3px;
}

/* Says which picture is showing while the edits are hidden. */
.adjust-peek-tag {
  position: absolute;
  top: 22px;
  left: 50%;
  padding: 4px 10px;
  border-radius: 999px;
  color: #f8fafc;
  background: rgb(13 17 23 / 78%);
  box-shadow: 0 1px 6px rgb(0 0 0 / 35%);
  font-size: 0.75rem;
  font-weight: 650;
  line-height: 1.4;
  pointer-events: none;
  transform: translateX(-50%);
}

.adjust-body {
  display: grid;
  flex: 1 1 auto;
  gap: 14px;
  padding: 16px;
  border-top: 1px solid #e2e8f0;
  overflow-y: auto;
}

.adjust-body .setting {
  flex: none;
}

/* Section headings, so thirteen sliders read as four short groups. */
.adjust-group {
  margin: 4px 0 -6px;
  color: #64748b;
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.adjust-group:not(:first-child) {
  margin-top: 6px;
  padding-top: 14px;
  border-top: 1px solid #e2e8f0;
}

.adjust-body .setting--range {
  grid-template-columns: minmax(0, 1fr) 4.5ch;
}

.adjust-body .field-label {
  grid-column: 1 / -1;
}

.adjust-body output {
  color: #172033;
  font-size: 0.8125rem;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  text-align: right;
}

.adjust-foot {
  display: flex;
  flex: none;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-top: 1px solid #e2e8f0;
  background: #f8fafc;
}

.adjust-note {
  margin: 0;
  color: #64748b;
  font-size: 0.75rem;
  line-height: 1.4;
}

.link-button {
  padding: 2px 4px;
  border: 0;
  border-radius: 6px;
  color: #6d28d9;
  background: none;
  font-size: 0.75rem;
  font-weight: 650;
  cursor: pointer;
}

.link-button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

/* ------------------------------------------------------- scroll lock */

/* While a modal dialog is open the page behind it stays put (see openModal).
   overflow: hidden keeps the current scroll position; the padding stands in
   for a classic scrollbar, whose disappearance would shift the page. */
html.scroll-locked {
  overflow: hidden;
  overscroll-behavior: none;
  padding-right: var(--scrollbar-gap, 0px);
}

/* Scrolling inside a dialog stops at its edges instead of carrying on into
   the page underneath. */
dialog,
.adjust-body {
  overscroll-behavior: contain;
}

/* ------------------------------------------------------- compare dialog */

.compare-dialog {
  width: min(100% - 32px, 1100px);
  padding: 0;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  color: #172033;
  background: #fff;
  box-shadow: 0 18px 50px rgb(0 0 0 / 30%);
}

.compare-dialog::backdrop {
  background: rgb(9 12 20 / 62%);
}

.compare-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid #e2e8f0;
}

.compare-head h2 {
  margin: 0;
}

.compare-viewport {
  position: relative;
  overflow: hidden;
  /* A size container, so the wipe layers below can be positioned in units of
     its width (cqw) by transforms alone, and follow it when it resizes. */
  container-type: inline-size;
  background: #0d1117;
  line-height: 0;
  touch-action: none;
  /* No long-press image menu, text selection or tap flash mid-drag. */
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
}

.compare-viewport img,
.compare-viewport canvas {
  display: block;
  width: 100%;
  max-height: 72vh;
  height: auto;
  margin-inline: auto;
  object-fit: contain;
}

/*
 * The wipe moves three composited layers by transform and changes nothing
 * else, so dragging it never lays out or repaints: each frame the browser only
 * moves textures it already has, which is what keeps it in step with a
 * finger. Animating `left` and `clip-path` instead repainted both full-size
 * images on every frame.
 *
 * The original is revealed through a window (.compare-before) that slides in
 * from the left, while the picture inside it slides back by exactly the same
 * amount, so the picture stays put and only the window's edge moves.
 */
.compare-before {
  position: absolute;
  inset: 0;
  overflow: hidden;
  transform: translate3d(calc((var(--wipe, 0.5) - 1) * 100cqw), 0, 0);
  will-change: transform;
}

/*
 * Zoom (src/zoom.js) sets --zoom and --pan-* on the viewport, and both
 * pictures apply them in the same order about the same origin, so they stay
 * aligned pixel for pixel. The window and the divider are not zoomed: the line
 * stays where it is on screen while the pictures move under it.
 */
#compare-after {
  transform: translate3d(var(--pan-x, 0px), var(--pan-y, 0px), 0) scale(var(--zoom, 1));
  transform-origin: 50% 50%;
  will-change: transform;
}

.compare-before canvas {
  transform:
    translate3d(calc((1 - var(--wipe, 0.5)) * 100cqw), 0, 0)
    translate3d(var(--pan-x, 0px), var(--pan-y, 0px), 0)
    scale(var(--zoom, 1));
  transform-origin: 50% 50%;
  will-change: transform;
}

.compare-viewport.is-zoomed {
  cursor: grab;
}

.compare-divider {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 2px;
  background: #fff;
  box-shadow: 0 0 10px rgb(0 0 0 / 55%);
  cursor: ew-resize;
  touch-action: none;
  transform: translate3d(calc(var(--wipe, 0.5) * 100cqw - 1px), 0, 0);
  will-change: transform;
}

/* An invisible, finger-sized grab area: the visible line is 2px, which is far
   below the ~44px a touch target needs to be. */
.compare-divider::before {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 44px;
  content: "";
  translate: -50% 0;
}

.compare-grip {
  position: absolute;
  top: 50%;
  left: 50%;
  display: grid;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 10px rgb(0 0 0 / 45%);
  touch-action: none;
  translate: -50% -50%;
}

.compare-grip::before,
.compare-grip::after {
  position: absolute;
  top: 50%;
  color: #172033;
  font-size: 12px;
  line-height: 1;
  translate: 0 -50%;
}

.compare-grip::before {
  left: 7px;
  content: "‹";
}

.compare-grip::after {
  right: 7px;
  content: "›";
}

.compare-divider:focus-visible {
  outline: 3px solid rgb(124 58 237 / 70%);
}

.compare-tag {
  position: absolute;
  top: 10px;
  padding: 4px 9px;
  border-radius: 999px;
  color: #f8fafc;
  background: rgb(13 17 23 / 72%);
  font-size: 0.6875rem;
  font-weight: 650;
  line-height: 1.4;
  pointer-events: none;
}

.compare-tag--left {
  left: 10px;
}

.compare-tag--right {
  right: 10px;
}

/* Zoom controls under a picture, never on it, so pressing them cannot also
   peek or move the comparison line. */
.zoom-bar {
  display: flex;
  flex: none;
  gap: 6px;
  align-items: center;
  justify-content: center;
  padding: 6px 12px;
  border-top: 1px solid #e2e8f0;
}

.zoom-bar .icon-button {
  width: 34px;
  height: 34px;
}

.zoom-bar .icon-button svg {
  width: 17px;
  height: 17px;
}

.zoom-level {
  min-width: 64px;
  min-height: 34px;
  padding: 4px 10px;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  color: #172033;
  background: #fff;
  font: inherit;
  font-size: 0.8125rem;
  font-variant-numeric: tabular-nums;
  font-weight: 650;
  cursor: pointer;
}

.zoom-level:focus-visible {
  outline: 3px solid rgb(37 99 235 / 45%);
  outline-offset: 2px;
}

.compare-note {
  margin: 0;
  padding: 10px 16px 14px;
  color: #64748b;
  font-size: 0.75rem;
}

html[data-theme="dark"] {
  color: #e6edf3;
  background: #0d1117;
  color-scheme: dark;
}

html[data-theme="dark"] body {
  background: #0d1117;
}

html[data-theme="dark"] .subtitle,
html[data-theme="dark"] .quick-guide,
html[data-theme="dark"] .privacy-badge,
html[data-theme="dark"] .status,
html[data-theme="dark"] .field-label,
html[data-theme="dark"] .advanced summary,
html[data-theme="dark"] .pane-note,
html[data-theme="dark"] .queue-select span,
html[data-theme="dark"] .empty {
  color: #8c959f;
}

html[data-theme="dark"] .card {
  border-color: #30363d;
  background: #161b22;
  box-shadow: 0 8px 28px rgb(0 0 0 / 24%);
}

html[data-theme="dark"] .language-control select,
html[data-theme="dark"] select,
html[data-theme="dark"] input[type="text"],
html[data-theme="dark"] input[type="number"] {
  border-color: #30363d;
  color: #e6edf3;
  background: #0d1117;
}

html[data-theme="dark"] .button {
  color: #0d1117;
  background: #f0f6fc;
}

html[data-theme="dark"] .button.secondary {
  color: #e6edf3;
  background: #30363d;
}

html[data-theme="dark"] .button[aria-pressed="true"] {
  color: #fff;
  background: #7c3aed;
}

html[data-theme="dark"] .settings-panel,
html[data-theme="dark"] .stage {
  border-color: #30363d;
  background: #0d1117;
}

html[data-theme="dark"] .queue-select {
  border-color: #30363d;
  background: #161b22;
}

html[data-theme="dark"] .pane-note.warning {
  color: #ff7b72;
}

html[data-theme="dark"] .setting--range output {
  color: #e6edf3;
}

html[data-theme="dark"] .document-save {
  border-color: #30363d;
}

html[data-theme="dark"] .progress {
  background: #30363d;
}

html[data-theme="dark"] .progress-bar {
  background: #a78bfa;
}

html[data-theme="dark"] .icon-button {
  color: #e6edf3;
  border-color: #30363d;
  background: #21262d;
}

html[data-theme="dark"] .icon-button--primary {
  color: #fff;
  border-color: #7c3aed;
  background: #7c3aed;
}

html[data-theme="dark"] .adjust-dialog {
  border-color: #30363d;
  color: #e6edf3;
  background: #161b22;
}

html[data-theme="dark"] .adjust-head,
html[data-theme="dark"] .adjust-foot,
html[data-theme="dark"] .adjust-body {
  border-color: #30363d;
}

html[data-theme="dark"] .zoom-bar {
  border-color: #30363d;
}

html[data-theme="dark"] .zoom-level {
  border-color: #30363d;
  color: #e6edf3;
  background: #21262d;
}

html[data-theme="dark"] .adjust-preview {
  background: repeating-conic-gradient(#21262d 0% 25%, #161b22 0% 50%) 50% / 16px 16px;
}

html[data-theme="dark"] .adjust-foot {
  background: #0d1117;
}

html[data-theme="dark"] .adjust-note {
  color: #8c959f;
}

html[data-theme="dark"] .adjust-body output {
  color: #e6edf3;
}

html[data-theme="dark"] .adjust-group {
  color: #8c959f;
}

html[data-theme="dark"] .adjust-group:not(:first-child) {
  border-color: #30363d;
}

html[data-theme="dark"] .link-button {
  color: #a78bfa;
}

html[data-theme="dark"] .info {
  background: #484f58;
}

html[data-theme="dark"] .tip {
  color: #e6edf3;
  background: #30363d;
}

html[data-theme="dark"] .compare-dialog {
  border-color: #30363d;
  color: #e6edf3;
  background: #161b22;
}

html[data-theme="dark"] .compare-head {
  border-color: #30363d;
}

html[data-theme="dark"] .compare-note {
  color: #8c959f;
}

@media (max-width: 640px) {
  .app-shell {
    width: min(100% - 20px, 1180px);
    padding-block: 14px;
  }

  .site-header,
  .header-actions {
    align-items: flex-start;
  }

  .site-header {
    flex-direction: column;
  }

  .header-actions {
    width: 100%;
    justify-content: space-between;
  }

  .toolbar-row > *,
  .setting {
    width: 100%;
    max-width: none;
  }

  /* A control is otherwise at least as wide as its longest option, however
     narrow the screen, and one long label widens the whole toolbar past the
     edge of a phone. Each setting has a full row to itself here, so let it
     shrink instead. Wider screens keep content-sized controls, where there is
     room for every label and shrinking would only clip them. */
  .setting,
  select,
  input[type="number"] {
    min-width: 0;
  }

  select {
    max-width: 100%;
  }

  .document-controls .button {
    flex: 1 1 auto;
  }

  /* As in Safe Layer: a square at the end of the row. The selector has to
     outrank `.document-controls .button` above, which would stretch it into a
     full-width bar. */
  .document-controls .theme-toggle {
    width: 42px;
    flex: 0 0 auto;
    margin-left: auto;
  }

  .document-save .button {
    width: 100%;
  }

  .export-actions {
    width: 100%;
    flex-direction: column;
  }
}
