/* Local scene tokens: the original homepage keeps its established palette. */
.kraft-upstairs {
  --upstairs-floor: #d2d5dc;
  --upstairs-ink: #454648;
  --upstairs-blue: #384cff;
  --upstairs-focus: #263ed6;
  position: fixed;
  inset: 0;
  box-sizing: border-box;
  width: 100%;
  max-width: none;
  height: 100vh;
  height: 100dvh;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  overflow: hidden;
  color: var(--upstairs-ink);
  background: var(--upstairs-floor);
  transform: translateY(-101%);
  transition: transform 650ms cubic-bezier(.22, .8, .22, 1);
  overscroll-behavior: contain;
  font-family: KraftSpace, 'Courier New', monospace;
}
.kraft-upstairs[data-visible="true"] { transform: translateY(0); }
.kraft-upstairs::backdrop { background: transparent; }
.kraft-upstairs-canvas { display: block; width: 100%; height: 100%; }
.kraft-upstairs button {
  appearance: none;
  border: 0;
  color: inherit;
  background: transparent;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.kraft-upstairs-brand {
  position: absolute;
  top: max(20px, env(safe-area-inset-top));
  left: max(40px, env(safe-area-inset-left));
  min-height: 44px;
  padding: 0;
  font-family: KraftSpace, 'Courier New', monospace;
  display: flex;
  align-items: center;
  width: 160px;
}
.kraft-upstairs-brand img { display: block; width: 100%; height: auto; }
.kraft-upstairs-return {
  position: absolute;
  left: 50%;
  bottom: max(40px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  min-height: 44px;
  padding: 8px 12px;
  white-space: nowrap;
  font-family: 'Courier New', monospace;
  font-size: clamp(14px, 1.2vw, 18px);
  line-height: 1.5;
  letter-spacing: .15px;
}
.kraft-upstairs-return span { display: inline-block; transition: transform 180ms ease; }
.kraft-upstairs-return:hover span { transform: translateY(3px); }
.kraft-upstairs button:hover { color: #202123; }
.kraft-upstairs button:active { opacity: .68; }
.kraft-upstairs button:focus-visible,
.kraft-header .kraft-upstairs-open:focus-visible { outline: 2px solid #263ed6; outline-offset: 5px; }
.kraft-header .kraft-upstairs-open {
  display: inline-grid;
  position: absolute;
  right: clamp(18px, 3vw, 42px);
  bottom: -40px;
  z-index: 1;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 50%;
  color: inherit;
  background: transparent;
  font: 24px/1 'Courier New', monospace;
  cursor: pointer;
  transition: border-color 180ms ease, transform 180ms ease;
}
.kraft-header .kraft-upstairs-open:hover { border-color: currentColor; transform: translateY(-2px); }
.kraft-header .kraft-upstairs-open:active { transform: translateY(0); }
.kraft-upstairs-copy {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  -webkit-user-select: text;
  user-select: text;
  cursor: text;
}
.kraft-upstairs-copy h2, .kraft-upstairs-copy p { font: inherit; color: inherit; margin: 0 0 .5em; white-space: pre; }
.kraft-upstairs-copy:focus-visible { outline: none; }
.kraft-upstairs-copy:focus-visible .kraft-upstairs-line { outline: 2px solid var(--upstairs-focus); outline-offset: 4px; }
/* Native glyph boxes share the tile renderer's coordinates and character advance.
   They stay transparent because selection is painted using the same ceramic tiles. */
.kraft-upstairs[data-renderer="ready"] .kraft-upstairs-copy {
  inset: 0;
  width: auto;
  height: auto;
  margin: 0;
  overflow: visible;
  clip-path: none;
  color: transparent;
  pointer-events: none;
}
.kraft-upstairs[data-renderer="ready"] .kraft-upstairs-line {
  position: absolute;
  left: var(--quote-x, 0px);
  top: var(--quote-y, 0px);
  display: block;
  height: 8px;
  font: 10px/8px monospace;
  letter-spacing: 0;
  text-transform: none;
  text-shadow: none;
  white-space: pre;
  transform-origin: 0 0;
  transform: matrix(var(--quote-pixel, 1), calc(var(--quote-pixel, 1) * -.16), calc(var(--quote-pixel, 1) * .24), var(--quote-pixel, 1), 0, 0);
  pointer-events: auto;
}
.kraft-upstairs[data-renderer="ready"] .kraft-upstairs-copy:focus-visible .kraft-upstairs-line {
  outline-width: calc(2px / var(--quote-pixel, 1));
  outline-offset: calc(4px / var(--quote-pixel, 1));
}
.kraft-upstairs[data-renderer="ready"] .kraft-upstairs-character {
  display: inline-block;
  width: var(--quote-advance);
  height: 8px;
  vertical-align: top;
  color: transparent;
  -webkit-user-select: text;
  user-select: text;
}
.kraft-upstairs[data-renderer="ready"] .kraft-upstairs-copy::selection,
.kraft-upstairs[data-renderer="ready"] .kraft-upstairs-copy *::selection { color: transparent; background: transparent; text-shadow: none; }
.kraft-upstairs[data-renderer="unavailable"] {
  background-image: linear-gradient(#ffffff50 1px, transparent 1px), linear-gradient(90deg, #ffffff50 1px, transparent 1px);
  background-size: 16px 16px;
}
.kraft-upstairs[data-renderer="unavailable"] .kraft-upstairs-copy {
  width: auto;
  height: auto;
  margin: 0;
  top: 30%;
  left: 12%;
  right: 8%;
  overflow: visible;
  clip-path: none;
  white-space: normal;
  font: bold clamp(24px, 5vw, 72px)/1.25 'Courier New', monospace;
}
@media (max-width: 700px) {
  .kraft-upstairs-brand { top: max(16px, env(safe-area-inset-top)); left: 22px; width: 140px; }
  .kraft-upstairs-return { bottom: max(24px, env(safe-area-inset-bottom)); }
  .kraft-header .kraft-upstairs-open { right: 18px; }
}
@media (prefers-reduced-motion: reduce) {
  .kraft-upstairs, .kraft-upstairs button, .kraft-upstairs-return span, .kraft-header .kraft-upstairs-open { transition: none; }
}
@media (forced-colors: active) {
  .kraft-upstairs { background: Canvas; color: CanvasText; }
  .kraft-upstairs-canvas { visibility: hidden; }
  #kraft-upstairs .kraft-upstairs-copy { clip-path: none; width: auto; height: auto; inset: 30% 8% auto 10%; margin: 0; overflow: visible; color: CanvasText; pointer-events: auto; font: bold 24px/1.5 monospace; }
  #kraft-upstairs .kraft-upstairs-line { position: static; display: inline; height: auto; font: inherit; transform: none; }
  #kraft-upstairs .kraft-upstairs-character { display: inline; width: auto; height: auto; vertical-align: baseline; color: CanvasText; }
  #kraft-upstairs .kraft-upstairs-copy:focus-visible .kraft-upstairs-line { outline: 2px solid Highlight; outline-offset: 4px; }
  #kraft-upstairs .kraft-upstairs-copy::selection,
  #kraft-upstairs .kraft-upstairs-copy *::selection { color: HighlightText; background: Highlight; }
  .kraft-upstairs button:focus-visible, .kraft-header .kraft-upstairs-open:focus-visible { outline-color: Highlight; }
}

#kraft-collage-grab-preview[data-scene="products"] .kraft-upstairs-open { visibility: hidden; }

/* Replace the native arrow only where a functioning custom pointer is present.
   The rule is local to the dialog, including buttons, so closing restores it. */
@media (pointer: fine) {
  #kraft-upstairs[data-renderer="ready"],
  #kraft-upstairs[data-renderer="ready"] *,
  #kraft-upstairs[data-renderer="ready"]::backdrop { cursor: none; }
}
@media (forced-colors: active) {
  #kraft-upstairs[data-renderer="ready"],
  #kraft-upstairs[data-renderer="ready"] *,
  #kraft-upstairs[data-renderer="ready"]::backdrop { cursor: auto; }
  #kraft-upstairs[data-renderer="ready"] button { cursor: pointer; }
  #kraft-upstairs .kraft-upstairs-copy,
  #kraft-upstairs .kraft-upstairs-copy * { cursor: text; }
}
