/* Eight Worlds structural contract.
   Rails are 64×48, corners 48×48; the physical cut is at 32, with radius 16.
   Whole stitch cells fit each rail length; corners and focal art never stretch.
   Theme files supply materials and illustrations, never a second frame. */
body:is([data-visual-theme='pastel-princess'], [data-visual-theme='field-journal'], [data-world-family]) .editor-scroll {
  container: world-desk / inline-size;
}
body:is([data-visual-theme='pastel-princess'], [data-visual-theme='field-journal'], [data-world-family]) .ink-stage {
  --world-frame-size: 48px;
  --world-frame-overlap: 16px;
  --world-board-radius: calc(var(--world-frame-size) / 3);
  --world-rail-length: calc(var(--world-frame-size) * 4 / 3);
  --world-rail-inset: var(--world-frame-size);
  margin: 68px auto 66px;
  max-width: min(1160px, calc(100% - 144px));
  border: 0;
  background: none;
  box-shadow: none;
  isolation: isolate;
  overflow: visible;
}
body:is([data-visual-theme='pastel-princess'], [data-visual-theme='field-journal'], [data-world-family]) .ink-stage::before,
body:is([data-visual-theme='pastel-princess'], [data-visual-theme='field-journal'], [data-world-family]) .ink-stage::after {
  display: none;
  content: none;
}

/* Exactly one slab, exactly the editor's dimensions. No four-pixel extension
   outside the covered cut, no inset highlight masquerading as another frame. */
body:is([data-visual-theme='pastel-princess'], [data-visual-theme='field-journal'], [data-world-family]) .theme-board-underlay {
  position: absolute;
  z-index: 0;
  inset: 0;
  display: block;
  border: 0;
  border-radius: var(--world-board-radius);
  background: var(--world-surface);
  box-shadow: 0 7px 15px rgb(43 30 25 / .15);
  pointer-events: none;
}
body:is([data-visual-theme='pastel-princess'], [data-visual-theme='field-journal'], [data-world-family]) .theme-board-underlay::before,
body:is([data-visual-theme='pastel-princess'], [data-visual-theme='field-journal'], [data-world-family]) .theme-board-underlay::after {
  display: none;
  content: none;
}
body:is([data-visual-theme='pastel-princess'], [data-visual-theme='field-journal'], [data-world-family]) .note-editor {
  /* Keep the paper at the base without trapping its placed content below the
     sibling margin/grain layers. Objects share the stage's z2, below the z4 frame. */
  z-index: auto;
  border: 0;
  border-radius: var(--world-board-radius);
  background-color: var(--world-surface);
  box-shadow: none;
}
body:is([data-visual-theme='pastel-princess'], [data-visual-theme='field-journal'], [data-world-family]) .board-decoration {
  z-index: 1;
  overflow: hidden;
}
body:is([data-visual-theme='pastel-princess'], [data-visual-theme='field-journal'], [data-world-family]) .board-ornament {
  display: none;
}

/* Non-directional material grain. The ruled/grid geometry is owned by the
   theme's paper style; a second diagonal 'fiber rule' cannot leak into it. */
body:is([data-visual-theme='pastel-princess'], [data-visual-theme='field-journal'], [data-world-family]) .theme-material-grain {
  position: absolute;
  z-index: 1;
  inset: 0;
  display: block;
  overflow: hidden;
  border-radius: var(--world-board-radius);
  background: var(--world-paper-grain) 0 0 / 256px 256px repeat;
  opacity: .42;
  mix-blend-mode: normal;
  pointer-events: none;
}
body:is([data-visual-theme='pastel-princess'], [data-visual-theme='field-journal'], [data-world-family])[data-paper='chalkboard'] .theme-material-grain {
  background-image: var(--world-chalk-grain);
  background-size: 384px 384px;
  opacity: .46;
}
body:is([data-visual-theme='pastel-princess'], [data-visual-theme='field-journal'], [data-world-family]) .theme-material-grain::before,
body:is([data-visual-theme='pastel-princess'], [data-visual-theme='field-journal'], [data-world-family]) .theme-material-grain::after {
  display: none;
  content: none;
}

/* A balanced pair of still-life illustrations belongs to the surrounding desk,
   not the board's edge. Their shared centerline and responsive outer margins
   replace the old three arbitrarily staggered stickers. Percentage lengths are
   resolved against the board; cqw measures the actual editor pane, even split. */
body:is([data-visual-theme='pastel-princess'], [data-visual-theme='field-journal'], [data-world-family]) .theme-atmosphere {
  position: absolute;
  z-index: 5;
  inset: 0;
  display: block;
  overflow: visible;
  border: 0;
  border-radius: 0;
  background: none;
  box-shadow: none;
  pointer-events: none;
}
body:is([data-visual-theme='pastel-princess'], [data-visual-theme='field-journal'], [data-world-family]) .theme-atmosphere::before,
body:is([data-visual-theme='pastel-princess'], [data-visual-theme='field-journal'], [data-world-family]) .theme-atmosphere::after {
  display: none;
  content: none;
}

