:root {
  --bg: #f4f1eb;
  --ink: #1d2528;
  --muted: #627077;
  --line: #c7c0b7;
  --shelf: #74777f;
  --peg: #e7dccb;
  --dap: #f7f9fb;
  --dap-edge: #164c63;
  --selected: #f6c343;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Aptos, Segoe UI, Arial, sans-serif;
}

button,
input,
select {
  font: inherit;
}

.app-header {
  display: grid;
  grid-template-columns: minmax(210px, 260px) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
  padding: 10px 14px;
  background: #263234;
  color: #fff;
  border-bottom: 3px solid #d3a53b;
}

.brand-block {
  min-width: 0;
  padding-top: 4px;
}

.app-header h1 {
  margin: 0;
  font-size: 18px;
  line-height: 1.15;
  letter-spacing: 0;
}

.app-header p {
  margin: 4px 0 0;
  color: #d9e1e2;
  font-size: 11px;
  line-height: 1.3;
}

.toolbar {
  display: flex;
  align-items: stretch;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.workspace-topbar,
.segmented {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.toolbar-section {
  display: grid;
  align-content: start;
  gap: 5px;
  padding: 6px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.07);
}

.toolbar-section-title {
  color: #d9e1e2;
  font-size: 10px;
  line-height: 1;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.toolbar-row {
  display: flex;
  align-items: end;
  gap: 5px;
  flex-wrap: wrap;
}

.project-section {
  flex: 1 1 430px;
}

.crop-section {
  opacity: 0.9;
}

.toolbar button,
.workspace-topbar button {
  border: 1px solid #728184;
  background: #fff;
  color: #182326;
  min-height: 30px;
  padding: 5px 8px;
  border-radius: 5px;
  cursor: pointer;
  font-size: 13px;
  line-height: 1.15;
  white-space: nowrap;
}

.toolbar .primary-action {
  border-color: #d3a53b;
  background: #f6c343;
  color: #172124;
  font-weight: 700;
}

.toolbar .danger-action {
  border-color: #99524f;
  color: #7a2825;
}

.project-control {
  display: grid;
  gap: 2px;
  font-size: 10px;
  line-height: 1.1;
  color: #d9e1e2;
}

.project-control span {
  font-weight: 700;
}

.project-control select {
  min-width: 158px;
  height: 30px;
  border: 1px solid #728184;
  border-radius: 5px;
  padding: 3px 28px 3px 8px;
  background: #fff;
  color: #182326;
  font-size: 13px;
}

.toolbar button:hover,
.workspace-topbar button:hover,
.toolbar button:focus,
.workspace-topbar button:focus {
  outline: 2px solid #f6c343;
  outline-offset: 1px;
}

.toolbar button.active {
  background: #f6c343;
  border-color: #f6c343;
  color: #172124;
  font-weight: 700;
}
.segmented {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.toolbar button,
.workspace-topbar button {
  border: 1px solid #728184;
  background: #fff;
  color: #182326;
  min-height: 32px;
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
}

.project-control {
  display: grid;
  gap: 2px;
  font-size: 10px;
  line-height: 1.1;
  color: #d9e1e2;
}

.project-control select {
  min-width: 150px;
  height: 32px;
  border: 1px solid #728184;
  border-radius: 6px;
  padding: 4px 8px;
  background: #fff;
  color: #182326;
}

.toolbar button:hover,
.workspace-topbar button:hover,
.toolbar button:focus,
.workspace-topbar button:focus {
  outline: 2px solid #f6c343;
  outline-offset: 1px;
}

.toolbar button.active {
  background: #f6c343;
  border-color: #f6c343;
  color: #172124;
  font-weight: 700;
}

.segmented {
  gap: 0;
}

.segmented button {
  border-radius: 0;
}

.segmented button:first-child {
  border-radius: 6px 0 0 6px;
}

.segmented button:last-child {
  border-radius: 0 6px 6px 0;
}

.segmented .active {
  background: #24564e;
  color: #fff;
}

.main-shell {
  display: grid;
  grid-template-columns: var(--library-width, 360px) 10px minmax(520px, 1fr);
  min-height: calc(100vh - 76px);
}

.panel-resizer {
  position: relative;
  background: #d8d1c7;
  border-left: 1px solid rgba(38, 50, 52, 0.18);
  border-right: 1px solid rgba(38, 50, 52, 0.18);
  cursor: col-resize;
  touch-action: none;
  z-index: 30;
}

.panel-resizer::before {
  content: "";
  position: absolute;
  inset: 0 3px;
  border-left: 2px solid rgba(38, 50, 52, 0.28);
  border-right: 2px solid rgba(255, 255, 255, 0.55);
}

.panel-resizer:hover,
.panel-resizer:focus-visible,
body.panel-resizing .panel-resizer {
  background: #f6c343;
}

body.panel-resizing {
  cursor: col-resize;
  user-select: none;
}

body.panel-resizing iframe,
body.panel-resizing img,
body.panel-resizing .fixture {
  pointer-events: none;
}

.reference-panel {
  border-right: 1px solid var(--line);
  background: #fffaf1;
  padding: 14px;
  overflow: auto;
}

.panel-title {
  font-weight: 700;
  margin-bottom: 10px;
}

.reference-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.reference-header .panel-title {
  margin-bottom: 0;
}

.reference-header button,
.reference-preview-button {
  border: 1px solid #b8c0c3;
  background: #fff;
  color: #172124;
  border-radius: 6px;
  padding: 5px 8px;
  cursor: pointer;
}

.reference-select {
  width: 100%;
  margin: 10px 0 8px;
  border: 1px solid #b8c0c3;
  border-radius: 6px;
  min-height: 32px;
  padding: 6px 8px;
  background: #fff;
  color: var(--ink);
}

.reference-preview-button {
  display: block;
  width: 100%;
  padding: 0;
  overflow: hidden;
  text-align: left;
}

.reference-panel img {
  display: block;
  width: 100%;
  border: 1px solid var(--line);
  background: white;
}

.reference-preview-button img {
  max-height: 260px;
  object-fit: contain;
}

.reference-note {
  margin-top: 12px;
  color: #3a4549;
  line-height: 1.35;
  font-size: 13px;
}

.library-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 18px;
}

.library-header .panel-title {
  margin-bottom: 0;
}

.library-header button {
  border: 1px solid #b8c0c3;
  background: #fff;
  color: #172124;
  border-radius: 6px;
  padding: 5px 8px;
  cursor: pointer;
}

.product-search {
  width: 100%;
  margin-top: 10px;
  border: 1px solid #b8c0c3;
  border-radius: 6px;
  min-height: 32px;
  padding: 6px 8px;
}

.product-filters {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
  margin-top: 8px;
}

.product-filters label {
  display: grid;
  gap: 3px;
  min-width: 0;
  color: #526068;
  font-size: 10px;
  line-height: 1.1;
  font-weight: 700;
}

.product-filters select,
.product-filters button {
  width: 100%;
  min-width: 0;
  min-height: 30px;
  border: 1px solid #b8c0c3;
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 5px 7px;
  font-size: 12px;
}

.product-filters button {
  align-self: end;
  cursor: pointer;
  font-weight: 700;
}

.product-filters button:hover,
.product-filters button:focus {
  outline: 2px solid #f6c343;
  outline-offset: 1px;
}

.import-status {
  margin: 8px 0;
  color: #526068;
  font-size: 12px;
  line-height: 1.3;
}

.product-library {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding-bottom: 20px;
}

.product-card {
  border: 1px solid #c9d0d2;
  background: #fff;
  border-radius: 6px;
  padding: 6px;
  cursor: pointer;
  min-width: 0;
}

.product-card:hover,
.product-card:focus {
  outline: 2px solid #f6c343;
  outline-offset: 1px;
}

.product-card img {
  display: block;
  width: 100%;
  aspect-ratio: 1.15;
  object-fit: contain;
  background: #f7f7f7;
  border: 1px solid #ececec;
}

.product-name {
  margin-top: 5px;
  font-size: 11px;
  line-height: 1.2;
  color: #283438;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.product-id {
  margin-top: 3px;
  font-size: 9px;
  color: #7b858a;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.product-meta {
  margin-top: 4px;
  font-size: 10px;
  line-height: 1.2;
  color: #56646a;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.header-library-title {
  margin-top: 14px;
}

.header-library {
  display: grid;
  gap: 8px;
}

.header-card {
  display: grid;
  grid-template-columns: 82px 1fr;
  gap: 8px;
  align-items: center;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 7px;
  background: #fff;
  text-align: left;
  cursor: grab;
}

.header-card:hover,
.header-card:focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: 0 0 0 2px rgba(30, 114, 117, 0.12);
}

.header-card img {
  width: 82px;
  height: 32px;
  object-fit: contain;
  background: #eef1f1;
}

.header-name {
  font-size: 11px;
  font-weight: 700;
  color: var(--ink);
}

.header-meta {
  font-size: 10px;
  color: var(--muted);
}

.workspace-shell {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.workspace-topbar {
  min-height: 54px;
  padding: 10px 12px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}
.workspace-topbar {
  align-items: flex-start;
}

.header-tray {
  flex: 1 1 560px;
  min-width: 360px;
  display: grid;
  grid-template-columns: auto minmax(140px, 210px) minmax(220px, 1fr);
  align-items: center;
  gap: 8px;
  padding: 0 2px;
}

.header-tray-title {
  color: #435056;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.header-search {
  width: 100%;
  min-width: 0;
  height: 30px;
  border: 1px solid #b8c0c3;
  border-radius: 6px;
  padding: 4px 8px;
  color: var(--ink);
  background: #fff;
}

.header-tray .header-library {
  min-width: 0;
  display: flex;
  align-items: stretch;
  gap: 8px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 2px 2px 5px;
  scrollbar-width: thin;
}

.header-tray .header-card {
  flex: 0 0 178px;
  display: grid;
  grid-template-columns: 66px minmax(0, 1fr);
  grid-template-rows: auto auto;
  align-items: center;
  gap: 2px 7px;
  min-height: 42px;
  padding: 5px;
}

.header-tray .header-card img {
  grid-row: 1 / 3;
  width: 66px;
  height: 26px;
  object-fit: contain;
  background: transparent;
}

.header-tray .header-name,
.header-tray .header-meta {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.header-empty {
  display: flex;
  align-items: center;
  min-height: 42px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

@media (max-width: 1100px) {
  .header-tray {
    min-width: 100%;
    grid-template-columns: auto minmax(130px, 1fr);
  }

  .header-tray .header-library {
    grid-column: 1 / -1;
  }
}

.workspace-topbar label {
  display: grid;
  gap: 3px;
  font-size: 11px;
  color: var(--muted);
}

.tool-note {
  max-width: 320px;
  color: #435056;
  font-size: 12px;
  line-height: 1.25;
}

.workspace-topbar input,
.workspace-topbar select {
  height: 30px;
  min-width: 140px;
  border: 1px solid #b8c0c3;
  border-radius: 6px;
  padding: 4px 8px;
  color: var(--ink);
  background: #fff;
}

.workspace-topbar #labelInput {
  width: min(36vw, 420px);
}

.fixture-scroll {
  overflow: auto;
  padding: 18px;
  height: calc(100vh - 130px);
  cursor: grab;
}

.fixture-scroll:active,
body.planogram-panning .fixture-scroll {
  cursor: grabbing;
}

.fixture-scroll .asset,
.fixture-scroll button,
.fixture-scroll input,
.fixture-scroll select {
  cursor: auto;
}

.fixture {
  position: relative;
  width: calc(var(--source-w) * var(--zoom));
  height: calc(var(--source-h) * var(--zoom));
  background:
    radial-gradient(circle, rgba(85, 76, 67, 0.26) 1.2px, transparent 1.6px) 0 0 / 18px 18px,
    linear-gradient(180deg, transparent 0 170px, rgba(74, 78, 87, 0.38) 170px 184px, transparent 184px 356px, rgba(74, 78, 87, 0.38) 356px 370px, transparent 370px 551px, rgba(74, 78, 87, 0.38) 551px 565px, transparent 565px 762px, rgba(74, 78, 87, 0.38) 762px 776px, transparent 776px),
    var(--peg);
  border: 1px solid #9d968e;
  box-shadow: 0 14px 34px rgba(29, 37, 40, 0.18);
  --source-w: 1926px;
  --source-h: 872px;
  --zoom: 0.62;
}

.fixture.blank-bay {
  background:
    linear-gradient(90deg, rgba(36, 86, 78, 0.12) 0 1px, transparent 1px) 0 0 / calc(var(--px-per-inch) * 1px * var(--zoom)) 100%,
    linear-gradient(180deg, rgba(36, 86, 78, 0.08) 0 1px, transparent 1px) 0 0 / 100% calc(var(--px-per-inch) * 1px * var(--zoom)),
    #f1eadf;
}

.fixture.blank-bay.pegboard-only {
  background:
    radial-gradient(circle, rgba(84, 77, 70, 0.35) 1.5px, transparent 1.9px) 0 0 / 18px 18px,
    linear-gradient(90deg, rgba(36, 86, 78, 0.16) 0 1px, transparent 1px) 0 0 / calc(var(--px-per-inch) * 1px * var(--zoom)) 100%,
    #eadfce;
}

.fixture.blank-bay.hybrid-bay {
  background:
    linear-gradient(90deg, rgba(36, 86, 78, 0.12) 0 1px, transparent 1px) 0 0 / calc(var(--px-per-inch) * 1px * var(--zoom)) 100%,
    linear-gradient(180deg, rgba(36, 86, 78, 0.08) 0 1px, transparent 1px) 0 0 / 100% calc(var(--px-per-inch) * 1px * var(--zoom)),
    #f1eadf;
}

.fixture.crop-mode {
  background-image: var(--source-image);
  background-size: 100% 100%;
  background-repeat: no-repeat;
  background-color: #fff;
}

.empty-bay-prompt {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  display: none;
  z-index: 12;
  min-width: 280px;
  padding: 16px;
  border: 1px solid rgba(38, 50, 52, 0.18);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  color: #263234;
  box-shadow: 0 8px 20px rgba(29, 37, 40, 0.12);
}

.empty-bay-title {
  margin-bottom: 12px;
  font-size: 24px;
  font-weight: 800;
  line-height: 1.1;
  text-align: center;
  letter-spacing: 0;
}

.empty-bay-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.empty-bay-actions button {
  min-height: 38px;
  border: 1px solid #728184;
  border-radius: 6px;
  background: #fff;
  color: #182326;
  padding: 7px 10px;
  cursor: pointer;
  font-weight: 700;
}

.empty-bay-actions button:hover,
.empty-bay-actions button:focus {
  outline: 2px solid #f6c343;
  outline-offset: 1px;
}

.fixture.starter-prompt .empty-bay-prompt {
  display: block;
}
.header-drop-zone {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 52px;
  display: flex;
  align-items: center;
  padding-left: 12px;
  border-bottom: 1px dashed rgba(30, 114, 117, 0.42);
  background: rgba(255, 255, 255, 0.52);
  color: rgba(24, 35, 38, 0.54);
  font-size: 11px;
  font-weight: 700;
  pointer-events: none;
  z-index: 3;
}

.asset.header-instance {
  z-index: 18;
  background: transparent;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.22);
}

.asset.header-instance img {
  object-fit: contain;
}

.asset.header-instance.selected {
  z-index: 24;
}
.measurement-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
}

.hybrid-pegboard-area {
  position: absolute;
  background:
    radial-gradient(circle, rgba(84, 77, 70, 0.36) 1.5px, transparent 1.9px) 0 0 / 18px 18px,
    rgba(234, 223, 206, 0.72);
  border-bottom: 1px solid rgba(115, 102, 88, 0.55);
}

.hybrid-divider {
  position: absolute;
  height: 4px;
  background: #ffffff;
  border-top: 1px solid #778184;
  border-bottom: 1px solid #778184;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.20);
}

.hybrid-divider-label {
  font-weight: 700;
}

.upright {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 9px;
  background: linear-gradient(90deg, #f9f9f7 0 35%, #cfd4d6 35% 100%);
  border-left: 1px solid #aeb6b9;
  border-right: 1px solid #8f9a9e;
  box-shadow: 1px 0 2px rgba(0, 0, 0, 0.18);
}

.shelf-board {
  position: absolute;
  height: calc(2px * var(--zoom) * var(--px-per-inch));
  min-height: 8px;
  background: linear-gradient(#e9ecec, #9ca4a8);
  border-top: 2px solid #fff;
  border-bottom: 1px solid #667074;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.22);
}

.shelf-edge {
  position: absolute;
  height: 3px;
  background: rgba(255, 255, 255, 0.95);
  border-top: 1px solid #fff;
}

.price-rail {
  position: absolute;
  height: 12px;
  background: linear-gradient(#eef2f3, #c7cdd0);
  border-top: 1px solid #fff;
  border-bottom: 1px solid #919ca0;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.ruler-label {
  position: absolute;
  color: #182326;
  font-size: 10px;
  line-height: 1.1;
  padding: 0;
  white-space: nowrap;
  text-shadow:
    -1px -1px 0 rgba(255, 255, 255, 0.86),
    1px -1px 0 rgba(255, 255, 255, 0.86),
    -1px 1px 0 rgba(255, 255, 255, 0.86),
    1px 1px 0 rgba(255, 255, 255, 0.86);
}

.ruler-line {
  position: absolute;
  background: rgba(24, 35, 38, 0.72);
}

.ruler-line.vertical {
  top: 0;
  bottom: 0;
  width: 1px;
}

.ruler-line.horizontal {
  left: 0;
  right: 0;
  height: 1px;
}

.bay-divider {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 3px;
  background: rgba(211, 165, 59, 0.86);
}

.case-slot {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  border-left: 1px dashed rgba(19, 87, 94, 0.42);
}

.tube-reference {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  border-left: 1px dotted rgba(166, 92, 25, 0.3);
}

.shelf-guide {
  position: absolute;
  left: 0;
  right: 0;
  height: 6px;
  background: rgba(96, 99, 107, 0.72);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.7);
}

.shelf-snap-zone {
  position: absolute;
  left: 0;
  right: 0;
  height: 1px;
  border-top: 1px dotted rgba(0, 103, 125, 0.45);
}

.pegboard-note {
  position: absolute;
  right: 10px;
  top: 10px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid #b8c0c3;
  color: #263234;
  font-size: 12px;
  padding: 5px 7px;
  border-radius: 5px;
}

.items {
  position: absolute;
  inset: 0;
}

.asset {
  position: absolute;
  transform-origin: center center;
  cursor: grab;
  user-select: none;
  overflow: hidden;
  z-index: 2;
}

.asset img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}

.asset.product-instance {
  background: transparent;
  border: 0;
}

.asset.product-instance img {
  object-fit: contain;
}

.asset.competitor-space-instance {
  overflow: visible;
  background: #b9bec2;
  border: 2px solid #69737a;
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.35),
    0 1px 3px rgba(29, 37, 40, 0.18);
  cursor: move;
}

.asset.competitor-space-instance::after {
  content: "";
  position: absolute;
  left: 8px;
  top: 8px;
  width: 18px;
  height: 18px;
  border-radius: 3px;
  background:
    radial-gradient(circle, rgba(24, 35, 38, 0.55) 1.5px, transparent 1.8px) 0 0 / 6px 6px;
  opacity: 0;
  pointer-events: none;
}

.asset.competitor-space-instance.selected::after,
.asset.competitor-space-instance:hover::after {
  opacity: 0.75;
}

.competitor-space-fill {
  width: 100%;
  height: 100%;
  background: repeating-linear-gradient(
    135deg,
    rgba(255, 255, 255, 0.16) 0,
    rgba(255, 255, 255, 0.16) 8px,
    transparent 8px,
    transparent 16px
  );
  pointer-events: none;
}

.asset.competitor-space-instance .asset-label {
  inset: 7px 8px;
  color: #182326;
  text-shadow: none;
  pointer-events: none;
  user-select: none;
  cursor: move;
  white-space: nowrap;
  overflow: hidden;
  overflow-wrap: normal;
  word-break: normal;
  text-overflow: ellipsis;
}

.asset.competitor-space-instance .asset-label:not(:empty) {
  background: rgba(255, 255, 255, 0.34);
}

.crop-image {
  width: 100%;
  height: 100%;
  background-repeat: no-repeat;
  pointer-events: none;
}

.asset.selected {
  outline: 3px solid var(--selected);
  outline-offset: 2px;
  z-index: 20;
}

.crop-mode .asset {
  background: rgba(0, 255, 255, 0.08);
  border: 2px solid #00d5ff;
  overflow: visible;
}

.crop-mode .asset img,
.crop-mode .asset .crop-image,
.crop-mode .asset .asset-label {
  opacity: 0;
}

.crop-mode .asset.selected {
  background: rgba(246, 195, 67, 0.16);
  border-color: var(--selected);
}

.asset-label {
  position: absolute;
  inset: 14%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 5px;
  color: #fff;
  font-weight: 700;
  font-size: 11px;
  line-height: 1.1;
  text-align: center;
  overflow-wrap: anywhere;
  user-select: text;
  cursor: text;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.88);
}

