body[data-view='editor'] {
  overflow: hidden;
  background: var(--side);
}
.ed-top {
  height: 58px;
  position: relative;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 clamp(14px, 1.45vw, 30px);
  background: #f5f3f0;
  border-bottom: 1px solid #dbd7d0;
}
#ed-left,
#ed-right {
  display: flex;
  align-items: center;
  gap: 8px;
}
#ed-left {
  min-width: 0;
}
#ed-right {
  flex-shrink: 0;
}
.ed-top button:not(.seal) {
  padding: 7px;
  border: 0;
  border-radius: 6px;
  color: #7d7366;
}
.ed-top .icon {
  width: 17px;
  height: 17px;
}
#ed-title {
  color: #776d60;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}
.seal {
  font-size: 12px;
  padding: 8px 14px;
  margin-left: 5px;
}
#ed-status,
.tool-group h3,
.photo-switch {
  font: 500 11px/1.55 var(--sans);
  text-transform: uppercase;
  letter-spacing: 0.035em;
  color: #817668;
}
.workspace {
  --railw: clamp(210px, 15.6vw, 320px);
  --pad: clamp(20px, 4.45dvh, 48px);
  height: calc(100dvh - 58px);
  display: grid;
  grid-template-columns: var(--railw) minmax(0, 1fr);
  position: relative;
}
.tools {
  overflow: auto;
  min-height: 0;
  padding: 23px clamp(14px, 1.2vw, 25px);
  background: #f5f3f0;
  border-right: 1px solid #ddd8d1;
  scrollbar-width: thin;
}
.tool-group {
  position: relative;
  margin-bottom: 26px;
}
.tool-group h3 {
  margin: 0 0 12px;
}
.elements {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 9px;
}
.element {
  grid-column: span 2;
  min-width: 0;
  min-height: 68px;
  flex-direction: column;
  padding: 9px 2px;
  gap: 7px;
  color: #807467;
  border-radius: 10px;
  font-size: 11px;
}
.element:nth-child(-n + 2) {
  grid-column: span 3;
}
.element .icon {
  width: 20px;
  height: 20px;
}
.pager {
  position: absolute;
  top: -3px;
  right: 0;
  display: flex;
}
.pager button {
  padding: 3px;
  border: 0;
}
.pager .icon {
  width: 14px;
  height: 14px;
}
.sticker-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 9px;
}
.sticker-grid button {
  height: clamp(42px, 3.8vw, 72px);
  border: 0;
  padding: 6px;
}
.sticker-grid img {
  display: block;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}
