/* ---------- Responsive ---------- */
@media (max-width: 980px) {
  .app {
    grid-template-columns: 1fr 1fr;
    align-items: stretch;
  }
  .primary-nav {
    display: none;
  }
  .nav-burger {
    display: block;
  }
  body {
    font-size: 18px;
  }
  h2#title,
  h2 {
    font-size: 1.8rem;
  }
  .panel-colors {
    grid-template-columns: 1fr;
  }
}

/* --- Mobile patch --- */
@media (max-width: 820px) {
  /* Container should breathe edge-to-edge on phones */
  .container {
    width: 100%;
    padding-inline: 12px;
  }

  /* The main app becomes a single, orderly column */
  .app {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 16px;
  }

  /* Header row */
  .header-inner {
    height: 64px;
  }
  .primary-nav {
    display: none;
  }
  .nav-burger {
    display: block;
  }

  /* Titles a bit smaller on mobile */
  h2#title,
  h2 {
    font-size: 1.45rem;
    letter-spacing: 1px;
  }

  /* Cards look lighter and tighter */
  .card {
    padding: 14px;
    margin: 0;
  }

  /* === Controls (left column) === */
  .controls-row {
    flex-direction: column;
  }

  .upload-inline {
    flex: 0 0 auto;
    width: 100%;
  }

  .upload-inline .upload-box {
    min-height: 120px;
  }

  .scroll-bar {
    gap: 8px;
  }
  #scaleRange,
  #zoomRange {
    width: 100%;
  }

  .dimensions {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    justify-items: stretch;
  }

  .dimension-input input,
  .dimension-input .area-box {
    width: 100%;
    min-width: 80px;
    height: 38px;
    font-size: 1rem;
    text-align: center;
    border: 2px solid #007bff;
    border-radius: 6px;
    padding: 4px 6px;
    box-sizing: border-box;
  }

  /* Buttons are easy to tap */
  .button,
  .btn {
    width: 100%;
    height: 46px;
    margin: 10px 0 0 0;
    font-size: 1rem;
  }

  .dither-row {
    gap: 10px;
    margin: 14px 0 8px 0;
    flex-wrap: wrap;
  }
  .dither-row .btn {
    width: auto;
    margin: 0;
    flex: 1 1 220px;
  }

  /* Advanced options (summary) - wide hit area */
  .adv-card > summary {
    padding: 12px;
  }

  /* === Canvas / actions (right column) === */
  .canvas-wrap {
    gap: 12px;
  }
  .canvas-viewport {
    width: 100%;
    height: clamp(260px, 50vh, 62vh);
    padding: 6px;
  }
  .canvas-wrap .scroll-bar {
    width: 100%;
  }
  .canvas-viewport > #canvas {
    max-width: 100% !important;
    max-height: 100% !important;
    width: auto !important;
    height: auto !important;
  }

  /* Action buttons under the canvas */
  .actions .btn + .btn {
    margin-left: 0;
  }

  /* === Colors section (bottom) === */

  .colors-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%; /* <-- keeps the row spanning the card */
    gap: 8px;
  }
  .colors-card-head .head-left {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
  }
  .section-title {
    margin: 0;
    white-space: nowrap;
    line-height: 1.1;
  }
  #paid-total-cost {
    white-space: nowrap;
  }
  .btn-eye {
    flex: 0 0 auto;
  }

  .panel-colors {
    grid-template-columns: 1fr; /* Free / Paid stack */
    gap: 16px;
  }
  #colors-free,
  #colors-paid {
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 10px;
    max-height: 300px; /* keep list scrollable, not endless */
    padding: 10px;
  }
  .toggle-color {
    font-size: 0.95rem;
    padding: 10px 12px;
  }

  /* Footer spacing */
  .site-footer {
    margin-top: 16px;
  }
}

/* Ultra-small phones (≤ 480px) – make color chips pack tighter */
@media (max-width: 480px) {
  #colors-free,
  #colors-paid {
    grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  }
  .brand-name {
    font-size: 0.95rem;
  }
}

/* Sticky header spacing: keep content from hiding underneath */
.site-header + .container.app {
  margin-top: 14px;
}

/* Keep header items usable and brand not squashed on mobile */
@media (max-width: 820px) {
  .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 {
    width: 40px;
    height: 40px;
  }
  #lang-select {
    min-width: 120px;
    padding: 6px 10px;
    font-size: 0.95rem;
  }
}
/*Mobile patch end*/