.asset-label:not(:empty) {
  background: rgba(0, 0, 0, 0.28);
}

.asset-label:empty::before {
  content: attr(data-placeholder);
  padding: 3px 5px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.62);
  color: rgba(255, 255, 255, 0.9);
  font-size: 10px;
}

.resize-handle {
  position: absolute;
  width: 14px;
  height: 14px;
  border: 2px solid #fff;
  background: var(--selected);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
  display: none;
}

.resize-handle::before {
  content: "";
  position: absolute;
  inset: -8px;
}

.resize-handle.se { right: -7px; bottom: -7px; cursor: nwse-resize; }
.resize-handle.nw { left: -7px; top: -7px; cursor: nwse-resize; }
.resize-handle.ne { right: -7px; top: -7px; cursor: nesw-resize; }
.resize-handle.sw { left: -7px; bottom: -7px; cursor: nesw-resize; }
.resize-handle.n { left: calc(50% - 7px); top: -7px; cursor: ns-resize; }
.resize-handle.s { left: calc(50% - 7px); bottom: -7px; cursor: ns-resize; }
.resize-handle.e { right: -7px; top: calc(50% - 7px); cursor: ew-resize; }
.resize-handle.w { left: -7px; top: calc(50% - 7px); cursor: ew-resize; }

.asset.competitor-space-instance .resize-handle {
  width: 22px;
  height: 22px;
  border: 3px solid #fff;
  border-radius: 4px;
  background: #f6c343;
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.38);
}

