/* Catalog Studio v2 — A4 free-form canvas */

#canvasScroll:focus {
  outline: 2px solid rgba(99, 102, 241, 0.35);
  outline-offset: -2px;
}

.studio-aside-title {
  min-height: 2.75rem;
}

.studio-page-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.65rem;
  padding: 0.3rem 0.55rem;
  border-radius: 0.5rem;
  border: 1px solid #e2e8f0;
  background: #f8fafc;
}
.studio-page-ctl {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.7rem;
  font-weight: 600;
  color: #64748b;
  white-space: nowrap;
}
.studio-page-ctl--inline {
  font-weight: 500;
}
.studio-page-ctl-input {
  border: 1px solid #e2e8f0;
  border-radius: 0.375rem;
  padding: 0.2rem 0.4rem;
  font-size: 0.75rem;
  background: #fff;
  color: #334155;
}
.studio-page-ctl--checks {
  padding-left: 0.5rem;
  border-left: 1px solid #e2e8f0;
}
.studio-page-check {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  font-size: 0.72rem;
  font-weight: 500;
  color: #475569;
  cursor: pointer;
}
.studio-page-check input {
  border-radius: 0.2rem;
}

.studio-tool-btn {
  border-radius: 0.5rem;
  border: 1px solid #e2e8f0;
  background: #fff;
  padding: 0.25rem 0.6rem;
  font-size: 0.75rem;
  color: #334155;
  white-space: nowrap;
}
.studio-tool-btn:hover:not(:disabled) { background: #f8fafc; }
.studio-tool-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.studio-tool-btn--download {
  background: #eef2ff;
  border-color: #c7d2fe;
  color: #4338ca;
  font-weight: 600;
}
.studio-tool-btn--download:hover:not(:disabled) { background: #e0e7ff; }

.page-tab.active {
  background: #4f46e5 !important;
  color: #fff !important;
  border-color: #4f46e5 !important;
}

/* A4 canvas — visible overflow so resize/move handles are reachable */
.studio-canvas {
  position: relative;
  flex-shrink: 0;
  overflow: visible;
}

/* Default fallback; actual size set inline from editor */
.canvas-a4-portrait { width: 794px; height: 1123px; }
.canvas-a4-landscape { width: 1123px; height: 794px; }
.canvas-a5-portrait { width: 559px; height: 794px; }

.canvas-stage {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: visible;
  z-index: 2;
}

/* Canva-style dot grid for alignment */
.canvas-grid {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  background-color: #fafbfc;
  background-image: radial-gradient(circle, #b8c0cc 1px, transparent 1px);
  background-size: 20px 20px;
  background-position: 0 0;
}
.canvas-grid.hidden { display: none; }
.studio-canvas:has(.canvas-grid:not(.hidden)) {
  background-color: #fafbfc;
}

/* Surface textures */
.studio-canvas.bg-white { background: #fff; }
.studio-canvas.bg-linen {
  background-color: #ebe4d6;
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='6' height='6'%3E%3Cpath d='M0 0h1v1H0zm3 3h1v1H3z' fill='%23c8bda8' fill-opacity='.22'/%3E%3C/svg%3E"),
    linear-gradient(145deg, #f2ebe0 0%, #e5dcc8 100%);
}
.studio-canvas.bg-marble {
  background-color: #f0eeeb;
  background-image:
    radial-gradient(circle at 20% 30%, rgba(255,255,255,.9) 0%, transparent 45%),
    linear-gradient(125deg, #ebe8e4, #f7f5f2);
}
.studio-canvas.bg-suiting {
  background-color: #1e2a38;
  background-image:
    repeating-linear-gradient(90deg, transparent, transparent 2px, rgba(255,255,255,.03) 2px, rgba(255,255,255,.03) 3px),
    linear-gradient(160deg, #2c3e50, #1a252f);
}
.studio-canvas.bg-cream { background: linear-gradient(145deg, #faf6ee, #f3ead8); }
.studio-canvas.bg-kraft { background-color: #c9a66b; background-image: linear-gradient(135deg, #d4b483, #b8894d); }
.studio-canvas.bg-denim { background: linear-gradient(160deg, #4a6fa5, #2f4f7a); }
.studio-canvas.bg-canvas {
  background-color: #e8e2d4;
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='8'%3E%3Cpath d='M0 0h1v1H0zm4 4h1v1H4z' fill='%23b8ae9c' fill-opacity='.28'/%3E%3C/svg%3E"),
    linear-gradient(145deg, #ece6d8 0%, #e0d9cb 100%);
}
.studio-canvas.bg-wool { background: linear-gradient(145deg, #d9d2c7, #bfb6a8); }
.studio-canvas.bg-silk { background: linear-gradient(125deg, #fff8f0, #f3e8dc 45%, #efe2d2); }
.studio-canvas.bg-charcoal { background: linear-gradient(160deg, #3a3f45, #1f2328); }
.studio-canvas.bg-ivory { background: linear-gradient(180deg, #fffff5, #f7f2e8); }
.studio-canvas.bg-blush { background: linear-gradient(145deg, #fff1f2, #f8d7da); }
.studio-canvas.bg-sage { background: linear-gradient(145deg, #eef4ea, #d8e5d0); }
.studio-canvas.bg-navy { background: linear-gradient(160deg, #1e3a5f, #0f2744); }
.studio-canvas.bg-warm-grey { background: linear-gradient(145deg, #ece7e1, #d8d0c7); }
.studio-canvas.bg-cool-grey { background: linear-gradient(145deg, #e8edf2, #cfd8e3); }
.studio-canvas.bg-sandstone { background: linear-gradient(145deg, #f0e6d8, #dcc7ad); }
.studio-canvas.bg-tweed {
  background-color: #4a4f57;
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='6' height='6'%3E%3Cpath d='M0 3h6M3 0v6' stroke='%23ffffff' stroke-opacity='.06'/%3E%3C/svg%3E"),
    linear-gradient(155deg, #5c636d, #3a4048);
}
.studio-canvas.bg-chambray {
  background-color: #c8d4e4;
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='4' height='4'%3E%3Cpath d='M0 0h1v1H0zm2 2h1v1H2z' fill='%238fa3bf' fill-opacity='.35'/%3E%3C/svg%3E"),
    linear-gradient(145deg, #d8e2f0, #b8c8dc);
}
.studio-canvas.bg-cotton {
  background-color: #faf9f6;
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='5' height='5'%3E%3Ccircle cx='1' cy='1' r='.6' fill='%23e8e4dc'/%3E%3C/svg%3E"),
    linear-gradient(180deg, #fff, #f3f0ea);
}
.studio-canvas.bg-leather {
  background-color: #6b4a2e;
  background-image:
    radial-gradient(circle at 30% 20%, rgba(255,255,255,.08), transparent 45%),
    linear-gradient(145deg, #7a5538, #4f3420);
}
.studio-canvas.bg-suede {
  background-color: #a8896c;
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='3' height='3'%3E%3Cpath d='M0 1.5h3' stroke='%23000' stroke-opacity='.04'/%3E%3C/svg%3E"),
    linear-gradient(160deg, #b8997c, #947a60);
}
.studio-canvas.bg-heather {
  background-color: #b8bcc4;
  background-image:
    radial-gradient(circle at 25% 35%, rgba(255,255,255,.35) 0%, transparent 40%),
    radial-gradient(circle at 70% 65%, rgba(0,0,0,.06) 0%, transparent 35%),
    linear-gradient(145deg, #c5c9d0, #a8adb6);
}
.studio-canvas.bg-pearl {
  background-color: #f7f4ef;
  background-image:
    radial-gradient(circle at 20% 30%, rgba(255,255,255,.95), transparent 50%),
    radial-gradient(circle at 75% 70%, rgba(230,220,255,.25), transparent 45%),
    linear-gradient(125deg, #fffaf5, #efe8e0);
}
.studio-canvas.bg-velvet {
  background-color: #4a1528;
  background-image:
    radial-gradient(ellipse at 50% 0%, rgba(255,255,255,.12), transparent 55%),
    linear-gradient(165deg, #5c1a33, #2d0d1a);
}
.studio-canvas.bg-oatmeal {
  background-color: #e9e2d6;
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='7' height='7'%3E%3Cpath d='M0 0h1v1H0zm3.5 3.5h1v1h-1z' fill='%23c9bfb0' fill-opacity='.3'/%3E%3C/svg%3E"),
    linear-gradient(145deg, #f0e9de, #ddd4c6);
}
.studio-canvas.bg-slate-fabric {
  background-color: #5a6672;
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='5' height='5'%3E%3Cpath d='M0 2.5h5M2.5 0v5' stroke='%23fff' stroke-opacity='.05'/%3E%3C/svg%3E"),
    linear-gradient(155deg, #6a7784, #46515c);
}
.studio-canvas.bg-mohair {
  background-color: #d5cfc7;
  background-image:
    radial-gradient(circle at 40% 40%, rgba(255,255,255,.4), transparent 50%),
    linear-gradient(145deg, #e2dcd4, #c8c0b6);
}

.fabric-surface .canvas-el--button .canvas-el__btn-img { mix-blend-mode: multiply; }
.fabric-suiting .canvas-el--button .canvas-el__btn-img,
.fabric-charcoal .canvas-el--button .canvas-el__btn-img,
.fabric-navy .canvas-el--button .canvas-el__btn-img,
.fabric-tweed .canvas-el--button .canvas-el__btn-img,
.fabric-velvet .canvas-el--button .canvas-el__btn-img,
.fabric-leather .canvas-el--button .canvas-el__btn-img,
.fabric-slate-fabric .canvas-el--button .canvas-el__btn-img { mix-blend-mode: soft-light; opacity: 0.96; }

/* Print placement guide — hide button photos, show center dot only */
.canvas-el--print-guide .canvas-el__btn-stage,
.canvas-el--print-guide .btn-flip,
.canvas-el--print-guide .canvas-el__btn-blend { display: none !important; }
.print-guide-dot {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 4px;
  height: 4px;
  margin: -2px 0 0 -2px;
  border-radius: 50%;
  background: #111827;
  box-shadow: 0 0 0 1px #fff, 0 0 0 1.5px rgba(17, 24, 39, 0.35);
  pointer-events: none;
  z-index: 2;
}
.is-print-guide .canvas-el--button:not(.canvas-el--print-guide) .canvas-el__btn-stage { display: none !important; }

/* Off-screen export — preserve full text (no ellipsis clipping) */
.catalog-export-host .canvas-el--text-stack,
.catalog-export-host .canvas-el--text {
  overflow: visible !important;
}
.catalog-export-host .canvas-el__stack-line {
  overflow: visible !important;
  text-overflow: clip !important;
  white-space: nowrap;
  line-height: 1.35;
}
.catalog-export-host .canvas-el__text {
  overflow: visible !important;
  white-space: pre-wrap;
}

/* Canvas elements */
.canvas-el {
  position: absolute;
  box-sizing: border-box;
  touch-action: none;
  user-select: none;
}

.canvas-el.is-selected {
  outline: 2px solid #6366f1;
  outline-offset: 2px;
}

.canvas-el__handles {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 200;
}

.canvas-el__rz {
  position: absolute;
  width: 14px;
  height: 14px;
  background: #fff;
  border: 2px solid #6366f1;
  border-radius: 3px;
  pointer-events: auto;
  touch-action: none;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
  z-index: 201;
}
.canvas-el__rz--nw { left: 0; top: 0; cursor: nwse-resize; transform: translate(-50%, -50%); }
.canvas-el__rz--ne { right: 0; top: 0; cursor: nesw-resize; transform: translate(50%, -50%); }
.canvas-el__rz--sw { left: 0; bottom: 0; cursor: nesw-resize; transform: translate(-50%, 50%); }
.canvas-el__rz--se { right: 0; bottom: 0; cursor: nwse-resize; transform: translate(50%, 50%); }
.canvas-el__rz--n { left: 50%; top: 0; transform: translate(-50%, -50%); cursor: ns-resize; }
.canvas-el__rz--s { left: 50%; bottom: 0; transform: translate(-50%, 50%); cursor: ns-resize; }
.canvas-el__rz--e { right: 0; top: 50%; transform: translate(50%, -50%); cursor: ew-resize; }
.canvas-el__rz--w { left: 0; top: 50%; transform: translate(-50%, -50%); cursor: ew-resize; }

/* Canva-style move puck below selection */
.canvas-el__move-puck {
  position: absolute;
  left: 50%;
  bottom: -38px;
  width: 32px;
  height: 32px;
  margin-left: -16px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid #6366f1;
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.18);
  pointer-events: auto;
  cursor: grab;
  touch-action: none;
  z-index: 204;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #6366f1;
}
.canvas-el__move-puck::before {
  content: "";
  width: 14px;
  height: 14px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236366f1' stroke-width='2.2' stroke-linecap='round'%3E%3Cpath d='M12 2v20M2 12h20M7 7l5 5 5-5M7 17l5-5 5 5'/%3E%3C/svg%3E");
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  opacity: 0.9;
}
.canvas-el__move-puck:active { cursor: grabbing; transform: scale(0.96); }

.canvas-el:not(.is-selected) .canvas-el__rz,
.canvas-el:not(.is-selected) .canvas-el__move-puck { display: none; }

.canvas-el.is-dragging {
  will-change: transform;
  z-index: 9999 !important;
  opacity: 0.94;
  transition: none;
  cursor: grabbing;
}
.canvas-el.is-dragging .canvas-el__move-puck { cursor: grabbing; }

/* Background image frame */
.canvas-el--bg {
  overflow: hidden;
  border: 1px dashed transparent;
}
.canvas-el--bg.is-selected {
  overflow: visible;
  border-color: rgba(99, 102, 241, 0.5);
  cursor: grab;
}
.canvas-el--bg.is-selected:active { cursor: grabbing; }
.canvas-el--bg img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
  border-radius: inherit;
}

/* Transparent button image — 3-layer drop-shadow */
.canvas-el--button {
  background: transparent !important;
  border: none;
  overflow: visible;
}
.canvas-el--text.is-selected { overflow: visible; }

.canvas-el__btn-stage {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 1;
}
.canvas-el--button .btn-flip {
  pointer-events: auto;
  position: relative;
  z-index: 1;
}

.canvas-el__btn-blend {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  isolation: isolate;
}

/* No rectangular vignette — keeps circular button shadow only */

/* ── Multi-image flip widget ── */
.btn-flip {
  width: 100%;
  height: 100%;
  position: relative;
  cursor: pointer;
}

.btn-flip__scene {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 72px;
  perspective: 1100px;
  transform-style: preserve-3d;
}

.btn-flip--front-only .btn-flip__scene {
  perspective: none;
  transform-style: flat;
}

.btn-flip__inner {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: inherit;
  transform-style: preserve-3d;
  transition: transform 0.62s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.38s ease;
}

.btn-flip__face {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  transform-style: preserve-3d;
}

.btn-flip__face--back {
  transform: rotateY(180deg);
}

/* 3-layer shadow on all button photos */
.canvas-el__btn-img,
.btn-flip .canvas-el__btn-img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  object-position: center;
  background: transparent !important;
  filter:
    drop-shadow(0 1px 2px rgba(0, 0, 0, 0.35))
    drop-shadow(0 4px 10px rgba(0, 0, 0, 0.22))
    drop-shadow(0 10px 22px rgba(0, 0, 0, 0.12));
  transition: filter 0.4s cubic-bezier(0.22, 1, 0.36, 1);
  pointer-events: none;
}

.canvas-el--button .btn-flip:hover .canvas-el__btn-img,
.canvas-el--button:hover .canvas-el__btn-img {
  filter:
    drop-shadow(0 2px 4px rgba(0, 0, 0, 0.42))
    drop-shadow(0 8px 16px rgba(0, 0, 0, 0.28))
    drop-shadow(0 16px 32px rgba(0, 0, 0, 0.14));
}

/* Ground contact — circular only via img drop-shadow; hide square box contact */
.canvas-el--button .btn-flip__contact {
  display: none;
}

/* 2 images — click/touch toggle per button only (no hover flip) */
.canvas-el--button .btn-flip--dual.is-flipped .btn-flip__inner {
  transform: rotateY(180deg);
}

/* 3 images — click cycle: front(0) → back(1) → side(2) */
.btn-flip--triple.is-back .btn-flip__inner--pair {
  transform: rotateY(180deg);
}

.btn-flip--triple.is-side .btn-flip__inner--pair {
  opacity: 0;
  transform: rotateY(180deg) scale(0.94);
  pointer-events: none;
}

.btn-flip--triple .btn-flip__side {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  opacity: 0;
  visibility: hidden;
  transform: scale(0.9) rotateY(-8deg);
  transition:
    opacity 0.45s cubic-bezier(0.22, 1, 0.36, 1),
    transform 0.45s cubic-bezier(0.22, 1, 0.36, 1),
    visibility 0s linear 0.45s;
  pointer-events: none;
  z-index: 3;
}

.btn-flip--triple.is-side .btn-flip__side {
  opacity: 1;
  visibility: visible;
  transform: scale(1) rotateY(0deg);
  transition:
    opacity 0.45s cubic-bezier(0.22, 1, 0.36, 1),
    transform 0.45s cubic-bezier(0.22, 1, 0.36, 1),
    visibility 0s;
}

.btn-flip__side-badge {
  position: absolute;
  bottom: 4px;
  right: 4px;
  font-size: 9px;
  letter-spacing: 0.04em;
  padding: 2px 5px;
  border-radius: 4px;
  background: rgba(15, 23, 42, 0.65);
  color: #fff;
  pointer-events: none;
}

.btn-flip__dots {
  display: flex;
  justify-content: center;
  gap: 4px;
  margin-top: 4px;
  pointer-events: none;
}
.btn-flip__dots span {
  width: 5px;
  height: 5px;
  border-radius: 999px;
  background: #cbd5e1;
  transition: background 0.2s, transform 0.2s;
}
.btn-flip__dots span.active {
  background: #6366f1;
  transform: scale(1.2);
}

.btn-flip__dots--overlay {
  position: absolute;
  bottom: 4px;
  left: 0;
  right: 0;
  margin: 0;
  z-index: 5;
  pointer-events: none;
}
.btn-flip__dots--overlay span {
  width: 4px;
  height: 4px;
  background: rgba(255, 255, 255, 0.55);
  box-shadow: 0 0 2px rgba(0, 0, 0, 0.35);
}
.btn-flip__dots--overlay span.active {
  background: #6366f1;
}

.btn-flip__hint {
  display: block;
  text-align: center;
  font-size: 9px;
  color: #94a3b8;
  margin-top: 2px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
}
.canvas-el--button:hover .btn-flip__hint {
  opacity: 1;
}

.canvas-el__contact {
  display: none;
}

/* Text frame */
.canvas-el--text {
  background: transparent;
  border: 1px dashed transparent;
  min-height: 1em;
  overflow: visible;
}
.canvas-el--text.is-selected {
  border-color: rgba(99, 102, 241, 0.45);
  background: rgba(255, 255, 255, 0.04);
}
.canvas-el--text.is-editing {
  border-color: #6366f1;
  background: rgba(255, 255, 255, 0.92);
  z-index: 300 !important;
  touch-action: auto;
  user-select: text;
}
.canvas-el--text.is-selected {
  z-index: 250;
}

.canvas-el__text {
  width: 100%;
  min-height: 100%;
  height: auto;
  outline: none;
  overflow: visible;
  word-break: break-word;
  white-space: pre-wrap;
  cursor: text;
  user-select: text;
  pointer-events: auto;
  padding: 2px 4px;
  box-sizing: border-box;
}
.canvas-el--text.is-selected .canvas-el__text {
  cursor: text;
}

/* Merged button label stack — item / color / size in one column */
.canvas-el--text-stack {
  background: transparent;
  border: 1px dashed transparent;
  overflow: visible;
}
.canvas-el--text-stack.is-selected {
  border-color: rgba(99, 102, 241, 0.45);
  background: rgba(255, 255, 255, 0.04);
  z-index: 250;
}
.canvas-el--text-stack.is-editing {
  border-color: #6366f1;
  background: rgba(255, 255, 255, 0.92);
  z-index: 300 !important;
  touch-action: auto;
  user-select: text;
}
.canvas-el__stack {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  width: 100%;
  height: 100%;
  pointer-events: auto;
  box-sizing: border-box;
}
.canvas-el__stack-line {
  width: 100%;
  text-align: center;
  line-height: 1.35;
  padding: 0 1px;
  box-sizing: border-box;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: text;
  user-select: text;
  pointer-events: auto;
}
.canvas-el--text-stack.is-selected .canvas-el__stack-line {
  cursor: grab;
}
.canvas-el--text-stack.is-selected.is-dragging .canvas-el__stack-line {
  cursor: grabbing;
}
.canvas-el--text-stack.is-selected:not(.is-editing) {
  cursor: grab;
}
.canvas-el--text-stack.is-dragging {
  cursor: grabbing;
}

.style-modern-sans .canvas-el__text:not([style*="font-family"]),
.style-modern-sans .canvas-el__stack-line:not([style*="font-family"]) { font-family: ui-sans-serif, system-ui, sans-serif; }
.style-classic-serif .canvas-el__text:not([style*="font-family"]),
.style-classic-serif .canvas-el__stack-line:not([style*="font-family"]) { font-family: Georgia, "Times New Roman", serif; }
.style-minimal-round .canvas-el__text:not([style*="font-family"]),
.style-minimal-round .canvas-el__stack-line:not([style*="font-family"]) { font-family: "Segoe UI", Inter, sans-serif; }
.style-sharp-bold .canvas-el__text:not([style*="font-family"]),
.style-sharp-bold .canvas-el__stack-line:not([style*="font-family"]) { font-family: "Arial Black", "Helvetica Neue", sans-serif; font-weight: 700; }
.style-editorial-times .canvas-el__text:not([style*="font-family"]),
.style-editorial-times .canvas-el__stack-line:not([style*="font-family"]) { font-family: "Times New Roman", Times, serif; }
.style-luxury-serif .canvas-el__text:not([style*="font-family"]),
.style-luxury-serif .canvas-el__stack-line:not([style*="font-family"]) { font-family: "Palatino Linotype", Palatino, Georgia, serif; }
.style-zen-light .canvas-el__text:not([style*="font-family"]),
.style-zen-light .canvas-el__stack-line:not([style*="font-family"]) { font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-weight: 300; letter-spacing: 0.04em; }
.style-mono-tech .canvas-el__text:not([style*="font-family"]),
.style-mono-tech .canvas-el__stack-line:not([style*="font-family"]) { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; }
.style-vintage-typewriter .canvas-el__text:not([style*="font-family"]),
.style-vintage-typewriter .canvas-el__stack-line:not([style*="font-family"]) { font-family: "Courier New", Courier, monospace; }
.style-soft-round .canvas-el__text:not([style*="font-family"]),
.style-soft-round .canvas-el__stack-line:not([style*="font-family"]) { font-family: "Trebuchet MS", "Lucida Grande", sans-serif; }
.style-compact-impact .canvas-el__text:not([style*="font-family"]),
.style-compact-impact .canvas-el__stack-line:not([style*="font-family"]) { font-family: "Arial Narrow", Arial, sans-serif; font-stretch: condensed; }
.style-chinese-hei .canvas-el__text:not([style*="font-family"]),
.style-chinese-hei .canvas-el__stack-line:not([style*="font-family"]) { font-family: "Microsoft JhengHei", "PingFang TC", "Noto Sans TC", sans-serif; }
.style-chinese-ming .canvas-el__text:not([style*="font-family"]),
.style-chinese-ming .canvas-el__stack-line:not([style*="font-family"]) { font-family: "PMingLiU", "Noto Serif TC", "Songti TC", serif; }
.style-fashion-thin .canvas-el__text:not([style*="font-family"]),
.style-fashion-thin .canvas-el__stack-line:not([style*="font-family"]) { font-family: "Helvetica Neue", Arial, sans-serif; font-weight: 200; letter-spacing: 0.06em; }
.style-playful-pop .canvas-el__text:not([style*="font-family"]),
.style-playful-pop .canvas-el__stack-line:not([style*="font-family"]) { font-family: "Comic Sans MS", "Segoe UI", sans-serif; }
.style-elegant-garamond .canvas-el__text:not([style*="font-family"]),
.style-elegant-garamond .canvas-el__stack-line:not([style*="font-family"]) { font-family: Garamond, "EB Garamond", Georgia, serif; }
.style-industrial-gothic .canvas-el__text:not([style*="font-family"]),
.style-industrial-gothic .canvas-el__stack-line:not([style*="font-family"]) { font-family: "Franklin Gothic Medium", "Arial Narrow", sans-serif; }
.style-hand-script .canvas-el__text:not([style*="font-family"]),
.style-hand-script .canvas-el__stack-line:not([style*="font-family"]) { font-family: "Segoe Script", "Brush Script MT", cursive; }
.style-geometric-futura .canvas-el__text:not([style*="font-family"]),
.style-geometric-futura .canvas-el__stack-line:not([style*="font-family"]) { font-family: Futura, "Century Gothic", sans-serif; }
.style-retro-70s .canvas-el__text:not([style*="font-family"]),
.style-retro-70s .canvas-el__stack-line:not([style*="font-family"]) { font-family: "Cooper Black", Georgia, serif; }
.style-newspaper .canvas-el__text:not([style*="font-family"]),
.style-newspaper .canvas-el__stack-line:not([style*="font-family"]) { font-family: "Times New Roman", Times, serif; font-weight: 700; }
.style-label-mono .canvas-el__text:not([style*="font-family"]),
.style-label-mono .canvas-el__stack-line:not([style*="font-family"]) { font-family: "Roboto Mono", Consolas, monospace; }
.style-cantonese-kai .canvas-el__text:not([style*="font-family"]),
.style-cantonese-kai .canvas-el__stack-line:not([style*="font-family"]) { font-family: "KaiTi", "DFKai-SB", "標楷體", serif; }
.style-japanese-mincho .canvas-el__text:not([style*="font-family"]),
.style-japanese-mincho .canvas-el__stack-line:not([style*="font-family"]) { font-family: "Yu Mincho", "Hiragino Mincho ProN", serif; }
.style-art-deco .canvas-el__text:not([style*="font-family"]),
.style-art-deco .canvas-el__stack-line:not([style*="font-family"]) { font-family: "Poiret One", "Century Gothic", sans-serif; letter-spacing: 0.08em; }
.style-brutalist .canvas-el__text:not([style*="font-family"]),
.style-brutalist .canvas-el__stack-line:not([style*="font-family"]) { font-family: Impact, "Arial Black", sans-serif; text-transform: uppercase; }

/* Text effects */
.text-effect--shadow { text-shadow: 2px 3px 6px rgba(0, 0, 0, 0.38); }
.text-effect--lift { text-shadow: 0 2px 6px rgba(0, 0, 0, 0.22), 0 10px 28px rgba(0, 0, 0, 0.14); }
.text-effect--outline {
  -webkit-text-stroke: 1px currentColor;
  paint-order: stroke fill;
}
.text-effect--hollow {
  color: transparent !important;
  -webkit-text-stroke: 1.5px currentColor;
}
.text-effect--background {
  background: rgba(99, 102, 241, 0.14);
  padding: 2px 10px;
  border-radius: 6px;
  display: inline-block;
}
.text-effect--neon { text-shadow: 0 0 6px currentColor, 0 0 14px currentColor, 0 0 28px rgba(99, 102, 241, 0.55); }

/* Toolbar */
.studio-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
  background: #fff;
  color: #475569;
}
.studio-icon-btn:hover:not(:disabled) { background: #f8fafc; color: #1e293b; }
.studio-icon-btn:disabled { opacity: 0.35; cursor: not-allowed; }

.studio-tool-btn.is-active {
  background: #eef2ff;
  border-color: #818cf8;
  color: #4338ca;
}

.studio-text-ctl { background: #fff; }
.studio-text-ctl-btn { background: #fff; color: #475569; }
.studio-text-ctl-btn:hover { background: #f1f5f9; }

.studio-text-toggle {
  min-width: 28px;
  height: 28px;
  padding: 0 6px;
  border-radius: 6px;
  border: 1px solid #e2e8f0;
  background: #fff;
  font-size: 13px;
  color: #334155;
}
.studio-text-toggle:hover { background: #f8fafc; }
.studio-text-toggle.is-active {
  background: #4f46e5;
  border-color: #4f46e5;
  color: #fff;
}
.studio-align-btn[data-align="center"] { text-align: center; }
.studio-align-btn[data-align="right"] { text-align: right; }

.studio-color-swatch {
  display: block;
  width: 22px;
  height: 22px;
  border-radius: 4px;
  border: 1px solid #cbd5e1;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35);
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* Rulers & guides */
.canvas-workspace {
  display: grid;
  grid-template-columns: 28px auto;
  grid-template-rows: 28px auto;
  gap: 0;
  width: fit-content;
}
.canvas-workspace:not(.show-rulers) {
  display: block;
}
.canvas-workspace:not(.show-rulers) .canvas-mount {
  margin: 0 auto;
}

.studio-ruler-corner {
  width: 28px;
  height: 28px;
  background: #e2e8f0;
  border: 1px solid #cbd5e1;
  grid-column: 1;
  grid-row: 1;
}
.studio-ruler {
  position: relative;
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  overflow: hidden;
  user-select: none;
}
.studio-ruler--h {
  grid-column: 2;
  grid-row: 1;
  height: 28px;
  cursor: crosshair;
}
.studio-ruler--v {
  grid-column: 1;
  grid-row: 2;
  width: 28px;
  cursor: crosshair;
}
.studio-ruler__tick {
  position: absolute;
  top: 16px;
  font-size: 7px;
  color: #64748b;
  transform: translateX(-50%);
  line-height: 1;
  pointer-events: none;
}
.studio-ruler__tick::before {
  content: "";
  position: absolute;
  left: 50%;
  top: -10px;
  width: 1px;
  background: #94a3b8;
  transform: translateX(-50%);
}
.studio-ruler__tick--minor::before { height: 4px; }
.studio-ruler__tick--half::before { height: 7px; background: #64748b; }
.studio-ruler__tick--major { font-weight: 600; color: #475569; }
.studio-ruler__tick--major::before { height: 10px; background: #475569; }
.studio-ruler__tick--v {
  left: 16px;
  top: auto;
  transform: translateY(-50%);
  writing-mode: vertical-rl;
  text-orientation: mixed;
}
.studio-ruler__tick--v::before {
  left: -10px;
  top: 50%;
  height: 1px;
  transform: translateY(-50%);
}
.studio-ruler__tick--v.studio-ruler__tick--minor::before { width: 4px; }
.studio-ruler__tick--v.studio-ruler__tick--half::before { width: 7px; background: #64748b; }
.studio-ruler__tick--v.studio-ruler__tick--major::before { width: 10px; background: #475569; }

.canvas-mount {
  position: relative;
  grid-column: 2;
  grid-row: 2;
}
.guide-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 50;
}
.guide-layer.hidden { display: none; }
.guide-line {
  position: absolute;
  pointer-events: auto;
  z-index: 51;
}
.guide-line--h {
  left: 0;
  right: 0;
  height: 1px;
  background: rgba(236, 72, 153, 0.85);
  cursor: ns-resize;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.5);
}
.guide-line--h::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: -4px;
  height: 9px;
}
.guide-line--v {
  top: 0;
  bottom: 0;
  width: 1px;
  background: rgba(236, 72, 153, 0.85);
  cursor: ew-resize;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.5);
}
.guide-line--v::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: -4px;
  width: 9px;
}

.studio-canvas.is-drop-target {
  outline: 3px dashed #6366f1;
  outline-offset: 4px;
}
.canvas-drop-hint {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(99, 102, 241, 0.12);
  color: #4338ca;
  font-size: 15px;
  font-weight: 600;
  pointer-events: none;
  z-index: 60;
}

/* Library sidebar */
.studio-sidebar {
  width: 18rem;
  min-width: 12rem;
  max-width: 36rem;
}
.studio-sidebar-resizer {
  width: 5px;
  margin: 0 -2px;
  cursor: col-resize;
  background: transparent;
  flex-shrink: 0;
  z-index: 25;
  position: relative;
}
.studio-sidebar-resizer:hover,
.studio-sidebar-resizer.is-dragging {
  background: #c7d2fe;
}
.studio-library-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.studio-lib-size-btn {
  border: 1px solid #e2e8f0;
  background: #fff;
  color: #475569;
  border-radius: 0.35rem;
  width: 1.5rem;
  height: 1.5rem;
  font-size: 0.85rem;
  line-height: 1;
  cursor: pointer;
}
.studio-lib-size-btn:hover { background: #f8fafc; }
body.studio-resizing { cursor: col-resize !important; user-select: none; }

/* Library */
.lib-card {
  cursor: grab;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
  background: #fff;
  overflow: hidden;
}
.lib-card:active,
.lib-card.is-dragging { cursor: grabbing; }
.lib-card.is-dragging { opacity: 0.65; }
.lib-card.is-selected {
  border-color: #6366f1;
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.25);
}
.lib-card.is-drop-before { box-shadow: inset 0 3px 0 #6366f1; }

/* Library — flat catalog thumb only; no transparency grid / 3D / shadow */
.lib-card__preview {
  aspect-ratio: 1;
  background: #f1f5f9;
  padding: calc(6px * var(--lib-thumb-scale, 1));
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.lib-card__preview .lib-card__img {
  max-width: calc(100% * var(--lib-thumb-scale, 1));
  max-height: calc(100% * var(--lib-thumb-scale, 1));
  width: auto;
  height: auto;
  object-fit: contain;
  pointer-events: none;
  filter: none !important;
  background: transparent;
  border-radius: 4px;
  box-shadow: none;
}
.lib-card__preview .lib-card__empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: #94a3b8;
  font-size: 12px;
}

/* Trash drop zone — visible while dragging canvas elements */
.studio-trash {
  position: fixed;
  right: 28px;
  bottom: 88px;
  width: 76px;
  min-height: 76px;
  padding: 10px 8px;
  border-radius: 18px;
  background: #fff;
  border: 2px dashed #cbd5e1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: #64748b;
  z-index: 95;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.1);
  transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
  pointer-events: none;
}
.studio-trash__label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
}
/* Text color picker (Canva-style) */
.studio-color-wrap {
  position: relative;
}
.studio-color-popover {
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  width: 248px;
  max-height: 420px;
  overflow-y: auto;
  padding: 12px;
  border-radius: 12px;
  background: #fff;
  border: 1px solid #e2e8f0;
  box-shadow: 0 12px 40px rgba(15, 23, 42, 0.18);
}
.studio-color-popover-head {
  font-size: 13px;
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 10px;
}
.studio-color-section + .studio-color-section {
  margin-top: 12px;
}
.studio-color-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 11px;
  font-weight: 600;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.studio-color-see-all {
  border: none;
  background: none;
  color: #2563eb;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
}
.studio-color-see-all:hover {
  text-decoration: underline;
}
.studio-color-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}
.studio-color-chip {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid rgba(15, 23, 42, 0.12);
  cursor: pointer;
  padding: 0;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.studio-color-chip:hover {
  transform: scale(1.08);
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.15);
}
.studio-color-chip--gradient {
  border-color: rgba(15, 23, 42, 0.08);
}
.studio-color-custom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid #e2e8f0;
  font-size: 12px;
  font-weight: 600;
  color: #475569;
}
.studio-color-custom input[type="color"] {
  width: 36px;
  height: 36px;
  border: none;
  padding: 0;
  background: none;
  cursor: pointer;
}

.studio-trash.is-over {
  border-color: #ef4444;
  border-style: solid;
  background: #fef2f2;
  color: #dc2626;
  transform: scale(1.08);
  box-shadow: 0 10px 28px rgba(239, 68, 68, 0.22);
}

.drag-ghost {
  position: fixed;
  z-index: 200;
  width: 80px;
  height: 80px;
  pointer-events: none;
  opacity: 0.92;
  background: #fff;
  border-radius: 6px;
  border: 1px solid #e2e8f0;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}
.drag-ghost img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: none !important;
}

@media (prefers-reduced-motion: reduce) {
  .canvas-el__btn-img,
  .btn-flip__inner,
  .btn-flip__side { transition: none !important; }
  .canvas-el--button .btn-flip--dual:hover .btn-flip__inner { transform: none; }
}
