/* =============================================================
   YMAZO Designer v3 — 单页面布局（左工具 / 中画布 / 右详情 / 底栏）
   ============================================================= */

.ymazo-designer {
  --tools-w: 56px;
  --tool-panel-w: 280px;
  --side-w: 300px;
  --top-h: 40px;
  --tabs-h: 44px;
  --accent: #E11D48;
  --border: #e6e6e6;
  --bg: #fafafa;
  --card: #ffffff;
  --ink: #111;
  --ink-soft: #666;
  --ink-mute: #aaa;

  display: grid;
  grid-template-columns: var(--tools-w) 0px 1fr var(--side-w);
  grid-template-rows: var(--top-h) auto var(--tabs-h) 1fr;
  grid-template-areas:
    "top top top top"
    "togglebar togglebar togglebar togglebar"
    "tabs tabs tabs tabs"
    "tools tool-panel canvas side";
  transition: grid-template-columns .2s;
  min-height: 540px;
  height: calc(100vh - 70px);
  max-height: 1100px;
  background: var(--bg);
  font-family: "Hiragino Sans","Yu Gothic",system-ui,sans-serif;
  color: var(--ink);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,.05);
  margin: 0 auto;
  max-width: 1480px;
  position: relative;  /* picker modal を内側に閉じ込める */
}
.ymazo-designer.has-tool-panel {
  grid-template-columns: var(--tools-w) var(--tool-panel-w) 1fr var(--side-w);
}