.asset.competitor-space-instance .resize-handle.se { right: -12px; bottom: -12px; }
.asset.competitor-space-instance .resize-handle.nw { left: -12px; top: -12px; }
.asset.competitor-space-instance .resize-handle.ne { right: -12px; top: -12px; }
.asset.competitor-space-instance .resize-handle.sw { left: -12px; bottom: -12px; }
.asset.competitor-space-instance .resize-handle.n { left: calc(50% - 11px); top: -12px; }
.asset.competitor-space-instance .resize-handle.s { left: calc(50% - 11px); bottom: -12px; }
.asset.competitor-space-instance .resize-handle.e { right: -12px; top: calc(50% - 11px); }
.asset.competitor-space-instance .resize-handle.w { left: -12px; top: calc(50% - 11px); }

.selected .resize-handle {
  display: block;
}

.crop-mode .resize-handle {
  display: none;
}

.crop-handle {
  position: absolute;
  width: 12px;
  height: 12px;
  background: #fff;
  border: 2px solid #00a6c8;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
  display: none;
}

.crop-mode .selected .crop-handle {
  display: block;
}

.crop-handle.nw,
.crop-handle.se {
  cursor: nwse-resize;
}

.crop-handle.ne,
.crop-handle.sw {
  cursor: nesw-resize;
}

