.layout-editor-main { max-width: 1100px; }
.editor-top {
  display: flex; justify-content: space-between; gap: 12px; align-items: flex-start;
  margin-bottom: 14px;
}
.editor-top h1 { margin: 0 0 6px; }
.editor-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.editor-tips ul { margin: 8px 0 0; padding-left: 18px; color: var(--muted); font-size: 13px; line-height: 1.7; }
.editor-canvas {
  margin-top: 14px;
  position: relative;
}
.editor-subhead {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  margin: 18px 0 10px;
}
.per-row {
  display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px;
}
.per-row input {
  width: 64px; border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px;
  background: #fff; color: var(--text); font: inherit;
}

.guide-layer {
  pointer-events: none;
  position: absolute;
  left: 18px; right: 18px;
  top: 0; bottom: 18px;
  opacity: 0;
  transition: opacity .15s ease;
  z-index: 1;
}
body.show-guides .guide-layer { opacity: 1; }
.guide-v {
  position: absolute; top: 0; bottom: 0; width: 0;
  border-left: 1px dashed #8bb8de;
}
.guide-v.guide-right {
  border-left: 2px solid #3a8fd6;
}
.guide-h {
  position: absolute; left: 0; right: 0; height: 0;
  border-top: 1px dashed #8bb8de;
}

.editor-row, .editor-products {
  position: relative;
  z-index: 2;
  display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-start;
}