/* ---------- LEFT TOOL PANEL ---------- */
.ymazo-designer__tool-panel {
  grid-area: tool-panel;
  background: #fff;
  border-right: 1px solid var(--border);
  overflow-y: auto;
  overflow-x: hidden;
  display: none;
  flex-direction: column;
  width: var(--tool-panel-w);
}
.ymazo-designer.has-tool-panel .ymazo-designer__tool-panel {
  display: flex;
}
.ymazo-designer__tp-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  font-size: 14px;
  background: #fafafa;
  flex-shrink: 0;
}
.ymazo-designer__tp-head .close {
  border: none;
  background: transparent;
  font-size: 20px;
  cursor: pointer;
  color: var(--ink-soft);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.ymazo-designer__tp-head .close:hover { background: #eee; color: var(--ink); }
.ymazo-designer__tp-body {
  padding: 14px 16px;
  flex: 1;
}

/* ---------- IMAGE UPLOAD PANEL ---------- */
.ymazo-designer__upload-drop {
  border: 2px dashed #ccc;
  border-radius: 10px;
  padding: 22px 16px;
  text-align: center;
  cursor: pointer;
  transition: all .15s;
  margin-bottom: 14px;
  background: #fafafa;
}
.ymazo-designer__upload-drop:hover,
.ymazo-designer__upload-drop.is-dragover {
  border-color: var(--accent);
  background: #fff5f7;
}
.ymazo-designer__upload-drop .ico {
  font-size: 32px;
  display: block;
  margin-bottom: 8px;
  opacity: .6;
}
.ymazo-designer__upload-drop .title {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 4px;
}
.ymazo-designer__upload-drop .hint {
  font-size: 10px;
  color: var(--ink-mute);
  line-height: 1.4;
}
.ymazo-designer__recent-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--ink-mute);
  text-transform: uppercase;
  letter-spacing: .04em;
  margin: 16px 0 8px;
}
.ymazo-designer__recent-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}
.ymazo-designer__recent-item {
  position: relative;
  aspect-ratio: 1;
  background: #fafafa;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  overflow: hidden;
  transition: all .12s;
}
.ymazo-designer__recent-item:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}
.ymazo-designer__recent-item.is-adding {
  border-color: var(--accent);
  opacity: .72;
}
.ymazo-designer__recent-item.is-adding::after {
  content: "追加中";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,.72);
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
}
.ymazo-designer__recent-item img {
  width: 100%; height: 100%;
  object-fit: contain;
  background: #fff;
}
.ymazo-designer__recent-item .del {
  position: absolute;
  top: 2px; right: 2px;
  width: 18px; height: 18px;
  background: rgba(0,0,0,.6);
  color: #fff;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  font-size: 11px;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.ymazo-designer__recent-item:hover .del { display: flex; }
.ymazo-designer__recent-empty {
  font-size: 11px;
  color: var(--ink-mute);
  text-align: center;
  padding: 12px;
}

/* ---------- TABS ROW ---------- */
.ymazo-designer__tabs {
  grid-area: tabs;
  background: #f4f4f4;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: stretch;
  padding: 0 12px;
  gap: 4px;
  overflow-x: auto;
}
.ymazo-designer__tabs-list {
  display: flex;
  gap: 4px;
  align-items: stretch;
}
.ymazo-designer__tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 12px;
  background: #e9e9e9;
  border: none;
  border-top-left-radius: 6px;
  border-top-right-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-soft);
  cursor: pointer;
  position: relative;
  top: 4px;
  height: calc(100% - 4px);
  transition: background .12s, color .12s;
  white-space: nowrap;
}
.ymazo-designer__tab:hover { background: #dedede; color: var(--ink); }
.ymazo-designer__tab.is-active {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 -1px 0 var(--accent) inset, 1px 0 0 var(--border), -1px 0 0 var(--border);
}
.ymazo-designer__tab .check {
  color: var(--accent);
  font-weight: 700;
}
.ymazo-designer__tab .size {
  color: var(--ink-mute);
  font-size: 10px;
  font-weight: 500;
}
.ymazo-designer__tab .remove {
  width: 16px; height: 16px;
  border: none;
  background: rgba(0,0,0,.06);
  border-radius: 50%;
  font-size: 11px;
  line-height: 1;
  cursor: pointer;
  color: var(--ink-soft);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: 2px;
  padding: 0;
}
.ymazo-designer__tab .remove:hover { background: var(--accent); color: #fff; }
.ymazo-designer__tab-add {
  align-self: center;
  width: 32px; height: 32px;
  border: 1.5px dashed #bbb;
  background: #fff;
  border-radius: 6px;
  font-size: 18px;
  font-weight: 700;
  color: var(--ink-soft);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-left: 4px;
  transition: all .12s;
}
.ymazo-designer__tab-add:hover { border-color: var(--accent); color: var(--accent); border-style: solid; }
.ymazo-designer__tabs-empty {
  display: inline-flex;
  align-items: center;
  font-size: 12px;
  color: var(--ink-mute);
  padding: 0 8px;
}

/* ---------- POSITION PICKER MODAL ---------- */
.ymazo-designer__picker {
  position: absolute;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ymazo-designer__picker[hidden] { display: none; }
.ymazo-designer__picker-bg {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.4);
  cursor: pointer;
}
.ymazo-designer__picker-panel {
  position: relative;
  background: #fff;
  border-radius: 12px;
  width: min(720px, 92%);
  max-height: 80%;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 32px rgba(0,0,0,.2);
  overflow: hidden;
}
.ymazo-designer__picker-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.ymazo-designer__picker-head h3 { margin: 0; font-size: 15px; font-weight: 700; }
.ymazo-designer__picker-x {
  width: 28px; height: 28px;
  border: none; background: #f0f0f0;
  border-radius: 50%; font-size: 18px;
  cursor: pointer; color: var(--ink-soft);
}
.ymazo-designer__picker-x:hover { background: #ddd; color: var(--ink); }
.ymazo-designer__picker-body {
  padding: 16px;
  overflow-y: auto;
}
.ymazo-designer__picker-body .ymazo-designer__pos-grid {
  grid-template-columns: repeat(3, 1fr);
}
.ymazo-designer__picker-body .ymazo-designer__pos-card.is-already-added {
  opacity: .4;
  pointer-events: none;
}
.ymazo-designer__picker-body .ymazo-designer__pos-card.is-already-added::after {
  content: "追加済み";
  position: absolute;
  top: 8px; left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,.6);
  color: #fff;
  padding: 2px 8px;
  font-size: 10px;
  border-radius: 999px;
}

/* ---------- 設計確認 MODAL ---------- */
.ymazo-designer__confirm .ymazo-designer__picker-panel {
  width: min(880px, 95%);
  max-height: 90%;
}
.ymazo-designer__confirm-body {
  padding: 18px;
  overflow-y: auto;
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 20px;
}
.ymazo-designer__confirm-views {
  display: flex;
  gap: 12px;
  justify-content: center;
}
.ymazo-designer__confirm-view {
  flex: 1;
  text-align: center;
  background: #fafafa;
  border-radius: 8px;
  padding: 8px;
}
.ymazo-designer__confirm-view img {
  width: 100%;
  height: auto;
  max-height: 380px;
  object-fit: contain;
  background: #fff;
}
.ymazo-designer__confirm-view-label {
  font-size: 11px;
  color: var(--ink-mute);
  text-transform: uppercase;
  font-weight: 700;
  margin-top: 6px;
}
.ymazo-designer__confirm-details {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.ymazo-designer__confirm-line {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.ymazo-designer__confirm-line .label { color: var(--ink-soft); }
.ymazo-designer__confirm-line .val { font-weight: 600; color: var(--ink); }
.ymazo-designer__confirm-pos {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  padding: 6px 10px;
  background: #f8f8f8;
  border-radius: 6px;
  margin-bottom: 4px;
}
.ymazo-designer__confirm-pos .name { color: var(--ink); }
.ymazo-designer__confirm-pos .price { color: var(--accent); font-weight: 700; }
.ymazo-designer__size-qty-table {
  width: 100%;
  border-collapse: collapse;
  background: #fafafa;
  border-radius: 6px;
  overflow: hidden;
  font-size: 13px;
}
.ymazo-designer__size-qty-table th {
  padding: 8px;
  text-align: left;
  background: #f0f0f0;
}
.ymazo-designer__size-qty-table td {
  padding: 8px;
}
.ymazo-designer__size-qty-table tfoot tr {
  border-top: 1px solid #ddd;
}
.ymazo-designer__size-qty-table tfoot td {
  font-weight: 700;
}
.ymazo-designer__size-total {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.ymazo-designer__size-empty-hint {
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
  line-height: 1.2;
}
.ymazo-designer__size-qty-row .size {
  font-weight: 600;
}
.ymazo-designer__size-stepper {
  display: inline-grid;
  grid-template-columns: 32px 58px 32px;
  align-items: center;
  border: 1px solid #cfd4dc;
  border-radius: 7px;
  overflow: hidden;
  background: #fff;
}
.ymazo-designer__size-stepper button {
  width: 32px;
  height: 32px;
  border: 0;
  background: #f8fafc;
  color: var(--ink);
  font-size: 18px;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
}
.ymazo-designer__size-stepper button:active {
  background: #eef2f7;
}
.ymazo-designer__size-stepper input {
  width: 58px;
  height: 32px;
  border: 0;
  border-left: 1px solid #cfd4dc;
  border-right: 1px solid #cfd4dc;
  text-align: center;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
  background: #fff;
  appearance: textfield;
}
.ymazo-designer__size-stepper input::-webkit-outer-spin-button,
.ymazo-designer__size-stepper input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.ymazo-designer__confirm-total {
  font-size: 22px;
  font-weight: 800;
  color: var(--ink);
  text-align: right;
  padding-top: 10px;
  border-top: 2px solid var(--ink);
  margin-top: 4px;
}
.ymazo-designer__confirm-footer {
  display: flex;
  gap: 10px;
  padding: 14px 18px;
  border-top: 1px solid var(--border);
  background: #fafafa;
}

/* ---------- TEXT EDITOR PANEL ---------- */
.ymazo-designer__text-panel { display: flex; flex-direction: column; gap: 12px; }
.ymazo-designer__text-panel h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
}
.ymazo-designer__text-panel .field { display: flex; flex-direction: column; gap: 4px; }
.ymazo-designer__text-panel label {
  font-size: 10px;
  color: var(--ink-mute);
  text-transform: uppercase;
  letter-spacing: .04em;
  font-weight: 700;
}
.ymazo-designer__text-panel textarea,
.ymazo-designer__text-panel input[type="text"],
.ymazo-designer__text-panel select {
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 13px;
  font-family: inherit;
  background: #fff;
  box-sizing: border-box;
}
.ymazo-designer__text-panel textarea {
  resize: vertical;
  min-height: 56px;
}
.ymazo-designer__text-panel .field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.ymazo-designer__text-panel input[type="range"] {
  width: 100%;
}
.ymazo-designer__text-panel input[type="color"] {
  width: 40px;
  height: 28px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: none;
  cursor: pointer;
}
.ymazo-designer__text-panel .color-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.ymazo-designer__text-panel .color-row input[type="text"] {
  flex: 1;
  font-family: monospace;
}
.ymazo-designer__text-panel .range-row {
  display: flex; align-items: center; gap: 8px;
}
.ymazo-designer__text-panel .range-row span {
  font-size: 11px;
  color: var(--ink-soft);
  min-width: 32px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.ymazo-designer__tool.is-active {
  background: #fff5f7;
  color: var(--accent);
}

/* ---------- 色 TINT OVERLAY ---------- */
.ymazo-designer__mockup-tint {
  position: absolute;
  inset: 0;
  z-index: 1;
  -webkit-mask: var(--tint-mask) center / contain no-repeat;
  mask: var(--tint-mask) center / contain no-repeat;
  background: var(--tint-color, transparent);
  mix-blend-mode: multiply;
  opacity: 0;
  transition: opacity .2s, background .2s;
  pointer-events: none;
}
.ymazo-designer__mockup-tint.is-active { opacity: 1; }

/* ---------- COLOR PALETTE ---------- */
.ymazo-designer__color-palette {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 4px;
  width: 100%;
}
.ymazo-designer__color-swatch {
  width: 100%;
  aspect-ratio: 1;
  border: 1.5px solid #ddd;
  border-radius: 4px;
  cursor: pointer;
  padding: 0;
  position: relative;
}
.ymazo-designer__color-swatch:hover {
  border-color: #999;
  transform: scale(1.1);
  z-index: 1;
}
.ymazo-designer__color-swatch.is-disabled {
  cursor: pointer;
  opacity: .45;
  overflow: hidden;
}
.ymazo-designer__color-swatch.is-disabled:hover {
  border-color: #ddd;
  transform: none;
  z-index: auto;
}
.ymazo-designer__color-swatch.is-disabled::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 10%;
  right: 10%;
  height: 1.5px;
  background: rgba(80,80,80,.55);
  transform: rotate(-38deg);
  pointer-events: none;
}
.ymazo-designer__color-swatch.is-active {
  border-color: var(--accent);
  border-width: 2.5px;
}
.ymazo-designer__color-swatch.is-active::after {
  content: "✓";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  text-shadow: 0 0 2px rgba(0,0,0,.5);
  font-size: 14px;
  font-weight: 700;
}

/* ---------- STICKER / TEMPLATE LIBRARY ---------- */
.ymazo-designer__sticker-tabs {
  display: flex;
  gap: 4px;
  padding: 10px 16px 0;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}
.ymazo-designer__sticker-tab {
  border: none;
  background: transparent;
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-soft);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}
.ymazo-designer__sticker-tab:hover { color: var(--ink); }
.ymazo-designer__sticker-tab.is-active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
.ymazo-designer__sticker-body,
.ymazo-designer__template-body {
  padding: 16px;
  overflow-y: auto;
}
.ymazo-designer__sticker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
  gap: 8px;
}
.ymazo-designer__sticker-item {
  aspect-ratio: 1;
  background: #fafafa;
  border: 1.5px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all .12s;
  padding: 8px;
}
.ymazo-designer__sticker-item:hover {
  border-color: var(--accent);
  background: #fff;
  transform: translateY(-2px);
}
.ymazo-designer__sticker-item img,
.ymazo-designer__sticker-item svg {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.ymazo-designer__template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
}
.ymazo-designer__template-card {
  border: 1.5px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  transition: all .12s;
  background: #fff;
}
.ymazo-designer__template-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,.08);
}
.ymazo-designer__template-card img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: contain;
  background: #fafafa;
}
.ymazo-designer__template-card .name {
  padding: 6px 8px;
  font-size: 11px;
  font-weight: 600;
  text-align: center;
}

