/* -------- Selection square: show on hover / when selected -------- */
.select-check {
  position: absolute;
  left: 10px;
  top: 10px;
  z-index: 3;
  display: none;
  width: 26px;
  height: 26px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.2);
  align-items: center;
  justify-content: center;
}
.gallery-item:hover .select-check {
  display: flex;
}
.gallery-item.is-selected .select-check {
  display: flex;
  background: rgba(0, 149, 255, 0.8);
  border-color: #fff;
}
.select-check input {
  width: 18px;
  height: 18px;
}

/* Highlight selected tile */
.gallery-item.is-selected {
  outline: 2px solid rgba(0, 149, 255, 0.6);
  box-shadow: 0 12px 24px rgba(0, 149, 255, 0.15);
}

/* -------- Floating selection bar -------- */
.selection-bar {
  position: sticky; /* sits under the toolbar and scrolls away; change to fixed if you prefer */
  top: 10px;
  z-index: 15;
  backdrop-filter: blur(6px);
  background: rgba(20, 20, 26, 0.75);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  margin: 10px 0 6px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.selection-bar #selectionCount {
  font-weight: 600;
  color: #cfd7ff;
}
.selection-bar .selection-actions {
  margin-left: auto;
  display: flex;
  gap: 8px;
}

/* -------- Viewer select control -------- */
.viewer-select {
  position: absolute;
  left: 10px;
  top: 10px;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #222;
  color: #fff;
  font-weight: 700;
  display: grid;
  place-items: center;
  cursor: pointer;
  opacity: 0.9;
}
.viewer-select[aria-pressed="true"] {
  background: #0d6efd; /* brand */
  border-color: #7fb8ff;
}

/* Keep everything within the screen on mobile */
@media (max-width: 820px) {
  /* Container edge-to-edge */
  .container {
    width: 100% !important;
    padding-inline: 12px !important;
  }

  /* Force app to one column no matter what came before */
  .app {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 16px !important;
  }

  /* Remove any leftover fixed widths that cause overflow */
  .scroll-bar {
    gap: 8px !important;
    flex-wrap: nowrap;
  }
  #scaleRange,
  #zoomRange {
    width: 100% !important;
  }

  /* Inputs stretch nicely */
  .dimensions {
    display: grid !important;
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 10px !important;
  }
  .dimension-input input,
  .dimension-input .area-box {
    width: 100% !important;
    min-width: 0 !important;
  }

  /* Buttons full width, stack with nice spacing */
  .button,
  .btn {
    width: 100% !important;
    height: 46px !important;
    margin: 10px 0 0 0 !important;
    font-size: 1rem !important;
  }

  /* Canvas area should never overflow horizontally */
  .canvas-wrap {
    gap: 12px !important;
  }
  .canvas-viewport {
    width: 100% !important;
    max-width: 100% !important;
    height: clamp(260px, 50vh, 62vh) !important;
    padding: 6px !important;
    overflow: auto !important;
  }
  .canvas-viewport > #canvas {
    max-width: 100% !important;
    max-height: 100% !important;
    width: auto !important;
    height: auto !important;
    aspect-ratio: auto !important;
  }

  /* Colors section stacks and stays scrollable */
  .panel-colors {
    grid-template-columns: 1fr !important;
    gap: 16px !important;
  }
  #colors-free,
  #colors-paid {
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)) !important;
    gap: 10px !important;
    max-height: 300px !important;
    padding: 10px !important;
  }

  /* Header: keep brand readable and tools usable */
  .brand {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
  }
  .brand-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 52vw;
    font-size: clamp(1rem, 3.6vw, 1.15rem);
  }
  .nav-tools {
    margin-left: auto;
    gap: 8px;
    flex-shrink: 0;
  }
  .nav-burger {
    display: block !important;
    width: 40px;
    height: 40px;
  }
  #lang-select {
    min-width: 120px;
    padding: 6px 10px;
    font-size: 0.95rem;
  }
}

/* Even tighter on tiny phones */
@media (max-width: 480px) {
  #colors-free,
  #colors-paid {
    grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)) !important;
  }
  .brand-name {
    font-size: 0.95rem !important;
  }
}