.photo-switch {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0 0 22px;
}
.photo-switch input {
  accent-color: #786a56;
  width: 16px;
  height: 16px;
}
.swatches {
  display: grid;
  grid-template-columns: repeat(5, minmax(20px, 1fr));
  gap: 10px 8px;
}
.swatch {
  width: clamp(25px, 2vw, 40px);
  aspect-ratio: 1;
  border-radius: 50%;
  padding: 0;
  border: 1px solid #d5cfc5;
  background-size: cover;
  background-position: center;
}
.swatch[aria-pressed='true'] {
  outline: 2px solid #85745c;
  outline-offset: 2px;
}
.swatch.upload-bg {
  border-style: dashed;
}
.paper-buttons {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
}
.paper-buttons button {
  font-size: 11px;
  padding: 4px 7px;
}
.paper-buttons [aria-pressed='true'] {
  background: #e5ded3;
}
.tools label {
  font-size: 12px;
}
.tools textarea {
  min-height: 90px;
}
.tools input[type='range'] {
  width: 100%;
  accent-color: #88735d;
}
.tools input[type='color'] {
  width: 100%;
  height: 32px;
  background: transparent;
  border: 1px solid var(--line);
}
.stage,
.read-scene {
  background-position: center;
  background-size: cover;
  background-color: #999782;
}
.stage {
  min-width: 0;
  min-height: 0;
  overflow: auto;
  scrollbar-width: thin;
}
.stage.panning {
  cursor: grab;
  touch-action: none;
}
.panning .piece {
  pointer-events: none;
}
.stage-center {
  width: max-content;
  min-width: 100%;
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: var(--pad) 18px;
}
#paper-size {
  --zoom: 1;
  width: calc(
    min(
        calc((100dvh - 60px - var(--pad) - var(--pad)) * 0.75),
        calc(100vw - var(--railw) - 45px)
      ) *
      var(--zoom)
  );
  filter: drop-shadow(0 4px 10px #30322218);
}
.sheet {
  position: relative;
  isolation: isolate;
  container-type: inline-size;
  aspect-ratio: 3/4;
  width: 100%;
  background: #fffdf8;
  overflow: hidden;
  clip-path: polygon(
    0 0.18%,
    3% 0.11%,
    7% 0.23%,
    11% 0.07%,
    16% 0.13%,
    21% 0,
    26% 0.2%,
    34% 0.1%,
    39% 0.26%,
    46% 0.08%,
    56% 0.2%,
    65% 0,
    74% 0.1%,
    81% 0.04%,
    88% 0.19%,
    96% 0.04%,
    100% 0.15%,
    100% 99.87%,
    96% 99.96%,
    92% 99.83%,
    85% 99.94%,
    81% 99.77%,
    75% 99.89%,
    67% 99.76%,
    59% 100%,
    52% 99.85%,
    45% 100%,
    36% 99.82%,
    30% 99.96%,
    22% 99.8%,
    13% 99.96%,
    7% 99.77%,
    0 99.94%
  );
}
.paper-lines {
  background-color: #fffffd;
  background-image:
    linear-gradient(#fffffd 0 10%, transparent 16%),
    repeating-linear-gradient(
      to bottom,
      transparent 0 3.62%,
      #b4bfbd50 3.73%,
      transparent 3.84%
    );
}
.paper-pink {
  background-color: #f8e8e1;
}
.paper-green {
  background-color: #e6edde;
}
.piece {
  position: absolute;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.35;
  transform-origin: center;
  min-width: 2px;
  color: #59534c;
}
.piece-content {
  min-height: 0.5em;
}
.piece-content a {
  color: #894239;
}
.piece-content :is(img, video, audio) {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
}
.piece-content audio {
  min-height: 36px;
}
.photocard {
  background: #fffdf9;
  padding: 5% 5% 15%;
  box-shadow: 0 1px 5px #29241c30;
}
#sheet .piece {
  touch-action: none;
  user-select: none;
  cursor: move;
}
#sheet .piece-content {
  pointer-events: none;
}
#sheet .selected {
  outline: 1.5px solid #579afa;
}
.sel-bar {
  display: flex;
  gap: 2px;
  position: absolute;
  bottom: calc(100% + 10px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 5;
  padding: 3px;
  background: #fff;
  border: 1px solid #dedbd4;
  border-radius: 8px;
  box-shadow: 0 3px 9px #27251f1d;
}
.sel-bar.below {
  bottom: auto;
  top: calc(100% + 34px);
}
.sel-bar button {
  padding: 5px;
  border: 0;
  color: #837667;
}
.sel-bar .icon {
  width: 14px;
  height: 14px;
}
.grip {
  position: absolute;
  width: 11px;
  height: 11px;
  background: white;
  border: 1.5px solid #579afa;
  border-radius: 50%;
  padding: 0;
  z-index: 4;
}
.grip.nw {
  left: -5px;
  top: -5px;
  cursor: nwse-resize;
}
.grip.ne {
  right: -5px;
  top: -5px;
  cursor: nesw-resize;
}
.grip.sw {
  left: -5px;
  bottom: -5px;
  cursor: nesw-resize;
}
.grip.se {
  right: -5px;
  bottom: -5px;
  cursor: nwse-resize;
}
.grip.rotate {
  width: 23px;
  height: 23px;
  top: calc(100% + 10px);
  left: calc(50% - 11px);
  border-color: #d5cfc6;
  cursor: grab;
}
.grip.rotate .icon {
  width: 14px;
  height: 14px;
}
#viewport-tools {
  position: absolute;
  right: 18px;
  bottom: 18px;
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 4px 8px;
  border: 1px solid #e4e0d7;
  background: #fffcf3e6;
  border-radius: 25px;
  box-shadow: 0 2px 10px #332d1f16;
}
#viewport-tools button {
  padding: 5px;
  border: 0;
  border-radius: 50%;
}
#viewport-tools .icon {
  width: 16px;
  height: 16px;
}
[data-scene='meadow'] {
  background-image: url('assets/meadow.webp');
}
[data-scene='blush'] {
  background-image: radial-gradient(circle at 55% 50%, #efcfa8, #b5a69c);
}
[data-scene='sunset'] {
  background-image: linear-gradient(165deg, #617d99, #f1b4a3 60%, #efd1ac);
}
[data-scene='linen'] {
  background-image: url('assets/paper.webp');
  background-size: 210px;
}
[data-scene='cream'] {
  background-image: linear-gradient(130deg, #d1c6ad, #f3ebd9, #c8baa3);
}
[data-scene='olive'] {
  background-image: radial-gradient(ellipse at 70% 20%, #c8caa0, #7e835a);
}
[data-scene='sky'] {
  background-image: linear-gradient(#7098b8, #b9cccd 60%, #ebc99f);
}
[data-scene='night'] {
  background-image: radial-gradient(ellipse at top right, #4b5c77, #161f30 80%);
}
[data-scene='grid'] {
  background-color: #ece8de;
  background-image:
    repeating-linear-gradient(0deg, transparent 0 23px, #9c95866b 23px 24px),
    repeating-linear-gradient(90deg, transparent 0 23px, #9c95866b 23px 24px);
}
[data-scene='check'] {
  background-color: #d3d7bd;
  background-image:
    repeating-linear-gradient(0deg, transparent 0 5px, #757e5a50 5px 6px),
    repeating-linear-gradient(90deg, transparent 0 5px, #757e5a50 5px 6px);
}
.reading-dialog {
  width: min(96vw, 940px);
  max-height: 94dvh;
  padding: 0;
  border: 0;
  border-radius: 12px;
}
.reading-dialog #dialog-title {
  position: absolute;
  z-index: 1;
  top: 13px;
  left: 17px;
  max-width: 75%;
  margin: 0;
  padding: 0;
  color: #fff;
  text-shadow: 0 1px 5px #242516;
  font: 500 12px var(--sans);
  letter-spacing: 0;
}
.reading-dialog #close-dialog {
  background: #fffdf9e8;
}
.read-scene {
  display: grid;
  justify-items: center;
  padding: 44px 22px 26px;
}
.read-scene .sheet {
  width: min(100%, 59vh);
}
@media (max-width: 719px) {
  .ed-top {
    height: 77px;
    flex-wrap: wrap;
    align-content: center;
    gap: 0;
    padding: 4px 9px;
  }
  #ed-left {
    width: 100%;
    font-size: 12px;
  }
  #ed-right {
    width: 100%;
    justify-content: flex-end;
    gap: 3px;
  }
  #ed-status {
    margin-right: auto;
    padding-left: 7px;
    font-size: 9px;
  }
  .ed-top button:not(.seal) {
    padding: 5px;
  }
  .seal {
    font-size: 10px;
    padding: 6px 8px;
  }
  .workspace {
    height: calc(100dvh - 77px);
    display: flex;
    flex-direction: column;
    --pad: 12px;
  }
  .stage {
    order: 1;
    flex: 1 1 auto;
  }
  .stage-center {
    padding: 12px 10px;
  }
  #paper-size {
    width: calc(
      min(88vw, max(110px, calc((100dvh - 272px) * 0.75))) * var(--zoom)
    );
  }
  .tools {
    order: 2;
    flex: 0 0 166px;
    display: flex;
    width: 100%;
    align-items: flex-start;
    gap: 20px;
    padding: 12px 15px;
    border: 0;
    border-top: 1px solid var(--line);
    overflow: auto;
  }
  .tool-group {
    flex: 0 0 auto;
    min-width: 172px;
    margin: 0;
  }
  .tool-group h3 {
    font-size: 9px;
    margin-bottom: 5px;
  }
  .elements {
    gap: 3px;
  }
  .element {
    min-height: 42px;
    gap: 2px;
    padding: 3px;
    font-size: 9px;
  }
  .element .icon {
    width: 15px;
    height: 15px;
  }
  .sticker-grid {
    grid-template-columns: repeat(3, 38px);
    gap: 3px;
  }
  .sticker-grid button {
    height: 38px;
    padding: 3px;
  }
  .tools .photo-switch {
    min-width: 85px;
    flex-direction: column;
    gap: 11px;
    font-size: 9px;
    margin: 0;
  }
  .tools.editing {
    display: block;
  }
  .tools.editing .tool-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 5px 13px;
  }
  .tools.editing h3 {
    grid-column: 1/-1;
  }
  .tools label {
    margin: 3px 0;
    font-size: 10px;
  }
  .tools textarea {
    min-height: 58px;
  }
  .swatches {
    grid-template-columns: repeat(5, 24px);
    gap: 6px;
  }
  .swatch {
    width: 24px;
  }
  #viewport-tools {
    bottom: 176px;
    right: 9px;
    padding: 2px 4px;
  }
  #viewport-tools button {
    padding: 3px;
  }
  .sel-bar {
    gap: 0;
    padding: 2px;
  }
  .sel-bar button {
    padding: 3px;
  }
  .sel-bar .icon {
    width: 12px;
    height: 12px;
  }
  .reading-dialog {
    width: 96vw;
  }
  .read-scene {
    padding: 47px 10px 24px;
  }
  .read-scene .sheet {
    width: min(100%, 62vh);
  }
}
