* {
  box-sizing: border-box;
}
:root {
  color-scheme: light;
  font-family: Arial, Helvetica, sans-serif;
  color: #202020;
  background: #fff;
  font-size: 13px;
  font-synthesis: none;
}
body {
  margin: 0;
}
main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 40px 36px 24px;
}
header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding-bottom: 12px;
  gap: 20px;
}
h1 {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 30px;
  font-weight: 400;
  letter-spacing: -1.1px;
  margin: 0;
}
.identity {
  min-width: 0;
}
.site-mark {
  display: block;
  flex-shrink: 0;
}
.description {
  max-width: 530px;
  margin: 12px 0 0;
  color: #696969;
  font-size: 12px;
  line-height: 1.6;
}
.file-picker {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 16px;
  min-width: 0;
}
#filename {
  max-width: 240px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  color: #696969;
}
#filename:empty {
  display: none;
}
.upload {
  flex-shrink: 0;
  position: relative;
  border: 1px solid #888;
  padding: 10px 14px;
  cursor: pointer;
}
.upload input {
  position: absolute;
  inset: 0;
  width: 100%;
  opacity: 0;
  cursor: pointer;
}
.upload:focus-within {
  outline: 2px solid #202020;
  outline-offset: 3px;
}
.upload.dragging {
  background: #eee;
}
#status {
  color: #696969;
  font-size: 12px;
  min-height: 16px;
  margin: 16px 0 26px;
  overflow-wrap: anywhere;
}
#status.error {
  color: #a32323;
}
#status:empty {
  display: none;
}
fieldset {
  border: 0;
  padding: 24px 0 0;
  margin: 0;
  min-width: 0;
}
[hidden] {
  display: none !important;
}
fieldset:disabled {
  opacity: 0.55;
  pointer-events: none;
}
section + section {
  margin-top: 36px;
}
.sheet-toolbar {
  margin-bottom: 18px;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 12px;
}
.toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
}
button,
select,
input {
  font: inherit;
  color: inherit;
}
button {
  background: #fff;
  border: 1px solid #bbb;
  border-radius: 0;
  padding: 6px 10px;
  cursor: pointer;
}
button:hover {
  background: #f1f1f1;
  border-color: #222;
}
button:disabled {
  cursor: wait;
}
select {
  border: 0;
  border-bottom: 1px solid #aaa;
  background: transparent;
  border-radius: 0;
  padding: 3px 16px 3px 3px;
}
:focus-visible {
  outline: 2px solid #555;
  outline-offset: 3px;
}
.workspace {
  background: #f1f1ef;
  padding: 28px;
  overflow: hidden;
}
#sheet-view {
  position: relative;
  margin: 0 auto;
  width: 100%;
  max-width: 960px;
  line-height: 0;
  isolation: isolate;
}
#sheet-canvas {
  width: 100%;
  height: auto;
  display: block;
  background: white;
}
#editor.empty .workspace,
#editor.empty .page-image {
  background: transparent;
}
#sheet-view.empty #sheet-canvas {
  background: transparent;
}
#editor.empty #crop {
  outline-color: #999;
  box-shadow: none;
}
#editor.empty .cell {
  border-color: #999;
  box-shadow: none;
}
#editor.empty .cell-number {
  visibility: hidden;
}
#editor.empty .page canvas {
  outline: 1px solid #999;
}
#crop {
  position: absolute;
  outline: 1px solid #222;
  box-shadow: 0 0 0 2000px #0003;
}
#grid {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(2, 1fr);
}
.cell {
  position: relative;
  min-width: 0;
  min-height: 0;
  padding: 0;
  background: transparent;
  border: 0;
  border-right: 1px solid #2227;
  border-bottom: 1px solid #2227;
  text-align: left;
}
.cell:nth-child(4n) {
  border-right: 0;
}
.cell:nth-child(n + 5) {
  border-bottom: 0;
}
.cell:hover {
  background: #fff1;
  border-color: #2227;
}
.cell:focus-visible {
  outline-offset: -3px;
}
.cell-number {
  position: absolute;
  top: 6px;
  left: 6px;
  min-width: 22px;
  padding: 5px 6px;
  background: #fffe;
  color: #222;
  font-family: "Courier New", monospace;
  font-size: 12px;
  text-align: center;
  line-height: 1;
}
.cell.cover {
  box-shadow: inset 0 0 0 1px #2229;
}
.cell.cover .cell-number {
  background: #222;
  color: #fff;
}
.edge,
#crop i {
  position: absolute;
  touch-action: none;
  z-index: 2;
}
.edge[data-handle="top"] {
  top: -5px;
  left: 9px;
  right: 9px;
  height: 10px;
  cursor: ns-resize;
}
.edge[data-handle="bottom"] {
  bottom: -5px;
  left: 9px;
  right: 9px;
  height: 10px;
  cursor: ns-resize;
}
.edge[data-handle="left"] {
  left: -5px;
  top: 9px;
  bottom: 9px;
  width: 10px;
  cursor: ew-resize;
}
.edge[data-handle="right"] {
  right: -5px;
  top: 9px;
  bottom: 9px;
  width: 10px;
  cursor: ew-resize;
}
#crop i {
  width: 10px;
  height: 10px;
  background: #fff;
  border: 1px solid #222;
}
#crop i[data-handle="top,left"] {
  top: -5px;
  left: -5px;
  cursor: nwse-resize;
}
#crop i[data-handle="top,right"] {
  top: -5px;
  right: -5px;
  cursor: nesw-resize;
}
#crop i[data-handle="bottom,left"] {
  bottom: -5px;
  left: -5px;
  cursor: nesw-resize;
}
#crop i[data-handle="bottom,right"] {
  bottom: -5px;
  right: -5px;
  cursor: nwse-resize;
}
.crop-inputs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 18px;
  padding-top: 16px;
  font-size: 12px;
}
.trim-control {
  display: flex;
  align-items: center;
  gap: 8px;
}
.trim-stepper {
  display: flex;
  align-items: center;
}
.trim-stepper input {
  appearance: textfield;
  -moz-appearance: textfield;
  width: 42px;
  height: 28px;
  border: 0;
  padding: 3px;
  background: transparent;
}
.trim-stepper input::-webkit-inner-spin-button,
.trim-stepper input::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.angle-control {
  display: flex;
  align-items: center;
  gap: 6px;
}
.rotation-zone {
  position: absolute;
  z-index: 3;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  background: transparent;
  opacity: 0;
  color: #222;
  cursor:
    url("rotate-cursor.svg") 10 10,
    crosshair;
  touch-action: none;
}
.rotation-zone:hover,
.rotation-zone:focus-visible,
.rotation-zone.rotating {
  opacity: 1;
  background: transparent;
}
.rotation-zone:focus-visible {
  outline: 1px solid currentColor;
  outline-offset: -3px;
  background: #8882;
}
.rotation-zone[data-rotation-corner="top-left"] {
  top: -28px;
  left: -28px;
  clip-path: polygon(0 0, 100% 0, 100% 50%, 50% 50%, 50% 100%, 0 100%);
}
.rotation-zone[data-rotation-corner="top-right"] {
  top: -28px;
  right: -28px;
  clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 100%, 50% 50%, 0 50%);
}
.rotation-zone[data-rotation-corner="bottom-left"] {
  bottom: -28px;
  left: -28px;
  clip-path: polygon(0 0, 50% 0, 50% 50%, 100% 50%, 100% 100%, 0 100%);
}
.rotation-zone[data-rotation-corner="bottom-right"] {
  bottom: -28px;
  right: -28px;
  clip-path: polygon(50% 0, 100% 0, 100% 100%, 0 100%, 0 50%, 50% 50%);
}
.trim-arrows {
  display: flex;
  flex-direction: column;
}
.trim-arrows button {
  display: grid;
  place-items: center;
  width: 22px;
  height: 14px;
  border: 0;
  padding: 0;
  background: transparent;
}
.trim-arrows button:hover {
  background: #8882;
}
.trim-arrows button::before {
  content: "";
  width: 4px;
  height: 4px;
  border-top: 1px solid currentColor;
  border-left: 1px solid currentColor;
}
.trim-arrows button[data-step="1"]::before {
  transform: translateY(1px) rotate(45deg);
}
.trim-arrows button[data-step="-1"]::before {
  transform: translateY(-1px) rotate(225deg);
}
#pages {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 16px;
}
.page {
  min-width: 0;
}
.page-image {
  background: #f1f1ef;
  padding: 8px;
  display: flex;
  justify-content: center;
  align-items: center;
}
.page canvas {
  width: 100%;
  height: auto;
  display: block;
}
.page-caption {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 8px;
  font-family: "Courier New", monospace;
  font-size: 11px;
}
.page-caption button {
  border: 0;
  padding: 2px 0;
  color: #666;
  font-size: 11px;
}
.export-controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 20px;
  margin-top: 24px;
  font-size: 12px;
}
#dpi {
  border: 0;
}
.export-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}
.primary {
  border-color: #222;
}
.adjustments {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 20px;
  margin-top: 20px;
  font-size: 12px;
}
.adjustments label {
  display: flex;
  align-items: center;
  gap: 10px;
}
.adjustments input {
  appearance: none;
  -webkit-appearance: none;
  width: 120px;
  height: 24px;
  margin: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
}
.adjustments input::-webkit-slider-runnable-track {
  height: 1px;
  background: #aaa;
}
.adjustments input::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 5px;
  height: 13px;
  margin-top: -6px;
  border: 0;
  border-radius: 0;
  background: currentColor;
}
.adjustments input::-moz-range-track {
  height: 1px;
  background: #aaa;
}
.adjustments input::-moz-range-thumb {
  width: 5px;
  height: 13px;
  border: 0;
  border-radius: 0;
  background: currentColor;
}
.adjustments output {
  width: 28px;
  font-family: "Courier New", monospace;
  font-size: 11px;
  text-align: right;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    color: #e5e5e5;
    background: #000;
  }
  body {
    background: #000;
  }
  #status,
  .description {
    color: #999;
  }
  #status.error {
    color: #ff8c8c;
  }
  .upload {
    border-color: #666;
  }
  .upload:focus-within {
    outline-color: #ccc;
  }
  .upload.dragging {
    background: #181818;
  }
  button {
    background: #000;
    border-color: #555;
  }
  button:hover {
    background: #181818;
    border-color: #999;
  }
  select {
    border-color: #666;
  }
  #filename {
    color: #999;
  }
  .rotation-zone {
    color: #ddd;
  }
  select option {
    color: #e5e5e5;
    background: #000;
  }
  :focus-visible {
    outline-color: #ccc;
  }
  .workspace,
  .page-image {
    background: #0b0b0b;
  }
  #sheet-view.empty #sheet-canvas {
    background: #000;
  }
  .page-caption button {
    color: #aaa;
  }
  .primary {
    border-color: #aaa;
  }
  .adjustments input::-webkit-slider-runnable-track {
    background: #555;
  }
  .adjustments input::-moz-range-track {
    background: #555;
  }
  /* Overlay controls sit on the document, not on the themed interface. */
  .cell {
    background: transparent;
    border-color: #2227;
  }
  .cell:hover {
    background: #fff1;
    border-color: #2227;
  }
}
@media (max-width: 720px) {
  main {
    padding: 24px 18px;
  }
  header {
    align-items: flex-start;
    flex-direction: column;
    gap: 14px;
  }
  h1 {
    font-size: 26px;
  }
  .sheet-toolbar {
    justify-content: flex-start;
  }
  .toolbar {
    gap: 10px;
  }
  .file-picker {
    max-width: 100%;
    flex-direction: row-reverse;
    justify-content: flex-end;
    gap: 12px;
  }
  #filename {
    max-width: 150px;
  }
  .cell-number {
    top: 3px;
    left: 3px;
    min-width: 18px;
    padding: 4px;
    font-size: 10px;
  }
  .crop-inputs {
    gap: 12px;
  }
  #pages {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
  }
}
