h1 { text-align: center; font-size: 22px; margin-bottom: 12px; }
.header-row { font-weight: bold; border-bottom: 1px solid #ddd; padding-bottom: 4px; margin-bottom: 4px; }

    body { font-family: Arial, sans-serif; }
    #controls { margin-bottom: 10px; }
    #controls > div { margin-bottom: 10px; }
    #controls input[type="number"] {  width: 55px; }
    #controls input[type="text"] {  width: 55px; }

    #controls > label { 
        display: block;  
        margin-bottom: 4px; 
    }

    #controls {
        background: #f7f7f7;
        border: 1px solid #ddd;
        border-radius: 6px;
        padding: 10px 12px;
    }

    .col-name   { width: 162px; }
    .col-warp   { width: 76px; }
    .col-weft   { width: 60px; }

    label { margin-right: 10px; }

    .hide-weft .col-weft,
    .hide-weft .weft {         display: none;    }
    
    .preview { display: inline-block;  }

    .preview-buttons {
        margin-top: 10px;            /* расстояние от картинки до ряда кнопок */
        display: flex;
        justify-content: space-between; /* левая и правая */
    }

    .preview-buttons button {
        height: 32px;
        padding: 0 10px;
    }

    .layout {
        display: flex;
        align-items: flex-start;
        gap: 20px;
    }

    .preview {  flex-shrink: 0; /* чтобы canvas не сжимался */  }

    .row {
        display: flex;
        align-items: center;
        gap: 8px;
    }

    .row input[type="color"] { width: 60px; padding: 0; }

    .row input[type="text"] { width: 68px !important; padding: 2px 4px; box-sizing: border-box; }


.color-block {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 4px 0;
}

/* Кнопка + слева */
.toggle-color {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1px solid #ccc;
  background: #f7f7f7;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Основная строка с полями */
.color-block .row {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Если строка не open, показываем только кнопку + */
.color-block:not(.open) .row {
  display: none;
}

/* Полностью скрытая пустая строка */
.color-block.hidden {
  display: none;
}

/* «Следующая» строка: только кнопка +, без полей */
.color-block.next-only .row {
  display: none;
}


@media (max-width: 700px) {
  .layout {
    flex-direction: column;      /* вместо двух столбцов — одна колонка */
    align-items: stretch;
  }

  .preview {    align-self: center;          /* картинка по центру */ }

  h1 {     font-size: 18px;    text-align: center;  }

  #controls input[type="number"],
  #controls input[type="color"],
  #controls input[type="text"],
  #controls input[type="checkbox"],
  .preview-buttons button {    min-height: 36px;  }

  #controls {     font-size: 14px;  }

  #plaid {
    width: 280px;   /* видимая ширина на экране */
    height: auto;  /* высота подстраивается, пропорции как у canvas 320×400 */
  }
}