.edit-chip, .edit-product {
  position: relative;
  border: 1px solid #d7e6f4;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 8px 18px rgba(55,110,160,.06);
  user-select: none;
  overflow: visible;
}
.edit-chip {
  min-width: 120px; min-height: 56px;
  width: 160px; height: 72px;
  display: grid; place-items: center;
  font-family: "Outfit", "DM Sans", "PingFang SC", sans-serif;
  font-weight: 650; font-size: 16px; color: #244868;
}
.edit-chip.active {
  background: linear-gradient(180deg, #4ea0df, #3a8fd6);
  border-color: #2f7fc4; color: #fff;
}
.edit-product {
  min-width: 140px; min-height: 110px;
  width: 180px; height: 128px;
  padding: 12px 12px 18px;
  display: flex; flex-direction: column; justify-content: space-between;
}
.edit-product .name,
.edit-chip .name {
  font-weight: 650;
  outline: none;
  cursor: text;
  border-radius: 6px;
  padding: 2px 4px;
}
.edit-product .name { font-size: 14px; color: #17324d; }
.edit-chip .name {
  text-align: center; width: 78%;
  color: inherit;
}
.edit-product .name.is-editing,
.edit-chip .name.is-editing {
  background: #fff;
  color: #17324d !important;
  box-shadow: 0 0 0 2px rgba(58,143,214,.35);
}
.edit-product .meta { font-size: 12px; color: #6b849c; }
.edit-product .price { font-weight: 700; color: #2f7fc4; font-size: 18px; cursor: pointer; }

.drag-handle {
  position: absolute; left: 6px; top: 6px;
  width: 18px; height: 18px;
  border-radius: 6px;
  display: grid; place-items: center;
  font-size: 10px; letter-spacing: -1px;
  color: #8aa4bc; background: #eef5fb;
  cursor: grab; z-index: 3;
}
.edit-chip.active .drag-handle { background: rgba(255,255,255,.22); color: #fff; }
.drag-handle:active { cursor: grabbing; }

.edit-chip.dragging, .edit-product.dragging { opacity: .55; }
.edit-chip.drag-over, .edit-product.drag-over {
  outline: 2px dashed #3a8fd6; outline-offset: 2px;
}

.resize-handle {
  position: absolute; right: 2px; bottom: 2px;
  width: 16px; height: 16px; border-radius: 4px;
  background: linear-gradient(135deg, transparent 48%, #6aa8d8 48%);
  cursor: nwse-resize; z-index: 3;
}
.del-btn {
  position: absolute; top: 4px; right: 4px;
  width: 20px; height: 20px; border: none; border-radius: 6px;
  background: rgba(212,83,83,.12); color: #d45353; cursor: pointer; font-size: 12px;
  display: none; z-index: 3;
}
.edit-chip:hover .del-btn, .edit-product:hover .del-btn { display: grid; place-items: center; }

.add-tile {
  min-width: 120px; min-height: 56px;
  border: 1px dashed #9ec4e8; border-radius: 14px;
  background: #f7fbff; color: #2f7fc4;
  display: grid; place-items: center; cursor: pointer; font-weight: 650;
}
.add-tile.product {
  min-width: 140px; min-height: 110px; width: 180px; height: 128px;
}
.add-tile:hover { background: #eef6fc; }

.save-ok { color: #1f9d6a !important; }
.save-err { color: #d45353 !important; }

.card-actions {
  position: absolute;
  left: 10px;
  bottom: 8px;
  display: flex;
  gap: 6px;
  z-index: 3;
}
.btn-add-card,
.btn-clear-card {
  border: 1px solid #9ec4e8;
  background: #eef6fc;
  color: #2f7fc4;
  border-radius: 8px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
.btn-add-card:hover { background: #dff0ff; }
.btn-clear-card {
  border-color: #e8b4b4;
  background: #fff5f5;
  color: #c44;
}
.btn-clear-card:hover { background: #ffe8e8; }

.stock-modal {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(15, 35, 55, .45);
  display: grid; place-items: center; padding: 20px;
}
.stock-modal[hidden] { display: none !important; }
.stock-modal-card {
  width: min(520px, 100%);
  background: #fff;
  border-radius: 16px;
  border: 1px solid #d7e6f4;
  box-shadow: 0 20px 50px rgba(20, 60, 100, .2);
  padding: 16px;
}
.stock-modal-head {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  margin-bottom: 8px;
}
.stock-modal-card textarea {
  width: 100%; min-height: 180px; margin-top: 8px;
  border: 1px solid #d7e6f4; border-radius: 12px; padding: 12px;
  font-family: Consolas, "Courier New", monospace; font-size: 13px;
  resize: vertical;
}
.stock-modal-actions { margin-top: 12px; display: flex; justify-content: flex-end; }

.hero-editor-wrap { padding: 14px; }
.hero-editor-bar {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  margin-bottom: 12px; flex-wrap: wrap;
}
.hero-editor-actions { display: flex; gap: 8px; }
.hero-canvas {
  position: relative;
  height: 220px;
  border: 1px dashed #9ec4e8;
  border-radius: 14px;
  background:
    linear-gradient(180deg, #dceefc 0%, #eef6fc 100%);
  overflow: hidden;
}
.hero-box {
  position: absolute;
  box-sizing: border-box;
  border: 1px solid #9ec4e8;
  border-radius: 10px;
  background: rgba(255,255,255,.92);
  padding: 8px 10px 8px 22px;
  z-index: 2;
  user-select: none;
}
.hero-box .drag-handle {
  position: absolute; left: 4px; top: 6px;
  font-size: 12px; color: #6b849c; cursor: grab;
}
.hero-box .resize-handle {
  position: absolute; right: 0; bottom: 0; width: 14px; height: 14px;
  cursor: nwse-resize;
  background: linear-gradient(135deg, transparent 50%, #3a8fd6 50%);
  border-radius: 0 0 8px 0;
}
.hero-box-text {
  outline: none; min-height: 1.2em; word-break: break-word;
  color: #123454; font-size: 14px; line-height: 1.4;
}
.hero-box-nav {
  background: rgba(255,255,255,.72);
  padding: 6px 10px 6px 22px;
}
.hero-nav-preview {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  font-size: 12px; color: #3d5f7d; line-height: 1.2;
  pointer-events: none;
}
.hero-nav-preview .pill {
  background: #fff; border-radius: 8px; padding: 4px 8px;
  box-shadow: 0 2px 8px rgba(47,127,196,.12); color: #2f7fc4;
}
.hero-box-text.hero-brand {
  font-size: 18px; font-weight: 700; letter-spacing: .02em; line-height: 1.2;
}
.hero-box-text.hero-title {
  font-size: 26px; font-weight: 700; letter-spacing: -.02em; line-height: 1.15;
}
.hero-box-text.hero-desc { font-size: 14px; color: #5b7690; }
.hero-img {
  padding: 0;
  background: #fff;
  overflow: hidden;
}
.hero-img img {
  width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none;
}
.hero-img .drag-handle { z-index: 3; background: rgba(255,255,255,.85); border-radius: 4px; padding: 0 2px; }
.hero-img .hero-del {
  position: absolute; top: 4px; right: 4px; z-index: 3;
  width: 22px; height: 22px; border: 0; border-radius: 6px;
  background: rgba(200,60,60,.9); color: #fff; cursor: pointer;
}

.crop-stage {
  position: relative;
  width: 100%;
  margin-top: 10px;
  background: #1a2a3a;
  border-radius: 12px;
  overflow: hidden;
  user-select: none;
}
.crop-stage img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 420px;
}
.crop-sel {
  position: absolute;
  border: 2px solid #4ea0df;
  box-shadow: 0 0 0 9999px rgba(0,0,0,.45);
  cursor: move;
  box-sizing: border-box;
}
.crop-h {
  position: absolute; width: 12px; height: 12px;
  background: #fff; border: 2px solid #3a8fd6; border-radius: 2px;
}
.crop-h.nw { left: -6px; top: -6px; cursor: nwse-resize; }
.crop-h.ne { right: -6px; top: -6px; cursor: nesw-resize; }
.crop-h.sw { left: -6px; bottom: -6px; cursor: nesw-resize; }
.crop-h.se { right: -6px; bottom: -6px; cursor: nwse-resize; }