/* Layer 4: complete foreground perimeter. */
body:is([data-visual-theme='pastel-princess'], [data-visual-theme='field-journal'], [data-world-family]) .theme-frame {
  z-index: 4;
  inset: calc(var(--world-frame-overlap) - var(--world-frame-size));
  display: block;
  overflow: visible;
  border: 0;
  background: none;
  filter: none;
  isolation: isolate;
}
body:is([data-visual-theme='pastel-princess'], [data-visual-theme='field-journal'], [data-world-family]) .theme-frame::before,
body:is([data-visual-theme='pastel-princess'], [data-visual-theme='field-journal'], [data-world-family]) .theme-frame::after {
  display: none;
  content: none;
}
body:is([data-visual-theme='pastel-princess'], [data-visual-theme='field-journal'], [data-world-family]) .theme-frame :is(.theme-frame-edge, .theme-frame-corner) {
  display: block;
  border: 0;
  border-image: none;
  background-position: left top;
  opacity: 1;
  filter: none;
  transform: none;
}
body:is([data-visual-theme='pastel-princess'], [data-visual-theme='field-journal'], [data-world-family]) :is(.theme-frame-edge-top, .theme-frame-edge-bottom) {
  right: var(--world-rail-inset);
  left: var(--world-rail-inset);
  height: var(--world-frame-size);
  background-repeat: round no-repeat;
  background-size: var(--world-rail-length) 100%;
}
body:is([data-visual-theme='pastel-princess'], [data-visual-theme='field-journal'], [data-world-family]) :is(.theme-frame-edge-left, .theme-frame-edge-right) {
  top: var(--world-rail-inset);
  bottom: var(--world-rail-inset);
  width: var(--world-frame-size);
  background-repeat: no-repeat round;
  background-size: 100% var(--world-rail-length);
}
body:is([data-visual-theme='pastel-princess'], [data-visual-theme='field-journal'], [data-world-family]) .theme-frame-edge-top {
  top: 0;
  bottom: auto;
  background-image: var(--world-rail-top);
}
body:is([data-visual-theme='pastel-princess'], [data-visual-theme='field-journal'], [data-world-family]) .theme-frame-edge-bottom {
  top: auto;
  bottom: 0;
  background-image: var(--world-rail-bottom);
}
body:is([data-visual-theme='pastel-princess'], [data-visual-theme='field-journal'], [data-world-family]) .theme-frame-edge-left {
  right: auto;
  left: 0;
  background-image: var(--world-rail-left);
}
body:is([data-visual-theme='pastel-princess'], [data-visual-theme='field-journal'], [data-world-family]) .theme-frame-edge-right {
  right: 0;
  left: auto;
  background-image: var(--world-rail-right);
}
body:is([data-visual-theme='pastel-princess'], [data-visual-theme='field-journal'], [data-world-family]) .theme-frame-corner {
  z-index: 1;
  width: var(--world-frame-size);
  height: var(--world-frame-size);
  background-repeat: no-repeat;
  background-size: contain;
}
body:is([data-visual-theme='pastel-princess'], [data-visual-theme='field-journal'], [data-world-family]) .theme-frame-corner-top-left {
  inset: 0 auto auto 0;
  background-image: var(--world-corner-tl);
}
body:is([data-visual-theme='pastel-princess'], [data-visual-theme='field-journal'], [data-world-family]) .theme-frame-corner-top-right {
  inset: 0 0 auto auto;
  background-image: var(--world-corner-tr);
}
body:is([data-visual-theme='pastel-princess'], [data-visual-theme='field-journal'], [data-world-family]) .theme-frame-corner-bottom-right {
  inset: auto 0 0 auto;
  background-image: var(--world-corner-br);
}
body:is([data-visual-theme='pastel-princess'], [data-visual-theme='field-journal'], [data-world-family]) .theme-frame-corner-bottom-left {
  inset: auto auto 0 0;
  background-image: var(--world-corner-bl);
}

body:is([data-visual-theme='pastel-princess'], [data-visual-theme='field-journal'], [data-world-family]) .theme-frame-bow {
  display: none;
}
body[data-visual-theme='pastel-princess'] .theme-frame-bow {
  z-index: 6;
  top: -22px;
  left: 50%;
  display: block;
  width: 112px;
  height: 94px;
  border: 0;
  border-radius: 0;
  background: var(--world-focal) center / contain no-repeat;
  box-shadow: none;
  transform: translateX(-50%);
}
body[data-visual-theme='pastel-princess'] .theme-frame-companion { display: none; }
body:is([data-visual-theme='pastel-princess'], [data-visual-theme='field-journal'], [data-world-family]) .board-resize-handle {
  bottom: calc(var(--world-frame-overlap) - var(--world-frame-size) - 32px);
}
body:is([data-visual-theme='pastel-princess'], [data-visual-theme='field-journal'], [data-world-family]) .editor-hint { display: none; }

/* Compact editor padding must still clear the foreground trim. The base app's
   12px tablet inset is smaller than this frame's 16px physical overlap. */
@media (max-width: 820px), (hover: none) and (pointer: coarse) {
  body:is([data-visual-theme='pastel-princess'], [data-visual-theme='field-journal'], [data-world-family]) .note-editor {
    padding-left: max(12px, calc(var(--world-frame-overlap) + 4px));
    padding-right: max(12px, calc(var(--world-frame-overlap) + 4px));
  }
}

@media (max-width: 600px) {
  body:is([data-visual-theme='pastel-princess'], [data-visual-theme='field-journal'], [data-world-family]) .ink-stage {
    --world-frame-size: 32px;
    --world-frame-overlap: 10.6667px;
    margin-top: 94px;
    max-width: calc(100% - 80px);
  }
  body[data-visual-theme='pastel-princess'] .theme-frame-bow { width: 82px; height: 70px; top: -20px; }
    }

@media print {
  body:is([data-visual-theme='pastel-princess'], [data-visual-theme='field-journal'], [data-world-family]) :is(.theme-frame, .theme-atmosphere, .theme-material-grain, .theme-board-underlay, .board-decoration, .board-ornament) {
    display: none !important;
  }
  body:is([data-visual-theme='pastel-princess'], [data-visual-theme='field-journal'], [data-world-family]) :is(.note-editor, .print-board-content) {
    color: #111 !important;
    border: 0 !important;
    background: #fff !important;
    box-shadow: none !important;
  }
}