/* ---------- TOP ---------- */
.ymazo-designer__top {
  grid-area: top;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  background: #fff;
  border-bottom: 1px solid var(--border);
}
.ymazo-designer__title { font-size: 15px; font-weight: 700; letter-spacing: .02em; margin: 0; }
.ymazo-designer__title small { font-weight: 400; color: var(--ink-soft); font-size: 12px; margin-left: 8px; }

.ymazo-designer__top-right {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

/* ---------- MODE 2D / 3D toggle ---------- */
.ymazo-designer__mode-toggle {
  display: inline-flex;
  background: #f4f4f4;
  border-radius: 999px;
  padding: 3px;
}
.ymazo-designer__mode-toggle button {
  border: none;
  background: transparent;
  padding: 5px 14px;
  font-size: 12px;
  border-radius: 999px;
  cursor: pointer;
  color: #666;
  font-weight: 700;
  letter-spacing: .04em;
}
.ymazo-designer__mode-toggle button.is-active {
  background: var(--ink);
  color: #fff;
}

/* 3D モード時は zoom + view toggle 隠す */
.ymazo-designer.is-3d-mode .js-2d-only { display: none !important; }
.ymazo-designer.is-3d-mode .ymazo-designer__canvas-wrap { display: none !important; }
.ymazo-designer.is-3d-mode .ymazo-designer__tabs { opacity: .4; pointer-events: none; }
.ymazo-designer.is-3d-mode .ymazo-designer__canvas-3d { display: flex; }

/* ---------- 3D VIEWER (CSS 3D card-flip) ---------- */
.ymazo-designer__canvas-3d {
  display: none;
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, #edf1f6 0%, #d6dde7 72%, #c5ceda 100%);
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  /* CSS 3D 視野 */
  perspective: 1400px;
  perspective-origin: 50% 45%;
  align-items: center;
  justify-content: center;
}
.ymazo-designer__shirt-3d {
  position: relative;
  width: min(85%, 480px);
  aspect-ratio: 1100 / 1430;
  transform-style: preserve-3d;
  cursor: grab;
  transition: transform .12s ease-out;
  will-change: transform;
}
.ymazo-designer__shirt-3d:active { cursor: grabbing; transition: none; }
.ymazo-designer__shirt-face {
  position: absolute;
  inset: 0;
  background-size: contain;
  background-position: center;
  background-repeat: no-repeat;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  filter: drop-shadow(0 12px 28px rgba(0,0,0,.18));
  display: block !important;  /* テーマの div:empty{display:none} 対抗 */
}
.ymazo-designer__shirt-face--front {
  transform: translateZ(2px);   /* 少しだけ Z で分離（z-fighting 防止） */
}
.ymazo-designer__shirt-face--back {
  transform: rotateY(180deg) translateZ(2px);
}
.ymazo-designer__shirt-3d-hint {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,.5);
  color: #fff;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 11px;
  pointer-events: none;
  white-space: nowrap;
}
.ymazo-designer__cart-btn {
  position: relative;
  border: 1.5px solid var(--border);
  background: #fff;
  border-radius: 999px;
  padding: 5px 14px 5px 12px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--ink);
  transition: all .12s;
}
.ymazo-designer__cart-btn:hover { border-color: var(--accent); color: var(--accent); }
.ymazo-designer__cart-btn .js-cart-count {
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 999px;
  min-width: 16px;
  text-align: center;
  font-weight: 700;
}
.ymazo-designer__cart-btn.is-empty .js-cart-count { background: #ccc; }

/* ---------- CART MODAL ---------- */
.ymazo-designer__cart-modal .ymazo-designer__picker-panel {
  width: min(720px, 95%);
  max-height: 86%;
}
.ymazo-designer__cart-body {
  padding: 16px 18px;
  overflow-y: auto;
  flex: 1;
}
.ymazo-designer__cart-empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--ink-mute);
}
.ymazo-designer__cart-empty .ico { font-size: 48px; display: block; margin-bottom: 12px; opacity: .4; }
.ymazo-designer__cart-item {
  display: grid;
  grid-template-columns: 80px 1fr auto;
  gap: 14px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 10px;
  align-items: center;
  background: #fff;
}
.ymazo-designer__cart-item-thumb {
  width: 80px;
  aspect-ratio: 4/5;
  background: #fafafa;
  border-radius: 6px;
  overflow: hidden;
}
.ymazo-designer__cart-item-thumb img { width: 100%; height: 100%; object-fit: contain; }
.ymazo-designer__cart-item-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.ymazo-designer__cart-item-info .name {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
}
.ymazo-designer__cart-item-info .meta {
  font-size: 11px;
  color: var(--ink-soft);
  line-height: 1.5;
}
.ymazo-designer__cart-item-info .price {
  font-size: 14px;
  font-weight: 800;
  color: var(--accent);
  margin-top: 2px;
}
.ymazo-designer__cart-item-actions {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.ymazo-designer__cart-item-qty {
  width: 56px;
  padding: 4px 6px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 12px;
  text-align: center;
}
.ymazo-designer__cart-item-del {
  border: none;
  background: transparent;
  color: var(--ink-mute);
  cursor: pointer;
  font-size: 11px;
  padding: 2px;
  text-decoration: underline;
}
.ymazo-designer__cart-item-del:hover { color: var(--accent); }
.ymazo-designer__cart-footer {
  padding: 16px 18px;
  border-top: 1px solid var(--border);
  background: #fafafa;
  display: flex;
  align-items: center;
  gap: 10px;
}
.ymazo-designer__cart-footer .total {
  flex: 1;
  font-size: 18px;
  font-weight: 800;
  color: var(--ink);
}
.ymazo-designer__cart-footer .total span { font-size: 12px; color: var(--ink-mute); font-weight: 500; margin-right: 6px; }
.ymazo-designer__cart-footer .js-cart-checkout {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 12px 24px;
  font-weight: 700;
  cursor: pointer;
  font-size: 14px;
}
.ymazo-designer__cart-footer .js-cart-checkout:hover { background: #be1641; }
.ymazo-designer__cart-footer .js-cart-checkout:disabled { background: #ccc; cursor: not-allowed; }
.ymazo-designer__cart-footer .js-cart-continue {
  border: 1.5px solid var(--border);
  background: #fff;
  border-radius: 999px;
  padding: 10px 18px;
  font-weight: 600;
  cursor: pointer;
  font-size: 12px;
  color: var(--ink);
}
.ymazo-designer__view-toggle,
.ymazo-designer__zoom-toggle {
  display: inline-flex;
  background: #f4f4f4;
  border-radius: 999px;
  padding: 3px;
}
.ymazo-designer__view-toggle button,
.ymazo-designer__zoom-toggle button {
  border: none;
  background: transparent;
  padding: 5px 14px;
  font-size: 12px;
  border-radius: 999px;
  cursor: pointer;
  color: #666;
  font-weight: 600;
}
.ymazo-designer__view-toggle button.is-active,
.ymazo-designer__zoom-toggle button.is-active {
  background: var(--ink);
  color: #fff;
}

/* ---------- LEFT TOOLS ---------- */
.ymazo-designer__tools {
  grid-area: tools;
  background: #fff;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 8px;
}
.ymazo-designer__tool {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 4px;
  border: none;
  background: transparent;
  cursor: pointer;
  border-radius: 6px;
  color: var(--ink-soft);
  transition: all .12s;
  font-size: 9px;
  font-weight: 600;
}
.ymazo-designer__tool[hidden] { display: none !important; }
.ymazo-designer__tool-ico { font-size: 18px !important; width: 20px !important; height: 20px !important; }
.ymazo-designer__tool:hover { background: #f4f4f4; color: var(--ink); }
.ymazo-designer__tool[disabled] { opacity: .35; cursor: not-allowed; }
.ymazo-designer__tool-ico {
  width: 24px; height: 24px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 20px; line-height: 1;
}
.ymazo-designer__tool--accent { color: var(--accent); }
.ymazo-designer__tool--accent:hover { background: #fff5f7; color: var(--accent); }

/* ---------- CENTER CANVAS ---------- */
.ymazo-designer__canvas-area {
  grid-area: canvas;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px 24px;  /* T シャツが画面いっぱいに張り付くのを防ぐ余白 */
  overflow: hidden;
  /* 白 T シャツが背景と同化しないよう、柔らかいグレー + 微妙な放射状で立体感 */
  background:
    radial-gradient(ellipse at center, #edf1f6 0%, #d9e0e9 72%, #c8d1dd 100%);
}
.ymazo-designer__canvas-wrap {
  position: relative;
  width: auto;
  height: 100%;
  aspect-ratio: 1100 / 1430;
  max-width: 100%;
  max-height: 100%;
  background: transparent;
  border-radius: 6px;
  overflow: hidden;
  transition: transform .3s ease;
  transform-origin: var(--zoom-x, 50%) var(--zoom-y, 50%);
}
.ymazo-designer__canvas-wrap.is-zoomed {
  transform: scale(var(--zoom-scale, 1));
}
.ymazo-designer__mockup {
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 16px 28px rgba(40,52,70,.16));
  user-select: none;
  pointer-events: none;
  z-index: 0;
}
.js-position-overlay {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}
.ymazo-designer__canvas-layer { position: absolute; inset: 0; z-index: 3; }
.ymazo-designer__canvas-layer canvas { position: absolute !important; }

.ymazo-designer__position-box {
  position: absolute;
  border: 0;  /* guides are drawn by ::after so all four sides stay visible on mobile */
  box-sizing: border-box;
  cursor: pointer;
  pointer-events: none;
  transition: all .15s;
  --position-guide-color: rgba(248,180,200,.7);
  --position-guide-line: 1.5px;
  --position-guide-dash: 8px;
  --position-guide-gap: 6px;
}
.ymazo-designer__position-box::after {
  content: "";
  position: absolute;
  inset: 1px;
  pointer-events: none;
  box-sizing: border-box;
  border-radius: 2px;
  opacity: 0;
  transition: opacity .15s;
  background:
    repeating-linear-gradient(90deg, var(--position-guide-color) 0 var(--position-guide-dash), transparent var(--position-guide-dash) calc(var(--position-guide-dash) + var(--position-guide-gap))) left top / 100% var(--position-guide-line) no-repeat,
    repeating-linear-gradient(90deg, var(--position-guide-color) 0 var(--position-guide-dash), transparent var(--position-guide-dash) calc(var(--position-guide-dash) + var(--position-guide-gap))) left bottom / 100% var(--position-guide-line) no-repeat,
    repeating-linear-gradient(180deg, var(--position-guide-color) 0 var(--position-guide-dash), transparent var(--position-guide-dash) calc(var(--position-guide-dash) + var(--position-guide-gap))) left top / var(--position-guide-line) 100% no-repeat,
    repeating-linear-gradient(180deg, var(--position-guide-color) 0 var(--position-guide-dash), transparent var(--position-guide-dash) calc(var(--position-guide-dash) + var(--position-guide-gap))) right top / var(--position-guide-line) 100% no-repeat;
}
.ymazo-designer__position-box:hover {
  --position-guide-color: rgba(248,180,200,.7);  /* 淡いピンク（hover）*/
  background: transparent;
}
.ymazo-designer__position-box:hover::after {
  opacity: 1;
}
.ymazo-designer__position-box.is-active {
  --position-guide-color: #ef8cad;  /* originalprint.jp 風 淡いピンク */
  --position-guide-line: 2px;
  box-shadow: none;  /* 二重感を消す */
  pointer-events: none;  /* fabric にドラッグを通す */
}
.ymazo-designer__position-box.is-active::after {
  opacity: 1;
}
/* 「基点→」ラベル — 印刷枠の外、上辺の左に配置（デザインに被らない） */
.ymazo-designer__position-box.is-active::before {
  display: none;
  content: none;
}
.ymazo-designer__position-box.is-selected:not(.is-active) {
  --position-guide-color: rgba(248,180,200,.4);  /* 淡いピンク */
  --position-guide-line: 1.5px;
}
.ymazo-designer__position-box.is-selected:not(.is-active)::after {
  opacity: 1;
}
.ymazo-designer__position-box.has-object:not(.is-active):not(:hover) {
  --position-guide-color: rgba(248,180,200,.5);
  --position-guide-line: 1.5px;
}
.ymazo-designer__position-box.has-object:not(.is-active):not(:hover)::after {
  opacity: 1;
}
.ymazo-designer__position-label {
  position: absolute;
  top: -20px; left: 0;
  font-size: 10px;
  color: #666;
  background: rgba(255,255,255,0.95);
  padding: 1px 5px;
  border-radius: 3px;
  font-weight: 600;
  pointer-events: none;
  display: none;
  white-space: nowrap;
  line-height: 1.2;
}
.ymazo-designer__position-box.is-active .ymazo-designer__position-label {
  background: var(--accent);
  color: #fff;
  display: none;
}

.ymazo-designer__loading {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,.9);
  z-index: 30; font-size: 12px; color: #666;
}
.ymazo-designer__loading::before {
  content: ""; width: 18px; height: 18px;
  border: 2px solid #e0e0e0;
  border-top-color: var(--accent);
  border-radius: 50%; margin-right: 8px;
  animation: ymazo-spin .7s linear infinite;
}
@keyframes ymazo-spin { to { transform: rotate(360deg); } }

/* ---------- RIGHT SIDE ---------- */
.ymazo-designer__side {
  grid-area: side;
  background: #fff;
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.ymazo-designer__side-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  font-weight: 700;
  color: var(--ink-mute);
  text-transform: uppercase;
  letter-spacing: .08em;
}
/* flex:1 だと内容が短くてもパネル全高まで伸び、色選択と「次へ」が最下部に押し下げられて
   小さいノートPCで見切れる。内容ぶんだけの高さにして、フッター(色+次へ)を直下＝上の方に詰める。
   内容が長い時は overflow-y で side-body 側だけスクロール（min-height:0 で縮小許可）。 */
.ymazo-designer__side-body { padding: 12px 16px; overflow-y: auto; flex: 0 1 auto; min-height: 0; }

.ymazo-designer__side-footer {
  border-top: 1px solid var(--border);
  background: #fafafa;
  padding: 10px 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
}
.ymazo-designer__sf-row {
  display: flex; align-items: center; gap: 8px;
  flex-wrap: wrap;
}
.ymazo-designer__sf-label {
  font-size: 10px; color: var(--ink-mute);
  text-transform: uppercase; letter-spacing: .06em;
  font-weight: 700; min-width: 76px;
}
.ymazo-designer__sf-price {
  display: flex; flex-direction: column; align-items: flex-end;
  padding: 8px 0 4px;
  border-top: 1px dashed var(--border);
  margin-top: 4px;
}
.ymazo-designer__sf-price .per { font-size: 11px; color: var(--ink-mute); }
.ymazo-designer__sf-price .total { font-size: 26px; font-weight: 800; color: var(--ink); line-height: 1.1; }

.ymazo-designer__pos-empty {
  text-align: center; color: var(--ink-mute);
  padding: 30px 12px; font-size: 13px; line-height: 1.5;
}
.ymazo-designer__pos-empty span { display: block; font-size: 32px; margin-bottom: 10px; }

.ymazo-designer__pos-active { margin-bottom: 18px; }
.ymazo-designer__pos-active h3 {
  margin: 0 0 4px; font-size: 16px;
}
.ymazo-designer__pos-active h3 .view {
  font-size: 11px; color: var(--ink-mute); font-weight: 400; margin-left: 6px;
}

.ymazo-designer__size-chips {
  display: grid; grid-template-columns: repeat(5,1fr); gap: 6px; margin: 10px 0;
}
.ymazo-designer__size-chip {
  padding: 9px 4px;
  border: 1.5px solid var(--border);
  background: #fff;
  border-radius: 8px;
  font-size: 12px; font-weight: 700;
  color: #444; cursor: pointer;
  transition: all .12s;
}
.ymazo-designer__size-chip:hover { border-color: #888; color: var(--ink); }
.ymazo-designer__size-chip.is-active {
  background: var(--ink); color: #fff; border-color: var(--ink);
}
.ymazo-designer__size-chip .dim {
  display: block; font-size: 9px; opacity: .6; margin-top: 1px; font-weight: 500;
}

.ymazo-designer__pos-info {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: 12px; color: var(--ink-soft);
  background: #f8f8f8; padding: 10px 12px; border-radius: 8px;
  margin-top: 8px;
}
.ymazo-designer__pos-info strong { color: var(--ink); font-size: 14px; }

.ymazo-designer__pos-action {
  display: flex; gap: 8px; margin-top: 10px;
}
.ymazo-designer__btn {
  flex: 1;
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  background: #fff;
  border-radius: 8px;
  font-size: 12px; font-weight: 600;
  cursor: pointer;
  transition: all .12s;
  color: var(--ink);
}
.ymazo-designer__btn:hover { border-color: var(--ink); }
.ymazo-designer__btn:disabled {
  opacity: .58;
  cursor: default;
  border-color: var(--border);
}
.ymazo-designer__btn--primary {
  background: var(--accent); color: #fff; border-color: var(--accent);
}
.ymazo-designer__btn--primary:hover { background: #be1641; border-color: #be1641; }
.ymazo-designer__btn--danger { color: var(--accent); }
.ymazo-designer__btn--danger:hover { background: #fff5f7; border-color: var(--accent); }

.ymazo-designer__other-list { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.ymazo-designer__other-list-title {
  font-size: 11px; color: var(--ink-mute); font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em; margin-bottom: 8px;
}
.ymazo-designer__other-pos {
  display: flex; justify-content: space-between; align-items: center;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 6px;
  cursor: pointer;
  font-size: 12px;
  transition: all .12s;
}
.ymazo-designer__other-pos:hover { border-color: #999; }
.ymazo-designer__other-pos.is-set { background: #fafafa; border-color: var(--ink); }
.ymazo-designer__other-pos .name { font-weight: 600; }
.ymazo-designer__other-pos .price { color: var(--ink-soft); font-size: 11px; }

/* ---------- POSITION CARD GRID（仿 4173 mini T 恤）---------- */
.ymazo-designer__pos-grid-title {
  margin: 16px 0 8px;
  font-size: 11px;
  font-weight: 700;
  color: var(--ink-mute);
  text-transform: uppercase;
  letter-spacing: .06em;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.ymazo-designer__pos-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}
.ymazo-designer__pos-card {
  position: relative;
  background: #fff;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 6px;
  cursor: pointer;
  transition: all .12s;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.ymazo-designer__pos-card:hover {
  border-color: #888;
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(0,0,0,.06);
}
.ymazo-designer__pos-card.is-active {
  border-color: var(--accent);
  border-width: 2px;
  padding: 5px;
  background: #fff5f7;
}
.ymazo-designer__pos-card.is-set {
  border-color: var(--ink);
  background: #fafafa;
}
.ymazo-designer__pos-card.is-set.is-active {
  border-color: var(--accent);
  background: #fff5f7;
}
.ymazo-designer__pos-thumb {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 5;
  background: #f4f4f4;
  border-radius: 6px;
  overflow: hidden;
}
.ymazo-designer__pos-thumb img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  user-select: none;
  pointer-events: none;
}
.ymazo-designer__pos-thumb-rect {
  position: absolute;
  background: rgba(225,29,72,0.22);
  border: 1.5px solid rgba(225,29,72,0.95);
  border-radius: 2px;
  pointer-events: none;
  display: block !important; /* 主题の base.css 的 div:empty{display:none} 对抗 */
}
.ymazo-designer__pos-card.is-set .ymazo-designer__pos-thumb-rect {
  background: rgba(225,29,72,0.55);
}
.ymazo-designer__pos-check {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 18px;
  height: 18px;
  background: var(--accent);
  color: #fff;
  border-radius: 50%;
  display: flex !important; /* 同上、empty div 防止 */
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.ymazo-designer__pos-cardinfo {
  text-align: center;
  line-height: 1.25;
  padding: 2px 2px 4px;
}
.ymazo-designer__pos-cardinfo .name {
  font-size: 11px;
  font-weight: 700;
  color: var(--ink);
}
.ymazo-designer__pos-cardinfo .dim {
  font-size: 9px;
  color: var(--ink-mute);
  margin-top: 1px;
}
.ymazo-designer__pos-cardinfo .price {
  font-size: 10px;
  color: var(--accent);
  font-weight: 700;
  margin-top: 2px;
}

/* ---------- BOTTOM BAR ---------- */
.ymazo-designer__bottom {
  grid-area: bottom;
  background: #fff;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 18px;
  gap: 20px;
}
.ymazo-designer__bottom-group {
  display: flex; align-items: center; gap: 10px;
}
.ymazo-designer__bottom-label {
  font-size: 10px; color: var(--ink-mute);
  text-transform: uppercase; letter-spacing: .06em;
  font-weight: 700;
}
.ymazo-designer__chips {
  display: flex; gap: 4px;
}
.ymazo-designer__chip {
  padding: 6px 12px;
  border: 1.5px solid var(--border);
  background: #fff;
  border-radius: 999px;
  font-size: 12px; font-weight: 600;
  cursor: pointer;
  color: #555;
}
.ymazo-designer__chip:hover { border-color: var(--ink); color: var(--ink); }
.ymazo-designer__chip.is-active {
  background: var(--ink); color: #fff; border-color: var(--ink);
}
.ymazo-designer__qty-input {
  width: 70px;
  padding: 8px 10px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 14px; font-weight: 700;
  text-align: center;
}
.ymazo-designer__qty-input:focus { outline: none; border-color: var(--accent); }
.ymazo-designer__qty-tier {
  font-size: 10px; color: var(--ink-mute);
}

.ymazo-designer__bottom-spacer { flex: 1; }

.ymazo-designer__price-block {
  text-align: right; line-height: 1.1;
}
.ymazo-designer__price-block .per {
  font-size: 11px; color: var(--ink-mute); display: block; margin-bottom: 2px;
}
.ymazo-designer__price-block .total {
  font-size: 24px; font-weight: 800; color: var(--ink);
}

.ymazo-designer__cta {
  width: 100%;
  padding: 14px 24px;
  background: var(--accent); color: #fff;
  border: none; border-radius: 999px;
  font-size: 14px; font-weight: 700; cursor: pointer;
  letter-spacing: .03em;
  transition: all .15s;
}
.ymazo-designer__cta:hover:not(:disabled) { background: #be1641; transform: translateY(-1px); }
.ymazo-designer__cta:disabled { background: #ccc; cursor: not-allowed; }

/* ---------- Messages ---------- */
.ymazo-designer__msg-area {
  position: fixed;
  top: 80px; right: 20px;
  z-index: 100;
  max-width: 360px;
}
.ymazo-designer__msg {
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 8px;
  font-size: 13px;
  box-shadow: 0 4px 12px rgba(0,0,0,.12);
  animation: ymazo-slide-in .2s ease-out;
  display: flex;
  align-items: center;
  gap: 10px;
}
@keyframes ymazo-slide-in { from { transform: translateX(20px); opacity: 0; } }
.ymazo-designer__msg-text { flex: 1; min-width: 0; }
.ymazo-designer__msg-close {
  width: 24px;
  height: 24px;
  border: none;
  border-radius: 999px;
  background: rgba(0,0,0,.08);
  color: currentColor;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}
.ymazo-designer__msg-close:hover { background: rgba(0,0,0,.14); }
.ymazo-designer__msg--warn { background: #fff8e6; color: #92670c; border: 1px solid #fde2a3; }
.ymazo-designer__msg--err { background: #fef2f4; color: #b91c1c; border: 1px solid #fecaca; }
.ymazo-designer__msg--ok { background: #f0fdf4; color: #14532d; border: 1px solid #bbf7d0; }
.ymazo-designer__pointer-hint {
  position: fixed;
  z-index: 9999;
  width: max-content;
  max-width: calc(100vw - 16px);
  padding: 5px 8px;
  border-radius: 6px;
  background: rgba(17,17,17,.92);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
  box-shadow: 0 4px 10px rgba(0,0,0,.18);
  pointer-events: none;
  opacity: 0;
  transform: translateY(2px);
  transition: opacity .12s ease, transform .12s ease;
}
.ymazo-designer__pointer-hint.is-visible {
  opacity: 1;
  transform: translateY(0);
}
/* 軽い重なり用：やさしいアンバー（注文OKの一文も入るので折り返し可に） */
.ymazo-designer__pointer-hint--warn {
  background: rgba(180,83,9,.96);
  white-space: normal;
  max-width: min(260px, calc(100vw - 16px));
  text-align: center;
}

/* 大きく重なり(50%超)用：手動で×を押すまで消えない常駐ヒント */
.ymazo-designer__overlap-hint {
  position: fixed;
  z-index: 10000;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: calc(100vw - 16px);
  padding: 8px 8px 8px 12px;
  border-radius: 8px;
  background: rgba(178,42,42,.97);
  color: #fff;
  font-size: 12.5px;
  font-weight: 700;
  line-height: 1.3;
  box-shadow: 0 6px 18px rgba(0,0,0,.28);
  opacity: 0;
  transform: translateY(2px);
  transition: opacity .12s ease, transform .12s ease;
}
.ymazo-designer__overlap-hint.is-visible {
  opacity: 1;
  transform: translateY(0);
}
.ymazo-designer__overlap-hint-text { white-space: normal; }
.ymazo-designer__overlap-hint-close {
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: rgba(255,255,255,.22);
  color: #fff;
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
}
.ymazo-designer__overlap-hint-close:hover { background: rgba(255,255,255,.38); }

.ymazo-designer__file-input { display: none; }

/* ---------- 配置缺失提示 ---------- */
.ymazo-designer__setup-needed {
  max-width: 640px; margin: 60px auto; padding: 36px;
  background: #fffbea; border: 1px solid #ffe89d; border-radius: 12px; text-align: center;
}
.ymazo-designer__setup-needed h2 { margin: 0 0 14px; color: #92670c; }
.ymazo-designer__setup-needed code {
  background: #fff; padding: 2px 8px; border-radius: 4px;
  font-size: 13px; border: 1px solid #ffe89d;
}
.ymazo-designer__setup-needed ol { text-align: left; line-height: 1.8; }

/* ========================================================
   📱 TOGGLE BAR — 整体/拡大 + 前/背（mobile + desktop 両方）
   ======================================================== */
.ymazo-designer__toggle-bar {
  grid-area: togglebar;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 4px 18px;
  background: #fff;
  border-bottom: 1px solid var(--border);
}

/* 位置 mm ラベル（オブジェクト選択時）*/
.ymazo-designer__pos-info-label {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 12px;
  transform: none;
  background: rgba(255,255,255,.96);
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 10.5px;
  color: #333;
  box-shadow: 0 2px 8px rgba(0,0,0,.15);
  pointer-events: auto;
  z-index: 12;
  line-height: 1.35;
  font-variant-numeric: tabular-nums;
  min-width: 0;
  max-width: calc(100% - 16px);
  white-space: normal;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 3px 6px;
}
.ymazo-designer__pos-info-label .label {
  display: inline-flex;
  font-size: 10.5px;
  color: #888;
  font-weight: 700;
  margin-right: 0;
}
.ymazo-designer__pos-info-label .vals {
  font-size: 12px;
  font-weight: 800;
  color: #333;
  display: inline-flex;
  white-space: nowrap;
}
.ymazo-designer__pos-info-label .vals,
.ymazo-designer__pos-info-label .is-size { display: inline-flex; }
.ymazo-designer__pos-info-label .is-size {
  margin-left: 0;
}
.ymazo-designer__pos-info-label .placement {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: 999px;
  background: #f1f5f9;
  color: #64748b;
  font-size: 10px;
  font-weight: 700;
  white-space: nowrap;
}
.ymazo-designer__pos-info-label .placement.is-manual {
  background: #fff1f2;
  color: var(--accent);
}
.ymazo-designer__pos-info-label .placement-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #d7dee8;
  border-radius: 999px;
  background: #fff;
  color: #111;
  font-size: 10px;
  font-weight: 800;
  line-height: 1;
  padding: 5px 9px;
  cursor: pointer;
  pointer-events: auto;
  white-space: nowrap;
}
.ymazo-designer__pos-info-label .placement-toggle:active {
  transform: translateY(1px);
}
.ymazo-designer__pos-info-label .placement-toggle:disabled {
  opacity: .7;
  cursor: default;
}
.ymazo-designer__pos-info-label[hidden] { display: none; }
.ymazo-designer.is-3d-mode .ymazo-designer__pos-info-label { display: none !important; }

/* =============================================================
   📱 RESPONSIVE: タブレット (1023px〜) / スマホ (〜1023px)
   ============================================================= */

/* タブレット（1023〜768px）: 左 panel を縮め、右 panel を縮める */
@media (max-width: 1023px) and (min-width: 769px) {
  .ymazo-designer {
    --tools-w: 52px;
    --tool-panel-w: 240px;
    --side-w: 280px;
  }
}

/* 📱 スマホ（〜768px）: フルスクリーン overlay + 縦積み */
@media (max-width: 768px) {
  /* デザイナーが Shopify ヘッダーを覆って全画面化（モバイル専用フォーカスモード）*/
  .ymazo-designer {
    position: fixed !important;
    inset: 0 !important;
    z-index: 1000 !important;
  }

  /* ROOT: シンプル縦積み */
  .ymazo-designer,
  .ymazo-designer.has-tool-panel {
    --tools-h: 56px;
    --tabs-h: 40px;
    --togglebar-h: 36px;
    --top-h: 44px;
    grid-template-columns: 1fr;
    grid-template-rows:
      var(--top-h)
      var(--togglebar-h)
      var(--tabs-h)
      1fr
      auto
      auto;
    grid-template-areas:
      "top"
      "togglebar"
      "tabs"
      "canvas"
      "side"
      "tools";
    height: 100dvh;
    max-height: none;
    min-height: 100dvh;
    border-radius: 0;
    margin: 0;
    max-width: none;
    box-shadow: none;
    overflow: hidden;
  }

  /* TOP */
  .ymazo-designer__top { padding: 0 12px; height: var(--top-h); }
  .ymazo-designer__title { font-size: 14px; }
  .ymazo-designer__title small { display: none; }
  .ymazo-designer__cart-btn { padding: 4px 10px 4px 8px; font-size: 13px; }

  /* TOGGLE BAR */
  .ymazo-designer__toggle-bar {
    height: var(--togglebar-h);
    padding: 0 12px;
    justify-content: center;
    gap: 10px;
  }
  .ymazo-designer__zoom-toggle button,
  .ymazo-designer__view-toggle button { padding: 4px 12px; font-size: 12px; }

  /* TABS */
  .ymazo-designer__tabs { padding: 0 8px; height: var(--tabs-h); }
  .ymazo-designer__tab { padding: 0 10px; font-size: 11px; }
  .ymazo-designer__tab .size { font-size: 9px; }
  .ymazo-designer__tab-add { width: 30px; height: 30px; font-size: 18px; }

  /* CANVAS */
  .ymazo-designer__canvas-area { padding: 6px; overflow: hidden; min-height: 200px; }
  /* モバイル：overlay 表示するが touch はすべて fabric に通す */
  .js-position-overlay { pointer-events: none !important; }
  .ymazo-designer__position-box { pointer-events: none !important; }
  .ymazo-designer__position-label { display: none !important; }  /* ラベルは小さい画面で邪魔なので隠す */

  /* TOOLS: 下部 dock + iOS safe area */
  .ymazo-designer__tools {
    flex-direction: row;
    align-items: center;
    justify-content: space-around;
    border-right: none;
    border-top: 1px solid var(--border);
    background: #fff;
    padding: 4px 6px;
    padding-bottom: max(4px, env(safe-area-inset-bottom));
    min-height: var(--tools-h);
    height: auto;
    z-index: 5;
    overflow-x: auto;
  }
  .ymazo-designer__tool { flex: 0 0 auto; min-width: 50px; padding: 4px 2px; font-size: 9px; gap: 2px; }
  .ymazo-designer__tool-ico { font-size: 20px !important; }

  /* TOOL PANEL: ボトムシート */
  .ymazo-designer__tool-panel {
    position: fixed;
    inset: auto 0 0 0;
    width: 100%;
    max-height: 70vh;
    border-right: none;
    border-top: 1px solid var(--border);
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -8px 24px rgba(0,0,0,.18);
    z-index: 35;
    transform: translateY(100%);
    transition: transform .25s ease;
    pointer-events: none;
  }
  .ymazo-designer.has-tool-panel .ymazo-designer__tool-panel {
    transform: translateY(0);
    display: flex;
    pointer-events: auto;
  }
  .ymazo-designer__tp-head { padding: 14px 16px 10px; position: relative; }
  .ymazo-designer__tp-head::before {
    content: "";
    position: absolute;
    top: 4px; left: 50%;
    transform: translateX(-50%);
    width: 40px; height: 4px;
    background: #ccc;
    border-radius: 2px;
  }

  /* SIDE: 1 つの grid セル — 縦積み（settings → price/cta） */
  .ymazo-designer__side {
    grid-area: side;
    flex-direction: column;
    border-left: none;
    border-top: 1px solid var(--border);
    background: #fff;
    max-height: none;
  }
  /* モバイルは側パネルを隠して画布を広く使う（元の専用レイアウト）。
     画像の背景削除は下部ツールバーの「🪄 透過」ボタンから行う。 */
  .ymazo-designer__side-header,
  .ymazo-designer__side-body { display: none; }
  .ymazo-designer__side-footer {
    display: flex;
    flex-direction: column;
    padding: 0;
    gap: 0;
    background: #fff;
  }
  /* size + color + qty を 1 行に圧縮（横スクロール） */
  .ymazo-designer__side-footer > .ymazo-designer__sf-row {
    flex-direction: row;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    margin: 0;
    border-bottom: 1px solid #f0f0f0;
    overflow-x: auto;
    flex-wrap: nowrap;
  }
  .ymazo-designer__side-footer > .ymazo-designer__sf-row > .ymazo-designer__sf-label {
    font-size: 10px;
    min-width: auto;
    flex: 0 0 auto;
  }
  /* color palette: 横スクロール円形 */
  .ymazo-designer__color-palette {
    display: flex !important;
    grid-template-columns: none !important;
    gap: 5px;
    flex-wrap: nowrap;
    overflow-x: auto;
    flex: 1;
    -webkit-overflow-scrolling: touch;
  }
  .ymazo-designer__color-palette .ymazo-designer__color-swatch {
    width: 28px; height: 28px;
    flex-shrink: 0;
    border-radius: 50%;
    border-width: 1.5px;
  }
  .ymazo-designer__color-palette .ymazo-designer__color-swatch.is-active::after { font-size: 13px; }
  .ymazo-designer__chip { padding: 4px 10px; font-size: 12px; }
  .ymazo-designer__qty-input { width: 50px; padding: 4px; font-size: 13px; }
  .ymazo-designer__qty-tier { display: none; }

  /* price 行 */
  .ymazo-designer__sf-price {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    padding: 6px 12px;
    margin: 0;
    border: none;
    background: #fafafa;
  }
  .ymazo-designer__sf-price .per { font-size: 10px; line-height: 1; order: 1; }
  .ymazo-designer__sf-price .total { font-size: 18px; line-height: 1.1; order: 2; font-weight: 800; }

  /* CTA full-width below price */
  .ymazo-designer__cta {
    border-radius: 0;
    padding: 12px 16px;
    font-size: 14px;
    margin: 0;
    width: 100%;
  }

  /* MODALS: full screen */
  .ymazo-designer__picker .ymazo-designer__picker-panel {
    width: 100%; max-width: none; max-height: 100dvh; height: 100dvh;
    border-radius: 0;
  }
  .ymazo-designer__picker-body .ymazo-designer__pos-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .ymazo-designer__confirm-body { grid-template-columns: 1fr; }
  .ymazo-designer__confirm-view img { max-height: 220px; }
  .ymazo-designer__cart-item {
    grid-template-columns: 56px 1fr;
    gap: 10px;
    padding: 10px;
  }
  .ymazo-designer__cart-item-thumb { width: 56px; }
  .ymazo-designer__cart-item-info .name { font-size: 12px; }
  .ymazo-designer__cart-item-actions { flex-direction: row; grid-column: 1 / -1; justify-content: space-between; }
  .ymazo-designer__cart-footer { flex-wrap: wrap; padding: 12px; }
  .ymazo-designer__cart-footer .total {
    width: 100%; text-align: right; order: -1; font-size: 16px;
  }
  .ymazo-designer__cart-footer .js-cart-continue { flex: 1; padding: 10px 12px; }
  .ymazo-designer__cart-footer .js-cart-checkout { flex: 2; padding: 12px 14px; font-size: 13px; }

  /* メッセージ位置調整 */
  .ymazo-designer__msg-area {
    top: 60px; right: 8px; left: 8px; max-width: none;
  }

  .ymazo-designer__sticker-grid { grid-template-columns: repeat(4, 1fr); }
  .ymazo-designer__template-grid { grid-template-columns: repeat(2, 1fr); }
  .ymazo-designer__recent-grid { grid-template-columns: repeat(4, 1fr); }
}

@media (hover: none) and (pointer: coarse) {
  .ymazo-designer__recent-item:hover {
    transform: none;
  }
  .ymazo-designer__recent-item .del {
    display: flex;
    width: 22px;
    height: 22px;
    font-size: 13px;
  }
}

/* 縦長ファブレット（370px〜480px）: さらに切り詰め */
@media (max-width: 480px) {
  .ymazo-designer__title { font-size: 12px; }
  .ymazo-designer__cart-btn { padding: 3px 8px; font-size: 12px; }
  .ymazo-designer__zoom-toggle button,
  .ymazo-designer__view-toggle button { padding: 4px 10px; font-size: 11px; }
}

/* ---------- モバイル最適化（≤768px）：シャツを縮めず重要 UI を最大化 ---------- */
.ymazo-designer__mobile-size-row { display: none; }
@media (max-width: 768px) {
  /* タイトル行は従来どおり独立行のまま、少し小さく・上下を詰める */
  .ymazo-designer { --top-h: 30px; }
  .ymazo-designer__title { font-size: 12px; }
  /* 白のみ運用のためシャツカラー行は隠す（デスクトップは表示のまま） */
  .ymazo-designer__sf-row--color { display: none !important; }
  /* サイズ chips：キャンバス下端の空き背景に浮かせる（レイアウトを占有しない） */
  .ymazo-designer__mobile-size-row:not([hidden]) {
    display: flex; justify-content: center;
    position: absolute; left: 6px; right: 6px; bottom: 6px; z-index: 7;
    pointer-events: none;
  }
  .ymazo-designer__mobile-size-chips {
    display: flex; gap: 5px; max-width: 100%; overflow-x: auto;
    -webkit-overflow-scrolling: touch; scrollbar-width: none; padding: 2px;
    pointer-events: auto;
  }
  .ymazo-designer__mobile-size-chips::-webkit-scrollbar { display: none; }
  .ymazo-designer__mobile-size-chips .ymazo-designer__size-chip {
    flex: 0 0 auto; padding: 6px 9px; font-size: 11px; line-height: 1.1;
    background: rgba(255, 255, 255, 0.92); border-radius: 999px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
  }
  .ymazo-designer__mobile-size-chips .ymazo-designer__size-chip.is-active {
    background: #e51b4f; border-color: #e51b4f; color: #fff;
  }
  /* シャツは縮めない：チップ用の余白は確保せず、シャツ下部の空きにそのまま重ねて浮かせる */
  /* 既存の「印刷サイズ/おすすめ配置/手動で調整」バーはサイズ chips の上に積む（バー同士の重なりだけ解消） */
  .ymazo-designer__pos-info-label { bottom: 46px; }
}
/* 選択サイズ枠の外側に「ここまで印刷できる」最大範囲を薄く示す */
.ymazo-designer__position-maxhint {
  position: absolute; z-index: 5; pointer-events: none;
  border: 1px dashed rgba(229, 27, 79, 0.25); border-radius: 8px;
}