.crop-handle.n,
.crop-handle.s {
  cursor: ns-resize;
}

.crop-handle.e,
.crop-handle.w {
  cursor: ew-resize;
}

.crop-handle.nw { left: -7px; top: -7px; }
.crop-handle.n { left: calc(50% - 6px); top: -7px; }
.crop-handle.ne { right: -7px; top: -7px; }
.crop-handle.e { right: -7px; top: calc(50% - 6px); }
.crop-handle.se { right: -7px; bottom: -7px; }
.crop-handle.s { left: calc(50% - 6px); bottom: -7px; }
.crop-handle.sw { left: -7px; bottom: -7px; }
.crop-handle.w { left: -7px; top: calc(50% - 6px); }

.draft-crop {
  position: absolute;
  border: 2px dashed #f6c343;
  background: rgba(246, 195, 67, 0.14);
  pointer-events: none;
  z-index: 50;
}


.reference-viewer {
  position: fixed;
  inset: 0;
  display: none;
  grid-template-rows: auto minmax(0, 1fr);
  padding: 14px;
  background: rgba(24, 35, 38, 0.82);
  z-index: 2000;
}

.reference-viewer.open {
  display: grid;
}

.reference-viewer-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 12px;
  background: #fff;
  color: var(--ink);
  font-weight: 800;
  border-radius: 6px 6px 0 0;
}

.reference-viewer-bar button {
  border: 1px solid #728184;
  background: #fff;
  color: #182326;
  min-height: 32px;
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
}

.reference-viewer img {
  width: 100%;
  height: 100%;
  min-height: 0;
  object-fit: contain;
  background: #fff;
  border: 1px solid #fff;
  border-top: 0;
}
@media (max-width: 1180px) {
  .app-header {
    grid-template-columns: 1fr;
  }

  .toolbar {
    justify-content: flex-start;
  }

  .project-section {
    flex-basis: 100%;
  }
}

@media (max-width: 900px) {
  .toolbar-section {
    width: 100%;
  }

  .toolbar-row {
    align-items: stretch;
  }

  .toolbar button,
  .project-control,
  .project-control select {
    width: 100%;
  }

  .main-shell {
    grid-template-columns: 1fr;
  }

  .panel-resizer {
    display: none;
  }

  .reference-panel {
    max-height: 260px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
}
