/* Spend the available room on the frame, rather than empty side columns or
   a caption row below it. Width and height both constrain the portrait. */
body[data-chapter-canvas-refresh] main.ritual-room.canvas > .room-content:has(.wip-canvas-composition) {padding:0;}
body[data-chapter-canvas-refresh] main.ritual-room.canvas .wip-canvas-composition {
  grid-template-columns:94px minmax(0,1fr) 94px;grid-template-rows:minmax(0,1fr) auto;gap:14px 14px;
}
body[data-chapter-canvas-refresh] main.ritual-room.canvas .wip-canvas-composition .canvas-stage-real {
  grid-template-rows:minmax(0,1fr);padding:40px 0 0;
}
body[data-chapter-canvas-refresh] main.ritual-room.canvas .wip-canvas-composition .canvas-art-mount {
  grid-area:1 / 1;width:min(100%,calc(100cqh * 558 / 671));align-self:center;
}
body[data-chapter-canvas-refresh] main.ritual-room.canvas .wip-canvas-composition .canvas-stage-real > .canvas-status {
  position: relative;
  inset: auto;
  grid-area: 1 / 1;
  place-self: center;
  z-index: 9;
  display: grid;
  justify-items: center;
  gap: 8px;
  box-sizing: border-box;
  width: max-content;
  max-width: min(300px, 78cqw, calc(var(--canvas-frame-width, 100cqh * 558 / 671) * .78));
  margin: 0;
  padding: 10px 14px;
  border: 1px solid #8e6b5055;
  border-radius: 5px;
  background: #f8f2e8f7;
  color: #684432;
  font: 500 13px/1.4 var(--pluritual-sans, Arial, sans-serif);
  text-align: center;
  pointer-events: none;
}
body[data-chapter-canvas-refresh] main.ritual-room.canvas .wip-canvas-composition .canvas-status .canvas-load-retry {
  margin: 0;
  pointer-events: auto;
}
body[data-chapter-canvas-refresh] main.ritual-room.canvas .wip-canvas-composition .canvas-art-mount > .canvas-cartel {
  display:block!important;position:absolute;top:-10px;left:4px;z-index:12;transform:translateY(-50%);
  width:auto;margin:0;padding:0;border:0;pointer-events:none;white-space:nowrap;
}
/* A fixed handmade contour for each pigment, with the full native hit area. */
body[data-chapter-canvas-refresh] main.ritual-room.canvas .wip-canvas-palette [data-color]::before {
  border-radius:var(--pigment-shape);rotate:var(--pigment-turn);
}
body[data-chapter-canvas-refresh] main.ritual-room.canvas .wip-canvas-palette [data-color][aria-label="Rose"] {--pigment-shape:46% 54% 51.5% 48.5% / 52% 46% 54% 48%;--pigment-turn:-3deg;}
body[data-chapter-canvas-refresh] main.ritual-room.canvas .wip-canvas-palette [data-color][aria-label="Blue"] {--pigment-shape:52.5% 47.5% 46.5% 53.5% / 45% 51.5% 48.5% 55%;--pigment-turn:2.5deg;}
body[data-chapter-canvas-refresh] main.ritual-room.canvas .wip-canvas-palette [data-color][aria-label="Green"] {--pigment-shape:48.5% 51.5% 56% 44% / 51% 45% 55% 49%;--pigment-turn:-2deg;}
body[data-chapter-canvas-refresh] main.ritual-room.canvas .wip-canvas-palette [data-color][aria-label="Yellow"] {--pigment-shape:54% 46% 49% 51% / 48% 54.5% 45.5% 52%;--pigment-turn:3.5deg;}
body[data-chapter-canvas-refresh] main.ritual-room.canvas .wip-canvas-palette [data-color][aria-label="Orange"] {--pigment-shape:44.5% 55.5% 47.5% 52.5% / 53.5% 49% 51% 46.5%;--pigment-turn:2deg;}
body[data-chapter-canvas-refresh] main.ritual-room.canvas .wip-canvas-palette [data-color][aria-label="Red"] {--pigment-shape:51% 49% 54.5% 45.5% / 44.5% 53% 47% 55.5%;--pigment-turn:-3.5deg;}
body[data-chapter-canvas-refresh] main.ritual-room.canvas .wip-canvas-palette [data-color][aria-label="Brown"] {--pigment-shape:55% 45% 50.5% 49.5% / 52.5% 46.5% 53.5% 47.5%;--pigment-turn:-1.5deg;}
body[data-chapter-canvas-refresh] main.ritual-room.canvas .wip-canvas-palette [data-color][aria-label="Black"] {--pigment-shape:47% 53% 45% 55% / 49% 55.5% 44.5% 51%;--pigment-turn:3deg;}
body[data-chapter-canvas-refresh] main.ritual-room.canvas .wip-canvas-palette [data-color][aria-label="Grey"] {--pigment-shape:50% 50% 56% 44% / 46% 52% 48% 54%;--pigment-turn:1.5deg;}
body[data-chapter-canvas-refresh] main.ritual-room.canvas .wip-canvas-palette [data-color][aria-label="White"] {--pigment-shape:53.5% 46.5% 48% 52% / 54.5% 47.5% 52.5% 45.5%;--pigment-turn:-2.5deg;}
.wip-frame-test-controls {display:flex;flex-wrap:wrap;gap:6px;margin-block:8px;}
.wip-frame-test-controls [aria-pressed="true"] {outline:1px solid currentColor;outline-offset:2px;}
@media(min-width:901px) {
  /* Share the frame's size container: the palette sits 20px from its actual edge. */
  body[data-chapter-canvas-refresh] main.ritual-room.canvas .wip-canvas-composition {position:relative;container-type:size;}
  body[data-chapter-canvas-refresh] main.ritual-room.canvas .wip-canvas-palette {position:absolute;grid-area:auto;left:calc(50% + var(--canvas-frame-width,600px)/2 + 20px);top:var(--canvas-frame-center,45%);transform:translateY(-50%);}
}
@media(max-width:900px) {
  body[data-chapter-canvas-refresh] main.ritual-room.canvas .wip-canvas-composition {grid-template-columns:minmax(0,1fr);grid-template-rows:minmax(0,1fr) max-content auto;gap:6px;}
  body[data-chapter-canvas-refresh] main.ritual-room.canvas .wip-canvas-composition .canvas-stage-real {padding-top:44px;}
  body[data-chapter-canvas-refresh] main.ritual-room.canvas .wip-canvas-composition .canvas-art-mount > .canvas-cartel {top:-38px;left:0;transform:none;}
}
@media(min-width:700px) and (max-width:900px) and (max-height:500px) {
  body[data-chapter-canvas-refresh] main.ritual-room.canvas .wip-canvas-composition {grid-template-columns:minmax(0,1.2fr) minmax(230px,1fr);grid-template-rows:88px auto minmax(0,1fr);gap:6px 16px;}
}
/* Keep the portrait frame and its original controls in one compact group. */
@media(max-width:699px),(orientation:portrait){
  body[data-chapter-canvas-refresh] main.ritual-room.canvas .wip-canvas-composition {
    display: flex;
    flex-direction: column;
    justify-content: safe center;
    container-type: inline-size;
    gap: 8px;
    height: 100%;
    min-height: 0;
  }
  body[data-chapter-canvas-refresh] main.ritual-room.canvas > .room-content:has(.wip-canvas-composition) {overflow-y:auto;overflow-x:hidden;}
  body[data-chapter-canvas-refresh] main.ritual-room.canvas .wip-canvas-composition .canvas-stage-real {
    /* Cap the portrait at the height implied by its width and two 34px clearances. */
    flex: 0 1 calc(100cqw * 671 / 558 + 68px);
    grid-template-rows: minmax(0, 1fr);
    height: auto;
    min-height: 0;
    padding: 34px 0;
  }
  body[data-chapter-canvas-refresh] main.ritual-room.canvas .wip-canvas-composition .canvas-art-mount {
    grid-area: 1 / 1;
    align-self: center;
    container-type: inline-size;
    width: min(100%, calc(100cqh * 558 / 671));
  }
  body[data-chapter-canvas-refresh] main.ritual-room.canvas .wip-canvas-composition .canvas-art-mount > .canvas-cartel {
    top: -24px;
    left: 4px;
    transform: none;
  }
  body[data-chapter-canvas-refresh] main.ritual-room.canvas .wip-canvas-palette {position:static;transform:none;flex:none;align-self:center;width:max-content;max-width:100%;}
  body[data-chapter-canvas-refresh] main.ritual-room.canvas .wip-canvas-palette .canvas-palette {grid-template-columns:repeat(10,minmax(0,44px));gap:0;}
  body[data-chapter-canvas-refresh] main.ritual-room.canvas .wip-canvas-palette [data-color] {min-width:0;width:100%;}
  body[data-chapter-canvas-refresh] main.ritual-room.canvas .wip-canvas-composition .canvas-hand-card {flex:none;align-self:center;gap:8px;padding:0;}
  @container(max-width:340px){
    body[data-chapter-canvas-refresh] main.ritual-room.canvas .wip-canvas-composition .canvas-art-mount > .canvas-cartel {display:none!important;}
  }
}
@media(max-width:419px){
  body[data-chapter-canvas-refresh] main.ritual-room.canvas .wip-canvas-palette .canvas-palette {grid-template-columns:repeat(5,44px);gap:0 8px;}
}
/* The hand overlaps the lower moulding while its action stays below the frame. */
body[data-chapter-canvas-refresh] main.ritual-room.canvas .wip-canvas-composition {
  position: relative;
  --canvas-slot-overlap: clamp(6px, calc(var(--canvas-frame-width, 320px) * .04), 28px);
}
body[data-chapter-canvas-refresh] main.ritual-room.canvas .wip-canvas-composition .canvas-stage-real {
  padding-bottom: 22px;
}
body[data-chapter-canvas-refresh] main.ritual-room.canvas .wip-canvas-composition #handSlots {
  position: absolute;
  grid-area: auto;
  top: calc(var(--canvas-frame-bottom, 100%) - var(--canvas-slot-overlap));
  left: var(--canvas-frame-center-x, 50%);
  transform: translateX(-50%);
  z-index: 8;
}
/* Canvas controls and proposal cards share the finish of the pixel wells. */
body[data-chapter-canvas-refresh] main.ritual-room.canvas .wip-canvas-composition #handSlots .hand-slot,
body[data-chapter-canvas-refresh] main.ritual-room.canvas :is(.canvas-stage-real .canvas-tools .canvas-tool-group > button, .canvas-filter-panel .canvas-live-card) {
  border: 1px solid var(--canvas-control-edge, #8e6b50);
  border-radius: 3px;
  background: var(--canvas-control-fill, #d9c6ad);
  color: #66452f;
  box-shadow: var(--canvas-control-shadow, inset 0 2px 4px #694a383d, 0 1px 0 #fff7);
}
body[data-chapter-canvas-refresh] main.ritual-room.canvas .canvas-stage-real :is(.canvas-tools, .canvas-tools .canvas-tool-group) {
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}
body[data-chapter-canvas-refresh] main.ritual-room.canvas .canvas-stage-real .canvas-tools .canvas-tool-zoom {
  gap: inherit;
}
body[data-chapter-canvas-refresh] main.ritual-room.canvas :is(.canvas-stage-real .canvas-tools .canvas-tool-group > button, .canvas-filter-panel .canvas-live-card):where(:hover:not(:disabled)) {
  background: var(--canvas-control-hover, #e5d4bd);
}
body[data-chapter-canvas-refresh] main.ritual-room.canvas :is(.canvas-stage-real .canvas-tools .canvas-tool-group > button, .canvas-filter-panel .canvas-live-card)[aria-pressed="true"] {
  background: var(--canvas-control-active, #a3503a);
  color: var(--canvas-control-active-ink, #fff8ed);
}
body[data-chapter-canvas-refresh] main.ritual-room.canvas .canvas-stage-real .canvas-tools .canvas-tool-group > button:disabled {
  color: #987e67;
  opacity: 1;
}
body[data-chapter-canvas-refresh] main.ritual-room.canvas .wip-canvas-composition #handSlots .hand-slot.empty > span {
  background: transparent;
}
body[data-chapter-canvas-refresh] main.ritual-room.canvas .wip-canvas-composition #handSlots .hand-slot.filled {
  background: #ede0cb;
  box-shadow: 0 1px 2px #694a3840;
}
body[data-chapter-canvas-refresh] main.ritual-room.canvas .wip-canvas-composition #handSlots .hand-slot.filled > span {
  box-shadow: inset 0 0 0 1px #694a384d;
}
body[data-chapter-canvas-refresh] main.ritual-room.canvas .wip-canvas-composition .canvas-guidance.is-invitation {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  overflow: hidden !important;
  clip-path: inset(50%) !important;
  pointer-events: none;
}
@media (min-width: 901px) and (min-height: 1000px) and (orientation: landscape) {
  body[data-chapter-canvas-refresh] main.ritual-room.canvas .wip-canvas-composition .canvas-stage-real { padding-bottom: 10px; }
}
@media (max-width: 900px), (orientation: portrait) {
  body[data-chapter-canvas-refresh] main.ritual-room.canvas .wip-canvas-composition .canvas-stage-real { padding-bottom: 34px; }
}
@media (min-width: 700px) and (max-width: 900px) and (max-height: 500px) {
  body[data-chapter-canvas-refresh] main.ritual-room.canvas .wip-canvas-composition .canvas-stage-real {
    padding-block: 28px 30px;
  }
  body[data-chapter-canvas-refresh] main.ritual-room.canvas .wip-canvas-composition .canvas-art-mount > .canvas-cartel {
    top: -27px;
  }
  body[data-chapter-canvas-refresh] main.ritual-room.canvas .wip-canvas-composition .hand-slot {
    width: 30px !important;
    min-width: 30px !important;
    height: 30px !important;
  }
  body[data-chapter-canvas-refresh] main.ritual-room.canvas .wip-canvas-composition #handSlots { gap: 4px !important; }
}
